コード例 #1
0
ファイル: Share.php プロジェクト: thezawad/vakuum
 public static function uploadTestdata($judger, $data_config)
 {
     $prob_name = $data_config['name'];
     $testdata_path = MDL_Config::getInstance()->getVar('judger_testdata') . $prob_name . '/';
     $dest_path = $judger->getConfig()->getTestdataPath() . $prob_name . '/';
     if (!file_exists($dest_path) || !is_dir($dest_path)) {
         if (@mkdir($dest_path) === false) {
             throw new MDL_Exception_Judge_Share(MDL_Exception_Judge_Share::TESTDATA_UPLOAD);
         }
         chmod($dest_path, 0755);
     }
     unset($data_config['id']);
     unset($data_config['title']);
     $xml = BFL_XML::Array2XML($data_config);
     if (file_put_contents($dest_path . "config.xml", $xml) === false) {
         throw new MDL_Exception_Judge_Share(MDL_Exception_Judge_Share::TESTDATA_UPLOAD);
     }
     if ($testdata_path == $dest_path) {
         return;
     }
     if ($data_config['checker']['type'] == 'custom') {
         //Upload checker
         $checker_source = $data_config['checker']['custom']['source'];
         $checker_file = $testdata_path . $checker_source;
         $this->copy_file($dest_path . $checker_source, $checker_file);
     }
     //Upload testdatas
     foreach ($data_config['case'] as $item) {
         foreach (array('input', 'output') as $key) {
             $testdata_file = $testdata_path . $item[$key];
             $this->copy_file($dest_path . $item[$key], $testdata_file);
         }
     }
 }
コード例 #2
0
ファイル: Data.php プロジェクト: thezawad/vakuum
 /**
  * edit
  * @param array $data_config
  * @return void
  */
 public static function edit($data_config)
 {
     $prob_id = $data_config['id'];
     $data_config = self::format($data_config);
     $data_config['version'] = time();
     $data_config = BFL_XML::Array2XML($data_config);
     $prob_meta = new MDL_Problem_Meta($prob_id);
     $prob_meta->setVar('data_config', $data_config);
     $prob_meta->setVar('verified', 0);
 }
コード例 #3
0
ファイル: run.php プロジェクト: thezawad/vakuum
function writeExecutorConfigFile($program, $time_limit, $memory_limit, $output_limit, $openfile)
{
    $prob_config = array('program' => $program, 'file' => $openfile);
    if ($time_limit != 0) {
        $prob_config['time_limit'] = $time_limit;
    }
    if ($memory_limit != 0) {
        $prob_config['memory_limit'] = $memory_limit;
    }
    if ($output_limit != 0) {
        $prob_config['output_limit'] = $output_limit;
    }
    $xml = BFL_XML::Array2XML($prob_config);
    file_put_contents("prob.xml", $xml);
}
コード例 #4
0
ファイル: FTP.php プロジェクト: thezawad/vakuum
 public static function uploadTestdata($judger, $data_config)
 {
     $prob_name = $data_config['name'];
     $testdata_path = MDL_Config::getInstance()->getVar('judger_testdata') . $prob_name . '/';
     $temp_file = tempnam(sys_get_temp_dir(), 'Vakuum');
     unset($data_config['id']);
     unset($data_config['title']);
     $xml = BFL_XML::Array2XML($data_config);
     file_put_contents($temp_file, $xml);
     $pftp = self::connect($judger);
     if (ftp_chdir($pftp, $judger->getConfig()->getTestdataPath()) === false) {
         throw new MDL_Exception_Judge_FTP(MDL_Exception_Judge_FTP::TESTDATA_UPLOAD);
     }
     if (@ftp_chdir($pftp, $prob_name) === false) {
         ftp_mkdir($pftp, $prob_name);
         ftp_chmod($pftp, 0755, $prob_name);
         ftp_chdir($pftp, $prob_name);
     }
     //Upload config.xml
     if (ftp_put($pftp, 'config.xml', $temp_file, FTP_BINARY) === false) {
         throw new MDL_Exception_Judge_FTP(MDL_Exception_Judge_FTP::TESTDATA_UPLOAD);
     }
     if ($data_config['checker']['type'] == 'custom') {
         //Upload checker
         $checker_source = $data_config['checker']['custom']['source'];
         $checker_file = $testdata_path . $checker_source;
         if (ftp_put($pftp, $checker_source, $checker_file, FTP_BINARY) === false) {
             throw new MDL_Exception_Judge_FTP(MDL_Exception_Judge_FTP::TESTDATA_UPLOAD);
         }
     }
     //Upload testdatas
     foreach ($data_config['case'] as $item) {
         foreach (array('input', 'output') as $key) {
             $testdata_file = $testdata_path . $item[$key];
             if (ftp_put($pftp, $item[$key], $testdata_file, FTP_BINARY) === false) {
                 throw new MDL_Exception_Judge_FTP(MDL_Exception_Judge_FTP::TESTDATA_UPLOAD);
             }
         }
     }
     ftp_close($pftp);
 }
コード例 #5
0
ファイル: Edit.php プロジェクト: thezawad/vakuum
 protected static function encodeConfig($config)
 {
     return BFL_XML::Array2XML($config);
 }
コード例 #6
0
ファイル: problem.php プロジェクト: thezawad/vakuum
 public function ACT_dodispatch()
 {
     if (isset($_POST['ajax'])) {
         $ajax = true;
     }
     //TODO: add non-ajax support
     if (!isset($_POST['prob_id']) || !isset($_POST['judger_id'])) {
         die('interface error');
     }
     $prob_id = $_POST['prob_id'];
     $judger_id = $_POST['judger_id'];
     $prob_names = MDL_Problem_Show::getProblemName($prob_id);
     $data_config = MDL_Problem_Data::getDataConfig($prob_id, $prob_names['prob_name'], $prob_names['prob_title']);
     $verify_result = MDL_Problem_Dispatch::verify($data_config);
     if ($verify_result['overall'] != '') {
         die('problem not verified');
     }
     $rs = MDL_Problem_Dispatch::transmitTestdata($judger_id, $data_config);
     if ($rs['version'] == $data_config['version'] && $rs['hash_code'] == $verify_result['hash_code']) {
         $result['overall'] = "";
         if ($data_config['checker']['type'] == 'custom' && $data_config['checker']['custom']['language'] != '') {
             if (!isset($rs['checker_compile']) || $rs['checker_compile'] != 1) {
                 $result['overall'] = "checker_compile";
             }
         }
     } else {
         $result['overall'] = "verify";
     }
     echo BFL_XML::Array2XML($result);
 }
コード例 #7
0
ファイル: Record.php プロジェクト: thezawad/vakuum
 public static function recordExecute($info)
 {
     $newCase = $info;
     unset($newCase['record_id']);
     $record_meta = new MDL_Record_Meta($info['record_id']);
     if ($record_meta->getVar('status') == self::STATUS_STOPPED) {
         return;
     }
     if (isset($record_meta->result)) {
         $result = $record_meta->result;
         $result = BFL_XML::XML2Array($result);
     } else {
         $result = array();
     }
     if (isset($result['execute']['case'])) {
         if (!isset($result['execute']['case'][0])) {
             $result['execute']['case'] = array($result['execute']['case']);
         }
         $result['execute']['case'][] = $newCase;
     } else {
         $result['execute']['case'] = $newCase;
     }
     $result = BFL_XML::Array2XML($result);
     $record_meta->setVar('result', $result);
     $record_meta->setVar('result_text', $info['case_id']);
     $record_meta->setVar('status', self::STATUS_RUNNING);
 }