From 6aac1f68384bb521a6f5f3ba716fc301157b0c07 Mon Sep 17 00:00:00 2001 From: icret Date: Fri, 12 Nov 2021 22:17:05 +0800 Subject: [PATCH] v2.4.1 --- README.md | 10 +- admin/admin.inc.php | 132 ++++++------------ admin/info.php | 131 +++++++++++++++++ admin/{index.php => tool.php} | 75 +--------- application/chart.php | 91 +++++------- application/footer.php | 42 +++--- application/function.php | 4 +- application/header.php | 25 ++-- application/list.php | 129 +++++++++-------- application/login.php | 43 ++++-- application/total_files.php | 40 +++--- config/config.php | 20 ++- i/cache/d2efe4a4eedde82b566dc7eed5bb2513.php | 1 - ...chart_d2efe4a4eedde82b566dc7eed5bb2513.php | 1 - index.php | 2 +- public/static/jscolor.min.js | 1 - public/static/viewjs/viewer.min.css | 9 ++ public/static/viewjs/viewer.min.js | 10 ++ 18 files changed, 405 insertions(+), 361 deletions(-) create mode 100755 admin/info.php rename admin/{index.php => tool.php} (80%) delete mode 100755 i/cache/d2efe4a4eedde82b566dc7eed5bb2513.php delete mode 100755 i/cache/total_chart_total_chart_d2efe4a4eedde82b566dc7eed5bb2513.php delete mode 100755 public/static/jscolor.min.js create mode 100755 public/static/viewjs/viewer.min.css create mode 100755 public/static/viewjs/viewer.min.js diff --git a/README.md b/README.md index c4db86f..6ffbd1f 100755 --- a/README.md +++ b/README.md @@ -66,7 +66,15 @@ RewriteRule config/(.*).(php)$ – [F]
点击查看2.0版更新日志 -* 2021-11-5 v2.4.0 +* 2021-11-12 v2.4.1 +- 增加缓存周期配置 +- 增加上传统计 +- 增加viewjs +- 更新依赖件 +- 修复统计错误 + + +* 2021-11-9 v2.4.0 - 增加统计缓存 - 增加最近30天上传统计与占用空间图表 - 增加初始化安装(可能会不支持二级目录安装,可删除install文件夹初始化) diff --git a/admin/admin.inc.php b/admin/admin.inc.php index 530c576..436a480 100755 --- a/admin/admin.inc.php +++ b/admin/admin.inc.php @@ -36,7 +36,7 @@ if (isset($_POST['form'])) { @@ -78,12 +78,14 @@ if (isset($_POST['form'])) { +
+ + +
- > + >
@@ -102,18 +104,14 @@ if (isset($_POST['form'])) {
- > + >
- > + >
@@ -124,27 +122,13 @@ if (isset($_POST['form'])) {
@@ -158,15 +142,9 @@ if (isset($_POST['form'])) {
@@ -176,36 +154,15 @@ if (isset($_POST['form'])) {
@@ -231,9 +188,7 @@ if (isset($_POST['form'])) {
- title=" 轻微有损压缩图片, 此压缩有可能使图片变大!特别是小图片 也有一定概率改变图片方向"> + title=" 轻微有损压缩图片, 此压缩有可能使图片变大!特别是小图片 也有一定概率改变图片方向">
@@ -270,9 +225,7 @@ if (isset($_POST['form'])) {
- > + >
@@ -295,9 +248,7 @@ if (isset($_POST['form'])) {
- > + >
@@ -308,9 +259,7 @@ if (isset($_POST['form'])) {
- > + >
@@ -345,9 +294,7 @@ if (isset($_POST['form'])) {
- > + >
@@ -359,18 +306,14 @@ if (isset($_POST['form'])) {
- > + >
- title="开启后会受服务器到https://moderatecontent.com速度影响,国内不建议开启!"> + title="开启后会受服务器到https://moderatecontent.com速度影响,国内不建议开启!">
@@ -383,6 +326,11 @@ if (isset($_POST['form'])) {
+
+ + + +

当前软件版本:

@@ -398,7 +346,7 @@ if (isset($_POST['form'])) {
- + + + + +
@@ -116,12 +94,6 @@ if (is_array($char_data)) { ?>

当前版本:,Github版本:

-

统计时间: ' . read_total_json('total_time') . ';文件夹:' . read_total_json('dirnum') . '个;托管图片:' . read_total_json('filenum') . '张;占用:' . read_total_json('usage_space') . ';缓存周期:每小时。'; - ?> -

@@ -224,13 +196,6 @@ if (is_array($char_data)) { -
-
-

上传统计(每日更新)

- -

单位:上传/个 占用/Mb 统计时间:

-

-

@@ -296,9 +261,9 @@ if (is_array($char_data)) {
- 已缓存个文件 - 缓存占用 - + 已缓存文件: + 占用 +
@@ -306,10 +271,6 @@ if (is_array($char_data)) { - - diff --git a/application/chart.php b/application/chart.php index 7831080..f750cae 100755 --- a/application/chart.php +++ b/application/chart.php @@ -2,7 +2,7 @@ require_once __DIR__ . '/function.php'; /** - * 统计 + * 统计最近一个月上传文件数与空间占用 */ // 获取最近一周,一个月,一年 https://www.cnblogs.com/-mrl/p/7680700.html @@ -29,17 +29,22 @@ function getLatelyTime($type = '') return $result; } -$total_contents = APP_ROOT . $config['path']; // 获取用户自定义的上传目录 -$chart_total_fileName = 'total_chart_' . md5_file(APP_ROOT . '/config/config.php'); // 以config.php文件的md5命名 -$chart_total_file = $total_contents . 'cache/' . $chart_total_fileName . '.php'; // 文件绝对目录 +$total_contents = APP_ROOT . $config['path']; // 获取用户自定义的上传目录 +$chart_total_file_md5 = strval(md5_file(APP_ROOT . '/config/config.php')); // 以config.php文件的md5命名 +$chart_total_file = $total_contents . "cache/chart-$chart_total_file_md5.php"; // 文件绝对目录 function write_chart_total() { global $total_contents; global $chart_total_file; + global $chart_total_file_md5; $count_day = getLatelyTime('month'); + $count_contents['filename'] = $chart_total_file_md5; // 文件名称 + $count_contents['total_time'] = date('Y-m-d H:i:s'); // 统计时间 + $count_contents['date'] = date('YmdH'); // 校对时间 + for ($i = 0; $i < count($count_day); $i++) { // 统计每日上传数量 $count_contents['chart_data'][] = [$count_day[$i] => getFileNumber($total_contents . $count_day[$i])]; @@ -49,10 +54,7 @@ function write_chart_total() // 统计每日占用空间 $count_contents['chart_disk'][] = [$count_day[$i] => getDirectorySize($total_contents . $count_day[$i])]; } - - $count_contents['total_time'] = date('Y-m-d H:i:s'); // 统计时间 - $count_contents['date'] = date('Ymd'); // 校对时间 - + $count_contents = json_encode($count_contents, true); // serialize存储文件 file_put_contents($chart_total_file, $count_contents); // 存储文件 } @@ -60,60 +62,35 @@ function write_chart_total() function read_chart_total() { global $chart_total_file; + global $config; - if (is_file($chart_total_file)) { + $cache_freq = $config['cache_freq']; - $chart_total_file = file_get_contents($chart_total_file); - $chart_total_file = json_decode($chart_total_file, true); - - - if ($chart_total_file['date'] !== date('Ymd')) { - write_chart_total(); - } else { - for ($i = 0; $i < count($chart_total_file['chart_data']); $i++) { - // 读取每日上传数量 - foreach ($chart_total_file['chart_data'][$i] as $key => $value) { - $chart_data_date[] = '"' . $key . '" ,'; - $chart_data_num[] = '"' . $value . '" ,'; - //echo $key . '
'; - //echo $value . '
'; - } - foreach ($chart_total_file['chart_disk'][$i] as $value) { - $value = round($value / 1024 / 1024, 2); - - $chart_total_disk[] = '"' . $value . '" ,'; - } - } - - return array('date' => $chart_data_date, 'number' => $chart_data_num, 'disk' => $chart_total_disk, 'total_time' => $chart_total_file['total_time']); - } + if (file_exists($chart_total_file)) { + $read_chart_file = file_get_contents($chart_total_file); + $read_chart_file = json_decode($read_chart_file, true); } else { write_chart_total(); + $read_chart_file = file_get_contents($chart_total_file); + $read_chart_file = json_decode($read_chart_file, true); } - - /* - switch ($name) { - case 'date': - return $chart_data_date; - break; - case 'number': - return $chart_data_num; - case 'disk': - return $chart_total_disk; - break; - default: - return $chart_data_date; + if ((date('YmdH') - $read_chart_file['date']) > $cache_freq) { + write_chart_total(); + $read_chart_file = file_get_contents($chart_total_file); + $read_chart_file = json_decode($read_chart_file, true); } - */ + + for ($i = 0; $i < count($read_chart_file['chart_data']); $i++) { + // 读取每日上传数量 + foreach ($read_chart_file['chart_data'][$i] as $key => $value) { + $chart_data_date[] = '"' . $key . '" ,'; + $chart_data_num[] = '"' . $value . '" ,'; + } + foreach ($read_chart_file['chart_disk'][$i] as $value) { + $value = round($value / 1024 / 1024, 2); + $chart_total_disk[] = '"' . $value . '" ,'; + } + } + return array('filename' => $read_chart_file['filename'], 'date' => $chart_data_date, 'number' => $chart_data_num, 'disk' => $chart_total_disk, 'total_time' => $read_chart_file['total_time']); } -/* - -$char_data = read_chart_total(); -$chart_date = $char_data['date']; -$chart_number = $char_data['number']; -$chart_disk = $char_data['disk']; -var_dump($char_data['disk']); -var_dump($char_data['number']); - -*/ \ No newline at end of file diff --git a/application/footer.php b/application/footer.php index 9dedd82..3f58202 100755 --- a/application/footer.php +++ b/application/footer.php @@ -51,28 +51,28 @@ NProgress.start(); NProgress.done(); -