Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

L2J PHP Status/Acc creation/Online players Scripts

Status
Not open for further replies.
Junior Spellweaver
Joined
Jul 19, 2007
Messages
142
Reaction score
0
Ive decided to make this thread cuz theres allot of good servers out there with pages looking like something frontpage would spit out.. besides it was time to give something back to the rz community =)

I could post all scripts from castle sieges to clan hall owners lol.. but i will just post this 3 for example.. and ofcourse learning purposes..

Server Status:

anyway status script is the easyest thing to do with php.. and i wont even try to explain it since its mostly obvious..

PHP:
<?php    print'<table width="150">';    $server  = "127.0.0.1";    $portg   = "7777";    $portl   = "9014";    $timeout = "5";    if ($server and $port and $timeout) {        $game =  @fsockopen("$server", $portg, $errno, $errstr, $timeout);        $login =  @fsockopen("$server", $portl, $errno, $errstr, $timeout);    }    print'<tr><td align="center"><strong>Server Status</strong></td></tr>';    if($login) { print'<tr><td>Login:</td><td><font color="#00FF00"><strong> Online</strong></font><br><br></td></tr>'; }    else { print'<tr><td>Login:</td><td><font color="#FF0000"><strong> Offline</strong></font><br><br></td></tr>'; }    if($game) { print'<tr><td>Game:</td><td><font color="#00FF00"><strong> Online</strong></font></td></tr>'; }    else { print'<tr><td>Game:</td><td"><font color="#FF0000"><strong> Offline</strong></td></tr>'; }     print'</table>';?>

Acc creation:


I wasted allot of time to get to know what encryption l2 uses for passwords.. anyway i wanted to spare you some time..

First create acc.php file in same directory as index.. and add this script to it
PHP:
<?php  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  function l2j_encrypt($password)     {        return base64_encode(pack("H*", sha1(utf8_encode($password))));    }  $str =  l2j_encrypt($_POST['pass']);  $user = $_POST["name"];  $db_link = mysql_pconnect( mySQL_hostname, mySQL_username, mySQL_password )    or die( 'Error connecting to mysql<br><br>'.mysql_error() );  $db_select = mysql_select_db( mySQL_database, $db_link )    or die( 'Error connecting to Database<br><br>'.mysql_error() );  if ($user == '') { print'Incorrect UserID'; mysql_close(); }  else {	  $db_add = mysql_query( "INSERT INTO `accounts` VALUES ('$user', '$str', '0', '0', '')" )	    or die( 'Error: '.mysql_error() );  }  print 'Account Created<br><br>Enjoy youre gameplay.';  mysql_close();?>
after that add this to index

Code:
            <form action="acc.php" method=post>                        UserID:<input type="text" name="name" size 20><br><br>                        Password:<input type="password" name="pass" size 20><br><br>                         <input type=submit name="submit" value="Login">            </form>[/COLOR]

Online Players:

PHP:
//connects to mysql
$db = mysql_pconnect( '127.0.0.1', 'dbUsername', 'dbPassword');
mysql_select_db( 'l2jdatabaseName', $db ); // Change to your gameserver database name

// get number of online players (just the number) not all their data of each
$query_number = "SELECT COUNT(*) AS number FROM characters WHERE online='1'";
$result_number = mysql_query( $query_number ) or die ( mysql_error() );
$number = mysql_result(0, $result_number, 'number');

// Print the number
echo 'Players online :'.$number;

This script connects to the database(that means you need to have php connected to sql.. if you need any help with it try searching with google for apache php mysql install guides and i bet first link will work). Ive explained some of the code.. so learning from it should be easy..

]sometimes you will only get for example clan id.. not the name of it.. and in that case i suggest you use 2 whiles (one inside the other) to check other tables for names...


hope it was helpful.. enjoy :)
 
Last edited by a moderator:
Newbie Spellweaver
Joined
Dec 18, 2005
Messages
89
Reaction score
0
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

Thx 4 share =)
 
Junior Spellweaver
Joined
Oct 29, 2005
Messages
185
Reaction score
0
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

very useful share/guide
i will test
 
Newbie Spellweaver
Joined
Feb 24, 2006
Messages
8
Reaction score
0
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

Ive decided to make this thread cuz theres allot of good servers out there with pages looking like something frontpage would spit out.. besides it was time to give something back to the rz community =)

I could post all scripts from castle sieges to clan hall owners lol.. but i will just post this 3 for example.. and ofcourse learning purposes..

Server Status:

anyway status script is the easyest thing to do with php.. and i wont even try to explain it since its mostly obvious..

Code:
<?php
    print'<table width="150">';
    $server  = "127.0.0.1";
    $portg   = "7777";
    $portl   = "9014";
    $timeout = "5";

    if ($server and $port and $timeout) {
        $game =  @fsockopen("$server", $portg, $errno, $errstr, $timeout);
        $login =  @fsockopen("$server", $portl, $errno, $errstr, $timeout);
    }
    print'<tr><td align="center"><strong>Server Status</strong></td></tr>';
    if($login) { print'<tr><td>Login:</td><td><font color="#00FF00"><strong> Online</strong></font><br><br></td></tr>'; }
    else { print'<tr><td>Login:</td><td><font color="#FF0000"><strong> Offline</strong></font><br><br></td></tr>'; }
    if($game) { print'<tr><td>Game:</td><td><font color="#00FF00"><strong> Online</strong></font></td></tr>'; }
    else { print'<tr><td>Game:</td><td"><font color="#FF0000"><strong> Offline</strong></td></tr>'; } 
?>

Will be good if you can teach me how i can paste pictures there.

Acc creation:

I wasted allot of time to get to know what encryption l2 uses for passwords.. anyway i wanted to spare you some time..

First create acc.php file in same directory as index.. and add this script to it
Code:
<?php
  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

  function l2j_encrypt($password) 
    {
        return base64_encode(pack("H*", sha1(utf8_encode($password))));
    }

  $str =  l2j_encrypt($_POST['pass']);

  $user = $_POST["name"];

  $db_link = mysql_pconnect( mySQL_hostname, mySQL_username, mySQL_password )
    or die( 'Error connecting to mysql<br><br>'.mysql_error() );

  $db_select = mysql_select_db( mySQL_database, $db_link )
    or die( 'Error connecting to Database<br><br>'.mysql_error() );

  if ($user == '') { print'Incorrect UserID'; mysql_close(); }
  else {
  if ($user == '') { print'Incorrect Password'; mysql_close(); }

  $db_add = mysql_query( "INSERT INTO `accounts` VALUES ('$user', '$str', '0', '0', '')" )
    or die( 'Error: '.mysql_error() );
  
  print 'Account Created<br><br>Enjoy youre gameplay.';
  mysql_close();
?>

after that add this to index

Code:
            <form action="acc.php" method=post>
                        UserID:<input type="text" name="name" size 20><br><br>
                        Password:<input type="password" name="pass" size 20><br><br>
                         <input type=submit name="submit" value="Login">
            </form>

For acc creation , i did everything what you said but i get error

Parse error: syntax error, unexpected $end in /home/l2an/public_html/acc.php on line 31
 
Junior Spellweaver
Joined
Jul 19, 2007
Messages
142
Reaction score
0
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

thnx for noticing lol... ive edited first post so it works now..

but this was meant more for you to learn what encryption do pass use.. i mean this code is not good for a real site.. you need to make pics generator or some mail verification so no one can abuse it to spam accs.. and it could be printed in same window as site.. just details ^^
 
Newbie Spellweaver
Joined
Jul 14, 2007
Messages
27
Reaction score
0
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

Ive decided to make this thread cuz theres allot of good servers out there with
Server Status:

anyway status script is the easyest thing to do with php.. and i wont even try to explain it since its mostly obvious..

Code:
<?php
    print'<table width="150">';
    $server  = "127.0.0.1";
    $portg   = "7777";
    $portl   = "9014";
    $timeout = "5";

    if ($server and $port and $timeout) {
        $game =  @fsockopen("$server", $portg, $errno, $errstr, $timeout);
        $login =  @fsockopen("$server", $portl, $errno, $errstr, $timeout);
    }
    print'<tr><td align="center"><strong>Server Status</strong></td></tr>';
    if($login) { print'<tr><td>Login:</td><td><font color="#00FF00"><strong> Online</strong></font><br><br></td></tr>'; }
    else { print'<tr><td>Login:</td><td><font color="#FF0000"><strong> Offline</strong></font><br><br></td></tr>'; }
    if($game) { print'<tr><td>Game:</td><td><font color="#00FF00"><strong> Online</strong></font></td></tr>'; }
    else { print'<tr><td>Game:</td><td"><font color="#FF0000"><strong> Offline</strong></td></tr>'; } 
?>
Ok u think that is easy but i don't even know from where i must start.Yes i am :newbie:
so can u help?And make a proper guide?
 
Junior Spellweaver
Joined
Jul 19, 2007
Messages
142
Reaction score
0
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

well theres not really much to say here... i can tell you what each line does but if you wanna learn html or php basics.. youre gonna need allot more than my guide..

<?php //start of a php tag.. you can insert it anywhere in the code
print'<table width="150">'; //print function is used to output something.. in this case a start of a table 150px wide
$server = "127.0.0.1"; //this is just few veriables defining the connection
$portg = "7777"; //game server port
$portl = "9014"; //login server port
$timeout = "5"; //timeout..

if ($server and $port and $timeout) { //if clouse checks if $server and $port and $timeout are true..
$game = @fsockopen("$server", $portg, $errno, $errstr, $timeout); //if connection exists the $game variable returns true
$login = @fsockopen("$server", $portl, $errno, $errstr, $timeout); //same for login..
}
print'<tr><td align="center"><strong>Server Status</strong></td></tr>'; //tr creates a row, td creates a column(align="center" aligns all content to the center), strong makes text thick... then you have to close each tags opened </strong></td></tr>

if($login) { print'<tr><td>Login:</td><td><font color="#00FF00"><strong> Online</strong></font><br><br></td></tr>'; } //if $login returns true print online...

else { print'<tr><td>Login:</td><td><font color="#FF0000"><strong> Offline</strong></font><br><br></td></tr>'; } // if $login returns false then.. else print offline
if($game) { print'<tr><td>Game:</td><td><font color="#00FF00"><strong> Online</strong></font></td></tr>'; } //same for game server
else { print'<tr><td>Game:</td><td"><font color="#FF0000"><strong> Offline</strong></td></tr>'; }
print'</table>'; ?> //close tag for table and end of the php code


if you want just the striped out code.. teh basics look at this..

<?php
$server = "127.0.0.1";
$portg = "7777";
$portl = "9014";
$timeout = "5";

if ($server and $port and $timeout) {
$game = @fsockopen("$server", $portg, $errno, $errstr, $timeout);
$login = @fsockopen("$server", $portl, $errno, $errstr, $timeout);
}

if($login) { print'Login: Online'; }
else { print'Login: Offline'; }

if($game) { print'Game: Online'; }
else { print'Game: Offline'; }
?>
 
Newbie Spellweaver
Joined
Jul 14, 2007
Messages
27
Reaction score
0
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

well theres not really much to say here... i can tell you what each line does but if you wanna learn html or php basics.. youre gonna need allot more than my guide..

<?php //start of a php tag.. you can insert it anywhere in the code
print'<table width="150">'; //print function is used to output something.. in this case a start of a table 150px wide
$server = "127.0.0.1"; //this is just few veriables defining the connection
$portg = "7777"; //game server port
$portl = "9014"; //login server port
$timeout = "5"; //timeout..

if ($server and $port and $timeout) { //if clouse checks if $server and $port and $timeout are true..
$game = @fsockopen("$server", $portg, $errno, $errstr, $timeout); //if connection exists the $game variable returns true
$login = @fsockopen("$server", $portl, $errno, $errstr, $timeout); //same for login..
}
print'<tr><td align="center"><strong>Server Status</strong></td></tr>'; //tr creates a row, td creates a column(align="center" aligns all content to the center), strong makes text thick... then you have to close each tags opened </strong></td></tr>

if($login) { print'<tr><td>Login:</td><td><font color="#00FF00"><strong> Online</strong></font><br><br></td></tr>'; } //if $login returns true print online...

else { print'<tr><td>Login:</td><td><font color="#FF0000"><strong> Offline</strong></font><br><br></td></tr>'; } // if $login returns false then.. else print offline
if($game) { print'<tr><td>Game:</td><td><font color="#00FF00"><strong> Online</strong></font></td></tr>'; } //same for game server
else { print'<tr><td>Game:</td><td"><font color="#FF0000"><strong> Offline</strong></td></tr>'; }
print'</table>'; ?> //close tag for table and end of the php code


if you want just the striped out code.. teh basics look at this..

<?php
$server = "127.0.0.1";
$portg = "7777";
$portl = "9014";
$timeout = "5";

if ($server and $port and $timeout) {
$game = @fsockopen("$server", $portg, $errno, $errstr, $timeout);
$login = @fsockopen("$server", $portl, $errno, $errstr, $timeout);
}

if($login) { print'Login: Online'; }
else { print'Login: Offline'; }

if($game) { print'Game: Online'; }
else { print'Game: Offline'; }
?>
Ok thanks but can u tell me how to set it to my site?
 
Junior Spellweaver
Joined
Jul 19, 2007
Messages
142
Reaction score
0
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

just paste it into your source...

you will need to have php supported hosting for the page..
 
Newbie Spellweaver
Joined
Jul 14, 2007
Messages
27
Reaction score
0
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

just paste it into your source...

you will need to have php supported hosting for the page..
I am using ucoz server.Does ucoz have supported php hosting?
 
Newbie Spellweaver
Joined
Aug 27, 2007
Messages
7
Reaction score
0
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

I tried your script of server status, but its always shows that game and login server is offline, but it is online, i made the IP, and port change but it says offline, i don't whats the problem.
 
The Cat in the Hat
Legend
Joined
Oct 26, 2005
Messages
4,475
Reaction score
677
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

I should have watched my mouth and not said/talked poop to DeadlyData telling him things like your are not welcome here because then I become the one who is truly not welcome here.
 

poa

Initiate Mage
Joined
Dec 7, 2007
Messages
1
Reaction score
0
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

Optimized mysql query and php :D
Code:
<?php
//first you need to define db info
  define('mySQL_hostname', 'host');  //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 `online` FROM `characters` where `online`=1");
//tells how much rows are there (will come helpfull with while loops)
   $rows = mysql_num_rows($chars);
    echo "Online players:<em>".$rows."<em>"; //prints out the $x number of players online
?>

Fixed PHP errors
Code:
<?php
$server = "localhost";
$portg = "7777";
$portl = "2106";
$timeout = "1";

$game = @fsockopen("$server", $portg, $errno, $errstr, $timeout);
$login = @fsockopen("$server", $portl, $errno, $errstr, $timeout);

	echo "Login: ";
	echo $login ? "<font color=\"green\">OnLine</font>" : "<font color=\"red\">Off line</font>";
	echo "<br>Game: ";
	echo $game ? "<font color=\"green\">OnLine</font>" : "<font color=\"red\">Off line</font>";
?>
Thanks!
 
Last edited:
Newbie Spellweaver
Joined
Aug 30, 2006
Messages
98
Reaction score
0
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

Hy nice share but one question why my status don't work? It says always offline even if my server IS online. :S This is with all status scripts i downloaded... Im using Vista ( please i don't want to hear, vista is bad etc... ) and im using as server pack:
L2oneo rev 1617.

Please someone help me,
Thanks Remco
 
Newbie Spellweaver
Joined
Dec 24, 2007
Messages
7
Reaction score
0
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

Hy nice share but one question why my status don't work? It says always offline even if my server IS online. :S This is with all status scripts i downloaded... Im using Vista ( please i don't want to hear, vista is bad etc... ) and im using as server pack:
L2oneo rev 1617.

Please someone help me,
Thanks Remco

Welll there is a problem with the php code i am writting to you what you have to write:

<?php
$server = "Host";
$portg = "7777";
$portl = "2106";
$timeout = "1";

$game = @fsockopen("$server", $portg, $errno, $errstr, $timeout);
$login = @fsockopen("$server", $portl, $errno, $errstr, $timeout);

print'<table width="150">';
if($login) { print'<tr><td>Login:</td><td><font color="#00FF00"><strong> Online</strong></font><br><br></td></tr>'; }
else { print'<tr><td>Login:</td><td><font color="#FF0000"><strong> Offline</strong></font><br><br></td></tr>'; }
if($game) { print'<tr><td>Game:</td><td><font color="#00FF00"><strong> Online</strong></font></td></tr>'; }
else { print'<tr><td>Game:</td><td><font color="#FF0000"><strong> Offline</strong></td></tr>'; }
print'</table>';
?>

If it does not work try change the site from html to php. I hope a helped.

From Lineage II Unknown Private Server
TopG@mer
 
Newbie Spellweaver
Joined
Dec 24, 2007
Messages
7
Reaction score
0
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

Online Players:

This script connects to the database(that means you need to have php connected to sql.. if you need any help with it try searching with google for apache php mysql install guides and i bet first link will work). Ive explained some of the code.. so learning from it should be easy..

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");

//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 "0" else "1"), 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
?>

when i set up this i get this error:

Code:
[B]Warning[/B]:  mysql_pconnect():  in [B]/mnt/w0602/d17/s23/b02c4150/www/vip/unknown/online.php[/B] on line [B]17[/B]
Error connecting to mysql
any idea anyone??

TopG@mer
 
Junior Spellweaver
Joined
Jul 19, 2007
Messages
142
Reaction score
0
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

well it tells you whats wrong.... it cant connect to your database so ether you dont have a php supported server with mysql extensions enabled.. or you entered wrong connection data..

try using just this snippet no matter if your file is .html or .php lol...
<?php
phpinfo();
?>

and if you get php, mysql.... info printed out then it works..
 
Newbie Spellweaver
Joined
Dec 24, 2007
Messages
7
Reaction score
0
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

I have navicat, how do i set up it to work for php???
 
Newbie Spellweaver
Joined
Dec 24, 2007
Messages
7
Reaction score
0
Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

sry i mean web server
 
Status
Not open for further replies.
Back
Top