lag gifer med alle tallene fra 0 til 9...
Kode
#!/usr/local/bin/perl
##############################################################################
# c2countit Version 1.31 #
# Copyright 1998 Chad Casselman c2@chipinc.com #
# Created 01/15/98 Last Modified 05/16/98 #
# URL: http:/www.websitereporter.com #
##############################################################################
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 1998 Chad Casselman. All Rights Reserved. #
# #
# Counter may be used and modified free of charge by anyone so long as #
# this copyright notice and the comments above remain intact. By using this #
# code you agree to indemnify Chad Casselman from any liability that #
# might arise from it's use. #
# #
# Selling the code for this program without prior written consent is #
# expressly forbidden. In other words, please ask first before you try and #
# make money off of my program. #
# #
# Obtain permission before redistributing this software over the Internet or #
# in any other medium. In all cases copyright and header must remain intact.#
# #
##############################################################################
#######################################################################
#########################> USER OPTIONS <##############################
#######################################################################
$file_dir = "/path/to/directory/cgi";
$fly = "/path/to/directory/cgi/fly -q";
$filetemp = time;
$temp = "/path/to/directory/cgi/$filetemp.txt";;
$block_repeats = "0";
$private = "0";
@site_urls = ("websitereporter.com","www.websitereporter.com","209.130.97.145");
$digit_dir = "/path/to/directory/cgi/c2countit/digits";
$width = "15";
$height = "20";
#######################################################################
########################> END USER OPTIONS <###########################
#######################################################################
### !!!! DO NOT CHANGE ANYTHING BELOW THIS LINE !!!! ###
#######################################################################
$host = $ENV{'REMOTE_HOST'};
if ($private == 1) {
&private_call;
}
&getinfo;
&incrementcounter;
$num = $length = length($count);
while ($num > 0) {
$NUMS{$num} = chop($count);
$num--;
}
$image_width = ($width * $length);
$image_height = ($height);
$insert = 0;
open(FLY,">$temp") | | die "Sorry: c2countit can't open: $temp!\n";
print FLY "new\n";
print FLY "size $image_width,$image_height\n";
$c = 1;
while ($c <= $length) {
print FLY "copy $insert,0,-1,-1,-1,-1,$digit_dir/$NUMS{$c}\.gif\n";
$insert = ($insert + $width);
$c++;
}
print FLY "interlace\n";
close(FLY);
$output = `$fly -i $temp`;
print "Content-type: image/gif\n\n";
print "$output";
unlink($temp);
exit(0);
#######################################################################
# Checks for valid counter call
#
sub private_call {
$OK = 0;
if ($call = $ENV{'HTTP_REFERER'}) {
foreach $site (@site_urls) {
if($call =~ m/^http:\/\/$site/){
$OK = 1;
}
}
}
if (!$OK) {
exit(0);
}
}
#
#
#######################################################################
#######################################################################
# Gets the correct files and check for invisible counter
#
sub getinfo {
($userfile,$arglist) = split(/\\\[/,"@ARGV");
($user, $file) = split(/\\&/,$userfile);
@args = split(/\\&/,$arglist);
if($user =~ m/\.|\/|\\|\s/){
exit(0);
}
$countfile = "$file_dir/$user";
}
#
#
#######################################################################
#######################################################################
# Increment the counter and record it
#
sub incrementcounter {
if (-e $countfile) {open(COUNT,"+<$countfile") | | die("c2countit can't open $countfile: $!\n");
flock(COUNT,$lock);
$count = <COUNT>;
chop $count;
$lastvisitor = <COUNT>;
chop $lastvisitor;
if(($block_repeats == "1") && ($host == $lastvisitor)) {
;
}else{ $count++; }
$number = $count;
} else {open(COUNT,">$countfile") | | die("c2countit can't open $countfile: $!\n");
flock(COUNT,$lock);
$count = 1;
}
seek(COUNT,0,0);
print (COUNT "$count\n$host\n");
flock(COUNT,$unlock);
close(COUNT);
}
#
#
#######################################################################