Beispiel #1
0
 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());
 }
Beispiel #2
0
 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);
 }
Beispiel #3
0
 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;
 }
Beispiel #4
0
 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()
 {
     $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;
 }
Beispiel #7
0
 public function indexAction()
 {
     $this->view->title = "Submit a solution";
     $this->view->problems = ProblemTable::get_problem_list(webconfig::getContestId(), 0, 100);
     $this->view->problem_code = $this->_request->get("probid");
 }