public function indexAction()
 {
     $auth = Zend_Auth::getInstance();
     if (!$auth->hasIdentity()) {
         $this->view->error_message = "You need to login to change the contest.";
         return;
     }
     $contest = $this->_request->get("contest");
     $contestM = Contest::factory($contest);
     if (!$contestM->authenticateUser($auth->getIdentity())) {
         $this->view->error_message = "You have not been granted access to this contest. This might be a restricted contest.";
         return;
     }
     $session = new Zend_Session_Namespace(webconfig::$session_namespace);
     $session->contestid = $contest;
     $session->contestname = "Custom Contest";
     $this->_redirect("/");
 }
Beispiel #2
0
 public function getContestState($contestname)
 {
     $contest = Contest::factory((string) $contestname);
     if (empty($contest)) {
         return "before";
     }
     $start = $contest->getContestTime();
     $end = $contest->getContestEndTime();
     $current = time();
     if ($current < $start) {
         return "before";
     }
     if ($current < $end) {
         return "ongoing";
     }
     if (!$contest->isResultDeclared()) {
         return "pending_result";
     }
     return "after";
 }
Beispiel #3
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);
     }
 }
Beispiel #4
0
if (!is_file(get_file_name("data/problems/{$id}/index.html"))) {
    echo "data/problems/{$id}/index.html does not exist. Aborting right now.\n";
    exit(1);
}
if (empty($nick)) {
    $nick = readline("Enter a nickname for the problem: ");
}
$element = $dom->createComment("nickname is also stored for informative purposes only.");
$root->appendChild($element);
$element = $dom->createElement("nick", $nick);
$root->appendChild($element);
if (empty($contest)) {
    $contest = 'general';
}
require_once "lib/contest.inc";
$c = Contest::factory($contest);
if (empty($c)) {
    die("That contest does not exist.\n");
}
if (empty($numcases)) {
    $numcases = 0 + readline("Number of testcases: ");
}
for ($i = 0; $i < $numcases; $i++) {
    $testcase = $dom->createElement("test");
    $def = "data/problems/{$id}/{$namespace}{$i}.in";
    if (!is_file(get_file_name($def))) {
        die("{$def}: not found\n");
    }
    $element = $dom->createElement("inputpath", $def);
    $testcase->appendChild($element);
    $def = "data/problems/{$id}/{$namespace}{$i}.out";