From a9aa438ea0558eb0044cf1e54a9190ddb41b65e5 Mon Sep 17 00:00:00 2001 From: cassio Date: Tue, 2 Jul 2013 09:44:46 +0400 Subject: restructuring of boca's git --- boca-1.5.2/src/admin/problem.php | 414 --------------------------------------- 1 file changed, 414 deletions(-) delete mode 100644 boca-1.5.2/src/admin/problem.php (limited to 'boca-1.5.2/src/admin/problem.php') diff --git a/boca-1.5.2/src/admin/problem.php b/boca-1.5.2/src/admin/problem.php deleted file mode 100644 index 6a894ba..0000000 --- a/boca-1.5.2/src/admin/problem.php +++ /dev/null @@ -1,414 +0,0 @@ -. -//////////////////////////////////////////////////////////////////////////////// -// Last modified 31/aug/2012 by cassio@ime.usp.br -if ($_POST["confirmation"] != "confirm") - unset($_POST['noflush']); - -require('header.php'); -if(($ct = DBContestInfo($_SESSION["usertable"]["contestnumber"])) == null) - ForceLoad("../index.php"); - -if (isset($_GET["delete"]) && is_numeric($_GET["delete"]) && isset($_GET["input"])) { - $param = array(); - $param['number']=$_GET["delete"]; - $param['inputfilename']=$_GET["input"]; - if(!DBDeleteProblem ($_SESSION["usertable"]["contestnumber"], $param)) { - MSGError('Error deleting problem'); - LogError('Error deleting problem'); - } - ForceLoad("problem.php"); -} - -if(isset($_POST['Submit5']) && $_POST['Submit5']=='Build') - ForceLoad("buildproblem.php"); - -if(isset($_POST['Submit5']) && $_POST['Submit5']=='Send') { - if(isset($_POST['basename']) && - isset($_POST['fullname']) && - isset($_POST['timelimit']) && - $_POST["confirmation"] == "confirm") { - if ($_FILES["probleminput"]["name"] != "") { - $type=myhtmlspecialchars($_FILES["probleminput"]["type"]); - $size=myhtmlspecialchars($_FILES["probleminput"]["size"]); - $name=myhtmlspecialchars($_FILES["probleminput"]["name"]); - $temp=myhtmlspecialchars($_FILES["probleminput"]["tmp_name"]); - if (!is_uploaded_file($temp)) { - ob_end_flush(); - IntrusionNotify("file upload problem."); - ForceLoad("../index.php"); - } - } else $name = ""; - if ($_FILES["problemsol"]["name"] != "") { - $type1=myhtmlspecialchars($_FILES["problemsol"]["type"]); - $size1=myhtmlspecialchars($_FILES["problemsol"]["size"]); - $name1=myhtmlspecialchars($_FILES["problemsol"]["name"]); - $temp1=myhtmlspecialchars($_FILES["problemsol"]["tmp_name"]); - if (!is_uploaded_file($temp1)) { - ob_end_flush(); - IntrusionNotify("file upload problem."); - ForceLoad("../index.php"); - } - } else $name1 = ""; - if (isset($_FILES["problemdesc"]) && $_FILES["problemdesc"]["name"] != "") { - $type2=myhtmlspecialchars($_FILES["problemdesc"]["type"]); - $size2=myhtmlspecialchars($_FILES["problemdesc"]["size"]); - $name2=myhtmlspecialchars($_FILES["problemdesc"]["name"]); - $temp2=myhtmlspecialchars($_FILES["problemdesc"]["tmp_name"]); - if (!is_uploaded_file($temp2)) { - ob_end_flush(); - IntrusionNotify("file upload problem."); - ForceLoad("../index.php"); - } - } else $name2 = ""; - - $ds = DIRECTORY_SEPARATOR; - if($ds=="") $ds = "/"; - $tmpdir = getenv("TMP"); - if($tmpdir=="") $tmpdir = getenv("TMPDIR"); - if($tmpdir[0] != $ds) $tmdir = $ds . "tmp"; - if($tmpdir=="") $tmpdir = $ds . "tmp"; - $locr = $_SESSION["locr"]; - $tfile = tempnam($tmpdir, "problem"); - if(@mkdir($tfile . "_d", 0700)) { - $dir = $tfile . "_d"; - @mkdir($dir . $ds . 'limits'); - @mkdir($dir . $ds . 'compare'); - @mkdir($dir . $ds . 'compile'); - @mkdir($dir . $ds . 'run'); - @mkdir($dir . $ds . 'input'); - @mkdir($dir . $ds . 'output'); - @mkdir($dir . $ds . 'tests'); - @mkdir($dir . $ds . 'description'); - $filea = array('compare' . $ds . 'c','compare' . $ds . 'cpp','compare' . $ds . 'java', - 'compile' . $ds . 'c','compile' . $ds . 'cpp','compile' . $ds . 'java', - 'run' . $ds . 'c','run' . $ds . 'cpp','run' . $ds . 'java'); - foreach($filea as $file) { - $rfile=$locr . $ds . '..' . $ds . 'doc' . $ds . 'problemexamples' . $ds . 'problemtemplate' . $ds . $file; - if(is_readable($rfile)) { - @copy($rfile, $dir . $ds . $file); - } else { - @unlink($tfile); - cleardir($dir); - ob_end_flush(); - MSGError('Could not read problem template file ' . $rfile); - ForceLoad('problem.php'); - } - } - $tl = explode(',',$_POST['timelimit']); - if(!isset($tl[1]) || !is_numeric(trim($tl[1]))) $tl[1]='1'; - $str = "echo " . trim($tl[0]) . "\necho " . trim($tl[1]) . "\necho 512\necho " . floor(10 + $size1 / 512) . "\nexit 0\n"; - file_put_contents($dir . $ds . 'limits' . $ds . 'c',$str); - file_put_contents($dir . $ds . 'limits' . $ds . 'cpp',$str); - file_put_contents($dir . $ds . 'limits' . $ds . 'java',$str); - $str = "basename=" . trim($_POST['basename']) . "\nfullname=" . trim($_POST['fullname']); - if($name2) { - @copy($temp2, $dir . $ds . 'description' . $ds . $name2); - @unlink($temp2); - $str .= "\ndescfile=" . $name2; - } - $str .= "\n"; - file_put_contents($dir . $ds . 'description' . $ds . 'problem.info',$str); - if($name && $name1) { - @copy($temp, $dir . $ds . 'input' . $ds . 'file1'); - @unlink($temp); - @copy($temp1, $dir . $ds . 'output' . $ds . 'file1'); - @unlink($temp1); - } else { - @unlink($tfile); - cleardir($dir); - ob_end_flush(); - MSGError('Could not read problem input/output files'); - ForceLoad('problem.php'); - } - $ret=create_zip($dir, glob($dir . $ds . '*'),$dir . '.zip'); - cleardir($dir); - if($ret <= 0) { - @unlink($tfile); - @unlink($dir . '.zip'); - ob_end_flush(); - MSGError('Could not write to zip file'); - ForceLoad('problem.php'); - } - $str = file_get_contents($dir . '.zip'); - @unlink($dir . '.zip'); - @unlink($tfile); - header ("Expires: " . gmdate("D, d M Y H:i:s") . " GMT"); - header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); - header ("Cache-Control: no-cache, must-revalidate"); - header ("Pragma: no-cache"); - header ("Content-transfer-encoding: binary\n"); - header ("Content-type: application/force-download"); - header ("Content-Disposition: attachment; filename=" . basename($dir . '.zip')); - ob_end_flush(); - echo $str; - exit; - } else { - @unlink($tfile); - ob_end_flush(); - MSGError('Could not write to temporary directory'); - } - } - ForceLoad('problem.php'); -} - -if (isset($_POST["Submit3"]) && isset($_POST["problemnumber"]) && is_numeric($_POST["problemnumber"]) && - isset($_POST["problemname"]) && $_POST["problemname"] != "") { - if ($_POST["confirmation"] == "confirm") { - if ($_FILES["probleminput"]["name"] != "") { - $type=myhtmlspecialchars($_FILES["probleminput"]["type"]); - $size=myhtmlspecialchars($_FILES["probleminput"]["size"]); - $name=myhtmlspecialchars($_FILES["probleminput"]["name"]); - $temp=myhtmlspecialchars($_FILES["probleminput"]["tmp_name"]); - if (!is_uploaded_file($temp)) { - IntrusionNotify("file upload problem."); - ForceLoad("../index.php"); - } - } else $name = ""; - - $param = array(); - $param['number'] = $_POST["problemnumber"]; - $param['name'] = $_POST["problemname"]; - $param['inputfilename'] = $name; - $param['inputfilepath'] = $temp; - $param['fake'] = 'f'; - $param['colorname'] = $_POST["colorname"]; - $param['color'] = $_POST["color"]; - DBNewProblem ($_SESSION["usertable"]["contestnumber"], $param); - } - ForceLoad("problem.php"); -} -?> -
- - - - - - - - - - - - -\n"; - if($prob[$i]["fake"]!='t') { - if(strpos($prob[$i]["fullname"],"(DEL)") !== false) { - echo " \n"; - } else { - echo " \n"; - } - echo " \n"; - echo " \n"; - echo " \n"; - if (isset($prob[$i]["descoid"]) && $prob[$i]["descoid"] != null && isset($prob[$i]["descfilename"])) { - echo " \n"; - } - else - echo " \n"; - if ($prob[$i]["inputoid"] != null) { - $tx = $prob[$i]["inputhash"]; - echo " \n"; - } - else - echo " \n"; -/* - if ($prob[$i]["soloid"] != null) { - $tx = $prob[$i]["solhash"]; - echo " \n"; - } - else - echo " \n"; - if ($prob[$i]["timelimit"]!="") - echo " \n"; - else - echo " \n"; -*/ - if ($prob[$i]["color"]!="") { - echo " \n"; - } else - echo " \n"; - echo " \n"; -} -echo "
Problem #Short NameFullnameBasenameDescfilePackage fileColor
" . $prob[$i]["number"]; - echo "(deleted)"; - } else { - echo " " . $prob[$i]["number"]; - } - echo "" . $prob[$i]["number"] . " (fake)" . $prob[$i]["name"] . "" . $prob[$i]["fullname"] . " " . $prob[$i]["basefilename"] . " " . - basename($prob[$i]["descfilename"]) . " " . - $prob[$i]["inputfilename"] . " " . - "\"$tx\"" . - " " . - $prob[$i]["solfilename"] . " ". - "\"$tx\"" . - " " . $prob[$i]["timelimit"] . " " . $prob[$i]["colorname"] . - "\"".$prob[$i]["colorname"]."\" 
"; -if (count($prob) == 0) echo "
NO PROBLEMS DEFINED
"; - -?> - -

Clicking on a problem number will delete it.
-WARNING: deleting a problem will remove EVERYTHING related to it.
-It is NOT recommended to change anything while the contest is running.
-To import a problem, fill in the following fields.
-To replace the data of a problem, proceed as if it did not exist (data will be replaced without removing it).
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - -
Number: - -
Short Name (usually a letter): - -
Problem package (ZIP): - -
Color name: - -
Color (RGB HTML format): - -
-
-
- - -
- -


To build a problem package from files, use this link: - -
-
- - - -- cgit v1.2.3