aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/logroot.php56
-rwxr-xr-xsrc/private/autojudging.php6
-rw-r--r--src/private/logroot/.placeholder0
3 files changed, 60 insertions, 2 deletions
diff --git a/src/logroot.php b/src/logroot.php
new file mode 100644
index 0000000..fed3d06
--- /dev/null
+++ b/src/logroot.php
@@ -0,0 +1,56 @@
+<?php
+ob_start();
+header ("Expires: " . gmdate("D, d M Y H:i:s") . " GMT");
+header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+header ("Cache-Control: no-cache, must-revalidate");
+header ("Pragma: no-cache");
+header ("Content-Type: text/html; charset=utf-8");
+session_start();
+if (!isset($_POST["comp"])) {
+ session_unset();
+ session_destroy();
+ session_start();
+ echo session_id();
+ exit;
+}
+ob_end_flush();
+
+function sanitizeFilename($text)
+{
+ $text = str_replace("*", "", $text);
+ $text = str_replace("$", "", $text);
+ $text = str_replace(")", "", $text);
+ $text = str_replace("(", "", $text);
+ $text = str_replace(";", "", $text);
+ $text = str_replace("&", "", $text);
+ $text = str_replace("<", "", $text);
+ $text = str_replace(">", "", $text);
+ $text = str_replace("\"", "", $text);
+ $text = str_replace("'", "", $text);
+ $text = str_replace("`", "", $text);
+ $text = addslashes($text);
+ return $text;
+}
+
+function myhash($k) {
+ return hash('sha256',$k);
+}
+
+if(isset($_POST["comp"]) && $_POST["comp"] != "" ) {
+ $name = sanitizeFilename($_POST["comp"]);
+ $password = $_POST["code"];
+ $secrets = file("/var/www/boca/src/private/run-past.config");
+ for($i = 0; $i < count($secrets); $i++) {
+ $secret = explode(' ', $secrets[$i]);
+ $p = myhash($secret[2] . session_id());
+ if($p == $password) {
+ @file_put_contents("/var/www/boca/src/private/logroot/" . $secret[0] . '.' . $name, base64_decode($_POST['data']), LOCK_EX | FILE_APPEND);
+ @file_put_contents("/var/www/boca/src/private/logroot/logroot.log", $name . "|" . $secret[0] . '|' . date(DATE_RFC2822) . "\n", LOCK_EX | FILE_APPEND);
+ echo "ok\n";
+ exit;
+ }
+ }
+}
+echo "incorrect\n";
+exit;
+?>
diff --git a/src/private/autojudging.php b/src/private/autojudging.php
index 5bd45cc..c5b5556 100755
--- a/src/private/autojudging.php
+++ b/src/private/autojudging.php
@@ -461,7 +461,7 @@ if($retval != 0) {
$ex = escapeshellcmd($scriptcomp) ." ".
escapeshellarg($dir . $ds . "team" . $ds . $file)." ".
escapeshellarg($dir . $ds . "output" . $ds . $file)." ".
- escapeshellarg($dir . $ds . "input" . $ds . $file) . " >compout";
+ escapeshellarg($dir . $ds . "input" . $ds . $file) . " >compout 2>&1";
echo "Executing " . $ex . " at " . getcwd() . " for output file $file\n";
if(system($ex, $localretval)===false)
$localretval = -1;
@@ -474,7 +474,9 @@ if($retval != 0) {
fwrite($fp, $dif[$difi]);
if($difi >= 5000) fwrite($fp, "===OUTPUT OF COMPARING SCRIPT TOO LONG - TRUNCATED===\n");
else fwrite($fp, "===OUTPUT OF COMPARING SCRIPT ENDS HERE===\n");
- $answertmp = trim($dif[count($dif)-1]);
+ $answertmp = '';
+ if(count($dif) > 0)
+ $answertmp = substr(trim($dif[count($dif)-1]),0,200);
fclose($fp);
foreach (glob($dir . $ds . '*') as $fne) {
@chown($fne,"nobody");
diff --git a/src/private/logroot/.placeholder b/src/private/logroot/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/private/logroot/.placeholder