#!/usr/bin/perl # Self-modifing Page Counter (simple version) # Copyright (C) 2000 Neil Fraser, Scotland # http://neil.fraser.name/ # This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU General Public License for more details. http://www.gnu.org/ # This script is designed to be included in an SHTML document. # e.g. # There is no data file to hold the current page count. Instead, # the script completely rewrites itself each time it executes. Note # that these comments will vanish after the first successful execution. # Change this variable to point at this script: $file = '/home/httpd/cgi-bin/counter.pl'; $x=1; print "Content-type: text/html\n\n$x"; # Here be dragons... $c='#!/usr/bin/perl\n${d}t=$q$t$q;${d}q=$t$q$t;${d}d=$t$d$t;${d}n=pack(${t}c$t,10);\n${d}x=$x+1;print ${q}Content-type: text/html${d}n${d}n${d}x$q;\n${d}c=$t$c$t;\nopen(F,$q> '.$file.'$q);\nprint F $q$c$q;\nclose F;\n'; open(F,"> $file"); print F "#!/usr/bin/perl\n\$t=\"'\";\$q='\"';\$d='\$';\$n=pack('c',10);\n\$x=$x+1;print \"Content-type: text/html\$n\$n\$x\";\n\$c='$c';\nopen(F,\"> $file\");\nprint F \"$c\";\nclose F;\n"; close F;