#!/usr/bin/perl

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


print <<"top";

<html>
<head>
<title>Eagle Real Estate, Inc.</title>
<meta http-equiv="Refresh" content="15; URL=presentation.idx">
</head>
<body bgcolor="white" leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="640">
<tr>
<td valign="top" width="640">

top

$d_name = "muncieml_db1";
$d_username = "muncieml_db1";
$d_pass = "\@rockdb1";


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 $uasth = $dbh->prepare("select Price,AddressNumber,AddressDirection,AddressStreet,City,Zip,Status,MLSNUM,Bedrooms,FullBaths,HalfBaths,TotalSqFt,Acres,AgentID,AgentName,CoAgentID,CoAgentName,ListingOffiice1Name,ListingOffice1Phone,ListingOffice1ID,Remarks from listings_res where ListingOffice1ID = '130' order by RAND() limit 1");
$uasth->execute;

$dbh->disconnect;

while (($Price,$AddressNumber,$AddressDirection,$AddressStreet,$City,$Zip,$Status,$MLSNUM,$Bedrooms,$FullBaths,$HalfBaths,$TotalSqFt,$Acres,$AgentID,$AgentName,$CoAgentID,$CoAgentName,$ListingOffiice1Name,$ListingOffice1Phone,$ListingOffice1ID,$Remarks) = $uasth->fetchrow_array()) {


open(DBFILE,"/home/muncieml/public_html/remarksdb.txt");
@dbfile = <DBFILE>;
close(DBFILE);

foreach $dbline (@dbfile) {
$dbline =~ s/\n//gi;
if ($dbline) {
$Remarks =~ s/(.*?)$dbline//gi;
}
#$makestuff .= "$dbline\n";
}

$Remarks =~ s/CHR1/\'/gi;
$Remarks =~ s/CHR2/\"/gi;

if (-e "/home/muncieml/public_html/images/photos/full/meiar$MLSNUM\.jpg") {
$photourl = "http://www.munciemls.com/images/photos/full/meiar$MLSNUM\.jpg";
}
else {
$photourl = "http://www.eagle-online.com/images/featured_nophoto.gif";
}

$Price = &commas($Price);

if($HalfBaths eq "None") {
$HalfBaths = "0"
}
else {
}

print qq~

<table border="0" cellpadding="0" cellspacing="0" width="640">
<tr>
<td valign="top" bgcolor="white" width="250">
<img src="listing_overview.gif"><br>
</td>
<td valign="top" bgcolor="white" width="390">
<font size="6" face="Arial">
<b>$AddressNumber $AddressDirection $AddressStreet</b></font><br>
<font size="1" face="Arial"><b>$City, Indiana $Zip</b></font><br>
</td>
</tr>
<tr>
<td valign="top" colspan="2" bgcolor="white" width="640">
	<table border="0" cellpadding="0" cellspacing="0" width="640">
	<tr>
	<td valign="top" bgcolor="white" width="250">

		<table border="0" cellpadding="3" cellspacing="0" width="100%">
		<tr>
		<td valign="top" width="100%">
			<font size="4" face="Arial"><b>Listing Price \$$Price</b><br>
			<b>MLS</b> #$MLSNUM</font><br>
		</td>
		</tr>
		<tr>
		<td valign="top" width="100%" bgcolor="#E2E2E2">
			<font size="3" face="Arial"><b>Beds</b> $Bedrooms   <b>Baths</b> $FullBaths Full - $HalfBaths Half</font><br>
		</td>
		</tr>
		<tr>
		<td valign="top" width="100%">
			<font size="3" face="Arial"><b>SQFT.</b> $TotalSqFt<br>    <b>Acres</b> $Acres</font><br>
		</td>
		</tr>
		<tr>
		<td valign="top" width="100%" bgcolor="#E2E2E2">
			<font size="4" face="Arial">
			<font size="2"><i>Presented By:</i></font><br>
			<b>$AgentName<br>
			$ListingOffiice1Name<b>
			</font><br>
		</td>
		</tr>
		<tr>
		<td valign="top" width="100%">
			<font size="2" face="Arial"><b>Remarks:</b> $Remarks</font>
		</td>
		</tr>
		</table>

	</td>
	<td valign="top" bgcolor="white" width="390">
	<br>
		<center>
			<table border="0" cellpadding="0" cellspacing="0" width="381">
			  <tr>
			    <td width="333">
			    <img border="0" src="$photourl" width="333" height="250"><br>
			    </td>
			    <td width="333" rowspan="2">
			    <img border="0" src="right_pic.jpg"></td>
			  </tr>
			  <tr>
			    <td>
			    <img border="0" src="bottom_pic.jpg"></td>
			  </tr>
			</table>
		</center>
	</td>
	</tr>
	</table>
</td>
</tr>
</table>

~;
}


print <<"TheEND";

</td>
</tr>
</table>
</center>
</body>
</html>

TheEND



sub commas {
	local($_)=@_;
	1 while s/(.*\d)(\d\d\d)/$1,$2/;
	$_;
}