Downloads containing example2.php

Downloads
Name Author Game Mode Rating
Jazz Server List + Server...Featured Download Cataphract PT Utility 8 Download file

File preview

<?php
/*
** This file illustrates how to reproduce Jazz2 Online/Digiex
** gip.php script.
** For a more powerful and complete use of the si.php and
** sl.php scripts, see the file named 'example.php'
**********************************************************
*/
//List server
$sl_conf['listserver'] = 'jazz.nimrod-online.com';

//error reporting level
error_reporting (0);

//General auxiliar functions
function signifnumber($version) {
	if (($version=="1.20")||($version=="1.20s")) return "0";
	if (($version=="1.21")||($version=="1.21s")) return "1";
	if (($version=="1.24")||($version=="1.24s")) return "4";
	return FALSE;
}
function hidesh($version) {
	//Hides the fact a server is running a shareware version
	if (substr($version,-1)=="s") return substr($version,0,4);
	else return $version;
}

if (@$_GET['si'] == 2) {
	if ((!isset($_GET['ip'])) || (!isset($_GET['versionsn'])))
		die("Insufficient parameters");
	$formato = 'Content-Disposition: attachment; filename="jazz2.%s"';
	header(sprintf($formato,$_GET['versionsn']==4?"j2si":"j2i"));
	header('Content-Type: application/x-jazz2');
	echo $_GET['ip'].":10052";
	exit;
}
if (@$_GET['si'] == 1) {
	include "example2-2.php";
	exit;
}
?>
<?php echo '<?xml version="1.0" encoding="ISO-8859-1"?>'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
	"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Server List - Digex/J20 Style</title>
<link href="digiex.css" title="Jazz2 Online color set"
	rel="stylesheet" />
<script type="text/javascript" src="popup.js">
</script>
</head>
<body class="sl">

<table class="serverList">
<thead>
<tr class="SLTitle"><td colspan="6">Server List</td></tr>
<tr class="SLHeader">
	<td>Server Name:</td>
	<td>Public?</td>
	<td>Type:</td>
	<td>Game Version:</td>
	<td>Server Uptime:</td>
	<td>Server Capacity:</td>
</tr>
</thead>
<tfoot>
<tr class="SLMOTDCredits">
<td colspan="6">
<?php
$errno = 0; $errstr = "";
$socket = fsockopen ($sl_conf['listserver'],10058,$errno,$errstr,1.5);
if ($socket !== FALSE) {
	echo "<span class=\"motd\">Message of the Day:<br />";
	$motd = "";
	while (!feof($socket)) $motd .= fread($socket, 4096);
	echo str_replace("\n","<br />",$motd)."<br /></span>";
}
else echo "<div class=\"MOTDErrorMsg\">Could not retrieve the MOTD.</div>";
?>
<div class="credits">Table design credits due to the <a href="http://digiex.net/"
title="Digiex Website">Digital Existence Network</a><br />
Color set credits due to <a href="http://www.jazz2online.com/"
title="Jazz2 Online Website">Jazz2 Online</a></div>
</td>
</tr>
</tfoot>
<tbody>
<?php
include "sl.php";
if ($sl_errno != 0) {
	echo "<tr class=\"SLError\">\n";
	echo "\t<td colspan=\"6\">Error: ($sl_errno) $sl_errstr</td>\n";
	echo "</tr>\n";
}
for ($i=0; $i<count($sl_servers); $i++) {
	$obj = $sl_servers[$i];
	$anable = ((signifnumber($obj->getversion()) !== FALSE)
		&& ($obj->gettype()=="public"));
	echo "<tr>\n";
	echo "\t<td class=\"SLname\">";
	if ($anable) {
		echo '<a href="javascript:launchsi(\''.
		$_SERVER['PHP_SELF'].'?'.
		'si=1&amp;'.
		'version='.$obj->getversion().'&amp;'.
		'ip='.$obj->getip().'&amp;'.
		'gamemode='.$obj->getgamemode(TRUE).'&amp;'.
		'name='.urlencode($obj->getname(TRUE)).
		'\')" title="Get Server Information">';
	}
	echo $obj->getname(TRUE);
	echo ($anable?"</a>":"")."</td>\n";
	echo "\t<td class=\"SLtype\">".
		($obj->gettype()=="private"?"No!":"Yes!").
		"</td>\n";
	echo "\t<td class=\"SLgamemode\">".
		$obj->getgamemode()."</td>\n";
	echo "\t<td class=\"SLversion\">".
		hidesh($obj->getversion(TRUE))."</td>\n";
	echo "\t<td class=\"SLuptime\">".
		$obj->getuptime()."</td>\n";
	echo "\t<td class=\"SLplayers\">".$obj->getplayers(TRUE);
	if ($anable) {
		echo " &#183; ";
		echo '<a href="'.$_SERVER['PHP_SELF'].'?'.
			'si=2&amp;'.
			'ip='.$obj->getip().'&amp;'.
			'versionsn='.signifnumber($obj->getversion()).
			'" title="Join the Server">';
		echo 'Go</a>';
	}
	echo "</td>\n";
	echo "</tr>\n";
}
?>
<tr class="SLPlaying">
	<td colspan="6">
		<span class="enf"><?php echo $sl_total_players; ?></span>
		people playing JJ2 Online<br />
		<span class="enf"><?php
			echo $sl_total_capacity - $sl_total_players;
		?></span>
		more people could be playing JJ2 Online
	</td>
</tr>
</tbody>
</table>

</body></html>