]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - wiki_fullsearch.php3
This commit was generated by cvs2svn to compensate for changes in r2,
[SourceForge/phpwiki.git] / wiki_fullsearch.php3
1 <?
2    /*
3       Search the text of pages for a match.
4       A few too many regexps for my liking, but it works.
5    */
6
7    WikiHeader("Search Results");
8    echo "<h1>$LogoImage Search Results</h1>\n";
9
10    $found = $count = 0;
11
12    // from classic wiki: $pat =~ s/[+?.*()[\]{}|\\]/\\$&/g;
13
14    $full = preg_replace("/[+?.*()[\]{}|\\\]/", "", $full);
15
16    // looping through all keys
17    $key = dbmfirstkey($dbi);
18
19    while ($key) {
20       $pagedata = dbmfetch($dbi, $key);   
21
22       // test the serialized data first, before going further
23       if (preg_match("/$full/i", $pagedata)) {
24
25          echo "<h3>", LinkExistingWikiWord($key), "</h3>\n";
26          $pagehash = unserialize($pagedata);
27
28          // print out all matching lines, highlighting the match
29          for ($j = 0; $j < (count($pagehash["text"])); $j++) {
30             if (preg_match("/$full/i", $pagehash["text"][$j], $pmatches)) {
31                $matched = preg_replace("/$full/i", "<b>\\0</b>",
32                                        $pagehash["text"][$j]);
33                $found += count($pmatches);
34                echo "<li>", $matched, "</li>\n";
35             }
36          }
37          echo "<hr>\n";
38       }
39       $count++;
40       $key = dbmnextkey($dbi, $key);
41    }
42
43    echo "$found matches found out of $count pages searched.\n";
44    WikiFooter();
45
46
47 ?>