$totalJsonName, // 文件名称 'date' => date('YmdH', strtotime('-1 hour')), // 识别日期格式 'total_time' => date('Y-m-d H:i:s'), // 统计时间 'dirnum' => $dirn, // 文件夹数量 'filenum' => $filen, // 文件数量 'usage_space' => $usage_space, // 占用空间 'todayUpload' => $todayUpload, // 今日上传数量 'yestUpload' => $yestUpload // 昨日上传数量 ]; $totalJsonInfo = json_encode($totalJsonInfo, true); if (is_dir($total_file_path . 'cache/')) { $totalJsonFile = fopen($total_file_path . "cache/$totalJsonName.php", 'w+'); fwrite($totalJsonFile, $totalJsonInfo); fclose($totalJsonFile); } else { mkdir($total_file_path . 'cache/', 0777, true); // 创建cache目录 } } function read_total_json($total) // 读取json文件 { global $config; global $totalJsonFile; global $totalJsonName; $totalJsonPath = APP_ROOT . $config['path'] . 'cache/' . $totalJsonName . '.php'; // 文件的路径 if (file_exists($totalJsonPath)) { $totalJsonFile = file_get_contents($totalJsonPath); $totalJsonFile = json_decode($totalJsonFile, true); if ($totalJsonFile['date'] !== date('YmdH', strtotime('-1 hour'))) { creat_json(); } } else { creat_json(); } return $totalJsonFile[$total]; }