html5中文学习网

您的位置: 首页 > 网络编程 > PHP编程 » 正文

站内搜索HTML版_PHP教程_编程技术

[ ] 已经帮助:人解决问题
  1. <?php    
  2. /****************************************************     
  3. program : Spr2[search_html]     
  4. Author  : uchinaboy      
  5. E-mail  : uchinaboy@163.com     
  6. QQ      : 16863798     
  7. Date    : 2001-8-9    
  8. ****************************************************/    
  9. //require("config.inc.php");    
  10.  
  11. function get_msg($path) {    
  12. global $key$i;    
  13. $handle = opendir($path);    
  14. while ($filename = readdir($handle)) {    
  15. //echo $path."/".$filename."<br>";    
  16. $newpath = $path."/".$filename;    
  17. $check_type = preg_match("//.html?$/"$filename);    
  18. if (is_file($newpath) && $check_type) {    
  19. $fp = fopen($newpath"r");    
  20. $msg = fread($fpfilesize($newpath));    
  21. fclose($fp);    
  22. match_show($key$msg$newpath$filename);    
  23. }    
  24. if (is_dir($path."/".$filename) && ($filename != ".") &&  ($filename != "..")) {    
  25. //echo "<BR><BR><BR>".$newpath."<BR><BR><BR>";    
  26. get_msg($path."/".$filename);    
  27. }    
  28. }    
  29. closedir($handle);    
  30. return $i;    
  31. }    
  32.  
  33. function match_show($key$msg$newpath$filename) {    
  34. global $key$i;    
  35. $key = chop($key);    
  36. if ($key) {    
  37. $msg = preg_replace("/<style>.+<//style>/is"""$msg);    
  38. $msg = str_replace(" """$msg);    
  39. $msg = preg_replace("/<[^>]+>/"""$msg);    
  40. $value = preg_match("/.*$key.*/i"$msg$res);    
  41. if ($value) {    
  42. $res[0] = preg_replace("/$key/i""<FONT SIZE=/"2/"  COLOR=/"red/">$key</FONT>"$res[0]);    
  43. $i++;    
  44. $link = $newpath;    
  45. print "<a href=/"$link/">$filename</a><BR>";    
  46. print $res[0]."<BR><br>";    
  47. }    
  48. }else {    
  49. echo "请输入关键词";    
  50. exit;    
  51. }      
  52. }    
  53. $i = get_msg(".");    
  54. echo "<BR><BR>".$i."<BR><BR><BR>";    
  55.  
  56. ?>   


p4iHTML5中文学习网 - HTML5先行者学习网
p4iHTML5中文学习网 - HTML5先行者学习网
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助