验证Token是否正确
@param string $name Token关键字
@param string $token 要验证的Token值
@return boolean
339582
static function validate($name,$token){
        if(isset($_SESSION['_hiano_token'][$name])){
            $ret =  $_SESSION['_hiano_token'][$name] == $token;
            unset($_SESSION['_hiano_token'][$name]);
            return $ret;
        }
        return false;
    }
350430
public function isValidToken($src, $token)
    {
        $img_token = $this->getToken($src);
        if ($img_token === null) {
            return false;
        }

        if (!hash_equals($img_token, $token)) {
            \Yii::warning("Invalid token", __METHOD__);
            return false;
        }

        return true;
    }
1242920
public function verify($token, $data=null)
    {
        $data = static::formatData($data);
        
        $key = trim($token);
        
        // if shared, use same key based data
        if ($this->options['shared']) {
            $key = md5(serialize($data));
            $data['_token_'] = $token;
        }
        
        $sdata = static::getStorage()->get($key);
        
        if (!$sdata || !isset($sdata['_expire_time_'])) {
            return ErrorInfo::error(ErrorInfo::ERR_TOKEN_INVALID, $this->getTitle() . ' 已过期，请刷新重试[0]。');
        } else {
            if (time() > $sdata['_expire_time_'] ) {
                // if auto refresh, reset old token and return new token
                if ($this->options['auto_refresh']) {
                    
                    $this->reset($token, $data);
                    
                    $newtoken = static::get($data);
                    return ErrorInfo::success(['token'=>$newtoken, 'refresh_token'=>$token]);
                }
                
                return ErrorInfo::error(ErrorInfo::ERR_TOKEN_EXPIRED, $this->getTitle() . ' 已过期，请刷新重试[1]。');
            }
            
            if ($data) {
                foreach ($data as $k => $v) {
                    if (!isset($sdata[$k]) || $v != $sdata[$k]) {
                        $msg = sprintf($this->getTitle() . ' 不正确[%s]', $k);
                        return ErrorInfo::error(ErrorInfo::ERR_TOKEN_DATA, $msg);
                        break;
                    }
                }
            }
        }
        
        return ErrorInfo::success($this->options['name'] . ' 正确');
    }
1360333
public function checkToken($token, $once = true)
    {
        $check = $this->token() === $token;

        if ($once) {
            $this->delete('__token');
        }

        return $check;
    }
642757
public function validateForgotPasswordToken($username, $token)
    {
        $this->username = $username;

        if ($this->getMeta()->forgotPasswordToken == $token) {
            $this->getMeta()->forgotPasswordToken = '';
            $this->getMeta()->save();

            return true;
        }

        return false;
    }
431122
protected function validateToken($name, $value)
    {
        $token = $this->getFromStorage($name);
        if (function_exists('hash_equals')) {
            $result = ($token !== false && hash_equals($token, $value));
        } else {
            $result = ($token !== false && $token === $value);
        }
        $this->removeFromStorage($name);

        return $result;
    }
608011
public static function remove($name)
	{
		$names = parseCfgName($name);
		if (isset($names[1]))
		{
			// 删除数据
			$first = array_shift($names);
			$obj = self::getInstance($first);
			return $obj->remove($name);
		}
		else
		{
			// 删除配置分组
			unset(self::$instances['Config'][$name]);
			return true;
		}
	}
1295136
public function createGroup($name){
        if (!$this->access_token && !$this->checkAuth()) return false;
        $data = array(
                'group'=>array('name'=>$name)
        );
        $result = $this->http_post(self::API_URL_PREFIX.self::GROUP_CREATE_URL.'access_token='.$this->access_token,self::json_encode($data));
        if ($result)
        {
            $json = json_decode($result,true);
            if (!$json || !empty($json['errcode'])) {
                $this->errCode = $json['errcode'];
                $this->errMsg = $json['errmsg'];
                return false;
            }
            return $json;
        }
        return false;
    }
1123612
protected function getItemName($token)
    {
        $name = $this->prefixKey($token);

        if ($this->isItemNameValid($name)) {
            return $name;
        }

        return false;
    }
964063
public function loginViaToken($token)
    {
        $user = $this->userDao->getUserByToken($token);
        if ($user) {
            $this->loginWithoutPassword($user->getLogin());
            return true;
        } else {
            return false;
        }
    }
54657
public function verify($token = null)
    {
        $token = isset($token)
            ? $token
            : input()->postGet('csrf-token');

        if (is_string($token)) {
            return hash_equals($this->getToken(), $token);
        }

        return false;
    }
400585
public static function validate($token)
    {
        if ($token === null) {
            return false;
        }

        if (gettype($token) == 'string' && trim($token) == '') {
            // False if String Empty
            return false;
        }

        if (strlen($token) < 20) return false;
        if (strlen($token) > 50) return false;

        // Type 0: c0afcccdde5081d6429de37d16166ead
        $type0RegExpression = '/(^[a-z0-9]+$)/i';

        // Type 1: de305d54-75b4-431b-adb2-eb6b9e546014
        // UUID strict: http://en.wikipedia.org/wiki/Universally_unique_identifier#Definition
        $type1RegExpression = '/(^[a-f0-9]{8}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{12}$)/i';

        if (preg_match($type0RegExpression, $token) == false
            && preg_match($type1RegExpression, $token) == false
        ) {
            return false;
        }

        return true;
    }
1328480
private function isIgnoredTag(?string $name): bool
    {
        foreach (self::$ignoreTags as $tag) {
            if (strcasecmp($tag, $name) === 0) {
                return true;
            }
        }

        return false;
    }
1219794
public function lastIndexByName($name) {
        for ($i = count($this->tokens) - 1; $i >= 0; $i--) {
            if ($this->tokens[$i]->getName() === $name) {
                return $i;
            }
        }

        return null;
    }
875866
private function match($token)
    {
        if ( ! $this->lexer->isNextToken($token) ) {
            $this->syntaxError($this->lexer->getLiteral($token));
        }

        return $this->lexer->moveNext();
    }
97049
protected function isEntityNameValid($name)
    {
        if (is_string($name) === false) {
            return false;
        }

        $match = preg_match(self::PATTERN_VALIDATE_NAME, $name);
        if ($name === '' || $match === false || $match <= 0 || ReservedKeywords::isReservedKeyword($name) !== false) {
            return false;
        } else {
            return true;
        }
    }
205863
public function validateOneTimeToken(string $token): bool
	{
		if(!empty($this->sessionData['mako.tokens']))
		{
			foreach($this->sessionData['mako.tokens'] as $key => $value)
			{
				if(hash_equals($value, $token))
				{
					unset($this->sessionData['mako.tokens'][$key]);

					return true;
				}
			}
		}

		return false;
	}