sub parse_form {
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
}
foreach $pair (@pairs) {
local($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/:/:/g;
$value =~ s/,/,/g;
$value =~ s/</</g;
$value =~ s/>/>/g;
$v{$name} = $value;
}
}
sub checklength {
if (length($v{'email'}) > 40) { &breakerror('E-Mail too long'); }
if (length($v{'subj'}) > 40) { &breakerror('Subject too long'); }
if (length($v{'message'}) > 4000) { &breakerror('Message too long'); }
if (length($v{'icq'}) > 10) { &breakerror('ICQ too long'); }
@msg = split(/\n/,$v{'message'});
$msgnew ="";
foreach $m (@msg){
$ml = length($m);
$mdiv = ($ml - ($ml % 80)) / 80;
if ($ml > 80) {
for $i (0..$mdiv){
$msgnew = join "\n",$msgnew,substr($m,$i*80,80);
}
} else {
$msgnew = join "\n",$msgnew,$m;
}
}
$v{'message'} = $msgnew;
}
sub breakerror {
print @_;
exit;
}
1;
จำนวน : 45 บรรทัด