\n", "", " "; echo "\n"; } //search_results_title(): function search_results_title($HTTP_GET_VARS) { @$keyword=$HTTP_GET_VARS['keyword']; @$action=$HTTP_GET_VARS['action']; if($action == "SEARCH") echo "Find: '".htmlentities(stripslashes($keyword))."'
\n"; } //search_keyword_length_check(): function search_keyword_length_check($HTTP_GET_VARS) { global $HTTP_GET_VARS; @$keyword=$HTTP_GET_VARS['keyword']; @$action=$HTTP_GET_VARS['action']; if($action == "SEARCH") { if(strlen($keyword)<3||strlen($keyword)>40) { echo "

Invalid search term
Please type 3 to 40 characters

"; $HTTP_GET_VARS['action'] = "ERROR"; } } } //search_files(): function search_files($server_name, $doc_root, $search_dir, $file_types, $file_skip, $file_hits, $file_terms, $file_bytes, $HTTP_GET_VARS) { global $count_hits; @$keyword=$HTTP_GET_VARS['keyword']; @$action=$HTTP_GET_VARS['action']; if($action == "SEARCH") { foreach($search_dir as $dir) { $handle = @opendir($doc_root.$dir); while($file = @readdir($handle)) { if(in_array($file, $file_skip)) {continue;} elseif($count_hits>=$file_hits) {break;} elseif(is_dir($doc_root.$dir."/".$file)) { $search_dir = array("$dir/$file"); search_files($server_name, $doc_root, $search_dir, $file_types, $file_skip, $file_hits, $file_terms, $file_bytes, $HTTP_GET_VARS); } elseif(preg_match("/($file_types)$/i", $file)) { $fd=fopen($doc_root.$dir."/".$file,"r"); $text=fread($fd, $file_bytes); $keyword_html = htmlentities($keyword); $do=stristr($text, $keyword)||stristr($text, $keyword_html); if($do) { $count_hits++; if(preg_match_all("=]*>(.*)=siU", $text, $title)) { if(!$title[1][0]) $link_title="No Title"; else $link_title=$title[1][0]; } else {$link_title="No Title";} echo "$count_hits. $file
"; $extract = strip_tags($text); $keyword = preg_quote($keyword); $keyword = str_replace("/","\/","$keyword"); $keyword_html = preg_quote($keyword_html); $keyword_html = str_replace("/","\/","$keyword_html"); echo ""; if(preg_match_all("/((\s\S*){0,3})($keyword|$keyword_html)((\s?\S*){0,3})/i", $extract, $match, PREG_SET_ORDER)); { $number=$file_terms; for ($h=0;$h<$number;$h++) { if (!empty($match[$h][3])) printf(".. %s%s%s ..", $match[$h][1], $match[$h][3], $match[$h][4]); } } flush(); } fclose($fd); } } @closedir($handle); } } } //search_no_hits(): function search_no_hits($HTTP_GET_VARS, $count_hits) { @$keyword=$HTTP_GET_VARS['keyword']; @$action=$HTTP_GET_VARS['action']; if($action == "SEARCH" && $count_hits<1) echo "

The term '".htmlentities(stripslashes($keyword))."' not found

"; } ?>