Alain: abfrage in textdatei

Beitrag lesen

Morgen,
Ich habe ein cgi das remonte_user,IP, agent ,datum etc. in einer textdatei abspeichert,die ich ab und zu angucke zwecks statistik.
Aber ich möchte nicht jeden user zwei oder drei vier mal in dieser textdatei abgespeichert haben ,wenn die IP und usernamen übereinstimmen.
Meine frage diesbezüglich kann man das realisieren vielleicht mit $ENV{remonte_user}_last ?

Hier ist der teil vom cgi das diese daten abspeichert:

$logfile = "/homepages/htdocs/geschützt/logs/stat.log";
$username = $ENV{'REMOTE_USER'} || 'phoneuser';
$ip_now   = $ENV{'REMOTE_ADDR'};

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

&log;

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 "HR $username, $ip_now, $date, $ENV{'HTTP_USER_AGENT'}, $ENV{'HTTP_REFERER'}\n";

close (LOG);
        }

sub redir {

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

exit;