refactor: sync code from uoj.ac

This commit is contained in:
Baoshuo Ren 2022-11-06 10:26:21 +08:00
parent 26809917a1
commit 844c93da84
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
144 changed files with 17388 additions and 11478 deletions

View File

@ -1,16 +0,0 @@
name: Lint & Test
on:
- push
- pull_request
jobs:
php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=./web/.php-cs-fixer.php --diff --dry-run

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
uoj_data/
uoj_data_1/
uoj_data_2/
.php-cs-fixer.cache
docker-compose.local.yml

16
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,16 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}

4
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"intelephense.format.braces": "k&r",
"intelephense.completion.triggerParameterHints": false
}

View File

@ -1,4 +1,4 @@
FROM mysql:5.7
FROM mysql:8.0
ADD . /opt/uoj_db
WORKDIR /opt/uoj_db

View File

@ -1,2 +1,2 @@
USE `app_uoj233`;
insert into judger_info (judger_name, password, ip) values ('compose_judger', '_judger_password_', 'uoj-judger');
insert into judger_info (judger_name, password, ip, display_name, description) values ('compose_judger', '_judger_password_', 'uoj-judger', '内建 Judger', '');

View File

@ -30,18 +30,18 @@ USE `app_uoj233`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `best_ac_submissions` (
`problem_id` int(11) NOT NULL,
`problem_id` int NOT NULL,
`submitter` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`submission_id` int(11) NOT NULL,
`used_time` int(11) NOT NULL,
`used_memory` int(11) NOT NULL,
`tot_size` int(11) NOT NULL,
`shortest_id` int(11) NOT NULL,
`shortest_used_time` int(11) NOT NULL,
`shortest_used_memory` int(11) NOT NULL,
`shortest_tot_size` int(11) NOT NULL,
`submission_id` int NOT NULL,
`used_time` int NOT NULL,
`used_memory` int NOT NULL,
`tot_size` int NOT NULL,
`shortest_id` int NOT NULL,
`shortest_used_time` int NOT NULL,
`shortest_used_memory` int NOT NULL,
`shortest_tot_size` int NOT NULL,
PRIMARY KEY (`problem_id`,`submitter`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci TABLESPACE `innodb_system`;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -60,16 +60,20 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `blogs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id` int NOT NULL AUTO_INCREMENT,
`title` text COLLATE utf8mb4_unicode_ci NOT NULL,
`content` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
`content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`post_time` datetime NOT NULL,
`active_time` datetime NOT NULL,
`poster` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`content_md` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
`zan` int(11) NOT NULL,
`content_md` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`zan` int NOT NULL DEFAULT '0',
`is_hidden` tinyint(1) NOT NULL,
`type` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'B',
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
KEY `post_time` (`post_time`),
KEY `active_time` (`active_time`),
KEY `poster` (`poster`,`is_hidden`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -89,14 +93,19 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `blogs_comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`blog_id` int(11) NOT NULL,
`id` int NOT NULL AUTO_INCREMENT,
`blog_id` int NOT NULL,
`content` text COLLATE utf8mb4_unicode_ci NOT NULL,
`post_time` datetime NOT NULL,
`poster` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`zan` int(11) NOT NULL,
`reply_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
`zan` int NOT NULL,
`reply_id` int NOT NULL,
`is_hidden` tinyint(1) NOT NULL DEFAULT '0',
`reason_to_hide` varchar(10000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `reply_id` (`reply_id`,`id`),
KEY `blog_id` (`blog_id`,`post_time`),
KEY `blog_id_2` (`blog_id`,`reply_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -116,8 +125,8 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `blogs_tags` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`blog_id` int(11) NOT NULL,
`id` int NOT NULL AUTO_INCREMENT,
`blog_id` int NOT NULL,
`tag` varchar(30) NOT NULL,
PRIMARY KEY (`id`),
KEY `blog_id` (`blog_id`),
@ -143,8 +152,8 @@ UNLOCK TABLES;
CREATE TABLE `click_zans` (
`type` char(2) COLLATE utf8mb4_unicode_ci NOT NULL,
`username` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`target_id` int(11) NOT NULL,
`val` tinyint(4) NOT NULL DEFAULT '1',
`target_id` int NOT NULL,
`val` tinyint NOT NULL DEFAULT '1',
PRIMARY KEY (`type`,`target_id`,`username`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -165,15 +174,17 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `contests` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`start_time` datetime NOT NULL,
`last_min` int(11) NOT NULL,
`player_num` int(11) NOT NULL,
`status` varchar(50) NOT NULL,
`extra_config` varchar(200) NOT NULL,
`zan` int(11) NOT NULL,
PRIMARY KEY (`id`)
`end_time` datetime GENERATED ALWAYS AS ((`start_time` + interval `last_min` minute)) VIRTUAL NOT NULL,
`last_min` int NOT NULL,
`player_num` int NOT NULL DEFAULT '0',
`status` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`extra_config` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '{}',
`zan` int NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `status` (`status`,`id`) USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -193,15 +204,17 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `contests_asks` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`contest_id` int(11) NOT NULL,
`id` int NOT NULL AUTO_INCREMENT,
`contest_id` int NOT NULL,
`username` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`question` text NOT NULL,
`answer` text NOT NULL,
`post_time` datetime NOT NULL,
`reply_time` datetime NOT NULL,
`is_hidden` tinyint(1) DEFAULT '0',
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
KEY `contest_id` (`contest_id`,`is_hidden`,`username`) USING BTREE,
KEY `username` (`username`,`contest_id`) USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -221,7 +234,7 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `contests_notice` (
`contest_id` int(11) NOT NULL,
`contest_id` int NOT NULL,
`title` varchar(30) NOT NULL,
`content` varchar(500) NOT NULL,
`time` datetime NOT NULL,
@ -246,7 +259,7 @@ UNLOCK TABLES;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `contests_permissions` (
`username` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`contest_id` int(11) NOT NULL,
`contest_id` int NOT NULL,
PRIMARY KEY (`username`,`contest_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -267,10 +280,11 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `contests_problems` (
`problem_id` int(11) NOT NULL,
`contest_id` int(11) NOT NULL,
`dfn` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`problem_id`,`contest_id`)
`problem_id` int NOT NULL,
`contest_id` int NOT NULL,
`level` int NOT NULL DEFAULT 0,
PRIMARY KEY (`problem_id`,`contest_id`),
KEY `contest_id` (`contest_id`,`problem_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -291,9 +305,9 @@ UNLOCK TABLES;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `contests_registrants` (
`username` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`contest_id` int(11) NOT NULL,
`contest_id` int NOT NULL,
`has_participated` tinyint(1) NOT NULL,
`rank` int(11) NOT NULL,
`final_rank` int NOT NULL,
PRIMARY KEY (`contest_id`,`username`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -314,12 +328,14 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `contests_submissions` (
`contest_id` int(11) NOT NULL,
`contest_id` int NOT NULL,
`submitter` varchar(20) NOT NULL,
`problem_id` int(11) NOT NULL,
`submission_id` int(11) NOT NULL,
`score` int(11) NOT NULL,
`penalty` int(11) NOT NULL,
`problem_id` int NOT NULL,
`submission_id` int NOT NULL,
`score` int NOT NULL,
`penalty` int NOT NULL,
`cnt` int DEFAULT NULL,
`n_failures` int DEFAULT NULL,
PRIMARY KEY (`contest_id`,`submitter`,`problem_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -340,11 +356,13 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `contests_reviews` (
`contest_id` int(11) NOT NULL,
`problem_id` int(11) NOT NULL DEFAULT 0,
`contest_id` int NOT NULL,
`problem_id` int NOT NULL DEFAULT 0,
`poster` varchar(20) NOT NULL,
`content` text NOT NULL,
PRIMARY KEY (`contest_id`,`problem_id`,`poster`)
PRIMARY KEY (`contest_id`,`problem_id`,`poster`),
KEY `contest_id` (`contest_id`,`problem_id`),
KEY `poster` (`poster`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -364,7 +382,7 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `countdowns` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`title` text NOT NULL,
`end_time` datetime NOT NULL,
PRIMARY KEY (`id`)
@ -387,8 +405,8 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `custom_test_submissions` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`problem_id` int(10) unsigned NOT NULL,
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`problem_id` int UNSIGNED NOT NULL,
`submit_time` datetime NOT NULL,
`submitter` varchar(20) NOT NULL,
`content` text NOT NULL,
@ -396,8 +414,10 @@ CREATE TABLE `custom_test_submissions` (
`result` blob NOT NULL,
`status` varchar(20) NOT NULL,
`status_details` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
PRIMARY KEY (`id`),
KEY `submitter` (`submitter`,`problem_id`,`id`),
KEY `judge_time` (`judge_time`,`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -416,10 +436,10 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `friend_links` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id` int unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(40) NOT NULL,
`url` varchar(100) NOT NULL,
`level` int(10) NOT NULL DEFAULT 10,
`level` int NOT NULL DEFAULT 10,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -440,7 +460,7 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `groups` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id` int NOT NULL AUTO_INCREMENT,
`title` text NOT NULL,
`announcement` text NOT NULL DEFAULT '',
`is_hidden` tinyint(1) NOT NULL DEFAULT 0,
@ -455,10 +475,11 @@ CREATE TABLE `groups` (
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `groups_assignments` (
`group_id` int(11) NOT NULL,
`list_id` int(11) NOT NULL,
`group_id` int NOT NULL,
`list_id` int NOT NULL,
`end_time` datetime NOT NULL,
PRIMARY KEY (`group_id`, `list_id`)
PRIMARY KEY (`group_id`, `list_id`),
KEY `list_id` (`list_id`,`group_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -469,9 +490,11 @@ CREATE TABLE `groups_assignments` (
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `groups_users` (
`group_id` int(11) NOT NULL,
`group_id` int NOT NULL,
`username` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`group_id`, `username`)
PRIMARY KEY (`group_id`, `username`),
KEY `group_id` (`group_id`, `username`),
KEY `username` (`username`, `group_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -482,23 +505,26 @@ CREATE TABLE `groups_users` (
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `hacks` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`problem_id` int(10) unsigned NOT NULL,
`contest_id` int(10) unsigned DEFAULT NULL,
`submission_id` int(10) unsigned NOT NULL,
`hacker` varchar(20) NOT NULL,
`owner` varchar(20) NOT NULL,
`input` varchar(150) NOT NULL,
`input_type` char(20) NOT NULL,
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`problem_id` int UNSIGNED NOT NULL,
`contest_id` int UNSIGNED DEFAULT NULL,
`submission_id` int UNSIGNED NOT NULL,
`hacker` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`owner` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`input` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
`input_type` char(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`submit_time` datetime NOT NULL,
`judge_time` datetime DEFAULT NULL,
`success` tinyint(1) DEFAULT NULL,
`status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`details` blob NOT NULL,
`is_hidden` tinyint(1) NOT NULL,
PRIMARY KEY (`id`),
KEY `submission_id` (`submission_id`),
KEY `is_hidden` (`is_hidden`,`problem_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
KEY `is_hidden` (`is_hidden`,`problem_id`),
KEY `status` (`status`),
KEY `judge_time` (`judge_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -539,11 +565,14 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `judger_info` (
`judger_name` varchar(50) NOT NULL,
`password` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`ip` char(20) NOT NULL,
`judger_name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`ip` char(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`enabled` tinyint(1) NOT NULL DEFAULT '1',
`display_name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`judger_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -555,6 +584,26 @@ LOCK TABLES `judger_info` WRITE;
/*!40000 ALTER TABLE `judger_info` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `meta`
--
CREATE TABLE `meta` (
`name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`value` json NOT NULL,
`updated_at` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `meta`
--
LOCK TABLES `meta` WRITE;
/*!40000 ALTER TABLE `meta` DISABLE KEYS */;
/*!40000 ALTER TABLE `meta` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `problems`
--
@ -562,18 +611,20 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `problems` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` text NOT NULL,
`id` int unsigned NOT NULL AUTO_INCREMENT,
`title` text COLLATE utf8mb4_unicode_ci NOT NULL,
`uploader` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`is_hidden` tinyint(1) NOT NULL DEFAULT '0',
`submission_requirement` text,
`submission_requirement` mediumtext COLLATE utf8mb4_unicode_ci,
`hackable` tinyint(1) NOT NULL DEFAULT '0',
`extra_config` varchar(500) NOT NULL DEFAULT '{"view_content_type":"ALL","view_details_type":"ALL"}',
`extra_config` varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '{"view_content_type":"ALL","view_details_type":"ALL"}',
`zan` int(11) NOT NULL DEFAULT '0',
`ac_num` int(11) NOT NULL DEFAULT '0',
`submit_num` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
`assigned_to_judger` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'any',
PRIMARY KEY (`id`),
KEY `assigned_to_judger` (`assigned_to_judger`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci TABLESPACE `innodb_system`;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -592,11 +643,11 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `problems_contents` (
`id` int(11) NOT NULL,
`statement` mediumtext NOT NULL,
`statement_md` mediumtext NOT NULL,
`id` int NOT NULL,
`statement` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`statement_md` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -616,9 +667,10 @@ UNLOCK TABLES;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `problems_permissions` (
`username` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`problem_id` int(11) NOT NULL,
PRIMARY KEY (`username`,`problem_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
`problem_id` int NOT NULL,
PRIMARY KEY (`username`,`problem_id`),
KEY `problem_id` (`problem_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -637,9 +689,10 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `problems_solutions` (
`problem_id` int(11) NOT NULL,
`blog_id` int(11) NOT NULL,
PRIMARY KEY (`problem_id`, `blog_id`)
`problem_id` int NOT NULL,
`blog_id` int NOT NULL,
PRIMARY KEY (`problem_id`, `blog_id`),
KEY `problem_id` (`problem_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -659,8 +712,8 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `problems_tags` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`problem_id` int(11) NOT NULL,
`id` int NOT NULL AUTO_INCREMENT,
`problem_id` int NOT NULL,
`tag` varchar(30) NOT NULL,
PRIMARY KEY (`id`),
KEY `problem_id` (`problem_id`),
@ -684,7 +737,7 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `lists` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id` int NOT NULL AUTO_INCREMENT,
`title` text NOT NULL,
`description` text NOT NULL DEFAULT '',
`is_hidden` tinyint(1) NOT NULL DEFAULT '0',
@ -699,9 +752,10 @@ CREATE TABLE `lists` (
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `lists_problems` (
`list_id` int(11) NOT NULL,
`problem_id` int(11) NOT NULL,
PRIMARY KEY (`list_id`, `problem_id`)
`list_id` int NOT NULL,
`problem_id` int NOT NULL,
PRIMARY KEY (`list_id`, `problem_id`),
KEY `list_id` (`list_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -712,8 +766,8 @@ CREATE TABLE `lists_problems` (
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `lists_tags` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`list_id` int(11) NOT NULL,
`id` int NOT NULL AUTO_INCREMENT,
`list_id` int NOT NULL,
`tag` varchar(30) NOT NULL,
PRIMARY KEY (`id`),
KEY `list_id` (`list_id`),
@ -728,14 +782,14 @@ CREATE TABLE `lists_tags` (
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `search_requests` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id` int NOT NULL AUTO_INCREMENT,
`created_at` datetime NOT NULL,
`remote_addr` varchar(50) NOT NULL,
`type` enum('search','autocomplete') NOT NULL,
`cache_id` int(11) NOT NULL,
`q` varchar(100) NOT NULL,
`content` text NOT NULL,
`result` mediumtext NOT NULL,
`remote_addr` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`type` enum('search','autocomplete') COLLATE utf8mb4_unicode_ci NOT NULL,
`cache_id` int NOT NULL,
`q` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`content` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
`result` json NOT NULL,
PRIMARY KEY (`id`),
KEY `remote_addr` (`remote_addr`,`created_at`),
KEY `created_at` (`created_at`)
@ -758,27 +812,42 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `submissions` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`problem_id` int(10) unsigned NOT NULL,
`contest_id` int(10) unsigned DEFAULT NULL,
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`problem_id` int UNSIGNED NOT NULL,
`contest_id` int UNSIGNED DEFAULT NULL,
`submit_time` datetime NOT NULL,
`submitter` varchar(20) NOT NULL,
`content` text NOT NULL,
`language` varchar(15) NOT NULL,
`tot_size` int(11) NOT NULL,
`submitter` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`content` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
`language` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL,
`tot_size` int NOT NULL,
`judge_reason` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`judge_time` datetime DEFAULT NULL,
`result` blob NOT NULL,
`status` varchar(20) NOT NULL,
`result_error` varchar(20) DEFAULT NULL,
`score` int(11) DEFAULT NULL,
`used_time` int(11) NOT NULL DEFAULT '0',
`used_memory` int(11) NOT NULL DEFAULT '0',
`judger` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`result` mediumblob NOT NULL,
`status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`result_error` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`score` int DEFAULT NULL,
`hide_score_to_others` tinyint(1) NOT NULL DEFAULT '0',
`hidden_score` int DEFAULT NULL,
`used_time` int NOT NULL DEFAULT '0',
`used_memory` int NOT NULL DEFAULT '0',
`is_hidden` tinyint(1) NOT NULL,
`status_details` varchar(100) NOT NULL,
`status_details` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `is_hidden` (`is_hidden`,`problem_id`),
KEY `score` (`problem_id`, `submitter`, `score`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
KEY `status` (`status`,`id`),
KEY `result_error` (`result_error`),
KEY `problem_id` (`problem_id`,`id`),
KEY `language` (`language`,`id`),
KEY `language2` (`is_hidden`,`language`,`id`),
KEY `user_score` (`problem_id`,`submitter`,`score`,`id`),
KEY `problem_id2` (`is_hidden`,`problem_id`,`id`),
KEY `id2` (`is_hidden`,`id`),
KEY `problem_score2` (`is_hidden`,`problem_id`,`score`,`id`),
KEY `contest_submission_status` (`contest_id`,`status`),
KEY `submitter2` (`is_hidden`,`submitter`,`id`),
KEY `submitter` (`submitter`,`id`) USING BTREE,
KEY `contest_id` (`contest_id`,`is_hidden`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -790,6 +859,83 @@ LOCK TABLES `submissions` WRITE;
/*!40000 ALTER TABLE `submissions` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `submissions_history`
--
CREATE TABLE `submissions_history` (
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`submission_id` int UNSIGNED NOT NULL,
`judge_reason` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`judge_time` datetime DEFAULT NULL,
`judger` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`result` mediumblob NOT NULL,
`status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`status_details` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`result_error` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`score` int DEFAULT NULL,
`used_time` int NOT NULL DEFAULT '0',
`used_memory` int NOT NULL DEFAULT '0',
`major` tinyint(1) NOT NULL,
PRIMARY KEY (`id`),
KEY `submission_judge_time` (`submission_id`,`judge_time`,`id`),
KEY `submission` (`submission_id`,`id`),
KEY `status_major` (`status`,`major`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `submissions_history`
--
LOCK TABLES `submissions_history` WRITE;
/*!40000 ALTER TABLE `submissions_history` DISABLE KEYS */;
/*!40000 ALTER TABLE `submissions_history` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `system_updates`
--
CREATE TABLE `system_updates` (
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`time` datetime NOT NULL,
`type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`target_id` int UNSIGNED NOT NULL,
`message` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `type_id_time` (`type`,`target_id`,`time`),
KEY `type_time` (`type`,`time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `system_updates`
--
LOCK TABLES `system_updates` WRITE;
/*!40000 ALTER TABLE `system_updates` DISABLE KEYS */;
/*!40000 ALTER TABLE `system_updates` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `upgrades`
--
CREATE TABLE `upgrades` (
`name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` enum('up','down') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `upgrades`
--
LOCK TABLES `upgrades` WRITE;
/*!40000 ALTER TABLE `upgrades` DISABLE KEYS */;
/*!40000 ALTER TABLE `upgrades` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `user_info`
--
@ -797,32 +943,29 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `user_info` (
`usergroup` char(1) NOT NULL DEFAULT 'U',
`usergroup` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'U',
`username` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`usertype` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'student',
`realname` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`school` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`usertype` varchar(250) NOT NULL DEFAULT 'student',
`email` varchar(50) NOT NULL,
`password` char(32) NOT NULL,
`svn_password` char(10) NOT NULL,
`qq` bigint(20) NOT NULL,
`sex` char(1) NOT NULL DEFAULT 'U',
`ac_num` int(11) NOT NULL,
`email` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` char(32) COLLATE utf8mb4_unicode_ci NOT NULL,
`svn_password` char(10) COLLATE utf8mb4_unicode_ci NOT NULL,
`qq` bigint NOT NULL DEFAULT '0',
`sex` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'U',
`ac_num` int NOT NULL DEFAULT 0,
`register_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`remote_addr` varchar(50) NOT NULL,
`http_x_forwarded_for` varchar(50) NOT NULL,
`remember_token` char(60) NOT NULL,
`motto` varchar(200) NOT NULL,
`last_login` timestamp NOT NULL DEFAULT 0,
`last_visited` timestamp NOT NULL DEFAULT 0,
`images_size_limit` int(11) UNSIGNED NOT NULL DEFAULT 104857600, /* 100 MiB */
`codeforces_handle` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`github` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`website` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`avatar_source` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'gravatar',
`last_login_time` datetime DEFAULT CURRENT_TIMESTAMP,
`last_visit_time` datetime DEFAULT CURRENT_TIMESTAMP,
`expiration_time` datetime DEFAULT NULL,
`remote_addr` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`http_x_forwarded_for` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`remember_token` char(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`motto` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`extra` json NOT NULL,
PRIMARY KEY (`username`),
KEY `ac_num` (`ac_num`,`username`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -841,13 +984,13 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `users_images` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`path` varchar(100) NOT NULL,
`uploader` varchar(20) NOT NULL,
`width` int(11) NOT NULL,
`height` int(11) NOT NULL,
`width` int NOT NULL,
`height` int NOT NULL,
`upload_time` datetime NOT NULL,
`size` int(11) NOT NULL,
`size` int NOT NULL,
`hash` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
KEY `uploader` (`uploader`),
@ -874,13 +1017,16 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `user_msg` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`sender` varchar(20) NOT NULL,
`receiver` varchar(20) NOT NULL,
`message` varchar(5000) NOT NULL,
`send_time` datetime NOT NULL,
`read_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
KEY `sender` (`sender`),
KEY `receiver` (`receiver`),
KEY `read_time` (`receiver`,`read_time`) USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -900,13 +1046,14 @@ UNLOCK TABLES;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `user_system_msg` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id` int NOT NULL AUTO_INCREMENT,
`title` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`content` text COLLATE utf8mb4_unicode_ci NOT NULL,
`receiver` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`send_time` datetime NOT NULL,
`read_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
KEY `receiver` (`receiver`,`read_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

View File

@ -24,6 +24,8 @@ services:
build:
context: ./judger/
dockerfile: Dockerfile
args:
- USE_MIRROR=1
container_name: uoj-judger
restart: always
stdin_open: true
@ -44,6 +46,8 @@ services:
build:
context: ./
dockerfile: web/Dockerfile
args:
- USE_MIRROR=1
container_name: uoj-web
restart: always
stdin_open: true

View File

@ -1,15 +1,24 @@
FROM ubuntu:22.04
ARG CLONE_ADDFLAG
ARG USE_MIRROR
ENV USE_MIRROR $USE_MIRROR
SHELL ["/bin/bash", "-c"]
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y vim ntp zip unzip curl wget build-essential fp-compiler python2.7 python3.10 python3-requests libseccomp-dev openjdk-8-jdk openjdk-11-jdk openjdk-17-jdk
ENV PKGS="vim ntp zip unzip curl wget build-essential fp-compiler python2.7 python3.10 python3-requests libseccomp-dev openjdk-8-jdk openjdk-11-jdk openjdk-17-jdk"
RUN if [[ "$USE_MIRROR" == "1" ]]; then\
sed -i "s@http://.*archive.ubuntu.com@http://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list &&\
sed -i "s@http://.*security.ubuntu.com@http://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list ;\
fi &&\
apt-get update &&\
(apt-get install -y --allow-unauthenticated --no-install-recommends -o Dpkg::Options::="--force-overwrite" -o APT::Acquire::Retries="30" --fix-missing $PKGS || apt --fix-broken install -y || apt-get install -y --allow-unauthenticated --no-install-recommends -o Dpkg::Options::="--force-overwrite" -o APT::Acquire::Retries="30" --fix-missing $PKGS)
ADD . /opt/uoj_judger
WORKDIR /opt/uoj_judger
# Install environment and set startup script
RUN sh install.sh -p && echo "\
RUN sh install.sh -p && echo -e "\
#!/bin/sh\n\
if [ ! -f \"/opt/uoj_judger/.conf.json\" ]; then\n\
cd /opt/uoj_judger && sh install.sh -i\n\

View File

@ -35,12 +35,15 @@ const std::vector<std::pair<const char *, const char *>> suffix_search_list = {
{".code" , "" },
{"20.cpp" , "C++20" },
{"17.cpp" , "C++17" },
{"14.cpp" , "C++14" },
{"14.cpp" , "C++" },
{"11.cpp" , "C++11" },
{".cpp" , "C++" },
{"03.cpp" , "C++03" },
{"98.cpp" , "C++98" },
{".cpp" , "C++" },
{".c" , "C" },
{".pas" , "Pascal" },
{"2.7.py" , "Python2.7"},
{"2.py" , "Python2.7"},
{".py" , "Python3" },
{"7.java" , "Java7" },
{"8.java" , "Java8" },

View File

@ -1,18 +1,30 @@
FROM ubuntu:22.04
ARG CLONE_ADDFLAG
ARG USE_MIRROR
ENV USE_MIRROR $USE_MIRROR
SHELL ["/bin/bash", "-c"]
ENV DEBIAN_FRONTEND=noninteractive
RUN dpkg -s gnupg 2>/dev/null || (apt-get update && apt-get install -y gnupg) &&\
echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu jammy main" | tee /etc/apt/sources.list.d/ondrej-php.list && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C &&\
apt-get update --allow-unauthenticated &&\
apt-get install -y --allow-unauthenticated -o Dpkg::Options::="--force-overwrite" php7.4 php7.4-yaml php7.4-xml php7.4-dev php7.4-zip php7.4-mysql php7.4-mbstring php7.4-gd php7.4-imagick libseccomp-dev git vim ntp zip unzip curl wget libapache2-mod-xsendfile mysql-server php-pear cmake fp-compiler re2c libyaml-dev python2.7 python3.10 python3-requests openjdk-8-jdk openjdk-11-jdk openjdk-17-jdk
ENV PKGS="php7.4 php7.4-yaml php7.4-xml php7.4-dev php7.4-zip php7.4-mysql php7.4-mbstring php7.4-gd php7.4-imagick libseccomp-dev git vim ntp zip unzip curl wget apache2 libapache2-mod-xsendfile php-pear mysql-client build-essential fp-compiler re2c libseccomp-dev libyaml-dev python2.7 python3.10 python3-requests openjdk-8-jdk openjdk-11-jdk openjdk-17-jdk"
RUN if [[ "$USE_MIRROR" == "1" ]]; then\
sed -i "s@http://.*archive.ubuntu.com@https://mirrors.aliyun.com@g" /etc/apt/sources.list &&\
sed -i "s@http://.*security.ubuntu.com@https://mirrors.aliyun.com@g" /etc/apt/sources.list ;\
fi &&\
apt-get -o "Acquire::https::Verify-Peer=false" update && apt-get -o "Acquire::https::Verify-Peer=false" install -y --no-install-recommends gnupg ca-certificates &&\
echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu jammy main" | tee /etc/apt/sources.list.d/ondrej-php.list && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C &&\
if [[ "$USE_MIRROR" == "1" ]]; then\
find /etc/apt/sources.list.d/ -type f -name "*.list" -exec sed -i.bak -r 's#deb(-src)?\s*http(s)?://ppa.launchpad.net#deb\1 https://launchpad.proxy.ustclug.org#ig' {} \; &&\
find /etc/apt/sources.list.d/ -type f -name "*.list" -exec sed -i.bak -r 's#deb(-src)?\s*http(s)?://ppa.launchpadcontent.net#deb\1 https://launchpad.proxy.ustclug.org#ig' {} \; ;\
fi &&\
apt-get update --allow-unauthenticated &&\
(apt-get install -y --allow-unauthenticated --no-install-recommends -o Dpkg::Options::="--force-overwrite" -o APT::Acquire::Retries="30" --fix-missing $PKGS || apt-get install --fix-broken -y -o APT::Acquire::Retries="30")
ADD . /opt/uoj
WORKDIR /opt/uoj
# Install environment and set startup script
RUN sh web/install.sh -p && echo "\
RUN sh web/install.sh -p && echo -e "\
#!/bin/sh\n\
if [ ! -f \"/var/uoj_data/.UOJSetupDone\" ]; then\n\
cd /opt/uoj/web && sh install.sh -i\n\

View File

@ -21,12 +21,12 @@ return [
'main' => [
'protocol' => 'http',
'host' => '_httpHost_',
'port' => 80
'port' => '80/443'
],
'blog' => [
'protocol' => 'http',
'host' => '_httpHost_',
'port' => 80
'port' => '80/443'
]
],
'security' => [
@ -54,7 +54,6 @@ return [
],
'switch' => [
'blog-domain-mode' => 3,
'force-login' => true,
'open-register' => false
]
];

View File

@ -1,101 +1,103 @@
<?php
if (!Auth::check()) {
redirectToLogin();
}
requireLib('bootstrap5');
requirePHPLib('form');
if (!isNormalUser($myUser)) {
become403Page();
}
Auth::check() || redirectToLogin();
isSuperUser(Auth::user()) || UOJResponse::page403();
requireLib('bootstrap5');
requirePHPLib('form');
if (!isSuperUser($myUser)) {
become403Page();
}
$time_form = new UOJForm('time');
$time_form->addVInput(
'name', 'text', '比赛标题', 'New Contest',
function($name, &$vdata) {
if ($name == '') {
return '标题不能为空';
}
if (strlen($name) > 100) {
return '标题过长';
}
$time_form = new UOJBs4Form('time');
$time_form->addVInput(
'name',
'text',
'比赛标题',
'New Contest',
function ($name, &$vdata) {
if ($name == '') {
return '标题不能为空';
}
$name = HTML::escape($name);
if (strlen($name) > 100) {
return '标题过长';
}
if ($name === '') {
return '无效编码';
}
$name = HTML::escape($name);
$vdata['name'] = $name;
if ($name === '') {
return '无效编码';
}
return '';
},
null
);
$time_form->addVInput(
'start_time', 'text', '开始时间', date("Y-m-d H:i:s"),
function($str, &$vdata) {
try {
$vdata['start_time'] = new DateTime($str);
} catch (Exception $e) {
return '无效时间格式';
}
return '';
},
null
);
$time_form->addVInput(
'last_min', 'text', '时长(单位:分钟)', 180,
function($str, &$vdata) {
if (!validateUInt($str)) {
return '必须为一个整数';
}
$vdata['name'] = $name;
$vdata['last_min'] = $str;
return '';
},
null
);
$time_form->addVInput(
'start_time',
'text',
'开始时间',
date("Y-m-d H:i:s"),
function ($str, &$vdata) {
try {
$vdata['start_time'] = new DateTime($str);
} catch (Exception $e) {
return '无效时间格式';
}
return '';
},
null
);
$time_form->addVInput(
'last_min',
'text',
'时长(单位:分钟)',
180,
function ($str, &$vdata) {
if (!validateUInt($str)) {
return '必须为一个整数';
}
return '';
},
null
);
$time_form->handle = function(&$vdata) {
$start_time_str = $vdata['start_time']->format('Y-m-d H:i:s');
$esc_name = DB::escape($vdata['name']);
$esc_last_min = DB::escape($vdata['last_min']);
DB::query("insert into contests (name, start_time, last_min, status) values ('$esc_name', '$start_time_str', $esc_last_min, 'unfinished')");
};
$time_form->succ_href = "/contests";
$time_form->runAtServer();
?>
$vdata['last_min'] = $str;
return '';
},
null
);
$time_form->handle = function (&$vdata) {
$start_time_str = $vdata['start_time']->format('Y-m-d H:i:s');
DB::insert([
"insert into contests",
"(name, start_time, last_min, status)", "values",
DB::tuple([$vdata['name'], $start_time_str, $vdata['last_min'], 'unfinished'])
]);
};
$time_form->succ_href = "/contests";
$time_form->runAtServer();
?>
<?php echoUOJPageHeader('添加比赛') ?>
<div class="row">
<div class="col-lg-9">
<!-- left col -->
<div class="col-lg-9">
<div class="card card-default mb-2">
<div class="card-body">
<div class="card card-default mb-2">
<div class="card-body">
<h1 class="card-title">添加比赛</h1>
<h1 class="h2 card-title">添加比赛</h1>
<div class="w-full" style="max-width: 400px">
<?php $time_form->printHTML(); ?>
</div>
<div class="w-full" style="max-width: 400px">
<?php $time_form->printHTML(); ?>
</div>
</div>
</div>
</div>
<!-- right col -->
<aside class="col-lg-3 mt-3 mt-lg-0">
<?php uojIncludeView('sidebar', array()) ?>
</aside>
</div>
</div>
</div>
<!-- end left col -->
<!-- right col -->
<aside class="col-lg-3 mt-3 mt-lg-0">
<?php uojIncludeView('sidebar') ?>
</aside>
</div>
<?php echoUOJPageFooter() ?>

View File

@ -1,73 +1,57 @@
<?php
if (!Auth::check() && UOJConfig::$data['switch']['force-login']) {
redirectToLogin();
}
requireLib('bootstrap5');
requirePHPLib('form');
?>
<?php echoUOJPageHeader(UOJLocale::get('announcements')) ?>
if (!isNormalUser($myUser) && UOJConfig::$data['switch']['force-login']) {
become403Page();
}
<div class="row">
<!-- left col -->
<div class="col-lg-9">
<h1>
<?= UOJLocale::get('announcements') ?>
</h1>