From 4a862c6ecc1cc82a2fc94a9371fbbc3df9755d57 Mon Sep 17 00:00:00 2001 From: printempw Date: Tue, 16 Aug 2016 22:58:21 +0800 Subject: [PATCH] notify user if texture file is deleted --- app/Controllers/SkinlibController.php | 5 ++++- app/Controllers/TextureController.php | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/Controllers/SkinlibController.php b/app/Controllers/SkinlibController.php index 8cef14d2..93aa1a20 100644 --- a/app/Controllers/SkinlibController.php +++ b/app/Controllers/SkinlibController.php @@ -96,7 +96,10 @@ class SkinlibController extends BaseController { if (!isset($_GET['tid'])) Http::abort(404, 'No specified tid.'); $texture = Texture::find($_GET['tid']); - if (!$texture) Http::abort(404, '请求的材质已经被删除'); + + if (!$texture || $texture && !\Storage::exist(BASE_DIR."/textures/".$texture->hash)) { + Http::abort(404, '请求的材质文件已经被删除,请联系管理员删除该条目'); + } if ($texture->public == "0") { if (is_null($this->user) || ($this->user->uid != $texture->uploader && !$this->user->is_admin)) diff --git a/app/Controllers/TextureController.php b/app/Controllers/TextureController.php index d5bc7163..225c71be 100644 --- a/app/Controllers/TextureController.php +++ b/app/Controllers/TextureController.php @@ -119,8 +119,14 @@ class TextureController extends BaseController public function raw($tid) { if ($t = Texture::find($tid)) { - header('Content-Type: image/png'); - echo \Storage::fread(BASE_DIR."/textures/".$t->hash); + $fname = BASE_DIR."/textures/".$t->hash; + + if (\Storage::exist($fname)) { + header('Content-Type: image/png'); + echo \Storage::fread($fname); + } else { + Http::abort(404, '请求的材质文件已经被删除'); + } } else { Http::abort(404, '材质不存在'); }