$s_dirs = array(""); searches the entire server $s_skip = array("/aspnet_client","/blog","/Cal","/CGI-BIN","/CSS","/email","/Files","/flash","/images","/lightbox","/PDFs","/Scripts","/SpryAssets","/thumbs"); // Which files/dirs do you like to skip? $s_files = "htm|php"; // Which files types should be searched? Example: "html$|htm$|php4$" $min_chars = "3"; // Min. chars that must be entered to perform the search $max_chars = "30"; // Max. chars that can be submited to perform the search $default_val = ""; // Default value in searchfield $limit_hits = array("20","30","50","100"); // How many hits should be displayed, to suppress the select-menu simply use one value in the array --> array("100") $message_1 = "Invalid Searchterm!"; // Invalid searchterm $message_2 = "Please enter at least $min_chars characters."; // Invalid searchterm long ($min_chars/$max_chars) $message_3 = "Your search result(s) for:"; // Headline searchresults $message_4 = "Sorry, no hits."; // No hits $message_5 = "results"; // Hits // $message_6 = "Match case"; // Match case $message_7 = "End of search"; $no_title = "Carolina Woman"; // This should be displayed if no title or empty title is found in file $limit_extracts_extracts = ""; // How many extratcts per file do you like to display. Default: "" --> every extract, alternative: 'integer' e.g. "3" $byte_size = "20000"; // How many bytes per file should be searched? Reduce to increase speed //ini_set("error_reporting", "2047"); // Debugger // search_form(): Gibt das Suchformular aus function search_form($_GET, $limit_hits, $default_val, $message_5, $PHP_SELF) { @$keyword=$_GET['keyword']; @$case=$_GET['case']; @$limit=$_GET['limit']; echo "
\n", "\n", " "; $j=count($limit_hits); if($j==1) echo ""; elseif($j>1) { echo " "; } echo "\n", "
\n", //"$message_6 \n"; } // search_headline() function search_headline($_GET, $message_3) { @$keyword=$_GET['keyword']; @$action=$_GET['action']; if($action == "SEARCH") echo "

$message_3 '".htmlentities(stripslashes($keyword))."'

"; } // search_error() function search_error($_GET, $min_chars, $max_chars, $message_1, $message_2, $limit_hits) { global $_GET; @$keyword=$_GET['keyword']; @$action=$_GET['action']; @$limit=$_GET['limit']; if($action == "SEARCH") { if(strlen($keyword)<$min_chars||strlen($keyword)>$max_chars||!in_array ($limit, $limit_hits)) { echo "

$message_1
$message_2

"; $_GET['action'] = "ERROR"; } } } // search_dir() function search_dir($my_server, $my_root, $s_dirs, $s_files, $s_skip, $message_1, $message_2, $no_title, $limit_extracts, $byte_size, $_GET) { global $count_hits; @$keyword=$_GET['keyword']; @$action=$_GET['action']; @$limit=$_GET['limit']; @$case=$_GET['case']; if($action == "SEARCH") { foreach($s_dirs as $dir) { $handle = @opendir($my_root.$dir); while($file = @readdir($handle)) { if(in_array($file, $s_skip)) { continue; } elseif($count_hits>=$limit) { break; } elseif(is_dir($my_root.$dir."/".$file)) { $s_dirs = array("$dir/$file"); search_dir($my_server, $my_root, $s_dirs, $s_files, $s_skip, $message_1, $message_2, $no_title, $limit_extracts, $byte_size, $_GET); // search_dir() } elseif(preg_match("/($s_files)$/i", $file)) { $fd=fopen($my_root.$dir."/".$file,"r"); $text=fread($fd, $byte_size); // 50 KB $keyword_html = htmlentities($keyword); if($case) { $do=strstr($text, $keyword)||strstr($text, $keyword_html); } else { $do=stristr($text, $keyword)||stristr($text, $keyword_html); } if($do) { $count_hits++; if(preg_match("/(.+)<\/title>/i", $text, $title)) { if(!$title[1][0]) // <title> $link_title=$no_title; // ...also $no_title else $link_title=$title[1][0]; // ... } else { $link_title=$no_title; // $no_title } echo "$count_hits. $link_title
"; $auszug = 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", $auszug, $match, PREG_SET_ORDER)); { if(!$limit_extracts) $number=count($match); else $number=$limit_extracts; for ($h=0;$h<$number;$h++) { if (!empty($match[$h][3])) printf(".. %s%s%s ..", $match[$h][1], $match[$h][3], $match[$h][4]); } } echo "

"; flush(); } fclose($fd); } } @closedir($handle); } } } // search_no_hits() function search_no_hits($_GET, $count_hits, $message_4) { @$action=$_GET['action']; if($action == "SEARCH" && $count_hits<1) echo "

$message_4

"; } ?> Carolina Woman Magazine