- 增加限制游客上传

* 2023-02-01 v2.7.0 dev
- 增加限制游客上传
- 增加上传历史记录
- 增加粘贴上传状态
- 增加广场非图片图标
- 增加前端显示缩略图链接
- 增加每日获取Bing图片背景
- 增加图片详细信息管理登录后显示更多信息
- 增加解析上传IP地址 (使用方法参考提示信息)
- 修复图片详细信息中随机图片排版混乱
- 替换访问生成缩略图代码
- 更新一些组件
- 调整前端显示
- 优化代码
This commit is contained in:
icret
2023-02-01 22:20:33 +08:00
parent 22b75d89c7
commit ef5b17deed
9 changed files with 277 additions and 190 deletions

View File

@@ -7,7 +7,7 @@ require __DIR__ . '/class.upload.php';
// 检查登录
if ($config['mustLogin']) {
if (checkLogin() !== 204 && checkLogin() !== 205) {
if (is_who_login(null)) {
exit(json_encode(array(
"result" => "failed",
"code" => 401,
@@ -16,6 +16,17 @@ if ($config['mustLogin']) {
}
}
// 无文件
if (empty($_FILES['file'])) {
exit(json_encode(
array(
"result" => "failed",
"code" => 204,
"message" => "没有选择上传的文件",
)
));
}
// 黑/白IP名单上传
if ($config['check_ip']) {
if (checkIP(null, $config['check_ip_list'], $config['check_ip_model'])) {
@@ -28,15 +39,23 @@ if ($config['check_ip']) {
}
}
// 无文件
if (empty($_FILES['file'])) {
exit(json_encode(
array(
"result" => "failed",
"code" => 204,
"message" => "没有选择上传的文件",
)
));
// 根据IP限制游客每日上传数量
if ($config['ip_upload_counts'] > 0 && !is_who_login(null)) {
$ipList = APP_ROOT . '/admin/logs/ipcounts/' . date('Ymd') . '.php';
if (is_file($ipList)) {
$ipList = file_get_contents($ipList);
$ipList = explode(PHP_EOL, $ipList);
if (array_count_values($ipList)[real_ip()] >= $config['ip_upload_counts']) {
exit(json_encode(
array(
"result" => "failed",
"code" => 403,
"message" => "游客限制每日上传 " . $config['ip_upload_counts'] . ' 张',
)
));
}
clearstatcache();
}
}
$handle = new Upload($_FILES['file'], 'zh_CN');
@@ -188,8 +207,6 @@ if ($handle->uploaded) {
}
/** 后续处理 */
require __DIR__ . '/process.php';
// 使用fastcgi_finish_request操作
if (function_exists('fastcgi_finish_request')) {
fastcgi_finish_request();
@@ -201,6 +218,8 @@ if ($handle->uploaded) {
@water($handle->file_dst_pathname);
// 压缩
@compress($handle->file_dst_pathname);
// 记录同IP上传次数
@ip_upload_counts();
} else {
// 普通模式鉴黄
@process_checkImg($processUrl);
@@ -210,6 +229,8 @@ if ($handle->uploaded) {
@water($handle->file_dst_pathname);
// 压缩
@compress($handle->file_dst_pathname);
// 记录同IP上传次数
@ip_upload_counts();
}
unset($handle);