Server Statistics on WebSite. PHP?
Posted: Thu Mar 04, 2010 8:10 am
Hi, I am working on a website for my server and I want to have most statistic available to view on the site. But of course like always I have issues. I don't know much at all about php, I found this script that's supposed to show my server status (On or Offline). Its a php file and I have no idea where to put it, I have tried copying it to my website in html format but that just shows the whole script on the website. I have tried making a link to pointing to the php file but that does the same thing, Shows the whole script when you click the link. Any help would be appreciated, posted script below. Please no flaming, you don't have to remind me that I'm a newbie at this.
Code: Select all
<?php #Login Server$serverLip="127.0.0.1";$serverLport="2106"; #GameServer$serverGip="127.0.0.1";$serverGPort="7777"; #Database Host$databaseHost="127.0.0.1";$databaseLogin="your user";$databasePassword="your pass";$databaseName="your db"; ?> <?php #Login$flogin = @fsockopen ($serverLip,$serverLport, $errno, $errstr, 1);if ( $flogin ) $lstat = "<font color=#00FF00>ONLINE</font>"; else $lstat = "<font color=#FF0000>OFFLINE</font>"; #Sieghardt$fgame2 = @fsockopen ($serverGip,$serverGPort, $errno, $errstr, 1);if ( $fgame2 ) $gstat2 = "<font color=#00FF00>ONLINE</font>"; else $gstat2 = "<font color=#FF0000>OFFLINE</font>"; mysql_connect($databaseHost,$databaseLogin,$databasePassword) or die (mysql_error()); mysql_select_db($databaseName) or die(mysql_error()); //online kari$query = ("SELECT * FROM characters WHERE online=1 and accesslevel=0"); $result = mysql_query($query) or die(mysql_error()); $num2=mysql_numrows($result);$sum=$sum+$num2; //Alliance$query = ("SELECT * FROM clan_data WHERE ally_name!=\"\""); $result = mysql_query($query) or die(mysql_error()); $alliance2=mysql_numrows($result); //all characters $query = ("SELECT * FROM characters WHERE accesslevel>=0"); $result = mysql_query($query) or die(mysql_error()); $char2=mysql_numrows($result); //all GM characters $query = ("SELECT * FROM characters Where accesslevel > 99"); $result = mysql_query($query) or die(mysql_error()); $gmchar2=mysql_numrows($result); //all accounts $query = ("SELECT * FROM accounts WHERE access_level>=0"); $result = mysql_query($query) or die(mysql_error()); $accounts2=mysql_numrows($result); //Clan $get_config_data="SELECT clan_id FROM clan_data"; $query = ("SELECT clan_id FROM clan_data WHERE clan_id>0"); $result = mysql_query($query) or die(mysql_error()); $clan2=mysql_numrows($result); //GM$quary = mysql_query ("SELECT char_name FROM characters WHERE accesslevel>100 AND online=1");while ($gmtitle2 = mysql_fetch_array ($quary)) { $gmname2 = $gmtitle2["char_name"];} //Titan$quary = mysql_query ("SELECT char_name FROM characters WHERE accesslevel=75 AND online=1");while ($titantitle2 = mysql_fetch_array ($quary)) { $titanname2 = $titantitle2["char_name"];} mysql_close();mysql_connect($databaseHost,$databaseLogin,$databasePassword) or die(mysql_error()); mysql_select_db($databaseName) or die(mysql_error()); ?> <html><head><title>MEDNet Lineage II - Kamael Szerver</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2"></head><body><font color=#000000><span class="style3">Login:</span></font> <?php print ("$lstat"); ?><br><font color=#000000><span class="style3">Game:</span></font> <?php print ("$gstat2"); ?><br><font color=#000000><span class="style3">Online Players:</span></font> <font color=#ff0000><?php print ("$num2"); ?></font><br><font color=#000000><span class="style3">All Account:</span></font> <font color=#ff0000><?php print ("$accounts2"); ?></font><br><font color=#000000><span class="style3">All Characters:</span></font> <font color=#ff0000><?php print ("$char2"); ?></font><br><font color=#000000><span class="style3">All GM Characters:</span></font> <font color=#ff0000><?php print ("$gmchar2"); ?></font><br><font color=#000000><span class="style3">All Clan:</span></font> <font color=#ff0000><?php print ("$clan2"); ?></font><br><font color=#000000><span class="style3">All Alliance:</span></font> <font color=#ff0000><?php print ("$alliance2"); ?></font><br><font color=#000000><span class="style3">Online Titan:</span></font> <font color=#ff0000><?php print ("$titanname2"); ?></font><br><br><font color=#000000><span class="style3">Online GM:</span><br></font> <font color=#008800><?php print ("$gmname2"); ?></font><br></html>