- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta http-equiv="p_w_picpathtoolbar" content="false" />
- <meta name="baidu-site-verification" content="JQiKjfbHRXKGMrk2" />
- <meta name="Copyright" content="Copyright www.lunanzuche.com All Rights Reserved." />
- <meta name="MSSmartTagsPreventParsing" content="true" />
- <meta name="author" content="MR newdomer" />
- <title>search results</title>
- </head>
- <body>
- <?PHP
- /**
- * s即表单提交来的参数
- **/
- $s = $_GET['s'];
- $dir = substr($_SERVER["SCRIPT_FILENAME"],0,-10);//获取网站文件夹
- $dir=opendir($dir);//Ŀ¼
- while(($file=readdir($dir))!==false){
- if($file!=="." && $file!==".." &&strpos($file,".")){
- //ȡļ
- $c = file_get_contents($file);
- //ƥǷؼ
- $s = $s;
- $r = "/\<title\>(.*)$s(.*)\<\/title\>/i";
- if(preg_match($r,$c)){
- $list[]=$file;
- }
- }
- }
- if(empty($list)){
- echo "no result";
- }else{
- print_r($list);
- }
- //print_r(count($list));
- closedir($dir);
- ?>
- </body>
- </html>
此种方式只适用于小的网站,暂时没有分页功能
转载于:https://blog.51cto.com/cet68/1141244