浅貝CUPエントリー
御宿案内
宿泊予約
スキープラン
交通アクセス
タウンガイド
BOARD WALK
HOME
苗場PDFMAP
夏山
Mt.Naeba Link
湯沢 Link
#!/usr/bin/perl ################################################################################ # # ėp[tH[ pgdmailform.cgi # PGD WORKS by Akira Motojima # http://pgd.jp/ # # #------------------------------------------------------------------------------- # # # Perl5 # /usr/sbin/sendmail g邱 # W[ HTML::Template, Jcode 삷邱 # W[ HTML::Template, Jcode 삷邱 # #------------------------------------------------------------------------------- # # ݒ # # ./lib/pgdmailform_config.cgi ҏWĂB # ڍׂ̓t@C̃RgQ # #------------------------------------------------------------------------------- # # s # # http://-------/****/pgdmailform.cgi # ʃev[gŎs̏ꍇ # http://-------/****/pgdmailform.cgi?type=TYPE # #------------------------------------------------------------------------------- # # ev[g̐ݒu # # ./template/default/ ^Cvw肳ĂȂ炪p # ./template/TYPE/ ^Cvw肳Ăꍇ # At@CȂdefault̃t@Cp(mail.txt) # # ev[g̏ɂĂ ./template/default/form.html ̃RgQ # #------------------------------------------------------------------------------- # # # # 2008/05/25 Unicode::Japanese L[MjisϊJcodeւ悤ɂ # 2008/04/28 C # 2008/03/13 쐬 # ################################################################################ ##### require use lib './lib/'; use strict; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser set_message); set_message(' '); use HTML::Template; use Jcode; require 'pgdmailform_common.cgi'; require 'pgdmailform_config.cgi'; require 'pgdmailform_sendmail.cgi'; require 'pgduserinfo.cgi'; ##### run my $in = new CGI; my %in; foreach my $key ($in->param) { my @list = $in->param($key); $in{$key} = join('/',@list); } # tH[^Cv̎擾 my $type = $in{'type'}; if ($type eq '') { $type = 'default';} if (!$PgdMailFormConfig::type_available{$type}) { die("̃tH[͌ݗpł܂B");} # JڏԂ̎擾 my $mode = $in{'mode'}; delete $in{'mode'}; # hiddenɂ܂Ƃߓn珜O if ($mode eq 'check') { &check_and_send; } elsif ($mode eq 'send') { &check_and_send; } else { &form; } exit; ##### routine sub form { my ($form_value,$error_list) = @_; # html ev[g my $html_template_file = $PgdMailFormCommon::template_dir . $type . '/' . $PgdMailFormCommon::template_form; # ev[gftHgev[g𗘗p if (!-e $html_template_file) { $html_template_file = $PgdMailFormCommon::template_dir . 'default/' . $PgdMailFormCommon::template_form;} # ev[g̑I my $tmpl = HTML::Template->new( 'die_on_bad_params' => 0, 'filename' => $html_template_file, ); # HTMLev[g p[^ $tmpl->param( 'type' => $type, 'error_count' => scalar keys %{$error_list}, ); # lAG[lev[gɈn foreach my $key (keys %{$form_value}) { # input/textareap $tmpl->param($key => %{$form_value}->{$key}); # select/radio/checkboxp lURLGR[hs my $keystr = %{$form_value}->{$key}; $keystr =~ s/([^a-zA-Z0-9_.!~*'()-])/'%'.unpack('H2',$1)/eg; $keystr = $key . '-' . $keystr; $tmpl->param($keystr => 1); } foreach my $key (keys %{$error_list}) { $tmpl->param("error-$key" => %{$error_list}->{$key});} # ϐev[gɑ $tmpl->param(%ENV); print "Content-Type: text/html\n\n"; print $tmpl->output(); } sub check_and_send { # K{ڈꗗ̎擾 my @required_list = split(/[^\w\-\_]+/,$in{'required'}); my %required_list; foreach my $key (@required_list) { if ($key =~ /^[\w\-\_]+$/) { $required_list{$key} = 1; } } my @loop_list = (); my %form_value; my %error_list; foreach my $key (keys %in) { if ($key eq '') { next;} # lAL[̃TCỸ`FbN if (length $in{$key} > $PgdMailFormCommon::max_size || length $key > $PgdMailFormCommon::max_size) { $error_list{$key} = 1; } # tH[}bg`FbN if ($in{$key} ne '') { if (($key =~ /^zip$/i || $key =~ /^zip[^12].+/i) && $in{$key} !~ /^\d{3}\-?\d{4}$/) { $error_list{$key} = 1;} if ($key =~ /^zip1/i && $in{$key} !~ /^\d{3}$/) { $error_list{$key} = 1;} elsif ($key =~ /^zip2/i && $in{$key} !~ /^\d{4}$/) { $error_list{$key} = 1;} if ($key =~ /^(tel|fax)/i && $in{$key} !~ /^\d[\d\-]+\d$/) { $error_list{$key} = 1;} if ($key =~ /^email/i && $in{$key} !~ /^[\w\.\-\_\,\/\?\+]+\@\w+[\w\-\.]+\.[\w\-\.]+\w$/) { $error_list{$key} = 1;} } # G[`FbN #if ($key eq 'email2' && $in{'email2'} ne $in{'email'}) { $error_list{$key} = 1;} #elsif ($key eq 'age' && $in{$key} ne '' && $in{$key} < 10) { $error_list{$key} = 1;} if ($in{$key} ne '') { # l̊i[ loopp my %row_data; $row_data{'key'} = $key; $row_data{'value'} = $in{$key}; push(@loop_list,\%row_data); $form_value{$key} = $in{$key}; } } # K{ڂ̃`FbN foreach my $key (keys %required_list) { my $error_flg = 0; # ܂lȂG[Ƃ if ($in{$key} eq '') { $error_flg = 1; } # checkbox ̏ꍇ key- ɒlłG[ foreach my $key_in (keys %in) { if ($key_in !~ /^$key\-\d+$/) { next;} if ($in{$key_in} ne '') { $error_flg = 0;} } # G[ꍇev[gɏo if ($error_flg) { $error_list{$key} = 1; } } # G[Lꍇ̓tH[ɍ߂ if (scalar keys %error_list != 0) { &form(\%form_value,\%error_list); exit; } # check[h̏ꍇmFʂ\ if ($mode eq 'check') { # html ev[g my $html_template_file = $PgdMailFormCommon::template_dir . $type . '/' . $PgdMailFormCommon::template_check; # ev[gftHgev[g𗘗p if (!-e $html_template_file) { $html_template_file = $PgdMailFormCommon::template_dir . 'default/' . $PgdMailFormCommon::template_check;} # ev[g̑I my $tmpl = HTML::Template->new( 'die_on_bad_params' => 0, 'filename' => $html_template_file, ); # HTMLev[g p[^ $tmpl->param('loop_list' => \@loop_list); # ͂ꂽev[gɏo $tmpl->param(%form_value); # ϐev[gɑ $tmpl->param(%ENV); print "Content-Type: text/html\n\n"; print $tmpl->output(); # send[h̏ꍇ[𑗐M } elsif ($mode eq 'send') { # [USʂ̎擾 my %userinfo = (); &Userinfo::GetUserInfo(\%userinfo); ##### [̑M # [ev[g # ^CvɑΉ郁[ev[gꍇ͐ݒuYƌȂăftHgev[gĂяoG[Ƃ my $mail_template_file = $PgdMailFormCommon::template_dir . $type . '/' . $PgdMailFormCommon::template_mail; # ev[gG[ if (!-e $mail_template_file) { die('[ev[gݒuĂ܂B');} # ev[g̑I my $mail = HTML::Template->new( 'die_on_bad_params' => 0, 'filename' => $mail_template_file, ); # HTMLev[g p[^ $mail->param( 'loop_list' => \@loop_list, ); # ͂ꂽev[gɏo $mail->param(%form_value); # [Uev[gɏo foreach my $key (keys %userinfo) { $mail->param("userinfo-$key" => $userinfo{$key});} # ϐev[gɑ $mail->param(%ENV); # [M̃ZNg if (!$PgdMailFormConfig::mail_to{$type}) { $PgdMailFormConfig::mail_to{$type} = $PgdMailFormConfig::mail_to{'default'};} if (!$PgdMailFormConfig::mail_cc{$type}) { $PgdMailFormConfig::mail_cc{$type} = $PgdMailFormConfig::mail_cc{'default'};} my %maildata = ( 'From' => $in{'email'}, 'To' => $PgdMailFormConfig::mail_to{$type}, 'Cc' => $PgdMailFormConfig::mail_cc{$type}, 'Bcc' => $PgdMailFormConfig::mail_bcc{$type}, 'Subject' => $PgdMailFormConfig::mail_subject{$type}, 'Return-Path' => '', 'Data' => $mail->output(), ); # Unicode -> JIS u if ($PgdMailFormConfig::utf8_char_fix) { # tH[ʂhtmlev[g my $html_template_file = $PgdMailFormCommon::template_dir . $type . '/' . $PgdMailFormCommon::template_form; # ev[gftHgev[g𗘗p if (!-e $html_template_file) { $html_template_file = $PgdMailFormCommon::template_dir . 'default/' . $PgdMailFormCommon::template_form;} open(FILE,$html_template_file); flock(FILE,1); my @template_text =
; flock(FILE,8); close(DATA); my $template_text = join('',@template_text); # UTF8ŗLΒus if(Jcode::getcode($template_text) eq 'utf8') { foreach my $key (keys %maildata) { $maildata{$key} =~ s/\xEF\xBD\x9E/\xE3\x80\x9C/g; # `_ EFBD9E E3809C $maildata{$key} =~ s/\xEF\xBC\x8D/\xE2\x88\x92/g; # nCt EFBC8D E28892 $maildata{$key} =~ s/\xE2\x88\xA5/\xE2\x80\x96/g; # sL E288A5 E28096 } } } # [M &PgdMailFormSendmail::sendmail(\%maildata) or die("[̑MɎs܂ [$@]"); ##### MҌԓ[̑M # [ev[g my $mail_sender_template_file = $PgdMailFormCommon::template_dir . $type . '/' . $PgdMailFormCommon::template_mail_sender; # ev[gꍇ̂ݑM if (-e $mail_sender_template_file) { # ev[g̑I my $mail_sender = HTML::Template->new( 'die_on_bad_params' => 0, 'filename' => $mail_sender_template_file, ); # HTMLev[g p[^ $mail_sender->param( 'loop_list' => \@loop_list, ); # ͂ꂽev[gɏo foreach my $key (keys %form_value) { $mail_sender->param($key => $form_value{$key}); # ϐɃGR[hltăev[gɏo(TMPL_IFp) my $keystr = $form_value{$key}; $keystr =~ s/([^a-zA-Z0-9_.!~*'()-])/'%'.unpack('H2',$1)/eg; $keystr = $key . '-' . $keystr; $mail_sender->param($keystr => 1); } # [Uev[gɏo foreach my $key (keys %userinfo) { $mail_sender->param("userinfo-$key" => $userinfo{$key});} # ϐev[gɑ $mail_sender->param(%ENV); # [From̃ZNg mail_sender_to ݒ肳ĂAĂȂΑM惁[AhXFromɃZbgB my $mail_from; if ($PgdMailFormConfig::mail_sender_to{$type}) { $mail_from = $PgdMailFormConfig::mail_sender_to{$type}; } else { $mail_from = $PgdMailFormConfig::mail_to{$type}; } my %maildata = ( 'From' => $mail_from, 'To' => $in{'email'}, 'Subject' => $PgdMailFormConfig::mail_sender_subject{$type}, 'Return-Path' => '', 'Data' => $mail_sender->output(), ); # [M &PgdMailFormSendmail::sendmail(\%maildata) or die("[̑MɎs܂ [$@]"); } ##### Mʏo # html ev[g my $html_template_file = $PgdMailFormCommon::template_dir . $type . '/' . $PgdMailFormCommon::template_send; # ev[gftHgev[g𗘗p if (!-e $html_template_file) { $html_template_file = $PgdMailFormCommon::template_dir . 'default/' . $PgdMailFormCommon::template_send;} # ev[g̑I my $tmpl = HTML::Template->new( 'die_on_bad_params' => 0, 'filename' => $html_template_file, ); # ͂ꂽev[gɏo $tmpl->param(%form_value); # ϐev[gɑ $tmpl->param(%ENV); print "Content-Type: text/html\n\n"; print $tmpl->output(); } else { die('mode ܂B'); } }
苗場旅館組合案内所
949-6212 新潟県 南魚沼郡 湯沢町 三国97-7
TEL: 025-789-2706
FAX: 025-789-4181
Mail:
info@naeba.gr.jp