function submitUser($request, $method = 'reg') { $time = time(); global $path_site; if ($method == 'login') { // LOGIN USER $un = $request['username']; $unlower = strtolower($request['username']); $unupper = strtoupper($request['username']); $unucfirst = ucfirst($request['username']); $unucwords = ucwords($request['username']); $password = $request['password']; $query = "select id,password,email,zip from user where (username = '******' or username = '******' or username = '******' or username = '******' or username = '******') and status='active'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_row($result); if (pw_check($password, $row[1])) { // START SESSION set_session($row[0], $request['username'], stripslashes($row[2]), $row[3]); //return return TRUE; } else { return FALSE; } } else { if ($method == 'forgot') { // LOGIN USER $email = strtolower($request['user_email']); $tempPassword = uniqid(rand(0, 9999999)); $query = "update user set password='******' where email='" . $email . "' and status <> 'deleted'"; if ($result = mysql_query($query)) { // SEND EMAIL, RETURN TRUE CHANGE IN PRODUCTION - THE HTTP HOST BELOW NEEDS TO BE UPDATED $query = "select username from user where email='" . $email . "' and status <> 'deleted'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_row($result); // SEND AN EMAIL TO USER $to = stripslashes($row[0]) . '<' . $email . '>'; $from = EMAIL_FORGOT_FROM; $subject = EMAIL_FORGOT_SUBJECT; // CALL CONTENT AND REPLACE TAGS INSIDE $template = $path_site . EMAIL_FORGOT_TEMPLATE; $returnOutput = new main_output($template); // replace tags from template @$returnOutput->replace_tags(array('subject' => EMAIL_BUSINESS_REGISTER_SUBJECT, 'username' => stripslashes($row[0]), 'site_name' => SITE_NAME, 'site_title' => SITE_TITLE, 'temppassword' => $tempPassword, 'path_site' => SITE_BASEURL_SECURE)); // Call the output $body = $returnOutput->output; // CALL SEND EMAIL // send_email($to,$subject,$body,$from); send_email($email, $subject, $body); //return return TRUE; } else { //echo $query; return FALSE; } } else { if ($method == 'verify') { // LOGIN USER mysql_query("update user set status='active' where secToken='" . $request['verify'] . "'") or die(mysql_error()); $result = mysql_query("select id,username,email,zip from user where secToken='" . $request['verify'] . "'") or die(mysql_error()); $row = mysql_fetch_row($result); set_session($row[0], stripslashes($row[1]), stripslashes($row[2]), $row[3]); return TRUE; } else { if ($method == 'profile') { $userid = $_SESSION['user']['id']; $flag_nl = 0; if (isset($request['newsletter']) and ($request['newsletter'] == 'on' or $request['newsletter'] == 1)) { $flag_nl = 1; } // check if old password was selected. $query_pw = NULL; if (isset($request['user_pass2']) and !empty($request['user_pass2'])) { $query_pw = "password = '******'user_pass2']) . "', "; } $query = "\n\t\t\t\tupdate user set\n\t\t\t\t\temail = '" . addslashes(strtolower($request['user_email'])) . "',\n\t\t\t\t\tusername = '******'user_name']) . "',\n\t\t\t\t\tfirstName = '" . addslashes($request['user_fname']) . "',\n\t\t\t\t\tmi = '" . addslashes($request['user_mi']) . "',\n\t\t\t\t\tlastName = '" . addslashes($request['user_lname']) . "',\n\t\t\t\t\taddr1 = '" . addslashes($request['user_addr1']) . "',\n\t\t\t\t\taddr2 = '" . addslashes($request['user_addr2']) . "',\n\t\t\t\t\tcity = '" . addslashes($request['user_city']) . "',\n\t\t\t\t\tstate = '" . addslashes($request['user_state']) . "',\n\t\t\t\t\tzip = '" . addslashes($request['user_zc1']) . addslashes($request['user_zc2']) . "',\n\t\t\t\t\tmainPhone = '" . addslashes($request['user_phone1'] . $request['user_phone2'] . $request['user_phone3']) . "',\n\t\t\t\t\taltPhone = '" . addslashes($request['user_phone4'] . $request['user_phone5'] . $request['user_phone6']) . "',\t\t\t\t\t\n\t\t\t\t\t" . $query_pw . "\n\t\t\t\t\tflag_nl = '" . $flag_nl . "' \n\t\t\t\tWHERE id = '" . $userid . "'\n\t\t\t"; mysql_query($query) or die(mysql_error()); return TRUE; } else { if ($method == 'reg') { global $path_site; $flag_agree = 0; // get agree flag if (isset($request['agree']) and ($request['agree'] == 'on' or $request['agree'] == '1')) { $flag_agree = 1; } // INSERT VALUES /*$query = " insert into user set username = '******'user_name']). "', email = '" .addslashes(strtolower($request['user_email'])). "', password = '******'user_pass']). "', firstName = '" .addslashes($request['user_fname']). "', mi = '" .addslashes($request['user_mi']). "', lastName = '" .addslashes($request['user_lname']). "', addr1 = '" .addslashes($request['user_addr1']). "', addr2 = '" .addslashes($request['user_addr2']). "', city = '" .addslashes($request['user_city']). "', state = '" .addslashes($request['user_state']). "', zip = '" .addslashes($request['user_zc1']).addslashes($request['user_zc2']). "', mainPhone = '" .addslashes($request['user_phone1'].$request['user_phone2'].$request['user_phone3']). "', altPhone = '" .addslashes($request['user_phone4'].$request['user_phone5'].$request['user_phone6']). "', flag_nl = '" .$flag_nl. "' , flag_tosu = '" .$flag_agree. "', dateReg = '" .$time. "' ";*/ $query = "\n\t\t\t\tinsert into user set\n\t\t\t\t\tusername = '******'user_name']) . "',\n\t\t\t\t\temail = '" . addslashes(strtolower($request['user_email'])) . "',\n\t\t\t\t\tpassword = '******'user_pass']) . "',\n\t\t\t\t\tfirstName = '" . addslashes($request['user_fname']) . "',\n\t\t\t\t\tlastName = '" . addslashes($request['user_lname']) . "',\n\t\t\t\t\tflag_tosu = '" . $flag_agree . "',\n\t\t\t\t\tdateReg = '" . $time . "'\n\t\t\t"; mysql_query($query) or die(mysql_error()); $userid = mysql_insert_id(); // Add a record into pubProfile $query = "\n\t\t\t\tinsert into public_profile set\n\t\t\t\t\tname = '" . addslashes($request['user_fname']) . "',\n\t\t\t\t\tuserid='" . $userid . "'\n\t\t\t"; mysql_query($query) or die(mysql_error()); // INSERT INTO USERS PERMISSIONS $query = "\n\t\t\t\tinsert into user_groups set\n\t\t\t\t\tuserid='" . $userid . "'\n\t\t\t"; mysql_query($query) or die(mysql_error()); //INSERT SECURITY TOKEN $secToken = sha1(time() . rand(0, 9999999) . $userid); mysql_query("update user set secToken = '" . $secToken . "' where id='" . $userid . "'") or die(mysql_error()); // NEW // set_session($userid,$request['user_name'],strtolower($request['user_email'])); if (isset($_REQUEST['l']) and $_REQUEST['l'] = 'c') { $_SESSION['user']['id'] = $userid; } //send verification email. $to = $request['user_name'] . '<' . $request['user_email'] . '>'; $from = EMAIL_REGISTER_FROM; $subject = EMAIL_REGISTER_SUBJECT; // email for registration // CALL CONTENT AND REPLACE TAGS INSIDE $template = $path_site . EMAIL_REGISTER_TEMPLATE; $returnOutput = new main_output($template); // replace tags from template @$returnOutput->replace_tags(array('subject' => EMAIL_REGISTER_SUBJECT, 'username' => $request['user_name'], 'site_name' => SITE_NAME, 'site_title' => SITE_TITLE, 'verifyURL' => EMAIL_REGISTER_VERIFYLINK . $secToken)); // Call the output $body = $returnOutput->output; // CALL SEND EMAIL send_email($request['user_email'], $subject, $body); return TRUE; } } } } } }
die("NOT ALLOWED!"); } $dares = pg_safe_exec("SELECT * FROM users WHERE id='" . $user_id . "'"); $dauser = pg_fetch_object($dares, 0); header("Pragma: no-cache\n\n"); $errorz[0] = "Empty password is not permitted, try again !"; $errorz[1] = "Passwords do not match, try again !"; $errorz[2] = "Password is too weak, try again !"; $errorz[3] = "Password can't be your username, try again !"; $errorz[4] = "Password can't be your verification answer, try again !"; $errorz[5] = "Password can't be your e-mail addy, try again !"; $errorz[6] = "Your current password is invalid, try again !"; if ($mode == "write" && $crc == md5($SECURE_ID . CRC_SALT_0011)) { $da_error = -1; if ($pass1 == $pass2 && ($pass1 != "" && $pass2 != "")) { if ($admin > 0 && BOFH_PASS_ADMIN && !pw_check($pass1) || BOFH_PASS_USER && !pw_check($pass1) || strlen($pass1) < PW_MIN_CHARS) { $da_error = 2; } else { if (strtolower($dauser->user_name) == strtolower($pass1)) { $da_error = 3; } else { if (strtolower($dauser->verificationdata) == strtolower($pass1)) { $da_error = 4; } else { if (strtolower($dauser->email) == strtolower($pass1)) { $da_error = 5; } else { if (chk_password($dauser->user_name, $pass0, -1) <= 0) { $da_error = 6; // possible bruteforce attack (but rare, user must be already logged in), will add security later... } else {
return TRUE; else return FALSE; } function pw_encode($password) { for ($i = 1; $i <= 10; $i++) $seed .= substr('0123456789abcdef', rand(0,15), 1); return sha1($seed.$password.$seed).$seed; } echo('<response>'); if ($success) { $queryResults = $mysqlConnection->processQuery("SELECT password FROM user WHERE uid='".$user_id."'"); if (pw_check($_POST['oldPassword'], $queryResults[0][0])) { $newPassword = pw_encode($_POST['newPassword']); $mysqlConnection->processQuery("UPDATE user SET password = '******' WHERE uid = '".$user_id."'"); } else { $success = false; $wrongPassword = true; } } echo('<success>'.$success.'</success>'.'<wrong>'.$wrongPassword.'</wrong>'); echo('</response>'); ?>
SetCookie("rlogin", "", 0, "/", COOKIE_DOMAIN); } } else { SetCookie("auth", $username . ":" . (int) $user_id . ":" . (int) $time . ":" . $cookie . ":" . (int) $dynts . ":" . $cook2, time() + COOKIE_EXPIRE, "/"); if (REMEMBER_LOGIN || PREFILL_NOTICE) { SetCookie("rlogin", $username, 2147483645, "/"); } else { SetCookie("rlogin", "", 0, "/"); } } $admin = (int) $is_admin; //local_seclog("Login"); if ($is_admin && BOFH_PASS_ADMIN || BOFH_PASS_USER) { // check password complexity BOFH stylee (excepted for ALUMNIs) if ($is_alumni == 0) { if (!pw_check($password)) { $unsecure_pw_url = "main.php?sba=1&SECURE_ID=" . md5($user_id . CRC_SALT_0013 . $cookie); header("Location: " . $unsecure_pw_url . "\n\n"); die; } } } if ($redir) { header("Location: " . urldecode($redir)); } else { header("Location: main.php?sba=1"); //echo "$cookie"; } exit; } else { // user_id <= 0
if (!$securize_mode) { die("Wrong way !"); } $dares = pg_safe_exec("SELECT * FROM users WHERE id='" . $user_id . "'"); $dauser = pg_fetch_object($dares, 0); header("Pragma: no-cache\n\n"); $errorz[0] = "Empty password is not permitted, try again !"; $errorz[1] = "Passwords do not match, try again !"; $errorz[2] = "Password is too weak, try again !"; $errorz[3] = "Password can't be your username, try again !"; $errorz[4] = "Password can't be your verification answer, try again !"; $errorz[5] = "Password can't be your e-mail addy, try again !"; if ($mode == "write" && $crc == md5($SECURE_ID . CRC_SALT_0017)) { $da_error = -1; if ($pass1 == $pass2 && ($pass1 != "" && $pass2 != "")) { if (!pw_check($pass1)) { $da_error = 2; } else { if (strtolower($dauser->user_name) == strtolower($pass1)) { $da_error = 3; } else { if (strtolower($dauser->verificationdata) == strtolower($pass1)) { $da_error = 4; } else { if (strtolower($dauser->email) == strtolower($pass1)) { $da_error = 5; } else { // change password $valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $password = ""; srand((double) microtime() * 1000000);
/** * Validation and filtering * * @return boolean True is satisfactory */ function authenticate($username, $password) { //Checking the users email if (is_email($username)) { $this->email = $username; if (trim($this->email) == "" || !is_email($this->email)) { $this->setError("The entered Email is invalid."); return false; } // check for existing email $query = 'SELECT id, password' . ' FROM ' . $this->_tbl . ' WHERE email = ' . $this->_db->Quote($this->email) . ' AND id != ' . (int) $this->id; $this->_db->setQuery($query); if (!($result = $this->_db->loadAssoc())) { $this->setError("Sorry, the Email and Password entered did not match our records."); return false; } } else { $this->username = $username; // Validate user information if (trim($this->username) == '' && trim($this->email) == '') { $this->setError("Please enter your Username or Email address."); return false; } if (preg_match("#[<>\"'%;()&]#i", $this->username) || strlen(utf8_decode($this->username)) < 2) { $this->setError("The entered Username is invalid."); return false; } // check for existing username $query = 'SELECT id, password' . ' FROM ' . $this->_tbl . ' WHERE username = '******' AND id != ' . (int) $this->id; $this->_db->setQuery($query); if (!($result = $this->_db->loadAssoc())) { $this->setError("Sorry, the Username and Password entered did not match our records."); return false; } } //checking the users password $this->password = $password; if (!pw_check($this->password, $result['password'])) { $this->setError("Sorry, the Username and Password entered did not match our records."); return false; } $this->load($result['id']); $this->setLastVisit(); set_session($this->id, $this->username, $this->email, $this->zip); return true; }