php 全文搜索

<?php

require($_SERVER['DOCUMENT_ROOT'] . '../smshotactive.inc.php');



//$str = mb_ereg_replace('(??| )+$', '', $str);
//echo mb_ereg_replace('????', "\n????", $str);
//??
//$keyword=trim($_POST[?°keyword?±]);

//???·


$keyword="index";

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!="index-a1.php"){
                            if(eregi("$keyword",$body)){
                                   if(eregi("<title>(.+)</title>",$data,$m)){
                        $title=$m["1"];
                                   }
                                   else{
                        $title="??±?";
                                   }
                                   $array[]="$dir/$file $title";
                            }
                        }
             }
      }
   }
}





$array=array();
listFiles("..",$keyword,$array);

foreach($array as $value){
   //2   list($filedir,$title)=split("[ ]",$value,"2");
   //?3 echo $filedir."<a target=_blank>$title </a>"."<br>";
}


?>
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页