User-Profile-Image
hankin
  • 5
  • 首页
  • Dedecms
  • Notes
  • php
  • Tools
  • Music
  • 分类
    • Tools
    • php
    • Notes
    • Music
    • Dedecms
  • 页面
  • 友链
      请到[后台->主题设置->友情链接]中设置。
Help?

Please contact us on our email for need any support

Support
  • 首页
  • Dedecms
  • Notes
  • php
  • Tools
  • Music
    首页   ›   Dedecms   ›   正文
Dedecms

Dedecms后台文章列表添加百度收录显示功能

2013-12-09 21:52:00
3187  0 0

今天接到个SEO一个任务,让后台的文章列表显示百度是否收录。捣腾了一会。结果,FTP没上传php的权限,先存这里吧。下面代码加到include/extend.func.php结尾:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
  function litimgurls($imgid=0)
  {
  global $lit_imglist,$dsql;
  //获取附加表
  $row = $dsql->GetOne("SELECT c.addtable FROM #@__archives AS a LEFT JOIN #@__channeltype AS c
  ON a.channel=c.id where a.id='$imgid'");
  $addtable = trim($row['addtable']);
 
  //获取图片附加表imgurls字段内容进行处理
  $row = $dsql->GetOne("Select imgurls From `$addtable` where aid='$imgid'");
 
  //调用inc_channel_unit.php中ChannelUnit类
  $ChannelUnit = new ChannelUnit(2,$imgid);
 
  //调用ChannelUnit类中GetlitImgLinks方法处理缩略图
  $lit_imglist = $ChannelUnit->GetlitImgLinks($row['imgurls']);
 
  //返回结果
  return $lit_imglist;
  }
  function GetOneDocUrl($aid)
  {
  global $dsql;
  include_once(DEDEINC."/channelunit.func.php");
  $aid = trim(ereg_replace('[^0-9]','',$aid));
$chRow = $dsql->GetOne("Select arc.*,ch.maintable,ch.addtable,ch.issystem From `#@__arctiny` arc left join `#@__channeltype` ch on ch.id=arc.channel where arc.id='$aid' ");
if(!is_array($chRow)) {
  return $reArr;
  }
  else {
  if(empty($chRow['maintable'])) $chRow['maintable'] = '#@__archives';
  }
if($chRow['issystem']!=-1)
  {
  $nquery = " Select arc.*,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath
  From `{$chRow['maintable']}` arc left join `#@__arctype` tp on tp.id=arc.typeid
  where arc.id='$aid' ";
  }
  else
  {
  $nquery = " Select arc.*,1 as ismake,0 as money,'' as filename,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath
  From `{$chRow['addtable']}` arc left join `#@__arctype` tp on tp.id=arc.typeid
  where arc.aid='$aid' ";
  }
$arcRow = $dsql->GetOne($nquery);
$url = GetFileUrl($aid,$arcRow['typeid'],$arcRow['senddate'],$reArr['title'],$arcRow['ismake'],$arcRow['arcrank'],$arcRow['namerule'],$arcRow['typedir'],$arcRow['money'],$arcRow['filename'],$arcRow['moresite'],$arcRow['siteurl'],$arcRow['sitepath']);
  $url='http://www.baidu.com/s?wd='.$arcRow['siteurl'].$url;
  $curl=curl_init();
  curl_setopt($curl,CURLOPT_URL,$url);
  curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
  $rs=curl_exec($curl);
  curl_close($curl);
 
  $arr=parse_url($url);
 
  if(strpos($arr['query'],'http://')){
  $arr['query']=str_replace('http://','',str_replace('wd=','',$arr['query']));
  }else{
  $arr['query']=str_replace('wd=','',$arr['query']);
  }
 
  if(strpos($arr['query'],'?')){
  $str=strstr($arr['query'],'?');
  $arr['query']=str_replace($str,'',$arr['query']);
  }
 
  if(strpos($arr['query'],'/')){
  $narr=explode('/',$arr['query']);
  $arr['query']=$narr[0];
  }
 
  if(strpos($rs,'<b>'.$arr['query'].'</b>')){
  return "已收录";
  }else{
  return "<font color='#FF0000'>未收录</font>";
  }
  }

然后是后台模版代码:

1
{dede:field.id function='GetOneDocUrl(@me)'/}

加到content_list.htm相应位置,OK大功告成。

评论 (0)

点击这里取消回复。

欢迎您 游客  

Archives
  • 2019年4月
  • 2018年10月
  • 2018年5月
  • 2018年2月
  • 2016年7月
  • 2015年12月
  • 2014年9月
  • 2014年3月
  • 2014年1月
  • 2013年12月
  • 2013年11月
Categories
  • Dedecms
  • Music
  • Notes
  • php
  • Tools
标签
Dedecms Dedecms短信 Dedecms自定义表单 dedecms自定义表单必填字段 dede_fieldshash showmsg sitemap 织梦 网站地图 自定义表单短信
其他操作
  • 登录
  • 条目feed
  • 评论feed
  • WordPress.org
Copyright © 2025
smarty_hankin 主题. Designed by hankin
主页
页面
博主
Alvin 管理员
14 文章 0 评论 57399 浏览
测试
测试