站內搜尋HTML版_PHP教程

來源:互聯網
上載者:User
  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].

    http://www.bkjia.com/PHPjc/486037.htmlwww.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 ***************************...

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.