getFileNumber($total_contents . $count_day[$i])]; } for ($i = 0; $i < count($count_day); $i++) { // 统计每日占用空间 $count_contents['chart_disk'][] = [$count_day[$i] => getDirectorySize($total_contents . $count_day[$i])]; } 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() { global $chart_total_file; global $config; $cache_freq = $config['cache_freq']; 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); } 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']); }