当前位置: 首页>>代码示例>>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;未经允许,请勿转载。