Here's the script for the one currently used on J2O. If you want to display the MOTD from the list server, uncomment the relevant portions, but this may be impractical as the MOTD is sometimes quite big. You'll also need to make a script to create a .j2i file (or link to the one on J2O) if you want to be able to join games from this. And finally you'll need to get the images (or create your own) and change the script to output the correct locations. They are in http://www.jazz2online.com/J2Ov2/panels/gip_stuff/.
If you link to the script with textColor, linkColor, and hoverColor in the query string (without a '#' preceding), they will be used instead of the default colours.
The preg_match function should all be on one line, with a single space between (.*?) and the final (.*).
If you want to completely customize the script, you can just take the portion up to (but not including) where it says "echo <<<END". At this point, all the server information is in the array $valid_servers, and you can loop through and display it how you want.
PHP Code:
<?php
/* Mini Games in Progress Script for Jazz Jackrabbit 2
Copyright (c) 2004 Jazz2Online (http://www.jazz2online.com)
You are free to use and modify this script, but you must
keep the above copyright notice in place.
*/
$servers[0] = 'uk.jazzjackrabbit.net';
//$servers[1] = 'us.jazzjackrabbit.net';
if (!$textColor) $textColor = "000000";
if (!$linkColor) $linkColor = "000000";
if (!$hoverColor) $hoverColor = "B62700";
$num = 0;
WHILE ($servers[$num]) {
$sLink = @fsockopen($servers[$num], 10057, &$errorNum, &$errorString, 3);
if (!$sLink) {
$svrDown[$num] = $errorNum . ': ' . $errorString;
$svrError = TRUE;
} else {
$sRawData = "";
WHILE (!feof($sLink)) {
$sRawData .= fgets($sLink,1024);
}
fclose($sLink);
$svrError = FALSE;
// Get MOTD
/*$mLink = @fsockopen($servers[$num], 10058);
if ($mLink) {
while (!feof($mLink)) $motd .= fgets($mLink,256);
$servername = $servers[$num];
}*/
break;
}
$num++;
}
$sData = explode("\n",$sRawData);
FOR ($num = 0; $num < count($sData) - 1; $num++) {
// $server 1 2 3 4 5 6 7 8 9
preg_match('/(.*):(\d*) (local|mirror) (private|public) (.*) (1\..{0,4}) (\d*) (.*?) (.*)/',$sData[$num],$server);
$valid_servers[$num]['ip'] = $server[1];
$valid_servers[$num]['port'] = $server[2];
$valid_servers[$num]['list'] = $server[3];
$valid_servers[$num]['access'] = $server[4];
$valid_servers[$num]['type'] = $server[5];
$valid_servers[$num]['version'] = $server[6];
$valid_servers[$num]['uptime'] = $server[7];
$valid_servers[$num]['capacity'] = $server[8];
$valid_servers[$num]['name'] = str_replace('|','',trim($server[9]));
}
echo <<<END
<html>
<head>
<title>Games in Progress</title>
<style type="text/css">
ul { margin: 0; padding: 0; }
li { list-style-type: none; padding-left: 0; line-height: 1; }
span { font-family: Arial; }
.s { font-size: 11px; font-weight: bold; }
.i { font-size: 9px; color: #$textColor; }
.m { font-size: 10px; font-style: italic; }
body { margin: 4px; }
a { text-decoration: none; color: #$linkColor; }
a:hover { color: #$hoverColor; }
img { border: 0; }
</style>
</head>
<body>
<ul>
END;
if ($svrError == TRUE) {
echo "<li><span>Error connecting to list servers. Errors listed below.</span></li>";
foreach ($svrDown as $errorText) echo "<li><span>$errorText</span></li>";
} elseif ($num == 0) {
echo "<li><span>No servers currently listed.</span></li>";
} else {
foreach ($valid_servers as $Server) {
echo "<li>";
switch ($Server[type]) {
case 'battle':
$img = "gip_battle.png";
break;
case 'capture':
$img = "gip_ctf.png";
break;
case 'treasure':
$img = "gip_treasure.png";
break;
default:
$img = "gip_question.png";
}
$encodedIP = base64_encode($Server[ip].":".$Server[port]);
if ($Server[access] != "private") echo "<a href=\"gip_stuff/join.php?ip=$encodedIP\">";
echo "<img src=\"gip_stuff/$img\" /> ";
if ($Server[access] == "private") $Server[name] .= " (P)";
echo "<span class=\"s\">$Server[name]</span>";
if ($Server[access] != "private") echo "</a>";
echo "";
$uptime = round($Server[uptime] / 60);
echo "<span class=\"i\"> $Server[version] :: $Server[capacity] :: ".$uptime."min</span>";
echo "</li>";
}
/* if ($motd) {
echo "<li></li>";
echo "<li><span class=\"m\" title=\"Message of the Day at $servername\">";
echo nl2br($motd);
echo "</span></li>";
} */
echo "</ul>";
echo "</body>";
echo "</html>";
}
?>
__________________
With our extreme gelatinous apology,
We beg to inform your Imperial Majesty,
Unto whom be dominion and power and glory,
There still remains that strange precipitate
Which has the quality to resist
Our oldest and most trusted catalyst.
It is a substance we cannot cremate
By temperatures known to our Laboratory.
~ E.J. Pratt
|