2

I am trying to make script, I want to show the info from the gameserver ip inserted from the URL.

In current config I have:

<?php
define( 'SQ_TIMEOUT',     1 );
define( 'SQ_ENGINE',      SourceQuery :: SOURCE );  
define( 'SQ_SERVER_ADDR', '123.45.67.890' ); 
define( 'SQ_SERVER_PORT', 12345); 
?>

and i tried like this:

<?php

define( 'SQ_TIMEOUT',     1 );
define( 'SQ_ENGINE',      SourceQuery :: SOURCE );  

    if (isset($_GET['ip'])){
        $ip = $_GET['ip'];
    }
    if (isset($_GET['port'])){
        $port = $_GET['port'];
    }

define( 'SQ_SERVER_ADDR', $ip ); 
define( 'SQ_SERVER_PORT', $port );     
?>

to be like

http://localhost/".$ip.":".$port.

instead of a fixed ip. inserted on "define"

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47

1 Answers1

0

You can't have you url as localhost/$ip:$port

You will need it as localhost/addr=$IP:$PORT because you are using $_GET

Modify your code with this code below:

<?php

define( 'SQ_TIMEOUT',     1 );
define( 'SQ_ENGINE',      SourceQuery :: SOURCE );  

    if (isset($_GET['addr'])){
        $addr = $_GET['addr'];
        $addrarray = explode(':', $myString);
        $ip = $addrarray[0];
        $port = $addrarray[1];
    }

define( 'SQ_SERVER_ADDR', $ip ); 
define( 'SQ_SERVER_PORT', $port ); 

?>

Now have your address as this:

I am using an example ip: 192.168.0.0 and an example port: 1234

localhost/addr=192.168.0.0:1234

Hope it helps :)

David
  • 923
  • 1
  • 9
  • 11
  • so it will be like: Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE ); $players_online = $Query->GetInfo()['Players']; – MrNapz Braz Jul 28 '15 at 12:32