#!/usr/local/bin/perl



require './jcode.pl';

$req_method = $ENV{'REQUEST_METHOD'};



$htmlfile = "/usr/home/heimei/hikkosi/thanks.htm";



($sec,$min,$hour,$mday,$mon,$year) = localtime(time);

$year = ($year + 1900);

$month = ($mon + 1);



if ($req_method eq "GET") {

	$form_info = $ENV{'QUERY_STRING'};

} elsif ($req_method eq "POST") {

	$formsize = $ENV{'CONTENT_LENGTH'};

	read (STDIN,$form_info,$formsize);

}



$value = $form_info;

@form_data = split(/&/,$form_info);

foreach $pair (@form_data) {

	($form_name,$value) = split(/=/,$pair);

	$value =~ tr/+/ /;

	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;

	$code = &jcode'convert(*value,'jis');

	$FORM{$form_name} = $value;

}



	&yurikoMailForm;

	&ResaultHtml;

exit(0);



sub yurikoMailForm {

	open(MAIL,"|mail matsu\@esaka.co.jp");

	print MAIL "\n$FORM{'subject'}\n\n";

	print MAIL "$FORM{'sendedtime'}

$year$FORM{'idnen'}$month$FORM{'idtuki'}$mday$FORM{'idhi'} $hour$FORM{'ji'} $min$FORM{'fun'}\n\n";

print MAIL <<EofMailFormat;



$FORM{'idkibou'}

$FORM{'boat'}

$FORM{'old'}

$FORM{'marine'}

$FORM{'new'}

$FORM{'event'}

$FORM{'rental'}



$FORM{'idmail'} = $FORM{'mail'}

$FORM{'idmassage'} = $FORM{'massage'}



$FORM{'idadd'} = $FORM{'pre'}$FORM{'add'}

$FORM{'idname'} = $FORM{'name'}

$FORM{'idtell'} = $FORM{'tell'}



$FORM{'idotodoke'} = $FORM{'nen'}$FORM{'idnen'}$FORM{'tuki'}$FORM{'idtuki'}$FORM{'hi'}$FORM{'idhi'}

$FORM{'idtime'} = $FORM{'time'}\n\n





EofMailFormat

	close(MAIL);

}

sub ResaultHtml {

	open (IN,$htmlfile) || die "Cannot open $htmlfile for reading\n";

	print "Content-type: text/html\n\n";

	while(<IN>) { print$_; }

	close(IN);

}



