<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>狂人山庄 &#124; Silence,声仔,吴洪声,奶罩 &#187; spider</title>
	<atom:link href="http://wuhongsheng.com/tag/spider/feed/" rel="self" type="application/rss+xml" />
	<link>http://wuhongsheng.com</link>
	<description>响应我党号召,全面建设和谐博客,坚持和谐写博的路线不动摇</description>
	<lastBuildDate>Mon, 14 Jun 2010 06:54:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>如何识别真实的搜索引擎蜘蛛</title>
		<link>http://wuhongsheng.com/it/2007/12/php-search-engine-bot-authentication/</link>
		<comments>http://wuhongsheng.com/it/2007/12/php-search-engine-bot-authentication/#comments</comments>
		<pubDate>Fri, 21 Dec 2007 06:47:19 +0000</pubDate>
		<dc:creator>吴洪声</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[spider]]></category>

		<guid isPermaLink="false">http://wuhongsheng.com/it/2007/12/php-search-engine-bot-authentication/</guid>
		<description><![CDATA[&#60;?php $ua = $_SERVER&#91;'HTTP_USER_AGENT'&#93;; if &#40;stristr&#40;$ua, 'msnbot'&#41; &#124;&#124; stristr&#40;$ua, 'googlebot'&#41;&#41; &#123; //it's pretending to be MSN's bot or Google's bot $ip = $_SERVER&#91;'REMOTE_ADDR'&#93;; $hostname = gethostbyaddr&#40;$ip&#41;; if&#40;!preg_match&#40;&#34;/\.googlebot\.com$/&#34;, $hostname&#41; &#38;&#38; !preg_match&#40;&#34;/search\.live\.com$/&#34;, $hostname&#41;&#41;&#123; //the hostname does not belong to either live.com or googlebot.com. //Remember the UA already said it is either MSNBot or Googlebot. //So it's a [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$ua</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">stristr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ua</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'msnbot'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">stristr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ua</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'googlebot'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//it's pretending to be MSN's bot or Google's bot</span>
	<span style="color: #000088;">$ip</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$hostname</span> <span style="color: #339933;">=</span> <span style="color: #990000;">gethostbyaddr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/\.googlebot\.com$/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$hostname</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/search\.live\.com$/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$hostname</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//the hostname does not belong to either live.com or googlebot.com.</span>
		<span style="color: #666666; font-style: italic;">//Remember the UA already said it is either MSNBot or Googlebot.</span>
		<span style="color: #666666; font-style: italic;">//So it's a spammer.</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Please leave&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//Now we have a hit that half-passes the check. One last go:</span>
		<span style="color: #000088;">$real_ip</span> <span style="color: #339933;">=</span> <span style="color: #990000;">gethostbyname</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$hostname</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$real_ip</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//spammer!</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Please leave&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//real bot</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Welcome!&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>



<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://wuhongsheng.com/it/2007/12/php-search-engine-bot-authentication/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.361 seconds -->
