dev-master
9999999-dev http://github.com/renatorib/otinfoOpen Tibia Server Info Parser
MIT
The Requires
tibia opentibia otserv
Wallogit.com
2017 © Pedro Peláez
Open Tibia Server Info Parser
Catch information from servers' response by ip and port, (*1)
Just download this repo, and include otinfo.php
Important: Must have a writable cache folder in the same level of otinfo.php or will not work correctly, (*2)
include('otinfo.php');
To instantiate an otserv, create a new Otinfo object, (*3)
$server = new Otinfo\Otinfo('shadowcores.twifysoft.net');
The first parameter is the server $ip, and the second is the $port (defined 7171 as default), (*4)
Get informations, (*5)
if ($server->execute()) {
echo "Players online: " . $server->players['online'] . "<br />";
echo "Server location: " . $server->serverinfo['location'] . "<br />";
echo "Client version: " . $server->serverinfo['client'] . "<br />";
// these are just a few examples
} else {
echo "Server offline";
// if execute() returns false, the server are offline
}
The `execute()' method catch/parse the responses returned by server and return false if server are offline., (*6)
Each server has its own response, and may be different from the others. This means that not all respond with the same information, and a server may have information that others do not have., (*7)
Here are some possible answers nodes
* players
* serverinfo
* motd
* owner
* monsters
* map
* npcs
* maybe others, (*8)
This means if you want to test, can print_r, var_dump, and whatelse, the nodes to know returned responses, (*9)
print_r($server->players); print_r($server->serverinfo); //etc
Otinfo cache itself not only for performance, but also to avoid empty responses, caused due to the protection of tfs.
As said before, you must have a writable cache folder in the same level of otinfo.php or will not work correctly.
The time of cache as default 180 seconds (three minutes). May you edit in otinfo.php changing this line, (*10)
private static $cache = 180; //seconds you want
When the connection is bad, you can increase the timeout, (*11)
private static $timeout = 5; //seconds you want
Made with :heart: by Renato Ribeiro and Ranieri Althoff, (*12)
Contributors - my heartfelt thanks * gpedro * rmobis * yrpen * DSpeichert, (*13)
Open Tibia Server Info Parser
MIT
tibia opentibia otserv