全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 2250|回复: 6

在介绍个这两天折腾的东西phpsou 开源的搜索

[复制链接]
发表于 2011-2-27 18:40:39 | 显示全部楼层 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2011-2-27 18:51:45 | 显示全部楼层
结果都是淘宝客
发表于 2011-2-27 18:55:33 | 显示全部楼层
  1. CREATE TABLE IF NOT EXISTS `ve123_links` (
  2.   `link_id` mediumint(9) NOT NULL auto_increment,
  3.   `title` varchar(225) NOT NULL,
  4.   `tuiguang` int(11) NOT NULL,
  5.   `site_id` mediumint(9) NOT NULL,
  6.   `url` varchar(325) NOT NULL,
  7.   `keywords` mediumtext NOT NULL,
  8.   `description` mediumtext NOT NULL,
  9.   `fulltxt` mediumtext NOT NULL,
  10.   `pagesize` float NOT NULL,
  11.   `level` int(11) NOT NULL,
  12.   `addtime` int(11) NOT NULL,
  13.   `updatetime` int(11) NOT NULL,
  14.   `lrymd5` varchar(32) NOT NULL,
  15.   PRIMARY KEY  (`link_id`)
  16. ) ENGINE=MyISAM DEFAULT CHARSET=gbk AUTO_INCREMENT=1 ;
复制代码
  1.    function q($wd,$domain='')
  2.    {
  3.       global $db;
  4.           $this->db = &$db;
  5.           $this->wd=$wd;
  6.           require "../include/splitword.func.php";
  7.           $sp = new SplitWord();
  8.       $wd_split = $sp->SplitRMM($wd);
  9.                 $sp->Clear();
  10.                         $this->wd_split=$wd_split = ereg_replace("[ ]{1,}"," ",trim($wd_split));
  11.                         $this->wd_array=$wd_array=explode(" ",$wd_split);
  12.                         $this->wd_count=$wd_count=count($wd_split);//echo $wd_count;
  13.           $tgarray=$this->GetTg();
  14.           $tgarray_count=count($tgarray);
  15.       $ordersql=" order by  links.tuiguang desc,(";
  16.           foreach($wd_array as $value)
  17.           {
  18.                 $ordersql.="(case when links.title like '%".$value."%' then 1 else 0 end)+";
  19.           }
  20.           
  21.           $ordersql.="(case when links.title like '%".$wd."%' then 8 else 0 end)";
  22.           // $ordersql=rtrim($ordersql,"+");
  23.            $ordersql.=") desc";
  24.            $keywordsql=$this->GetKeywordSql("links.title,' ',links.url");
  25.            if(empty($keywordsql))
  26.            {
  27.                $keywordsql="links.title like '%".$wd."%'";
  28.            }
  29.            if(empty($domain))
  30.            {
  31.               $sql="select links.*,sites.qp from ve123_links links left join ve123_sites sites on links.site_id=sites.site_id where links.title<>'' and ".$keywordsql.$ordersql;
  32.            }
  33.            else
  34.            {
  35.                   if($domain==getdomain($domain))
  36.                       {
  37.                           $sql="select * from ve123_links where title<>'' and url like '%.".$domain."%' or url like '%//".$domain."%'"; //echo $sql;
  38.                       }
  39.                   else
  40.                       {
  41.                            $sql="select * from ve123_links where title<>'' and url regexp 'http://".$domain."'";//echo $sql;
  42.                        }
  43.            }
  44.            //echo $sql;
  45.            $query=$db->query($sql);
  46.            $this->total=$total=$db->num_rows($query)+$tgarray_count;
  47.            $pagesize=10;
  48.            $this->totalpage=$totalpage=ceil($total/$pagesize);
  49.            $p=intval($_GET["p"]);
  50.            if($p<=0){$p=1;}
  51.            $offset=($p-1)*$pagesize;
  52.            $query=$db->query($sql." limit $offset,$pagesize");
  53.             while($row=$db->fetch_array($query))
  54.          {
  55.                       $data["title"]=$this->GetRedKeyWord(str_cut($row["title"],50));
  56.                           if(!$row["description"])$row["description"] = $row["fulltxt"];
  57.                           $data["txt"]=$this->GetRedKeyWord(str_cut($row["description"],250));
  58.                           $data["url"]=str_cut($row["url"],400);
  59.                           $data["updatetime"]=date("Y-m-d",$row["updatetime"]);
  60.                           $data["pagesize"]=$row["pagesize"];
  61.                           $data["link_id"]=$row["link_id"];
  62.                           $data["tuiguang"]=$row["tuiguang"];
  63.                           $array[] = $data;
  64.                  }
  65.                  
  66.                  $array_count=count($array);
  67.                  if(empty($array_count))
  68.                  {
  69.                      $newarray=$tgarray;
  70.                  }
  71.                  elseif($p==1&&$tgarray_count>0)
  72.                  {
  73.                      $newarray=array_merge($tgarray,$array);
  74.                  }
  75.                  else
  76.                  {
  77.                      $newarray=$array;
  78.                  }
  79.                  return $newarray;
  80.    }
复制代码
基于mysql like和联表的查询,表连myisam的fulltext索引都不加,用这东西会死人的......

[ 本帖最后由 Kokgog 于 2011-2-27 18:56 编辑 ]

评分

参与人数 1威望 +20 收起 理由
我是人 + 20 画圈圈,出真相。

查看全部评分

发表于 2011-2-27 19:01:28 | 显示全部楼层
哈哈哈哈。
发表于 2011-2-27 19:02:14 | 显示全部楼层
搜索 做不了
 楼主| 发表于 2011-2-27 19:04:17 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2011-2-27 19:08:52 | 显示全部楼层
玩玩的话可以考虑用heritrix当爬虫,用coreseek当搜索中间件,比这东西靠谱多了....
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-5-9 06:16 , Processed in 0.074440 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表