From be2491b093b1f0ca430bede679ecbb670041e483 Mon Sep 17 00:00:00 2001 From: cassio Date: Tue, 2 Jul 2013 09:46:45 +0400 Subject: restructuring of boca's git --- src/admin/site.php | 605 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 605 insertions(+) create mode 100644 src/admin/site.php (limited to 'src/admin/site.php') diff --git a/src/admin/site.php b/src/admin/site.php new file mode 100644 index 0000000..84241f3 --- /dev/null +++ b/src/admin/site.php @@ -0,0 +1,605 @@ +. +//////////////////////////////////////////////////////////////////////////////// +// Last modified 05/aug/2012 by cassio@ime.usp.br +require 'header.php'; + +if(($ct = DBContestInfo($_SESSION["usertable"]["contestnumber"])) == null) + ForceLoad("../index.php"); +if($ct["contestlocalsite"]==$ct["contestmainsite"]) $main=true; else $main=false; + +if ($main) { + if(isset($_GET["new"]) && $_GET["new"]=="1") { + $n = DBNewSite($_SESSION["usertable"]["contestnumber"]); + ForceLoad("site.php?site=$n"); + } +} +if (isset($_GET["site"]) && is_numeric($_GET["site"])) + $site=$_GET["site"]; +else if (isset($_POST["site"]) && is_numeric($_POST["site"])) + $site=$_POST["site"]; +else + $site=$ct["contestlocalsite"]; + +if(($st = DBSiteInfo($_SESSION["usertable"]["contestnumber"], $site)) == null) + ForceLoad("../index.php"); +$sitetime = DBAllSiteTime($_SESSION["usertable"]["contestnumber"], $site); + +if (isset($_POST["Logoff"]) && $_POST["Logoff"] == "Logoff all users") { + if ($_POST["confirmation"] == "confirm") { + DBSiteLogoffAll ($_SESSION["usertable"]["contestnumber"], $site); + } + ForceLoad("site.php?site=$site"); +} +if (isset($_POST["Logins"]) && $_POST["Logins"] == "Enable logins") { + if ($_POST["confirmation"] == "confirm") { + DBSiteLogins ($_SESSION["usertable"]["contestnumber"], $site, "t"); + } + ForceLoad("site.php?site=$site"); +} +if (isset($_POST["Logins"]) && $_POST["Logins"] == "Disable logins") { + if ($_POST["confirmation"] == "confirm") { + DBSiteLogins ($_SESSION["usertable"]["contestnumber"], $site, "f"); + } + ForceLoad("site.php?site=$site"); +} +if (isset($_POST["Submit2"]) && $_POST["Submit2"] == "Start Now") { + if ($_POST["confirmation"] == "confirm") { + if(!DBSiteStartNow ($_SESSION["usertable"]["contestnumber"], $site)) + MSGError("Site is already running"); + } + ForceLoad("site.php?site=$site"); +} +if (isset($_POST["SubmitDC"]) && $_POST["SubmitDC"] == "Delete ALL site clars") { + if ($_POST["confirmation"] == "confirm") { + DBSiteDeleteAllClars ($_SESSION["usertable"]["contestnumber"], $site, + $_SESSION["usertable"]["usernumber"], $_SESSION["usertable"]["usersitenumber"]); + } + ForceLoad("site.php?site=$site"); +} +if (isset($_POST["SubmitDR"]) && $_POST["SubmitDR"] == "Delete ALL site 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 ($_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 ($_POST["confirmation"] == "confirm") { + DBSiteDeleteAllBkps ($_SESSION["usertable"]["contestnumber"], $site, + $_SESSION["usertable"]["usernumber"], $_SESSION["usertable"]["usersitenumber"]); + } + ForceLoad("site.php?site=$site"); +} +if (isset($_POST["Submit3"]) && $_POST["Submit3"] == "Stop Now") { + if ($_POST["confirmation"] == "confirm") { + if(DBSiteEndNow ($_SESSION["usertable"]["contestnumber"], $site)) + MSGError("Site has been finished"); + } + ForceLoad("site.php?site=$site"); +} +if (isset($_POST["endat"]) && $_POST["endat"] == "Stop At") { + if ($_POST["confirmation"] == "confirm" && + isset($_POST["enddateh"]) && $_POST["enddateh"] >= 0 && $_POST["enddateh"] <= 23 && + isset($_POST["enddatemin"]) && $_POST["enddatemin"] >= 0 && $_POST["enddatemin"] <= 59 && + isset($_POST["enddated"]) && isset($_POST["enddatem"]) && isset($_POST["enddatey"]) && + checkdate($_POST["enddatem"], $_POST["enddated"], $_POST["enddatey"])) { + $te = mktime ($_POST["enddateh"], $_POST["enddatemin"], 0, $_POST["enddatem"], $_POST["enddated"], $_POST["enddatey"]); + if($te > time()) + MSGError("Impossible to stop at a future time. Still running"); + else { + if(DBSiteEndNow ($_SESSION["usertable"]["contestnumber"], $site, $te)) + MSGError("Site has been finished"); + } + } + ForceLoad("site.php?site=$site"); +} +if (isset($_POST["Submit1"]) && $_POST["Submit1"] == "Send" && isset($_POST["name"]) && isset($_POST["site"]) && is_numeric($_POST["site"]) && + $_POST["name"] != "" && isset($_POST["lastmileanswer"]) && isset($_POST["scorelevel"]) && + is_numeric($_POST["lastmileanswer"]) && isset($_POST["lastmilescore"]) && + is_numeric($_POST["lastmilescore"]) && is_numeric($_POST["scorelevel"]) && + isset($_POST["chiefname"]) && + isset($_POST["startdateh"]) && $_POST["startdateh"] >= 0 && $_POST["startdateh"] <= 23 && + isset($_POST["startdatemin"]) && $_POST["startdatemin"] >= 0 && $_POST["startdatemin"] <= 59 && + isset($_POST["startdated"]) && isset($_POST["startdatem"]) && isset($_POST["startdatey"]) && + + checkdate($_POST["startdatem"], $_POST["startdated"], $_POST["startdatey"])) { + if ($_POST["confirmation"] == "confirm") { + $t = mktime ($_POST["startdateh"], $_POST["startdatemin"], 0, $_POST["startdatem"], $_POST["startdated"], $_POST["startdatey"]); + + $param['contestnumber']=$_SESSION["usertable"]["contestnumber"]; + $param['sitenumber']=$_POST["site"]; + $param['sitename']=$_POST["name"]; +// $param['siteip']=$_POST["ip"]; + $param['siteduration']=$_POST["duration"]*60; + $param['sitelastmileanswer']= $_POST["lastmileanswer"]*60; + $param['sitelastmilescore']= $_POST["lastmilescore"]*60; + $param['sitejudging']= $_POST["judging"]; + $param['sitetasking']= $_POST["tasking"]; + if(isset($_POST["autoend"])) + $param['siteautoend']= $_POST["autoend"]; + if(isset($_POST["globalscore"])) + $param['siteglobalscore']= $_POST["globalscore"]; + if(isset($_POST["active"])) + $param['siteactive']=$_POST["active"]; + $param['sitescorelevel']=$_POST["scorelevel"]; + $param['sitepermitlogins']=''; + if(isset($_POST["autojudge"])) + $param['siteautojudge']=$_POST["autojudge"]; + $param['sitechiefname']=$_POST["chiefname"]; + DBUpdateSite ($param); + $st1 = DBSiteInfo($_SESSION["usertable"]["contestnumber"],$_POST["site"]); + if($t != $st1["sitestartdate"]) { + $param = array('contest'=>$_SESSION["usertable"]["contestnumber"], + 'site'=>$_POST["site"], + 'start'=>$t); + DBRenewSiteTime($param); + } + } + ForceLoad("site.php?site=".$_POST["site"]); +} + + +if ($main && isset($_FILES["importfile"]) && isset($_POST["Submit"]) && $_POST["Submit"]=='Import' && $_FILES["importfile"]["name"]!="") { + if ($_POST["confirmation"] == "confirm") { + $type=myhtmlspecialchars($_FILES["importfile"]["type"]); + $size=myhtmlspecialchars($_FILES["importfile"]["size"]); + $name=myhtmlspecialchars($_FILES["importfile"]["name"]); + $temp=myhtmlspecialchars($_FILES["importfile"]["tmp_name"]); + if (!is_uploaded_file($temp)) { + IntrusionNotify("file upload problem."); + ForceLoad("../index.php"); + } + + if (($ar = file($temp)) === false) { + IntrusionNotify("Unable to open the uploaded file."); + ForceLoad("site.php"); + } + $userlist=array(); + if(strtolower(substr($name,-4))==".tsv") { + for ($i=0; $i= $count($ar)) MSGError('File format not recognized'); + $oklines=0; + for ($i++; $i 0) { +?> +
+
TAKE NOTE OF THE USERS AND PASSWORDS AND KEEP THEM SECRET

+ + + + + + $pass) { + echo "\n"; + } +?> +
UsernamePassword
$user$pass


TAKE NOTE OF THE USERS AND PASSWORDS AND KEEP THEM SECRET
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + +Start date (contest=" . dateconv($ct["conteststartdate"]) . "):"; +?> + + + +\n"; + echo " \n"; + echo " \n"; + echo " \n"; + if($st["siteautoended"]) + $w = (int) ($st["siteduration"]/60); + else + $w = (int) ($st["currenttime"]/60); + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; +} +?> + +Duration (contest="; +echo $ct["contestduration"]/60; +echo "):"; +?> + + + +Stop answering (contest="; +echo $ct["contestlastmileanswer"]/60; +echo "):"; +?> + + + +Stop scoreboard (contest="; +echo $ct["contestlastmilescore"]/60; +echo "):"; +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Site number: +\n"; +$cs = DBAllSiteInfo($_SESSION["usertable"]["contestnumber"]); +for ($i=0; $i" . $cs[$i]["sitenumber"] . "\n"; +} +if($main) { + echo "\n"; +} +echo "\n"; + +//else +// echo "\n"; + +if($ct["contestlocalsite"]==$site) echo "(local site)"; +?> +
Name: + " size="50" maxlength="50" /> +
IP (plus boca path): + " size="50" maxlength="200" /> +
IP (plus boca path): + +
hh:mm + " size="2" maxlength="2" /> + : + " size="2" maxlength="2" /> + dd/mm/yyyy + " size="2" maxlength="2" /> + / + " size="2" maxlength="2" /> + / + " size="4" maxlength="4" /> +
Site finished at:" . dateconv($st["siteendeddate"]) . "
Real duration:" . $w . " minutes
+ " size="20" maxlength="20" /> +
+ " size="20" maxlength="20" /> +
+ " size="20" maxlength="20" /> +
Runs/clars that will be judged here (comma sep): + " size="20" maxlength="200" /> +
Tasks that will be treated here (comma sep): + " size="20" maxlength="200" /> +
Username of the chief judge (if any): + " size="20" maxlength="20" /> +
Active: +"; + else + echo ""; +?> +
Autoend: +"; + else + echo ""; +?> +
Global score: + " size="20" maxlength="50" /> +
Autojudge (without human interaction): +"; + else + echo ""; + echo " <- experimental"; +?> +
Logins are: + +
Score level: + " size="2" maxlength="2" /> +
Number of Clars: +
Number of Runs: +
Number of Tasks: +
+
+
+ + + + + +
+ + + +


+ + + + + + +
+
+
+ + + + +"; + echo ""; + echo ""; + echo ""; +} +?> +
Starting atEnding at
"; + echo dateconv($sitetime[$i]["sitestartdate"]); + echo ""; + if($sitetime[$i]["siteenddate"] == 0) { + if($st["siterunning"]) + echo "still open"; + else echo "auto-ended"; + } + else + echo dateconv($sitetime[$i]["siteenddate"]); + echo "
+
+ + +
+ + + + + + +
+(Do not use this button unless really necessary) + : + hh:mm + " size="2" maxlength="2" /> + : + " size="2" maxlength="2" /> + dd/mm/yyyy + " size="2" maxlength="2" /> + / + " size="2" maxlength="2" /> + / + " size="4" maxlength="4" /> +
+
+ +

+
+ + + + + +
Import file: + +
+ +
+ +
+ + + + -- cgit v1.2.3