function get_captcha_img() { $CI =& get_instance(); $vals = array('img_path' => 'captcha/', 'img_url' => base_url('captcha') . '/', 'font_path' => 'fonts/arial.ttf', 'word' => get_random_word(5, '2345689ABCDEFGHKLMNPQRSTWXYZ'), 'img_width' => '150', 'img_height' => '50', 'expiration' => '7200'); $cap = create_captcha($vals); $data = array('captcha_time' => $cap['time'], 'ip_address' => $CI->input->ip_address(), 'word' => $cap['word']); $query = $CI->db->insert_string('captcha', $data); $CI->db->query($query); return $cap['image']; }
function reset_password($username) { $new_password = get_random_word(6, 13); if ($new_password == false) { throw new Exception('Could not generate new password.'); } $rand_number = rand(0, 999); $new_password .= $rand_number; $conn = db_connect(); $result = $conn->query("update user\n set passwd = sha1('" . $new_password . "')\n where username = '******'"); if (!$result) { throw new Exception('Could not change password.'); } else { return $new_password; } }
function reset_password($username) { // set password for username to a random value // return the new password or fasle on falure. // get random dictionary word b/w 6 and 13 chars length. $new_password = get_random_word(6, 13); if ($new_password == false) { throw new Exception('<br /><div class=\'container\'><span style=\'color:red;\'>Could not generate new password.</span></div>'); } // add a number between 0 and 999 to it // to make it a slightly better password. $rand_number = rand(0, 999); $new_password .= $rand_number; // set user's password to this in database or return false $conn = db_connect(); $result = $conn->query("update login set passwd = sha1('" . $new_password . "') where username = '******'"); if (!$result) { throw new Exception('<br /><div class=\'container\'><span style=\'color:red;\'>Could not change password.</span></div>'); } else { return $new_password; // changed successfully } }
private function initializeVisitorId() { $CI =& get_instance(); $CI->load->helper("cookie"); $id = get_cookie(VISITOR_TRACKING_COOKIE_NAME); if ($id) { $id = base64_decode($id); $id = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, TRACKING_ENCRYPTION_KEY, $id, MCRYPT_MODE_CBC, TRACKING_IV); $id = strstr($id, "_burge", TRUE); } if (!$id) { $id = $CI->input->ip_address() . "_" . time() . "_" . get_random_word(4); $id_ex = $id . "_burge"; $id_ex = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, TRACKING_ENCRYPTION_KEY, $id_ex, MCRYPT_MODE_CBC, TRACKING_IV); $id_ex = base64_encode($id_ex); set_cookie(VISITOR_TRACKING_COOKIE_NAME, $id_ex, 365 * 24 * 60 * 60, "", "/"); } $this->visitorId = $id; }
function reset_password($username) { //set password for username to a random value //return the new password or false on failure //get a random dictionary word b/w 6 and 13 chars in length $new_password = get_random_word(6, 13); if ($new_password == false) { throw new Exception('Could not generate new password.'); } //add a number between 0 and 999 to it //to make it a slightly better password $rand_number = rand(0, 999); $new_password .= $rand_number; //set user's password to this in database or return false $conn = db_connect(); $result = $conn->query("update user set password=sha1('" . $new_password . "') where username='******'"); if (!$result) { throw new Exception('Could not change password.'); //not changed } else { return $new_password; //changed successfully } }
function reset_password($username) { // get a random dictionary word b/w 6 and 13 chars in length $new_password = get_random_word(6, 13); if ($new_password == false) { echo 'Could not generate new password.'; } // add a number between 0 and 999 to it // to make it a slightly better password srand((double) microtime() * 1000000); $rand_number = rand(0, 999); $new_password .= $rand_number; // set user's password to this in database or return false $conn = connect_db(); $result = $conn->query("update user\n set passwd = sha1('{$new_password}')\n where username = '******'"); if (!$result) { echo 'Could not change password.'; } else { return $new_password; } // changed successfully }
function get_captcha($length = 0) { if (!$length) { $length = rand(4, 5); } $vals = array('word' => get_random_word($length), 'img_path' => CAPTCHA_DIR . "/", 'img_url' => CAPTCHA_URL . "/", 'font_path' => HOME_DIR . '/system/fonts/f' . rand(3, 4) . '.ttf', 'font_size' => rand(20, 25), 'img_width' => '150', 'img_height' => 50, 'expiration' => 10); $cap = create_captcha($vals); $CI =& get_instance(); $CI->session->set_flashdata("captcha", $cap['word']); return $cap['image']; }
function reset_password($username) { // get a random dictionary word b/w 6 and 13 chars in length $new_password = get_random_word(6, 13); if ($new_password == false) { return false; } // add a number between 0 and 999 to it // to make it a slightly better password srand((double) microtime() * 1000000); $rand_number = rand(0, 999); $new_password .= $rand_number; // set user's password to this in database or return false if (!($conn = db_connect())) { return false; } $result = mysql_query("update user\r\n set passwd = password('{$new_password}')\r\n where username = '******'"); if (!$result) { return false; } else { return $new_password; } // changed successfully }
function reset_password($username) { global $db; // set password for username to a random value // return the new password or false on failure // get a random new password word b/w 6 and 13 chars in length $new_password = get_random_word(6, 13); // <-------------------- Function "get_random_word is found below this current function. if ($new_password == false) { throw new Exception('Could not generate new password.'); } // add a number between 0 and 999 to it // to make it a slightly better password $rand_number = rand(0, 999); // Hash the new password, then add the 3 random number at the en of it. $hashed_reset = password_hash($new_password, PASSWORD_DEFAULT); $hashed_reset .= $rand_number; // Update the users table, and set the new password where username = variable $username. $SQL_RESET = $db->query("update users set password = '******' where username = '******' "); // If it cant change the password, throw exception error. if (!$SQL_RESET) { throw new Exception('Could not change password.'); // Not changed. } else { // Changed successfully. return $new_password; } }