-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathceinfo.php
More file actions
108 lines (104 loc) · 5.3 KB
/
ceinfo.php
File metadata and controls
108 lines (104 loc) · 5.3 KB
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
<?require_once("oj-header.php")?>
<title>Compile Error Info</title>
<?
require_once("./include/db_info.inc.php");
require_once("./include/const.inc.php");
if (!isset($_GET['sid'])){
echo "No such code!\n";
require_once("oj-footer.php");
exit(0);
}
$ok=false;
$id=strval(intval($_GET['sid']));
$sql="SELECT * FROM `solution` WHERE `solution_id`='".$id."'";
$result=mysql_query($sql);
$row=mysql_fetch_object($result);
if ($row && $row->user_id==$_SESSION['user_id']) $ok=true;
if (isset($_SESSION['source_browser'])) $ok=true;
if ($ok==true){
echo "<pre id='errtxt'>";
mysql_free_result($result);
$sql="SELECT `error` FROM `compileinfo` WHERE `solution_id`='".$id."'";
$result=mysql_query($sql);
$row=mysql_fetch_object($result);
echo htmlspecialchars(str_replace("\n\r","\n",$row->error))."</pre>";
echo "<div id='errexp'>Explain:</div>";
mysql_free_result($result);
}else{
mysql_free_result($result);
echo "I am sorry, You could not view this message!";
}
?>
<script>
var pats=new Array();
var exps=new Array();
pats[0]=/warning.*declaration of 'main' with no type/;
exps[0]="C++标准中,main函数必须有返回值";
pats[1]=/'.*' was not declared in this scope/;
exps[1]="变量没有声明过,检查下是否拼写错误!";
pats[2]=/main’ must return ‘int’/;
exps[2]="在标准C语言中,main函数返回值类型必须是int,教材和VC中使用void是非标准的用法";
pats[3]=/ .* was not declared in this scope/;
exps[3]="函数或变量没有声明过就进行调用,检查下是否导入了正确的头文件";
pats[4]=/printf.*was not declared in this scope/;
exps[4]="printf函数没有声明过就进行调用,检查下是否导入了stdio.h或cstdio头文件";
pats[5]=/ warning: ignoring return value of/;
exps[5]="警告:忽略了函数的返回值,可能是函数用错或者没有考虑到返回值异常的情况";
pats[6]=/:.*__int64’ undeclared/;
exps[6]="__int64没有声明,在标准C/C++中不支持微软VC中的__int64,请使用long long来声明64位变量";
pats[7]=/:.*expected ‘;’ before/;
exps[7]="前一行缺少分号";
pats[8]=/ .* undeclared \(first use in this function\)/;
exps[8]="变量使用前必须先进行声明,也有可能是拼写错误,注意大小写区分。";
pats[9]=/scanf.*was not declared in this scope/;
exps[9]="scanf函数没有声明过就进行调用,检查下是否导入了stdio.h或cstdio头文件";
pats[10]=/memset.*was not declared in this scope/;
exps[10]="memset函数没有声明过就进行调用,检查下是否导入了stdlib.h或cstdlib头文件";
pats[11]=/malloc.*was not declared in this scope/;
exps[11]="malloc函数没有声明过就进行调用,检查下是否导入了stdlib.h或cstdlib头文件";
pats[12]=/puts.*was not declared in this scope/;
exps[12]="puts函数没有声明过就进行调用,检查下是否导入了stdio.h或cstdio头文件";
pats[13]=/gets.*was not declared in this scope/;
exps[13]="gets函数没有声明过就进行调用,检查下是否导入了stdio.h或cstdio头文件";
pats[14]=/str.*was not declared in this scope/;
exps[14]="string类函数没有声明过就进行调用,检查下是否导入了string.h或cstring头文件";
pats[15]=/‘import’ does not name a type/;
exps[15]="不要将Java语言程序提交为C/C++,提交前注意选择语言类型。";
pats[16]=/asm’ undeclared/;
exps[16]="不允许在C/C++中嵌入汇编语言代码。";
pats[17]=/redefinition of/;
exps[17]="函数或变量重复定义,看看是否多次粘贴代码。";
pats[18]=/expected declaration or statement at end of input/;
exps[18]="程序好像没写完,看看是否复制粘贴时漏掉代码。";
pats[19]=/warning: unused variable/;
exps[19]="警告:变量声明后没有使用,检查下是否拼写错误,误用了名称相似的变量。";
pats[20]=/implicit declaration of function/;
exps[20]="函数隐性声明,检查下是否导入了正确的头文件。";
pats[21]=/too .* arguments to function/;
exps[21]="函数调用时提供的参数数量不对,检查下是否用错参数。";
pats[22]=/expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘namespace’/;
exps[22]="不要将C++语言程序提交为C,提交前注意选择语言类型。";
pats[23]=/stray ‘\\[0123456789]*’ in program/;
exps[23]="中文空格、标点等不能出现在程序中注释和字符串以外的部分。";
pats[24]=/division by zero/;
exps[24]="除以零将导致浮点溢出。";
pats[25]=/cannot be used as a function/;
exps[25]="变量不能当成函数用,检查变量名和函数名重复的情况,也可能是拼写错误。";
function explain(){
//alert("asdf");
var errmsg=document.getElementById("errtxt").innerHTML;
var expmsg="辅助解释:<br>";
for(var i=0;i<pats.length;i++){
var pat=pats[i];
var exp=exps[i];
var ret=pat.exec(errmsg);
if(ret){
expmsg+=ret+":"+exp+"<br>";
}
}
document.getElementById("errexp").innerHTML=expmsg;
//alert(expmsg);
}
explain();
</script>
<?require_once("oj-footer.php")?>