站内搜索HTML版_PHP教程
程序员文章站
2022-05-15 16:18:32
...
- /****************************************************
- program : Spr2[search_html]
- Author : uchinaboy
- E-mail : uchinaboy@163.com
- QQ : 16863798
- Date : 2001-8-9
- ****************************************************/
- //require("config.inc.php");
- function get_msg($path) {
- global $key, $i;
- $handle = opendir($path);
- while ($filename = readdir($handle)) {
- //echo $path."/".$filename."
";- $newpath = $path."/".$filename;
- $check_type = preg_match("/.html?$/", $filename);
- if (is_file($newpath) && $check_type) {
- $fp = fopen($newpath, "r");
- $msg = fread($fp, filesize($newpath));
- fclose($fp);
- match_show($key, $msg, $newpath, $filename);
- }
- if (is_dir($path."/".$filename) && ($filename != ".") && ($filename != "..")) {
- //echo "
".$newpath."
";- get_msg($path."/".$filename);
- }
- }
- closedir($handle);
- return $i;
- }
- function match_show($key, $msg, $newpath, $filename) {
- global $key, $i;
- $key = chop($key);
- if ($key) {
- $msg = preg_replace("//is", "", $msg);
- $msg = str_replace(" ", "", $msg);
- $msg = preg_replace("/]+>/", "", $msg);
- $value = preg_match("/.*$key.*/i", $msg, $res);
- if ($value) {
- $res[0] = preg_replace("/$key/i", "$key", $res[0]);
- $i++;
- $link = $newpath;
- print "$filename
";- print $res[0].
上一篇: 再来个快的_PHP教程
推荐阅读