Code tester

ServUO [1] => Name=My Shard [2] => Age=3 [3] => Clients=1 [4] => Items=112187 [5] => Chars=2934 [6] => Mem=217514K [7] => Ver=2 )

RunUO and Sphere Shards don’t return version:
Array ( [0] => ServUO [1] => Name=My Shard [2] => Age=3 [3] => Clients=1 [4] => Items=112187 [5] => Chars=2934 [6] => Mem=217514K )

2016 – Ixtabay for www.RunUO.com
*/

$shard_addr =”Playaob.ddns.net”;
$shard_port =”2593″;

$fp = fsockopen($shard_addr, $shard_port);

if (!$fp) {
echo “Cannot connect to $shard_addr:$shard_port\n”;
} else {

fwrite($fp, “\x7f\x00\x00\x01\xf1\x00\x04\xff”);
stream_set_timeout($fp, 2);
$res = fread($fp, 2000);

$info = stream_get_meta_data($fp);
fclose($fp);

if ($info[‘timed_out’]) {
echo ‘Connection to to $shard_addr:$shard_port timed out!’;
} else {

$ver = ”;

$arr = explode(‘,’, $res);
// print_r($arr); // Uncomment if you want to see the raw array

$emu = $arr[0];
$name = ltrim(strstr($arr[1],’=’), ‘=’);
$age = ltrim(strstr($arr[2], ‘=’), ‘=’);
$clients = ltrim(strstr($arr[3], ‘=’), ‘=’);
$items = ltrim(strstr($arr[4], ‘=’), ‘=’);
$mobs = ltrim(strstr($arr[5], ‘=’), ‘=’);
$mem = ltrim(strstr($arr[6], ‘=’), ‘=’);

if ($emu <> “ServUO”) $ver = “Unknown”; // Only ServUO Shards return version
else $ver = ltrim(strstr($arr[07], ‘=’), ‘=’);

// Example usage
echo << table tr th, table tr td { border-right: none; border-bottom: none; cell-padding-left: 2px; min-width: 100px; } th { text-align:right; }

Status: Online
Emu: $emu
Name: $name
Uptime: $age hours
Players Online: $clients
Total Items: $items
Mobs: $mobs
Memory Used: $mem
Version: $ver

EOF;

}

}

?>