General
Legends Website
Tutorial & Skiing
Legends FAQs
Player Configuration
Legends Teams List
How to Host
Server List Backup

Add-Ons
New Maps
New Skins
New Voices
Player Scripts
Server Scripts & Mods

Modding
Legends Mapping Guide
Legends Scripting Guide
Creating Team Skins
Creating Voice Packs

Gameplay Guide
Legends Guide

Linux
Installation Instructions
Installer Script
Package Creator Scripts
Legends Distro Status

Legends Master Server Query on your website

Various efficient ways to get stats on your site.

DokuWiki

    {{rss>http://legendsthegame.net/legendsservers.rss 20 author date 5m }}

    PHP Master Query

    This PHP will check the XML data feed from this website, cache it and display the currently running Servers in a table. Just paste the chunk in your PHP where you want the table to appear, or save it as a file and use it as an include()

    It looks like this (with your styles)

     
    <? /* this chunk can go anywhere you want it to appear, or you can make it a page by adding <HTML><BODY> to the start and end */
    	error_reporting(0); // change to 1 to see detailed problems
     
    	$local_file = "legendsservers.xml";  //filename to save cache in
    	if(time() - filemtime($local_file) > 300 ) // get stats every 5 minutes and cache it
    	{
    		$url = "http://legendsthegame.net/legendsservers.xml";
    		$xmldata = file_get_contents($url);
    		$file = fopen($local_file, "w"); 
    		fwrite($file, $xmldata);
    		fclose($file);
    	}
     
        $p = xml_parser_create();
        xml_parse_into_struct($p,file_get_contents($local_file),$results,$index);
        xml_parser_free($p);
     
        $NUMSERVERS = $results[$index[NUMSERVERS][0]][value];
        $PUBDATE = $results[$index[PUBDATE][0]][value];
     
    	?>
    	<table cellpadding="0" cellspacing="0" border="0" bgcolor="#999999"><tr><td>
    	<table cellpadding="2" cellspacing="1" border="0"><tr bgcolor="#ffffff"><td colspan="5"><h2>Legends Servers</h2>
    	<? echo($NUMSERVERS); ?> servers reported. <a href="http://legendsthegame.net/legendsservers.rss" title="RSS currently populated Legends servers feed">Get Live Feed</a> - <a href="http://legendsthegame.net/community/doku.php?id=server:php_masterquery" title="show this list on your server">Get this PHP</a>
    	<br />Last Server Refresh: <? echo($PUBDATE); ?> (updated every 5 minutes)</td></tr>
    	<tr bgcolor="#ffffff"><td>Name</td><td>Players</td><td>Join</td><td>OS</td><td>Password</td></tr>
    	<?	
    	/* XML structure for http://legendsthegame.net/legendsservers.xml
    	MASTERSERVER-QUERY
    	  PUBDATE
    	  NUMSERVERS
    	  SERVER
    		IP
    		PORT
    		NAME
    		PLAYERS
    		MAXPLAYERS
    		VERSION
    		OS
    		PASSWORD
    	*/					
    	for ($i=0; $i < $NUMSERVERS; $i++) {
    		echo("\n<tr bgcolor='#ffffff'>");
    		echo("<td>" . htmlentities($results[$index[NAME][$i]][value]) . "</td>");
    		echo("<td>" . $results[$index[PLAYERS][$i]][value] . "/" . $results[$index[MAXPLAYERS][$i]][value] . "</td>");
    		echo("<td><a href='legends://" . $results[$index[IP][$i]][value] . ":" . $results[$index[PORT][$i]][value] . "' title='Instant join'>Connect</a></td>");
    		//echo("<td>" . $results[$index[VERSION][$i]][value] . "</td>");
    		echo("<td>" . $results[$index[OS][$i]][value] . "</td>");
    		echo("<td>" . $results[$index[PASSWORD][$i]][value] . "</td>");
    		echo("</tr>");
    	}
    	?>
    	</table></td></tr></table>

    Javascript Master Query IFRAME

    This is an IFRAME as seen at the top of the Legends Forums. It has fade-in fade-out effects to cycle between all active servers and show how many players are on each. Very simple, will work on websites which can't use PHP. Has no impact on your host. You can specift background colour, link colour, font, font size - see the code and work it out.

    It looks like this

    <div style="background-color:#ffffff;"><iframe align="middle" name="rssfeed" width="95%" height="13" src="http://legendsthegame.net/rssreader.html?bg=ffffff&txt=0000ff&pxsize=09&fontfam=Arial%20Black" marginheight="0" marginwidth="0" scrolling="no" frameborder="0" ></iframe></div>

    Javascript Master Query Ad Banner

    Javascript generated by Feedburner to display stats as a Banner. Has no impact on your host. Go here to get the code for Email Sigs, MySqace, Typepad, Wordpress etc. If you want to change the background to an image or anything like that you can just create your own feed at feedburner and put in our RSS url ( http://legendsthegame.net/legendsservers.rss ).

    It looks like this

    <p style="margin-top:10px; margin-bottom:0; padding-bottom:0; text-align:center; line-height:0"><a href="http://feeds.feedburner.com/~r/ActiveLegendsServers/~6/1"><img src="http://feeds.feedburner.com/ActiveLegendsServers.1.gif" alt="Active Legends Servers" style="border:0"></a></p><p style="margin-top:5px; padding-top:0; font-size:x-small; text-align:center"><a href="http://www.feedburner.com/fb/a/headlineanimator/install?id=993291&amp;w=1" onclick="window.open(this.href, 'haHowto', 'width=520,height=600,toolbar=no,address=no,resizable=yes,scrollbars'); return false" target="_blank">&uarr; Grab this Headline Animator</a></p>
     
    server/php_masterquery.txt · Last modified: 2008/07/03 16:09 (external edit)