Server Monitor Problem
#7

The problem is not with the code the problem is with your website host. As I have told earlier to you in some thread free hosts does not allow use of socket functions and those queries require use of socket functions.
There are two solution to this :
1) Either upgrade your website host to premium cuz most of premium host allows the use of socket function but not all premium host allows it so if you upgrade then be sure to inquire before upgrading.

2) Other solution is to fetch server data indirectly by api which is hosted on socket supported host, I uploaded a php file on my site which outputs the server info in JSON object form, here is how you can use it:
Quote:
http://brozeus.tk/api.php?srv=X.X.X.X&port=7777

Where X.X.X.X is the server ip and 7777 is the port.
Note that api is designed in such a way that if server is not online then it outputs "0".
Here is how you will use on your website.
PHP код:
<?php
//example
    
$url 'http://brozeus.tk/api.php?srv=X.X.X.X&port=7777';//replace ip and port here
    
$data file_get_contents($url);
    if(
$data == "0")//if server is offline
    
{
        echo 
"Server OFFLINE";
    }
    else
    {
        
$data json_decode($datatrue);//decoding data and converting to array
        
echo "Server ONLINE";
        echo 
"Host Name :".$data["hostname"];
        echo 
"Server gamemode : ".$data["gamemode"];
        echo 
"Map Name :".$data["mapname"]
        echo 
"Current Players : ".$data["players"];
        echo 
"Max Players : ".$data["maxplayers"];        
    }
?>
The keys name in array are case sensitive so make sure you use things as $data["players"], not $data["Players"]
All letters in array key will be in lowercase.
Reply


Messages In This Thread
Server Monitor Problem - by Michael B - 29.04.2015, 16:48
Re: Server Monitor Problem - by Jimmy0wns - 29.04.2015, 16:54
Re: Server Monitor Problem - by Michael B - 29.04.2015, 17:19
Re: Server Monitor Problem - by Jimmy0wns - 29.04.2015, 17:25
Re: Server Monitor Problem - by Abagail - 29.04.2015, 21:15
Re: Server Monitor Problem - by Michael B - 30.04.2015, 03:16
Re: Server Monitor Problem - by BroZeus - 30.04.2015, 04:58
Re: Server Monitor Problem - by Michael B - 30.04.2015, 08:31

Forum Jump:


Users browsing this thread: 1 Guest(s)