i like to include a search engine on my PHP guestbook.
The message data are stored in guest.dat and re.dat.
I found a free php search engine script but got stuck on how to modify the script for use on my site.

I would appreciate if someone could advise me on how to modify the codes (to search the "guest.dat" and "re.dat" in the root directory) as appended below. Many thanks in advance.

HTML Code:
<html> <head> <title>Web Search</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <body bgcolor="#FFFFFF" text="#000000"> <form name="form1" method="post" action="search.php"> <table width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="36%"> <div align="center"> <input type="text" name="keyword"> </div> </td> <td width="64%"> <input type="submit" name="Submit" value="Search"> </td> </tr> </table> </form> </body> </html>
PHP Code:
<?php set_time_limit("600"); $keyword=trim($_POST["keyword"]); if($keyword==""){ echo"Please enter your keyword"; exit; } function listFiles($dir,$keyword,&$array){ $handle=opendir($dir); while(false!==($file=readdir($handle))){ if($file!="."&&$file!=".."){ if(is_dir("$dir/$file")){ listFiles("$dir/$file",$keyword,$array); } else{ $data=fread(fopen("$dir/$file","r"),filesize("$dir/$file")); if(eregi("<body([^>]+)>(.+)</body>",$data,$b)){ $body=strip_tags($b["2"]); } else{ $body=strip_tags($data); } if($file!="search.php"){ if(eregi("$keyword",$body)){ if(eregi("<title>(.+)</title>",$data,$m)){ $title=$m["1"]; } else{ $title="no title"; } $array[]="$dir/$file $title"; } } } } } } $array=array(); listFiles(".","$keyword",$array); foreach($array as $value){ list($filedir,$title)=split("[ ]",$value,"2"); echo "$title "."\n"; } ?>