Skip to content

Commit 63066b6

Browse files
committed
v2.8.5
1 parent 4338b90 commit 63066b6

11 files changed

+92
-27
lines changed

admin/admin.inc.php

+26-10
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250
auto_delete(); //定时删除
251251
?>
252252
<div class="row">
253-
<?php echo $config['set_notice']; ?>
253+
<?php if (!empty($config['set_notice'])) echo $config['set_notice']; ?>
254254
<div class="col-md-2 col-xs-4">
255255
<ul class="nav nav-tabs nav-stacked">
256256
<li><a data-tab href="#Content1">网站设置</a></li>
@@ -530,8 +530,8 @@
530530
</form>
531531
</div>
532532
<div class="col-md-3">
533-
<h5 class="header-dividing">缩略图缓存 <small><?php echo getFileNumber(APP_ROOT . $config['path'] . 'cache/') . '个 | 占 ' . getDistUsed(getDirectorySize(APP_ROOT . $config['path'] . 'cache/')); ?></small></h5>
534-
<button type="button" class="btn btn-primary" onclick="ajax_post('cache/','delDir')"><i class="icon icon-trash"> 清理缓存</i></button>
533+
<h5 class="header-dividing">缩略图缓存</h5>
534+
<button type="button" class="btn btn-primary" onclick="ajax_post('cache/','delDir')"><i class="icon icon-trash"> <small><?php echo getFileNumber(APP_ROOT . $config['path'] . 'cache/') . ' | ' . getDistUsed(getDirectorySize(APP_ROOT . $config['path'] . 'cache/')); ?></small></i></button>
535535
</div>
536536
<div class="col-md-1">
537537
<h5 class="header-dividing" data-toggle="tooltip" title="如果开启OPcache 点击重置缓存">OPcache</h5>
@@ -571,10 +571,6 @@
571571
</div>
572572
<div class="col-md-12">
573573
<div class="col-md-6">
574-
<div class="form-group">
575-
<label for="report" data-toggle="tooltip" title="举报地址支持Zoho表单、金数据、表单大师等<br/>(推荐ZOHO)留空则不显示">举报地址 <a href="https://store.zoho.com.cn/referral.do?servicename=ZohoForms&category=ZohoForms&ref=52f8a4e98a7a7d4c2475713784605af0dc842f6cc9732dd77f37b87f2959149e212e550f50a869f70360f15b80a4abc6" target="_blank"><i class="icon icon-external-link"></i></a></label>
576-
<input type="text" class="form-control" id="report" name="report" value="<?php echo $config['report']; ?>" placeholder="可以是网址或邮箱地址" onkeyup="this.value=this.value.replace(/\s/g,'')">
577-
</div>
578574
<div class="form-group">
579575
<div class="switch switch-inline">
580576
<input type="hidden" name="static_cdn" value="0">
@@ -584,18 +580,36 @@
584580
<input type="url" class="form-control" name="static_cdn_url" value="<?php echo $config['static_cdn_url']; ?>" onkeyup="this.value=this.value.replace(/\s/g,'')" data-toggle="tooltip" title="jsdelivr可在后边添加版本号 例:@2.5.6">
585581
</div>
586582
</div>
583+
<div class="col-md-6">
584+
<div class="form-group">
585+
<label for="report" data-toggle="tooltip" title="举报地址支持Zoho表单、金数据、表单大师等<br/>(推荐ZOHO)留空则不显示">举报地址 <a href="https://store.zoho.com.cn/referral.do?servicename=ZohoForms&category=ZohoForms&ref=52f8a4e98a7a7d4c2475713784605af0dc842f6cc9732dd77f37b87f2959149e212e550f50a869f70360f15b80a4abc6" target="_blank"><i class="icon icon-external-link"></i></a></label>
586+
<input type="text" class="form-control" id="report" name="report" value="<?php echo $config['report']; ?>" placeholder="可以是网址或邮箱地址" onkeyup="this.value=this.value.replace(/\s/g,'')">
587+
</div>
588+
</div>
589+
</div>
590+
<div class="col-md-12">
587591
<div class="col-md-6">
588592
<div class="form-group">
589593
<div class="switch switch-inline">
590594
<input type="hidden" name="check_ip" value="0">
591595
<input type="checkbox" name="check_ip" value="1" <?php if ($config['check_ip']) echo 'checked="checked"'; ?>>
592596
<label style="font-weight: bold">黑/白IP名单上传</label>
593597
</div>
594-
<textarea class="form-control" rows="4" name="check_ip_list" data-toggle="tooltip" title="每个IP以英文,结尾 支持IP段 例:123.23.23.44,193.134.*.*" placeholder=" 每个IP以英文,结尾 支持IP段 例:192.168.1.13,123.23.23.44,193.134.*.*" onkeyup="this.value=this.value.replace(/\s/g,'')"><?php echo $config['check_ip_list']; ?></textarea>
598+
<textarea class="form-control" rows="4" name="check_ip_list" data-toggle="tooltip" title="每个IP以英文,结尾 支持IP段 例:123.23.23.44,193.134.*.*" placeholder="每个IP以英文,结尾 支持IP段 例:192.168.1.13,123.23.23.44,193.134.*.*" onkeyup="this.value=this.value.replace(/\s/g,'')"><?php echo $config['check_ip_list']; ?></textarea>
595599
<label class="radio-inline"><input type="radio" name="check_ip_model" value="0" <?php if ($config['check_ip_model'] == 0) echo 'checked'; ?>> 黑名单模式</label>
596600
<label class="radio-inline"><input type="radio" name="check_ip_model" value="1" <?php if ($config['check_ip_model'] == 1) echo 'checked'; ?>> 白名单模式</label>
597601
</div>
598602
</div>
603+
<div class="col-md-6">
604+
<div class="form-group">
605+
<div class="switch switch-inline">
606+
<input type="hidden" name="md5_black" value="0">
607+
<input type="checkbox" name="md5_black" value="1" <?php if ($config['md5_black']) echo 'checked="checked"'; ?>>
608+
<label style="font-weight: bold">通过文件MD5禁止上传</label>
609+
</div>
610+
<textarea class="form-control" rows="4" name="md5_blacklist" data-toggle="tooltip" title="上传前后文件md5均可匹配<br/>不区分大小写, 直接输入即可匹配" placeholder="上传前后文件md5均可匹配, 不区分大小写, 直接输入即可匹配" onkeyup="this.value=this.value.replace(/\s/g,'')"><?php echo $config['md5_blacklist']; ?></textarea>
611+
</div>
612+
</div>
599613
</div>
600614
<div class="col-md-12">
601615
<h5 class="header-dividing">高级设置 <?php if ($config['domain'] == $config['imgurl']) echo '<small> 网站域名与图片域名相同,锁定隐藏' . $config['path'] . '目录开关</small>'; ?></h5>
@@ -680,7 +694,7 @@
680694
<div class="switch switch-inline" data-toggle="tooltip" title="关闭后将不能进入后台设置<br/>再次开启需修改config.php: <code>'show_admin_inc'=>1,</code>">
681695
<input type="hidden" name="show_admin_inc" value="0">
682696
<input type="checkbox" name="show_admin_inc" value="1" <?php if ($config['show_admin_inc']) echo 'checked="checked"'; ?>>
683-
<label style="font-weight: bold">后台设置</label>
697+
<label style="font-weight: bold">关闭设置</label>
684698
</div>
685699
</div>
686700
<div class="col-md-2">
@@ -900,6 +914,8 @@
900914
<h5>我的信息</h5>
901915
<hr />
902916
<p class="text-ellipsis">IP: <?php echo real_ip() . ip2region(real_ip()); ?></p>
917+
918+
<p class="text-ellipsis">配置文件更新日期:<?php echo date('Y-m-d H:i:s', filemtime($config_file)); ?></p>
903919
<p class="text-ellipsis">Browser: <?php echo $_SERVER['HTTP_USER_AGENT']; ?></p>
904920
<h5>图床信息</h5>
905921
<hr />
@@ -922,7 +938,7 @@
922938
<a href="https://www.openzui.com/" target="_blank"><span class="label label-badge label-primary" data-toggle="tooltip" title="前端框架">ZUI</span></a>
923939
<a href="https://github.com/verot/class.upload.php" target="_blank"><span class="label label-badge label-primary" data-toggle="tooltip" title="图像处理类">Verot</span></a>
924940
<a href="https://tinyfilemanager.github.io/" target="_blank"><span class="label label-badge label-primary" data-toggle="tooltip" title="文件管理">Tinyfilemanager</span></a>
925-
<a href="https://github.com/rehiy/web-indexr" target="_blank"><span class="label label-badge label-primary" data-toggle="tooltip" title="文件管理">Web-indexr</span></a>
941+
<a href="#"><span class="label label-badge label-primary" data-toggle="tooltip" title="文件管理">Web-indexr</span></a>
926942
<a href="#Ip2Region" data-toggle="collapse" target="_blank"><span class="label label-badge label-primary" data-toggle="tooltip" title="IP地址数据库">Ip2Region<i class="icon icon-angle-down"></i></span></a>
927943
<?php if (empty($config['TinyPng_key'])) : ?>
928944
<span class="label label-badge label-warning" data-toggle="tooltip" title="压缩图片 TinyPng<br/>未填写">TinyPng</span>

admin/version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.8.4
1+
2.8.5

api/index.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
// 上传错误 code:206 客户端文件有问题
164164
$reJson = array(
165165
"result" => "failed",
166-
"code" => 206,
166+
"code" => 400,
167167
"srcName" => $handle->file_src_name_body, // 2023-04-03 原始上传文件名称
168168
"id" => $tokenID, // 2023-04-03 增加 Token ID
169169
"message" => $handle->error,

app/base.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
// 判断当前系统是否为windows
3434
define('IS_WIN', strstr(PHP_OS, 'WIN') ? 1 : 0);
3535
// 定义程序版本
36-
define('APP_VERSION', '2.8.4');
36+
define('APP_VERSION', '2.8.5');
3737

3838
/*---------------基础配置结束-------------------*/

app/del.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
), JSON_UNESCAPED_UNICODE));
4242
} else {
4343
exit(json_encode(array(
44-
'code' => 200,
44+
'code' => 404,
4545
'msg' => '文件不存在',
4646
'type' => 'danger',
4747
'icon' => 'exclamation-sign',
@@ -64,7 +64,7 @@
6464
), JSON_UNESCAPED_UNICODE));
6565
}
6666
exit(json_encode(array(
67-
'code' => 200,
67+
'code' => 404,
6868
'msg' => '删除失败',
6969
'type' => 'danger',
7070
'icon' => 'exclamation-sign',
@@ -115,7 +115,7 @@
115115
), JSON_UNESCAPED_UNICODE));
116116
} else {
117117
exit(json_encode(array(
118-
'code' => 200,
118+
'code' => 404,
119119
'msg' => '删除失败',
120120
'type' => 'danger',
121121
'icon' => 'exclamation-sign',
@@ -139,7 +139,7 @@
139139
), JSON_UNESCAPED_UNICODE));
140140
} else {
141141
exit(json_encode(array(
142-
'code' => 200,
142+
'code' => 404,
143143
'msg' => '回收失败',
144144
'type' => 'danger',
145145
'icon' => 'exclamation-sign',

app/upload.php

+21-5
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
exit(json_encode(
5454
array(
5555
"result" => "failed",
56-
"code" => 403,
56+
"code" => 205,
5757
"message" => "你不能上传任何文件",
5858
),
5959
JSON_UNESCAPED_UNICODE
@@ -67,7 +67,7 @@
6767
exit(json_encode(
6868
array(
6969
"result" => "failed",
70-
"code" => 403,
70+
"code" => 202,
7171
"message" => sprintf("游客限制每日上传 %d 张", $config['ip_upload_counts']),
7272
),
7373
JSON_UNESCAPED_UNICODE
@@ -97,7 +97,7 @@
9797
exit(json_encode(
9898
array(
9999
"result" => "failed",
100-
"code" => 205,
100+
"code" => 406,
101101
"message" => "请勿上传非法文件",
102102
),
103103
JSON_UNESCAPED_UNICODE
@@ -166,6 +166,22 @@
166166

167167
// 图片完整相对路径:/i/2021/05/03/k88e7p.jpg
168168
if ($handle->processed) {
169+
// 黑名单文件 - 通过MD5检测
170+
if ($config['md5_black']) {
171+
$befor_upload_file_md5 = md5_file($handle->file_src_pathname);
172+
$after_upload_file_md5 = md5_file($handle->file_dst_pathname);
173+
if (stristr($config['md5_blacklist'], $befor_upload_file_md5) || stristr($config['md5_blacklist'], $after_upload_file_md5)) {
174+
if (file_exists($handle->file_dst_pathname)) unlink($handle->file_dst_pathname);
175+
exit(json_encode(
176+
array(
177+
"result" => "failed",
178+
"code" => 205,
179+
"message" => "当前文件禁止上传",
180+
),
181+
JSON_UNESCAPED_UNICODE
182+
));
183+
}
184+
}
169185
// 图片相对路径
170186
$pathIMG = $Img_path . $handle->file_dst_name;
171187
// 图片访问网址
@@ -217,10 +233,10 @@
217233
);
218234
echo json_encode($reJson, JSON_UNESCAPED_UNICODE);
219235
$handle->clean(); // 如果取消上传生成缩略图需要恢复此选项功能
220-
} else { // 上传错误 code:206 客户端文件有问题
236+
} else { // 上传错误 code:400 客户端文件有问题
221237
$reJson = array(
222238
"result" => "failed",
223-
"code" => 206,
239+
"code" => 400,
224240
"message" => $handle->error,
225241
"memory" => getDistUsed(memory_get_peak_usage()), // 占用内存 2023-02-12
226242
// 'log' => $handle->log, // 仅用作调试用

config/config.php

+8-5
Large diffs are not rendered by default.

docs/API.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
返回状态可以参考 [常见状态代码](./常见状态代码.md)
12
- 上传成功后返回JSON
23

34
```json

docs/_sidebar.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* [图床更新升级](./图床更新升级.md)
2323
* [更改域名/服务器](./更改域名-服务器.md)
2424
* [常见问题与环境要求](./常见问题.md)
25+
* [常见状态代码](./常见状态代码.md)
2526
* [打赏开发者](./打赏开发者.md)
2627
* [更新日志](./update.md)
2728
* [许可证](./许可证.md)

docs/update.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
* 2024-03-04 v2.8.5
2+
- 返回状态统一
3+
- 增加返回状态文档解释
4+
- 增加通过文件md5禁止上传
5+
16
* 2024-01-20 v2.8.4
27
- Fix [#163](https://github.com/icret/EasyImages2.0/pull/163)
38
- Fix [#159](https://github.com/icret/EasyImages2.0/pull/159)

docs/常见状态代码.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#### 上传状态代码
2+
- 200 - 上传成功
3+
- 202 - 超出游客上传限制
4+
- 204 - 没有选择上传的文件
5+
- 205 - 黑名单内或白名单外用户不允许上传
6+
- 400 - 代码或上传文件有问题
7+
- 401 - 已开启登陆上传且尚未登陆
8+
- 403 - 上传签名错误
9+
- 406 - 非法文件
10+
11+
#### 删除状态代码
12+
- 200 - 删除成功
13+
- 404 - 文件不存在
14+
15+
#### 登录状态代码
16+
- 201 - cookie不存在
17+
- 202 - 无法读取cookie
18+
- 203 - 密码错误
19+
- 204 - 管理员已登录
20+
- 205 - 普通用户已登录
21+
- 206 - 普通用户账号过期
22+
23+
<!-- https://mp.weixin.qq.com/s?__biz=MzI3NDc4NTQ0Nw==&mid=2247495035&idx=2&sn=05d56806e9dd42774d2982e8e28f7146&chksm=eb0c18b3dc7b91a575f49b72efb32e0921efd831571b1f06e011faba3cea72eac4f83407971b&scene=27 -->

0 commit comments

Comments
 (0)