public function defaultAction()
 {
     $pageSize = 20;
     // 获取参数
     $page = Pager::get();
     $title = Request::getGET('title');
     $status = (int) Request::getGET('status');
     // 构建where
     $where = array();
     $where[] = array('user_id', '=', $this->loginUserInfo['id']);
     if (!empty($title)) {
         $where[] = array('title', 'LIKE', "%{$title}%");
     }
     if (!empty($status) && $status != -1) {
         $where[] = array('hidden', '=', $status - 1);
     }
     // 获取数据
     $order = array('refresh_at' => 'DESC', 'id' => 'DESC');
     $offset = ($page - 1) * $pageSize;
     $setList = OjProblemSetInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = OjProblemSetInterface::getCount($where);
     foreach ($setList as &$setInfo) {
         $problemJson = $setInfo['problem_set'];
         $globalIds = (array) json_decode($problemJson, true);
         $setInfo['count'] = count($globalIds);
     }
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
     // 输出
     $this->renderFramework(array('html' => $html, 'setList' => $setList), 'setup/set/list.php');
 }
 public function defaultAction()
 {
     $pageSize = 20;
     // 获取参数
     $page = Pager::get();
     $status = (int) Request::getGET('status');
     // 构建where
     $where = array();
     $where[] = array('remote', '=', StatusVars::REMOTE_HQU);
     $where[] = array('user_id', '=', $this->loginUserInfo['id']);
     if (!empty($status) && $status != -1) {
         $where[] = array('hidden', '=', $status - 1);
     }
     // 获取数据
     $offset = ($page - 1) * $pageSize;
     $problemList = OjProblemInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = OjProblemInterface::getCount($where);
     $userIds = array_unique(array_column($problemList, 'user_id'));
     $userHash = UserCommonInterface::getById(array('id' => $userIds));
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 5), 'widget/pager.php');
     // 输出
     $this->renderFramework(array('problemList' => $problemList, 'userHash' => $userHash, 'html' => $html), 'setup/problem/list.php');
 }
 public function ajaxAction()
 {
     // 获取dir参数
     $dir = Request::getGET('dir', 'image');
     if (!array_key_exists($dir, self::$ALLOWED)) {
         echo json_encode(array('error' => 1, 'message' => '参数错误!'));
         return;
     }
     // 获取上传的文件
     $field = 'imgFile';
     $fileSize = Upload::getFilesize($field);
     $tmpName = Upload::getTmpName($field);
     $fileExt = Upload::getFileExt($field);
     if (empty($fileSize)) {
         echo json_encode(array('error' => 1, 'message' => '请上传文件!'));
         return;
     }
     // 校验格式
     if (!in_array($fileExt, self::$ALLOWED[$dir])) {
         echo json_encode(array('error' => 1, 'message' => '文件格式不支持,无法上传!'));
         return;
     }
     // 保存
     $cdnKey = Cdn::uploadLocalFile($tmpName, $this->loginUserInfo['id'], $fileExt);
     $url = Cdn::getUrl($cdnKey);
     echo json_encode(array('error' => 0, 'url' => $url));
 }
 public function defaultAction()
 {
     $pageSize = 20;
     // 获取参数
     $page = Pager::get();
     $title = Request::getGET('title');
     $status = (int) Request::getGET('status');
     // 构建where
     $where = array(array('user_id', '=', $this->loginUserInfo['id']), array('is_diy', '=', 1));
     if (!empty($status) && $status != -1) {
         $where[] = array('hidden', '=', $status - 1);
     }
     if (!empty($title)) {
         $where[] = array('title', 'LIKE', "%{$title}%");
     }
     // 获取数据
     $offset = ($page - 1) * $pageSize;
     $contestList = OjContestInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = 0;
     if (!empty($contestList)) {
         $allCount = OjContestInterface::getCount($where);
     }
     $userIds = array_unique(array_column($contestList, 'user_id'));
     $userHash = UserCommonInterface::getById(array('id' => $userIds));
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
     // 输出
     $this->renderFramework(array('contestList' => $contestList, 'userHash' => $userHash, 'html' => $html), 'setup/contest/list.php');
 }
Esempio n. 5
0
 public static function run()
 {
     header('Content-type: text/html; charset=utf-8');
     // debug
     Debug::p('PHP Begin');
     $htmlDebug = Request::getGET('htmldebug');
     $ajaxDebug = Request::getGET('ajaxdebug');
     if ($htmlDebug == 'on') {
         Cookie::set('htmldebug', 1);
     }
     if ($htmlDebug == 'off') {
         Cookie::delete('htmldebug');
     }
     if ($ajaxDebug == 'on') {
         Cookie::set('ajaxdebug', 1);
     }
     if ($ajaxDebug == 'off') {
         Cookie::delete('ajaxdebug');
     }
     self::parseUrl();
     $path = empty(self::$CLASS_DIR) ? PROJECT_PATH . '/controller/' . self::$CLASS_NAME . '.class.php' : PROJECT_PATH . '/controller/' . self::$CLASS_DIR . '/' . self::$CLASS_NAME . '.class.php';
     if (!is_file($path)) {
         $userAgent = Arr::get('HTTP_USER_AGENT', $_SERVER, '');
         throw new FrameworkException("控制器:{$path} 不存在!User Agent: {$userAgent}");
     }
     require_once $path;
     $obj = new self::$CLASS_NAME();
     $actionName = self::$ACTION . 'Action';
     $obj->{$actionName}();
     // debug
     Debug::p('PHP End');
     if (isset($_COOKIE['htmldebug']) && !self::$IS_AJAX || isset($_COOKIE['ajaxdebug']) && self::$IS_AJAX) {
         Debug::show();
     }
 }
 public function defaultAction()
 {
     $pageSize = 50;
     // 获取参数
     $page = Pager::get();
     $contestId = (int) Request::getGET('contest-id');
     $status = (int) Request::getGET('status', -1);
     $contestInfo = OjContestInterface::getById(array('id' => $contestId));
     if (empty($contestInfo) || $contestInfo['hidden'] || $contestInfo['type'] != ContestVars::TYPE_APPLY) {
         $this->renderError('竞赛不存在,或者竞赛不需要报名!');
     }
     // 构建where
     $where = array();
     $where[] = array('contest_id', '=', $contestId);
     if ($status != -1) {
         $where[] = array('status', '=', $status);
     }
     // 获取数据
     $offset = ($page - 1) * $pageSize;
     $applyList = OjContestApplyInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = OjContestApplyInterface::getCount($where);
     // userHash
     $userIds = array_unique(array_column($applyList, 'user_id'));
     $userHash = UserCommonInterface::getById(array('id' => $userIds));
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
     $this->renderFramework(array('html' => $html, 'applyList' => $applyList, 'contestInfo' => $contestInfo, 'userHash' => $userHash), 'contest/apply_list.php');
 }
 public function defaultAction()
 {
     $pageSize = 50;
     $page = Pager::get();
     $category = (int) Request::getGET('category', -1);
     $title = trim(Request::getGET('title', ''));
     $username = trim(Request::getGET('username', ''));
     $where = array();
     if ($category != -1) {
         $where[] = array('category', '=', $category);
     }
     if (!empty($username)) {
         $userInfo = UserCommonInterface::getByLoginName(array('login_name' => $username));
         $where[] = array('user_id', '=', Arr::get('id', $userInfo, 0));
     }
     if (!empty($title)) {
         $where[] = array('title', 'LIKE', "%{$title}%");
     }
     if ($category != -1) {
         $order = array('hidden' => 'ASC', 'title' => 'ASC', 'id' => 'DESC');
     } else {
         $order = array('id' => 'DESC');
     }
     $offset = ($page - 1) * $pageSize;
     $docList = DocInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = empty($docList) ? 0 : DocInterface::getCount($where);
     $userIds = array_unique(array_column($docList, 'user_id'));
     $userHash = UserCommonInterface::getById(array('id' => $userIds));
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 7), 'widget/pager.php');
     $this->renderFramework(array('html' => $html, 'docList' => $docList, 'userHash' => $userHash), 'doc/list.php');
 }
 public function defaultAction()
 {
     // 获取参数
     $globalId = (int) Request::getGET('global-id');
     $problemId = Request::getGET('problem-id');
     $problemInfo = array();
     if (!empty($globalId)) {
         $problemInfo = OjProblemInterface::getById(array('id' => $globalId));
     } else {
         if (!empty($problemId)) {
             $problemInfo = OjProblemInterface::getDetail(array('remote' => StatusVars::REMOTE_HQU, 'problem_id' => $problemId));
         }
     }
     if (empty($problemInfo)) {
         $this->renderError('题目不存在!');
     }
     // 权限校验
     if ($problemInfo['user_id'] != $this->loginUserInfo['id']) {
         $this->renderError('你没有权限查看!');
     }
     if ($problemInfo['remote'] != StatusVars::REMOTE_HQU) {
         $this->renderError('你没有权限查看!');
     }
     $this->renderFramework(array('problemInfo' => $problemInfo), 'setup/problem/detail.php');
 }
 public function defaultAction()
 {
     $pageSize = 15;
     $problemId = Request::getGET('problem-id');
     $language = (int) Request::getGET('language', -1);
     $result = (int) Request::getGET('result', -1);
     // 获取id
     $maxId = (int) Request::getGET('max-id', -1);
     $minId = (int) Request::getGET('min-id', -1);
     // 获取用户创建的所有题目
     $where = array(array('remote', '=', StatusVars::REMOTE_HQU), array('user_id', '=', $this->loginUserInfo['id']));
     $problemList = OjProblemInterface::getList(array('field' => 'problem_id', 'where' => $where));
     $problemIds = array_column($problemList, 'problem_id');
     // 构建where
     $where = array(array('user_id', '=', $this->loginUserInfo['id']), array('solution_id', '=', 0), array('problem_id', 'IN', $problemIds));
     if (!empty($problemId)) {
         // HQOJ上的题目,problem_code和problem_id相同
         $where[] = array('problem_id', '=', $problemId);
     }
     if ($language != -1) {
         $where[] = array('language', '=', $language);
     }
     if ($result != -1) {
         $where[] = array('result', '=', $result);
     }
     // 获取judgeList
     if ($maxId != -1) {
         $where[] = array('id', '<=', $maxId);
         $judgeList = OjJudgeInterface::getList(array('where' => $where, 'order' => array('id' => 'DESC'), 'limit' => $pageSize));
     } else {
         if ($minId != -1) {
             $where[] = array('id', '>=', $minId);
             $judgeList = OjJudgeInterface::getList(array('where' => $where, 'order' => array('id' => 'ASC'), 'limit' => $pageSize));
             $judgeList = array_reverse($judgeList, true);
         } else {
             $judgeList = OjJudgeInterface::getList(array('where' => $where, 'order' => array('id' => 'DESC'), 'limit' => $pageSize));
         }
     }
     // 获取userHash
     $userIds = array_unique(array_column($judgeList, 'user_id'));
     $userHash = UserCommonInterface::getById(array('id' => $userIds));
     // 格式化solution
     foreach ($judgeList as &$judgeInfo) {
         $text = StatusVars::$RESULT_FORMAT[$judgeInfo['result']];
         $class = StatusVars::$RESULT_CLASS[$judgeInfo['result']];
         $judgeInfo['result_html'] = sprintf('<span class="%s">%s</span>', $class, $text);
     }
     // 计算minId, maxId
     $minId = $maxId = 0;
     if (!empty($judgeList)) {
         $judgeIds = array_keys($judgeList);
         $maxId = $judgeIds[0];
         $minId = end($judgeIds);
     }
     // 缓存html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderMaxId' => $maxId, 'renderMinId' => $minId), 'widget/pager_status.php');
     // render
     $this->renderFramework(array('userHash' => $userHash, 'judgeList' => $judgeList, 'html' => $html), 'setup/problem/judge_list.php');
 }
 public function defaultAction()
 {
     $pageSize = 20;
     // 获取参数
     $page = Pager::get();
     $status = (int) Request::getGET('status', -1);
     $contestId = (int) Request::getGET('contest-id', 0);
     $where = array();
     $where[] = array('is_diy', '=', 0);
     if (!empty($contestId)) {
         $where[] = array('contest_id', '=', $contestId);
     }
     if ($status != -1) {
         $where[] = array('status', '=', $status);
     }
     // 获取数据
     $offset = ($page - 1) * $pageSize;
     $applyList = OjContestApplyInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = 0;
     $userHash = array();
     $contestHash = array();
     if (!empty($applyList)) {
         $allCount = OjContestApplyInterface::getCount($where);
         $userIds = array_column($applyList, 'user_id');
         $userHash = UserCommonInterface::getById(array('id' => $userIds));
         $contestIds = array_unique(array_column($applyList, 'contest_id'));
         $contestHash = OjContestInterface::getById(array('id' => $contestIds));
     }
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
     $this->renderFramework(array('html' => $html, 'applyList' => $applyList, 'contestHash' => $contestHash, 'userHash' => $userHash), 'contest/apply_list.php');
 }
Esempio n. 11
0
 public function iframeSetUserAction()
 {
     // 获取参数
     $globalId = (int) Request::getGET('global-id');
     if (empty($globalId)) {
         $this->renderError('参数错误!');
     }
     $this->renderIframe(array(), 'problem/iframe/set_user.php');
 }
Esempio n. 12
0
 public function defaultAction()
 {
     $globalId = Request::getGET('global-id');
     $problemInfo = OjProblemInterface::getById(array('id' => $globalId));
     if (empty($problemInfo) || !$problemInfo['hidden'] || $problemInfo['user_id'] != $this->loginUserInfo['id']) {
         $this->renderError('你没有操作权限!');
     }
     $this->renderFramework(array('problemInfo' => $problemInfo), 'setup/problem/edit.php');
 }
Esempio n. 13
0
 public function defaultAction()
 {
     $globalId = Request::getGET('global-id');
     $problemInfo = OjProblemInterface::getById(array('id' => $globalId));
     if (empty($problemInfo)) {
         $this->renderError('题目不存在!');
     }
     $this->renderFramework(array('problemInfo' => $problemInfo), 'problem/edit.php');
 }
Esempio n. 14
0
 public function defaultAction()
 {
     $contestId = (int) Request::getGET('contest-id');
     $contestInfo = OjContestInterface::getById(array('id' => $contestId));
     if (empty($contestInfo)) {
         $this->renderError('竞赛不存在!');
     }
     $this->renderFramework(array('contestInfo' => $contestInfo), 'contest/edit.php');
 }
Esempio n. 15
0
 public function iframeChangeAction()
 {
     $docId = (int) Request::getGET('doc-id');
     $docInfo = DocInterface::getById(array('id' => $docId));
     if (empty($docInfo)) {
         $this->renderError('文章不存在!');
     }
     $userInfo = UserCommonInterface::getById(array('id' => $docInfo['user_id']));
     $this->renderIframe(array('userInfo' => $userInfo, 'docInfo' => $docInfo), 'doc/iframe/change.php');
 }
Esempio n. 16
0
 public function iframeRemoveAction()
 {
     $managerId = Request::getGET('manager-id', 0);
     $managerInfo = RootManagerInterface::getById(array('id' => $managerId));
     if (empty($managerInfo)) {
         $this->renderIframeError('管理员不存在!');
     }
     $userInfo = UserCommonInterface::getById(array('id' => $managerInfo['user_id']));
     $this->renderIframe(array('userInfo' => $userInfo), 'manager/iframe/remove_path.php');
 }
 public function iframeShowAction()
 {
     $judgeId = (int) Request::getGET('judge-id');
     // 获取judgeInfo
     $judgeInfo = OjJudgeInterface::getRow(array('id' => $judgeId));
     if (empty($judgeInfo)) {
         $this->renderError();
     }
     $this->renderIframe(array('judgeInfo' => $judgeInfo), 'problem/iframe/judge_log.php');
 }
 public function defaultAction()
 {
     $docId = (int) Request::getGET('doc-id');
     $docInfo = DocInterface::getById(array('id' => $docId));
     if (empty($docInfo)) {
         $this->renderError();
     }
     $userInfo = UserCommonInterface::getById(array('id' => $docInfo['user_id']));
     $this->renderFramework(array('docInfo' => $docInfo, 'userInfo' => $userInfo), 'doc/detail.php');
 }
 public function iframeShowAction()
 {
     $judgeId = (int) Request::getGET('judge-id');
     // 获取judgeInfo
     $where = array(array('id', '=', $judgeId), array('solution_id', '=', 0), array('user_id', '=', $this->loginUserInfo['id']));
     $judgeInfo = OjJudgeInterface::getRow(array('where' => $where));
     if (empty($judgeInfo)) {
         $this->renderError();
     }
     $this->renderIframe(array('judgeInfo' => $judgeInfo), 'setup/problem/iframe/judge_log.php');
 }
 public function defaultAction()
 {
     $contestId = Request::getGET('contest-id');
     $contestInfo = OjContestInterface::getDetail(array('id' => $contestId));
     if (empty($contestInfo)) {
         $this->renderError('竞赛不存在!');
     }
     $problemHash = OjProblemInterface::getById(array('id' => $contestInfo['global_ids']));
     $solutionList = OjSolutionInterface::getList(array('field' => 'problem_global_id', 'where' => array(array('contest_id', '=', $contestId))));
     $submitGlobalIds = array_unique(array_column($solutionList, 'problem_global_id'));
     $this->renderFramework(array('contestInfo' => $contestInfo, 'problemHash' => $problemHash, 'globalIds' => $contestInfo['global_ids'], 'submitGlobalIds' => $submitGlobalIds), 'contest/set_problem.php');
 }
Esempio n. 21
0
 public function defaultAction()
 {
     $resetTicket = Request::getGET('reset-ticket');
     if (empty($resetTicket)) {
         $this->renderError();
     }
     $userInfo = UcAuthInterface::getUserInfoByResetTicket(array('reset_ticket' => $resetTicket));
     if (empty($userInfo)) {
         $this->renderError('你访问的页面已经过期,请重新操作!');
     }
     $this->renderFramework(array('userInfo' => $userInfo), 'reset.php');
 }
Esempio n. 22
0
 public function iframeEditAction()
 {
     $id = Request::getGET('permission-id', 0);
     if (empty($id)) {
         $this->renderIframeError('缺少参数!');
     }
     $permissionInfo = RootPermissionInterface::getById(array('id' => $id));
     if (empty($permissionInfo)) {
         $this->renderIframeError('权限不存在!');
     }
     $this->renderIframe(array('permissionInfo' => $permissionInfo), 'permission/iframe/permission_edit.php');
 }
Esempio n. 23
0
 public function defaultAction()
 {
     $contestId = (int) Request::getGET('contest-id');
     $contestInfo = OjContestInterface::getById(array('id' => $contestId));
     if (empty($contestInfo)) {
         $this->renderError('竞赛不存在!');
     }
     // 权限
     if ($contestInfo['user_id'] != $this->loginUserInfo['id']) {
         $this->renderError('你没有权限查看!');
     }
     $this->renderFramework(array('contestInfo' => $contestInfo), 'setup/contest/edit.php');
 }
 public function iframeUpdateAction()
 {
     $setId = Request::getGET('set-id');
     if (empty($setId)) {
         $this->renderError('参数错误');
     }
     $setInfo = OjProblemSetInterface::getById(array('id' => $setId));
     if (empty($setInfo)) {
         $this->renderError();
     }
     // 输出
     $this->renderIframe(array('setInfo' => $setInfo), 'setup/set/iframe/update.php');
 }
Esempio n. 25
0
 public function defaultAction()
 {
     $pageSize = 100;
     // 获取参数
     $page = Pager::get();
     $remote = (int) Request::getGET('remote', 0);
     $keyword = Request::getGET('keyword');
     $searchType = (int) Request::getGET('search-type', 1);
     // 构建where
     $where = array();
     $where[] = array('remote', '=', $remote);
     $where[] = array('hidden', '=', 0);
     if (!empty($keyword)) {
         if ($searchType == 1) {
             $where[] = array('OR' => array(array('problem_code', '=', $keyword), array('title', 'LIKE', "%{$keyword}%")));
         } else {
             if ($searchType == 2) {
                 $where[] = array('OR' => array(array('problem_code', '=', $keyword), array('source', 'LIKE', "%{$keyword}%")));
             }
         }
     }
     // 获取数据
     $order = array('problem_code' => 'ASC');
     $offset = ($page - 1) * $pageSize;
     $problemList = OjProblemInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = OjProblemInterface::getCount($where);
     // 获取用户解决的题目
     $userSolution = array();
     if ($this->loginUserInfo) {
         $globalIds = array_column($problemList, 'id');
         $where = array(array('user_id', '=', $this->loginUserInfo['id']), array('contest_id', '=', 0), array('problem_global_id', 'IN', $globalIds));
         $solutionList = OjSolutionInterface::getList(array('where' => $where));
         foreach ($solutionList as $solutionId => $solutionInfo) {
             $globalId = $solutionInfo['problem_global_id'];
             if (!array_key_exists($globalId, $userSolution) || $solutionInfo['result'] == StatusVars::ACCEPTED) {
                 $userSolution[$globalId] = $solutionInfo;
             }
         }
     }
     $userHash = array();
     if ($allCount > 0) {
         $userIds = array_unique(array_column($problemList, 'user_id'));
         $userHash = UserCommonInterface::getById(array('id' => $userIds));
     }
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 10), 'widget/pager.php');
     $tpl = $remote ? 'problem/list_remote.php' : 'problem/list.php';
     // 输出
     $this->renderFramework(array('html' => $html, 'problemList' => $problemList, 'userSolution' => $userSolution, 'userHash' => $userHash), $tpl);
 }
 public function defaultAction()
 {
     // 获取参数
     $id = (int) Request::getGET('global-id', 0);
     if (empty($id)) {
         $this->renderError('题目不存在!');
     }
     // 校验题目
     $problemInfo = OjProblemInterface::getById(array('id' => $id));
     if (empty($problemInfo) || $problemInfo['hidden']) {
         $this->renderError('题目不存在!');
     }
     $this->renderFramework(array('problemInfo' => $problemInfo), 'problem/submit.php');
 }
 public function defaultAction()
 {
     $setId = (int) Request::getGET('set-id');
     if (empty($setId)) {
         $this->renderError('参数错误');
     }
     $setInfo = OjProblemSetInterface::getById(array('id' => $setId));
     if (empty($setInfo)) {
         $this->renderError();
     }
     $globalIds = (array) json_decode($setInfo['problem_set'], true);
     $problemHash = OjProblemInterface::getById(array('id' => $globalIds));
     $this->renderFramework(array('setInfo' => $setInfo, 'problemHash' => $problemHash), 'setup/set/set_problem.php');
 }
 public function defaultAction()
 {
     // 获取参数
     $globalId = (int) Request::getGET('global-id');
     if (empty($globalId)) {
         $this->renderError();
     }
     // 校验题目
     $problemInfo = OjProblemInterface::getById(array('id' => $globalId));
     if (empty($problemInfo) || $problemInfo['user_id'] != $this->loginUserInfo['id']) {
         $this->renderError('题目不存在!');
     }
     $this->renderFramework(array('problemInfo' => $problemInfo), 'setup/problem/submit.php');
 }
 public function defaultAction()
 {
     // 获取参数
     $problemHash = Request::getGET('problem-hash');
     $globalId = array_search($problemHash, $this->contestInfo['problem_hash'], true);
     if (empty($globalId)) {
         $this->renderError('竞赛中无此题!');
     }
     // 校验题目
     $problemInfo = OjProblemInterface::getById(array('id' => $globalId));
     if (empty($problemInfo)) {
         $this->renderError('题目不存在!');
     }
     $this->renderFramework(array('problemInfo' => $problemInfo), 'problem/submit.php');
 }
Esempio n. 30
0
 public function defaultAction()
 {
     $pageSize = 50;
     // 获取参数
     $page = Pager::get();
     $title = Request::getGET('title');
     $status = (int) Request::getGET('status');
     $username = Request::getGET('username');
     // userInfo
     $userInfo = array();
     if (!empty($username)) {
         $userInfo = UserCommonInterface::getByLoginName(array('login_name' => $username));
     }
     // 构建where
     if (!empty($username) && empty($userInfo)) {
         $where = false;
     } else {
         $where = array();
         if (!empty($userInfo)) {
             $where[] = array('user_id', '=', $userInfo['id']);
         }
         if (!empty($status) && $status != -1) {
             $where[] = array('hidden', '=', $status - 1);
         }
         if (!empty($title)) {
             $where[] = array('title', 'LIKE', "%{$title}%");
         }
     }
     $order = array('listing_status' => 'DESC', 'refresh_at' => 'DESC', 'id' => 'DESC');
     $offset = ($page - 1) * $pageSize;
     $setList = OjProblemSetInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = 0;
     if (!empty($setList)) {
         $allCount = OjProblemSetInterface::getCount($where);
     }
     foreach ($setList as &$setInfo) {
         $globalIds = (array) json_decode($setInfo['problem_set'], true);
         $setInfo['count'] = count($globalIds);
     }
     // 获取用户
     $userIds = array_unique(array_column($setList, 'user_id'));
     $userHash = UserCommonInterface::getById(array('id' => $userIds));
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
     // 输出
     $this->renderFramework(array('html' => $html, 'setList' => $setList, 'userHash' => $userHash), 'set/list.php');
 }