#! /usr/local/bin/perl ########################################### #BooFormMail,v2.19 / this program is free.# # (C) BooBooClub 1998-2010 # ########################################### #set data $cgi = './bfm.cgi'; $linkname = 'back'; $linkurl = './url'; $sendmail = '/path/to/sendmail'; $to = 'your@mail.address'; $subject = 'From BooFormMail'; $from = 'from@address'; $type = 's'; $smsg = '

送信を受け付けました

'; $cmsg = '

以下のとおり送信を受け付けました

'; $rmsg = '

送信内容確認

'; $back = 'bgcolor="#ffffff"'; $raddr = 'on'; require './jcode.pl'; require './bmail.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) { &dcd; &scd; } if($from eq 'd'){ $fb = 'd'; $from = $FORM{'E-mail'}; } if($subject eq 'd'){ $sb = 'd'; $subject = $FORM{'subject'}; } if($FORM{'r'}){ shift(@pairs); } #read ENV $remoteaddr = $ENV{'REMOTE_ADDR'}; if($remoteaddr eq ''){ $remoteaddr = 'Cannot Get'; } #branch if($type eq "s" || $FORM{'r'} eq "rs"){ &mh; &s; } elsif($type eq "c" || $FORM{'r'} eq "rc"){ &mh; &c; } elsif($type eq "rs" || $type eq "rc"){ &r; } else{ &seterror; } sub mh{ $to =~ s/\r\n|[\r\n]//g; $from =~ s/\r\n|[\r\n]//g; $subject =~ s/\r\n|[\r\n]//g; if($from eq '' || length($from) > 245 || $from =~ /\@.*[\,\@]/){ &submiterror; } &jcode'convert(*subject,'jis'); $subjectm = &bmail::mime(header,$subject); open(SEND,"|$sendmail -t"); print SEND "From: $from\n"; print SEND "Subject: $subjectm\n"; print SEND 'MIME-Version: 1.0'."\n"; print SEND 'X-Mailer: BooFormMail-CGI'."\n"; print SEND "X-Mailer-Produced-by: BooBooClub\n"; if($raddr eq 'on'){ print SEND 'X-RemoteAddress: '."$remoteaddr"."\n"; } print SEND "To: $to\n"; print SEND 'Content-Type: text/plain; charset=iso-2022-jp'."\n\n"; } sub s{ foreach $pair(@pairs) { &dcd; &jcd; unless(($fb eq 'd' && $name eq 'E-mail')||($sb eq 'd' && $name eq 'subject')){ print SEND "$name = $FORM{$name}\n"; } } close SEND; #html print "Content-type:text/html\n\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."$smsg".''."\n"; print ''."\n"; print "\n"; print "

$smsg

\n"; print "$linkname
\n"; print "
\n"; print "
Produced by BooBooClub

\n"; print "\n"; exit 0; } sub c{ print "Content-type:text/html\n\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."$cmsg".''."\n"; print ''."\n"; print "\n"; print "

$cmsg

\n"; print "$linkname

\n"; print "\n"; foreach $pair(@pairs) { &dcd; &jcd; unless(($fb eq 'd' && $name eq 'E-mail')||($sb eq 'd' && $name eq 'subject')){ # print SEND "$name = $FORM{$name}\n"; } &scd; unless(($fb eq 'd' && $name eq 'E-mail')||($sb eq 'd' && $name eq 'subject')){ print ""; print ""; print "\n"; } } close SEND; print "
$name$FORM{$name}"; print ""; print "
\n"; print "
\n"; print "
\n"; print "
Produced by BooBooClub

\n"; print "\n"; exit 0; } sub r{ print "Content-type:text/html\n\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."$rmsg".''."\n"; print ''."\n"; print "\n"; print "
\n"; print "
$rmsg\n"; print "
\n"; print "\n"; print "\n"; foreach $pair(@pairs) { &dcd; &scd; unless(($fb eq 'd' && $name eq 'E-mail')||($sb eq 'd' && $name eq 'subject')){ print ""; print ""; print "\n"; } else{ print ""; } } print "
$name$FORM{$name}"; print ""; print "
\n"; print "

\n"; print "
\n"; print "
\n"; print "\n"; exit 0; } sub dcd{ ($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/(\r\n|[\r\n])\.(\r\n|[\r\n])/$1 \.$2/g; } sub jcd{ &jcode'convert(*name,'jis'); &jcode'convert(*value,'jis'); $FORM{$name} = $value; } sub scd{ &jcode'convert(*name,'sjis'); &jcode'convert(*value,'sjis'); $FORM{$name} = $value; } sub seterror{ print "Content-type:text/html\n\n"; print ''."\n"; print ''."\n"; print ''."\n"; print 'Error'."\n"; print ''."\n"; print "\n"; print "

Setting Error

CGI設定エラーです。

\n"; print "$linkname
\n"; print "\n"; exit 0; } sub submiterror{ print "Content-type:text/html\n\n"; print ''."\n"; print ''."\n"; print ''."\n"; print 'Error'."\n"; print ''."\n"; print "\n"; print "

Submit Error

送信エラーです。

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