-
Notifications
You must be signed in to change notification settings - Fork 1
/
Question.php
253 lines (223 loc) · 9.12 KB
/
Question.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
<!DOCTYPE html>
<html lang="zh-cn">
<?php require_once('Php/HTML_Head.php') ?>
<?php
if (array_key_exists('Problem', $_GET)) {
$ProblemID = intval($_GET['Problem']);
$sql = "SELECT `Show` FROM `oj_problem` WHERE `proNum`=" . $ProblemID . " LIMIT 1";
$result = oj_mysql_query($sql);
$ShowRow = oj_mysql_fetch_array($result);
if (!isset($ShowRow['Show'])) {
header('Location: /Message.php?Msg=未找到题目');
die();
}
if ($ShowRow['Show'] == 0 && !can_edit_problem()) {
header('Location: /Message.php?Msg=题目已被隐藏');
die();
}
} else {
header('Location: /Message.php?Msg=未知题号');
die();
}
$sql = "SELECT * FROM `oj_problem` WHERE `proNum`='" . $ProblemID . "' LIMIT 1";
$result = oj_mysql_query($sql);
$ProblemData;
if ($result) {
$ProblemData = oj_mysql_fetch_array($result);
if (!$ProblemData) {
header('Location: /Message.php?Msg=未知题号');
die();
}
} else {
header('Location: /Message.php?Msg=查找失败');
die();
}
$sql = "SELECT count(*) AS value FROM `oj_status` WHERE `Status` = " . Accepted . " AND `Show`=1 AND `Problem` = " . $ProblemID;
if (can_edit_problem()) {
$sql = "SELECT count(*) AS value FROM `oj_status` WHERE `Status` = " . Accepted . " AND Problem = " . $ProblemID;
}
$rs = oj_mysql_query($sql);
$PassNum = oj_mysql_fetch_array($rs);
$PassNum = $PassNum['value'];
$sql = "SELECT count(*) AS value FROM `oj_status` WHERE `Show`=1 AND `Problem` = " . $ProblemID;
if (can_edit_problem()) {
$sql = "SELECT count(*) AS value FROM `oj_status` WHERE `Problem` = " . $ProblemID;
}
$rs = oj_mysql_query($sql);
$SubNum = oj_mysql_fetch_array($rs);
$SubmitNum = $SubNum['value'];
?>
<body>
<?php require_once('Php/Page_Header.php') ?>
<div class="container">
<script src="/CodeMirror/codemirror.js"></script>
<link rel="stylesheet" href="/CodeMirror/codemirror.css">
<script src="/CodeMirror/clike.js"></script>
<script src="/CodeMirror/pascal.js"></script>
<script src="/CodeMirror/python.js"></script>
<script src="/CodeMirror/matchbrackets.js"></script>
<link rel="stylesheet" href="/highlight/styles/default.css">
<script src="/highlight/highlight.pack.js"></script>
<script>
hljs.initHighlightingOnLoad("C", "C++", "Java", "Python");
</script>
<?php
if (can_edit_problem()) {
?>
<script>
function changeStatus() {
$.get(<?php echo '"/Php/ProblemStatus.php?Problem=' . $ProblemID . '"' ?>, function(msg) {
var obj = eval('(' + msg + ')');
if (obj.status === 0) {
location.reload();
}
});
}
</script>
<?php
}
?>
<div class="animated fadeInDown">
<h1 class="text-center"><?php echo $ProblemData['Name'] ?>
<?php
if (can_read_test()) {
echo '<a class="label label-success" href="/ViewData.php?Problem=' . $ProblemID . '">数据</a> ';
}
if (can_edit_problem()) {
echo '<a class="label label-warning" href="/NewProblem.php?Problem=' . $ProblemID . '">编辑</a> ';
}
if (can_edit_problem()) {
if ($ShowRow['Show'] == 1) {
echo '<a href="javascript:changeStatus()" class="label label-primary">隐藏</a>';
} else {
echo '<a href="javascript:changeStatus()" class="label label-info">显示</a>';
}
}
?>
</h1>
<table class="autotable" align="center">
<tr>
<td><b>时间限制:</b><?php echo $ProblemData['LimitTime'] ?>ms</td>
<td><b>内存限制:</b><?php echo $ProblemData['LimitMemory'] ?>kb</td>
</tr>
<tr>
<td><b>提交总数:</b><?php echo $SubmitNum ?></td>
<td><b>通过数量:</b><?php echo $PassNum ?></td>
</tr>
</table>
<br>
<center>
<div class="btn-group">
<button type="button" class="btn btn-default" id="btnShowSubmit" data-backdrop="static" data-toggle="modal" data-target="#submitcode">提交代码</button>
<a type="button" class="btn btn-default" href=<?php echo '"/Status.php?Problem=' . $ProblemID . '"' ?>>查看记录</a>
</div>
</center>
<h3>题目描述</h3>
<div class="panel panel-default">
<div class="panel-body">
<?php echo $ProblemData['Description'] ?>
</div>
</div>
<h3>输入格式</h3>
<div class="panel panel-default">
<div class="panel-body">
<?php echo $ProblemData['InputFormat'] ?>
</div>
</div>
<h3>输出格式</h3>
<div class="panel panel-default">
<div class="panel-body">
<?php echo $ProblemData['OutputFormat'] ?>
</div>
</div>
<h3>样例输入</h3>
<div class="panel panel-default">
<div class="panel-body">
<pre class="SlateFix"><?php echo $ProblemData['EmpInput'] ?></pre>
</div>
</div>
<h3>样例输出</h3>
<div class="panel panel-default">
<div class="panel-body">
<pre class="SlateFix"><?php echo $ProblemData['EmpOutput'] ?></pre>
</div>
</div>
<?php if ($ProblemData['Hint'] != '') { ?>
<h3>提示</h3>
<div class="panel panel-default">
<div class="panel-body">
<?php echo $ProblemData['Hint'] ?>
</div>
</div>
<?php } ?>
<?php if ($ProblemData['Source'] != '') { ?>
<h3>来源</h3>
<div class="panel panel-default">
<div class="panel-body">
<?php echo $ProblemData['Source'] ?>
</div>
</div>
<?php } ?>
<center>
<div class="btn-group">
<button type="button" class="btn btn-default" id="btnShowSubmit" data-backdrop="static" data-toggle="modal" data-target="#submitcode">提交代码</button>
<a type="button" class="btn btn-default" href=<?php echo '"/Status.php?Problem=' . $ProblemID . '"' ?>>查看记录</a>
</div>
</center>
</div>
<div class="modal fade" id="submitcode" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form id="codeform" onsubmit="return(pstsubmit());">
<div class="modal-body" id="codemodalbody">
<textarea hidden name="code" id="codeeditor"></textarea>
<textarea hidden name="pid" id="pid"><?php echo $ProblemID ?></textarea>
</div>
<div class="modal-footer">
<div class="float-left">
语言:
<select name="language" id="language" style="height:32px;width:120px;">
<option value="C">C</option>
<option value="C++">C++</option>
<option value="Java">Java</option>
<option value="Python3.7">Python3.7</option>
</select>
<button id="SubmitCodeButton" type="submit" class="btn btn-primary">提交代码</button>
</div>
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script src="/MathJax-master/MathJax.js?config=TeX-AMS_HTML-full"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
processEscapes: true
},
TeX: {
equationNumbers: { autoNumber: "AMS" },
Macros: {
du: '^\\circ',
vv: '\\overrightarrow',
bm: '\\boldsymbol',
}
},
"HTML-CSS": {
linebreaks: {automatic: true},
showMathMenu: false
},
menuSettings: {
zoom: "Double-Click"
}
});
</script>
<?php
$PageActive = '#problem';
require_once('Php/Page_Footer.php');
?>
</body>
</html>