If you want to get gameserver status and have psychostats setup here is code for you. Just change the first line to your URL.
This probably only works with the default psychostats theme as it is definitely page scraping.
If you want the map images, get them from http://www.joomla-clantools.com/index.php?option=com_docman&task=cat_view&gid=25&Itemid=8 and extract them to a maps folder under your root install.
Example at http://ztkclan.com
$timeout = 3;
$host = "stats.ztkclan.com";
$sock = fsockopen($host, 80, $errno, $errstr, $timeout);
if(!$sock){
echo "Unable to get server status";
}else{
$out = "GET /server.php HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($sock, $out);
stream_set_blocking($fp, FALSE );
stream_set_timeout($sock, $timeout);
$info = stream_get_meta_data($sock);
while (!feof($sock) && !$info['timed_out']) {
$file .= fgets($sock, 4096);
$info = stream_get_meta_data($sock);
}
fclose($sock);
if(!$info['timed_out']){
$file = substr($file, strpos($file, "Live Server View")+18);
$name = substr($file, 0, strpos($file, "</font>"));
$file = substr($file, strpos($file, "IP</td>"));
$ip = substr($file, strpos($file, "\">")+2, strpos($file, "</td>\n\t\t</tr>")-(strpos($file, "\">")+2)-1);
$file = substr($file, strpos($file, "Map</td>"));
$map = substr($file, strpos($file, "\">")+2, strpos($file, "</td>\n\t\t</tr>")-(strpos($file, "\">")+2));
if(file_exists("maps/" . $map . ".jpg")){
$mapImage = "maps/$map.jpg";
}
$file = substr($file, strpos($file, "Time</td>"));
$time = substr($file, strpos($file, "\">")+2, strpos($file, "</td>\n\t\t</tr>")-(strpos($file, "\">")+2));
$file = substr($file, strpos($file, "Game</td>"));
$game = substr($file, strpos($file, "\">")+2, strpos($file, "</td>\n\t\t</tr>")-(strpos($file, "\">")+2));
$file = substr($file, strpos($file, "Server</td>"));
$server= substr($file, strpos($file, "\">")+2, strpos($file, "</td>\n\t\t</tr>")-(strpos($file, "\">")+2));
$file = substr($file, strpos($file, "Players</td>"));
$players = substr($file, strpos($file, "\">")+2, strpos($file, "</td>\n\t\t</tr>")-(strpos($file, "\">")+2));
$file = substr($file, strpos($file, "Public</td>"));
$public = substr($file, strpos($file, "\">")+2, strpos($file, "</td>\n\t\t</tr>")-(strpos($file, "\">")+2));
$file = substr($file, strpos($file, "Ping</td>"));
$ping = substr($file, strpos($file, "\">")+2, strpos($file, "</td>\n\t\t</tr>")-(strpos($file, "\">")+2));
unset($file);
echo "Players: $players <br />
IP: $ip <br />
Map: $map <br />";
if(isset($mapImage)){
echo "<img src='$mapImage' alt='$map'><br />";
}
}else{
echo "Unable to connect to server";
}
}
I changed the code a bit to support timeouts. This should prevent your page from timing out when you try and pull stats from a slow host.
I updated the code once again. It now actually times out when it should instead of not like it did before.