From 8ec306e09dc167ec36de0d6aa3b0545dd92603da Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Thu, 13 Oct 2022 20:20:51 +0800 Subject: [PATCH] feat(web/super_manage): add image_hosting manage --- web/app/controllers/super_manage.php | 63 ++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/web/app/controllers/super_manage.php b/web/app/controllers/super_manage.php index fd6939a..19fdb92 100644 --- a/web/app/controllers/super_manage.php +++ b/web/app/controllers/super_manage.php @@ -603,6 +603,58 @@ EOD; EOD; }; + $image_hosting_cols = ['*']; + $image_hosting_config = ['page_len' => 20, 'table_classes' => ['table', 'table-bordered', 'table-hover', 'table-striped']]; + $image_hosting_header_row = << + ID + 上传者 + 预览 + 文件大小 + 上传时间 + +EOD; + $image_hosting_print_row = function($row) { + $user_link = getUserLink($row['uploader']); + if ($row['size'] < 1024 * 512) { + $size = strval(round($row['size'] * 1.0 / 1024, 1)) . ' KB'; + } else { + $size = strval(round($row['size'] * 1.0 / 1024 / 1024, 1)) . ' MB'; + } + + echo << + {$row['id']} + $user_link + + $size + {$row['upload_time']} + +EOD; + }; + + $image_deleter = new UOJForm('image_deleter'); + $image_deleter->addInput('image_deleter_id', 'text', '图片 ID', '', + function ($x, &$vdata) { + if (!validateUInt($x)) { + return 'ID 不合法'; + } + if (!DB::selectCount("select count(*) from users_images where id = $x")) { + return '图片不存在'; + } + $vdata['id'] = $x; + return ''; + }, + null + ); + $image_deleter->handle = function(&$vdata) { + $id = $vdata['id']; + $result = DB::selectFirst("SELECT * from users_images WHERE id = $id"); + unlink(UOJContext::storagePath().$result['path']); + DB::delete("DELETE FROM users_images WHERE id = $id"); + }; + $image_deleter->runAtServer(); + $tabs_info = array( 'users' => array( 'name' => '用户管理', @@ -627,6 +679,10 @@ EOD; 'judger' => array( 'name' => '评测机管理', 'url' => '/super-manage/judger' + ), + 'image_hosting' => array( + 'name' => '图床管理', + 'url' => '/super-manage/image_hosting' ) ); @@ -758,6 +814,13 @@ EOD;

评测机列表

+ +

图床管理

+ +
+

删除图片

+ printHTML() ?> +