3 Search the text of pages for a match.
4 A few too many regexps for my liking, but it works.
7 WikiHeader("Search Results");
8 echo "<h1>$LogoImage Search Results</h1>\n";
12 // from classic wiki: $pat =~ s/[+?.*()[\]{}|\\]/\\$&/g;
14 $full = preg_replace("/[+?.*()[\]{}|\\\]/", "", $full);
16 // looping through all keys
17 $key = dbmfirstkey($dbi);
20 $pagedata = dbmfetch($dbi, $key);
22 // test the serialized data first, before going further
23 if (preg_match("/$full/i", $pagedata)) {
25 echo "<h3>", LinkExistingWikiWord($key), "</h3>\n";
26 $pagehash = unserialize($pagedata);
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";
40 $key = dbmnextkey($dbi, $key);
43 echo "$found matches found out of $count pages searched.\n";