Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Free CGI script?? (Tracker)

Posted on 1998-07-02
20
Medium Priority
?
361 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Implementing Azure Infrastructure Exam 70-533

This course is designed to familiarize and instruct students in the content that is covered by Microsoft Exam 70-533, Implementing Microsoft Azure Solutions. It focuses on all the November 2016 objective domain topics.

 
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 100 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
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…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

715 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