$title="Glimpse Search"; include "header"; /* Set this to the directory containing your .glimpse* files */ $gdir = "/u/www/servers/lerdorf/php3"; /* Set this to the path of your glimpse binary */ $glimpse = "/usr/local/bin/glimpse"; if(!isset($pattern)) { ?>
You may use a ';' (semi-colon) between expressions to represent a logical "AND" while a ',' (comma) represents an "OR". So, to search for APPLE and ORANGE, use "APPLE;ORANGE". You may also use full regular expressions in the search field.} else { ?>
Search expression:
SORRY - Search index is currently being rebuilt, please try again in a few minutes.
No matches found!"; } else { ?>Results - out of
$i=$st_num-1; while($i<$num && $i<($st_num+$psize-1)) { ereg("(/[^/]*)(/[^/]*)\$",$result[$i],&$regs); $line = $regs[1].$regs[2]; $file = ereg_replace(":.*\$","",$result[$i]); $l = strlen($file); if($l<30) { $filepat=$file; } else { /* Glimpse can't handle file pattern specs longer than 29 chars so we take the last 29 and hope the path is unique in those 29 */ $filepat = substr($file,$l-29,29); } $url = ereg_replace(":.*\$","",$line); $cnt = (int)ereg_replace("^.*: ","",$line); $size = filesize($file); $mtime = date("D M d/y",filemtime($file)); error_reporting(0); $fp = fopen($file,"r"); error_reporting(1); if($fp>-1) { $text = fgetss($fp,256); $text = ereg_replace(" +"," ",$text); $text = ereg_replace(13,"",$text); while(strlen($text)<3 && !feof($fp)) { $text = fgetss($fp,256); $text = ereg_replace(" +"," ",$text); $text = ereg_replace(13,"",$text); if(!strlen(ereg("[a-zA-Z0-9]",$text))) { $text=""; } } $j=0; $remain = ereg_replace(".+[\?]","",$text); if($text!=$remain) { $text = $text - $remain; } echo "$text file size: $size modified: $mtime matches: $cnt\n"; echo "
"; exec("$glimpse $icase $words $fuzzy -y -L0:0:1 -q -F '$filepat' -H $gdir '$pattern'",&$context); $pos = ereg("@",$context); unset($context); $pos = substr($pos,1,strlen($pos)); $pos = intval(ereg_replace("{.*","",$pos)); if($pos > ftell($fp)) { fseek($fp,$pos-1); } while(!feof($fp) && $j<240) { $text = fgetss($fp,256); $j+=strlen($text); echo HtmlSpecialChars($text); } fclose($fp); echo "\n"; } $i++; } ?> $st_num+=$psize; if($st_num <= $num) { ?> } } } ?>