Connecting the world

Trending !

Joined users

Ruhani sharma
David Smith
My Heaven Models Raipur
Ujjan Roy
carpenters dubai
Heli Teerth
Anunta Tech
carrieandlowellcom phát tán mã độc BOTNET

Get Mobile Apps

Get Messenger

Welcome back!

Welcome!

OR
Don't have an account? Create a new account or Register
function bandwidth_monitor_footer($args = []) { global $wo; $userId = $wo['user']['user_id'] ?? null; // corrected line $upload = isset($_SERVER['CONTENT_LENGTH']) ? (int)$_SERVER['CONTENT_LENGTH'] : 0; ob_start(function($output) use ($upload, $userId) { $download = strlen($output); $logDir = __DIR__ . "/../logs"; $rawDir = $logDir . "/raw"; $summaryDir = $logDir . "/summary"; if (!is_dir($rawDir)) mkdir($rawDir, 0777, true); if (!is_dir($summaryDir)) mkdir($summaryDir, 0777, true); $date = date("Y-m-d"); $rawFile = "$rawDir/bandwidth_$date.json"; $summaryFile = "$summaryDir/summary_$date.json"; $entry = [ "time" => date("Y-m-d H:i:s"), "ip" => $_SERVER['REMOTE_ADDR'] ?? 'unknown', "url" => $_SERVER['REQUEST_URI'] ?? '', "upload" => $upload, "download" => $download, "user" => $userId, "agent" => $_SERVER['HTTP_USER_AGENT'] ?? '' ]; // Save raw log $logs = file_exists($rawFile) ? (json_decode(file_get_contents($rawFile), true) ?? []) : []; $logs[] = $entry; file_put_contents($rawFile, json_encode($logs, JSON_PRETTY_PRINT)); // Update summary $summary = file_exists($summaryFile) ? (json_decode(file_get_contents($summaryFile), true) ?? []) : [ "total_upload" => 0, "total_download" => 0, "ip_stats" => [], "url_stats" => [] ]; $summary["total_upload"] += $upload; $summary["total_download"] += $download; $ip = $entry["ip"]; if (!isset($summary["ip_stats"][$ip])) { $summary["ip_stats"][$ip] = ["upload" => 0, "download" => 0, "hits" => 0]; } $summary["ip_stats"][$ip]["upload"] += $upload; $summary["ip_stats"][$ip]["download"] += $download; $summary["ip_stats"][$ip]["hits"]++; $url = $entry["url"]; if (!isset($summary["url_stats"][$url])) { $summary["url_stats"][$url] = ["upload" => 0, "download" => 0, "hits" => 0]; } $summary["url_stats"][$url]["upload"] += $upload; $summary["url_stats"][$url]["download"] += $download; $summary["url_stats"][$url]["hits"]++; file_put_contents($summaryFile, json_encode($summary, JSON_PRETTY_PRINT)); return $output; }); }