-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreinfo.php
103 lines (91 loc) · 4.15 KB
/
reinfo.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
<?php
$cache_time = 10;
$OJ_CACHE_SHARE = false;
require_once './include/cache_start.php';
require_once './include/db_info.inc.php';
require_once './include/setlang.php';
$view_title = "Welcome To Online Judge";
require_once "./include/const.inc.php";
if (!isset($_GET['sid'])) {
echo "No such code!\n";
require_once "oj-footer.php";
exit(0);
}
function is_valid($str2)
{
global $_SESSION, $OJ_NAME;
if (isset($_SESSION[$OJ_NAME . '_' . 'source_browser']) || isset($_SESSION[$OJ_NAME . '_' . 'administrator'])) {
//2020.01.20修改逻辑 管理员与源代码审查者均有查看RE_INFO权限
return true;
}
//return true; // 如果希望能让任何人都查看对比和RE,放开行首注释 if you fail to view diff , try remove the // at beginning of this line.
$n = strlen($str2);
$str = str_split($str2);
$m = 1;
for ($i = 0; $i < $n; $i++) {
if (is_numeric($str[$i])) {
$m++;
}
}
return $n / $m > 3;
}
$ok = false;
$id = strval(intval($_GET['sid']));
$sql = "SELECT * FROM `solution` WHERE `solution_id`=?";
$result = pdo_query($sql, $id);
$row = $result[0];
$lang = $row['language'];
$contest_id = intval($row['contest_id']);
$isRE = $row['result'] == 10;
// 用于具体评测信息页的顶部表格展示
$solution_info = array(
"sid" => $row['solution_id'],
"pid" => $row['problem_id'],
"uid" => $row['user_id'],
"time" => $row['time'],
"memory" => $row['memory'],
"length" => $row['code_length'],
"score" => $row['pass_rate'] * 100,
"date" => $row['judgetime']
);
if ($row && $row['user_id'] == $_SESSION[$OJ_NAME . '_' . 'user_id']) {
$ok = true;
}
if (isset($_SESSION[$OJ_NAME . '_' . 'source_browser']) || isset($_SESSION[$OJ_NAME . '_' . 'administrator'])) {
//2020.01.20修改逻辑 管理员与源代码审查者均有查看RE_INFO权限
$ok = true;
}
$view_reinfo = "";
if (
isset($_SESSION[$OJ_NAME . '_' . 'source_browser']) || isset($_SESSION[$OJ_NAME . '_' . 'administrator']) ||
($ok && $lang != 3 && $contest_id == 0 && // 防止打表过数据弱的题目
!( // 默认禁止比赛中查看WAd对比和RE详情
(isset($OJ_EXAM_CONTEST_ID) && $OJ_EXAM_CONTEST_ID > 0) || // 如果希望教学中无论练习或比赛均开放数据对比与运行错误,可以将这里
(isset($OJ_ON_SITE_CONTEST_ID) && $OJ_ON_SITE_CONTEST_ID > 0) // 的所有条件简化为 $ok,即40行到46行简化为: if($ok){
)) // if you want a friendly WA and RE, change line 38-43 to "if($ok){"
) {
if ($row['user_id'] != $_SESSION[$OJ_NAME . '_' . 'user_id']) {
$view_mail_link = "<a href='mail.php?to_user=" . htmlentities($row['user_id'], ENT_QUOTES, "UTF-8") . "&title=$MSG_SUBMIT $id'>Mail the auther</a>";
}
$sql = "SELECT `error` FROM `runtimeinfo` WHERE `solution_id`=?";
$result = pdo_query($sql, $id);
if (isset($result[0])) {
$row = $result[0];
}
if ($row && ($OJ_SHOW_DIFF || isset($_SESSION[$OJ_NAME . '_' . 'source_browser']) || isset($_SESSION[$OJ_NAME . '_' . 'administrator']) || $isRE) && ($OJ_TEST_RUN || is_valid($row['error']) || isset($_SESSION[$OJ_NAME . '_' . 'source_browser']))) {
$view_reinfo = htmlentities(str_replace("\n\r", "\n", $row['error']), ENT_QUOTES, "UTF-8");
} else {
$view_reinfo = "出于数据保密原因,当前错误提示不可查看,如果希望能让任何人都查看对比和运行错误,请管理员配置$OJ_SHOW_DIFF=true;<br>然后编辑本文件,开放18行首注释,令is_valid总是返回true。 <br>\n Sorry , not available (RE:" . $isRE . ",OJ_SHOW_DIFF:" . $OJ_SHOW_DIFF . ",TR:" . $OJ_TEST_RUN . ",valid:" . is_valid($row['error']) . ")";
}
} else {
$view_errors = "抱歉,您没有权限查看此信息!";
require "template/$OJ_TEMPLATE/error.php";
exit(0);
}
/////////////////////////Template
require "template/$OJ_TEMPLATE/reinfo.php";
require "oj-footer.php";
/////////////////////////Common foot
if (file_exists('./include/cache_end.php')) {
require_once './include/cache_end.php';
}