Emlog, WordPress, Typecho articles, whether Baidu has included the detection code

Emlog, WordPress, Typecho articles, whether Baidu has included the detection code

 September
2017-04-10 / 0 comments / 16419 reading / Checking for inclusion

Baidu, 360, Sogou, and a series of Chinese search engines, all know that Baidu is the most commonly used! With the following code, open the article can see whether Baidu included the article.
Just detect the situation of the article included, and can not SEO, the effect can see this site!

EMLOG

1. Open the module.php file under the theme and add the following code to the corresponding location

 <? php //Judge whether the content page is included in Baidu function checkBaiduInclude($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, 'not found')){ return 1; }else{ return 0; } } function logurl($id){ $url=Url::log($id); if(checkBaiduInclude($url)==1){ echo "<a rel='external nofollow' href=' http://www.baidu.com/s?wd= $URL 'title ='click to view the included details' target' = '_ Blank '> Baidu has included, details < / a > "; }else{ echo "<a style=\"color:red;\ "Rel =" external nofollow "title =" click to submit, thank you\ " target=\"_ blank\" href=\" http://zhanzhang.baidu.com/sitesubmit/index?sitename= $URL \ "> not included in Baidu, submit < / a >"; } } ?>

2. Open the echo under the theme_ Log.php file, add the mount point to the location to be displayed

 <? php echo logurl($logid); ?>

WordPress

1. Open functions under the topic PHP file, add the following code to the bottom? > file front

 //Judge whether the content page is included in Baidu function baidu_ check($url, $post_id){ $baidu_ record = get_ post_ meta($post_id,'baidu_record',true); if( $baidu_record != 1){ $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, 'the URL was not found. You can directly visit') &! Strpos ($RS, 'sorry, no and')){ update_ post_ meta($post_id, 'baidu_record', 1) || add_ post_ meta($post_id, 'baidu_record', 1, true); return 1; } else { return 0; } } else { return 1; } } function baidu_ record() { global $wpdb; $post_ id = ( null === $post_id ) ?  get_ the_ ID() : $post_ id; if(baidu_check(get_permalink($post_id), $post_ id ) == 1) { Echo '< a target "﹤ u blank" title = "click to view the included details" rel = "external nofollow" rel = "external nofollow" target = ﹤ u blank "HTML=“ https://www.9ywk.com/wp-content/themes/begin/go.php?url=aHR0cDovL3d3dy5iYWlkdS5jb20vcz93ZD0nLmdldF90aGVfdGl0bGUoKS4n "> Baidu has included, details < / a > '; } else { echo '<a style="color:red;"  Rel = "external nofollow" title: "click submit to include!" target="_blank" rel="external nofollow" target="_blank" href=" https://www.9ywk.com/wp-content/themes/begin/go.php?url=aHR0cDovL3poYW56aGFuZy5iYWlkdS5jb20vc2l0ZXN1Ym1pdC9pbmRleD9zaXRlbmFtZT0nLmdldF9wZXJtYWxpbmsoKS4n "> not included in Baidu, submit < / a > '; } }

2. Open the single.php file under the theme and add the mount point to the location to be displayed

 <? php baidu_ record(); ?>

Typecho

1. Open the functions under the topic PHP file, add the following code to the bottom? > file front

 /*Does Baidu include Typecho articles*/ function baidu_ record() { $url='http://'.$_ SERVER['HTTP_HOST'].$_ SERVER['REQUEST_URI']; if(checkBaidu($url)==1) {echo "<a rel='external nofollow' href=' http://www.baidu.com/s?wd= $url' target='_ Blank >, details < / a > "; } else {echo "<a target=\"_blank\"  href=\" http://zhanzhang.baidu.com/sitesubmit/index?sitename= $URL \ "> not included, click Submit < / 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, 'not found')) {/ / if not found, the description has been included by Baidu return 1; } else { return -1; } }

2. In the appropriate position of the article page post.php under the topic, add the mount to the position to be displayed

 <span>Baidu collection: <? php echo baidu_ record() ?></ span>

  • Code from the network, typeecho effect can see the bottom of this site article
one

comment

Bloggers have closed comments on all pages
//