ファイル名: w/warewan_tagu.cgi

#!/usr/local/bin/perl

require './jcode.pl';

if ($ENV{'REQUEST_METHOD'} eq 'GET')
{
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST')
{
read(STDIN, $form, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $form);
}
else
{
print "METHOD エラー!\n";
}

foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$value =~ s/\n//g;
$value =~ s/\,//g;
&jcode'convert(*value,'sjis');
$FORM{$name} = $value;
}
if ($FORM{'action'} eq 'true'){&comment;}
else {&tagu;}
#------------------------------------------------------------
sub tagu
{
$Title = 'タグ練習';
$BODY = '<BODY BGCOLOR="#000000" TEXT="#C0C0C0">';
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>$Title</TITLE></HEAD>\n";
print "$BODY\n";
print "<div style=\"line-height:150%\"><center>\n";
print "<BR><BR>\n";
print "<font size = +2><i>タグの練習</i></font>\n";
print "<BR><BR>\n";
print "大体のタグは使えると思います。<!--は、使えません。\n";
print "<BR>\n";
print "練習用なので、保存せず、すぐ消えてしまいます。\n";
print "<BR>\n";
print "いろいろ試して問題がありましたら、連絡ください。\n";
print "<BR><BR>\n";
print "</div></center>\n";
print "<div align=\"center\"><center>\n";
print "<form action=warewan_tagu.cgi method=POST>\n";
print "<input type=hidden name=action value=true>\n";
print "<textarea name=comment rows=8 cols=80></textarea>\n";
print "<BR>\n";
print "<input type=submit value=OK!>\n";
print "</form>\n";
print "</div></center>\n";
print "</BODY>\n";
print "</HTML>\n";
}
sub comment
{
$Title = 'タグ練習結果';
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>$Title</TITLE></HEAD>\n";
print "<BODY>\n";
print "結果 \n";
print "<a href=\"warewan_tagu.cgi\"> 書き込み欄へもどる。</a>\n";
print "<BR><BR>\n";
print "$FORM{'comment'}\n";
print "</BODY>\n";
print "</HTML>\n";
}
#------------------------------------------------------------

exit;