Introducing MWH in the index page and commenrted out with html tags # Copyright (C) 2001 Fahad Al-Awadi (info@panoramika.com) # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. $LINKS= array (); $FILES= array (); $index= array ('index.php'); $replace= "$find"; if ($find=="") print "Please enter a word you wish to search for"; // Output error message if no word else { while ($index!=1) $index = array_walk ($index, 'Process'); foreach ($LINKS as $links) { foreach ($FILES as $files) { if (ereg ($files, $links)) $conclusion[$links]= $files; } } foreach($conclusion as $links => $files) { if ($files!="" && is_file($files)) { //$entries= file ($files); //$contents= implode (" ", $entries); $contents=file_get_contents ($file); // contents of the file put in an array $text= strip_tags ("$contents"); } $conclusion2[$links]= $text; } foreach($conclusion2 as $links => $text) { if (preg_match ("/\b$find\b/i", $text, $founded)) { $number[] =count ($founded); $conclusion3[$links]= $text; } } if (!empty($number)) { $total_matches= array_sum ($number); if ($total_matches >1) $s= 's'; print "Your search for '$find' has found in $total_matches page".$s."

"; $n=1; foreach($conclusion3 as $links => $text) { $text= stristr($text, "$find"); $text_r = preg_replace ("/\b$find\b/i", $replace, $text); print "

$links

$text_r"; if (count ($conclusion3)-$n!=0)print '
'; $n+=1; } } else print "Sorry no matching results were found"; } //************************************************* function Process ($file) { $ext= '(inc|html|php|htm|txt)'; //add the extentions of files you wish to search through. $n= "/()/s"; global $FILES; global $LINKS; global $index; global $message; if ($file!="" && is_file($file)) { $entries= file ($file); $contents= implode (" ", $entries); //converting the values of the array entries into a one string if ( preg_match_all ($n, $contents, $links)) { foreach ($links[0] as $links) { if ( preg_match_all ("/$ext/", $links, $links2)) { if (preg_match_all ("/(\.?\/.*?(inc|html|php|htm|txt))/", $links, $z)) { if (($links!='') && !in_array ("$links", $LINKS)) { array_push ($LINKS, "$links"); foreach ($z[0] as $files) { //$files=ereg_replace ("./", "", $files); //print_r ($files); if (!in_array("$files", $FILES) && $files!="") array_push ( $FILES, "$files"); $index[]= $files; } } } } } } elseif (!in_array("$file", $FILES)) array_push ( $FILES, "$file"); return $index; } } ?>