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 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'); }
public function defaultAction() { $pageSize = 15; $username = Request::getGET('username'); $remote = (int) Request::getGET('remote', -1); $problemCode = Request::getGET('problem-code'); // 因为ZOJ的题号是code $language = (int) Request::getGET('language', -1); $result = (int) Request::getGET('result', -1); $contestId = (int) Request::getGET('contest-id'); $globalId = (int) Request::getGET('global-id'); // 获取id $maxId = (int) Request::getGET('max-id', -1); $minId = (int) Request::getGET('min-id', -1); // 获取userInfo,username转换为userId $userInfo = array(); if (!empty($username)) { $userInfo = UserCommonInterface::getByLoginName(array('login_name' => $username)); } // 构建where $where = array(); if ($this->isOjAdmin) { if ($contestId) { $where[] = array('contest_id', '=', $contestId); } } if (!empty($username)) { $where[] = array('user_id', '=', Arr::get('id', $userInfo, 0)); } if ($remote != -1) { $where[] = array('remote', '=', $remote); } if (!empty($problemCode)) { $where[] = array('problem_code', '=', $problemCode); } if (!empty($globalId)) { $where[] = array('problem_global_id', '=', $globalId); } if ($language != -1) { $where[] = array('language', '=', $language); } if ($result != -1) { $where[] = array('result', '=', $result); } // 获取solutionList if ($maxId != -1) { $where[] = array('id', '<=', $maxId); $order = array('id' => 'DESC'); $solutionList = OjSolutionInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'include_contest' => $this->isOjAdmin)); } else { if ($minId != -1) { $where[] = array('id', '>=', $minId); $order = array('id' => 'ASC'); $solutionList = OjSolutionInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'include_contest' => $this->isOjAdmin)); $solutionList = array_reverse($solutionList, true); } else { $order = array('id' => 'DESC'); $solutionList = OjSolutionInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'include_contest' => $this->isOjAdmin)); } } // 获取userHash $userIds = array_unique(array_column($solutionList, 'user_id')); $userHash = UserCommonInterface::getById(array('id' => $userIds)); // 格式化solution foreach ($solutionList as &$solutionInfo) { // level $userInfo = $userHash[$solutionInfo['user_id']]; list($solutionInfo['level'], $solutionInfo['permission']) = OjSolutionHelper::solutionPermission($solutionInfo, $userInfo['share'], Arr::get('id', $this->loginUserInfo, 0), $this->isOjAdmin); $solutionInfo['has_log'] = OjSolutionHelper::hasLog($solutionInfo); } // 计算minId, maxId $minId = $maxId = 0; if (!empty($solutionList)) { $n = count($solutionList); $maxId = $solutionList[0]['id']; $minId = $solutionList[$n - 1]['id']; } // 缓存html $html = array(); $html['pager'] = $this->view->fetch(array('renderMaxId' => $maxId, 'renderMinId' => $minId), 'widget/pager_status.php'); $tpl = $this->isOjAdmin ? 'status/list_admin.php' : 'status/list.php'; // render $this->renderFramework(array('userHash' => $userHash, 'solutionList' => $solutionList, 'html' => $html), $tpl); }
public function defaultAction() { $pageSize = 15; // 获取参数 $username = Request::getGET('username'); $language = (int) Request::getGET('language', -1); $result = (int) Request::getGET('result', -1); $problemHash = Request::getGET('problem-hash'); $maxId = (int) Request::getGET('max-id', -1); $minId = (int) Request::getGET('min-id', -1); $globalId = array_search($problemHash, $this->contestInfo['problem_hash']); // 获取userInfo,username转换为userId $userInfo = array(); if (!empty($username)) { $userInfo = UserCommonInterface::getByLoginName(array('login_name' => $username)); } // 构建where $where = array(); $where[] = array('contest_id', '=', $this->contestInfo['id']); $where[] = array('hidden', '=', 0); $where[] = array('problem_global_id', 'IN', $this->contestInfo['global_ids']); if (!empty($username)) { $where[] = array('user_id', '=', Arr::get('id', $userInfo, 0)); } if (!empty($globalId)) { $where[] = array('problem_global_id', '=', $globalId); } if ($language != -1) { $where[] = array('language', '=', $language); } if ($result != -1) { $where[] = array('result', '=', $result); } // 获取solutionList if ($maxId != -1) { $where[] = array('solution_id', '<=', $maxId); $solutionList = OjSolutionInterface::getList(array('where' => $where, 'order' => array('id' => 'DESC'), 'limit' => $pageSize, 'include_contest' => true)); } else { if ($minId != -1) { $where[] = array('solution_id', '>=', $minId); $solutionList = OjSolutionInterface::getList(array('where' => $where, 'order' => array('id' => 'ASC'), 'limit' => $pageSize, 'include_contest' => true)); $solutionList = array_reverse($solutionList, true); } else { $solutionList = OjSolutionInterface::getList(array('where' => $where, 'order' => array('id' => 'DESC'), 'limit' => $pageSize, 'include_contest' => true)); } } // 获取userHash $userIds = array_unique(array_column($solutionList, 'user_id')); $userHash = UserCommonInterface::getById(array('id' => $userIds)); // 格式化solution foreach ($solutionList as &$solutionInfo) { $solutionInfo['permission'] = false; if ($this->isContestAdmin || $solutionInfo['user_id'] == $this->loginUserInfo['id']) { $solutionInfo['permission'] = true; } $solutionInfo['has_log'] = OjSolutionHelper::hasLog($solutionInfo); } // 如果是报名,获取报名列表 $applyHash = array(); if ($this->contestInfo['type'] == ContestVars::TYPE_APPLY) { $where = array(array('contest_id', '=', $this->contestInfo['id'])); $applyHash = OjContestApplyInterface::getList(array('where' => $where)); $applyHash = Arr::listToHash('user_id', $applyHash); } // 计算minId, maxId $minId = $maxId = 0; if (!empty($solutionList)) { $solutionIds = array_keys($solutionList); $maxId = $solutionIds[0]; $minId = end($solutionIds); } // 缓存html $html = array(); $html['pager'] = $this->view->fetch(array('renderMaxId' => $maxId, 'renderMinId' => $minId), 'widget/pager_status.php'); // render $this->renderFramework(array('userHash' => $userHash, 'solutionList' => $solutionList, 'html' => $html, 'applyHash' => $applyHash), 'status/list.php'); }
public static function getDetail($id) { $solutionInfo = self::getById($id); if (empty($solutionInfo)) { return array(); } $sourceInfo = OjSolutionCodeInterface::getByField(array('solution_id' => $id)); $solutionInfo['has_log'] = OjSolutionHelper::hasLog($solutionInfo); $logInfo = array(); if ($solutionInfo['has_log']) { $logInfo = OjSolutionLogInterface::getByField(array('solution_id' => $id)); } $solutionInfo['source'] = Arr::get('source', $sourceInfo, '', true); $solutionInfo['source_format'] = htmlspecialchars($solutionInfo['source'], ENT_COMPAT, 'UTF-8'); $solutionInfo['ce'] = Arr::get('ce', $logInfo, '', true); $solutionInfo['re'] = Arr::get('re', $logInfo, '', true); $solutionInfo['detail'] = Arr::get('detail', $logInfo, '', true); return $solutionInfo; }