#!/usr/bin/perl
# Perl Location on your server
#####################
# Setup Begin
$ssicounterfile = "/home/httpd/elvis/public_html/ssicounter/ssicounter"; #记录次数的dbm档案,不需副档名
$resultpage = "/home/httpd/elvis/public_html/ssicounter/result.htm"; #统计结果画面绝对位置
# Setup End
#####################
if ("$ENV{'QUERY_STRING'}" =~ /result/) {
open(RESULT,"$resultpage");
@resultpage=<RESULT>;
close(RESULT);
print "Content-type: text/html/n/n";
foreach (@resultpage) {
if ($_ =~ /<!--resulthere-->/) {
dbmopen(%TEMP,"$ssicounterfile",0666);
%SSICOUNTER=%TEMP;
dbmclose(%TEMP);
@script_filename=keys %SSICOUNTER;
@script_filename=sort @script_filename;
print "<table border=1>/n";
print "<tr><td>文件位置</td><td>次数</td></tr>/n";
foreach $temp (@script_filename) {
print "<tr><td>$temp</td><td align=right>$SSICOUNTER{$temp} times</td></tr>/n";
}
print "</table>/n";
}
else {
print "$_";
}
}
}
else {
$script_filename=$ENV{"SCRIPT_FILENAME"};
dbmopen(%SSICOUNTER,"$ssicounterfile",0666);
if ($SSICOUNTER{"$script_filename"}) {
$SSICOUNTER{"$script_filename"}=$SSICOUNTER{"$script_filename"}+1;
}
else {
$SSICOUNTER{"$script_filename"}=1;
}
$return_number=$SSICOUNTER{"$script_filename"};
dbmclose(%SSICOUNTER);
#print "Content-type: text/plain/n/n";
print "<b>$return_number</b>";
}
exit 0;