#!/usr/bin/perl # Perl Location on your server ############################################################################## # If you encounter problems while trying to configure this script, help # # is available. In order to get your problem solved: # # 1) Read this file thoroughly # # 2) Consult the THANKS-CGI Frequently Asked Questions: # # http://www.thanks-cgi.com/faq/ # # 3) If you are still having difficulty installing this script, send # # e-mail to: support@thanks-cgi.com # # Include any error messages you are receiving and as much detail # # as you can so we can spot your problem. # # # # Hopefully we will be able to help you solve your problems. Thank you. # ############################################################################## # COPYRIGHT NOTICE # # Copyright 1998 THANKS-CGI All Rights Reserved. # # Not for re-sell or re-distribution. # ############################################################################## # Setup Begin $gifurl = "http://cc.oulu.fi/~ahepoaho/static/static.gif"; # The image for check the result. $filehead = "http://cc.oulu.fi/~ahepoaho/static/"; # The REAL PATH of result. $usedfile = "http://cc.oulu.fi/~ahepoaho/static/usedfile.txt"; # The record file of statics. $resultpage= "http://cc.oulu.fi/~ahepoaho/static/result.htm"; # The page to show the result # End ##################### if ("$ENV{'QUERY_STRING'}" =~ /^result/) { open(RESULT,"$resultpage"); @resultpage=; close(RESULT); print "Content-type: text/html\n\n"; foreach (@resultpage) { if ($_ =~ //) { open(USEDFILE,"$usedfile"); @usedfile=; close(USEDFILE); @usedfile=sort byhittimes @usedfile; print "\n"; print "\n"; foreach $temp (@usedfile) { ($a,$b,$c)=split(/¡ü/,$temp); $counterfile= "$filehead$b"; open(COUNTERFILE,"$counterfile"); $counter=; close(COUNTERFILE); $counter=0 if ($counter eq ""); print "\n"; } print "
FROMHITS
$a$counter hits
\n"; } else { print "$_"; } } } else { $userfrom ="$ENV{'QUERY_STRING'}"; $userfrom =~ tr/+/ /; $userfrom =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; @userfrom = split(/\?/,$userfrom); $userfrom = $userfrom[0]; if ($userfrom =~ /^http/) { open(USEDFILE,"$usedfile"); @usedfile=; close(USEDFILE); $check=0; $b=0; foreach (@usedfile) { ($a,$b,$c)=split(/¡ü/,$_); if ($a eq $userfrom) { $check=1; last; } } if ($check==0) { $b++; open(USEDFILE,">>$usedfile"); print USEDFILE "$userfrom¡ü$b¡ü\n"; close(USEDFILE); } $counterfile="$filehead$b"; open(COUNTERFILE,"$counterfile"); $counter=; close(COUNTERFILE); $counter++; open(COUNTERFILE,">$counterfile"); print COUNTERFILE "$counter"; close(COUNTERFILE); } print "Location: $gifurl\n\n"; } exit 0; ######## sub byhittimes { ($a1,$a2,$a3)=split(/¡ü/,$a); $afile= "$filehead$a2"; open(COUNTERFILE,"$afile"); $acount=; close(COUNTERFILE); ($b1,$b2,$b3)=split(/¡ü/,$b); $bfile= "$filehead$b2"; open(COUNTERFILE,"$bfile"); $bcount=; close(COUNTERFILE); return ($bcount<=>$acount); }