From f57ff959a97565c6a143e7ad6a98334fac6ebf0d Mon Sep 17 00:00:00 2001
From: Baoshuo
Date: Thu, 20 Oct 2022 21:12:05 +0800
Subject: [PATCH] refactor(web/super_manage): image hosting
---
web/app/controllers/super_manage.php | 118 ++++++++++++++++++++++++++-
1 file changed, 117 insertions(+), 1 deletion(-)
diff --git a/web/app/controllers/super_manage.php b/web/app/controllers/super_manage.php
index 83aeda5..483390e 100644
--- a/web/app/controllers/super_manage.php
+++ b/web/app/controllers/super_manage.php
@@ -474,7 +474,7 @@ EOD);
]);
$custom_test_deleter = new UOJForm('custom_test_deleter');
- $custom_test_deleter->addInput('last', 'text', '删除末尾的 n 条记录', '5',
+ $custom_test_deleter->addInput('last', 'text', '删除末尾记录', '5',
function ($x, &$vdata) {
if (!validateUInt($x)) {
return '不合法';
@@ -494,6 +494,68 @@ EOD);
};
$custom_test_deleter->submit_button_config['align'] = 'compressed';
$custom_test_deleter->runAtServer();
+ } elseif ($cur_tab == 'image_hosting') {
+ if (isset($_POST['submit-delete_image']) && $_POST['submit-delete_image'] == 'delete_image') {
+ crsf_defend();
+
+ $image_id = $_POST['image_id'];
+
+ if (!validateUInt($image_id)) {
+ die('' . SCRIPT_REFRESH_AS_GET);
+ }
+
+ if (!($image = DB::selectFirst("SELECT * from users_images where id = $image_id"))) {
+ die('' . SCRIPT_REFRESH_AS_GET);
+ }
+
+ unlink(UOJContext::storagePath().$result['path']);
+ DB::delete("DELETE FROM users_images WHERE id = $image_id");
+
+ die('' . SCRIPT_REFRESH_AS_GET);
+ }
+
+
+ $change_user_image_total_size_limit_form = new UOJForm('change_user_image_total_size_limit');
+ $change_user_image_total_size_limit_form->submit_button_config['align'] = 'compressed';
+ $change_user_image_total_size_limit_form->addInput('change_user_image_total_size_limit_username', 'text', '用户名', '',
+ function ($x, &$vdata) {
+ if (!validateUsername($x)) {
+ return '用户名不合法';
+ }
+
+ if (!queryUser($x)) {
+ return '用户不存在';
+ }
+
+ $vdata['username'] = $x;
+
+ return '';
+ },
+ null
+ );
+ $change_user_image_total_size_limit_form->addInput('change_user_image_total_size_limit_limit', 'text', '存储限制(单位:Byte)', '104857600',
+ function ($x, &$vdata) {
+ if (!validateUInt($x, 10)) {
+ return '限制不合法';
+ }
+
+ if (intval($x) > 2147483648) {
+ return '限制不能大于 2 GB';
+ }
+
+ $vdata['limit'] = $x;
+
+ return '';
+ },
+ null
+ );
+
+ $change_user_image_total_size_limit_form->handle = function(&$vdata) {
+ DB::update("UPDATE user_info SET images_size_limit = {$vdata['limit']} WHERE username = '{$vdata['username']}'");
+ };
+
+ $change_user_image_total_size_limit_form->runAtServer();
+
}
?>
@@ -963,9 +1025,63 @@ echoSubmissionsList(
删除末尾的 n 条记录
printHTML() ?>