Esempio n. 1
0
 public function uploadAction()
 {
     if (!$this->_request->isPost()) {
         $this->_redirect(webconfig::getContestRelativeBaseUrl());
     }
     $auth = Zend_Auth::getInstance();
     if (!$auth->hasIdentity()) {
         $this->_redirect(webconfig::getContestRelativeBaseUrl() . "auth/login");
     }
     $lang = $this->_request->get("lang");
     $prob = $this->_request->get("probid");
     $source = $_FILES['source']['tmp_name'];
     if (empty($lang) or empty($prob) or empty($source)) {
         $this->_redirect(webconfig::getContestRelativeBaseUrl() . "/error/illegal");
         return;
     }
     $id = UploadSubmission::upload($auth->getIdentity(), $prob, $lang, $source, ProblemTable::get_problem($prob)->owner);
     if ($id == -1) {
         $this->view->message = "You are trying to submit the same " . "solution twice!";
     } else {
         if ($id == -2) {
             $this->view->message = "You have exceeded the submission " . "limit on this problem.";
         } else {
             if ($id < 0) {
                 $this->view->message = "Unknown error";
             } else {
                 $this->_redirect(webconfig::getContestRelativeBaseUrl() . "submit/success/{$id}");
             }
         }
     }
 }
Esempio n. 2
0
 public function problem($problem)
 {
     $prob = ProblemTable::get_problem($problem);
     return $this->view->link("/problems/" . $prob->getId(), $prob->getId(), array("title" => $prob->getNickname()));
 }
Esempio n. 3
0
 function validateProblemAccess()
 {
     $this->view->problem_code = $this->_request->get("probid");
     $this->view->prob = $prob = ProblemTable::get_problem("{$this->view->problem_code}");
     if (empty($prob) || $prob->owner != webconfig::getContestId()) {
         $this->_forward("404", "error");
         return false;
     }
     return true;
 }