#!/usr/local/bin/perl
print "Content-type: text/html\n\n";


# When "POST", the input from the standard input is stored into the variable $str
if ($ENV{'REQUEST_METHOD'} eq "POST") {
    read(STDIN, $str, $ENV{'CONTENT_LENGTH'});
} else {
    $str = $ENV{'QUERY_STRING'};
}

# Decode
@part = split(/&/, $str);
foreach $i (@part) {
    ($variable, $value) = split(/=/, $i);
    $value =~ tr/+/ /;
    $value =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack("C", hex($1))/eg;
    $value =~ s/</&lt;/g;
    $value =~ s/>/&gt;/g;
    $value =~ s/\r\n/\n/g;
    $value =~ s/\r/\n/g;
    $cgi{$variable} = $value;
}

# Mail-Address
$myname = "MYNAME";
$mymail = "MYNAME\@MYDOMAIN";
$mailto = "/usr/bin/mail " . $mymail;

#

# Program Body

#
if ($cgi{'addr'} eq "" ) {
    print &print_value(<<EOF);
    <TITLE>oversight</TITLE>
    <H1><FONT color="red">Submission is not completed</FONT></H1>
<BR>
Your <STRONG>E-mail address</STRONG> is not filled out in the input form. 
<p>
Please click the "<STRONG>Back</STRONG>" button of your Web browser. 
If you want to clear all, then click <a href="http://URL/reviewersample.html">Clear All and Back to the Input Form</a>.  
    <HR>
    <ADDRESS>
        If you have any questions or problems, please contact with the, Please contact with the Administrator: <A HREF="mailto:$mymail">$mymail</A>
    </ADDRESS>
EOF
    exit (1);
}

$tmp = "/var/tmp/ReviewInfo";
open(FILE, ">$tmp");
flock(FILE, 2);
 print FILE "$str";
close(FILE);
flock(FILE, 8);
#
print &print_value(<<EOF);

    <HEAD><TITLE>Your Preference</TITLE></HEAD>
    <BODY>
<H1>
Preference of Interested Papers for PC members 
</H1>
<H2>
<FONT color="red">Step 2: Confirmation </FONT>
</H2>

<HR>

<p>
Please <STRONG>click</STRONG> "<STRONG>Submit Information</STRONG>" to submit. 

<UL>
    <LI> E-mail Address : <B>$cgi{'addr'}</B>
    <LI> Preference :
<UL>
EOF
if ($cgi{'paper01'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper01'}
EOF
}
if ($cgi{'paper02'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper02'}
EOF
}
if ($cgi{'paper03'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper03'}
EOF
}
if ($cgi{'paper04'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper04'}
EOF
}
if ($cgi{'paper05'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper05'}
EOF
}
if ($cgi{'paper06'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper06'}
EOF
}
if ($cgi{'paper07'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper07'}
EOF
}
if ($cgi{'paper08'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper08'}
EOF
}
if ($cgi{'paper09'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper09'}
EOF
}
if ($cgi{'paper10'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper10'}
EOF
}
if ($cgi{'paper11'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper11'}
EOF
}
if ($cgi{'paper12'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper12'}
EOF
}
if ($cgi{'paper13'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper13'}
EOF
}
if ($cgi{'paper14'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper14'}
EOF
}
if ($cgi{'paper15'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper15'}
EOF
}
if ($cgi{'paper16'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper16'}
EOF
}
if ($cgi{'paper17'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper17'}
EOF
}
if ($cgi{'paper18'} ne "" ) {
print &print_value(<<EOF);
        <LI> $cgi{'paper18'}
EOF
}
print &print_value(<<EOF);
</UL>
    <LI>Comments : <B>$cgi{'comment'} <BR></B>
</UL>

<p>
<FORM ACTION="http://URL/myinput.cgi" method="post">
<INPUT TYPE="submit" VALUE="Submit Information">
</FORM>

<p>
    <A href="http://URL/reviewersample.html">Clear All and Back to the input form</A>

<HR>
      If you have any questions or problems, please contact with the Administrator: <A HREF="mailto:$mymail">$mymail</A>)
    </BODY>
EOF

exit;

sub print_value{
    local($value) = @_;
    $value;
}
