コード例 #1
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);
 }
コード例 #2
0
ファイル: Auth.php プロジェクト: thezawad/vakuum
 public static function getLoginedUserInformation()
 {
     $acl = MDL_ACL::getInstance();
     $user_id = $acl->getUser()->getID();
     if ($user_id != 0) {
         try {
             $user = MDL_User_Detail::getUser($user_id);
             BFL_Register::setVar('personal', $user);
             if (isset($user['identity'])) {
                 $acl->setIdentity($user['identity']);
             }
             if (isset($user['preference'])) {
                 $preference = BFL_XML::XML2Array($user['preference']);
                 BFL_Register::setVar('user_preference', $preference);
             }
         } catch (MDL_Exception_User $e) {
             if ($e->testDesc(MDL_Exception_User::FIELD_USER, MDL_Exception_User::INVALID_USER_ID)) {
                 $acl->resetSession();
                 $acl->initialize(SESSION_PREFIX, 'guest');
             } else {
                 throw $e;
             }
         }
     }
 }
コード例 #3
0
ファイル: Info.php プロジェクト: thezawad/vakuum
 protected function decodeConfig($config_string)
 {
     $rs = BFL_XML::XML2Array($config_string);
     if (!isset($rs['problems'][0])) {
         $rs['problems'] = array($rs['problems']);
     }
     return $rs;
 }
コード例 #4
0
ファイル: Config.php プロジェクト: thezawad/vakuum
 public function __construct($judger_config = '')
 {
     if ($judger_config != '') {
         $this->config = BFL_XML::XML2Array($judger_config);
     } else {
         $this->config = array('url' => '', 'public_key' => '', 'upload' => 'ftp');
     }
 }
コード例 #5
0
ファイル: Result.php プロジェクト: thezawad/vakuum
 public function __construct($record_meta)
 {
     if (isset($record_meta->result)) {
         $result = $record_meta->result;
         $result = BFL_XML::XML2Array($result);
     } else {
         $result = array();
     }
     $this->result = $result;
 }
コード例 #6
0
ファイル: Data.php プロジェクト: thezawad/vakuum
 public static function getDataConfig($prob_id, $prob_name, $prob_title)
 {
     $prob_meta = new MDL_Problem_Meta($prob_id);
     $data_config_xml = $prob_meta->getVar('data_config');
     if ($data_config_xml != '') {
         $data_config = BFL_XML::XML2Array($data_config_xml);
     } else {
         $data_config = array();
     }
     $new_data_config = array('id' => $prob_id, 'name' => $prob_name, 'title' => $prob_title, 'input' => isset($data_config['input']) ? $data_config['input'] : "", 'output' => isset($data_config['output']) ? $data_config['output'] : "", 'checker' => isset($data_config['checker']) ? $data_config['checker'] : "std_checker", 'time_limit' => isset($data_config['time_limit']) ? $data_config['time_limit'] : "", 'memory_limit' => isset($data_config['memory_limit']) ? $data_config['memory_limit'] : "", 'output_limit' => isset($data_config['output_limit']) ? $data_config['output_limit'] : "");
     $new_data_config['checker'] = array('name' => isset($data_config['checker']['name']) ? $data_config['checker']['name'] : "std_checker", 'type' => isset($data_config['checker']['type']) ? $data_config['checker']['type'] : "standard", 'custom' => array('source' => isset($data_config['checker']['custom']['source']) ? $data_config['checker']['custom']['source'] : "", 'language' => isset($data_config['checker']['custom']['language']) ? $data_config['checker']['custom']['language'] : ""));
     if (isset($data_config['additional_file'])) {
         if (!is_array($data_config['additional_file'])) {
             $data_config['additional_file'] = array($data_config['additional_file']);
         }
         $new_data_config['additional_file'] = $data_config['additional_file'];
     } else {
         $new_data_config['additional_file'] = array();
     }
     if (isset($data_config['case'])) {
         if (!isset($data_config['case'][0])) {
             $data_config['case'] = array($data_config['case']);
         }
         foreach ($data_config['case'] as $item) {
             $newcase = array();
             foreach (array('input', 'output', 'time_limit', 'memory_limit', 'output_limit') as $key) {
                 if (isset($item[$key])) {
                     $newcase[$key] = $item[$key];
                 }
             }
             $new_data_config['case'][] = $newcase;
         }
     } else {
         $new_data_config['case'] = array();
     }
     if (isset($data_config['version'])) {
         $new_data_config['version'] = $data_config['version'];
     } else {
         $new_data_config['version'] = 0;
     }
     return $new_data_config;
 }
コード例 #7
0
ファイル: data.php プロジェクト: thezawad/vakuum
function getTestdataVersion($prob_name)
{
    $path = Config::getInstance()->getVar('path');
    $testdata_path = $path['testdata'] . $prob_name . '/';
    $rs['version'] = 0;
    $rs['hash_code'] = '';
    if (file_exists($testdata_path . 'config.xml')) {
        $xml = file_get_contents($testdata_path . 'config.xml');
        $data_config = BFL_XML::XML2Array($xml);
        if (!isset($data_config['version']) || $data_config['version'] == 0) {
            $rs['version'] = 0;
        } else {
            $rs['version'] = $data_config['version'];
        }
        if ($data_config['checker']['type'] == 'custom') {
            if (!file_exists($testdata_path . $data_config['checker']['name'])) {
                $rs['version'] = -1;
            }
        }
        $hash_code = '';
        if ($data_config['checker']['type'] == 'custom') {
            $checker_file = $testdata_path . $data_config['checker']['custom']['source'];
            if (file_exists($checker_file)) {
                $hash_code .= sha1_file($checker_file, true);
            }
        }
        foreach ($data_config['case'] as $item) {
            $input_file = $testdata_path . $item['input'];
            $output_file = $testdata_path . $item['output'];
            if (file_exists($input_file)) {
                $hash_code .= sha1_file($input_file, true);
            }
            if (file_exists($output_file)) {
                $hash_code .= sha1_file($output_file, true);
            }
        }
        $hash_code = sha1($hash_code);
        $rs['hash_code'] = $hash_code;
    }
    return $rs;
}
コード例 #8
0
ファイル: Show.php プロジェクト: thezawad/vakuum
 /**
  * Ger Problem
  * @param string $sql_where
  * @param string $param
  * @return array Problem
  */
 private static function getProblemAbstract($sql_where, $param)
 {
     $db = BFL_Database::getInstance();
     $stmt = $db->factory('select * from ' . DB_TABLE_PROB . ' ' . $sql_where);
     $stmt->bindParam(':param', $param);
     $stmt->execute();
     $rs = $stmt->fetch();
     if (empty($rs)) {
         throw new MDL_Exception_Problem(MDL_Exception_Problem::NOTFOUND);
     }
     $problem = $rs;
     $prob_id = $problem['prob_id'];
     $prob_meta = new MDL_Problem_Meta($prob_id);
     $rs = $prob_meta->getAll();
     $problem = array_merge($problem, $rs);
     $problem['data_config'] = BFL_XML::XML2Array($problem['data_config']);
     if (!isset($problem['data_config']['case'][0])) {
         $problem['data_config']['case'] = array($problem['data_config']['case']);
     }
     return $problem;
 }
コード例 #9
0
ファイル: MDL_Problem.php プロジェクト: thezawad/vakuum
 public function getInfo()
 {
     if ($this->prob_info == NULL) {
         $problem = $this->getProblemMeta()->getAll();
         $problem['data_config'] = BFL_XML::XML2Array($problem['data_config']);
         if (!isset($problem['data_config']['case'][0])) {
             $problem['data_config']['case'] = array($problem['data_config']['case']);
         }
         $this->prob_info = $problem;
     }
     return $this->prob_info;
 }
コード例 #10
0
ファイル: config.php プロジェクト: thezawad/vakuum
 protected function __construct()
 {
     $xml = file_get_contents("config.xml");
     $this->config = BFL_XML::XML2Array($xml);
 }
コード例 #11
0
ファイル: run.php プロジェクト: thezawad/vakuum
function readTestdataConfig($file_path)
{
    $xml = file_get_contents($file_path);
    $_array = BFL_XML::XML2Array($xml);
    return $_array;
}