Hi guys, came here to post a useful tool, made with <3 from Renato Ribeiro, Gabriel Pedro and Ranieri Althoff
Checkout the project page: http://renatorib.github.io/otinfo/
Otinfo allows you gets information from the server using sockets.
Usage
1. The first, you should include the class
2. Next, you instantiate the variable
Here the second parameter is optional. He is set to 7171 by default, if the switch port is not 7171
3. Finally run the execute method and got all the information
Note that returns false if it does not connect to the server, then we will check
Cache
The class caches the information from the servers for a time of 120 seconds (default), if you want to change the time alter otinfo.php
All the example code
Download
You can download from my github repository, here: https://github.com/renatorib/otinfo
If you want to contribute, we accept pull requests
Checkout the project page: http://renatorib.github.io/otinfo/
Otinfo allows you gets information from the server using sockets.
Usage
1. The first, you should include the class
Code:
include('otinfo.php');
2. Next, you instantiate the variable
Code:
$server = new Otinfo('shadowcores.twifysoft.net');
Code:
$server = new Otinfo('shadowcores.twifysoft.net', 7172);
3. Finally run the execute method and got all the information
Note that returns false if it does not connect to the server, then we will check
Code:
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
}
Cache
The class caches the information from the servers for a time of 120 seconds (default), if you want to change the time alter otinfo.php
Code:
private static $cache = 180; //seconds you want
All the example code
PHP:
<?php
include('otinfo.php');
$server = new Otinfo('shadowcores.twifysoft.net');
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
}
Download
You can download from my github repository, here: https://github.com/renatorib/otinfo
If you want to contribute, we accept pull requests
Last edited: