&decode(デコード)

基本構造へ戻る

######################################################
# デコード#
######################################################
#
#
sub decode{
if ($ENV{'REQUEST_METHOD'} eq "POST"){
$post_flag = 1;
read(STDIN, $buf, $ENV{'CONTENT_LENGTH'});
} else {
$post_flag = 0;
$buf = $ENV{'QUERY_STRING'};}
undef(%in); $page = 0;
@pair = split (/&/,$buf);
foreach (split(/&/, $buf)) {
local($key, $val) = split(/=/, $_);
#($names, $val) = split (/=/, $_);
#$val =~ tr/ / /;
$val =~ tr/+/ /;
$val =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c", hex($1))/eg;
&jcode'convert(*val,"sjis","","z");
# 改行処理
$val =~ s/\r\n/<br>/g;
$val =~ s/\r/<br>/g;
$val =~ s/\n/<br>/g;
$val =~s/;/,/g;
# タグ処理
$val =~ s/&/&/g;
$val =~ s/"/"/g;
$val =~ s/ $val =~ s/>/>/g;
$FORM{$names} = $val;
# ページ繰り越し
if ($key =~ /^page(\d+)$/) {
$page = $1;
}
$FORM{$key} .= "\0" if (defined($FORM{$key}));
$FORM{$key} .= $val;
}
}
#
#
######################################################