MOON
Server: Apache
System: Linux 3-228-103-98.cprapid.com 3.10.0-1160.62.1.el7.x86_64 #1 SMP Tue Apr 5 16:57:59 UTC 2022 x86_64
User: api (1001)
PHP: 8.0.30
Disabled: NONE
Upload Files
File: /home/api/public_html/nashville/get-agent-listings.php
<?php
ini_set( "memory_limit", "128M" );
require( "php/config.php" );

$oRes = new Result( "SearchResults" );
$oSearch = new Search();
$oSearch->setActive( true );

foreach ( $_GET as $k => $v )
{
    switch( strtolower( $k ) )
    {
        case "agentid":
            if ( preg_match( "@^[[:alnum:],]+$@", $v ) === 1 )
                $aAgentIDs = explode( ",", $v );
            break;
        case "active":
            if ( $v === "1" )
                $bActive = true;
            break;
        case "https":
            if ( strtolower( $v ) == "on" )
                $oRes->bHttps = true;
            break;
        case "sold":
            if ( $v === "1" )
            {
                $oRes->aSearchReturnFields[] = "ClosedDate";
                $oRes->aSearchReturnFields[] = "SalePrice";
                $oSearch->setVal( 'propertystatus', 'off-market' );
                $oSearch->setVal( "sortby", "SalePrice" );
            }
            break;
        case "closeddate":
            if ( preg_match( "@^[\d]{4}-[\d]{2}-[\d]{2}$@", $v ) === 1 )
            $oSearch->setVal( 'closeddate', $v );
            break;
        case "limit":
            if ( is_numeric( $v ) )
                $oRes->setLimit( $v );
            break;
    }
}

if ( is_array( $aAgentIDs ) && ( count( $aAgentIDs ) > 0 ) )
{
//    foreach ( $aAgentIDs as &$aAID )
//        $aAID = "RTC" . $aAID;
    $oSearch->setVal( "ListingAgentID", $aAgentIDs );
}
        
$aResult = $oSearch->doQuery();
if ( isset( $aResult["Data"] ) )
{
	$oRes->addData( $aResult["Data"], "Data" );
}
$oRes->addData( $oSearch->aSQLStatements, "sql" );

$oMLS->finish( "nashville", "agent-listings", json_encode( $_GET ) );

print $oRes->getJSON();