加入流量查看,访客与视频数量图片数量查看
This commit is contained in:
@@ -73,6 +73,25 @@ if (!move_uploaded_file($file['tmp_name'], $target)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$bytes = (int)($file['size'] ?? 0);
|
||||
try {
|
||||
$statsRoot = __DIR__ . '/../stats';
|
||||
if (!is_dir($statsRoot)) { @mkdir($statsRoot, 0777, true); }
|
||||
$dailyPath = $statsRoot . '/daily.json';
|
||||
$today = (new DateTime('now'))->format('Y-m-d');
|
||||
$daily = [];
|
||||
if (file_exists($dailyPath)) {
|
||||
$rawDaily = @file_get_contents($dailyPath);
|
||||
$decoded = json_decode($rawDaily, true);
|
||||
if (is_array($decoded)) { $daily = $decoded; }
|
||||
}
|
||||
if (!isset($daily[$today]) || !is_array($daily[$today])) {
|
||||
$daily[$today] = ['visits' => 0, 'video_plays' => 0, 'picture_shows' => 0, 'uv' => 0, 'bandwidth_in' => 0, 'bandwidth_out' => 0];
|
||||
}
|
||||
$daily[$today]['bandwidth_in'] += (int)$bytes;
|
||||
@file_put_contents($dailyPath, json_encode($daily, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT), LOCK_EX);
|
||||
} catch (Throwable $e) {}
|
||||
|
||||
// 可选:记录一个简单的元信息文件
|
||||
$meta = [
|
||||
'original_name' => $origName,
|
||||
|
||||
Reference in New Issue
Block a user