CGI Counter so einrichten, das ausgabe im geschützten Bereich
Maxx
- cgi
Hallo
ich habe hier nen cgi-Counter, den ich gerne so einrichten würde, das er zwar auf der Startseite die Zugriffe zählt, aber die ausgabe (eine über Inframe) auf einem Passwortgeschützten Bereich auf der Seite statt findet. Nun habe ich es nicht selbst geschrieben, und bin etwas ratlos, ob das mit diesem Script denn überhaupt geht ohne es komlett zu ändern. Hier der Source:
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
#############################################################
#############################################################
@ignore = ("127.0.0.1");
$keep_online_time = 5;
$keep_in_log_time = 30;
$use_flock = 1;
$templ_dir = ".";
$data_dir = "Data";
#############################################################
#############################################################
$LOCK_EX = 2;
$LOCK_UN = 8;
$current_time = time;
open(LOG, "+>>$data_dir/log.txt");
flock(LOG,$LOCK_EX) if ($use_flock);
seek(LOG,0,0);
@entries = <LOG>;
seek(LOG,0,0);
truncate(LOG,0);
$add=1;
$online=1;
$ignore=0;
foreach (@ignore)
{
if ($ENV{REMOTE_ADDR} eq $_)
{
$add=0;
$online=0;
$ignore=1;
}
}
print LOG "$ENV{REMOTE_ADDR}|$current_time\n" if (!$ignore);
foreach $curentry (@entries)
{
$curentry =~ s/[\n\r]//g;
($ip, $time) = split(/|/, $curentry);
if ($current_time - $time <= $keep_in_log_time*60 && $ip ne $ENV{REMOTE_ADDR})
{
print LOG "$curentry\n";
}
if ($current_time - $time <= $keep_online_time*60 && $ip ne $ENV{REMOTE_ADDR})
{
$online++;
}
if ($current_time - $time <= $keep_in_log_time*60 && $ip eq $ENV{REMOTE_ADDR})
{
$add=0;
}
}
flock(LOG,$LOCK_UN) if ($use_flock);
close(LOG);
open(COUNT, "+>>$data_dir/count.txt");
flock(COUNT,$LOCK_EX) if ($use_flock);
seek(COUNT,0,0);
$count = <COUNT>;
if ($add != 0)
{
$count++;
seek(COUNT,0,0);
truncate(COUNT,0);
print COUNT $count;
}
flock(COUNT,$LOCK_UN) if ($use_flock);
close(COUNT);
if (!defined($no_output))
{
print "Content-type: text/html\n";
print "Pragma: no-cache\n";
print "Expires: now\n\n";
$ENV{QUERY_STRING} =~ s/\W//g;
if ($ENV{QUERY_STRING} eq "")
{
open(FILE,"$templ_dir/counter.html");
}
else
{
open(FILE,"$templ_dir/counter_$ENV{QUERY_STRING}.html");
}
foreach (<FILE>)
{
$_ =~ s/{ONLINE}/$online/g;
$_ =~ s/{COUNT}/$count/g;
print "$_";
}
close(FILE);
exit;
}
1;
Maxx
Hi,
#############################################################
Program starts here
GTCounter 1.1 by Wladimir Palant (http://www.gtchat.de/)
#############################################################
was sagt der Autor zu Deiner Frage?
Und was sagt die mitgelieferte Installationsanleitung?
Viele Grüße
Michael