<?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>涂雅 &#187; wordpress</title>
	<atom:link href="http://iove.net/category/tech/wordpress-tech/feed" rel="self" type="application/rss+xml" />
	<link>http://iove.net</link>
	<description>致力Web技术研究，关注互联网热点</description>
	<lastBuildDate>Fri, 23 Dec 2011 03:40:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>给WordPress添加访问排行榜的功能</title>
		<link>http://iove.net/archives/2785.html</link>
		<comments>http://iove.net/archives/2785.html#comments</comments>
		<pubDate>Mon, 30 Aug 2010 01:00:00 +0000</pubDate>
		<dc:creator>涂雅</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[排行榜]]></category>
		<category><![CDATA[插件]]></category>

		<guid isPermaLink="false">http://iove.net/archives/2785.html</guid>
        <description><![CDATA[涂雅导读：<img src="http://images.iove.net/logo/wordpress.jpg" class="logo" />有朋友对我的排行榜的功能比较感兴趣，本来准备做一个插件的，但我考虑到做一个插件前前后后估计得花上一周的时间，所以还是放弃吧。把思路和代码放出来，有熟悉php的朋友可以自己拿去用。<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1873.html&from=http%3A%2F%2Fiove.net%2Farchives%2F2785.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(分析)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1505.html&from=http%3A%2F%2Fiove.net%2Farchives%2F2785.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">为jquery.AutoComplete添加触发事件</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1144.html&from=http%3A%2F%2Fiove.net%2Farchives%2F2785.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">wordpress文章置顶重复的终极解决方法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1306.html&from=http%3A%2F%2Fiove.net%2Farchives%2F2785.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">利用Google AJAX 库让你的wordpress加速1-3秒</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><br />全文：
		<p><em>阅读提示：阅读本文要求懂PHP或者相关的开发者。</em></p>
<p>好久不写技术类的文章了，这两天我又把博客换回来了，博客又从韩国换回到了Godaddy，因为最近韩国服务开始不稳定了，Godaddy貌似好一些了。感谢郭嘉，感谢功夫网，感谢方滨兴，让我从美国到韩国又回到美国。趁机会把博客又小搞了一下，这次完全换成PHP了，也换了一个模版，自己觉得这个模版还不错，估计搞技术的人会比较喜欢。最看重的是这个模版很轻巧，没有使用jQuery，首页体积经过压缩后只有60k不到（不包括Google等三方的Javascript代码）。</p>
<p>之前我曾经花几天给Wordpress增加了一个拦截器，优点是访问速度变快了，缺点是许多Wordpress的功能不能使用了，评论也有些美中不足。这次又改造了一下Wordpress，基本上使用了WP原生功能，但在模版与WP上都做了一些改进。插件我只使用了4个，分别是Akismet、cos-html-cache、Google XML Sitemaps、WP-Syntax，可以通过简单修改程序达到的功能，一率不用插件。因为插件太消耗资源了，特别是在虚拟主机上运行的时候，以前就是一个wp_simpleTag把我的博客搞死了。</p>
<p>除了插件上，还保留了原来的排行榜的功能，这个功能觉得还不错的，所以今天把这个功能的经验分享出来。可能会有人说我喜欢倒腾，没办法，搞技术的人就是这样，你可以把我当成一个Geek就行了，比如说玩Linux的人也比较爱倒腾。</p>
<h2><span style="color: #ff0000;">修改数据库</span></h2>
<p>首先应该修改数据库，你需要创建一个统计表，字段很简单，只有文章、日期、主键而已，如下：</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`wp_stats`</span> <span style="color: #66cc66;">&#40;</span>
  <span style="color: #ff0000;">`stats_ID`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`post_ID`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> COMMENT <span style="color: #ff0000;">'文章的id'</span><span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`view_date`</span> datetime <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span> COMMENT <span style="color: #ff0000;">'访问时间'</span><span style="color: #66cc66;">,</span>
  <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`stats_ID`</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> ENGINE<span style="color: #66cc66;">=</span>InnoDB <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">98898</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET<span style="color: #66cc66;">=</span>utf8;</pre></div></div>

<p>对于访问量的统计，有一个叫wp_postViews的插件可以使用，但是我还是觉得直接添加一个字段来记录访问量，如果你不需要访问量的数据，可能忽略此步，代码如下：</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> wp_posts
 <span style="color: #993333; font-weight: bold;">ADD</span> view_count INT <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0'</span>;</pre></div></div>

<h2><span style="color: #ffc000;">添加统计代码</span></h2>
<p>我设置的统计原则是同一电脑在24小时访问才进行计数，统计代码分为两个部分，第一部分是服务器端的php代码，我们在blog的根目录下添加一个stat.php的文件，代码如下：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
get_results<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;SELECT ID FROM wp_posts WHERE post_status
		= 'publish' AND post_type = 'POST' AND ID = &quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$postID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//数据库中存在这篇文章</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myrows</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//更新文章的访问量</span>
			<span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'UPDATE wp_posts SET view_count =
			IFNULL(view_count, 0) + 1 WHERE ID = '</span><span style="color: #339933;">.</span> <span style="color: #000088;">$postID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">//添加一条访问记录</span>
			<span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO wp_stats(post_ID,view_date)
			 VALUES(&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$postID</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;, utc_timestamp())&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">//写入到Cookies中去</span>
			<span style="color: #990000;">setcookie</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;StatsPost&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cook</span><span style="color: #339933;">.</span><span style="color: #000088;">$postID</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">3600</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>这个代码主要是用于统计的，我接下来会在日志中添加一个Javascript文件引用，把文章的ID传过来，代码的工作内容大致如下：</p>
<ol>
<li>判断文章IT是否为合法的ID</li>
<li>从Cookies读取用户已经访问过的文章ID列表，检查是否已经访问，如果已经访问则不再统计</li>
<li>检测wp_posts表中是否存在这个ID</li>
<li>如果存在，把wp_posts表的view_count字段加1，同时往wp_stats表中插入一条数据</li>
</ol>
<p>第二部分是客户端的代码，这个代码很简单，加入一个Script代码就行。我们需要修改模版下的Single.php文件，在这个文件的底部添加：&lt;script src=&#8221;/stat.php&#8221;&gt;&lt;/script&gt;</p>
<h2>排行榜</h2>
<p>接下来我们要为博客添加排行榜的功能，数据是有统计了，如果不显示出来也没什么意议。</p>
<ol>
<li>新建一个模版，模版名称为为排行榜。</li>
<li>在模版中添加如下代码：

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> postList<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #339933;">,</span> <span style="color: #000088;">$title</span><span style="color: #339933;">,</span> <span style="color: #000088;">$showDate</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>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;ul&gt;&lt;li class=&quot;caption&quot;&gt;&lt;h3&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$title</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/h3&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$rows</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>	
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$rows</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li title=&quot;发表于：'</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Date</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' 访问：'</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ViewCount</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;
		&lt;a href=&quot;/archives/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.html&quot;&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Title</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">/*if($showDate){
			echo '&lt;span class=&quot;date&quot;&gt;';
&nbsp;
			$unit;
			$count;
			var span = time() - $row-&gt;Date;
			if(span &lt;= 600){
				$unit = &quot;分钟&quot;;
				$count = round(span / 60);
			}elseif(span &lt;= 2 * 24 * 60 * 60){
				$unit = &quot;小时&quot;;
				$count = round(span / 60 / 60, 1);
			}elseif(span &lt;= 10 * 24 * 60 * 60){
				$unit = &quot;天&quot;;
				$count = round(span / 60 / 60, 2);
			}else{
				$unit = &quot;&quot;;
				$count = date(&quot;'Y-n-j H:i'&quot;,$row-&gt;Date);
			}
			echo $count.$unit;
&nbsp;
		}else
		{
			echo '&lt;span class=&quot;count&quot;&gt;';
			echo $row-&gt;ViewCount;
		}*/</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;span class=&quot;count&quot;&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ViewCount</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//echo '&lt;br /&gt;&lt;span class=&quot;date&quot;&gt;'.date('Y-n-j H:i', strtotime($row-&gt;Date)).'&lt;/span&gt;';</span>
		<span style="color: #666666; font-style: italic;">//echo '&lt;span class=&quot;view&quot;&gt;访问：'.$row-&gt;ViewCount.'&lt;/span&gt;';</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/ul&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$viewSql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT B.ID,A.ViewCount,
                       convert_tz(post_date_gmt, '+00:00', '+8:00') Date,
                       post_title Title,
                       comment_count CommentCount
                  FROM (SELECT COUNT(*) ViewCount, post_ID
                          FROM wp_stats
                         WHERE time_to_sec(timediff(utc_timestamp(), view_date)) &lt;
                               {0}
                         GROUP BY post_ID  ORDER BY COUNT(*) DESC  LIMIT 0, 10) A
                  LEFT JOIN wp_posts B ON A.post_ID = B.ID ORDER BY ViewCount DESC,post_date_gmt DESC&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$postSql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT ID,view_count ViewCount,
		   convert_tz(post_date_gmt, '+00:00', '+8:00') Date,
		   post_title Title,
		   comment_count CommentCount
	  FROM wp_posts WHERE post_status = 'publish'
           AND post_type = 'POST' ORDER BY {0}post_date_gmt DESC LIMIT 0, 10&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;div class=&quot;post clear&quot;&gt;
&lt;h2 class=&quot;entry-title hot&quot;&gt;爬行榜&lt;/h2&gt;
&lt;ul class=&quot;hotPost&quot;&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li class=&quot;frame&quot;&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//获取最新文章 </span>
	postList<span style="color: #009900;">&#40;</span><span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'{0}'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$postSql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'最新文章'</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: #666666; font-style: italic;">//24小时排行</span>
	postList<span style="color: #009900;">&#40;</span><span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'{0}'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'86400'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$viewSql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'24小时排行'</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>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/li&gt;&lt;li class=&quot;frame&quot;&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//30天排行</span>
	postList<span style="color: #009900;">&#40;</span><span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'{0}'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'2592000'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$viewSql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'30天排行'</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> 
	<span style="color: #666666; font-style: italic;">//获取历史排行</span>
	postList<span style="color: #009900;">&#40;</span><span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'{0}'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ViewCount DESC,'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$postSql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'历史排行榜'</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>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//获取评论最多的</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/ul&gt;  
&lt;/div&gt;</pre></div></div>

</li>
<li>上传模版，并在wordpress的后台中新建一个页面，页面的模版就选择榜行榜</li>
</ol>
<p>经过这样处理之后你的博客就会有一个排行榜的功能了，我目前的排行榜包括24小时排行、30天排行、历史排行、最新文章，当然如果我要的话，还可以增加60天排行之类的，但我觉得没有必要。</p>
<p>说一下这种方式的问题，随你的访客越来越多，wp_stats表可能会越来越庞大，我的处理是当数据到一个量级之后，用sql把这个表group on到另一个表中去。一般来说，个人博客的访问量都比较低，所以很多人可以不用考虑这个问题，半年清一次也就差不多了。</p>
<p>我本来准备把这个功能搞成一个插件的，但觉得会费太多的事，因为插件还要考虑很多东西，所以先将代码放出来，有需要的朋友可以用到。</p>
<p>2010-9-1注：找到一个同样功能的插件，我还没有试，不过从介绍看应该功能是一样的，还拥有更多的功能，地址：<a href="http://wordpress.org/extend/plugins/stats/" target="_blank">http://wordpress.org/extend/plugins/stats/</a></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1873.html&from=http%3A%2F%2Fiove.net%2Farchives%2F2785.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(分析)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1505.html&from=http%3A%2F%2Fiove.net%2Farchives%2F2785.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">为jquery.AutoComplete添加触发事件</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1144.html&from=http%3A%2F%2Fiove.net%2Farchives%2F2785.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">wordpress文章置顶重复的终极解决方法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1306.html&from=http%3A%2F%2Fiove.net%2Farchives%2F2785.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">利用Google AJAX 库让你的wordpress加速1-3秒</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>©<a target="_blank" href="http://iove.net/">涂雅</a>，本文链接地址为<a target="_blank" href="http://iove.net/archives/2785.html">http://iove.net/archives/2785.html</a>，转载请保留此链接，否则视为侵权。<hr />标签：<a href="http://iove.net/tag/wordpress" rel="tag">wordpress</a>,<a href="http://iove.net/tag/%e6%8e%92%e8%a1%8c%e6%a6%9c" rel="tag">排行榜</a>,<a href="http://iove.net/tag/%e6%8f%92%e4%bb%b6" rel="tag">插件</a> 分类：<a href="http://iove.net/category/tech/wordpress-tech" title="查看 wordpress 的全部文章" rel="category tag">wordpress</a><h3>联系涂雅</h3><a target="_blank" href="http://t.sina.com.cn/conisyi/">新浪微博</a> | <a target="_blank" href="http://t.qq.com/conisyi">腾讯微博</a>| <a target="_blank" href="http://twitter.com/conisyi">Twitter</a> | <a target="_blank" href="http://www.facebook.com/facebook">Facebook</a> | <a target="_blank" href="https://www.google.com/reader/shared/conis.yi">Google Reader</a> | E-Mail：conis.yi<img src="http://iove.net/images/mailat.gif">gmail.com<br /><h3>涂雅导航</h3><a href="http://iove.net/category/it-comment" target="_blank">IT评论</a> | <a href="http://iove.net/category/tech" target="_blank">IT技术</a> | <a href="http://iove.net/category/quick-news" target="_blank">涂雅速涂</a> | <a href="http://iove.net/feedback" title="给我留言" target="_blank">给我留言</a> | <a href="http://iove.net/friend" title="友情链接" target="_blank">友情链接</a> | <a href="http://iove.net/about" title="关于涂雅" target="_blank">关于涂雅</a>        ]]></description>
		<wfw:commentRss>http://iove.net/archives/2785.html/feed</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
		<item>
		<title>36小时急行军——全面改造WordPress(操刀&amp;结局)</title>
		<link>http://iove.net/archives/1964.html</link>
		<comments>http://iove.net/archives/1964.html#comments</comments>
		<pubDate>Mon, 17 May 2010 10:38:07 +0000</pubDate>
		<dc:creator>涂雅</dc:creator>
				<category><![CDATA[seo]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[旧城改造]]></category>
		<category><![CDATA[重构]]></category>

		<guid isPermaLink="false">http://iove.net/?p=1964</guid>
        <description><![CDATA[涂雅导读：实际上快要到我准备要上线的时间点，发现有功能还没有完成，这是我们项目中常常会出现的情况，因为需求方需求的变更或者增加，导致项目不能如期完成。那么这个时候我们需要一些策略，当然首先是和需求方沟通能不能延迟上线，如果确定不可以的话，那我们就可算解决方案了。基本上方案有三种，第一种是增加人手，但有时候增加人手也不一定可以解决问题，《People ware》（中文译作人件，怪怪的）中有一句经典名言：“一个女人一个孩子需要10月，10个女人生1个孩子也需要10个月”，也就是说有很多事情是不能并行的。<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1864.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1964.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress（诱因）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1877.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1964.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(解决方案)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1873.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1964.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(分析)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1770.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1964.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">实战旧城改造之——重构wordpress</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><br />全文：
		<h2><span style="color: #ff0000;">第四章：操刀&amp;结局</span></h2>
<p>有了解决方案，剩下的就码代码的工作了，这部分我就不细述了，从我决定要改到正式上线，大概花了36个小时的工作时间。期间应该有一半左右的时间花在前台处理中（javascript/css/html/xslt/photoshop），这36个小时可说是超负荷工作，完全没有偷懒，所以和平时的工作效率自然不可以同日而语。</p>
<p>在做的过程中，不知道怎么让我找到了一个城市IP地址的库，所以想给博客加上一个留言者所在地理位置的功能，于是又添加了原先没有计划的需求。看到没有，就算是程序员自己开发软件，也在不停地添加新的需求，所以平时我们么能埋怨客户变更或者增加需求呢？所以这个时候，我们需要有策略来解决需求的变更与增加。就拿我这次来说吧，我会评估新需求带来的好处和所需要的时间，如果工作量不大又能有不错的效果，那么我就加上去。</p>
<p>在我确定要上线的时候，发现还有一些功能没有做，比如说友情链接和一些分类还是采用原来的部分，最后我决定放弃这些功能，因为这些功能本身访问量就不大，还是可以使用原来的系统，因为新旧系统是无缝结合的，所以无论是用户还是搜索引擎都是透明的。</p>
<p>最终增加或修改的功能（包括36小时后又添加的一些小功能）：<br />
1.    首页以及文章、RSS完全静态化，也可以实时输出<br />
2.    在RSS第一篇文章中添加了24小时热文的排名，版权声明，链接等功能<br />
3.    在RSS中添加了版权声明和相关文章的列表<br />
4.    在侧边栏添加了24小时排行、30天排行<br />
5.    增加了排行版，可以查看24小时排行，30天排行，历史排行，评论排行，随机文<br />
6.    添加了查看所有评论的功能，用户可以通过这个功能查看完全的评论，并且显示评论所针对的文章</p>
<p>经过几天的监控，发现可用率基本在100%，因为采用了静态首页和文章页，所以除了服务器彻底不能访问的情况下，用户都可以访问我的博客。</p>
<p>实际上我怀疑Godaddy的服务器对MySql的连接数应该是有一个限制，我连数据库都有主动Close，但最初还是会常出现Timeout expired的错误，这点用户可能感觉不出来，因为用户访问的是静态页，但表现出来的是统计数据不准确，无法打开非首页的列表页，后来我折腾了几天，最后是把连接字符串的min pool size改成25（现在是50）才解决问题。我目前还不清楚为什么会这样，也找了min pool size参数的含义，但还是不太明白，呵呵，有知道的朋友告诉我一下，感谢了。</p>
<h2><span style="color: #ff0000;">总结</span></h2>
<p>这次改造，我自己觉得还是比较成功的，首先我的可控制性加强了，我现在可以把插件都停掉，呵呵，剩下几个后台的插件就可以了。用户最直接的体验应该就是速度变快了，然后功能有所增加，当然有人也不喜欢这些功能，呵呵，在我发第一章的时候就有读者说不喜欢这些功能，嗯，感谢这位读者，不过我还是觉得要放上去，我的地盘我作主，哈哈，你不要介意。</p>
<p>我用YSlow进行测试，发现在默认测试情况下可以达到D级，如果调到small site or blog模式，可以达到A级，之所以是D级，原因主要有3个，第一是没有做CDN，第二个是没有压缩，第三个是没有加ETag，呵呵，对于小网站，这三点都可以不做了:P（现在添加了广告，然后jquery在另一个网站，所以好像已经不是这个级别了）</p>
<h2><span style="color: #ff0000;">问题</span></h2>
<p>在我上线之后也有问题发生，包括我之前在博客中也谈到XSLT特殊字符的问题，还包括MySql的超时问题，还有其它等等等多个小问题。那主要原因是我这次时间非常短，然后因为是自己的博客，也不会向项目那么谨慎，基本上不会太测试就直接上了。</p>
<p>在开发的过程中，我也常常会有新的想法要加上去，所以这时候我们应该理解需求方，因为如果是你自己的东西，如果你有一个好点子，你当然也希望加上去。那除了评论者所在位置的功能之外，我后来还想了其它的功能，但因为时间关系，我强制我自己打消这个念头。从这里我们也可以看到，有时候需求方会提出很多的需求，那么你不能直接Say No，比较合理的做法是你大概评估一个工作量，然后告诉他，如果要实现这个，我们需要增加这么久的工作量或者这么多的人手，这个时候，需求方基本上都会主动放弃大部分的需求，除非他真的很想要这个功能或者不在乎延时。</p>
<p>实际上快要到我准备要上线的时间点，发现有功能还没有完成，这是我们项目中常常会出现的情况，因为需求方需求的变更或者增加，导致项目不能如期完成。那么这个时候我们需要一些策略，当然首先是和需求方沟通能不能延迟上线，如果确定不可以的话，那我们就可算解决方案了。基本上方案有三种，第一种是增加人手，但有时候增加人手也不一定可以解决问题，《People ware》（中文译作人件，怪怪的）中有一句经典名言：“一个女人一个孩子需要10月，10个女人生1个孩子也需要10个月”，也就是说有很多事情是不能并行的。</p>
<p>第二解决方案是缩减功能，比如说裁剪不重要的功能，或者说上线一个DEMO，例如在用户很少用到的功能，我们可以先放一个静态的内容，然后逐步完善。最忌讳的是项目管理人员信誓旦旦说可以上线，结果需求方眼巴巴着等着上线，结果马上就要上线的时候，项目管理人员说，不行！这个事情是最扯蛋的事情了。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1864.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1964.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress（诱因）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1877.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1964.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(解决方案)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1873.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1964.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(分析)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1770.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1964.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">实战旧城改造之——重构wordpress</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>©<a target="_blank" href="http://iove.net/">涂雅</a>，本文链接地址为<a target="_blank" href="http://iove.net/archives/1964.html">http://iove.net/archives/1964.html</a>，转载请保留此链接，否则视为侵权。<hr />标签：<a href="http://iove.net/tag/wordpress" rel="tag">wordpress</a>,<a href="http://iove.net/tag/%e6%97%a7%e5%9f%8e%e6%94%b9%e9%80%a0" rel="tag">旧城改造</a>,<a href="http://iove.net/tag/%e9%87%8d%e6%9e%84" rel="tag">重构</a> 分类：<a href="http://iove.net/category/tech/seo-tech" title="查看 seo 的全部文章" rel="category tag">seo</a>,<a href="http://iove.net/category/tech/wordpress-tech" title="查看 wordpress 的全部文章" rel="category tag">wordpress</a><h3>联系涂雅</h3><a target="_blank" href="http://t.sina.com.cn/conisyi/">新浪微博</a> | <a target="_blank" href="http://t.qq.com/conisyi">腾讯微博</a>| <a target="_blank" href="http://twitter.com/conisyi">Twitter</a> | <a target="_blank" href="http://www.facebook.com/facebook">Facebook</a> | <a target="_blank" href="https://www.google.com/reader/shared/conis.yi">Google Reader</a> | E-Mail：conis.yi<img src="http://iove.net/images/mailat.gif">gmail.com<br /><h3>涂雅导航</h3><a href="http://iove.net/category/it-comment" target="_blank">IT评论</a> | <a href="http://iove.net/category/tech" target="_blank">IT技术</a> | <a href="http://iove.net/category/quick-news" target="_blank">涂雅速涂</a> | <a href="http://iove.net/feedback" title="给我留言" target="_blank">给我留言</a> | <a href="http://iove.net/friend" title="友情链接" target="_blank">友情链接</a> | <a href="http://iove.net/about" title="关于涂雅" target="_blank">关于涂雅</a>        ]]></description>
		<wfw:commentRss>http://iove.net/archives/1964.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>36小时急行军——全面改造WordPress(解决方案)</title>
		<link>http://iove.net/archives/1877.html</link>
		<comments>http://iove.net/archives/1877.html#comments</comments>
		<pubDate>Sun, 09 May 2010 13:12:00 +0000</pubDate>
		<dc:creator>涂雅</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[旧城改造]]></category>
		<category><![CDATA[重构]]></category>

		<guid isPermaLink="false">http://iove.net/?p=1877</guid>
        <description><![CDATA[涂雅导读：我计划将首页、文章页、RSS全面拦截，因为这些内容的访问量最多，也是我最不愿意出错，最希望速度快的地方，而标签、搜索、分类列表这些内容，因为和首页功能是一样的，只是查询的条件不一样，所以也在整改之中。同时我还增加了我一直想要的功能，就是实时统计24小时/30天文章排行，而不是只有历史文章排行，现在如果我需要，我可以添加任意时间的文章排行。<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1964.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1877.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(操刀&amp;结局)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1873.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1877.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(分析)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1864.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1877.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress（诱因）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F2200.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1877.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">目前微博同步的最佳解决方案</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><br />全文：
		<h2><span style="color: #ff0000;">第三章：解决方案</span></h2>
<p>因为我本身对PHP不太熟悉，我不想选择一个我自己不熟悉的语言来做解决方案，除非我没有选择，但现在我有选择。这个解决方案是利用Asp.Net做的，实际上这个解决方案和语言无关，你可以利用Python、PHP、Java等任何你熟悉的语言来解决这个问题。</p>
<p>我准备要在读系统加一个拦截器，把用户的请求都拦截到我这里进行处理，如果我不想处理的，则交给wordpress原有的系统进行处理，这样即可以实现我的需求，又不伤害原有的系统。太捧了，就这么干！用什么拦截？答案是通过URL进行拦截，我们知道网站的请求都是基于URL的，所以我们可以采用URL Rewrite对URL进行重写，把原来由Wordpess处理的转到我的程序处理，这样无论对用户还是搜索引擎都是透明的，URL Rewrite真是个好东西。</p>
<p>在拦截器方面，我准备采用Xslt+Xml的方式进行处理，原因有四，第我有一个现成的框架，里面集成了Xslt+xml的一些理；第二，我已经多次成功应用这种解决方案，比较成熟；第三，我希望可以达到数据与实现分离，Xslt+xml正是有这种优点；第四，我希望可以在实时输出和静态页面中自由切换。</p>
<p>我计划将首页、文章页、RSS全面拦截，因为这些内容的访问量最多，也是我最不愿意出错，最希望速度快的地方，而标签、搜索、分类列表这些内容，因为和首页功能是一样的，只是查询的条件不一样，所以也在整改之中。同时我还增加了我一直想要的功能，就是实时统计24小时/30天文章排行，而不是只有历史文章排行，现在如果我需要，我可以添加任意时间的文章排行。</p>
<p>对于实时输出和静态页面两种方案，我分别做了处理，如果是静态页面，对于一些动态内容采用预生成，但用户访问时会Ajax向服务器重新请求的方式，如文章排行，各种统计(访问量，引用)，预生成的原因是因为我要被搜索引擎索引到，Ajax请求的原因是这些信息都比较实时，也就说用户看到的和搜索引擎看到的略有不同。</p>
<p>对于首页的最新留言、30天排行、历史排行做了缓存，因为这些数据实时性都不强，所以大家看到历史排行中的访问量和文章的访问量显示上可能会有些差别，但我觉得这个并不影响到用户的体验，无关大雅。首页留言做缓存的原因是因为我目前留言并不是很多，当用户留言时，会清缓存，这样用户就不会感觉到有延时了，如果未来留言会达到每十分钟都有留言的话，那么这个缓存就没有存在的必要了。</p>
<p><strong>小结</strong></p>
<p>选择一种你熟悉的解决的方案，但是又不能破坏现在系统的完整性，在新系统不成熟与稳定的情况下，保证新系统随时可以切换到旧系统是很有必要的，这样可以最大限度的降低对用户的干扰。</p>
<p>在语言的选择方面，尽量不要使用两种不同的语言在同一个系统，除非你以后打算都使用这种语言，我这种情况比较特殊，一方面我这不是什么大项目，二是我随时还可以切换回原来的系统，充其量也只是在wordpress的外面加了一个壳而已。</p>
<p>一个团队应该尽量<a href="http://iove.net/archives/1532.html">选择其常用的语言作为开发语言</a>，这样可以避免出现不可控的情况，也可以充分发挥以前累积下来的开发成果。我就曾经见过一个项目，最开始是Java的，还没搞完老板觉得不行，又换成.Net，后来又换了一批人搞，换成了Java，再后来据说又来了一个北大的牛人，换成了PHP，再后来——没了。</p>
<p>很多时候，这些语言并没有多大的区别，但每个人肯定都会推荐自己熟悉的语言，否则自己不是要失业了，你说你要是做Java的推荐老板用PHP，那你不是没饭吃了。所以有些时候某些决策人会听信某些牛人去切换某种语言，实际我认为这些牛人是不负责任的，我之前也在我的博客谈到一篇关于语言选择的文章，有兴趣可以去看一下，在这里我就不再多谈关于语言的选择了。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1964.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1877.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(操刀&amp;结局)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1873.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1877.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(分析)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1864.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1877.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress（诱因）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F2200.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1877.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">目前微博同步的最佳解决方案</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>©<a target="_blank" href="http://iove.net/">涂雅</a>，本文链接地址为<a target="_blank" href="http://iove.net/archives/1877.html">http://iove.net/archives/1877.html</a>，转载请保留此链接，否则视为侵权。<hr />标签：<a href="http://iove.net/tag/wordpress" rel="tag">wordpress</a>,<a href="http://iove.net/tag/%e6%97%a7%e5%9f%8e%e6%94%b9%e9%80%a0" rel="tag">旧城改造</a>,<a href="http://iove.net/tag/%e9%87%8d%e6%9e%84" rel="tag">重构</a> 分类：<a href="http://iove.net/category/tech" title="查看 IT技术 的全部文章" rel="category tag">IT技术</a>,<a href="http://iove.net/category/tech/wordpress-tech" title="查看 wordpress 的全部文章" rel="category tag">wordpress</a><h3>联系涂雅</h3><a target="_blank" href="http://t.sina.com.cn/conisyi/">新浪微博</a> | <a target="_blank" href="http://t.qq.com/conisyi">腾讯微博</a>| <a target="_blank" href="http://twitter.com/conisyi">Twitter</a> | <a target="_blank" href="http://www.facebook.com/facebook">Facebook</a> | <a target="_blank" href="https://www.google.com/reader/shared/conis.yi">Google Reader</a> | E-Mail：conis.yi<img src="http://iove.net/images/mailat.gif">gmail.com<br /><h3>涂雅导航</h3><a href="http://iove.net/category/it-comment" target="_blank">IT评论</a> | <a href="http://iove.net/category/tech" target="_blank">IT技术</a> | <a href="http://iove.net/category/quick-news" target="_blank">涂雅速涂</a> | <a href="http://iove.net/feedback" title="给我留言" target="_blank">给我留言</a> | <a href="http://iove.net/friend" title="友情链接" target="_blank">友情链接</a> | <a href="http://iove.net/about" title="关于涂雅" target="_blank">关于涂雅</a>        ]]></description>
		<wfw:commentRss>http://iove.net/archives/1877.html/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>36小时急行军——全面改造WordPress(分析)</title>
		<link>http://iove.net/archives/1873.html</link>
		<comments>http://iove.net/archives/1873.html#comments</comments>
		<pubDate>Sat, 08 May 2010 11:49:22 +0000</pubDate>
		<dc:creator>涂雅</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[旧城改造]]></category>
		<category><![CDATA[重构]]></category>

		<guid isPermaLink="false">http://iove.net/?p=1873</guid>
        <description><![CDATA[涂雅导读：上一章谈到要改造wordpress的诱因，那么这一章我将做一个分析，如何改造这个wordpress，会有哪些困难，需求是什么？
...
重构实际上很困难，特别是一些前期规划不好的系统，很多时候我们不愿意将原来的系统完全推倒，因为这样我们一方面要面临未知的风险，另一方面我们也不愿意浪费原有的投入。对于决策者来说，你怎么让他相信，你重构之后的收益如何呢？原来的问题还会存在吗？或者这个时候，我们采用产品化的方案，将系统产品化为若干个产品，然后产品之间通过接口进行组合，使系统松散耦合。这样一方面可以使重构不那么大面积，降低风险，另一方面也将原来铁板一块的系统逐个击破，化整为零。<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1864.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1873.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress（诱因）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1877.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1873.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(解决方案)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1964.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1873.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(操刀&amp;结局)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1770.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1873.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">实战旧城改造之——重构wordpress</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><br />全文：
		<h2><span style="color: #ff0000;">第二章：分析</span></h2>
<p><a href="http://iove.net/archives/1864.html">这个诱因</a>有没有让你觉得有点似曾相识？很多时候我们自己公司的网站也处在这种情况，随着业务的增加、变更和访问量的增加，原来的网站已经是岌岌可危，不改不行。可是一改又牵一发动全身，真是动也要死，不动也要死。有个朋友在看了我的《<a href="http://iove.net/archives/1687.html">你有勇气重构么</a>》留了一个言，说晚改早死，早改晚死。有句话是这么说的，你去做了，可能还有一丝机会，你不去做，就完完全没有机会了。</p>
<p>像这种项目就是典型的旧城改造项目，我们需要不影响原有的业务（我不想让我的博客停了），但我们又需要修改系统以适用于新的需求。在业务系统正在运行的情况下，我们需要让新系统和旧系统很好的衔接，达到平稳过度，好像有点像权力交接，没错啦，就可以理解为权力交接。</p>
<p>我把Wordress分成读系统和写系统，读系统就是各位读者大大们看到的部分了，而写部分就是我天天辛辛苦苦输入的地方了，呵呵，也就是传说中的后台，wordpress中的wp-admin部分。Wordpress主要的压力来自于读系统，而写系统一方面使用比较少，插件也会比较少，另一方面我自己用就算出出错也没有关系，自己可以接受。但是各位看到的部分，我怎么能容许它出错呢？我怎么能容忍它如此之慢呢？狮可忍，鼠不可忍，哈哈。</p>
<p>有两种大方向的解决方案，一种是完全抛弃现在的Wordpress，完全我自己写一个新的博客系统，这样我就可以完全控制整个系统的任何部分，因为我自己写的我会非常熟悉。我估计我要自己写一个小博客系统的话，可能需要花半个月的时间，再加上功能的完善，估计得花上一个月的时间了。但很快这种方案就被我否决了，第一个原因是我会花大多的时间在改造博客上去，而没有精力去做其它事情，而另一个原因是我需要Wordpress的很多功能，比如说Pingback，Trackback，Google Sitemap的生成和Google的通知，但我而对这些东西的规则却不是很了解，如果我要去完成这些东西，所花的代价将会太大了。</p>
<p>那么现在只有一条路了，修改Wordpress！怎么改？改多少？这是一个问题。我首先拟定几个原则：</p>
<ol>
<li>WordPress我以后还要用，要升级，所以我不想直接修改wordpress中的代码</li>
<li> 因为服务器的原因，我想实现静态化</li>
<li>要对用户透明，对搜索引擎透明，不能因为更改而导致Url的变更</li>
<li>减小文件请求数，减小Javascript和CSS</li>
</ol>
<p>最初考虑的是使用Html静态化的插件，但找了两个插件，包括月光所推荐的一个插件，但我很快就发现这个插件不太适合我，如果我要实现我的功能，我还得去修改这个插件，以我这样半吊子的PHP水平，指不定还有什么错误等着我。</p>
<p><strong>小结</strong></p>
<p>重构实际上很困难，特别是一些前期规划不好的系统，很多时候我们不愿意将原来的系统完全推倒，因为这样我们一方面要面临未知的风险，另一方面我们也不愿意浪费原有的投入。对于决策者来说，你怎么让他相信，你重构之后的收益如何呢？原来的问题还会存在吗？或者这个时候，我们采用产品化的方案，将系统产品化为若干个产品，然后产品之间通过接口进行组合，使系统松散耦合。这样一方面可以使重构不那么大面积，降低风险，另一方面也将原来铁板一块的系统逐个击破，化整为零。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1864.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1873.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress（诱因）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1877.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1873.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(解决方案)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1964.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1873.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(操刀&amp;结局)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1770.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1873.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">实战旧城改造之——重构wordpress</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>©<a target="_blank" href="http://iove.net/">涂雅</a>，本文链接地址为<a target="_blank" href="http://iove.net/archives/1873.html">http://iove.net/archives/1873.html</a>，转载请保留此链接，否则视为侵权。<hr />标签：<a href="http://iove.net/tag/wordpress" rel="tag">wordpress</a>,<a href="http://iove.net/tag/%e6%97%a7%e5%9f%8e%e6%94%b9%e9%80%a0" rel="tag">旧城改造</a>,<a href="http://iove.net/tag/%e9%87%8d%e6%9e%84" rel="tag">重构</a> 分类：<a href="http://iove.net/category/tech" title="查看 IT技术 的全部文章" rel="category tag">IT技术</a>,<a href="http://iove.net/category/tech/wordpress-tech" title="查看 wordpress 的全部文章" rel="category tag">wordpress</a><h3>联系涂雅</h3><a target="_blank" href="http://t.sina.com.cn/conisyi/">新浪微博</a> | <a target="_blank" href="http://t.qq.com/conisyi">腾讯微博</a>| <a target="_blank" href="http://twitter.com/conisyi">Twitter</a> | <a target="_blank" href="http://www.facebook.com/facebook">Facebook</a> | <a target="_blank" href="https://www.google.com/reader/shared/conis.yi">Google Reader</a> | E-Mail：conis.yi<img src="http://iove.net/images/mailat.gif">gmail.com<br /><h3>涂雅导航</h3><a href="http://iove.net/category/it-comment" target="_blank">IT评论</a> | <a href="http://iove.net/category/tech" target="_blank">IT技术</a> | <a href="http://iove.net/category/quick-news" target="_blank">涂雅速涂</a> | <a href="http://iove.net/feedback" title="给我留言" target="_blank">给我留言</a> | <a href="http://iove.net/friend" title="友情链接" target="_blank">友情链接</a> | <a href="http://iove.net/about" title="关于涂雅" target="_blank">关于涂雅</a>        ]]></description>
		<wfw:commentRss>http://iove.net/archives/1873.html/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>36小时急行军——全面改造WordPress（诱因）</title>
		<link>http://iove.net/archives/1864.html</link>
		<comments>http://iove.net/archives/1864.html#comments</comments>
		<pubDate>Fri, 07 May 2010 10:00:00 +0000</pubDate>
		<dc:creator>涂雅</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[旧城改造]]></category>
		<category><![CDATA[重构]]></category>

		<guid isPermaLink="false">http://iove.net/?p=1864</guid>
        <description><![CDATA[涂雅导读：　　Hi, guys，如果你以前也来过我的博客，有没有觉得我的博客现在有没有觉得快一些？如果快一些给我留个言，要是都没觉得快我就白干了，哈哈。反正我现在访问速度是比较以前快了，而且可用率也基本上达到了100%（天灾人祸那种极端的情况就不说了），而且我的博客也增加了不少功能，比如说查看所有评论，访问24小时排行，RSS的一些新功能……来看看我是怎么折腾我的Wordpress吧<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1964.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1864.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(操刀&amp;结局)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1877.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1864.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(解决方案)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1873.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1864.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(分析)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1770.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1864.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">实战旧城改造之——重构wordpress</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><br />全文：
		<h2><span style="color: #99cc00;">涂雅导读</span></h2>
<p>前段时间网站的访问量略有上升，眼看着正在向好的方面发展，可是wordpress频频给我掉链子，我一气之下<a href="http://iove.net/archives/1770.html">决定将wordpress进行整改</a>，从我开始改造到上线，大约花了36小时的时间。通过这种次造，网站的速度得到了大大的提升（虽然还是不太快，这和国外服务器有关），也增加了不少的功能，如24小时访问排行、1个月访问排行；显示留言者的地理位置；减小了CSS和JS文件的大小和数量；首页及RSS、文章页完全实现静态化；为RSS输出增加了24小时排名的功能等等。</p>
<p>我是把这次改造当成一个小项目来做的，我也想通过这次改造来聊聊项目管理以及重构的一些看法，就如同我上次在一篇文章中问道：<a href="http://iove.net/archives/1687.html">你有勇气构么？</a>就这一个小小的项目，我们仍然可以看到许多项目管理中的特点，我们需要用有限的资源和有限的时间来满足无限的需求。最后我们需要在项目管理的铁三角(时间、成本、质量)中进行妥协调配，来达到需求方满意的结果。</p>
<p>对于程序员来说，我觉得这样的项目也会有启发意义，我们程序员常常会问，为什么老是改需求，为什么老是增加需求？我想如果你自己试试去做一下你自己的项目，并确定一个完成时间，你就会发现你自己也会变更需求，如果我们自己给自己做项目都会变更需求，那么为什么客户不会变更需求呢？</p>
<h2><span style="color: #ff0000;">第一章：诱因</span></h2>
<p>WordPress是一个很优秀的Blog程序，它非常地灵活，和Firefox一样支持插件，所以世界有许许多的程序员为它开发插件，我也曾经为它开发过<a href="http://iove.net/archives/1344.html">一款名为wp-markKeyword的插件</a>。但正是因为它的插件机制，所以在性能方面，wordpress不是太好，我想原因有两个。<br />
第一个是因为开发者的水平参差不齐，就像我这个PHP新手也可以开发了一个插件放到了wordpress的官网上，这样你所使用插件难免会有些存着Bug。而正是因为Wordpress的灵活性，所以你想实现的功能基本上都需要插件，大到垃圾过滤这样的功能，小到将引号正常输出这样的功能，你都需要装一个插件，所以一般wordpress的博主基本上要装10个以上的插件。</p>
<p>第二个原因则是由wordpress的机制造成了，wordpress采用插件机制，所以很多功能都需要一个Hook（钩子，以前开发Windows程序常常会用到），这样你一个很简单的功能，可能会被插件截获N次，而在这么多插件的N次Hook中，一方面存在性能的损耗，另一方面也存在着逻辑错误的隐忧。加上Wordpress对插件的审核极为宽松（反正我开发的两款插件都放上去了），不如Apple Store般的严格，不过Apple Store可是要收开发者99美金一年的:p</p>
<p>我的服务器是Godaddy的虚拟主机，用过国外主机的朋友们都知道，一是天灾二是人祸，国外虚拟主机基本上一个月总有那么几天，一天总有那么几次，有时候是Godaddy本身的问题，有时候可能是其他不能说的原因。</p>
<p>所以就这样Wordpress的原因加上服务器的原因，导致我的博客在最极端的时候一天的可用率只有80%左右，所以我常常去51.la去看在线人数，当在线人数为0的时候，我就咯噔一下，是不是网站又不能访问了，基本去访问的时候都会有这样的情况。经历几次折腾之后，我实在受不了了，好歹也是个程序员，怎么能这样下去呢？于是下决心要解决这个问题，经过初步分析，发现常常不能访问的情况是php执行超时错误，经过停掉所的插件再启用插件，发现simple tags极为可疑，反正我是停掉这个插件后错误频率会降低，但还是会存在这种错误。而且我发现在出错的时候，静态文件是可以访问的，说明了什么？说明静态内容没有问题呗，要么是程序的问题，要么是服务器做了限制。</p>
<p>经过多次排查，我受不了了，看来小打小闹是终不是长久之计啊，本着我等DIY的程序员精神，怎么也得把家伙给折腾了，说干就干，立马操刀。</p>
<p><strong>小结</strong></p>
<p>如果我们发现系统不能满足现在的需求，我们就需要重构，很多人一听重构，就认为是那种推倒重来。实际上我们可以用一种逐步改造的方式达到平稳过渡，慢慢迁移到新的系统中来。我们也不能因为麻烦就不去重构，当我们发现修改的成本在急剧增加的时候，将我们发现系统在频频出问题的时候，重构可能就要开始了！</p>
<p><span style="color: #ff0000;">未完待续，准备写成四集连载&#8230;</span></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1964.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1864.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(操刀&amp;结局)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1877.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1864.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(解决方案)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1873.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1864.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(分析)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1770.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1864.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">实战旧城改造之——重构wordpress</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>©<a target="_blank" href="http://iove.net/">涂雅</a>，本文链接地址为<a target="_blank" href="http://iove.net/archives/1864.html">http://iove.net/archives/1864.html</a>，转载请保留此链接，否则视为侵权。<hr />标签：<a href="http://iove.net/tag/wordpress" rel="tag">wordpress</a>,<a href="http://iove.net/tag/%e6%97%a7%e5%9f%8e%e6%94%b9%e9%80%a0" rel="tag">旧城改造</a>,<a href="http://iove.net/tag/%e9%87%8d%e6%9e%84" rel="tag">重构</a> 分类：<a href="http://iove.net/category/tech" title="查看 IT技术 的全部文章" rel="category tag">IT技术</a>,<a href="http://iove.net/category/tech/wordpress-tech" title="查看 wordpress 的全部文章" rel="category tag">wordpress</a><h3>联系涂雅</h3><a target="_blank" href="http://t.sina.com.cn/conisyi/">新浪微博</a> | <a target="_blank" href="http://t.qq.com/conisyi">腾讯微博</a>| <a target="_blank" href="http://twitter.com/conisyi">Twitter</a> | <a target="_blank" href="http://www.facebook.com/facebook">Facebook</a> | <a target="_blank" href="https://www.google.com/reader/shared/conis.yi">Google Reader</a> | E-Mail：conis.yi<img src="http://iove.net/images/mailat.gif">gmail.com<br /><h3>涂雅导航</h3><a href="http://iove.net/category/it-comment" target="_blank">IT评论</a> | <a href="http://iove.net/category/tech" target="_blank">IT技术</a> | <a href="http://iove.net/category/quick-news" target="_blank">涂雅速涂</a> | <a href="http://iove.net/feedback" title="给我留言" target="_blank">给我留言</a> | <a href="http://iove.net/friend" title="友情链接" target="_blank">友情链接</a> | <a href="http://iove.net/about" title="关于涂雅" target="_blank">关于涂雅</a>        ]]></description>
		<wfw:commentRss>http://iove.net/archives/1864.html/feed</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>今天晚上博客停掉约4个小时</title>
		<link>http://iove.net/archives/1803.html</link>
		<comments>http://iove.net/archives/1803.html#comments</comments>
		<pubDate>Sun, 02 May 2010 16:24:50 +0000</pubDate>
		<dc:creator>涂雅</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[改版]]></category>

		<guid isPermaLink="false">http://iove.net/?p=1803</guid>
        <description><![CDATA[涂雅导读：　　首先向访问的朋友说说声对不起，今天晚上许多来访者吃了个闭门羹，呵呵，不过我一直在处理，直到刚才才处理好，因为我家里的网速比较慢，所以排查问题花了不少时间。
...
　　说下排查的经过吧，我现在的博客是我前几天花了一些时间加了一个拦截器，增加了24小时排行版、30天排行版、访客留言添加了所在位置、不少数据都做了缓存处理等功能，这部分的改造我下次将会讲到。由于我采用的解决方案是由xslt+xml实时生成内容输出到页面，所以当某个用户访问了这个页面的时候，就出现了我前面讲到的问题。<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1864.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1803.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress（诱因）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1873.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1803.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(分析)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1877.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1803.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(解决方案)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1046.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1803.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">博客搬家地址改变——升级版</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><br />全文：
		<p>　　首先向访问的朋友说说声对不起，今天晚上许多来访者吃了个闭门羹，呵呵，不过我一直在处理，直到刚才才处理好，因为我家里的网速比较慢，所以排查问题花了不少时间。<br />
　　问题的起因是由于我的一篇文章《实战设计模式之用组合模式实现JSON（六）》，ID为808的文章造成的，由于这篇文章是从word中复制过去了，当中包含了一些特殊字符（目前是估计，我还没有去查这篇文章，删除这篇文章问题已经解决，所以判断是包含特殊字符或者内容），造成了.net在作xslt+xml转换的时候CPU 100%运转，而我的服务器提供商Godaddy似乎有相应保护机制，当某个虚拟主机的CPU占用率超过设定值的时候，会自动停止这个虚拟主机的动态内容服务，为什么说只停动态内容呢，因为静态页面是一直可以访问的。<br />
　　说下排查的经过吧，我现在的博客是我前几天花了一些时间加了一个拦截器，增加了24小时排行版、30天排行版、访客留言添加了所在位置、不少数据都做了缓存处理等功能，这部分的改造我下次将会讲到。由于我采用的解决方案是由xslt+xml实时生成内容输出到页面，所以当某个用户访问了这个页面的时候，就出现了我前面讲到的问题。<br />
　　其实我使用xslt+xml做解决方案已经有三年了，我蛮喜欢这种解决方案的，可以达到数据和实现的完美分离。不过缺点也是有的，比如说xml对数据的要求很高，一方面是xml的元字符，而最重要的一点，则是编码问题，如果你采用了utf8做解释，而你的数据中包含unicode特殊字符的时候，肯定会出现错误。我以前就曾经出一过人民币符号解释出错的问题，后来采用了&ren;，但偶尔还是会出错，最后只好全部采用了gb2312进行解释。<br />
　　另外如果你是用.net进行xslt+xml的解释，还要注意一个问题，就是代码执行权限要求是Full Trust Level，而大部虚拟主机都是High Trust Level或者Medium Trust Level的，当然如果你是自己的服务器就不会存在这个问题了:P。<br />
　　之前在设计这个拦截器的就时候就准备了两种方案，一种是直接读数据库＋缓存，另一种是直接生成静态页面，生成静态页面的好处是只要服务器没有宕机就可以访问，但不好的地方是实时性不强，所以我在24小时排行等地方都采用了Ajax进行获取。所以这次有问题之后我就考虑干脆使用静态页面方案算了，速度上肯定会比较快，而且不会受服务器的影响，毕竟虚拟主机谁都有可能占用CPU100%，如果是使用静态页只要主机不挂掉，基本上都可以保证能访问。<br />
　　最终查出问题的是生成静态面的时候，当到了808（呵，这个ID真不错，可惜没干好事），发现我本机的CPU占用100%，一查进程，是w3wp这个进程一直在100%地占用着CPU，郁闷 。<br />
　　刚刚又发现一个奇怪的问题，如果我使用aspx直接去访问某个页面，会了直处理请求状态，服务器一直无响应，但如果我使用url rewite重写一个非aspx的url，则可以访问，在我本地没事，奇怪，有知道的朋友告诉一声是怎么回事。另外还有一个奇怪的问题，我数据库链接是使用using，但却报连接池超时的错误，甚至导致mysql不能访问（或者是巧合，godaddy的服务器经常性不能访问），本地没有发现问题。<br />
　　呵呵，现在是凌晨0点47分，发现还有十来个人正在访问我博客，同志们，你们辛苦了，这么晚了也要注意休息哈，我是来不起了，准备一会儿去见周公，你们也跟随我吧，哈哈。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1864.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1803.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress（诱因）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1873.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1803.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(分析)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1877.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1803.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(解决方案)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1046.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1803.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">博客搬家地址改变——升级版</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>©<a target="_blank" href="http://iove.net/">涂雅</a>，本文链接地址为<a target="_blank" href="http://iove.net/archives/1803.html">http://iove.net/archives/1803.html</a>，转载请保留此链接，否则视为侵权。<hr />标签：<a href="http://iove.net/tag/net" rel="tag">.net</a>,<a href="http://iove.net/tag/wordpress" rel="tag">wordpress</a>,<a href="http://iove.net/tag/%e6%94%b9%e7%89%88" rel="tag">改版</a> 分类：<a href="http://iove.net/category/tech/dot-net" title="查看 .Net 的全部文章" rel="category tag">.Net</a>,<a href="http://iove.net/category/tech/wordpress-tech" title="查看 wordpress 的全部文章" rel="category tag">wordpress</a><h3>联系涂雅</h3><a target="_blank" href="http://t.sina.com.cn/conisyi/">新浪微博</a> | <a target="_blank" href="http://t.qq.com/conisyi">腾讯微博</a>| <a target="_blank" href="http://twitter.com/conisyi">Twitter</a> | <a target="_blank" href="http://www.facebook.com/facebook">Facebook</a> | <a target="_blank" href="https://www.google.com/reader/shared/conis.yi">Google Reader</a> | E-Mail：conis.yi<img src="http://iove.net/images/mailat.gif">gmail.com<br /><h3>涂雅导航</h3><a href="http://iove.net/category/it-comment" target="_blank">IT评论</a> | <a href="http://iove.net/category/tech" target="_blank">IT技术</a> | <a href="http://iove.net/category/quick-news" target="_blank">涂雅速涂</a> | <a href="http://iove.net/feedback" title="给我留言" target="_blank">给我留言</a> | <a href="http://iove.net/friend" title="友情链接" target="_blank">友情链接</a> | <a href="http://iove.net/about" title="关于涂雅" target="_blank">关于涂雅</a>        ]]></description>
		<wfw:commentRss>http://iove.net/archives/1803.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>实战旧城改造之——重构wordpress</title>
		<link>http://iove.net/archives/1770.html</link>
		<comments>http://iove.net/archives/1770.html#comments</comments>
		<pubDate>Mon, 26 Apr 2010 16:00:59 +0000</pubDate>
		<dc:creator>涂雅</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[互联网]]></category>
		<category><![CDATA[旧城改造]]></category>
		<category><![CDATA[重构]]></category>

		<guid isPermaLink="false">http://iove.net/?p=1770</guid>
        <description><![CDATA[涂雅导读：凡事需要讲一个动机，搞IT的人都知道，我们现在的程序都是事件驱动的，而重构也是一样的，前段时间我在博客中讲到”你有勇气重构么？”，没想到我很快就出现这样的问题。我把本系列文章取名叫旧城改造，是因为我觉得现在很多网站和旧城改造一样，旧城已经不能满足需要了，但旧城里人口众多，不可能推倒重建。 Wordpress只是一个很小的程序，我计划花一个周期的休息时间来改造，但我希望可以通过这次改造抛砖引玉，给大家提供一个参考。<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1864.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1770.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress（诱因）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1964.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1770.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(操刀&amp;结局)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1873.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1770.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(分析)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1877.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1770.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(解决方案)</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><br />全文：
		<h2><span style="color: #ff0000;">为什么？</span></h2>
<p>凡事需要讲一个动机，搞IT的人都知道，我们现在的程序都是事件驱动的，而重构也是一样的，前段时间我在博客中讲到”<a href="http://iove.net/archives/1687.html">你有勇气重构么？</a>”，没想到我很快就出现这样的问题。我把本系列文章取名叫旧城改造，是因为我觉得现在很多网站和旧城改造一样，旧城已经不能满足需要了，但旧城里人口众多，不可能推倒重建。Wordpress只是一个很小的程序，我计划花一个周期的休息时间来改造，但我希望可以通过这次改造抛砖引玉，给大家提供一个参考。</p>
<p>WordPress是一个非常不错的博客程序，最重要的是，它支持各种各样的插件，全世界有成千上万的开发者在开发各有有趣的应用，和Firefox一样，如果没有插件，wordpress什么也不是。</p>
<p>问题就出在这里，因为插件的开发者水平可能也是参差不齐，插件是通过Hook进行的，所以一个页面可能经过大量的Hook，甚至有Bug的存在。访问量少还好一些，当访问量和订阅量大点的时候，就经常出现了超时错误和其它的一些500错误。同时网站速度非常慢，alexa的评分是19分，也就是只有19%的网站比我的网站慢。一方面给用户的体验不好，另一方面对SEO也是很不好的。再者就是我觉得博客的文件链接数太多，像javascript和css不同插件有不同的文件，导致了有很多的文件链接数。我大概总结了一些，现在有以下问题需要改进：</p>
<ol>
<li>网站常常报出500错误，造成用户的流失，同时对搜索引擎也非常不友好</li>
<li>速度太慢，分两个方面，一个是程序太慢，另一方面是由于每个插件都有自己的js和css，造成css和js过多，虽然这些文件都不大，但是每次http请求都要消耗时间，造成速度过慢</li>
<li>我希望有24小时、昨天、本周、本月、本年的阅读排行，但目标没有找到合适的插件</li>
<li>近来可能有采集站在做采集，希望可以对这个进行一些防范</li>
<li> 觉得用户体验不太好，希望可以加强和用户的互动</li>
</ol>
<h2><span style="color: #ff0000;">目标？</span></h2>
<ol>
<li> 响应速度在2000毫秒以内</li>
<li>下载速度（用户看到整个页面的内容）不超过10秒</li>
<li>基本杜绝500错误，除非服务器出现问题</li>
<li>可以支撑三倍于现在的访问量</li>
<li>Yslow测试可以在b级以上，最好在A级</li>
<li>良好的可扩展性，可以添加更多的功能（主要是前端的功能）</li>
</ol>
<h2><span style="color: #ff0000;">分析？</span></h2>
<p>根据现状以及目标进行分析，发现主要问题是在于读数据上，浏览者可能写数据主要是两个地方，一个是留言，另一个是访问量统计，数据的变动性比较少。改造有两种方法，一种是自己写一个博客，另一个是在wordpress上修改。自己写控制起来肯定非常方便，但工作量会太大，而且wordress有很多功能是我需要的，比如说pingback，比如说Google XML Sitemaps的功能等等，这些功能如果要自己写的话，需要花很多的时间。</p>
<p>修改wordpress也有些问题，因为我本身对php不熟悉，并且我认为wordpress这种hook来hook去的，比较浪费资源。尝试过几种静态化插件，但发现都不能满足我的需求。根据前面的分析，速度慢主要是针对用户来说的，而用户主要是在读数据，那么我们可以这样，把读数据端进行改造，而写数据端，也就是后台部分保留。这样即可以利用现有wordpress的功能，又可以实现用户访问速度的提升。<strong> </strong></p>
<p><strong>思路</strong></p>
<ol>
<li>首页和文章页生成静态页，在文章被更新、删除、添加的时候触发。也可以使用手动</li>
<li>重写前端代码，包括JS/CSS/Html</li>
<li>评论及访问量的统计、评论采用Ajax读取，在用户已经下载完数据再数据，以提供响应速度，因为用户并不急着看评论</li>
<li>用户访问文章的时候，通过Ajax向服务器提交，服务器将记录用户的访问信息</li>
<li>RSS必需静态化，因为各RSS阅读器会定期访问服务器，这也会造成服务器的压力</li>
<li>适当的时候，可以选择把首页和一些访问量大的页面进行缓存</li>
</ol>
<p><strong>原则</strong></p>
<ol>
<li>不改变现有的wordpress的任何代码，需要在发布文章的时候添加一个hook，以插件的方式实现，功能很简单</li>
<li>不改变现在的url，对用户和搜索引擎透明</li>
<li>随时还可以切换到wordpress</li>
</ol>
<h2><span style="color: #ff0000;">实现</span></h2>
<p>我计划使用asp.net来进行这次改造，因为我对C#比较熟悉，你也可以使用asp/php/java/pytho都没关系，最重要的我有一个C#的框架，这样可以减小许多代码量。先将数据库文章读取为xml，然后通过xslt格式化xml为静态页面并保存，然后通过url rewiter重写到新的地址。新程序需要开发的功能大概如下：</p>
<ol>
<li> 读取文章列表页</li>
<li>读取文章页</li>
<li>读取评论</li>
<li>添加评论</li>
<li>访客日志（不记录详细日志）</li>
<li>前端功能(Html/CSS/Javascript)</li>
</ol>
<h2><span style="color: #ff0000;">问题</span></h2>
<ol>
<li>采用php和C#两种语言混合是不是不太好？</li>
</ol>
<p>嗯，是不太好，但因为我使用asp.net比较熟悉，这样开发速度会比较快一些，因为我现在写的程序相当于一个拦截器，把用户读取请求都拦截起来，不会对原有的程序产生影响。同时，毕竟这不是产品级的，根据我的需求，我认为不会造成什么大的影响</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1864.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1770.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress（诱因）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1964.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1770.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(操刀&amp;结局)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1873.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1770.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(分析)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1877.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1770.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">36小时急行军——全面改造Wordpress(解决方案)</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>©<a target="_blank" href="http://iove.net/">涂雅</a>，本文链接地址为<a target="_blank" href="http://iove.net/archives/1770.html">http://iove.net/archives/1770.html</a>，转载请保留此链接，否则视为侵权。<hr />标签：<a href="http://iove.net/tag/wordpress" rel="tag">wordpress</a>,<a href="http://iove.net/tag/%e6%97%a7%e5%9f%8e%e6%94%b9%e9%80%a0" rel="tag">旧城改造</a>,<a href="http://iove.net/tag/%e9%87%8d%e6%9e%84" rel="tag">重构</a> 分类：<a href="http://iove.net/category/tech/wordpress-tech" title="查看 wordpress 的全部文章" rel="category tag">wordpress</a>,<a href="http://iove.net/category/tech/internet" title="查看 互联网 的全部文章" rel="category tag">互联网</a><h3>联系涂雅</h3><a target="_blank" href="http://t.sina.com.cn/conisyi/">新浪微博</a> | <a target="_blank" href="http://t.qq.com/conisyi">腾讯微博</a>| <a target="_blank" href="http://twitter.com/conisyi">Twitter</a> | <a target="_blank" href="http://www.facebook.com/facebook">Facebook</a> | <a target="_blank" href="https://www.google.com/reader/shared/conis.yi">Google Reader</a> | E-Mail：conis.yi<img src="http://iove.net/images/mailat.gif">gmail.com<br /><h3>涂雅导航</h3><a href="http://iove.net/category/it-comment" target="_blank">IT评论</a> | <a href="http://iove.net/category/tech" target="_blank">IT技术</a> | <a href="http://iove.net/category/quick-news" target="_blank">涂雅速涂</a> | <a href="http://iove.net/feedback" title="给我留言" target="_blank">给我留言</a> | <a href="http://iove.net/friend" title="友情链接" target="_blank">友情链接</a> | <a href="http://iove.net/about" title="关于涂雅" target="_blank">关于涂雅</a>        ]]></description>
		<wfw:commentRss>http://iove.net/archives/1770.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>更改web.config，让godady的win主机启用gzip压缩</title>
		<link>http://iove.net/archives/1538.html</link>
		<comments>http://iove.net/archives/1538.html#comments</comments>
		<pubDate>Mon, 15 Mar 2010 05:46:12 +0000</pubDate>
		<dc:creator>涂雅</dc:creator>
				<category><![CDATA[seo]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[godaddy]]></category>
		<category><![CDATA[优化]]></category>
		<category><![CDATA[速度]]></category>

		<guid isPermaLink="false">http://conis.cn/?p=1538</guid>
        <description><![CDATA[涂雅导读：使用godaddy的朋友注意了，godaddy的windows主机是可以提供gzip压缩的，但是这个gzip并不在godaddy提供的控制面版本，而是在web.config的配置中，你只需要把如下代码加入到web.config的configuration节点中，就可以实现动态压缩。<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1536.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1538.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">javascript开发经验之——压缩</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1328.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1538.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">web开发人员应该掌握的几个工具</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1617.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1538.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Closure Compiler批量压缩javascript</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1324.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1538.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">亲爱的web程序员，你看过你的源码么？</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><br />全文：
		<p>阅读本文首先确定你正在使用或者准备使用godaddy的windows虚拟主机，当然也会适合别的windows主机，同时，请确定你的虚拟主机的iis模式是7而不是6，因为godaddy同时还支持iis6模式，貌似。</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;system.webServer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;urlCompression</span> <span style="color: #000066;">doStaticCompression</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">doDynamicCompression</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/system.webServer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>我之前也为这个问题发愁，因为本身国外的网速就有点慢，如果可以启用gzip压缩的话，那么就可以加快下载速度，让用户快一些访问到网页的内容，提高用户体验。</p>
<p>使用godaddy的朋友注意了，godaddy的windows主机是可以提供gzip压缩的，但是这个gzip并不在godaddy提供的控制面版本，而是在web.config的配置中，你只需要把如下代码加入到web.config的configuration节点中，就可以实现动态压缩。</p>
<p>上图是王道，下面是我的wordpress博客启用压缩也没有启用压缩前后对比：<br />
<img title="20100315-1" src="http://images.iove.net/2010/03/20100315-1.JPG" alt="" /></p>
<p>上面是未经过压缩的监控数据</p>
<p><img title="20100315-3" src="http://images.iove.net/2010/03/20100315-3.JPG" alt="" /></p>
<p>上而是启用gzip压缩的监控数据</p>
<p>我们可以看到，没有压缩之前的首页html大小是60k，压完后就变成了19k，这个比例非常大，只有原来的1/2。<br />
<img title="20100315-2" src="http://images.iove.net/2010/03/20100315-2.JPG" alt="" /><br />
上页这个是没有经过压缩的首页总大小<br />
<img title="20100315-4" src="http://images.iove.net/2010/03/20100315-4.JPG" alt="" /></p>
<p>上页这个是压缩后的总大小，网页总大小减小了50k，因为我的网页能压缩的不太多，像jquery是经过压缩的，有些调用到外部的javascript没有办法压缩，图片也没有办法压缩，所以压缩比例并不高，只是15%而已。如果你的网站图片不多，javascript和文字性的内容比较多，压缩比较应该会更大一些。</p>
<p>不过有些奇怪的是，css好像并没有经过压缩，按道理应该是支持静态压缩的。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1536.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1538.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">javascript开发经验之——压缩</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1328.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1538.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">web开发人员应该掌握的几个工具</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1617.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1538.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Closure Compiler批量压缩javascript</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1324.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1538.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">亲爱的web程序员，你看过你的源码么？</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>©<a target="_blank" href="http://iove.net/">涂雅</a>，本文链接地址为<a target="_blank" href="http://iove.net/archives/1538.html">http://iove.net/archives/1538.html</a>，转载请保留此链接，否则视为侵权。<hr />标签：<a href="http://iove.net/tag/godaddy" rel="tag">godaddy</a>,<a href="http://iove.net/tag/seo" rel="tag">seo</a>,<a href="http://iove.net/tag/%e4%bc%98%e5%8c%96" rel="tag">优化</a>,<a href="http://iove.net/tag/%e9%80%9f%e5%ba%a6" rel="tag">速度</a> 分类：<a href="http://iove.net/category/tech/seo-tech" title="查看 seo 的全部文章" rel="category tag">seo</a>,<a href="http://iove.net/category/tech/wordpress-tech" title="查看 wordpress 的全部文章" rel="category tag">wordpress</a><h3>联系涂雅</h3><a target="_blank" href="http://t.sina.com.cn/conisyi/">新浪微博</a> | <a target="_blank" href="http://t.qq.com/conisyi">腾讯微博</a>| <a target="_blank" href="http://twitter.com/conisyi">Twitter</a> | <a target="_blank" href="http://www.facebook.com/facebook">Facebook</a> | <a target="_blank" href="https://www.google.com/reader/shared/conis.yi">Google Reader</a> | E-Mail：conis.yi<img src="http://iove.net/images/mailat.gif">gmail.com<br /><h3>涂雅导航</h3><a href="http://iove.net/category/it-comment" target="_blank">IT评论</a> | <a href="http://iove.net/category/tech" target="_blank">IT技术</a> | <a href="http://iove.net/category/quick-news" target="_blank">涂雅速涂</a> | <a href="http://iove.net/feedback" title="给我留言" target="_blank">给我留言</a> | <a href="http://iove.net/friend" title="友情链接" target="_blank">友情链接</a> | <a href="http://iove.net/about" title="关于涂雅" target="_blank">关于涂雅</a>        ]]></description>
		<wfw:commentRss>http://iove.net/archives/1538.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>新年刚过，发布一个生成POT文件的小工具</title>
		<link>http://iove.net/archives/1529.html</link>
		<comments>http://iove.net/archives/1529.html#comments</comments>
		<pubDate>Sun, 21 Feb 2010 05:37:06 +0000</pubDate>
		<dc:creator>涂雅</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[随笔]]></category>
		<category><![CDATA[mo]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[pot]]></category>
		<category><![CDATA[国际化]]></category>
		<category><![CDATA[多语言]]></category>
		<category><![CDATA[工具]]></category>

		<guid isPermaLink="false">http://conis.cn/?p=1529</guid>
        <description><![CDATA[涂雅导读：这段时间一直弄PHP，觉得PHP还是蛮不错的，最关键的是LAMP都是免费的，虽然说目前国内盗版泛滥无所谓，但对于大公司来说还得用正版，如果用其它开发语言，在数据库和服务器软件都是一笔不小的支出。闲话少说，用PHP做多国语言的时候，都会用到一个GetText，GetText好是好，可是POT文件得自己手动一个一个添加，麻烦不说，还容易出错，容易漏掉。

抽空自己用.net做了一个工具，这个工具就是专门搜索php文件中的__()函数以及_e()函数，然后提取其中的字符串，生成POT格式的文本文件。<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="代码生成工具CodeRobot 1.5版发布" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F781.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1529.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/12/17/12481698.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">代码生成工具CodeRobot 1.5版发布</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="新手入门——Ophone(Android)开发项目文件结构" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1225.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1529.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/12/17/12480256.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">新手入门——Ophone(Android)开发项目文件结构</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="发布基于jQuery的灯箱广告插件momoSlideShow" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1497.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1529.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/12/17/12480814.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">发布基于jQuery的灯箱广告插件momoSlideShow</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="发布一个基于javascript的日期扩展" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fiove.net%2Farchives%2F1408.html&from=http%3A%2F%2Fiove.net%2Farchives%2F1529.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">发布一个基于javascript的日期扩展</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><br />全文：
		<br />
<b>Fatal error</b>:  Maximum execution time of 30 seconds exceeded in <b>D:\Hosting\4246813\html\subsite\iove.net\wp-content\plugins\wumii-related-posts\wumii-related-posts.php</b> on line <b>192</b><br />

