mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-26 20:56:20 +00:00
feat(web/super_manage/image_hosting): change user images total size limit
This commit is contained in:
parent
d8d97b4f93
commit
24acc89709
@ -634,6 +634,9 @@ EOD;
|
|||||||
};
|
};
|
||||||
|
|
||||||
$image_deleter = new UOJForm('image_deleter');
|
$image_deleter = new UOJForm('image_deleter');
|
||||||
|
$image_deleter->submit_button_config['align'] = 'compressed';
|
||||||
|
$image_deleter->submit_button_config['text'] = '删除';
|
||||||
|
$image_deleter->submit_button_config['class_str'] = 'btn btn-danger';
|
||||||
$image_deleter->addInput('image_deleter_id', 'text', '图片 ID', '',
|
$image_deleter->addInput('image_deleter_id', 'text', '图片 ID', '',
|
||||||
function ($x, &$vdata) {
|
function ($x, &$vdata) {
|
||||||
if (!validateUInt($x)) {
|
if (!validateUInt($x)) {
|
||||||
@ -655,6 +658,39 @@ EOD;
|
|||||||
};
|
};
|
||||||
$image_deleter->runAtServer();
|
$image_deleter->runAtServer();
|
||||||
|
|
||||||
|
$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();
|
||||||
|
|
||||||
$tabs_info = array(
|
$tabs_info = array(
|
||||||
'users' => array(
|
'users' => array(
|
||||||
'name' => '用户管理',
|
'name' => '用户管理',
|
||||||
@ -821,6 +857,10 @@ EOD;
|
|||||||
<h4>删除图片</h4>
|
<h4>删除图片</h4>
|
||||||
<?php $image_deleter->printHTML() ?>
|
<?php $image_deleter->printHTML() ?>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<h4>修改用户存储上限</h4>
|
||||||
|
<?php $change_user_image_total_size_limit_form->printHTML() ?>
|
||||||
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -20,14 +20,14 @@ function validateMotto($motto) {
|
|||||||
return is_string($motto) && ($len = mb_strlen($motto, 'UTF-8')) !== false && $len <= 1024;
|
return is_string($motto) && ($len = mb_strlen($motto, 'UTF-8')) !== false && $len <= 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateUInt($x) { // [0, 1000000000)
|
function validateUInt($x, $len = 8) { // [0, 1000000000)
|
||||||
if (!is_string($x)) {
|
if (!is_string($x)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($x === '0') {
|
if ($x === '0') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return preg_match('/^[1-9][0-9]{0,8}$/', $x);
|
return preg_match('/^[1-9][0-9]{0,'.$len.'}$/', $x);
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateInt($x) {
|
function validateInt($x) {
|
||||||
|
Loading…
Reference in New Issue
Block a user