PHP Status/Acc creation/Online players Scripts

Page 1 of 5 12345 LastLast
Results 1 to 15 of 68
  1. #1
    Proficient Member vvizzi is offline
    MemberRank
    Jul 2007 Join Date
    LocatedLocation
    151Posts

    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..

    PHP 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>'; }     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 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 {      $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>
    Code:
    
    

    Online Players:

    PHP Code:
    //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 DaRkAnGeL; 21-09-13 at 12:08 AM. Reason: improve php code for getting online players


  2. #2
    ~ksemer~ DaRkAnGeL is offline
    MemberRank
    Oct 2006 Join Date
    Java_HomeLocation
    5,115Posts

    Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

    nice try m8 :)

  3. #3
    Member Lib3rty is offline
    MemberRank
    Dec 2005 Join Date
    VenezuelaLocation
    89Posts

    Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

    Thx 4 share =)

  4. #4
    Proficient Member fabrrp is offline
    MemberRank
    Oct 2005 Join Date
    BrazilLocation
    197Posts

    Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

    very useful share/guide
    i will test

  5. #5
    Apprentice Slekys14 is offline
    MemberRank
    Feb 2006 Join Date
    10Posts

    Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

    [QUOTE=vvizzi;2807340]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

  6. #6
    Proficient Member vvizzi is offline
    MemberRank
    Jul 2007 Join Date
    LocatedLocation
    151Posts

    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 ^^

  7. #7
    Enthusiast fakoykas is offline
    MemberRank
    Jul 2007 Join Date
    28Posts

    Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

    Quote Originally Posted by vvizzi View Post
    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?

  8. #8
    Proficient Member vvizzi is offline
    MemberRank
    Jul 2007 Join Date
    LocatedLocation
    151Posts

    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'; }
    ?>

  9. #9
    Enthusiast fakoykas is offline
    MemberRank
    Jul 2007 Join Date
    28Posts

    Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

    Quote Originally Posted by vvizzi View Post
    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?

  10. #10
    Proficient Member vvizzi is offline
    MemberRank
    Jul 2007 Join Date
    LocatedLocation
    151Posts

    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..

  11. #11
    Enthusiast fakoykas is offline
    MemberRank
    Jul 2007 Join Date
    28Posts

    Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

    Quote Originally Posted by vvizzi View Post
    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?

  12. #12
    Apprentice hunskull is offline
    MemberRank
    Aug 2007 Join Date
    7Posts

    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.

  13. #13
    The Cat in the Hat cypher is offline
    MemberRank
    Oct 2005 Join Date
    IrelandLocation
    5,073Posts

    Re: [Share/Guide]PHP Status/Acc creation/Online players Scripts

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

  14. #14
    Novice poa is offline
    MemberRank
    Dec 2007 Join Date
    1Posts

    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 by poa; 18-12-07 at 09:22 PM. Reason: Two codes ok ;)

  15. #15
    Valued Member Remcolineage is offline
    MemberRank
    Aug 2006 Join Date
    NetherlandsLocation
    104Posts

    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



Page 1 of 5 12345 LastLast

Advertisement