Advertisement
HeavyNight

test

May 23rd, 2024
629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.50 KB | None | 0 0
  1. <?php
  2. // URL del archivo INI remoto
  3. $iniUrl = 'https://heavynightlauncher.com/Launcher-Categorias/Categoria2/Category-Config.ini';
  4.  
  5. // Función para descargar y leer el archivo INI
  6. function getServerConfig($url) {
  7.     $iniContent = @file_get_contents($url);
  8.     if ($iniContent === false) {
  9.         return false;
  10.     }
  11.  
  12.     $config = parse_ini_string($iniContent, true);
  13.     if ($config === false) {
  14.         return false;
  15.     }
  16.  
  17.     return $config;
  18. }
  19.  
  20. // Obtener la configuración del servidor
  21. $config = getServerConfig($iniUrl);
  22. if ($config === false) {
  23.     die("No se pudo obtener la configuración del servidor.");
  24. }
  25.  
  26. // Extraer la IP y el puerto del archivo INI
  27. $serverHost = $config['General']['ip'];
  28. $serverPort = isset($config['General']['puerto']) ? $config['General']['puerto'] : null;
  29.  
  30. // Construir la URL para consultar la API
  31. if ($serverPort) {
  32.     $apiUrl = "https://api.mcsrvstat.us/2/{$serverHost}:{$serverPort}";
  33. } else {
  34.     $apiUrl = "https://api.mcsrvstat.us/2/{$serverHost}";
  35. }
  36.  
  37. // Obtener los datos del servidor desde la API
  38. $serverData = @file_get_contents($apiUrl);
  39. if ($serverData === false) {
  40.     die("No se pudo obtener la información del servidor.");
  41. }
  42.  
  43. $serverData = json_decode($serverData, true);
  44. if ($serverData === null) {
  45.     die("Error al decodificar la respuesta de la API.");
  46. }
  47.  
  48. // Verificar si el servidor está en línea
  49. if (isset($serverData['online']) && $serverData['online'] === true) {
  50.     echo "En linea";
  51. } else {
  52.     echo "Apagado";
  53. }
  54. ?>
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement