#!opt/local/bin/perl # You change these lines for your need. $PATH_CP="/usr/bin/cp"; $PATH_COUNT="/usr/local/etc/htdocs/iliev/tarball/data"; $PATH_TMP="/usr/local/etc/htdocs/iliev/tarball/data.tmp"; $PATH_SKEL="/usr/local/etc/htdocs/iliev/tarball/js.skel"; # You need not modify the code below. # JS-counter Ver 1.1 Copyright(c) by Gaku UEDA # This program is distributed WITHOUT ANY WARRANTY. # # Permission is granted to copy and distribute this file in modified # or unmodified form, for noncommercial use, provided # (a) this copyright notice is preserved. # (b) you are non-smoker or you stop smoking. $this_uri = $ENV{'DOCUMENT_URI'}; if (!-e $PATH_COUNT) { open(FH, "> ". $PATH_COUNT) || exit(1); close(FH); } open(FH, $PATH_COUNT) || exit(1); open(FHTMP, "> ".$PATH_TMP) || exit(1); $found = 0; while () { chop; ($uri, $count) = split; if ($uri eq $this_uri) { $count++; &PrintCount($count); $found = 1; } print FHTMP join("\t", $uri, $count),"\n"; } if ($found == 0) { print FHTMP join("\t", $this_uri, 1),"\n"; &PrintCount(1); } close(FH); close(FHTMP); system($PATH_CP, $PATH_TMP, $PATH_COUNT) || exit(2); # Embed js-counter into HTML. sub PrintCount { local($cnt) = @_; open(FSKEL, $PATH_SKEL) || exit(3); while () { s/###count###/$cnt/g; print; } }