Link to home
Start Free TrialLog in
Avatar of eversoslightly
eversoslightly

asked on

Free CGI script?? (Tracker)

Anyone know where I can find a good CGI script that tracks hits?  (Not just a counter, but a tracker, that would tell domain names, etc.).  This tracker needs to have support for separate accounts, and the stats need to be separated (not just in one file).  Thanks!
Avatar of happy1
happy1

Hi,
does your site support SSI?
If yes, give me please, temporarly access to your site (login-password)
and I will try to install one for you. I'm using that for myself, it's freeware.
I'm offering that because I know about your problems with CGI:)

Regards, Happy®One
Contact me: yanki@goplay.com
Avatar of eversoslightly

ASKER

Yep... I do have SSI
Thanks a lot, but I wouldn't feel comfortable doing that.
If you could though, you could e-mail me the script.
That would be helpful!
Thanks a lot!
-Ever-So
everso@bstar.net
OK, check this script (Roblog 4.02) -
http://tdi.uregina.ca/~eislerr/cgi/roblog/index.html
Happy®One
Well, at the moment, I'm getting the error:

HTTP Proxy reports :
The proxy server has encountered an error (Connection refused).

just trying to log into that site... I'll try again later today.  The question is still open for other people's suggestions!
Well, I checked out that site.  That script doesn't support multiple accounts unless you make multiple copies of the script - which is not what I want.  I've seen quite a few scripts like this one.  Thanks anyways!

Anyone else found one?

-Ever-So
Why not write your own ssi script!

You will need to create a simple database with int CLICKS and char *HOSTNAME
you can know what host the come from with the following C instruction.

getenv("REMOTE_HOST");  // You are reading the value of the REMOTE_HOST ambient variable.

If you need help please contact me!
jconde@securities.com


Well, I really don't know how to write in CGI... if you would be willing to write some simple code that would work and would be acceptable to me, I would raise the points to 150, and give you an A.

Thanks,
Ever-So
Idealy, I'd like it to have most of the functions that Nedstat has. ( http://usa.nedstat.net/cgi-bin/viewstat?name=everso ).  Referer isn't neccessary, but would be nice.
-Ever-So
What operating system are you using Ever So?
My server is running Unix.
Yes here is the URL  ..i use these people and they're GREAT!!!
 http://www.extreme-dm.com/tracking
Sorry, I know about that, but thats not exactly what I want - I want a CGI script for -My- server - I don't want someone else to host it.  Thanks anyways!
Avatar of moonlight
I could give you my own cgi script for unix (perl script)
but I have made it for just one page. You would need to alter it a little for several pages. I actually need to expand it myself to work with several pages but it would take some time. Meanwhile you could always just copy the script several times, and give each a unique name. This would give you one script, and one logfile for every page. Tell me if you want MY script.
Well, as I've said before, I want a script that will be able to have multiple accounts, although, I do not want to have multiple copies of the script.  Seeing as I do not know how to use CGI and perl, and such, I would not know how to edit the script.  If you would be willing to fix your script up so it can have unlimited accounts, I would raise the points to 150 and give you an A.  (As long, as I stated above, that it had many of the same features as nedstat).

Thank-you much for all your help!

-Ever-So.
ASKER CERTIFIED SOLUTION
Avatar of mikegrb
mikegrb

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ooops just noticed the multiple accounts part... let me tweek it a little....
Make the beggining look like this (up to the lock check):

#!/usr/bin/perl

$confile = '/var/lib/httpd/data/config';

$acnt = $ARGV[0];

open(CNFG, $confile) || &CDie("Can't open conf file: $!");
IT: while($line = <CNFG>) {
      chop($line);
      if($line =~ /^$acnt\|:\|(.*?)$/) { $logfile = $1; last IT }
}

unless($logfile) &CDie("Undefined Account");

if(-e "$logfile.lock") {
      sleep 1;
}
----------------
Now make you config file look like
<account id>|:|<log file>
one per line and execute it like this:
<!--#exec cmd="/var/lib/httpd/cgi-bin/logger <account id>" -->
it will place a text counter on the page and log the time, date,
remote host, remote ip, and browser type... to change the format
change the print CNT line. To add refferer make that line:

   print CNT "$time: $ENV{REMOTE_HOST} - $ENV{REMOTE_ADDR} - $ENV{HTTP_USER_AGENT} - $ENV{HTTP_REFERER}\n";

oh and additionaly I had one bug (that I can find):
open(CNT,">>$counterdfile") || &CDie("Can't open $logfile: $!");
should be
open(CNT,">>$logfile") || &CDie("Can't open $logfile: $!");

That lock check doesn't look very reliable.
What if two processes simultaneously test the lock file, then simultaneously create it?
Why not use the built in flock function?
upon reconsidering a lock in not necessary at all as there is no
negative result other than an incorrect count...

I have fixed some other probs now... I havn't run it but it parses okay.

Here is a `new' version :) in its entirety:
#!/usr/bin/perl

$confile = '/var/lib/httpd/data/config';

$acnt = $ARGV[0];

open(CNFG, $confile) || &CDie("Can't open conf file: $!");
IT: while($line = <CNFG>) {
      chop($line);
      if($line =~ /^$acnt\|:\|(.*?)$/) { $logfile = $1; last IT }
}

&CDie("Undefined Account") unless($logfile);
if(-e $logfile) {
      open(CNT,$logfile) || &CDie("Can't open $logfile: $!");
      while($line = <CNT>) { $count++; }
      close(CNT);
}

print $count++;

$time = scalar(localtime);
open(CNT,">>$logfile") || &CDie("Can't open $logfile: $!");
print CNT "$time: $ENV{REMOTE_HOST} - $ENV{REMOTE_ADDR} - $ENV{HTTP_USER_AGENT}\n";
close(CNT);

sub CDie {
      print "Error: $_[0]\n";
      exit 0;
}

argh I didn't include the refferer :/


print CNT "$time: $ENV{REMOTE_HOST} - $ENV{REMOTE_ADDR} - $ENV{HTTP_USER_AGENT}\n";
should be
print CNT "$time: $ENV{REMOTE_HOST} - $ENV{REMOTE_ADDR} - $ENV{HTTP_USER_AGENT} - $ENV{HTTP_REFERER}\n";