方法很简单只需两步即可完成,在核心文件module.php加入代码和在文章内页echo_log.php调用即可。

首先在module.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
<?php
// 判断内容页是否百度收录,并且以博主和或者理员身份访问博客文章时自动向百度提交未收录的文章
function baidu($url){
$url='http://www.baidu.com/s?wd='.$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 0;
}
}
function checkbaidu($id){
$url=Url::log($id);
if(baidu($url)==1){
echo "<a style=\\"color:#1EA83A;\\" rel=\\"external nofollow\\" title=\\"点击查看!\\" target=\\"\_blank\\" href=\\"http://www.baidu.com/s?wd=$url\\">\[百度已收录\]</a>";
} else {
if (ROLE == 'admin' ROLE == 'writer') {
$urls = array($url,);
$api = 'http://data.zz.baidu.com/urls?site=https://blog.aneu.cn&token=U1WtVQnKHqd6nTDf';
$ch = curl\_init();
$options = array(
CURLOPT\_URL => $api,
CURLOPT\_POST => true,
CURLOPT\_RETURNTRANSFER => true,
CURLOPT\_POSTFIELDS => implode("\\n", $urls),
CURLOPT\_HTTPHEADER => array('Content-Type: text/plain'),);
curl\_setopt\_array($ch, $options);
$result = curl\_exec($ch);
echo '';
}
echo "<a style=\\"color:red;\\" rel=\\"external nofollow\\" title=\\"点击提交收录!\\" target=\\"\_blank\\" href=\\"http://zhanzhang.baidu.com/sitesubmit/index?sitename=$url\\">\[百度未收录\]</a>";
}
}
?>
<?php
//判断内容页是否360收录
function haoso($url){
$url='https://www.so.com/s?a=index&q='.$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 0;}}

function logurlhaoso($id){$url=Url::log($id);
if(haoso($url)==1){echo "<a style=\\"color:#1EA83A;\\" rel=\\"external nofollow\\" title=\\"点击查看!\\" target=\\"\_blank\\" href=\\"https://www.so.com/s?a=index&q=$url\\">\[360已收录\]</a>";
}else{echo "<a style=\\"color:red;\\" rel=\\"external nofollow\\" title=\\"点击提交收录!\\" target=\\"\_blank\\" href=\\"http://info.so.com/site\_submit.html\\">\[360未收录\]</a>";}}
?>

<?php
//判断内容页是否搜狗收录
function sogou($url){
$url='https://www.sogou.com/sie?query='.$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 0;}}

function logurlsogou($id){$url=Url::log($id);
if(sogou($url)==1){echo "<a style=\\"color:#1EA83A;\\" rel=\\"external nofollow\\" title=\\"点击查看!\\" target=\\"\_blank\\" href=\\"https://www.sogou.com/sie?query=$url\\">\[搜狗已收录\]</a>";
}else{echo "<a style=\\"color:red;\\" rel=\\"external nofollow\\" title=\\"点击提交收录!\\" target=\\"\_blank\\" href=\\"http://fankui.help.sogou.com/index.php/web/web/index/type/1?v=1&urlword=$url\\">\[搜狗未收录\]</a>";}}
?>

其次在echo_log.php文件内调用以下代码

1
2
3
百度<?php echo checkbaidu($logid);?>
360<?php echo logurlhaoso($logid);?>
搜狗<?php echo logurlsogou($logid);?>

最后在说一点更换百度API,例如如下:

1
2
3
$api = 'http://data.zz.baidu.com/urls?site=https://blog.aneu.cn&token=U1WtVQnKHqd6nTDf';
更换
$api = '自己的百度API';