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


PHP User::getUserByEmail方法代碼示例

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


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

示例1: mailCheck

 /**
  * 郵件地址檢測
  * @param $address
  * @return null|string
  */
 public static function mailCheck($address)
 {
     $pattern = "/^[A-Za-z0-9-_.+%]+@[A-Za-z0-9-.]+\\.[A-Za-z]{2,4}\$/";
     if (!preg_match($pattern, $address)) {
         return "郵箱地址格式不正確";
     }
     /*
     if (is_numeric(stristr($chkMailAddress, "qq.com")))
         return "該郵箱地址不被支持,請更換";
     */
     if (User::getUserByEmail($address) != false) {
         return "郵箱地址已經被注冊使用";
     }
     return null;
 }
開發者ID:sendya,項目名稱:shadowsocks-panel,代碼行數:20,代碼來源:Utils.php

示例2: forgePwd

 /**
  * @JSON
  * @throws \Core\Error
  */
 public function forgePwd()
 {
     $result = array('error' => 1, 'message' => '請求找回密碼失敗,請刷新頁麵重試。');
     $siteName = SITE_NAME;
     if (isset($_POST['email']) && $_POST['email'] != '') {
         $user = User::getUserByEmail(htmlspecialchars(trim($_POST['email'])));
         if (!$user) {
             return $result;
         }
         if ($user->enable == 0) {
             $verify_code = json_decode($user->forgePwdCode, true)['verification'];
             if ($verify_code != null) {
                 $result['message'] = '您的賬戶還未進行郵箱校驗,請校驗完畢後再試!';
                 return $result;
             }
         }
         $user->lastFindPasswdTime = time();
         if ($user->lastFindPasswdCount != 0 && $user->lastFindPasswdCount > 2) {
             $result['message'] = '找回密碼重試次數已達上限!';
             return $result;
         }
         $code = Utils::randomChar(10);
         $forgePwdCode['code'] = $code;
         $forgePwdCode['time'] = time();
         $user->forgePwdCode = json_encode($forgePwdCode);
         $content = Option::get('custom_mail_forgePassword_content');
         $params = ['code' => $code, 'nickname' => $user->nickname, 'email' => $user->email, 'useTraffic' => Utils::flowAutoShow($user->flow_up + $user->flow_down), 'transfer' => Utils::flowAutoShow($user->transfer), 'expireTime' => date('Y-m-d H:i:s', $user->expireTime)];
         $content = Utils::placeholderReplace($content, $params);
         $mailer = Mailer::getInstance();
         $mail = new \Model\Mail();
         $mail->to = $user->email;
         $mail->subject = "[" . SITE_NAME . "] Password Recovery";
         $mail->content = $content;
         $mailer->toQueue(true);
         // 添加到郵件列隊
         $isOk = $mailer->send($mail);
         $user->save();
         $result['uid'] = $user->uid;
         if ($isOk) {
             $result['message'] = '驗證代碼已經發送到該注冊郵件地址,請注意查收!<br/>請勿關閉本頁麵,您還需要驗證碼來驗證您的賬戶所有權才可重置密碼!!';
             $result['error'] = 0;
         } else {
             $result['message'] = '郵件發送失敗, 請聯係管理員檢查郵件係統設置!';
             $result['error'] = 1;
         }
         return $result;
     } else {
         if ($_POST['code'] != '' && $_POST['uid'] != '') {
             $uid = $_POST['uid'];
             $code = trim($_POST['code']);
             $user = User::GetUserByUserId(trim($uid));
             $forgePwdCode = json_decode($user->forgePwdCode, true);
             // forgePwdCode.length > 1 且 驗證碼一樣 且 時間不超過600秒(10分鍾)
             if (count($forgePwdCode) > 1 && $forgePwdCode['code'] == $code && time() - intval($forgePwdCode['time']) < 600) {
                 $newPassword = Utils::randomChar(10);
                 $user->setPassword($newPassword);
                 $user->lastFindPasswdCount = 0;
                 $user->lastFindPasswdTime = 0;
                 $user->save();
                 $content = Option::get('custom_mail_forgePassword_content_2');
                 $params = ['code' => $code, 'newPassword' => $newPassword, 'nickname' => $user->nickname, 'email' => $user->email, 'useTraffic' => Utils::flowAutoShow($user->flow_up + $user->flow_down), 'transfer' => Utils::flowAutoShow($user->transfer), 'expireTime' => date('Y-m-d H:i:s', $user->expireTime)];
                 $content = Utils::placeholderReplace($content, $params);
                 $mailer = Mailer::getInstance();
                 $mail = new \Model\Mail();
                 $mail->to = $user->email;
                 $mail->subject = "[" . SITE_NAME . "] Your new Password";
                 $mail->content = $content;
                 $mailer->toQueue(true);
                 // 添加到郵件列隊
                 $isOk = $mailer->send($mail);
                 if ($isOk) {
                     $result['message'] = '新密碼已經發送到該賬戶郵件地址,請注意查收!<br/> 並且請在登錄後修改密碼!';
                     $result['error'] = 0;
                 } else {
                     $result['message'] = '郵件發送失敗, 請聯係管理員檢查郵件係統設置!';
                     $result['error'] = 1;
                 }
             } else {
                 $result['message'] = '驗證碼已經超時或者 驗證碼填寫不正確。請再次確認';
                 $result['error'] = -1;
             }
             return $result;
         } else {
             Template::putContext('user', User::getCurrent());
             Template::setView('panel/forgePwd');
         }
     }
     return $result;
 }
開發者ID:sendya,項目名稱:shadowsocks-panel,代碼行數:93,代碼來源:Auth.php


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