I have got a code that searches through the meta tags of pages in a directory, but does can someone show me how i could use an array to search multible directories. I think i have added an array at the right place but i am not sure.
-> code
PHP Code:<?
$ext = array("html", "htm", "txt", "php", "jsp");
$_GET[q]=str_replace("<","<",$_GET[q]);
$_GET[q]=str_replace(">",">",$_GET[q]);
$ar = Array();
$qr = explode(" ", $_GET[q]);
$cnt=0;
$mt = explode(' ', microtime());
$script_start_time = $mt[0] + $mt[1];
$ar = dfil();
$h=count($ar);
$n=0;
while($n <= $h) {
if($ar[$n] != "") { srch($ar[$n]); }
$n=$n+1;
}
function dfil() {
global $ext;
$tr = Array(); <----------------- this is the place i think :S
$handle = opendir("./");
while($file = readdir($handle)) {
if( $file != "." && $file != ".." && $file) {
list($a,$b) = explode(".", $file);
$n=0;
$k = count($ext);
while($n <= $k) {
if($b == $ext[$n] && $b != "") { array_push($tr, $file); }
$n=$n+1;
} } }
closedir($handle);
return $tr;
}
function srch($fls) {
global $qr; global $cnt;
$ar = @fread(fopen("$fls", "r"), 2000);
$ar = strip_tags($ar, "<meta><title>");
$br = $ar;
$ar = strtolower($ar);
$ar = str_replace("\"", "", $ar);
list($t1, $t2) = explode("<meta name='keywords' content=", $ar);
list($keys, $t4) = explode(">", $t2);
$x=count($qr);
$y=0;
while($y <= $x) {
if(strpos($keys, $qr[$y])) {
list($t5, $t6) = explode("<meta name='description' content=", $ar);
list($desc, $t7) = explode(">", $t6);
$title = strip_tags($br, "<title>");
list($title, $t45) = explode("</", $br);
$title = preg_replace('/<.+?>/','',$title);
$dc=mBold($desc);
$o=<<<EOF
<a href="$fls"><font size="2" face="Verdana">$title</font></a>
<font size="2" face="Verdana"><br>$dc</font><br><br>
EOF;
$cnt=$cnt+1;
echo $o;
return 0;
}
$y=$y+1;
} }
function mBold($dta) {
global $qr;
$z=0;
$t=count($qr);
while($z <= $t) {
$dta=str_replace($qr[$z], "<B>$qr[$z]</B>", $dta);
$z=$z+1;
}
return $dta;
}
if($cnt==0) {
$no=<<<EOF
<font face=verdana color=navy size=2>
Deine suche für <b>$_GET[q]</b> wurde nichts gefunden</b></font>
EOF;
echo $no;
}
$mt = explode(' ', microtime());
$script_end_time = $mt[0] + $mt[1];
echo "<hr color=#C6C6DA><font face=arial size=1>$cnt Resultaten in ". round($script_end_time - $script_start_time, 5)." Sekunden</font>";
?>







Reply With Quote