- fix
parent
cdf9ea9fd9
commit
e56fdf6778
|
@ -41,6 +41,7 @@
|
|||
* [x] 支持创建仅上传用户
|
||||
* [x] 对于安装环境要求极低
|
||||
* [x] 对于服务器性能要求极低
|
||||
* [x] 理论上[支持所有常见格式](/docs/其他格式.md)
|
||||
* [x] 更多功能支持请安装尝试···
|
||||
|
||||
## 界面演示
|
||||
|
|
|
@ -990,11 +990,11 @@ auto_delete(); //定时删除
|
|||
<div class="bg-warning with-padding hidden-xs">
|
||||
<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>
|
||||
<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">
|
||||
<input class="form-control" type="hidden" name="del_version_file" value="/admin/logs/version/version.json" readonly>
|
||||
<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>
|
||||
<button class="btn btn-mini btn-danger" data-toggle="tooltip" title="② 升级后获取新的版本信息">更新版本号</button>
|
||||
</div>
|
||||
|
|
|
@ -33,20 +33,14 @@ if ($config['check_ip']) {
|
|||
|
||||
// 根据IP限制游客每日上传数量
|
||||
if ($config['ip_upload_counts'] > 0 && !is_who_login('status')) {
|
||||
$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();
|
||||
if (false == get_ip_upload_log_counts(real_ip())) {
|
||||
exit(json_encode(
|
||||
array(
|
||||
"result" => "failed",
|
||||
"code" => 403,
|
||||
"message" => sprintf("游客限制每日上传 %d 张", $config['ip_upload_counts']),
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,7 +188,7 @@ if ($handle->uploaded) {
|
|||
if (function_exists('fastcgi_finish_request')) { // fastcgi_finish_request 模式
|
||||
fastcgi_finish_request();
|
||||
// 记录同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);
|
||||
// 鉴黄
|
||||
|
@ -205,7 +199,7 @@ if ($handle->uploaded) {
|
|||
@process_compress($handle->file_dst_pathname);
|
||||
} else { // 普通模式
|
||||
// 记录同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);
|
||||
// 鉴黄
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* 如果因安装问题或其他问题可以给我发邮件。
|
||||
*/
|
||||
|
||||
use function PHPSTORM_META\type;
|
||||
|
||||
/*---------------基础配置开始-------------------*/
|
||||
|
||||
|
@ -1684,41 +1685,56 @@ function ip2region(String $IP)
|
|||
} catch (Exception $e) {
|
||||
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
|
||||
*/
|
||||
function ip_upload_counts()
|
||||
function write_ip_upload_count_logs()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if ($config['ip_upload_counts'] > 0) {
|
||||
|
||||
// 上传IP地址
|
||||
$ip = real_ip();
|
||||
// 日志目录
|
||||
$dir = APP_ROOT . '/admin/logs/ipcounts/';
|
||||
// 日志文件
|
||||
$file = $dir . date('Y-m-d') . '.php';
|
||||
// 创建日志目录
|
||||
if (!is_dir($dir)) mkdir($dir, 0777);
|
||||
|
||||
$file = $dir . date('Ymd') . '.php';
|
||||
file_put_contents($file, real_ip() . PHP_EOL, FILE_APPEND | LOCK_EX);
|
||||
// 创建日志文件
|
||||
if (!is_file($file)) file_put_contents($file, '<?php $ipcounts=array(); ?>' . 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/')) {
|
||||
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', $log . PHP_EOL, FILE_APPEND | LOCK_EX);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -41,20 +41,14 @@ if ($config['check_ip']) {
|
|||
|
||||
// 根据IP限制游客每日上传数量
|
||||
if ($config['ip_upload_counts'] > 0 && !is_who_login('status')) {
|
||||
$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();
|
||||
if (false == get_ip_upload_log_counts(real_ip())) {
|
||||
exit(json_encode(
|
||||
array(
|
||||
"result" => "failed",
|
||||
"code" => 403,
|
||||
"message" => sprintf("游客限制每日上传 %d 张", $config['ip_upload_counts']),
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,7 +207,7 @@ if ($handle->uploaded) {
|
|||
if (function_exists('fastcgi_finish_request')) { // fastcgi_finish_request 模式
|
||||
fastcgi_finish_request();
|
||||
// 同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);
|
||||
// 鉴黄
|
||||
|
@ -224,7 +218,7 @@ if ($handle->uploaded) {
|
|||
@process_compress($handle->file_dst_pathname);
|
||||
} else { // 普通模式
|
||||
// 记录同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);
|
||||
// 鉴黄
|
||||
|
|
|
@ -115,7 +115,7 @@ $config=Array
|
|||
'guest_path_status'=>0,
|
||||
'token_path_status'=>0,
|
||||
'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>
|
||||
<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>
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
* [x] 支持创建仅上传用户
|
||||
* [x] 对于安装环境要求极低
|
||||
* [x] 对于服务器性能要求极低
|
||||
* [x] 理论上[支持所有常见格式](./其他格式.md)
|
||||
* [x] 更多功能支持请安装尝试···
|
||||
|
||||
## 界面演示
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
*2023-02-12 v2.7.5 dev
|
||||
*2023-02-15 v2.7.5 dev
|
||||
- 增加定时删除文件
|
||||
- 修复一处bug
|
||||
- 更换检测新版本方式
|
||||
- API上传增加返回Token ID
|
||||
- 优化显示
|
||||
|
|
Loading…
Reference in New Issue