PageRenderTime 38ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/boca-1.5.0/src/judge/runeditchief.php

https://bitbucket.org/jorgenio/boca
PHP | 320 lines | 276 code | 19 blank | 25 comment | 75 complexity | d8f3f10508df1222db46558bb83b8542 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. ////////////////////////////////////////////////////////////////////////////////
  3. //BOCA Online Contest Administrator
  4. // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
  5. //
  6. // This program is free software: you can redistribute it and/or modify
  7. // it under the terms of the GNU General Public License as published by
  8. // the Free Software Foundation, either version 3 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // This program is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU General Public License for more details.
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. ////////////////////////////////////////////////////////////////////////////////
  18. // Last modified 05/aug/2012 by cassio@ime.usp.br
  19. require 'header.php';
  20. if (isset($_POST["cancel"]) && $_POST["cancel"]=="Cancel editing")
  21. ForceLoad($runphp);
  22. if (isset($_POST["giveup"]) && $_POST["giveup"]=="Renew" &&
  23. isset($_POST["sitenumber"]) && isset($_POST["number"]) && is_numeric($_POST["number"]) &&
  24. is_numeric($_POST["sitenumber"])) {
  25. $sitenumber = myhtmlspecialchars($_POST["sitenumber"]);
  26. $number = myhtmlspecialchars($_POST["number"]);
  27. if (DBGiveUpRunAutojudging($_SESSION["usertable"]["contestnumber"], $sitenumber, $number))
  28. MSGError("Run renewed.");
  29. ForceLoad($runphp);
  30. }
  31. if (isset($_POST["delete"]) && $_POST["delete"]=="Delete" &&
  32. isset($_POST["sitenumber"]) && isset($_POST["number"]) && is_numeric($_POST["number"]) &&
  33. is_numeric($_POST["sitenumber"])) {
  34. if ($_POST["confirmation"]=="confirm") {
  35. $sitenumber = myhtmlspecialchars($_POST["sitenumber"]);
  36. $number = myhtmlspecialchars($_POST["number"]);
  37. if (DBRunDelete($number, $sitenumber, $_SESSION["usertable"]["contestnumber"],
  38. $_SESSION["usertable"]["usernumber"], $_SESSION["usertable"]["usersitenumber"]))
  39. MSGError("Run deleted.");
  40. }
  41. ForceLoad($runphp);
  42. }
  43. if (isset($_POST["answer"]) && isset($_POST["open"]) && $_POST["open"]=="Open run for rejudging" &&
  44. isset($_POST["sitenumber"]) && isset($_POST["number"]) && is_numeric($_POST["number"]) &&
  45. is_numeric($_POST["sitenumber"])) {
  46. if ($_POST["confirmation"] == "confirm") {
  47. $sitenumber = myhtmlspecialchars($_POST["sitenumber"]);
  48. $number = myhtmlspecialchars($_POST["number"]);
  49. DBGiveUpRunAutojudging($_SESSION["usertable"]["contestnumber"], $sitenumber, $number);
  50. if (DBChiefRunGiveUp($_POST["number"], $_POST["sitenumber"], $_SESSION["usertable"]["contestnumber"]))
  51. MSGError("Run returned.");
  52. ForceLoad($runphp);
  53. }
  54. }
  55. if (isset($_POST["answer"]) && isset($_POST["Submit"]) && $_POST["Submit"]=="Judge" && is_numeric($_POST["answer"]) &&
  56. isset($_POST["sitenumber"]) && isset($_POST["number"]) && is_numeric($_POST["sitenumber"]) &&
  57. is_numeric($_POST["number"])) { // && isset($_POST["notifyuser"]) && isset($_POST["updatescore"])) {
  58. if ($_POST["confirmation"] == "confirm") {
  59. $answer = myhtmlspecialchars($_POST["answer"]);
  60. $sitenumber = myhtmlspecialchars($_POST["sitenumber"]);
  61. $number = myhtmlspecialchars($_POST["number"]);
  62. // $notuser = myhtmlspecialchars($_POST["notifyuser"]);
  63. // $updscore = myhtmlspecialchars($_POST["updatescore"]);
  64. DBChiefUpdateRun($_SESSION["usertable"]["contestnumber"],
  65. $_SESSION["usertable"]["usersitenumber"],
  66. $_SESSION["usertable"]["usernumber"],
  67. $sitenumber, $number, $answer); //, $notuser, updscore);
  68. }
  69. ForceLoad($runphp);
  70. }
  71. if (!isset($_GET["runnumber"]) || !isset($_GET["runsitenumber"]) ||
  72. !is_numeric($_GET["runnumber"]) || !is_numeric($_GET["runsitenumber"])) {
  73. IntrusionNotify("tried to open the admin/runedit.php with wrong parameters.");
  74. ForceLoad($runphp);
  75. }
  76. // ???
  77. $runsitenumber = myhtmlspecialchars($_GET["runsitenumber"]);
  78. $runnumber = myhtmlspecialchars($_GET["runnumber"]);
  79. if (($a = DBChiefGetRunToAnswer($runnumber, $runsitenumber,
  80. $_SESSION["usertable"]["contestnumber"])) === false) {
  81. MSGError("Another judge got it first.");
  82. ForceLoad($runphp);
  83. }
  84. $b = DBGetProblemData($_SESSION["usertable"]["contestnumber"], $a["problemnumber"]);
  85. ?>
  86. <br><br><center><b>Use the following fields to judge the run:
  87. </b></center>
  88. <form name="form1" method="post" action="<?php echo $runeditphp; ?>">
  89. <input type=hidden name="confirmation" value="noconfirm" />
  90. <center>
  91. <table border="1">
  92. <tr>
  93. <td width="27%" align=right><b>Site:</b></td>
  94. <td width="83%">
  95. <input type=hidden name="sitenumber" value="<?php echo $a["sitenumber"]; ?>" />
  96. <?php echo $a["sitenumber"]; ?>
  97. </td>
  98. </tr>
  99. <tr>
  100. <td width="27%" align=right><b>Number:</b></td>
  101. <td width="83%">
  102. <input type=hidden name="number" value="<?php echo $a["number"]; ?>" />
  103. <?php echo $a["number"]; ?>
  104. </td>
  105. </tr>
  106. <tr>
  107. <td width="27%" align=right><b>Time:</b></td>
  108. <td width="83%">
  109. <?php echo dateconvminutes($a["timestamp"]); ?>
  110. </td>
  111. </tr>
  112. <tr>
  113. <td width="27%" align=right><b>Problem</b><i> <?php echo $a["problemname"]; ?></i>: </td>
  114. <td width="83%">
  115. <?php
  116. for ($i=0;$i<count($b);$i++) {
  117. echo "<b>Input:</b><a href=\"../filedownload.php?". filedownload($b[$i]["inputoid"], $b[$i]["inputfilename"]) ."\">";
  118. echo $b[$i]["inputfilename"] . "</a>";
  119. echo " <a href=\"#\" class=menu style=\"font-weight:bold\" onClick=\"window.open('../filewindow.php?".
  120. filedownload($b[$i]["inputoid"], $b[$i]["inputfilename"]) ."', 'View$i - INPUT','width=680,height=600,scrollbars=yes,resizable=yes')\">view</a> &nbsp;";
  121. echo "<b>Sol:</b><a href=\"../filedownload.php?". filedownload($b[$i]["soloid"], $b[$i]["solfilename"]) . "\">";
  122. echo $b[$i]["solfilename"] . "</a>";
  123. echo " <a href=\"#\" class=menu style=\"font-weight:bold\" onClick=\"window.open('../filewindow.php?".
  124. filedownload($b[$i]["soloid"], $b[$i]["solfilename"]) ."', 'View$i - CORRECT OUTPUT','width=680,height=600,scrollbars=yes,resizable=yes')\">view</a>";
  125. }
  126. ?>
  127. &nbsp;</td>
  128. </tr>
  129. <tr>
  130. <td width="27%" align=right><b>Language</b>:</td>
  131. <td width="83%"><i> <?php echo $a["language"]; ?></i>
  132. &nbsp;</td>
  133. </tr>
  134. <tr>
  135. <td width="27%" align=right><b>Source code:</b></td>
  136. <td width="83%">
  137. <?php
  138. echo "<a href=\"../filedownload.php?". filedownload($a["sourceoid"],$a["sourcename"]) . "\">" . $a["sourcename"] . "</a>\n";
  139. echo "<a href=\"#\" class=menu style=\"font-weight:bold\" onClick=\"window.open('../filewindow.php?" .
  140. filedownload($a["sourceoid"],$a["sourcename"]) ."', 'View - SOURCE', ".
  141. "'width=680,height=600,scrollbars=yes,resizable=yes')\">view</a>\n";
  142. ?>
  143. </td>
  144. </tr>
  145. <tr>
  146. <td width="27%" align=right><b>Answer:</b></td>
  147. <td width="83%">
  148. <select name="answer">
  149. <?php
  150. $ans = DBGetAnswers($_SESSION["usertable"]["contestnumber"]);
  151. //$isfak = true;
  152. for ($i=0;$i<count($ans);$i++)
  153. if ($a["answer"] == $ans[$i]["number"]) {
  154. // if($ans[$i]["fake"] != "t") $isfak = false;
  155. echo "<option selected value=\"" . $ans[$i]["number"] . "\">" . $ans[$i]["desc"] . "</option>\n";
  156. } else
  157. echo "<option value=\"" . $ans[$i]["number"] . "\">" . $ans[$i]["desc"] . "</option>\n";
  158. echo "</select>";
  159. // if(!$isfak) {
  160. if($a["judgesite"] != "" && $a["judge"] != "") {
  161. $uu = DBUserInfo ($_SESSION["usertable"]["contestnumber"], $a["judgesite"], $a["judge"]);
  162. echo " [judge=" . $uu["username"] . " (" . $a["judgesite"] . ")]";
  163. }
  164. ?>
  165. </td>
  166. </tr>
  167. <tr>
  168. <td width="27%" align=right><b>Answer 1:</b></td>
  169. <td width="83%">
  170. <?php
  171. $ans = DBGetAnswers($_SESSION["usertable"]["contestnumber"]);
  172. for ($i=0;$i<count($ans);$i++)
  173. if ($a["answer1"] == $ans[$i]["number"]) {
  174. // if($ans[$i]["fake"] != "t") {
  175. if($a["judgesite1"] != "" && $a["judge1"] != "") {
  176. $uu = DBUserInfo ($_SESSION["usertable"]["contestnumber"], $a["judgesite1"], $a["judge1"]);
  177. echo $ans[$i]["desc"] . " [judge=" . $uu["username"] . " (" . $a["judgesite1"] . ")]";
  178. } else
  179. echo $ans[$i]["desc"];
  180. }
  181. ?>
  182. </td>
  183. </tr>
  184. <tr>
  185. <td width="27%" align=right><b>Answer 2:</b></td>
  186. <td width="83%">
  187. <?php
  188. $ans = DBGetAnswers($_SESSION["usertable"]["contestnumber"]);
  189. for ($i=0;$i<count($ans);$i++)
  190. if ($a["answer2"] == $ans[$i]["number"]) {
  191. // if($ans[$i]["fake"] != "t") {
  192. if($a["judgesite2"] != "" && $a["judge2"] != "") {
  193. $uu = DBUserInfo ($_SESSION["usertable"]["contestnumber"], $a["judgesite2"], $a["judge2"]);
  194. echo $ans[$i]["desc"] . " [judge=" . $uu["username"] . " (" . $a["judgesite2"] . ")]";
  195. } else
  196. echo $ans[$i]["desc"];
  197. }
  198. ?>
  199. </td>
  200. </tr>
  201. <!--
  202. <tr>
  203. <td width="27%" align=right><b>Notify user:</b></td>
  204. <td width="83%">
  205. <input class=checkbox type=checkbox name="notifyuser" value="yes"
  206. <?php
  207. if (($s=DBSiteInfo($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usersitenumber"])) == null)
  208. ForceLoad("../index.php");
  209. if ($a["timestamp"] < $s["sitelastmileanswer"]) echo "checked"; ?>>
  210. (do not change this unless you know exactly what you are doing)
  211. </td>
  212. </tr>
  213. <tr>
  214. <td width="27%" align=right><b>Update score board:</b></td>
  215. <td width="83%">
  216. <input class=checkbox type=checkbox name="updatescore" value="yes"
  217. <?php if ($a["timestamp"] < $s["sitelastmilescore"]) echo "checked"; ?>>
  218. (do not change this unless you know exactly what you are doing)
  219. </td>
  220. </tr>
  221. -->
  222. </table>
  223. </center>
  224. <br>
  225. <script language="javascript">
  226. function conf() {
  227. if (confirm("Confirm?")) {
  228. document.form1.confirmation.value='confirm';
  229. }
  230. }
  231. </script>
  232. <center>
  233. <input type="submit" name="Submit" value="Judge" onClick="conf()">
  234. <input type="submit" name="open" value="Open run for rejudging" onClick="conf()">
  235. <input type="submit" name="cancel" value="Cancel editing">
  236. <input type="submit" name="delete" value="Delete" onClick="conf()">
  237. <input type="reset" name="Submit2" value="Clear">
  238. <br><br>
  239. </center>
  240. <center>
  241. <br>
  242. <b>Autojudging:</b>
  243. <input type="submit" name="giveup" value="Renew">
  244. <br><br>
  245. <table border="1">
  246. <tr>
  247. <td width="27%" align=right><b>Autojudging answer:</b></td>
  248. <td width="83%">
  249. <?php
  250. if($a["autobegin"]!="" && $a["autoend"]=="")
  251. echo "in progress";
  252. else if($a["autoend"]!="") {
  253. if($a["autoanswer"]!="") echo $a["autoanswer"];
  254. else echo "Autojudging error";
  255. } else
  256. echo "unavailable";
  257. ?>
  258. </td>
  259. </tr>
  260. <tr>
  261. <td width="27%" align=right><b>Autojudged by:</b></td>
  262. <?php if($a["autobegin"]!="" && $a["autoend"]=="")
  263. echo "<td width=\"83%\">". $a["autoip"] ." since ". dateconvsimple($a["autobegin"]) ."</td>";
  264. else if($a["autoend"]!="")
  265. echo "<td width=\"83%\">". $a["autoip"] ." from ". dateconvsimple($a["autobegin"]) ." to ". dateconvsimple($a["autoend"]) ."</td>";
  266. else
  267. echo "<td width=\"83%\">unavailable</td>";
  268. ?>
  269. </tr>
  270. <tr>
  271. <td width="27%" align=right><b>Standard output:</b></td>
  272. <td width="83%">
  273. <?php
  274. if($a["autostdout"]!="") {
  275. echo "<a href=\"../filedownload.php?".filedownload($a["autostdout"],"stdout") ."\">stdout</a>\n";
  276. echo "<a href=\"#\" class=menu style=\"font-weight:bold\" onClick=\"window.open('../filewindow.php?".
  277. filedownload($a["autostdout"],"stdout") ."', 'View - STDOUT','width=680,height=600,scrollbars=yes,".
  278. "resizable=yes')\">view</a>\n";
  279. } else
  280. echo "unavailable";
  281. ?>
  282. </td>
  283. </tr>
  284. <tr>
  285. <td width="27%" align=right><b>Standard error:</b></td>
  286. <td width="83%">
  287. <?php
  288. if($a["autostderr"]!="") {
  289. echo "<a href=\"../filedownload.php?". filedownload($a["autostderr"],"stderr") . "\">stderr</a>\n";
  290. echo "<a href=\"#\" class=menu style=\"font-weight:bold\" onClick=\"window.open('../filewindow.php?".
  291. filedownload($a["autostderr"],"stderr") ."', 'View - STDERR','width=680,height=600,scrollbars=yes,".
  292. "resizable=yes')\">view</a>\n";
  293. } else
  294. echo "unavailable";
  295. ?>
  296. </td>
  297. </tr>
  298. </table></center>
  299. </form>
  300. </body>
  301. </html>