Please Login First!"; exit(1); } if (isset($OJ_LANG)) { require_once("../lang/$OJ_LANG.php"); } require_once ("../include/const.inc.php"); require_once ("../include/problem.php"); ?>
  - Import Offline ...
"); $j=mb_strpos($Node,""); return mb_substr($Node,$i+$len+2,$j-($i+$len+2)); } function get_extension($file) { $info = pathinfo($file); return $info['extension']; } function getAttribute($Node, $TagName,$attribute) { return $Node->children()->$TagName->attributes()->$attribute; } function hasProblem($title) { //return false; $sql = "SELECT problem_id FROM problem WHERE title=?"; $result = pdo_query($sql, $title); $ret=0; if (isset($result[0])&&isset($result[0][0])) $ret=$result[0][0]; //echo "row->$rows_cnt"; return $ret; } function mkpta($pid,$prepends,$node) { $language_ext = $GLOBALS['language_ext']; $OJ_DATA = $GLOBALS['OJ_DATA']; foreach ($prepends as $prepend) { $language = $prepend->attributes()->language; $lang = getLang($language); $file_ext = $language_ext[$lang]; $basedir = "$OJ_DATA/$pid"; $file_name = "$basedir/$node.$file_ext"; file_put_contents($file_name,$prepend); } } function import_dir($json) { global $OJ_DATA,$OJ_SAE,$OJ_REDIS,$OJ_REDISSERVER,$OJ_REDISPORT,$OJ_REDISQNAME,$domain,$DOMAIN; $qduoj_problem=json_decode($json); echo( $qduoj_problem->{'problem'}->{'title'})."
"; $title = $qduoj_problem->{'problem'}->{'title'}; $time_limit = floatval($qduoj_problem->{'problem'}->{'timeLimit'}); $unit = "ms"; //echo $unit; if ($unit=='ms') $time_limit /= 1000; $memory_limit = floatval($qduoj_problem->{'problem'}->{'memoryLimit'}); $unit = "M"; if ($unit=='kb') $memory_limit /= 1024; $description = $qduoj_problem->{'problem'}->{'description'}; $input = $qduoj_problem->{'problem'}->{'input'}; $output = $qduoj_problem->{'problem'}->{'output'}; $sample_input = strip($qduoj_problem->{'problem'}->{'examples'},"input"); $sample_output = strip($qduoj_problem->{'problem'}->{'examples'},"output"); // echo $sample_input."
"; // echo $sample_output; $hint = $qduoj_problem->{'problem'}->{'hint'}; $source = $qduoj_problem->{'problem'}->{'source'}; $spj=0; $pid = addproblem($title, $time_limit, $memory_limit, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj, $OJ_DATA); return $pid; } if (!isset($_FILES ["offline"])||$_FILES ["offline"] ["error"] > 0) { echo "  - Error: File size is too big, change in PHP.ini
"; echo $MSG_OFFLINE_ZIP_IMPORT; ?>
.zip
	+ data
	|   + problem1
	|   |      + 1.in
	|   |      + 1.out
	|   |      + 2.in
	|   |      + 2.out
	|   |
	|   + problem2
	|   |
	|   ......
	+ source   
	     + student1
	     |    + problem1
	     |       + problem1.cpp
	     |    + problem2
	     |       + problem2.cpp
	     |
	     + student2
	     |    + problem1
	     |       + problem1.cpp
	     |    + problem2
	     |       + problem2.cpp
	     |
	     ......
"; $plist=""; $i=0; $sql_1 = "INSERT INTO `contest_problem`(`contest_id`,`problem_id`,`num`) VALUES (?,?,?)"; for(; $i0){ $problems[$problem]=$pid; $sql_1 = "INSERT INTO `contest_problem`(`contest_id`,`problem_id`,`num`) VALUES (?,?,?)"; pdo_query($sql_1,$cid,$pid,$nextNum); $nextNum++; } } if(isset($nums[$problem])&&isset($problems[$problem])){ $num=$nums[$problem]; $pid=$problems[$problem]; if( $OJ_OFFLINE_ZIP_CCF_DIRNAME && $pdname!=$student && $pdname!=$problem){ $file_content.="\nThe dirname of this file is NOT qualified. Will be rated as 0 point!"; } $len=strlen($file_content); $sql = "INSERT INTO solution(problem_id,user_id,contest_id,num,nick,in_date,language,ip,code_length,result) VALUES(?,?,?,?,?,NOW(),?,'127.0.0.1',?,14)"; $insert_id = pdo_query($sql, $pid,$student,$cid,$num,$student, 1 , $len); // echo "submiting$language.....$insert_id"; $sql = "INSERT INTO `source_code`(`solution_id`,`source`) VALUES(?,?)"; pdo_query($sql ,$insert_id, $file_content); $sql = "INSERT INTO `source_code_user`(`solution_id`,`source`) VALUES(?,?)"; $ret=pdo_query($sql, $insert_id, $file_content); if($ret<0){ echo "

$student - $problem

- 非法字符,提交失败
"; echo " - 尝试转码
"; $file_content=mb_convert_encoding($file_content, "utf8", "gbk"); $sql = "INSERT INTO `source_code`(`solution_id`,`source`) VALUES(?,?)"; pdo_query($sql ,$insert_id, $file_content); $sql = "INSERT INTO `source_code_user`(`solution_id`,`source`) VALUES(?,?)"; $ret=pdo_query($sql, $insert_id, $file_content); if($ret<0){ pdo_query("delete from solution where solution_id=?",$insert_id); echo " - 转码失败,提交无效
"; }else{ echo " - 转码成功
"; } } pdo_query("UPDATE solution SET result=1 WHERE solution_id=?", $insert_id); pdo_query("UPDATE problem SET submit=submit+1 WHERE problem_id=?", $pid); } } } if (isset($OJ_UDP) && $OJ_UDP) { trigger_judge(); } zip_entry_close($dir_resource); } } zip_close($resource); unlink ( $_FILES ["offline"] ["tmp_name"] ); system ("rmdir $tempdir"); }else{ echo " zip file Only
\n"; } } ?>