$s_dirs = array(""); durchsucht den ganzen Server $s_skip = array("..",".",""); // Welche Ordner oder Dateien sollen ausgelassen werden? $s_files = "html|htm|HTM|HTML|php3|php4|php|txt|"; // Welche Dateien (Endung) sollen durchsucht werden? Beispiel fuer mehrere Endungen: "html$|htm$|php4$" $limit_extracts = ""; // Wieviele Treffer (Auszuege) sollen _pro Dokument_ ausgegeben. Default: "" also alle, Alternativ: 'Zahl' z.B. "2" $byte_size = "51200"; // Wieviel byte sollen pro zu durchsuchender html-Datei durchsucht werden (Je kleiner, desto schneller die Suche, desto geringer die Chance auf einen Treffer --> html-Dateien sollten eigentlich nicht groesser als 10 KB, also 10240 byte sein) Default: '51200', weil grosse Dateien vorhanden? $limit_hits = array("500"); // Max. Treffer anzeigen, um das select-menue zu unterdruecken und beispielsweise max. 100 Treffer anzuzeigen --> array("100") $path = $NWCONF_SYSTEM['server_path'].'language/'.$NWCONF_DISPLAY['language'].'.lang'.$NWCONF_SYSTEM['php_ext']; if(!file_exists($path)) { DIE("$path"); } else{ if(!include($path)) { DIE("Fehler"); } } //ini_set("error_reporting", "2047"); // Debugger // search_form(): Gibt das Suchformular aus function search_form($HTTP_GET_VARS, $limit_hits, $PHP_SELF) { global $NW_TRANSLATION, $NWCONF_SYSTEM; @$keyword=$HTTP_GET_VARS['keyword']; @$case=$HTTP_GET_VARS['case']; @$limit=$HTTP_GET_VARS['limit']; echo '
', "\n", " "; $j=count($limit_hits); if($j==1) echo ""; elseif($j>1) { echo " "; } echo "\n", "
\n", "". $NW_TRANSLATION['message_6']." \n", "
\n", "
\n"; } // search_headline(): Ueberschrift Suchergebnisse function search_headline($HTTP_GET_VARS) { global $NW_TRANSLATION, $NWCONF_SYSTEM; @$keyword=$HTTP_GET_VARS['keyword']; @$action=$HTTP_GET_VARS['action']; if($action == "SEARCH") // Volltextsuche echo "

". $NW_TRANSLATION['message_3']." '".htmlentities(stripslashes($keyword))."'

"; } // search_error(): Auf Fehler testen und Suchfehler anzeigen function search_error($HTTP_GET_VARS, $min_chars, $max_chars, $message_1, $message_2, $limit_hits) { global $HTTP_GET_VARS,$NW_TRANSLATION, $NWCONF_SYSTEM; @$keyword=$HTTP_GET_VARS['keyword']; @$action=$HTTP_GET_VARS['action']; @$limit=$HTTP_GET_VARS['limit']; if($action == "SEARCH") { // Volltextsuche if(strlen($keyword)<$NWCONF_SYSTEM['min_chars']||strlen($keyword)>$NWCONF_SYSTEM['max_chars']||!in_array ($limit, $limit_hits)) { // Ist die Anfrage in Ordnung (min. '$min_chars' Zeichen, max. '$max_chars' Zeichen)? echo '

'. $NW_TRANSLATION['message_1'].'
'. $NW_TRANSLATION['message_2'].'

'; $HTTP_GET_VARS['action'] = "ERROR"; // Suche abbrechen } } } // search_dir(): Volltextsuche in Verzeichnissen function search_dir($my_server, $my_root, $s_dirs, $s_files, $s_skip, $message_1, $message_2, $no_title, $limit_extracts, $byte_size, $HTTP_GET_VARS) { global $count_hits,$NW_TRANSLATION; @$keyword=$HTTP_GET_VARS['keyword']; @$action=$HTTP_GET_VARS['action']; @$limit=$HTTP_GET_VARS['limit']; @$case=$HTTP_GET_VARS['case']; if($action == "SEARCH") { // Volltextsuche foreach($s_dirs as $dir) { // Alle Verzeichnisse in $s_dirs durchsuchen $handle = @opendir($my_root.$dir); while($file = @readdir($handle)) { if(in_array($file, $s_skip)) { // Alles in $skip auslassen continue; } elseif($count_hits>=$limit) { break; // Maximale Trefferzahl erreicht } elseif(is_dir($my_root.$dir."/".$file)) { // Unterverzeichnisse durchsuchen $s_dirs = array("$dir/$file"); search_dir($my_server, $my_root, $s_dirs, $s_files, $s_skip, $NW_TRANSLATION['message_1'], $NW_TRANSLATION['message_2'], $NW_TRANSLATION['no_title'], $limit_extracts, $byte_size, $HTTP_GET_VARS); // search_dir() rekursiv auf alle Unterverzeichnisse aufrufen } elseif(preg_match("/($s_files)$/i", $file)) { // Alle Dateien gemaess Endungen $s_files $fd=fopen($my_root.$dir."/".$file,"r"); $text=fread($fd, $byte_size); // 50 KB $keyword_html = htmlentities($keyword); if($case) { // Gross-/Kleinschreibung beruecksichtigen? $do=strstr($text, $keyword)||strstr($text, $keyword_html); } else { $do=stristr($text, $keyword)||stristr($text, $keyword_html); } if($do) { $count_hits++; // Treffer zaehlen if(preg_match_all("/TITLE\|\|(.*)\|\|END/siU", $text, $titel)){ // Headline auslesen, falls vorhanden if(!$titel[1][0]) // Headline nicht vorhanden $link_title = $NW_TRANSLATION['no_title']; // ...also $no_title else $link_title = $titel[1][0]; // Headline vorhanden... } else{ $link_title = $NW_TRANSLATION['no_title']; // ...ansonsten $no_title } if(preg_match_all("/ARTICLE\|\|(.*)\|\|END/siU", $text, $url)){ $link_url = $url[1][0]; echo "$count_hits. $link_title
"; // Ausgabe des Links } else{ echo "$count_hits. $link_title
"; // Ausgabe des Links } if(preg_match_all("/DATE\|\|(.*)\|\|END/siU", $text, $topic )){ // Rubrik auslesen, falls vorhanden if(!3) // Rubrik nicht vorhanden $topic_title = $NW_TRANSLATION['no_topic']; // ...also $no_topic else $topic_title = $topic[1][0]; // Rubrik vorhanden... } else{ $topic_title = $NW_TRANSLATION['no_topic']; // ...ansonsten $no_topic } echo '

'.$NW_TRANSLATION['no_topic1']. $topic_title.'

'; // Ausgabe der Rubrik $text1 = preg_replace("/TOPIC\|\|/s", " ", $text); $text2 = preg_replace("/\|\|END/s", " ", $text1); $text3 = preg_replace("/TEXT\|\|/s", " ", $text2); $text4 = preg_replace("/TITLE\|\|/s", " ", $text3); $text5 = preg_replace("/SHORTTEXT2\|\|/s", " ", $text4); $text6 = preg_replace("/SHORTTEXT3\|\|/s", " ", $text5); $text7 = preg_replace("/LONGTEXT2\|\|/s", " ", $text6); $text8 = preg_replace("/LONGTEXT3\|\|/s", " ", $text7); $text9 = preg_replace("/NAME\|\|/s", " ", $text8); $text10 = preg_replace("/EMAIL\|\|/s", " ", $text9); $text11 = preg_replace("/LINK\|\|/s", " ", $text10); $text12 = preg_replace("/LINK1\|\|/s", " ", $text11); $text13 = preg_replace("/LINK2\|\|/s", " ", $text12); $text14 = preg_replace("/DATE\|\|/s", " ", $text14); $auszug = strip_tags($text13); $keyword = preg_quote($keyword); // unescapen $keyword = str_replace("/", "\/", "$keyword"); $keyword_html = preg_quote($keyword_html); // unescapen $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++){ // Kein Limit angegeben also alle Vorkommen ausgeben 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(): Ausgabe 'keine Treffer' bei der Suche function search_no_hits($HTTP_GET_VARS, $count_hits) { global $NW_TRANSLATION, $NWCONF_SYSTEM; @$action=$HTTP_GET_VARS['action']; if($action == "SEARCH" && $count_hits<1) // Volltextsuche, kein Treffer echo "

". $NW_TRANSLATION['message_4']."

"; } include ($NWCONF_SYSTEM['server_path'] . 'templates/default/header_all.tpl.php'); ?>