diff --git a/modules/dashboard/dashboard.php b/modules/dashboard/dashboard.php index a40875d2..df8b3c1d 100644 --- a/modules/dashboard/dashboard.php +++ b/modules/dashboard/dashboard.php @@ -202,6 +202,21 @@ function exec_ogp_module() foreach($colhtml as $html ) echo $html.''; } + + // Server Status Link - Available to all users + echo "
+
+

Server Status

+
+

View the status of all game servers

+ + 🖥️ View Server Status + +
Opens in a new window +
+
+
"; + if( $isAdmin AND $db->isModuleInstalled('status') ) { echo "".get_lang('server_status')."
"; diff --git a/server_status.php b/server_status.php new file mode 100644 index 00000000..5110a5f0 --- /dev/null +++ b/server_status.php @@ -0,0 +1,291 @@ +getUserById($_SESSION['user_id']); + +// Get settings +$settings = $db->getSettings(); +@$GLOBALS['panel_language'] = $settings['panel_language']; +ogpLang(); + +function ping_host($host, $timeout = 5) { + if (function_exists('exec')) { + $output = array(); + $result = 0; + + // Use ping command based on OS + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + exec("ping -n 1 -w " . ($timeout * 1000) . " " . escapeshellarg($host), $output, $result); + } else { + exec("ping -c 1 -W " . $timeout . " " . escapeshellarg($host), $output, $result); + } + + if ($result === 0) { + // Extract ping time from output + foreach ($output as $line) { + if (preg_match('/time[<=]([0-9.]+)\s*ms/i', $line, $matches)) { + return floatval($matches[1]); + } + } + return 0; // Host is up but couldn't extract time + } + } + return false; // Host is down or ping unavailable +} + +function get_hostname($ip) { + $hostname = gethostbyaddr($ip); + return ($hostname && $hostname !== $ip) ? $hostname : false; +} + +// Get all remote servers +$servers = $db->getRemoteServers(); + +?> + + + + + + Server Status - OGP + + + +
+

🖥️ Server Status Dashboard

+ + + + +
+ No servers configured in the system. +
+ + + + + + + + + + + + + status_chk(); + $is_online = ($status === 1); + + // Get ping time + $ping_time = ping_host($server_ip, 3); + + // Determine ping color class + $ping_class = ''; + if ($ping_time !== false) { + if ($ping_time <= 50) { + $ping_class = 'ping-good'; + } elseif ($ping_time <= 150) { + $ping_class = 'ping-medium'; + } else { + $ping_class = 'ping-bad'; + } + } + ?> + + + + + + + + + +
Server NameLocation/IPHostnameStatusPing (ms)
+ +
() + +
N/A'; ?> + + 🟢 UP + + 🔴 DOWN + + + + + ms + + + N/A + +
+ + +
+ Last updated: +
+ +
+ ← Back to Dashboard +
+
+ + \ No newline at end of file