aboutsummaryrefslogtreecommitdiff
path: root/src/logroot.php
diff options
context:
space:
mode:
authorCassio de Campos <cassiopc@gmail.com>2017-08-12 17:46:04 +0000
committerCassio de Campos <cassiopc@gmail.com>2017-08-12 17:46:04 +0000
commit1a7aa506cf7c239890fab96fd024640b1b712eb8 (patch)
tree67376e7230b180cab9d8f8cc986cd56ffb09589e /src/logroot.php
parent4a96669616d1600604abfa21da5b410432e5b0a4 (diff)
downloadboca-1a7aa506cf7c239890fab96fd024640b1b712eb8.tar.gz
boca-1a7aa506cf7c239890fab96fd024640b1b712eb8.zip
scripts for logging root activity and bug fix of autojudge
Diffstat (limited to 'src/logroot.php')
-rw-r--r--src/logroot.php56
1 files changed, 56 insertions, 0 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;
+?>