mantis: search engine

Beitrag lesen

jemand ne ahnung warum das nicht klappt??

TextSearch.php
<?php

function query_html ($dir, $q_num, $q_array)
{
 //chdir($dir);
 $current_dir=opendir($dir);
 while ($current_file=readdir($current_dir))
 {
  if ($current_file=="." || $current_file=="..")
  continue;
  $fn="$dir"."$current_file";
  $filearray = file("$fn");
  $relevancy=0;
  $mypage="$current_file";
  $mycontent=strtolower(strip_tags(implode (" ", $filearray)));
  for ($d=0; $d<$q_num; $d++)
  {
   $relevancy+=substr_count((string)$mycontent, (string)strtolower(strip_tags($q_array[$d])));
  }//end of for
  if ($relevancy>0)
  $res["$mypage"]=$relevancy;
 }//end of while
 if (count($res)>0)
 arsort ($res);
 return $res;
}//end of query_html

function print_answers ($search, $zoneurl, $r)
{
 $c=0;
 if (count($r)<1)
  echo "Search Fail !!!<br>";
 else
 {
  echo "<BR>Searched for word <b> ".$search.". </b>     Results found : <b>".count($r)."</b>";
  while ($element=each($r))
  {
   if ($c<5)
   {
    echo "<li>";
    echo "<a href=";
    echo $zoneurl.$element["key"];
    echo ">";
    echo "Page number ".$element["key"]."</a>";
    echo "</li>\n";
    $c++;
   }
  }//end of while
 }//end of else
}//end of print_answers
?>
<HTML>
<HEAD>
<TITLE> Text Search  </TITLE>
</HEAD>
<BODY>
<form action="testsearch.php" method="post" name="form1">
<input type="text" name="search" value="<?php echo $search;?>">
<input type="submit" value="submit" name="submit1">
<?php

if(!empty($search))
{
 $q_array=explode(" ", $search);
 $q_num=(integer)count($q_array);

$r=query_html ("./", $q_num, $q_array);
 print_answers ($search, "http://yourserver/searchfolder/", $r);
}
?>
</form>
</BODY>
</HTML>