CGI Counter Needs Debugging
by Jason <dawgclan(at)shaw.ca>
|
Date: |
Fri, 05 Apr 2002 14:31:37 -0800 |
To: |
Website Help List <hwg-techniques(at)hwg.org> |
In-Reply-To: |
|
|
todo: View
Thread,
Original
|
|
Hmm ok Thanks, I just logged into my Webserver and found something real
odd.
It has made a Directory called
\home\dawgclan\public_html\counter\cgi\counter.pl\
And 2 files called
\home\dawgclan\public_html\counter\cgi\counter.pl\count.txt
\home\dawgclan\public_html\counter\cgi\counter.pl\iplog.txt
heheh It's not going to the directory and making the file called
iplog.txt it's making the file called the whole thing.
I'll try the shtml file but it looks like it is executing because the
\home\dawgclan\public_html\counter\cgi\counter.pl\count.txt has 7 in it
and iplog has about 7 ip's
Jason
-----Original Message-----
From: Kenneth Dombrowski
[mailto:kenneth.dombrowski(at)designmattersinc.com]
Sent: April 5, 2002 1:04 PM
To: dawgclan(at)shaw.ca
Subject: FW: CGI Counter
Also, I just realized, line 48:
$pathtocounter =~ s/\//\\/g;
Should be commented out for your *nix server
That was there for my nt server
-----Original Message-----
From: Kenneth Dombrowski
[mailto:kenneth.dombrowski(at)designmattersinc.com]
Sent: Friday, April 05, 2002 11:05 AM
To: 'Jason'
Subject: RE: CGI Counter
What server are you running? Apache? Try a .shtml extension
The script is never being called. Look at the source of the page, the
#exec cgi is still there
Web servers have to be configured to scan pages for processing commands,
most of them leave .html files alone and just assume they can serve them
up as they are. This is to save on the performance hit of reading every
file before returning it
-----Original Message-----
From: owner-hwg-techniques(at)hwg.org [mailto:owner-hwg-techniques(at)hwg.org]
On Behalf Of Jason
Sent: Thursday, April 04, 2002 7:12 PM
To: Website Help List
Subject: RE: CGI Counter
Hmmmm Thanks for the Script Kenneth but It's not working.
http://dawgclan.vectorstar.net/test.html contains just the Exec CGI
counter and nothing else on page, and it's not running. And would anyone
know how to store all the I.P's in a database? I would really like to do
that, I was talking to a teacher at school today and that's what he
suggested, and it makes for quicker read time. And 1 file. Sounds good
to me. If anyone can help please speak up. Here is the New Counter
Source. http://dawgclan.vectorstar.net/cgi/newcounter.txt
Here is the Perl Script http://dawgclan.vectorstar.net/cgi/counter.pl
Thanks
Jason
-----Original Message-----
From: Kenneth Dombrowski [mailto:printer2(at)designmattersinc.com]
Sent: April 4, 2002 2:28 PM
To: 'Jason'
Subject: RE: CGI Counter
Jason,
Sorry it took so long to get back to you, a busy day @ work..
The attached script is a revised version of yours.
In addition to what you asked for, the script now creates separate
counters for each page you put it on, I assumed this was desirable
behavior.
I also assumed you are including the output onto your page via the #exec
cgi syntax.
It updates only once per IP per page. An added bonus is you get a log of
all the ips visiting each page. This isn't managed in a very
conservative way, however, it's going to store every ip for every page;
16 bytes per page per ip... When disk space becomes an issue you'll save
some space if you put them in a central file & reference them in the
page-specific files by line number
Or set the whole thing up to use berkeley db or something similar
The script dies early if the page accessing it does not live on a server
configured in @legal_servers; One of the first things you'll probably
want to do is change line 24 '255.255.255.255' to your server's ip.
I don't think any other config will be necessary.
If you're using this on a heavily trafficed site, I would suggest you
read about locking with semaphore files:
http://perl.plover.com/yak/hw1/Hardware-notes.html#Semaphore_Files
Also, one possible glaring weakness is line 52. I'm not sure what
happens if mkdir is called and the path to the directory includes other
directories that have not been made... Maybe it's okay, maybe it'll
fail. You can either read up on it & fix it if necessary, or be careful
that the required directories exist manually... If you do end up
updating it, I'd be interested in seeing it
I Hope it works for you,
Kenneth
-----Original Message-----
From: owner-hwg-techniques(at)hwg.org [mailto:owner-hwg-techniques(at)hwg.org]
On Behalf Of Jason
Sent: Wednesday, April 03, 2002 6:44 PM
To: Website Help List
Subject: CGI Counter
Sorry about that here is the cgi source.
http://dawgclan.vectorstar.net/cgi/counter.txt
and the real script is http://dawgclan.vectorstar.net/cgi/counter.cgi
I would like to make it log once per I.P and also make it usable only on
my domain. Thanks Jason _________________________________________
Jason
Dawgclan Network
ICQ#: 48569749
Website: http://dawgclan.vectorstar.net
_________________________________________
HWG hwg-techniques mailing list archives,
maintained by Webmasters @ IWA