Alain: htaccess

Beitrag lesen

Moin, wenn Du cgis auch im memberbereich installieren kannst dann kannst Du ein cgi ins member verzeichniss installieren,der Dir die ENV% in eine logdatei schreibt. Im memberbereich wird automatisch der remonte_user mitgeliefert,weil die sich ja angemeldet haben. Das cgi selbst kannst Du so <img SRC="stats.cgi" border="0" height="1" width="1"> auf der haubtseite einbinden. Ich benutze z.B. dieses cgi:

#!/usr/local/bin/perl -w

$logfile = "/log/stat.log";

$exclude = 0;

$my_addr =  "http://www.Deinhost.de/";

used with the "exclude" portion

$HomeDirURL = "member/index.html";

again, change if you're not using SSI's

$username         = $ENV{'REMOTE_USER'};

########## So much for that.. On with the show! #######

Get the input

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

Split the name-value pairs

@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {

($name, $value) = split(/=/, $pair);

# Un-Webify plus signs and %-encoding

$value =~ tr/+/ /;

$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

# Stop people from using subshells to execute commands

# Not a big deal when using sendmail, but very important

# when using UCB mail (aka mailx).

$value =~ s/~!/ ~!/g;

# Uncomment for debugging purpose

# print "Setting $name to $value<P>";

$FORM{$name} = $value;

}

($sec,$min,$hour,$mday,$mon,$wday,$yday,$isdst) = localtime(time);

if ($sec < 10) {

$sec = "0$sec";

}

if ($min < 10) {

$min = "0$min";

}

if ($hour < 10) {

$hour = "0$hour";

}

if ($mon < 10) {

$mon = "0$mon";

}

if ($mday < 10) {

$mday = "0$mday";

}

$month = ($mon + 1);

@months = ("January","February","March","April","May","June","July","August","September","October","November","December");

$date = "$hour:$min:$sec $mday/$month";

Now that we know what the time/date is.. let's have fun

{

if ($exclude == 1)

{

&log unless ($ENV{'HTTP_REFERER'} eq $my_addr);

} else {

&log;

}

&redir;

exit;

}

sub log {

if (! open(LOG,">>$logfile")) {

print "Content-type: text/html\n\n";

print "Couldn't open $logfile so I'm bugging out..\n";

exit;

}

print LOG "At $date, $username $ENV{'HTTP_REFERER'}, IP $ENV{'REMOTE_ADDR'} use $ENV{'HTTP_USER_AGENT'}.\n";

close (LOG);

}

sub redir {

print "Location: $HomeDirURL\n\n"; }

Grüsse vom Alain

--
...nobody is perfect I am nobody