Gossamer Forum
Home : Products : DBMan : Customization :

"Who's Online", like the option for this Forum

Quote Reply
"Who's Online", like the option for this Forum
I would like to know how I would go about adding a "Who's Online" option for DBMan. I have a membership database and would like to give my members the option to see what other members are online. It's like the "Who's Online" Option for this forum...

Thanks ahead of time.

Quote Reply
Re: "Who's Online", like the option for this Forum In reply to
There's a couple of ways to go with this.

The forum actually lists the users who did something within the last 10 minutes. I suppose it would be possible to do that. It would require saving something like the .log file, with fields of username, action and time. At the same time, it would have to go through every line in the file and delete the ones that are more than 10 minutes old. When someone selected "Who's Online," that file would be accessed.

The other option is to create a "true" logoff. The basic DBMan just goes to another web page when a user selects "Log off." You can make the script delete the session file at the time of log off. Then, when someone selected "Who's Online," it would access the auth directory and give a list of the users who had current session files.

Which do you want? What do you want the "Who's Online" page to include?


JPD
Quote Reply
Re: "Who's Online", like the option for this Forum In reply to
Keep in mind that the more efficient method is to use MySQL or another structured datbase storage program (like ODBC-DSN, MSQL, etc.). This type of Modification would be better suited for DBMAN SQL. Using a flat file log system is possible, but not efficient in terms of CPU and bandwidth.

BTW: There are a couple Mods for LINKS SQL that does this...

Regards,

Eliot Lee
Quote Reply
Re: "Who's Online", like the option for this Forum In reply to
Of course the best way would be the one which is most efficient and less time consuming. But the way I would probably do it is the second option, for it gives more accurate results.

The who's online page would return a listing of who's on the web at that certain time. It would return just information as their username, age, location, and gender. Like similar sites to my own, it would then allow me to know who i could send an instant message to.

Thanks

Quote Reply
Re: "Who's Online", like the option for this Forum In reply to
The only problem with using the second option is that people don't always log off. The could be shown to be on the site for up to 6 hours after they have left it, depending on your setting in the .cfg file.

To create a true logoff is very simple. In db.cgi, change

elsif ($in{'logoff'}) { &auth_logging('logged off') if ($auth_logging);

to

elsif ($in{'logoff'}) { unlink ("$auth_dir/$db_uid"); &auth_logging('logged off') if ($auth_logging);

Creating the "Who's Online" page will take a little more time. I'd like to get through the new messages before I go to sleep, so I'll have to do it later.


JPD
Quote Reply
Re: "Who's Online", like the option for this Forum In reply to
If you set the amount of time in the .cfg file to for example 20 minutes, the user will be logged of after 20 minutes whether or not he is still active?, right? What you would like for the above to be perfect is the time stated in .cfg to start all over every time the user does something within the DB. Is that possible (or maybe its allready like that...)??

Quote Reply
Re: "Who's Online", like the option for this Forum In reply to
No, it isn't already like that.

I don't know if this would work, but you could try adding

Code:

open(AUTH, ">$auth_dir/$db_uid") or &cgierr("unable to open auth file: $auth_dir/$uid. Reason: $!\n");
print AUTH "$uid: $ENV{'REMOTE_HOST'}\n";
close AUTH;
to auth.pl, sub auth_logging. I think that it would just write over the file that already exists, which would update the stat function.

You would have to be sure that you had set $auth_logging = 1; in your .cfg file.

Also, be aware that searches are not logged, so the above would not be executed if someone just did a search. I suppose you could log searches, though.


JPD
Quote Reply
Re: "Who's Online", like the option for this Forum In reply to
I'm also really looking forward to have a Who's Online mod. That would be really wonderful...

Quote Reply
Re: "Who's Online", like the option for this Forum In reply to
It would be great if I could get some help with this.

I would appreciate it if someone would do the following:

Set $auth_time = 600 in your .cfg file.

Set $auth_logging = 1;

Add the code from a couple of posts above to sub auth_logging.

Log into your database and add, delete and modify some records. Twelve minutes after you have logged in, stop making changes and wait two minutes. Then try to do something else. See if you get an "invalid/expired user session" message. If you don't, then my code is working correctly.

I need to know if rewriting the session file will reset the stat function of the file.

After you do the test, be sure to set your $auth_time variable back to where it was.


JPD
Quote Reply
Re: "Who's Online", like the option for this Forum In reply to
Hi all...
Have anyone done the above testing??

:)

Quote Reply
Re: "Who's Online", like the option for this Forum In reply to
Frankly, I'm beginning to feel like The Little Red Hen here.

"Who will help me bake the bread?" asked the little red hen.

"Not I," said the duck.

"Not I," said the cow.

"Not I," said the goose.

...

"Who will help me eat the bread?" asked the little red hen.

"I will," said the duck.

"I will," said the cow.

"I will," said the goose.



JPD
Quote Reply
Re: "Who's Online", like the option for this Forum In reply to
Hi JPDeni,

I have tried what you said above. The result was after i did something after 2 minutes,i would go to the login_failure page.

Thanks
:)

Quote Reply
Re: "Who's Online", like the option for this Forum In reply to
Hmmmm. Well, I guess my idea didn't work. I'll see what else I can figure out.


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: "Who's Online", like the option for this Forum In reply to
Hi JPDeni,

Have you found out the other way to do the who's online mod?

I would really appreicate to do any testing with you.

:)

Quote Reply
Re: "Who's Online", like the option for this Forum In reply to
Not as yet. I'm working on some other things right now.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: "Who's Online", like the option for this Forum In reply to
Thanks for your reply, JPDeni

I look forward to hearing any news from you

:)

Quote Reply
Re: "Who's Online", like the option for this Forum In reply to
The "Who's Online" mod is now written and available at http://www.jpdeni.com/...Mods/whos_online.txt.


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: "Who's Online", like the option for this Forum In reply to
JP,
I tried it out and didn't work... I'm really in need for this type of modification in order to "refresh" user's $db_uid file.

Please help. I need a way to keep a user from getting autodeleted in the amount of time set by my $auth_time field while they are in a part of my site that does not call my db.cgi, therefor does not "refresh" their $db_uid file in my auth directory. Any ideas on how I can do this?

Thanks in advance for any help you can give =)

~CygnusX1