Thread Werte in Datei schreiben (CGI-Formular) (84 answers)
Opened by fred0815 at 2013-12-23 10:21

fred0815
 2013-12-23 13:00
#172700 #172700
User since
2013-12-23
32 Artikel
BenutzerIn

user image
Ups, übersehen.
Optimal, hier jetzt das fertige Script:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!C:/xampp/perl/bin/perl.exe -wT
use strict;
use warnings;
use CGI;
my $cgi = CGI->new;
my $param_IP = $cgi->param('IP'); # Hole den Parameter IP (=Inhalt der Textarea)
my @IP = split /\cM?\cJ/, $param_IP if defined($param_IP) and length($param_IP); # Teile mehrzeilige Einträge im Textfeld in einzelne Zeilen und speicher sie ins Array
open(my $fh,">>", ".htaccess") or die "Cant open .htaccess: $!";
foreach my $IP (@IP) {
$IP =~ s/[\cM\cJ]//g; # entferne alle Zeilenenden
print $fh 'allow from ';
print $fh $IP,"\n"; # speichere eine IP
}
close($fh) or die "Cant close .htaccess: $!";
print $cgi->header(
-status => '204 No Content',); # only HTTP header is in response

View full thread Werte in Datei schreiben (CGI-Formular)