function search()
 {
     $address = '';
     $tagdata = $this->EE->TMPL->tagdata;
     $prec = !$this->EE->TMPL->fetch_param('prec') ? '' : ',' . $this->EE->TMPL->fetch_param('prec');
     $prefix = !$this->EE->TMPL->fetch_param('prefix') ? '' : ',' . $this->EE->TMPL->fetch_param('prefix');
     $orderby = !$this->EE->TMPL->fetch_param('orderby') ? false : ($this->EE->TMPL->fetch_param('orderby') == 'distance' ? false : $this->EE->TMPL->fetch_param('orderby'));
     $sort = !$this->EE->TMPL->fetch_param('sort') ? 'asc' : $this->EE->TMPL->fetch_param('sort');
     $this->EE->TMPL->tagparams['limit'] = !$this->EE->TMPL->fetch_param('limit') ? 99999 : $this->EE->TMPL->fetch_param('limit');
     $address_fields = !$this->EE->TMPL->fetch_param('address_fields') ? false : $this->EE->TMPL->fetch_param('address_fields');
     $debug = !$this->EE->TMPL->fetch_param('debug') ? false : true;
     //@delete
     $reverse_geocoding = !$this->EE->TMPL->fetch_param('reverse_geocoding') ? '' : ',' . $this->EE->TMPL->fetch_param('reverse_geocoding');
     if (isset($_POST) and count($_POST) > 0 or isset($_GET) and count($_GET) > 0) {
         $zipLongitude = $this->EE->security->xss_clean($this->EE->input->get_post('long'));
         $zipLatitude = $this->EE->security->xss_clean($this->EE->input->get_post('lat'));
         $unit = $this->EE->security->xss_clean($this->EE->input->get_post('unit'));
         //@add to site description
         if ($address_fields) {
             foreach (explode('|', $address_fields) as $field_name) {
                 $address = $this->EE->input->get_post($field_name) ? $address . $this->EE->security->xss_clean($this->EE->input->get_post($field_name)) . ', ' : '';
             }
         } else {
             $address = $this->EE->security->xss_clean($this->EE->input->get_post('address'));
             if (is_array($address)) {
                 $address = implode(",", $address);
             }
         }
         $address = $prefix . $address;
         $radius = $this->EE->security->xss_clean($this->EE->input->get_post('radius'));
     } else {
         $zipLongitude = $this->EE->TMPL->fetch_param('long') != '' ? $this->EE->TMPL->fetch_param('long') : "";
         $zipLatitude = $this->EE->TMPL->fetch_param('lat') != '' ? $this->EE->TMPL->fetch_param('lat') : '';
         $unit = $this->EE->TMPL->fetch_param('unit') != '' ? $this->EE->TMPL->fetch_param('unit') : 'ml';
         $address = $this->EE->TMPL->fetch_param('address') != '' ? $this->EE->TMPL->fetch_param('address') : '';
         $radius = $this->EE->TMPL->fetch_param('radius') != '' ? $this->EE->TMPL->fetch_param('radius') : $this->default_radius;
     }
     $radius = $radius == '' ? $this->default_radius : $radius;
     $earth_radius = $unit == 'km' ? 6371 : 3959;
     //earth_radius
     if (($zipLongitude == "" or $zipLatitude == "") and $address == "") {
         $zipLongitude = $this->default_long;
         $zipLatitude = $this->default_lat;
         $address = $this->default_address;
     }
     $entry_id = '';
     $points = array();
     $entry_id = rtrim($entry_id, '|');
     $channel = new Channel();
     $LD = '\\{';
     $RD = '\\}';
     $SLASH = '\\/';
     $variable = "entries";
     $return_data = "";
     if (isset($_POST['categories'])) {
         $this->EE->TMPL->tagparams['category'] = (isset($this->EE->TMPL->tagparams['category']) ? $this->EE->TMPL->tagparams['category'] : '') . '|' . implode("|", $this->EE->security->xss_clean($_POST['categories']));
     }
     if (preg_match("/" . LD . $variable . ".*?" . RD . "(.*?)" . LD . '\\/' . $variable . RD . "/s", $tagdata, $entries)) {
         $channel->EE->TMPL->tagdata = $entries[1];
         if ($channel->EE->TMPL->fetch_param('related_categories_mode') == 'yes') {
             return $channel->related_entries();
         }
         $channel->initialize();
         $channel->uri = $channel->query_string != '' ? $channel->query_string : 'index.php';
         if ($channel->enable['custom_fields'] == TRUE) {
             $channel->fetch_custom_channel_fields();
         }
         if ($channel->enable['member_data'] == TRUE) {
             $channel->fetch_custom_member_fields();
         }
         if ($channel->enable['pagination'] == TRUE) {
             if (version_compare(APP_VER, '2.4', '>=')) {
                 $channel->add_pagination_data();
             } else {
                 $channel->fetch_pagination_data();
             }
         }
         $save_cache = FALSE;
         $channel->EE->TMPL->tagparams['dynamic'] = 'no';
         //$zipLongitude.$zipLatitude.$address
         if ($channel->EE->config->item('enable_sql_caching') == 'y') {
             if (FALSE == ($channel->sql = $channel->fetch_cache())) {
                 $save_cache = TRUE;
             } else {
                 if ($channel->EE->TMPL->fetch_param('dynamic') != 'no') {
                     if (preg_match("#(^|\\/)C(\\d+)#", $channel->query_string, $match) or in_array($channel->reserved_cat_segment, explode("/", $channel->query_string))) {
                         $channel->cat_request = TRUE;
                     }
                 }
             }
             if (FALSE !== ($cache = $channel->fetch_cache('pagination_count'))) {
                 if (FALSE !== $channel->fetch_cache('field_pagination')) {
                     if (FALSE !== ($pg_query = $channel->fetch_cache('pagination_query'))) {
                         $channel->paginate = TRUE;
                         $channel->field_pagination = TRUE;
                         $channel->create_pagination(trim($cache), $channel->EE->db->query(trim($pg_query)));
                     }
                 } else {
                     $channel->create_pagination(trim($cache));
                 }
             }
         }
         if ($channel->sql == '') {
             $channel->build_sql_query();
         }
         if ($channel->sql == '') {
             return $channel->EE->TMPL->no_results();
         }
         $sql = "";
         //@start geocoding
         //if don't have the Latitude and Longitude, do query to google.map; ($zipLongitude == "" OR $zipLatitude == "") AND
         if ($address != "" and ($zipLongitude == "" or $zipLatitude == "")) {
             $GetLatLong_result = $this->GetLatLong($address, 2);
             if ($GetLatLong_result != false) {
                 list($zipLongitude, $zipLatitude) = $GetLatLong_result;
             } else {
                 return $this->EE->TMPL->no_results();
             }
         }
         if ($reverse_geocoding and $address == "") {
             $GetLatLong_result = $this->GetLatLong($zipLatitude . ',' . $zipLongitude, $api_key, 1);
             if ($GetLatLong_result != false) {
                 $address = $GetLatLong_result;
             } else {
                 return $this->EE->TMPL->no_results();
             }
         }
         //@END geocoding
         $conds['radius'] = $radius;
         $tagdata = $this->EE->functions->prep_conditionals($tagdata, $conds);
         $tagdata = str_replace(array('{center:long}', '{center:lat}', '{radius}'), array($zipLongitude, $zipLatitude, $radius), $tagdata);
         $where_strpos = strpos($channel->sql, "WHERE");
         if ($where_strpos > 0) {
             $sql_entry_id = substr($channel->sql, $where_strpos + 5, strpos($channel->sql, "ORDER BY") - $where_strpos - 5);
             $limit_strpos = strpos($channel->sql, "LIMIT");
             $order_by = substr($channel->sql, strpos($channel->sql, "ORDER BY"), $limit_strpos);
             $limit = substr($channel->sql, strpos($channel->sql, "LIMIT"));
             $sql = str_replace('FROM', ", gm.*, ROUND( {$earth_radius} * acos( cos( radians({$zipLatitude}) ) * cos( radians( gm.latitude ) ) * cos( radians( gm.longitude ) - radians({$zipLongitude}) ) + sin( radians({$zipLatitude}) ) *  sin( radians( gm.latitude ) ) ) {$prec} ) AS distance   FROM ", $channel->sql);
             $sql = substr($sql, 0, strpos($sql, "WHERE")) . "RIGHT JOIN exp_mx_google_map AS gm ON t.entry_id = gm.entry_id HAVING distance < {$radius} AND " . $sql_entry_id;
             if ($orderby) {
                 $sql = $sql . $order_by;
             } else {
                 $sql = $sql . " ORDER BY distance " . $sort;
             }
             $channel->sql = $sql;
         }
         if ($save_cache == TRUE) {
             $channel->save_cache($channel->sql);
         }
         $channel->query = $channel->EE->db->query($channel->sql);
         if ($channel->query->num_rows() == 0) {
             return $channel->EE->TMPL->no_results();
         }
         foreach ($channel->query->result_array() as $row) {
             $points[$row['point_id']] = $row['distance'];
         }
         $channel->EE->TMPL->tagparams['points'] = $points;
         if ($channel->EE->config->item('relaxed_track_views') === 'y' && $channel->query->num_rows() == 1) {
             $channel->hit_tracking_id = $channel->query->row('entry_id');
         }
         $channel->track_views();
         $channel->EE->load->library('typography');
         $channel->EE->typography->initialize();
         $channel->EE->typography->convert_curly = FALSE;
         if ($channel->enable['categories'] == TRUE) {
             $channel->fetch_categories();
         }
         $channel->parse_channel_entries();
         if ($channel->enable['pagination'] == TRUE) {
             if (version_compare(APP_VER, '2.4', '>=')) {
                 $channel->add_pagination_data();
             } else {
                 $channel->fetch_pagination_data();
             }
         }
         if (count($channel->EE->TMPL->related_data) > 0 && count($channel->related_entries) > 0) {
             $channel->parse_related_entries();
         }
         if (count($channel->EE->TMPL->reverse_related_data) > 0 && count($channel->reverse_related_entries) > 0) {
             $channel->parse_reverse_related_entries();
         }
         $return_data = str_replace($entries[0], $channel->return_data, $tagdata);
     }
     return $return_data;
 }
 /**
  *	List of Entires for an Author, Sub-Processing for entries() method
  *
  *	@access		private
  *	@param		array
  *	@return		string
  */
 private function _entries($params = array())
 {
     /**	----------------------------------------
     		/**	Execute?
     		/**	----------------------------------------*/
     if ($this->entry_id == '') {
         return FALSE;
     }
     /**	----------------------------------------
     		/**	Invoke Channel/Weblog class
     		/**	----------------------------------------*/
     if (APP_VER < 2.0) {
         if (!class_exists('Weblog')) {
             require PATH_MOD . 'weblog/mod.weblog' . EXT;
         }
         $channel = new Weblog();
     } else {
         if (!class_exists('Channel')) {
             require PATH_MOD . 'channel/mod.channel.php';
         }
         $channel = new Channel();
     }
     // --------------------------------------------
     //  Invoke Pagination for EE 2.4 and Above
     // --------------------------------------------
     if (APP_VER >= '2.4.0') {
         ee()->load->library('pagination');
         $channel->pagination = new Pagination_object('Channel');
         // Used by pagination to determine whether we're coming from the cache
         $channel->pagination->dynamic_sql = FALSE;
     }
     /**	----------------------------------------
     		/**	Pass params
     		/**	----------------------------------------*/
     ee()->TMPL->tagparams['entry_id'] = $this->entry_id;
     ee()->TMPL->tagparams['inclusive'] = '';
     if (isset($params['dynamic']) and $params['dynamic'] == "off") {
         if (APP_VER < 2.0) {
             ee()->TMPL->tagparams['dynamic'] = 'off';
         } else {
             ee()->TMPL->tagparams['dynamic'] = 'no';
         }
     }
     /**	----------------------------------------
     		/**	Pre-process related data
     		/**	----------------------------------------*/
     ee()->TMPL->tagdata = ee()->TMPL->assign_relationship_data(ee()->TMPL->tagdata);
     ee()->TMPL->var_single = array_merge(ee()->TMPL->var_single, ee()->TMPL->related_markers);
     /**	----------------------------------------
     		/**	Execute needed methods
     		/**	----------------------------------------*/
     if (APP_VER < 2.0) {
         $channel->fetch_custom_weblog_fields();
     } else {
         $channel->fetch_custom_channel_fields();
     }
     $channel->fetch_custom_member_fields();
     // --------------------------------------------
     //  Pagination Tags Parsed Out
     // --------------------------------------------
     if (APP_VER >= '2.4.0') {
         $channel->pagination->get_template();
     } else {
         $channel->fetch_pagination_data();
     }
     if (APP_VER >= '2.4.0') {
         $channel->pagination->cfields = $channel->cfields;
         $channel->pagination->build();
     } else {
         $channel->create_pagination();
     }
     /**	----------------------------------------
     		/**	Grab entry data
     		/**	----------------------------------------*/
     //$channel->create_pagination();
     $channel->build_sql_query();
     if ($channel->sql == '') {
         return $this->no_results();
     }
     $channel->query = ee()->db->query($channel->sql);
     if (APP_VER < 2.0) {
         $channel->query->result = $channel->query->result_array();
     }
     if (!isset($channel->query) or $channel->query->num_rows() == 0) {
         return $this->no_results();
     }
     if (APP_VER < 2.0) {
         if (!class_exists('Typography')) {
             require PATH_CORE . 'core.typography' . EXT;
         }
         $channel->TYPE = new Typography();
         $channel->TYPE->convert_curly = FALSE;
     } else {
         ee()->load->library('typography');
         ee()->typography->initialize();
         ee()->typography->convert_curly = FALSE;
     }
     $channel->fetch_categories();
     /**	----------------------------------------
     		/**	Parse and return entry data
     		/**	----------------------------------------*/
     if (APP_VER < 2.0) {
         $channel->parse_weblog_entries();
     } else {
         $channel->parse_channel_entries();
     }
     if (APP_VER >= '2.4.0') {
         $channel->return_data = $channel->pagination->render($channel->return_data);
     } else {
         $channel->add_pagination_data();
     }
     /**	----------------------------------------
     		/**	Count tag
     		/**	----------------------------------------*/
     if (count(ee()->TMPL->related_data) > 0 and count($channel->related_entries) > 0) {
         $channel->parse_related_entries();
     }
     if (count(ee()->TMPL->reverse_related_data) > 0 and count($channel->reverse_related_entries) > 0) {
         $channel->parse_reverse_related_entries();
     }
     // ----------------------------------------
     //  Handle problem with pagination segments in the url
     // ----------------------------------------
     if (preg_match("#(/P\\d+)#", ee()->uri->uri_string, $match)) {
         $channel->return_data = str_replace($match['1'], "", $channel->return_data);
     } elseif (preg_match("#(P\\d+)#", ee()->uri->uri_string, $match)) {
         $channel->return_data = str_replace($match['1'], "", $channel->return_data);
     }
     $tagdata = $channel->return_data;
     return $tagdata;
 }