▲
$v) { if (is_int($k) && $prefix != null) { $k = urlencode($prefix . $k); } if ((!empty($key)) || ($key === 0)) $k = $key.'['.urlencode($k).']'; if (is_array($v) || is_object($v)) { array_push($ret, http_build_query($v, '', $sep, $k)); } else { array_push($ret, $k.'='.urlencode($v)); } } if (empty($sep)) $sep = ini_get('arg_separator.output'); return implode($sep, $ret); }// http_build_query }//if //Fetch settings header require('fetch_settings.php'); //Detect Mobile Device $isMobile = false; $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); $mobileAgents = array("iphone","android","webos","ipod","blackberry"); $mobileAgent = ""; for($i=0;$iassign('lang', $lang); //Clean variables $requestVarNames = array("postcode", "town", "state", "lat", "lng","start", "location"); cleanRequestVars($requestVarNames); //Validate lat, lng are present (redirect if needed) if(($_REQUEST['lat'] == "") || ($_REQUEST['lng'] == "")){ @header('Location:store_locator.php'); die(""); //js backup redirect } //Load template variables $xtpl->assign('styleHref', 'skins/'.$settingsArray['skin'].'/style.css'); $xtpl->assign('formAction', 'store_locator_results.php'); $xtpl->assign('formMethod', 'GET'); $xtpl->assign('skinLoc','skins/'.$settingsArray['skin']); $emailArray = @explode("@", $settingsArray['contactEmail']); $xtpl->assign('siteEmail',sprintf("", $emailArray[0], $emailArray[1])); $xtpl->assign('sitePhone',$settingsArray['contactPhone']); $xtpl->assign('settingsarray', $settingsArray); $xtpl->assign('today',date('l jS \of F Y h:i:s A')); $xtpl->assign('postcode', $_REQUEST['postcode']); $xtpl->assign('location_field', $_REQUEST['location']); $xtpl->assign('town', $_REQUEST['town']); $xtpl->assign('state', $_REQUEST['state']); $xtpl->assign('pageTitle', $settingsArray['pageTitle']); $xtpl->assign('metaKeywords', $settingsArray['metaKeywords']); $xtpl->assign('metaDescription', $settingsArray['metaDescription']); //Build Page Head Script $js = "\n"; $js .= "\n"; $js .= "\n"; $js .= "\n"; $js .= "\n"; $js .= "\n"; $xtpl->assign('headScript', $js); //Set Country if( isset($_REQUEST['countryIso']) && $_REQUEST['countryIso'] != ""){ $defaultCountryIso = $_REQUEST['countryIso']; }else{ $defaultCountryIso = $settingsArray['countryIso']; } $xtpl->assign('countryIso', $defaultCountryIso); //Fetch countries $sql = "select * from countries where iso is not null and iso != '' order by name asc"; $result = $mysql->exSql($sql) or die($mysql->debugPrint()); while($row = mysql_fetch_assoc($result)){ if(DEFAULTLANG!=CURRENTLANG){ $translatedText = fetchTranslation(CURRENTLANG,DEFAULTLANG, sprintf("country-%s", $row['iso']), $row['name']); $row['name'] = $translatedText; } if($row['iso'] == $defaultCountryIso){ $row['selected'] = "selected"; } $xtpl->assign('country', $row); $xtpl->parse('main.countryisooption1'); $xtpl->parse('main.countryisooption2'); } $showOptions=false; //Fetch categories $sql = "select * from categories order by Title asc"; $result = $mysql->exSql($sql) or die($mysql->debugPrint()); while($row = mysql_fetch_assoc($result)){ if(DEFAULTLANG!=CURRENTLANG){ $translatedText = fetchTranslation(CURRENTLANG,DEFAULTLANG, sprintf("cat-%s", $row['id']), $row['Title']); $row['Title'] = $translatedText; } if(!empty($_REQUEST['category']) && is_array($_REQUEST['category'])){ if(in_array($row['id'],$_REQUEST['category'])){ $row['selected'] = 'SELECTED'; $showOptions=true; } } $xtpl->assign('category', $row); $xtpl->parse('main.categories1'); $xtpl->parse('main.categories2'); } //Fetch services $sql = "select * from services order by Title asc"; $result = $mysql->exSql($sql) or die($mysql->debugPrint()); while($row = mysql_fetch_assoc($result)){ if(DEFAULTLANG!=CURRENTLANG){ $translatedText = fetchTranslation(CURRENTLANG,DEFAULTLANG, sprintf("serv-%s", $row['id']), $row['Title']); $row['Title'] = $translatedText; } if(!empty($_REQUEST['services']) && is_array($_REQUEST['services'])){ if(in_array($row['id'],$_REQUEST['services'])){ $row['selected'] = 'SELECTED'; $showOptions=true; } } $xtpl->assign('service', $row); $xtpl->parse('main.services1'); $xtpl->parse('main.services2'); } if(!empty($_REQUEST['businessname'])){ $showOptions=true; } if($showOptions){ $xtpl->parse('main.showmoreoptionshtml1'); $xtpl->parse('main.showmoreoptionshtml2'); } //Build Page Script /*//$js = "\n"; //$js .= "\n";*/ $js .= "\n"; $js .= "\n"; $js .= "\n"; $xtpl->assign('pageScript', $js); //Build radius search sql $lat = mysqlSafe($mysql->conn, $_REQUEST['lat']); $lng = mysqlSafe($mysql->conn, $_REQUEST['lng']); $sql = '(SIN(RADIANS('.$lat.')) * SIN(RADIANS(`latitude`)) + COS(RADIANS('.$lat.')) * COS(RADIANS(`latitude`)) * COS(RADIANS((('.$lng.') - (`longitude`)))))'; $sql = 'ACOS'.$sql; $sql = 'DEGREES('.$sql.')'; $sql = '('.$sql.' * 69 )'; //convert to km (if needed) if($settingsArray['distanceType'] == "KM"){ $sql = '('.$sql.' * 1.61 )'; } $whereDistance = $sql; $distanceColumn = $sql . ' as `'.$settingsArray['distanceType'].'` '; //Build where SQL $whereSql = array(); //Filter Categories if(!empty($_REQUEST['category']) && is_array($_REQUEST['category'])){ $cSQL = array(); for($i=0;$i 0 ", intval($_REQUEST['category'][$i])); } $whereSql[] = sprintf(" ( %s ) ", implode(" OR ", $cSQL)); } //Filter Services if(!empty($_REQUEST['services']) && is_array($_REQUEST['services'])){ $sSQL = array(); for($i=0;$i 0 ", intval($_REQUEST['services'][$i])); //Assign the Correct Procedure Name and Price for Each Dentist if ($_REQUEST['services'][0]=="11") { $desc = "Braces for Children"; $proctag='bracesfee'; } if ($_REQUEST['services'][0]=="3") { $desc = "Dental Bridges"; $proctag='bridgefee'; } if ($_REQUEST['services'][0]=="5") { $desc = "Cavity Fillings - Composite (1 Surface)"; $proctag="cavitycompfee"; } if ($_REQUEST['services'][0]=="4") { $desc = "Cavity Fillings - Silver (1 Surface)"; $proctag="cavitysilverfee"; } if ($_REQUEST['services'][0]=="2") { $desc = "Crowns"; $proctag="crownfee"; } if ($_REQUEST['services'][0]=="6") { $desc = "Deep Cleanings (Per Quadrant)"; $proctag="deepcleaningfee"; } if ($_REQUEST['services'][0]=="8") { $desc = "Dentures"; $proctag="denturesfee"; } if ($_REQUEST['services'][0]=="7") { $desc = "Implants (Single Tooth)"; $proctag="implantfee"; } if ($_REQUEST['services'][0]=="10") { $desc = "Invisalign"; $proctag="invisalignfee"; } if ($_REQUEST['services'][0]=="1") { $desc = "New Patient Exam / Consultations"; $proctag="newexamfee"; } if ($_REQUEST['services'][0]=="15") { $desc = "Regular Check-up and Cleanings"; $proctag="regcheckupfee"; } if ($_REQUEST['services'][0]=="12") { $desc = "Root Canals"; $proctag="rootcanalfee"; } if ($_REQUEST['services'][0]=="9") { $desc = "Simple Extractions"; $proctag="simpextractfee"; } if ($_REQUEST['services'][0]=="13") { $desc = "Veneers (Per Tooth)"; $proctag="veneersfee"; } if ($_REQUEST['services'][0]=="14") { $desc = "Tooth Whitening"; $proctag="whiteningfee"; } } $whereSql[] = sprintf(" ( %s ) ", implode(" OR ", $sSQL)); } //Filter Business Name if(!empty($_REQUEST['businessname'])){ $whereSql[] = sprintf(" businessName LIKE '%s' ", "%".mysql_real_escape_string($_REQUEST['businessname'],$mysql->conn)."%");//mysql full text coming soon... } $whereSql = (@implode(" and ",$whereSql)==""?"":" and ".@implode(" and ",$whereSql)); $sql = sprintf("select *, %s from `stores` where %s <= %s %s order by %s asc", $distanceColumn, $whereDistance, $settingsArray['withInDistance'], $whereSql, $settingsArray['distanceType']); //Execute radius search sql $result = $mysql->exSql($sql) or die($mysql->debugPrint()); $totalRows = mysql_num_rows($result); //Start paging results $resultsPerPage = 10; $startRow = intval($_REQUEST['start']); if($startRow>0) $startRow--; $sql .= " limit $startRow, $resultsPerPage "; $startRow++; $key = "start"; parse_str($_SERVER['QUERY_STRING'],$rp); define(PAGEQUERYSTRING,http_build_query(array_diff_key($rp,array($key=>"")))); //Execute radius search sql $result = $mysql->exSql($sql) or die($mysql->debugPrint()); $pageTotalRows = mysql_num_rows($result); //Configure Paging $totalPages = @ceil($totalRows/$resultsPerPage); $currentPage = ceil($totalPages-($totalRows-$startRow)/$resultsPerPage); if($currentPage==0) $currentPage++; //Set template location if($_REQUEST['postcode'] != ""){ $location = $_REQUEST['postcode'] . ", " . $_REQUEST['countryIso']; }else{ $location = $_REQUEST['location'] . ", " . $_REQUEST['countryIso']; } $location = ucwords($location); $xtpl->assign('location', $location); //If no results, parse error notice and exit if($totalRows==0){ $xtpl->parse('main.errornotice'); $xtpl->parse('main'); $xtpl->out('main'); exit(); } //Load template with paging data $xtpl->assign('currentPage', $currentPage); $xtpl->assign('totalPages', $totalPages); $xtpl->assign('totalRows', $totalRows); $xtpl->assign('pageTotalRows', $pageTotalRows); if($totalPages>1){ $nextPage = $currentPage+1; $pdata = array( 'page' => $nextPage, 'start' => ($currentPage*$resultsPerPage), 'postcode' => $_REQUEST['postcode'], 'lat' => $_REQUEST['lat'], 'lng' => $_REQUEST['lng'], 'location' => $_REQUEST['location'], 'countryIso' => $_REQUEST['countryIso']); $xtpl->assign('pdata', $pdata); if($nextPage <= $totalPages){ $xtpl->parse('main.searchresults.paging.nextpage'); $xtpl->parse('main.searchresults.paging2.nextpage'); } } if($currentPage>1){ $lastPage = $currentPage-1; $pdata = array( 'page' => $lastPage, 'start' => (($lastPage-1)*$resultsPerPage), 'postcode' => $_REQUEST['postcode'], 'lat' => $_REQUEST['lat'], 'lng' => $_REQUEST['lng'], 'location' => $_REQUEST['location'], 'countryIso' => $_REQUEST['countryIso']); $xtpl->assign('pdata', $pdata); $xtpl->parse('main.searchresults.paging.lastpage'); $xtpl->parse('main.searchresults.paging2.lastpage'); } $xtpl->parse('main.searchresults.paging'); $xtpl->parse('main.searchresults.paging2'); $letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $count = 0; while($row = mysql_fetch_assoc($result)){ //build results set information for template $address = $row['address'] . ", " . $row['city'] . " " . $row['state']; if($isMobile){ switch($mobileAgent){ case "iphone": case "ipod": $row['mobile']['directions'] = sprintf("https://maps.google.com/maps?daddr=%s&ll=%s,%s",$address, $row['latitude'], $row['longitude']); $row['mobile']['map'] = sprintf("https://maps.google.com/maps?q=%s&ll=%s,%s",$address, $row['latitude'], $row['longitude']); $row['mobile']['phone'] = sprintf("tel:%s",$row['phone']); break; case "android": $row['mobile']['directions'] = sprintf("geo:%s,%s?q=%s", $row['latitude'], $row['longitude'], $row['address']); $row['mobile']['map'] = sprintf("geo:%s,%s?q=%s", $row['latitude'], $row['longitude'], $row['address']); $row['mobile']['phone'] = sprintf("tel:%s",$row['phone']); break; default: $row['mobile']['directions'] = "https://m.bing.com/search/search.aspx?A=routepointsentry&EA=" . $address . "&EP=pmqd88dphz&TR=f&AT=0&RT=1&HS=0"; $row['mobile']['map'] = "https://m.bing.com/search/search.aspx?Q=" . $address . "&d=&dl=pmqd88dphz%253b%253b29579%252c%2BSC%253b%253b&pq=&a=results&MID=1"; $row['mobile']['phone'] = sprintf("tel:%s",$row['phone']); break; } } $row['iconSrc'] = 'sladmin/images/icons/gmap/marker'.$letters{$count}.'.png'; $row['onclick1'] = sprintf("showInfo(%s, '%s');", $count, 'hiddenDiv'.$count); $row['onclick2'] = sprintf("showMiniMap(%s);", $count); $row['hiddenDivId'] = 'hiddenDiv'.$count; $row['itemDivId'] = 'itemDiv'.$count; $row['distance'] = sprintf("%01.2f %s", $row[$settingsArray['distanceType']], $settingsArray['distanceType']); //push onto another array for later processing $trow[] = $row; //assign row to data set $xtpl->assign('data', $trow[(sizeof($trow)-1)]); $pprice=$row[$proctag]; $xtpl->assign('price', $pprice); $xtpl->assign('pproc', $desc); //if display website, parse website html if($row['website'] != "" && $row['displayWebsite'] == '1'){ $xtpl->parse('main.searchresults.resultsdisplay1.websiteHTML'); $xtpl->parse('main.searchresults.resultsdisplay2.websiteHTML'); } //if dislay weekly ad, parse weekly ad html if($row['displayWeeklyAd'] == '1'){ $xtpl->parse('main.searchresults.resultsdisplay1.weeklyAdHTML'); $xtpl->parse('main.searchresults.resultsdisplay2.weeklyAdHTML'); } //if even row, parse alt row html if($count%2 == "1"){ $xtpl->parse('main.searchresults.resultsdisplay2.altrow'); } //parse row data set html $xtpl->parse('main.searchresults.resultsdisplay1'); $xtpl->parse('main.searchresults.resultsdisplay2'); $count++; } $onloadStr = "load(".$trow[0]['latitude'].", ".$trow[0]['longitude'].", 9); loadOverlays(); showInfo(0, 'hiddenDiv0');"; $xtpl->assign('bodyonload', $onloadStr); //Google Maps JavaSript $js = ""; $xtpl->assign('googleMapScript', $js); $xtpl->parse('main.searchresults'); //parse and output to template $xtpl->parse('main'); $xtpl->out('main'); //Save Cached Page (if needed) if($settingsRow['enablecaching']=="1"){ require('dynamic_cache_footer.php'); } ?>