From f819df0f0f2b755b672c26308b700783a5c2d2b4 Mon Sep 17 00:00:00 2001 From: wispx <1591788658@qq.com> Date: Sat, 19 Jan 2019 11:04:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E5=9B=BE=E7=89=87=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=A2=9E=E5=8A=A0"=E5=8F=AF=E7=96=91=E5=9B=BE?= =?UTF-8?q?=E7=89=87"=E9=80=89=E9=A1=B9=EF=BC=8C=E9=89=B4=E9=BB=84?= =?UTF-8?q?=E4=B8=8D=E7=9B=B4=E6=8E=A5=E6=8B=A6=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/index/controller/Install.php | 3 ++- application/index/controller/Upload.php | 9 ++++++--- application/index/controller/admin/Images.php | 19 ++++++++++++++----- .../index/view/admin/images/index.html | 8 ++++++-- install.sql | 3 ++- update.sql | 1 + 6 files changed, 31 insertions(+), 12 deletions(-) diff --git a/application/index/controller/Install.php b/application/index/controller/Install.php index 1cf6ec48..7a5b6d7c 100644 --- a/application/index/controller/Install.php +++ b/application/index/controller/Install.php @@ -217,7 +217,8 @@ EOT; // 新建表字段 $tableFields = [ 'lsky_images' => [ - 'folder_id' => "ALTER TABLE `lsky_images` ADD `folder_id` INT NOT NULL DEFAULT '0' COMMENT '文件夹ID' AFTER `user_id`;" + 'folder_id' => "ALTER TABLE `lsky_images` ADD `folder_id` INT NOT NULL DEFAULT '0' COMMENT '文件夹ID' AFTER `user_id`;", + 'suspicious' => "ALTER TABLE `lsky_images` ADD `suspicious` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '可疑图片' AFTER `ip`;", ], 'lsky_users' => [ 'default_folder' => "ALTER TABLE `lsky_users` ADD `default_folder` VARCHAR(32) DEFAULT NULL COMMENT '默认上传文件夹' AFTER `quota`;" diff --git a/application/index/controller/Upload.php b/application/index/controller/Upload.php index f576a9ca..557a3f7c 100644 --- a/application/index/controller/Upload.php +++ b/application/index/controller/Upload.php @@ -91,6 +91,7 @@ class Upload extends Base $url = make_url($domain, $pathname); // 图片鉴黄 + $suspicious = 0; if ($this->config['open_audit']) { $client = new Client(); $response = $client->get("https://www.moderatecontent.com/api/v2?key={$this->config['audit_key']}&url={$url}"); @@ -98,8 +99,9 @@ class Upload extends Base $result = json_decode($response->getBody()->getContents()); if (0 == $result->error_code) { if ($result->rating_index >= $this->config['audit_index']) { - $strategy->delete($pathname); - throw new Exception('图片[' . $image->getInfo('name') . ']涉嫌违规,禁止上传!'); + /*$strategy->delete($pathname); + throw new Exception('图片[' . $image->getInfo('name') . ']涉嫌违规,禁止上传!');*/ + $suspicious = 1; } } else { $strategy->delete($pathname); @@ -117,7 +119,8 @@ class Upload extends Base 'size' => $size, 'mime' => $mime, 'sha1' => $sha1, - 'md5' => $md5 + 'md5' => $md5, + 'suspicious' => $suspicious ]; // 默认上传文件夹,暂只支持一级 diff --git a/application/index/controller/admin/Images.php b/application/index/controller/admin/Images.php index 05924148..32ef6500 100644 --- a/application/index/controller/admin/Images.php +++ b/application/index/controller/admin/Images.php @@ -33,11 +33,17 @@ class Images extends Base $this->assign('strategyList', $this->strategyList); } - public function index($strategy = '', $keyword = '', $limit = 15) + public function index($where = '', $keyword = '', $limit = 15) { + $where = json_decode($where, true); + if (null == $where) { + $where = [ + 'suspicious' => 0 + ]; + } $model = new ImagesModel(); - if (!empty($strategy)) { - $model = $model->where('strategy', $strategy); + foreach ($where as $field => $value) { + $model = $model->where($field, $value); } if (!empty($keyword)) { $model = $model->where('pathname|sha1|md5', 'like', "%{$keyword}%"); @@ -47,7 +53,8 @@ class Images extends Base 'keyword' => $keyword ] ])->each(function ($item) { - $item->username = Users::where('id', $item->user_id)->value('username'); + $username = Users::where('id', $item->user_id)->value('username'); + $item->username = $username ? $username : '访客'; $item->strategyStr = isset($this->strategyList[$item->strategy]) ? $this->strategyList[$item->strategy]['name'] : '未知'; return $item; }); @@ -55,8 +62,10 @@ class Images extends Base 'images' => $images, 'keyword' => $keyword, 'strategyList' => $this->strategyList, - 'strategy' => $strategy + 'strategy' => isset($where['strategy']) ? $where['strategy'] : '', + 'suspicious' => isset($where['suspicious']) ? $where['suspicious'] : 0 ]); + return $this->fetch(); } diff --git a/application/index/view/admin/images/index.html b/application/index/view/admin/images/index.html index 0c57b8d8..79adf3e9 100644 --- a/application/index/view/admin/images/index.html +++ b/application/index/view/admin/images/index.html @@ -16,11 +16,12 @@