From b11a776195f7765a87a0e6319d0f1534dc217e05 Mon Sep 17 00:00:00 2001 From: icret Date: Tue, 3 May 2022 17:23:09 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 11 ++++++++--- admin/admin.inc.php | 2 +- application/WaterMask.php | 16 ++++++++++++++++ application/del.php | 14 +++++++++++--- application/function.php | 27 +++++++++++++++++++++++++++ application/process.php | 4 ++-- config/config.php | 6 +++--- install/index.php | 2 +- 8 files changed, 69 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 526cdd7..024e930 100755 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ ## 目录 -[特点](#特点)-[注意](#常见问题)-[安装](#安装)-[升级](#程序升级)-[安全](#安全配置)-[鉴黄](#鉴黄)-[更新日志](#更新日志)-[支持开发者](#支持开发者)-[界面演示](#界面演示)-[兼容](#兼容)-[鸣谢](#鸣谢)-[许可证](#开源许可) +[特点](#特点)-[注意](#常见问题)-[安装](#安装)-[升级](#程序升级)-[安全](#安全配置)-[API](#API上传)-[鉴黄](#鉴黄)-[更新日志](#更新日志)-[支持开发者](#支持开发者)-[界面演示](#界面演示)-[兼容](#兼容)-[鸣谢](#鸣谢)-[许可证](#开源许可) ## 特点 @@ -83,8 +83,8 @@ chown -R www:www /web目录 - 安装环境 Ngixn(推荐) / Apache + PHP(推荐≥7.0) - 软件商店搜索`简单图床`一键部署 -#### API使用 -- 示例 +#### API上传 +- 需要开启图床安全->API上传示例 ```html
@@ -174,6 +174,11 @@ $HTTP["url"] =~ "^/(i|public)/" {
点击查看2.0版更新日志 +* 2022-05-04 v2.6.2 deving +- 增加转换webp后也会添加水印 +- webp水印会增大图片体积消耗更多PHP内存,PHP8以上有很大概率失败! +- 修复一些bugs + * 2022-05-03 v2.6.1 - 增加登陆用户有效期 - 增加管理员/登陆用户/Token专用目录 diff --git a/admin/admin.inc.php b/admin/admin.inc.php index ba779ca..bec0c3d 100755 --- a/admin/admin.inc.php +++ b/admin/admin.inc.php @@ -1117,7 +1117,7 @@ if (isset($_GET['recycle_reimg'])) {

- +
diff --git a/application/WaterMask.php b/application/WaterMask.php index af7fbcd..7514eaf 100755 --- a/application/WaterMask.php +++ b/application/WaterMask.php @@ -78,6 +78,12 @@ class Imgs imagecopyresampled($temp_img, $im, 0, 0, 0, 0, $temp_w, $temp_h, $width, $height); imagepng($temp_img, $savepath, 100); break; + case 18: + $im = imagecreatefromwebp($src); + imagesavealpha($im, true); //这里很重要;3-1 + imagecopyresampled($temp_img, $im, 0, 0, 0, 0, $temp_w, $temp_h, $width, $height); + imagewebp($temp_img, $savepath, 100); + break; } imagedestroy($im); return $savepath; @@ -162,6 +168,10 @@ class Imgs $dst_img = imagecreatefrompng($src); imagesavealpha($dst_img, true); //这里很重要;3-1 break; + case 18: + $dst_img = imagecreatefromwebp($src); + imagesavealpha($dst_img, true); //这里很重要;3-1 + break; default: return array('code' => false, 'msg' => '目标图片类型错误'); @@ -200,6 +210,9 @@ class Imgs case 3: $markim = imagecreatefrompng($def['res']); break; + case 18: + $markim = imagecreatefromwebp($def['res']); + break; default: return array('code' => false, 'msg' => '水印图片类型错误'); @@ -316,6 +329,9 @@ class Imgs case 'gif': imagegif($dst_img, $def['name']); break; + case 'webp': + imagegif($dst_img, $def['name']); + break; default: return array('code' => false, 'msg' => '保存图片类型有误'); break; diff --git a/application/del.php b/application/del.php index db81de5..2f1d4df 100755 --- a/application/del.php +++ b/application/del.php @@ -26,8 +26,6 @@ if (isset($_GET['hash'])) { $delHash = $_GET['hash']; $delHash = urlHash($delHash, 1); - // getDel($delHash, 'hash'); - if ($config['image_recycl']) { // 如果开启回收站则进入回收站 if (checkImg($delHash, 3, 'recycle/') == true) { @@ -57,10 +55,20 @@ if (isset($_GET['hash'])) { // 检查登录后再处理url删除请求 if (is_who_login('admin')) { - // 删除 + + // 广场页面删除 if (isset($_GET['url'])) { getDel($_GET['url'], 'url'); } + + // 从管理页面删除 + if (isset($_GET['url_admin_inc'])) { + $del_url = $_GET['url_admin_inc']; + if ($config['hide_path']) { + $del_url = $config['domain'] . $config['path'] . parse_url($del_url)['path']; + } + getDel($del_url, 'url'); + } // 回收 if (isset($_GET['recycle_url'])) { $recycle_url = $_GET['recycle_url']; diff --git a/application/function.php b/application/function.php index 9ec075b..e972da0 100755 --- a/application/function.php +++ b/application/function.php @@ -1311,6 +1311,8 @@ function is_local($url) /** * 将图片域名转换为数组并随即输出 + * @param $text 字符串 + * @return String 随机网址 */ function rand_imgurl($text = null) { @@ -1319,3 +1321,28 @@ function rand_imgurl($text = null) $url = explode(',', $url); return $url[array_rand($url, 1)]; } + +/** + * 判断webp或gif动图是否为动态图片 + * @param $src 图片的绝对路径 + * @return bool 是|否 + */ +function isAnimatedGifWebp($src) +{ + $ext = pathinfo($src)['extension']; + + if ($ext == 'webp') { + $webpContents = file_get_contents($src); + $where = strpos($webpContents, "ANMF"); + if ($where !== FALSE) { + // animated + return true; + } + return false; + } + + $fp = fopen($src, 'rb'); + $filecontent = fread($fp, filesize($src)); + fclose($fp); + return strpos($filecontent, chr(0x21) . chr(0xff) . chr(0x0b) . 'NETSCAPE2.0') === FALSE ? false : true; +} diff --git a/application/process.php b/application/process.php index deae196..b391751 100755 --- a/application/process.php +++ b/application/process.php @@ -29,7 +29,7 @@ function water($source) // 文字水印 if ($config['watermark'] == 1) { // 过滤gif - if (isAnimatedGif($source) === 0) { + if (!isAnimatedGifWebp($source)) { $arr = [ # 水印图片路径(如果不存在将会被当成是字符串水印) 'res' => $config['waterText'], @@ -48,7 +48,7 @@ function water($source) // 图片水印 if ($config['watermark'] == 2) { // 过滤gif - if (isAnimatedGif($source) === 0) { + if (!isAnimatedGifWebp($source)) { $arr = [ # 水印图片路径(如果不存在将会被当成是字符串水印) 'res' => APP_ROOT . $config['waterImg'], diff --git a/config/config.php b/config/config.php index ba07e09..675b59d 100755 --- a/config/config.php +++ b/config/config.php @@ -15,13 +15,13 @@ $config=Array 'user'=>'admin', 'password'=>'e6e061838856bf47e1de730719fb2609', 'mustLogin'=>0, - 'apiStatus'=>1, + 'apiStatus'=>0, 'path'=>'/i/', 'mime'=>'image/*,video/*', 'imgName'=>'default', 'maxSize'=>10485760, 'maxUploadFiles'=>30, - 'watermark'=>0, + 'watermark'=>1, 'waterText'=>'简单图床 - png.cm', 'waterPosition'=>0, 'textColor'=>'rgba(255,0,0,1)', @@ -92,7 +92,7 @@ $config=Array 'token_path_status'=>0, 'admin_path'=>'u', 'version'=>'2.6.1', - 'update'=>'2022-05-03 19:00:49', + 'update'=>'2022-05-04 01:08:52', 'footer'=>'请勿上传违反中国政策的图片