´äº¯ Á¤¸» °¨»çÇÕ´Ï´Ù.
¸»¾¸ÇϽŠ´ë·Î ű׸¦ ´Ù½Ã Àß Çغôõ´Ï
±×·± ¸Þ¼¼Áö´Â ¾È³ª¿É´Ï´Ù.
±×·±µ¥ ¾ÆÁ÷µµ ¾ÈµË´Ï´Ù.
htmlȸ鿡¼ submit¸¦ ´©¸£¸é
¹®¼¿¡ µ¥ÀÌÅÍ°¡ ¾øÀ¸´Ï
°ü¸®ÀÚ¿¡°Ô ¹®ÀÇÇ϶ó´Â ¸Þ¼¼Áö°¡ ³ª¿É´Ï´Ù.
±×·¡¼ ȯ°æ º¯¼ö °ªÀ» ¾Ë¾ÆºÃ´Âµ¥¿ä.
REQUEST_METHOD ´Â POST Àä.
CONTENT_LENGTH °¡ 0 ÀÌ ³ª¿É´Ï´Ù.
Áö±Ý Red Hat Linux 6.1ÇÏ°í¿ä apache 1.3.12¸¦ ¾²°í
Àִµ¥¿ä...
¾îµð°¡ À߸øµÈ °ÇÁö ¸ð¸£°Ú½À´Ï´Ù.
ÀÚ±¸ ±ÍÂú°Ô Çصå·Á¼ Á˼ÛÇÕ´Ï´Ù.
¹Ø¿¡ ÇÁ·Î±×·¥ óÀ½ ºÎºÐ¸¸ ¿Ã¸®°Ú½À´Ï´Ù.
ÀÌ°ÍÀº Á¦°¡ ¸¸µç°ÍÀÌ ¾Æ´Ï°í ½ÃÇèÇØ º¸·Á°í °¡Á®¿Â °ÍÀÔ´Ï´Ù.
°¨»çÇÕ´Ï´Ù º¹ ¸¹ÀÌ ¹ÞÀ¸½Ê½Ã¿ä.
-- input.html --
input guestbook
WRITE
After write press button
Reading guestbook
-- guestbook.cgi --
#!/usr/bin/perl
&initialize;
&read_parse;
&check_value;
&write_book;
&print_book;
exit;
sub initialize {
$book_path = "./guestbook.html";
$dot = "* ";
$separate = "
";
$browser = $ENV{
HTTP_USER_AGENT
};
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time);
$month = ($mon 1);
$date = "$yearyear $monthmonth $mdayday";
$time = "$hourhour $minminute $secsecond";
print "Content-type: text/html
";
}
sub read_parse {
if( $ENV{
REQUEST_METHOD
} eq "POST" ) {
read(STDIN, $buffer, $ENV{
CONNECT_LENGTH
});
} else {
print "This guestbook support only post method.
";
exit;
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/ / /;
$value =~ s/%([a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
}