2 // Search the text of pages for a match.
3 rcs_id('$Id: fullsearch.php,v 1.6 2001-02-12 01:43:10 dairiki Exp $');
5 if (empty($searchterm))
6 $searchterm = ''; // FIXME: do something better here?
8 fix_magic_quotes_gpc($searchterm);
11 . sprintf(gettext ("Searching for \"%s\" ....."),
12 htmlspecialchars($searchterm))
15 // search matching pages
16 $query = InitFullSearch($dbi, $searchterm);
18 // quote regexp chars (space are treated as "or" operator)
19 $qterm = preg_replace("/\s+/", "|", preg_quote($searchterm));
23 while ($pagehash = FullSearchNextMatch($dbi, $query)) {
24 $html .= "<DT><B>" . LinkExistingWikiWord($pagehash["pagename"]) . "</B>\n";
27 // print out all matching lines, highlighting the match
28 for ($j = 0; $j < (count($pagehash["content"])); $j++) {
29 if ($hits = preg_match_all("/$qterm/i", $pagehash["content"][$j], $dummy)) {
30 $matched = preg_replace("/$qterm/i",
31 "${FieldSeparator}OT\\0${FieldSeparator}CT",
32 $pagehash["content"][$j]);
33 $matched = htmlspecialchars($matched);
34 $matched = str_replace("${FieldSeparator}OT", '<b>', $matched);
35 $matched = str_replace("${FieldSeparator}CT", '</b>', $matched);
36 $html .= "<dd><small>$matched</small></dd>\n";
42 $html .= "</dl>\n<hr noshade>"
43 . sprintf (gettext ("%d matches found in %d pages."),
47 echo GeneratePage('MESSAGE', $html, gettext ("Full Text Search Results"), 0);