#!/usr/bin/perl

print "Content-type: text/html\n\n";
$long = $ENV{'QUERY_STRING'};

if ($long) {
	@pairs=split(/&/,$long);
	foreach $item(@pairs) {
		($name,$content)=split (/=/,$item,2);
		$content=~tr/+/ /;
		$content=~ s/%(..)/pack("c",hex($1))/ge;
		if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$content; }
		else { $INPUT{$name} = $content; }
	}
}
else {
	read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
	@pairs = split(/&/, $buffer);
	foreach $pair (@pairs) {
		($name, $value) = split(/=/, $pair);
		$value =~ tr/+/ /;
		$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
		if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$value; }
		else { $INPUT{$name} = $value; }
	}
}
require "config.idx";

print qq~
<html>
<head>
<title>Users Feedback >> Eagle Real Estate MuncieMLS.com</title>
~;
&header;

print qq~
<td valign=top>
<script language="Javascript1.2"><!-- // load htmlarea
_editor_url = "/htmlarea/";                     // URL to htmlarea files
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
 document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
 document.write(' language="Javascript1.2"></scr' + 'ipt>');  
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
// --></script>
<img src="images/headers/contact_us.gif" width="581" height="33" alt="User Feedback"><Br>
<table border="0" cellpadding="6" cellspacing="0" width="581">
<tr>
<td valign="top">

<table cellSpacing="0" cellPadding="0" width="100%" border="0" NOF="LY">
  <tr vAlign="top" align="left">
    <td width="100%">
    <font face="Arial,Helvetica,Univers,Zurich BT,sans-serif" size="-1">
    <font face="Arial,Helvetica,Univers,Zurich BT,sans-serif" color="#7fc28b" size="+2">
    <b>Send Feedback On The Use Of MuncieMLS.com</b></font></font></td>
  </tr>
</table>
<table cellSpacing="0" cellPadding="0" border="0" NOF="LY">
  <tr vAlign="top" align="left">
    <td width="13" height="14">
    <img height="1" src="images/line_spacer.gif" width="13" border="0"></td>
    <td>&nbsp;</td>
  </tr>
  <tr vAlign="top" align="left">
    <td>&nbsp;</td>
    <td width="100%">
    <table id="Table1" cellSpacing="0" cellPadding="0" width="100%" border="0">
      <tr vAlign="center">
        <td width="100%" height="24">
        <font face="Arial,Helvetica,Univers,Zurich BT,sans-serif" size="-1">
As we are continually trying to improve www.MuncieMLS.com we would like to hear from our users.  You feedback will be used to further improve our website!<br><br>
~;

if ($INPUT{action} eq "send") {

$temp_message = $INPUT{comments};
$temp_message =~ s/\"/\&quot;/g;

			open(MAIL,"|/usr/sbin/sendmail -t");
			print MAIL "To: ryan.orr\@eaglesold.com\n";
			print MAIL "From: <$INPUT{firstname} $INPUT{lastname}> $INPUT{email}\n";
			print MAIL "Subject: New MuncieMLS.com Feedback From $INPUT{firstname} $INPUT{lastname}\n";
			print MAIL "Content-type: text/html\n\n";
			print MAIL qq~
			<html>
			<head>
			<title>Official Eagle Real Estate, Inc. E-Mail</title>
			<link rel="stylesheet" TYPE="text/css" href="http://www.munciemls.com/includes/style.css">
			</head>
			<body bgcolor="white" leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">
			<br><br>
			<center>
			<table border="0" cellspacing="0" cellpadding="0" width="600">
			<tr>
			<td valign="top" width="600">
			<img src="http://www.munciemls.com/images/emailheader.gif"><br>
			<table border="0" cellspacing="0" cellpadding="15" width="100%">
			<tr>
			<td valign="top" width="100%">
			<font size="2">
				<font color="red">The Following Feedback Was Received</font><br><br>
				<b>From:</b><br>
				$INPUT{firstname} $INPUT{lastname}<br>
				<b>E-Mail:</b> $INPUT{email}<br>
				<b>MuncieMLS.com Userid:</b> $INPUT{userid}<br><br>
				<b>Comments:</b><br>
				$temp_message<br>
			<br><br><br>
			</font>
			</td>
			</tr>
			</table>
			<img src="http://www.munciemls.com/images/emailfooter.gif"><br><br><br>
			</td>
			</tr>
			</table>
			</center>
			</body>
			</html>
			~;
			close(MAIL);



print qq~
<font size="2" color="red">Thank You for your feedback!  The Following Comments Have Been Sent:<br></font>
<table border="0" cellpadding="4" cellspacing="0">
<tr>
<td><b>Firstname:</b></td><td width="100%">$INPUT{firstname}</td>
</tr>
<tr>
<td><b>Lastname:</b></td><td width="100%">$INPUT{lastname}</td>
</tr>
<tr>
<td><b>E-Mail:</b></td><td width="100%">$INPUT{email}</td>
</tr>
<tr>
<td colspan="2"><b>Your Comments / How Can We Improve?</b></td>
</tr>
<tr>
<td colspan="2">
$temp_message<br>
</td>
</tr>
</table>
~;
}
else {

use DBI;
my $dsn = "DBI:mysql:database=$d_name;host=localhost";
my $dbh = DBI->connect($dsn, $d_username, $d_pass, {RaiseError => 1}) || die $DBI::errstr;


my $rqasth = $dbh->prepare("select firstname,lastname from users where userid = '$Cook{userid}'");
$rqasth->execute;
while (($rfirstname,$rlastname) = $rqasth->fetchrow_array()) {
$temp_firstname = $rfirstname;
$temp_lastname = $rlastname;
}
print qq~
<script language="JavaScript1.2" defer>
	editor_generate('comments');
</script>
<form method="post" action="feedback.idx">
<input type="hidden" name="action" value="send">
<input type="hidden" name="userid" value="$Cook{userid}">
<table border="0" cellpadding="4" cellspacing="0">
<tr>
<td><b>Firstname:</b></td><td><input type="text" name="firstname" value="$temp_firstname"></td>
</tr>
<tr>
<td><b>Lastname:</b></td><td><input type="text" name="lastname" value="$temp_lastname"></td>
</tr>
<tr>
<td><b>E-Mail:</b></td><td><input type="text" name="email" value="$Cook{email}"></td>
</tr>
<tr>
<td colspan="2"><b>Your Comments / How Can We Improve?</b></td>
</tr>
<tr>
<td colspan="2">
<textarea rows="26" name="comments" cols="62"></textarea><br>
<input type="submit" value="Send Your Feedback Now!">
</td>
</tr>
</table>
</form>


~;
}
print qq~
</font></td>
      </tr>
    </table>
    </td>
  </tr>
</table>
</td>
</tr>
</table>
~;
&footer;


