From 95574a35d526dec0da63a393bb7c6d5db1212fa4 Mon Sep 17 00:00:00 2001 From: icret Date: Sat, 30 Oct 2021 23:00:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=81=A2=E5=A4=8D=E9=93=BE?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + api/api-web.php | 18 +++++++++++++----- config/config.php | 6 ++++-- file.php | 2 +- libs/function.php | 20 +++++++++++++++----- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index b8fea74..43089aa 100755 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ RewriteRule config/(.*).(php)$ – [F] - 或者参考:[https://www.545141.com/981.html](https://www.545141.com/981.html)
点击查看2.0版更新日志 + * 2021年10月30日 - 增加监黄接口 - 增加对php5.6-php8.0的支持 diff --git a/api/api-web.php b/api/api-web.php index 26ebba7..3b553fd 100755 --- a/api/api-web.php +++ b/api/api-web.php @@ -36,6 +36,12 @@ if (isset($_POST['delDir'])) { header("refresh:1;"); // 1s后刷新当前页面 } } +// 恢复图片 +if(isset($_GET['reimg'])){ + $name = $_GET['reimg']; + re_checkImg($name); +} + ?>
@@ -145,12 +151,12 @@ if (isset($_POST['delDir'])) {
@@ -193,7 +199,7 @@ if (isset($_POST['delDir'])) {

-
+

@@ -211,6 +217,7 @@ if (isset($_POST['delDir'])) { 长宽(像素) 大小 查看图片 + 还原图片 删除图片 @@ -227,7 +234,7 @@ if (isset($_POST['delDir'])) { @$filen_name = $cache_file[$i]; // 图片名称 @list($width, $height, $type, $attr) = getimagesize($file_cache_path); // 图片长、宽、类型、属性 $url = $config['imgurl'] . $config['path'] . 'cache/' . $cache_file[$i]; // 图片网络连接 - $unlink_url = $config['domain'] . '/api/del.php?url=' . $url; // 图片删除连接 + $unlink_img = $config['domain'] . '/api/del.php?url=' . $url; // 图片删除连接 // 缩略图文件 $thumb_cache_file = $config['domain'] . '/libs/thumb.php?img=' . $file_path . '&width=300&height=300'; echo ' @@ -238,7 +245,8 @@ if (isset($_POST['delDir'])) { ' . $height . '*' . $width . ' ' . $file_size . ' 查看原图 - 删除图片 + 恢复图片 + 删除图片 '; } diff --git a/config/config.php b/config/config.php index eb60d52..3dec031 100755 --- a/config/config.php +++ b/config/config.php @@ -179,7 +179,9 @@ $config = array( * 从 https://moderatecontent.com/ 获取key并填入/config/api_key.php的图片检查key * 开启后会受服务器到https://moderatecontent.com/ 速度影响,国内不建议开启! */ - 'checkImg' => false, + 'checkImg' => true, + // 设置是不良图片概率,概率越大准确率越高, + 'checkImg_value' => 50, // 当前版本 - 'version' => '2.3.1', + 'version' => '2.3.1' ); diff --git a/file.php b/file.php index 9cfbdf8..153bb1b 100755 --- a/file.php +++ b/file.php @@ -120,7 +120,7 @@ if ($handle->uploaded) { if($config['checkImg']){ require_once APP_ROOT . '/config/api_key.php'; - @checkImg($imageUrl); + checkImg($imageUrl); } } diff --git a/libs/function.php b/libs/function.php index 0949d28..53ed100 100755 --- a/libs/function.php +++ b/libs/function.php @@ -619,17 +619,16 @@ function get_json($img) $output = json_decode($output, true); return $output; } - // 检查图片是否违规 -function checkImg($imageUrl) +function checkImg($imageUrl, $mode = true) { global $config; $response = get_json($imageUrl); - if ($response['rating_index'] == '3') { // (1 = everyone, 2 = teen, 3 = adult) - + if ($response['rating_index'] == 3 or $response['predictions']['adult'] > $config['checkImg_value']) { // (1 = everyone, 2 = teen, 3 = adult) $old_path = APP_ROOT . parse_url($imageUrl)['path']; // 提交网址中的文件路径 /i/2021/10/29/p8vypd.png - $name = basename($imageUrl); // 文件名 p8vypd.png + //$name = date('Y_m_d').'_'.basename($imageUrl); // 文件名 p8vypd.png + $name = date('Y_m_d') . '_' . basename($imageUrl); // 文件名 2021_10_30_p8vypd.png $new_path = APP_ROOT . $config['path'] . 'cache/' . $name; // 新路径含文件名 $cache_dir = APP_ROOT . $config['path'] . 'cache/'; // cache路径 @@ -641,3 +640,14 @@ function checkImg($imageUrl) } } } + +// 还原被审查的图片 +function re_checkImg($name) +{ + global $config; + + $now_file = str_replace('_', '/', $name); // 当前图片相对位置 2021/10/30/p8vypd.png + $now_path_file = APP_ROOT . $config['path'] . 'cache/' . $name; // 当前图片绝对位置 */i/cache/2021_10_30_p8vypd.png + $to_file = APP_ROOT . $config['path'] . $now_file; // 还原图片的绝对位置 */i/2021/10/30/p8vypd.png + rename($now_path_file, $to_file); +}