验证验证码是否正确
@access public
@param string $code 用户验证码
@param string $id 验证码标识
@return bool 用户验证码是否正确
962937
public function check($code, $id = '') {
        $key = $this->authcode($this->seKey).$id;
        // 验证码不能为空
        $secode = session($key);
        if(empty($code) || empty($secode)) {
            return false;
        }
        // session 过期
        if(NOW_TIME - $secode['verify_time'] > $this->expire) {
            session($key, null);
            return false;
        }

        if($this->authcode(strtoupper($code)) == $secode['verify_code']) {
            $this->reset && session($key, null);
            return true;
        }

        return false;
    }
192084
public function updateCode($code, $card_id, $new_code)
    {
        if (empty($code) || empty($card_id) || $new_code) {
            return false;
        }

        $result = $this->httpPost(static::WECHAT_CARD_CODE_UPDATE_URL . 'access_token=' . $this->getAccessToken(), [
            'code' => $code,
            'card_id' => $card_id,
            'new_code' => $new_code
        ]);

        return isset($result['errmsg']) && $result['errmsg'] === 'ok' ? true : false;
    }
1126403
public static boolean check(String idCard) {
        // 验证身份证格式

        Matcher matcher = ID_CARD_PATTERN.matcher(idCard);
        if (!matcher.matches()) {
            // 格式不对
            logger.error("身份证格式不对{}", idCard);
            return false;
        }

        // 验证最后一位加权码
        byte[] idCardByte = idCard.getBytes();
        int sum = 0;
        for (int i = 0; i < 17; i++) {
            sum += (((int) idCardByte[i]) - 48) * POWER[i];
        }
        int mod = sum % 11;
        int calcLast = DIVISOR[mod];
        char last;
        if (idCardByte[17] == 'x' || idCardByte[17] == 'X') {
            last = 'X';
        } else {
            last = (char) idCardByte[17];
        }
        if (last != calcLast) {
            // 格式不对
            logger.error("加权码错误{}", idCard);
            return false;
        }
        return true;
    }
572677
public function codeMatches($price_rule_id, $code)
    {
        $sql = 'SELECT price_rule_id
                FROM price_rule
                WHERE code=? AND price_rule_id=? AND status=?';

        return (bool) $this->db->fetchColumn($sql, array($code, $price_rule_id, 1));
    }
929351
public function actionReset($id, $code)
    {
        if (!$this->enablePasswordRecovery) {
            return $this->redirect(['/user/security/login']);
        }
        /** @var Token $token */
        $token = Token::findOne(['user_id' => $id, 'code' => $code, 'type' => Token::TYPE_RECOVERY]);
        if ($token === null || $token->isExpired || $token->user === null) {
            Yii::$app->session->setFlash('danger', Yii::t('user', 'Recovery link is invalid or expired. Please try requesting a new one.'));
            return $this->render('/message', [
                'title' => Yii::t('user', 'Invalid or expired link'),
                'module' => $this->module
            ]);
        }
        /** @var RecoveryForm $model */
        $model = new RecoveryForm(['scenario' => 'reset']);
        if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
            Yii::$app->response->format = Response::FORMAT_JSON;
            return ActiveForm::validate($model);
        }
        if ($model->load(Yii::$app->getRequest()->post()) && $model->resetPassword($token)) {
            return $this->redirect(['/user/security/login']);
        }

        return $this->render('reset', ['model' => $model]);
    }
963741
public function execute($code = null) {

		if(null !== $code && false === ('-' . intval($code) == '-' . $code)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($code)), E_USER_ERROR);
		}

		$this -> setUrl();

		if(null !== $this -> seconds) {
			return Response :: addHeader('refresh', sprintf('%d;url=%s', $this -> seconds, $this -> url), $code);
		}

		Response :: addHeader('Location', $this -> url, $code);
	}
155489
public function getCode($code)
    {
        $result = $this->wechat->httpPost(self::WECHAT_DELETE_CARD_URL, [
            'code' => $code
        ], [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] === 'ok' ? $result : false;
    }
1220677
public function getInfo($id)
    {
        // 验证有效性
        if ($this->isValid($id) === false) {
            return false;
        }
        $code = $this->_checkIdArgument($id);
        $addressInfo = $this->_getAddressInfo($code['addressCode'], $code['birthdayCode']);

        return [
            'addressCode'   => $code['addressCode'],
            'abandoned'     => isset($this->_addressCodeList[$code['addressCode']]) ? 0 : 1,
            'address'       => is_array($addressInfo) ? implode($addressInfo) : '',
            'addressTree'   => array_values($addressInfo),
            'birthdayCode'  => date('Y-m-d', strtotime($code['birthdayCode'])),
            'constellation' => $this->_getConstellation($code['birthdayCode']),
            'chineseZodiac' => $this->_getChineseZodiac($code['birthdayCode']),
            'sex'           => ($code['order'] % 2 === 0 ? 0 : 1),
            'length'        => $code['type'],
            'checkBit'      => $code['checkBit'],
        ];
    }
1278734
public function isCode(int $code) : bool
    {
        return sizeof($this->codes) == 1 && $this->codes[0] == $code;
    }
290367
public function expireAuthorizationCode($code)
	{
		// auth model
		$authorizationCode = \Components\Developer\Models\Authorizationcode::oneByCode($code);

		// fetch by code
		if (!$authorizationCode->get('id'))
		{
			return false;
		}

		return $authorizationCode->destroy();
	}
946650
public static function find_by_id($id)
	{
		$hzad = self::oneOrNew($id);

		if (!$hzad->get('authenticator'))
		{
			return false;
		}

		return $hzad;
	}
1197423
public function actionConfirm($id, $code)
    {
        $user = User::findOne($id);
        if ($user === null || $this->getSetting('enableConfirmation') == false) {
            return $this->goBack();
        }
        $user->attemptConfirmation($code);
        return $this->redirect(['/user/settings/profile']);
    }
686998
public static function checkIdCard($idCard)
    {
        $cityCode = [
            '11', '12', '13', '14', '15',
            '21', '22', '23', '31', '32',
            '33', '34', '35', '36', '37',
            '41', '42', '43', '44', '45',
            '46', '50', '51', '52', '53',
            '54', '61', '62', '63', '64',
            '65', '71', '81', '82', '91',
        ];

        // 判断基本格式
        if(!preg_match('/^([\d]{17}[xX\d]|[\d]{15})$/', $idCard)){
            return false;
        }

        // 判断前两位
        if(!in_array(substr($idCard, 0, 2), $cityCode)){
            return false;
        }

        // 统一字母
        $idCard = preg_replace('/[xX]$/i', 'a', $idCard);
        $length = strlen($idCard);

        if($length == 18){
            $birthday = substr($idCard, 6, 4) . '-' . substr($idCard, 10, 2) . '-' . substr($idCard, 12, 2);
        }else{
            $birthday = '19' . substr($idCard, 6, 2) . '-' . substr($idCard, 8, 2) . '-' . substr($idCard, 10, 2);
        }

        // 判断生日
        if(date('Y-m-d', strtotime($birthday)) != $birthday){
            return false;
        }

        // 算法
        if($length == 18){
            $sum = 0;

            for($i = 17; $i >= 0; $i--){
                $tmp = substr($idCard, 17 - $i, 1);
                $sum += (pow(2, $i) % 11) * (($tmp == 'a') ? 10 : intval($tmp, 11));
            }

            if($sum % 11 != 1){
                return false;
            }
        }

        return true;
    }
546195
public function check($code, $namespace, $recipient)
    {
        $cacheKey = $this->getCacheKey($namespace, $recipient);
        /** @var ValidCode $validCode */
        $validCode = $this->cache->get($cacheKey);
        if (empty($validCode) || $validCode->isExpired() || $validCode->getCode() != $code) {
            return false;
        }
        //验证成功后删除缓存中保存的验证码
        $this->cache->delete($cacheKey);
        return true;
    }
340380
protected function UFGetIdByCode($entity, $code)
    {
        $rsData = CUserTypeEntity::GetList([], [
            'ENTITY_ID' => $entity,
            'FIELD_NAME' => $code,
        ]);
        if ($ob = $rsData->GetNext()) {
            return $ob['ID'];
        } else {
            return null;
        }
    }
668535
public function actionConfirm($id, $code)
    {
        $user = User::findOne($id);
        if ($user === null || Yii::$app->settings->get('emailChangeStrategy','user') == UserSettings::STRATEGY_INSECURE) {
            throw new NotFoundHttpException();
        }
        $user->attemptEmailChange($code);
        return $this->redirect(['account']);
    }
700361
public function check(string $cardId, array $codes)
    {
        $params = [
            'card_id' => $cardId,
            'code' => $codes,
        ];

        return $this->httpPostJson('card/code/checkcode', $params);
    }