From 9b14b06e636f55a24219a7eaa67121ac1c50382b Mon Sep 17 00:00:00 2001 From: icret Date: Tue, 16 Nov 2021 12:57:14 +0800 Subject: [PATCH] fix contents --- admin/chartjs.php | 137 ------------------ admin/logs/verson/verson.json | 41 ------ api/application/apiFunction.php | 4 +- application/chart.php | 7 +- application/class.upload.php | 4 +- application/class.version.php | 5 + application/function.php | 18 +-- application/{write-log.php => logs-write.php} | 8 +- application/total_files.php | 4 +- config/config.php | 2 +- file.php | 2 +- robots.txt | 3 +- 12 files changed, 36 insertions(+), 199 deletions(-) delete mode 100755 admin/chartjs.php delete mode 100755 admin/logs/verson/verson.json rename application/{write-log.php => logs-write.php} (91%) diff --git a/admin/chartjs.php b/admin/chartjs.php deleted file mode 100755 index 548a87e..0000000 --- a/admin/chartjs.php +++ /dev/null @@ -1,137 +0,0 @@ - - -
- -
- -
-
统计时间:
-
- -
-
今日上传 -
- -
-
昨日上传 -
- -
-
- 累计上传 -
- -
- -
- 缓存文件 -
- -
-
- 可疑图片 -
- -
-
- 文件夹 -
- -
-
- 占用存储 -
- -
-
- 剩余空间 -
- -
-
-
-

最近30上传趋势与空间占用(上传/张 占用/MB)

- -
-
- - - - - - getDirectorySize($total_contents . $count_day[$i])]; } - $count_contents = json_encode($count_contents, true); // serialize存储文件 + if(!is_dir(APP_ROOT.'/admin/logs/counts/')){ + mkdir(APP_ROOT.'/admin/logs/counts/',0755,true); + } + + $count_contents = json_encode($count_contents, true); file_put_contents($chart_total_file, $count_contents); // 存储文件 + } function read_chart_total() diff --git a/application/class.upload.php b/application/class.upload.php index 85d2ae5..8ae9b2d 100755 --- a/application/class.upload.php +++ b/application/class.upload.php @@ -25,7 +25,7 @@ // | This script is free to use, don't abuse. | // +------------------------------------------------------------------------+ -//namespace Verot\Upload; +// namespace Verot\Upload; if (!defined('IMG_WEBP')) define('IMG_WEBP', 32); @@ -2956,7 +2956,7 @@ class Upload { function imageunset($im) { if (is_resource($im)) { imagedestroy($im); - } else if (is_object($im) && $im instanceOf \GdImage) { + } else if (is_object($im) && $im instanceOf GdImage) { unset($im); } } diff --git a/application/class.version.php b/application/class.version.php index 3723285..abc2851 100755 --- a/application/class.version.php +++ b/application/class.version.php @@ -30,6 +30,11 @@ class getVerson public function downJson() { + if(!is_dir(__DIR__.'/../admin/logs/verson/')) + { + mkdir(__DIR__.'/../admin/logs/verson/',0755,true); + } + $verson = $this->geturl($this->url); $verson = json_decode($verson, true); $file = fopen(__DIR__ . '/../admin/logs/verson/verson.json', 'w+'); diff --git a/application/function.php b/application/function.php index aebd3a8..2b11d4c 100755 --- a/application/function.php +++ b/application/function.php @@ -638,7 +638,7 @@ function checkImg($imageUrl) $response = get_json($imageUrl); if ($response['rating_index'] == 3 or $response['predictions']['adult'] > $config['checkImg_value']) { // (1 = everyone, 2 = teen, 3 = adult) //$old_path = APP_ROOT . parse_url($imageUrl)['path']; // 提交网址中的文件路径 /i/2021/10/29/p8vypd.png - $old_path = APP_ROOT . str_replace($config['imgurl'], '', $imageUrl);; // 提交网址中的文件路径 /i/2021/10/29/p8vypd.png + $old_path = APP_ROOT . str_replace($config['imgurl'], '', $imageUrl); // 提交网址中的文件路径 /i/2021/10/29/p8vypd.png $name = date('Y_m_d') . '_' . basename($imageUrl); // 文件名 2021_10_30_p8vypd.png $new_path = APP_ROOT . $config['path'] . 'suspic/' . $name; // 新路径含文件名 $cache_dir = APP_ROOT . $config['path'] . 'suspic/'; // suspic路径 @@ -668,15 +668,15 @@ function creat_cache_images($imgName) require_once __DIR__ . '/class.thumb.php'; global $config; - $old_img_path = APP_ROOT . config_path() . $imgName; // 获取要创建缩略图文件的绝对路径 - $cache_path = APP_ROOT . $config['path'] . 'cache/'; // cache目录的绝对路径 - if (!isAnimatedGif($old_img_path)) { // 仅针对非gif创建图片缩略图 - if (is_dir($cache_path)) { + $old_img_path = APP_ROOT . config_path() . $imgName; // 获取要创建缩略图文件的绝对路径 + $cache_path = APP_ROOT . $config['path'] . 'cache/'; // cache目录的绝对路径 + + if(!is_dir($cache_path)){ // 创建cache目录 + mkdir($cache_path, 0777, true); + } + if (!isAnimatedGif($old_img_path)) { // 仅针对非gif创建图片缩略图 $new_imgName = APP_ROOT . $config['path'] . 'cache/' . date('Y_m_d') . '_' . $imgName; // 缩略图缓存的绝对路径 - Thumb::out($old_img_path, $new_imgName, 300, 300); // 保存缩略图 - } else { - mkdir($cache_path, 0777, true); // 创建cache目录 - } + Thumb::out($old_img_path, $new_imgName, 300, 300); // 保存缩略图 } } diff --git a/application/write-log.php b/application/logs-write.php similarity index 91% rename from application/write-log.php rename to application/logs-write.php index 8f638ac..1913600 100755 --- a/application/write-log.php +++ b/application/logs-write.php @@ -57,7 +57,6 @@ function real_ip() */ function write_log($file, $cacheFile = null) { - global $config; $name = trim(basename($file), " \t\n\r\0\x0B"); // 图片名称 $log = array($name => array( 'date' => date('Y-m-d H:i:s'), // 上传日期 @@ -69,8 +68,13 @@ function write_log($file, $cacheFile = null) $logFileName = APP_ROOT . '/admin/logs/upload/' . date('Y-m') . '.php'; + // 创建日志文件夹 + if(!is_dir(APP_ROOT.'/admin/logs/upload/')){ + mkdir(APP_ROOT.'/admin/logs/upload',0755,true); + } + // 写入禁止浏览器直接访问 - if (is_file($logFileName) == false) { + if (!is_file($logFileName)){ $php_code = ''; file_put_contents($logFileName, $php_code); } diff --git a/application/total_files.php b/application/total_files.php index 5e235bc..bdc9e11 100755 --- a/application/total_files.php +++ b/application/total_files.php @@ -61,10 +61,10 @@ function creat_json() // 创建json文件 'yestUpload' => $yestUpload // 昨日上传数量 ]; $totalJsonInfo = json_encode($totalJsonInfo, true); - if (is_dir($total_file_path . 'cache/')) { + if (is_dir(APP_ROOT.'/admin/logs/counts/')) { file_put_contents($totalJsonName, $totalJsonInfo); } else { - mkdir($total_file_path . 'cache/', 0777, true); // 创建cache目录 + mkdir(APP_ROOT.'/admin/logs/counts/', 0777, true); // 创建cache目录 file_put_contents($totalJsonName, $totalJsonInfo); } } diff --git a/config/config.php b/config/config.php index 6c56fe2..f4c66dc 100755 --- a/config/config.php +++ b/config/config.php @@ -74,7 +74,7 @@ $config=Array 'checkEnv'=>1, 'checkImg'=>0, 'checkImg_value'=>50, - 'upload_logs'=>0, + 'upload_logs'=>1, 'cache_freq'=>2, 'version'=>'2.4.2', 'form'=>'', diff --git a/file.php b/file.php index 9ee3077..2a3f4af 100755 --- a/file.php +++ b/file.php @@ -122,7 +122,7 @@ if ($handle->uploaded) { // 上传日志控制 if ($config['upload_logs'] == true) { - require_once APP_ROOT . '/application/write-log.php'; + require_once APP_ROOT . '/application/logs-write.php'; @write_log($imageUrl); } diff --git a/robots.txt b/robots.txt index c002314..3478983 100755 --- a/robots.txt +++ b/robots.txt @@ -2,4 +2,5 @@ User-agent: * Disallow: Disallow: /config/ -Disallow: /admin/ \ No newline at end of file +Disallow: /admin/ +Disallow: /install/ \ No newline at end of file