forked from BNUACM/bnuoj-web-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contest_prob.php
323 lines (315 loc) · 10.3 KB
/
contest_prob.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
<?php
include_once('conn.php');
$cpid = convert_str($_GET['cpid']);
if ($cpid==0&&isset($_GET['cid'])) {
$cid=convert_str($_GET['cid']);
$query = "select contest_problem.cpid from contest_problem where contest_problem.cid='$cid' order by contest_problem.lable asc limit 0,1";
list($cpid) = mysql_fetch_array(mysql_query($query));
}
$query = "select contest_problem.cid,contest_problem.pid,contest_problem.lable,contest.isprivate from contest_problem,contest where contest_problem.cpid='$cpid' and contest.cid=contest_problem.cid";
$result = mysql_query($query);
$row=@mysql_fetch_row($result);
$cid=$row[0];
$pid=$row[1];
$label=$row[2];
$isvirtual=$row[3];
$lastlang=$_COOKIE["lastlang"];
if ($lastlang==null) $lastlang=1;
if (mysql_num_rows($result)==0||!db_contest_started($cid)||($isvirtual==1&&(!db_user_in_contest($cid,$nowuser)||!db_user_match($nowuser, $nowpass)))) {
?>
<div id="one_content_container">
<div id="one_content_top"></div>
<div id="one_content">
<p>
<div class="error"><b>Problem Unavailable! Or it's a private contest!</b></div>
</p>
</div>
<div id="one_content_base"></div>
</div>
<?php
}else {
echo " <div id=\"sidebar_container\">";
include("contest_sidebar.php");
echo " </div>";
$query="select title,description,input,output,sample_in,sample_out,hint,source,time_limit,case_time_limit,memory_limit,special_judge_status,hide,vname,vid,ignore_noc from problem where pid='$pid'";
$result = mysql_query($query);
list($ptitle,$desc,$inp,$oup,$sin,$sout,$hint,$source,$tl,$ctl,$ml,$spj,$hide,$vname,$vid,$ignoc)=@mysql_fetch_row($result);
if ($ml=="0") $ml="Unknown ";
if ($tl=="0") $tl="Unknown ";
if ($ctl=="0") $ctl="Unknown ";
?>
<div id="content_container">
<div id="content_top"></div>
<div id="content">
<!-- insert the page content here -->
Current Server Time: <span id="servertime"><?php echo date("Y-m-d H:i:s"); ?></span>
<?php
if (mysql_num_rows($result)!=1) {
?>
<p>
<div class="error"><b>Problem Unavailable!</b></div>
</p>
<?php
} else {
?>
<div id="showproblem">
<div class="center" id="probpagi">
<?php
$cha = "SELECT lable,cpid FROM contest_problem WHERE cid = '$cid' order by lable asc";
$que = mysql_query($cha);
while ( $go = mysql_fetch_array($que) ) {
?>
<a href="#problem/<?php echo $go['cpid'] ?>" class="button"><?php echo $go['lable'] ?></a>
<?php
}
?>
</div>
<h1 class="center pagetitle"><?php echo $label.". ".$ptitle; ?></h1>
<div id="conditions">
<?php if($ignoc=="0") { ?>
<div style="float:left; width:33%"><label>Time Limit: </label><?php echo $tl; ?>ms</div>
<div style="float:left; width:33%"><label>Case Time Limit: </label><?php echo $ctl; ?>ms</div>
<div style="float:left; width:33%"><label>Memory Limit: </label><?php echo $ml; ?>KB</div>
<?php } else { ?>
<div style="float:left; width:50%"><label>Case Time Limit: </label><?php echo $ctl; ?>ms</div>
<div style="float:left; width:50%"><label>Memory Limit: </label><?php echo $ml; ?>KB</div>
<?php } ?>
<?php
if ($spj) {
?>
<div id="spjinfo">Special Judge</div>
<?php
}
?>
<div style="clear:both"></div>
</div>
<div class="extrainfo ui-state-highlight">
<?php
$ojrow=mysql_fetch_array(mysql_query("select * from ojinfo where name='$vname'"));
echo "64-bit integer IO format: <b style='color:black'>".htmlspecialchars($ojrow['int64io'])."</b> Java class name: <b style='color:black'>".htmlspecialchars($ojrow['javaclass'])."</b>";
?>
</div>
<div class="functions center">
<?php
if (db_contest_type($cid)!=99) {
?>
<a href="#" class="submitprob button">Submit</a>
<a href="#status/<?php echo $label?>" class="button">Status</a>
<?php
}
?>
<?php
if (db_contest_passed($cid)) {
?>
<a href="problem_show.php?pid=<?php echo $pid; ?>" class="goprob button">PID: <?php echo $pid; ?></a>
<?php
}
?>
<?php
if (db_user_match($nowuser,$nowpass)&&db_user_isroot($nowuser)) {
?>
<a href="admin_index.php?pid=<?php echo $pid;?>#problemtab" class="button">Edit</a>
<?php
}
?>
</div>
<div class="functions center">
<b>Font Size:</b> <button id="font-plus">+</button> <button id="font-minus">-</button>
</div>
<?php
if ($desc!="") {
?>
<div class="content-wrapper ui-corner-all">
<?php
$desc=preg_replace('/<head[\s\S]*\/head>/', "", $desc);
echo latex_content($desc)."\n";
?>
<div style="clear:both"></div>
</div>
<?php
}
?>
<?php
if ($inp!="") {
?>
<h2> Input </h2>
<div class="content-wrapper ui-corner-all">
<?php
echo latex_content($inp)."\n";
?>
<div style="clear:both"></div>
</div>
<?php
}
?>
<?php
if ($oup!="") {
?>
<h2> Output </h2>
<div class="content-wrapper ui-corner-all">
<?php
echo latex_content($oup)."\n";
?>
<div style="clear:both"></div>
</div>
<?php
}
?>
<?php
if ($sin!="") {
?>
<h2> Sample Input </h2>
<div class="content-wrapper ui-corner-all">
<?php
if (stristr($sin,'<br')==null&&stristr($sin,'<pre')==null&&stristr($sin,'<p>')==null) {
?>
<pre>
<?php
}
?>
<?php
echo $sin;
?>
<?php
if (stristr($sin,'<br')==null&&stristr($sin,'<pre')==null&&stristr($sin,'<p>')==null) {
?>
</pre>
<?php
}
?>
<div style="clear:both"></div>
</div>
<?php
}
?>
<?php
if ($sout!="") {
?>
<h2> Sample Output </h2>
<div class="content-wrapper ui-corner-all">
<?php
if (stristr($sout,'<br')==null&&stristr($sin,'<pre')==null&&stristr($sout,'<p>')==null) {
?>
<pre>
<?php
}
?>
<?php
echo $sout;
?>
<?php
if (stristr($sout,'<br')==null&&stristr($sin,'<pre')==null&&stristr($sout,'<p>')==null) {
?>
</pre>
<?php
}
?>
<div style="clear:both"></div>
</div>
<?php
}
?>
<?php
if (trim(strip_tags($hint))!=""||strlen($hint)>50) {
?>
<h2> Hint </h2>
<div class="content-wrapper ui-corner-all">
<?php
echo latex_content($hint)."\n";
?>
<div style="clear:both"></div>
</div>
<?php
}
?>
<div class="functions center" style="margin-bottom:0">
<?php
if (db_contest_type($cid)!=99) {
?>
<a href="#" class="submitprob button">Submit</a>
<a href="#status/<?php echo $label?>" class="button">Status</a>
<?php
}
?>
<?php
if (db_contest_passed($cid)) {
?>
<a href="problem_show.php?pid=<?php echo $pid; ?>" class="goprob button">PID: <?php echo $pid; ?></a>
<?php
}
?>
<?php
if (db_user_match($nowuser,$nowpass)&&db_user_isroot($nowuser)) {
?>
<a href="admin_index.php?pid=<?php echo $pid;?>#problemtab" class="button">Edit</a>
<?php
}
?>
</div>
</div>
<?php
}
?>
</div>
<div id="content_base"></div>
</div>
<?php
}
?>
<div id="submitdialog" class="topdialog" title="Submit <?php echo $label ?>: " name="<?php echo $vname ?>" style="display:none">
<form action="#" method="post" id="cprobsubmit">
<table width="100%">
<tr>
<th style="width:120px">Username: </th>
<td style="text-align:left;"><?php echo $nowuser ?><input name="user_id" value="<?php echo $nowuser ?>" readonly="readonly" style="display:none"></td>
</tr>
<tr style="display:none">
<th>Problem: </th>
<td><?php echo $label ?><input name="lable" value="<?php echo $label ?>" readonly="readonly" style="display:none"></td>
</tr>
<tr style="display:none">
<th>Contest: </th>
<td><?php echo $cid ?><input name="contest_id" value="<?php echo $cid ?>" readonly="readonly" style="display:none"></td>
</tr>
<tr>
<th>Language: </th>
<td style="text-align:left;">
<select name="language" id="lang" accesskey="l">
<option value="1" <?php if ($lastlang==1) echo "selected='selected'"; ?>>GNU C++</option>
<option value="2" <?php if ($lastlang==2) echo "selected='selected'"; ?>>GNU C</option>
<option value="3" <?php if ($lastlang==3) echo "selected='selected'"; ?>>Oracle Java</option>
<option value="4">Free Pascal</option>
<option value="5">Python</option>
<option value="6">C# (Mono)</option>
<option value="7">Fortran</option>
<option value="8">Perl</option>
<option value="9">Ruby</option>
<option value="10">Ada</option>
<option value="11">SML</option>
<option value="12">Visual C++</option>
<option value="13">Visual C</option>
<option value="14">CLang</option>
<option value="15">CLang++</option>
</select>
</td>
</tr>
<tr>
<th>Share Code?</th>
<td style="text-align:left;">
<input name="isshare" type="radio" style="width:16px" value="1" />Yes <input name="isshare" value="0" type="radio" style="width:16px" />No
</td>
</tr>
<tr>
<th colspan="2" style="width:120px">Source Code: </th>
</tr>
<tr>
<td colspan="2"><textarea rows="16" name="source" style="width:450px" accesskey="c" onKeyUp="if(this.value.length > 327680) this.value=this.value.substr(0,327680)"></textarea></td>
</tr>
</table>
<div class="center">
<input name='submit' type='submit' value='Submit' accesskey="s" />
<span id="submitmsgbox" style="display:none; z-index:600;"></span>
<input name='reset' type='reset' value='Reset' accesskey="r" />
</div>
</form>
</div>