diff options
Diffstat (limited to 'src/admin/problem.php')
| -rw-r--r-- | src/admin/problem.php | 55 |
1 files changed, 44 insertions, 11 deletions
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>"; ?> |