本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}