6 * @copyright (c) 2005 phpBB Group
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 if (!defined('IN_PHPBB'))
22 include_once($phpbb_root_path . 'includes/search/search.' . $phpEx);
26 * Fulltext search for MySQL
29 class fulltext_mysql extends search_backend
32 var $word_length = array();
33 var $split_words = array();
35 var $common_words = array();
36 var $pcre_properties = false;
37 var $mbstring_regex = false;
39 function fulltext_mysql(&$error)
43 $this->word_length = array('min' => $config['fulltext_mysql_min_word_len'], 'max' => $config['fulltext_mysql_max_word_len']);
45 if (version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>=')))
47 // While this is the proper range of PHP versions, PHP may not be linked with the bundled PCRE lib and instead with an older version
48 if (@preg_match('/\p{L}/u', 'a') !== false)
50 $this->pcre_properties = true;
54 if (function_exists('mb_ereg'))
56 $this->mbstring_regex = true;
57 mb_regex_encoding('UTF-8');
64 * Checks for correct MySQL version and stores min/max word length in the config
70 if ($db->sql_layer != 'mysql4' && $db->sql_layer != 'mysqli')
72 return $user->lang['FULLTEXT_MYSQL_INCOMPATIBLE_VERSION'];
75 $result = $db->sql_query('SHOW TABLE STATUS LIKE \'' . POSTS_TABLE . '\'');
76 $info = $db->sql_fetchrow($result);
77 $db->sql_freeresult($result);
80 if (isset($info['Engine']))
82 $engine = $info['Engine'];
84 else if (isset($info['Type']))
86 $engine = $info['Type'];
89 if ($engine != 'MyISAM')
91 return $user->lang['FULLTEXT_MYSQL_NOT_MYISAM'];
94 $sql = 'SHOW VARIABLES
96 $result = $db->sql_query($sql);
98 $mysql_info = array();
99 while ($row = $db->sql_fetchrow($result))
101 $mysql_info[$row['Variable_name']] = $row['Value'];
103 $db->sql_freeresult($result);
105 set_config('fulltext_mysql_max_word_len', $mysql_info['ft_max_word_len']);
106 set_config('fulltext_mysql_min_word_len', $mysql_info['ft_min_word_len']);
112 * Splits keywords entered by a user into an array of words stored in $this->split_words
113 * Stores the tidied search query in $this->search_query
115 * @param string &$keywords Contains the keyword as entered by the user
116 * @param string $terms is either 'all' or 'any'
117 * @return bool false if no valid keywords were found and otherwise true
119 function split_keywords(&$keywords, $terms)
121 global $config, $user;
125 $match = array('#\sand\s#iu', '#\sor\s#iu', '#\snot\s#iu', '#(^|\s)\+#', '#(^|\s)-#', '#(^|\s)\|#');
126 $replace = array(' +', ' |', ' -', ' +', ' -', ' |');
128 $keywords = preg_replace($match, $replace, $keywords);
131 // Filter out as above
132 $split_keywords = preg_replace("#[\n\r\t]+#", ' ', trim(htmlspecialchars_decode($keywords)));
135 if ($this->pcre_properties)
137 $split_keywords = preg_replace('#([^\p{L}\p{N}\'*"()])#u', '$1$1', str_replace('\'\'', '\' \'', trim($split_keywords)));
139 else if ($this->mbstring_regex)
141 $split_keywords = mb_ereg_replace('([^\w\'*"()])', '\\1\\1', str_replace('\'\'', '\' \'', trim($split_keywords)));
145 $split_keywords = preg_replace('#([^\w\'*"()])#u', '$1$1', str_replace('\'\'', '\' \'', trim($split_keywords)));
148 if ($this->pcre_properties)
151 preg_match_all('#(?:[^\p{L}\p{N}*"()]|^)([+\-|]?(?:[\p{L}\p{N}*"()]+\'?)*[\p{L}\p{N}*"()])(?:[^\p{L}\p{N}*"()]|$)#u', $split_keywords, $matches);
152 $this->split_words = $matches[1];
154 else if ($this->mbstring_regex)
156 mb_ereg_search_init($split_keywords, '(?:[^\w*"()]|^)([+\-|]?(?:[\w*"()]+\'?)*[\w*"()])(?:[^\w*"()]|$)');
158 while (($word = mb_ereg_search_regs()))
160 $this->split_words[] = $word[1];
166 preg_match_all('#(?:[^\w*"()]|^)([+\-|]?(?:[\w*"()]+\'?)*[\w*"()])(?:[^\w*"()]|$)#u', $split_keywords, $matches);
167 $this->split_words = $matches[1];
170 // We limit the number of allowed keywords to minimize load on the database
171 if ($config['max_num_search_keywords'] && sizeof($this->split_words) > $config['max_num_search_keywords'])
173 trigger_error($user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', $config['max_num_search_keywords'], sizeof($this->split_words)));
176 // to allow phrase search, we need to concatenate quoted words
177 $tmp_split_words = array();
179 foreach ($this->split_words as $word)
183 $phrase .= ' ' . $word;
184 if (strpos($word, '"') !== false && substr_count($word, '"') % 2 == 1)
186 $tmp_split_words[] = $phrase;
190 else if (strpos($word, '"') !== false && substr_count($word, '"') % 2 == 1)
196 $tmp_split_words[] = $word . ' ';
201 $tmp_split_words[] = $phrase;
204 $this->split_words = $tmp_split_words;
206 unset($tmp_split_words);
209 foreach ($this->split_words as $i => $word)
211 $clean_word = preg_replace('#^[+\-|"]#', '', $word);
214 $clean_len = utf8_strlen(str_replace('*', '', $clean_word));
215 if (($clean_len < $config['fulltext_mysql_min_word_len']) || ($clean_len > $config['fulltext_mysql_max_word_len']))
217 $this->common_words[] = $word;
218 unset($this->split_words[$i]);
224 $this->search_query = '';
225 foreach ($this->split_words as $word)
227 if ((strpos($word, '+') === 0) || (strpos($word, '-') === 0) || (strpos($word, '|') === 0))
229 $word = substr($word, 1);
231 $this->search_query .= $word . ' ';
236 $this->search_query = '';
237 foreach ($this->split_words as $word)
239 if ((strpos($word, '+') === 0) || (strpos($word, '-') === 0))
241 $this->search_query .= $word . ' ';
243 else if (strpos($word, '|') === 0)
245 $this->search_query .= substr($word, 1) . ' ';
249 $this->search_query .= '+' . $word . ' ';
254 $this->search_query = utf8_htmlspecialchars($this->search_query);
256 if ($this->search_query)
258 $this->split_words = array_values($this->split_words);
259 sort($this->split_words);
266 * Turns text into an array of words
268 function split_message($text)
273 if ($this->pcre_properties)
275 $text = preg_replace('#([^\p{L}\p{N}\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text)));
277 else if ($this->mbstring_regex)
279 $text = mb_ereg_replace('([^\w\'*])', '\\1\\1', str_replace('\'\'', '\' \'', trim($text)));
283 $text = preg_replace('#([^\w\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text)));
286 if ($this->pcre_properties)
289 preg_match_all('#(?:[^\p{L}\p{N}*]|^)([+\-|]?(?:[\p{L}\p{N}*]+\'?)*[\p{L}\p{N}*])(?:[^\p{L}\p{N}*]|$)#u', $text, $matches);
292 else if ($this->mbstring_regex)
294 mb_ereg_search_init($text, '(?:[^\w*]|^)([+\-|]?(?:[\w*]+\'?)*[\w*])(?:[^\w*]|$)');
297 while (($word = mb_ereg_search_regs()))
305 preg_match_all('#(?:[^\w*]|^)([+\-|]?(?:[\w*]+\'?)*[\w*])(?:[^\w*]|$)#u', $text, $matches);
309 // remove too short or too long words
310 $text = array_values($text);
311 for ($i = 0, $n = sizeof($text); $i < $n; $i++)
313 $text[$i] = trim($text[$i]);
314 if (utf8_strlen($text[$i]) < $config['fulltext_mysql_min_word_len'] || utf8_strlen($text[$i]) > $config['fulltext_mysql_max_word_len'])
320 return array_values($text);
324 * Performs a search on keywords depending on display specific params. You have to run split_keywords() first.
326 * @param string $type contains either posts or topics depending on what should be searched for
327 * @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched)
328 * @param string $terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words)
329 * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query
330 * @param string $sort_key is the key of $sort_by_sql for the selected sorting
331 * @param string $sort_dir is either a or d representing ASC and DESC
332 * @param string $sort_days specifies the maximum amount of days a post may be old
333 * @param array $ex_fid_ary specifies an array of forum ids which should not be searched
334 * @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts
335 * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched
336 * @param array $author_ary an array of author ids if the author should be ignored during the search the array is empty
337 * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match
338 * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered
339 * @param int $start indicates the first index of the page
340 * @param int $per_page number of ids each page is supposed to contain
341 * @return boolean|int total number of results
345 function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
349 // No keywords? No posts.
350 if (!$this->search_query)
355 // generate a search_key from all the options to identify the results
356 $search_key = md5(implode('#', array(
357 implode(', ', $this->split_words),
364 implode(',', $ex_fid_ary),
365 implode(',', $m_approve_fid_ary),
366 implode(',', $author_ary)
369 // try reading the results from cache
371 if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE)
373 return $result_count;
378 $join_topic = ($type == 'posts') ? false : true;
380 // Build sql strings for sorting
381 $sql_sort = $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
382 $sql_sort_table = $sql_sort_join = '';
384 switch ($sql_sort[0])
387 $sql_sort_table = USERS_TABLE . ' u, ';
388 $sql_sort_join = ($type == 'posts') ? ' AND u.user_id = p.poster_id ' : ' AND u.user_id = t.topic_poster ';
396 $sql_sort_table = FORUMS_TABLE . ' f, ';
397 $sql_sort_join = ' AND f.forum_id = p.forum_id ';
401 // Build some display specific sql strings
405 $sql_match = 'p.post_subject';
406 $sql_match_where = ' AND p.post_id = t.topic_first_post_id';
411 $sql_match = 'p.post_text';
412 $sql_match_where = '';
416 $sql_match = 'p.post_subject, p.post_text';
417 $sql_match_where = ' AND p.post_id = t.topic_first_post_id';
422 $sql_match = 'p.post_subject, p.post_text';
423 $sql_match_where = '';
427 if (!sizeof($m_approve_fid_ary))
429 $m_approve_fid_sql = ' AND p.post_approved = 1';
431 else if ($m_approve_fid_ary === array(-1))
433 $m_approve_fid_sql = '';
437 $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')';
440 $sql_select = (!$result_count) ? 'SQL_CALC_FOUND_ROWS ' : '';
441 $sql_select = ($type == 'posts') ? $sql_select . 'p.post_id' : 'DISTINCT ' . $sql_select . 't.topic_id';
442 $sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : '';
443 $field = ($type == 'posts') ? 'post_id' : 'topic_id';
444 if (sizeof($author_ary) && $author_name)
446 // first one matches post of registered users, second one guests and deleted users
447 $sql_author = ' AND (' . $db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')';
449 else if (sizeof($author_ary))
451 $sql_author = ' AND ' . $db->sql_in_set('p.poster_id', $author_ary);
458 $sql_where_options = $sql_sort_join;
459 $sql_where_options .= ($topic_id) ? ' AND p.topic_id = ' . $topic_id : '';
460 $sql_where_options .= ($join_topic) ? ' AND t.topic_id = p.topic_id' : '';
461 $sql_where_options .= (sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
462 $sql_where_options .= $m_approve_fid_sql;
463 $sql_where_options .= $sql_author;
464 $sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
465 $sql_where_options .= $sql_match_where;
467 $sql = "SELECT $sql_select
468 FROM $sql_from$sql_sort_table" . POSTS_TABLE . " p
469 WHERE MATCH ($sql_match) AGAINST ('" . $db->sql_escape(htmlspecialchars_decode($this->search_query)) . "' IN BOOLEAN MODE)
472 $result = $db->sql_query_limit($sql, $config['search_block_size'], $start);
474 while ($row = $db->sql_fetchrow($result))
476 $id_ary[] = (int) $row[$field];
478 $db->sql_freeresult($result);
480 $id_ary = array_unique($id_ary);
482 if (!sizeof($id_ary))
487 // if the total result count is not cached yet, retrieve it from the db
490 $sql = 'SELECT FOUND_ROWS() as result_count';
491 $result = $db->sql_query($sql);
492 $result_count = (int) $db->sql_fetchfield('result_count');
493 $db->sql_freeresult($result);
501 // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page
502 $this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir);
503 $id_ary = array_slice($id_ary, 0, (int) $per_page);
505 return $result_count;
509 * Performs a search on an author's posts without caring about message contents. Depends on display specific params
511 * @param string $type contains either posts or topics depending on what should be searched for
512 * @param boolean $firstpost_only if true, only topic starting posts will be considered
513 * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query
514 * @param string $sort_key is the key of $sort_by_sql for the selected sorting
515 * @param string $sort_dir is either a or d representing ASC and DESC
516 * @param string $sort_days specifies the maximum amount of days a post may be old
517 * @param array $ex_fid_ary specifies an array of forum ids which should not be searched
518 * @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts
519 * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched
520 * @param array $author_ary an array of author ids
521 * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match
522 * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered
523 * @param int $start indicates the first index of the page
524 * @param int $per_page number of ids each page is supposed to contain
525 * @return boolean|int total number of results
529 function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
533 // No author? No posts.
534 if (!sizeof($author_ary))
539 // generate a search_key from all the options to identify the results
540 $search_key = md5(implode('#', array(
543 ($firstpost_only) ? 'firstpost' : '',
549 implode(',', $ex_fid_ary),
550 implode(',', $m_approve_fid_ary),
551 implode(',', $author_ary),
555 // try reading the results from cache
557 if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE)
559 return $result_count;
564 // Create some display specific sql strings
567 // first one matches post of registered users, second one guests and deleted users
568 $sql_author = '(' . $db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')';
572 $sql_author = $db->sql_in_set('p.poster_id', $author_ary);
574 $sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
575 $sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : '';
576 $sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
577 $sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : '';
579 // Build sql strings for sorting
580 $sql_sort = $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
581 $sql_sort_table = $sql_sort_join = '';
582 switch ($sql_sort[0])
585 $sql_sort_table = USERS_TABLE . ' u, ';
586 $sql_sort_join = ($type == 'posts') ? ' AND u.user_id = p.poster_id ' : ' AND u.user_id = t.topic_poster ';
590 $sql_sort_table = ($type == 'posts' && !$firstpost_only) ? TOPICS_TABLE . ' t, ' : '';
591 $sql_sort_join = ($type == 'posts' && !$firstpost_only) ? ' AND t.topic_id = p.topic_id ' : '';
595 $sql_sort_table = FORUMS_TABLE . ' f, ';
596 $sql_sort_join = ' AND f.forum_id = p.forum_id ';
600 if (!sizeof($m_approve_fid_ary))
602 $m_approve_fid_sql = ' AND p.post_approved = 1';
604 else if ($m_approve_fid_ary == array(-1))
606 $m_approve_fid_sql = '';
610 $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')';
613 // If the cache was completely empty count the results
614 $calc_results = ($result_count) ? '' : 'SQL_CALC_FOUND_ROWS ';
616 // Build the query for really selecting the post_ids
617 if ($type == 'posts')
619 $sql = "SELECT {$calc_results}p.post_id
620 FROM " . $sql_sort_table . POSTS_TABLE . ' p' . (($firstpost_only) ? ', ' . TOPICS_TABLE . ' t ' : ' ') . "
633 $sql = "SELECT {$calc_results}t.topic_id
634 FROM " . $sql_sort_table . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p
640 AND t.topic_id = p.topic_id
648 // Only read one block of posts from the db and then cache it
649 $result = $db->sql_query_limit($sql, $config['search_block_size'], $start);
651 while ($row = $db->sql_fetchrow($result))
653 $id_ary[] = (int) $row[$field];
655 $db->sql_freeresult($result);
657 // retrieve the total result count if needed
660 $sql = 'SELECT FOUND_ROWS() as result_count';
661 $result = $db->sql_query($sql);
662 $result_count = (int) $db->sql_fetchfield('result_count');
663 $db->sql_freeresult($result);
673 $this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir);
674 $id_ary = array_slice($id_ary, 0, $per_page);
676 return $result_count;
682 * Destroys cached search results, that contained one of the new words in a post so the results won't be outdated.
684 * @param string $mode contains the post mode: edit, post, reply, quote ...
686 function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id)
690 // Split old and new post/subject to obtain array of words
691 $split_text = $this->split_message($message);
692 $split_title = ($subject) ? $this->split_message($subject) : array();
694 $words = array_unique(array_merge($split_text, $split_title));
699 // destroy cached search results containing any of the words removed or added
700 $this->destroy_cache($words, array($poster_id));
706 * Destroy cached results, that might be outdated after deleting a post
708 function index_remove($post_ids, $author_ids, $forum_ids)
710 $this->destroy_cache(array(), $author_ids);
714 * Destroy old cache entries
720 // destroy too old cached search results
721 $this->destroy_cache(array());
723 set_config('search_last_gc', time(), true);
727 * Create fulltext index
729 function create_index($acp_module, $u_action)
733 // Make sure we can actually use MySQL with fulltext indexes
734 if ($error = $this->init())
739 if (empty($this->stats))
746 if (!isset($this->stats['post_subject']))
748 if ($db->sql_layer == 'mysqli' || version_compare($db->sql_server_info(true), '4.1.3', '>='))
750 //$alter[] = 'MODIFY post_subject varchar(100) COLLATE utf8_unicode_ci DEFAULT \'\' NOT NULL';
754 $alter[] = 'MODIFY post_subject text NOT NULL';
756 $alter[] = 'ADD FULLTEXT (post_subject)';
759 if (!isset($this->stats['post_text']))
761 if ($db->sql_layer == 'mysqli' || version_compare($db->sql_server_info(true), '4.1.3', '>='))
763 $alter[] = 'MODIFY post_text mediumtext COLLATE utf8_unicode_ci NOT NULL';
767 $alter[] = 'MODIFY post_text mediumtext NOT NULL';
769 $alter[] = 'ADD FULLTEXT (post_text)';
772 if (!isset($this->stats['post_content']))
774 $alter[] = 'ADD FULLTEXT post_content (post_subject, post_text)';
779 $db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter));
782 $db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
788 * Drop fulltext index
790 function delete_index($acp_module, $u_action)
794 // Make sure we can actually use MySQL with fulltext indexes
795 if ($error = $this->init())
800 if (empty($this->stats))
807 if (isset($this->stats['post_subject']))
809 $alter[] = 'DROP INDEX post_subject';
812 if (isset($this->stats['post_text']))
814 $alter[] = 'DROP INDEX post_text';
817 if (isset($this->stats['post_content']))
819 $alter[] = 'DROP INDEX post_content';
824 $db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter));
827 $db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
833 * Returns true if both FULLTEXT indexes exist
835 function index_created()
837 if (empty($this->stats))
842 return (isset($this->stats['post_text']) && isset($this->stats['post_subject']) && isset($this->stats['post_content'])) ? true : false;
846 * Returns an associative array containing information about the indexes
848 function index_stats()
852 if (empty($this->stats))
858 $user->lang['FULLTEXT_MYSQL_TOTAL_POSTS'] => ($this->index_created()) ? $this->stats['total_posts'] : 0,
866 if (strpos($db->sql_layer, 'mysql') === false)
868 $this->stats = array();
873 FROM ' . POSTS_TABLE;
874 $result = $db->sql_query($sql);
876 while ($row = $db->sql_fetchrow($result))
878 // deal with older MySQL versions which didn't use Index_type
879 $index_type = (isset($row['Index_type'])) ? $row['Index_type'] : $row['Comment'];
881 if ($index_type == 'FULLTEXT')
883 if ($row['Key_name'] == 'post_text')
885 $this->stats['post_text'] = $row;
887 else if ($row['Key_name'] == 'post_subject')
889 $this->stats['post_subject'] = $row;
891 else if ($row['Key_name'] == 'post_content')
893 $this->stats['post_content'] = $row;
897 $db->sql_freeresult($result);
899 $sql = 'SELECT COUNT(post_id) as total_posts
900 FROM ' . POSTS_TABLE;
901 $result = $db->sql_query($sql);
902 $this->stats['total_posts'] = (int) $db->sql_fetchfield('total_posts');
903 $db->sql_freeresult($result);
907 * Display a note, that UTF-8 support is not available with certain versions of PHP
911 global $user, $config;
915 <dt><label>' . $user->lang['FULLTEXT_MYSQL_PCRE'] . '</label><br /><span>' . $user->lang['FULLTEXT_MYSQL_PCRE_EXPLAIN'] . '</span></dt>
916 <dd>' . (($this->pcre_properties) ? $user->lang['YES'] : $user->lang['NO']) . ' (PHP ' . PHP_VERSION . ')</dd>
919 <dt><label>' . $user->lang['FULLTEXT_MYSQL_MBSTRING'] . '</label><br /><span>' . $user->lang['FULLTEXT_MYSQL_MBSTRING_EXPLAIN'] . '</span></dt>
920 <dd>' . (($this->mbstring_regex) ? $user->lang['YES'] : $user->lang['NO']). '</dd>
923 <dt><label>' . $user->lang['MIN_SEARCH_CHARS'] . ':</label><br /><span>' . $user->lang['FULLTEXT_MYSQL_MIN_SEARCH_CHARS_EXPLAIN'] . '</span></dt>
924 <dd>' . $config['fulltext_mysql_min_word_len'] . '</dd>
927 <dt><label>' . $user->lang['MAX_SEARCH_CHARS'] . ':</label><br /><span>' . $user->lang['FULLTEXT_MYSQL_MAX_SEARCH_CHARS_EXPLAIN'] . '</span></dt>
928 <dd>' . $config['fulltext_mysql_max_word_len'] . '</dd>
932 // These are fields required in the config table