Open-Realty Export Script

From Real Estate Wiki

Jump to: navigation, search

Contents

Introduction

If you are using [Open-Realty http://www.open-realty.org] as your websites database backend, you might be interested in using this script to export your properties into the PropBot.com database.

Overview of the OpenPMXLite Plugin Script

The purpose of this script is to be able to allow a OpenPMXLite data feed to be created from your existing Open-Realty database and used for syndication purposes.

Once you install this script, you will need to create an account on websites that accept OpenPMXLite feeds like (PropBot.com). You may also simply allow your current website customers to view your OpenPMXLite feed using their favorite RSS reader.

PropBot.com will read your feed daily and analyze your feed by adding, changing and removing properties automatically.

Steps for Installation

Downloading



<?php

// This script is licensed under the GPL public license.
//

set_time_limit(0);
include("source/connection.inc");

$yourWebsiteDomain="http://www.example.com";


print "
<rss version='2.0' xmlns:opmxl=\"http://www.propbot.org\">
	<channel>
        <title>PropBot.com </title>
	<link>http://www.propbot.com</link>
	<description>PropBot Property Feed</description>
	<image>
		<title>PropBot.com</title>
			<url>http://www.propbot.com/images/logo1-horiz-sm.gif</url>
			<link>http://www.propbot.com</link>
	</image>";

$strSql =" SELECT hl.id, hl.title, hl.hostname, hl.extension, hl.description, CONCAT(DATE_FORMAT(hl.date, '%a, %d %b %Y'), ' 00:00:00 GMT') as date, hl.large_photo1, hl.typeId, hl.address, hl.city, hl.state, hl.zip, hl.price, hl.lotsize, hl.sft, hl.bedrooms, hl.bathrooms, hl.age, hl.status, hl.lotsizetype, hl.interiorsizetype, hl.category, hl.renttype, hl.securitydeposit, sa.firstname, sa.dphone, sa.email 
		FROM house_listings AS hl, site_admins AS sa 
		WHERE 1=1
			AND hl.hostname = sa.hostname 
			AND hl.extension = sa.extension 
			AND LENGTH(hl.state)=2 
			AND hl.address != '' 
			AND hl.city != '' 
			AND hl.state != '' 
			AND hl.zip != '' 
			ORDER BY hl.hostname";
			
$strList=mysql_query($strSql);
while($rsList = mysql_fetch_array($strList)){
	if(preg_match('[^\sa-zA-Z0-9\\:\./\-_!\+\$]', $rsList['description']) || preg_match('[^\sa-zA-Z0-9\\:\./\-_!\+\$]', $rsList['title'])) continue;
	$link = "http://www.".$rsList['hostname'].".".$rsList['extension']."/detail.php?tid=".$rsList['id'];
	
	$image = ($rsList['large_photo1']) ? "$yourWebsiteDomain/listings/large/".$rsList['large_photo1'] : "";

	$domain = "http://www.".$rsList['hostname'].".".$rsList['extension'];
	$price = (is_numeric($rsList['price'])) ? $rsList['price'] : 0;
	$description = $rsList['description'];
	$description=preg_replace('/&/',' and ',$description);
	$description=preg_replace('/[^-.!:+"\'\d\s\w]/','', $description);
	
	$title = $rsList['title'];
	$title=preg_replace('/&/',' and ',$title);
	$title=preg_replace('/[^-.!:+"\'\d\s\w]/','', $title);

	if($rsList['status'] == 0) $status = "Pending";
	elseif($rsList['status'] == 1) $status = "Active";
	elseif($rsList['status'] == 2) $status = "Closed";
	if($price == 0) $status = "Temporary Off Market";
	$status =  (preg_match("/\bsold\b/i", $title) || preg_match("/\bsold\b/i", $description)) ? "Closed" : $status;

	if(strlen($rsList['category']) == 3){
		$category = $rsList['category'];
	}else{
		$category = ($price>10 && $price<3000) ? "rfr" : "rfs";
	}
	
	$lotsizetype = ($rsList['lotsizetype']) ? $rsList['lotsizetype'] : "sqfeet";
	$interiorsizetype = ($rsList['interiorsizetype']) ? $rsList['interiorsizetype'] : "sqfeet";

	$search = array('/ acre/', '/ Acre/', '/ sq ft/', '/ Acres/', '/N/A/', '/+/', '/,/', '/ ac./', '/NA/', '/LT/', '/ ac/', '///', '/%/');
	$lotsize = preg_replace($search, '', $rsList['lotsize']);
	
	if(strpos($lotsize, '/')){
		$arr = explode('/', $lotsize);
		$lotsize = number_format($arr[0]/$arr[1], 2);
		$lotsizetype = "acres";
	}elseif(strpos($lotsize, 'x')){
		$arr = explode('x', $lotsize);
		$lotsize = $arr[0]*$arr[1];
	}

	$lotsize = (is_numeric($lotsize)) ? $lotsize : 0;
	$interiorsize = (is_numeric($rsList['sft'])) ? $rsList['sft'] : 0;
	
	switch($category){
		case 'rfs': ##Residential For Sale
			$xml="
<item>
	<title>".$title."</title>
	<link>".$link."</link>
	<guid>".$link."</guid>
	<description>".$description."</description>
	<pubDate>".$rsList['date']."</pubDate>
	<opmxl:image1>".$image."</opmxl:image1>
	<opmxl:category>".$category."</opmxl:category>
	<opmxl:propertytype>".$rsList['typeId']."</opmxl:propertytype>
	<opmxl:status>".$status."</opmxl:status>
	<opmxl:address>".preg_replace('/&/',' and ',$rsList['address'])."</opmxl:address>
	<opmxl:locality>".preg_replace('/&/',' and ',$rsList['city'])."</opmxl:locality>
	<opmxl:province>".$rsList['state']."</opmxl:province>
	<opmxl:postalcode>".$rsList['zip']."</opmxl:postalcode>
	<opmxl:price>".$price."</opmxl:price>
	<opmxl:pricetype>USD</opmxl:pricetype>
	<opmxl:lotsize>".$lotsize."</opmxl:lotsize>
	<opmxl:lotsizetype>".$lotsizetype."</opmxl:lotsizetype>
	<opmxl:interiorsize>".$interiorsize."</opmxl:interiorsize>
	<opmxl:interiorsizetype>".$interiorsizetype."</opmxl:interiorsizetype>
	<opmxl:bedrooms>".$rsList['bedrooms']."</opmxl:bedrooms>
	<opmxl:bathrooms>".$rsList['bathrooms']."</opmxl:bathrooms>
	<opmxl:latitude></opmxl:latitude>
	<opmxl:longitude></opmxl:longitude>
	<opmxl:yearbuilt>".$rsList['age']."</opmxl:yearbuilt>
	<opmxl:contactname>".preg_replace('/&/',' and ',$rsList['firstname'])."</opmxl:contactname>
	<opmxl:contactphone>".preg_replace('/&/',' and ',$rsList['dphone'])."</opmxl:contactphone>
	<opmxl:contactemail>".$rsList['email']."</opmxl:contactemail>
	<opmxl:contactdomain>".$domain."</opmxl:contactdomain>
</item>";
			break;
		case 'rfr': ##Residential For Rent
			$xml="
<item>
	<title>".$title."</title>
	<link>".$link."</link>
	<guid>".$link."</guid>
	<description>".$description."</description>
	<pubDate>".$rsList['date']."</pubDate>
	<opmxl:image1>".$image."</opmxl:image1>
	<opmxl:category>".$category."</opmxl:category>
	<opmxl:status>".$status."</opmxl:status>
	<opmxl:propertytype>".$rsList['typeId']."</opmxl:propertytype>
	<opmxl:address>".preg_replace('/&/',' and ',$rsList['address'])."</opmxl:address>
	<opmxl:locality>".preg_replace('/&/',' and ',$rsList['city'])."</opmxl:locality>
	<opmxl:province>".$rsList['state']."</opmxl:province>
	<opmxl:postalcode>".$rsList['zip']."</opmxl:postalcode>
	<opmxl:price>".$price."</opmxl:price>
	<opmxl:pricetype>USD</opmxl:pricetype>
	<opmxl:renttype>".$rsList['renttype']."</opmxl:renttype>
	<opmxl:securitydeposit>".$rsList['securitydeposit']."</opmxl:securitydeposit>
	<opmxl:lotsize>".$lotsize."</opmxl:lotsize>
	<opmxl:lotsizetype>".$lotsizetype."</opmxl:lotsizetype>
	<opmxl:interiorsize>".$interiorsize."</opmxl:interiorsize>
	<opmxl:interiorsizetype>".$interiorsizetype."</opmxl:interiorsizetype>
	<opmxl:bedrooms>".$rsList['bedrooms']."</opmxl:bedrooms>
	<opmxl:bathrooms>".$rsList['bathrooms']."</opmxl:bathrooms>
	<opmxl:latitude></opmxl:latitude>
	<opmxl:longitude></opmxl:longitude>
	<opmxl:yearbuilt>".$rsList['age']."</opmxl:yearbuilt>
	<opmxl:contactname>".preg_replace('/&/',' and ',$rsList['firstname'])."</opmxl:contactname>
	<opmxl:contactphone>".preg_replace('/&/',' and ',$rsList['dphone'])."</opmxl:contactphone>
	<opmxl:contactemail>".$rsList['email']."</opmxl:contactemail>
	<opmxl:contactdomain>".$domain."</opmxl:contactdomain>
</item>";
			break;
		case 'cfs': ##Commercial For Sale
			$xml="
<item>
	<title>".$title."</title>
	<link>".$link."</link>
	<guid>".$link."</guid>
	<description>".$description."</description>
	<pubDate>".$rsList['date']."</pubDate>
	<opmxl:image1>".$image."</opmxl:image1>
	<opmxl:category>".$category."</opmxl:category>
	<opmxl:status>".$status."</opmxl:status>
	<opmxl:propertytype>".$rsList['typeId']."</opmxl:propertytype>
	<opmxl:address>".preg_replace('/&/',' and ',$rsList['address'])."</opmxl:address>
	<opmxl:locality>".preg_replace('/&/',' and ',$rsList['city'])."</opmxl:locality>
	<opmxl:province>".$rsList['state']."</opmxl:province>
	<opmxl:postalcode>".$rsList['zip']."</opmxl:postalcode>
	<opmxl:price>".$price."</opmxl:price>
	<opmxl:pricetype>USD</opmxl:pricetype>
	<opmxl:lotsize>".$lotsize."</opmxl:lotsize>
	<opmxl:lotsizetype>".$lotsizetype."</opmxl:lotsizetype>
	<opmxl:interiorsize>".$interiorsize."</opmxl:interiorsize>
	<opmxl:interiorsizetype>".$interiorsizetype."</opmxl:interiorsizetype>
	<opmxl:latitude></opmxl:latitude>
	<opmxl:longitude></opmxl:longitude>
	<opmxl:yearbuilt>".$rsList['age']."</opmxl:yearbuilt>
	<opmxl:contactname>".preg_replace('/&/',' and ',$rsList['firstname'])."</opmxl:contactname>
	<opmxl:contactphone>".preg_replace('/&/',' and ',$rsList['dphone'])."</opmxl:contactphone>
	<opmxl:contactemail>".$rsList['email']."</opmxl:contactemail>
	<opmxl:contactdomain>".$domain."</opmxl:contactdomain>
</item>";
			break;
		case 'cfl': ##Commercial For Lease
			$xml="
<item>
	<title>".$title."</title>
	<link>".$link."</link>
	<guid>".$link."</guid>
	<description>".$description."</description>
	<pubDate>".$rsList['date']."</pubDate>
	<opmxl:image1>".$image."</opmxl:image1>
	<opmxl:category>".$category."</opmxl:category>
	<opmxl:status>".$status."</opmxl:status>
	<opmxl:propertytype>".$rsList['typeId']."</opmxl:propertytype>
	<opmxl:address>".preg_replace('/&/',' and ',$rsList['address'])."</opmxl:address>
	<opmxl:locality>".preg_replace('/&/',' and ',$rsList['city'])."</opmxl:locality>
	<opmxl:province>".$rsList['state']."</opmxl:province>
	<opmxl:postalcode>".$rsList['zip']."</opmxl:postalcode>
	<opmxl:price>".$price."</opmxl:price>
	<opmxl:pricetype>USD</opmxl:pricetype>
	<opmxl:rentType>".$rsList['renttype']."</opmxl:rentType>
	<opmxl:lotsize>".$lotsize."</opmxl:lotsize>
	<opmxl:lotsizetype>".$lotsizetype."</opmxl:lotsizetype>
	<opmxl:interiorsize>".$interiorsize."</opmxl:interiorsize>
	<opmxl:interiorsizetype>".$interiorsizetype."</opmxl:interiorsizetype>
	<opmxl:latitude></opmxl:latitude>
	<opmxl:longitude></opmxl:longitude>
	<opmxl:yearbuilt>".$rsList['age']."</opmxl:yearbuilt>
	<opmxl:contactname>".preg_replace('/&/',' and ',$rsList['firstname'])."</opmxl:contactname>
	<opmxl:contactphone>".preg_replace('/&/',' and ',$rsList['dphone'])."</opmxl:contactphone>
	<opmxl:contactemail>".$rsList['email']."</opmxl:contactemail>
	<opmxl:contactdomain>".$domain."</opmxl:contactdomain>
</item>";
			break;
		case 'lfs': ##Land For Sale
			$xml="
<item>
	<title>".$title."</title>
	<link>".$link."</link>
	<guid>".$link."</guid>
	<description>".$description."</description>
	<pubDate>".$rsList['date']."</pubDate>
	<opmxl:image1>".$image."</opmxl:image1>
	<opmxl:category>".$category."</opmxl:category>
	<opmxl:status>".$status."</opmxl:status>
	<opmxl:propertytype>".$rsList['typeId']."</opmxl:propertytype>
	<opmxl:address>".preg_replace('/&/',' and ',$rsList['address'])."</opmxl:address>
	<opmxl:locality>".preg_replace('/&/',' and ',$rsList['city'])."</opmxl:locality>
	<opmxl:province>".$rsList['state']."</opmxl:province>
	<opmxl:postalcode>".$rsList['zip']."</opmxl:postalcode>
	<opmxl:price>".$price."</opmxl:price>
	<opmxl:pricetype>USD</opmxl:pricetype>
	<opmxl:lotsize>".$lotsize."</opmxl:lotsize>
	<opmxl:lotsizetype>".$lotsizetype."</opmxl:lotsizetype>
	<opmxl:latitude></opmxl:latitude>
	<opmxl:longitude></opmxl:longitude>
	<opmxl:yearbuilt>".$rsList['age']."</opmxl:yearbuilt>
	<opmxl:contactname>".preg_replace('/&/',' and ',$rsList['firstname'])."</opmxl:contactname>
	<opmxl:contactphone>".preg_replace('/&/',' and ',$rsList['dphone'])."</opmxl:contactphone>
	<opmxl:contactemail>".$rsList['email']."</opmxl:contactemail>
	<opmxl:contactdomain>".$domain."</opmxl:contactdomain>
</item>";
			break;
	} ##END SWITCH
	print $xml."\n";
}##END WHILE
print "
	</channel>
</rss>";
?>

Installation

The script will need to be installed into a public directory where the PropBot.com servers can see it on the web. Generally, it can be installed in the public_html directory and should be fine.

Modifications Needed

Open-Realty needs to have a couple modifications added into the system so that the properties will by congruent with the PropBot.com Search engine.

  1. Property Types needs to be added in ENUM
  2. Property Status Types needs to be added in ENUM
  3. DateUpdated Field needs to be added in TIMESTAMP
Personal tools