Add regexp rule support for texture name
This commit is contained in:
parent
34842787e3
commit
335e8ca498
|
|
@ -204,6 +204,8 @@ class AdminController extends Controller
|
|||
|
||||
$form->checkbox('auto_del_invalid_texture')->label()->hint();
|
||||
|
||||
$form->text('texture_name_regexp')->hint()->placeholder();
|
||||
|
||||
$form->textarea('comment_script')->rows(6)->description();
|
||||
|
||||
$form->checkbox('allow_sending_statistics')->label()->hint();
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ class SkinlibController extends Controller
|
|||
}
|
||||
|
||||
$this->validate($request, [
|
||||
'name' => 'required|no_special_chars',
|
||||
'name' => 'required|'.(option('texture_name_regexp') ? 'texture_name_regexp' : 'no_special_chars'),
|
||||
'file' => 'required|max:'.option('max_upload_file_size'),
|
||||
'public' => 'required'
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -46,6 +46,10 @@ class ValidatorExtendServiceProvider extends ServiceProvider
|
|||
return preg_match($regexp, $value);
|
||||
});
|
||||
|
||||
Validator::extend('texture_name_regexp', function ($a, $value, $p, $v) {
|
||||
return preg_match(option('texture_name_regexp'), $value);
|
||||
});
|
||||
|
||||
Validator::extend('preference', function ($a, $value, $p, $v) {
|
||||
return preg_match('/^(default|slim)$/', $value);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ return [
|
|||
'update_source' => 'https://work.prinzeugen.net/update.json',
|
||||
'copyright_text' => '<strong>Copyright © '.getdate()['year'].' <a href="{site_url}">{site_name}</a>.</strong> All rights reserved.',
|
||||
'auto_del_invalid_texture' => 'false',
|
||||
'texture_name_regexp' => '',
|
||||
'return_200_when_notfound' => 'false',
|
||||
'cache_expire_time' => '31536000',
|
||||
'max_upload_file_size' => '1024',
|
||||
|
|
|
|||
|
|
@ -103,6 +103,10 @@ general:
|
|||
title: Invalid Textures
|
||||
label: Delete invalid textures automatically.
|
||||
hint: Delete textures records whose file no longer exists from skinlib.
|
||||
texture_name_regexp:
|
||||
title: Texture Name Rules
|
||||
hint: The RegExp for validating name of uploaded textures. Leave empty to allow any character except single, double quote and backslash.
|
||||
placeholder: Regular Expressions
|
||||
comment_script:
|
||||
title: Comment Script
|
||||
description: Placeholders are available in comment scripts. <code>{tid}</code> will be replaced with texture id, <code>{name}</code> will be replaced with texture name, <code>{url}</code> will be replaced with current URL.
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ upload:
|
|||
|
||||
texture-name: Texture Name
|
||||
name-rule: Less than 32 characters and must not contain any special one.
|
||||
name-rule-regexp: Custom name rules are applied. :regexp
|
||||
texture-type: Texture Type
|
||||
select-file: Select File
|
||||
private-score-notice: It will spend you more scores to set it as private. You will be charged :score scores for every KB storage.
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
# Blessing Skin
|
||||
username: ':attribute format is invalid.'
|
||||
player_name: 'The :attribute contains invalid character.'
|
||||
no_special_chars: 'The :attribute must not contain special characters.'
|
||||
preference: 'The :attribute must be default or slim.'
|
||||
model: 'The :attribute must be steve, alex or cape.'
|
||||
username: ':attribute format is invalid.'
|
||||
player_name: 'The :attribute contains invalid character.'
|
||||
texture_name_regexp: 'The :attribute contains invalid character.'
|
||||
no_special_chars: 'The :attribute must not contain special characters.'
|
||||
preference: 'The :attribute must be default or slim.'
|
||||
model: 'The :attribute must be steve, alex or cape.'
|
||||
|
||||
accepted: 'The :attribute must be accepted.'
|
||||
active_url: 'The :attribute is not a valid URL.'
|
||||
|
|
|
|||
|
|
@ -103,6 +103,10 @@ general:
|
|||
title: 失效材质
|
||||
label: 自动删除失效材质
|
||||
hint: 自动从皮肤库中删除文件不存在的材质记录
|
||||
texture_name_regexp:
|
||||
title: 材质名称规则
|
||||
hint: 皮肤库上传材质时名称的正则表达式。留空表示允许使用除半角单双引号、反斜杠以外的任意字符。
|
||||
placeholder: 正则表达式,不懂别乱填
|
||||
comment_script:
|
||||
title: 评论代码
|
||||
description: 评论代码内可使用占位符,<code>{tid}</code> 将会被自动替换为材质的 id,<code>{name}</code> 会被替换为材质名称,<code>{url}</code> 会被替换为当前页面地址。
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ upload:
|
|||
|
||||
texture-name: 材质名称
|
||||
name-rule: 材质名称应该小于 32 个字节且不能包含奇怪的符号
|
||||
name-rule-regexp: 本站已应用特殊的名称规则::regexp
|
||||
texture-type: 材质类型
|
||||
select-file: 选择文件
|
||||
private-score-notice: 私密材质将会消耗更多的积分:每 KB 存储空间 :score 积分
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
# Blessing Skin
|
||||
username: ':attribute 格式错误。'
|
||||
player_name: ':attribute 不符合规则。'
|
||||
no_special_chars: ':attribute 不能包含特殊字母。'
|
||||
preference: ':attribute 的值必须为 default 或 slim。'
|
||||
model: ':attribute 的值必须为 steve、alex 或 cape。'
|
||||
username: ':attribute 格式错误。'
|
||||
player_name: ':attribute 不符合规则。'
|
||||
texture_name_regexp: ':attribute 不符合规则。'
|
||||
no_special_chars: ':attribute 不能包含特殊字母。'
|
||||
preference: ':attribute 的值必须为 default 或 slim。'
|
||||
model: ':attribute 的值必须为 steve、alex 或 cape。'
|
||||
|
||||
accepted: ':attribute 必须接受。'
|
||||
active_url: ':attribute 不是一个有效的网址。'
|
||||
|
|
|
|||
|
|
@ -30,7 +30,10 @@
|
|||
<div class="box-body">
|
||||
<div class="form-group">
|
||||
<label for="name">{{ trans('skinlib.upload.texture-name') }}</label>
|
||||
<input id="name" class="form-control" type="text" placeholder="{{ trans('skinlib.upload.name-rule') }}" />
|
||||
<?php $regexp = option('texture_name_regexp'); ?>
|
||||
<input id="name" class="form-control" type="text" placeholder="{{
|
||||
$regexp ? trans('skinlib.upload.name-rule-regexp', compact('regexp')) : trans('skinlib.upload.name-rule')
|
||||
}}" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user