#! /usr/local/bin/perl ########################################### #BooGetData ,v1.02 / this program is free.# # (C) BooBooClub 2000-2005 # ########################################### #set data $cgi = './bgdata.cgi'; $setdat = './dataset.txt'; $checkdat = './check.txt'; $output = './csvdata.csv'; $review = 'review.html'; $thanks = 'thanks.html'; $nerror = 'error.html'; $tbop = 'border="1" bordercolor="#88aa88"'; $tdlo = 'align="left"'; $tdro = 'align="left"'; #read lib require './jcode.pl'; #read if ($ENV{'REQUEST_METHOD'} eq "POST"){ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else{ $buffer = $ENV{'QUERY_STRING'}; } if (length($buffer) < 1){ &submiterror; } @pairs = split(/&/,$buffer); foreach $pair (@pairs) { ($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//>/ig; $value =~ s/\r\n|[\r\n]/
/ig; &jcode'convert(*name,'sjis'); &jcode'convert(*value,'sjis'); if($value ne ''){ $FORM{$name} .= "\0".$value; } push(@valsort,$name); } foreach $key (keys %FORM){ $FORM{$key} =~ s/^\0//; } #Operation if($setdat ne ''){ open (SET,"$setdat"); $set = join('',); close (SET); $set =~ s/\r\n|[\r\n]//g; @set = split(/,/,$set); } if($checkdat ne ''){ open (CHECK,"$checkdat"); $check = join('',); close (CHECK); $check =~ s/\r\n|[\r\n]//g; @check = split(/,/,$check); } foreach $check(@check){ if($FORM{$check} eq '' || $FORM{$check} =~ /^\0+$/){ $nodata .= "\0".$check; } } $nodata =~ s/^\0//; $nodata =~ s/\0/
/g; if($nodata ne ''){ &noinputerror; } if ($review eq '' || $FORM{'r'} ne ''){ &outputdata; &s; } elsif ($review ne ''){ &r; } else{ &seterror; } sub outputdata{ open (DAT,">>$output"); &body; print DAT "$body\r\n"; close (DAT); } sub s{ $view = "\n" .$view ."
\n"; open (HTML,"$thanks"); @msg = ; close (HTML); $msg = join('',@msg); $msg =~ s//$view/g; print "Content-type:text/html\n\n"; print $msg; exit 0; } sub r{ &body; $view = "\n" ."\n" ."\n" .$view .$hide ."\n" ."\n" ."
\n"; open (HTML,"$review"); @msg = ; close (HTML); $msg = join('',@msg); $msg =~ s//$view/g; print "Content-type:text/html\n\n"; print $msg; exit 0; } sub body{ if($set ne ''){ $hide .= "\n"; foreach $set(@set){ $name = $set; $value = $FORM{$set}; if($value =~ /\0/){ @value = split(/\0/,$value); foreach $value(@value){ &setbody; } } else{ &setbody; } } } else{ foreach $set (@valsort){ $name = $set; $value = $FORM{$set}; if($value =~ /\0/){ @value = split(/\0/,$value); foreach $value(@value){ &setbody; } } else{ &setbody; } } } } sub setbody{ if($set ne 'r' && $set !~ /^\*/){ $body .= "$value".','; $view .= "$name$value\n"; } $value =~ s/
/\r\n/g; $hide .= "\n"; } sub noinputerror{ $errmsg = "
\n" ."$nodata
\n" ."
\n"; open (HTML,"$nerror"); @msg = ; close (HTML); $msg = join('',@msg); $msg =~ s//$errmsg/g; print "Content-type:text/html\n\n"; print $msg; exit 0; } sub submiterror{ print "Content-type:text/html\n\n"; print "Submit Error\n"; print "\n"; print "

Submit Error

送信エラーです。

\n"; print "
\n"; print "\n"; exit 0; } sub seterror{ print "Content-type:text/html\n\n"; print "Setting Error\n"; print "\n"; print "

Setting Error

CGI設定エラーです。

\n"; print "
\n"; print "\n"; exit 0; }