Solved

Free CGI script?? (Tracker)

Posted on 1998-07-02
20
350 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
Comment Utility
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
Comment Utility
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
Comment Utility
OK, check this script (Roblog 4.02) -
http://tdi.uregina.ca/~eislerr/cgi/roblog/index.html
Happy®One
0
 
LVL 1

Author Comment

by:eversoslightly
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
What operating system are you using Ever So?
0
 
LVL 1

Author Comment

by:eversoslightly
Comment Utility
My server is running Unix.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Expert Comment

by:grnemstr
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Ooops just noticed the multiple accounts part... let me tweek it a little....
0
 
LVL 1

Expert Comment

by:mikegrb
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now