本文整理汇总了PHP中generateHash函数的典型用法代码示例。如果您正苦于以下问题:PHP generateHash函数的具体用法?PHP generateHash怎么用?PHP generateHash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generateHash函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:HomerGaidarski,项目名称:Gunter-Hans-Transaction-Reports,代码行数:26,代码来源:helper.php
示例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();
}
开发者ID:iweave,项目名称:unmark,代码行数:28,代码来源:user.php
示例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);
}
}
}
}
开发者ID:hyrmedia,项目名称:modules,代码行数:28,代码来源:ldap_main.php
示例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);
}
开发者ID:skarabasakis,项目名称:alumniclub_usercake,代码行数:35,代码来源:class.newuser.php
示例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;
}
开发者ID:bendroid,项目名称:pligg-cms,代码行数:30,代码来源:login.php
示例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();
}
}
}
开发者ID:AdwayLele,项目名称:CupCake,代码行数:59,代码来源:class.newuser.php
示例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();
}
开发者ID:AdwayLele,项目名称:CupCake,代码行数:8,代码来源:class.user.php
示例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));
}
开发者ID:Jocaldwe,项目名称:OrderUp,代码行数:8,代码来源:class.user.php
示例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);
}
开发者ID:nodemodular,项目名称:digital-whispers,代码行数:8,代码来源:class_loggedinuser.php
示例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);
}
开发者ID:nekushi-cororo,项目名称:openex,代码行数:8,代码来源:class.user.php
示例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("[email protected]", "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();
}
}
}
开发者ID:khalid-ali,项目名称:DogePos,代码行数:57,代码来源:class.newuser.php
示例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();
}
开发者ID:ashwini0529,项目名称:ACM-Event,代码行数:10,代码来源:class.user.php
示例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);
}
开发者ID:vbraguimcanto,项目名称:UserPie,代码行数:11,代码来源:class.user.php
示例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);
}
开发者ID:davidvdtak,项目名称:AIRdb,代码行数:11,代码来源:class.user.php
示例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;
}
开发者ID:CoinDice,项目名称:CoinDice,代码行数:15,代码来源:functions.php
示例16: SignInWithCredentials
function SignInWithCredentials($mysqli)
{
$requestBody = file_get_contents('php://input');
$xml = simplexml_load_string($requestBody);
$emailAddress = escapeURLData($xml->emailAddress);
$password = escapeURLData($xml->password);
$appId = escapeURLData($_REQUEST["appId"]);
// Check for a matching guid before proceeding.
$stmt = $mysqli->prepare("SELECT guid FROM app_ids WHERE app_id = ?");
$stmt->bind_param("s", $appId);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($guid);
$stmt->fetch();
if (!$guid) {
returnErrorResponse();
exit;
}
// Get the salt value for this guid and name.
$stmt = $mysqli->prepare("SELECT salt, password FROM users WHERE guid = ? AND name = ?");
$stmt->bind_param("ss", $guid, $emailAddress);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($salt, $hashedPassword);
$stmt->fetch();
if ($stmt->num_rows == 0) {
// Invalid name so no salt.
returnErrorResponse();
exit;
}
if (generateHash($password, $salt) != $hashedPassword) {
// password does not match the hashed password.
returnErrorResponse();
exit;
} else {
// Create and insert a new authToken.
$authToken = createAuthToken($emailAddress . $appId);
$stmt = $mysqli->prepare("UPDATE users SET auth_token = ? WHERE guid = ? AND name = ? ");
$stmt->bind_param("sss", $authToken, $guid, $emailAddress);
$stmt->execute();
// Output the success xml.
header("Content-Type: application/xml");
$xml = simplexml_load_string("<result/>");
$xml->addAttribute("httpResponseCode", '200');
$xml->addChild("authToken", $authToken);
echo $xml->asXML();
}
}
开发者ID:wavetronix,项目名称:Entitlement-Admin,代码行数:48,代码来源:index.php
示例17: userPieAddUser
public function userPieAddUser()
{
global $db, $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();
if (!$this->mail_failure) {
//Insert the user into the database providing no errors have been found.
$sql = "INSERT INTO `" . $db_table_prefix . "users` (\n\t\t\t\t\t\t\t`username`,\n\t\t\t\t\t\t\t`username_clean`,\n\t\t\t\t\t\t\t`password`,\n\t\t\t\t\t\t\t`email`,\n\t\t\t\t\t\t\t`activationtoken`,\n\t\t\t\t\t\t\t`last_activation_request`,\n\t\t\t\t\t\t\t`LostpasswordRequest`, \n\t\t\t\t\t\t\t`active`,\n\t\t\t\t\t\t\t`group_id`,\n\t\t\t\t\t\t\t`sign_up_date`,\n\t\t\t\t\t\t\t`last_sign_in`\n\t\t\t\t\t\t\t)\n\t\t\t\t\t \t\tVALUES (\n\t\t\t\t\t\t\t'" . $db->sql_escape($this->unclean_username) . "',\n\t\t\t\t\t\t\t'" . $db->sql_escape($this->clean_username) . "',\n\t\t\t\t\t\t\t'" . $secure_pass . "',\n\t\t\t\t\t\t\t'" . $db->sql_escape($this->clean_email) . "',\n\t\t\t\t\t\t\t'" . $this->activation_token . "',\n\t\t\t\t\t\t\t'" . time() . "',\n\t\t\t\t\t\t\t'0',\n\t\t\t\t\t\t\t'1',\n\t\t\t\t\t\t\t'1',\n\t\t\t\t\t\t\t'" . time() . "',\n\t\t\t\t\t\t\t'0'\n\t\t\t\t\t\t\t)";
return $db->sql_query($sql);
}
}
}
开发者ID:b2simms,项目名称:Fantasy_Football_App,代码行数:16,代码来源:class.newuser.php
示例18: userIsLoggedIn
/**
* This function compares the submitted email & password to those in the user
* table for a match and starts a session with ['loggedIn'} = TRUE if found.
* @return boolean
*/
function userIsLoggedIn()
{
$salt = generateSalt($_POST['email']);
$password = generateHash($salt, $_POST['password']);
if (databaseContainsUser($_POST['email'], $password)) {
$_SESSION['loggedIn'] = TRUE;
$_SESSION['email'] = $_POST['email'];
$_SESSION['password'] = $password;
return TRUE;
} else {
unset($_SESSION['loggedIn']);
unset($_SESSION['email']);
unset($_SESSION['password']);
return FALSE;
}
}
开发者ID:lintonrentfro,项目名称:simpleconvention,代码行数:21,代码来源:access.inc.php
示例19: userCakeAddUser
public function userCakeAddUser()
{
global $db, $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);
//Do we need to send out an activation email?
if ($emailActivation) {
//Construct a unique activation token
$this->activation_token = generateActivationToken();
//User must activate their account first
$this->user_active = 0;
$mail = new userCakeMail();
//Build the activation message
$activation_message = "<p>You will need first activate your account before you can login, follow the below link to activate your account.</p>";
$activation_message .= "<p><a href='" . $websiteUrl . "activate-account.php?token=" . $this->activation_token . "'>Activate my account!</a></p>";
//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, "New User")) {
$this->mail_failure = true;
}
}
} else {
//Instant account activation
$this->user_active = 1;
}
if (!$this->mail_failure) {
//Insert the user into the database providing no errors have been found.
$sql = "INSERT INTO `" . $db_table_prefix . "Users` (`Username`, `Username_Clean`, `Password`, `Email`, `ActivationToken`, `LastActivationRequest`, `LostPasswordRequest`, `Active`, `Group_ID`, `SignUpDate`, `LastSignIn`)\r\n\t\t\t\t\t VALUES ('" . $db->sql_escape($this->unclean_username) . "', '" . $db->sql_escape($this->clean_username) . "', '" . $secure_pass . "', '" . $db->sql_escape($this->clean_email) . "','" . $this->activation_token . "','" . time() . "', 0, '" . $this->user_active . "', '1', '" . time() . "', '0')";
$db->sql_query($sql);
if ($db->sql_affectedrows() <= 0) {
$this->sql_failure = true;
} else {
$this->sql_failure = false;
}
}
}
}
开发者ID:nodemodular,项目名称:digital-whispers,代码行数:46,代码来源:class_newuser.php
示例20: store
function store()
{
global $db, $current_user;
if (!$this->date) {
$this->date = time();
}
$user_login = $db->escape($this->username);
$user_level = $this->level;
$user_karma = $this->karma;
$user_date = $this->date;
$user_pass = $db->escape($this->pass);
$user_lang = $this->lang;
$user_email = $db->escape($this->email);
$user_names = $db->escape($this->names);
$user_url = $db->escape(htmlentities($this->url));
$user_public_email = $db->escape($this->public_email);
$user_location = $db->escape($this->location);
$user_occupation = $db->escape($this->occupation);
$user_aim = $db->escape($this->aim);
$user_msn = $db->escape($this->msn);
$user_yahoo = $db->escape($this->yahoo);
$user_gtalk = $db->escape($this->gtalk);
$user_skype = $db->escape($this->skype);
$user_irc = $db->escape(htmlentities($this->irc));
$user_avatar_source = $db->escape($this->avatar_source);
if (strlen($user_pass) < 49) {
$saltedpass = generateHash($user_pass);
} else {
$saltedpass = $user_pass;
}
if ($this->id === 0) {
$this->id = $db->insert_id;
} else {
// Username is never updated
$sql = "UPDATE " . table_users . " set user_avatar_source='{$user_avatar_source}' ";
$extra_vars = $this->extra;
if (is_array($extra_vars)) {
foreach ($extra_vars as $varname => $varvalue) {
$sql .= ", " . $varname . " = '" . $varvalue . "' ";
}
}
$sql .= " , user_login='{$user_login}', user_occupation='{$user_occupation}', user_location='{$user_location}', public_email='{$user_public_email}', user_level='{$user_level}', user_karma={$user_karma}, user_date=FROM_UNIXTIME({$user_date}), user_pass='{$saltedpass}', user_lang={$user_lang}, user_email='{$user_email}', user_names='{$user_names}', user_url='{$user_url}', user_aim='{$user_aim}', user_msn='{$user_msn}', user_yahoo='{$user_yahoo}', user_gtalk='{$user_gtalk}', user_skype='{$user_skype}', user_irc='{$user_irc}' WHERE user_id={$this->id}";
//die($sql);
$db->query($sql);
}
}
开发者ID:holsinger,项目名称:openfloor,代码行数:46,代码来源:user.php
注:本文中的generateHash函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论