验证验证码是否正确
@access public

@param string $code 用户验证码
@param string $id   验证码标识

@return bool 用户验证码是否正确
196871
public function check($code, $id = '') {
        $key = $this->authcode($this->seKey) . $id;
        // 验证码不能为空
        $secode = request()->session()->get($key);
        if (empty($code) || empty($secode)) {
            return false;
        }
        // session 过期
        if (time() - $secode[ 'verify_time' ] > $this->expire) {
            request()->session()->del($key);
            return false;
        }
        if ($this->authcode(strtoupper($code)) == $secode[ 'verify_code' ] && $this->reset) {
            request()->session()->del($key);
            return true;
        }
        return false;
    }
530877
public function checkCode($cardId, $code)
    {
        $params = [
            'card_id' => $cardId,
            'code'    => $code,
        ];

        return $this->parseJSON('json', [self::API_CHECK_CODE, $params]);
    }
698877
public function remove($id)
    {
        if ($this->locked) {
            return false;
        }

        if (strpos($id, '.') !== false) {
            $k = '$this->data' . "['" . str_replace('.', "']['", $id) . "']";
            eval('$has = isset(' . $k . ');');
            if ($has) {
                eval('unset(' . $k . ');');
                return true;
            } else {
                return false;
            }
        } elseif ($this->has($id)) {
            unset($this->data[$id]);
            return true;
        } else {
            return false;
        }
    }
1078676
public function getInfo(string $id, string $code): array
    {
        return $this->httpClient->postJson('card/invoice/reimburse/getinvoiceinfo', ['card_id' => $id, 'encrypt_code' => $code]);
    }
1289791
public function findUserByPersistenceCode($code)
    {
        $persistence = $this->findByPersistenceCode($code);

        if ($persistence)
        {
            return $persistence->getUser();
        }

        return false;
    }
1335509
private function _checkIdArgument($id)
    {
        $id = strtoupper($id);
        $length = strlen($id);

        if ($length === 15) {
            return $this->_generateShortType($id);
        } elseif ($length === 18) {
            return $this->_generatelongType($id);
        }

        return false;
    }
313766
protected function iblockGetIdByCode($code, $siteId = null)
    {
        $siteId = $siteId ?: $this->iblockGetDefaultSiteId();
        $res = CIBlock::getList([], [
            'CODE' => $code,
            'CHECK_PERMISSIONS' => 'N',
            'SITE_ID' => $siteId,
        ]);
        $iblock = $res->fetch();

        return !empty($iblock['ID']) ? $iblock['ID'] : null;
    }
276601
public function isCodeValid($code)
    {
        $codeFromConfig = $this->getWebsiteConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
            $this->getWebsite()
        );

        return $codeFromConfig === $code;
    }
239775
public function delete(string $id): bool
    {
        if (\array_key_exists($id, $this->cache)) {

            //delete value
            unset($this->cache[$id]);

            //return function result
            return true;
        }

        return false;
    }
1064385
private static function packJsonError($code, $message, $id) {

        if ( !is_null($id) ) {

            return array(
                'jsonrpc' => '2.0',
                'error' => array(
                    'code' => $code,
                    'message' => $message
                ),
                'id' => $id
            );

        } else {

            return null;

        }

    }
1048474
public function get(string $code, string $cardId = '', bool $checkConsume = true)
    {
        $params = [
            'code' => $code,
            'check_consume' => $checkConsume,
            'card_id' => $cardId,
        ];

        return $this->httpPostJson('card/code/get', $params);
    }
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;
    }
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();
	}
470040
public function actionConfirm($id, $code, $return)
    {
        $user = $this->finder->findUserById($id);

        if ($user === null || $this->module->enableConfirmation == false) {
            throw new NotFoundHttpException();
        }

        $event = $this->getUserEvent($user);

        $this->trigger(self::EVENT_BEFORE_CONFIRM, $event);

        $user->attemptConfirmation($code);

        $this->trigger(self::EVENT_AFTER_CONFIRM, new UserRegistrationEvent([
            'id' => $user->id
        ]));

        if (!empty($return)) {
            \Yii::$app->user->setReturnUrl($return);
            return $this->redirect($return);
        }

        return $this->render('/message', [
            'title'  => \Yii::t('user', 'Account confirmation'),
            'module' => $this->module,
        ]);
    }
740114
public function match($id)
    {
        return $id == $this->id || (strlen($this->getAlias()) && @preg_match($this->getAlias(), $id));
    }
1299148
public function updateStatus(string $id, string $code, string $status): array
    {
        return $this->httpClient->postJson('card/invoice/reimburse/updateinvoicestatus', ['card_id' => $id, 'encrypt_code' => $code, 'reimburse_status' => $status]);
    }
1140213
public static function validate($code = '', $key = -1)
    {
        if (strlen($key) < 1) {
            return false;
        }

        if (!is_numeric($key)) {
            return false;
        }

        if (!is_string($code)) {
            return false;
        }

        if (strlen($code) < 2) {
            return false;
        }

        $numerals = str_split($code);
        $rank = array_reverse(array_keys($numerals));
        $orderedNumerals = array();
        foreach ($rank as $i => $rankValue) {
            $orderedNumerals[$rankValue + 1] = $numerals[$i];
        }
        $results = array();
        foreach ($orderedNumerals as $cle => $value) {
            $results[$value] = ($cle % 2 == 0) ? ((int) $value * 1) : ((int) $value * 2);
        }
        $sum = 0;
        foreach ($results as $cle => $value) {
            $sum += array_sum(str_split($value));
        }
        $validKey = str_split($sum);
        $validKey = 10 - array_pop($validKey);

        return $key === $validKey;
    }