Server IP : 51.89.169.208 / Your IP : 3.148.107.92 Web Server : Apache System : Linux ns3209505.ip-198-244-202.eu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Tue Nov 5 04:50:16 EST 2024 x86_64 User : yellowleaf ( 1019) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/yellowleaf/public_html/search/ |
Upload File : |
<?php session_start(); header('Content-Type: text/html; charset=utf-8'); $path = $_SERVER['DOCUMENT_ROOT']; include_once $path.'/connect_db.php'; $starttime = microtime(true); session_start(); //print_r($_GET);exit; $cat=trim(ucwords(strtolower(addslashes($_GET['q'])))); $q_words = explode(" ",strtolower($cat)); if($cat=="Taxi, Restaurant or Company Name"){$cat='';} // make empty if default value $area=ucwords(strtolower(addslashes($_GET['a']))); $areasplit=explode(',',$area); $areasplit=$areasplit[0]; if($area=="Town e.g London or E14"){$area='';} // make empty if default value $town_id = addslashes($_GET['a_id']); if(empty($town_id)){$town_id=0;} // make '0' if not get a_id $cattype=addslashes($_GET['type']); $longlat=$_GET['location']; $arid=addslashes($_GET['arid']) ? : ''; list($file_path,$query_string) = explode('?',$_SERVER['REQUEST_URI']); parse_str($query_string, $query_array); $cat = preg_replace("/[^A-Za-z 0-9]/", "", $cat); $pcat = str_replace(' ',' +',$cat); $current_page = addslashes($_GET['page'])?:1; $per_page = addslashes($_GET['show'])?:20; $offset = $per_page * ($current_page - 1); $cap_cat = str_replace(' ',' ',ucwords(strtolower($cat))); $cat_found=$_GET['cat_found']; $area_found=$_GET['area_found']; $filter = $_GET["filter"]; $lonlat_details= explode("|", addslashes($_GET['location'])); $long =$lonlat_details[0]; $lat=$lonlat_details[1]; $radius = 200; $kilometers=6371; // reference to calculate with kilometers $miles=3959; // reference to calculate with miles function short_title_converter($string){ $short_title = ""; $split_string = explode(" ", $string); foreach ($split_string as $key => $value) { if ($key <= 2) { $word = trim($value); if (!preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $word[0])) { $first_char = ucwords($word[0]); }else if(!preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $word[1])){ $first_char = ucwords($word[1]); }else{ $first_char = ""; } $short_title .= $first_char; } } return $short_title; } // set cat impressions $date = time(); $connect->query("INSERT INTO `cat_score` SET `cat_name` = '$cat', `imp` = '1', `date` = '$date' ON DUPLICATE KEY UPDATE `imp` = `imp`+1"); if ($arid){ $connect->query("UPDATE locations SET pop=pop+1 WHERE area_id='{$arid}'"); } $date=time(); if($area) { $areas = $area; }else{ $areas = "UK"; } if($cat) { $cats = $cat; $result_head ="$cats in $areas"; }else{ $cats = "businesses"; $result_head ="$cats in $areas"; } // $result_head ="Showing '$cats' in $areas."; if($area_found=='true'){ if($cat) { $sub = " MATCH (`companyname`,`description`,`services_offered`,`category_plural`) AGAINST ('+{$pcat}' IN BOOLEAN MODE) AND "; } $query = "SELECT *, ( {$miles} * acos( cos( radians(' ".$connect->real_escape_string($lat)." ') ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(' ".$connect->real_escape_string($long)." ') ) + sin( radians(' ".$connect->real_escape_string($lat)." ') ) * sin( radians( latitude ) ) ) ) AS distance FROM ads WHERE $sub `active`='1' HAVING distance < '".$connect->real_escape_string($radius)."' ORDER BY distance LIMIT {$per_page} OFFSET $offset" ; $query_result = $connect->query($query) or die($connect->error); $num_rows = $query_result->num_rows; if ($num_rows > 5) { $connect->query("INSERT INTO cats SET cat_name='{$cap_cat}', date='{$date}', no_results='{$num_rows}' ON DUPLICATE KEY UPDATE pop=pop+1, no_results='$num_rows', date='$date'"); } if(!$num_rows){ $result_head .="<div style=\"padding-top:10px\">Your search for <b>$cat</b> did not match any businesses<br><br>Our Suggestions:<br><br>Make sure all words are spelled correctly.<br>Try different business categories.<br>Try more general keywords.</div>"; } $num_rows = $connect->query("SELECT *, ( {$miles} * acos( cos( radians(' ".$connect->real_escape_string($lat)." ') ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(' ".$connect->real_escape_string($long)." ') ) + sin( radians(' ".$connect->real_escape_string($lat)." ') ) * sin( radians( latitude ) ) ) ) AS distance FROM ads WHERE $sub `active`='1' HAVING distance < '".$connect->real_escape_string($radius)."' ORDER BY distance ")->num_rows; }elseif($area_found=='false'){ $checker = preg_match('/[0-9]/', $area); if ($checker) {$checker = explode(' ',$area); $area=$checker[0]; } $query = "SELECT * FROM locations WHERE area_name LIKE '{$area}%' ORDER BY pop DESC LIMIT {$per_page} OFFSET $offset" ; $query_result = $connect->query($query) or die($connect->error); $num_rows = $query_result->num_rows; if($num_rows){$result_head.="<div style=\"padding-top:10px\">Please select your location from the list below so we can begin your search.</div>";}else{$result_head .="<div style=\"padding-top:10px\">We could not understand the location '<b>$area</b>'. Please make sure the town name is spelled correctly, Please try again..</div>";} $num_rows = $connect->query("SELECT * FROM locations WHERE area_name LIKE '{$area}%' ORDER BY pop DESC ")->num_rows; }else{ if($cat) { // $sub = "where MATCH (`companyname`,`description`,`services_offered`,`category_plural`) AGAINST ('+{$pcat}' IN BOOLEAN MODE) AND"; $sub = "WHERE MATCH (`companyname`,`description`,`services_products`,`category_plural`) AGAINST ('+{$pcat}' IN BOOLEAN MODE) AND"; } else{ $sub = "WHERE"; } $town_name = ucwords($areas); if($town_id){ $loc_sql = $connect->query("SELECT town_id,stripped_name,postcode,lon,lat FROM towns_new WHERE town_id = '{$town_id}'"); if($loc_sql->num_rows > 0){ $loc_row = $loc_sql->fetch_assoc(); $town_name = $loc_row['stripped_name']; } } if(empty($area)){ $query = "SELECT * FROM ads WHERE `active`='1' ORDER BY adid DESC LIMIT {$per_page} OFFSET $offset"; // echo $query; // die(); $query_result = $connect->query($query) or die($connect->error); // $num_rows = $query_result->num_rows; $num_rows = $connect->query("SELECT * FROM ads WHERE `active`='1' ORDER BY adid DESC")->num_rows; } else { $query = "SELECT * FROM ads {$sub} `active`='1' AND town_name LIKE '{$town_name}' ORDER BY adid DESC LIMIT {$per_page} OFFSET $offset"; // echo $query; // die(); $query_result = $connect->query($query) or die($connect->error); // $num_rows = $query_result->num_rows; $num_rows = $connect->query("SELECT * FROM ads {$sub} `active`='1' AND town_name LIKE '{$town_name}' ORDER BY adid DESC")->num_rows; } $search_query_count = $num_rows; // echo $num_rows; // die(); // $query = "SELECT * FROM ads {$sub} ORDER BY adid DESC LIMIT {$per_page} OFFSET $offset"; // $query_result = $connect->query($query) or die($connect->error); // $num_rows = $connect->query("SELECT * FROM ads {$sub} ORDER BY adid DESC")->num_rows; /** find town lat lon */ // $area_name_query = $connect->query("SELECT * FROM 3town WHERE area_name LIKE '{$town_name}' LIMIT 1"); // $area_query_rows = $area_name_query->num_rows; // $result_area = $area_name_query->fetch_assoc(); // $area_lat = $result_area['area_lat']; // $area_lon = $result_area['area_lon']; // echo "Lat: ".$area_lat."<br>"; // echo "Lon: ".$area_lon; // $nearby_sql_query = "SELECT *, ( {$miles} * acos( cos( radians({$area_lat}) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians({$area_lon}) ) + sin( radians({$area_lat}) ) * sin( radians( latitude ) ) ) ) // AS distance // FROM ads // {$sub} `active`='1' // HAVING distance < {$radius} // ORDER BY distance asc"; // // LIMIT {$per_page} OFFSET $offset" ; // $nearby_query_result = $connect->query($nearby_sql_query) or die($connect->error); // echo "<pre>"; // print_r($nearby_query_result->fetch_assoc()); // die(); } while ($row = $query_result->fetch_assoc()){ $words_array=array();$filtered='';$word_pos=0;$last_pos=0; foreach($row as $a=>$b){$$a=$b;} if ($area_found=='false') { $mresult .= '<div class="cn_shaddow sresult" style="margin-top:13px"><table width="100%"><tr><td valign="top" style="padding:0px;"> <a style="font-size:14pt;" href="/search/?q='.$cat.'&cat_found='.$cat_found.'&type='.$cattype.'&a='.$area_name.',+'.$area_parent_name.'&area_found=true&location='.$area_lon.'|'.$area_lat.'&arid='.$area_id.'">'.$cap_cat.' in '.$area_name.', '.$area_parent_name.'</a></td></tr></table></div>'; }else { $r_ad_name=strtolower($companyname); $r_ad_name = preg_replace("/[^A-Za-z 0-9]/", "", $r_ad_name); $r_ad_name=str_replace(" "," ",$r_ad_name); $ad_name=str_replace(" ","-",$r_ad_name); $content_data = "$companyname Listed in: $category $street1 $street2 $county_name $district_name $town_name $postcode $description $services_offered Areas covered: $areas_cover Products & Services offered: $products"; $content_data = preg_replace('/\s+/', ' ', $content_data); $split_words=explode(' ',$content_data); // foreach($split_words as $single_word){ // if(in_array(preg_replace('/[^a-zA-Z0-9]/','',strtolower($single_word)),$q_words)){ construct_array($word_pos); } // $word_pos++; // } // foreach($words_array as $word_pos=>$a){ // if(($word_pos-$last_pos)>1 && $word_pos && $last_pos){$filtered.='..';} // $last_pos=$word_pos; // $filtered.=$split_words[$word_pos].' '; // } if(!$words_array[0]){$filtered='..'.$filtered;} $mresult .= '<div class="cn_shaddow sresult"> <table width="100%"> <tr> <td width="90" valign="top" style="text-align:center;padding:17px 4px;"> <div style="width:125px;height:125px;overflow:hidden;"> '; if($row['image']!=''){ $mresult .= '<img width="300" style="margin-left:-80px" src="/members/uploads/logo/'.$row['image'].'">'; }else{ $mresult .= '<img width="125" src="/img/no_logo.png">'; } if ($row["aspect_ratio"] == 1) { $aspect_ratio_class = 'aspect-square'; }else{ $aspect_ratio_class = ''; } $short_title = short_title_converter($companyname); $business_logo_placeholder = '<div class="business-placeholder-image">'.$short_title.'</div>'; $img = $row['image'] && file_exists($path.'/members/uploads/logo/'.$row['image']) ? '<img class="'.$aspect_ratio_class.'" alt="Listing" src="/members/uploads/logo/'.$row['image'].'">' : $business_logo_placeholder; $mresult .= '</div>'; $view_port = addslashes($_GET['v']); // $char_display = ($view_port == "m") ? 100 : 300; $char_display = ($view_port == "m") ? substr($row['description'], 0, 100) : substr($row['description'], 0, 300); if(strlen($row['description']) > 300 && $view_port != "m"){ $char_display .= "..."; } // echo $row['description']; // die(); // $filtered = str_replace(" || "," ",$filtered); // if ($filtered == "..") { $addtitle=" $q"; $subDesc=substr($description,0,300); if(strlen($str)<$char_display){$filtered=$subDesc.'...'; } else {$filtered=$description;} } $fulladd = $street1."$street2, $town_name, $county_name"; if(preg_match("/$areasplit/i", $fulladd) == TRUE){ $servtown_name = " Serving $areasplit"; } else { $servtown_name = "";} // if (strlen($filtered) > 300) {$filtered = substr($filtered,0,300);} // $mresult .= '</td><td valign="top" style="padding:10px 10px 10px 15px;"> // <div style="padding-top:0px;margin-bottom:5px; float:right; font-size:11pt;color:#DA9A05;"><b>'.$tel.'</b></div> // <a style="font-size:15pt;" href="/pages/'.$adid.'-'.$ad_name.'.html">'.$row['companyname'].''.$addtitle.''.$servtown_name.'</a> // <div style="padding-top:5px;font-size:10pt;color:#008000;"><b>Approx. '.round($row['distance'], 1).' mi. from '.$area.', '.$area_county.' UK.</b></div> // <div style="margin:5px 0px;color:#666;font-size:10pt;">'.highlightWords($filtered,$cat).'..</div></td></tr> // </table></div>'; $mresult .= '</td><td valign="top" style="padding:10px 10px 10px 15px;"> <div style="padding-top:0px;margin-bottom:5px; float:right; font-size:11pt;color:#DA9A05;"><b>'.$tel.'</b></div> <a style="font-size:15pt;" href="/pages/'.$adid.'-'.$ad_name.'.html">'.$row['companyname'].''.$addtitle.''.$servtown_name.'</a> <div style="padding-top:5px;font-size:10pt;color:#008000;"><b>Approx. '.round($row['distance'], 1).' mi. from '.$area.', '.$area_county.' UK.</b></div> <div style="margin:5px 0px;color:#666;font-size:10pt;">'.$char_display.'</div></td></tr> </table></div>'; // if ($row["aspect_ratio"] == 1) { // $aspect_ratio_class = 'aspect-square'; // }else{ // $aspect_ratio_class = ''; // } $serv = ''; $style_business_item = ''; if($row['services_products']){ $services_offered = explode(' || ', $row['services_products']); $serv = '<ul class="business-item-features">'; foreach($services_offered as $key => $sa){ $sa = trim($sa); if (!empty($sa)) { if($sa!='.'){ $serv .= '<li>'.ucfirst($sa).'</li>'; } } } $serv .= '</ul>'; } else{ // $serv .= '<ul class="business-item-features">No service found.</ul>'; $style_business_item = 'style="display: none"'; } /** ratings */ $r7 = $connect->query("SELECT * FROM `reviews` WHERE `rev_ad_id` = '{$row['adid']}' AND `rev_spam`='0' ORDER BY rev_id DESC") or die($connect->error); $rev_num_row = $r7->num_rows; $average_rating_html = ''; if($rev_num_row){ unset($ratings); while($rev_row = mysqli_fetch_array($r7)){ $ratings[] = $rev_row['rev_rating']; // company overall review rating $arr_sum = array_sum($ratings); $total_review = count($ratings); $mean = $arr_sum / $rev_num_row; $average_rating = round($mean, 1); $average = round($mean*2)/2; // round to the nearest half $average_rating_html = ''; for($i=1; $i<=5; $i++){ if($i <= $average){ $average_rating_html .= '<svg fill="#FFCC22"> <use xlink:href="index.svg#star-fill"></use> </svg>'; } else{ $average_rating_html .= '<svg fill="#EEE"> <use xlink:href="index.svg#star-fill"></use> </svg>'; } } } } else{ $total_review = 0; $average = 0; $average_rating_html = ''; for($i=1; $i<=5; $i++){ $average_rating_html .= '<svg fill="#EEE"> <use xlink:href="index.svg#star-fill"></use> </svg>'; } } // for opening times $add_que_sql = $connect->query("SELECT * FROM opening_hours WHERE opadid ='{$adid}'"); $add_row = $add_que_sql->fetch_assoc(); $current_day = strtolower(date("l")); $opening_status = ''; $opening_at = ''; $closing_at = ''; for($i=0; $i<=7; $i++){ if($i==0){ $future_day = strtolower(date("l", strtotime("+{$i} days"))); $time = explode(" - ", $add_row["$future_day"]); $start = str_replace(".", ":", $time[0]); $end = str_replace(".", ":", $time[1]); $current = date("h:iA"); $start_time = DateTime::createFromFormat('h:iA', $start); $current_time = DateTime::createFromFormat('h:iA', $current); $end_time = DateTime::createFromFormat('h:iA', $end); // echo $start. " ".$current." ".$end; // die(); if ($current_time >= $start_time && $current_time <= $end_time) { $opening_status = 'Open'; $ap = strtolower((substr($end,-2))); $clsing_time = str_ireplace($ap, '', $end).$ap; $closing_at = "Closes at {$clsing_time} Today"; break; } } else{ $future_day = strtolower(date("l", strtotime("+{$i} days"))); if($add_row["$future_day"] != "Closed" && $add_row["$future_day"] != ""){ $time = explode(" - ", $add_row["$future_day"]); $start = str_replace(".", ":", $time[0]); $start = str_replace("AM", " am", $start); $start = str_replace("PM", " pm", $start); $opening_status = 'Closed'; $day = ucfirst($future_day); $opening_at = "Opens on {$day} {$start}"; break; } } } $mresults .= '<div class="business-item"> <div class="business-item-box"> <div class="business-item-image"> '.$img.' </div> <div class="business-item-info" style="width: 100%"> <a href="/pages/'.$adid.'-'.$ad_name.'.html" class="business-item-title">'.$row['companyname'].''.$addtitle.'</a> <p class="business-item-description">'.$char_display.'</p> <div class="business-item-actions"> <button class="button button-yellow button-sm button-icon send-message" data-adid="'.$row['adid'].'" id="ga4_business_search_message_button"> <svg> <use xlink:href="/business/index.svg#message-line"></use> </svg> Message </button> <a rel="nofollow" href="'.url_display($row['url']).'" class="button button-yellow button-sm button-icon" target="_blank" id="ga4_business_search_website_button"> <svg> <use xlink:href="/business/index.svg#global-line"></use> </svg> Website </a> <!--<a href="#" class="button button-yellow button-sm button-icon"> <svg> <use xlink:href="/business/index.svg#phone-line"></use> </svg> Call </a>--> </div> <div class="business-item-location"> <svg> <use xlink:href="/business/index.svg#map-pin-line"></use> </svg> <div>'.$fulladd.", ".trim($row['postcode']).'</div> </div> <div class="business-item-status"> <span style="'.(($opening_status == "Open") ? "color: var(--green)" : "" ).'">'.$opening_status.'</span> '.(($opening_status == "Closed") ? $opening_at : $closing_at ).' </div> '.$serv.' </div> <div class="business-item-more" style="display: none"> <div class="listing-star-container"> '.$average_rating_html.' </div> <div class="business-item-rating-text"> '.$average.' (<a href="#">'.$total_review.' Rating</a>) </div> <a href="/pages/'.$adid.'-'.$ad_name.'.html#write-review" class="business-item-review">Write a review</a> <a href="/pages/'.$adid.'-'.$ad_name.'.html" class="button button-yellow button-sm">More Info</a> </div> </div> <div class="business-item-bottom"> <div class="business-item-bottom-features" '.$style_business_item.'> <button type="button" class="business-item-bottom-features-header"> Products and services <svg> <use xlink:href="/business/index.svg#arrow-down-line"></use> </svg> </button> <!--<ul class="business-item-features"> <li>Vegetarian Restaurant</li> <li>Vegetarian Restaurant</li> <li>Vegetarian Restaurant</li> <li>Vegetarian Restaurant</li> <li>Vegetarian Restaurant</li> <li>Vegetarian Restaurant</li> </ul>--> '.$serv.' </div> <div class="business-item-bottom-actions"> <a href="#" class="button button-yellow button-sm button-icon send-message" data-adid="'.$row['adid'].'"> <svg> <use xlink:href="/business/index.svg#message-line"></use> </svg> Message </a> <a href="tel:'.$row['tel'].'" class="button button-yellow button-sm button-icon"> <svg> <use xlink:href="/business/index.svg#phone-line"></use> </svg> Call </a> <a href="/pages/'.$adid.'-'.$ad_name.'.html" class="button button-outline-yellow button-sm">More Info</a> </div> </div> </div>'; $addtitle=''; } } if(!$num_rows){ $mresults = '<p style="font-size: 18px; color: rgba(0, 0, 0, .7)">No business found.</p>'; } $total = $num_rows; if($total){ $showing_sentence = number_format($total); } $pagination['prev'] = ''; if ($current_page > 1) { $query_string = change_param(['field'=>'page', 'value'=>($current_page - 1)]); $pagination['prev'] = ' <a href="'.$file_path.$query_string.'" class="business-pagination-item"> <svg> <use xlink:href="index.svg#arrow-left-s-line"></use> </svg> </a>'; } $max_pages = ceil($total/$per_page)?:1; $pagination['next'] = ''; if ($total > $offset + $per_page) { $query_string = change_param(['field'=>'page', 'value'=>($current_page + 1)]);// saved url for later use $pagination['next'] = '<a href="'.$file_path.$query_string.'" class="business-pagination-item"> <svg> <use xlink:href="index.svg#arrow-right-s-line"></use> </svg> </a>'; } if ($total > 0) { $limit = 5; $pages = ceil($total/$per_page); if($pages>=5){ $show_max_pages = $limit; } elseif($pages<=4){ $show_max_pages = $pages; } $start_from = 1; if ($max_pages >= $limit) { if ($current_page == $show_max_pages && $current_page != $max_pages) { $start_from = $start_from + 3; $show_max_pages = $show_max_pages+3; }else if($current_page > $show_max_pages){ $start_from = $current_page - 2; $increase_show_max = $current_page + 2; if ($increase_show_max > $max_pages) { $show_max_pages = $max_pages; if ($current_page == $max_pages) { $start_from = $max_pages - 4; } }else{ $show_max_pages = $increase_show_max; } } } for ($i=$start_from; $i <= $show_max_pages; $i++) { $query_string = change_param(['field'=>'page', 'value'=>$i]); if ($current_page == $i) { $page_no .= '<a class="active" href="'.$file_path.$query_string.'">'.$i.'</a>'; }else{ $page_no .= '<a href="'.$file_path.$query_string.'">'.$i.'</a>'; } } $pagination_html= $pagination['prev'].$page_no.$pagination['next']; $pagination_info = "{$current_page} of {$max_pages} pages"; } // $pagination_html=' // <div class="result-main-pagination"> // '.$pagination['prev'].' // <div class="result-main-pagination-page">Page '.$current_page.' of '.$max_pages.'</div> // '. $pagination['next'].' // </div>'; // floating advertise button on right if(isset($_SESSION['ename'])||isset($_COOKIE['yl_user'])){$yleaf_url='/members/';}else{$yleaf_url='/advertise/';} $provided_by_btn='<a style="border:0px;outline:none;" href="'.$yleaf_url.'"> <img src="/img/providedby.png" onmouseover="this.src=\'/img/providedby_hover.png\'" onmouseout="this.src=\'/img/providedby.png\'" style="border:0;outline:none;"> </a>'; $endtime = microtime(true); $duration = $endtime - $starttime; $duration = round(($duration * 10)); if (!$suggestions) {$suggestions = "Currently no suggestions available for <b>$cat</b>.";} function _readphp_eval($code) { ob_start(); print eval('?>'. $code); $output = ob_get_contents(); ob_end_clean(); return $output; } $tplbody= file_get_contents("results_tpl.html"); $header= file_get_contents($path.'/header-footer/header.php'); $header = _readphp_eval($header); $footer= file_get_contents($path.'/header-footer/footer.php'); $footer = _readphp_eval($footer); $tplbody = str_replace("{top_bar}", "$top_bar", $tplbody); $tplbody = str_replace("{header}", "$header", $tplbody); $tplbody = str_replace("{provided_by_btn}", "$provided_by_btn", $tplbody); $tplbody = str_replace("{loggedin_nav}", "$loggedin_nav", $tplbody); $tplbody = str_replace("{today_date}", "$today_date", $tplbody); $tplbody = str_replace("{footer}", "$footer", $tplbody); $tplbody = str_replace("{cat}", $cat, $tplbody); $tplbody = str_replace("{area}", $area, $tplbody); $tplbody = str_replace("{cat_found}", "$cat_found", $tplbody); $tplbody = str_replace("{type}", "$cattype", $tplbody); $tplbody = str_replace("{area_found}", "$area_found", $tplbody); $tplbody = str_replace("{longlat}", "$longlat", $tplbody); $tplbody = str_replace("{suggestions}", $suggestions, $tplbody); $tplbody = str_replace("{result_head}", $result_head, $tplbody); $tplbody = str_replace("{search_query_count}", number_format($search_query_count), $tplbody); $tplbody = str_replace("{result}", $mresults, $tplbody); $tplbody = str_replace("{areasplit}", $areasplit, $tplbody); $tplbody = str_replace("{page_info}", $pagination_info, $tplbody); $tplbody = str_replace("{pagin_html}", $pagination_html, $tplbody); $outputline = explode("\n",$tplbody); foreach ($outputline as $line) { if (trim($line)) { echo trim($line); echo " "; } } function highlightWords($string, $cat) { $words=explode(' ',$cat); foreach ( $words as $word ) { $word=trim(quotemeta(stripslashes($word))); $color_pos=1; $string = preg_replace('#([^a-zA-Z0-9])('.$word.')([^a-zA-Z0-9])#Usi', '\1<span style="background-color: #FFFF93">\2</span>\3', $string); $color_pos++; } return $string; } function construct_array($pos){ global $words_array; $words_include=15; for ($i=$words_include;$i>0;$i--) { if(($pos-$i)>=0){$words_array[$pos-$i]=1; } } $words_array[$pos]=1; for ($i=1;$i<=$words_include;$i++) { $words_array[$pos+$i]=1; } } function change_param($info){ global $query_array; $params_temp = $query_array; $key = $info['field']; $value = $info['value']; $is_array = false; if(is_array($params_temp[$key])){ $is_array = true; $array_key = array_search($value, $params_temp[$key]); $params_temp[$key][$array_key] = $value; }else{ $params_temp[$key] = $value; } unset($params_temp['ajax']);unset($params_temp['utm_expid']); if (($key == 'page' && $value == '1') || $key !== 'page' ) {unset($params_temp['page']);} if ($info['delete']==1 && !$is_array) {unset($params_temp[$key]);} if ($is_array && $info['delete']==1) {unset($params_temp[$key][$array_key]);} $query_string = http_build_query_decoded($params_temp); if($query_string == ""){return '';} return '?'.$query_string ; } function http_build_query_decoded($params){ $query = http_build_query($params); if(strpos($query,'%5B') !== false){ $query = preg_replace('/%5B[0-9]+%5D/simU', '%5B%5D', $query); } return urldecode($query); } function url_display($url){ if(strlen($url)<1){ return "#"; } $chk = preg_match('/^https?:\/\//', $url, $url_check); if(!$chk){ return "https://".$url; } else{ return $url; } } ?>