forked from BNUACM/bnuoj-web-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error_rejudge.php
55 lines (48 loc) · 1.59 KB
/
error_rejudge.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
52
53
54
55
<?php
include("conn.php");
$runid = $_POST['runid'];
if ($runid=="") {
echo "Unable to rejudge.";
die();
}
$sql="select pid,result,contest_belong,jnum from status where runid='$runid'";
$que = mysql_query($sql);
if (!$que) {
echo "Unable to rejudge.";
die();
}
list($pid,$result,$cid,$jnum)=mysql_fetch_array($que);
if ((!db_user_match($nowuser,$nowpass)||!db_user_isroot($nowuser))&&$jnum>1) {
echo "Unable to rejudge. Already tried ".($jnum+1)." times.";
die();
}
if ($result!="Judge Error"&&$result!="Judge Error (Vjudge Failed)"&&$result!="") {
echo "Unable to rejudge.";
die();
}
$ispretest=true;
if ($cid=="0"||!db_contest_has_cha($cid)||db_contest_passed($cid)) $ispretest=false;
$host="localhost";
/*if (db_problem_isvirtual($pid))*/ $port=$vserver_port;
/*else {
echo "Unable to rejudge.";
die();
}*/
list($vname)=@mysql_fetch_array(mysql_query("select vname from problem where pid=$pid"));
$sql_r = "update status set result='Rejudging',jnum=jnum+1 where runid='$runid' ";
$que_r = mysql_query($sql_r);
$fp = fsockopen($host,$port,$errno, $errstr);
if (!$fp) {
echo "<br>$errno ($srrstr) </br>\n";
}
else {
if (!$ispretest) $msg=$reerrorstring."\n".$runid."\n".$vname;
else $msg=$pretest_string."\n".$runid."\n".$vname;
if (fwrite($fp,$msg)===FALSE) {
echo "<br>can not send msg</br>";
exit;
}
fclose($fp);
}
echo $runid." has been sent to Rejudge.";
?>