public function run() { $solutionInfo = OjSolutionInterface::getDetail(array('id' => $this->solutionId)); if (empty($solutionInfo)) { Logger::error('judge', "SOLUTION_ID:{$this->solutionId},Solution不存在!"); throw new Exception("SOLUTION_ID:{$this->solutionId},Solution不存在!"); } if ($solutionInfo['remote'] != StatusVars::REMOTE_HDU) { Logger::error('judge', "SOLUTION_ID:{$this->solutionId},必须是HDU的Solution!"); throw new Exception("SOLUTION_ID:{$this->solutionId},必须是HDU的Solution!"); } // post提交 $postData = array(); $postData['problemid'] = $solutionInfo['problem_id']; $postData['language'] = StatusVars::$hduLangMap[$solutionInfo['language']]; $postData['usercode'] = iconv('UTF-8', 'GBK', $solutionInfo['source']); if (false === $postData['usercode']) { Logger::error('judge', "SOLUTION_ID:{$this->solutionId},代码中含有非法字符,转码失败!"); $data = array('id' => $this->solutionId, 'result' => StatusVars::INVALID, 'time_cost' => 0, 'memory_cost' => 0); OjSolutionInterface::save($data); Logger::info('judge', "SOLUTION_ID:{$this->solutionId},代码转码失败,写入INVALID"); return; } $content = $this->ch->post(StatusVars::HDU_SUBMIT_URL, $postData); if (!preg_match('/Location: status.php/sU', $content)) { Logger::error('judge', "SOLUTION_ID:{$this->solutionId},CURL提交代码到HDU失败!CURL耗时:{$this->ch->getLastExecTime()}MS"); $data = array('id' => $this->solutionId, 'result' => StatusVars::TIME_OUT, 'time_cost' => 0, 'memory_cost' => 0); OjSolutionInterface::save($data); Logger::info('judge', "SOLUTION_ID:{$this->solutionId},提交到HDU失败,写入TIME_OUT"); return; } else { Logger::info('judge', "SOLUTION_ID:{$this->solutionId},CURL成功提交代码到HDU!CURL耗时:{$this->ch->getLastExecTime()}MS"); } // 提交后马上获取runId $rowInfo = $this->getResult(); // 获取获取结果超时 if (false === $rowInfo) { Logger::info('judge', "SOLUTION_ID:{$this->solutionId},获取结果失败1,写入TIME_OUT"); $data = array('id' => $this->solutionId, 'result' => StatusVars::TIME_OUT, 'time_cost' => 0, 'memory_cost' => 0); OjSolutionInterface::save($data); return; } else { Logger::info('judge', "SOLUTION_ID:{$this->solutionId},HDU成功获取RUN_ID!"); if (in_array($rowInfo['result'], StatusVars::$hduResultMap)) { Logger::info('judge', "SOLUTION_ID:{$this->solutionId},HDU远程judge成功!"); } $trans = new Trans(DbConfig::$SERVER_TRANS); $trans->begin(); $data = array('trans' => $trans, 'id' => $this->solutionId, 'result' => $rowInfo['result'], 'time_cost' => $rowInfo['time_cost'], 'memory_cost' => $rowInfo['memory_cost'], 'run_id' => $rowInfo['run_id'], 'remote_uid' => $this->uid); OjSolutionInterface::save($data); // 保存Log $dataLog = array('trans' => $trans, 'solution_id' => $this->solutionId, 'ce' => Arr::get('ce', $rowInfo['judge_log'], ''), 're' => Arr::get('re', $rowInfo['judge_log'], '')); OjSolutionLogInterface::save($dataLog); $trans->commit(); } if (!in_array($rowInfo['result'], StatusVars::$hduResultMap)) { $this->sync(); } }
public function run() { $solutionInfo = OjSolutionInterface::getDetail(array('id' => $this->solutionId)); if (empty($solutionInfo)) { Logger::error('judge', "SOLUTION_ID:{$this->solutionId},Solution不存在!"); throw new Exception("SOLUTION_ID:{$this->solutionId},Solution不存在!"); } if ($solutionInfo['remote'] != StatusVars::REMOTE_POJ) { Logger::error('judge', "SOLUTION_ID:{$this->solutionId},必须是POJ的Solution!"); throw new Exception("SOLUTION_ID:{$this->solutionId},必须是POJ的Solution!"); } // post提交 $postData = array(); $postData['problem_id'] = $solutionInfo['problem_id']; $postData['language'] = StatusVars::$pojLangMap[$solutionInfo['language']]; $postData['source'] = $solutionInfo['source']; $postData['submit'] = 'Submit'; $postData['encoded'] = 0; $content = $this->ch->post(StatusVars::POJ_SUBMIT_URL, $postData); if (!preg_match('/Location: http:\\/\\/poj.org\\/status/sU', $content)) { Logger::error('judge', "SOLUTION_ID:{$this->solutionId},CURL提交代码到POJ失败!CURL耗时:{$this->ch->getLastExecTime()}MS"); $data = array('id' => $this->solutionId, 'result' => StatusVars::TIME_OUT, 'time_cost' => 0, 'memory_cost' => 0); OjSolutionInterface::save($data); Logger::info('judge', "SOLUTION_ID:{$this->solutionId},提交到POJ失败,写入TIME_OUT"); return; } else { Logger::info('judge', "SOLUTION_ID:{$this->solutionId},CURL成功提交代码到POJ!CURL耗时:{$this->ch->getLastExecTime()}MS"); } // 提交后马上获取runId $rowInfo = $this->getResult(); // 获取获取结果超时 if (false === $rowInfo) { Logger::info('judge', "SOLUTION_ID:{$this->solutionId},获取结果失败1,写入TIME_OUT"); $data = array('id' => $this->solutionId, 'result' => StatusVars::TIME_OUT, 'time_cost' => 0, 'memory_cost' => 0); OjSolutionInterface::save($data); return; } else { Logger::info('judge', "SOLUTION_ID:{$this->solutionId},POJ成功获取RUN_ID!"); if (in_array($rowInfo['result'], StatusVars::$pojResultMap)) { Logger::info('judge', "SOLUTION_ID:{$this->solutionId},POJ远程judge成功!"); } $trans = new Trans(DbConfig::$SERVER_TRANS); $trans->begin(); $data = array('trans' => $trans, 'id' => $this->solutionId, 'result' => $rowInfo['result'], 'time_cost' => $rowInfo['time_cost'], 'memory_cost' => $rowInfo['memory_cost'], 'run_id' => $rowInfo['run_id'], 'remote_uid' => $this->uid); OjSolutionInterface::save($data); // 保存Log $dataLog = array('trans' => $trans, 'solution_id' => $this->solutionId, 'ce' => Arr::get('ce', $rowInfo['judge_log'], ''), 're' => Arr::get('re', $rowInfo['judge_log'], '')); OjSolutionLogInterface::save($dataLog); $trans->commit(); } if (!in_array($rowInfo['result'], StatusVars::$pojResultMap)) { $this->sync(); } }
public function iframeShowAction() { $solutionId = (int) Request::getGET('solution-id'); $solutionInfo = OjSolutionInterface::getDetail(array('id' => $solutionId)); if (empty($solutionInfo) || false == OjSolutionHelper::hasLog($solutionInfo)) { $this->renderError(); } // 获取属主 $userId = $solutionInfo['user_id']; $userInfo = UserCommonInterface::getById(array('id' => $userId)); // 是否有权限查看,竞赛管理员,自己的solution if (!$this->isContestAdmin && $solutionInfo['user_id'] != $this->loginUserInfo['id']) { $this->renderError('您没有权限查看!'); } $this->renderIframe(array('solutionInfo' => $solutionInfo), 'status/iframe/judge_log.php'); }
public function iframeShowAction() { $solutionId = (int) Request::getGET('solution-id'); $solutionInfo = OjSolutionInterface::getDetail(array('id' => $solutionId)); if (empty($solutionInfo) || false == OjSolutionHelper::hasLog($solutionInfo)) { $this->renderError(); } // 获取属主 $userId = $solutionInfo['user_id']; $userInfo = UserCommonInterface::getById(array('id' => $userId)); // solution level list($solutionInfo['level'], $solutionInfo['permission']) = OjSolutionHelper::solutionPermission($solutionInfo, $userInfo['share'], Arr::get('id', $this->loginUserInfo, 0), $this->isOjAdmin); if (!$solutionInfo['permission']) { $this->renderError('您没有权限查看!'); } $this->renderIframe(array('solutionInfo' => $solutionInfo), 'status/iframe/judge_log.php'); }
public function defaultAction() { $solutionId = (int) Request::getGET('solution-id'); // 获取solutionInfo $solutionInfo = OjSolutionInterface::getDetail(array('id' => $solutionId)); if (empty($solutionInfo)) { $this->renderError(); } // 获取属主 $userId = $solutionInfo['user_id']; $userInfo = UserCommonInterface::getById(array('id' => $userId)); if (empty($userInfo)) { $this->renderError(); } // 是否有权限查看,竞赛管理员,自己的solution if (!$this->isContestAdmin && $solutionInfo['user_id'] != $this->loginUserInfo['id']) { $this->renderError('您没有权限查看!'); } $this->renderFramework(array('solutionInfo' => $solutionInfo), 'status/code.php'); }
public function defaultAction() { $solutionId = (int) Request::getGET('solution-id'); // 获取solutionInfo $solutionInfo = OjSolutionInterface::getDetail(array('id' => $solutionId)); if (empty($solutionInfo)) { $this->renderError(); } // 获取属主 $userId = $solutionInfo['user_id']; $userInfo = UserCommonInterface::getById(array('id' => $userId)); if (empty($userInfo)) { $this->renderError(); } // solution level list($solutionInfo['level'], $solutionInfo['permission']) = OjSolutionHelper::solutionPermission($solutionInfo, $userInfo['share'], Arr::get('id', $this->loginUserInfo, 0), $this->isOjAdmin); if (!$solutionInfo['permission']) { $this->renderError('您没有权限查看!'); } $this->renderFramework(array('solutionInfo' => $solutionInfo), 'status/code.php'); }