1){ header('Location: /'.basename($_SERVER['REQUEST_URI'])); exit; } require './inc/application.php'; $ua = $_SERVER['HTTP_USER_AGENT']; define('MAP_MAX', (stripos($ua,'Safari')!==false && stripos($ua,'Chrome')===false) ? 100: 9999); //ini_set('display_errors', $_GET['_x'] ? 'On' : 'Off'); $cid = (int)$cid; if ($s_res){ if($_GET['t'] && $_GET['t']!='zip'){ if(!in_array($_GET['t'],['city','county','lake'])) $_GET['t'] = ''; if(!$cid && isset($_GET['mapped_country'])) $cid = (int)$_GET['mapped_country']; if(!$cid) $_GET['t'] = ''; } if($cid){ $get_cnt = count($_GET); if($get_cnt==2 || ($get_cnt==4 && $_GET['t']=='lake' && $_GET['pg']=='advanced')){ if(strpos($_SERVER['REQUEST_URI'],'search.php')) $r_type = 1; elseif(preg_match('/-b\d+\.html$/',$_SERVER['REQUEST_URI']) && (strpos($_SERVER['REQUEST_URI'],'%20') || preg_match('/-[a-z]{2}-/',$_SERVER['REQUEST_URI'])) ) $r_type = 2; else $r_type = 0; if($r_type){ $url = '/search.php?cid='.$cid.'&s_res=AND"'; $url1 = $url; ProcessSearchFriendlyURLs($url); $not_changed = ($url1 == $url); $url = substr($url,0,-1); if($not_changed || ($r_type==2 && $url==$_SERVER['REQUEST_URI'])){} else{ header('HTTP/1.1 301 Moved Permanently'); header('Location: '.$url); exit; } } } // ?off=1&cid=849&stype=&s_res=AND&s_by=&a_d= elseif(empty($_GET['s_by']) && preg_match('/off=(\d+)&cid=(\d+)&stype=&s_res=AND(?:&s_by=&a_d=[^&]*)?(?:&t=lake&grid=0)?$/',$_SERVER['QUERY_STRING'],$m)){ $url = '/search.php?cid='.$m[2].'&s_res=AND&off='.$m[1].'"'; $url1 = $url; ProcessSearchFriendlyURLs($url); if($url1 != $url){ $url = substr($url,0,-1); //header('HTTP/1.1 301 Moved Permanently'); header('Location: '.$url); exit; } } } hwRealm('U_LIST_ADS'); } require_once './search_functions.php'; foreach($_GET as $key => $value){ if(stripos($key, 'amp;') !== FALSE){ $newKey = str_ireplace('amp;', '', $key); $_GET[$newKey] = $value; unset($_GET[$key]); } } if($cid){ $aCat = $db->one_assoc('SELECT type,name,LENGTH(description) AS descrLen,latitude,longitude,pid,title,avg_price_home,avg_price_lot, nearby_cities_csv,TRIM(lh_short_text) AS short_text FROM '. TBL_CAT . " WHERE id=$cid"); if(!$aCat){ //header(( strpos(PHP_SAPI,'cgi')===0 ? 'Status:' : $_SERVER['SERVER_PROTOCOL'] ).' 404 Not Found'); $buf = @file_get_contents(TPL_PATH.'removed_lakes.txt'); if(preg_match('/^'.$cid.'\|(\d+)/m',$buf,$m)){ // if this one of the removed lakes, redirect 301 to the state page $url = '/browse_map.php?cat='.$m[1].'"'; ProcessSearchFriendlyURLs($url); $url = substr($url,0,-1); header('Location: '.$url, true, APPLICATION_ENV == 'PROD' ? 301 : 302); } else { header('Location: /'); } exit; } // Lee 2025-07-09: Prevent pending lakes from showing at all // Kirk suggested redirecting to the state page instead if($aCat['name'] === '(pending lake)'){ define('ROBOTS_NOINDEX_FOLLOW', true); // <-- existing code that might not work as intended $state_url = '/browse_map.php?cat=' . $aCat['pid'] . '"'; ProcessSearchFriendlyURLs($state_url); $state_url = substr($state_url,0,-1); header('Location: ' . $state_url, true, 301); exit; } } else $aCat = []; // $cid - category or main is searched // $stype - all,any,exact (valid for partial pattern matching) $ajax = false; $body = $lake_info = ''; if (EN_UF) $O_UFS = new FieldsSet(TPL_PATH . 'ufields.txt'); // print_r($O_LFS->A_SEARCH); $SITE_URL = SITE_URL; if (!$s_res) { $title = 'Advanced Search'; define('ROBOTS_INDEX_NOFOLLOW', true); define('EN_BS4', true); define('EN_BS4_WRAP', true); echo str_replace('','',ShowHeader(false)); ShowAdvSearchForm(); } else { //if(DESKTOP_CLIENT && !isset($_GET['grid'])) $_GET['grid'] = 1; if(isPost()) $a_vars = &$_POST; else $a_vars = &$_GET; //Extra layer against XSS and SQL Injection Attempts foreach(['f_price_min','f_price_max'] as $f){ if($a_vars[$f] && strpos($a_vars[$f],',')) $a_vars[$f] = str_replace(',','',$a_vars[$f]); } foreach(['hw_cid','hw_zip_r','hw_id','f_price_min','f_price_max','f_square_min','f_square_max','rent_pool_ex','f_age_min','f_age_max'] as $f){ if(isset($a_vars[$f])){ if($a_vars[$f]==='' || $a_vars[$f]<0) $a_vars[$f] = ''; else $a_vars[$f] = (int)$a_vars[$f]; } } foreach(['f_rooms','f_rooms_min','f_rooms_max','f_bath','f_bath_min','f_lot_size_min','f_lot_size_max'] as $f){ if(isset($a_vars[$f])){ if($a_vars[$f]<=0) $a_vars[$f] = ''; else $a_vars[$f] = (float)$a_vars[$f]; } } foreach(['lat','lon'] as $f){ if(isset($a_vars[$f])) $a_vars[$f] = (float)$a_vars[$f]; } if(isset($a_vars['hw_zip']) && ctype_digit($a_vars['hw_zip']) && $a_vars['hw_zip'] > 0){ //Fix for zipcodes with 0 as first number, this is stripped by the (int) cast above if(strlen($a_vars['hw_zip']) == 4) $a_vars['hw_zip'] = "0{$a_vars['hw_zip']}"; } if (isset($a_vars['ajax']) && $a_vars['ajax'] == 'true') $ajax = true; // echo $a_vars['ajax'];exit(1); /*if (!empty($q)) { $a_f = $O_LFS->A_SEARCH; if (EN_UF) $a_f = array_merge($a_f, $O_UFS->A_SEARCH); foreach ($a_f as $k) { if (isset($a_vars[$k])) $a_vars[$k] = $q; } }*/ $f_by = []; //if(DESKTOP_CLIENT){ // filters $A_FF = [ ['Type','f_type','multi'], ['Price','f_price','range'], ['Waterfront','f_lake_wf',''], ['Bedrooms','f_rooms','range'], ['Baths','f_bath_min','plus'], ['Acres','f_lot_size','range'], ['Sq Ft','f_square','range'], ['Year Built','f_age','range'], ['Pool','rent_pool_ex',''], ['Sale Status','f_rent_buy_ex',''], ['Open House','openhouse',''], ['ohD1','ohD1',''], ['ohM1','ohM1',''], ['ohD2','ohD2',''], ['ohM2','ohM2',''], ['ohY2','ohY2',''], ['Zip_R','hw_zip_r',''], ['Zip','hw_zip',''], ]; function F_By_Init($a_fl){ if(!is_array($a_fl)) return []; global $a_vars,$A_FF; $f_by = []; foreach($A_FF as $f){ $k = $f[1]; switch($f[2]){ case 'range': $v = ''; if($a_fl["{$k}_min"]){ $a_vars["{$k}_min"] = $a_fl["{$k}_min"]; $v = $a_fl["{$k}_min"]; if($k=='f_price'){ if($v<1000000) $v = '$'.substr($v,0,-3).'k'; else $v = '$'.substr($v,0,-6).'M'; } } if($a_fl["{$k}_max"]){ $a_vars["{$k}_max"] = $a_fl["{$k}_max"]; $v1 = $a_fl["{$k}_max"]; if($k=='f_price'){ if($v1<1000000) $v1 = '$'.substr($v1,0,-3).'k'; else $v1 = '$'.substr($v1,0,-6).'M'; } $v.= ($v?'':($k=='f_price'?'$':'').'0').'-'.$v1; } elseif($v) $v.='+'; if($v) $f_by[] = [$f[0],$v]; break; default: if($a_fl[$k] || ($k=='rent_pool_ex' && $a_fl[$k]===0)){ $a_vars[$k] = $a_fl[$k]; $v = $a_fl[$k]; if($f[2]=='plus') $v.='+'; elseif($f[2]=='multi'){ $v = implode(',',$v); if($k=='f_type') $v = ''.$v.''; } elseif($k=='rent_pool_ex') $v = $v ? 'Yes' : 'No'; $f_by[] = [$f[0],$v]; } } } return $f_by; } $isUrlSeoFriendly = preg_match('/-b\d+\.html$/',$_SERVER['REQUEST_URI']); $resetFilters = !empty($_COOKIE['resetF']); if(!$resetFilters && ( $isUrlSeoFriendly || ($_GET['stype']=='any' && count($_GET)==3) ) ){ //read filters $s_res = 'AND'; // override "OR" //search.php?s_res=OR&cid=45&stype=any $f_by = F_By_Init(hwSessionGetVar('filters')); } elseif(($resetFilters && $isUrlSeoFriendly) || $_GET['pg']=='advanced'){ //save filters if($resetFilters) setcookie('resetF', '', time()-3600); $a_fl = []; foreach($A_FF as $f){ $k = $f[1]; switch($f[2]){ case 'multi': if(is_array($a_vars[$k]) && (count($a_vars[$k])>1 || $a_vars[$k][0]!='')) $a_fl[$k] = $a_vars[$k]; else $a_fl[$k] = []; break; case 'range': $a_fl["{$k}_min"] = $a_vars["{$k}_min"]; $a_fl["{$k}_max"] = $a_vars["{$k}_max"]; break; default: $a_fl[$k] = $a_vars[$k]; } } hwSessionSetVar('filters',$a_fl); $f_by = F_By_Init($a_fl); } //} $res = doDatabaseFetch(); $num_rows = $db->num_rows($res); if($num_rows==0 && $cid && preg_match('/-b\d+\.html$/',$_SERVER['REQUEST_URI']) && !$f_by){ if(!empty($aCat['pid'])){ $url = '/browse_map.php?cat='.$aCat['pid'].'"'; ProcessSearchFriendlyURLs($url); $url = substr($url,0,-1); header('Location: '.$url); exit; } } if($_GET['map']){ if($num_rows>0) while($v = $db->fetch_row($res)){ if($v[10]){ list($v[10]) = explode("\n", $v[10]); $v[10] = hwImgPath($v[10]).$v[10]; } if($v[12]){ //Alt. title for LHUB $a_Remove = []; if(!empty($v[13])) $a_Remove[] = $v[13]; if(!empty($v[14])) $a_Remove[] = $v[14]; $v[3] = ValidateLhubTitle($v[3], $a_Remove); if(empty($v[3])) $v[3] = $v[12]; } $v[3] = str_replace(["\n","\r"],' ',$v[3]); echo implode('|',array_slice($v,0,12))."\n"; } exit; } define('EN_BS4', 1); //$cid && ($a_vars['stype']!='any') if($db->num_rows($res)==0 && !empty($_GET['off'])){ $url = '/search.php?' . rtrim(preg_replace('/(&|^)off=[^&]+&?/', '\\1', strip_tags($_SERVER['QUERY_STRING'])),'&').'"'; ProcessSearchFriendlyURLs($url); $url = substr($url,0,-1); header('Location: '.$url); exit; } $a_out = GetSearchResults($res); $USA_CA = false; if(isset($a_vars['hw_cid']) && $a_vars['hw_cid']) $cid = $a_vars['hw_cid']; if($cid){ //$cid is specified incrementCatHits($cid); $catPathArray = explode(' > ', GetCatPathCached($cid)); $stateId = 0; if(isset($catPathArray[2]) || (isset($catPathArray[1]) && $aCat['type']=='1') ){ // non-US $stateCatName = $catPathArray[1]; $lakeCatName = isset($catPathArray[2]) ? $catPathArray[2] : ''; $stateAbbrev = $stateCatName; } else{ $stateCatName = $catPathArray[0]; $lakeCatName = isset($catPathArray[1]) ? $catPathArray[1] : ''; $stateAbbrev = LookupAbbrByStateName($stateCatName); // state or lake ? if(strlen($stateAbbrev)==2){ if($aCat['type']=='1') $stateId = $cid; else $stateId = $aCat['pid']; } } $IS_USA = strlen($stateAbbrev)==2; $USA_CA = ($IS_USA || $catPathArray[0]=='Canada'); //define('EN_BS4', $IS_USA && $_GET['t']); if(!$lakeCatName && ($_GET['f_city_ex'] || $_GET['f_county_ex'])){ $geo = html_esc($_GET['f_city_ex']?$_GET['f_city_ex']:$_GET['f_county_ex'].' County'); $title = sprintf($A_LNG['page_title_search_geo'], $geo, $stateCatName); $description = str_replace('%s',$geo.', '.$stateAbbrev,$A_LNG['page_desc_browse_map']); } else{ $aCat['title'] = trim($aCat['title']); if($aCat['title']) $title = $aCat['title']; else $title = sprintf($A_LNG['page_title_search'], $lakeCatName, $stateAbbrev); $description = sprintf($A_LNG['page_desc_search'], $lakeCatName, $stateAbbrev); } if($_GET['off']){ $off = (int)$_GET['off']; $title.= ','.($off+1); $description.= ' Page '.($off+1); } else $off = 0; }//end if($cid!=0) if(empty($a_out)){ if(!empty($f_by)){ // || $pg=='advanced' $a_out = []; $a_out['rows']=$a_out['nav']=''; $a_out['lower']=$a_out['upper']=$a_out['numrows']='0'; } } if(!empty($a_out) && !EN_BS4){ $a_out['EN_FILTERED'] = !empty($f_by); if($a_out['EN_FILTERED']){ $a_out['EN_CLEAR'] = !empty($cid); $a_out['f_by'] = ''; foreach($f_by as $k=>$f){ if($f[0]=='Zip_R'){ if(!isset($f_by[$k+1])) break; $v = $f[1].' mi. from '.$f_by[$k+1][1]; } else $v = $f[0].': '.$f[1]; $a_out['f_by'].= ($k>0?'/ ':'').$v.' '; if($f[0]=='Zip_R') break; } } } //US or $catPathArray[2] is req'd if(!$_GET['off'] && isset($catPathArray[1]) && (strlen($stateAbbrev)==2 || isset($catPathArray[2])) && !($_GET['f_city_ex'] || $_GET['f_county_ex']) ){ $lake_info = include SITE_PATH . "getlakeinfo.php"; } $noResults = true; if (empty($a_out) && !EN_BS4) { $cat_info = $cid ? GetCatInfo($cid) : ''; //include(GetFSetFileName('search_no_match.htm')); //$lake_info = include SITE_PATH."lakeinfo/getlakeinfo.php"; if (isset($a_vars['hw_redirect']) && $a_vars['hw_redirect'] == 'out') { if ($a_vars['hw_type'] == 'disabled') { $a_out['ad_id'] = $a_vars['hw_id']; $a_out['ad_zip'] = html_esc($a_vars['hw_zip']); $a_out['cat_info'] = $cat_info; $a_out['lake_info'] = $lake_info; $a_out['SITE_URL'] = $SITE_URL; $title = "Ad # {$a_out['ad_id']}"; $body = EvalAdvTpl(GetFSetFileName('search_disabled_no_radius.htm'), $a_out); } elseif ($a_vars['hw_type'] == 'expired') { $a_out['ad_id'] = $a_vars['hw_id']; $a_out['ad_zip'] = html_esc($a_vars['hw_zip']); $a_out['cat_info'] = $cat_info; $a_out['lake_info'] = $lake_info; $a_out['SITE_URL'] = $SITE_URL; $title = "Ad # {$a_out['ad_id']}"; $body = EvalAdvTpl(GetFSetFileName('search_expired_no_radius.htm'), $a_out); } } else { $a_out['search_cat'] = $cid; $a_out['cat_path'] = GetCatPathCached($cid, 1, 1); $a_out['cat_info'] = $cat_info; $a_out['SITE_URL'] = $SITE_URL; $a_out['lake_info'] = $lake_info; $body = EvalAdvTpl(GetFSetFileName('search_no_match.htm'), $a_out); } $lake_info = ''; } elseif(is_string($a_out)){ // map displayed $body = $a_out; } //else !empty($a_out) else { $noResults = false; //Used to populate the map points for the initial GET request //so that when a customer clicks on Map these results it works //the first time //error_log(print_r(buildMapData($res), TRUE)); //if (!$ajax && !$_GET['t']) $a_out['mapData'] = json_encode(buildMapData($res)); $a_out['openhouses'] = false; $a_out['cat_path'] = ''; if($cid){ $a_out['openhouses'] = in_array($aCat['type'],['1','4']); $a_out['cat_path'] = GetCatPathCached($cid, 1, 1); if($aCat['type']=='1') $a_out['cat_path'] = substr($a_out['cat_path'],0,-4).' (All Lakes)'; if($cid==$_GET['mapped_country'] || $cid==$_GET['mapped_state']){ $a_out['cat_path1'] = $db->one_data('SELECT name FROM '.TBL_GH_CAT.' WHERE id='.$cid); } else{ //$v = explode(' > ', strip_tags($a_out['cat_path'])); $a_out['cat_path1'] = $aCat['name'];//array_pop($v); } } elseif($_GET['f_title'] && in_array($_GET['f_title'],['auction','open house'])) $a_out['cat_path1'] = ucwords($_GET['f_title']); else $a_out['cat_path1'] = ''; $href = strip_tags($QUERY_STRING); $href = preg_replace(['/&s_by=[^&]*/','/&a_d=[^&]*/','/&grid=[^&]*/'], '', $href); if(strpos($href,'grid=')===0) $href = preg_replace('/grid=[^&]&/', '', $href); //$href = str_replace('&', '&', $href); // add saved filters $a_fl = hwSessionGetVar('filters'); if($a_fl) foreach($a_fl as $k=>$v){ if($v){ if(is_array($v)){ foreach($v as $v1) $href.='&'.$k.'[]='.urlencode($v1); } else $href.='&'.$k.'='.urlencode($v); } } $a_out['href_base'] = 'search.php?'.$href; $a_out['href_grid'] = $a_out['href_base'].'&grid=1'; $a_out['href'] = $a_out['href_base'].'&s_by='; // customize href_base/href_grid below if($s_by){ $s_by_addon = '&s_by='.urlencode($s_by); if($a_d) $s_by_addon.='&a_d='.urlencode($a_d); $a_out['href_base'].=$s_by_addon; $a_out['href_grid'].=$s_by_addon; } else { // For SE-friendly Map link only $a_out['href_base'].='"'; ProcessSearchFriendlyURLs($a_out['href_base']); $a_out['href_base'] = substr($a_out['href_base'],0,-1); } $sortOptions = array( array( 'displayName' => 'Price', 'param' => 'f_price'), array( 'displayName' => 'Type (Lot/Home)', 'param' => 'f_type'), array( 'displayName' => 'Lake Name', 'param' => 'f_lake_on'), array( 'displayName' => 'State', 'param' => 'f_state'), array( 'displayName' => 'Waterfront', 'param' => 'f_lake_wf'), array( 'displayName' => 'Views', 'param' => 'hits'), array( 'displayName' => 'Date', 'param' => 'date'), ); foreach($sortOptions as $sortOption){ if($s_by==$sortOption['param']){ $a_out['sort_by_name'] .= $sortOption['displayName'].($a_d == 'asc' ? ' Ascending' : ' Descending'); break; } //$a_out['sort_dropdown_options'] .= "\n"; //$a_out['sort_dropdown_options'] .= "\n"; } if(!empty($a_out['sort_by_name'])){ $a_out['sort_by_name'] = 'Sorted by: ' . $a_out['sort_by_name']; } else { $a_out['sort_by_name'] = ''; } $a_out['s_by'] = $s_by; $a_out['a_d'] = $a_d; $a_out['EN_ZIP'] = ($USA_CA || ($a_vars['hw_zip'] && $a_vars['hw_zip_r'])); //this looks like it's getting the formatted template code, and setting //the variable "s" to the template code so that we can echo it out if ($a_vars['hw_redirect'] == 'out' && !$USA_CA) { if($a_vars['hw_cid']){ $a_out['showViewAllLink'] = true; $a_out['lakeCatId'] = (int)$a_vars['hw_cid']; $a_out['lakeCatName'] = $db->one_data('SELECT name FROM ' . TBL_CAT . ' WHERE id='.$a_out['lakeCatId']); } $adId = $a_out['ad_id'] = $a_vars['hw_id']; $a_out['ad_zip'] = html_esc($a_vars['hw_zip']); list($adStreetAddress, $adCity, $adState) = $db->one_row('SELECT v_255_28, v_255_2, v_255_3 FROM ' . TBL_AD . " WHERE link_id=$adId"); $adStateAbbrev = LookupAbbrByStateName($adState); $title = sprintf($A_LNG['page_title_disabled_ad'], $adId, $adStreetAddress, $adCity, $adStateAbbrev, $a_out['ad_zip']); $description = sprintf($A_LNG['page_desc_disabled_ad'], $adId); $body = EvalAdvTpl(TPL_PATH.($a_vars['hw_type'] == 'expired'?'search_expired.htm':'search_disabled.htm'), $a_out); //$a_vars['hw_type'] == 'disabled' } else { if ($a_vars['hw_redirect'] == 'out'){ $a_out['listOtherByZip'] = true; if($a_vars['hw_cid']){ $a_out['showViewAllLink'] = true; $a_out['lakeCatId'] = (int)$a_vars['hw_cid']; $a_out['lakeCatName'] = $db->one_data('SELECT name FROM ' . TBL_CAT . ' WHERE id='.$a_out['lakeCatId']); } $adId = $a_vars['hw_id']; $a_out['ad_action'] = ($a_vars['hw_type'] == 'disabled'?'activate':'renew'); $a_out['ad_status'] = 'Ad # '.$adId.($a_vars['hw_type'] == 'disabled'?' is disabled':' has expired'); list($adStreetAddress, $adCity, $adState, $stateId) = $db->one_row('SELECT v_255_28, v_255_2, v_255_3, state_id FROM ' . TBL_AD . " WHERE link_id=$adId"); if(!$a_vars['hw_cid']){ $a_out['cat_path'] = GetCatPathCached($stateId, 1, 1); $a_out['cat_path1'] = strip_tags($a_out['cat_path']); } $adStateAbbrev = LookupAbbrByStateName($adState); $title = sprintf($A_LNG['page_title_disabled_ad'], $adId, $adStreetAddress, $adCity, $adStateAbbrev, $a_out['ad_zip']); $description = sprintf($A_LNG['page_desc_disabled_ad'], $adId); } $a_out['lat'] = $a_vars['lat']; $a_out['lon'] = $a_vars['lon']; $a_out['ad_zip'] = html_esc($a_vars['hw_zip']); $zip_radius = $a_vars['hw_zip_r']; //$zip_radius = $zip_radius / 1.4; $a_out['ad_zip_r'] = $zip_radius; $a_out['hw_zip_r'] = $a_vars['hw_zip_r']; $a_out['search_wf'] = html_esc($a_vars['f_lake_wf']); $a_out['search_type'] = html_esc($a_vars['f_type_ex']); $a_out['search_min'] = $a_vars['f_price_min']; $a_out['search_max'] = $a_vars['f_price_max']; $a_out['search_lot_min'] = $a_vars['f_lot_size_min']; $a_out['search_lot_max'] = $a_vars['f_lot_size_max']; $a_out['search_rooms'] = $a_vars['f_rooms']; $a_out['search_rooms_min'] = $a_vars['f_rooms_min']; $a_out['search_rooms_max'] = $a_vars['f_rooms_max']; $a_out['search_square_min'] = $a_vars['f_square_min']; $a_out['search_square_max'] = $a_vars['f_square_max']; $a_out['search_baths'] = $a_vars['f_bath_min'] ? $a_vars['f_bath_min'] : $a_vars['f_bath']; $a_out['search_cat'] = $cid; $a_out['search_rent_buy'] = html_esc($a_vars['f_rent_buy_ex']); $a_out['search_rent_pool'] = html_esc($a_vars['rent_pool_ex']); $a_out['f_city_ex'] = $a_out['f_county_ex'] = ''; if($a_vars['f_city_ex']){ $a_out['f_city_ex'] = html_esc($a_vars['f_city_ex']); $a_out['cat_path'] = (MOBILE_CLIENT?' ':'').$a_out['f_city_ex'].', '.$a_out['cat_path'].' ' ; $a_out['cat_path1'] = $a_out['f_city_ex']; } elseif($a_vars['f_county_ex']){ $a_out['f_county_ex'] = html_esc($a_vars['f_county_ex']); $a_out['cat_path'] = (MOBILE_CLIENT?'  ':'').$a_out['f_county_ex'].' County, '.$a_out['cat_path'].' ' ; $a_out['cat_path1'] = $a_out['f_county_ex'].' County'; } if($lake_info) $a_out['lake_info_button'] = "Lake info"; else $a_out['lake_info_button'] = ''; $a_out['EN_MAP'] = (!$_GET['grid'] && $a_out['numrows']<=MAP_MAX); $a_out['GOOGLE_API_KEY3'] = GOOGLE_API_KEY3; define('SEARCH_RESULTS_PAGE', true); if(isset($a_out['LHUB']) && $a_out['LHUB']){ $LHUB = $a_out['LHUB']; unset($a_out['LHUB']); } $a_out['EN_SHORTTEXT'] = (strpos($_SERVER['REQUEST_URI'],'.html')!==false); if($a_out['EN_SHORTTEXT']){ $isLake = preg_match('/\b(?:lake|reservoir|lac\s)/i',$lakeCatName); $hasHomePrice = ($aCat['avg_price_home']>0); $a_out['catShortText'] = !empty($aCat['short_text']) ? $aCat['short_text'].'

' : ''; $a_out['catShortText'].= 'Lakehouse.com has '.$a_out['numrows'].' '.($isLake?'lake ':'').'propert'.($a_out['numrows']%10==1?'y':'ies'). ' for sale on '.$lakeCatName.', as well as '.($isLake?'lakefront ':'').'homes, lots, land and acreage'. ($aCat['nearby_cities_csv'] ? ' in '.$aCat['nearby_cities_csv'] : ''). ($hasHomePrice ? '. Median home price: $'.number_format($aCat['avg_price_home']) : ''). ($aCat['avg_price_lot']>0 ? ($hasHomePrice ? ', lot' : '. Lot').' price: $'.number_format($aCat['avg_price_lot']) : '').'.'; //' View listing photos and property details. Contact a real estate agent to help you with buying or selling.'; } $a_out['EN_LONGTEXT'] = ($aCat['descrLen']>1); if(!$lake_info) $a_out['lake_info'] = ''; if(EN_BS4){ $a_out['ltype'] = (is_array($_GET['f_type']) && count($_GET['f_type'])==1) ? html_esc($_GET['f_type'][0]).($_GET['f_type'][0]=='Acreage'?'':'s') : 'Homes'; $a_out['search_age_min'] = $a_vars['f_age_min']; $a_out['search_age_max'] = $a_vars['f_age_max']; $a_out['MAP_MAX'] = MAP_MAX; $a_out['IMAGES_URL'] = IMAGES_URL; if($aCat['type']=='4'){ $a_out['llat'] = trim($aCat['latitude']); $a_out['llon'] = trim($aCat['longitude']); } else $a_out['llat'] = $a_out['llon'] = ''; $t = $_GET['t']; if(!$t && $a_vars['hw_zip'] && $a_vars['hw_zip_r']) $t = 'zip'; $a_out['IS_ZIP'] = ($t=='zip'); $a_out['IS_CC'] = !$a_out['IS_ZIP']; $a_out['t'] = html_esc($t); if($a_out['IS_CC']) $a_out = $a_out + getMappedCCDropDowns($t, $stateId); $v = DESKTOP_CLIENT ? 'MOBILE' : 'DESKTOP'; $v1 = $_GET['grid'] ? 'LIST' : 'GRID'; $body = preg_replace([ '#.*?#s', '##s', '#.*?#s', '##s', ], '', file_get_contents(TPL_PATH.'search_results5.htm')); if(MOBILE_CLIENT) $body = str_replace('##filters_mobile##', file_get_contents(TPL_PATH.'filters_mobile.htm'),$body); if(is_file(SITE_PATH.'img/statemaps/'.$stateId.'.jpg')) $a_out['img_map'] = 'statemaps/'.$stateId.'.jpg'; else $a_out['img_map'] = 'map_static'.(MOBILE_CLIENT?'_mobile':'').'.jpg'; $a_out['nearby_lakes'] = ''; if(preg_match('/-b\d+\.html$/',$_SERVER['REQUEST_URI']) && $aCat['latitude']!=$aCat['longitude']){ $USE_CACHE = (APPLICATION_ENV == 'PROD'); $keyLakes = SITE_KEY_SHORT.'NL'; if($USE_CACHE && $GLOBALS['cache']->isAvailable() && $GLOBALS['cache']->isBrowseMapCacheEnabled()) { $a_out['nearby_lakes'] = $GLOBALS['cache']->getBrowseMapPage($cid, false, $keyLakes); //MOBILE_CLIENT } if(!$a_out['nearby_lakes']){ $a_out['nearby_lakes'] = ' '; require_once SITE_PATH . 'modules/Zip_Search/hw_user_api.php'; $sql = 'SELECT DISTINCT(catid) FROM '.TBL_AD.' l WHERE l.exp_date>=NOW() AND l.approved="1" AND catid<>'.$cid. hwFilterGetSQL('l').FilterSpons('l', 0).ZipSearchGetSQL('', 25, $aCat['latitude'], $aCat['longitude']); $a_c = $db->one_col_array($sql); if($a_c){ $a_c = $db->select('SELECT id,name FROM '.TBL_CAT.' WHERE id IN('.implode(',',$a_c).') AND name NOT LIKE "(%" ORDER BY name'); if($a_c){ $tpl = new Tpl; $tpl->InitArray('row'); foreach($a_c as $v) $tpl->AddCell('row',$v); $a_out['nearby_lakes'] = $tpl->Parse(TPL_PATH.'nearby_lakes.htm'); ProcessSearchFriendlyURLs($a_out['nearby_lakes']); //$body = str_replace('',$tpl->Parse(TPL_PATH.'nearby_lakes.htm'),$body); } } if($USE_CACHE && $GLOBALS['cache']->isAvailable() && $GLOBALS['cache']->isBrowseMapCacheEnabled()){ $GLOBALS['cache']->putBrowseMapPage($cid, false, $a_out['nearby_lakes'], $keyLakes); //MOBILE_CLIENT } } } $a_out['hasNearbyLakes'] = (strlen($a_out['nearby_lakes'])>1); // Add lake communities section (only on first page) $a_out['lake_communities'] = ''; if(preg_match('/-b\d+\.html$/',$_SERVER['REQUEST_URI'])) { $sql = 'SELECT v_255_36 AS community, COUNT(*) as adCount, SUM(v_255_4) as totalPrice FROM '.TBL_AD.' WHERE catid = '.$cid.' AND v_255_36 NOT IN ("", "Metes and Bounds") AND exp_date>=NOW() AND approved="1" GROUP BY v_255_36 ORDER BY totalPrice DESC LIMIT 50'; // Requires a successful auto_assign_lake lookup $sql = ' SELECT ad.v_255_36 AS community, COUNT(*) AS adCount, SUM(ad.v_255_4) AS totalPrice FROM '.TBL_AD.' AS ad INNER JOIN auto_assign_lake AS aal ON ad.catid = aal.catid AND ad.v_255_36 = aal.community AND ad.v_255_27 = aal.zip WHERE ad.catid = '.$cid.' AND ad.exp_date >= NOW() AND ad.approved = "1" GROUP BY ad.v_255_36 ORDER BY adCount DESC LIMIT 50 '; $lake_communities = $db->select($sql); if($lake_communities) { $tpl = new Tpl; $tpl->InitArray('row'); foreach($lake_communities as $community) { $tpl->AddCell('row', [ 'search_cat' => $cid, 'name' => ucwords(strtolower($community['community'])), 'count' => $community['adCount'] ]); } $a_out['lake_name'] = $aCat['name']; $a_out['lake_communities'] = $tpl->Parse(TPL_PATH.'lake_communities.htm'); ProcessSearchFriendlyURLs($a_out['lake_communities']); } } $body = EvalBuffer($body, $a_out); } else{ $body = EvalAdvTpl(TPL_PATH.'search_results.htm', $a_out); } //$body = $O_LFS->GetPage(TPL_PATH.$tpl_f, $a_out, false, false, true); } if(DESKTOP_CLIENT){ if ($s_by && $a_d != 'asc'){ $body = str_replace('&s_by=' . $s_by.'"', '&s_by=' . $s_by . '&a_d=asc"', $body); } } }//end else if ($ajax) { $json = ['html'=>$body]; //ifwe have some ad results then process the coords if (!$noResults) $json['mapData'] = buildMapData($res); $json['result'] = 'success'; echo json_encode($json); exit; } //this is the echo of the actual template code else{ if(MOBILE_CLIENT) echo str_replace('','',ShowHeader(false)); elseif(!$_GET['grid']) echo str_replace('','',ShowHeader(false)); else ShowHeader(); if(!$lake_info) echo $body; } $db->free_result($res); }//end else we have results if(EN_BS4 && $_GET['s_res']){ $GLOBALS['GRID'] = ($_GET['grid']=='1'); $buf = ShowFooter(0); if($lake_info){ if(!empty($GLOBALS['SPOTLIGHT_AGENT'])){ $agent_descr = $db->one_data('SELECT description FROM user WHERE id='.(int)$GLOBALS['SPOTLIGHT_AGENT']['userid']); $lake_info = str_ireplace( ['.lakeAgent{display:none}','',''], ['',$GLOBALS['SPOTLIGHT_AGENT']['f_name'].': '.$aCat['name'].' Real Estate Agent Info',$agent_descr], $lake_info); } echo str_replace('##lake_info##',$lake_info,$body); $lake_info = ''; } $spot_pfx = $_GET['t']=='lake' ? $aCat['name'] : $stateCatName; echo str_ireplace(['##spot_pfx##',''],[$spot_pfx, ''. ((DESKTOP_CLIENT && !$_GET['grid']) ? '' : ''). ($_GET['grid']?' ':''). ''],$buf); } else ShowFooter(); function getMappedCCDropDowns($t, $no_empty = false) { global $db,$cid,$aCat; $country_id = $state_id = $lake_id = 0; if($_GET['mapped_country']) $country_id = (int)$_GET['mapped_country']; if($_GET['mapped_state']) $state_id = (int)$_GET['mapped_state']; if($_GET['mapped_lake']) $lake_id = (int)$_GET['mapped_lake']; $ctype = $db->one_data('SELECT type FROM ' . TBL_GH_CAT . ' WHERE id='.$cid); if($ctype==='0') $country_id = $cid; elseif($ctype=='1') $state_id = $cid; else{ // lake ? //$aCat = $db->one_assoc('SELECT pid,type FROM ' . TBL_CAT . ' WHERE id='.$cid); if($aCat['type']=='4'){ $lake_id = $cid; $state_id = $aCat['pid']; } } //$state_id = (int)$_GET['mapped_state']; //if($_GET['mapped_country']) $country_id = $db->one_data('SELECT id FROM ' . TBL_GH_CAT . ' WHERE type=0 AND id='.(int)$_GET['mapped_country']); if(!$country_id && $state_id>0) $country_id = $db->one_data('SELECT pid FROM ' . TBL_GH_CAT . ' WHERE type=1 AND id='.$state_id); $dropDowns = []; //$dropDowns['mapped_country'] = GetJQMappedCatMenu('mapped_country', 0, $country_id, '