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 @@
- {foreach $strategyList as $key => $value} - + {/foreach} + @@ -98,6 +99,9 @@ }, {confirmText: '确定', cancelText: '取消'}); } }; + $('.mdui-select.where').on('close.mdui.select', function () { + $('#search-form').submit(); + }); $('.mdui-select.operation').on('close.mdui.select', function () { if ($(this).val() !== '') { var selected = $('tr.mdui-table-row-selected'); diff --git a/install.sql b/install.sql index 2b5ca477..a5b82298 100644 --- a/install.sql +++ b/install.sql @@ -82,7 +82,7 @@ INSERT INTO `lsky_config` (`id`, `key`, `type`, `input_type`, `name`, `title`, ` (41, '', 'text', 'text', 'system_version', '系统版本', NULL, '1.4.2', ''), -(42, 'audit', 'bool', 'checkbox', 'open_audit', '开启图片鉴黄', '鉴黄接口申请地址:https://www.moderatecontent.com', '0', ''), +(42, 'audit', 'bool', 'checkbox', 'open_audit', '开启图片鉴黄', '接口申请地址:https://www.moderatecontent.com', '0', ''), (43, 'audit', 'text', 'text', 'audit_key', 'Key', NULL, '', ''), (44, 'audit', 'select', 'text', 'audit_index', '内容评级', '1=所有人,2=少年,3=成人', '3', '{\"1\": \"所有人\", \"2\": \"少年\", \"3\": \"成人\"}'), (45, 'other', 'bool', 'checkbox', 'open_api', '开启API', '是否开放接口', '0', ''), @@ -109,6 +109,7 @@ CREATE TABLE IF NOT EXISTS `lsky_images` ( `sha1` varchar(100) NOT NULL COMMENT 'hash sha1', `md5` varchar(32) NOT NULL COMMENT 'hash md5', `ip` varchar(128) DEFAULT NULL COMMENT '上传者IP', + `suspicious` tinyint(1) NOT NULL DEFAULT '0' COMMENT '可疑图片', `create_time` int(11) NOT NULL COMMENT '创建时间' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='图片表'; diff --git a/update.sql b/update.sql index f85dd398..93dd6e38 100644 --- a/update.sql +++ b/update.sql @@ -49,6 +49,7 @@ UPDATE `lsky_images` SET `strategy` = 'kodo' WHERE `lsky_images`.`strategy` = 'q -- v1.4.3 UPDATE `lsky_config` SET `value` = '1.4.3' WHERE `lsky_config`.`name` = 'system_version'; +UPDATE `lsky_config` SET `tip` = '接口申请地址:https://www.moderatecontent.com' WHERE `lsky_config`.`name` = 'open_audit'; INSERT IGNORE INTO `lsky_config` (`id`, `key`, `type`, `input_type`, `name`, `title`, `tip`, `value`, `extend`) VALUES (NULL, 'basics', 'textarea', 'textarea', 'custom_style', '自定义CSS', NULL, '\r\n', ''), (NULL, 'basics', 'textarea', 'textarea', 'statistics_code', '统计代码', NULL, '', '');