当前位置: 首页>>代码示例>>PHP>>正文


PHP Typecho_Common::hashValidate方法代码示例

本文整理汇总了PHP中Typecho_Common::hashValidate方法的典型用法代码示例。如果您正苦于以下问题:PHP Typecho_Common::hashValidate方法的具体用法?PHP Typecho_Common::hashValidate怎么用?PHP Typecho_Common::hashValidate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Typecho_Common的用法示例。


在下文中一共展示了Typecho_Common::hashValidate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: hasLogin

 public static function hasLogin()
 {
     $cookieUid = Typecho_Cookie::get('__typecho_uid');
     if (null !== $cookieUid) {
         $db = Typecho_Db::get();
         $user = $db->fetchRow($db->select()->from('table.users')->where('uid = ?', intval($cookieUid))->limit(1));
         $cookieAuthCode = Typecho_Cookie::get('__typecho_authCode');
         if ($user && Typecho_Common::hashValidate($user['authCode'], $cookieAuthCode)) {
             return true;
         }
         Typecho_Cookie::delete('__typecho_uid');
         Typecho_Cookie::delete('__typecho_authCode');
     }
     return false;
 }
开发者ID:kirainmoe,项目名称:typecho-plugin-Access,代码行数:15,代码来源:Plugin.php

示例2: __construct

 /**
  * 构造方法
  *
  * @access public
  * @var void
  */
 public function __construct($request, $response, $params = NULL)
 {
     parent::__construct($request, $response, $params);
     /* 获取插件配置 */
     $options = parent::widget('Widget_Options');
     $this->_config = $options->plugin('Remix');
     /* 初始服务标识 */
     if (isset($request->serve) && !empty($request->serve)) {
         static::$serve = $request->filter('strip_tags', 'trim', 'xss')->serve;
     } else {
         static::$serve = 'xiami';
     }
     /* 判断来路 */
     $siteParts = parse_url($options->siteUrl);
     $refParts = parse_url($request->getReferer());
     $hash = $request->getServer('HTTP_REMIX_HASH');
     if (!$request->isAjax() || $siteParts['host'] != $refParts['host'] || !Typecho_Common::hashValidate($this->_config->hash, $hash)) {
         throw new Typecho_Widget_Exception(_t('Bad Request!'), 403);
     }
 }
开发者ID:actcms,项目名称:Remix,代码行数:26,代码来源:Action.php

示例3: hasLogin

 /**
  * 判断用户是否已经登录
  *
  * @access public
  * @return boolean
  */
 public function hasLogin()
 {
     if (NULL !== $this->_hasLogin) {
         return $this->_hasLogin;
     } else {
         $cookieUid = Typecho_Cookie::get('__typecho_uid');
         if (NULL !== $cookieUid) {
             /** 验证登陆 */
             $user = $this->db->fetchRow($this->db->select()->from('table.users')->where('uid = ?', intval($cookieUid))->limit(1));
             $cookieAuthCode = Typecho_Cookie::get('__typecho_authCode');
             if ($user && Typecho_Common::hashValidate($user['authCode'], $cookieAuthCode)) {
                 $this->_user = $user;
                 return $this->_hasLogin = true;
             }
             $this->logout();
         }
         return $this->_hasLogin = false;
     }
 }
开发者ID:r0ker,项目名称:hctf2015-all-problems,代码行数:25,代码来源:User.php

示例4: doReset

 /**
  * 重置密码
  *
  * @access public
  * @return void
  */
 public function doReset()
 {
     /* 验证token */
     $token = $this->request->filter('strip_tags', 'trim', 'xss')->token;
     list($uid, $hashValidate, $timeStamp) = explode('.', base64_decode($token));
     $currentTimeStamp = $this->options->gmtTime;
     /* 检查链接时效 */
     if ($currentTimeStamp - $timeStamp > 3600) {
         // 链接失效, 返回登录页
         $this->notice->set(_t('该链接已失效, 请重新获取'), 'notice');
         $this->response->redirect($this->options->loginUrl);
     }
     $db = Typecho_Db::get();
     $user = $db->fetchRow($db->select()->from('table.users')->where('uid = ?', $uid));
     $hashString = $user['name'] . $user['mail'] . $user['password'];
     $hashValidate = Typecho_Common::hashValidate($hashString, $hashValidate);
     if (!$hashValidate) {
         // token错误, 返回登录页
         $this->notice->set(_t('该链接已失效, 请重新获取'), 'notice');
         $this->response->redirect($this->options->loginUrl);
     }
     require_once 'theme/reset.php';
     /* 重置密码 */
     if ($this->request->isPost()) {
         /* 验证表单 */
         if ($error = $this->resetForm()->validate()) {
             $this->notice->set($error, 'error');
             return false;
         }
         $hasher = new PasswordHash(8, true);
         $password = $hasher->HashPassword($this->request->password);
         $update = $db->query($db->update('table.users')->rows(array('password' => $password))->where('uid = ?', $user['uid']));
         if (!$update) {
             $this->notice->set(_t('重置密码失败'), 'error');
         }
         $this->notice->set(_t('重置密码成功'), 'success');
         $this->response->redirect($this->options->loginUrl);
     }
 }
开发者ID:TPlugin,项目名称:Passport,代码行数:45,代码来源:Widget.php

示例5: hasLogin

 /**
  * 判断用户是否已经登录
  *
  * @access public
  * @return void
  */
 public function hasLogin()
 {
     if (NULL !== $this->_hasLogin) {
         return $this->_hasLogin;
     } else {
         if (NULL !== $this->request->__typecho_uid) {
             /** 验证登陆 */
             $user = $this->db->fetchRow($this->db->select()->from('table.users')->where('uid = ?', intval($this->request->__typecho_uid))->limit(1));
             //var_dump(Typecho_Common::hashValidate($user['authCode'], $this->request->__typecho_authCode));
             //die;
             if ($user && Typecho_Common::hashValidate($user['authCode'], $this->request->__typecho_authCode)) {
                 $this->_user = $user;
                 return $this->_hasLogin = true;
             }
             $this->logout();
         }
         return $this->_hasLogin = false;
     }
 }
开发者ID:raindali,项目名称:express,代码行数:25,代码来源:User.php


注:本文中的Typecho_Common::hashValidate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。