> Template for MY ACTIVE PROPERTIES Page * ---------------------------------------------------------------------------------------------------------------------- */ ?> > Active Listings |------------------------------------------------------------------------------------------------ */ $active_listings = array(); $MLSIDs = array(); $error = 0; if($wp_plugin_aem_params['plugin_aem_option_api_key'] == "") { $error++; } // check if no error if($error == 0) { if(count($db_listings['active_listings']) > 0) { $sl = 0; foreach($db_listings['active_listings'] as $db_active_listings) { $MLSIDs[$db_active_listings['MLS']] = $db_active_listings['MLS']; $active_listings[$sl] = unserialize(base64_decode($db_active_listings['full_property_details'])); $active_listings[$sl]['DefaultImageURL']['value'] = $db_active_listings['DefaultImageURL']; $active_listings[$sl]['DefaultThumbnailURL']['value'] = $db_active_listings['DefaultThumbnailURL']; $sl++; } } if($wp_plugin_aem_params['plugin_aem_option_xml_agent_enable'] == "Yes" && $wp_plugin_aem_params['plugin_aem_option_xml_agent'] > 0) { $my_active_listings_status = array(); $my_active_listings_status[] = "Active"; $my_active_listings_status[] = "Act. Cont."; foreach($my_active_listings_status as $listing_status) { // set xml query $xml_query_url = "query?status=".urlencode($listing_status)."&limit=100&page=0&agent=".$wp_plugin_aem_params['plugin_aem_option_xml_agent']."&apikey=".$wp_plugin_aem_params['plugin_aem_option_api_key']; // set the xml url (Baycentric Web Service URL with XML Query) $xml_url = $wp_plugin_aem_params['plugin_aem_option_xml_parser'].rawurlencode($xml_query_url); #echo ''.$listing_status.''; // set response to null $response_xml = ''; // initiate curl object $request = curl_init($xml_url); // set to 0 to eliminate header info from response curl_setopt($request, CURLOPT_HEADER, 0); // Returns response data instead of TRUE(1) curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // uncomment this line if you get no gateway response. curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // execute curl post and store results in $xml $response_xml = curl_exec($request); // check CURL for error if ($curl_error = curl_error($request)) { $error++; // error counter } // check if no response_xml if($response_xml == '') { $error++; // error counter } // close curl curl_close($request); // check if no error found if($error == 0) { // parse the xml content & store into array $arr = xml2array($response_xml); // check if array contains Listings array key if (sizeof($arr) == 1 && $arr["Listings"]) { // check if the Listings array key has Listings if (array_key_exists("Listing", $arr["Listings"])) { // check & get only the Listing if(array_key_exists("MLS", $arr["Listings"]["Listing"])) { #$property_active_results_listing[] = $arr["Listings"]; $property_active_results = $arr["Listings"]; } else { // get the Listings $property_active_results = $arr["Listings"]["Listing"]; } // end if else -- if(array_key_exists("MLS", $arr["Listings"]["Listing"])) // check the total listings if(count($property_active_results) > 0) { // loop through the active results (Listings) foreach($property_active_results as $active_results) { // MLS Listing# if($active_results["MLS"]["value"] != "" || $active_results["MLS"]["value"] > 0) { // re-check if the listing is already added if($MLSIDs[$active_results["MLS"]["value"]] == "" && $MLSIDs[$active_results["MLS"]["value"]] <= 0) { $MLSIDs[$active_results["MLS"]["value"]] = $active_results["MLS"]["value"]; $active_listings[] = $active_results; } // end if else } // end if else - if($active_results["MLS"]["value"] == "" || $active_results["MLS"]["value"] <= 0) } // end foreach -- foreach($property_active_results as $active_results) } // end if -- if(count($property_active_results) > 0) } // end if -- if (array_key_exists("Listing", $arr["Listings"])) } // end if -- if (sizeof($arr) == 1 && $arr["Listings"]) } // end if -- if($error == 0) { } // end of foreach } // end of if // Search Results: Pagination $frontText = ""; $limit = 10; $adjacents = 1; $targetpage = "index.php?"; $pagestring = "pg="; $total_listings = count($active_listings); // get current page if($_GET['pg'] > 0) { $pg = $_GET['pg']; // get page from the url parameter ( eg. ?pg=2 ) } else { $pg = 1; // default = page 1 } // check if current page value is greater than 1 (page 2 and above) if($pg > 1) { $offset = (($pg - 1) * $limit);// set the start number of displaying records } else { $offset = 0; // default: page 1 will start displaying records from record 1 } // get listings page numbering $n = $offset; } ?>

Loading...

Loading Search Results...