Jump to content

[Share]Server status/online script


Recommended Posts

  • 3 weeks later...
  • 6 months later...

This is a php script. Make a new file *.php, upload it on your FTP, open some internet browser, enter your website address with the *.php file call, and look.

 

This is a tool for server webmaster who need to display the online player of a server. This is not a cheat, this is not a crap, this is just a php script.

 

More, I think the code is really simple and understable with all the comments, just need to read and not flood asking noob questions about that. If you don't know what this code is talking about, if you don't know what php is done to do, just look and close your flooding spamming fingers.

dude it didn't work if i put the php file with the code inside the website show a white page with this :

'; //prints out the $x number of players online ?>

 

any solution ?

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

Parse error: syntax error, unexpected T_STRING in C:\Program Files\VertrigoServ\www\status\Map\map.php on line 27

what's wrong???

 

i use this code

 

 

<?php

//first you need to define db info

  define('mySQL_hostname', '127.0.0.1');  //database IP

  define('mySQL_database', 'Database');  //database name

  define('mySQL_username', 'User');  //database user

  define('mySQL_password', 'Pass');  //database password

 

//connects to mysql

  $db_link = mysql_pconnect( mySQL_hostname, mySQL_username, mySQL_password )

    or die( 'Error connecting to mysql<br><br>'.mysql_error() );

 

//connects to Database

  $db_select = mysql_select_db( mySQL_database, $db_link )

    or die( 'Error connecting to Database<br><br>'.mysql_error() );

 

//selects desired table

  $chars=mysql_query("SELECT * FROM `characters` WHERE `accesslevel`=0);

 

//tells how much rows are there (will come helpfull with while loops)

  $rows =mysql_numrows($characters);

 

  $i=0;

  $x=0;

 

//while $i is smaller than number of rows repeat the code

  while ($i < $rows) {

    $online=mysql_result($chars,$i,"online"); //looks into characters table, under column online(if player is online its "1" else "0"), at row $i

    if ($online == 1) { $x++; } // if column online at row $i is "1", increase $x

    $i++; //increase $i

    }

  print 'Online players:<em>'.$x.'<em>'; //prints out the $x number of players online

?>

Link to comment
Share on other sites

  • 3 weeks later...

My Server Status Script:

 

<?php

////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////// Created By Mentor www.teamsrv.net ////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////


$login_ip = "127.0.0.1";
$login_port = "2106";
$game_ip = "127.0.0.1";
$game_port = "7777";
$ventrilo_ip = "127.0.0.1";
$ventrilo_port = "3784";

$mysql_host = "127.0.0.1";
$mysql_user = "root";
$mysql_passwd = "root";
$mysql_db = "l2jdb";

///////////////////////////
////////Login Server///////
///////////////////////////
$ls = @fsockopen ($login_ip, $login_port, $errno, $errstr, 1);
if ( $ls ) 
    $ls = "<font color=green>Online</font>"; 
else 
    $ls = "<font color=red>Offline</font>"; 

///////////////////////////
////////Game Server ///////
///////////////////////////
$gs = @fsockopen ($game_ip, $game_port, $errno, $errstr, 1);
if ( $gs ) 
    $gs = "<font color=green>Online</font>"; 
else 
    $gs = "<font color=red>Offline</font>"; 

///////////////////////////
////////Vent Server ///////
///////////////////////////
$ve = @fsockopen ($ventrilo_ip, $ventrilo_port, $errno, $errstr, 1);
if ( $ve ) 
    $ve = "<font color=green>Online</font>"; 
else 
    $ve = "<font color=red>Offline</font>"; 


/////////////////////////////
////MySQL Login Server///////
/////////////////////////////

mysql_connect($mysql_host, $mysql_user, $mysql_passwd) or die ("Nem sikerült csatlakozni a MySQL szerverhez!");
mysql_select_db($mysql_db) or die("Nincs ilyen adatbázis: ".$mysql_db); 

// All Accounts
$accounts=mysql_numrows(mysql_query("SELECT * FROM accounts"));

// Online Players Num
$num=mysql_numrows(mysql_query("SELECT * FROM characters WHERE online=1 and accesslevel=0"));

// Online GMs Num
$gmnum=mysql_numrows(mysql_query("SELECT * FROM characters WHERE online=1 and accesslevel>0"));

// All Alliance Num
$alliance=mysql_numrows(mysql_query("SELECT * FROM clan_data WHERE ally_name!=\'\'"));

// All Characters
$char=mysql_numrows(mysql_query("SELECT * FROM characters WHERE accesslevel=0"));

// All GM Characters
$gmchar=mysql_numrows(mysql_query("SELECT * FROM characters Where accesslevel > 0"));

// All Clan
$clan=mysql_numrows(mysql_query("SELECT * FROM clan_data"));

$gmnamesql = mysql_query("SELECT char_name FROM characters WHERE accesslevel>=1 AND online=1 ORDER BY char_name ASC");    
while ($gmnam = mysql_fetch_object($gmnamesql)) {  
$gmname .= "<font color=green>$gmnam->char_name</font>, ";  
}

print "
<table width='100%' border='0'>
<tr><td width='80%'><b>Auth Server:</b></td><td>".$ls."</td></tr>
<tr><td width='80%'><b>Bartz Server:</b></td><td>".$gs."</td></tr>
<tr><td width='80%'>Accounts:</td><td>".$accounts."</td></tr>
<tr><td width='80%'>Online Players:</td><td>".$num."</td></tr>
<tr><td width='80%'>Online GM:</td><td>".$gmnum."</td></tr>
<tr><td width='80%'>Characters:</td><td>".$char."</td></tr>
<tr><td width='80%'>GM Characters:</td><td>".$gmchar."</td></tr>
<tr><td width='80%'>Clans:</td><td>".$clan."</td></tr>
<tr><td width='80%'>Alliances:</td><td>".$alliance."</td></tr>
<tr><td>Online GM: ".$gmname."</td></tr>
</table>
";
////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////// Created By Mentor www.teamsrv.net ////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////

?>

Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock