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}");
             }
         }
     }
 }
Exemple #2
0
	/**
	 * @dataProvider provider
	 */

	public function testUploadHashWorks ($user, $prob, $lang, $source, $owner, $score)
	{
		config::$enable_hash_test = true;
                $a = UploadSubmission::upload ($user, $prob, $lang, $source, $owner);
                $b = UploadSubmission::upload ($user, $prob, $lang, $source, $owner);

		$user = User::factory ($user);

		if (!$user->isAdmin())
			$this->assertEquals (-1, $b);
		else
			$this->assertGreaterThan (0, $b);
		
	}