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/judge/team.php | 195 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 src/judge/team.php (limited to 'src/judge/team.php') diff --git a/src/judge/team.php b/src/judge/team.php new file mode 100644 index 0000000..11d03ad --- /dev/null +++ b/src/judge/team.php @@ -0,0 +1,195 @@ +. +//////////////////////////////////////////////////////////////////////////////// +// Last modified 21/jul/2012 by cassio@ime.usp.br +require('header.php'); + +if (isset($_FILES["sourcefile"]) && isset($_POST["problem"]) && isset($_POST["Submit"]) && isset($_POST["language"]) && + is_numeric($_POST["problem"]) && is_numeric($_POST["language"]) && $_FILES["sourcefile"]["name"]!="") { + if ($_POST["confirmation"] == "confirm") { + if(($ct = DBContestInfo($_SESSION["usertable"]["contestnumber"])) == null) + ForceLoad("../index.php"); + + $prob = myhtmlspecialchars($_POST["problem"]); + $lang = myhtmlspecialchars($_POST["language"]); + + $type=myhtmlspecialchars($_FILES["sourcefile"]["type"]); + $size=myhtmlspecialchars($_FILES["sourcefile"]["size"]); + $name=myhtmlspecialchars($_FILES["sourcefile"]["name"]); + $temp=myhtmlspecialchars($_FILES["sourcefile"]["tmp_name"]); + + if ($size > $ct["contestmaxfilesize"]) { + LOGLevel("User {$_SESSION["usertable"]["username"]} tried to submit file " . + "$name with $size bytes ({$ct["contestmaxfilesize"]} max allowed).", 1); + MSGError("File size exceeds the limit allowed."); + ForceLoad($runteam); + } + if(strpos($name,' ') === true || strpos($temp,' ') === true) { + MSGError("File name cannot contain spaces."); + ForceLoad($runteam); + } + if (!is_uploaded_file($temp) || strlen($name)>100) { + IntrusionNotify("file upload problem."); + ForceLoad("../index.php"); + } + + + $ac=array('contest','site','user','problem','lang','filename','filepath'); + $ac1=array('runnumber','rundate','rundatediff','rundatediffans','runanswer','runstatus','runjudge','runjudgesite', + 'runjudge1','runjudgesite1','runanswer1','runjudge2','runjudgesite2','runanswer2', + 'autoip','autobegindate','autoenddate','autoanswer','autostdout','autostderr','updatetime'); + $param = array('contest'=>$_SESSION["usertable"]["contestnumber"], + 'site'=>$_SESSION["usertable"]["usersitenumber"], + 'user'=> $_SESSION["usertable"]["usernumber"], + 'problem'=>$prob, + 'lang'=>$lang, + 'filename'=>$name, + 'filepath'=>$temp); + if($runteam=='team.php') $param['allowneg']=1; + DBNewRun ($param); + $_SESSION['forceredo']=true; + } + ForceLoad($runteam); +} + +$ds = DIRECTORY_SEPARATOR; +if($ds=="") $ds = "/"; + +$runtmp = $_SESSION["locr"] . $ds . "private" . $ds . "runtmp" . $ds . "run-contest" . $_SESSION["usertable"]["contestnumber"] . + "-site". $_SESSION["usertable"]["usersitenumber"] . "-user" . $_SESSION["usertable"]["usernumber"] . ".php"; +$redo = TRUE; +if(!isset($_SESSION['forceredo']) || $_SESSION['forceredo']==false) { + $actualdelay = 30; + if(file_exists($runtmp)) { + if(isset($strtmp) || (($strtmp = file_get_contents($runtmp,FALSE,NULL,-1,1000000)) !== FALSE)) { + list($d) = sscanf($strtmp,"%*s %d"); + if($d > time() - $actualdelay) { + $conf=globalconf(); + $strtmp = decryptData(substr($strtmp,strpos($strtmp,"\n")+1),$conf["key"],'runtmp'); + if($strtmp !== false) + $redo = FALSE; + } + } + } +} +if($redo) { + $_SESSION['forceredo']=false; + if(($st = DBSiteInfo($_SESSION["usertable"]["contestnumber"],$_SESSION["usertable"]["usersitenumber"])) == null) + ForceLoad("../index.php"); + $strtmp="
\n\n \n \n\n". + " \n \n \n \n \n"; + $strcolors = "0"; + $run = DBUserRuns($_SESSION["usertable"]["contestnumber"], + $_SESSION["usertable"]["usersitenumber"], + $_SESSION["usertable"]["usernumber"]); + for ($i=0; $i\n"; + $strtmp .= " \n"; + $strtmp .= " \n"; + $strtmp .= " \n"; +// $strtmp .= " \n"; + if (trim($run[$i]["answer"]) == "") { + $run[$i]["answer"] = "Not answered yet"; + $strtmp .= " \n"; + $strtmp .= "\n"; + + $strtmp .= " \n"; + + if ($run[$i]["anstime"]>$_SESSION["usertable"]["userlastlogin"]-$st["sitestartdate"] && $run[$i]["anstime"] < $st['sitelastmileanswer'] && + $run[$i]["ansfake"]!="t" && !isset($_SESSION["popups"]['run' . $i . '-' . $run[$i]["anstime"]])) { + $_SESSION["popups"]['run' . $i . '-' . $run[$i]["anstime"]] = "Run ".$run[$i]["number"]." result: ".$run[$i]["answer"]. "
"; + } + } +$strtmp .= "
Run #TimeProblemLanguageAnswerFile
" . dateconvminutes($run[$i]["timestamp"]) . "" . $run[$i]["problem"] . "" . $run[$i]["language"] . "" . $run[$i]["status"] . "Not answered yet"; + } + else { + $strtmp .= " " . $run[$i]["answer"]; + if($run[$i]['yes']=='t') { + $strtmp .= " \"".$run[$i]["colorname"]."\""; + $strcolors .= "\t" . $run[$i]["colorname"] . "\t" . $run[$i]["color"]; + } + } + $strtmp .= ""; + $strtmp .= $run[$i]["filename"] . ""; + + $strtmp .= "
"; +if (count($run) == 0) $strtmp .= "
NO RUNS AVAILABLE
"; + +$strtmp .= "

To submit a program, just fill in the following fields:
\n". +"
\n". +" \n". +"
\n". +" \n". +" \n". +" \n". +" \n". +" \n". +" \n". +" \n". +" \n". +" \n". +" \n". +" \n". +" \n". +" \n". +"
Problem:\n". +" \n". +"
Language: \n". +" \n". +"
Source code:\n". +" \n". +"
\n". +"
\n". +" \n". +"
\n". +" \n". +" \n". +"
\n". +"
\n"; + $conf=globalconf(); + $strtmp1 = " \t" . encryptData($strcolors,$conf["key"],false) . "\n" . encryptData($strtmp,$conf["key"],false); + $randnum = session_id() . "_" . rand(); + if(file_put_contents($runtmp . "_" . $randnum, $strtmp1,LOCK_EX)===FALSE) { + if(!isset($_SESSION['writewarn'])) { + LOGError("Cannot write to the user-run cache file $runtmp -- performance might be compromised"); + $_SESSION['writewarn']=true; + } + } + @rename($runtmp . "_" . $randnum, $runtmp); +} +echo $strtmp; +?> + + + + -- cgit v1.2.3