tablerender(LAN_SEARCH_20, "
".LAN_SEARCH_21."
"); require_once(FOOTERF); exit; } if($_GET['t'] == '0'){$_GET['t'] = 'news';} if($_GET['t'] == 1){$_GET['t'] = 'comments';} if($_GET['t'] == 2){$_GET['t'] = 'users';} if($_GET['t'] == 3){$_GET['t'] = 'downloads';} if($_GET['t'] == 4){$_GET['t'] = 'pages';} $search_prefs = $sysprefs -> getArray('search_prefs'); // load search routines $search_info = array(); $auto_order = 1000; function search_info($id, $type, $plug_require, $info='') { global $tp, $search_prefs, $auto_order; if (check_class($search_prefs[$type.'_handlers'][$id]['class'])) { if ($plug_require) { require_once($plug_require); $ret = $search_info[0]; } else { $ret = $info; } $ret['chars'] = $search_prefs[$type.'_handlers'][$id]['chars']; $ret['results'] = $search_prefs[$type.'_handlers'][$id]['results']; $ret['pre_title'] = $search_prefs[$type.'_handlers'][$id]['pre_title']; $ret['pre_title_alt'] = $tp -> toHtml($search_prefs[$type.'_handlers'][$id]['pre_title_alt']); $ret['order'] = (isset($search_prefs[$type.'_handlers'][$id]['order']) && $search_prefs[$type.'_handlers'][$id]['order']) ? $search_prefs[$type.'_handlers'][$id]['order'] : $auto_order; $auto_order++; return $ret; } else { return false; } } //core search routines if ($search_info['news'] = search_info('news', 'core', false, array('sfile' => e_HANDLER.'search/search_news.php', 'qtype' => LAN_SEARCH_98, 'refpage' => 'news.php', 'advanced' => e_HANDLER.'search/advanced_news.php', 'id' => 'news'))) { // $search_id++; } else { unset($search_info['news']); } if ($search_info['comments'] = search_info('comments', 'core', false, array('sfile' => e_HANDLER.'search/search_comment.php', 'qtype' => LAN_SEARCH_99, 'refpage' => 'comment.php', 'advanced' => e_HANDLER.'search/advanced_comment.php', 'id' => 'comment'))) { // $search_id++; } else { unset($search_info['comments']); } if ($search_info['users'] = search_info('users', 'core', false, array('sfile' => e_HANDLER.'search/search_user.php', 'qtype' => LAN_140, 'refpage' => 'user.php', 'advanced' => e_HANDLER.'search/advanced_user.php', 'id' => 'user'))) { // $search_id++; } else { unset($search_info['users']); } if ($search_info['downloads'] = search_info('downloads', 'core', false, array('sfile' => e_HANDLER.'search/search_download.php', 'qtype' => LAN_197, 'refpage' => 'download.php', 'advanced' => e_HANDLER.'search/advanced_download.php', 'id' => 'download'))) { // $search_id++; } else { unset($search_info['downloads']); } if ($search_info['pages'] = search_info('pages', 'core', false, array('sfile' => e_HANDLER.'search/search_pages.php', 'qtype' => LAN_418, 'refpage' => 'page.php', 'advanced' => e_HANDLER.'search/advanced_pages.php', 'id' => 'pages'))) { // $search_id++; } else { unset($search_info['pages']); } //plugin search routines // plugin folder is used as the search key. ie. $_GET['t'] = 'chatbox'; foreach ($search_prefs['plug_handlers'] as $plug_dir => $active) { if (is_readable(e_PLUGIN.$plug_dir."/e_search.php")) { if ($search_info[$plug_dir] = search_info($plug_dir, 'plug', e_PLUGIN.$plug_dir."/e_search.php")) { // $search_id++; } else { unset($search_info[$plug_dir]); } } } // order search routines function array_sort($array, $column, $order = SORT_DESC) { $i = 0; foreach($array as $info) { $sortarr[] = $info[$column]; $i++; } array_multisort($sortarr, $order, $array, $order); return($array); } $search_info = array_sort($search_info, 'order', SORT_ASC); // validate search query $perform_search = true; function magic_search($data) { foreach ($data as $key => $value) { if (is_array($value)) { $data[$key] = magic_search($value); } else { $data[$key] = stripslashes($value); } } return $data; } if (!e_QUERY) { $enhanced = true; } if (isset($_GET['q']) || isset($_GET['in']) || isset($_GET['ex']) || isset($_GET['ep']) || isset($_GET['beg'])) { if (MAGIC_QUOTES_GPC == true) { $_GET = magic_search($_GET); } $full_query = $_GET['q']; if ($_GET['in']) { $en_in = explode(' ', $_GET['in']); foreach ($en_in as $en_in_key) { $full_query .= " +".$en_in_key; } $enhanced = true; } if ($_GET['ex']) { $en_ex = explode(' ', $_GET['ex']); foreach ($en_ex as $en_ex_key) { $full_query .= " -".$en_ex_key; } $enhanced = true; } if ($_GET['ep']) { $full_query .= " \"".$_GET['ep']."\""; $enhanced = true; } if ($_GET['be']) { $en_be = explode(' ', $_GET['be']); foreach ($en_be as $en_be_key) { $full_query .= " ".$en_be_key."*"; } $enhanced = true; } if (isset($_GET['r']) && !is_numeric($_GET['r'])) { $perform_search = false; $SEARCH_MESSAGE = LAN_SEARCH_201; $result_flag = 0; } else if (strlen($full_query) == 0) { $perform_search = false; $SEARCH_MESSAGE = LAN_SEARCH_201; } elseif (strlen($full_query) < ($char_count = ($search_prefs['mysql_sort'] ? 4 : 3))) { $perform_search = false; $SEARCH_MESSAGE = str_replace('--CHARS--', $char_count, LAN_417); } elseif ($search_prefs['time_restrict']) { $time = time() - $search_prefs['time_secs']; $query_check = $tp -> toDB($full_query); $ip = getip(); if ($sql -> db_Select("tmp", "tmp_ip, tmp_time, tmp_info", "tmp_info LIKE 'type_search%' AND tmp_ip='".$ip."'")) { $row = $sql -> db_Fetch(); if (($row['tmp_time'] > $time) && ($row['tmp_info'] != 'type_search '.$query_check)) { $perform_search = false; $SEARCH_MESSAGE = LAN_SEARCH_17.$search_prefs['time_secs'].LAN_SEARCH_18; } else { $sql -> db_Update("tmp", "tmp_time='".time()."', tmp_info='type_search ".$query_check."' WHERE tmp_info LIKE 'type_search%' AND tmp_ip='".$ip."'"); } } else { $sql -> db_Insert("tmp", "'".$ip."', '".time()."', 'type_search ".$query_check."'"); } } if ($perform_search) { $result_flag = $_GET['r']; } $query = trim($full_query); } // forward user if searching in google $search_count = count($search_info); $google_id = $search_count + 1; if ($perform_search) { if ($search_prefs['selector'] == 1) { // Care needed - with alpha strings on search of single area $_GET['t'][$google_id] returns a character on page > 1 if (isset($_GET['t'][$google_id]) && ($_GET['t']==$google_id) && $_GET['t'][$google_id]) { // echo "We think google should be used using checkboxes
"; header("location:http://www.google.com/search?q=".stripslashes(str_replace(" ", "+", $query))); exit; } } else { if (isset($_GET['t']) && $_GET['t'] == $google_id) { header("location:http://www.google.com/search?q=".stripslashes(str_replace(" ", "+", $query))); exit; } } } // determine areas being searched if (!$search_prefs['user_select'] && $_GET['r'] < 1) { foreach($search_info as $key => $value) { $searchtype[$key] = true; } } else { if (isset($_GET['t'])) { if (is_array($_GET['t'])) { $searchtype = $_GET['t']; } else { $searchtype[$_GET['t']] = true; } } else { if (isset($_GET['ref'])) { foreach($search_info as $key => $value) { if ($value['id'] == $_GET['ref']) { $searchtype[$key] = true; $_GET['t'] = $key; } } } else if (e_QUERY) { if (isset($_SERVER['HTTP_REFERER'])) { if (!$refpage = substr($_SERVER['HTTP_REFERER'], (strrpos($_SERVER['HTTP_REFERER'], "/")+1))) { $refpage = "index.php"; } } else { $refpage = ""; } foreach($search_info as $key => $value) { if ($value['refpage']) { if (strpos($refpage, $value['refpage']) !== FALSE) { $searchtype[$key] = true; $_GET['t'] = $key; } } } } if (!isset($searchtype) && isset($query)) { if ($search_prefs['multisearch']) { $searchtype['all'] = true; } else { $searchtype[0] = true; } } } } // standard search config if ($search_prefs['selector'] == 2) { $SEARCH_DROPDOWN = "".$value['qtype'].$POST_CHECKBOXES; } else { $SEARCH_MAIN_CHECKBOXES .= $PRE_CHECKBOXES."".$value['qtype'].$POST_CHECKBOXES; } } if (check_class($search_prefs['google'])) { if ($search_prefs['selector'] == 2) { $SEARCH_DROPDOWN .= ""; } else if ($search_prefs['selector'] == 1) { $SEARCH_MAIN_CHECKBOXES .= $PRE_CHECKBOXES."Google".$POST_CHECKBOXES; } else { $SEARCH_MAIN_CHECKBOXES .= $PRE_CHECKBOXES."Google".$POST_CHECKBOXES; } } if ($search_prefs['selector'] == 2) { $SEARCH_DROPDOWN .= ""; } $value = isset($_GET['q']) ? $tp -> post_toForm($_GET['q']) : ""; $SEARCH_MAIN_SEARCHFIELD = ""; if ($search_prefs['selector'] == 1) { $SEARCH_MAIN_CHECKALL = ""; $SEARCH_MAIN_UNCHECKALL = ""; } $SEARCH_MAIN_SUBMIT = ""; $ENHANCED_ICON = "".LAN_SEARCH_23.""; $enhanced_types['in'] = LAN_SEARCH_24.':'; $enhanced_types['ex'] = LAN_SEARCH_25.':'; $enhanced_types['ep'] = LAN_SEARCH_26.':'; $enhanced_types['be'] = LAN_SEARCH_27.':'; $ENHANCED_DISPLAY = $enhanced ? "" : "style='display: none'"; // advanced search config if (!$_GET['adv'] || $_GET['t'] == 'all') { foreach ($_GET as $gk => $gv) { if ($gk != 't' && $gk != 'q' && $gk != 'r' && $gk != 'in' && $gk != 'ex' && $gk != 'ep' && $gk != 'be' && $gk != 'adv') { unset($_GET[$gk]); } } } $SEARCH_TYPE_SEL = " ".LAN_SEARCH_29."  ".LAN_SEARCH_30; foreach ($search_info as $key => $value) { if (!isset($search_info[$key]['advanced'])) { $js_adv .= " && abid != '".$key."'"; } } if (isset($search_info[$_GET['t']]['advanced'])) { $SEARCH_TYPE_DISPLAY = ""; } else { $SEARCH_TYPE_DISPLAY = "style='display: none'"; } if (check_class($search_prefs['google'])) { $js_adv .= " && abid != '".$google_id."'"; } if ($perform_search) { $con = new convert; e107_require(e_HANDLER.'search_class.php'); $sch = new e_search; // omitted words message $stop_count = count($sch -> stop_keys); if ($stop_count) { if ($stop_count > 1) { $SEARCH_MESSAGE = LAN_SEARCH_32.": "; } else { $SEARCH_MESSAGE = LAN_SEARCH_33.": "; } $i = 1; foreach ($sch -> stop_keys as $stop_key) { $SEARCH_MESSAGE .= $stop_key; if ($i != $stop_count) { $SEARCH_MESSAGE .= ', '; } $i++; } } } require_once(HEADERF); // render search config if (!isset($SEARCH_TOP_TABLE)) { if (file_exists(THEME."search_template.php")) { require(THEME."search_template.php"); } else { require(e_BASE.$THEMES_DIRECTORY."templates/search_template.php"); } } $text = preg_replace("/\{(.*?)\}/e", '$\1', $SEARCH_TOP_TABLE); foreach ($enhanced_types as $en_id => $ENHANCED_TEXT) { $ENHANCED_DISPLAY_ID = "en_".$en_id; $ENHANCED_FIELD = ""; $text .= preg_replace("/\{(.*?)\}/e", '$\1', $SEARCH_ENHANCED); } if ($search_prefs['user_select']) { $text .= preg_replace("/\{(.*?)\}/e", '$\1', $SEARCH_CATS); } $text .= preg_replace("/\{(.*?)\}/e", '$\1', $SEARCH_TYPE); if ($_GET['adv']) { if (isset($search_info[$_GET['t']]['advanced'])) { @require_once($search_info[$_GET['t']]['advanced']); foreach ($advanced as $adv_key => $adv_value) { if ($adv_value['type'] == 'single') { $SEARCH_ADV_TEXT = $adv_value['text']; $text .= preg_replace("/\{(.*?)\}/e", '$\1', $SEARCH_ADV_COMBO); } else { if ($adv_value['type'] == 'dropdown') { $SEARCH_ADV_A = $adv_value['text']; $SEARCH_ADV_B = ""; } else if ($adv_value['type'] == 'date') { $SEARCH_ADV_A = $adv_value['text']; $SEARCH_ADV_B = " "; } else if ($adv_value['type'] == 'author') { require_once(e_HANDLER.'user_select_class.php'); $us = new user_select; $SEARCH_ADV_A = $adv_value['text']; $SEARCH_ADV_B = $us -> select_form('popup', $adv_key, $_GET[$adv_key]); } else if ($adv_value['type'] == 'dual') { $SEARCH_ADV_A = $adv_value['adv_a']; $SEARCH_ADV_B = $adv_value['adv_b']; } $text .= preg_replace("/\{(.*?)\}/e", '$\1', $SEARCH_ADV); } } } else { $_GET['adv'] = 0; } } $text .= $SEARCH_MESSAGE ? preg_replace("/\{(.*?)\}/e", '$\1', $SEARCH_TABLE_MSG) : ""; $text .= preg_replace("/\{(.*?)\}/e", '$\1', $SEARCH_BOT_TABLE); $ns -> tablerender(PAGE_NAME." ".SITENAME, $text); // parse search if ($perform_search) { foreach ($search_info as $key => $a) { if (isset($searchtype[$key]) || isset($searchtype['all'])) { unset($text); if (file_exists($search_info[$key]['sfile'])) { $pre_title = ($search_info[$key]['pre_title'] == 2) ? $search_info[$key]['pre_title_alt'] : $search_info[$key]['pre_title']; $search_chars = $search_info[$key]['chars']; $search_res = $search_info[$key]['results']; @require_once($search_info[$key]['sfile']); $_GET['q'] = rawurlencode($_GET['q']); $parms = $results.",".$search_res.",".$_GET['r'].",".e_SELF."?q=".$_GET['q']."&t=".$key."&r=[FROM]"; $core_parms = array('r' => '', 'q' => '', 't' => '', 's' => ''); foreach ($_GET as $pparm_key => $pparm_value) { if (!isset($core_parms[$pparm_key])) { $parms .= "&".$pparm_key."=".$_GET[$pparm_key]; } } if ($results > $search_res) { $nextprev = ($results > $search_res) ? $tp -> parseTemplate("{NEXTPREV={$parms}}") : ""; $text .= "
".$nextprev."
"; } if ($results > 0) { $res_from = $_GET['r'] + 1; $res_to = ($_GET['r'] + $search_res) > $results ? $results : ($_GET['r'] + $search_res); $res_display = $res_from." - ".$res_to." ".LAN_SEARCH_12." ".$results; } else { $res_display = ""; } $ns->tablerender(LAN_SEARCH_11." ".$res_display." ".LAN_SEARCH_13." ".(isset($_GET[$advanced_caption['id']]) ? $advanced_caption['title'][$_GET[$advanced_caption['id']]] : $search_info[$key]['qtype']), $text); } } } } // old 6xx search parser for reverse compatability function parsesearch($text, $match) { $text = strip_tags($text); $temp = stristr($text, $match); $pos = strlen($text) - strlen($temp); $matchedText = substr($text,$pos,strlen($match)); if ($pos < 70) { $text = "...".substr($text, 0, 100)."..."; } else { $text = "...".substr($text, ($pos-50), $pos+30)."..."; } $text = preg_replace("/".$match."/i", "".$matchedText."", $text); return($text); } function headerjs() { global $search_count, $google_id, $search_prefs, $js_adv, $search_info; if ($search_prefs['selector'] == 1) { $types = array_keys($search_info); $types = implode("', '", $types); $script = ""; } $script .= ""; return $script; } require_once(FOOTERF); ?>