SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Online/ofline status check

    For a forum I am lookng for a simple but accurate online/offline check functionality so users can see which user is online or offline. Are there some ready mad scripts or does anyone know of a good tutorial to accomplish this?

    Thank you in advance!
    “Good artists copy, great artists steal” (Pablo Picasso - 1934)

  2. #2
    SitePoint Enthusiast volter9's Avatar
    Join Date
    Jun 2014
    Location
    United States, CA
    Posts
    63
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Which type of forum do you have? Some kind of phpBB or custom one that you wrote yourself?
    And do you want to make it dynamic (JS) or just static render of on/off line users?

  3. #3
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by volter9 View Post
    Which type of forum do you have? Some kind of phpBB or custom one that you wrote yourself?
    And do you want to make it dynamic (JS) or just static render of on/off line users?
    It is custom. And i would like to have it with js zo dynamic. I have been searchin for quite some tiime
    “Good artists copy, great artists steal” (Pablo Picasso - 1934)

  4. #4
    SitePoint Enthusiast volter9's Avatar
    Join Date
    Jun 2014
    Location
    United States, CA
    Posts
    63
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It's quite easy to realize, all you need is to create another two fields in table with users: online (tinyint) and last_online (timestamp).
    Each time (or each second time) user enters on the page you update the last_online to now() and set online to 1, like that:

    Code:
    UPDATE users SET last_online = NOW(), online = 1 WHERE id = $user_id
    And execute another SQL statement to put offline users who are not online:

    Code:
    UPDATE users SET online = 0 WHERE online = 1 AND last_online < NOW() - 120
    Where 120 is amount of seconds you want to put users in offline mode.

    Then you can select users by online field. However I don't understand where do you want to display this data. Reply please.

    users can see which user is online or offline
    Do you want it display in bottom of main page on forum, or you have some kind of popup with info about user, or you want to display data on user's page or even in the topic section?

  5. #5
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by volter9 View Post
    Do you want it display in bottom of main page on forum, or you have some kind of popup with info about user, or you want to display data on user's page or even in the topic section?
    Thank you again for the reply. Very very helpful. Gonna work on it right away!

    About the above question. I just want a online or offline icon next to their profile
    “Good artists copy, great artists steal” (Pablo Picasso - 1934)

  6. #6
    Grüße aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    It seems volter9 already gave you your answer, but I just wanted to give Offline.js (a library to automatically alert your users when they've lost internet connectivity) a mention.

  7. #7
    SitePoint Wizard donboe's Avatar
    Join Date
    Jun 2010
    Location
    Netherlands
    Posts
    2,106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes he indeed did Pullo. Thank you anyway for the tip about Offline.js. I am going to look into that
    “Good artists copy, great artists steal” (Pablo Picasso - 1934)


Bookmarks

Posting Permissions

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