//测验百度有无收录的函数
function baidu_check_recond($pageurl){
$s = '';
$url='http://www.baidu.com/s?wd='.$pageurl;
$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,'提交网址') && strpos($rs,'相关结果')){
return false; //如果存在提交网址和相关结果字眼,则表明百度未收录,返回false
} else {
return true; //否则返回true
}
}
//引入测验百度是否收录并加载代码的函数
function baidu_get_push($url){
$check = baidu_check_recond($url);
if($check==false){
echo "
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
} else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(bp, s);
})();
(function(){
var src = (document.location.protocol == 'http:') ? 'http://js.passport.qihucdn.com/11.0.1.js?af9e600e6a4ba6d33cd7f1b088210cf7':'https://jspassport.ssl.qhimg.com/11.0.1.js?af9e600e6a4ba6d33cd7f1b088210cf7';
document.write('
})();";
}
}