forked from svn2github/hustoj
/
db.sql
270 lines (242 loc) · 11.6 KB
/
db.sql
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
set names utf8mb4;
create database if not exists jol ;
use jol;
CREATE TABLE IF NOT EXISTS `compileinfo` (
`solution_id` int(11) NOT NULL DEFAULT 0,
`error` text,
PRIMARY KEY (`solution_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `contest` (
`contest_id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) DEFAULT NULL,
`start_time` datetime DEFAULT NULL,
`end_time` datetime DEFAULT NULL,
`defunct` char(1) NOT NULL DEFAULT 'N',
`description` text,
`private` tinyint(4) NOT NULL DEFAULT '0',
`langmask` int NOT NULL DEFAULT '0' COMMENT 'bits for LANG to mask',
`password` CHAR( 16 ) NOT NULL DEFAULT '',
`user_id` varchar(48) NOT NULL DEFAULT 'admin',
PRIMARY KEY (`contest_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `contest_problem` (
`problem_id` int(11) NOT NULL DEFAULT '0',
`contest_id` int(11) DEFAULT NULL,
`title` char(200) NOT NULL DEFAULT '',
`num` int(11) NOT NULL DEFAULT '0',
`c_accepted` int(11) NOT NULL DEFAULT '0',
`c_submit` int(11) NOT NULL DEFAULT '0',
KEY `Index_contest_id` (`contest_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `loginlog` (
`user_id` varchar(48) NOT NULL DEFAULT '',
`password` varchar(40) DEFAULT NULL,
`ip` varchar(46) DEFAULT NULL,
`time` datetime DEFAULT NULL,
KEY `user_log_index` (`user_id`,`time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `mail` (
`mail_id` int(11) NOT NULL AUTO_INCREMENT,
`to_user` varchar(48) NOT NULL DEFAULT '',
`from_user` varchar(48) NOT NULL DEFAULT '',
`title` varchar(200) NOT NULL DEFAULT '',
`content` text,
`new_mail` tinyint(1) NOT NULL DEFAULT '1',
`reply` tinyint(4) DEFAULT '0',
`in_date` datetime DEFAULT NULL,
`defunct` char(1) NOT NULL DEFAULT 'N',
PRIMARY KEY (`mail_id`),
KEY `uid` (`to_user`)
) ENGINE=MyISAM AUTO_INCREMENT=1013 DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `news` (
`news_id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` varchar(48) NOT NULL DEFAULT '',
`title` varchar(200) NOT NULL DEFAULT '',
`content` mediumtext NOT NULL,
`time` datetime NOT NULL DEFAULT '2016-05-13 19:24:00',
`importance` tinyint(4) NOT NULL DEFAULT '0',
`menu` int(11) NOT NULL DEFAULT '0',
`defunct` char(1) NOT NULL DEFAULT 'N',
PRIMARY KEY (`news_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1004 DEFAULT CHARSET=utf8mb4;
INSERT INTO `news`(user_id,title,content,time,importance,menu,defunct) VALUES ('zhblue','HelloWorld!','\r\n 这是一个新安装的HUSTOJ系统,有关它的使用和配置,请看以下链接:\r\n<br />\r\n\r\n <ul>\r\n <li>\r\n <a href=\"http://hustoj.com\" target=\"_blank\">hustoj.com</a> 最新的常见问题\r\n </li>\r\n <li>\r\n <a href=\"https://gitee.com/zhblue/hustoj\" target=\"_blank\">gitee.com</a> 国内的镜像站,不定期同步github的源码\r\n </li>\r\n <li>\r\n <a href=\"http://github.com/zhblue/hustoj\" target=\"_blank\">github.com</a> 国外的主站,最新源码在这里\r\n </li>\r\n <li>\r\n <a href=\"https://zhblue.github.io/hustoj/\" target=\"_blank\">https://zhblue.github.io/hustoj/</a> 中文基础操作文档\r\n </li>\r\n <li>\r\n <a href=\"https://gitee.com/zhblue/hustoj/tree/master/wiki\" target=\"_blank\">wiki</a> 英文高阶文档\r\n </li>\r\n </ul>\r\n<br />\r\n\r\n 如果需要题目,可以访问:\r\n<br />\r\n\r\n <ul>\r\n <li>\r\n <a href=\"http://tk.hustoj.com\" target=\"_blank\">tk.hustoj.com</a> 注册即可下载免费专区的1000多道题目,使用购物车可以批量下载,下载到的xm<x>l文件可以直接导入系统。\r\n </li>\r\n <li>\r\n <a href=\"https://github.com/zhblue/freeproblemset/tree/master/fps-examples\" target=\"_blank\">FPS sample</a> FPS主站样例有部分题目可用。\r\n </li>\r\n <li>\r\n <a href=\"https://github.com/Azure99/EasyFPSViewer/releases\" target=\"_blank\">EasyFPSViewer</a> 是一个Windows下的FPS/xm<x>l编辑查看工具,可以查看、分割、提取xm<x>l中的题目。\r\n </li><li>\r\n<a href=\"http://royqh.net/redpandacpp/download/\" target=\"_blank\">小熊猫C++</a> 是一个Windows下的IDE, 是DEV-C++的精神继承者。\r\n</li>\r\n </ul>\r\n<br />\r\n\r\n <br />\r\n<br />\r\n\r\n 当你已经熟练使用本系统,可以在后台公告列表编辑本页内容或者隐藏它。\r\n<br />','2009-06-13 18:00:00',0,0,'N');
CREATE TABLE IF NOT EXISTS `privilege` (
`user_id` char(48) NOT NULL DEFAULT '',
`rightstr` char(30) NOT NULL DEFAULT '',
`valuestr` char(11) NOT NULL DEFAULT 'true',
`defunct` char(1) NOT NULL DEFAULT 'N',
KEY `user_id_index` (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `problem` (
`problem_id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(200) NOT NULL DEFAULT '',
`description` mediumtext,
`input` mediumtext,
`output` mediumtext,
`sample_input` text,
`sample_output` text,
`spj` char(1) NOT NULL DEFAULT '0',
`hint` text,
`source` varchar(100) DEFAULT NULL,
`in_date` datetime DEFAULT NULL,
`time_limit` DECIMAL(10,3) NOT NULL DEFAULT 0,
`memory_limit` int(11) NOT NULL DEFAULT 0,
`defunct` char(1) NOT NULL DEFAULT 'N',
`accepted` int(11) DEFAULT '0',
`submit` int(11) DEFAULT '0',
`solved` int(11) DEFAULT '0',
`remote_oj` varchar(16) DEFAULT NULL,
`remote_id` varchar(32) DEFAULT NULL,
PRIMARY KEY (`problem_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `reply` (
`rid` int(11) NOT NULL AUTO_INCREMENT,
`author_id` varchar(48) NOT NULL,
`time` datetime NOT NULL DEFAULT '2016-05-13 19:24:00',
`content` text NOT NULL,
`topic_id` int(11) NOT NULL,
`status` int(2) NOT NULL DEFAULT '0',
`ip` varchar(46) NOT NULL,
PRIMARY KEY (`rid`),
KEY `author_id` (`author_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `sim` (
`s_id` int(11) NOT NULL,
`sim_s_id` int(11) DEFAULT NULL,
`sim` int(11) DEFAULT NULL,
PRIMARY KEY (`s_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `solution` (
`solution_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`problem_id` int(11) NOT NULL DEFAULT 0,
`user_id` char(48) NOT NULL,
`nick` char(20) NOT NULL DEFAULT '',
`time` int(11) NOT NULL DEFAULT 0,
`memory` int(11) NOT NULL DEFAULT 0,
`in_date` datetime NOT NULL DEFAULT '2016-05-13 19:24:00',
`result` smallint(6) NOT NULL DEFAULT '0',
`language` INT UNSIGNED NOT NULL DEFAULT '0',
`ip` char(46) NOT NULL,
`contest_id` int(11) DEFAULT 0,
`valid` tinyint(4) NOT NULL DEFAULT '1',
`num` tinyint(4) NOT NULL DEFAULT '-1',
`code_length` int(11) NOT NULL DEFAULT 0,
`judgetime` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`pass_rate` DECIMAL(4,3) UNSIGNED NOT NULL DEFAULT 0,
`lint_error` int UNSIGNED NOT NULL DEFAULT 0,
`judger` CHAR(16) NOT NULL DEFAULT 'LOCAL',
`remote_oj` char(16) not NULL DEFAULT '',
`remote_id` char(32) not NULL DEFAULT '',
PRIMARY KEY (`solution_id`),
KEY `uid` (`user_id`),
KEY `pid` (`problem_id`),
KEY `res` (`result`),
KEY `cid` (`contest_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1001 DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `source_code` (
`solution_id` int(11) NOT NULL,
`source` text NOT NULL,
PRIMARY KEY (`solution_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS source_code_user like source_code;
CREATE TABLE IF NOT EXISTS `topic` (
`tid` int(11) NOT NULL AUTO_INCREMENT,
`title` varbinary(60) NOT NULL,
`status` int(2) NOT NULL DEFAULT '0',
`top_level` int(2) NOT NULL DEFAULT '0',
`cid` int(11) DEFAULT NULL,
`pid` int(11) NOT NULL,
`author_id` varchar(48) NOT NULL,
PRIMARY KEY (`tid`),
KEY `cid` (`cid`,`pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `users` (
`user_id` varchar(48) NOT NULL DEFAULT '',
`email` varchar(100) DEFAULT NULL,
`submit` int(11) DEFAULT '0',
`solved` int(11) DEFAULT '0',
`defunct` char(1) NOT NULL DEFAULT 'N',
`ip` varchar(46) NOT NULL DEFAULT '',
`accesstime` datetime DEFAULT NULL,
`volume` int(11) NOT NULL DEFAULT '1',
`language` int(11) NOT NULL DEFAULT '1',
`password` varchar(32) DEFAULT NULL,
`reg_time` datetime DEFAULT NULL,
`nick` varchar(20) NOT NULL DEFAULT '',
`school` varchar(20) NOT NULL DEFAULT '',
`group_name` varchar(16) not null default '',
`activecode` varchar(16) not null default '',
PRIMARY KEY (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `online` (
`hash` varchar(32) collate utf8mb4_unicode_ci NOT NULL,
`ip` varchar(46) character set utf8mb4 NOT NULL default '',
`ua` varchar(255) character set utf8mb4 NOT NULL default '',
`refer` varchar(255) collate utf8mb4_unicode_ci default NULL,
`lastmove` int(10) NOT NULL,
`firsttime` int(10) default NULL,
`uri` varchar(255) collate utf8mb4_unicode_ci default NULL,
PRIMARY KEY (`hash`),
UNIQUE KEY `hash` (`hash`)
) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `runtimeinfo` (
`solution_id` int(11) NOT NULL DEFAULT 0,
`error` text,
PRIMARY KEY (`solution_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `custominput` (
`solution_id` int(11) NOT NULL DEFAULT 0,
`input_text` text,
PRIMARY KEY (`solution_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `printer` (
`printer_id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` char(48) NOT NULL,
`in_date` datetime NOT NULL DEFAULT '2018-03-13 19:38:00',
`status` smallint(6) NOT NULL DEFAULT '0',
`worktime` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`printer` CHAR(16) NOT NULL DEFAULT 'LOCAL',
`content` text NOT NULL ,
PRIMARY KEY (`printer_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `balloon` (
`balloon_id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` char(48) NOT NULL,
`sid` int(11) NOT NULL ,
`cid` int(11) NOT NULL ,
`pid` int(11) NOT NULL ,
`status` smallint(6) NOT NULL DEFAULT '0',
PRIMARY KEY (`balloon_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `share_code` (
`share_id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` varchar(48) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`title` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`share_code` text COLLATE utf8mb4_unicode_ci,
`language` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`share_time` datetime DEFAULT NULL,
PRIMARY KEY (`share_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;
delimiter //
drop trigger if exists simfilter//
create trigger simfilter
before insert on sim
for each row
begin
declare new_user_id varchar(64);
declare old_user_id varchar(64);
select user_id from solution where solution_id=new.s_id into new_user_id;
select user_id from solution where solution_id=new.sim_s_id into old_user_id;
if old_user_id=new_user_id then
set new.s_id=0;
end if;
end//
CREATE PROCEDURE DEFAULT_ADMINISTRATOR(user_name VARCHAR(48))
BEGIN
DECLARE privileged_count INT DEFAULT 0;
SET privileged_count=(SELECT COUNT(1) FROM `privilege`);
IF privileged_count=0 THEN
INSERT INTO privilege values(user_name, 'administrator', 'true', 'N');
end if;
end//
delimiter ;