#!/usr/bin/perl

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



require "config.idx";

$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; }
	}
}



&header;

print qq~
<td valign="top" width="581">
<table border="0" cellpadding="0" cellspacing="0" width="581">
<tr>
<td valign="top" colspan="2" width="581">
<img src="images/headers/myhomes_account.gif" height="33" width="581" alt="MY HOMES Account"><br>
</td>
</tr>
<tr>
<td colspan="2" valign="top" width="581" align="right">
<b>[</b> <a href="myhomes.idx">Back to MyHomes</a> <b>]</b><img src="images/line_spacer.gif" height="1" width="5"><br>
</td>
</tr>
<tr>
<td colspan="2" valign="Top"><img src="images/line_spacer.gif" width="581" height="4"><br></td>
</tr>
<tr><td valign=top colspan=2>

~;

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 $masth = $dbh->prepare("select * from new_listings where listingtype = 'res'");
$masth->execute;

print <<"TOPOFTHETABLE";
<strong>Residential</strong><br>

TOPOFTHETABLE

while (($mlsnumber,$listingtype) = $masth->fetchrow_array()) {

print "MLS\# <a href=\"showdetails.idx?mlsnumber=$mlsnumber\">$mlsnumber</a><br>";

}

print <<"TOPOFTHETABLE";
<br><br><strong>Commercial</strong><br>

TOPOFTHETABLE


my $masth = $dbh->prepare("select * from new_listings where listingtype = 'com'");
$masth->execute;

while (($mlsnumber,$listingtype) = $masth->fetchrow_array()) {

print "MLS\# <a href=\"showdetails_commercial.idx?mlsnumber=$mlsnumber\">$mlsnumber</a><br>";

}


print <<"TOPOFTHETABLE";
<br><br><strong>Investment</strong><br>

TOPOFTHETABLE



my $masth = $dbh->prepare("select * from new_listings where listingtype = 'inv'");
$masth->execute;

while (($mlsnumber,$listingtype) = $masth->fetchrow_array()) {

print "MLS\# <a href=\"showdetails_investment.idx?mlsnumber=$mlsnumber\">$mlsnumber</a><br>";

}


print <<"TOPOFTHETABLE";
<br><br><strong>Land</strong><br>

TOPOFTHETABLE



my $masth = $dbh->prepare("select * from new_listings where listingtype = 'lan'");
$masth->execute;

while (($mlsnumber,$listingtype) = $masth->fetchrow_array()) {

print "MLS\# <a href=\"showdetails_land.idx?mlsnumber=$mlsnumber\">$mlsnumber</a><br>";

}










&footer;