+ Reply to Thread
Results 1 to 10 of 10

Thread: Count number of users online?

  1. #1
    apoorav's Avatar
    apoorav is offline x10 Sophmore apoorav is an unknown quantity at this point
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    110

    Lightbulb Count number of users online?

    How to count number of online users? plz give me the code to display number of online users and total users.

    THANKS in advance!!
    If you feel my post is usefull then click on to give me Reputation

  2. #2
    Awesomexr's Avatar
    Awesomexr is offline x10 Sophmore Awesomexr is an unknown quantity at this point
    Join Date
    Dec 2008
    Location
    haslam.pcriot.com
    Posts
    118

    Re: Count number of users online?

    http://sourceforge.net/projects/guri...3.zip/download

    This is a HTML/PHP piece of programming that displays how many users are online. There are additional features like displaying the countries and etc.
    Last edited by Awesomexr; 11-30-2009 at 02:19 PM.

  3. #3
    apoorav's Avatar
    apoorav is offline x10 Sophmore apoorav is an unknown quantity at this point
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    110

    Re: Count number of users online?

    Code is good but there are some configuration problems with database plz solve them
    If you feel my post is usefull then click on to give me Reputation

  4. #4
    miguelkp's Avatar
    miguelkp is offline x10 Lieutenant miguelkp is an unknown quantity at this point
    Join Date
    Oct 2009
    Location
    El Bierzo - Spain
    Posts
    302

    Re: Count number of users online?

    I use a prefab counter: Histats.com has a lot. You can choose a counter (they have a lot, diferent counters... I'm sure at least one will look fine with your website template). And then customize what info is going to be displayed.
    Clic on userbar to visit my band's website:

  5. #5
    apoorav's Avatar
    apoorav is offline x10 Sophmore apoorav is an unknown quantity at this point
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    110

    Re: Count number of users online?

    Quote Originally Posted by miguelkp View Post
    I use a prefab counter: Histats.com has a lot. You can choose a counter (they have a lot, diferent counters... I'm sure at least one will look fine with your website template). And then customize what info is going to be displayed.
    Thanks,but i want php code with full installation instructions
    If you feel my post is usefull then click on to give me Reputation

  6. #6
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: Count number of users online?

    This could be very simple..

    Each login creates a session (if you are using sessions i.e. you have session_start() at the top of the page)

    You could then just count the amount of active sessions.

    PHP Code:

    /* Define how long the maximum amount of time the session can be inactive. */ 
    define("MAX_IDLE_TIME"3); 

    function 
    countactiveusers(){ 

    if ( 
    $directory_handle opendirsession_save_path() ) ) { 
    $count 0
    while ( 
    false !== ( $file readdir$directory_handle ) ) ) { 
    if(
    $file != '.' && $file != '..'){ 
    // Comment the 'if(...){' and '}' lines if you get a significant amount of traffic 
    if(time()- fileatime(session_save_path() . '\\' $file) < MAX_IDLE_TIME 60) { 
    $count++; 


    closedir($directory_handle); 

    return 
    $count

    } else { 
    return 
    false




    echo 
    'Number of users online: ' countactiveusers() . '<br />'
    Simples!

    This method does not rely on using a database which is faster, but gets you no stats

  7. #7
    apoorav's Avatar
    apoorav is offline x10 Sophmore apoorav is an unknown quantity at this point
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    110

    Exclamation Re: Count number of users online?

    Quote Originally Posted by freecrm View Post
    This could be very simple..

    Each login creates a session (if you are using sessions i.e. you have session_start() at the top of the page)

    You could then just count the amount of active sessions.

    PHP Code:

    /* Define how long the maximum amount of time the session can be inactive. */ 
    define("MAX_IDLE_TIME"3); 

    function 
    countactiveusers(){ 

    if ( 
    $directory_handle opendirsession_save_path() ) ) { 
    $count 0
    while ( 
    false !== ( $file readdir$directory_handle ) ) ) { 
    if(
    $file != '.' && $file != '..'){ 
    // Comment the 'if(...){' and '}' lines if you get a significant amount of traffic 
    if(time()- fileatime(session_save_path() . '\\' $file) < MAX_IDLE_TIME 60) { 
    $count++; 


    closedir($directory_handle); 

    return 
    $count

    } else { 
    return 
    false




    echo 
    'Number of users online: ' countactiveusers() . '<br />'
    Simples!

    This method does not rely on using a database which is faster, but gets you no stats
    I want the script to count number of users online and of different country flags counter with full installation instructions with details according to X10hosting databse
    If you feel my post is usefull then click on to give me Reputation

  8. #8
    ChatIndia's Avatar
    ChatIndia is offline Community Advocate ChatIndia is on a distinguished road
    Join Date
    Sep 2009
    Location
    Exam Time. I won't tell you
    Posts
    1,320

    Re: Count number of users online?

    why you want to use your own database. I've seen many website which gives you the same service and that too without the need of any database in your site.
    Your appreciation is extremely Important. Click on the button at the bottom left corner of my post.

  9. #9
    xgreenberetx is offline x10Hosting Member xgreenberetx is an unknown quantity at this point
    Join Date
    Oct 2009
    Posts
    57

    Re: Count number of users online?

    The links for downloads are down, but you can easily find your own flag icons/images. Some of the script is outdated but you can get the main part and use trial and error for the rest.

    http://forums.tutorialized.com/php-9...line-3776.html

  10. #10
    connerty is offline x10Hosting Member connerty is an unknown quantity at this point
    Join Date
    May 2009
    Posts
    2

    Re: Count number of users online?

    Well really you need to create your own depending on your own circumstances. For instance where would you retrieve where the live? Via a database of your members or via the IP pool from wich they come from. All of these different solutions will work only for your circumstances. Also it is nice to be asked if it is okay for us to help you with a problem as apposed to be being told to fix it for you.

+ Reply to Thread

Similar Threads

  1. Earn Money Online
    By nbkt231092 in forum Earning Money
    Replies: 0
    Last Post: 08-28-2009, 01:52 AM
  2. What is billing account?
    By peyman in forum Free Hosting
    Replies: 34
    Last Post: 12-05-2006, 07:56 PM
  3. number of people online
    By apple19 in forum Feedback and Suggestions
    Replies: 11
    Last Post: 03-09-2006, 03:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers