$id = preg_replace('/[^0-9 ]/i', '', $user_profile['id']); if (isset($_GET['unlink']) && iMEMBER) { dbquery("UPDATE " . DB_USERS . " SET user_oauth_uid='0' WHERE user_oauth_uid='" . $id . "'"); redirect(BASEDIR . $settings['opening_page']); } if ($id == 0) { $loginUrl = $facebook->getLoginUrl() . "&scope={$scope}"; redirect($loginUrl); die("Failed to retreive Facebook ID"); } if ($user_profile['username']) { $user1 = $user_profile['username']; } else { $user1 = ""; $user_profile['username'] = ""; } if ($user_profile['email']) { $email1 = $user_profile['email']; } else { $email1 = ""; $user_profile['email'] = ""; } if (iGUEST) { $result = dbquery("SELECT user_id, user_salt, user_algo, user_oauth_uid FROM " . DB_USERS . " WHERE user_oauth_uid='" . $id . "' AND user_status='0' AND user_actiontime='0' LIMIT 1"); if (dbrows($result) == 1) { $user = dbarray($result); Authenticate::setUserCookie($user['user_id'], $user['user_salt'], "sha256", $remember, true); redirect(BASEDIR . $settings['opening_page']); } else { $action_url = FUSION_SELF . (FUSION_QUERY ? "?" . FUSION_QUERY : ""); if (isset($_GET['redirect']) && strstr($_GET['redirect'], "/")) { $action_url = cleanurl(urldecode($_GET['redirect'])); } echo "
{$locale['new-account']} | \n"; echo "{$locale['existing-account']} | \n"; echo "
\n";
$e = array();
if (isset($_POST['register'])) {
$username = stripinput(trim(preg_replace("/ +/i", " ", $_POST['user_name'])));
$email = stripinput(trim(preg_replace("/ +/i", "", $_POST['user_email'])));
$password1 = stripinput(trim(preg_replace("/ +/i", "", $_POST['password'])));
$salt = sha1($password1, substr($password1, 12));
$password = hash_hmac('sha256', $password1, $salt);
if ($username == "" || $password1 == "" || $email == "" || $id == "") {
$e[] = $locale['e-1'];
}
if (!preg_match("/^[-0-9A-Z_@\s]+$/i", $username)) {
$e[] = $locale['e-2'];
}
if (!preg_match("/^[-0-9A-Z_\.]{1,50}@([-0-9A-Z_\.]+\.){1,50}([0-9A-Z]){2,4}$/i",
$email)) {
$e[] = $locale['e-3'];
}
if (dbcount("(user_id)", DB_USERS, "user_name='$username'") >= 1) {
$e[] = $locale['e-4'];
}
if (dbcount("(user_id)", DB_USERS, "user_email='$email'") >= 1) {
$e[] = $locale['e-5'];
}
if (dbcount("(user_id)", DB_USERS, "user_oauth_uid='$id'") >= 1) {
$e[] = $locale['e-6'];
}
if (empty($e)) {
$time = time();
$result = dbquery("INSERT INTO " . DB_USERS .
" (user_name, user_algo, user_salt, user_password, user_email, user_joined, user_oauth_uid) VALUES('$username', 'sha256', '$salt', '$password', '$email', '$time', '$id')");
if (!$result) {
echo $locale['reg-fail'];
$e2 = true;
} else {
echo " {$locale['reg-suc']} "; Authenticate::setUserCookie(mysql_insert_id(), $salt, "sha256", $remember, true); echo " | \n";
echo "\n";
echo " {$locale['reg-leave']} "; echo " | ";
echo "
'.htmlspecialchars(print_r($e, true)).''; // Shows Errors (Redirect Loop Solution) //die(); redirect($loginUrl); }