forked from Alex-Tsvetanov/AT-Judge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubmission.php
49 lines (46 loc) · 1.33 KB
/
submission.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
include_once ($_SERVER["DOCUMENT_ROOT"] . "/lib/mysql.php");
$dbname = "judge";
$conn = new MySQL ($dbname);
$sql = "SELECT * FROM `Submissions`";
$result = $conn->query($sql);
$ID = $result->num_rows;
//echo $ID;
//echo "<br><hr><br>";
$CONTEST = $_REQUEST["contest"];
$USER = $_REQUEST["email"];
if ($conn->query ("SELECT * FROM `Users` WHERE `Email`='{$USER}'")->num_rows == 0)
{
echo '<script>alert("Don\'t cheat! Haven\'t got any user with that email!"); window.location = "/queue";</script>';
}
else
{
$CODE = "";
if ($_REQUEST["sourcecode"] == "")
{
//// echo "no code";
//// var_export ($_FILES);
//// var_dump ($_FILES);
//// echo $_FILES['uploadedfile']['tmp_name'];
$CODE = urlencode (file_get_contents ($_FILES['uploadedfile']['tmp_name']));
}
else
{
//// echo "some code lines";
$CODE = urlencode ($_REQUEST["sourcecode"]);
}
////echo $CODE;
$LANG = $_REQUEST["lang"];
$TASK = $_REQUEST["task"];
////echo $CODE;
$sql =
'INSERT INTO `Submissions` (`ID`,`ContestID`,`TaskID`,`UserID` ,`Code`,`Lang`) VALUES (' .
'"' . $ID . '","' . $CONTEST . '","' . $TASK . '","' . $USER . '","' . $CODE . '","' . $LANG .
'");';
;
$result = $conn->query($sql);
echo '<script>window.location = "/queue";</script>';
}
////include ($_SERVER["DOCUMENT_ROOT"] . "/lib/queue.php");
////print_queue ();
?>