Emlog, wordpress, typecho articles, whether Baidu has included detection codes

Emlog, wordpress, typecho articles, whether Baidu has included detection codes

 September
2017-04-10 / 0 Comments / 16813 Reading / Checking whether to include

Baidu, 360, Sogou, and a series of Chinese search engines all know that Baidu is the most commonly used! Use the following code to open the article to see whether Baidu has included the article.
Just check the article collection, 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 //Determine whether the content page is included by 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 collection details' target='_ Blank '>Baidu has included, details</a>"; }else{ echo "<a style=\"color:red;\ "Rel=" external nofollow  "title=" Click to submit for inclusion, thank you\ " target=\"_ blank\" href=\" http://zhanzhang.baidu.com/sitesubmit/index?sitename= $url  ">Baidu not included, 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 the functions.php file under the theme, and add the following code to the bottom?> front

 //Determine whether the content page is included by 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 is not found. You can directly access')&&! Strpos ($rs, 'Sorry, 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="_blank" title="Click to view the collection details" rel="external nofollow" rel="external nofollow" target="_blank" href=“ 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 to submit!" target="_blank" rel="external nofollow" target="_blank" href=“ https://www.9ywk.com/wp-content/themes/begin/go.php?url=aHR0cDovL3poYW56aGFuZy5iYWlkdS5jb20vc2l0ZXN1Ym1pdC9pbmRleD9zaXRlbmFtZT0nLmdldF9wZXJtYWxpbmsoKS4n ">Baidu has not included, 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.php file under the theme, and add the following code to the bottom?> front

 /*Whether the typecho article is included by Baidu*/ 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 '>Included, 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 ')) {//Not found indicates that Baidu has included it return 1; } else { return -1; } }

2. Add the mount to the position to be displayed in the appropriate position in the post. php of the article page under the theme

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

  • The code comes from the network, and the typecho effect can be seen at the bottom of this site
one

comment

The blogger has closed comments on all pages
//