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


PHP XenForo_Application::hashEquals方法代碼示例

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


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

示例1: verifyFromInput

 public function verifyFromInput($context, XenForo_Input $input, array $user, array &$providerData)
 {
     $code = $input->filterSingle('code', XenForo_Input::STRING);
     $code = preg_replace('/[^0-9]/', '', $code);
     if (!$code) {
         return false;
     }
     $matched = null;
     foreach ($providerData['codes'] as $i => $expectedCode) {
         if (XenForo_Application::hashEquals($expectedCode, $code)) {
             $matched = $i;
             break;
         }
     }
     if ($matched === null) {
         return false;
     }
     $providerData['used'][] = $providerData['codes'][$matched];
     unset($providerData['codes'][$matched]);
     if (!$providerData['codes']) {
         // regenerate automatically
         $regenerated = true;
         $this->generateInitialData($user, array());
     } else {
         $regenerated = false;
     }
     $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
     $mail = XenForo_Mail::create('two_step_login_backup', array('user' => $user, 'ip' => $ip, 'regenerated' => $regenerated), $user['language_id']);
     $mail->send($user['email'], $user['username']);
     return true;
 }
開發者ID:VoDongMy,項目名稱:xenforo-laravel5.1,代碼行數:31,代碼來源:Backup.php

示例2: validateUserConfirmationRecord

 /**
  * Validates a user confirmation record against a specific key.
  *
  * @param string $key
  * @param array $confirmation Confirmation record from DB.
  *
  * @return boolean
  */
 public function validateUserConfirmationRecord($key, array $confirmation)
 {
     if (!XenForo_Application::hashEquals($confirmation['confirmation_key'], $key)) {
         return false;
     }
     if ($confirmation['confirmation_date'] < XenForo_Application::$time - 3 * 86400) {
         return false;
     }
     if ($confirmation['confirmation_type'] == 'password' && $confirmation['confirmation_date'] < XenForo_Application::$time - 12 * 3600) {
         return false;
     }
     return true;
 }
開發者ID:darkearl,項目名稱:projectT122015,代碼行數:21,代碼來源:UserConfirmation.php

示例3: verifyFromInput

 public function verifyFromInput($context, XenForo_Input $input, array $user, array &$providerData)
 {
     if (empty($providerData['code']) || empty($providerData['codeGenerated'])) {
         return false;
     }
     if (time() - $providerData['codeGenerated'] > 900) {
         return false;
     }
     $code = $input->filterSingle('code', XenForo_Input::STRING);
     $code = preg_replace('/[^0-9]/', '', $code);
     if (!XenForo_Application::hashEquals($providerData['code'], $code)) {
         return false;
     }
     unset($providerData['code']);
     unset($providerData['codeGenerated']);
     return true;
 }
開發者ID:VoDongMy,項目名稱:xenforo-laravel5.1,代碼行數:17,代碼來源:Email.php

示例4: loginUserByRememberKeyFromCookie

 /**
  * Logs a user in based on their remember key from a cookie.
  *
  * @param integer $userId
  * @param string $rememberKey
  * @param array|false|null $auth User's auth record (retrieved if null)
  *
  * @return boolean
  */
 public function loginUserByRememberKeyFromCookie($userId, $rememberKey, $auth = null)
 {
     if ($auth === null) {
         $auth = $this->getUserAuthenticationRecordByUserId($userId);
     }
     if (!$auth) {
         return false;
     }
     $known = $this->prepareRememberKeyForCookie($auth['remember_key']);
     if (!$known || !$rememberKey) {
         return false;
     }
     return XenForo_Application::hashEquals($known, $rememberKey);
 }
開發者ID:darkearl,項目名稱:projectT122015,代碼行數:23,代碼來源:User.php

示例5: verifyCode

 /**
  * Check if the code is correct. This will accept codes starting from $discrepancy*30sec ago to $discrepancy*30sec from now
  *
  * @param string $secret
  * @param string $code
  * @param int $discrepancy This is the allowed time drift in 30 second units (8 means 4 minutes before or after)
  * @param int|null $currentTimeSlice time slice if we want use other that time()
  * @return bool
  */
 public function verifyCode($secret, $code, $discrepancy = 1, $currentTimeSlice = null)
 {
     if ($currentTimeSlice === null) {
         $currentTimeSlice = floor(time() / 30);
     }
     for ($i = -$discrepancy; $i <= $discrepancy; $i++) {
         $calculatedCode = $this->getCode($secret, $currentTimeSlice + $i);
         if (XenForo_Application::hashEquals($calculatedCode, $code)) {
             return true;
         }
     }
     return false;
 }
開發者ID:VoDongMy,項目名稱:xenforo-laravel5.1,代碼行數:22,代碼來源:GoogleAuthenticator.php


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