View Single Post
Old 2003-11-13, 03:31 PM   #2
guschi2k
Heh Heh Heh! Lisa! Vampires are make believe, just like elves and gremlins and eskimos!
 
guschi2k's Avatar
 
Join Date: Oct 2003
Location: right here
Posts: 75
Send a message via ICQ to guschi2k
if you just want to count the traffic you sent to a specific url and don't need any fancy administration / stats GUI

Code:
#!/usr/bin/perl
# Set Variables
# This is the counter log filename
$databasefile = '../html/stats/iwonderiftheycounallthetrafficisend.txt';
# This is your main URL path
$YourURL = 'http://www.domain.com';
##########################################################
$originallink = "$ENV{'QUERY_STRING'}";
# v3.5 - Get remote file
if ((substr($originallink, 0, 7) eq 'http://') ||
    (substr($originallink, 0, 6) eq 'ftp://')) {
 $link = $originallink;
}
else {
 $link = "$YourURL/$originallink";       # YourURL + Link to file
}
open(DB,"+<$databasefile") || die $!;
flock(DB,2);                  # Locking file
seek(DB,0,0);
@DATA = <DB>;
$SIZE = @DATA;

$i = 0;
while ($i <= $SIZE) {
   ($counter,$oldlink) = split(/`/,$DATA[$i]);
   chop($oldlink);
   if ($oldlink eq $originallink) {
     $counter++;
     $DATA[$i] = "$counter`$originallink\n";
     goto LocateLink;
   }
   $i++;
}
push @DATA, "1`$originallink\n";
LocateLink:
@DATA = sort {($b =~ /(\d+)/)[0] <=> ($a =~ /(\d+)/)[0]} @DATA;
seek(DB,0,0);
print(DB @DATA);
truncate(DB,tell(DB));
flock(DB, 8);                # Unlocking file
close(DB);
print "Location: $link\n\n";
i found that piece of code a while ago and use it to count all the traffic is send to specific urls

you just need to create a *.txt file and start to send all traffic through count.cgi or however you want to name it

i'm sure it can handle 100k clicks per hour without slowing your server down.
__________________
Tonys XXX Links wants your quality free sites|king|
Pleeeaaase help & save my addiction SaveEnterprise
guschi2k is offline   Reply With Quote