PHP Script

Discussion in 'Bukkit Help' started by BeeT, Jan 7, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    BeeT

    Hello, where I can find script like this:

    Server ip:
    Server status:
    Server slots:
    In server online players:

    Maybe I can get it without plugins? Only php script or smth like this?
     
  2. Offline

    Volume

    Yes, but about the last point is hardly. I know that this can be done via the plugin

    P.S Sorry, i use google translit
     
  3. Offline

    XtenD

    NightQuery, Minequery. Search for it.
     
  4. Offline

    Volume

    pff, plugins, not interesting...
     
  5. Offline

    Pezmantbh

    Are you going to add anything useful to the conversation? :)


    To the person that started the thread, there are several plugins (such as those mentioned by XtenD) that will help you achieve this. Do you know PHP?
     
  6. Offline

    BeeT

    Yeah, but now i need to install plugin, install mysql... I will try to make it with rcon, but idk, maybe there are already made.
     
  7. Offline

    Bertware

    I have a PHP script that get Server name, IP, Port, online players/slots

    PHP:
    <?php

    error_reporting
    (0); //prevent error when server can not be reached

    $host $_GET['ip']; //server.php?ip=IP-OR-HOST
    if ($host=="") {
    $host $_SERVER['REMOTE_ADDR'];
    }
    $port 25565;

    if (
    substr_count($host ".") != 4) { //If not an IP, resolve host
    $host gethostbyname($host);
    }

    //connect to server

    echo "checking $host on port $port...<br>";
    $socket socket_create(AF_INETSOCK_STREAMSOL_TCP);
    $timeout = array(sec=>3,usec=>0);
    socket_set_option($socketSOL_SOCKETSO_RCVTIMEO$timeout);
    socket_set_option($socketSOL_SOCKETSO_SNDTIMEO$timeout);

     
    $connected socket_connect($socket$host$port);

     if (!
    $connected) { //If not connected: die
     
    die("Server offline");
     }

    if (
    $connected) {
        
    $ping_start microtime(true);
        
    socket_send($socket"\xFE"10);
        
    $data "";
        
    $result socket_recv($socket$data1500);$ping_end microtime(true);
        
    socket_close($socket);

        if (
    $result != false && substr($data01) == "\xFF") { //get values
            
    $info explode("\xA7"mb_convert_encoding(substr($data,1), "iso-8859-1""utf-16be"));
            
    $serverName substr($info[0], 1);
            
    $playersOnline $info[1];
            
    $playersMax $info[2];
            
    $ping round(($ping_end $ping_start) * 1000);
    //echo values
            
    echo   "Server: $serverName<br/>
                    Address: 
    $host<br/>
                    Port: 
    $port<br/>
                    Players Online: 
    $playersOnline/$playersMax <br/>
                    Ping: 
    $ping ms<br/>";
        } else {
            echo 
    "Failed to receive data";
        }
    } else {
        echo 
    "Failed to connect";
    }
    ?>
    Ping isn't really useful, as it changes all the time
     
Thread Status:
Not open for further replies.

Share This Page