<?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>Life Studio &#187; 电脑网络</title>
	<atom:link href="http://wange.im/category/computer/feed" rel="self" type="application/rss+xml" />
	<link>http://wange.im</link>
	<description>My Life, My Studio...</description>
	<lastBuildDate>Sat, 31 Jul 2010 13:01:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>美化 Feedburner 邮箱订阅</title>
		<link>http://wange.im/landscaping-feedburner-email-subscriptions.html</link>
		<comments>http://wange.im/landscaping-feedburner-email-subscriptions.html#comments</comments>
		<pubDate>Sat, 31 Jul 2010 13:01:20 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[FeedBurner]]></category>
		<category><![CDATA[博客]]></category>

		<guid isPermaLink="false">http://wange.im/?p=3605</guid>
		<description><![CDATA[　　感谢Boss方小盆友，就在我文囧不知道今天更新啥的时候，Boss方解救了我，因为他问了我一个问题：“老万，你文章页侧边栏最下面那个输入邮箱订阅是咋整的？求教程。。”其实这个很简单，一句话就可以搞定的，既然我文囧，好吧，我就发挥一下我吹水的实力，把这一句话可以解决的答案拉扯出洋洋洒洒一整篇。
　　还没有玩过我右下角这个邮箱订阅的新老朋友们，可以先试试，放心吧，不是一键订阅的，输入邮箱后还需要一个确认的过程，所以你可以输入并点击确定试试，就算你不小心订阅了本站，也可以通过邮件取消订阅（一般上了我的贼船，想下船的比较难，HIAHIA～）玩过的朋友应该都发现了吧，这是 Feedburner，我们都知道 Feedbuner 已经不幸遇难，不过它的邮箱订阅功能居然奇迹般地存活了下来，简单说来，这个邮箱订阅就是借用了 Feedburner 的功能并且加以美化。具体地、罗嗦地、详细地方法如下：
　　1、跨墙登陆 Feedburner，怎么跨墙请 Google 之。有童鞋抱怨 Feedburner 没有中文版，这也没啥好抱怨的，人家一头撞在墙上，连吭都不吭一声，已经很伟大了。而且嘛，Feedburner 也不是没有中文版，只是汉化得比较烂，Feedburner 都不好意思公开。对英文不太友爱，又不嫌弃 Feedburner 这汉化水准的童鞋，可以尝试这个链接。
　　2、获取邮箱订阅代码。在 Feedburner 的设置中，选择 Publicize — Email Subscriptions — Subscription Management，选择 Feedburner 中文版的用户请对照执行。这时候会得到类似如下的代码：
&#60;form style="border:1px solid #ccc;padding:3px;text-align:center;" action="http://feedburner.google.com/fb/a/mailverify" method="post" target="popupwindow" onsubmit="window.open('http://feedburner.google.com/fb/a/mailverify?uri=wange', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true"&#62;
    &#60;p&#62;Enter your email address:&#60;/p&#62;
    &#60;p&#62;&#60;input type="text" style="width:140px" name="email"/&#62;&#60;/p&#62;
    &#60;input type="hidden" value="wange" name="uri"/&#62;
    &#60;input type="hidden" name="loc" value="en_US"/&#62;
    &#60;input type="submit" value="Subscribe" [...]]]></description>
			<content:encoded><![CDATA[<p>　　感谢<a title="Boss方的博客" rel="external nofollow" href="http://bossfang.com/" target="_blank">Boss方</a>小盆友，就在我文囧不知道今天更新啥的时候，Boss方解救了我，因为他问了我一个问题：“老万，你文章页侧边栏最下面那个输入邮箱订阅是咋整的？求教程。。”其实这个很简单，一句话就可以搞定的，既然我文囧，好吧，我就发挥一下我吹水的实力，把这一句话可以解决的答案拉扯出洋洋洒洒一整篇。</p>
<p>　　还没有玩过我右下角这个邮箱订阅的新老朋友们，可以先试试，放心吧，不是一键订阅的，输入邮箱后还需要一个确认的过程，所以你可以输入并点击确定试试，就算你不小心订阅了本站，也可以通过邮件取消订阅（一般上了我的贼船，想下船的比较难，HIAHIA～）玩过的朋友应该都发现了吧，这是 Feedburner，我们都知道 Feedbuner 已经不幸遇难，不过它的邮箱订阅功能居然奇迹般地存活了下来，简单说来，这个邮箱订阅就是借用了 Feedburner 的功能并且加以美化。具体地、罗嗦地、详细地方法如下：</p>
<p>　　1、跨墙登陆 Feedburner，怎么跨墙请 Google 之。有童鞋抱怨 Feedburner 没有中文版，这也没啥好抱怨的，人家一头撞在墙上，连吭都不吭一声，已经很伟大了。而且嘛，Feedburner 也不是没有中文版，只是汉化得比较烂，Feedburner 都不好意思公开。对英文不太友爱，又不嫌弃 Feedburner 这汉化水准的童鞋，可以尝试<a title="Feedburner 中文版" rel="external nofollow" href="http://u.wange.im/43" target="_blank">这个链接</a>。</p>
<p>　　2、获取邮箱订阅代码。在 Feedburner 的设置中，选择 Publicize — Email Subscriptions — Subscription Management，选择 Feedburner 中文版的用户请对照执行。这时候会得到类似如下的代码：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;form</span> <span style="color: #ff0000;">style=</span><span style="color: #0000ff;">"border:1px solid #ccc;padding:3px;text-align:center;"</span> <span style="color: #ff0000;">action=</span><span style="color: #0000ff;">"http://feedburner.google.com/fb/a/mailverify"</span> <span style="color: #ff0000;">method=</span><span style="color: #0000ff;">"post"</span> <span style="color: #ff0000;">target=</span><span style="color: #0000ff;">"popupwindow"</span> <span style="color: #ff0000;">onsubmit=</span><span style="color: #0000ff;">"window.open('http://feedburner.google.com/fb/a/mailverify?uri=wange', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true"</span><span style="color: #000080; font-weight: bold;">&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;p&gt;</span><span style="color: #000000;">Enter your email address:</span><span style="color: #000080; font-weight: bold;">&lt;/p&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;p&gt;&lt;input</span> <span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"text"</span> <span style="color: #ff0000;">style=</span><span style="color: #0000ff;">"width:140px"</span> <span style="color: #ff0000;">name=</span><span style="color: #0000ff;">"email"</span><span style="color: #000080; font-weight: bold;">/&gt;&lt;/p&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;input</span> <span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"hidden"</span> <span style="color: #ff0000;">value=</span><span style="color: #0000ff;">"wange"</span> <span style="color: #ff0000;">name=</span><span style="color: #0000ff;">"uri"</span><span style="color: #000080; font-weight: bold;">/&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;input</span> <span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"hidden"</span> <span style="color: #ff0000;">name=</span><span style="color: #0000ff;">"loc"</span> <span style="color: #ff0000;">value=</span><span style="color: #0000ff;">"en_US"</span><span style="color: #000080; font-weight: bold;">/&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;input</span> <span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"submit"</span> <span style="color: #ff0000;">value=</span><span style="color: #0000ff;">"Subscribe"</span> <span style="color: #000080; font-weight: bold;">/&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;p&gt;</span><span style="color: #000000;">Delivered by </span><span style="color: #000080; font-weight: bold;">&lt;a</span> <span style="color: #ff0000;">href=</span><span style="color: #0000ff;">"http://feedburner.google.com"</span> <span style="color: #ff0000;">target=</span><span style="color: #0000ff;">"_blank"</span><span style="color: #000080; font-weight: bold;">&gt;</span><span style="color: #000000;">FeedBurner</span><span style="color: #000080; font-weight: bold;">&lt;/a&gt;&lt;/p&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;/form&gt;</span></div>
<p>　　但是懂一些 HTML 知识的同学应该不难看出，其中关键的有用的部分就只有 form 标签里的那一行，把它提取出来，其余全部扔掉。</p>
<p>　　3、美化邮箱订阅代码。美化的方法当然各有不同，我就根据自己的主题，修改觉得比较合适的样式，仅供参考：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;form</span> <span style="color: #ff0000;">style=</span><span style="color: #0000ff;">"height:40px;position:relative;padding:3px;"</span> <span style="color: #ff0000;">action=</span><span style="color: #0000ff;">"http://feedburner.google.com/fb/a/mailverify"</span> <span style="color: #ff0000;">method=</span><span style="color: #0000ff;">"post"</span> <span style="color: #ff0000;">target=</span><span style="color: #0000ff;">"popupwindow"</span> <span style="color: #ff0000;">onsubmit=</span><span style="color: #0000ff;">"window.open('http://feedburner.google.com/fb/a/mailverify?uri=wange', 'popupwindow', 'scrollbars=yes,width=350,height=520');return true"</span><span style="color: #000080; font-weight: bold;">&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;input</span> <span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"text"</span> <span style="color: #ff0000;">style=</span><span style="color: #0000ff;">"width:220px;height:25px;position:absolute;left:20px;line-height:25px;font-family:'Courier New','Lucida Console','monospace';padding:5px;border:1px solid #ccc;"</span> <span style="color: #ff0000;">name=</span><span style="color: #0000ff;">"email"</span> <span style="color: #ff0000;">value=</span><span style="color: #0000ff;">"请输入您的邮箱"</span> <span style="color: #ff0000;">onfocus=</span><span style="color: #0000ff;">"if (this.value == '请输入您的邮箱') {this.value = '';}"</span> <span style="color: #ff0000;">onblur=</span><span style="color: #0000ff;">"if (this.value == '') {this.value = '请输入您的邮箱';}"</span><span style="color: #000080; font-weight: bold;">/&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;input</span> <span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"hidden"</span> <span style="color: #ff0000;">value=</span><span style="color: #0000ff;">"wange"</span> <span style="color: #ff0000;">name=</span><span style="color: #0000ff;">"uri"</span><span style="color: #000080; font-weight: bold;">/&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;input</span> <span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"hidden"</span> <span style="color: #ff0000;">name=</span><span style="color: #0000ff;">"loc"</span> <span style="color: #ff0000;">value=</span><span style="color: #0000ff;">"en_US"</span><span style="color: #000080; font-weight: bold;">/&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;input</span> <span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"submit"</span> <span style="color: #ff0000;">style=</span><span style="color: #0000ff;">"width:60px;height:35px;position:absolute;right:20px;"</span> <span style="color: #ff0000;">value=</span><span style="color: #0000ff;">"确认订阅"</span> <span style="color: #000080; font-weight: bold;">/&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;/form&gt;</span></div>
<p><img style="float:left;" src="http://vpdpfq.bay.livefilestore.com/y1p3KoT7vP_Mz1dtXsotYotcR2CC3gqjjGxBNtOcIlOVlpFkVjsTjr5AqCKafMLyCRkdKJ1yeVT7hybxR_iJmuUU6MuuTRe2k6m/subscribe.jpg" alt="" />　　比较懒，样式都内联了，童鞋们不要学我。不过这有一点方便，就是这么一坨代码扔哪里都可以，就算删掉，也不用担心有残留在样式表里的 CSS，我就把这串代码放在 Wordpress 的小工具里，当然放在 sidebar.php 也是可以的。最后上一张效果图，顺便打个小广告：小站订阅方式多多，不仅可以通过这个邮箱订阅，还可以通过 <a title="Feedsky" href="http://feed.wange.im" target="_blank">http://feed.wange.im</a> 这个网址订阅我哟～还等什么，快上贼船吧！</p>
<div style='background:#EFEFEF;border:1px dashed #CCC;color:#777;margin:5px 0;padding:5px 10px;-moz-border-radius:10px 0;-webkit-border-top-left-radius:10px;-webkit-border-top-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:10px;border-radius:10px 0;'><div>&raquo; 转载请注明来源：<a title="Life Studio" href="http://wange.im/">Life Studio</a> &raquo; <a rel="bookmark" title="美化 Feedburner 邮箱订阅" href="http://wange.im/landscaping-feedburner-email-subscriptions.html">《美化 Feedburner 邮箱订阅》</a></div><div>&raquo; 本文链接地址：<a rel="bookmark" title="美化 Feedburner 邮箱订阅" href="http://wange.im/landscaping-feedburner-email-subscriptions.html">http://wange.im/landscaping-feedburner-email-subscriptions.html</a></div><div>&raquo; 订阅本站：<a title="Life Studio" target="_blank" href="http://feed.wange.im">http://feed.wange.im</a></div></div><h3>相关日志</h3><ul class="st-related-posts"><li><a href="http://wange.im/final-statement-on-changing-domain.html" title="关于更改域名的最后通牒 (2010年07月19日)">关于更改域名的最后通牒</a> (187)</li><li><a href="http://wange.im/you-subscribe-to-my-blog.html" title="你订阅了我的博客吗？ (2010年06月15日)">你订阅了我的博客吗？</a> (226)</li><li><a href="http://wange.im/burn-twitter-feed-with-feedburner.html" title="用 FeedBurner 烧制 Twitter feed (2010年03月19日)">用 FeedBurner 烧制 Twitter feed</a> (86)</li><li><a href="http://wange.im/output-latest-tsina-to-wordpress-without-plugin.html" title="Wordpress 非插件调用最新新浪围脖 (2010年02月16日)">Wordpress 非插件调用最新新浪围脖</a> (71)</li><li><a href="http://wange.im/r-u-reading-this-in-goole-reader.html" title="您是在 google reader 看到本文的吗？ (2010年02月7日)">您是在 google reader 看到本文的吗？</a> (171)</li><li><a href="http://wange.im/embed-bbs-in-blog.html" title="如果在博客嵌入个人论坛 (2010年07月29日)">如果在博客嵌入个人论坛</a> (187)</li><li><a href="http://wange.im/wange-is-only-one.html" title="万戈只有一个！ (2010年07月21日)">万戈只有一个！</a> (270)</li><li><a href="http://wange.im/link-transaction.html" title="链接买吧买吧不是罪 (2010年07月14日)">链接买吧买吧不是罪</a> (290)</li><li><a href="http://wange.im/date-with-immmmm.html" title="终于有幸一睹木木本尊 (2010年07月7日)">终于有幸一睹木木本尊</a> (272)</li><li><a href="http://wange.im/google-docs-in-blog.html" title="在博客上嵌入 Google 文档 (2010年07月6日)">在博客上嵌入 Google 文档</a> (196)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://wange.im/landscaping-feedburner-email-subscriptions.html/feed</wfw:commentRss>
		<slash:comments>76</slash:comments>
		</item>
		<item>
		<title>Wordpress 向来自其他域的访客致欢迎词</title>
		<link>http://wange.im/wordpress-say-hello-to-vistors.html</link>
		<comments>http://wange.im/wordpress-say-hello-to-vistors.html#comments</comments>
		<pubDate>Fri, 30 Jul 2010 12:11:08 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[搜索]]></category>

		<guid isPermaLink="false">http://wange.im/?p=3587</guid>
		<description><![CDATA[　　在 Wordpress 上对来自其他域的访客显示欢迎词，这个效果我之前写过一篇类似的，《Wordpress 高亮显示关键词及欢迎提示》，之前这一篇是对特定访客显示欢迎词，也就是只对来自搜索引擎的访客显示欢迎提示词，而且对常用的搜索引擎还需要我手工添加进数组，并不是很全面，对百度、Google、有道、必应这些之外的搜索引擎就无效了。而今天介绍的这个方法就很全面，不仅可以涵盖所有的搜索引擎，就连其他任何不加密的网站也都适用！
　　不信？可以先做个测试。如果我有在贵站留过言，或者你很给面子地给我做了一个友链的小盆友们，你们可以通过自己网站上任何一个可以通向本站的链接访问本站。进来之后，你看到了啥？右侧的那个浮动层瞧见没？就是这个了。再比如说通过我的 Twitter(@wange1228)的主页，上面有我博客的链接，点击进入我的网站后，如下图：










　　现在应该明白我讲的是啥效果了吧，在道明方法之前，首先要感谢 illacrimo-plus 主题的作者，虽然我也不知道是谁。本文的方法就是从这个主题上扒下来的，方法如下：
1、把以下代码复制到 Wordpress 主题的 functions.php 中：
function show_refer_in(){
     $refer_info=$_SERVER['HTTP_REFERER'];
     $ban_list=array($_SERVER["HTTP_HOST"]);
     for($ii=0;$ii&#60;count($ban_list);$ii++){
        if(strpos($refer_info,$ban_list[$ii])){
            return;
        }
 [...]]]></description>
			<content:encoded><![CDATA[<p>　　在 Wordpress 上对来自其他域的访客显示欢迎词，这个效果我之前写过一篇类似的，《<a title="http://wange.im/highlight-keywords-and-hellobaby-in-wordpress.html" href="Wordpress 高亮显示关键词及欢迎提示">Wordpress 高亮显示关键词及欢迎提示</a>》，之前这一篇是对特定访客显示欢迎词，也就是只对来自搜索引擎的访客显示欢迎提示词，而且对常用的搜索引擎还需要我手工添加进数组，并不是很全面，对百度、Google、有道、必应这些之外的搜索引擎就无效了。而今天介绍的这个方法就很全面，不仅可以涵盖所有的搜索引擎，就连其他任何不加密的网站也都适用！</p>
<p>　　不信？可以先做个测试。如果我有在贵站留过言，或者你很给面子地给我做了一个友链的小盆友们，你们可以通过自己网站上任何一个可以通向本站的链接访问本站。进来之后，你看到了啥？右侧的那个浮动层瞧见没？就是这个了。再比如说通过我的 Twitter(<a title="Follow Me on Twitter" href="http://twitter.com/wange1228" target="_blank">@wange1228</a>)的主页，上面有我博客的链接，点击进入我的网站后，如下图：</p>
<table border="0" align="center">
<tbody>
<tr>
<td>
<p><div class="wp-caption alignnone" style="width: 210px"><img title="Twitter上的博客链接" src="http://vpdpfq.bay.livefilestore.com/y1pSbfAPu1N_x8WgNde06NGQWVuewSf2rgvzKMPDLiEbfTNv01zwbX6tB33IMFv7l7SF93IXJkPVwhQacAZZ-1ioxZjFP62kZ2W/twitter.jpg" alt="" width="200" height="150" /><p class="wp-caption-text">Twitter上的博客链接</p></div></td>
<td>
<p><div class="wp-caption alignnone" style="width: 310px"><img title="从twitter来的欢迎词" src="http://vpdpfq.bay.livefilestore.com/y1pgyStthY_WwVkrwZ4hA_3pC0MGUX3jQwHLj0es5CwRfWoEqm1vwYIW-XgrheLRjQpQIOAIa1H51fnRNZCVKrl_vj0h-UMm8dG/fromtwitter.jpg" alt="" width="300" height="150" /><p class="wp-caption-text">从twitter来的欢迎词</p></div></td>
</tr>
</tbody>
</table>
<p>　　现在应该明白我讲的是啥效果了吧，在道明方法之前，首先要感谢 illacrimo-plus 主题的作者，虽然我也不知道是谁。本文的方法就是从这个主题上扒下来的，方法如下：</p>
<p>1、把以下代码复制到 Wordpress 主题的 functions.php 中：</p>
<div class="source" style="font-family: 'Courier New','Lucida Console','monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">function</span> <span style="color: #000000;">show_refer_in</span><span style="color: #000000;">(){</span><br />
     <span style="color: #000000;">$refer_info</span><span style="color: #000000;">=</span><span style="color: #000000;">$_SERVER</span><span style="color: #000000;">[</span><span style="color: #0000ff;">'HTTP_REFERER'</span><span style="color: #000000;">];</span><br />
     <span style="color: #000000;">$ban_list</span><span style="color: #000000;">=</span><span style="color: #000000;">array</span>(<span style="color: #000000;">$_SERVER</span><span style="color: #000000;">[</span><span style="color: #0000ff;">"HTTP_HOST"</span><span style="color: #000000;">]);</span><br />
     <span style="color: #000080; font-weight: bold;">for</span>(<span style="color: #000000;">$ii</span><span style="color: #000000;">=</span><span style="color: #0000ff;">0</span>;<span style="color: #000000;">$ii</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">count</span>(<span style="color: #000000;">$ban_list</span>);<span style="color: #000000;">$ii</span><span style="color: #000000;">++</span><span style="color: #000000;">){</span><br />
        <span style="color: #000080; font-weight: bold;">if</span>(<span style="color: #000000;">strpos</span>(<span style="color: #000000;">$refer_info</span><span style="color: #000000;">,</span><span style="color: #000000;">$ban_list</span><span style="color: #000000;">[</span><span style="color: #000000;">$ii</span><span style="color: #000000;">])){</span><br />
            <span style="color: #000080; font-weight: bold;">return</span>;<br />
        <span style="color: #000000;">}</span><br />
    <span style="color: #000000;">}</span><br />
    <span style="color: #000080; font-weight: bold;">if</span>(<span style="color: #000000;">$refer_info</span><span style="color: #000000;">){</span><br />
        <span style="color: #000000;">preg_match</span>(<span style="color: #0000ff;">"/^(http:\/\/)?([^\/]+)/i"</span><span style="color: #000000;">,</span><br />
        <span style="color: #000000;">$refer_info</span><span style="color: #000000;">,</span> <span style="color: #000000;">$matches</span>);<br />
        <span style="color: #000000;">$host</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$matches</span><span style="color: #000000;">[</span><span style="color: #0000ff;">2</span><span style="color: #000000;">];</span><br />
        <span style="color: #000000;">echo</span> <span style="color: #0000ff;">"&lt;div id=\"hellobaby\"&gt;欢迎来自 "</span><span style="color: #000000;">.</span><span style="color: #000000;">$host</span><span style="color: #000000;">.</span><span style="color: #0000ff;">" 的朋友！&lt;br /&gt;推荐您 &lt;b&gt;&lt;a href=\"http://feed.wange.im\" target=\"_blank\"&gt;点击这里&lt;/a&gt;&lt;/b&gt; 订阅我的博客 o(∩_∩)o&lt;div class=\"closebox\"&gt;&lt;a href=\"javascript:void(0)\" onclick=\"$('#hellobaby').slideUp('slow');$('.closebox').css('display','none');\" title=\"关闭\"&gt;×&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;"</span>;<br />
    <span style="color: #000000;">}</span><br />
<span style="color: #000000;">}</span></div>
<p>2、在主题文件的任何部位调用以下函数，我建议是放在 footer.php 中：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #008080;">&lt;?php</span> <span style="color: #000000;">show_refer_in</span>();<span style="color: #008080;">?&gt;</span></div>
<p>3、接下来样式部分仅供参考：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000000;">#hellobaby</span> <span style="color: #000000;">{</span><br />
    <span style="color: #000080; font-weight: bold;">background</span><span style="color: #000000;">:</span><span style="color: #0000ff;">#000000</span>;<br />
    <span style="color: #000080; font-weight: bold;">border</span><span style="color: #000000;">:</span><span style="color: #0000ff;">1px</span> <span style="color: #000080; font-weight: bold;">solid</span> <span style="color: #0000ff;">#B3B3B3</span>;<br />
    <span style="color: #000080; font-weight: bold;">color</span><span style="color: #000000;">:</span><span style="color: #0000ff;">#FFFFFF</span>;<br />
    <span style="color: #000080; font-weight: bold;">font-size</span><span style="color: #000000;">:</span><span style="color: #0000ff;">14px</span>;<br />
    <span style="color: #000080; font-weight: bold;">opacity</span><span style="color: #000000;">:</span><span style="color: #0000ff;">0</span><span style="color: #000000;">.</span><span style="color: #0000ff;">7</span>;<br />
    <span style="color: #000000;">filter</span><span style="color: #000000;">:</span><span style="color: #000000;">alpha</span>(<span style="color: #000080; font-weight: bold;">opacity</span><span style="color: #000000;">=</span><span style="color: #0000ff;">70</span>);<br />
    <span style="color: #000080; font-weight: bold;">padding</span><span style="color: #000000;">:</span><span style="color: #0000ff;">10px</span>;<br />
    <span style="color: #000080; font-weight: bold;">position</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">absolute</span>;<br />
    <span style="color: #000080; font-weight: bold;">right</span><span style="color: #000000;">:</span><span style="color: #0000ff;">0</span>;<br />
    <span style="color: #000080; font-weight: bold;">top</span><span style="color: #000000;">:</span><span style="color: #0000ff;">250px</span>;<br />
<span style="color: #000000;">}</span></div>
<p>　　基本完成了，本文提到的文法和 <a title="http://wange.im/highlight-keywords-and-hellobaby-in-wordpress.html" href="Wordpress 高亮显示关键词及欢迎提示">Wordpress 高亮显示关键词及欢迎提示</a>中的提示词部分有点重复，不过高亮显示关键词还是很有用的，所以两者我都用上了，感觉还不错，你说呢？</p>
<p>　　Update：经热烈讨论，同学们普遍反映，如果每次跳转过来都会有这个欢迎词，就会显得有些烦人，有些碍眼。感谢小邪，提供了记住 Cookies 的方法，8过很遗憾，居然在我这里测试会报错。所以我用了另一种折衷的办法，加了个判断，对所有留过言的朋友不显示该欢迎词，其实也是借用了 Cookies 的概念，现在要看这个效果的小盆友们，就要先清除浏览器缓存才行咯。感谢，也欢迎大家提出更多宝贵意见～</p>
<div style='background:#EFEFEF;border:1px dashed #CCC;color:#777;margin:5px 0;padding:5px 10px;-moz-border-radius:10px 0;-webkit-border-top-left-radius:10px;-webkit-border-top-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:10px;border-radius:10px 0;'><div>&raquo; 转载请注明来源：<a title="Life Studio" href="http://wange.im/">Life Studio</a> &raquo; <a rel="bookmark" title="Wordpress 向来自其他域的访客致欢迎词" href="http://wange.im/wordpress-say-hello-to-vistors.html">《Wordpress 向来自其他域的访客致欢迎词》</a></div><div>&raquo; 本文链接地址：<a rel="bookmark" title="Wordpress 向来自其他域的访客致欢迎词" href="http://wange.im/wordpress-say-hello-to-vistors.html">http://wange.im/wordpress-say-hello-to-vistors.html</a></div><div>&raquo; 订阅本站：<a title="Life Studio" target="_blank" href="http://feed.wange.im">http://feed.wange.im</a></div></div><h3>相关日志</h3><ul class="st-related-posts"><li><a href="http://wange.im/highlight-keywords-in-wordpress-search.html" title="Wordpress 站内搜索高亮显示关键词 (2010年07月18日)">Wordpress 站内搜索高亮显示关键词</a> (119)</li><li><a href="http://wange.im/highlight-keywords-and-hellobaby-in-wordpress.html" title="Wordpress 高亮显示关键词及欢迎提示 (2010年07月16日)">Wordpress 高亮显示关键词及欢迎提示</a> (180)</li><li><a href="http://wange.im/embed-bbs-in-blog.html" title="如果在博客嵌入个人论坛 (2010年07月29日)">如果在博客嵌入个人论坛</a> (187)</li><li><a href="http://wange.im/dwthemes-with-dustmedia.html" title="与尘埃老哥共建 DWthemes 工作室 (2010年07月28日)">与尘埃老哥共建 DWthemes 工作室</a> (186)</li><li><a href="http://wange.im/comment-count-in-wordpress-with-jquery.html" title="Jquery 实现 Wordpress 评论字数计数 (2010年07月27日)">Jquery 实现 Wordpress 评论字数计数</a> (145)</li><li><a href="http://wange.im/wordpress-shows-the-number-of-recent-comments.html" title="WordPress 显示访客最近评论次数 (2010年07月20日)">WordPress 显示访客最近评论次数</a> (198)</li><li><a href="http://wange.im/show-your-recent-comments-in-wordpress.html" title="Wordpress 实现“您的足迹”功能 (2010年07月12日)">Wordpress 实现“您的足迹”功能</a> (262)</li><li><a href="http://wange.im/world-clock-with-php.html" title="PHP 实现的静态世界时钟功能 (2010年07月9日)">PHP 实现的静态世界时钟功能</a> (142)</li><li><a href="http://wange.im/remove-comments-url-in-wordpress.html" title="Wordpress 去掉评论中链接的方法 (2010年07月8日)">Wordpress 去掉评论中链接的方法</a> (172)</li><li><a href="http://wange.im/date-with-immmmm.html" title="终于有幸一睹木木本尊 (2010年07月7日)">终于有幸一睹木木本尊</a> (272)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://wange.im/wordpress-say-hello-to-vistors.html/feed</wfw:commentRss>
		<slash:comments>175</slash:comments>
		</item>
		<item>
		<title>Jquery 实现 Wordpress 评论字数计数</title>
		<link>http://wange.im/comment-count-in-wordpress-with-jquery.html</link>
		<comments>http://wange.im/comment-count-in-wordpress-with-jquery.html#comments</comments>
		<pubDate>Tue, 27 Jul 2010 14:02:49 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[留言]]></category>

		<guid isPermaLink="false">http://wange.im/?p=3567</guid>
		<description><![CDATA[　　不好意思各位访客朋友们，因为去了合肥几天，博客也就搁置了，回来也没有一一回复童鞋们的留言，赶紧埋头把手头上的工作解决掉，晚上又挤了一点时间折腾 Wordpress，拳不离手，曲不离口，一天不折腾 Wordpress，手就痒痒，三天没碰代码，都感觉有点生疏了，差点找不到折腾的目标。
　　今天折腾的 Wordpress 目标是实现留言字数的实时计数功能。因为看到之前 qiqiboy 写过一篇文章介绍了，不过 qiqiboy 是自己写的 Javascript 脚本，虽然很简单，不过我还是嫌代码多，就一直没加上，今天折腾了一种 Jquery 实现的 Wordpress 对评论字数进行实时统计计数的功能。因为比较仓促，就只在留言板页面加上了这个效果，有兴趣的朋友可以先去留言板看看效果。样式也没有怎么修整过，比较粗糙，多多包涵啦～
　　接下来说方法：
1、加载 Jquery
　　这个是必须的，可以用  Google 托管的，也可以下载到本地服务器调用，Jquery 1.2X 的版本就够用了。
2、Jquery 的执行脚本
&#60;script type="text/javascript" &#62;
$(function(){
    var $comment = $('#comment');
    var $str  =  $('#str');
    var time;
    $comment.focus(function(){
        time = window.setInterval( substring,100 );
    });   
    function substring() {
        var val = $comment.val();
        var length = val.length;
        if( $str.html() != (length) [...]]]></description>
			<content:encoded><![CDATA[<p>　　不好意思各位访客朋友们，因为去了合肥几天，博客也就搁置了，回来也没有一一回复童鞋们的留言，赶紧埋头把手头上的工作解决掉，晚上又挤了一点时间折腾 Wordpress，拳不离手，曲不离口，一天不折腾 Wordpress，手就痒痒，三天没碰代码，都感觉有点生疏了，差点找不到折腾的目标。</p>
<p>　　今天折腾的 Wordpress 目标是实现留言字数的实时计数功能。因为看到之前 <a title="评论框的简单计数器" rel="external nofollow" href="http://www.qiqiboy.com/2010/07/14/a-simple-comment-box-counter.html" target="_blank">qiqiboy 写过一篇文章介绍</a>了，不过 qiqiboy 是自己写的 Javascript 脚本，虽然很简单，不过我还是嫌代码多，就一直没加上，今天折腾了一种 Jquery 实现的 Wordpress 对评论字数进行实时统计计数的功能。因为比较仓促，就只在<a title="留言板" href="http://wange.im/guestbook">留言板</a>页面加上了这个效果，有兴趣的朋友可以先去留言板看看效果。样式也没有怎么修整过，比较粗糙，多多包涵啦～</p>
<p>　　接下来说方法：</p>
<p><strong>1、加载 Jquery</strong></p>
<p>　　这个是必须的，可以用  Google 托管的，也可以下载到本地服务器调用，Jquery 1.2X 的版本就够用了。</p>
<p><strong>2、Jquery 的执行脚本</strong></p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000000;">&lt;</span><span style="color: #000000;">script</span> <span style="color: #000000;">type</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"text/javascript"</span> <span style="color: #000000;">&gt;</span><br />
<span style="color: #000000;">$</span>(<span style="color: #000080; font-weight: bold;">function</span><span style="color: #000000;">(){</span><br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">$comment</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#comment'</span>);<br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">$str</span>  <span style="color: #000000;">=</span>  <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#str'</span>);<br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">time</span>;<br />
    <span style="color: #000000;">$comment</span><span style="color: #000000;">.</span><span style="color: #000000;">focus</span>(<span style="color: #000080; font-weight: bold;">function</span><span style="color: #000000;">(){</span><br />
        <span style="color: #000000;">time</span> <span style="color: #000000;">=</span> <span style="color: #000000;">window</span><span style="color: #000000;">.</span><span style="color: #000000;">setInterval</span>( <span style="color: #000000;">substring</span><span style="color: #000000;">,</span><span style="color: #0000ff;">100</span> );<br />
    <span style="color: #000000;">});</span>   <br />
    <span style="color: #000080; font-weight: bold;">function</span> <span style="color: #000000;">substring</span>() <span style="color: #000000;">{</span><br />
        <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">val</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$comment</span><span style="color: #000000;">.</span><span style="color: #000000;">val</span>();<br />
        <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">length</span> <span style="color: #000000;">=</span> <span style="color: #000000;">val</span><span style="color: #000000;">.</span><span style="color: #000000;">length</span>;<br />
        <span style="color: #000080; font-weight: bold;">if</span>( <span style="color: #000000;">$str</span><span style="color: #000000;">.</span><span style="color: #000000;">html</span>() <span style="color: #000000;">!=</span> (<span style="color: #000000;">length</span>) <span style="color: #000000;">){</span><br />
            <span style="color: #000080; font-weight: bold;">if</span>(<span style="color: #000000;">length</span><span style="color: #000000;">==</span><span style="color: #0000ff;">0</span><span style="color: #000000;">){</span><br />
                <span style="color: #000000;">$</span>(<span style="color: #0000ff;">"#wordcount"</span><span style="color: #000000;">)[</span><span style="color: #0000ff;">0</span><span style="color: #000000;">].</span><span style="color: #000000;">firstChild</span><span style="color: #000000;">.</span><span style="color: #000000;">nodeValue</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">"您已输入0"</span>;<br />
                <span style="color: #000000;">$str</span><span style="color: #000000;">.</span><span style="color: #000000;">html</span>(<span style="color: #000000;">length</span>);<br />
            <span style="color: #000000;">}</span><span style="color: #000080; font-weight: bold;">else</span><span style="color: #000000;">{</span><br />
                <span style="color: #000000;">$</span>(<span style="color: #0000ff;">"#wordcount"</span><span style="color: #000000;">)[</span><span style="color: #0000ff;">0</span><span style="color: #000000;">].</span><span style="color: #000000;">firstChild</span><span style="color: #000000;">.</span><span style="color: #000000;">nodeValue</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">"您已输入"</span>;<br />
                <span style="color: #000000;">$str</span><span style="color: #000000;">.</span><span style="color: #000000;">html</span>(<span style="color: #000000;">length</span>);<br />
            <span style="color: #000000;">}</span><br />
        <span style="color: #000000;">}</span><br />
    <span style="color: #000000;">}</span><br />
<span style="color: #000000;">});</span><br />
<span style="color: #000000;">&lt;</span><span>/script&gt;</span></div>
<p>　　是不是看起来更精简一些呢？这个一定要放在 Jquery 的后面，代码的顺序问题。</p>
<p><strong>3、HTML 部分</strong></p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;p</span> <span style="color: #ff0000;">id=</span><span style="color: #0000ff;">"wordcount"</span><span style="color: #000080; font-weight: bold;">&gt;</span><br />
<span style="color: #000000;">    您已输入</span><span style="color: #000080; font-weight: bold;">&lt;span</span> <span style="color: #ff0000;">id=</span><span style="color: #0000ff;">"str"</span><span style="color: #000080; font-weight: bold;">&gt;</span><span style="color: #000000;">0</span><span style="color: #000080; font-weight: bold;">&lt;/span&gt;</span><span style="color: #000000;">字</span><br />
<span style="color: #000080; font-weight: bold;">&lt;/p&gt;</span></div>
<p>　　这部分代码就是要 wordcount 和 str 这两个 id 和第二步中的相匹配，包括第二步中的 #comment 也要和评论框的 id 相匹配，否则获取不到。 </p>
<p>　　好了，就写到这里吧，也不多写了，重点都说到了，接下去就看各位的悟性了，哈哈～</p>
<div style='background:#EFEFEF;border:1px dashed #CCC;color:#777;margin:5px 0;padding:5px 10px;-moz-border-radius:10px 0;-webkit-border-top-left-radius:10px;-webkit-border-top-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:10px;border-radius:10px 0;'><div>&raquo; 转载请注明来源：<a title="Life Studio" href="http://wange.im/">Life Studio</a> &raquo; <a rel="bookmark" title="Jquery 实现 Wordpress 评论字数计数" href="http://wange.im/comment-count-in-wordpress-with-jquery.html">《Jquery 实现 Wordpress 评论字数计数》</a></div><div>&raquo; 本文链接地址：<a rel="bookmark" title="Jquery 实现 Wordpress 评论字数计数" href="http://wange.im/comment-count-in-wordpress-with-jquery.html">http://wange.im/comment-count-in-wordpress-with-jquery.html</a></div><div>&raquo; 订阅本站：<a title="Life Studio" target="_blank" href="http://feed.wange.im">http://feed.wange.im</a></div></div><h3>相关日志</h3><ul class="st-related-posts"><li><a href="http://wange.im/wordpress-shows-the-number-of-recent-comments.html" title="WordPress 显示访客最近评论次数 (2010年07月20日)">WordPress 显示访客最近评论次数</a> (198)</li><li><a href="http://wange.im/hide-visitor-info-in-wordpress.html" title="记录并隐藏 Wordpress 评论者信息 (2009年12月6日)">记录并隐藏 Wordpress 评论者信息</a> (189)</li><li><a href="http://wange.im/show-your-recent-comments-in-wordpress.html" title="Wordpress 实现“您的足迹”功能 (2010年07月12日)">Wordpress 实现“您的足迹”功能</a> (262)</li><li><a href="http://wange.im/remove-comments-url-in-wordpress.html" title="Wordpress 去掉评论中链接的方法 (2010年07月8日)">Wordpress 去掉评论中链接的方法</a> (172)</li><li><a href="http://wange.im/replace-comment-text-in-wordpress.html" title="过滤并替换 Wordpress 留言指定字符 (2010年07月5日)">过滤并替换 Wordpress 留言指定字符</a> (242)</li><li><a href="http://wange.im/no-admin-comments-in-wordpress.html" title="Wordpress 统计排除管理员的评论数 (2010年06月18日)">Wordpress 统计排除管理员的评论数</a> (146)</li><li><a href="http://wange.im/per-page-of-wp-list-comments-in-wordpress.html" title="Wordpress 不同页面不同评论分页功能 (2010年06月16日)">Wordpress 不同页面不同评论分页功能</a> (133)</li><li><a href="http://wange.im/paginate-comments-in-wordpress.html" title="Wordpress 指定页面评论分页功能 (2010年06月13日)">Wordpress 指定页面评论分页功能</a> (140)</li><li><a href="http://wange.im/commenter-gravatar-in-wordpress.html" title="Wordpress 记录评论者 gravatar 头像 (2010年05月18日)">Wordpress 记录评论者 gravatar 头像</a> (154)</li><li><a href="http://wange.im/fadeto-effect-with-jquery.html" title="利用 JQuery 实现图片显隐特效 (2010年04月8日)">利用 JQuery 实现图片显隐特效</a> (119)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://wange.im/comment-count-in-wordpress-with-jquery.html/feed</wfw:commentRss>
		<slash:comments>145</slash:comments>
		</item>
		<item>
		<title>WordPress 显示访客最近评论次数</title>
		<link>http://wange.im/wordpress-shows-the-number-of-recent-comments.html</link>
		<comments>http://wange.im/wordpress-shows-the-number-of-recent-comments.html#comments</comments>
		<pubDate>Tue, 20 Jul 2010 12:29:52 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[转来载去]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[留言]]></category>

		<guid isPermaLink="false">http://wange.im/?p=3547</guid>
		<description><![CDATA[　　暑假本来是我静下心来好好折腾 Wordpress 的时候，可是俺们领导疯了，暑假加班还要死命地拖着我一起，已经连续两天了，明天还要加班，哥的假期就这样被他活生生地给毁了。所以最近都没有太多的时间折腾 Wordpress 好玩的新功能，看到有啥新鲜的东东就顺手牵羊地加上了，比如说 Winy 小盆友的 WordPress 显示最近评论次数。加上后自我感觉效果还不错，就分享一下这个方法啦～
　　说的简单点，Wordpress 显示最近评论次数的功能就在于，显示访客30天发表留言的数量。Winy 小盆友的代码写的不错，我啥也没改就扔上来了（8好意思啊 Winy 童鞋，我连 URL 都赤果果地照搬过来了，HIAHIA～）。
　　把以下代码复制到 Wordpress 主题文件夹的 functions.php 中：
//copy下面的代码到主题functions.php里调用/*** welcome message* @param unknown_type $email* @return void&#124;string*/function WelcomeCommentAuthorBack($email = &#39;&#39;){&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(empty($email)){&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }&#160;&#160;&#160;&#160;&#160;&#160;&#160; global $wpdb;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $past_30days = gmdate(&#39;Y-m-d H:i:s&#39;,((time()-(24*60*60*30))+(get_option(&#39;gmt_offset&#39;)*3600)));&#160;&#160;&#160;&#160;&#160;&#160;&#160; $sql = &#34;SELECT count(comment_author_email) AS times FROM $wpdb-&#62;comments WHERE comment_approved = &#39;1&#39; AND comment_author_email = '$email' AND comment_date [...]]]></description>
			<content:encoded><![CDATA[<p>　　暑假本来是我静下心来好好折腾 Wordpress 的时候，可是俺们领导疯了，暑假加班还要死命地拖着我一起，已经连续两天了，明天还要加班，哥的假期就这样被他活生生地给毁了。所以最近都没有太多的时间折腾 Wordpress 好玩的新功能，看到有啥新鲜的东东就顺手牵羊地加上了，比如说 <a title="Winy Sky" rel="external nofollow" href="http://winysky.com" target="_blank">Winy</a> 小盆友的 <a title="WordPress显示最近评论次数" rel="external nofollow" href="http://winysky.com/wordpress-shows-the-number-of-recent-comments" target="_blank">WordPress 显示最近评论次数</a>。加上后自我感觉效果还不错，就分享一下这个方法啦～</p>
<p>　　说的简单点，Wordpress 显示最近评论次数的功能就在于，显示访客30天发表留言的数量。Winy 小盆友的代码写的不错，我啥也没改就扔上来了（8好意思啊 Winy 童鞋，我连 URL 都赤果果地照搬过来了，HIAHIA～）。</p>
<p>　　把以下代码复制到 Wordpress 主题文件夹的 functions.php 中：<br />
<DIV style="FONT-FAMILY: 'Courier New', 'Lucida Console', 'monospace'; COLOR: #000000" class=source jQuery1279628256062="14"><SPAN style="FONT-STYLE: italic; COLOR: #008800">//copy下面的代码到主题functions.php里调用</SPAN><BR><SPAN style="FONT-STYLE: italic; COLOR: #008800">/**</SPAN><BR><SPAN style="FONT-STYLE: italic; COLOR: #008800">* welcome message</SPAN><BR><SPAN style="FONT-STYLE: italic; COLOR: #008800">* @param unknown_type $email</SPAN><BR><SPAN style="FONT-STYLE: italic; COLOR: #008800">* @return void|string</SPAN><BR><SPAN style="FONT-STYLE: italic; COLOR: #008800">*/</SPAN><BR><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">function</SPAN> <SPAN style="COLOR: #000000">WelcomeCommentAuthorBack</SPAN>(<SPAN style="COLOR: #000000">$email</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #0000ff">&#39;&#39;</SPAN><SPAN style="COLOR: #000000">){</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">if</SPAN>(<SPAN style="COLOR: #000000">empty</SPAN>(<SPAN style="COLOR: #000000">$email</SPAN><SPAN style="COLOR: #000000">)){</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">return</SPAN>;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">}</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">global</SPAN> <SPAN style="COLOR: #000000">$wpdb</SPAN>;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$past_30days</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">gmdate</SPAN>(<SPAN style="COLOR: #0000ff">&#39;Y-m-d H:i:s&#39;</SPAN><SPAN style="COLOR: #000000">,((</SPAN><SPAN style="COLOR: #000000">time</SPAN>()<SPAN style="COLOR: #000000">-</SPAN>(<SPAN style="COLOR: #0000ff">24</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #0000ff">60</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #0000ff">60</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #0000ff">30</SPAN>))<SPAN style="COLOR: #000000">+</SPAN>(<SPAN style="COLOR: #000000">get_option</SPAN>(<SPAN style="COLOR: #0000ff">&#39;gmt_offset&#39;</SPAN>)<SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #0000ff">3600</SPAN>)));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$sql</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #0000ff">&quot;SELECT count(comment_author_email) AS times FROM $wpdb-&gt;comments WHERE comment_approved = &#39;1&#39; AND comment_author_email = '$email' AND comment_date &gt;= '$past_30days'&quot;</SPAN>;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$times</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">$wpdb</SPAN><SPAN style="COLOR: #000000">-&gt;</SPAN><SPAN style="COLOR: #000000">get_results</SPAN>(<SPAN style="COLOR: #000000">$sql</SPAN>);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$times</SPAN> <SPAN style="COLOR: #000000">=</SPAN> (<SPAN style="COLOR: #000000">$times</SPAN><SPAN style="COLOR: #000000">[</SPAN><SPAN style="COLOR: #0000ff">0</SPAN><SPAN style="COLOR: #000000">]</SPAN><SPAN style="COLOR: #000000">-&gt;</SPAN><SPAN style="COLOR: #000000">times</SPAN>) <SPAN style="COLOR: #000000">?</SPAN> <SPAN style="COLOR: #000000">$times</SPAN><SPAN style="COLOR: #000000">[</SPAN><SPAN style="COLOR: #0000ff">0</SPAN><SPAN style="COLOR: #000000">]</SPAN><SPAN style="COLOR: #000000">-&gt;</SPAN><SPAN style="COLOR: #000000">times</SPAN> <SPAN style="COLOR: #000000">:</SPAN> <SPAN style="COLOR: #0000ff">0</SPAN>;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$message</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">$times</SPAN> <SPAN style="COLOR: #000000">?</SPAN> <SPAN style="COLOR: #000000">sprintf</SPAN>(<SPAN style="COLOR: #000000">__</SPAN>(<SPAN style="COLOR: #0000ff">&#39;过去30天内您评论了&lt;strong&gt;%1$s&lt;/strong&gt;次，感谢关注~&#39;</SPAN> <SPAN style="COLOR: #000000">),</SPAN> <SPAN style="COLOR: #000000">$times</SPAN>) <SPAN style="COLOR: #000000">:</SPAN> <SPAN style="COLOR: #0000ff">&#39;您很久都没有留言了，这次想说点什么吗？&#39;</SPAN>;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">return</SPAN> <SPAN style="COLOR: #000000">$message</SPAN>;<BR><SPAN style="COLOR: #000000">}</SPAN><BR></DIV>　　使用方法：在　comments.php　合适的地方，比如留言框上面调用这个函数：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #008080;">&lt;?php</span> <span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #000000;">WelcomeCommentAuthorBack</span>(<span style="color: #000000;">$comment_author_email</span>); <span style="color: #008080;">?&gt;</span></div>
<p><img style="float: right;" src="http://storage.live.com/items/C3C8B704573706D9!568?filename=welcome.jpg" alt="" />　　基本的使用方法就是这样啦，之前留过言的童鞋可以在下面评论的欢迎提示词中看到效果，把鼠标移到你的昵称上，就会弹出一个留言次数的小提示了。截图如右图，不看不知道，一看吓一跳，在过去的30个月里，我居然盖了2082层楼，平均每天70层楼，我才是当之无愧的水王呀，哈哈哈哈。</p>
<p>　　不过要声明一下，我另外还用了 Jquery 的方法先把这个提示消息隐藏了起来，需要鼠标有一个 mouseover 的事件才会显示出来，需要加上此效果的朋友可以看<a title="JQuery 鼠标滑动渐隐渐显效果" href="http://wange.im/fadein-and-fadeout-with-jquery.html">这篇文章</a>，这里就不重复说明了。</p>
<p>　　围观 Winy 原创：<a title="WordPress显示最近评论次数" rel="external nofollow" href="http://winysky.com/wordpress-shows-the-number-of-recent-comments" target="_blank">http://winysky.com/wordpress-shows-the-number-of-recent-comments</a></p>
<div style='background:#EFEFEF;border:1px dashed #CCC;color:#777;margin:5px 0;padding:5px 10px;-moz-border-radius:10px 0;-webkit-border-top-left-radius:10px;-webkit-border-top-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:10px;border-radius:10px 0;'><div>&raquo; 转载请注明来源：<a title="Life Studio" href="http://wange.im/">Life Studio</a> &raquo; <a rel="bookmark" title="WordPress 显示访客最近评论次数" href="http://wange.im/wordpress-shows-the-number-of-recent-comments.html">《WordPress 显示访客最近评论次数》</a></div><div>&raquo; 本文链接地址：<a rel="bookmark" title="WordPress 显示访客最近评论次数" href="http://wange.im/wordpress-shows-the-number-of-recent-comments.html">http://wange.im/wordpress-shows-the-number-of-recent-comments.html</a></div><div>&raquo; 订阅本站：<a title="Life Studio" target="_blank" href="http://feed.wange.im">http://feed.wange.im</a></div></div><h3>相关日志</h3><ul class="st-related-posts"><li><a href="http://wange.im/comment-count-in-wordpress-with-jquery.html" title="Jquery 实现 Wordpress 评论字数计数 (2010年07月27日)">Jquery 实现 Wordpress 评论字数计数</a> (145)</li><li><a href="http://wange.im/hide-visitor-info-in-wordpress.html" title="记录并隐藏 Wordpress 评论者信息 (2009年12月6日)">记录并隐藏 Wordpress 评论者信息</a> (189)</li><li><a href="http://wange.im/show-your-recent-comments-in-wordpress.html" title="Wordpress 实现“您的足迹”功能 (2010年07月12日)">Wordpress 实现“您的足迹”功能</a> (262)</li><li><a href="http://wange.im/remove-comments-url-in-wordpress.html" title="Wordpress 去掉评论中链接的方法 (2010年07月8日)">Wordpress 去掉评论中链接的方法</a> (172)</li><li><a href="http://wange.im/replace-comment-text-in-wordpress.html" title="过滤并替换 Wordpress 留言指定字符 (2010年07月5日)">过滤并替换 Wordpress 留言指定字符</a> (242)</li><li><a href="http://wange.im/no-admin-comments-in-wordpress.html" title="Wordpress 统计排除管理员的评论数 (2010年06月18日)">Wordpress 统计排除管理员的评论数</a> (146)</li><li><a href="http://wange.im/per-page-of-wp-list-comments-in-wordpress.html" title="Wordpress 不同页面不同评论分页功能 (2010年06月16日)">Wordpress 不同页面不同评论分页功能</a> (133)</li><li><a href="http://wange.im/paginate-comments-in-wordpress.html" title="Wordpress 指定页面评论分页功能 (2010年06月13日)">Wordpress 指定页面评论分页功能</a> (140)</li><li><a href="http://wange.im/commenter-gravatar-in-wordpress.html" title="Wordpress 记录评论者 gravatar 头像 (2010年05月18日)">Wordpress 记录评论者 gravatar 头像</a> (154)</li><li><a href="http://wange.im/fadeto-effect-with-jquery.html" title="利用 JQuery 实现图片显隐特效 (2010年04月8日)">利用 JQuery 实现图片显隐特效</a> (119)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://wange.im/wordpress-shows-the-number-of-recent-comments.html/feed</wfw:commentRss>
		<slash:comments>198</slash:comments>
		</item>
		<item>
		<title>Wordpress 站内搜索高亮显示关键词</title>
		<link>http://wange.im/highlight-keywords-in-wordpress-search.html</link>
		<comments>http://wange.im/highlight-keywords-in-wordpress-search.html#comments</comments>
		<pubDate>Sun, 18 Jul 2010 12:00:26 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[关键词]]></category>
		<category><![CDATA[搜索]]></category>
		<category><![CDATA[非插件]]></category>
		<category><![CDATA[高亮]]></category>

		<guid isPermaLink="false">http://wange.im/?p=3534</guid>
		<description><![CDATA[　　被 Qiqiboy 刺激后，我阴差阳错地折腾出了非插件的 Wordpress 高亮显示关键词及欢迎提示，但是这个搜索关键词高亮提示仅仅是针对来自 Google、百度等搜索引擎的访客，貌似对用站内搜索的朋友就有些不公平了，所以昨天考完试，我今天又马不停蹄地折腾起来，誓言要把 Wordpress 站内搜索高亮显示关键词的功能搞定！结果，还真搞定了，哈哈～
　　无论是用 PHP 还是 Javascript 来实现 Wordpress 站内搜索高亮关键词，都不可避免地会用到正则表达式，而偏偏这又是我的软肋，汗颜～先是参考了网上流传最多的 Jquery 实现站内搜索高亮关键词的方法，很可惜，这是一个老外的成果，完全没有考虑到我们非英语为母语的国家，所以这个高亮方法仅支持英文单词开头的关键词，用中文就杯具了。
　　所以最终还是参考了 Qiqiboy 的 wordpress高亮搜索结果+实现关键字前后截断显示。。。，他用的是 PHP 正则表达式的方法，最大的特点就是可以完美支持中文，而且比 Jquery 的方法执行速度也更快，最让我喜欢的一点是，非插件！哈哈～于是就拿来根据自己的主题修改了一番，方法如下：
　　在 Wordpress 主题文件的 search.php 搜索结果文件中的主循环中加入以下代码：
&#60;?php
    $title = get_the_title();
    $content = mb_strimwidth(strip_tags(apply_filters('the_content', $post-&#62;post_content)), 0, 600,"......");
    $keys = explode(" ",$s);
    $title = preg_replace('/('.implode('&#124;', $keys) .')/iu','&#60;span style="font-weight:700;background:#ffff00;"&#62;\0&#60;/span&#62;',$title);
    $content = preg_replace('/('.implode('&#124;', $keys) .')/iu','&#60;span style="font-weight:700;background:#ffff00;"&#62;\0&#60;/span&#62;',$content);
?&#62;
　　调用高亮的标题用以下代码：
&#60;?php echo $title; ?&#62;
　　调用高亮的日志内容用以下代码：
&#60;?php echo $content;?&#62;
　　就这样，效果还是蛮不错的，大家可以去我头部导航右上角的站内搜索输入一些关键词试试，中文的、英文的都可以。另外我的 PHP [...]]]></description>
			<content:encoded><![CDATA[<p>　　被 <a title="Qiqiboy" rel="external nofollow" href="http://www.qiqiboy.com/" target="_blank">Qiqiboy</a> 刺激后，我阴差阳错地折腾出了非插件的 <a title="Wordpress 高亮显示关键词及欢迎提示" href="http://wange.im/highlight-keywords-and-hellobaby-in-wordpress.html">Wordpress 高亮显示关键词及欢迎提示</a>，但是这个搜索关键词高亮提示仅仅是针对来自 Google、百度等搜索引擎的访客，貌似对用站内搜索的朋友就有些不公平了，所以昨天考完试，我今天又马不停蹄地折腾起来，誓言要把 Wordpress 站内搜索高亮显示关键词的功能搞定！结果，还真搞定了，哈哈～</p>
<p>　　无论是用 PHP 还是 Javascript 来实现 Wordpress 站内搜索高亮关键词，都不可避免地会用到正则表达式，而偏偏这又是我的软肋，汗颜～先是参考了网上流传最多的 <a title="How to Highlight Search Terms with jQuery" rel="external nofollow" href="http://weblogtoolscollection.com/archives/2009/04/10/how-to-highlight-search-terms-with-jquery/" target="_blank">Jquery 实现站内搜索高亮关键词的方法</a>，很可惜，这是一个老外的成果，完全没有考虑到我们非英语为母语的国家，所以这个高亮方法仅支持英文单词开头的关键词，用中文就杯具了。</p>
<p>　　所以最终还是参考了 Qiqiboy 的 <a title="wordpress高亮搜索结果+实现关键字前后截断显示。。。" rel="external nofollow" href="http://www.qiqiboy.com/2010/07/16/wordpress-highlighted-keyword-search-results.html">wordpress高亮搜索结果+实现关键字前后截断显示。。。</a>，他用的是 PHP 正则表达式的方法，最大的特点就是可以完美支持中文，而且比 Jquery 的方法执行速度也更快，最让我喜欢的一点是，非插件！哈哈～于是就拿来根据自己的主题修改了一番，方法如下：</p>
<p>　　在 Wordpress 主题文件的 search.php 搜索结果文件中的主循环中加入以下代码：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #008080;">&lt;?php</span><br />
    <span style="color: #000000;">$title</span> <span style="color: #000000;">=</span> <span style="color: #000000;">get_the_title</span>();<br />
    <span style="color: #000000;">$content</span> <span style="color: #000000;">=</span> <span style="color: #000000;">mb_strimwidth</span>(<span style="color: #000000;">strip_tags</span>(<span style="color: #000000;">apply_filters</span>(<span style="color: #0000ff;">'the_content'</span><span style="color: #000000;">,</span> <span style="color: #000000;">$post</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">post_content</span><span style="color: #000000;">)),</span> <span style="color: #0000ff;">0</span><span style="color: #000000;">,</span> <span style="color: #0000ff;">600</span><span style="color: #000000;">,</span><span style="color: #0000ff;">"......"</span>);<br />
    <span style="color: #000000;">$keys</span> <span style="color: #000000;">=</span> <span style="color: #000000;">explode</span>(<span style="color: #0000ff;">" "</span><span style="color: #000000;">,</span><span style="color: #000000;">$s</span>);<br />
    <span style="color: #000000;">$title</span> <span style="color: #000000;">=</span> <span style="color: #000000;">preg_replace</span>(<span style="color: #0000ff;">'/('</span><span style="color: #000000;">.</span><span style="color: #000000;">implode</span>(<span style="color: #0000ff;">'|'</span><span style="color: #000000;">,</span> <span style="color: #000000;">$keys</span>) <span style="color: #000000;">.</span><span style="color: #0000ff;">')/iu'</span><span style="color: #000000;">,</span><span style="color: #0000ff;">'&lt;span style="font-weight:700;background:#ffff00;"&gt;\0&lt;/span&gt;'</span><span style="color: #000000;">,</span><span style="color: #000000;">$title</span>);<br />
    <span style="color: #000000;">$content</span> <span style="color: #000000;">=</span> <span style="color: #000000;">preg_replace</span>(<span style="color: #0000ff;">'/('</span><span style="color: #000000;">.</span><span style="color: #000000;">implode</span>(<span style="color: #0000ff;">'|'</span><span style="color: #000000;">,</span> <span style="color: #000000;">$keys</span>) <span style="color: #000000;">.</span><span style="color: #0000ff;">')/iu'</span><span style="color: #000000;">,</span><span style="color: #0000ff;">'&lt;span style="font-weight:700;background:#ffff00;"&gt;\0&lt;/span&gt;'</span><span style="color: #000000;">,</span><span style="color: #000000;">$content</span>);<br />
<span style="color: #008080;">?&gt;</span></div>
<p>　　调用高亮的标题用以下代码：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #008080;">&lt;?php</span> <span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #000000;">$title</span>; <span style="color: #008080;">?&gt;</span></div>
<p>　　调用高亮的日志内容用以下代码：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #008080;">&lt;?php</span> <span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #000000;">$content</span>;<span style="color: #008080;">?&gt;</span></div>
<p>　　就这样，效果还是蛮不错的，大家可以去我头部导航右上角的站内搜索输入一些关键词试试，中文的、英文的都可以。另外我的 PHP 实力很菜，这修改过程可能不太完美，而且以上代码是根据我自己主题的需要修改的，并不完全通用。大家有同样需要 Wordpress 站内搜索关键词高亮显示功能的，可以直接去 Qiqiboy 的原文学习：<a title="wordpress高亮搜索结果+实现关键字前后截断显示。。。" rel="external nofollow" href="http://www.qiqiboy.com/2010/07/16/wordpress-highlighted-keyword-search-results.html" target="_blank">http://www.qiqiboy.com/2010/07/16/wordpress-highlighted-keyword-search-results.html</a></p>
<p>　　最后贴一张站内搜索关键词高亮的截图：</p>
<div class="wp-caption alignnone" style="width: 535px"><img title="Wordpress 站内搜索高亮显示关键词" src="http://storage.live.com/items/C3C8B704573706D9!566?filename=keyword-highlight.jpg" alt="" width="525" height="224" /><p class="wp-caption-text">Wordpress 站内搜索高亮显示关键词</p></div>
<div style='background:#EFEFEF;border:1px dashed #CCC;color:#777;margin:5px 0;padding:5px 10px;-moz-border-radius:10px 0;-webkit-border-top-left-radius:10px;-webkit-border-top-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:10px;border-radius:10px 0;'><div>&raquo; 转载请注明来源：<a title="Life Studio" href="http://wange.im/">Life Studio</a> &raquo; <a rel="bookmark" title="Wordpress 站内搜索高亮显示关键词" href="http://wange.im/highlight-keywords-in-wordpress-search.html">《Wordpress 站内搜索高亮显示关键词》</a></div><div>&raquo; 本文链接地址：<a rel="bookmark" title="Wordpress 站内搜索高亮显示关键词" href="http://wange.im/highlight-keywords-in-wordpress-search.html">http://wange.im/highlight-keywords-in-wordpress-search.html</a></div><div>&raquo; 订阅本站：<a title="Life Studio" target="_blank" href="http://feed.wange.im">http://feed.wange.im</a></div></div><h3>相关日志</h3><ul class="st-related-posts"><li><a href="http://wange.im/highlight-keywords-and-hellobaby-in-wordpress.html" title="Wordpress 高亮显示关键词及欢迎提示 (2010年07月16日)">Wordpress 高亮显示关键词及欢迎提示</a> (180)</li><li><a href="http://wange.im/wordpress-say-hello-to-vistors.html" title="Wordpress 向来自其他域的访客致欢迎词 (2010年07月30日)">Wordpress 向来自其他域的访客致欢迎词</a> (175)</li><li><a href="http://wange.im/output-twitter-to-wordpress-revision.html" title="Wordpress 非插件调用 Twitter 修订版 (2010年06月28日)">Wordpress 非插件调用 Twitter 修订版</a> (147)</li><li><a href="http://wange.im/pagenavi-without-plugins-in-wordpress.html" title="Wordpress 非插件日志分页效果 (2010年05月27日)">Wordpress 非插件日志分页效果</a> (121)</li><li><a href="http://wange.im/share-to-sns-without-plugins-for-wordpress.html" title="Wordpress 非插件实现分享按钮 (2010年05月19日)">Wordpress 非插件实现分享按钮</a> (168)</li><li><a href="http://wange.im/related-posts-with-thumbs-for-wordpress.html" title="Wordpress 免插件实现图片相关日志 (2010年05月4日)">Wordpress 免插件实现图片相关日志</a> (98)</li><li><a href="http://wange.im/wordpress-ip-statistics-without-plugins.html" title="Wordpress 非插件统计网站访问信息 (2010年04月10日)">Wordpress 非插件统计网站访问信息</a> (115)</li><li><a href="http://wange.im/related-posts-without-plugins-in-wordpress.html" title="Wordpress 非插件相关日志的两种方法 (2010年04月4日)">Wordpress 非插件相关日志的两种方法</a> (134)</li><li><a href="http://wange.im/sync-wordpress-to-twitter.html" title="非插件同步 Wordpress 日志到 Twitter (2010年04月1日)">非插件同步 Wordpress 日志到 Twitter</a> (113)</li><li><a href="http://wange.im/wordpress-statistics-without-plugins.html" title="Wordpress 非插件统计网站信息 (2010年03月20日)">Wordpress 非插件统计网站信息</a> (102)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://wange.im/highlight-keywords-in-wordpress-search.html/feed</wfw:commentRss>
		<slash:comments>119</slash:comments>
		</item>
		<item>
		<title>Wordpress 高亮显示关键词及欢迎提示</title>
		<link>http://wange.im/highlight-keywords-and-hellobaby-in-wordpress.html</link>
		<comments>http://wange.im/highlight-keywords-and-hellobaby-in-wordpress.html#comments</comments>
		<pubDate>Fri, 16 Jul 2010 12:01:57 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[关键词]]></category>
		<category><![CDATA[搜索]]></category>
		<category><![CDATA[非插件]]></category>
		<category><![CDATA[高亮]]></category>

		<guid isPermaLink="false">http://wange.im/?p=3496</guid>
		<description><![CDATA[　　写这篇文章绝对是受了 Qiqiboy 的刺激，该小盆友说我的 Wordpress 站内搜索没有用关键词高亮，而且还有图有真相的，巨受打击。好吧，我顶着明天两门考试可能挂彩的压力，今天就不复习了，全心投入到研究 Wordpress 关键词搜索高亮显示的行列中，什么 PHP 啊、JQuery 啊、CSS 啊、正则啊、获取 Cookies 啊，反正能用的我都用上了，8 过神奇的是，折腾出来的不是 Wordpress 自带的站内搜索的关键词高亮，而是来自 Google、百度等搜索引擎的关键词高亮显示，并且对访客显示欢迎提示词。
　　这样说是很难让人理解的，你可以先试试用百度或者 Google 搜索本站的关键词“万戈”，再通过搜索引擎的结果点击进入本站，就可以看到效果了，在右侧栏的位置可以看到一个可以随滚动条上下浮动的弹出层，显示“欢迎来自 *** 的朋友！推荐您 点击这里 订阅我的博客 o(∩_∩)o ”，这里的 *** 是可以显示通过哪个搜索引擎入口来访的，很亲切哟。
　　另外，用我的一些其他的关键词，如“Wordpress 读者墙”之类的，通过搜索引擎点击进入本站，则会看到你搜索的关键词已经加粗高亮，这样也就强调了访客希望看到的重点内容，提高了访客的体验。
　　以下两张分别是搜索引擎的关键词高亮和来自搜索引擎的访客欢迎提示词的截图。








　　好了，废话到此结束，下面是代码部分，首先要感谢一下 landing-sites 插件的作者，我就是在此研究成果上精简修改并折腾出了非插件版本的、更适合中国本土搜索引擎、再加上我无敌美化的代码～
　　一、首页是 PHP 的函数部分，老规矩，把以下代码复制到 Wordpress 主题目的 functions.php 中：
function ls_get_delim($ref) {&#160;&#160;&#160; $search_engines = array&#160;&#160;&#160; (&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#39;google.com&#39; =&#62; &#39;q&#39;,&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#39;google.com.hk&#39; =&#62; &#39;q&#39;,&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#39;baidu.com&#39; =&#62; &#39;wd&#39;,&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#39;search.yahoo.com&#39; =&#62; &#39;p&#39;,&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#39;cn.search.yahoo.com&#39; =&#62; &#39;p&#39;,&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>　　写这篇文章绝对是受了 <a title="Qiqiboy" rel="external nofollow" href="http://www.qiqiboy.com/" target="_blank">Qiqiboy</a> 的刺激，该小盆友说<a title="wordpress高亮搜索结果+实现关键字前后截断显示" rel="external nofollow" href="http://www.qiqiboy.com/2010/07/16/wordpress-highlighted-keyword-search-results.html" target="_blank">我的 Wordpress 站内搜索没有用关键词高亮</a>，而且还有图有真相的，巨受打击。好吧，我顶着明天两门考试可能挂彩的压力，今天就不复习了，全心投入到研究 Wordpress 关键词搜索高亮显示的行列中，什么 PHP 啊、JQuery 啊、CSS 啊、正则啊、获取 Cookies 啊，反正能用的我都用上了，8 过神奇的是，折腾出来的不是 Wordpress 自带的站内搜索的关键词高亮，而是来自 Google、百度等<strong>搜索引擎的关键词高亮显示</strong>，并且对访客<strong>显示欢迎提示词</strong>。</p>
<p>　　这样说是很难让人理解的，你可以先试试用百度或者 Google 搜索本站的关键词“万戈”，再通过搜索引擎的结果点击进入本站，就可以看到效果了，在右侧栏的位置可以看到一个可以随滚动条上下浮动的弹出层，显示“欢迎来自 *** 的朋友！推荐您 <strong><a href="http://feed.wange.im/" target="_blank">点击这里</a></strong> 订阅我的博客 o(∩_∩)o ”，这里的 *** 是可以显示通过哪个搜索引擎入口来访的，很亲切哟。</p>
<p>　　另外，用我的一些其他的关键词，如“Wordpress 读者墙”之类的，通过搜索引擎点击进入本站，则会看到你搜索的关键词已经加粗高亮，这样也就强调了访客希望看到的重点内容，提高了访客的体验。</p>
<p>　　以下两张分别是<strong>搜索引擎的关键词高亮</strong>和<strong>来自搜索引擎的访客欢迎提示词</strong>的截图。</p>
<table border="0" align="center">
<tbody>
<tr>
<td><div class="wp-caption alignnone" style="width: 220px"><img title="搜索高亮显示关键词" src="http://storage.live.com/items/C3C8B704573706D9!565?filename=highlight.jpg" alt="" width="210" height="220" /><p class="wp-caption-text">搜索高亮显示关键词</p></div></td>
<td><div class="wp-caption alignnone" style="width: 325px"><img title="搜索访客显示欢迎提示词" src="http://storage.live.com/items/C3C8B704573706D9!564?filename=hellobaby.jpg" alt="" width="315" height="220" /><p class="wp-caption-text">搜索访客显示欢迎提示词</p></div></td>
</tr>
</tbody>
</table>
<p>　　好了，废话到此结束，下面是代码部分，首先要感谢一下 <a target="_blank" rel="external nofollow" href="http://wordpress.org/extend/plugins/landing-sites/">landing-sites 插件</a>的作者，我就是在此研究成果上精简修改并折腾出了非插件版本的、更适合中国本土搜索引擎、再加上我无敌美化的代码～</p>
<p>　　一、首页是 PHP 的函数部分，老规矩，把以下代码复制到 Wordpress 主题目的 functions.php 中：</p>
<p><DIV style="FONT-FAMILY: 'Courier New', 'Lucida Console', 'monospace'; COLOR: #000000" class=source jQuery1279274116031="14"><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">function</SPAN> <SPAN style="COLOR: #000000">ls_get_delim</SPAN>(<SPAN style="COLOR: #000000">$ref</SPAN>) <SPAN style="COLOR: #000000">{</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$search_engines</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">array</SPAN>&nbsp;&nbsp;&nbsp; (<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">&#39;google.com&#39;</SPAN> <SPAN style="COLOR: #000000">=&gt;</SPAN> <SPAN style="COLOR: #0000ff">&#39;q&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">&#39;google.com.hk&#39;</SPAN> <SPAN style="COLOR: #000000">=&gt;</SPAN> <SPAN style="COLOR: #0000ff">&#39;q&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">&#39;baidu.com&#39;</SPAN> <SPAN style="COLOR: #000000">=&gt;</SPAN> <SPAN style="COLOR: #0000ff">&#39;wd&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">&#39;search.yahoo.com&#39;</SPAN> <SPAN style="COLOR: #000000">=&gt;</SPAN> <SPAN style="COLOR: #0000ff">&#39;p&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">&#39;cn.search.yahoo.com&#39;</SPAN> <SPAN style="COLOR: #000000">=&gt;</SPAN> <SPAN style="COLOR: #0000ff">&#39;p&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">&#39;cn.bing.com&#39;</SPAN> <SPAN style="COLOR: #000000">=&gt;</SPAN> <SPAN style="COLOR: #0000ff">&#39;q&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">&#39;search.lycos.com&#39;</SPAN> <SPAN style="COLOR: #000000">=&gt;</SPAN> <SPAN style="COLOR: #0000ff">&#39;query&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">&#39;youdao.com&#39;</SPAN> <SPAN style="COLOR: #000000">=&gt;</SPAN> <SPAN style="COLOR: #0000ff">&#39;q&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">&#39;search.aol.com&#39;</SPAN> <SPAN style="COLOR: #000000">=&gt;</SPAN> <SPAN style="COLOR: #0000ff">&#39;query&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">&#39;ask.com&#39;</SPAN> <SPAN style="COLOR: #000000">=&gt;</SPAN> <SPAN style="COLOR: #0000ff">&#39;q&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">&#39;hotbot.com&#39;</SPAN> <SPAN style="COLOR: #000000">=&gt;</SPAN> <SPAN style="COLOR: #0000ff">&#39;query&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">&#39;overture.com&#39;</SPAN> <SPAN style="COLOR: #000000">=&gt;</SPAN> <SPAN style="COLOR: #0000ff">&#39;Keywords&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">&#39;search.netscape.com&#39;</SPAN> <SPAN style="COLOR: #000000">=&gt;</SPAN> <SPAN style="COLOR: #0000ff">&#39;query&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">&#39;search.looksmart.com&#39;</SPAN> <SPAN style="COLOR: #000000">=&gt;</SPAN> <SPAN style="COLOR: #0000ff">&#39;qt&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">&#39;search.earthlink.net&#39;</SPAN> <SPAN style="COLOR: #000000">=&gt;</SPAN> <SPAN style="COLOR: #0000ff">&#39;q&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">&#39;search.viewpoint.com&#39;</SPAN> <SPAN style="COLOR: #000000">=&gt;</SPAN> <SPAN style="COLOR: #0000ff">&#39;k&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">&#39;mamma.com&#39;</SPAN> <SPAN style="COLOR: #000000">=&gt;</SPAN> <SPAN style="COLOR: #0000ff">&#39;query&#39;</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$delim</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">FALSE</SPAN>;<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">if</SPAN> (<SPAN style="COLOR: #000000">isset</SPAN>(<SPAN style="COLOR: #000000">$search_engines</SPAN><SPAN style="COLOR: #000000">[</SPAN><SPAN style="COLOR: #000000">$ref</SPAN><SPAN style="COLOR: #000000">]))</SPAN> <SPAN style="COLOR: #000000">{</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$delim</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">$search_engines</SPAN><SPAN style="COLOR: #000000">[</SPAN><SPAN style="COLOR: #000000">$ref</SPAN><SPAN style="COLOR: #000000">];</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">}</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">return</SPAN> <SPAN style="COLOR: #000000">$delim</SPAN>;<BR><SPAN style="COLOR: #000000">}</SPAN><BR><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">function</SPAN> <SPAN style="COLOR: #000000">ls_get_terms</SPAN>(<SPAN style="COLOR: #000000">$d</SPAN>) <SPAN style="COLOR: #000000">{</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$terms</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">null</SPAN>;<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$query_array</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">array</SPAN>();<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$query_terms</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">null</SPAN>;<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$query</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">explode</SPAN>(<SPAN style="COLOR: #000000">$d</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #0000ff">&#39;=&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #000000">$_SERVER</SPAN><SPAN style="COLOR: #000000">[</SPAN><SPAN style="COLOR: #0000ff">&#39;HTTP_REFERER&#39;</SPAN><SPAN style="COLOR: #000000">]);</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$query</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">explode</SPAN>(<SPAN style="COLOR: #0000ff">&#39;&amp;&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #000000">$query</SPAN><SPAN style="COLOR: #000000">[</SPAN><SPAN style="COLOR: #0000ff">1</SPAN><SPAN style="COLOR: #000000">]);</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$query</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">urldecode</SPAN>(<SPAN style="COLOR: #000000">$query</SPAN><SPAN style="COLOR: #000000">[</SPAN><SPAN style="COLOR: #0000ff">0</SPAN><SPAN style="COLOR: #000000">]);</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$query</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">str_replace</SPAN>(<SPAN style="COLOR: #0000ff">&quot;&#39;&quot;</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #0000ff">&#39;&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #000000">$query</SPAN>);<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$query</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">str_replace</SPAN>(<SPAN style="COLOR: #0000ff">&#39;&quot;&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #0000ff">&#39;&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #000000">$query</SPAN>);<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$query_array</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">preg_split</SPAN>(<SPAN style="COLOR: #0000ff">&#39;/[\s,\+\.]+/&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">$query</SPAN>);<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$query_terms</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">implode</SPAN>(<SPAN style="COLOR: #0000ff">&#39; &#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #000000">$query_array</SPAN>);<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$terms</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">htmlspecialchars</SPAN>(<SPAN style="COLOR: #000000">urldecode</SPAN>(<SPAN style="COLOR: #000000">$query_terms</SPAN>));<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">if</SPAN> (<SPAN style="COLOR: #000000">!</SPAN><SPAN style="COLOR: #000000">seems_utf8</SPAN>(<SPAN style="COLOR: #000000">$terms</SPAN><SPAN style="COLOR: #000000">)){</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$terms</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">iconv</SPAN>(<SPAN style="COLOR: #0000ff">&quot;GBK&quot;</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #0000ff">&quot;UTF-8&quot;</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #000000">$terms</SPAN>);<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">}</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">return</SPAN> <SPAN style="COLOR: #000000">$terms</SPAN>;<BR><SPAN style="COLOR: #000000">}</SPAN><BR><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">function</SPAN> <SPAN style="COLOR: #000000">ls_get_refer</SPAN>() <SPAN style="COLOR: #000000">{</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">if</SPAN> (<SPAN style="COLOR: #000000">!</SPAN><SPAN style="COLOR: #000000">isset</SPAN>(<SPAN style="COLOR: #000000">$_SERVER</SPAN><SPAN style="COLOR: #000000">[</SPAN><SPAN style="COLOR: #0000ff">&#39;HTTP_REFERER&#39;</SPAN><SPAN style="COLOR: #000000">])</SPAN> || (<SPAN style="COLOR: #000000">$_SERVER</SPAN><SPAN style="COLOR: #000000">[</SPAN><SPAN style="COLOR: #0000ff">&#39;HTTP_REFERER&#39;</SPAN><SPAN style="COLOR: #000000">]</SPAN> <SPAN style="COLOR: #000000">==</SPAN> <SPAN style="COLOR: #0000ff">&#39;&#39;</SPAN>)) <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">return</SPAN> <SPAN style="COLOR: #000000">FALSE</SPAN>;<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$referer_info</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">parse_url</SPAN>(<SPAN style="COLOR: #000000">$_SERVER</SPAN><SPAN style="COLOR: #000000">[</SPAN><SPAN style="COLOR: #0000ff">&#39;HTTP_REFERER&#39;</SPAN><SPAN style="COLOR: #000000">]);</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$referer</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">$referer_info</SPAN><SPAN style="COLOR: #000000">[</SPAN><SPAN style="COLOR: #0000ff">&#39;host&#39;</SPAN><SPAN style="COLOR: #000000">];</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">if</SPAN> (<SPAN style="COLOR: #000000">substr</SPAN>(<SPAN style="COLOR: #000000">$referer</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #0000ff">0</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #0000ff">4</SPAN>) <SPAN style="COLOR: #000000">==</SPAN> <SPAN style="COLOR: #0000ff">&#39;www.&#39;</SPAN>)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$referer</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">substr</SPAN>(<SPAN style="COLOR: #000000">$referer</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #0000ff">4</SPAN>);<BR><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">return</SPAN> <SPAN style="COLOR: #000000">$referer</SPAN>;<BR><SPAN style="COLOR: #000000">}</SPAN><BR><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">function</SPAN> <SPAN style="COLOR: #000000">ls_getinfo</SPAN>(<SPAN style="COLOR: #000000">$what</SPAN>) <SPAN style="COLOR: #000000">{</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$referer</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">ls_get_refer</SPAN>();<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">if</SPAN> (<SPAN style="COLOR: #000000">!</SPAN><SPAN style="COLOR: #000000">$referer</SPAN>) <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">return</SPAN> <SPAN style="COLOR: #000000">FALSE</SPAN>;<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$delimiter</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">ls_get_delim</SPAN>(<SPAN style="COLOR: #000000">$referer</SPAN>);<BR><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">if</SPAN> (<SPAN style="COLOR: #000000">$delimiter</SPAN>)<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">{</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$terms</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">ls_get_terms</SPAN>(<SPAN style="COLOR: #000000">$delimiter</SPAN>);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">if</SPAN> (<SPAN style="COLOR: #000000">$what</SPAN> <SPAN style="COLOR: #000000">==</SPAN> <SPAN style="COLOR: #0000ff">&#39;isref&#39;</SPAN>) <SPAN style="COLOR: #000000">{</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">return</SPAN> (<SPAN style="COLOR: #000000">$terms</SPAN> <SPAN style="COLOR: #000000">!=</SPAN> <SPAN style="COLOR: #0000ff">&#39;&#39;</SPAN><SPAN style="COLOR: #000000">?</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">true</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">false</SPAN>);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">}</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">if</SPAN> (<SPAN style="COLOR: #000000">$what</SPAN> <SPAN style="COLOR: #000000">==</SPAN> <SPAN style="COLOR: #0000ff">&#39;referrer&#39;</SPAN>) <SPAN style="COLOR: #000000">{</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$parsed</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">parse_url</SPAN>(<SPAN style="COLOR: #000000">$_SERVER</SPAN><SPAN style="COLOR: #000000">[</SPAN><SPAN style="COLOR: #0000ff">&#39;HTTP_REFERER&#39;</SPAN><SPAN style="COLOR: #000000">]);</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">echo</SPAN> <SPAN style="COLOR: #0000ff">&#39;&lt;a href=&quot;http://&#39;</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">$parsed</SPAN><SPAN style="COLOR: #000000">[</SPAN><SPAN style="COLOR: #0000ff">&#39;host&#39;</SPAN><SPAN style="COLOR: #000000">].</SPAN><SPAN style="COLOR: #0000ff">&#39;&quot;&gt;&#39;</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">$parsed</SPAN><SPAN style="COLOR: #000000">[</SPAN><SPAN style="COLOR: #0000ff">&#39;host&#39;</SPAN><SPAN style="COLOR: #000000">].</SPAN><SPAN style="COLOR: #0000ff">&#39;&lt;/a&gt;&#39;</SPAN>;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">}</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">if</SPAN> (<SPAN style="COLOR: #000000">$what</SPAN> <SPAN style="COLOR: #000000">==</SPAN> <SPAN style="COLOR: #0000ff">&#39;terms&#39;</SPAN>) <SPAN style="COLOR: #000000">{</SPAN> <SPAN style="COLOR: #000000">echo</SPAN> <SPAN style="COLOR: #000000">$terms</SPAN>; <SPAN style="COLOR: #000000">}</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">}</SPAN><BR><SPAN style="COLOR: #000000">}</SPAN><BR><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">function</SPAN>&nbsp; <SPAN style="COLOR: #000000">ls_terms_filter</SPAN>(<SPAN style="COLOR: #000000">$content</SPAN><SPAN style="COLOR: #000000">){</SPAN><BR><SPAN style="COLOR: #000000">$referer</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">ls_get_refer</SPAN>();<BR><SPAN style="COLOR: #000000">$output</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #0000ff">&#39;&#39;</SPAN>;<BR><SPAN style="COLOR: #000000">$delimiter</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">ls_get_delim</SPAN>(<SPAN style="COLOR: #000000">$referer</SPAN>);<BR><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">if</SPAN>(<SPAN style="COLOR: #000000">$delimiter</SPAN>)<BR><SPAN style="COLOR: #000000">{</SPAN><BR><SPAN style="COLOR: #000000">$terms</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">ls_get_terms</SPAN>(<SPAN style="COLOR: #000000">$delimiter</SPAN>);<BR><SPAN style="COLOR: #000000">$terms</SPAN><SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">array_unique</SPAN>(<SPAN style="COLOR: #000000">preg_split</SPAN>(<SPAN style="COLOR: #0000ff">&quot;/[\s,]+/&quot;</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #000000">$terms</SPAN>));<BR><SPAN style="COLOR: #000000">$contentarr</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">preg_split</SPAN>(<SPAN style="COLOR: #0000ff">&quot;/(&lt;.*&gt;)/U&quot;</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #000000">$content</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #0000ff">1</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #000000">PREG_SPLIT_DELIM_CAPTURE</SPAN>);<BR><SPAN style="COLOR: #000000">$stop</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">count</SPAN>(<SPAN style="COLOR: #000000">$contentarr</SPAN>);<BR><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">for</SPAN> (<SPAN style="COLOR: #000000">$i</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #0000ff">0</SPAN>; <SPAN style="COLOR: #000000">$i</SPAN> <SPAN style="COLOR: #000000">&lt;</SPAN> <SPAN style="COLOR: #000000">$stop</SPAN>; <SPAN style="COLOR: #000000">$i</SPAN><SPAN style="COLOR: #000000">++</SPAN>) <SPAN style="COLOR: #000000">{</SPAN><BR><SPAN style="COLOR: #000000">$content</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">$contentarr</SPAN><SPAN style="COLOR: #000000">[</SPAN><SPAN style="COLOR: #000000">$i</SPAN><SPAN style="COLOR: #000000">];</SPAN><BR><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">if</SPAN> ((<SPAN style="COLOR: #000000">strlen</SPAN>(<SPAN style="COLOR: #000000">$content</SPAN>) <SPAN style="COLOR: #000000">&gt;</SPAN> <SPAN style="COLOR: #0000ff">0</SPAN>) <SPAN style="COLOR: #000000">&amp;&amp;</SPAN> (<SPAN style="COLOR: #0000ff">&#39;&lt;&#39;</SPAN> <SPAN style="COLOR: #000000">!=</SPAN> <SPAN style="COLOR: #000000">$content</SPAN><SPAN style="COLOR: #000000">{</SPAN><SPAN style="COLOR: #0000ff">0</SPAN><SPAN style="COLOR: #000000">}))</SPAN> <SPAN style="COLOR: #000000">{</SPAN><BR><SPAN style="COLOR: #000000">foreach</SPAN> (<SPAN style="COLOR: #000000">$terms</SPAN> <SPAN style="COLOR: #000000">as</SPAN> <SPAN style="COLOR: #000000">$term</SPAN>) <SPAN style="COLOR: #000000">{</SPAN><BR><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">if</SPAN> (<SPAN style="COLOR: #000000">strlen</SPAN>(<SPAN style="COLOR: #000000">$term</SPAN>)<SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #0000ff">1</SPAN>)<BR><SPAN style="COLOR: #000000">$content</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">eregi_replace</SPAN>(<SPAN style="COLOR: #0000ff">&quot;($term)&quot;</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #0000ff">&quot;&lt;b style=&#39;background:#ffff00;&#39;&gt;\\1&lt;/b&gt;&quot;</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #000000">$content</SPAN>);<BR><SPAN style="COLOR: #000000">}</SPAN><BR><SPAN style="COLOR: #000000">}</SPAN><BR><SPAN style="COLOR: #000000">$output</SPAN> <SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">$content</SPAN>;<BR><SPAN style="COLOR: #000000">}</SPAN><BR><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">return</SPAN> <SPAN style="COLOR: #000000">$output</SPAN>;<BR><SPAN style="COLOR: #000000">}</SPAN> <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">else</SPAN><SPAN style="COLOR: #000000">{</SPAN><BR><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">return</SPAN> <SPAN style="COLOR: #000000">$content</SPAN>;<BR><SPAN style="COLOR: #000000">}</SPAN><BR><SPAN style="COLOR: #000000">}</SPAN><BR><SPAN style="COLOR: #000000">add_filter</SPAN>(<SPAN style="COLOR: #0000ff">&#39;the_content&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #0000ff">&#39;ls_terms_filter&#39;</SPAN>);<BR><SPAN style="COLOR: #000000">add_filter</SPAN>(<SPAN style="COLOR: #0000ff">&#39;comment_text&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #0000ff">&#39;ls_terms_filter&#39;</SPAN>);<BR><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">function</SPAN> <SPAN style="COLOR: #000000">ls_set_header</SPAN>() <SPAN style="COLOR: #000000">{</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">if</SPAN> (<SPAN style="COLOR: #000000">ls_getinfo</SPAN>(<SPAN style="COLOR: #0000ff">&#39;isref&#39;</SPAN>)) <SPAN style="COLOR: #000000">header</SPAN>(<SPAN style="COLOR: #0000ff">&#39;Vary: Referer&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #000000">FALSE</SPAN>);<BR><SPAN style="COLOR: #000000">}</SPAN><BR><SPAN style="COLOR: #000000">add_action</SPAN>(<SPAN style="COLOR: #0000ff">&#39;init&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #0000ff">&#39;ls_set_header&#39;</SPAN>);<BR></DIV></p>
<p>　　可以看到在搜索引擎的数组中，我加入了 google.com.hk、百度、有道、必应等适合中国网民的搜索引擎，当然你也可以按照这样的格式再添加几个。</p>
<p>　　二、是 HTML 和调用以上函数的部分，可以放在任何地方，个人建议放在 footer.php 中，最后用样式定一下位嘛就可以了：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #008080;">&lt;?php</span> <span style="color: #000080; font-weight: bold;">if</span> (<span style="color: #000000;">ls_getinfo</span>(<span style="color: #0000ff;">'isref'</span>)) <span style="color: #000000;">:</span> <span style="color: #008080;">?&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;div</span> <span style="color: #ff0000;">id=</span><span style="color: #0000ff;">'hellobaby'</span><span style="color: #000080; font-weight: bold;">&gt;</span><span style="color: #000000;">欢迎来自 </span><span style="color: #008080;">&lt;?php</span> <span style="color: #000000;">ls_getinfo</span>(<span style="color: #0000ff;">'referrer'</span>); <span style="color: #008080;">?&gt;</span><span style="color: #000000;"> 的朋友！</span><span style="color: #000080; font-weight: bold;">&lt;br</span> <span style="color: #000080; font-weight: bold;">/&gt;</span><span style="color: #000000;">推荐您 </span><span style="color: #000080; font-weight: bold;">&lt;b&gt;&lt;a</span> <span style="color: #ff0000;">href=</span><span style="color: #0000ff;">'http://feed.wange.im'</span> <span style="color: #ff0000;">target=</span><span style="color: #0000ff;">'_blank'</span><span style="color: #000080; font-weight: bold;">&gt;</span><span style="color: #000000;">点击这里</span><span style="color: #000080; font-weight: bold;">&lt;/a&gt;&lt;/b&gt;</span><span style="color: #000000;"> 订阅我的博客 o(∩_∩)o</span><br />
<span style="color: #000080; font-weight: bold;">&lt;div</span> <span style="color: #ff0000;">class=</span><span style="color: #0000ff;">"closebox"</span><span style="color: #000080; font-weight: bold;">&gt;&lt;a</span> <span style="color: #ff0000;">href=</span><span style="color: #0000ff;">"javascript:void(0)"</span> <span style="color: #ff0000;">onclick=</span><span style="color: #0000ff;">"$('#hellobaby').slideUp('slow');$('.closebox').css('display','none');"</span> <span style="color: #ff0000;">title=</span><span style="color: #0000ff;">"关闭"</span><span style="color: #000080; font-weight: bold;">&gt;</span><span style="color: #000000;">×</span><span style="color: #000080; font-weight: bold;">&lt;/a&gt;&lt;/div&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;/div&gt;</span><br />
<span style="color: #008080;">&lt;?php</span> <span style="color: #000080; font-weight: bold;">endif</span>; <span style="color: #008080;">?&gt;</span></div>
<p>　　三、最后是样式部分，这个各位可以发挥各自所长，下面我就提供一下我的样式表，仅供参考：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000000;">#hellobaby</span> <span style="color: #000000;">{</span><br />
    <span style="color: #000080; font-weight: bold;">background</span><span style="color: #000000;">:</span><span style="color: #0000ff;">#000000</span>;<br />
    <span style="color: #000080; font-weight: bold;">border</span><span style="color: #000000;">:</span><span style="color: #0000ff;">1px</span> <span style="color: #000080; font-weight: bold;">solid</span> <span style="color: #0000ff;">#B3B3B3</span>;<br />
    <span style="color: #000080; font-weight: bold;">color</span><span style="color: #000000;">:</span><span style="color: #0000ff;">#FFFFFF</span>;<br />
    <span style="color: #000080; font-weight: bold;">font-size</span><span style="color: #000000;">:</span><span style="color: #0000ff;">14px</span>;<br />
    <span style="color: #000080; font-weight: bold;">opacity</span><span style="color: #000000;">:</span><span style="color: #0000ff;">0</span><span style="color: #000000;">.</span><span style="color: #0000ff;">7</span>;<br />
    <span style="color: #000000;">filter</span><span style="color: #000000;">:</span><span style="color: #000000;">alpha</span>(<span style="color: #000080; font-weight: bold;">opacity</span><span style="color: #000000;">=</span><span style="color: #0000ff;">70</span>);<br />
    <span style="color: #000080; font-weight: bold;">padding</span><span style="color: #000000;">:</span><span style="color: #0000ff;">10px</span>;<br />
    <span style="color: #000080; font-weight: bold;">position</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">absolute</span>;<br />
    <span style="color: #000080; font-weight: bold;">right</span><span style="color: #000000;">:</span><span style="color: #0000ff;">0</span>;<br />
    <span style="color: #000080; font-weight: bold;">top</span><span style="color: #000000;">:</span><span style="color: #0000ff;">250px</span>;<br />
<span style="color: #000000;">}</span></div>
<p>　　写到这里，功能上已经实现了，剩下的就是美化工作，最后的最后，你也可以像我这样，给旁边的欢迎提示词用 JQuery 加一个滑动效果，那就更炫了，不过因为篇幅有限，我这里就不多介绍了。</p>
<p>　　最后的最后的最后，还要感谢 http://www.chinawp.com/2009/10/106/ 此文，给了我很大的帮助，本文的灵感就来源于此。</p>
<div style='background:#EFEFEF;border:1px dashed #CCC;color:#777;margin:5px 0;padding:5px 10px;-moz-border-radius:10px 0;-webkit-border-top-left-radius:10px;-webkit-border-top-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:10px;border-radius:10px 0;'><div>&raquo; 转载请注明来源：<a title="Life Studio" href="http://wange.im/">Life Studio</a> &raquo; <a rel="bookmark" title="Wordpress 高亮显示关键词及欢迎提示" href="http://wange.im/highlight-keywords-and-hellobaby-in-wordpress.html">《Wordpress 高亮显示关键词及欢迎提示》</a></div><div>&raquo; 本文链接地址：<a rel="bookmark" title="Wordpress 高亮显示关键词及欢迎提示" href="http://wange.im/highlight-keywords-and-hellobaby-in-wordpress.html">http://wange.im/highlight-keywords-and-hellobaby-in-wordpress.html</a></div><div>&raquo; 订阅本站：<a title="Life Studio" target="_blank" href="http://feed.wange.im">http://feed.wange.im</a></div></div><h3>相关日志</h3><ul class="st-related-posts"><li><a href="http://wange.im/highlight-keywords-in-wordpress-search.html" title="Wordpress 站内搜索高亮显示关键词 (2010年07月18日)">Wordpress 站内搜索高亮显示关键词</a> (119)</li><li><a href="http://wange.im/wordpress-say-hello-to-vistors.html" title="Wordpress 向来自其他域的访客致欢迎词 (2010年07月30日)">Wordpress 向来自其他域的访客致欢迎词</a> (175)</li><li><a href="http://wange.im/output-twitter-to-wordpress-revision.html" title="Wordpress 非插件调用 Twitter 修订版 (2010年06月28日)">Wordpress 非插件调用 Twitter 修订版</a> (147)</li><li><a href="http://wange.im/pagenavi-without-plugins-in-wordpress.html" title="Wordpress 非插件日志分页效果 (2010年05月27日)">Wordpress 非插件日志分页效果</a> (121)</li><li><a href="http://wange.im/share-to-sns-without-plugins-for-wordpress.html" title="Wordpress 非插件实现分享按钮 (2010年05月19日)">Wordpress 非插件实现分享按钮</a> (168)</li><li><a href="http://wange.im/related-posts-with-thumbs-for-wordpress.html" title="Wordpress 免插件实现图片相关日志 (2010年05月4日)">Wordpress 免插件实现图片相关日志</a> (98)</li><li><a href="http://wange.im/wordpress-ip-statistics-without-plugins.html" title="Wordpress 非插件统计网站访问信息 (2010年04月10日)">Wordpress 非插件统计网站访问信息</a> (115)</li><li><a href="http://wange.im/related-posts-without-plugins-in-wordpress.html" title="Wordpress 非插件相关日志的两种方法 (2010年04月4日)">Wordpress 非插件相关日志的两种方法</a> (134)</li><li><a href="http://wange.im/sync-wordpress-to-twitter.html" title="非插件同步 Wordpress 日志到 Twitter (2010年04月1日)">非插件同步 Wordpress 日志到 Twitter</a> (113)</li><li><a href="http://wange.im/wordpress-statistics-without-plugins.html" title="Wordpress 非插件统计网站信息 (2010年03月20日)">Wordpress 非插件统计网站信息</a> (102)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://wange.im/highlight-keywords-and-hellobaby-in-wordpress.html/feed</wfw:commentRss>
		<slash:comments>180</slash:comments>
		</item>
		<item>
		<title>一句话实现双击滚屏效果</title>
		<link>http://wange.im/scroll-for-double-click.html</link>
		<comments>http://wange.im/scroll-for-double-click.html#comments</comments>
		<pubDate>Thu, 15 Jul 2010 12:15:19 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://wange.im/?p=3492</guid>
		<description><![CDATA[　　双击滚屏的效果大家应该都见过吧，特别是在一些在线电子书的网站上，为了方便读者，都加上了双击鼠标自动滚屏的效果，单击鼠标则停止滚动，这应该也算是一种访客体验吧。包括我们最常见的百度百科，它也是用了双击自动滚屏的效果，可见这个效果比较适合于文字较多的网站，可便于阅读，省得滚动鼠标了。
　　鉴于本站取消了 Wordpress 的评论分页后，这评论数量一下子显的就多了起来，这也是为了方便童鞋们看之前的留言嘛，不过这样一来页面也就被拉长了，怕童鞋们把鼠标滚轮滚坏了来找我赔，所以我也就D调加上了这双击滚屏的效果。很快就被细心的木木小盆友发现了，于是就分享探讨了一下啦。
　　实现页面双击鼠标自动滚屏的效果无非是用 Javascript 脚本咯，这是大多数网站的作法，包括百度百科的，不过我对代码的要求是少而精，只要能实现同样的效果就行。于是我就找到了这么一段，应该说是一句代码，只要将其放在头部的 body 标签里就可以实现全站的双击自动滚屏的效果。
&#60;body onDblClick="s=setInterval('scrollBy(0,2)',50)" onMousedown="clearInterval(s)" onload="s=0;"&#62;
　　这样就 OK 了，这句代码不仅短小，更难能可贵的是，它还支持 Firefox、IE、Safari、Opera、Chrome 等所有主流浏览器，现在这年头测试网站能不用担心兼容还真是一件稀奇事呀，可喜可贺。说到这里，你可以双击一下页面试试，在本版面的任何一个角落双击鼠标都可以实现自动滚屏，单击鼠标左键则停止。
　　说到这里还没完，木木又问了一个问题，如何排除某区域的双击事件？呃。。。对，想起来了，木木也是比较能折腾的主，他用 JQuery 实现了双击回复评论的功能，所以如果在他的评论区域双击的话就可能冲突了，同一个双击事件，到底是滚屏还是回复评论呢？我捉摸着，既然双击滚屏的代码可以放在 body 标签里，那么能不能放在普通的 div 标签里呢？如果可以的话，那不就有办法排除掉评论区域了嘛。后来在本地测试了一下，还真行耶～这里就提供这么一个思路，就不再写代码了，原理和加在 body 中的一样，懂的朋友应该懂了。
　　话又说回来了，一句话的代码实现的滚屏效果毕竟不如百度百科那样大段的 Javascript 脚本实现的完美，页面往下滚动的时候可以发现细微的抖动，不是很平滑，几经调试才选择了以上代码中感觉最为合适的参数，将就着看还是可以接受的。
　　写完才发现原来自己这么话唠，不就一句代码嘛，居然写了这么一长串……
&#187; 转载请注明来源：Life Studio &#187; 《一句话实现双击滚屏效果》&#187; 本文链接地址：http://wange.im/scroll-for-double-click.html&#187; 订阅本站：http://feed.wange.im相关日志JQuery 鼠标滑动渐隐渐显效果 (80)Google 短网址服务 goo.gl shortener (120)JQuery 鼠标提示特效之 Sweet Titles (88)HTML 转换到 Javascript（附源码） (45)]]></description>
			<content:encoded><![CDATA[<p>　　双击滚屏的效果大家应该都见过吧，特别是在一些在线电子书的网站上，为了方便读者，都加上了双击鼠标自动滚屏的效果，单击鼠标则停止滚动，这应该也算是一种访客体验吧。包括我们最常见的百度百科，它也是用了双击自动滚屏的效果，可见这个效果比较适合于文字较多的网站，可便于阅读，省得滚动鼠标了。</p>
<p>　　鉴于本站<a title="Wordpress 不同页面不同评论分页功能" href="http://wange.im/per-page-of-wp-list-comments-in-wordpress.html">取消了 Wordpress 的评论分页</a>后，这评论数量一下子显的就多了起来，这也是为了方便童鞋们看之前的留言嘛，不过这样一来页面也就被拉长了，怕童鞋们把鼠标滚轮滚坏了来找我赔，所以我也就D调加上了这双击滚屏的效果。很快就被细心的<a title="木木木木木" rel="external nofollow" href="http://immmmm.com/" target="_blank">木木</a>小盆友发现了，于是就分享探讨了一下啦。</p>
<p>　　实现页面双击鼠标自动滚屏的效果无非是用 Javascript 脚本咯，这是大多数网站的作法，包括百度百科的，不过我对代码的要求是少而精，只要能实现同样的效果就行。于是我就找到了这么一段，应该说是一句代码，只要将其放在头部的 body 标签里就可以实现全站的双击自动滚屏的效果。</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;body</span> <span style="color: #ff0000;">onDblClick=</span><span style="color: #0000ff;">"s=setInterval('scrollBy(0,2)',50)"</span> <span style="color: #ff0000;">onMousedown=</span><span style="color: #0000ff;">"clearInterval(s)"</span> <span style="color: #ff0000;">onload=</span><span style="color: #0000ff;">"s=0;"</span><span style="color: #000080; font-weight: bold;">&gt;</span></div>
<p>　　这样就 OK 了，这句代码不仅短小，更难能可贵的是，它还支持 Firefox、IE、Safari、Opera、Chrome 等所有主流浏览器，现在这年头测试网站能不用担心兼容还真是一件稀奇事呀，可喜可贺。说到这里，你可以双击一下页面试试，在本版面的任何一个角落双击鼠标都可以实现自动滚屏，单击鼠标左键则停止。</p>
<p>　　说到这里还没完，木木又问了一个问题，如何排除某区域的双击事件？呃。。。对，想起来了，木木也是比较能折腾的主，他<a title="[jQuery] 新评论双击再修改" rel="external nofollow" href="http://immmmm.com/double-click-rapid-changes-new-comment.html" target="_blank">用 JQuery 实现了双击回复评论的功能</a>，所以如果在他的评论区域双击的话就可能冲突了，同一个双击事件，到底是滚屏还是回复评论呢？我捉摸着，既然双击滚屏的代码可以放在 body 标签里，那么能不能放在普通的 div 标签里呢？如果可以的话，那不就有办法排除掉评论区域了嘛。后来在本地测试了一下，还真行耶～这里就提供这么一个思路，就不再写代码了，原理和加在 body 中的一样，懂的朋友应该懂了。</p>
<p>　　话又说回来了，一句话的代码实现的滚屏效果毕竟不如百度百科那样大段的 Javascript 脚本实现的完美，页面往下滚动的时候可以发现细微的抖动，不是很平滑，几经调试才选择了以上代码中感觉最为合适的参数，将就着看还是可以接受的。</p>
<p>　　写完才发现原来自己这么话唠，不就一句代码嘛，居然写了这么一长串……</p>
<div style='background:#EFEFEF;border:1px dashed #CCC;color:#777;margin:5px 0;padding:5px 10px;-moz-border-radius:10px 0;-webkit-border-top-left-radius:10px;-webkit-border-top-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:10px;border-radius:10px 0;'><div>&raquo; 转载请注明来源：<a title="Life Studio" href="http://wange.im/">Life Studio</a> &raquo; <a rel="bookmark" title="一句话实现双击滚屏效果" href="http://wange.im/scroll-for-double-click.html">《一句话实现双击滚屏效果》</a></div><div>&raquo; 本文链接地址：<a rel="bookmark" title="一句话实现双击滚屏效果" href="http://wange.im/scroll-for-double-click.html">http://wange.im/scroll-for-double-click.html</a></div><div>&raquo; 订阅本站：<a title="Life Studio" target="_blank" href="http://feed.wange.im">http://feed.wange.im</a></div></div><h3>相关日志</h3><ul class="st-related-posts"><li><a href="http://wange.im/fadein-and-fadeout-with-jquery.html" title="JQuery 鼠标滑动渐隐渐显效果 (2010年05月5日)">JQuery 鼠标滑动渐隐渐显效果</a> (80)</li><li><a href="http://wange.im/google-url-shortener.html" title="Google 短网址服务 goo.gl shortener (2010年03月21日)">Google 短网址服务 goo.gl shortener</a> (120)</li><li><a href="http://wange.im/jquery-sweet-titles-tooltips.html" title="JQuery 鼠标提示特效之 Sweet Titles (2010年03月14日)">JQuery 鼠标提示特效之 Sweet Titles</a> (88)</li><li><a href="http://wange.im/html-to-javascript.html" title="HTML 转换到 Javascript（附源码） (2010年03月11日)">HTML 转换到 Javascript（附源码）</a> (45)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://wange.im/scroll-for-double-click.html/feed</wfw:commentRss>
		<slash:comments>148</slash:comments>
		</item>
		<item>
		<title>Wordpress 实现“您的足迹”功能</title>
		<link>http://wange.im/show-your-recent-comments-in-wordpress.html</link>
		<comments>http://wange.im/show-your-recent-comments-in-wordpress.html#comments</comments>
		<pubDate>Mon, 12 Jul 2010 12:03:45 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[留言]]></category>

		<guid isPermaLink="false">http://wange.im/?p=3471</guid>
		<description><![CDATA[　　今天手贱，又小小地折腾了一下 Wordpress，我也不知道该怎么描述这个功能，可能标题让你有点晕，我们还是先看效果吧。如果是之前留过言的访客，请看内页侧边栏，我新添加了一个“您的足迹”，可以看到，这里列出了留言访客的最近10条评论，当然，只能看到你自己的最近10条评论，原理就是调用记录在你浏览器中的 Cookies，如果你是第一次来访，或者刚刚清空了浏览器的缓存，那就看不到“您的足迹”这个板块了。
　　这其实就是一个最新评论功能的修改版，最新评论中指定隐藏管理员评论，而在“您的足迹”中正好是相对的，要指定显示某一个访客的评论，这里的访客就是指当前浏览器 Cookies 中记录的上一次评论者的信息。明白了原理，实现这个功能也就不难了，在最新评论代码的基础上，把 Cookies 中的访客信息作为变量传递给 comment_author 这个字段就可以了。
　　把以下代码复制到 Wordpress 主题文件中需要的地方，比如说 sidebar.php：
&#60;?php
    if($_COOKIE["comment_author_" . COOKIEHASH]!=""){
        global $wpdb;
        $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_author_email, comment_type, comment_author_url, SUBSTRING(comment_content,1,25) AS com_excerpt FROM $wpdb-&#62;comments LEFT OUTER JOIN $wpdb-&#62;posts ON ($wpdb-&#62;comments.comment_post_ID = $wpdb-&#62;posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND comment_author [...]]]></description>
			<content:encoded><![CDATA[<p>　　今天手贱，又小小地折腾了一下 Wordpress，我也不知道该怎么描述这个功能，可能标题让你有点晕，我们还是先看效果吧。如果是之前留过言的访客，请看内页侧边栏，我新添加了一个“您的足迹”，可以看到，这里列出了留言访客的最近10条评论，当然，只能看到你自己的最近10条评论，原理就是调用记录在你浏览器中的 Cookies，如果你是第一次来访，或者刚刚清空了浏览器的缓存，那就看不到“您的足迹”这个板块了。</p>
<p>　　这其实就是一个最新评论功能的修改版，<a title="Wordpress 隐藏博主的最新留言" href="http://wange.im/hide-recent-author-comment-in-wordpress.html">最新评论中指定隐藏管理员评论</a>，而在“您的足迹”中正好是相对的，要指定显示某一个访客的评论，这里的访客就是指当前浏览器 Cookies 中记录的上一次评论者的信息。明白了原理，实现这个功能也就不难了，在最新评论代码的基础上，把 Cookies 中的访客信息作为变量传递给 comment_author 这个字段就可以了。</p>
<p>　　把以下代码复制到 Wordpress 主题文件中需要的地方，比如说 sidebar.php：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #008080;">&lt;?php</span><br />
    <span style="color: #000080; font-weight: bold;">if</span>(<span style="color: #000000;">$_COOKIE</span><span style="color: #000000;">[</span><span style="color: #0000ff;">"comment_author_"</span> <span style="color: #000000;">.</span> <span style="color: #000000;">COOKIEHASH</span><span style="color: #000000;">]</span><span style="color: #000000;">!=</span><span style="color: #0000ff;">""</span><span style="color: #000000;">){</span><br />
        <span style="color: #000080; font-weight: bold;">global</span> <span style="color: #000000;">$wpdb</span>;<br />
        <span style="color: #000000;">$sql</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">"SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_author_email, comment_type, comment_author_url, SUBSTRING(comment_content,1,25) AS com_excerpt FROM </span><span style="color: #0000ff;">$wpdb-&gt;comments</span><span style="color: #0000ff;"> LEFT OUTER JOIN </span><span style="color: #0000ff;">$wpdb-&gt;posts</span><span style="color: #0000ff;"> ON (</span><span style="color: #0000ff;">$wpdb-&gt;comments</span><span style="color: #0000ff;">.comment_post_ID = </span><span style="color: #0000ff;">$wpdb-&gt;posts</span><span style="color: #0000ff;">.ID) WHERE comment_approved = '1' AND comment_type = '' AND comment_author = '"</span><span style="color: #000000;">.</span><span style="color: #000000;">$_COOKIE</span><span style="color: #000000;">[</span><span style="color: #0000ff;">"comment_author_"</span> <span style="color: #000000;">.</span> <span style="color: #000000;">COOKIEHASH</span><span style="color: #000000;">]</span><span style="color: #000000;">.</span><span style="color: #0000ff;">"' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT 10"</span>;<br />
        <span style="color: #000000;">$comments</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$wpdb</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">get_results</span>(<span style="color: #000000;">$sql</span>);<br />
        <span style="color: #000080; font-weight: bold;">foreach</span> (<span style="color: #000000;">$comments</span> <span style="color: #000080; font-weight: bold;">as</span> <span style="color: #000000;">$comment</span>) <span style="color: #000000;">{</span><br />
            <span style="color: #000000;">$output</span> <span style="color: #000000;">.=</span> <span style="color: #0000ff;">"</span><span style="color: #0000ff;">\n</span><span style="color: #0000ff;">&lt;li&gt;&lt;a href=</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">"</span> <span style="color: #000000;">.</span><span style="color: #000000;">get_permalink</span>(<span style="color: #000000;">$comment</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">ID</span>)<span style="color: #000000;">.</span><span style="color: #0000ff;">"#comment-"</span><span style="color: #000000;">.</span><span style="color: #000000;">$comment</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">comment_ID</span><span style="color: #000000;">.</span> <span style="color: #0000ff;">"</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;"> title=</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">"</span> <span style="color: #000000;">.</span> <span style="color: #000000;">$comment</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">post_title</span> <span style="color: #000000;">.</span> <span style="color: #0000ff;">" 上的评论</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">&gt;"</span><span style="color: #000000;">.</span><span style="color: #000000;">strip_tags</span>(<span style="color: #000000;">$comment</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">comment_author</span>)<span style="color: #000000;">.</span><span style="color: #0000ff;">"： "</span><span style="color: #000000;">.</span> <span style="color: #000000;">strip_tags</span>(<span style="color: #000000;">$comment</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">com_excerpt</span>) <span style="color: #000000;">.</span><span style="color: #0000ff;">"&lt;/a&gt;&lt;/li&gt;"</span>;<br />
        <span style="color: #000000;">}</span><br />
        <span style="color: #000000;">$output</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">'&lt;h3&gt;您的足迹&lt;/h3&gt;&lt;ul&gt;'</span><span style="color: #000000;">.</span><span style="color: #000000;">$output</span><span style="color: #000000;">.</span><span style="color: #0000ff;">'&lt;/ul&gt;'</span>;<br />
        <span style="color: #000000;">$output</span> <span style="color: #000000;">=</span> <span style="color: #000000;">convert_smilies</span>(<span style="color: #000000;">$output</span>);<br />
        <span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #000000;">$output</span>;<br />
    <span style="color: #000000;">}</span><br />
<span style="color: #008080;">?&gt;</span></div>
<p>　　因为我水平有限，就不一一解释以上代码的意思了，怕误导大家，另外样式表我也不提供了，每个主题的样式都各不相同，这个大家自由发挥吧。如果你嫌以上代码太累赘，可以把代码封装起来放在 Wordpress 主题的 functions.php 里，然后在需要的地方调用，这个扩展也不在本文讨论范围。</p>
<p>　　下面给第一次来访而看不到效果的朋友截了一张图，也欢迎新来的朋友踊跃留言测试呀～<br />
<img src="http://storage.live.com/items/C3C8B704573706D9!563?filename=zuji.jpg" alt="" /></p>
<div style='background:#EFEFEF;border:1px dashed #CCC;color:#777;margin:5px 0;padding:5px 10px;-moz-border-radius:10px 0;-webkit-border-top-left-radius:10px;-webkit-border-top-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:10px;border-radius:10px 0;'><div>&raquo; 转载请注明来源：<a title="Life Studio" href="http://wange.im/">Life Studio</a> &raquo; <a rel="bookmark" title="Wordpress 实现“您的足迹”功能" href="http://wange.im/show-your-recent-comments-in-wordpress.html">《Wordpress 实现“您的足迹”功能》</a></div><div>&raquo; 本文链接地址：<a rel="bookmark" title="Wordpress 实现“您的足迹”功能" href="http://wange.im/show-your-recent-comments-in-wordpress.html">http://wange.im/show-your-recent-comments-in-wordpress.html</a></div><div>&raquo; 订阅本站：<a title="Life Studio" target="_blank" href="http://feed.wange.im">http://feed.wange.im</a></div></div><h3>相关日志</h3><ul class="st-related-posts"><li><a href="http://wange.im/comment-count-in-wordpress-with-jquery.html" title="Jquery 实现 Wordpress 评论字数计数 (2010年07月27日)">Jquery 实现 Wordpress 评论字数计数</a> (145)</li><li><a href="http://wange.im/wordpress-shows-the-number-of-recent-comments.html" title="WordPress 显示访客最近评论次数 (2010年07月20日)">WordPress 显示访客最近评论次数</a> (198)</li><li><a href="http://wange.im/remove-comments-url-in-wordpress.html" title="Wordpress 去掉评论中链接的方法 (2010年07月8日)">Wordpress 去掉评论中链接的方法</a> (172)</li><li><a href="http://wange.im/replace-comment-text-in-wordpress.html" title="过滤并替换 Wordpress 留言指定字符 (2010年07月5日)">过滤并替换 Wordpress 留言指定字符</a> (242)</li><li><a href="http://wange.im/no-admin-comments-in-wordpress.html" title="Wordpress 统计排除管理员的评论数 (2010年06月18日)">Wordpress 统计排除管理员的评论数</a> (146)</li><li><a href="http://wange.im/per-page-of-wp-list-comments-in-wordpress.html" title="Wordpress 不同页面不同评论分页功能 (2010年06月16日)">Wordpress 不同页面不同评论分页功能</a> (133)</li><li><a href="http://wange.im/paginate-comments-in-wordpress.html" title="Wordpress 指定页面评论分页功能 (2010年06月13日)">Wordpress 指定页面评论分页功能</a> (140)</li><li><a href="http://wange.im/commenter-gravatar-in-wordpress.html" title="Wordpress 记录评论者 gravatar 头像 (2010年05月18日)">Wordpress 记录评论者 gravatar 头像</a> (154)</li><li><a href="http://wange.im/show-time-since-in-wordpress.html" title="Wordpress 显示发布内容于多少时间前 (2010年02月17日)">Wordpress 显示发布内容于多少时间前</a> (79)</li><li><a href="http://wange.im/comments-notification-failure.html" title="关于本站评论邮件通知部分失效 (2010年02月3日)">关于本站评论邮件通知部分失效</a> (173)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://wange.im/show-your-recent-comments-in-wordpress.html/feed</wfw:commentRss>
		<slash:comments>262</slash:comments>
		</item>
		<item>
		<title>获取 Live Skydrive 的真实地址</title>
		<link>http://wange.im/real-url-in-skydrive.html</link>
		<comments>http://wange.im/real-url-in-skydrive.html#comments</comments>
		<pubDate>Sun, 11 Jul 2010 13:38:14 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[精品推荐]]></category>
		<category><![CDATA[skydrive]]></category>
		<category><![CDATA[图片]]></category>

		<guid isPermaLink="false">http://wange.im/?p=3465</guid>
		<description><![CDATA[　　我们都知道，国外网站好的服务大多惨遭不幸，国内网站就没有什么出彩的服务可以和国外同类网站相比，就算偶尔冒出两个也维持不了多久，等翅膀长硬了，于是就纷纷搞收费服务，或者变向甚至不加掩饰地压缩用户现有的空间或者服务产品等。比如说自以为土皇帝的网易就这么干过，曾经应允了永久免费且支持外链的网易相册，在一夜之间，没有任何通知的情况下，就压缩了我所有高清的照片，分辨率和原图像素、大小都被大大压缩，这是何等的卑劣！所以之后我就毅然地放弃了网易相册，国内网站一般黑，我一刻也呆不下去了，之后我就选择了可靠的微软的服务，也就是现在的 Live Skydrive 作为图床。
　　为了不给服务器造成太大的压力，相信很多朋友都把图片和多媒体等比较大的文件放在第三方的服务器上，比如说 dropbox、skydrive 等，不过就如同之前所说的，国外很多优秀的网络服务都被墙奸了，现在稳定且还未被墙的第三方存储服务就要算 Skydrive 比较知名的了，我现在博客上的所有外链图片都是存放在 Skydrive 上的，比较满意。
　　不过用久了 Skydrive 就会发现一个问题，其外链地址是会改变的，这个让人比较囧，以至于上次发布了一本 w3school 离线版电子书教程的下载点，这本电子书存放在了 Skydrive 上，然后三天两头有人来提醒我说链接地址无效，我还经常去更新一下呢。知道 Skydrive 有这个问题（不知道是 bug？还是微软故意为之），但是一直不知道怎么解决。
　　那天看到灰狼兄的一篇文章，才恍然大悟，原来这是有解决办法的，是任平生大哥的杰作，严重怀疑任兄是微软的内部工作人员，居然能开发出 Live 服务这么多好的优化产品，我们是受益匪浅啊。以下就记录一下如何获取 Live Skydrive 外链的真实不变的地址。
　　在 Skydrive 登陆后，选择需要得到外链的文件页面，在浏览器的地址栏里粘贴以下代码：
javascript:var%20n=document.title.replace('%20-%20Windows%20Live','');var%20id=((location.hash=='')?window.selfPageData.currentItemHash:location.hash).replace('#resId/','');var%20u='http://storage.live.com/items/'+id+'?filename='+encodeURI(n);var%20p='http://'+document.location.host+'/redir.aspx?page=self&#38;resId='+id;var%20e='&#60;input%20onmouseover=%22this.select();%22%20onclick=%22this.select();%22%20value=%22';var%20f='%22%20style=%22width:580px%22%20type=%22text%22%20/&#62;&#60;br&#62;';var%20d='by%20(&#60;a%20href=%22http://rpsh.net/%22&#62;Rpsh&#60;/a&#62;)';var%20c='\u5916\u94FE\u5730\u5740:'+d+e+u+f+'\u5206\u4EAB\u5730\u5740:'+e+p+f;var%20a=document.getElementById('content');var%20g=(a.getElementsByTagName('p')[0]);var%20b=g?g:document.createElement('P');b.innerHTML=c;a.insertBefore(b,a.firstChild);void(0)
　　此时会得到一个形如：http://storage.live.com/items/……这样的地址，这才是上传文件真正的、不变的、唯一的外链地址，很明显，这比原来那又臭又长的 URL 要干净清爽很多。如下图：

　　这张截图我就用了这唯一外链地址，另外我还想作个小测试，因为 Skydrive 的外链在某些网络下被墙的，比如在我学校的校园网内就无法看到在 Skydrive 上的外链图片，老七也是经常吼着看不到我的图，不知道现在换了新的不变的外链地址能不能看到这图呢？我明天去学校测试看看，也请大家帮忙测试啊，特别是七叔，能不能看到上面这张图？如果能看到的话就太好了，一下子解决了我两个问题。
　　参考自：http://rpsh.net/archives/get-direct-url-of-files-on-live-skydrive/
&#187; 转载请注明来源：Life Studio &#187; 《获取 Live Skydrive 的真实地址》&#187; 本文链接地址：http://wange.im/real-url-in-skydrive.html&#187; 订阅本站：http://feed.wange.im相关日志Wordpress 免插件实现图片相关日志 (98)利用 JQuery 实现图片显隐特效 (119)非插件 Wordpress 标题个性化字体图片 (51)招、招、招广告啦～～～ (145)JQuery 实现带滑动层的图片展示效果 (76)JS 实现放大镜产品展示效果（三） (142)将 Wordpress [...]]]></description>
			<content:encoded><![CDATA[<p>　　我们都知道，国外网站好的服务大多惨遭不幸，国内网站就没有什么出彩的服务可以和国外同类网站相比，就算偶尔冒出两个也维持不了多久，等翅膀长硬了，于是就纷纷搞收费服务，或者变向甚至不加掩饰地压缩用户现有的空间或者服务产品等。比如说自以为土皇帝的网易就这么干过，曾经应允了永久免费且支持外链的网易相册，在一夜之间，没有任何通知的情况下，就压缩了我所有高清的照片，分辨率和原图像素、大小都被大大压缩，这是何等的卑劣！所以之后我就毅然地放弃了网易相册，国内网站一般黑，我一刻也呆不下去了，之后我就选择了可靠的微软的服务，也就是现在的 Live Skydrive 作为图床。</p>
<p>　　为了不给服务器造成太大的压力，相信很多朋友都把图片和多媒体等比较大的文件放在第三方的服务器上，比如说 dropbox、skydrive 等，不过就如同之前所说的，国外很多优秀的网络服务都被墙奸了，现在稳定且还未被墙的第三方存储服务就要算 Skydrive 比较知名的了，我现在博客上的所有外链图片都是存放在 Skydrive 上的，比较满意。</p>
<p>　　不过用久了 Skydrive 就会发现一个问题，其外链地址是会改变的，这个让人比较囧，以至于上次发布了一本 <a title="w3school 离线版电子书教程下载" href="http://wange.im/w3school-ebook.html">w3school 离线版电子书教程</a>的下载点，这本电子书存放在了 Skydrive 上，然后三天两头有人来提醒我说链接地址无效，我还经常去更新一下呢。知道 Skydrive 有这个问题（不知道是 bug？还是微软故意为之），但是一直不知道怎么解决。</p>
<p>　　那天看到<a title="获取Skydrive的真实地址" href="http://www.itlobo.com/articles/1390.html" target="_blank">灰狼兄的一篇文章</a>，才恍然大悟，原来这是有解决办法的，是<a title="任平生" href="http://rpsh.net" target="_blank">任平生</a>大哥的杰作，严重怀疑任兄是微软的内部工作人员，居然能开发出 Live 服务这么多好的优化产品，我们是受益匪浅啊。以下就记录一下如何获取 Live Skydrive 外链的真实不变的地址。</p>
<p>　　在 Skydrive 登陆后，选择需要得到外链的文件页面，在浏览器的地址栏里粘贴以下代码：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000000;">javascript</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">var</span><span style="color: #000000;">%</span><span style="color: #0000ff;">20</span>n<span style="color: #000000;">=</span><span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">title</span><span style="color: #000000;">.</span><span style="color: #000000;">replace</span>(<span style="color: #0000ff;">'%20-%20Windows%20Live'</span><span style="color: #000000;">,</span><span style="color: #0000ff;">''</span>);<span style="color: #000080; font-weight: bold;">var</span><span style="color: #000000;">%</span><span style="color: #0000ff;">20</span><span style="color: #000000;">id</span><span style="color: #000000;">=</span>((<span style="color: #000000;">location</span><span style="color: #000000;">.</span><span style="color: #000000;">hash</span><span style="color: #000000;">==</span><span style="color: #0000ff;">''</span>)<span style="color: #000000;">?</span><span style="color: #000000;">window</span><span style="color: #000000;">.</span><span style="color: #000000;">selfPageData</span><span style="color: #000000;">.</span><span style="color: #000000;">currentItemHash</span><span style="color: #000000;">:</span><span style="color: #000000;">location</span><span style="color: #000000;">.</span><span style="color: #000000;">hash</span><span style="color: #000000;">).</span><span style="color: #000000;">replace</span>(<span style="color: #0000ff;">'#resId/'</span><span style="color: #000000;">,</span><span style="color: #0000ff;">''</span>);<span style="color: #000080; font-weight: bold;">var</span><span style="color: #000000;">%</span><span style="color: #0000ff;">20</span><span style="color: #000000;">u</span><span style="color: #000000;">=</span><span style="color: #0000ff;">'http://storage.live.com/items/'</span><span style="color: #000000;">+</span><span style="color: #000000;">id</span><span style="color: #000000;">+</span><span style="color: #0000ff;">'?filename='</span><span style="color: #000000;">+</span><span style="color: #000000;">encodeURI</span>(n);<span style="color: #000080; font-weight: bold;">var</span><span style="color: #000000;">%</span><span style="color: #0000ff;">20</span>p<span style="color: #000000;">=</span><span style="color: #0000ff;">'http://'</span><span style="color: #000000;">+</span><span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">location</span><span style="color: #000000;">.</span><span style="color: #000000;">host</span><span style="color: #000000;">+</span><span style="color: #0000ff;">'/redir.aspx?page=self&amp;resId='</span><span style="color: #000000;">+</span><span style="color: #000000;">id</span>;<span style="color: #000080; font-weight: bold;">var</span><span style="color: #000000;">%</span><span style="color: #0000ff;">20</span><span style="color: #000000;">e</span><span style="color: #000000;">=</span><span style="color: #0000ff;">'&lt;input%20onmouseover=%22this.select();%22%20onclick=%22this.select();%22%20value=%22'</span>;<span style="color: #000080; font-weight: bold;">var</span><span style="color: #000000;">%</span><span style="color: #0000ff;">20</span><span style="color: #000000;">f</span><span style="color: #000000;">=</span><span style="color: #0000ff;">'%22%20style=%22width:580px%22%20type=%22text%22%20/&gt;&lt;br&gt;'</span>;<span style="color: #000080; font-weight: bold;">var</span><span style="color: #000000;">%</span><span style="color: #0000ff;">20</span><span style="color: #000000;">d</span><span style="color: #000000;">=</span><span style="color: #0000ff;">'by%20(&lt;a%20href=%22http://rpsh.net/%22&gt;Rpsh&lt;/a&gt;)'</span>;<span style="color: #000080; font-weight: bold;">var</span><span style="color: #000000;">%</span><span style="color: #0000ff;">20</span><span style="color: #000000;">c</span><span style="color: #000000;">=</span><span style="color: #0000ff;">'\u5916\u94FE\u5730\u5740:'</span><span style="color: #000000;">+</span><span style="color: #000000;">d</span><span style="color: #000000;">+</span><span style="color: #000000;">e</span><span style="color: #000000;">+</span><span style="color: #000000;">u</span><span style="color: #000000;">+</span><span style="color: #000000;">f</span><span style="color: #000000;">+</span><span style="color: #0000ff;">'\u5206\u4EAB\u5730\u5740:'</span><span style="color: #000000;">+</span><span style="color: #000000;">e</span><span style="color: #000000;">+</span>p<span style="color: #000000;">+</span><span style="color: #000000;">f</span>;<span style="color: #000080; font-weight: bold;">var</span><span style="color: #000000;">%</span><span style="color: #0000ff;">20</span><span style="color: #000000;">a</span><span style="color: #000000;">=</span><span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">getElementById</span>(<span style="color: #0000ff;">'content'</span>);<span style="color: #000080; font-weight: bold;">var</span><span style="color: #000000;">%</span><span style="color: #0000ff;">20</span><span style="color: #000000;">g</span><span style="color: #000000;">=</span>(<span style="color: #000000;">a</span><span style="color: #000000;">.</span><span style="color: #000000;">getElementsByTagName</span>(<span style="color: #0000ff;">'p'</span><span style="color: #000000;">)[</span><span style="color: #0000ff;">0</span><span style="color: #000000;">]);</span><span style="color: #000080; font-weight: bold;">var</span><span style="color: #000000;">%</span><span style="color: #0000ff;">20</span>b<span style="color: #000000;">=</span><span style="color: #000000;">g</span><span style="color: #000000;">?</span><span style="color: #000000;">g</span><span style="color: #000000;">:</span><span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">createElement</span>(<span style="color: #0000ff;">'P'</span>);b<span style="color: #000000;">.</span><span style="color: #000000;">innerHTML</span><span style="color: #000000;">=</span><span style="color: #000000;">c</span>;<span style="color: #000000;">a</span><span style="color: #000000;">.</span><span style="color: #000000;">insertBefore</span>(b<span style="color: #000000;">,</span><span style="color: #000000;">a</span><span style="color: #000000;">.</span><span style="color: #000000;">firstChild</span>);<span style="color: #000080; font-weight: bold;">void</span>(<span style="color: #0000ff;">0</span>)</div>
<p>　　此时会得到一个形如：http://storage.live.com/items/……这样的地址，这才是上传文件真正的、不变的、唯一的外链地址，很明显，这比原来那又臭又长的 URL 要干净清爽很多。如下图：<br />
<img src="http://storage.live.com/items/C3C8B704573706D9!562?filename=skydrive.jpg" alt="" /></p>
<p>　　这张截图我就用了这唯一外链地址，另外我还想作个小测试，因为 Skydrive 的外链在某些网络下被墙的，比如在我学校的校园网内就无法看到在 Skydrive 上的外链图片，<a title="老七" href="http://www.se7ens.cn/" target="_blank">老七</a>也是经常吼着看不到我的图，不知道现在换了新的不变的外链地址能不能看到这图呢？我明天去学校测试看看，也请大家帮忙测试啊，特别是七叔，能不能看到上面这张图？如果能看到的话就太好了，一下子解决了我两个问题。</p>
<p>　　参考自：<a title="如何获得 Live Skydrive 音乐文件唯一外链地址" href="http://rpsh.net/archives/get-direct-url-of-files-on-live-skydrive/" target="_blank">http://rpsh.net/archives/get-direct-url-of-files-on-live-skydrive/</a></p>
<div style='background:#EFEFEF;border:1px dashed #CCC;color:#777;margin:5px 0;padding:5px 10px;-moz-border-radius:10px 0;-webkit-border-top-left-radius:10px;-webkit-border-top-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:10px;border-radius:10px 0;'><div>&raquo; 转载请注明来源：<a title="Life Studio" href="http://wange.im/">Life Studio</a> &raquo; <a rel="bookmark" title="获取 Live Skydrive 的真实地址" href="http://wange.im/real-url-in-skydrive.html">《获取 Live Skydrive 的真实地址》</a></div><div>&raquo; 本文链接地址：<a rel="bookmark" title="获取 Live Skydrive 的真实地址" href="http://wange.im/real-url-in-skydrive.html">http://wange.im/real-url-in-skydrive.html</a></div><div>&raquo; 订阅本站：<a title="Life Studio" target="_blank" href="http://feed.wange.im">http://feed.wange.im</a></div></div><h3>相关日志</h3><ul class="st-related-posts"><li><a href="http://wange.im/related-posts-with-thumbs-for-wordpress.html" title="Wordpress 免插件实现图片相关日志 (2010年05月4日)">Wordpress 免插件实现图片相关日志</a> (98)</li><li><a href="http://wange.im/fadeto-effect-with-jquery.html" title="利用 JQuery 实现图片显隐特效 (2010年04月8日)">利用 JQuery 实现图片显隐特效</a> (119)</li><li><a href="http://wange.im/image-title-for-wordpress-without-plugins.html" title="非插件 Wordpress 标题个性化字体图片 (2010年03月10日)">非插件 Wordpress 标题个性化字体图片</a> (51)</li><li><a href="http://wange.im/ads-for-sale.html" title="招、招、招广告啦～～～ (2010年03月2日)">招、招、招广告啦～～～</a> (145)</li><li><a href="http://wange.im/jquery-slide-pic-show.html" title="JQuery 实现带滑动层的图片展示效果 (2010年02月24日)">JQuery 实现带滑动层的图片展示效果</a> (76)</li><li><a href="http://wange.im/enlarge-show-effects-with-js-3.html" title="JS 实现放大镜产品展示效果（三） (2010年02月4日)">JS 实现放大镜产品展示效果（三）</a> (142)</li><li><a href="http://wange.im/convert-smilies-to-pic-in-wordpress.html" title="将 Wordpress 中的表情符号转化为图片 (2009年12月8日)">将 Wordpress 中的表情符号转化为图片</a> (135)</li><li><a href="http://wange.im/disable-hotlinking-with-htaccess.html" title="用 .htaccess 防止图片盗链 (2009年11月24日)">用 .htaccess 防止图片盗链</a> (131)</li><li><a href="http://wange.im/loading-for-wordpress.html" title="给 Wordpress 添加 Loading 预载 (2009年11月19日)">给 Wordpress 添加 Loading 预载</a> (126)</li><li><a href="http://wange.im/lightbox-with-css.html" title="纯 CSS 实现 Lightbox 效果 (2009年11月15日)">纯 CSS 实现 Lightbox 效果</a> (98)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://wange.im/real-url-in-skydrive.html/feed</wfw:commentRss>
		<slash:comments>186</slash:comments>
		</item>
		<item>
		<title>PHP 实现的静态世界时钟功能</title>
		<link>http://wange.im/world-clock-with-php.html</link>
		<comments>http://wange.im/world-clock-with-php.html#comments</comments>
		<pubDate>Fri, 09 Jul 2010 12:19:24 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wange.im/?p=3459</guid>
		<description><![CDATA[　　昨天有个博友的网站上需要加上显示世界时钟的功能，于是向我求助，因为是用在 Wordpress 主题上的，所以要用 PHP 来实现，硬着头皮答应了下来。不过说实话，我的 PHP 水平还不如我的英语水平，就是只会看不会写的那种，Wordpress 主题以内的一些 PHP 函数我还算比较熟悉，但是 Wordpress 以外的 PHP 我就有些傻眼了，每次写 PHP 都是咬着笔头，翻着 PHP 手册，搜着 Google，挤牙膏一样才挤出那么一点东西。
　　关于这个世界时钟的功能，原理上是很简单的，只要设置一个基准的默认时间，然后把其他地区的时间加上时间差就可以了，但是用什么函数呢？翻呀翻，搜呀搜，终于被我搞定了，贴出来留个纪念。先看 DEMO～
　　以下是世界时钟完整的 PHP 代码：
&#60;?php
//设置默认时区
date_default_timezone_set('Etc/GMT-8');
//当地时间，即北京时间
$localtime = date('Y-m-d H:i:s');
//伦敦时间
$london = date('Y-m-d H:i:s',strtotime("-8 hours $localtime"));
//柏林时间
$berlin = date('Y-m-d H:i:s',strtotime("-7 hours $localtime"));
//开罗时间
$cairo = date('Y-m-d H:i:s',strtotime("-6 hours $localtime"));
//莫斯科时间
$moscow = date('Y-m-d H:i:s',strtotime("-5 hours $localtime"));
//新德里时间
$newdelhi = date('Y-m-d H:i:s',strtotime("-3 hours $localtime"));
//曼谷时间
$bangkok = date('Y-m-d H:i:s',strtotime("-1 hours $localtime"));
//东京时间
$tokyo [...]]]></description>
			<content:encoded><![CDATA[<p>　　昨天有个博友的网站上需要加上显示世界时钟的功能，于是向我求助，因为是用在 Wordpress 主题上的，所以要用 PHP 来实现，硬着头皮答应了下来。不过说实话，我的 PHP 水平还不如我的英语水平，就是只会看不会写的那种，Wordpress 主题以内的一些 PHP 函数我还算比较熟悉，但是 Wordpress 以外的 PHP 我就有些傻眼了，每次写 PHP 都是咬着笔头，翻着 PHP 手册，搜着 Google，挤牙膏一样才挤出那么一点东西。</p>
<p>　　关于这个世界时钟的功能，原理上是很简单的，只要设置一个基准的默认时间，然后把其他地区的时间加上时间差就可以了，但是用什么函数呢？翻呀翻，搜呀搜，终于被我搞定了，贴出来留个纪念。<a title="世界时钟" href="http://wange.im/demo/worldclock/">先看 DEMO</a>～</p>
<p>　　以下是世界时钟完整的 PHP 代码：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #008080;">&lt;?php</span><br />
<span style="font-style: italic; color: #008800;">//设置默认时区</span><br />
<span style="color: #000000;">date_default_timezone_set</span>(<span style="color: #0000ff;">'Etc/GMT-8'</span>);<br />
<span style="font-style: italic; color: #008800;">//当地时间，即北京时间</span><br />
<span style="color: #000000;">$localtime</span> <span style="color: #000000;">=</span> <span style="color: #000000;">date</span>(<span style="color: #0000ff;">'Y-m-d H:i:s'</span>);<br />
<span style="font-style: italic; color: #008800;">//伦敦时间</span><br />
<span style="color: #000000;">$london</span> <span style="color: #000000;">=</span> <span style="color: #000000;">date</span>(<span style="color: #0000ff;">'Y-m-d H:i:s'</span><span style="color: #000000;">,</span><span style="color: #000000;">strtotime</span>(<span style="color: #0000ff;">"-8 hours </span><span style="color: #0000ff;">$localtime</span><span style="color: #0000ff;">"</span>));<br />
<span style="font-style: italic; color: #008800;">//柏林时间</span><br />
<span style="color: #000000;">$berlin</span> <span style="color: #000000;">=</span> <span style="color: #000000;">date</span>(<span style="color: #0000ff;">'Y-m-d H:i:s'</span><span style="color: #000000;">,</span><span style="color: #000000;">strtotime</span>(<span style="color: #0000ff;">"-7 hours </span><span style="color: #0000ff;">$localtime</span><span style="color: #0000ff;">"</span>));<br />
<span style="font-style: italic; color: #008800;">//开罗时间</span><br />
<span style="color: #000000;">$cairo</span> <span style="color: #000000;">=</span> <span style="color: #000000;">date</span>(<span style="color: #0000ff;">'Y-m-d H:i:s'</span><span style="color: #000000;">,</span><span style="color: #000000;">strtotime</span>(<span style="color: #0000ff;">"-6 hours </span><span style="color: #0000ff;">$localtime</span><span style="color: #0000ff;">"</span>));<br />
<span style="font-style: italic; color: #008800;">//莫斯科时间</span><br />
<span style="color: #000000;">$moscow</span> <span style="color: #000000;">=</span> <span style="color: #000000;">date</span>(<span style="color: #0000ff;">'Y-m-d H:i:s'</span><span style="color: #000000;">,</span><span style="color: #000000;">strtotime</span>(<span style="color: #0000ff;">"-5 hours </span><span style="color: #0000ff;">$localtime</span><span style="color: #0000ff;">"</span>));<br />
<span style="font-style: italic; color: #008800;">//新德里时间</span><br />
<span style="color: #000000;">$newdelhi</span> <span style="color: #000000;">=</span> <span style="color: #000000;">date</span>(<span style="color: #0000ff;">'Y-m-d H:i:s'</span><span style="color: #000000;">,</span><span style="color: #000000;">strtotime</span>(<span style="color: #0000ff;">"-3 hours </span><span style="color: #0000ff;">$localtime</span><span style="color: #0000ff;">"</span>));<br />
<span style="font-style: italic; color: #008800;">//曼谷时间</span><br />
<span style="color: #000000;">$bangkok</span> <span style="color: #000000;">=</span> <span style="color: #000000;">date</span>(<span style="color: #0000ff;">'Y-m-d H:i:s'</span><span style="color: #000000;">,</span><span style="color: #000000;">strtotime</span>(<span style="color: #0000ff;">"-1 hours </span><span style="color: #0000ff;">$localtime</span><span style="color: #0000ff;">"</span>));<br />
<span style="font-style: italic; color: #008800;">//东京时间</span><br />
<span style="color: #000000;">$tokyo</span> <span style="color: #000000;">=</span> <span style="color: #000000;">date</span>(<span style="color: #0000ff;">'Y-m-d H:i:s'</span><span style="color: #000000;">,</span><span style="color: #000000;">strtotime</span>(<span style="color: #0000ff;">"+1 hours </span><span style="color: #0000ff;">$localtime</span><span style="color: #0000ff;">"</span>));<br />
<span style="font-style: italic; color: #008800;">//悉尼时间</span><br />
<span style="color: #000000;">$sydney</span> <span style="color: #000000;">=</span> <span style="color: #000000;">date</span>(<span style="color: #0000ff;">'Y-m-d H:i:s'</span><span style="color: #000000;">,</span><span style="color: #000000;">strtotime</span>(<span style="color: #0000ff;">"+2 hours </span><span style="color: #0000ff;">$localtime</span><span style="color: #0000ff;">"</span>));<br />
<span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #0000ff;">'伦敦时间：'</span> <span style="color: #000000;">.</span> <span style="color: #000000;">$london</span><span style="color: #000000;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span>;<br />
<span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #0000ff;">'柏林时间：'</span> <span style="color: #000000;">.</span> <span style="color: #000000;">$berlin</span><span style="color: #000000;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span>;<br />
<span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #0000ff;">'开罗时间：'</span> <span style="color: #000000;">.</span> <span style="color: #000000;">$cairo</span><span style="color: #000000;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span>;<br />
<span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #0000ff;">'莫斯科时间：'</span> <span style="color: #000000;">.</span> <span style="color: #000000;">$moscow</span><span style="color: #000000;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span>;<br />
<span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #0000ff;">'新德里时间：'</span> <span style="color: #000000;">.</span> <span style="color: #000000;">$newdelhi</span><span style="color: #000000;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span>;<br />
<span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #0000ff;">'曼谷时间：'</span> <span style="color: #000000;">.</span> <span style="color: #000000;">$bangkok</span><span style="color: #000000;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span>;<br />
<span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #0000ff;">'北京时间：'</span> <span style="color: #000000;">.</span> <span style="color: #000000;">$localtime</span><span style="color: #000000;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span>;<br />
<span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #0000ff;">'东京时间：'</span> <span style="color: #000000;">.</span> <span style="color: #000000;">$tokyo</span><span style="color: #000000;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span>;<br />
<span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #0000ff;">'悉尼时间：'</span> <span style="color: #000000;">.</span> <span style="color: #000000;">$sydney</span><span style="color: #000000;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span>;<br />
<span style="color: #008080;">?&gt;</span></div>
<p>　　看代码还是很好理解的，但是却花了我近一个小时来研究时间函数，才写出这么几行。尤其是这个 date_default_timezone_set() 函数，刚开始我没有写这个函数，输出的时间和实际时间相差了8个小时，我想那一定是时区的问题了，一查果然如此。因为北京时间是东8区的，而从 php5.1.0 开始，php.ini 里加入了 date.timezone 这个选项，默认情况下关闭的，也就是显示的时间都是格林威治标准时间（GMT），这和我们的北京时间正好相差8小时。</p>
<p>　　这样就做好了，看着自己的成果，还算不错，哈哈～不过有些遗憾，这个 PHP 实现的时钟只是静态的，只有刷新页面才能更新时钟，如果可以动态实时的显示世界时钟的功能就更完美了，不过动态的应该需要 Javascript 脚本的配合使用吧，这个更高级了，我还不会。不知道有没有现成的世界时钟的 API 可以调用呢？这样也免去了自己写代码的麻烦。</p>
<p>　　今天算是小有收获，又学会了一个 PHP 函数，另外感谢所有向我提问的童鞋，是你们给了我一个折腾的目标。</p>
<div style='background:#EFEFEF;border:1px dashed #CCC;color:#777;margin:5px 0;padding:5px 10px;-moz-border-radius:10px 0;-webkit-border-top-left-radius:10px;-webkit-border-top-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:10px;border-radius:10px 0;'><div>&raquo; 转载请注明来源：<a title="Life Studio" href="http://wange.im/">Life Studio</a> &raquo; <a rel="bookmark" title="PHP 实现的静态世界时钟功能" href="http://wange.im/world-clock-with-php.html">《PHP 实现的静态世界时钟功能》</a></div><div>&raquo; 本文链接地址：<a rel="bookmark" title="PHP 实现的静态世界时钟功能" href="http://wange.im/world-clock-with-php.html">http://wange.im/world-clock-with-php.html</a></div><div>&raquo; 订阅本站：<a title="Life Studio" target="_blank" href="http://feed.wange.im">http://feed.wange.im</a></div></div><h3>相关日志</h3><ul class="st-related-posts"><li><a href="http://wange.im/random-ads-with-array-in-wordpress.html" title="Wordpress 显示随机广告的方法 (2010年05月13日)">Wordpress 显示随机广告的方法</a> (165)</li><li><a href="http://wange.im/php-study-notes-echo-output.html" title="PHP 学习笔记：echo 输出 (2009年09月12日)">PHP 学习笔记：echo 输出</a> (20)</li><li><a href="http://wange.im/php-video-tutorial.html" title="《PHP从入门到精通》视频教程 (2009年09月11日)">《PHP从入门到精通》视频教程</a> (33)</li><li><a href="http://wange.im/wordpress-say-hello-to-vistors.html" title="Wordpress 向来自其他域的访客致欢迎词 (2010年07月30日)">Wordpress 向来自其他域的访客致欢迎词</a> (175)</li><li><a href="http://wange.im/embed-bbs-in-blog.html" title="如果在博客嵌入个人论坛 (2010年07月29日)">如果在博客嵌入个人论坛</a> (187)</li><li><a href="http://wange.im/dwthemes-with-dustmedia.html" title="与尘埃老哥共建 DWthemes 工作室 (2010年07月28日)">与尘埃老哥共建 DWthemes 工作室</a> (186)</li><li><a href="http://wange.im/comment-count-in-wordpress-with-jquery.html" title="Jquery 实现 Wordpress 评论字数计数 (2010年07月27日)">Jquery 实现 Wordpress 评论字数计数</a> (145)</li><li><a href="http://wange.im/wordpress-shows-the-number-of-recent-comments.html" title="WordPress 显示访客最近评论次数 (2010年07月20日)">WordPress 显示访客最近评论次数</a> (198)</li><li><a href="http://wange.im/highlight-keywords-in-wordpress-search.html" title="Wordpress 站内搜索高亮显示关键词 (2010年07月18日)">Wordpress 站内搜索高亮显示关键词</a> (119)</li><li><a href="http://wange.im/highlight-keywords-and-hellobaby-in-wordpress.html" title="Wordpress 高亮显示关键词及欢迎提示 (2010年07月16日)">Wordpress 高亮显示关键词及欢迎提示</a> (180)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://wange.im/world-clock-with-php.html/feed</wfw:commentRss>
		<slash:comments>142</slash:comments>
		</item>
	</channel>
</rss>
