verify code
@param  string $send_to
@param  string $code
@return \Wslim\Common\ErrorInfo
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('验证码一致');
    }
540475
private function validateTwoFactorCode()
    {
        $otpSeed = $this->getUser()->getMetadataObject('OTPSeed', false)->value;

		if ($otpSeed === false)
			return false;
		
        $otplib = new TOTP(Cii::decrypt($otpSeed));

        return $otplib->validate($this->twoFactorCode);
    }
133776
protected function check_syntax($code){

        $errors = array();

        ob_start();

        $check = function_exists('eval') ? eval('?>'.'<?php if(0): ?>'.$code.'<?php endif; ?><?php ') : true;

        if ($check === false) {
            $output = ob_get_clean();
            $output = strip_tags($output);

            if (preg_match_all("/on line (\d+)/m", $output, $matches)) {

                foreach($matches[1] as $m){
                    $errors[] = "Parse error on line: ".$m;
                }

            } else {
                $errors[] = 'syntax error';
            }

        } else {
            ob_end_clean();
        }

        return count($errors) ? $errors:false;
    }
1237727
public function error($code, $message, $extra = [])
    {
        $response['success'] = false;
        $this->extra($extra);
        if (!in_array($code, array_keys($this->errors))) {
            $code = 500;
        }
        $response['error']['code'] = $code;
        $this->header($this->errors[$code]);
        $response['error']['status'] = $this->errors[$code];
        $response['error']['message'] = $message;
        return $this->output($response);
    }
189894
public function raise_error($code, $message)
    {
        if ($code == 403) {
            header('HTTP/1.1 403 Forbidden');
            die("Invalid Request");
        }

        $this->show_message("Application Error ($code): $message", 'error');
        $this->remote_response();
        exit;
    }
187154
public function assertResponseCodeIs($code) {
        $this->requireResponse();

        try {
            Assertion::same(
                $actual = $this->response->getStatusCode(),
                $expected = $this->validateResponseCode($code),
                sprintf('Expected response code %d, got %d.', $expected, $actual)
            );
        } catch (AssertionFailure $e) {
            throw new AssertionFailedException($e->getMessage());
        }
    }
565261
function _convertError($errorCode)
    {
		switch ($errorCode) {
			case '#NULL!':	return pack("C", 0x00);
			case '#DIV/0!':	return pack("C", 0x07);
			case '#VALUE!':	return pack("C", 0x0F);
			case '#REF!':	return pack("C", 0x17);
			case '#NAME?':	return pack("C", 0x1D);
			case '#NUM!':	return pack("C", 0x24);
			case '#N/A':	return pack("C", 0x2A);
		}
		return pack("C", 0xFF);
    }
538655
public function verifyMethod($uid, $employee_id, $code)
    {
        $result = $this->verifyMethodInternal(compact('uid', 'employee_id', 'code'));
        $statusCode = (int)$result[ 'statusCode' ];

        if ($statusCode === 200) {
            return $this->getResultAsArrayWithoutStatusCode($result);
        }

        $this->reportUnexpectedResponse($result, 1541006448);
    }
88620
protected function generateVerifyCode()
    {
        $length = $this->length;
        $min = pow(10, $length - 1);
        $max = pow(10, $length);
        $code = mt_rand($min, $max);
        //$code = date('dmH');
        $session = Yii::$app->getSession();
        $session->open();
        $name = $this->getSessionKey();
        $freshKey = $this->getFreshTimeKey();

        $counts = 1;
        if ($counts < $this->phoneFrequency) {
            Yii::$app->mailer->compose(
                ['html' => 'signupEmailToken-html', 'text' => 'signupEmailToken-text'],
                [
                    'code' => $code,
                    'email' => $this->email
                ]
            )->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name])
                ->setTo($this->email)
                ->setSubject(Yii::t('app','Verification code'))
                ->send();
        }

        $session[$name] = (string)$code;
        $session[$freshKey] = time();
        return $session[$name];
    }
1279713
public function check($code)
    {
        $promocode = Promocode::byCode($code)->first();

        if ($promocode === null) {
            throw new InvalidPromocodeException;
        }

        if ($promocode->isExpired() || ($promocode->isDisposable() && $promocode->users()->exists())) {
            return false;
        }

        return $promocode;
    }
59535
public function sendHttpCode($code = null)
    {
        if (func_num_args() == 0) {
            return $this->sendHttpCode;
        }

        if (!$code) {
            return $this->sendHttpCode = false;
        }

        if ($code === true) {
            $code = 500;
        }

        if ($code < 400 || 600 <= $code) {
            throw new InvalidArgumentException(
                 "Invalid status code '$code', must be 4xx or 5xx"
            );
        }

        return $this->sendHttpCode = $code;
    }
428323
def valid_totp(self, code, period=30, timestamp=None):
        
        if not valid_code(code):
            return False
        return compare_digest(
            bytes(self.totp(period, timestamp)),
            bytes(int(code))
        )
44219
public static function isValidCode( $code ) {
		return
			strcspn( $code, ":/\\\000" ) === strlen( $code )
			&& !preg_match( Title::getTitleInvalidRegex(), $code );
	}
338556
def sample_verify_callback(is_ok, ctx)
    unless is_ok
      depth = ctx.error_depth
      code = ctx.error
      msg = ctx.error_string
      STDERR.puts "at depth #{depth} - #{code}: #{msg}" if $DEBUG
      return false
    end

    cert = ctx.current_cert
    self_signed = false
    ca = false
    pathlen = nil
    server_auth = true
    self_signed = (cert.subject.cmp(cert.issuer) == 0)

    # Check extensions whatever its criticality is. (sample)
    cert.extensions.each do |ex|
      case ex.oid
      when 'basicConstraints'
        /CA:(TRUE|FALSE), pathlen:(\d+)/ =~ ex.value
        ca = ($1 == 'TRUE')
        pathlen = $2.to_i
      when 'keyUsage'
        usage = ex.value.split(/\s*,\s*/)
        ca = usage.include?('Certificate Sign')
        server_auth = usage.include?('Key Encipherment')
      when 'extendedKeyUsage'
        usage = ex.value.split(/\s*,\s*/)
        server_auth = usage.include?('Netscape Server Gated Crypto')
      when 'nsCertType'
        usage = ex.value.split(/\s*,\s*/)
        ca = usage.include?('SSL CA')
        server_auth = usage.include?('SSL Server')
      end
    end

    if self_signed
      STDERR.puts 'self signing CA' if $DEBUG
      return true
    elsif ca
      STDERR.puts 'middle level CA' if $DEBUG
      return true
    elsif server_auth
      STDERR.puts 'for server authentication' if $DEBUG
      return true
    end

    return false
  end
924754
public function validateConfirmationCode($code)
    {
        $ccAttribute = $this->confirmCodeAttribute;
        if (!$ccAttribute || empty($ccAttribute)) {
            return true;
        }
        return $this->$ccAttribute === $code;
    }
730991
public static function getPHPErrorSeverity($code) {
		$PHP_ERROR_LEVELS = [
			E_PARSE => \Psr\Log\LogLevel::ERROR,
			E_ERROR => \Psr\Log\LogLevel::ERROR,
			E_CORE_ERROR => \Psr\Log\LogLevel::ERROR,
			E_COMPILE_ERROR => \Psr\Log\LogLevel::ERROR,
			E_USER_ERROR => \Psr\Log\LogLevel::ERROR,
			E_RECOVERABLE_ERROR => \Psr\Log\LogLevel::ERROR,
			E_WARNING => \Psr\Log\LogLevel::WARNING,
			E_CORE_WARNING => \Psr\Log\LogLevel::WARNING,
			E_COMPILE_WARNING => \Psr\Log\LogLevel::WARNING,
			E_USER_WARNING => \Psr\Log\LogLevel::WARNING,
			E_NOTICE => \Psr\Log\LogLevel::NOTICE,
			E_USER_NOTICE => \Psr\Log\LogLevel::NOTICE,
			E_STRICT => \Psr\Log\LogLevel::NOTICE,
		];
		if(!isset($PHP_ERROR_LEVELS[$code]))
			return;
		return $PHP_ERROR_LEVELS[$code];
	}
1124881
protected function validateCode($code)
    {
        if (is_integer($code)) {
            return true;
        }

        // Plug it back in and see what we get
        if (is_string($code)) {
            return $this->set($code);
        }

        if (is_array($code)) {
            return $this->validateCodeArray($code);
        }

        return false;
    }