"; foreach ($files as $file) { $a = fopen($file, "r"); $string = fread($a, filesize($file)); fclose($a); if(stristr($string, $term)) { $count++; $matchFound = true; if ($count <= $numPerPage * ($page-1)) { continue; } if ($count > $numPerPage * $page) { break; } $out = split(" ", $string); $title = $out[0]; $url = $out[1]; $desc = $out[2]; $retVal .= " "; if ($desc != null && $desc != '') { $retVal .= "
" . $desc . "
"; } $retVal .= "
" . $url . "
"; } } $retVal .= "
"; if ($matchFound && $count > $numPerPage) { $navButtons = "
"; if ($page > 1) { $navButtons .= "<< Prev"; } else { $navButtons .= "<< Prev"; } $navButtons .= "|"; if ($count > $numPerPage * $page) { $navButtons .= "Next >>"; } else { $navButtons .= "Next >>"; } $navButtons .= "
"; $retVal = str_replace("#TOP_OF_RESULTS#", $navButtons, $retVal); $retVal .= $navButtons; } else { $retVal = str_replace("#TOP_OF_RESULTS#", "", $retVal); } } if (!$matchFound) { return "
No matches for '" . $term . "'
"; } return $retVal; } function listallfiles($searchpath) { $allfiles=array(); $root = @opendir($searchpath); while($file = readdir($root)) { if($file != "." && $file != "..") { if (!is_dir($file)) { $ext = getfileextention($file); if ($ext == "idx") { $allfiles[] = $searchpath . $file; } } } } closedir($root); return $allfiles; } function getfileextention($filename) { $path_info = pathinfo($filename); return $path_info['extension']; } ?>