#!/usr/bin/perl
my $buffer; $time = time; $work = $ENV{"QUERY_STRING"}; @pairs_end = split(/&/, $work); foreach $pair (@pairs_end) { ($kname, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $END{$kname} = $value; }
if ($ENV{'REQUEST_METHOD'} eq "POST") { binmode STDIN; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; } my ($qx_name, $value); if ($buffer !~ /\n/) { for (split /&/, $buffer) { ($qx_name, $value) = split /=/; $qx_name =~ y/+/ /; $qx_name =~ s/%(..)/chr hex $1/ge; $value =~ y/+/ /; $value =~ s/%(..)/chr hex $1/ge; $$qx_name = $value; } } else { # ÆÄÀÏ ¾÷·Îµå my ($qx_name, $value); my ($border) = ($buffer =~ /^(.+?)\r?\n/); $buffer =~ s/${border}--$//; my $bad_char = '`~!@#%^&*()|,<>?;:\'"[]{}';
for (split /$border/, $buffer) {
next if $_ eq ''; s/^\r?\n//;
if (/name="FILE(\d)"; filename="(.+?)"/i) { my ($FILE_VAR) = $1; next if $2 eq ''; my ($FILE_NAME) = $2 =~ m{([^\\^/]+)$}; $FILE_NAME =~ s/[$bad_char]//g; #ÆÄÀÏÀ̸§ ¹è¿ÀúÀå $FILES{'file'}->{name} = $FILE_NAME; s/^.+?\r?\n\r?\n//s; s/\r?\n$//s; if($_ eq '') { $FILES{'file'}->{name} = ''; next; } else {
} #ÆÄÀϳ»¿ë ¹è¿ÀúÀå #$FILES{'file'}->{data} = $_; my ($File_Name_In) = "FILE" . "$FILE_VAR"; $Field{$File_Name_In} = $FILE_NAME;
} else { s/^.+?name\=\"(\S+?)\"\r?\n\r?\n(.+?)\r?\n$//s; ($qx_name = $1) =~ tr/\r//d; ($value = $2) =~ tr/\r//d; $$qx_name = $value; } } #for }#else
############################################################################# if ($END{'action'} eq "") { &add; } elsif ($END{'action'} eq "add_reg") { &add_reg; }
############################################################################# sub add { print "content-type:text/html\n\n";
#ÆÄÀÏÀ» ¿¾î¼ ÀоÀÚ. ±»ÀÌ ¾Æ·¡ ¹æ¹ýÀ» ¾²Áö ¾Ê¾Æµµ µÇÁö¸¸ È®À强À» À§Çؼ #¾Æ·¡ ó·³ »ç¿ëÇÑ´Ù. open (SR,"data.txt"); while (<SR>) { $view_read .= $_; } close SR;
print qq~
<html> <form action=test.cgi?action=add_reg method=post> <input type=text name=view value=$view_read> <input type=submit> </html> ~; }
############################################################################# sub add_reg { #ÀԷ°ú µ¿½Ã¿¡ ÆÄÀÏÀ» ¾²°í sub add ·Î ´Ù½Ã ³¯·ÁÁØ´Ù. open (SR,">data.txt"); print SR "$view"; close SR; &add; }
|