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}"); } } } }
public function setUp () { global $test_nonadmin_uid; global $test_non_general_contest, $test_non_general_contest_problem; /* create a contest */ $this->contest = $test_non_general_contest; $this->problem = $test_non_general_contest_problem; webconfig::$multi_contest = true; parent::setUp (); system ("../backend/admin/addcontest.php --id {$this->contest} --name TestContest --start-time '-1 hour' --duration '2 hours' --quiet"); $this->login ($test_nonadmin_uid); }
public function setUp () { global $test_nonadmin_uid1; global $test_non_general_contest; global $test_non_general_contest_problem; $this->contest = $test_non_general_contest; $this->problem = $test_non_general_contest_problem; parent::setUp (); /* create a contest */ system ("../backend/admin/addcontest.php --id {$this->contest} --name TestContest --start-time '-10 minutes' --duration '9 minutes' --quiet"); webconfig::$multi_contest = true; }
public function indexAction() { if (webconfig::getContest()->isQueuePrivate()) { $user = User::factory(Zend_Auth::getInstance()->getIdentity()); if (!$user || !$user->isAdmin()) { $this->_forward("privacy", "error", NULL, array()); } } $user = $this->_request->get("user"); $prob = $this->_request->get("prob"); $this->view->user = $user; $this->view->prob = $prob; Zend_Loader::loadClass("RanklistModel"); $ranklist = new RanklistModel(); $this->view->ranks = $ranklist->getRanks($user, $prob, webconfig::getContestId()); }
public function indexAction() { $offset = (int) $this->_request->get("offset"); $limit = (int) $this->_request->get("limit"); if (empty($offset)) { $offset = 0; } if (empty($limit)) { $limit = 100; } $user = $this->_request->get("user"); $uid = $this->_request->get("uid"); $problem = $this->_request->get("problem"); $state = $this->_request->get("state"); if (webconfig::getContest()->isQueuePrivate()) { $auth = Zend_Auth::getInstance(); if (!$auth->hasIdentity()) { $this->_forward("login", "error", NULL, array()); } else { $userobj = User::factory($auth->getIdentity()); if (!$userobj->isAdmin() and !isset($uid)) { $this->_forward("privacy", "error", NULL, array()); } } } Zend_Loader::loadClass("Zend_Paginator"); Zend_Loader::loadClass("Zend_Paginator_Adapter_DbSelect"); $db = contestDB::get_zend_db(); $query = $db->select()->from('submissionqueue')->join("users", "submissionqueue.uid = users.uid")->where("owner = ?", webconfig::getContestId())->order("id desc"); if (!empty($user)) { $query = $query->where("users.username = ?", $user); } if (!empty($uid)) { $query = $query->where("users.uid = ?", $uid); } if (!empty($problem)) { $query = $query->where("submissionqueue.problemid = ?", $problem); } if (!empty($state)) { $query = $query->where("submissionqueue.state = ?", $state); } $adapter = new Zend_Paginator_Adapter_DbSelect($query); $this->view->paginator = new Zend_Paginator($adapter); $this->view->paginator->setCurrentPageNumber($this->_getParam('page')); $this->view->paginator->setItemCountPerPage(50); }
public function _buildUrl($url) { /* does this $url need building? */ if (substr($url, 0, 1) != "/") { return $url; } /* fix the $url */ $baseurl = Zend_Controller_Front::getInstance()->getBaseUrl(); if (substr($url, 0, strlen("/public/")) == "/public/") { $url = $this->concat($this->getStaticBaseDirectory(), $url); } else { if (webconfig::getContestId() != "general") { $url = $this->concat("/contests/" . webconfig::getContestId(), $url); } $url = $this->concat($baseurl, $url); } return $url; }
public function indexAction() { $page = $this->getRequest()->get("page"); $contest = Contest::factory(webconfig::getContestId()); if (!$contest) { return; } $xp = $contest->getXPath(); $res = $xp->query("/contest/frontend/page[@id='{$page}']/@href"); $href = $res->item(0)->nodeValue; if (substr($href, 0, 5) == "http:" or substr($href, 0, 6) == "https:") { $this->_redirect($href); } $file = config::getFilename("data/contests/" . $res->item(0)->nodeValue); if (!is_file($file)) { echo "Please edit '{$file}' to view this page."; } else { echo file_get_contents($file); } }
public function indexAction() { $_user = $this->_request->get("user"); if (webconfig::getContest()->isQueuePrivate()) { $user = User::factory(Zend_Auth::getInstance()->getIdentity()); if (!$user || !$user->isAdmin()) { $this->_forward("privacy", "error", NULL, array()); } } if (empty($_user)) { $this->_redirect(webconfig::getContestRelativeBaseUrl()); } /* fillin information from User XML data */ Zend_Loader::loadClass("UserModel"); $userm = new UserModel(); $user = $userm->getRow($_user); $this->view->username = $user->_username; $this->view->inst = $userm->getInstitute($user); $this->view->name = $userm->getMember($user, 0)->name; }
public function indexAction() { $uid = Zend_Auth::getInstance(); if (!$uid->hasIdentity()) { $this->_forward("login", "error", null, array()); return; } $user = User::factory($uid->getIdentity()); $this->contestmodel = new ContestModel(); $this->state = $this->contestmodel->getContestState(webconfig::getContestId()); $is_admin = $user->isAdmin(); if (!$is_admin and $this->state == "pending_result") { $this->_forward("pending", "error", null, array()); return; } $this->view->id = (int) $this->getRequest()->get("id"); $download = $this->getRequest()->get("download"); $this->view->sub = SubmissionTable::get_submission($this->view->id); if (empty($this->view->sub)) { $this->_forward("404", "error"); return; } $this->view->user = Zend_Auth::getInstance()->getIdentity(); $this->view->admin = User::factory($this->view->user)->isAdmin(); if (empty($this->view->sub) or $this->view->user != $this->view->sub->uid and !$this->view->admin) { $this->_forward("illegal", "error"); return; } if ($download == "true") { $this->_helper->layout->disableLayout(); $this->view->download = true; $this->_response->setHeader("Content-Type", "text/src"); } else { $this->view->download = false; } }
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; }
function logoutAction() { $this->log->info(Zend_Auth::getInstance()->getIdentity() . " has logged off."); Zend_Auth::getInstance()->clearIdentity(); $this->_redirect(webconfig::getContestRelativeBaseUrl()); }
public function update2Action() { $this->view->mode = "update"; try { $this->validate(); } catch (Exception $e) { $this->log->info("Error in updated profile: " . $e->getMessage()); $this->error_message = $e->getMessage(); $this->copyToView(); return; } $this->saveXML(); $this->copyToView(); User::factory($this->user)->setPassword($this->password); $this->_redirect(webconfig::getContestRelativeBaseUrl() . "/profile/profile-update-success"); }
public function setUp () { webconfig::$allow_register = false; parent::setUp (); }