= 1048576) return round($total_size / 1048576, 2) . ' MB'; if ($total_size >= 1024) return round($total_size / 1024, 1) . ' KB'; return $total_size . ' B'; } // 2. ENDPOINT LIVE DATA (Brak odświeżania strony - JS odpytuje ten fragment w tle co 5 sekund) if (isset($_GET['action']) && $_GET['action'] === 'get_live_data') { header('Content-Type: application/json'); $live_pages = []; $files = glob($data_dir . '/*.txt'); if ($files) { foreach ($files as $file) { $content = file_get_contents($file); $parts = explode("\n---BODY_START---\n", $content); $meta = json_decode($parts[0], true); if ($meta) { $meta['file_id'] = basename($file); // Konwersja daty na UNIX timestamp dla obliczeń live w JS $meta['timestamp'] = ($meta['last_check'] !== 'Nigdy') ? strtotime($meta['last_check']) : 0; $live_pages[] = $meta; } } } echo json_encode([ 'disk_size' => get_disk_size_formatted($data_dir), 'server_time' => time(), 'pages' => $live_pages ]); exit; } // 3. WERYFIKACJA LOGOWANIA DLA AKCJI MODYFIKUJĄCYCH if (isset($_POST['add_url']) || isset($_GET['delete'])) { $valid_user = 'admin'; $valid_pass = 'Dupa0000!'; if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_USER'] !== $valid_user || $_SERVER['PHP_AUTH_PW'] !== $valid_pass) { header('WWW-Authenticate: Basic realm="Zaloguj sie do pulpitu dowodzenia"'); header('HTTP/1.0 401 Unauthorized'); exit("Autoryzacja wymagana."); } } // --- TUTAJ ZACZYNA SIĘ TWÓJ TESTOWY LOGER IP --- $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://ifconfig.me/ip"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 5); $moje_wykryte_ip = trim(curl_exec($ch)); curl_close($ch); if (!empty($moje_wykryte_ip)) { $data_godzina = date("Y-m-d H:i:s"); $host = gethostbyaddr($moje_wykryte_ip); $log_line = "[" . $data_godzina . "] IP: " . $moje_wykryte_ip . " | HOST: " . $host . PHP_EOL; file_put_contents(__DIR__ . '/log_ip.txt', $log_line, FILE_APPEND); } if (!is_dir($data_dir)) { mkdir($data_dir, 0755, true); } // Dane wizytatora (Ciebie na stronie) $visitor_ip = $_SERVER['REMOTE_ADDR']; $visitor_host = gethostbyaddr($visitor_ip); function url_to_filename($url) { return md5($url) . '.txt'; } // Dodawanie strony if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_url'])) { $url = filter_var($_POST['url'], FILTER_VALIDATE_URL); if ($url) { $filename = $data_dir . '/' . url_to_filename($url); if (!file_exists($filename)) { $initial_data = json_encode([ 'url' => $url, 'last_check' => 'Nigdy', 'status' => 'Oczekuje...', 'speed' => 0, 'avg_24h' => 0, 'avg_7d' => 0, 'trend' => '▬', 'history' => [] ]) . "\n---BODY_START---\n"; file_put_contents($filename, $initial_data); } } header("Location: " . $_SERVER['PHP_SELF']); exit; } // Usuwanie strony if (isset($_GET['delete'])) { $file_to_delete = $data_dir . '/' . basename($_GET['delete']); if (file_exists($file_to_delete)) { unlink($file_to_delete); } header("Location: " . $_SERVER['PHP_SELF']); exit; } // Funkcja sprawdzająca status (wywoływana przez Cron / Ręcznie) function check_and_update_page($file_path) { if (!file_exists($file_path)) return null; $content = file_get_contents($file_path); $parts = explode("\n---BODY_START---\n", $content); $meta = json_decode($parts[0], true); $url = $meta['url']; $old_speed = isset($meta['speed']) ? (int)$meta['speed'] : 0; $history = isset($meta['history']) ? $meta['history'] : []; if (!function_exists('curl_init')) { return [ 'url' => $url, 'last_check' => date('Y-m-d H:i:s'), 'status' => 'Brak cURL', 'speed' => 0, 'avg_24h' => 0, 'avg_7d' => 0, 'trend' => '▬', 'history' => $history ]; } $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) MonitorBot'); $start_time = microtime(true); $response_body = curl_exec($ch); $end_time = microtime(true); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); $speed = round(($end_time - $start_time) * 1000); $status = ($http_code === 200) ? 'Online' : 'Error (' . $http_code . ')'; if ($response_body === false) { $status = 'Offline'; $speed = 0; $response_body = 'Failed to fetch content.'; } $now = time(); if ($status === 'Online' && $speed > 0) { $history[] = ['timestamp' => $now, 'speed' => $speed]; } $limit_24h = $now - 86400; $limit_7d = $now - 604800; $cleaned_history = []; $sum_24h = $count_24h = $sum_7d = $count_7d = 0; foreach ($history as $entry) { $entry_time = (int)$entry['timestamp']; $entry_speed = (int)$entry['speed']; if ($entry_time >= $limit_7d) { $cleaned_history[] = $entry; $sum_7d += $entry_speed; $count_7d++; if ($entry_time >= $limit_24h) { $sum_24h += $entry_speed; $count_24h++; } } } $avg_24h = ($count_24h > 0) ? round($sum_24h / $count_24h) : 0; $avg_7d = ($count_7d > 0) ? round($sum_7d / $count_7d) : 0; if ($status === 'Online' && $speed > 0) { $trend = ($old_speed === 0) ? '▬' : (($speed < $old_speed) ? '▲' : (($speed > $old_speed) ? '▼' : '▬')); } else { $trend = '▬'; } $new_meta = [ 'url' => $url, 'last_check' => date('Y-m-d H:i:s'), 'status' => $status, 'speed' => $speed, 'avg_24h' => $avg_24h, 'avg_7d' => $avg_7d, 'trend' => $trend, 'history' => $cleaned_history ]; file_put_contents($file_path, json_encode($new_meta) . "\n---BODY_START---\n" . $response_body); return $new_meta; } // Obsługa wywołania automatycznego sprawdzania (Cron / Akcja) if ( (isset($_GET['action']) && $_GET['action'] === 'cron_check') || (php_sapi_name() === 'cli') ) { $files = glob($data_dir . '/*.txt'); if ($files) { foreach ($files as $file) { check_and_update_page($file); } } if (php_sapi_name() === 'cli' || isset($_GET['silent'])) { exit("Ok\n"); } header("Location: " . $_SERVER['PHP_SELF']); exit; } // Wstępne załadowanie bazy do pierwszego wyrenderowania HTML $pages = []; $files = glob($data_dir . '/*.txt'); if ($files) { foreach ($files as $file) { $content = file_get_contents($file); $parts = explode("\n---BODY_START---\n", $content); $meta = json_decode($parts[0], true); if ($meta) { $meta['file_id'] = basename($file); $meta['timestamp'] = ($meta['last_check'] !== 'Nigdy') ? strtotime($meta['last_check']) : 0; $pages[] = $meta; } } } ?> HUD MAINFRAME // LIVE MONITOR v3

SYSTEM METRYCZNY // LIVE OPERATOR

AUTOMATYCZNY PODGLĄD DANYCH W CZASIE RZECZYWISTYM (BEZ ODŚWIEŻANIA)

👤 CLIENT_IP:
🌐 HOSTNAME:
🖴 STORAGE: ???..
⏱️ OSTATNI_SKAN: 0s temu
🕒 ZEGAREK_PL: --:--:--
500) { $row_color = 'orange'; $blink_class = 'row-medium'; } else { $row_color = 'red'; $blink_class = 'row-dead'; } ?>
ADRES_NODE STATUS POMIAR_BIEŻĄCY ŚREDNIA_24H ŚREDNIA_7D TREND ZNAK_CZASU_SCANU (LIVE) AKCJE
BRAK URUCHOMIONYCH WĘZŁÓW W BAZIE SYSTEMU.
"