= "4.1.0") { extract($_GET); extract($_POST); extract($_SERVER); extract($_COOKIE); } header("content-type:text/html; charset=shift_jis"); @readfile(".header.html"); mb_language("Ja"); mb_internal_encoding("SJIS"); print '
検索:  '.'

'; function MakePattern($word){ $word = quotemeta($word); // SJIS なので、quote で エスケープする $word = str_replace(" "," ",$word); $word = ereg_replace(" +"," ",$word); $word = ereg_replace(" $","",$word); $word = ereg_replace(" ",")(?=.*",$word); $word="/(?=.*".$word.")/i"; return $word; } if(isset($word) && strlen($word)>0){ echo "検索結果 : ".$word; $pat=MakePattern($word); echo '
'; $res =SearchDir(".",$pat); rsort($res); print "検索結果の数:".count($res)."

"; for($i=0; $i
"; } function SearchDir($dn,$pat){ $a=array(); $dir=@opendir($dn); while(false !== ($fn=readdir($dir))){ if(is_dir($dn.'/'.$fn) && $fn!=".." && $fn!="."){ $res = SearchDir($dn.'/'.$fn,$pat); if(isset($res)) $a=array_merge($a,$res); } else if (is_file($dn.'/'.$fn) && preg_match("/^[a-z,0-9]*.html$/i",$fn)){ $res = SearchContents($dn.'/'.$fn,$pat); // .html ファイルだったら... if(isset($res)){ $a=array_merge($a,$res); } } } closedir($dir); return $a; } function SearchContents($fn,$pat){ $fp=fopen($fn,"r"); $data=fread($fp,filesize($fn)); $data=strip_tags($data); if(preg_match($pat,$data)) { //$d = filemtime($fn); $link=''.ereg_replace(".*/","",$fn).'
'; $data = mb_substr($data,0,50); $res=array($link.$data); } fclose($fp); return $res; } @readfile(".footer.html"); ?>