$p[0], 'time' => $p[1], 'profile' => $p[2], 'duration' => (int)$p[3], 'status' => trim($p[4]), 'bytes' => isset($p[5]) ? (int)$p[5] : 0, ]; } } echo json_encode([ 'enabled' => $base['enabled'], 'windows' => $base['windows'], 'active' => $base['active'], 'last_sync' => $base['last_sync'], 'bw_history' => $history, 'bw_warn_gb' => $warnGb, 'settings' => [ 'bw_limit' => (int)($vars['BW_LIMIT'] ?? 0), 'retry_count' => (int)($vars['RETRY_COUNT'] ?? 3), 'sleep' => (int)($vars['SLEEP'] ?? 300), 'bw_warn_gb' => (float)($vars['BANDWIDTH_WARN_GB'] ?? 50), ], 'ts' => time(), ]);