Add option for denying directly downloading textures

This commit is contained in:
printempw 2018-07-22 00:08:50 +08:00
parent 8454ee4306
commit df8381b7c6
6 changed files with 14 additions and 3 deletions

View File

@ -204,6 +204,8 @@ class AdminController extends Controller
$form->checkbox('auto_del_invalid_texture')->label()->hint();
$form->checkbox('allow_downloading_texture')->label();
$form->text('texture_name_regexp')->hint()->placeholder();
$form->textarea('comment_script')->rows(6)->description();

View File

@ -32,6 +32,7 @@ return [
'update_source' => 'https://work.prinzeugen.net/update.json',
'copyright_text' => '<strong>Copyright &copy; '.getdate()['year'].' <a href="{site_url}">{site_name}</a>.</strong> All rights reserved.',
'auto_del_invalid_texture' => 'false',
'allow_downloading_texture' => 'true',
'texture_name_regexp' => '',
'return_200_when_notfound' => 'false',
'cache_expire_time' => '31536000',

View File

@ -103,6 +103,9 @@ general:
title: Invalid Textures
label: Delete invalid textures automatically.
hint: Delete textures records whose file no longer exists from skinlib.
allow_downloading_texture:
title: Downloading Textures
label: Allow users to directly download the source file of a skinlib item.
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.

View File

@ -103,6 +103,9 @@ general:
title: 失效材质
label: 自动删除失效材质
hint: 自动从皮肤库中删除文件不存在的材质记录
allow_downloading_texture:
title: 直接下载材质
label: 允许用户直接下载皮肤库中材质的原始文件
texture_name_regexp:
title: 材质名称规则
hint: 皮肤库上传材质时名称的正则表达式。留空表示允许使用除半角单双引号、反斜杠以外的任意字符。

View File

@ -68,10 +68,12 @@
</tr>
<tr>
<td>Hash
@if (option('allow_downloading_texture'))
<i class="fa fa-question-circle" title="{{ trans('skinlib.show.download-raw') }}" data-toggle="tooltip" data-placement="top"></i>
@endif
</td>
<td>
<a href="{{ url('raw/'.$texture->tid) }}.png" title="{{ $texture->hash }}">{{ substr($texture->hash, 0, 15) }}...</a>
<a href="{{ option('allow_downloading_texture') ? url("raw/{$texture->tid}.png") : 'javascript:;' }}" title="{{ $texture->hash }}">{{ substr($texture->hash, 0, 15) }}...</a>
</td>
</tr>
<tr>

View File

@ -31,7 +31,7 @@ Route::get('/{api}/textures/{hash}', 'TextureController@textureWithAp
Route::get('/avatar/{base64_email}.png', 'TextureController@avatar');
Route::get('/avatar/{size}/{base64_email}.png', 'TextureController@avatarWithSize');
Route::get('/raw/{tid}.png', 'TextureController@raw');
Route::get('/preview/{tid}.png', 'TextureController@preview');
Route::get('/preview/{size}/{tid}.png', 'TextureController@previewWithSize');
option('allow_downloading_texture') && Route::get('/raw/{tid}.png', 'TextureController@raw');