Solved

Free CGI script?? (Tracker)

Posted on 1998-07-02
20
355 Views
Last Modified: 2013-12-25
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!
0
Comment
Question by:eversoslightly
  • 8
  • 5
  • 2
  • +4
20 Comments
 
LVL 2

Expert Comment

by:happy1
ID: 1830417
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
0
 
LVL 1

Author Comment

by:eversoslightly
ID: 1830418
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
0
 
LVL 2

Expert Comment

by:happy1
ID: 1830419
OK, check this script (Roblog 4.02) -
http://tdi.uregina.ca/~eislerr/cgi/roblog/index.html
Happy®One
0
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
LVL 1

Author Comment

by:eversoslightly
ID: 1830420
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!
0
 
LVL 1

Author Comment

by:eversoslightly
ID: 1830421
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
0
 
LVL 7

Expert Comment

by:jconde
ID: 1830422
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


0
 
LVL 1

Author Comment

by:eversoslightly
ID: 1830423
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
0
 
LVL 1

Author Comment

by:eversoslightly
ID: 1830424
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
0
 
LVL 7

Expert Comment

by:jconde
ID: 1830425
What operating system are you using Ever So?
0
 
LVL 1

Author Comment

by:eversoslightly
ID: 1830426
My server is running Unix.
0
 

Expert Comment

by:grnemstr
ID: 1830427
Yes here is the URL  ..i use these people and they're GREAT!!!
 http://www.extreme-dm.com/tracking
0
 
LVL 1

Author Comment

by:eversoslightly
ID: 1830428
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!
0
 
LVL 3

Expert Comment

by:moonlight
ID: 1830429
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.
0
 
LVL 1

Author Comment

by:eversoslightly
ID: 1830430
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.
0
 
LVL 1

Accepted Solution

by:
mikegrb earned 50 total points
ID: 1830431
Here is a possiblity:

If you need help with it let me know.

#!/usr/bin/perl

print "Content-type: text/plain\n\n";

$logfile = '/var/lib/httpd/data/log';

if(-e "$logfile.lock") {
      sleep 1;
}


open(CLK,">$logfile.lock") || &CDie("Can't lock log: $!");
print CLK "$$\n";
close(CLK);

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


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

unlink "$logfile.lock" || &CDie("Can't unlock $logfile: $!");

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

0
 
LVL 1

Expert Comment

by:mikegrb
ID: 1830432
Ooops just noticed the multiple accounts part... let me tweek it a little....
0
 
LVL 1

Expert Comment

by:mikegrb
ID: 1830433
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: $!");

0
 
LVL 84

Expert Comment

by:ozo
ID: 1830434
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?
0
 
LVL 1

Expert Comment

by:mikegrb
ID: 1830435
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;
}

0
 
LVL 1

Expert Comment

by:mikegrb
ID: 1830436
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";
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question