#!/usr/local/bin/perl -w -I/home1/share/share/lib require "/home1/share/share/cgishare.pl"; %cfgparm = &read_cfg; use CGI; my $query = new CGI; my $host= $query->param('w') eq "" ? $ENV{'SERVER_NAME'} : $query->param('w'); my $entry = $query->param('p') eq "" ? 1 :$query->param('p'); my $Image = $query->param('i') eq "" ? 1 : $query->param('i'); my $trans = $query->param('t') eq "" ? "n" : $query->param('t'); #my $Image =1; #my $host="www.unisite.net"; #my $entry=1; my $CFile = "count/".$host.".dat"; my $imgpath = $cfgparm{'COUNTIMGPATH'}; my $images=$imgpath."/".$Image.".png"; use Image::Size; my ($x, $y) = imgsize($images); my $width=$x/10; my $Count=1; my $exciting = "false"; if ($x eq "" || $y eq "" ) { print "Content-type: image/png\n\n"; print " "; exit; } #Change this to the directory where your digits are (0-9) (It must be #relvative to the page that the counter will be displayed on!!) #--------------------------------------------# #---DO NOT change anything below this line---# #--------------------------------------------# if (open(COUNT, $CFile)) { my $cline; my $filec; while () { $cline=$_; if ($cline =~ /^$entry:(\d+)/) { $Count=$1; ++$Count; $exciting= "true"; $filec.=$entry.":".$Count."\n"; } else { $filec .=$cline; } } close(COUNT); open(WCOUNT, ">".$CFile); print WCOUNT $filec; if ($exciting eq "false") { print WCOUNT "$entry:$Count\n"; } close(WCOUNT); } else { open(COUNT, ">".$CFile); print COUNT "$entry:$Count\n"; close(COUNT); } my $countsize=length($Count) * $width; use GD; my $im= new GD::Image($countsize,$y); print "Check pointa $images $Count, $countsize $width\n"; #open (PNG, $images) || die; #my $src = newFromPng GD::Image(\*PNG) || die; my $src = newFromPng GD::Image($image); #my $src = newFromPng GD::Image(PNG) || die; #close PNG; print "Check pointb\n"; my @Nums = split(//, $Count); my $i =0; foreach $CNum (@Nums) { my $post=$CNum * $width; $im->copy($src,$i, 0, $post, 0, $width, $y); $i = $i+ $width; } if ($trans ne "n") { my ($r,$g,$b) = split /-/, $trans; if ($r ne "" || $g ne "" || $b ne "") { my $white = $im->colorClosest($r,$g,$b); $im->transparent($white); } } print "Content-type: image/png\n\n"; print $im->png; #print "Count is $Count x = $x y = $y width=$width size=$countsize\n"; exit;