/*
Search the text of pages for a match.
A few too many regexps for my liking, but it works.
*/
$found = 0;
$count = 0;
if(get_magic_quotes_gpc())
$full = stripslashes($full);
$result = "
Searching for \"" . htmlspecialchars($full) .
"\" ....
\n\n";
// quote regexp chars
$full = preg_quote($full);
// search matching pages
$query = InitFullSearch($dbi, $full);
while ($pagehash = FullSearchNextMatch($dbi, $query)) {
$result .= "- " . LinkExistingWikiWord($pagehash["pagename"]) . "\n";
$count++;
// print out all matching lines, highlighting the match
for ($j = 0; $j < (count($pagehash["content"])); $j++) {
if ($hits = preg_match_all("/$full/i", $pagehash["content"][$j], $dummy)) {
$matched = preg_replace("/$full/i", "\\0",
$pagehash["content"][$j]);
$result .= "
- $matched
\n";
$found += $hits;
}
}
}
$result .= "
\n
$found matches found in $count pages.\n";
GeneratePage('MESSAGE', $result, "Full Text Search Results", 0);
?>