aktivere perl cgi-script fra html
Hej,Jeg har fundet nedstående perl-cgi counter.
I følge en besked som fulgte med skal jeg gøre følgende for at aktivere scriptet:
The script may be called in one of two ways
<!--#exec cgi="/cgi-bin/counter/counter.cgi"-->
<!--#include virtual="/cgi-bin/counter/counter.cgi"-->
Make sure the calling page ends in the .shtml extension.
Jeg har så lagt den ene af disse liner ind foran mit html kode og så ændret file taget for mit html dokument fra .htm til .shtml. Problemet er at det ikke virker. Er der nogen der har en ide?
Mange hilsner,
Rune
#!/usr/local/perl-5.8.0
#
# Copyright IMAX Scripts 2002 All Rights Reserved
#
# Visit IMAX at http://www.imaxscripts.com
#
# This program is copyrighted software. It may not be modified, distributed or sold
# without prior written consent from the copyright holder.
#
# Any use of this script is entirely at the risk of the user. No liability will be
# accepted by the author.
#
use Fcntl qw/:flock/;
$site_counter = 0; # Set to 1 for site counter or 0 for page counter
print "Content-type: text/html\n\n";
if ($site_counter) {
site_counter();
}
else {
page_counter();
}
sub site_counter {
open( FILE, "+<count.txt" ) or die "Cannot open count.txt: $!\n";
flock( FILE, LOCK_EX )
or die "Cannot get exclusive file access to count.txt: $!\n";
($count) = <FILE>;
$count++;
seek FILE, 0, 0;
truncate FILE, 0;
print FILE $count;
close(FILE);
print $count;
exit(0);
}
sub page_counter {
open( FILE, "+<count.txt" ) or die "Cannot open count.txt: $!\n";
flock( FILE, LOCK_EX )
or die "Cannot get exclusive file access to count.txt: $!\n";
while (<FILE>) {
if (/^$ENV{DOCUMENT_URI}\|/) {
( $page, $count ) = split ( /\|/, $_ );
$count++;
$known_page = 1;
$line = join ( "\|", $page, $count );
push ( @data, "$line\n" );
next;
}
push ( @data, $_ );
}
if ( !$known_page ) {
push ( @data, "$ENV{DOCUMENT_URI}\|1\n" );
$count = 1;
}
seek FILE, 0, 0;
truncate FILE, 0;
foreach $data (@data) {
print FILE $data;
}
close(FILE);
print $count;
exit(0);
}
