Пример #1
0
 /**
  * Runs all the set hooks for the given problem. 
  */
 function run_hooks()
 {
     $sub = SubmissionTable::get_submission($this->id);
     $this->info['problem'] = $sub->problemid;
     $xml = new DOMDocument();
     $xml_path = ProblemTable::get_problem_xml_file($sub->problemid);
     if (empty($xml_path) or !is_file($xml_path)) {
         return;
     }
     $xml->load($xml_path);
     $xp = new DOMXPath($xml);
     $res = $xp->query("/problem/hook");
     foreach ($res as $hook) {
         $this->run_single_hook($hook->nodeValue);
     }
     /* run hooks on the submission file */
     $xml = new DOMDocument();
     $xml_path = SubmissionTable::get_submission_xml_file($this->id);
     if (empty($xml_path) or !is_file($xml_path)) {
         return;
     }
     $xml->load($xml_path);
     $xp = new DOMXPath($xml);
     $res = $xp->query("/submission/hook");
     foreach ($res as $hook) {
         $this->run_single_hook($hook->nodeValue);
     }
 }
Пример #2
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}");
             }
         }
     }
 }
Пример #3
0
 public function problem($problem)
 {
     $prob = ProblemTable::get_problem($problem);
     return $this->view->link("/problems/" . $prob->getId(), $prob->getId(), array("title" => $prob->getNickname()));
 }
Пример #4
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;
 }
Пример #5
0
#!/usr/bin/env php
<?php 
/**
 * Copyright 2009 Chennai Mathematical Institute
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @file   fsck.problem.php
 * @author Arnold Noronha <*****@*****.**>
 */
require_once dirname(__FILE__) . "/../config.inc";
require_once "lib/problems.inc";
$p = ProblemTable::fsckProblem($argv[1]);
if (!$p) {
    echo "{$argv[1]} failed check.\n";
    exit(1);
} else {
    echo "{$argv[1]} seems clean.\n";
}