1 <!-- $Id: fullsearch.php,v 1.2 2000-10-20 11:42:52 ahollosi Exp $ -->
4 Search the text of pages for a match.
5 A few too many regexps for my liking, but it works.
11 if(get_magic_quotes_gpc())
12 $full = stripslashes($full);
15 $result .= sprintf(gettext ("Searching for \"%s\" ....."),
16 htmlspecialchars($full));
17 $result .= "</B></P>\n<DL>\n";
20 $full = preg_quote($full);
22 // search matching pages
23 $query = InitFullSearch($dbi, $full);
24 while ($pagehash = FullSearchNextMatch($dbi, $query)) {
25 $result .= "<DT><B>" . LinkExistingWikiWord($pagehash["pagename"]) . "</B>\n";
28 // print out all matching lines, highlighting the match
29 for ($j = 0; $j < (count($pagehash["content"])); $j++) {
30 if ($hits = preg_match_all("|$full|i", $pagehash["content"][$j], $dummy)) {
31 $matched = preg_replace("|$full|i",
32 "${FieldSeparator}OT\\0${FieldSeparator}CT",
33 $pagehash["content"][$j]);
34 $matched = htmlspecialchars($matched);
35 $matched = str_replace("${FieldSeparator}OT", '<b>', $matched);
36 $matched = str_replace("${FieldSeparator}CT", '</b>', $matched);
37 $result .= "<dd><small>$matched</small></dd>\n";
43 $result .= "</dl>\n<hr noshade>";
44 $result .= sprintf (gettext ("%d matches found in %d pages."),
47 GeneratePage('MESSAGE', $result, gettext ("Full Text Search Results"), 0);