修复一些问题
parent
fc7052d226
commit
b11a776195
11
README.md
11
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
|
||||
<form action="http://127.0.0.1/api/index.php" method="post" enctype="multipart/form-data">
|
||||
<input type="file" name="image" accept="image/*">
|
||||
|
@ -174,6 +174,11 @@ $HTTP["url"] =~ "^/(i|public)/" {
|
|||
|
||||
<details><summary>点击查看2.0版更新日志</summary>
|
||||
|
||||
* 2022-05-04 v2.6.2 deving
|
||||
- 增加转换webp后也会添加水印
|
||||
- webp水印会增大图片体积消耗更多PHP内存,PHP8以上有很大概率失败!
|
||||
- 修复一些bugs
|
||||
|
||||
* 2022-05-03 v2.6.1
|
||||
- 增加登陆用户有效期
|
||||
- 增加管理员/登陆用户/Token专用目录
|
||||
|
|
|
@ -1117,7 +1117,7 @@ if (isset($_GET['recycle_reimg'])) {
|
|||
<p id="delimgurl"></p>
|
||||
<div class="form-group">
|
||||
<label for="del" class="text-primary">删除单张图片文件: </label>
|
||||
<input type="url" name="url" class="form-control input-sm" id="del" placeholder="请输入图片链接">
|
||||
<input type="url" name="url_admin_inc" class="form-control input-sm" id="del" placeholder="请输入图片链接">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-sm btn-primary" onClick="return confirm('确认要删除?\n* 删除文件后将无法恢复! ');">删除单文件</button>
|
||||
</form>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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'];
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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'],
|
||||
|
|
|
@ -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'=>'<a href="/admin/terms.php" target="_blank">请勿上传违反中国政策的图片</a>
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
|
|
|
@ -21,7 +21,7 @@ if (!IS_WIN) {
|
|||
} else {
|
||||
$file_php = false;
|
||||
}
|
||||
if (is_writable(APP_ROOT . '/i/')) {
|
||||
if (is_writable(APP_ROOT . $config['path'])) {
|
||||
$i_wjj = true;
|
||||
} else {
|
||||
$i_wjj = false;
|
||||
|
|
Loading…
Reference in New Issue