PHP status L2O 

Newbie Spellweaver
Joined
Nov 3, 2004
Messages
9
Reaction score
0
Please give me statistics of the server on php.
Wanted that she displayed how much players online, and top 10 and all players which play.
 
this is for statistic
Code:
<?
//get online counter
ob_start();
system("netstat -n");
$result=ob_get_contents();
ob_end_clean();
//TCP    217.21.36.15:7777      213.184.244.191:1178   ESTABLISHED
preg_match_all("/TCP.*:7777.*ESTABLISHED/mi",$result,$match);
$online=count($match[0]);

//get server status
$fp = @fsockopen ("localhost", 7777, $errno, $errstr, 3);
if(!$fp) $server_status="down";
else $server_status="up";
@fclose($fp);

//get amount of heroes
mssql_connect("localhost","mssql_user","mssql_password");
mssql_select_db("lin2world");
$result=mssql_query("SELECT count(*) FROM [user_data]");
list($heroes)=mssql_fetch_array($result);
//get amount of logins
mssql_select_db("lin2db");
$result=mssql_query("SELECT count(*) FROM [user_account]");
list($accounts)=mssql_fetch_array($result);

//here you have
echo "Online: ".$online."<br>"; //users online
echo "Server is: ".$server_status."<br>"; //server status
echo "Accounts: ".$accounts."<br>"; //amount of accounts
echo "Heroes: ".$heroes."<br>"; //amount of heroes
?>
top players and online players is attached
 

Attachments

Upvote 0
hm... I do not remember who post it... but it working.
l2cp - include here
in file config.php
Code:
<?
$mssql_addr="server IP";
$mssql_user="SQL_admin_name";
$mssql_pass="SQL_admin_password";
$mssql_db="lin2world";

$class_list=array(
	0=>"Fighter",1=>"Warrior",2=>"Gladiator",3=>"Warlord",
	4=>"Knight",5=>"Paladin",6=>"Dark_avenger",7=>"Rogue",
	8=>"Treasure_hunter",9=>"Hawkeye",10=>"Mage",11=>"Wizard",
	12=>"Sorcerer",13=>"Necromancer",14=>"Warlock",15=>"Cleric",
	16=>"Bishop",17=>"Prophet",18=>"Elven_fighter",19=>"Elven_knight",
	20=>"Temple_knight",21=>"Swordsinger",22=>"Elven_scout",23=>"Plains_walker",
	24=>"Silver_ranger",25=>"Elven_mage",26=>" Elven_wizard",27=>" Spellsinger",
	28=>"Elemental_summoner ",29=>"Oracle",30=>"Elder",31=>"Dark_fighter",
	32=>"Palus_knightr",33=>"Shillien_knight",34=>"Bladedancer",35=>"Assasin",
	36=>" Abyss_walker",37=>"Phantom_ranger",38=>"Dark_mage",39=>"Dark_wizard",
	40=>"Spellhowler",41=>"Phantom_summoner",42=>"Shillien_oracle",43=>"Shilien_elder",
	44=>"Orc_fighter",45=>"Orc_raider",46=>"Destroyer",47=>"Orc_monk",
	48=>"Tyrant",49=>"Orc_mage",50=>"Orc_shaman",51=>"Overlord",
	52=>"Warcryer",53=>"Dwarven_fighter",54=>"Scavenger",55=>"Bounty_hunter",
	56=>"Artisan", 57=> "Warsmith"
);

//all these heroes will be excluded from top list
$exclude_from_top=array(
	"user1","user2"
);
?>
create file online.php

Code:
<?
include("config.php");

mssql_connect($mssql_server,$mssql_user,$mssql_pass);
mssql_select_db($mssql_db);

$result=mssql_query("
	select
		char_name, Lev, builder,
		class, use_time,
		PK, Duel,gender
	from user_data
	where login>logout");

$online_users=array();
for($x=0;$online_users[$x]=mssql_fetch_assoc($result);$x++){
	$online_users[$x]['use_time_h']=round($online_users[$x]['use_time']/3600,1)."h";
**;
unset($online_users[count($online_users)-1]);

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<META HTTP-EQUIV="Expires" CONTENT="Fri, Jan 01 1900 00:00:00 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META http-equiv="Content-Type" content="text/html; charset=windows-1251">
<META http-equiv="content-language" content="en">
<META name="author" content="">
<META HTTP-EQUIV="Reply-to" CONTENT="@.com">
<META name="generator" content="PHPEd 3.1">
<META NAME="description" CONTENT="">
<META name="keywords" content="">
<META NAME="Creation_Date" CONTENT="08/15/2000">
<META name="revisit-after" content="15 days">
<title>Online</title>
</head>
<body>
<table border="1" align=center size=5>
	<tr>
	<td colspan="5">Users, play in Lineage2:</td>
	</tr>
	<tr>
    	<td>Nick</td>
    	<td>Lvl</td>
    	<td>Class</td>
    	<td>Total in game</td>
    	<td>PvP/PK</td>
	</tr>
	<?for($x=0;$x<count($online_users);$x++){?>
    <tr>
    	<td style="color:<?=$online_users[$x]["gender"]?"#FF8080":"#8080FF"?>"><?=$online_users[$x]["char_name"]?></td>
    	<td><?=$online_users[$x]["Lev"]?></td>
    	<td><?=$class_list[$online_users[$x]["class"]]?></td>
    	<td><?=$online_users[$x]["use_time_h"]?></td>
    	<td><?=$online_users[$x]["Duel"]?>/<?=$online_users[$x]["PK"]?></td>
    </tr>
	<?**?>
	<tr>
    	<td colspan="3">Total Online:</td>
    	<td><?=count($online_users)?></td>
    	</tr>
</table>
</body>
</html>

create file top30.php
Code:
<?
include("config.php");

mssql_connect($mssql_server,$mssql_user,$mssql_pass);
mssql_select_db($mssql_db);

$result=mssql_query("
	select
		char_name, Lev, builder,
		class, use_time,
		PK, Duel,gender
	from user_data
	where char_name not in (".("'".join("','",$exclude_from_top)."'").") and account_id>0
	order by Lev desc");

$online_users=array();
for($x=0;($online_users[$x]=mssql_fetch_assoc($result))&&$x<30;$x++){
	$online_users[$x]['use_time_h']=round($online_users[$x]['use_time']/3600,1)."h";
**;
unset($online_users[count($online_users)-1]);

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<META HTTP-EQUIV="Expires" CONTENT="Fri, Jan 01 1900 00:00:00 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META http-equiv="Content-Type" content="text/html; charset=windows-1251">
<META http-equiv="content-language" content="en">
<META name="author" content="">
<META HTTP-EQUIV="Reply-to" CONTENT="@.com">
<META name="generator" content="PHPEd 3.1">
<META NAME="description" CONTENT="">
<META name="keywords" content="">
<META NAME="Creation_Date" CONTENT="08/15/2000">
<META name="revisit-after" content="15 days">
<title>Online</title>
</head>
<body>
<table border="1" align=center>

	<tr>
        <td>##</td>
    	<td>Nick</td>
    	<td>Lvl</td>
    	<td>Class</td>
    	<td>Total in game</td>
    	<td>PvP/PK</td>
	</tr>
	<?for($x=0;$x<count($online_users);$x++){?>
    <tr>
        <td><?=$x+1?></td>
    	<td style="color:<?=$online_users[$x]["gender"]?"#FF8080":"#8080FF"?>"><?=$online_users[$x]["char_name"]?></td>
    	<td><?=$online_users[$x]["Lev"]?></td>
    	<td><?=$class_list[$online_users[$x]["class"]]?></td>
    	<td><?=$online_users[$x]["use_time_h"]?></td>
    	<td><?=$online_users[$x]["Duel"]?>/<?=$online_users[$x]["PK"]?></td>
    </tr>
	<?**?>
</table>
</body>
</html>

It is necessary to cause these files.
It is possible for example so:
in index.php and home.php
create button TOP 30
and insert this code :
Code:
echo '
	<tr>
		<td background="img/menubar.gif" valign="middle" width="703" style="border:1px solid black;" height="30">
			<div align="left" class="normal" style="margin-left: 10px;margin-right: 10px;">
				<script type="text/javascript" language="JavaScript1.2">
					<!--
					stm_bm(["tubtehr",430,"","blank.gif",0,"","",0,0,250,0,250,1,0,0,"","",0],this);
					stm_bp("p0",[0,4,0,0,0,0,5,0,100,"",-2,"",-2,90,0,0,"#000000","transparent","",3,0,0,"#ffffff"]);
					stm_ai("p0i0",[2,"","img/home.jpg","img/home.jpg",0,0,0,"home.php","_self","","","","",0,0,0,"","",0,0,0,0,1,"#3399ff",1,"#3399ff",1,"","",3,3,0,0,"#ffffff","#ffffff","#ffffff","#ff0000","bold 8pt Arial","bold 8pt Arial",0,0]);
					stm_aix("p0i1","p0i0",[2,"","img/options.jpg","img/options.jpg",0,0,0,"","_self","","","","",5,1]);
					stm_bpx("p1","p0",[1,4,5,0,3,0,0,0,100,"progid:DXImageTransform.Microsoft.Wipe(GradientSize=1.0,wipeStyle=1,motion=forward,enabled=0,Duration=0.60)",5,"progid:DXImageTransform.Microsoft.Wipe(GradientSize=1.0,wipeStyle=1,motion=reverse,enabled=0,Duration=0.60)",4,50,0,0,"#999999"]);
					stm_aix("p1i0","p0i0",[2,"","img/changepassword.jpg","img/changepassword.jpg",0,0,0,"home.php?page=changepassword","_self","","","","",0,0,0,"","",0,0,0,0,0]);
					stm_ep();
					stm_aix("p0i2","p0i1",[2,"","img/forum.jpg","img/forum.jpg",0,0,0,"/forums/"]);
					stm_ep();
[COLOR=Red]//this text need... (sorryi'm russian and bad eng...)	[/COLOR]			[COLOR=DarkOrange]	

stm_aix("p0i2","p0i1",[2,"","img/top10.jpg","img/top30.jpg",0,0,0,"top30.php"]);
					stm_ep();[/COLOR]
					stm_aix("p0i2","p0i1",[2,"","img/logout.jpg","img/logout.jpg",0,0,0,"logout.php"]);
					stm_em();
					//-->
				</script>
			</div>
		</td>
	</tr>

and into page/annoucement.php
add in the end of a file
Code:
require 'online.php';
echopage('footer', '');

?>

and hm... wh status server ONLINE\OFLINE
create file serverstatus.php
and yeah.txt
Code:
<?
header("Content-type: text/html; charset=\"windows-1251\"");
?>

<body bgColor=#B2CAFA style=border:none;margin:0>

<table align=center width=100%>
<tr align=center><td width=50%>

<table bgColor=#f2f2f2 style=border-style:ridge;border-width:2 align=center cellspacing=0 cellpadding=5>
<tr><th bgColor=#000080 colSpan=2><font color=#ffffff>Lineage 2</font></th></tr>
<?
error_reporting(0);

$IP = array(
"Auth server:" => "IP_Server:2106",
"Game server:" => "IP_Server:7777",
); while(list($ServerName,$Host)=each($IP)) {
list($IPAddress,$Port)=explode(":",$Host);
echo("<tr><td align=right>".$ServerName."</td>");
if($fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR_STR,(float)0.5)) {
echo("<td><font color=green><b>Ok</b></font></td>");
fclose($fp);
**
else {
echo ("<td><font color=#ff0000><b>Offline</b></td>");
**
echo ("</tr>");
**
echo ("</table>");
?>
</td>
<td>

<table bgColor=#f2f2f2 style=border-style:ridge;border-width:2 align=center cellspacing=0 cellpadding=5>
<tr><th bgColor=#000080 colSpan=2><font color=#ffffff>World Of Warcraft v 0.11.0 <br>на 10.106.41.14</font></th></tr>
<?
//error_reporting(0);

	$IP = array(
	"Game server:" => "10.106.41.14:8129");

		while(list($ServerName,$Host)=each($IP))
		{
		list($IPAddress,$Port)=explode(":",$Host);
		echo("<tr><td align=right>".$ServerName."</td>");

			if(filemtime("yeah.txt")+1*60<time())
			{
				if($fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR_STR,(float)0.5))
				{
				$tralala="<font color=green>Ok</font>";
				fclose($fp);
				**

				else
				$tralala="<font color=red>Offline</font>";

			$op=fopen("yeah.txt","w");
			fwrite($op,$tralala);
			fclose($op);
			**

echo "<td><b>".file_get_contents("yeah.txt")."</b></td>";
echo ("</tr>");
**
echo ("<tr></tr></table>");
?>
</td>
</tr>
</table>
 
Last edited:
Upvote 0
sorry for my lang
i.m used 2 servers Lineage2& World of Warcraft

and add into function.php
Code:
function echoindex($part) {
	if($part=='credits') {

	echo '
	<tr valign="top">
		<td width="100%" align="center">
		<iframe src=serverstatus.php width=100% height=100 style=border-style:none border=0></iframe>
		</td>
	</tr>
	';


	** elseif($part=='end') {
	echo '
	</table>
	</body>
	';
	** elseif($part=='head') {
	echo '
	<table width="703" align="center" border="0" cellpadding="0">
	<tr>
		<td height="96">
			<center>
				<img src="img/title.jpg" border="0">
			</center>
		</td>
	</tr>
	';
	** elseif($part=='space') {
	echo '
	<tr>
		<td class="normal">
			 
		</td>
	</tr>
	';
	** elseif($part=='title') {
	echo "
	<title>10.106.35.8 - Сервер: Lineage 2
	</title>
	<link href='img/styles.css' rel='stylesheet' type='text/css'>
	<body bgcolor='#B2CAFA' topmargin='0' leftmargin='0' rightmargin='0'>
	";
	**
**

and sorry..
I apologize for the mistakes if that that not clearly ask I I shall make archive with files for l2cp
 
Upvote 0
Ok.. edit config.php,serverstatus.php for u IP,SQL login and pass...
Redraw images into /img/ folder,
and /page/ in russian lang, if u edit it - thats great...
 
Last edited:
Upvote 0
I'm sorry for my english. About on-line.

Code:
$result=mssql_query("
	select
		char_name, Lev, builder,
		class, use_time,
		PK, Duel,gender
	from user_data
	where login>logout");

It is wrong to compare these values (login, logout). Because of falling a server or database, these fields may not show the real state.
Is there another way to get list of on-line users? Or somehow refresh these fields?
 
Upvote 0
Hi first of all thank you for the script !
but I have a problem ... everytime I try to open the page I get this error

Fatal error: Call to undefined function: mssql_connect() in C:\Program Files\Abyss Web Server\htdocs\online.php on line 4

my script on line 4 is:

mssql_connect($mssql_server,$mssql_user,$mssql_pass);

I cant see errors here.... but I still get this msg when I try to open it..

Any help will be appreciate !

Tyrael
 
Upvote 0
Back