pull/141/head
icret 2023-02-15 11:47:00 +08:00
parent cdf9ea9fd9
commit e56fdf6778
8 changed files with 67 additions and 60 deletions

View File

@ -41,6 +41,7 @@
* [x] 支持创建仅上传用户 * [x] 支持创建仅上传用户
* [x] 对于安装环境要求极低 * [x] 对于安装环境要求极低
* [x] 对于服务器性能要求极低 * [x] 对于服务器性能要求极低
* [x] 理论上[支持所有常见格式](/docs/其他格式.md)
* [x] 更多功能支持请安装尝试··· * [x] 更多功能支持请安装尝试···
## 界面演示 ## 界面演示

View File

@ -990,11 +990,11 @@ auto_delete(); //定时删除
<div class="bg-warning with-padding hidden-xs"> <div class="bg-warning with-padding hidden-xs">
<h5 class="header-dividing"><span class="label label-success">New</span> <?php echo getVersion('name'); ?></h5> <h5 class="header-dividing"><span class="label label-success">New</span> <?php echo getVersion('name'); ?></h5>
<pre style="background-color: rgba(0, 0, 0, 0);border-color:rgba(0, 0, 0, 0);">更新内容: <br /><?php echo getVersion('body'); ?></pre> <pre style="background-color: rgba(0, 0, 0, 0);border-color:rgba(0, 0, 0, 0);">更新内容: <br /><?php echo getVersion('body'); ?></pre>
<h6>* 更新日期: <?php echo getVersion('created_at'); ?> 下载新版本上传至网站升级, 然后点击更新版本号。</h6> <h6>* 更新日期: <?php echo getVersion('created_at'); ?> 下载新版本上传至网站升级 <a href="https://icret.gitee.io/easyimages2.0/#/./图床更新升级" target="_blank" data-toggle="tooltip" title="升级方法"><i class="icon icon-question"></i></a> 然后点击更新版本号。</h6>
<form action="<?php $_SERVER['SCRIPT_NAME']; ?>" method="post"> <form action="<?php $_SERVER['SCRIPT_NAME']; ?>" method="post">
<input class="form-control" type="hidden" name="del_version_file" value="/admin/logs/version/version.json" readonly> <input class="form-control" type="hidden" name="del_version_file" value="/admin/logs/version/version.json" readonly>
<div class="btn-group"> <div class="btn-group">
<a class="btn btn-mini btn-primary" href="https://github.com/icret/EasyImages2.0/releases" target="_blank" data-toggle="tooltip" title="Github releases">Github</a> <a class="btn btn-mini btn-primary" href="https://github.com/icret/EasyImages2.0/releases" target="_blank" data-toggle="tooltip" title="Releases Info">Github</a>
<a class="btn btn-mini btn-primary" href="<?php echo getVersion('zipball_url'); ?>" target="_blank" data-toggle="tooltip" title="① 下载后上传至网站更新">下载新版本</a> <a class="btn btn-mini btn-primary" href="<?php echo getVersion('zipball_url'); ?>" target="_blank" data-toggle="tooltip" title="① 下载后上传至网站更新">下载新版本</a>
<button class="btn btn-mini btn-danger" data-toggle="tooltip" title="② 升级后获取新的版本信息">更新版本号</button> <button class="btn btn-mini btn-danger" data-toggle="tooltip" title="② 升级后获取新的版本信息">更新版本号</button>
</div> </div>

View File

@ -33,20 +33,14 @@ if ($config['check_ip']) {
// 根据IP限制游客每日上传数量 // 根据IP限制游客每日上传数量
if ($config['ip_upload_counts'] > 0 && !is_who_login('status')) { if ($config['ip_upload_counts'] > 0 && !is_who_login('status')) {
$ipList = APP_ROOT . '/admin/logs/ipcounts/' . date('Ymd') . '.php'; if (false == get_ip_upload_log_counts(real_ip())) {
if (is_file($ipList)) { exit(json_encode(
$ipList = file_get_contents($ipList); array(
$ipList = explode(PHP_EOL, $ipList); "result" => "failed",
if (array_count_values($ipList)[real_ip()] >= $config['ip_upload_counts']) { "code" => 403,
exit(json_encode( "message" => sprintf("游客限制每日上传 %d 张", $config['ip_upload_counts']),
array( )
"result" => "failed", ));
"code" => 403,
"message" => "游客限制每日上传 " . $config['ip_upload_counts'] . ' 张',
)
));
}
clearstatcache();
} }
} }
@ -194,7 +188,7 @@ if ($handle->uploaded) {
if (function_exists('fastcgi_finish_request')) { // fastcgi_finish_request 模式 if (function_exists('fastcgi_finish_request')) { // fastcgi_finish_request 模式
fastcgi_finish_request(); fastcgi_finish_request();
// 记录同IP上传次数 // 记录同IP上传次数
@ip_upload_counts(); @write_ip_upload_count_logs();
// 上传日志 // 上传日志
@write_upload_logs($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size, $tokenID); @write_upload_logs($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size, $tokenID);
// 鉴黄 // 鉴黄
@ -205,7 +199,7 @@ if ($handle->uploaded) {
@process_compress($handle->file_dst_pathname); @process_compress($handle->file_dst_pathname);
} else { // 普通模式 } else { // 普通模式
// 记录同IP上传次数 // 记录同IP上传次数
@ip_upload_counts(); @write_ip_upload_count_logs();
// 上传日志 // 上传日志
@write_upload_logs($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size, $tokenID); @write_upload_logs($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size, $tokenID);
// 鉴黄 // 鉴黄

View File

@ -18,6 +18,7 @@
* 如果因安装问题或其他问题可以给我发邮件。 * 如果因安装问题或其他问题可以给我发邮件。
*/ */
use function PHPSTORM_META\type;
/*---------------基础配置开始-------------------*/ /*---------------基础配置开始-------------------*/
@ -1684,41 +1685,56 @@ function ip2region(String $IP)
} catch (Exception $e) { } catch (Exception $e) {
return '查询失败: ' . $e->getMessage(); return '查询失败: ' . $e->getMessage();
} }
/* 官方查询示例
require 'Ip2Region.php';
$ip2region = new Ip2Region();
$ip = '107.148.129.110';
echo PHP_EOL;
echo "查询IP:{$ip}" . PHP_EOL;
$info = $ip2region->btreeSearch($ip);
var_export($info);
echo PHP_EOL;
$info = $ip2region->memorySearch($ip);
var_export($info);
echo PHP_EOL;
*/
} }
/** /**
* 记录同IP每日上传次数 process * 记录同IP每日上传次数 process
*/ */
function ip_upload_counts() function write_ip_upload_count_logs()
{ {
global $config; global $config;
if ($config['ip_upload_counts'] > 0) { if ($config['ip_upload_counts'] > 0) {
// 上传IP地址
$ip = real_ip();
// 日志目录
$dir = APP_ROOT . '/admin/logs/ipcounts/'; $dir = APP_ROOT . '/admin/logs/ipcounts/';
// 日志文件
$file = $dir . date('Y-m-d') . '.php';
// 创建日志目录
if (!is_dir($dir)) mkdir($dir, 0777); if (!is_dir($dir)) mkdir($dir, 0777);
// 创建日志文件
$file = $dir . date('Ymd') . '.php'; if (!is_file($file)) file_put_contents($file, '<?php $ipcounts=array(); ?>' . PHP_EOL, FILE_APPEND | LOCK_EX);
file_put_contents($file, real_ip() . PHP_EOL, FILE_APPEND | LOCK_EX); // 引入日志
require $file;
// 获取存在的IP
if (isset($ipcounts[$ip])) {
$info[$ip] = $ipcounts[$ip] + 1;
} else {
$info[$ip] = 1;
}
// 写入日志
$info = array_replace($ipcounts, $info);
cache_write($file, $info, 'ipcounts');
} }
} }
/**
* 限制IP每日上传次数
* @param Sting $ip IP地址
*/
function get_ip_upload_log_counts($ip)
{
global $config;
$file = APP_ROOT . '/admin/logs/ipcounts/' . date('Y-m-d') . '.php';
if (!is_file($file)) return true;
require_once $file;
if (!isset($ipcounts[$ip])) return true;
if ($ipcounts[$ip] >= $config['ip_upload_counts']) return false;
return true;
}
/** /**
* 自动删除 * 自动删除
@ -1754,7 +1770,7 @@ function auto_delete()
} }
} }
/** 创建文件夹及文件 */ /** 创建日志文件夹及文件 */
if (!is_dir(APP_ROOT . '/admin/logs/tasks/')) { if (!is_dir(APP_ROOT . '/admin/logs/tasks/')) {
mkdir(APP_ROOT . '/admin/logs/tasks/', 0755, true); mkdir(APP_ROOT . '/admin/logs/tasks/', 0755, true);
} }
@ -1763,7 +1779,7 @@ function auto_delete()
file_put_contents(APP_ROOT . '/admin/logs/tasks/auto_delete.php', '<?php /** 自动删除日志 */ return; ?>' . PHP_EOL, FILE_APPEND | LOCK_EX); file_put_contents(APP_ROOT . '/admin/logs/tasks/auto_delete.php', '<?php /** 自动删除日志 */ return; ?>' . PHP_EOL, FILE_APPEND | LOCK_EX);
} }
/** 写入日志 */ // 写入日志
file_put_contents(APP_ROOT . '/admin/logs/tasks/auto_delete.php', $log . PHP_EOL, FILE_APPEND | LOCK_EX); file_put_contents(APP_ROOT . '/admin/logs/tasks/auto_delete.php', $log . PHP_EOL, FILE_APPEND | LOCK_EX);
return true; return true;
} }

View File

@ -41,20 +41,14 @@ if ($config['check_ip']) {
// 根据IP限制游客每日上传数量 // 根据IP限制游客每日上传数量
if ($config['ip_upload_counts'] > 0 && !is_who_login('status')) { if ($config['ip_upload_counts'] > 0 && !is_who_login('status')) {
$ipList = APP_ROOT . '/admin/logs/ipcounts/' . date('Ymd') . '.php'; if (false == get_ip_upload_log_counts(real_ip())) {
if (is_file($ipList)) { exit(json_encode(
$ipList = file_get_contents($ipList); array(
$ipList = explode(PHP_EOL, $ipList); "result" => "failed",
if (array_count_values($ipList)[real_ip()] >= $config['ip_upload_counts']) { "code" => 403,
exit(json_encode( "message" => sprintf("游客限制每日上传 %d 张", $config['ip_upload_counts']),
array( )
"result" => "failed", ));
"code" => 403,
"message" => "游客限制每日上传 " . $config['ip_upload_counts'] . ' 张',
)
));
}
clearstatcache();
} }
} }
@ -213,7 +207,7 @@ if ($handle->uploaded) {
if (function_exists('fastcgi_finish_request')) { // fastcgi_finish_request 模式 if (function_exists('fastcgi_finish_request')) { // fastcgi_finish_request 模式
fastcgi_finish_request(); fastcgi_finish_request();
// 同IP上传日志 // 同IP上传日志
@ip_upload_counts(); @write_ip_upload_count_logs();
// 日志 // 日志
@write_upload_logs($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size); @write_upload_logs($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size);
// 鉴黄 // 鉴黄
@ -224,7 +218,7 @@ if ($handle->uploaded) {
@process_compress($handle->file_dst_pathname); @process_compress($handle->file_dst_pathname);
} else { // 普通模式 } else { // 普通模式
// 记录同IP上传次数 // 记录同IP上传次数
@ip_upload_counts(); @write_ip_upload_count_logs();
// 日志 // 日志
@write_upload_logs($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size); @write_upload_logs($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size);
// 鉴黄 // 鉴黄

View File

@ -115,7 +115,7 @@ $config=Array
'guest_path_status'=>0, 'guest_path_status'=>0,
'token_path_status'=>0, 'token_path_status'=>0,
'admin_path'=>'u', 'admin_path'=>'u',
'update'=>'2023-02-14 21:17:45', 'update'=>'2023-02-15 11:44:21',
'footer'=>'<a href="https://github.com/icret/EasyImages2.0" target="_blank" rel="nofollow" data-toggle="tooltip" title="Since 2018 - Github">© Since 2018</a> 'footer'=>'<a href="https://github.com/icret/EasyImages2.0" target="_blank" rel="nofollow" data-toggle="tooltip" title="Since 2018 - Github">© Since 2018</a>
<a href="https://png.cm/" target="_blank" data-toggle="tooltip" title="EasyImage 简单图床">EasyImage</a> <a href="https://png.cm/" target="_blank" data-toggle="tooltip" title="EasyImage 简单图床">EasyImage</a>
<a href="/admin/terms.php" target="_blank" data-toggle="tooltip" title="使用协议">DMCA</a> <a href="/admin/terms.php" target="_blank" data-toggle="tooltip" title="使用协议">DMCA</a>

View File

@ -41,6 +41,7 @@
* [x] 支持创建仅上传用户 * [x] 支持创建仅上传用户
* [x] 对于安装环境要求极低 * [x] 对于安装环境要求极低
* [x] 对于服务器性能要求极低 * [x] 对于服务器性能要求极低
* [x] 理论上[支持所有常见格式](./其他格式.md)
* [x] 更多功能支持请安装尝试··· * [x] 更多功能支持请安装尝试···
## 界面演示 ## 界面演示

View File

@ -1,5 +1,6 @@
*2023-02-12 v2.7.5 dev *2023-02-15 v2.7.5 dev
- 增加定时删除文件 - 增加定时删除文件
- 修复一处bug
- 更换检测新版本方式 - 更换检测新版本方式
- API上传增加返回Token ID - API上传增加返回Token ID
- 优化显示 - 优化显示