2012-09-21 03:34:38 +00:00
|
|
|
<title>UnPS MC Checker</title>
|
2012-09-29 08:18:44 +00:00
|
|
|
<script language="javascript" type="text/javascript">
|
|
|
|
function showHide(shID) {
|
|
|
|
if (document.getElementById(shID)) {
|
|
|
|
if (document.getElementById(shID+'-show').style.display != 'none') {
|
|
|
|
document.getElementById(shID+'-show').style.display = 'none';
|
|
|
|
document.getElementById(shID).style.display = 'block';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
document.getElementById(shID+'-show').style.display = 'inline';
|
|
|
|
document.getElementById(shID).style.display = 'none';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style type="text/css">
|
|
|
|
.api {
|
|
|
|
display: none;
|
|
|
|
border-top: 1px solid #666;
|
|
|
|
border-bottom: 1px solid #666; }
|
|
|
|
a.showApi, a.hideApi {
|
|
|
|
text-decoration: none;
|
|
|
|
color: #36f;
|
|
|
|
padding-left: 8px; }
|
|
|
|
a.showApi:hover, a.hideApi:hover {
|
|
|
|
border-bottom: 1px dotted #36f; }
|
|
|
|
</style>
|
2012-09-21 03:34:38 +00:00
|
|
|
<body background="https://si0.twimg.com/profile_background_images/468495900/bg.gif" text="white">
|
|
|
|
<div align="center">
|
|
|
|
<img src="http://unps-gama.tk/upload/Pictures/header.png"><br>
|
2012-09-29 08:18:44 +00:00
|
|
|
<a href="#" id="api-show" class="showApi" onclick="showHide('api');return false;">API Here</a>
|
|
|
|
<div id="api" class="api">
|
2012-09-21 03:34:38 +00:00
|
|
|
<table align="center">
|
|
|
|
<tr><td>If you want to parse this information for yourself, just give the script an $ip and $port (default assumed)</td></tr>
|
|
|
|
<tr><td>then pull an arraylist for $srvinfo from 0-2 to get motd, players online, and max players. </td></tr>
|
2012-09-21 03:44:58 +00:00
|
|
|
<tr><td>Server and port are just echoed $ip and $port. To check online status, use testserver.php. </td></tr>
|
2012-09-21 03:34:38 +00:00
|
|
|
<tr><td>Call testserver.php and use the GetServerStatus($ip, $port); function - echo that and done :3</td></tr>
|
2012-09-29 09:18:58 +00:00
|
|
|
<tr><td>Example call: http://unps-gama.tk/mcping.php?ip=unps-gama.tk&port=25565</td></tr>
|
|
|
|
<tr><td>Example:<code><pre>
|
2012-09-21 03:34:38 +00:00
|
|
|
include('http://unps-gama.tk/mcping.php?ip=$ip&port=$port')
|
2012-09-29 08:18:44 +00:00
|
|
|
echo "Server:<font color='red'> " . $ip . "</font> on port:<font color='yellow'> " . $port . " </font> is: ";
|
2012-09-21 03:34:38 +00:00
|
|
|
include('http://unps-gama.tk/testserver.php');
|
|
|
|
$status = GetServerStatus($ip, $port);
|
2012-09-29 08:18:44 +00:00
|
|
|
if ($status=="ONLINE") echo "<font color='green'>" . $status . "</font>\n";
|
|
|
|
if ($status=="OFFLINE") echo "<font color='red'>" . $status . "</font>\n";
|
2012-09-21 03:34:38 +00:00
|
|
|
echo "motd: " . $srvinfo[0] . "\n";
|
|
|
|
echo "players online: " . $srvinfo[1] . "\n";
|
2012-09-29 08:18:44 +00:00
|
|
|
echo "max players: " . $srvinfo[2] . "\n";</pre></code></td></tr>
|
|
|
|
</table>
|
|
|
|
<a href="#" id="api-hide" class="hideApi" onclick="showHide('api');return false;">Close API</a>
|
|
|
|
</div><br><table align="center">
|
2012-09-21 03:34:38 +00:00
|
|
|
<?php
|
|
|
|
$ip = $_GET["ip"];
|
|
|
|
$port = $_GET["port"];
|
|
|
|
if ($port==null){$port = 25565;}
|
|
|
|
$fp = fsockopen($ip, $port, $errno, $errstr, 5); // Socket for connecting to server
|
|
|
|
|
|
|
|
if (!$fp) {
|
|
|
|
echo "<font color='red'>Error</font>";
|
|
|
|
} else {
|
|
|
|
$out = "\xFE"; // Hex needed for server info
|
|
|
|
|
|
|
|
fwrite($fp, $out);
|
|
|
|
while (!feof($fp)) {
|
|
|
|
$result .= fgets($fp, 128);
|
|
|
|
}
|
|
|
|
fclose($fp);
|
|
|
|
|
|
|
|
// Remove extra spaces between characters
|
|
|
|
$result = str_replace("\x00", "", $result);
|
|
|
|
$result = str_replace("\x1A", "", $result);
|
|
|
|
$result = str_replace("\xFF", "", $result);
|
|
|
|
|
|
|
|
$srvinfo = explode("\xA7",$result);
|
|
|
|
|
|
|
|
echo "<tr><td>\n";
|
|
|
|
echo "Server:<font color='red'> " . $ip . "</font> on port:<font color='yellow'> " . $port . " </font> is: ";
|
|
|
|
include('testserver.php');
|
|
|
|
$status = GetServerStatus($ip, $port);
|
|
|
|
if ($status=="ONLINE") echo "<font color='green'>" . $status . "</font></td></tr>\n";
|
|
|
|
if ($status=="OFFLINE") echo "<font color='red'>" . $status . "</font></td></tr>\n";
|
|
|
|
//echo $status . "<br>";
|
|
|
|
echo "<tr><td>motd: " . $srvinfo[0] . "</td></tr>\n";
|
|
|
|
echo "<tr><td>players online: " . $srvinfo[1] . "</td></tr>\n";
|
|
|
|
echo "<tr><td>max players: " . $srvinfo[2] . "</td></tr>\n";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</table>
|
|
|
|
</div>
|