public function run($client) { // todo debug模式下记录运行详细日志 unset($script); foreach ($this->scripts as $key => $script) { $runner = new $script['script'](); $result = $runner->run($script['config'], $client); Common::Log()->debug(__METHOD__, 'Running script detection ' . $script['script'] . ' with result ' . $result); if (!$result) { $this->error = $runner->getError(); Common::Log()->info(__METHOD__, 'Running script detection ' . $script['script'] . ' with error ' . $this->error); return false; } } }
public function quit($checkResult = false) { $this->Log->debug(__METHOD__, sprintf('system running use time %fs,RAM %s', Common::click(), Common::convertUnit(Common::RAMClick()))); $resultMsg = $this->resultMsg; if (self::$init !== null && self::$quit === null) { self::$quit = true; spl_autoload_unregister(array($this, 'autoLoad')); // 开启debug时将系统debug信息写入log if (Common::getConfig('debug_level', $this->config)) { $this->Log->writeLog(); } // 清理Model所占资源 if (is_object($this->Model)) { $this->Model->quit(); } // 注销register_shutdown_function,避免影响其他程序 $this->registerShutdown->unRegister(); } }
private function unsetCount() { // 重置该IP累计访问次数 Common::M()->del($this->client['ip'], self::IP_VISIT_TIMES_FLAG); // 重置该IP挑战失败次数 Common::M()->del($this->client['ip'], self::IP_FAILURE_PREFIX); }
public function ajaxReturnError() { $data = array('status' => 0, 'info' => '验证码错误'); Common::ajaxReturn($data); }
protected function checkVerify($code) { // 验证码不区分大小写 $code = strtolower($code); $checkCode = Common::session(self::ROBOT_CHALLENGE_FLAG); // 验证码不存在,直接返回 if (!$checkCode) { $this->error = 'Verify not exists'; return false; } if (substr(hash('sha256', $checkCode . $code), 0, 4) !== '0000') { // 验证失败 $checkTimes = intval(Common::session(self::ROBOT_CHALLENGE_VERIFY_TIMES)); // 验证码超过指定次数后失效 if ($checkTimes > self::ROBOT_CHALLENGE_ERROR_TIMES) { Common::session(self::ROBOT_CHALLENGE_FLAG, null); } else { $checkTimes++; Common::session(self::ROBOT_CHALLENGE_VERIFY_TIMES, $checkTimes); } $this->error = 'Check verify failure'; return false; } else { // 验证成功,重置验证次数统计,删除验证码 Common::session(self::ROBOT_CHALLENGE_VERIFY_TIMES, null); Common::session(self::ROBOT_CHALLENGE_FLAG, null); return true; } }
private function setVerify($code) { // 验证码不区分大小写 $code = strtolower($code); // 重置验证码验证失败次数 Common::session(self::ROBOT_CHALLENGE_VERIFY_TIMES, 0); if (Common::session(self::ROBOT_CHALLENGE_FLAG, $code)) { return true; } else { $this->error = 'Set verify into session failure'; return false; } }