站内搜索HTML版

 

  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&nb sp;{    
  49. echo "请输入关键词";    
  50. exit;    
  51. }      
  52. }    
  53. $i = get_msg(".");    
  54. echo "<BR><BR>".$i."<BR><BR><BR>";    
  55.  
  56. ?>   

 

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

Grow your business fast with

Suku