Last active
August 29, 2015 14:04
-
-
Save belak/94821f129b077a755686 to your computer and use it in GitHub Desktop.
Ville Minecraft Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[submodule "mcstat"] | |
path = mcstat | |
url = https://github.com/winny-/mcstat.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf8" /> | |
<title>TheVille Server Information</title> | |
<link rel="stylesheet" type="text/css" href="serverlist.css" /> | |
<script src="serverlist.js"></script> | |
</head> | |
<body> | |
<body link=#ffffff vlink=#ffffff> | |
<table width=100%><tr><td align=center> | |
<table border=0 class='servers' width=100%> | |
<?php | |
require(__DIR__ . '/mcstat/mcstat.php'); | |
// Settings | |
// This array has 3 parts - the host, port and description | |
$servers = array( | |
array("66.240.202.11", 25565, "V - Minecraft") | |
); | |
foreach ($servers as $server) { | |
# Grab the stats | |
$query = new MinecraftStatus($server[0], $server[1]); | |
$stats = $query->ping(false); | |
# Generate the tooltip | |
$current_players = ""; | |
foreach ($stats['players'] as $player) { | |
$current_players .= '<tr><td class=players>' . rawurlencode($player) . '</td></tr>'; | |
} | |
echo <<<EOF | |
<tr> | |
<td valign=absmiddle class='servers' align=center width=36> | |
<img src='http://www.theville.org/lgsln/icons/minecraft.png'> | |
</td> | |
<td class='servers' align=left>TheVille.org {$server[2]}<br> | |
<span class=servername>{$server[0]}:{$server[1]}</span> | |
</td> | |
<td class='servers' align=right>{$stats['player_count']}/{$stats['player_max']}</td> | |
<td class='servers' align=left> | |
<a href='#' class="tip" onmouseover="tooltip('<span class=servertitle>Current Players</span><br><hr><table border=0 cellpadding=2 cellspacing=2 width=100%>$current_players</table>');"onmouseout="tipexit();"> | |
EOF; | |
// The first light has a different image, so we handle that first | |
$url = 'http://www.theville.org/lgsln/other/first_slot.gif'; | |
if ($stats['player_count'] > 0) { | |
$url = 'http://www.theville.org/lgsln/other/first_player.gif'; | |
} | |
echo "<img title='Dogs Lights' class='si_players' src='$url'>"; | |
// Loop through the number of players, updating the lights | |
for ($i = 1; $i < $stats['player_max']; $i++) { | |
$url = 'http://www.theville.org/lgsln/other/mid_slot.gif'; | |
if ($i < $stats['player_count']) { | |
$url = 'http://www.theville.org/lgsln/other/mid_player.gif'; | |
} | |
echo "<img src='$url'>"; | |
} | |
echo "</a></td></tr>"; | |
} | |
?> | |
</table> | |
</td></tr></table> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#tooltip { | |
padding: 3px; | |
background: #f9f9f9; | |
border: 2px solid #000000; | |
text-align: center; | |
font-size: 10px; | |
font-family: sans-serif; | |
width:300px; | |
color: #cccccc; | |
z-index:6005; | |
} | |
span.tip { | |
border-bottom: 1px solid #eee; | |
color: #000000; | |
z-index:6005; | |
} | |
players { | |
text-align:left; | |
} | |
/* | |
body { | |
background-color:#321852; | |
font-size:9px; | |
font-family:verdana,tahoma,arial,sans-serif; | |
word-wrap:break-word; | |
color:#000000; | |
text-decoration:none; | |
} | |
*/ | |
.servers { | |
color:#ffffff; | |
font-family:sans-serif; | |
font-size:9px; | |
text-decoration:none; | |
font-family:sans-serif; | |
} | |
table.servers { | |
background: #321852; | |
border-width: 1px 1px 1px 1px; | |
border-spacing: 2px; | |
border-style: none none none none; | |
border-collapse: collapse; | |
color: #ffff00; | |
} | |
td.servers { | |
border-width: 1px 1px 1px 1px; | |
padding: 5px 5px 5px 5px; | |
border-style: inset inset inset inset; | |
border-color: gray gray gray gray; | |
-moz-border-radius: 0px 0px 0px 0px; | |
} | |
td.players { | |
text-align:left; | |
color:#000000; | |
} | |
img { | |
border:0 solid; | |
} | |
a { | |
color:#ffffff; | |
text-decoration:none; | |
} | |
.servertitle { | |
color:#000000; | |
font-weight:bold; | |
font-size:14px; | |
} | |
.servername { | |
color:#ffff00; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// position of the tooltip relative to the mouse in pixel // | |
var offsetx = -200; | |
var offsety = 8; | |
function newelement(newid) { | |
if(document.createElement) { | |
var el = document.createElement('div'); | |
el.id = newid; | |
with(el.style) { | |
display = 'none'; | |
position = 'absolute'; | |
} | |
el.innerHTML = ' '; | |
document.body.appendChild(el); | |
} | |
} | |
var ie5 = (document.getElementById && document.all); | |
var ns6 = (document.getElementById && !document.all); | |
var ua = navigator.userAgent.toLowerCase(); | |
var isapple = (ua.indexOf('applewebkit') != -1 ? 1 : 0); | |
function getmouseposition(e) { | |
if(document.getElementById) { | |
var iebody=(document.compatMode && | |
document.compatMode != 'BackCompat') ? | |
document.documentElement : document.body; | |
pagex = (isapple == 1 ? 0:(ie5)?iebody.scrollLeft:window.pageXOffset); | |
pagey = (isapple == 1 ? 0:(ie5)?iebody.scrollTop:window.pageYOffset); | |
mousex = (ie5)?event.x:(ns6)?clientX = e.clientX:false; | |
mousey = (ie5)?event.y:(ns6)?clientY = e.clientY:false; | |
var lixlpixel_tooltip = document.getElementById('tooltip'); | |
lixlpixel_tooltip.style.left = (mousex+pagex+offsetx) + 'px'; | |
lixlpixel_tooltip.style.top = (mousey+pagey+offsety) + 'px'; | |
} | |
} | |
function tooltip(tiptext) { | |
if(!document.getElementById('tooltip')) newelement('tooltip'); | |
var lixlpixel_tooltip = document.getElementById('tooltip'); | |
lixlpixel_tooltip.innerHTML = tiptext; | |
lixlpixel_tooltip.style.display = 'block'; | |
document.onmousemove = getmouseposition; | |
} | |
function tipexit() { | |
document.getElementById('tooltip').style.display = 'none'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment