优化和修复bugs

This commit is contained in:
icret
2023-02-05 13:24:32 +08:00
parent 60d0192bbc
commit ee0abc2bb6
7 changed files with 31 additions and 25 deletions

View File

@@ -1623,10 +1623,14 @@ function process_checkImg($imgurl)
* $fileSize 图片的大小
* $form 来源如果是网页上传直接显示网页,如果是API上传则显示ID
*/
function write_log($filePath, $sourceName, $absolutePath, $fileSize, $from = "web")
function write_upload_logs($filePath, $sourceName, $absolutePath, $fileSize, $from = "web")
{
global $config;
if (!$config['upload_logs']) {
return null;
}
$checkImg = $config['checkImg'] == true ? "ON" : "OFF";
// $name = trim(basename($filePath), " \t\n\r\0\x0B"); // 当前图片名称
@@ -1718,12 +1722,14 @@ function ip2region(String $IP)
*/
function ip_upload_counts()
{
$dir = APP_ROOT . '/admin/logs/ipcounts/';
global $config;
if (!is_dir($dir)) {
mkdir($dir, 0777);
if ($config['ip_upload_counts'] > 0) {
$dir = APP_ROOT . '/admin/logs/ipcounts/';
if (!is_dir($dir)) mkdir($dir, 0777);
$file = $dir . date('Ymd') . '.php';
file_put_contents($file, real_ip() . PHP_EOL, FILE_APPEND | LOCK_EX);
}
$file = $dir . date('Ymd') . '.php';
file_put_contents($file, real_ip() . PHP_EOL, FILE_APPEND | LOCK_EX);
}

View File

@@ -213,20 +213,18 @@ if ($handle->uploaded) {
// 同IP上传日志
@ip_upload_counts();
// 日志
if ($config['upload_logs']) @write_log($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);
// 鉴黄
@process_checkImg($processUrl);
// 日志
if ($config['upload_logs']) @write_log($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size);
// 水印
@water($handle->file_dst_pathname);
// 压缩
@ip_upload_counts();
@process_compress($handle->file_dst_pathname);
} else { // 普通模式
// 记录同IP上传次数
@ip_upload_counts();
// 日志
if ($config['upload_logs']) @write_log($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);
// 鉴黄
@process_checkImg($processUrl);
// 水印