Difference between revisions of "WikiTest"

From Oceania Classic: An Australian Ultima Online Free Shard
Jump to navigation Jump to search
(Created page with "<html> <?php /* shard_status.php v1.0 This is an example of how to get the status of a UO emulator (RunUO, ServUO, Sphere, etc.) by sending a packet to the shard address:port...")
 
(Blanked the page)
Tag: Blanking
 
Line 1: Line 1:
<html>
 
<?php
 
/*
 
shard_status.php
 
v1.0
 
  
This is an example of how to get the status of a UO emulator (RunUO, ServUO, Sphere, etc.)
 
by sending a packet to the shard address:port.
 
 
\x7f\x00\x00\x01\xf1\x00\x04\xff
 
 
Newer ServUO Shards will return something like this:
 
Array ( [0] => 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 ="login.oceaniaclassic.com";
 
$shard_port ="1999";
 
 
$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 <<<EOF
 
<style type="text/css">
 
table tr th,
 
table tr td {
 
    border-right: none;
 
    border-bottom: none;
 
    cell-padding-left: 2px;
 
min-width: 100px;
 
}
 
th {
 
text-align:right;
 
}
 
</style>
 
 
<table>
 
<tr>
 
<th>Status:</th>
 
<td>Online</td>
 
</tr>
 
<tr>
 
<th>Emu:</th>
 
<td>$emu</td>
 
</tr>
 
<tr>
 
<th>Name:</th>
 
<td>$name</td>
 
</tr>
 
<tr>
 
<th>Uptime:</th>
 
<td>$age hours</td>
 
</tr>
 
<tr>
 
<th>Players Online:</th>
 
<td>$clients</td>
 
</tr>
 
<tr>
 
<th>Total Items:</th>
 
<td>$items</td>
 
</tr>
 
<tr>
 
<th>Mobs:</th>
 
<td>$mobs</td>
 
</tr>
 
<tr>
 
<th>Memory Used:</th>
 
<td>$mem</td>
 
</tr>
 
<tr>
 
<th>Version:</th>
 
<td>$ver</td>
 
</tr>
 
</table>
 
 
EOF;
 
 
 
 
    }
 
 
}
 
 
 
 
?>
 

Latest revision as of 23:41, 12 October 2020