]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - wiki_fullsearch.php3
Added new markup rules for ordered and unordered lists.
[SourceForge/phpwiki.git] / wiki_fullsearch.php3
1 <!-- $Id: wiki_fullsearch.php3,v 1.8 2000-07-04 21:26:43 ahollosi Exp $ -->
2 <?
3    /*
4       Search the text of pages for a match.
5       A few too many regexps for my liking, but it works.
6    */
7
8    $found = 0;
9    $count = 0;
10
11    if(get_magic_quotes_gpc())
12       $full = stripslashes($full);
13
14    $result = "<P><B>Searching for \"" . htmlspecialchars($full) .
15                 "\" ....</B></P>\n<DL>\n";
16
17    // quote regexp chars
18    $full = preg_quote($full);
19
20    // search matching pages
21    $query = InitFullSearch($dbi, $full);
22    while ($pagehash = FullSearchNextMatch($dbi, $query)) {
23       $result .= "<DT><B>" . LinkExistingWikiWord($pagehash["pagename"]) . "</B>\n";
24       $count++;
25
26       // print out all matching lines, highlighting the match
27       for ($j = 0; $j < (count($pagehash["content"])); $j++) {
28          if ($hits = preg_match_all("|$full|i", $pagehash["content"][$j], $dummy)) {
29             $matched = preg_replace("|$full|i", "<b>\\0</b>",
30                                     $pagehash["content"][$j]);
31             $result .= "<dd><small>$matched</small></dd>\n";
32             $found += $hits;
33          }
34       }
35    }
36
37    $result .= "</dl>\n<hr noshade>$found matches found in $count pages.\n";
38    GeneratePage('MESSAGE', $result, "Full Text Search Results", 0);
39 ?>