Greenguy's Board


Go Back   Greenguy's Board > General Business Knowledge
Register FAQ Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2003-11-13, 03:31 PM   #1
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
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:49 PM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc