本文整理汇总了PHP中generateHash函数的典型用法代码示例。如果您正苦于以下问题:PHP generateHash函数的具体用法?PHP generateHash怎么用?PHP generateHash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generateHash函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkCredentials
function checkCredentials($username, $password)
{
$link = retrieve_mysqli();
//Test to see if their credentials are valid
$queryString = 'SELECT salt, hashed_password FROM user WHERE username = ?';
if ($stmt = mysqli_prepare($link, $queryString)) {
//Get the stored salt and hash as $dbSalt and $dbHash
mysqli_stmt_bind_param($stmt, "s", $username);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $dbSalt, $dbHash);
mysqli_stmt_fetch($stmt);
mysqli_stmt_close($stmt);
// close prepared statement
mysqli_close($link);
/* close connection */
//Generate the local hash to compare against $dbHash
$localhash = generateHash($dbSalt . $password);
//Compare the local hash and the database hash to see if they're equal
if ($localhash == $dbHash) {
return true;
}
// password hashes matched, this is a valid user
}
return false;
// password hashes did not match or username didn't exist
}
示例2: updatePassword
public function updatePassword()
{
if (!isset($this->clean->password) || !isValid($this->clean->password, 'password')) {
$this->data['message'] = reset(array_values(formatErrors(602)));
} else {
// Check current password
$current_password = isset($this->clean->current_password) ? $this->clean->current_password : null;
$res = $this->user->read($this->user_id, 1, 1, 'email,password');
if (!isset($res->password)) {
$this->data['message'] = 'We could not verify your current password.';
} elseif (verifyHash($current_password, $res->password) != $res->password) {
$this->data['message'] = 'Your current password does not match what we have on record.';
} else {
$password = generateHash($this->clean->password);
$user = $this->user->update($this->user_id, array('password' => $password));
if (isset($user->password) && $user->password == $password) {
$this->data['success'] = true;
// Send email
$this->load->library('email');
$this->email->initialize();
$sent = $this->email->updatePassword($user->email);
} else {
$this->data['message'] = 'Your password could not be updated at this time. Please try again.';
}
}
}
$this->renderJSON();
}
示例3: LdapAuthenticationPlugin
function LdapAuthenticationPlugin($input)
{
include_once "ldap_settings.php";
global $LDAPSynchUser;
// Authenticate the user.
$authenticated = $this->authenticate($input["username"], $input["password"]);
if ($authenticated) {
$_SESSION["Authenticated"] = true;
if (isset($LDAPSynchUser) && $LDAPSynchUser) {
global $db;
// Check to see if the user exists in the Pligg DB
$user = $db->get_row("SELECT user_id FROM " . table_users . " WHERE user_login = '" . $input["username"] . "'");
$saltedpass = generateHash($input["password"]);
if ($user->user_id > 0) {
// User exists in system so update the Pligg DB with the latest email & password for the user
mysql_query("UPDATE " . table_users . " SET user_email = '" . $this->email . "' WHERE user_id = {$user->user_id} LIMIT 1");
mysql_query("UPDATE " . table_users . " SET user_pass = '" . $saltedpass . "' WHERE user_id = {$user->user_id} LIMIT 1");
} else {
// User doesn't exist so dump it into the Pligg DB
$username = $db->escape(trim($input["username"]));
$userip = $_SERVER['REMOTE_ADDR'];
$email = $db->escape(trim($this->email));
$strsql = "INSERT INTO " . table_users . " (user_login, user_email, user_pass, user_date, user_ip) VALUES ('{$username}', '{$email}', '{$saltedpass}', now(), '{$userip}')";
$db->query($strsql);
}
}
}
}
示例4: userCakeAddUser
public function userCakeAddUser()
{
global $db, $emailActivation, $websiteUrl, $db_table_prefix;
//Construct a secure hash for the plain text password
$secure_pass = generateHash($this->clean_password);
//Construct a unique activation token
$this->activation_token = generateActivationToken();
//Do we need to send out an activation email?
if ($emailActivation) {
//User must activate their account first
$this->user_active = 0;
$mail = new userCakeMail();
//Build the activation message
$activation_message = lang("ACTIVATION_MESSAGE", array($websiteUrl, $this->activation_token));
//Define more if you want to build larger structures
$hooks = array("searchStrs" => array("#ACTIVATION-MESSAGE", "#ACTIVATION-KEY", "#USERNAME#"), "subjectStrs" => array($activation_message, $this->activation_token, $this->unclean_username));
/* Build the template - Optional, you can just use the sendMail function
Instead to pass a message. */
if (!$mail->newTemplateMsg("new-registration.txt", $hooks)) {
$this->mail_failure = true;
} else {
//Send the mail. Specify users email here and subject.
//SendMail can have a third parementer for message if you do not wish to build a template.
if (!$mail->sendMail($this->clean_email, "Επιβεβαιώστε την εγγραφή σας στο Σύλλογο Αποφοίτων")) {
$this->mail_failure = true;
}
}
} else {
//Instant account activation
$this->user_active = 1;
}
//Insert the user into the database providing no errors have been found.
$sql = "INSERT INTO `" . $db_table_prefix . "Users` (\n\t\t\t\t`Username`,\n\t\t\t\t`Username_Clean`,\n\t\t\t\t`Password`,\n\t\t\t\t`Email`,\n\t\t\t\t`ActivationToken`,\n\t\t\t\t`LastActivationRequest`,\n\t\t\t\t`LostPasswordRequest`, \n\t\t\t\t`Active`,\n\t\t\t\t`Group_ID`,\n\t\t\t\t`SignUpDate`,\n\t\t\t\t`LastSignIn`\n\t\t\t\t)\n\t\t \t\tVALUES (\n\t\t\t\t'" . $db->sql_escape($this->unclean_username) . "',\n\t\t\t\t'" . $db->sql_escape($this->clean_username) . "',\n\t\t\t\t'" . $secure_pass . "',\n\t\t\t\t'" . $db->sql_escape($this->clean_email) . "',\n\t\t\t\t'" . $this->activation_token . "',\n\t\t\t\t'" . time() . "',\n\t\t\t\t'0',\n\t\t\t\t'" . $this->user_active . "',\n\t\t\t\t'1',\n\t\t\t\t'" . time() . "',\n\t\t\t\t'0'\n\t\t\t\t)";
return $db->sql_query($sql);
}
示例5: Authenticate
function Authenticate($username, $pass, $remember = false, $already_salted_pass = '')
{
global $db;
$dbusername = sanitize($db->escape($username), 4);
check_actions('login_start', $vars);
$user = $db->get_row("SELECT * FROM " . table_users . " WHERE user_login = '{$dbusername}' or user_email= '{$dbusername}' ");
if ($already_salted_pass == '') {
$saltedpass = generateHash($pass, substr($user->user_pass, 0, SALT_LENGTH));
} else {
$saltedpass = $already_salted_pass;
}
if ($user->user_id > 0 && $user->user_pass === $saltedpass && $user->user_lastlogin != "0000-00-00 00:00:00" && $user->user_enabled) {
$this->user_login = $user->user_login;
$this->user_id = $user->user_id;
$vars = array('user' => serialize($this), 'can_login' => true);
check_actions('login_pass_match', $vars);
if ($vars['can_login'] != true) {
return false;
}
$this->authenticated = TRUE;
$this->md5_pass = md5($user->user_pass);
$this->SetIDCookie(1, $remember);
require_once mnminclude . 'check_behind_proxy.php';
$lastip = check_ip_behind_proxy();
$sql = "UPDATE " . table_users . " SET user_lastip = '{$lastip}', user_lastlogin = now() WHERE user_id = {$user->user_id} LIMIT 1";
$db->query($sql);
return true;
}
return false;
}
示例6: userCakeAddUser
public function userCakeAddUser()
{
global $mysqli, $emailActivation, $websiteUrl, $db_table_prefix;
//Prevent this function being called if there were construction errors
if ($this->status) {
//Construct a secure hash for the plain text password
$secure_pass = generateHash($this->clean_password);
//Construct a unique activation token
$this->activation_token = generateActivationToken();
//Do we need to send out an activation email?
if ($emailActivation == "true") {
//User must activate their account first
$this->user_active = 0;
$mail = new userCakeMail();
//Build the activation message
$activation_message = lang("ACCOUNT_ACTIVATION_MESSAGE", array($websiteUrl, $this->activation_token));
//Define more if you want to build larger structures
$hooks = array("searchStrs" => array("#ACTIVATION-MESSAGE", "#ACTIVATION-KEY", "#USERNAME#"), "subjectStrs" => array($activation_message, $this->activation_token, $this->displayname));
/* Build the template - Optional, you can just use the sendMail function
Instead to pass a message. */
if (!$mail->newTemplateMsg("new-registration.txt", $hooks)) {
$this->mail_failure = true;
} else {
//Send the mail. Specify users email here and subject.
//SendMail can have a third parementer for message if you do not wish to build a template.
if (!$mail->sendMail($this->clean_email, "New User")) {
$this->mail_failure = true;
}
}
$this->success = lang("ACCOUNT_REGISTRATION_COMPLETE_TYPE2");
} else {
//Instant account activation
$this->user_active = 1;
$this->success = lang("ACCOUNT_REGISTRATION_COMPLETE_TYPE1");
}
if (!$this->mail_failure) {
//Insert the user into the database providing no errors have been found.
$user = new UcUsers();
$user->setUserName($this->username);
$user->setDisplayName($this->displayname);
$user->setPassword($secure_pass);
$user->setEmail($this->clean_email);
$user->setActivationToken($this->activation_token);
$user->setLastActivationRequest(time());
$user->setLostPasswordRequest(0);
$user->setActive($this->user_active);
$user->setTitle('New Member');
$user->setSignUpStamp(time());
$user->setLastSignInStamp(0);
$user->save();
$inserted_id = $user->getId();
//Insert default permission into matches table
$permission = new UcUserPermissionMatches();
$permission->setUserId($inserted_id);
$permission->setPermissionId(1);
$permission->save();
}
}
}
示例7: updatePassword
public function updatePassword($pass)
{
$secure_pass = generateHash($pass);
$query = UcUsersQuery::create()->findById($this->user_id);
$user = $query[0];
$user->setPassword($secure_pass);
$user->save();
}
示例8: updatePassword
public function updatePassword($pass)
{
global $pdo;
$secure_pass = generateHash($pass);
$this->hash_pw = $secure_pass;
$stmt = $pdo->prepare("UPDATE users\n\t\t\tSET\n\t\t\tpassword = :pass \n\t\t\tWHERE\n\t\t\tid = :id");
$stmt->execute(array("pass" => $secure_pass, "id" => $this->user_id));
}
示例9: updatePassword
public function updatePassword($pass)
{
global $db, $db_table_prefix;
$secure_pass = generateHash($pass);
$this->hash_pw = $secure_pass;
$sql = "UPDATE " . $db_table_prefix . "Users SET Password = '" . $db->sql_escape(sanitize($secure_pass)) . "' WHERE User_ID = '" . (int) $this->user_id . "'";
return $db->sql_query($sql);
}
示例10: updatePassword
public function updatePassword($pass)
{
global $db, $db_table_prefix;
$secure_pass = generateHash($pass);
$this->hash_pw = $secure_pass;
$sql = "UPDATE " . $db_table_prefix . "Users\r\r\n\t\t SET\r\r\n\t\t\t Password = '" . $db->sql_escape($secure_pass) . "' \r\r\n\t\t\t WHERE\r\r\n\t\t\t User_ID = '" . $db->sql_escape($this->user_id) . "'";
return $db->sql_query($sql);
}
示例11: userCakeAddUser
public function userCakeAddUser()
{
global $mysqli, $emailActivation, $websiteUrl, $db_table_prefix;
//Prevent this function being called if there were construction errors
if ($this->status) {
//Construct a secure hash for the plain text password and pin
$secure_pass = generateHash($this->clean_password);
$secure_pin = generateHash($this->clean_pin);
//Construct a unique activation token
$this->activation_token = generateActivationToken();
//Do we need to send out an activation email?
if ($emailActivation == "true") {
//User must activate their account first
$this->user_active = 0;
$mail = new userCakeMail();
//Build the activation message
$activation_message = lang("ACCOUNT_ACTIVATION_MESSAGE", array($websiteUrl, $this->activation_token));
//Define more if you want to build larger structures
$hooks = array("searchStrs" => array("#ACTIVATION-MESSAGE", "#ACTIVATION-KEY", "#USERNAME#"), "subjectStrs" => array($activation_message, $this->activation_token, $this->displayname));
/* Build the template - Optional, you can just use the sendMail function
Instead to pass a message. */
if (!$mail->newTemplateMsg("new-registration.txt", $hooks)) {
$this->mail_failure = true;
} else {
//Send the mail. Specify users email here and subject.
//SendMail can have a third parementer for message if you do not wish to build a template.
if (!$mail->sendMail($this->clean_email, "New User")) {
$this->mail_failure = true;
}
}
$this->success = lang("ACCOUNT_REGISTRATION_COMPLETE_TYPE2");
} else {
//Email the admins:
$themsg = "A new user has signed up, " . $this->clean_email . "\r\nBusiness: " . $this->displayname . "\r\nLocation: " . $this->location . "\r\nAbout: " . $this->about;
$mail = new userCakeMail();
$mail->sendMail("dogepos@gmail.com", "New User", $themsg);
//Instant account activation
$this->user_active = 1;
$this->success = lang("ACCOUNT_REGISTRATION_COMPLETE_TYPE1");
}
if (!$this->mail_failure) {
//Insert the user into the database providing no errors have been found.
$stmt = $mysqli->prepare("INSERT INTO " . $db_table_prefix . "users (\r\n\t\t\t\t\tuser_name,\r\n\t\t\t\t\tdisplay_name,\r\n\t\t\t\t\tpassword,\r\n\t\t\t\t\tpin_hash,\r\n\t\t\t\t\temail,\r\n\t\t\t\t\tactivation_token,\r\n\t\t\t\t\tlast_activation_request,\r\n\t\t\t\t\tlost_password_request, \r\n\t\t\t\t\tactive,\r\n\t\t\t\t\ttitle,\r\n\t\t\t\t\tsign_up_stamp,\r\n\t\t\t\t\tlast_sign_in_stamp\r\n\t\t\t\t\t)\r\n\t\t\t\t\tVALUES (\r\n\t\t\t\t\t?,\r\n\t\t\t\t\t?,\r\n\t\t\t\t\t?,\r\n\t\t\t\t\t?,\r\n\t\t\t\t\t?,\r\n\t\t\t\t\t?,\r\n\t\t\t\t\t'" . time() . "',\r\n\t\t\t\t\t'0',\r\n\t\t\t\t\t?,\r\n\t\t\t\t\t'New Member',\r\n\t\t\t\t\t'" . time() . "',\r\n\t\t\t\t\t'0'\r\n\t\t\t\t\t)");
$stmt->bind_param("ssssssi", $this->username, $this->displayname, $secure_pass, $secure_pin, $this->clean_email, $this->activation_token, $this->user_active);
$stmt->execute();
$inserted_id = $mysqli->insert_id;
$this->userid = $inserted_id;
$stmt->close();
add_new_address($inserted_id, 'BOTH');
//Insert default permission into matches table
$stmt = $mysqli->prepare("INSERT INTO " . $db_table_prefix . "user_permission_matches (\r\n\t\t\t\t\tuser_id,\r\n\t\t\t\t\tpermission_id\r\n\t\t\t\t\t)\r\n\t\t\t\t\tVALUES (\r\n\t\t\t\t\t?,\r\n\t\t\t\t\t'3'\r\n\t\t\t\t\t)");
$stmt->bind_param("s", $inserted_id);
$stmt->execute();
$stmt->close();
}
}
}
示例12: updatePassword
public function updatePassword($pass)
{
global $mysqli, $db_table_prefix;
$secure_pass = generateHash($pass);
$this->hash_pw = $secure_pass;
$stmt = $mysqli->prepare("UPDATE " . $db_table_prefix . "users\n\t\t\tSET\n\t\t\tpassword = ? \n\t\t\tWHERE\n\t\t\tid = ?");
$stmt->bind_param("si", $secure_pass, $this->user_id);
$stmt->execute();
$stmt->close();
}
示例13: updatepassword
public function updatepassword($pass)
{
global $db, $db_table_prefix;
$secure_pass = generateHash($pass);
$this->hash_pw = $secure_pass;
if ($this->remember_me == 1) {
updateSessionObj();
}
$sql = "UPDATE " . $db_table_prefix . "users\n\t\t SET\n\t\t\t password = '" . $db->sql_escape($secure_pass) . "' \n\t\t\t WHERE\n\t\t\t user_id = '" . $db->sql_escape($this->user_id) . "'";
return $db->sql_query($sql);
}
示例14: updatepassword
public function updatepassword($pass)
{
global $db;
$secure_pass = generateHash($pass);
$this->hash_pw = $secure_pass;
if ($this->remember_me == 1) {
updateSessionObj();
}
$sql = "UPDATE {$db->users} SET password = '" . $db->sql_escape($secure_pass) . "' WHERE user_id = '" . $db->sql_escape($this->user_id) . "'";
return $db->sql_query($sql);
}
示例15: newPlayer
function newPlayer($wallet)
{
generate_:
$hash = generateHash(32);
if (mysql_num_rows(mysql_query("SELECT `id` FROM `players` WHERE `hash`='{$hash}' LIMIT 1")) != 0) {
goto generate_;
}
$alias = 'Player_';
$alias_i = mysql_fetch_array(mysql_query("SELECT `autoalias_increment` AS `data` FROM `system` LIMIT 1"));
$alias_i = $alias_i['data'];
mysql_query("UPDATE `system` SET `autoalias_increment`=`autoalias_increment`+1 LIMIT 1");
mysql_query("INSERT INTO `players` (`hash`,`alias`,`time_last_active`,`server_seed`) VALUES ('{$hash}','" . $alias . $alias_i . "',NOW(),'" . generateServerSeed() . "')");
header('Location: ./?unique=' . $hash . '# Do Not Share This URL!');
exit;
}