At first you need a php file something like: status.php
<?php
include("secure/config.php");
$Status = ServerStatus();
/*
* HTML Content (Edit what you wont)
*/
// Start HTML ?>
<table border="0">
<tr>
<td><?php echo $Str_Loginsrv; ?></td>
<td><?php echo $Status[0]; ?></td>
</tr>
<tr>
<td><?php echo $Str_Charsrv; ?></td>
<td><?php echo $Status[1]; ?></td>
</tr>
<tr>
<td><?php echo $Str_Mapsrv; ?></td>
<td><?php echo $Status[2]; ?></td>
</tr>
<tr>
<td><?php echo $Str_onlinepl; ?></td>
<td><?php echo PlayerCount(); ?></td>
</tr>
</table>
<?php // End HTML
/*
* Functions (Script by EaScriptable.de.vu)
* Non Licensed (do what you want)
*/
/*
* Server Status (Return Array of Login,Char,Map State)
*/
function ServerStatus() {
Global $Srv_Host, $Srv_Login, $Srv_Char, $Srv_Map, $Str_Online, $Str_Offline;
// Disable Error Reporting (for this function)
error_reporting(0);
$Status = array();
$LoginServer = fsockopen($Srv_Host, $Srv_Login, $errno, $errstr, 1);
$CharServer = fsockopen($Srv_Host, $Srv_Char, $errno, $errstr, 1);
$MapServer = fsockopen($Srv_Host, $Srv_Map, $errno, $errstr, 1);
if(!$LoginServer){ $Status[0]= $Str_Offline; } else { $Status[0] = $Str_Online; };
if(!$CharServer){ $Status[1] = $Str_Offline; } else { $Status[1] = $Str_Online; };
if(!$MapServer){ $Status[2] = $Str_Offline; } else { $Status[2] = $Str_Online; };
return $Status;
}
/*
* Online Player count (Return Array of Player Count as integer)
*/
function PlayerCount() {
Global $Srv_Host, $Srv_Username,$Srv_Password,$Srv_Database;
$Connection = mysql_connect($Srv_Host, $Srv_Username, $Srv_Password) or die(mysql_error());
mysql_select_db($Srv_Database, $Connection);
$query = "SELECT COUNT(*) as total FROM `char` WHERE online = '1'";
$cresult = mysql_query($query, $Connection);
mysql_close($Connection);
$resarray = mysql_fetch_array($cresult);
$playeronline = $resarray["total"];
return $playeronline;
}
?>
after you made this you must made a file like config.php wich should be located at a different location like in this example the folder secure/config.php
in this file you setup the connection to your server and db.
<?php
/*
* Configurations file (rAthena Status)
* Writen by Lawliet (EaScriptable.de.vu)
* Non Licensed (do what you want)
*
*/
$Srv_Host = "127.0.0.1";
// Login, Char, Map Server Port
$Srv_Login = 6900;
$Srv_Char = 6121;
$Srv_Map = 5121;
// Database Settings
$Srv_Database = "Ragnarok";
$Srv_Username = "Username";
$Srv_Password = "Password";
// Status Text
$Str_Loginsrv = "Login Server:";
$Str_Charsrv = "Char Server:";
$Str_Mapsrv = "Map Server:";
$Str_onlinepl = "Player Online:";
$Str_Online = '<font color="green">Online</font>'; // (Online) + COLOR
$Str_Offline = '<font color="red">Offline</font>'; // (Offline) + COLOR
?>
After that the only thing you need to to is to implement the php files into your html / bootstrap site and design (css) on the right location you want to display the script.