Searching procedures | > Module written by Matt Mecham | > Date started: 24th February 2002 | | > Module Version Number: 1.0.0 +-------------------------------------------------------------------------- | | MODULE NOTES: | ------------- | | I've been deliberating whether we should implement some kind of WORD ID / | search logging table for index. | iB3 PERL had such a feature, but that was to aide the DBM searches, which | were slow at best. | The biggest complaint we had was that adding a word ID / search logging table | effectively doubled the amount of space needed in the mySQL database. I've seen | this complaint echo'd on the support boards of other forum software. | The other downside to such a feature would be the overhaul needed to update it | with new posts/topics and topic movement / deletion. | | I figure that people post more than they search, so a full table scan once per | search request is offset against the CPU to keep the search log tables up to date | | I'm going to stick my neck out and go the full table scan route. It's not as effecient | as a search table would be, but the benefits include no overhead updating it, and a smaller | overall DB size - which is vital to some people on certain hosts. | | This may change if it becomes apparent that it's not very efficient in the long run +-------------------------------------------------------------------------- */ // $idx = new Search; class Search { var $output = ""; var $page_title = ""; var $nav = array(); var $html = ""; var $first = 0; var $search_type = 'posts'; var $sort_order = 'desc'; var $sort_key = 'last_post'; var $search_in = 'posts'; var $prune = '30'; var $st_time = array(); var $end_time = array(); var $st_stamp = ""; var $end_stamp = ""; function Search() { global $ibforums, $DB, $std, $print; if (! $ibforums->vars['allow_search']) { $std->Error( array( LEVEL => 1, MSG => 'search_off') ); } if ($ibforums->member['g_use_search'] != 1) { $std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission' ) ); } if ($ibforums->input['CODE'] == "") $ibforums->input['CODE'] = '00'; //-------------------------------------------- // Require the HTML and language modules //-------------------------------------------- $ibforums->lang = $std->load_words($ibforums->lang, 'lang_search', $ibforums->lang_id ); $ibforums->lang = $std->load_words($ibforums->lang, 'lang_forum' , $ibforums->lang_id ); require "./Skin/".$ibforums->skin_id."/skin_search.php"; $this->html = new skin_search(); $this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}"; if (isset($ibforums->input['st']) ) { $this->first = $ibforums->input['st']; } //-------------------------------------------- // What to do? //-------------------------------------------- if (! isset($ibforums->member['g_use_search']) ) { $std->Error( array( LEVEL => 1, MSG => 'cant_use_feature') ); } switch($ibforums->input['CODE']) { case '01': $this->do_search(); break; case '03': $this->get_new_posts(); break; case 'getactive': $this->get_active(); break; case 'show': $this->show_results(); break; default: $this->show_form(); break; } // If we have any HTML to print, do so... $print->add_output("$this->output"); $print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) ); } function show_form() { global $DB, $std, $ibforums; $last_cat_id = -1; $the_hiddens = ""; $DB->query("SELECT f.id as forum_id, f.name as forum_name, f.position, f.read_perms, c.id as cat_id, c.name as cat_name from ibf_forums f, ibf_categories c where c.id=f.category ORDER BY c.position, f.position"); $forums = "\n" ."