diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index f9de0794..6d014473 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -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(); diff --git a/config/options.php b/config/options.php index 65793a0b..11c923c5 100644 --- a/config/options.php +++ b/config/options.php @@ -32,6 +32,7 @@ return [ 'update_source' => 'https://work.prinzeugen.net/update.json', 'copyright_text' => 'Copyright © '.getdate()['year'].' {site_name}. All rights reserved.', 'auto_del_invalid_texture' => 'false', + 'allow_downloading_texture' => 'true', 'texture_name_regexp' => '', 'return_200_when_notfound' => 'false', 'cache_expire_time' => '31536000', diff --git a/resources/lang/en/options.yml b/resources/lang/en/options.yml index fad5cc9a..e85a0c8d 100644 --- a/resources/lang/en/options.yml +++ b/resources/lang/en/options.yml @@ -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. diff --git a/resources/lang/zh_CN/options.yml b/resources/lang/zh_CN/options.yml index 32e17df3..50f4c1fb 100644 --- a/resources/lang/zh_CN/options.yml +++ b/resources/lang/zh_CN/options.yml @@ -103,6 +103,9 @@ general: title: 失效材质 label: 自动删除失效材质 hint: 自动从皮肤库中删除文件不存在的材质记录 + allow_downloading_texture: + title: 直接下载材质 + label: 允许用户直接下载皮肤库中材质的原始文件 texture_name_regexp: title: 材质名称规则 hint: 皮肤库上传材质时名称的正则表达式。留空表示允许使用除半角单双引号、反斜杠以外的任意字符。 diff --git a/resources/views/skinlib/show.tpl b/resources/views/skinlib/show.tpl index 70503c2a..ed16ce8d 100644 --- a/resources/views/skinlib/show.tpl +++ b/resources/views/skinlib/show.tpl @@ -68,10 +68,12 @@ Hash + @if (option('allow_downloading_texture')) + @endif - {{ substr($texture->hash, 0, 15) }}... + tid}.png") : 'javascript:;' }}" title="{{ $texture->hash }}">{{ substr($texture->hash, 0, 15) }}... diff --git a/routes/static.php b/routes/static.php index 47e7c12c..bac55ebb 100644 --- a/routes/static.php +++ b/routes/static.php @@ -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');