Skip to content
This repository was archived by the owner on Mar 28, 2019. It is now read-only.

Commit 61e1a1d

Browse files
committed
Updated the admin panel to add a timout value
1 parent f14c672 commit 61e1a1d

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

admin/problems.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@
8585
<div class="tab-content">
8686
<div class="tab-pane active" id="tab1">
8787
Problem Title: <input style="width:700px;" type="text" id="title" name="title" value="<?php echo($selected['name']);?>"/><br/>
88+
<div class="controls">
89+
<div class="input-append">
90+
Time Limit: <input class="span2" id="appendedInput" size="8" type="text" name="time" value="<?php echo($selected['time']); ?>"><span class="add-on">ms</span>
91+
</div>
92+
</div>
93+
<br/>
8894
Detailed problem: <span class="label label-info">Markdown formatting supported</span></br/><br/>
8995
<textarea style="width:785px; height:400px;" name="problem" id="text"><?php echo($selected['text']);?></textarea><br/>
9096
</div>
@@ -113,6 +119,12 @@
113119
<div class="tab-content">
114120
<div class="tab-pane active" id="tab1">
115121
Problem Title: <input class="span8" type="text" id="title" name="title"/><br/>
122+
<div class="controls">
123+
<div class="input-append">
124+
Time Limit: <input class="span2" id="appendedInput" size="8" type="text" name="time"><span class="add-on">ms</span>
125+
</div>
126+
</div>
127+
<br/>
116128
Detailed problem: <span class="label label-info">Markdown formatting supported</span></br/><br/>
117129
<textarea style="height:400px;" class="span9" name="problem" id="text"></textarea><br/>
118130
</div>

admin/update.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@
4949
}
5050
} else if($_POST['action']=='addproblem') {
5151
// add a problem
52-
if(trim($_POST['title']) == "" or trim($_POST['problem']) == "")
52+
if(trim($_POST['title']) == "" or trim($_POST['problem']) == "" or !is_numeric($_POST['time']))
5353
header("Location: problems.php?derror=1");
5454
else {
55-
$query="INSERT INTO `problems` ( `name` , `text`, `input`, `output`) VALUES ('".mysql_real_escape_string($_POST['title'])."', '".mysql_real_escape_string($_POST['problem'])."', '".mysql_real_escape_string($_POST['input'])."', '".mysql_real_escape_string($_POST['output'])."')";
55+
$query="INSERT INTO `problems` ( `name` , `text`, `input`, `output`, `time`) VALUES ('".mysql_real_escape_string($_POST['title'])."', '".mysql_real_escape_string($_POST['problem'])."', '".mysql_real_escape_string($_POST['input'])."', '".mysql_real_escape_string($_POST['output'])."', '".$_POST['time']."')";
5656
mysql_query($query);
5757
header("Location: problems.php?added=1");
5858
}
5959
} else if($_POST['action']=='editproblem' and is_numeric($_POST['id'])) {
6060
// update an already existing problem
61-
if(trim($_POST['title']) == "" or trim($_POST['problem']) == "")
61+
if(trim($_POST['title']) == "" or trim($_POST['problem']) == "" or !is_numeric($_POST['time']))
6262
header("Location: problems.php?derror=1&action=edit&id=".$_POST['id']);
6363
else {
64-
mysql_query("UPDATE problems SET input='".mysql_real_escape_string($_POST['input'])."', output='".mysql_real_escape_string($_POST['output'])."', name='".mysql_real_escape_string($_POST['title'])."', text='".mysql_real_escape_string($_POST['problem'])."' WHERE sl='".$_POST['id']."'");
64+
$query = "UPDATE problems SET input='".mysql_real_escape_string($_POST['input'])."', output='".mysql_real_escape_string($_POST['output'])."', name='".mysql_real_escape_string($_POST['title'])."', text='".mysql_real_escape_string($_POST['problem'])."', time='".$_POST['time']."' WHERE sl='".$_POST['id']."'";
6565
mysql_query($query);
6666
header("Location: problems.php?updated=1&action=edit&id=".$_POST['id']);
6767
}

0 commit comments

Comments
 (0)