-
Notifications
You must be signed in to change notification settings - Fork 18
/
judge.php
51 lines (33 loc) · 1.04 KB
/
judge.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
50
51
<?php
/**
* @link http://restunited.com/docs/3bqbx05520d0
*/
require_once 'HackerRank/HackerRank.php';
$l=$_POST['lan'];
$tc=$_POST['in'];
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fu"]["name"]);
$uploadOk = 1;
if(move_uploaded_file($_FILES["fu"]["tmp_name"], $target_file))
{
$fname=basename( $_FILES["fu"]["name"]);
//echo "$fname";
}
// Get your key at https://www.hackerrank.com/api/docs
$api_key = "hackerrank|506454-980|3672eeb10462853e8c7fb2ea12b9d6082a71c97e";
$source = file_get_contents("uploads/$fname");
$lang = $l; // 1 = c, 2 = cpp
$testcases = "[\"1 2\", \"3 4\",\"0 0\"]";
echo "$tc";
$format = "JSON";
$wait = "true";
try {
$api_client = new HackerRank\APIClient();
$checker_api = new HackerRank\CheckerAPI($api_client);
$response = $checker_api->submission($api_key, $source, $lang, $testcases, $format);
//var_dump($response);
echo"<pre>".print_r($response,1)."</pre>";
}
catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}