• ----:)欢迎访问源码网(:----
    • 首页
    • 博客
    • 学院
    • 下载
    • 论坛
    • 影视
    • 发布源码
    • RSS
    • ITPig
    • 笑话网
    • 百家姓
    • 繁體中文

源码网 - 中国第一源码门户
选择镜像:网通镜像 - 电信主站
  • 首 页
  • 新闻动态
  • 网站运营
  • 网页制作
  • WEB开发
  • 编程开发
  • 图像媒体
  • 操作系统
  • 数据库
  • 服务器
热门搜索 优化 SEO 故事 cms IIS7 MySQL 个人 AdSense 主题推广 | 文章搜索: 高级搜索
会员登录/控制面版您的位置: 学院首页 >> WEB开发 >> PHP 开发 >> PHP入门 >> 详细内容
 

推荐文章

  • 谈谈新手如何学习PHP
  • PHP脚本的8个技巧
 
 

热点文章

  • PHP中的cookie
  • 谈谈新手如何学习PHP
  • PHP脚本的8个技巧
  • 二元分词函数的分析
  • PHP5学习笔记 -- Classes and Objects in PHP5
  • ascii码及扩展码
  • php调用MSSQL存储过程
  • php中Cookie的设置与使用
  • php新手入门(经验谈)
  • PHP编辑器
  • fgets函数
  • 如何用PHP做到即时简繁切换
 
 

相关文章

  • 实例演示在SQL数据库中启用全文检索
  • 在UNIX服务器上设置Oracle8i全文检索(1)
 
 

百度搜索

 
 

翻出一篇老文章:php文本站内全文检索

  • 阅览次数:
  • 文章来源: CP整理
  • 原文作者: 不详
  • 整理日期: 2007-02-08
  • 发表评论
  • 字体大小:
  • 小
  • 中
  • 大

<?php  
/****************************************************   
原作者: uchinaboy    
修改:lingshidao
特点:无需mysql支持;速度快;无需设置路径,放在哪级目录下,就搜索该目录和子目录;可以搜索一切文本类型的文件;显示文件相关内容;关键词自动高亮显示。
修改内容:增加了自动分页和风格设置文件。
搜索框代码(如果放在search.php相同目录下,无需修改):<form method="post" action="search.php"><input type="text" name="key" size=40 value="">                         
<input type="submit" value="检索"></form>
****************************************************/  
require ("template.php");
echo "<p align=\"center\">";
echo "检索结果";
echo "</p><hr>";
if (function_exists("set_time_limit") && !get_cfg_var('safe_mode')){
set_time_limit(600);}
function get_msg($path) {  
global $key, $i;  
$handle = opendir($path);  
while ($filename = readdir($handle)) {  
//echo $path."/".$filename."<br>";  
$newpath = $path."/".$filename;  
if (is_file($newpath)) {  
$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 "<BR><BR><BR>".$newpath."<BR><BR><BR>";  
get_msg($path."/".$filename);  
}  
}  
closedir($handle);  
return $i;  
}  

function match_show($key, $msg, $newpath, $filename) {
  global $i;
  $key = chop($key);
  if($key) { $check_type = preg_match("/\.html?$/", $filename);
  if($check_type) {$title = getHtmlTitle($msg);}
    $msg = preg_replace("/<style>.+<\/style>/is", "", $msg);
    $msg = preg_replace("/<[^>]+>/", "", $msg);
    $value = preg_match("/.*$key.*/i", $msg, $res);
        if($value) {
     

      if($title) {$m = $title;} else {$m = $filename;}
      $i++;
      $link = $newpath;
      echo "$i.◆<a href=\"$link\">$m</a><BR><BR>";
    }
  }else {
    echo "请输入关键词";
    exit;
  }
}

function getHtmlTitle($msg) {
    
    /* Locate where <title> is located in html file. */
    $lBound = strpos($msg, '<title>') + 7; //7 is the lengh of <title>.

    if ($lBound < 1)
        return;

    /* Locate where </TITLE> is located in html file. */
    $uBound = strpos($msg, '</title>', $lBound);

    if ($uBound < $lBound)
        return;

    /* Clean HTML and PHP tags out of $title with the madness below. */
    $title = ereg_replace("[\t\n\r]", ', substr($msg, $lBound, $uBound - $lBound));
    $title = trim(strip_tags($title));

    if (strlen($title) < 1) //A blank title is worthless.
        return;

    return $title;
}

$i = get_msg(".");
echo "<hr><p align=\"center\">";
echo " 已经搜索到了 $i 条信息";
?>  

上一篇:ASP抽取数据的执行效率
下一篇:比AcdSee功能还强大的图片处理、编辑软件,推荐下载!
  • 网友评论:
  • 查看所有评论
  • 我要发表评论
您的网名:
留言主题:
你要发表的内容:

 

关于本站 | 广告联系 | 版权声明 | 网站地图 | 发布软件 | 帮助中心 | 源码论坛

Copyright © 2005-2007 CodePub.Com  程序支持:木翼  滇ICP备05005971号