Closed Thread Icon

Topic awaiting preservation: PHP Who's Online... (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12567" title="Pages that link to Topic awaiting preservation: PHP Who&amp;#039;s Online... (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: PHP Who&#039;s Online... <span class="small">(Page 1 of 1)</span>\

 
readonlynet
Obsessive-Compulsive (I) Inmate

From: Connecticut
Insane since: Jan 2003

posted posted 01-05-2003 00:20

Hi, im new to this forum. I was wondering, how would I go about making a PHP Flat file type Visitors / Members online script? I know how to get total visitors by just counting how many sessions there are in the session_save_path(). But how can I make it count active members? Ive seen it done with MySQL, but havent seen it done with Flat file. So if anyone knows how i can do this, it would be very much appreciated to point me to the correct direction. Thanks

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 01-05-2003 18:34

Hmm shouldn't be that hard, I've seen these scripts in action but never done one personally though.

Do you have an example of how one works with MySQL? converting to a flat file type should be pretty basic



.:[ Never resist a perfect moment ]:.

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 01-05-2003 19:52

readonlynet: I'm not sure what you are after but counting the number of sessions should give you the number of active users. See this page (and the one it links to):
http://www.webkreator.com/php/concepts/counting-users-online-with-php.html

I saw a great script on a German site a couple of years back which told you how many users where in each section of your site and on each page but I can't seem to find it but I'm still looking

[edit: Hmmmmmm no luck yet - I thought I was close but........ Anyway have a look at this (as bitdamaged said if you can find an DB based one then changing it to flat file should be relatively straightforward):
www.coopercentral.org/scripts.php?id=5
www.hotscripts.com/PHP/Scripts_and_Programs/Counters/Real-Time/

hmmm this seems to use a flat file:
www.phponline.biz/usersonline/

lets us know what you find and which you end up using]

___________________
Emps

FAQs: Emperor

readonlynet
Obsessive-Compulsive (I) Inmate

From: Connecticut
Insane since: Jan 2003

posted posted 01-06-2003 03:39

those sites seem pretty much like what i have been finding. I have a script already that can find how many people are currently at the site. But i want it so when a user logs in, it records the person and when the person is idleing or exits his browser, it will delete him from the file. So this way i can make it say something like, "Currently XX visitors and XX members are online."

ill try to make one by just reading MySQL Version one. If you want to see one:

http://www.evilwalrus.com/viewcode/264.php - Found at Evilwalrus.com


thanks for all your help so far. Its been very helpful.

readonlynet
Obsessive-Compulsive (I) Inmate

From: Connecticut
Insane since: Jan 2003

posted posted 01-06-2003 03:58

After reading that example that I just posted, im getting more sence of how it works. The script checks if you have a cookie ( in this case i do ), and then it adds you to the database. If you dont have a cookie, it writes it to the database saying your a guest. Then you use if then to see if $user is not equal to guest and adds 1 to the members variable. Else, Adds 1 to the guests variable.

Now that i have more sence of how its operated, im going to try it tomorrow. Its 10:00PM here right now and im tired. heh. So after I attempt it again, I will post my results. Thanks!

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 01-06-2003 04:30

Here's how I do it via MySQL - you should be able to convert to flat file easily:

// users online
$uol_timeoutseconds = 300;
$uol_timestamp = time();
$uol_timeout = $uol_timestamp-$uol_timeoutseconds;
$uol_sql = "INSERT INTO useronline VALUES ('$uol_timestamp','$REMOTE_ADDR','$PHP_SELF')";
$uol_result = @mysql_query($uol_sql);
$uol_sql = "DELETE FROM useronline WHERE timestamp<$uol_timeout";
$uol_result = @mysql_query($uol_sql);
$uol_sql = "SELECT DISTINCT ip FROM useronline";
$uol_result = @mysql_query($uol_sql);
$uol_user = mysql_num_rows($uol_result);

by using the $PHP_SELF, you could look for users on the same page.

readonlynet
Obsessive-Compulsive (I) Inmate

From: Connecticut
Insane since: Jan 2003

posted posted 01-06-2003 14:43

Thanks for that code, seems to be a very good simple one. I will try to turn it into flat file. Thats a good idea too with the $PHP_SELF. Thanks.

readonlynet
Obsessive-Compulsive (I) Inmate

From: Connecticut
Insane since: Jan 2003

posted posted 01-11-2003 03:24

Complete! Finally, i have did it. It took me a while. The problem i had was deleting the members thats not active in 5 minutes. so then i learned a different way of deleting in flat file by using arrays with unset();

The script i made shows something like this:

"Currently browsing: 1 in total, 0 quest(s) and 1 member(s).
Members: brian"

Im not going to submit the code because knowing its using flat file, theres a lot of coding. Once i get to working on my site again, i will add it to my PHP Scripts section in experimental. So, thank you all for your help. If you would like to recieve the script to see how its done.. i will glady email you it.

abb
Bipolar (III) Inmate

From: Victoria, BC
Insane since: Mar 2002

posted posted 01-16-2003 18:21

yes please, email it to me...
a-bb@gmx.net

thanks!

Andrew

« BackwardsOnwards »

Show Forum Drop Down Menu