签名校验

@param string $verifyCode
@return boolean
18545
public function checkSignature($verifyCode)
    {
        if (empty($verifyCode))
            throw new Exception("请设定校验签名所需的verify_code");
        
        $verifyCode = trim($verifyCode);
        $this->_verifyToken = $verifyCode;
        $signature = isset($_GET['signature']) ? trim($_GET['signature']) : '';
        $timestamp = isset($_GET['timestamp']) ? trim($_GET['timestamp']) : '';
        $nonce = isset($_GET['nonce']) ? trim($_GET['nonce']) : '';
        $tmpArr = array(
            $verifyCode,
            $timestamp,
            $nonce
        );
        sort($tmpArr, SORT_STRING); // 按照字符串来进行比较，否则在某些数字的情况下，sort的结果与微信要求不符合，官方文档中给出的签名算法有误
        $tmpStr = sha1(implode($tmpArr));
        $this->_signature = $tmpStr;
        return $tmpStr === $signature ? true : false;
    }
1025555
public function execute($code,$args=array()) {
        $this->executeTimes++;
        N('db_write',1); // 兼容代码
        $this->debug(true);
        $this->queryStr = 'execute:'.$code;
        $result   = $this->_mongo->execute($code,$args);
        $this->debug(false);
        if($result['ok']) {
            return $result['retval'];
        }else{
            E($result['errmsg']);
        }
    }
136824
public function get($code=null, $token=null)
    {
        if (!$code || !DataHelper::verify_code($code)) {
            $code = DataHelper::random(4, false);
        }
        $code = strtoupper($code);
        
        if ($token && DataHelper::is_token($token)) {
            $this->getTokenInstance()->refreshData($token, ['code' => $code]);
        } else {
            $token = $this->getTokenInstance()->get(['code' => $code]);
        }
        
        return [
            //'code'  => $code, // 不要返回，仅用于测试
            'token'     => $token,
            'base64'    => base64_encode($this->getImageHandler()->getBody($code)),
        ];
    }
766240
public static function removeVerificationGroup($code)
    {
        if (isset(self::config()->verification_groups[$code])) {
            unset(self::config()->verification_groups[$code]);
        }
    }
892254
public static function validateOldPersonCode(string $personCode): bool
    {
        $personCode = str_replace('-', '', $personCode);
        $check = '01060307091005080402';
        $checksum = 1;
        for ($i = 0; $i < 10; $i++) {
            $checksum -= (int)$personCode[$i] * (int)substr($check, $i * 2, 2);
        }

        return !((int)($checksum - floor($checksum / 11) * 11) !== (int)$personCode[10]);
    }
977352
public function remove($code)
    {
        $entityManager = $this->getEntityManager();

        $queryBuilder = $entityManager->createQueryBuilder();
        $queryBuilder
            ->delete($this->entityName(), 'p')
            ->where('p.code = :code')
            ->setParameter('code', $code);

        return $queryBuilder->getQuery()->execute();
    }
1273288
public function getOpenIdByMini($code) {
        $url = 'https://api.weixin.qq.com/sns/jscode2session?appid='.self::$config['appId'].'&secret='.self::$config['appSecret'].'&js_code='.$code.'&grant_type=authorization_code';
        $result = $this->curl($url);
        $data = $this->get($result);
        return $data ? $data['openid'] : false;
    }
490068
public static function getName($code)
    {
        if (!isset(self::$codesDescriptions[$code])) {
            throw new InvalidArgumentException("Invalid code $code specified");
        }

        return self::$codesDescriptions[$code];
    }
432075
public static function getCodeName( $typeCode )
	{
		// Maybe this should be: XmlTypeCode::$codeToTypeMap[ $typeCode ];
		$oClass = new \ReflectionClass( __CLASS__ );
		foreach ( $oClass->getConstants() as $key => $value )
		{
			if ( $value == $typeCode ) return $key;
		}

		return false;
	}
499031
public function status($code = 200)
    {
        if (!isset(self::$codes[$code])) {
            return false;
        }
        $this->header($code . ' ' . self::$codes[$code]);
        return true;
    }
1173698
public function authenticate($code)
    {
        if ( $code )
        {
            $this->client->authenticate($code);

            $access_token = $this->client->getAccessToken();

            $this->session->put('googleapi_token', $access_token);

            return true;
        }

        return false;
    }
593517
public function checkVerifyCode($phone, $code){
		$cache = Cache::get(static::CACHE_PREFIX . $phone, '');
		return $code == $cache;
	}
1143595
public function validateCode($code)
    {
        $coupon = $this->_controller->getRepository()->find(array('code' => $code));

        if ($coupon && !$coupon->expired()) {
            $discount = $coupon->discount * 100;
            $this->setMessage(AnTranslator::sprintf('COM-SUBSCRIPTIONS-VALID-COUPON', $discount));
            return true;
        } else {
            $this->setMessage(AnTranslator::_('COM-SUBSCRIPTIONS-INVALID-COUPON'));
            return false;
        }
    }
349361
protected function compare($code, $expectedCode)
    {
        return ($expectedCode !== null && is_string($expectedCode) && $this->niceize($code) == $this->niceize($expectedCode));
    }
846776
public function verify($token, $code)
    {
        $code = strtoupper($code);
        
        if (!$code || !DataHelper::verify_code($code)) {
            return ErrorInfo::error('请输入图形码');
        }
        
        return $this->getTokenInstance()->verify($token, ['code' => $code]);
    }
733133
public function validate($code): bool
    {
        $codeLength = strlen($code);

        return ctype_digit($code) && $codeLength == $this->config['total_digits'] && strlen($code) <= 6;
    }
181270
public function verify($send_to, $code)
    {
        $sdata = static::getCache()->get($send_to);
        
        if (!$sdata) {
            return ErrorInfo::error('验证码过期请重新获取');
        } elseif (!isset($sdata['code']) || $sdata['code'] != $code) {
            return ErrorInfo::error('验证码不一致');
        }
        
        return ErrorInfo::success('验证码一致');
    }