#!/usr/bin/perl
#fjoin.cgi


#$mydir=`pwd`;
#chop $mydir;
require"cgi-lib.pl";


$email="anthony\@stepupeng.com";
$from = "Hair and Beauty";
&ReadParse(*in);

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

foreach (sort keys %ENV)
{
  #print "<b>$_</b>: $ENV{$_}<br>\n";
}


my($ua) = $ENV{HTTP_USER_AGENT};
my($uc) = $ENV{HTTP_ACCEPT_LANGUAGE};

#print "User-agent: $ua<p>\n";
if (index($ua, "MSIE") > -1) {
   #print "Your browser is Internet Explorer.<p>\n";
   $ub = "Internet Explorer.\n"; 
} elsif (index($ua, "Netscape") > -1) {
   #print "Your browser is Netscape.<p>\n";
   $ub = "Netscape.\n";
} elsif (index($ua, "Safari") > -1) {
   #print "Your browser is Safari.<p>\n";
   $ub = "Safari.\n";
} elsif (index($ua, "Opera") > -1) {
   #print "Your browser is Opera.<p>\n";
   $ub = "Opera.\n";
} elsif (index($ua, "Mozilla") > -1) {
   print "Your browser is probably Mozilla.<p>\n";
   $ub = "Mozilla.\n";
} else {
   print "I give up, I can't tell what browser you're using!<p>\n";
   $ub = "I give up, I can't tell what browser you're using!\n";
}

 print "$uc\n";
my $rem_ip = $ENV{REMOTE_ADDR}; 
#my $query = $ENV{QUERY_STRING};
my $datestring = localtime();
my $type = $ENV{HOSTNAME};
#my $len  = $ENV{CONTENT_LENGTH};
#my $meth = $ENV{REQUEST_METHOD};
#my $query = $ENV{QUERY_STRING};
#my $agent = $ENV{HTTP_USER_AGENT};
my $uc = $ENV{HTTP_ACCEPT_LANGUAGE}; 
my $host =(grep {chomp;} system ('hostname -s'))[0]; 

 open my $fh, '<', 'coffeelivecntr6.txt' or die "Ouch: $!\n";

 my $text = do {
   local $/;
   <$fh>
 };
 close $fh or die "Ugh: $!\n";
 
 print "$rem_ip\n";
 print "$text\n";
 print "$type\n"; 
 print "$datestring\n";
 print "$ub\n";	 
 print "$uc\n";
 #print "$meth\n";
 #print "$host\n";
 #print "$addr\n";
 #print "$agent\n";
 #my $host =system ('Hostname'); 
 my $host =(grep {chomp;} system ('hostname -s'))[0]; 

print "<html><head><TITLE>CD ORDER</TITLE></HEAD><BODY bgcolor=#E8E8E8>";
#print "<base href=\"/Product.htm\">";
print "<center><img src=\"/logo.gif\"></center><p>\n";
print "<center><h1>CD ORDER</h1></center>";
print "";

print "<center><tt><font size=+1>謝謝你的登記</font></tt>";
print "<center>If you have any questions, please send us a mail:<BR> ";
print "<center><a href=\"mailto:anthony\@stepupeng.com\">anthony\@stepupeng.com";
print "</a><center><a href=\"mailto:anthony\@stepupeng.com\"></a><a href=\"/index.htm\">BACK";
print "</a></center></center></center></center></BODY></HTML>";

$subject="二手咖啡機 SecHand";
my $send="/usr/sbin/sendmail -t";
my $mailout="|$send";
open(MAIL,$mailout);
# open(MAIL,"I mail-s\"$subject\"$email");
print MAIL "To: $email,$in{'email'}\n";
print MAIL "From: $email\n";
print MAIL "Subject: $subject,$rem_ip\n";
print MAIL "二手咖啡機 SecHand",$in{'name'},"\n";
print MAIL "IP ",$rem_ip,"\n";
print MAIL "No. of man ",$text,;
print MAIL "Browser ",$ub,;
print MAIL "Language ",$uc,"\n";
print MAIL "Time ",$datestring,"\n";

close(MAIL);
exit
