LAST EDITED ON Apr-15-12 AT 07:20 AM (CST)
Hi Len,
regarding comment #30 above, I've been looking into this and believe it can be done, however, I forsee problems that need to be addressed.When a new user registers, his ip gets recorded into the reg file. If the new user is going through a ISP, most likely the ISP will assign a dynamic ip address and what you may be recording into the reg file is only one ip address of a possible many ip address for this user. I may be wrong in this thinking and please correct me.
The usersonline.pl is called from your dispcat.pl (which ever version you are using) and records the ip address (12.452.3.112) into the usersonline.txt with a time stamp like this:
1332561284/12.452.3.112 The incomming ip is captured with this line:$ip = $ENV{'REMOTE_ADDR'};
All visitors and members gets this kind of recording into the temporary usersonline.txt. This file gets opened every time the dispcat is run and checks the time stamp of each line item and removes the line after a certain time of inactivity so as not to clutter your usersonline.txt file.
Now, when you look at the visitor counter on the mainpage site stats, you may see visitors(15).
ONE of those visitors is YOU as admin looking at your own site.
Some maybe members who may have logged on or not.
Some maybe visitors.
How to filter the members from visitors I guess is now the question.
I have been keeping a permanent record of ALL incomming ip's in a separate file and after awhile, I have seen a series of ip's that belong to me comming from my ISP. I use http://whatismyipaddress.com to get ip details.
After several months of recording I could see that my ip's would be grouped in to blocks.
The blocks of ips would look something like this:
xxx.58.12.15 - xxx.58.12.250
xx.2.32.1 - xx.2.33.9
etc
The first thing I did was to write a short script using these blocks of ip's to bypass the recording into usersonline.txt, this way I knew that I was not in the count of visitors.
The script I used was:
if($ip ge "110.58.12.15" && $ip le "110.58.12.250"){goto END;}
NOTE: at the very end of usersonline.pl just above the 1; I added the lable END:
Now that I am not counted, the next step is to separate the visitors from the members.
I don't think I have come across a file with just the names of members or members' ip's in it who are logged on. (I could be wrong) If such a file exsisted you could just subtract the visitor count from this file and end up with pure visitors.
So now the site stats would be:
Members online(3)
Visitors online(11)
----------- =(14) because you as admin are not counted now.
Assuming that such a file does not exsist then here comes the theoretical part.
In the config.pl sub setlogin subroutine (where only members log in), a line needs to be added to a new file that saves $alias.
example:
open(FILE, ">> $basepath/membersonly.dat");
flock(FILE, 2);
print FILE "$alias\n";
flock(FILE, 8);
close(FILE);
This would get all the logged in members in to one appending(continously being added to) file.
To read this file your would do this:
open(FILE, "$config{'basepath'}/membersonly.dat");
@members = <FILE>;
close(FILE);
my $membercount = scalar(@members);
Now when usersonline.pl reads the usersonline.txt with this:
open(FILE1,"...path/auction/usersonline.txt");
my @userdata = <FILE1>;
close(FILE1);
add after close(FILE1);
my $usercount = scalar(@userdata);
and now your can print the 2 lines for the site stats as:
print "Members online($membercount);
print "Visitors online($usercount-$membercount);
of course every time a member would log off, your would have to remove him from the membersonly.dat file.
The above is theorectical off the top of my head, but the concept I believe is sound. Maybe recording the cookie into the file is better?
Maybe someone with more tech knowledge can add something.
Regards,
Moneysav