當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PasswordHash::NewPassword方法代碼示例

本文整理匯總了PHP中PasswordHash::NewPassword方法的典型用法代碼示例。如果您正苦於以下問題:PHP PasswordHash::NewPassword方法的具體用法?PHP PasswordHash::NewPassword怎麽用?PHP PasswordHash::NewPassword使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PasswordHash的用法示例。


在下文中一共展示了PasswordHash::NewPassword方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: PasswordHash

 } else {
     // Check if the email exists in the database
     $sql = 'SELECT `user_id`,`username`,`display_name`,`email`,`last_reset`,`password` ' . 'FROM `' . TABLE_PREFIX . 'users` ' . 'WHERE `email`=\'' . $wb->add_slashes($_POST['email']) . '\'';
     if ($results = $database->query($sql)) {
         if ($results_array = $results->fetchRow()) {
             // Get the id, username, email, and last_reset from the above db query
             // Check if the password has been reset in the last 2 hours
             if (time() - (int) $results_array['last_reset'] < 2 * 3600) {
                 // Tell the user that their password cannot be reset more than once per hour
                 $errMsg = $MESSAGE['FORGOT_PASS_ALREADY_RESET'];
             } else {
                 require_once WB_PATH . '/framework/PasswordHash.php';
                 $pwh = new PasswordHash(0, true);
                 $old_pass = $results_array['password'];
                 // Generate a random password then update the database with it
                 $new_pass = $pwh->NewPassword();
                 $sql = 'UPDATE `' . TABLE_PREFIX . 'users` SET ' . '`password`=\'' . $database->escapeString($pwh->HashPassword($new_pass, true)) . '\', ' . '`last_reset`=' . time() . ' ' . 'WHERE `user_id`=' . (int) $results_array['user_id'];
                 unset($pwh);
                 // destroy $pwh-Object
                 if ($database->query($sql)) {
                     // Setup email to send
                     $mail_to = $email;
                     $mail_subject = $MESSAGE['SIGNUP2_SUBJECT_LOGIN_INFO'];
                     // Replace placeholders from language variable with values
                     $search = array('{LOGIN_DISPLAY_NAME}', '{LOGIN_WEBSITE_TITLE}', '{LOGIN_NAME}', '{LOGIN_PASSWORD}');
                     $replace = array($results_array['display_name'], WEBSITE_TITLE, $results_array['username'], $new_pass);
                     $mail_message = str_replace($search, $replace, $MESSAGE['SIGNUP2_BODY_LOGIN_FORGOT']);
                     // Try sending the email
                     if ($wb->mail(SERVER_EMAIL, $mail_to, $mail_subject, $mail_message)) {
                         $message = $MESSAGE['FORGOT_PASS_PASSWORD_RESET'];
                         $display_form = false;
開發者ID:WebsiteBaker-modules,項目名稱:WB-Portable,代碼行數:31,代碼來源:forgot_form.php


注:本文中的PasswordHash::NewPassword方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。