给自己Typecho的文章添加是否被百度收录1.0

1、在目录 /usr/themes/handsome/functions.php 文件 尾部增加

function baidu_record() {
$url='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

if(checkBaidu($url)==1)
{echo "百度已收录";
}
else
{echo "<a style=\"color:red;\" rel=\"external nofollow\" title=\"点击提交收录!\" target=\"_blank\" href=\"http://zhanzhang.b
aidu.com/sitesubmit/index?sitename=$url\">百度未收录</a>";}
}

   function checkBaidu($url) {
    $url = 'http://www.baidu.com/s?wd=' . urlencode($url);
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $rs = curl_exec($curl);
    curl_close($curl);
    if (!strpos($rs, '没有找到')) { //没有找到说明已被百度收录 
        return 1;
    } else {
        return -1;
    }
}

2、在post.php添加

<!--百度收录-->
<li class="meta-categories"><i class="pull-right text-muted" aria-hidden="true"></i> <span class="baidu-record"><?php echo baidu_record() ?></span></li>

3、效果看文章开头

© 版权声明
THE END
喜欢就支持一下吧
点赞10 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    请登录后查看评论内容