#!/usr/bin/perl

print "Content-type: application/rss+xml\n\n";
require "config.idx";

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,County,ListingOffice1Name,AgentName,AgentPhone,AgentID,MLSNUM,Bedrooms,YearBuilt,TotalSqFt,FullBaths,HalfBaths,Acres,AgentID,Remarks from listings_res3 WHERE ListingOffice1ID = '48'");
$uasth->execute;

print qq~<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Eagle Real Estate, Inc.  RSS Listing Feed</title>
<link>http://www.EagleSold.com/</link>
<description>Feed of All new listings by Eagle Real Estate, Inc.</description>
<lastBuildDate>Mon, 12 Sep 2005 18:37:00 GMT</lastBuildDate>
<language>en-us</language>~;
while (($Price,$AddressNumber,$AddressDirection,$AddressStreet,$City,$Zip,$County,$ListingOffice1Name,$AgentName,$AgentPhone,$AgentID,$MLSNUM,$Bedrooms,$YearBuilt,$TotalSqFt,$FullBaths,$HalfBaths,$Acres,$AgentID,$Remarks) = $uasth->fetchrow_array()) {

$Remarks =~ s/\'//gi;
$Remarks =~ s/\’//gi;
$Remarks =~ s/\"//gi;
$Remarks =~ s/\&//gi;
$Remarks =~ s/\<//gi;
$Remarks =~ s/\>//gi;
$Remarks =~ s/\-//gi;
$Remarks =~ s/\–//gi;
print qq~<item>
<title>$AddressNumber $AddressDirection $AddressStreet, $City</title>
<link>http://$MLSNUM.MuncieMLS.com</link>
<guid>http://$MLSNUM.MuncieMLS.com</guid>
<description><![CDATA[$Remarks]]><img src=http://media2.idxnow.com/meiar/thumbnail/meiarmls$MLSNUM.jpg></description>
</item>~;
}
print qq~
</channel>
</rss>~;