Exemplo n.º 1
0
 public function ajaxSubmitAction()
 {
     $setId = Request::getPOST('set-id');
     $title = trim(Request::getPOST('title'));
     $refreshAt = strtotime(trim(Request::getPOST('refresh-at')));
     if (empty($setId)) {
         $this->renderError('参数错误!');
     }
     if (empty($title) || mb_strlen($title, 'utf8') > 50) {
         $this->renderError('标题必填,限制50个字以内!');
     }
     $currentDay = intval(time() / 86400) * 86400 + 86400;
     if (empty($refreshAt) || $refreshAt > $currentDay) {
         $this->renderError('刷新时间不能超过今天!');
     }
     $setInfo = OjProblemSetInterface::getById(array('id' => $setId));
     if (empty($setInfo)) {
         $this->renderError('专题不存在!');
     }
     // 属主验证
     if ($setInfo['user_id'] != $this->loginUserInfo['id']) {
         $this->renderError('你没有修改权限!');
     }
     $data = array('id' => $setId, 'title' => $title, 'refresh_at' => $refreshAt);
     OjProblemSetInterface::save($data);
     $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '修改成功!');
     $this->renderAjax(0);
 }
Exemplo n.º 2
0
 public function ajaxStickCancelAction()
 {
     $setId = Request::getPOST('set-id');
     $setInfo = OjProblemSetInterface::getById(array('id' => $setId));
     if (empty($setInfo)) {
         $this->renderError('专题不存在!');
     }
     if (!$setInfo['listing_status']) {
         $this->renderError('已取消置顶!');
     }
     OjProblemSetInterface::cancelStick(array('id' => $setId));
     $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '操作成功!');
     $this->renderAjax(0);
 }
Exemplo n.º 3
0
 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();
     }
     if (!$this->isOjAdmin && $setInfo['hidden'] && Arr::get('id', $this->loginUserInfo['id'], 0) != $setInfo['user_id']) {
         $this->renderError();
     }
     $setInfo['global_ids'] = (array) json_decode($setInfo['problem_set'], true);
     list($rankHash, $mat, $userHash) = OjProblemSetInterface::getRankBoard(array('id' => $setId));
     $this->renderFramework(array('setInfo' => $setInfo, 'rankHash' => $rankHash, 'mat' => $mat, 'userHash' => $userHash), 'set/rank.php');
 }
 public function ajaxRemoveProblemAction()
 {
     $setId = (int) Request::getPOST('set-id');
     $globalId = (int) Request::getPOST('global-id');
     if (empty($setId) || empty($globalId)) {
         $this->renderError('参数错误!');
     }
     $setInfo = OjProblemSetInterface::getById(array('id' => $setId));
     if (empty($setInfo)) {
         $this->renderError('专题不存在!');
     }
     // 属主验证
     if ($this->loginUserInfo['id'] != $setInfo['user_id']) {
         $this->renderError('你没有权限操作!');
     }
     OjProblemSetInterface::removeProblem(array('id' => $setId, 'global_id' => $globalId));
     $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '操作成功');
     $this->renderAjax(0);
 }
Exemplo n.º 5
0
 public function ajaxHideAction()
 {
     // 获取参数
     $setId = Request::getPOST('set-id');
     if (empty($setId)) {
         $this->renderError('参数错误!');
     }
     $setInfo = OjProblemSetInterface::getById(array('id' => $setId));
     if (empty($setInfo)) {
         $this->renderError('专题不存在!');
     }
     // 属主验证
     if ($this->loginUserInfo['id'] != $setInfo['user_id']) {
         $this->renderError('你没有权限操作!');
     }
     if ($setInfo['hidden']) {
         $this->renderError('已经隐藏!');
     }
     // 更新数据
     OjProblemSetInterface::hide(array('id' => $setId));
     $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '操作成功!');
     $this->renderAjax(0);
 }
 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();
     }
     if (!$this->isOjAdmin && $setInfo['hidden'] && $this->loginUserInfo['id'] != $setInfo['user_id']) {
         Cookie::delete('current_set');
         $this->renderError('您没有权限查看!');
     }
     // 设置当前的set
     Cookie::set('current_set', $setId);
     $problemJson = $setInfo['problem_set'];
     $globalIds = (array) json_decode($problemJson, true);
     // 按照$globalIds顺序
     $problemList = OjProblemInterface::getById(array('id' => $globalIds));
     // 获取用户解决的题目
     $userSolution = array();
     if ($this->loginUserInfo) {
         $where = array(array('problem_global_id', 'IN', $globalIds), array('user_id', '=', $this->loginUserInfo['id']));
         $solutionList = OjSolutionInterface::getList(array('where' => $where));
         foreach ($solutionList as $solutionInfo) {
             $globalId = $solutionInfo['problem_global_id'];
             if (!array_key_exists($globalId, $userSolution) || $solutionInfo['result'] == StatusVars::ACCEPTED) {
                 $userSolution[$globalId] = $solutionInfo;
             }
         }
     }
     // userInfo
     $userInfo = UserCommonInterface::getById(array('id' => $setInfo['user_id']));
     $this->renderFramework(array('setInfo' => $setInfo, 'problemList' => $problemList, 'userSolution' => $userSolution, 'userInfo' => $userInfo), 'set/set_problem.php');
 }