Added created_at field to pastes

This commit is contained in:
Leo Lu 2020-08-14 01:29:26 +08:00
parent f25be16d1e
commit 8cbb222d0b
4 changed files with 9 additions and 2 deletions

View File

@ -702,12 +702,16 @@ create table pastes
( (
`index` varchar(20) null, `index` varchar(20) null,
creator varchar(20) null, creator varchar(20) null,
created_at datetime null,
content text null content text null
); );
create unique index pastes_index_uindex create unique index pastes_index_uindex
on pastes (`index`); on pastes (`index`);
create index pastes_created_at_index
on pastes (created_at);
alter table pastes alter table pastes
add constraint pastes_pk add constraint pastes_pk
primary key (`index`); primary key (`index`);

View File

@ -16,7 +16,7 @@ function handleUpload($zip_file_name, $content, $tot_size) {
$index = uojRandString(20); $index = uojRandString(20);
$esc_index = DB::escape($index); $esc_index = DB::escape($index);
} }
DB::query("insert into pastes (`index`, `creator`, `content`) values ('$esc_index', '${myUser['username']}', '$esc_content')"); DB::query("insert into pastes (`index`, `creator`, `content`, `created_at`) values ('$esc_index', '${myUser['username']}', '$esc_content', '".date('Y-m-d H:i:s')."')");
redirectTo("/pastes/".$index); redirectTo("/pastes/".$index);
} }

View File

@ -3,7 +3,9 @@
$paste_id = $_GET['rand_str_id']; $paste_id = $_GET['rand_str_id'];
$paste = DB::selectFirst("select * from pastes where `index` = '".DB::escape($paste_id)."'"); $paste = DB::selectFirst("select * from pastes where `index` = '".DB::escape($paste_id)."'");
if (!$paste) {
become404Page();
}
$REQUIRE_LIB['shjs'] = ""; $REQUIRE_LIB['shjs'] = "";
echoUOJPageHeader("Paste!"); echoUOJPageHeader("Paste!");
echoPasteContent($paste); echoPasteContent($paste);

View File

@ -410,6 +410,7 @@ function echoPasteContent($paste) {
$footer_text .= ", ".UOJLocale::get("problems::submitter") . <<<HTML $footer_text .= ", ".UOJLocale::get("problems::submitter") . <<<HTML
: <a href="/user/profile/${paste['creator']}">${paste['creator']}</a> : <a href="/user/profile/${paste['creator']}">${paste['creator']}</a>
HTML; HTML;
$footer_text .= ", ".UOJLocale::get("problems::submit time").": ".$paste['created_at'];
switch ($file_language) { switch ($file_language) {
case 'C++': case 'C++':