-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproblemdata.php
More file actions
39 lines (29 loc) · 1.06 KB
/
Copy pathproblemdata.php
File metadata and controls
39 lines (29 loc) · 1.06 KB
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
<?php
//CORS Headers
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: *");
//HTTP inputs
$rest_json = file_get_contents("php://input");
$_POST = json_decode($rest_json, true);
$id = $_POST['id'];
//connecting to SQL Database
$con = mysqli_connect("localhost", "root", "", "othscmsdb");
//looking for matching username
$sql = "SELECT * FROM submissions where id = \"$id\"";
$res = mysqli_query($con, $sql);
//checking if password is correct
if(mysqli_num_rows($res)>0){
while($row = mysqli_fetch_assoc($res)){
//$output = shell_exec($row['filePath']);
//$output = array();
$file=$row['filePath'];
exec('javac '.$file);
exec("java $file", $output);
$code = file($row['filePath']);
$response = array('team' => $row['user'], 'filePath' => $row['filePath'], 'systemTime' => $row['systemTime'], 'code' => $code,'output' => $output);
echo json_encode($response);
exit;
}
}
echo "No Such Problem Found";
?>