欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

站内搜索HTML版_PHP教程

程序员文章站 2022-05-15 16:18:32
...
  1. /****************************************************
  2. program : Spr2[search_html]
  3. Author : uchinaboy
  4. E-mail : uchinaboy@163.com
  5. QQ : 16863798
  6. Date : 2001-8-9
  7. ****************************************************/
  8. //require("config.inc.php");
  9. function get_msg($path) {
  10. global $key, $i;
  11. $handle = opendir($path);
  12. while ($filename = readdir($handle)) {
  13. //echo $path."/".$filename."
    ";
  14. $newpath = $path."/".$filename;
  15. $check_type = preg_match("/.html?$/", $filename);
  16. if (is_file($newpath) && $check_type) {
  17. $fp = fopen($newpath, "r");
  18. $msg = fread($fp, filesize($newpath));
  19. fclose($fp);
  20. match_show($key, $msg, $newpath, $filename);
  21. }
  22. if (is_dir($path."/".$filename) && ($filename != ".") && ($filename != "..")) {
  23. //echo "


    ".$newpath."


    ";
  24. get_msg($path."/".$filename);
  25. }
  26. }
  27. closedir($handle);
  28. return $i;
  29. }
  30. function match_show($key, $msg, $newpath, $filename) {
  31. global $key, $i;
  32. $key = chop($key);
  33. if ($key) {
  34. $msg = preg_replace("//is", "", $msg);
  35. $msg = str_replace(" ", "", $msg);
  36. $msg = preg_replace("/]+>/", "", $msg);
  37. $value = preg_match("/.*$key.*/i", $msg, $res);
  38. if ($value) {
  39. $res[0] = preg_replace("/$key/i", "$key", $res[0]);
  40. $i++;
  41. $link = $newpath;
  42. print "$filename
    "
    ;
  43. print $res[0].

    www.bkjia.comtruehttp://www.bkjia.com/PHPjc/486037.htmlTechArticle?php /**************************************************** program:Spr2[search_html] Author:uchinaboy E-mail:uchinaboy@163.com QQ:16863798 Date:2001-8-9 ***************************...