diff options
Diffstat (limited to 'src/admin')
| -rw-r--r-- | src/admin/contest.php | 36 | ||||
| -rw-r--r-- | src/admin/header.php | 6 | ||||
| -rw-r--r-- | src/admin/misc.php | 28 | ||||
| -rw-r--r-- | src/admin/option.php | 1 | ||||
| -rw-r--r-- | src/admin/problem.php | 55 | ||||
| -rw-r--r-- | src/admin/site.php | 18 | ||||
| -rw-r--r-- | src/admin/task.php | 3 | ||||
| -rw-r--r-- | src/admin/user.php | 24 |
8 files changed, 130 insertions, 41 deletions
diff --git a/src/admin/contest.php b/src/admin/contest.php index 58df217..fda17da 100644 --- a/src/admin/contest.php +++ b/src/admin/contest.php @@ -26,6 +26,37 @@ $localsite=$ct["contestlocalsite"]; $mainsite=$ct["contestmainsite"]; if ($localsite == $mainsite) $main=true; else $main=false; +if($main) { + if (isset($_POST["SubmitDC"]) && $_POST["SubmitDC"] == "Delete ALL clars") { + if ($_POST["confirmation"] == "confirm") { + DBSiteDeleteAllClars ($_SESSION["usertable"]["contestnumber"], -1, + $_SESSION["usertable"]["usernumber"], $_SESSION["usertable"]["usersitenumber"]); + } + ForceLoad("contest.php"); + } + if (isset($_POST["SubmitDR"]) && $_POST["SubmitDR"] == "Delete ALL runs") { + if ($_POST["confirmation"] == "confirm") { + DBSiteDeleteAllRuns ($_SESSION["usertable"]["contestnumber"], -1, + $_SESSION["usertable"]["usernumber"], $_SESSION["usertable"]["usersitenumber"]); + } + ForceLoad("contest.php"); + } + if (isset($_POST["SubmitDT"]) && $_POST["SubmitDT"] == "Delete ALL tasks") { + if ($_POST["confirmation"] == "confirm") { + DBSiteDeleteAllTasks ($_SESSION["usertable"]["contestnumber"], -1, + $_SESSION["usertable"]["usernumber"], $_SESSION["usertable"]["usersitenumber"]); + } + ForceLoad("contest.php"); + } + if (isset($_POST["SubmitDB"]) && $_POST["SubmitDB"] == "Delete ALL bkps") { + if ($_POST["confirmation"] == "confirm") { + DBSiteDeleteAllBkps ($_SESSION["usertable"]["contestnumber"], -1, + $_SESSION["usertable"]["usernumber"], $_SESSION["usertable"]["usersitenumber"]); + } + ForceLoad("contest.php"); + } +} + if (isset($_POST["Submit3"]) && isset($_POST["penalty"]) && is_numeric($_POST["penalty"]) && isset($_POST["maxfilesize"]) && isset($_POST["mainsite"]) && isset($_POST["name"]) && $_POST["name"] != "" && isset($_POST["lastmileanswer"]) && is_numeric($_POST["lastmileanswer"]) && @@ -254,6 +285,11 @@ echo $contest; <input type="submit" name="Submit3" value="Update" onClick="conf()"> <input type="submit" name="Submit3" value="Update Contest and All Sites" onClick="conf2()"> <input type="reset" name="Submit4" value="Clear"> +<br><br> + <input type="submit" name="SubmitDC" value="Delete ALL clars" onClick="conf2()"> + <input type="submit" name="SubmitDR" value="Delete ALL runs" onClick="conf2()"> + <input type="submit" name="SubmitDT" value="Delete ALL tasks" onClick="conf2()"> + <input type="submit" name="SubmitDB" value="Delete ALL bkps" onClick="conf2()"> <?php } else { ?> <input type="submit" name="Submit3" value="Update" onClick="conf()"> <input type="submit" name="Submit3" value="Become Main Site" onClick="conf3()"> diff --git a/src/admin/header.php b/src/admin/header.php index 6002b18..116f4f6 100644 --- a/src/admin/header.php +++ b/src/admin/header.php @@ -42,7 +42,6 @@ if(!isset($_POST['noflush'])) { echo "<link rel=stylesheet href=\"$loc/Css.php\" type=\"text/css\">\n"; } -//echo "<meta http-equiv=\"refresh\" content=\"60\" />"; if(!ValidSession()) { InvalidSession("admin/index.php"); ForceLoad("$loc/index.php"); @@ -52,6 +51,11 @@ if($_SESSION["usertable"]["usertype"] != "admin") { ForceLoad("$loc/index.php"); } +if ((isset($_GET["Submit1"]) && $_GET["Submit1"] == "Transfer") || + (isset($_GET["Submit3"]) && $_GET["Submit3"] == "Transfer scores")) { + echo "<meta http-equiv=\"refresh\" content=\"60\" />"; +} + if(!isset($_POST['noflush'])) { echo "</head><body id=\"body\"><table border=1 width=\"100%\">\n"; echo "<tr><td nowrap bgcolor=\"eeee00\" align=center>"; diff --git a/src/admin/misc.php b/src/admin/misc.php index 3e8d224..8ff1aeb 100644 --- a/src/admin/misc.php +++ b/src/admin/misc.php @@ -19,7 +19,7 @@ require 'header.php'; ?> <br> -<form name="form1" enctype="multipart/form-data" method="post" action="misc.php"> +<form name="form1" enctype="multipart/form-data" method="get" action="misc.php"> <input type=hidden name="confirmation" value="noconfirm" /> <script language="javascript" type="text/javascript"> function conf() { @@ -38,7 +38,7 @@ require 'header.php'; <center> <input type="submit" name="Submit1" value="Transfer" onClick="conf()"> <input type="submit" name="Submit2" value="Transfer all" onClick="conf()"> - <input type="submit" name="Submit3" value="Transfer scores"> + <input type="submit" name="Submit3" value="Transfer scores" onClick="conf()"> <input type="submit" name="Submit4" value="Clear cache" onClick="conf()"> <input type="submit" name="Submit5" value="Full clear" onClick="conf2()"> <input type="submit" name="Submit6" value="Update BOCA" onClick="conf2()"> @@ -49,35 +49,36 @@ require 'header.php'; OPERATION LOG DISPLAYS BELOW: <?php -if(isset($_POST['confirmation']) && $_POST['confirmation'] == 'confirm') { +echo "Start: " . now() . "\n"; +if(isset($_GET['confirmation']) && $_GET['confirmation'] == 'confirm') { $ds = DIRECTORY_SEPARATOR; if($ds=="") $ds = "/"; $dotransfer=false; $doscore=false; $dotransferall=false; -if (isset($_POST["Submit1"]) && $_POST["Submit1"] == "Transfer") { +if (isset($_GET["Submit1"]) && $_GET["Submit1"] == "Transfer") { $dotransfer=true; $doscore=true; } -if (isset($_POST["Submit2"]) && $_POST["Submit2"] == "Transfer all") { +if (isset($_GET["Submit2"]) && $_GET["Submit2"] == "Transfer all") { $dotransfer=true; $dotransferall=true; $doscore=true; } -if (isset($_POST["Submit3"]) && $_POST["Submit3"] == "Transfer scores") { +if (isset($_GET["Submit3"]) && $_GET["Submit3"] == "Transfer scores") { $doscore=true; } -if (isset($_POST["Submit4"]) && $_POST["Submit4"] == "Clear cache") { +if (isset($_GET["Submit4"]) && $_GET["Submit4"] == "Clear cache") { if(fixbocadir(dirname(__DIR__))) echo "Done\n"; else echo "Error (likely permission/ownership issues)\n"; } -if (isset($_POST["Submit5"]) && $_POST["Submit5"] == "Full clear") { +if (isset($_GET["Submit5"]) && $_GET["Submit5"] == "Full clear") { if(fixbocadir(dirname(__DIR__),true)) echo "Done\n"; else echo "Error (likely permission/ownership issues)\n"; } -if (isset($_POST["Submit6"]) && $_POST["Submit6"] == "Update BOCA") { +if (isset($_GET["Submit6"]) && $_GET["Submit6"] == "Update BOCA") { $dir = dirname(__DIR__); if(!is_readable($dir . $ds . "private" . $ds . "updateboca.log")) @file_put_contents($dir . $ds . "private" . $ds . "updateboca.log", ""); if(is_writable($dir . $ds . "private" . $ds . "updateboca.log")) { @@ -112,7 +113,7 @@ if (isset($_POST["Submit6"]) && $_POST["Submit6"] == "Update BOCA") { echo "Cannot update log file\n"; } } -if (isset($_POST["Submit7"]) && $_POST["Submit7"] == "Revert Update") { +if (isset($_GET["Submit7"]) && $_GET["Submit7"] == "Revert Update") { $dir = dirname(__DIR__); if(!is_readable($dir . $ds . "private" . $ds . "updateboca.log")) @file_put_contents($dir . $ds . "private" . $ds . "updateboca.log", ""); if(is_writable($dir . $ds . "private" . $ds . "updateboca.log")) { @@ -168,7 +169,7 @@ if($dotransfer || $doscore || $dotransferall) { $fname = $remotedir . $ds . "score_site" . $localsite . "_" . $localsite . "_x"; // . md5($_SERVER['HTTP_HOST']); @file_put_contents($fname . ".tmp",base64_encode(serialize($data0))); @rename($fname . ".tmp",$fname . ".dat"); - echo "Transferring scores\n"; + echo "Checking for transfers\n"; echo scoretransfer($fname . ".dat", $localsite); echo "Saving scores\n"; if(@create_zip($remotedir,glob($remotedir . '/*.dat'),$fname . ".tmp") != 1) { @@ -181,8 +182,8 @@ if($dotransfer || $doscore || $dotransferall) { @fclose($fp); } if($dotransfer) { - echo "Processing other data\n"; - getMainXML($_SESSION["usertable"]["contestnumber"],10,$dotransferall); + echo "Processing contest data\n"; + echo getMainXML($_SESSION["usertable"]["contestnumber"],10,$dotransferall); } @unlink($destination . ".lck"); } else { @@ -193,6 +194,7 @@ if($dotransfer || $doscore || $dotransferall) { } } } +echo "End: " . now() . "\n"; ?> </pre> </body> diff --git a/src/admin/option.php b/src/admin/option.php index 81e5879..d3581a4 100644 --- a/src/admin/option.php +++ b/src/admin/option.php @@ -15,7 +15,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. //////////////////////////////////////////////////////////////////////////////// -// Last modified 05/aug/2012 by cassio@ime.usp.br require('header.php'); require('../optionlower.php'); ?> diff --git a/src/admin/problem.php b/src/admin/problem.php index d462e79..a01bd35 100644 --- a/src/admin/problem.php +++ b/src/admin/problem.php @@ -192,13 +192,36 @@ if (isset($_POST["Submit3"]) && isset($_POST["problemnumber"]) && is_numeric($_P $param['inputfilename'] = $name; $param['inputfilepath'] = $temp; $param['fake'] = 'f'; - $param['colorname'] = $_POST["colorname"]; - $param['color'] = $_POST["color"]; + $param['colorname'] = trim($_POST["colorname"]); + $param['color'] = trim($_POST["color"]); DBNewProblem ($_SESSION["usertable"]["contestnumber"], $param); } } ForceLoad("problem.php"); } + +$prob = DBGetFullProblemData($_SESSION["usertable"]["contestnumber"],true); +for ($i=0; $i<count($prob); $i++) { + if($prob[$i]["fake"]!='t') { + if (isset($_POST["SubmitProblem" . $prob[$i]['number']]) && $_POST["SubmitProblem" . $prob[$i]['number']] == 'Update' && + isset($_POST["colorname" . $prob[$i]['number']]) && strlen($_POST["colorname" . $prob[$i]['number']]) <= 100 && + isset($_POST["color" . $prob[$i]['number']]) && strlen($_POST["color" . $prob[$i]['number']]) <= 6 && + isset($_POST["problemname" . $prob[$i]['number']]) && $_POST["problemname" . $prob[$i]['number']] != "" && strlen($_POST["problemname" . $prob[$i]['number']]) <= 20) { + if(strpos(trim($_POST["problemname" . $prob[$i]['number']]),' ')!==false) { + MSGError('Problem short name cannot have spaces'); + } else { + $param = array(); + $param['number'] = $prob[$i]['number']; + $param['name'] = trim($_POST["problemname" . $prob[$i]['number']]); + $param['fake'] = 'f'; + $param['colorname'] = trim($_POST["colorname" . $prob[$i]['number']]); + $param['color'] = trim($_POST["color" . $prob[$i]['number']]); + DBNewProblem ($_SESSION["usertable"]["contestnumber"], $param); + } + ForceLoad("problem.php"); + } + } +} ?> <br> <script language="javascript"> @@ -221,6 +244,7 @@ if (isset($_POST["Submit3"]) && isset($_POST["problemnumber"]) && is_numeric($_P } } </script> +<form name="form0" enctype="multipart/form-data" method="post" action="problem.php"> <table width="100%" border=1> <tr> <td><b>Problem #</b></td> @@ -234,7 +258,6 @@ if (isset($_POST["Submit3"]) && isset($_POST["problemnumber"]) && is_numeric($_P <td><b>Color</b></td> </tr> <?php - $prob = DBGetFullProblemData($_SESSION["usertable"]["contestnumber"],true); for ($i=0; $i<count($prob); $i++) { echo " <tr>\n"; if($prob[$i]["fake"]!='t') { @@ -247,10 +270,15 @@ for ($i=0; $i<count($prob); $i++) { "')\">" . $prob[$i]["number"]; } echo "</a></td>\n"; + echo "<input type=hidden name=\"problemname" . $prob[$i]['number'] . "\" value=\"" . $prob[$i]["name"] . "\" />"; + echo " <td nowrap>" . $prob[$i]["name"] . "</td>\n"; + //echo " <td nowrap>"; + //echo "<input type=\"text\" name=\"problemname" . $prob[$i]['number'] . "\" value=\"" . $prob[$i]["name"] . "\" size=\"4\" maxlength=\"20\" />"; + //echo "</td>\n"; } else { echo " <td nowrap>" . $prob[$i]["number"] . " (fake)</td>\n"; + echo " <td nowrap>" . $prob[$i]["name"] . "</td>\n"; } - echo " <td nowrap>" . $prob[$i]["name"] . "</td>\n"; echo " <td nowrap>" . $prob[$i]["fullname"] . " </td>\n"; echo " <td nowrap>" . $prob[$i]["basefilename"] . " </td>\n"; if (isset($prob[$i]["descoid"]) && $prob[$i]["descoid"] != null && isset($prob[$i]["descfilename"])) { @@ -283,15 +311,20 @@ for ($i=0; $i<count($prob); $i++) { else echo " <td nowrap> </td>\n"; */ - if ($prob[$i]["color"]!="") { - echo " <td nowrap>" . $prob[$i]["colorname"] . - "<img title=\"".$prob[$i]["color"]."\" alt=\"".$prob[$i]["colorname"]."\" width=\"25\" src=\"" . - balloonurl($prob[$i]["color"]) . "\" /></td>\n"; - } else - echo " <td nowrap> </td>\n"; + echo " <td nowrap>"; + if($prob[$i]["fake"]!='t') { + if ($prob[$i]["color"]!="") { + echo "<img title=\"".$prob[$i]["color"]."\" alt=\"".$prob[$i]["colorname"]."\" width=\"25\" src=\"" . + balloonurl($prob[$i]["color"]) . "\" />\n"; + } + echo "<input type=\"text\" name=\"colorname" . $prob[$i]['number'] . "\" value=\"" . $prob[$i]["colorname"] . "\" size=\"10\" maxlength=\"100\" />"; + echo "<input type=\"text\" name=\"color" . $prob[$i]['number'] . "\" value=\"" . $prob[$i]["color"]. "\" size=\"6\" maxlength=\"6\" />"; + echo "<input type=\"submit\" name=\"SubmitProblem" . $prob[$i]["number"] . "\" value=\"Update\">"; + } else echo " "; + echo "</td>\n"; echo " </tr>\n"; } -echo "</table>"; +echo "</table></form>"; if (count($prob) == 0) echo "<br><center><b><font color=\"#ff0000\">NO PROBLEMS DEFINED</font></b></center>"; ?> diff --git a/src/admin/site.php b/src/admin/site.php index dd88d1c..b71d9c8 100644 --- a/src/admin/site.php +++ b/src/admin/site.php @@ -76,28 +76,30 @@ if (isset($_POST["Submit2"]) && $_POST["Submit2"] == "Start Now") { } ForceLoad("site.php?site=$site"); } -if (isset($_POST["SubmitDC"]) && $_POST["SubmitDC"] == "Delete ALL site clars") { +if (isset($_POST["SubmitDC"]) && $_POST["SubmitDC"] == "Delete ALL clars") { if ($_POST["confirmation"] == "confirm") { DBSiteDeleteAllClars ($_SESSION["usertable"]["contestnumber"], $site, $_SESSION["usertable"]["usernumber"], $_SESSION["usertable"]["usersitenumber"]); + DBSiteDeleteAllClars ($_SESSION["usertable"]["contestnumber"], $ct["contestmainsite"], + $_SESSION["usertable"]["usernumber"], $_SESSION["usertable"]["usersitenumber"]); } ForceLoad("site.php?site=$site"); } -if (isset($_POST["SubmitDR"]) && $_POST["SubmitDR"] == "Delete ALL site runs") { +if (isset($_POST["SubmitDR"]) && $_POST["SubmitDR"] == "Delete ALL runs") { if ($_POST["confirmation"] == "confirm") { DBSiteDeleteAllRuns ($_SESSION["usertable"]["contestnumber"], $site, $_SESSION["usertable"]["usernumber"], $_SESSION["usertable"]["usersitenumber"]); } ForceLoad("site.php?site=$site"); } -if (isset($_POST["SubmitDT"]) && $_POST["SubmitDT"] == "Delete ALL site tasks") { +if (isset($_POST["SubmitDT"]) && $_POST["SubmitDT"] == "Delete ALL tasks") { if ($_POST["confirmation"] == "confirm") { DBSiteDeleteAllTasks ($_SESSION["usertable"]["contestnumber"], $site, $_SESSION["usertable"]["usernumber"], $_SESSION["usertable"]["usersitenumber"]); } ForceLoad("site.php?site=$site"); } -if (isset($_POST["SubmitDB"]) && $_POST["SubmitDB"] == "Delete ALL site bkps") { +if (isset($_POST["SubmitDB"]) && $_POST["SubmitDB"] == "Delete ALL bkps") { if ($_POST["confirmation"] == "confirm") { DBSiteDeleteAllBkps ($_SESSION["usertable"]["contestnumber"], $site, $_SESSION["usertable"]["usernumber"], $_SESSION["usertable"]["usersitenumber"]); @@ -530,10 +532,10 @@ echo "):</td>"; <input type="submit" name="Logins" value="Enable logins" onClick="conf()"> <br><br><br> - <input type="submit" name="SubmitDC" value="Delete ALL site clars" onClick="conf2()"> - <input type="submit" name="SubmitDR" value="Delete ALL site runs" onClick="conf2()"> - <input type="submit" name="SubmitDT" value="Delete ALL site tasks" onClick="conf2()"> - <input type="submit" name="SubmitDB" value="Delete ALL site bkps" onClick="conf2()"> + <input type="submit" name="SubmitDC" value="Delete ALL clars" onClick="conf2()"> + <input type="submit" name="SubmitDR" value="Delete ALL runs" onClick="conf2()"> + <input type="submit" name="SubmitDT" value="Delete ALL tasks" onClick="conf2()"> + <input type="submit" name="SubmitDB" value="Delete ALL bkps" onClick="conf2()"> <?php } ?> diff --git a/src/admin/task.php b/src/admin/task.php index a1446ce..cf707bc 100644 --- a/src/admin/task.php +++ b/src/admin/task.php @@ -81,6 +81,9 @@ if (isset($_GET["done"]) && is_numeric($_GET["done"]) && isset($_GET["site"]) && if (($s=DBSiteInfo($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usersitenumber"])) == null) ForceLoad("../index.php"); +if (trim($s["sitetasking"])!="") $s["sitetasking"].=",".$_SESSION["usertable"]["usersitenumber"]; +else $s["sitetasking"]=$_SESSION["usertable"]["usersitenumber"]; + $task = DBAllTasksInSites($_SESSION["usertable"]["contestnumber"], $s["sitetasking"], $order, true); for ($i=0; $i<count($task); $i++) { $st = $task[$i]["status"]; diff --git a/src/admin/user.php b/src/admin/user.php index 9085e45..466cb07 100644 --- a/src/admin/user.php +++ b/src/admin/user.php @@ -15,9 +15,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. //////////////////////////////////////////////////////////////////////////////// -// Last modified 26/oct/2014 by cassio@ime.usp.br -// allow passwords to be changed by default -// require('header.php'); if (isset($_GET["site"]) && isset($_GET["user"]) && is_numeric($_GET["site"]) && is_numeric($_GET["user"]) && @@ -52,6 +49,7 @@ if (isset($_POST["username"]) && isset($_POST["userfullname"]) && isset($_POST[" $param['permitip'] = htmlspecialchars($_POST["userip"]); $param['contest'] = $_SESSION["usertable"]["contestnumber"]; $param['changepass']='t'; + if(isset($_POST['changepass']) && $_POST['changepass'] != 't') $param['changepass']='f'; /* $param['user'] = myhtmlspecialchars($_POST["usernumber"]); $param['site'] = myhtmlspecialchars($_POST["usersitenumber"]); @@ -66,13 +64,14 @@ if (isset($_POST["username"]) && isset($_POST["userfullname"]) && isset($_POST[" */ - $passcheck = htmlspecialchars($_POST["passwordo"]); + $passcheck = $_POST["passwordo"]; $a = DBUserInfo($_SESSION["usertable"]["contestnumber"], $_SESSION["usertable"]["usersitenumber"], $_SESSION["usertable"]["usernumber"], null, false); if(myhash($a['userpassword'] . session_id()) != $passcheck) { MSGError('Admin password is incorrect'); } else { if ($_POST["passwordn1"] == $_POST["passwordn2"]) { - $param['pass'] = bighexsub(htmlspecialchars($_POST["passwordn1"]),$a['userpassword']); + $param['pass'] = bighexsub($_POST["passwordn1"],$a['userpassword']); + while(strlen($param['pass']) < strlen($a['userpassword'])) $param['pass'] = '0' . $param['pass']; if($param['user'] != 1000) DBNewUser($param); } @@ -257,9 +256,11 @@ for ($i=0; $i < count($usr); $i++) { ($usr[$i]["usernumber"] != $_SESSION["usertable"]["usernumber"] || $usr[$i]["usersitenumber"] != $_SESSION["usertable"]["usersitenumber"])) echo " <td nowrap><a href=\"user.php?site=" . $usr[$i]["usersitenumber"] . "&user=" . - $usr[$i]["usernumber"] . "\">" . $usr[$i]["usernumber"] . "</a></td>\n"; + $usr[$i]["usernumber"] . "\">" . $usr[$i]["usernumber"] . "</a>"; else - echo " <td nowrap>" . $usr[$i]["usernumber"] . "</td>\n"; + echo " <td nowrap>" . $usr[$i]["usernumber"]; + if($usr[$i]['userenabled'] != 't' && $usr[$i]['userlastlogin'] < 1) echo "(inactive)"; + echo "</td>\n"; echo " <td nowrap>" . $usr[$i]["usersitenumber"] . "</td>\n"; echo " <td nowrap>" . $usr[$i]["username"] . " </td>\n"; @@ -473,6 +474,15 @@ echo $u["userdesc"]; } ?>" size="50" maxlength="300" /> </td> </tr> <tr> + <td width="35%" align=right>Allow password change:</td> + <td width="65%"> + <select name="changepass"> + <option <?php if(isset($u) && $u["changepassword"]) echo "selected"; ?> value="t">Yes</option> + <option <?php if(!isset($u) || !$u["changepassword"]) echo "selected"; ?> value="f">No</option> + </select> + </td> + </tr> + <tr> <td width="35%" align=right>Admin (this user) Password:</td> <td width="65%"> <input type="password" name="passwordo" value="" size="20" maxlength="200" /> |