diff --git a/install/db/app_uoj233.sql b/install/db/app_uoj233.sql
index db51e85..b20be87 100644
--- a/install/db/app_uoj233.sql
+++ b/install/db/app_uoj233.sql
@@ -697,6 +697,27 @@ LOCK TABLES `user_system_msg` WRITE;
/*!40000 ALTER TABLE `user_system_msg` DISABLE KEYS */;
/*!40000 ALTER TABLE `user_system_msg` ENABLE KEYS */;
UNLOCK TABLES;
+
+create table pastes
+(
+ `index` varchar(20) null,
+ creator varchar(20) null,
+ created_at datetime null,
+ content text null
+);
+
+create unique index pastes_index_uindex
+ on pastes (`index`);
+
+create index pastes_created_at_index
+ on pastes (created_at);
+
+alter table pastes
+ add constraint pastes_pk
+ primary key (`index`);
+
+
+
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
diff --git a/web/.gitignore b/web/.gitignore
index 0cba4c5..6bebc64 100644
--- a/web/.gitignore
+++ b/web/.gitignore
@@ -3,6 +3,7 @@
app/.config.php
app/storage/tmp/*
app/storage/submission/*
+app/storage/paste/*
!app/storage/tmp/.gitkeep
!app/storage/submission/.gitkeep
-
+!app/storage/paste/.gitkeep
diff --git a/web/app/.default-config.php b/web/app/.default-config.php
index 82c2adc..0981d9d 100644
--- a/web/app/.default-config.php
+++ b/web/app/.default-config.php
@@ -53,5 +53,10 @@ return [
'switch' => [
'web-analytics' => false,
'blog-domain-mode' => 3
+ ],
+ 'tools' => [
+ // 请仅在https下启用以下功能.
+ // 非https下, chrome无法进行复制.
+ 'map-copy-enabled' => false,
]
];
diff --git a/web/app/controllers/map_visualizer.php b/web/app/controllers/map_visualizer.php
new file mode 100644
index 0000000..ee0a83b
--- /dev/null
+++ b/web/app/controllers/map_visualizer.php
@@ -0,0 +1,132 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "source code",
+ "name" => "paste",
+ "file_name" => "paste.code"
+ ]
+ ],
+ 'uojRandAvaiablePasteFileName',
+ 'handleUpload');
+$paste_form->succ_href = '/paste';
+$paste_form->runAtServer();
+echoUOJPageHeader("Paste!");
+$paste_form->printHTML();
+echoUOJPageFooter();
\ No newline at end of file
diff --git a/web/app/controllers/paste_view.php b/web/app/controllers/paste_view.php
new file mode 100644
index 0000000..16b8f65
--- /dev/null
+++ b/web/app/controllers/paste_view.php
@@ -0,0 +1,12 @@
+runAtServer();
+
+ $paste_deleter = new UOJForm('paste_deleter');
+ $paste_deleter->addInput('paste_deleter_name', 'text', 'Paste ID', '',
+ function ($x, &$vdata) {
+ if (DB::selectCount("select count(*) from pastes where `index`='$x'")==0) {
+ return '不合法';
+ }
+ $vdata['name'] = $x;
+ return '';
+ },
+ null
+ );
+ $paste_deleter->handle = function(&$vdata) {
+ DB::delete("delete from pastes where `index` = '${vdata['name']}'");
+ };
+ $paste_deleter->runAtServer();
$judgerlist_cols = array('judger_name', 'password');
$judgerlist_config = array();
@@ -328,6 +344,10 @@ EOD;
'judger' => array(
'name' => '评测机管理',
'url' => '/super-manage/judger'
+ ),
+ 'paste' => array(
+ 'name' => 'Paste管理',
+ 'url' => '/super-manage/paste'
)
);
@@ -458,6 +478,11 @@ EOD;
评测机列表
+
+
+
Paste管理
+
+
diff --git a/web/app/libs/uoj-html-lib.php b/web/app/libs/uoj-html-lib.php
index b46d987..fbf6981 100644
--- a/web/app/libs/uoj-html-lib.php
+++ b/web/app/libs/uoj-html-lib.php
@@ -393,6 +393,96 @@ function echoSubmissionsList($cond, $tail, $config, $user) {
}, $table_config);
}
+function echoPastesList() {
+ $header_row = '';
+ $col_names = ['`index`','creator','created_at'];
+ $header_row .= 'ID | ';
+ $header_row .= ''.UOJLocale::get("problems::submitter").' | ';
+ $header_row .= ''.UOJLocale::get('problems::submit time').' | ';
+ $header_row .= ' 操作 | ';
+ $header_row .= '
';
+ $table_name = 'pastes';
+ echoLongTable($col_names, $table_name, "1", 'order by created_at desc', $header_row,
+ function($paste) {
+ $user = getUserLink($paste['creator']);
+ $token = HTML::hiddenToken();
+ echo <<
+
+ {$paste['index']}
+ |
+
+ {$user}
+ |
+
+ {$paste['created_at']}
+ |
+
+
+ |
+
+HTML;
+ }, []);
+}
+
+function echoPasteContent($paste) {
+ $zip_file = new ZipArchive();
+ $submission_content = json_decode($paste['content'], true);
+ $zip_file->open(UOJContext::storagePath().$submission_content['file_name']);
+
+ $config = array();
+ foreach ($submission_content['config'] as $config_key => $config_val) {
+ $config[$config_val[0]] = $config_val[1];
+ }
+
+ $file_content = $zip_file->getFromName("paste.code");
+ $file_content = uojTextEncode($file_content, array('allow_CR' => true, 'html_escape' => true));
+ $file_language = htmlspecialchars($config["paste_language"]);
+ $footer_text = UOJLocale::get('problems::source code').', '.UOJLocale::get('problems::language').': '.$file_language;
+ $footer_text .= ", ".UOJLocale::get("problems::submitter") . <<${paste['creator']}
+HTML;
+ $footer_text .= ", ".UOJLocale::get("problems::submit time").": ".$paste['created_at'];
+
+ switch ($file_language) {
+ case 'C++':
+ case 'C++11':
+ $sh_class = 'sh_cpp';
+ break;
+ case 'Python2':
+ case 'Python3':
+ $sh_class = 'sh_python';
+ break;
+ case 'Java8':
+ case 'Java11':
+ $sh_class = 'sh_java';
+ break;
+ case 'C':
+ $sh_class = 'sh_c';
+ break;
+ case 'Pascal':
+ $sh_class = 'sh_pascal';
+ break;
+ default:
+ $sh_class = '';
+ break;
+ }
+ echo '';
+ echo '';
+ echo '
';
+ echo '
'.$file_content."\n".'
';
+ echo '
';
+ echo '';
+ echo '
';
+
+ $zip_file->close();
+}
function echoSubmissionContent($submission, $requirement) {
$zip_file = new ZipArchive();
diff --git a/web/app/libs/uoj-rand-lib.php b/web/app/libs/uoj-rand-lib.php
index 2e221c1..49e427b 100644
--- a/web/app/libs/uoj-rand-lib.php
+++ b/web/app/libs/uoj-rand-lib.php
@@ -31,3 +31,7 @@ function uojRandAvaiableSubmissionFileName() {
}
return uojRandAvaiableFileName("/submission/$num/");
}
+
+function uojRandAvaiablePasteFileName() {
+ return uojRandAvaiableFileName('/paste/');
+}
diff --git a/web/app/route.php b/web/app/route.php
index 87372a7..a4213e9 100644
--- a/web/app/route.php
+++ b/web/app/route.php
@@ -64,6 +64,11 @@ Route::group([
Route::any('/download.php', '/download.php');
Route::any('/click-zan', '/click_zan.php');
+
+ Route::any('/paste', '/paste_post.php');
+ Route::any('/pastes/{rand_str_id}', '/paste_view.php');
+
+ Route::any('/map_visualizer', '/map_visualizer.php');
}
);
diff --git a/web/app/storage/paste/.gitkeep b/web/app/storage/paste/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/web/app/views/main-nav.php b/web/app/views/main-nav.php
index 62952e9..9edf904 100644
--- a/web/app/views/main-nav.php
+++ b/web/app/views/main-nav.php
@@ -11,6 +11,16 @@
= UOJLocale::get('hacks') ?>
= UOJLocale::get('blogs') ?>
= UOJLocale::get('help') ?>
+
+
+
+ 工具
+
+
+