PHP Status/Acc creation/Online players Scripts

Page 5 of 5 FirstFirst 12345
Results 61 to 68 of 68
  1. #61
    Apprentice liamxroy is offline
    MemberRank
    Jan 2007 Join Date
    GreeceLocation
    23Posts

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

    //selects desired table
    $chars=mysql_query("SELECT * FROM characters");

    hahahahahaha
    and what if my db has 50k characters ?

    //selects ONLY ONLINE PLAYERS
    $chars=mysql_query("SELECT * FROM characters where online='1'");



    Edit : Rockkth check this out
    http://status.blackout-gaming.net/
    Last edited by liamxroy; 28-08-09 at 12:47 PM.

  2. #62
    Valued Member Phoenixal is offline
    MemberRank
    Feb 2007 Join Date
    114Posts

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

    Well done.....^^

    thanks for your scripts guys^^ especially the optimized ones helped me ;)

    Quote Originally Posted by rockkth View Post
    ok, i m going nuts,

    i have online players scripts, raid boss map, clan SCRIPTS WORKING all.

    but the server status script just shows the server offline!

    any ideas why the hell? my server supports mysql, php and so on.

    .......
    ?> [/code]
    and for you:

    Code:
    <html>
       <head></head>
         <body>
            <div class="sstatus">
            <h1>Serverstatus</h1>
            <div>
            <table><br/>
            <?php
                $server = "your.ip.address";
                $portg = "7777";
                $portl = "2106";
                $timeout = "1";
                $portm = "3306";
                
                $mysql = @fsockopen("$server", $portm, $errno, $errstr, $timeout);
                $game = @fsockopen("$server", $portg, $errno, $errstr, $timeout);
                $login = @fsockopen("$server", $portl, $errno, $errstr, $timeout);
    
                    echo "<tr><td><font color='#8D875C'>LoginServer: </font></td>";
                    echo $login ? "<td><img src='images/on1.png'>'</td>" : "<td><img src='images/off1.png'></td></tr>";
                    echo "<tr><td><font color='#8D875C'>GameServer: </font></td>";
                    echo $game ? "<td><img src='images/on1.png'></td>" : "<td><img src='images/off1.png'></td></tr>";
                    echo "<tr><td><font color='#8D875C'>Datenbank: </font></td>";
                    echo $mysql ? "<td><img src='images/on1.png'>'</td>" : "<td><img src='images/off1.png'></td></tr>";
            ?>
            </table>
            </div>
           </div>
         </body>
    </html>
    .....that should help....works without problems
    (try to run it in a seperate .php file the first time)


    and oh sry^^ i made it with pictures(online/offline)....just replace the "<img src=...>" strings with online/offline texts ;)

  3. #63
    Novice Twixus is offline
    MemberRank
    Mar 2010 Join Date
    4Posts

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

    Hello Community

    First im sorry fpr my bad english :D

    I have a Problem with the acc creater script...
    I will create a new account but mysql send a error

    here the error

    Code:
    Incorrect UserIDAccount Created
    
    Enjoy youre gameplay.
    Warning: mysql_close(): no MySQL-Link resource supplied in /mnt/web1/20/33/52222133/htdocs/l2/acc.php on line 29
    I Aks me why Incorrect UserId but Account createt??

    can any people help me pls?

  4. #64
    Novice dzeraldas is offline
    MemberRank
    Mar 2010 Join Date
    1Posts

    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 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>'; } 
        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
    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>
    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
    ?>
    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 :)
    can u help me to do this whit ucoz becuz its dont work and i dont know what to do

  5. #65
    Novice Twixus is offline
    MemberRank
    Mar 2010 Join Date
    4Posts

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

    Quote Originally Posted by Twixus View Post
    Hello Community

    First im sorry fpr my bad english :D

    I have a Problem with the acc creater script...
    I will create a new account but mysql send a error

    here the error

    Code:
    Incorrect UserIDAccount Created
    
    Enjoy youre gameplay.
    Warning: mysql_close(): no MySQL-Link resource supplied in /mnt/web1/20/33/52222133/htdocs/l2/acc.php on line 29
    I Aks me why Incorrect UserId but Account createt??

    can any people help me pls?
    Can now any people helm me? It“s very big Problem -.-

  6. #66
    Novice Dorin Grigore is offline
    MemberRank
    Sep 2013 Join Date
    1Posts

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

    Ok basically I registered just to correct the online counter script, it hurts me to see it how it is and sorry for old topic but i got on this topic from google so surely it would get some people wrong.

    Basically the script on the first post loads ALL THE CHARACTERS AND ITERATE THROUGH THEM. That is not good at all performance wise. The right script is this:

    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
    If someone could change this on the first topic would be great

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

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

    Quote Originally Posted by Dorin Grigore View Post
    Ok basically I registered just to correct the online counter script, it hurts me to see it how it is and sorry for old topic but i got on this topic from google so surely it would get some people wrong.

    Basically the script on the first post loads ALL THE CHARACTERS AND ITERATE THROUGH THEM. That is not good at all performance wise. The right script is this:

    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
    If someone could change this on the first topic would be great
    yes you are right. I will update the first post. Thanks ;)

  8. #68
    Novice kmixzi159 is offline
    MemberRank
    Mar 2014 Join Date
    Bangkok, ThailaLocation
    1Posts

    Re: PHP Status/Acc creation/Online players Scripts

    thank you :)



Page 5 of 5 FirstFirst 12345

Advertisement