From be2491b093b1f0ca430bede679ecbb670041e483 Mon Sep 17 00:00:00 2001 From: cassio Date: Tue, 2 Jul 2013 09:46:45 +0400 Subject: restructuring of boca's git --- old/import.php | 280 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 280 insertions(+) create mode 100644 old/import.php (limited to 'old/import.php') diff --git a/old/import.php b/old/import.php new file mode 100644 index 0000000..45dd4bd --- /dev/null +++ b/old/import.php @@ -0,0 +1,280 @@ +Starting to create the contest
"; + $asep = trim($ar[0]); + $i=1; + + for (; $iContest $nc created
"; + + for (; $i"; + } + + for (; $iSearching for answers
\n"; + $x = trim($ar[$i]); + if (strpos($x, "answ") !== false && strpos($x, "answ") == 0) { + unset($answnumber); + unset($answname); + unset($answyes); + while (strpos($x, "answ") !== false && strpos($x, "answ") == 0) { + $tmp = explode ("=", $x, 2); + switch (trim($tmp[0])) { + case "answernumber": $answnumber =trim($tmp[1]); break; + case "answername": $answname =trim($tmp[1]); break; + case "answeryes": $answyes =trim($tmp[1]); break; + } + $i++; + if ($i>=count($ar)) break; + $x = trim($ar[$i]); + } + if (isset($answnumber) && is_numeric($answnumber) && isset($answname)) { + DBNewAnswer ($nc, $answnumber, $answname, $answyes); + echo "Answer $answnumber created
"; + } + } + } + + for (; $iSearching for languages
\n"; + $x = trim($ar[$i]); + if (strpos($x, "lang") !== false && strpos($x, "lang") == 0) { + unset($langnumber); + unset($langname); + unset($langproblem); + unset($script); + unset($compscript); + unset($langscript); + unset($langcompscript); + unset($langscripthash); + unset($langcompscripthash); + while (strpos($x, "lang") !== false && strpos($x, "lang") == 0) { + $tmp = explode ("=", $x, 2); + switch (trim($tmp[0])) { + case "langnumber": $langnumber =trim($tmp[1]); break; + case "langname": $langname =trim($tmp[1]); break; + case "langproblem": $langproblem =trim($tmp[1]); break; + case "langscripthash": $langscripthash =trim($tmp[1]); break; + case "langscript": $langscript =trim($tmp[1]); + $i++; + for ($j=1; trim($ar[$i]) != "***$asep***"; $j++) { + if(substr($langscript,0,7)!="base64:") $script .= $ar[$i]; + else $script .= trim($ar[$i]); + $i++; + } + if(substr($langscript,0,7)=="base64:") { + $langscript = substr($langscript,7); + $script = base64_decode($script); + } + if(trim($langscripthash) != "" && myshorthash($script) != trim($langscripthash)) + echo "ERROR: Hash of $langscript does not match $langscripthash, ".myshorthash($script)."
\n"; + break; + case "langcompscripthash": $langcompscripthash=trim($tmp[1]); break; + case "langcompscript": $langcompscript =trim($tmp[1]); + $i++; + for ($j=1; trim($ar[$i]) != "***$asep***"; $j++) { + if(substr($langcompscript,0,7)!="base64:") $compscript .= $ar[$i]; + else $compscript .= trim($ar[$i]); + $i++; + } + if(substr($langcompscript,0,7)=="base64:") { + $langcompscript = substr($langcompscript,7); + $compscript = base64_decode($compscript); + } + if(trim($langcompscripthash) != "" && myshorthash($compscript) != trim($langcompscripthash)) + echo "ERROR: Hash of $langcompscript does not match
\n"; + break; + } + $i++; + if ($i>=count($ar)) break; + $x = trim($ar[$i]); + } + if (isset($langnumber) && is_numeric($langnumber) && isset($langname)) { + DBNewLanguage ($nc, + $langnumber, $langname, $langproblem, '', '', + $langshowingoutput, $script, $langscript, $compscript, $langcompscript, 1, 1); + echo "Language $langnumber created
"; + } + } + } + + for (; $iSearching for problems
\n"; + $x = trim($ar[$i]); + if (strpos($x, "prob") !== false && strpos($x, "prob") == 0) { + unset($probnumber); + unset($probname); + unset($probfullname); + unset($probbasename); + unset($probinputfile); + unset($probinputfilehash); + unset($probinputfilepath); + unset($probsolfile); + unset($probsolfilehash); + unset($probsolfilepath); + unset($probdescfile); + unset($probdescfilehash); + unset($probdescfilepath); + unset($probtimelimit); + unset($probcolorname); + unset($probcolor); + while (strpos($x, "prob") !== false && strpos($x, "prob") == 0) { + $tmp = explode ("=", $x, 2); + switch (trim($tmp[0])) { + case "probnumber": $probnumber =trim($tmp[1]); break; + case "probname": $probname =trim($tmp[1]); break; + case "probfullname": $probfullname =trim($tmp[1]); break; + case "probbasename": $probbasename =trim($tmp[1]); break; + case "probtimelimit": $probtimelimit =trim($tmp[1]); break; + case "probcolorname": $probcolorname =trim($tmp[1]); break; + case "probcolor": $probcolor =trim($tmp[1]); break; + case "probinputfilehash": $probinputfilehash =trim($tmp[1]); break; + case "probinputfile": $probinputfile =trim($tmp[1]); + $i++; + for ($j=1; trim($ar[$i]) != "***$asep***"; $j++) { + if(substr($probinputfile,0,7)!="base64:") $probinputfilepath .= $ar[$i]; + else $probinputfilepath .= trim($ar[$i]); + $i++; + } + if(substr($probinputfile,0,7)=="base64:") { + $probinputfile = substr($probinputfile,7); + $probinputfilepath = base64_decode($probinputfilepath); + } + if(trim($probinputfilehash) != "" && myshorthash($probinputfilepath) != trim($probinputfilehash)) + echo "ERROR: Hash of $probinputfile does not match
\n"; + break; + case "probsolfilehash": $probsolfilehash =trim($tmp[1]); break; + case "probsolfile": $probsolfile =trim($tmp[1]); + $i++; + for ($j=1; trim($ar[$i]) != "***$asep***"; $j++) { + if(substr($probsolfile,0,7)!="base64:") $probsolfilepath .= $ar[$i]; + else $probsolfilepath .= trim($ar[$i]); + $i++; + } + if(substr($probsolfile,0,7)=="base64:") { + $probsolfile = substr($probsolfile,7); + $probsolfilepath = base64_decode($probsolfilepath); + } + if(trim($probsolfilehash) != "" && myshorthash($probsolfilepath) != trim($probsolfilehash)) + echo "ERROR: Hash of $probsolfile does not match
\n"; + break; + case "probdescfilehash": $probdescfilehash=trim($tmp[1]); break; + case "probdescfile": $probdescfile =trim($tmp[1]); + $i++; + for ($j=1; trim($ar[$i]) != "***$asep***"; $j++) { + if(substr($probdescfile,0,7)!="base64:") $probdescfilepath .= $ar[$i]; + else $probdescfilepath .= trim($ar[$i]); + $i++; + } + if(substr($probdescfile,0,7)=="base64:") { + $probdescfile = substr($probdescfile,7); + $probdescfilepath = base64_decode($probdescfilepath); + } + if(trim($probdescfilehash) != "" && myshorthash($probdescfilepath) != trim($probdescfilehash)) + echo "ERROR: Hash of $probdescfile does not match
\n"; + break; + } + $i++; + if ($i>=count($ar)) break; + $x = trim($ar[$i]); + } + if (isset($probnumber) && is_numeric($probnumber) && isset($probname) && + isset($probfullname) && isset($probbasename) && + isset($probtimelimit) && isset($probcolorname) && isset($probcolor)) { + DBNewProblem ($nc, + $probnumber, $probname, $probfullname, $probbasename, $probinputfile, + $probinputfilepath, $probsolfile, $probsolfilepath, 'f', $probdescfile, $probdescfilepath, + $probtimelimit, $probcolorname, $probcolor, 1, 1, 1); + echo "Problem $probnumber created
"; + } + } + } + } + echo ""; + exit; +} +?> +
+
+
+To import a pre-defined contest, just fill in the import file field.
+
+
+ +
+ + + + + +
Import file: + +
+
+ +
+ + +
+
+ + + + -- cgit v1.2.3