File: /home/api/public_html/charlottesville/get-office-listings.php
<?php
$aOfficeIDs = false;
$bSold = false;
$bActive = true;
$iLimit = false;
foreach ( $_GET as $k => $v )
{
switch( strtolower( $k ) )
{
case "officeid":
if ( preg_match( "@^[[:alnum:],]+$@", $v ) === 1 )
$aOfficeIDs = explode( ",", $v );
break;
case "sold":
if ( $v === "1" )
$bSold = true;
break;
case "active":
if ( $v === "1" )
$bActive = true;
break;
case "limit":
if ( is_numeric( $v ) )
$iLimit = $v;
}
}
require( "php/config.php" );
$oRes = new Result( "OfficeListings" );
if ( ! $aOfficeIDs )
$oRes->FatalError( "OfficeID is not valid" );
$aMLS = array();
foreach ( $aOfficeIDs as $sOfficeID )
{
$tmp = $oMLS->getPropsByOffice( $sOfficeID );
if ( $tmp )
{
foreach ( $tmp as $prop )
$oRes->addData( $prop );
}
else $oRes->addError( "OfficeID '" . $sOfficeID . "' is not valid." );
}
print $oRes->getJSON();