Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12
  1. #11
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    Add another column to the Users tablE, call it "LastActivity" - Source talked about this.

    Everytime you check if the user is logged in, update that column with the "time()" function

    eg:

    PHP Code:
    mysql_query'UPDATE `Users` SET `LastActivity` = "' time() . '" WHERE `id` = "' $userID '" LIMIT 1;' ); 
    I do this when I check if the users logged in (exactly the same function name as Caleb uses ;o "checkLogin()")

    Now to get all the users who are logged in:

    PHP Code:
    <?php
    $mysqlUsers 
    mysql_query'SELECT * FROM `Users`' ) or die( 'Die' );

    if( 
    mysql_num_rows$mysqlUsers ) >= )
    {
        
    $loggedIn;
        
        while( 
    $r mysql_fetch_array$mysqlUsers ) )
        {
            
    $timeOut 60 30// 30 Minutes (Timeout)
            
            // Below is checking the time difference between their last inactivity and now, then checking it against 30mins ($timeOut )
            
            
    if( ( $r'LastActivity' ] - time() ) <= $timeOut )
            {
                
    $loggedIn .= $r'UserName' ] . ' ';
                
    // ^^ Add to the list of loggedIn users.
            
    }
            
        }
        
        echo 
    $loggedIn;
    }

    ?>
    Thats a basic timeout for you. I use that to log the user out if they been inactive too long too.
    Last edited by Protege; 22-10-2008 at 05:54 PM.
    Hi, names James. I am a web developer.

  2. #12

    Default

    Thank you everyone for your help. I do understand what you're all saying, and I have created the table w/ the timestamp in my database. I added those codes to my config page, but for some reason it's not updating the database at all. I think if it was updating it, the other PHP code that Protege gave me would work. Could anyone maybe help me with the first mysql entry to have it actually send the last activity to the db?

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •