<?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; PHP</title>
	<atom:link href="http://blog.upsuper.org/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.upsuper.org</link>
	<description>the place where there are some ghost appearing...</description>
	<lastBuildDate>Thu, 17 Jun 2010 08:12:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>新空间</title>
		<link>http://blog.upsuper.org/my-new-web-space/</link>
		<comments>http://blog.upsuper.org/my-new-web-space/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 15:11:20 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[探究学习]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[CGI]]></category>
		<category><![CDATA[My Blog]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[和谐]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=1069</guid>
		<description><![CDATA[由于某些众所周知的原因，我准备将空间搬到米国去了。由于另一个众所周知的原因，现在的域名也将很快停止使用。
我已经申请好了新的空间，近期可能就要搬过去了。先做个广告：在此诚招空间合租者一位，无限空间无限流量，PHP、Python、Perl、RoR、CGI、CGI-BIN、MySQL、PgSQL 全功能 Linux 空间，可自定义 php.ini，提供域名对应的邮箱储存、邮箱别名服务，支持 POP3、IMAP、邮件列表，独立 FTP 管理，带免费自签名证书的 SSL 服务，含一个免费域名及一个独立 IP，3年共计525元RMB。有意者邮箱联系 quanxunzhen@gmail.com
不过因为新空间还没摸索清楚，还在研究搬迁事宜。

下面讲讲今天的探索……这个新空间的 PHP 用了 CGI 的模式，而不是传统（或者说我熟悉的）PHP Module 的模式，而且作为 CGI 的 php 解析程序和 php.ini 配置文件也是放在网站的 cgi-bin 目录里面的，因此我怀疑可玩性很高，甚至可以自己编译 PHP 放上去用。不过这个空间有一个很麻烦的，就是不支持自动的泛域名匹配，这大大的不如现在的这个空间方便。不过经过一番研究，也并不是没有办法的。今天才算是第一次体会到了 Apache mod_rewrite 的强大！
本来以为 rewrite 不能实现那样功能的，因为似乎 rewrite 不能把主机名弄进来匹配，结果发现我想错了。参考了一些 Apache 的官方资料，我发现 Apache 的官方文档里有一种很有趣的方式间接实现泛域名到子文件夹的匹配，大约是这个样子的：

1
2
3
4
RewriteEngine on
RewriteCond   %{HTTP_HOST}             [...]]]></description>
			<content:encoded><![CDATA[<p>由于某些众所周知的原因，我准备将空间搬到米国去了。由于另一个众所周知的原因，现在的域名也将很快停止使用。</p>
<p>我已经申请好了新的空间，近期可能就要搬过去了。先做个广告：<strong>在此诚招空间合租者一位，无限空间无限流量，PHP、Python、Perl、RoR、CGI、CGI-BIN、MySQL、PgSQL 全功能 Linux 空间，可自定义 php.ini，提供域名对应的邮箱储存、邮箱别名服务，支持 POP3、IMAP、邮件列表，独立 FTP 管理，带免费自签名证书的 SSL 服务，含一个免费域名及一个独立 IP，3年共计525元RMB。有意者邮箱联系 <a href="mailto:quanxunzhen@gmail.com">quanxunzhen@gmail.com</a></strong></p>
<p>不过因为新空间还没摸索清楚，还在研究搬迁事宜。<br />
<span id="more-1069"></span><br />
下面讲讲今天的探索……这个新空间的 PHP 用了 CGI 的模式，而不是传统（或者说我熟悉的）PHP Module 的模式，而且作为 CGI 的 php 解析程序和 php.ini 配置文件也是放在网站的 cgi-bin 目录里面的，因此我怀疑可玩性很高，甚至可以自己编译 PHP 放上去用。不过这个空间有一个很麻烦的，就是不支持自动的泛域名匹配，这大大的不如现在的这个空间方便。不过经过一番研究，也并不是没有办法的。今天才算是第一次体会到了 Apache mod_rewrite 的强大！</p>
<p>本来以为 rewrite 不能实现那样功能的，因为似乎 rewrite 不能把主机名弄进来匹配，结果发现我想错了。参考了一些 Apache 的官方资料，我发现 Apache 的官方文档里有一种很有趣的方式间接实现泛域名到子文件夹的匹配，大约是这个样子的：</p>

<div class="wp_codebox"><table><tr id="p10695"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p1069code5"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">on</span>
<span style="color: #00007f;">RewriteCond</span>   %{HTTP_HOST}                 ^www\.[^.]+\.host\.com$
<span style="color: #00007f;">RewriteRule</span>   ^(.+)                        %{HTTP_HOST}$<span style="color: #ff0000;">1</span>          [C]
<span style="color: #00007f;">RewriteRule</span>   ^www\.([^.]+)\.host\.com(.*) /home/$<span style="color: #ff0000;">1</span>$<span style="color: #ff0000;">2</span></pre></td></tr></table></div>

<p>惊叹于这种其实妙想！这个恐怕能实现的功能比那个 VirtualHost 的模块还要强大了吧~</p>
<p>不过这个代码似乎是不能用的囧……做一个适合的修改就发生 500 错误……经过思考，我想起了很早以前说过的，mod_rewrite 是会把修改过的网址再次注入 rewrite 的，因此如果这样那么这个网址可能会不断的经过这个 rewrite 过程，造成死循环，最后被 Apache 以 500 强制结束。</p>
<p>看来想在网站根目录下像现在这样搞是不行了……不过，办法总是有的，其实有的时候我觉得自己还是蛮聪明的~我就在根目录下建立了一个名叫 www 的文件夹，然后给出了下面这样的 .htaccess：</p>

<div class="wp_codebox"><table><tr id="p10696"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p1069code6"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span>
<span style="color: #00007f;">RewriteCond</span> %{HTTP_HOST} ^[^\.]+\.upsuper\.org\.cn$
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_URI} !^/www/
<span style="color: #00007f;">RewriteRule</span> ^(.*)$ %{HTTP_HOST}/$<span style="color: #ff0000;">1</span>
<span style="color: #00007f;">RewriteRule</span> ^([^\.]+)\.upsuper\.org\.cn/(.*)$ /www/$<span style="color: #ff0000;">1</span>/$<span style="color: #ff0000;">2</span></pre></td></tr></table></div>

<p>OK，现在已经非常正常了，网页可以正常访问了~不过新的问题再度出现！所有的 PHP 都显示 404 错误……我汗！404？！那个 PHP 明明在那里凭啥 404 呢？</p>
<p>后来在空间商的 FAQ 里面偶然看到，解析 PHP 用的东西储存在已经被我删掉的 cgi-bin 文件夹里面……呃……马上把所有内容删掉恢复原来的内容。然后再放上这个，还是 404……其中必有问题……那么问题一定出在 cgi-bin 文件夹上……难道 Apache 最后也要通过自己访问 CGI 接口？其实其中奥妙我也不是很了解，不过最后又加了一条针对 cgi-bin 的 rewrite 规则，成功解决。关于 Apache 和 PHP 通过 CGI 接口的机制看来还是很值得好好研究研究的嗯……下面是最后的代码：</p>

<div class="wp_codebox"><table><tr id="p10697"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p1069code7"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span>
<span style="color: #00007f;">RewriteCond</span> %{HTTP_HOST} ^[^\.]+\.upsuper\.org\.cn$
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_URI} !^/www/
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_URI} !^/cgi-bin/
<span style="color: #00007f;">RewriteRule</span> ^(.*)$ %{HTTP_HOST}/$<span style="color: #ff0000;">1</span>
<span style="color: #00007f;">RewriteRule</span> ^([^\.]+)\.upsuper\.org\.cn/(.*)$ /www/$<span style="color: #ff0000;">1</span>/$<span style="color: #ff0000;">2</span></pre></td></tr></table></div>

<p>最后还有一个小小的问题，就是遇到找不到的 PHP，服务器虽然返回了 404 的头，不过显示的内容却是“No input file specified.”，而不是我指定的 404 页面（当然，IE 用户肯定什么都看不到，因为 IE 已经默认为他们准备好了一个“友好”的 404 页面）。这个虽然不是什么大问题，不过也还是很烦人的，有搜索了一番，最后在 rewrite 规则里面又加了两行解决问题：</p>

<div class="wp_codebox"><table><tr id="p10698"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1069code8"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteCond</span> %{DOCUMENT_ROOT}/$<span style="color: #ff0000;">1</span> !-f
<span style="color: #00007f;">RewriteRule</span> ^(.*\.php)$ - [T=text/html]</pre></td></tr></table></div>

<p>稍微想一想肯定看出来，这个代码不是没有问题的，不过我想我应该不会遇到吧……嗯……</p>
<p>最后就是关于 php.ini，php.ini 里面不小心撇到了 mbstring 的设置，发现默认语言竟然是 Japanese……呃……马上改成了 Chinese，并且把下面的默认编码 EUC-JP 也改成了 EUC-CN，真是无语……不知道这个是 PHP 的默认配置，还是那个客服看我英语这么差以为我是日本人“帮”我设置的呢？</p>
<p>参考资料：</p>
<ul>
<li><a href="http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html">URL Rewriting Guide &#8211; Apache HTTP Server</a></li>
<li><a href="http://jenseng.com/archives/000035.html">&#8220;No input file specified&#8221; | jenseng.com</a> <a href="http://www.panuworld.net/">panuworld</a> 的回复</li>
</ul>
<p>还想讲一点买空间的事情。因为这个空间商支持支付宝，我就决定用支付宝。而且支付宝不是支持 Linux 么，很好的嘛。今天中午就跑到邮局去汇款给我很早以前申请了但一直没用的支付宝账户充钱。然后充完跑回来打开上网本登录支付宝充值……为什么要打开上网本？因为台机的 Arch Linux 已经把 Firefox 升级到了 3.6，而支付宝唯一支持 Linux 的插件，是不兼容 Firefox 3.6 的……幸好上网本的 Ubuntu 9.10 很乖巧的使用了 Firefox 3.5.8，还能用那个支付宝插件。很期待支付宝能快些支持 Firefox 3.6，这样我以后也可以网购了~这年头天朝的银行不厚道，几乎完全不支持我家 Linux……还是支付宝好嗯~</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/my-new-web-space/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>支持 Haiti 的小网站</title>
		<link>http://blog.upsuper.org/a-small-site-for-haiti/</link>
		<comments>http://blog.upsuper.org/a-small-site-for-haiti/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 13:03:24 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[探究学习]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[公益]]></category>
		<category><![CDATA[兼容性]]></category>
		<category><![CDATA[地震]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=987</guid>
		<description><![CDATA[17号的时候虫子向我求助，想要我帮忙做一个支持海地的小网站。大体的思路就是，在上面的放一个大地图，然后大家可以留言、上传照片什么的，然后就在地图上出现亮点，然后亮点点进去可以看到留言和照片~这个网站已经进入公测了，大家可以在这里查看：Haiti ]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.upsuper.org/wp-content/uploads/2010/01/Haiti-3_1264924757767.png"><img src="http://blog.upsuper.org/wp-content/uploads/2010/01/Haiti-3_1264924757767-300x211.png" alt="" title="Haiti &lt;3_1264924757767" width="300" height="211" class="alignright size-medium wp-image-1000" /></a>17号的时候虫子向我求助，想要我帮忙做一个支持海地的小网站。大体的思路就是，在上面的放一个大地图，然后大家可以留言、上传照片什么的，然后就在地图上出现亮点，然后亮点点进去可以看到留言和照片~这个网站已经进入公测了，大家可以在这里查看：<a href="http://haiti.dnand.org/">Haiti <3</a>（话说我曾经问虫子“<3”是什么意思，她告诉我，是爱心的意思~）</p>
<p>我猜从来没做过网站的人一定会觉得这个很简单，但我觉得一点都不简单……不过似乎可以实现~这种无疑又是对我技术的一次挑战！<br />
<span id="more-987"></span><br />
一开始，我想用一种十分取巧的方式——直接用 Google Maps~探究了一段时间的 Google Maps。结果虫子要求：一是地图要暗，二是要出来的是亮点。想想，Google Maps 还是算了呃……（话说其实也不是不可以，不过实现了，很多数据从客户端走，也不大好）。不过像 Google Maps 这样极好的地图图片来源实在是太难得了！于是就直接用了~</p>
<p>首先要攻克的第一个问题是，如果我们知道来访者的经纬度，如何知道把他的点点在地图的什么位置？这是一个很神奇的问题，想想经纬度是为球面设计的，现在要把它转换到一个平面上。说来也巧，原来参与过天文软件 Stellarium 某个版本的翻译工作，正好翻译了其中被称作地图投影的部分。因为有好几个不同的投影方式，我渐渐就明白了，那个就是把球面图形映射到平面的方法！于是就找到了地图投影，经过查询，发现 Google Maps 使用的是 <a href="http://en.wikipedia.org/wiki/Mercator_projection">Mercator projection</a> (<a href="http://zh.wikipedia.org/zh-cn/%E9%BA%A5%E5%8D%A1%E6%89%98%E6%8A%95%E5%BD%B1%E6%B3%95">麦卡托投影法/墨卡托投影法/正轴等角圆柱投影</a>)。找到了投影法的名称，自然转换公式不是难事~不过这个公式看不懂……呃……算了，那些公式显然不在我现在的数学水平能够理解的范围之内，直接用好了……</p>
<p>用前面探究到的 Google Maps 的东西，写了个网页，对比了一下 Google Maps 转换的坐标和我的程序转换的坐标之间的情况，发现基本相等，有一部分会出现 1px 的差异，我就直接忽略之了~在调试这个程序的过程中，比较重要的大概就是 PHP 里面的三角函数相关的函数使用的都是弧度，而我们习惯上使用的经纬度都是角度，这样就需要一点点的转换了……好在 PHP 提供了 deg2rad 这样方便的函数~话说我的地图投影这个程序我把它单独分了一个文件出来，主要是里面定义了各种地图转换需要的常数，如果和别的功能合在一起大约看过去会比较乱……</p>
<p>下面遇到第二个重大的问题是：我们如何知道来访者所在的经纬度？！这个问题似乎比上面那个更复杂了……当然你可以直接请来访者告诉你，不过更好的方法显然是根据 IP 地址识别一下。不过说到 IP 地址的识别精度，那我也无奈了。我猜想在 IPv6 普及前，想要准确根据 IP 地址识别出位置大约是不可能的了。不过，可以接受的精度还是可以实现的~国内的 IP 数据库如纯真这样的，提供的都是一个字符串地址，那个是只能给人看的，电脑可不知道那些东西表示什么……于是就转向了国外的 IP 数据库。果然找到了些有趣的数据库，里面能包含 IP 可能对应的经度和纬度，而且还提供 CSV 下载，可好了~这里可以找到这个好东西：<a href="http://ipinfodb.com/ip_database.php">IP address geolocation SQL database :: IPInfoDB</a>。然后我需要一个可以提供 PHP 快速查找的文件。其实这个事情第一次做音乐投票系统的时候，为了限制投票 IP 在福建境内，就做过这个东西。思路也很简单：把每个 IP 段的数据变成定长的二进制数据，然后需要的时候二分查找~于是有了下面的转换用 Python 脚本：</p>

<div class="wp_codebox"><table><tr id="p98710"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code" id="p987code10"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #808080; font-style: italic;"># - * - coding: UTF-8 - * -</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">csv</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">struct</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
&nbsp;
fin = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'ip_group_city.csv'</span>, <span style="color: #483d8b;">'r'</span><span style="color: black;">&#41;</span>
c = <span style="color: #dc143c;">csv</span>.<span style="color: black;">reader</span><span style="color: black;">&#40;</span>fin, delimiter=<span style="color: #483d8b;">';'</span>, quotechar=<span style="color: #483d8b;">'&quot;'</span><span style="color: black;">&#41;</span>
fout = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'ipdata.dat'</span>, <span style="color: #483d8b;">'wb'</span><span style="color: black;">&#41;</span>
c.<span style="color: black;">next</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
a = <span style="color: #ff4500;">0</span>
s = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
<span style="color: #ff7700;font-weight:bold;">for</span> r <span style="color: #ff7700;font-weight:bold;">in</span> c:
  a += <span style="color: #ff4500;">1</span>
  s.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">struct</span>.<span style="color: black;">pack</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'&gt;Iff2sh'</span>,
      <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>r<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>,
      <span style="color: #008000;">float</span><span style="color: black;">&#40;</span>r<span style="color: black;">&#91;</span><span style="color: #ff4500;">7</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>, <span style="color: #008000;">float</span><span style="color: black;">&#40;</span>r<span style="color: black;">&#91;</span><span style="color: #ff4500;">8</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>,
      r<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>, <span style="color: #008000;">int</span><span style="color: black;">&#40;</span><span style="color: #008000;">float</span><span style="color: black;">&#40;</span>r<span style="color: black;">&#91;</span><span style="color: #ff4500;">10</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;font-weight:bold;">or</span> <span style="color: #483d8b;">'0'</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">if</span> a <span style="color: #66cc66;">%</span> <span style="color: #ff4500;">10000</span> == <span style="color: #ff4500;">0</span>:
    fout.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">''</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    s = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">stderr</span>, a,
fout.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">''</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">stderr</span>, a
fin.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
fout.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>这样，就当获取经纬度差不多了吧~嗯~虽然那个精度实在不敢恭维……不过根据那个网站自己的数据，至少国家是不会弄错的（准确度 90%+），只是城市就不跟你保证了~（那个数据貌似显示，这个数据库中城市在中国只有 71% 左右是正确的……）。</p>
<p>最后是关于地图的最后一个问题……如何绘制？</p>
<p>经过考察，这个小网站未来要放的那个服务器是不支持 ImageMagick 的，于是只能用 GD 库了……</p>
<p>那个小点点，其实就是圆咯。于是我一开始用 imageFilledEllipse 函数在地图上画直径为 3px 的圆。不过那个的效果实在是不大行……另外一件事就是关于上传照片的问题，某些相机比较囧的都把照片方向弄在 Exif 里面……虽然 PHP 有很方便的库可以直接读取 Exif，但旋转和翻转就麻烦了……</p>
<p>关于 GD 库，有一件事我觉得很无语，那就是有好几个比较有趣的函数，如 imageAntiAlias、imageRotate 下面都写着：<br />
<blockquote>
    <strong>Note:</strong> This function is only available if PHP is compiled with the bundled version of the GD library.
</p></blockquote>
<p>于是就各种囧的不能在我自己机子上调试……目标服务器的 GD 库倒是符合条件，不过我发现其实想要通用还有一种很好的方法：在 Notes 里面找！通常不能通用的函数在 Notes 里面都有相应的通用解决方案~这次我在 Notes 里面找到了图片翻转、旋转、判断 Exif 方向、平滑绘制圆的函数~我觉得有些时候，下面的 Notes 比上面的文档要有意义的多……平滑绘制圆的函数，我为了半透明又改了一点。当然，改的不完美，也就不敢拿出来献丑了，勉强能用就是了~</p>
<p>此外，还抄来了 WordPress 里面一段创建不同大小图片和创建缩略图的代码，很好用嗯~话说，太久没写 PHP，很多东西都忘的差不多了，比如说输入的数据中有单引号会自动被 PHP escape 掉，这还让我苦恼了一下呃……</p>
<p>另外就是，设计中虫子给我提出了一个神奇的要求：跟 twitter。为了这件事，我进行了各种不和谐的活动，以了解 twitter 的 APIs……然后用了一个带缓冲的转接程序弄好了。</p>
<p>至于客户端部分，我再次使用了 jQuery，jQuery 果然是个好东西。而且为了上传，我又使用了 Uploadify。有赖于<a href="http://blog.upsuper.org/2009-recommend-platform-of-music-recruiter-for-fuzhou-no1-middle-school/">上一次做音乐征集系统</a>的经验，这次少走了不少弯路，而且大量的 IE6 的 bug 也被我巧妙地解决了~而且我发现 IE6 的某些莫名其妙的 bug （比如我在制作过程中遇到了一个 div 明明 right 是 0，却超出右边界很多）都可以通过设置 zoom: 1; 来解决……不知道 IE6 这种莫名其妙的浏览器到底是什么样 SB 的团队制作出来的。IE 曾经是带领万维网发展的，现在却成为了严重的阻碍者！用 IE 的孩子们赶快觉醒吧……我真得不想在为了 IE 花掉大把的时间调试了……</p>
<p>顺便说一下新发现的 IE6 的 bug（其实我也不知道是不是我新发现的……）：还是隐藏显示的问题。是用 AlphaImageLoader 这个 filter 的元素隐藏后显示，这个 filter 的效果会消失，也就是没用了……为了这个 bug，这次不得不在脚本中都加入了 ie-fix……而且，更严重的是，如果你在显示后再设置这个 filter，又会出现另外一个 bug：这个时候，被设置这个 filter 的元素内部的所有元素可见，但变成不可用，也就是好像点不到一样！我估计是这个 filter 变成了一个在元素内部最上层的一个东西，于是就挡住了其他所有的元素。我汗啊，IE6 的 QA 是干什么吃的啊……这个的解决办法说来也简单，另外弄一个 div，设置在同样的位置，同样的长宽，对他用那个 filter 就行了……</p>
<p>对了对了！说到 AlphaImageLoader 这个 filter，我又想起来一件事，证明了百度不适合用来搜索技术资料，至少比 Google 逊太多了：你分别在这两个搜索引擎里面输入“filter:progid:DXImageTransform.Microsoft.AlphaImageLoader”，我把结果贴出来：</p>
<div style="width: 100%; text-align: center;"><a href="http://blog.upsuper.org/wp-content/uploads/2010/01/_filterprogidDXImageTransform.Microsoft.AlphaImageLoader_1264941140183-e1264941753180.png"><img src="http://blog.upsuper.org/wp-content/uploads/2010/01/_filterprogidDXImageTransform.Microsoft.AlphaImageLoader_1264941140183-e1264941753180-190x300.png" alt="" title="百度搜索_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader_1264941140183" width="190" height="300" class="alignnone size-medium wp-image-998" /></a><a href="http://blog.upsuper.org/wp-content/uploads/2010/01/filterprogidDXImageTransform.Microsoft.AlphaImageLoader-Google-搜索_1264941161008.png"><img src="http://blog.upsuper.org/wp-content/uploads/2010/01/filterprogidDXImageTransform.Microsoft.AlphaImageLoader-Google-搜索_1264941161008-163x300.png" alt="" title="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader - Google 搜索_1264941161008" width="163" height="300" class="alignnone size-medium wp-image-995" /></a></div>
<p>请认真对比我的关键词和两个引擎的结果，你会发现：百度第一页没一个是我要找的，甚至连一个完整匹配的关键词都没有！难道是我的关键词是我瞎编的？不，你看 Google 的结果吧……嗯……事实胜于雄辩，百度众自重……</p>
<p>整个网站的代码，可能在经过完善以后会公布，也可能不公布。由于这次的东西不是做给自己的，所以不能完全我自己说的算了……</p>
<p>参考资料：</p>
<ul>
<li><a href="http://code.google.com/intl/zh-CN/apis/maps/">Google 地图 API &#8211; Google 代码</a></li>
<li><a href="https://groups.google.com/group/Google-Maps-API/msg/8222b18e7921f6e6">What type of map projection does Google use for Google Maps &#8211; Google Groups</a></li>
<li><a href="http://mathworld.wolfram.com/MercatorProjection.html">Mercator Projection &#8212; from Wolfram MathWorld</a></li>
<li><a href="http://www.maxmind.com/app/city_accuracy">MaxMind &#8211; GeoIP City Accuracy for Selected Countries</a></li>
<li><a href="http://apiwiki.twitter.com/">Twitter API Wiki</a> (请自备专用工具访问)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/a-small-site-for-haiti/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>一中2009音乐征集系统 推荐平台</title>
		<link>http://blog.upsuper.org/2009-recommend-platform-of-music-recruiter-for-fuzhou-no1-middle-school/</link>
		<comments>http://blog.upsuper.org/2009-recommend-platform-of-music-recruiter-for-fuzhou-no1-middle-school/#comments</comments>
		<pubDate>Sat, 31 Oct 2009 06:47:19 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[我的计划]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[学校]]></category>
		<category><![CDATA[福州一中]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=877</guid>
		<description><![CDATA[经过约两周的努力编写和调试，终于在昨天晚上完成了。因为做这个网站的缘故，再次新学习了大量东西，比如 jQuery，以及 Linux 下 Photoshop 的替代品 GIMP 等。同时也权当是一次练手，毕竟很久没写这种东西了。不过这次又一次与 IE 的 bug 及非标准化进行了顽强的斗争……
我要记录下在这个过程中遇到的种种问题和解决方法，以后再遇到就有地方查了~

客户端部分
很早就听说了 jQuery，上次看完 wp-codebox 的代码才顿觉 jQuery 的强大，因此这次选择了这个。经过短暂的学习就基本了解了，还是比较简单的。此外，jQuery 的插件库相当强大，里面找到了所有我需要的东西，包括上传文件的插件和播放器的插件等。
编写客户端代码最艰苦的部分就是配色和设计界面，以及在各个浏览器中调试。关于兼容性的问题放在后面说，前面先写点关于 JavaScript 代码的事。
第一个比较有趣的问题是关于浮点数保留精度的问题。虽然保留精度大是件好事，可是 JavaScript 没有如 C 中的 printf 那么方便的东西（不过网上似乎也有类似实现，不过 JavaScript 实现这个东西……还是算了吧……）。而一下把很长很长的浮点数显示在用户面前，也绝对不是件好事。经过搜寻，最后使用下面代码实现：

1
2
3
4
5
6
Number.prototype.fix = function &#40;num&#41; &#123;
  with &#40;Math&#41; return round&#40;this.valueOf&#40;&#41; * pow&#40;10, num&#41;&#41; / pow&#40;10, num&#41;;
&#125;;
String.prototype.fix = function &#40;num&#41; &#123;
  return parseFloat&#40;this&#41;.fix&#40;num&#41;;
&#125;;

第二个问题就是关于 MP3 播放器背景的问题。我用的这个播放器插件极具可定制性，背景色和前景色都能定制，不过要求都要使用十六进制的形式传入。为了更好的适应主题颜色，我就使用 jQuery 的 .css [...]]]></description>
			<content:encoded><![CDATA[<p>经过约两周的努力编写和调试，终于在昨天晚上完成了。因为做这个网站的缘故，再次新学习了大量东西，比如 jQuery，以及 Linux 下 Photoshop 的替代品 GIMP 等。同时也权当是一次练手，毕竟很久没写这种东西了。不过这次又一次与 IE 的 bug 及非标准化进行了顽强的斗争……</p>
<p>我要记录下在这个过程中遇到的种种问题和解决方法，以后再遇到就有地方查了~<br />
<span id="more-877"></span></p>
<h3>客户端部分</h3>
<p>很早就听说了 jQuery，<a href="http://blog.upsuper.org/modify-code-highlight-plugin/">上次看完 wp-codebox 的代码</a>才顿觉 jQuery 的强大，因此这次选择了这个。经过短暂的学习就基本了解了，还是比较简单的。此外，jQuery 的插件库相当强大，里面找到了所有我需要的东西，包括上传文件的插件和播放器的插件等。</p>
<p>编写客户端代码最艰苦的部分就是配色和设计界面，以及在各个浏览器中调试。关于兼容性的问题放在后面说，前面先写点关于 JavaScript 代码的事。</p>
<p>第一个比较有趣的问题是关于浮点数保留精度的问题。虽然保留精度大是件好事，可是 JavaScript 没有如 C 中的 printf 那么方便的东西（不过网上似乎也有类似实现，不过 JavaScript 实现这个东西……还是算了吧……）。而一下把很长很长的浮点数显示在用户面前，也绝对不是件好事。经过搜寻，最后使用下面代码实现：</p>

<div class="wp_codebox"><table><tr id="p87715"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p877code15"><pre class="javascript" style="font-family:monospace;">Number.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">fix</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>num<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">with</span> <span style="color: #009900;">&#40;</span>Math<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> round<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">valueOf</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> pow<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> num<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> pow<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> num<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
String.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">fix</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>num<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">return</span> parseFloat<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fix</span><span style="color: #009900;">&#40;</span>num<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>第二个问题就是关于 MP3 播放器背景的问题。我用的这个播放器插件极具可定制性，背景色和前景色都能定制，不过要求都要使用十六进制的形式传入。为了更好的适应主题颜色，我就使用 jQuery 的 .css 方法在脚本中现场获取当前在 CSS 中定义的前景色和背景色。结果发现，其在 Firefox 内返回的是类似 rgb(0, 0, 0) 这样的颜色表大形式。据说在 Firefox 中永远放回这种形式，而 IE 中则总是返回你实际设置时使用的格式。针对这个问题，我写了下面代码来解决（毋庸置疑，这又是抄的）：</p>

<div class="wp_codebox"><table><tr id="p87716"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code" id="p877code16"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> hex <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>n <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">'00'</span><span style="color: #339933;">;</span>
  n <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>n <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span> <span style="color: #339933;">||</span> isNaN<span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">'00'</span><span style="color: #339933;">;</span>
  n <span style="color: #339933;">=</span> Math.<span style="color: #660066;">round</span><span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>n <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> n <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>n <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">255</span><span style="color: #009900;">&#41;</span> n <span style="color: #339933;">=</span> <span style="color: #CC0000;">255</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">'0123456789abcdef'</span>.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>n <span style="color: #339933;">-</span> n <span style="color: #339933;">%</span> <span style="color: #CC0000;">16</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #CC0000;">16</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span>
         <span style="color: #3366CC;">'0123456789abcdef'</span>.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span>n <span style="color: #339933;">%</span> <span style="color: #CC0000;">16</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> color2hex <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>color<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>color.<span style="color: #660066;">search</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/rgb/i</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    color <span style="color: #339933;">=</span> color.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> color.<span style="color: #660066;">length</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">', '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> hex<span style="color: #009900;">&#40;</span>color<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> hex<span style="color: #009900;">&#40;</span>color<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> hex<span style="color: #009900;">&#40;</span>color<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>color.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'#'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    color <span style="color: #339933;">=</span> color.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>color.<span style="color: #660066;">length</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">return</span> color.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> color.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span>
             color.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> color.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span>
             color.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> color.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">return</span> color<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>另外就是，为了防止大家大量重复提交同样音乐，这次加入了搜索功能，而且在提交一个音乐的时候就会自动进行搜索，并提示用户检查是否已有相同曲目被提交。至于搜索的实现，采用的是客户端搜索，算法上采用了非常著名而简单的 LCS (Longest common subsequence, 最长公共子序列) 这一 oier 的居家旅行杀人放火必备算法。事实证明，这一算法其实是很有效的~</p>

<div class="wp_codebox"><table><tr id="p87717"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p877code17"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> lcs<span style="color: #009900;">&#40;</span>str1<span style="color: #339933;">,</span> str2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> str1 <span style="color: #339933;">||</span> <span style="color: #339933;">!</span> str2<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> arr <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">,</span> j<span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> str1.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    arr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> str2.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>j<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      arr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> Math.<span style="color: #660066;">max</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">?</span> arr<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> j <span style="color: #339933;">?</span> arr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>str1.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> str2.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        arr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> Math.<span style="color: #660066;">max</span><span style="color: #009900;">&#40;</span>arr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> i <span style="color: #339933;">&amp;&amp;</span> j <span style="color: #339933;">?</span> arr<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">return</span> arr<span style="color: #009900;">&#91;</span>str1.<span style="color: #660066;">length</span><span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>str2.<span style="color: #660066;">length</span><span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>搜索算法：</p>

<div class="wp_codebox"><table><tr id="p87718"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code" id="p877code18"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> search<span style="color: #009900;">&#40;</span>type<span style="color: #339933;">,</span> text<span style="color: #339933;">,</span> callback<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  text <span style="color: #339933;">=</span> text.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\s+/g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> threshold <span style="color: #339933;">=</span> text.<span style="color: #660066;">length</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">0.25</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> result <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  getList<span style="color: #009900;">&#40;</span>type<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> value <span style="color: #339933;">||</span> <span style="color: #000066; font-weight: bold;">typeof</span> value <span style="color: #339933;">==</span> <span style="color: #3366CC;">'number'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      callback<span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #003366; font-weight: bold;">var</span> itemtext<span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">item</span><span style="color: #339933;">,</span> i<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> value.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">item</span> <span style="color: #339933;">=</span> value<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      itemtext <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">source</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">title</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\s+/g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">len</span> <span style="color: #339933;">=</span> itemtext.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">lcs</span> <span style="color: #339933;">=</span> lcs<span style="color: #009900;">&#40;</span>text<span style="color: #339933;">,</span> itemtext<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">lcs</span> <span style="color: #339933;">&gt;</span> threshold<span style="color: #009900;">&#41;</span> result.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    result.<span style="color: #660066;">sort</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>item1<span style="color: #339933;">,</span> item2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>item1.<span style="color: #660066;">lcs</span> <span style="color: #339933;">&gt;</span> item2.<span style="color: #660066;">lcs</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>item1.<span style="color: #660066;">lcs</span> <span style="color: #339933;">&lt;</span> item2.<span style="color: #660066;">lcs</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>item1.<span style="color: #660066;">len</span> <span style="color: #339933;">&lt;</span> item2.<span style="color: #660066;">len</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>item1.<span style="color: #660066;">len</span> <span style="color: #339933;">&gt;</span> item2.<span style="color: #660066;">len</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    callback<span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>还有一个是关于换肤的。<a href="http://blog.upsuper.org/replace-css-based-on-jquery/">上一次有一篇文章</a>测试过了基于更换 link 标签 href 属性换肤的可行性分析，这次就应用于了这个平台上。但在测试中发现 IE 并不像想像的那么完美。事实上，IE 在这个的测试过程中是非常废品的，几乎相当于不能换。经过多次实验，发现原因出在——IE6 在页面加载完毕后永远不会显示其还没有下载的样式信息。也就是说，更改 href 后，虽然 IE6 将原来的样式表无效化了，但此时发现新的样式表不在其缓存中，便拒绝启用新的样式表。但奇怪的是，IE6 这个时候事实上会连接服务器下载新的样式，因此在下一次访问的时候上次点过的皮肤就可以用了。这说明，我们只要要求 IE 预装载以后可能用到的东西就可以了。因此我就在页面底部加入了一个隐藏的 iframe 用于下载样式表和需要的图片。</p>
<p>除此之外，就是一些关于样式的新发现。我第一次知道当一个元素的 position 属性设置为 relative 的时候，对这个对象本身没有影响，但却使得其使用 position 属性的子元素的位移变由相对页面的位移变为相对该元素的位移。这的上传进度条的实现方法便是应用这一机制。</p>
<p>说到上传进度条，不得不说 Uploadify 这一插件真的很强大……我将其默认的上传进度和管理通过对各个必要函数绑定返回 false 来屏蔽掉了。</p>
<p>最后是关于 jQuery 优化的问题。虽然 jQuery 的官方测试表明，jQuery 的效率非常惊人，但优化下总归是有好处的。参考的资料见下面了，说说我大体做了哪些优化吧。一是缓存 jQuery 对象，防止重复调用选择器带来的性能损失。第二个是为选择器加上上下文限制，第三个是将部分效果移至 $(window).load 里。</p>
<p>在客户端的脚本部分的最最后，小小的埋怨一下 JavaScript 这个语言……我觉得实在是没有 Python 优美啊！什么时候 Python 能成为通用的客户端脚本啊，那个时候用 Python 就可以通吃服务器端和客户端了……</p>
<p>说完了脚本，来说说这次的界面。这次界面个人还是很满意的。在界面设计中，我自认为值得一提的是那个圆角，为什么呢？因为我以前一直以为 GIMP 不能画圆角。这次去网上找了才知道，GIMP 远比我想象的强大的多！猜猜圆角是怎么画出来的？是通过高斯模糊+调整色阶。具体的实现方法放在下面参考资料里面了，这里就不详述了。但我真的觉得很强大，虽然 GIMP 和 Photoshop 等商业软件还有差距，不过对于我来说，看来足够了。</p>
<p>最后再提下这次发现的不同浏览器的兼容性问题：</p>
<dl>
<dt>对于不显示的 Flash，IE 无法与其交互</dt>
<dt>对于曾经被隐藏但再次出现的 Flash，IE6 无法与其交互</dt>
<dd>解决方案：完全销毁原有 Flash 对象并重建</dd>
<dt>IE 中隐藏的 Flash MP3 播放器可以发出声音，但 Firefox 不行</dt>
<dd>解决方案：统一的办法就是直接销毁播放器，而非单单让其隐藏</dd>
<dt>IE 的 JavaScript 解析器不支持用 [index] 的方式索引字符</dt>
<dd>解决方案：使用原有标准的 .charAt(index) 方式索引</dd>
<dt>在 IE6 中，显示时尚未下载完成的 CSS 元素永远不会显示（如背景图片）</dt>
<dd>解决方案：在页面中加入一个隐藏的 iframe 用于预加载</dd>
<dt>IE6 中的双倍外边距 bug</dt>
<dd>解决方案：给相应对象加上 display:inline; 属性，或通过 hack 专门调低在 IE6 下的外边距</dd>
<dt>IE6 对于 display 的 inline-block 属性支持不完善</dt>
<dd>解决方案：给相应对象加上 zoom:1; 属性</dd>
<dt>IE6 不支持半透明的 png 图片</dt>
<dd>解决方案：采用 IE 专有的过滤器 filter:progid:DXImageTransform.Microsoft.AlphaImageLoader 可以完美解决</dd>
</dl>
<p>IE 的兼容性烦死人啊……看看我的 ie6-fix.css 和 ie7-fix.css 就知道了……</p>
<h4>使用部件</h4>
<ul>
<li><a href="http://jquery.com/">jQuery: The Write Less, Do More, JavaScript Library</a></li>
<li><a href="http://www.uploadify.com/">Uploadify &#8211; jQuery File Upload Plugin Script</a></li>
<li><a href="http://code.google.com/p/swfobject/">SWFObject</a></li>
<li><a href="http://www.sean-o.com/jquery/jmp3/">jMP3: Sean O&#8217;s JavaScript MP3 Player / jQuery plugin</a></li>
<li><a href="http://code.google.com/p/jquery-json/">JSON plugin for jQuery</a></li>
</ul>
<h4>参考资料</h4>
<ul>
<li><a href="http://www.k99k.com/jQuery_getting_started.html">jQuery中文入门教程</a></li>
<li><a href="http://topic.csdn.net/t/20031109/21/2443654.html">如何格式化浮点数计算结果 JavaScript &#8211; CSDN社区</a></li>
<li><a href="http://plugins.jquery.com/files/jquery.sifr.js_1.txt">jQuery.sifrSettings</a></li>
<li><a href="http://www.rainbk.net/post/199.html">jQuery性能优化指南 (全部) &#8211; 烟雨博客</a></li>
<li><a href="http://blog.chinaunix.net/u1/55011/showart.php?id=468782">1.3 圆整圆角 &#8211; The Gimp &#8211; 思魂轩</a></li>
<li><a href="http://www.uploadify.com/forum/viewtopic.php?f=7&#038;t=1878">Uploadify &bull; View topic &#8211; Uploadify doesnt fire uploadifyUpload/uploadifyClearQueue</a></li>
<li><a href="http://feiyu.asgard.cn/article_157.html">IE6下margin双倍问题 &#8211; 绯雨的天空</a></li>
<li><a href="http://www.howtocreate.co.uk/alpha.html">Making Internet Explorer use PNG Alpha transparency</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/2009-recommend-platform-of-music-recruiter-for-fuzhou-no1-middle-school/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>修改代码高亮插件</title>
		<link>http://blog.upsuper.org/modify-code-highlight-plugin/</link>
		<comments>http://blog.upsuper.org/modify-code-highlight-plugin/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 13:55:24 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[雕虫小技]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[博客]]></category>
		<category><![CDATA[插件]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=844</guid>
		<description><![CDATA[我一直在使用 wp-codebox 这个代码高亮插件。这个代码高亮插件似乎很久没有更新了，而且作者的网站也不能访问了（被墙了？），不知道是不是停止维护了？虽然在插件主页上显示这个插件仅支持到 2.5.1，我这个 2.8+ 的 WordPress 也并没有提示不兼容……虽然这个插件似乎对 SEO 有影响，而且可能停止维护，不过我暂时不打算更换插件，大不了我自己维护自己的版本……
今天就修改了一下……因为昨天发的那文章很多用这个来显示高亮代码，而且最后一个长代码我还使用了自动收缩。可是自动收缩没效果！下载栏也没有显示。今天查一下，发现是插件的功能栏被我关了……启用以后觉得很难看，很厚，而且和我的蓝色主题很不搭调，于是就决定自己修改了。
先是改了 CSS，把那功能栏调好看了些。然后开始改 main.php，把后面失效的帮助链接给删掉了。然后我让代码小等于5行，又不提供文件下载的代码段自动隐藏功能栏，而对于大于70行的代码，如果没有显示声明展开则自动收缩。最后，觉得那个收缩很卡，就让他直接消失好了……查了下插件用的 jQuery，新版本改进了执行效率，而且没有改变插件里面用的那些函数的特性，就直接下下来更新了……
这里把我修改后的插件也贴出来供大家参考吧：wp-codebox-upsuper.tar.lzma (577.8 KB)
顺便说一声，配的也是最新版的 GeSHi，虽然只更新了一个小小版本……
]]></description>
			<content:encoded><![CDATA[<p>我一直在使用 <a href="http://wordpress.org/extend/plugins/wp-codebox/">wp-codebox</a> 这个代码高亮插件。这个代码高亮插件似乎很久没有更新了，而且作者的网站也不能访问了（被墙了？），不知道是不是停止维护了？虽然在插件主页上显示这个插件仅支持到 2.5.1，我这个 2.8+ 的 WordPress 也并没有提示不兼容……虽然这个插件似乎对 SEO 有影响，而且可能停止维护，不过我暂时不打算更换插件，大不了我自己维护自己的版本……</p>
<p>今天就修改了一下……因为<a href="http://blog.upsuper.org/optimize-leap-year-checking-and-other/">昨天发的那文章</a>很多用这个来显示高亮代码，而且最后一个长代码我还使用了自动收缩。可是自动收缩没效果！下载栏也没有显示。今天查一下，发现是插件的功能栏被我关了……启用以后觉得很难看，很厚，而且和我的蓝色主题很不搭调，于是就决定自己修改了。</p>
<p>先是改了 CSS，把那功能栏调好看了些。然后开始改 main.php，把后面失效的帮助链接给删掉了。然后我让代码小等于5行，又不提供文件下载的代码段自动隐藏功能栏，而对于大于70行的代码，如果没有显示声明展开则自动收缩。最后，觉得那个收缩很卡，就让他直接消失好了……查了下插件用的 jQuery，新版本改进了执行效率，而且没有改变插件里面用的那些函数的特性，就直接下下来更新了……</p>
<p>这里把我修改后的插件也贴出来供大家参考吧：<a href="http://down.upsuper.org/wp-codebox-upsuper.tar.lzma">wp-codebox-upsuper.tar.lzma</a> (577.8 KB)</p>
<p>顺便说一声，配的也是最新版的 GeSHi，虽然只更新了一个小小版本……</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/modify-code-highlight-plugin/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Ubuntu 下安装 Blitz for PHP</title>
		<link>http://blog.upsuper.org/ubuntu-installed-blitz-for-php/</link>
		<comments>http://blog.upsuper.org/ubuntu-installed-blitz-for-php/#comments</comments>
		<pubDate>Fri, 22 May 2009 15:21:16 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[探究学习]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=764</guid>
		<description><![CDATA[Blitz 是为 PHP 设计的一个高效模板系统，关于这个模板系统的高效程度和更多内容参见其英文主页。因为安装这个还是比较麻烦的，上次安装过这次又忘记了怎么做……
非常无奈地，这个程序不仅没有进入 Ubuntu 的源，而且也没有看到编译好的 deb 包，所以首先，我先从 SourceForge 上下载了它的源代码。然后开始安装。

解压后，我一直以为源码包的默认安装方式：./configure &#8211; make &#8211; make install 错了！第一步就提示找不到 ./configure……看看 README，发现需要先执行一条命令叫做“phpize”。我在终端中输入 phpize，提示找不到命令，而且没有提示什么软件包中包含这个命令。在网上查到需要安装 php5-dev 包，于是就用 apt-get 安装了 php5-dev 包。再执行 phpize，发现目录里瞬间多出了许多文件。然后，执行 ./configure，make，make install。安装完成。
重启 apache2 查看 phpinfo，发现 blitz 没有出现！怎么会这样呢……突然看到 phpinfo 里面的“additional .ini files parsed”一栏里面都是形如“/etc/php5/apache2/conf.d/插件的名称.ini”，所以就找到 /etc/php5/apache2/conf.d/ 目录，查看了里面随便一个文件，发现其实格式很简单，就是

1
extension=插件名.so

于是就添加了一个文件“blitz.ini”，内容为

1
extension=blitz.so

保存。再次重启 apache2，查看 phpinfo，终于看到 blitz 了！
]]></description>
			<content:encoded><![CDATA[<p>Blitz 是为 PHP 设计的一个高效模板系统，关于这个模板系统的高效程度和更多内容参见<a href="http://alexeyrybak.com/blitz/blitz_en.html">其英文主页</a>。因为安装这个还是比较麻烦的，上次安装过这次又忘记了怎么做……</p>
<p>非常无奈地，这个程序不仅没有进入 Ubuntu 的源，而且也没有看到编译好的 deb 包，所以首先，我先从 <a href="http://sourceforge.net/projects/blitz-templates/">SourceForge</a> 上下载了它的源代码。然后开始安装。<br />
<span id="more-764"></span><br />
解压后，我一直以为源码包的默认安装方式：./configure &#8211; make &#8211; make install 错了！第一步就提示找不到 ./configure……看看 README，发现需要先执行一条命令叫做“phpize”。我在终端中输入 phpize，提示找不到命令，而且没有提示什么软件包中包含这个命令。在<a href="http://ubuntuforums.org/showthread.php?t=354278">网上查到</a>需要安装 php5-dev 包，于是就用 apt-get 安装了 php5-dev 包。再执行 phpize，发现目录里瞬间多出了许多文件。然后，执行 ./configure，make，make install。安装完成。</p>
<p>重启 apache2 查看 phpinfo，发现 blitz 没有出现！怎么会这样呢……突然看到 phpinfo 里面的“additional .ini files parsed”一栏里面都是形如“/etc/php5/apache2/conf.d/插件的名称.ini”，所以就找到 /etc/php5/apache2/conf.d/ 目录，查看了里面随便一个文件，发现其实格式很简单，就是</p>

<div class="wp_codebox"><table><tr id="p76421"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p764code21"><pre class="text" style="font-family:monospace;">extension=插件名.so</pre></td></tr></table></div>

<p>于是就添加了一个文件“blitz.ini”，内容为</p>

<div class="wp_codebox"><table><tr id="p76422"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p764code22"><pre class="text" style="font-family:monospace;">extension=blitz.so</pre></td></tr></table></div>

<p>保存。再次重启 apache2，查看 phpinfo，终于看到 blitz 了！</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/ubuntu-installed-blitz-for-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>关于 PHP 常数的定义和范围</title>
		<link>http://blog.upsuper.org/about-php-constants-definition-and-scope/</link>
		<comments>http://blog.upsuper.org/about-php-constants-definition-and-scope/#comments</comments>
		<pubDate>Sun, 17 May 2009 04:03:12 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[我的计划]]></category>
		<category><![CDATA[探究学习]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=760</guid>
		<description><![CDATA[PHP 的常数还是很有趣的。作为一个脚本语言，常数在 PHP 中成为了一种十分灵活的东西。没有细究 PHP 的文档，自己做了个实验来看看 PHP 到底时怎么处理常数的。实验代码如下：

1
2
3
4
5
6
7
8
function a&#40;$t&#41; &#123;
  define&#40;'T', $t&#41;;
  echo T;
&#125;
&#160;
a&#40;'a'&#41;;
echo T;
a&#40;'b'&#41;;

结果发现，输出的三个字符都是 a，而且没有报错。这说明，无论常数在哪里声明，都是全局有效的，而且定义后不可再被更改了（废话……不然还叫常数）。从定义发生的时机看，确实是第一次调用函数 a() 的时候被定义的，而后再次调用函数 a() 时没有被修改也没有报错。还真是有趣的说~

话说今天发现 PHP 的 link 函数的文档中写着“5.3.0  	 This function is now available on Windows platforms.”！十分好奇，Windows 下也有文件硬链接？载来 PHP 5.3.0 RC2（又一惊，5.3.0 已经到 RC2 了！）的代码，细细观赏一番，发现在 ext/standard 下有一个文件叫 link_win32.c，打开看到如下代码：

1
2
3
4
5
6
7
8
9
10
11
12
13
14
PHP_FUNCTION&#40;link&#41;
&#123;
/* ... 此处省略数行 ... */
#ifndef ZTS
	ret = CreateHardLinkA&#40;topath, frompath, NULL&#41;;
#else [...]]]></description>
			<content:encoded><![CDATA[<p>PHP 的常数还是很有趣的。作为一个脚本语言，常数在 PHP 中成为了一种十分灵活的东西。没有细究 PHP 的文档，自己做了个实验来看看 PHP 到底时怎么处理常数的。实验代码如下：</p>

<div class="wp_codebox"><table><tr id="p76025"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p760code25"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> a<span style="color: #009900;">&#40;</span><span style="color: #000088;">$t</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'T'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$t</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">echo</span> T<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
a<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'a'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> T<span style="color: #339933;">;</span>
a<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'b'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>结果发现，输出的三个字符都是 a，而且没有报错。这说明，无论常数在哪里声明，都是全局有效的，而且定义后不可再被更改了（废话……不然还叫常数）。从定义发生的时机看，确实是第一次调用函数 a() 的时候被定义的，而后再次调用函数 a() 时没有被修改也没有报错。还真是有趣的说~<br />
<span id="more-760"></span><br />
话说今天发现 PHP 的 link 函数的文档中写着“5.3.0  	 This function is now available on Windows platforms.”！十分好奇，Windows 下也有文件硬链接？载来 PHP 5.3.0 RC2（又一惊，5.3.0 已经到 RC2 了！）的代码，细细观赏一番，发现在 ext/standard 下有一个文件叫 link_win32.c，打开看到如下代码：</p>

<div class="wp_codebox"><table><tr id="p76026"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p760code26"><pre class="c" style="font-family:monospace;">PHP_FUNCTION<span style="color: #009900;">&#40;</span>link<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #808080; font-style: italic;">/* ... 此处省略数行 ... */</span>
<span style="color: #339933;">#ifndef ZTS</span>
	ret <span style="color: #339933;">=</span> CreateHardLinkA<span style="color: #009900;">&#40;</span>topath<span style="color: #339933;">,</span> frompath<span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">#else </span>
	ret <span style="color: #339933;">=</span> CreateHardLinkA<span style="color: #009900;">&#40;</span>dest_p<span style="color: #339933;">,</span> source_p<span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
<span style="color: #339933;">#endif	</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>ret <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		php_error_docref<span style="color: #009900;">&#40;</span>NULL TSRMLS_CC<span style="color: #339933;">,</span> E_WARNING<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span> strerror<span style="color: #009900;">&#40;</span>errno<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		RETURN_FALSE<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	RETURN_TRUE<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>CreateHardLinkA 难道是一个 API 函数？再一查，发现 MSDN 上有文档：<a href="http://msdn.microsoft.com/en-us/library/aa363860(VS.85).aspx">CreateHardLink Function (Windows)</a>，上面还写着“Establishes a hard link between an existing file and a new file. This function is only supported on the NTFS file system, and only for files, not directories.”，只有 NTFS 才能用。看来只好认为是学 Linux 的了……竟然支持，真是不可思议，不过 Windows 为什么默认却没有办法在 GUI 中使用这个功能呢？</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/about-php-constants-definition-and-scope/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP空间也做LaTeX公式显示</title>
		<link>http://blog.upsuper.org/php-space-show-latex-formula/</link>
		<comments>http://blog.upsuper.org/php-space-show-latex-formula/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 02:43:21 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[探究学习]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=713</guid>
		<description><![CDATA[原来一直以为只有自己的机子安装了 LaTeX、dvips 等等这些软件才能显示 LaTeX 公式。
今天上网查找了一下，发现不是这样的，原来比较基本的 LAMP 空间也可以这样了，这完全得益于一个叫做 mimeTeX 的开源软件。虽然这个软件生成的没有 LaTeX 生成的漂亮，不过还是比 Word 的公式编辑器生成的漂亮，最重要的是可以在网站上使用！

要安装这个，有一个比较必要的前提，就是你的网站必须不能运行在 PHP 的安全模式下，还有就是网站必须允许是用 .htaccess 配置文件，否则可能不行……不是……是肯定不行……另外权限设置比较严格的服务器上注意把相应权限设置妥当。
如果服务器是 Linux 平台下的，首先，我们要下载这个软件，源代码可以点击这里下载：mimetex.zip
这里推荐解压后直接上传整个文件夹的代码上去，因为最好可以在服务器端编译，而非客户端编译好，否则平台可能不兼容。在解压出来的文件目录中新建一个 complie.php 文件，其中输入

1
2
3
&#60;?php
echo `cc -DAA mimetex.c gifsave.c -lm -o mimetex.cgi &#62; cc1 2&#62; cc2`;
?&#62;

然后通过浏览器访问这个 PHP，再查看 cc1 和 cc2 文件。如果不出意外，cc1 和 cc2 应该都是没有内容的空文件。
接下来，把这个 mimetex.cgi 移动到你想要的文件夹，并给它加上执行权限（不然可能出现 500 错误）。
如果服务器是 Windows 的，因为 Windows 似乎对兼容做得比较不错，因此可以直接用我编译的这个cgi (编译器 mingw gcc 3.1.1)：mimetex.cgi (924KB)
下面，在你安放 mimetex.cgi 的文件夹下新建一个 [...]]]></description>
			<content:encoded><![CDATA[<p>原来一直以为只有自己的机子安装了 LaTeX、dvips 等等这些软件才能显示 LaTeX 公式。</p>
<p>今天上网查找了一下，发现不是这样的，原来比较基本的 LAMP 空间也可以这样了，这完全得益于一个叫做 mimeTeX 的开源软件。虽然这个软件生成的没有 LaTeX 生成的漂亮，不过还是比 Word 的公式编辑器生成的漂亮，最重要的是可以在网站上使用！<br />
<span id="more-713"></span><br />
要安装这个，有一个比较必要的前提，就是你的网站必须不能运行在 PHP 的安全模式下，还有就是网站必须允许是用 .htaccess 配置文件，否则可能不行……不是……是肯定不行……另外权限设置比较严格的服务器上注意把相应权限设置妥当。</p>
<p>如果服务器是 Linux 平台下的，首先，我们要下载这个软件，源代码可以点击这里下载：<a href="http://www.forkosh.com/mimetex.zip">mimetex.zip</a><br />
这里推荐解压后直接上传整个文件夹的代码上去，因为最好可以在服务器端编译，而非客户端编译好，否则平台可能不兼容。在解压出来的文件目录中新建一个 complie.php 文件，其中输入</p>

<div class="wp_codebox"><table><tr id="p71331"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p713code31"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> `cc <span style="color: #339933;">-</span>DAA mimetex<span style="color: #339933;">.</span>c gifsave<span style="color: #339933;">.</span>c <span style="color: #339933;">-</span>lm <span style="color: #339933;">-</span>o mimetex<span style="color: #339933;">.</span>cgi <span style="color: #339933;">&gt;</span> cc1 <span style="color: #cc66cc;">2</span><span style="color: #339933;">&gt;</span> cc2`<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>然后通过浏览器访问这个 PHP，再查看 cc1 和 cc2 文件。如果不出意外，cc1 和 cc2 应该都是没有内容的空文件。<br />
接下来，把这个 mimetex.cgi 移动到你想要的文件夹，并给它加上执行权限（不然可能出现 500 错误）。</p>
<p>如果服务器是 Windows 的，因为 Windows 似乎对兼容做得比较不错，因此可以直接用我编译的这个cgi (编译器 mingw gcc 3.1.1)：<a href="http://down.upsuper.org/mimetex.cgi">mimetex.cgi</a> (924KB)</p>
<p>下面，在你安放 mimetex.cgi 的文件夹下新建一个 .htaccess 文件，并设置如下内容：</p>

<div class="wp_codebox"><table><tr id="p71332"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p713code32"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">Options</span> +ExecCGI
<span style="color: #00007f;">AddHandler</span> cgi-<span style="color: #00007f;">script</span> cgi</pre></td></tr></table></div>

<p>如果你不想让别人借你的服务器生成图片的话，还可以输入以下内容：</p>

<div class="wp_codebox"><table><tr id="p71333"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p713code33"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">Order</span> <span style="color: #00007f;">deny</span>,<span style="color: #00007f;">allow</span>
<span style="color: #00007f;">Deny</span> from <span style="color: #0000ff;">all</span>
<span style="color: #00007f;">Allow</span> from 127.0.0.0/255.0.0.0 ::<span style="color: #ff0000;">1</span>/<span style="color: #ff0000;">128</span></pre></td></tr></table></div>

<p>当然，这样你就只能在 PHP 中用 curl 访问了~虽然我也推荐这样做。</p>
<p>上面这样就可以了，然后如果要生成某个 LaTeX 的图片，只要访问 <em>mimetex.cgi?你的公式</em> 就可以了，如</p>

<div class="wp_codebox"><table><tr id="p71334"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p713code34"><pre class="text" style="font-family:monospace;">mimetex.cgi?\sqrt{2}^2=2</pre></td></tr></table></div>

<p>这样，漂亮的 gif 图片就出来了。</p>
<p>最后再说说，我个人觉得，直接让客户端访问这个并不好，所以推荐加上权限控制，然后在 PHP 中是用 curl 获取，并做一次缓存。毕竟不管怎样，生成这个是要花费不少的 CPU，如果遇到大量公式的时候，应该会相当可怕……所以这种时候做一个缓存应该是很好的选择，毕竟那些 gif 都不大。这段代码就不写了，我想应该是很简单的~</p>
<p>说回来，如果认真看这个程序的 README 还会发现，如果加上编译参数 -DCACHEPATH=地址 就可以在 cgi 级别使用 MD5 Hash 的文件缓存。不过再想想，其实没什么必要，一个是用 PHP 控制缓存文件要更方便，同时考虑到文件系统在一个目录下文件多于 10000 个时会出现严重性能问题，最好使用多级目录来做缓存，不过看代码似乎没有多级缓存。除此之外，我想还有一些不错的方法可以做一些初级判重，这些用 PHP 实现会比改 cgi 要简单的多了~建议大家可以自己再多看看编译说明，似乎有不少有趣的编译参数~</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/php-space-show-latex-formula/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>WAP版百度投票</title>
		<link>http://blog.upsuper.org/wap-version-of-baidu-vote/</link>
		<comments>http://blog.upsuper.org/wap-version-of-baidu-vote/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 02:00:31 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[小程序]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[百度]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=678</guid>
		<description><![CDATA[百度贴吧的投票不支持手机，连 UCWEB 和 Opera Mini 都看不了，于是就自己写了个，不过只能查看，不能投票就是了……

其实我一直很奇怪，连我当时的音乐投票站点用的全 AJAX 那俩浏览器都能完全支持，为什么百度这个却不行呢？经过研究，我在投票的地方发现如下代码：

1
document.write&#40;'&#60;iframe id=&#34;vote_iframe&#34; id=&#34;vote_iframe&#34; width=&#34;100%&#34; frameborder=&#34;0&#34;  height=&#34;0&#34; scrolling=&#34;no&#34;  src=&#34;http://toupiao.baidu.com/sys/dtview/1/299ffee9f95d723176f722e6?bu='+r_url+'&#38;t='+Math.random&#40;&#41;+'&#34;&#62;&#60;/iframe&#62;'&#41;

这段代码出现在投票信息出现的地方，很明显，这就是投票信息。所以就打开 http://toupiao.baidu.com/sys/dtview/1/299ffee9f95d723176f722e6 看到了那个投票信息，再研究代码，便写出了下面程序：

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
header&#40;'Content-Type: text/vnd.wap.wml;charset=UTF-8'&#41;;
&#160;
$id = $_GET&#91;'id'&#93;;
$id = preg_replace&#40;'/[^0-9a-f]/i', '', $id&#41;;
&#160;
if &#40;! $id&#41; exit&#40;'错误的投票 id ！'&#41;;
&#160;
$file = './cache/'.$id;
&#160;
if &#40;file_exists&#40;$file&#41;&#41; &#123;
	include $file;
&#160;
	$curl = curl_init&#40;&#41;;
	curl_setopt&#40;$curl, CURLOPT_URL, 'http://toupiao.baidu.com/sys/rsview/1/'.$id.'?t='.rand&#40;&#41;&#41;;
	curl_setopt&#40;$curl, CURLOPT_HEADER, 0&#41;;
	curl_setopt&#40;$curl, CURLOPT_RETURNTRANSFER, 1&#41;;
	$content = curl_exec&#40;$curl&#41;;
	curl_close&#40;$curl&#41;;
&#160;
	preg_match&#40;'/vtVoterSum:(\d+),/i', $content, $match&#41;;
	if &#40;! $match&#41; exit&#40;'错误！'&#41;;
	$total = $match&#91;1&#93;;
&#160;
	preg_match_all&#40;'/{vtVoteNum:(\d+),vtVotePt:(\d+\.\d+)}/', $content, $match, [...]]]></description>
			<content:encoded><![CDATA[<p>百度贴吧的投票不支持手机，连 UCWEB 和 Opera Mini 都看不了，于是就自己写了个，不过只能查看，不能投票就是了……<br />
<span id="more-678"></span><br />
其实我一直很奇怪，连我当时的音乐投票站点用的全 AJAX 那俩浏览器都能完全支持，为什么百度这个却不行呢？经过研究，我在投票的地方发现如下代码：</p>

<div class="wp_codebox"><table><tr id="p67837"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p678code37"><pre class="javascript" style="font-family:monospace;">document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;iframe id=&quot;vote_iframe&quot; id=&quot;vote_iframe&quot; width=&quot;100%&quot; frameborder=&quot;0&quot;  height=&quot;0&quot; scrolling=&quot;no&quot;  src=&quot;http://toupiao.baidu.com/sys/dtview/1/299ffee9f95d723176f722e6?bu='</span><span style="color: #339933;">+</span>r_url<span style="color: #339933;">+</span><span style="color: #3366CC;">'&amp;t='</span><span style="color: #339933;">+</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'&quot;&gt;&lt;/iframe&gt;'</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>这段代码出现在投票信息出现的地方，很明显，这就是投票信息。所以就打开 <a href="http://toupiao.baidu.com/sys/dtview/1/299ffee9f95d723176f722e6">http://toupiao.baidu.com/sys/dtview/1/299ffee9f95d723176f722e6</a> 看到了那个投票信息，再研究代码，便写出了下面程序：</p>

<div class="wp_codebox"><table><tr id="p67838"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
</pre></td><td class="code" id="p678code38"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-Type: text/vnd.wap.wml;charset=UTF-8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/[^0-9a-f]/i'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'错误的投票 id ！'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'./cache/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$id</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">include</span> <span style="color: #000088;">$file</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$curl</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://toupiao.baidu.com/sys/rsview/1/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'?t='</span><span style="color: #339933;">.</span><span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_HEADER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/vtVoterSum:(\d+),/i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'错误！'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$total</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/{vtVoteNum:(\d+),vtVotePt:(\d+\.\d+)}/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$match</span><span style="color: #339933;">,</span> PREG_SET_ORDER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'错误！'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'%'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$curl</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://toupiao.baidu.com/sys/dtview/1/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'?t='</span><span style="color: #339933;">.</span><span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_HEADER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">iconv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'gb2312'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'utf-8'</span><span style="color: #339933;">,</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/vote_desc_array\[\d+\]=new Array\(&quot;(.+?)&quot;,\d+\);/i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$match</span><span style="color: #339933;">,</span> PREG_SET_ORDER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'错误！'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$fp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wb'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;?php<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">fprintf</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'$item[%d][0]=%s;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$i</span><span style="color: #339933;">,</span> <span style="color: #990000;">var_export</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>?&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&lt;span class=&quot;fB&quot;&gt;(\d+)&lt;\/span&gt;/i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//if (! $match) exit('错误！');</span>
	<span style="color: #000088;">$total</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/{optVoNum:(\d+),vtVotePt:(\d+\.\d+)}/i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$match</span><span style="color: #339933;">,</span> PREG_SET_ORDER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Location: index.php?id='</span><span style="color: #339933;">.</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'%'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'./userface.php'</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>至于 userface.php 就自己写 wml 界面就好了~</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/wap-version-of-baidu-vote/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>对字符串加长和数组合并的效率比较</title>
		<link>http://blog.upsuper.org/lengthening-of-the-string-and-compare-the-efficiency-of-the-combined-array/</link>
		<comments>http://blog.upsuper.org/lengthening-of-the-string-and-compare-the-efficiency-of-the-combined-array/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 04:59:02 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[探究学习]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[效率]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=674</guid>
		<description><![CDATA[对于字符串累加的处理，在 PHP 或 JavaScript 中似乎都可以通过类似 += (.= for PHP) 的方式实现，但有不少人抱怨道，这种方式效率很低。事实上，在我还在用 VB 的时候我就注意到这样的效率很低，当时的效率低是因为累加需要反复申请内存，而解决方法也很简单，就是用 Space$ 命令事先申请内存，然后用 Mid$ 来修改，这样效率大大提高！
然而在这里就不一样了，PHP 和 JavaScript 的内存机制我不是非常了解，同时我们似乎也不再使用预申请的方法来加速了（似乎也比较困难……），而是直接用上了 += 这样的符号。
下面就是问题了：这样的效率低吗？

很多人（包括我自己最初）根据自己的想象，认为使用添加数组内容，最后合并数组为字符串，这样效率比简单的 += 要快，但我经过反复实验认为并不是这样的。首先是 JavaScript，我使用的测试代码如下：

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function getTime&#40;&#41; &#123;
	return &#40;new Date&#40;&#41;&#41;.getTime&#40;&#41;;
&#125;
function testit&#40;&#41; &#123;
	for &#40;i = 0; i &#60; 10; ++i&#41; &#123;
		st = getTime&#40;&#41;;
		t = '';
		for &#40;j = 0; j &#60; 100000; ++j&#41; &#123;
			t += 'test';
		&#125;
		et = getTime&#40;&#41;;
		document.write&#40;et - [...]]]></description>
			<content:encoded><![CDATA[<p>对于字符串累加的处理，在 PHP 或 JavaScript 中似乎都可以通过类似 += (.= for PHP) 的方式实现，但有不少人抱怨道，这种方式效率很低。事实上，在我还在用 VB 的时候我就注意到这样的效率很低，当时的效率低是因为累加需要反复申请内存，而解决方法也很简单，就是用 Space$ 命令事先申请内存，然后用 Mid$ 来修改，这样效率大大提高！</p>
<p>然而在这里就不一样了，PHP 和 JavaScript 的内存机制我不是非常了解，同时我们似乎也不再使用预申请的方法来加速了（似乎也比较困难……），而是直接用上了 += 这样的符号。</p>
<p>下面就是问题了：这样的效率低吗？<br />
<span id="more-674"></span><br />
很多人（包括我自己最初）根据自己的想象，认为使用添加数组内容，最后合并数组为字符串，这样效率比简单的 += 要快，但我经过反复实验认为并不是这样的。首先是 JavaScript，我使用的测试代码如下：</p>

<div class="wp_codebox"><table><tr id="p67443"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code" id="p674code43"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> testit<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		st <span style="color: #339933;">=</span> getTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		t <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">100000</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>j<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			t <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'test'</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		et <span style="color: #339933;">=</span> getTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span>et <span style="color: #339933;">-</span> st<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\t</span>'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		st <span style="color: #339933;">=</span> getTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		a <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">100000</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>j<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			a.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'test'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		t <span style="color: #339933;">=</span> a.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		et <span style="color: #339933;">=</span> getTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span>et <span style="color: #339933;">-</span> st<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>以下是我在 Firefox 3.0.6 下执行的结果：</p>

<div class="wp_codebox"><table><tr id="p67444"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p674code44"><pre class="text" style="font-family:monospace;">196	207
195	215
199	203
196	203
200	197
110	111
104	111
107	111
108	113
105	107</pre></td></tr></table></div>

<p>可以看出，+= 的效率并不比数组合并低，甚至略快于数组合并。</p>
<p>下面我们看看 PHP 呢？</p>
<p>下面是测试用 PHP 代码：</p>

<div class="wp_codebox"><table><tr id="p67445"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p674code45"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$st</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$j</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">10000</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span><span style="color: #000088;">$j</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$str</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'test'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$et</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #009933; font-weight: bold;">%.7F</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$et</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$st</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$st</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$arr</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$j</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">10000</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span><span style="color: #000088;">$j</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$arr</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'test'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$et</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #009933; font-weight: bold;">%.7F</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$et</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$st</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>结果则如下：</p>

<div class="wp_codebox"><table><tr id="p67446"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p674code46"><pre class="text" style="font-family:monospace;">0.0039599	0.0461071
0.0070710	0.0408709
0.0052779	0.0322330
0.0061541	0.0294971
0.0051920	0.0230181
0.0039949	0.0204601
0.0038750	0.0246589
0.0043111	0.0245950
0.0047810	0.0232542
0.0038841	0.0230379</pre></td></tr></table></div>

<p>可以看出，数组合并的效率远低于字符串直接叠加！</p>
<p>上一次用 spidermonkey-bin 中的 js 命令做了一下实验，结果在这种条件下，字符串叠加的效率也是远优于数组合并，而不像在 Firefox 中这样。</p>
<p>我对于这些脚本语言对字符串和数组的具体实现机理不是很清楚，但可以肯定的是，个个常用的脚本引擎都对字符串处理做了许多优化，我猜测（因为 Ubuntu 下暂时没有 stable 的 Chrome）Chrome 的 V8 引擎中，字符串直接叠加的效率将继续远超数组。因此，我们不应该想当然地认为某某方式效率高，而应该用测试结果说话……</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/lengthening-of-the-string-and-compare-the-efficiency-of-the-combined-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>惊叹 isset 执行速度之快！</title>
		<link>http://blog.upsuper.org/amazing-speed-of-isset/</link>
		<comments>http://blog.upsuper.org/amazing-speed-of-isset/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 08:57:14 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[雕虫小技]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=664</guid>
		<description><![CDATA[今天无聊做了个小小的测试，结果却出乎我的意料。我对比了 isset 函数和比较运算符的速度，结果竟是 isset 比较快！

下面是测试代码：

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
header&#40;&#34;Content-Type: text/plain&#34;&#41;;
$tests = array&#40;'[size=1]', '[table=1px,solid,black]', '[/table]', '[/a=testit]'&#41;;
&#160;
for &#40;$i = 0; $i &#60; 10; ++$i&#41; &#123;
$st = microtime&#40;true&#41;;
for &#40;$j = 0; $j &#60; 20; ++$j&#41; &#123;
foreach &#40;$tests as $test&#41; &#123;
preg_match&#40;'/^\[(?&#60;c&#62;\/)?[A-Za-z]\w*(?(c):(?!)&#124;=[^\]]*)?\]$/', $test&#41;;
explode&#40;'=', substr&#40;$test, 1, -1&#41;, 1&#41;;
&#125;
&#125;
$et = microtime&#40;true&#41;;
printf&#40;&#34;%.6F\t&#34;, $et - $st&#41;;
&#160;
$st = microtime&#40;true&#41;;
for &#40;$j = 0; $j &#60; 20; ++$j&#41; &#123;
foreach &#40;$tests as [...]]]></description>
			<content:encoded><![CDATA[<p>今天无聊做了个小小的测试，结果却出乎我的意料。我对比了 isset 函数和比较运算符的速度，结果竟是 isset 比较快！<br />
<span id="more-664"></span><br />
下面是测试代码：</p>

<div class="wp_codebox"><table><tr id="p66450"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code" id="p664code50"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Type: text/plain&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$tests</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'[size=1]'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'[table=1px,solid,black]'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'[/table]'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'[/a=testit]'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$st</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$j</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span><span style="color: #000088;">$j</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$tests</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$test</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^\[(?&lt;c&gt;\/)?[A-Za-z]\w*(?(c):(?!)|=[^\]]*)?\]$/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$test</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'='</span><span style="color: #339933;">,</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$test</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$et</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #009933; font-weight: bold;">%.6F</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$et</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$st</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$st</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$j</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span><span style="color: #000088;">$j</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$tests</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$test</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^\[(?&lt;c&gt;\/)?([A-Za-z]\w*)(?(c):(?!)|=([^\]]*))?\]$/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$test</span><span style="color: #339933;">,</span> <span style="color: #000088;">$r</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$et</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #009933; font-weight: bold;">%.6F</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$et</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$st</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>下面选取了在我机子上和在我的网页服务器上测试的数据，这两台机的操作系统都是 Ubuntu，PHP 都为 5.2.6。我在学校服务器上测试结果与这里有较大出入，疑是 PHP 版本不同的缘故。</p>
<p>下面数据每个前15行为单独跑的数据，后面三行分别为最慢、最快和去掉最大最小值的平均值。</p>
<p>三列分别表示 isset、与变量比大小，与数值比大小。</p>
<p>下面是在我机子上跑的数据：</p>

<div class="wp_codebox"><table><tr id="p66451"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p664code51"><pre class="text" style="font-family:monospace;">0.001914	0.003213	0.003172
0.001762	0.002843	0.003285
0.001810	0.002995	0.003005
0.001736	0.002813	0.002978
0.001803	0.002903	0.003003
0.001814	0.002854	0.003005
0.001822	0.002850	0.003025
0.001809	0.002843	0.003014
0.001806	0.002834	0.003009
0.001790	0.002822	0.003000
0.001764	0.002838	0.002999
0.001766	0.003941	0.003149
0.001785	0.002831	0.003017
0.001794	0.002822	0.003011
0.001769	0.002854	0.003014
&nbsp;
0.001914	0.003941	0.003285
0.001736	0.002813	0.002978
0.001792	0.002885	0.003033</pre></td></tr></table></div>

<p>这个是在我的服务器上跑的数据：</p>

<div class="wp_codebox"><table><tr id="p66452"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p664code52"><pre class="text" style="font-family:monospace;">0.001070	0.001156	0.001107
0.001063	0.001157	0.001108
0.001061	0.001155	0.001127
0.001063	0.001156	0.001106
0.001060	0.001155	0.001105
0.001059	0.001142	0.001145
0.001042	0.001141	0.001111
0.001119	0.001146	0.001133
0.001041	0.001142	0.001104
0.001040	0.001146	0.001153
0.001114	0.001152	0.001105
0.001056	0.001248	0.001111
0.001046	0.001148	0.001111
0.001079	0.001153	0.001103
0.001057	0.001160	0.001112
&nbsp;
0.001119	0.001248	0.001153
0.001040	0.001141	0.001103
0.001062	0.001151	0.001114</pre></td></tr></table></div>

<p>（可以看出我的机子还是比不过那服务器的……不知道配置问题还是 Ubuntu Desktop 和 Server 的差别……）</p>
<p>同时我发现，在我的机上，与数值比大小比与变量比大小还慢，但在服务器上没有出现这种情况（本来就不该……）</p>
<p>神奇的测试结果……</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/amazing-speed-of-isset/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>我的 lab1（二）——编译安装 PHP 5.3</title>
		<link>http://blog.upsuper.org/my-lab1-b-compile-and-install-php-53/</link>
		<comments>http://blog.upsuper.org/my-lab1-b-compile-and-install-php-53/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 07:14:12 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[我的计划]]></category>
		<category><![CDATA[探究学习]]></category>
		<category><![CDATA[JeOS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=657</guid>
		<description><![CDATA[昨天把 JeOS 给弄好了，今天就开始弄 PHP 5.3 了……

把刚刚下好的 php-5.3.0beta1.tar.bz2 上传到 lab1 里面，准备解压。发现 JeOS 里面没有 bzip2……又 apt 了个……
用 tar jxvf php-5.3.0beta1.tar.bz2 解压了文件，进入文件夹，开始 configure。
刚刚 configure 没一会儿，提示找不到 C 编译器。冷了，连 gcc 什么的都没装。又 apt 了个 gcc 和 g++。再 configure，提示没找到 libxml2。apt 了 libxml2，还是找不到，去网上一查，发现还要 libxml2-dev，又 apt 了下来。
最后终于 configure 过了，开始 make。提示没有 make。其实这早在我的意料之中……apt 了 make 和 automake，开始 make，make 完提示说别忘了 make test，我就 make test……等他 test 完告诉我提交报告，那就提交报告吧……麻烦……提交完我就开始 sudo [...]]]></description>
			<content:encoded><![CDATA[<p>昨天把 JeOS 给弄好了，今天就开始弄 PHP 5.3 了……<br />
<span id="more-657"></span><br />
把刚刚下好的 php-5.3.0beta1.tar.bz2 上传到 lab1 里面，准备解压。发现 JeOS 里面没有 bzip2……又 apt 了个……</p>
<p>用 tar jxvf php-5.3.0beta1.tar.bz2 解压了文件，进入文件夹，开始 configure。</p>
<p>刚刚 configure 没一会儿，提示找不到 C 编译器。冷了，连 gcc 什么的都没装。又 apt 了个 gcc 和 g++。再 configure，提示没找到 libxml2。apt 了 libxml2，还是找不到，<a href="http://blog.sina.com.cn/s/blog_54ee3de50100btjv.html" target="_blank">去网上一查</a>，发现还要 libxml2-dev，又 apt 了下来。</p>
<p>最后终于 configure 过了，开始 make。提示没有 make。其实这早在我的意料之中……apt 了 make 和 automake，开始 make，make 完提示说别忘了 make test，我就 make test……等他 test 完告诉我提交报告，那就提交报告吧……麻烦……提交完我就开始 sudo make install。安装完，试一下 cli 的 php，可以使用了。很兴奋的回到外面在浏览器输入 phpinfo 的页面，结果提示下载……</p>
<p>失败了……在网上又一整查找，看到一篇<a href="http://blog.sina.com.cn/s/blog_54ee3de50100btjv.html" target="_blank"> Ubuntu 下编译安装 5.2.8 的</a>，里面的编译参数看不懂 _-b 所以我就一个都没敢加……不过我觉得实在费解，为什么要编译安装 5.2.8 呢……5.2.8 似乎没什么新特性，而且 Ubuntu 自带的 PHP 5.2.6 是加了 Suhosin Patch 的，安全！最后找到 PHP 的<a href="http://cn2.php.net/manual/en/install.unix.apache2.php" target="_blank">官方文档</a>才明白，那个 &#8211;with-apxs2 是表示 Apache2 的……</p>
<p>用 find |grep &#8216;apxs&#8217; 发现我饿 apxs2 在 /usr/bin/apxs2，就又重新开始 configure 了。这次 configure 倒也顺利（因为改装的都装好了），本想也顺便 &#8211;with-mysql 个，结果发现 mysql 没装……而且装了还是不过，就干脆不要了。</p>
<p>configure 完成后，照例是 make、make test、sudo make install。这或许就像 Windows 里的下一步一样。不过在 Ubuntu 的 apt 下，连这个都省了，我也被惯懒了……</p>
<p>sudo make install 果然出错了，提示 httpd.conf 至少应该有一个 LoadModule。想起上面那篇编译 5.2.8 的里面也写了这些东西，遍在 httpd.conf 里面加入了</p>

<div class="wp_codebox"><table><tr id="p65754"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p657code54"><pre class="apache" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;"># Dummy LoadModule directive to aid module installations</span>
<span style="color: #adadad; font-style: italic;"># LoadModule dummy_module /usr/lib/apache2/modules/mod_dummy.so</span></pre></td></tr></table></div>

<p>竟然真的过了 _-b 电脑还真好骗……</p>
<p><img src="http://blog.upsuper.org/wp-content/uploads/2009/01/phpinfo_1233299380831-300x293.png" alt="phpinfo_1233299380831" title="phpinfo_1233299380831" width="300" height="293" class="alignright size-medium wp-image-658" />安装完成后，再次重启 apache2，打开浏览器，查看 phpinfo。终于出来了，我的 PHP 5.3！</p>
<p>真是辛苦……本来以为用了这么久 Ubuntu 对 Linux 还算有点了解了，经过这么一折腾，发现自己原来连门都还没入……</p>
<p>好吧，PHP 5.3 的测试就再说吧……今天就这样了……</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/my-lab1-b-compile-and-install-php-53/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>我的 lab1（一）——Just enough 的 JeOS</title>
		<link>http://blog.upsuper.org/my-lab1-1-just-enough-of-jeos/</link>
		<comments>http://blog.upsuper.org/my-lab1-1-just-enough-of-jeos/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 15:17:53 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[探究学习]]></category>
		<category><![CDATA[JeOS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[虚拟机]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=655</guid>
		<description><![CDATA[为了想提早试验 PHP 5.3 （昨晚下了个 Alpha，今天发现变成 Beta 了……），我在 VMware 下建立了个实验室，因为据说 JeOS 是有为虚拟机优化的，所以用了 Ubuntu JeOS 8.04.1，取名叫 upsuper-lab1。

话说 VMware 6.5 还着实智能，识别出了 JeOS 的 iso 里面是 Ubuntu 8.04，不过可惜他智能过头了，自己弄了个安装程序准备介入，结果安装失败了……我把 VMware 额外加载的光驱干掉，再安一次就好了。
安装 JeOS 是文字界面（至少不是 LiveCD 那样的界面……），而且，Ubuntu 的文字界面安装有一大囧处，就是会检测 apt！JeOS 的安装确实两次卡在检测 apt 上……根据某次在学校安装 Alternate 的经验，赶快把网卡禁用掉，然后重新安装，所有不该有的东西成功跳过。
随后，系统启动进入 Ubuntu。我突然发现，这真是一个 Just enough 的系统，连图形界面都没有……囧……我第一个想法是，用 apt 弄一个 apache2 先。结果当我启动 apt 的时候，蓦然想起，网络还没弄好。如果在图形界面，肯定是瞬间就可以解决的问题（Ubuntu 有带些强大的网络管理程序），可是在文字界面……
幸好是在虚拟机，回到外面，在网上找到了网络配置的方法，用 vim 打开 /etc/network/interfaces，然后将其修改为

1
2
3
auto lo eth0
iface lo inet [...]]]></description>
			<content:encoded><![CDATA[<p>为了想提早试验 PHP 5.3 （昨晚下了个 Alpha，今天发现变成 Beta 了……），我在 VMware 下建立了个实验室，因为据说 JeOS 是有为虚拟机优化的，所以用了 Ubuntu JeOS 8.04.1，取名叫 upsuper-lab1。<br />
<span id="more-655"></span><br />
话说 VMware 6.5 还着实智能，识别出了 JeOS 的 iso 里面是 Ubuntu 8.04，不过可惜他智能过头了，自己弄了个安装程序准备介入，结果安装失败了……我把 VMware 额外加载的光驱干掉，再安一次就好了。</p>
<p>安装 JeOS 是文字界面（至少不是 LiveCD 那样的界面……），而且，Ubuntu 的文字界面安装有一大囧处，就是会检测 apt！JeOS 的安装确实两次卡在检测 apt 上……根据某次在学校安装 Alternate 的经验，赶快把网卡禁用掉，然后重新安装，所有不该有的东西成功跳过。</p>
<p>随后，系统启动进入 Ubuntu。我突然发现，这真是一个 Just enough 的系统，连图形界面都没有……囧……我第一个想法是，用 apt 弄一个 apache2 先。结果当我启动 apt 的时候，蓦然想起，网络还没弄好。如果在图形界面，肯定是瞬间就可以解决的问题（Ubuntu 有带些强大的网络管理程序），可是在文字界面……</p>
<p>幸好是在虚拟机，回到外面，在网上找到了<a href="http://www.blogjava.net/aoxj/archive/2008/04/18/194103.html" target="_blank">网络配置的方法</a>，用 vim 打开 /etc/network/interfaces，然后将其修改为</p>

<div class="wp_codebox"><table><tr id="p65558"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p655code58"><pre class="text" style="font-family:monospace;">auto lo eth0
iface lo inet loopback
iface eth0 inet dhcp</pre></td></tr></table></div>

<p>最后</p>

<div class="wp_codebox"><table><tr id="p65559"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p655code59"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>networking restart</pre></td></tr></table></div>

<p>成功的找到了网络。接着就是 Ubuntu 都需要的配置过程——改 apt 源。</p>
<p>还是 vim 打开 /etc/apt/sources.list<br />
将里面 cn.achieve.ubuntu.com 全部改成 tw.achieve.ubuntu.com 或 mirror.lupaworld.com，保存。</p>
<p>终于可以用 apt 了，真是欣慰。</p>
<p>运行 apt 发现中文都是菱形？！又在网上查找了一翻，找到一篇<a href="http://www.linuxdiyf.com/viewarticle.php?id=79931" target="_blank">相关的文章</a>，修改了 /etc/default/locale 文件的相关内容，重启。</p>
<p>把 apache2 安装好了，并把 VMware 的网络设置从 NAT 设置为 Bridge，然后在主机的浏览器输入 IP 地址，看到了那个著名的 It works!</p>
<p>下面是 ftp 服务器。因为我在自己的机子上都没做过 ftp，所以自然是不知道怎么弄的。去网上先是看到一个传说中很好的 ftp 服务器，叫做 wu-ftp，结果弄了半天配置不出来，就放弃了。换了个叫 vsftp 的。网上资料似乎很多，就是没有能让我配置成功的。最后我只得找到他的 <a href="http://vsftpd.beasts.org/vsftpd_conf.html" target="_blank">Manpage</a>，按着里面的说法配置。配出来恐怕安全性不高，不过足够易用就好了……下面是我的配置文件：</p>

<div class="wp_codebox"><table><tr id="p65560"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code" id="p655code60"><pre class="text" style="font-family:monospace;">anon_mkdir_write_enable=YES
anon_other_write_enable=YES
anon_upload_enable=YES
anon_world_readable_only=NO
anonymous_enable=YES
connect_from_port_20=YES
dirmessage_enable=YES
listen=YES
local_enable=YES
no_anon_password=YES
write_enable=YES
xferlog_enable=YES
xferlog_std_format=YES
accept_timeout=3600
connect_timeout=3600
file_open_mode=0777
anon_root=/var/www</pre></td></tr></table></div>

<p>匿名倒是没登上去，用我在 JeOS 里的用户名密码倒是登上去，而且可以直接查看整个文件系统（相关权限还在就是了）。</p>
<p>不管了，反正能用就行了，这是 lab 嘛……</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/my-lab1-1-just-enough-of-jeos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>我的 PHP 测试小程序</title>
		<link>http://blog.upsuper.org/my-php-test-applet/</link>
		<comments>http://blog.upsuper.org/my-php-test-applet/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 01:52:11 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[小程序]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=596</guid>
		<description><![CDATA[最近研究 PHP，为了方便，写了个小小的 PHP 页面用来测试简单的 PHP 代码段，为了看了更方便。虽然可能有更好的工具，不过也胡乱贴出来，呵呵~

首先要先在这个文件的文件夹下建立一个 script_test.php 文件，还要把这个文件设为 0777（这是 Linux 的属性，用 Windows 的不用鸟……Windows 的权限设置过于宽松了……）。
然后是代码：

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
&#60;?php
$script = stripslashes&#40;$_REQUEST&#91;'script'&#93;&#41;;
if &#40;$script !== false&#41; &#123;
	$ftest = fopen&#40;&#34;script_test.php&#34;, &#34;wb&#34;&#41;;
	fwrite&#40;$ftest, $script&#41;;
	fclose&#40;$ftest&#41;;
&#125;
?&#62;
&#60;?php if &#40;$_REQUEST&#91;'ret'&#93; == 'js'&#41; : ?&#62;
&#60;script language=&#34;javascript&#34;&#62;
parent.document.getElementById&#40;'show_test'&#41;.contentWindow.location.reload&#40;&#41;;
&#60;/script&#62;
&#60;?php else : ?&#62;
&#60;style&#62;textarea &#123; width: 100%; height: 400px; &#125;&#60;/style&#62;
&#60;table width=&#34;100%&#34;&#62;
&#60;tr valign=&#34;top&#34;&#62;&#60;td width=&#34;50%&#34;&#62;
&#60;form action=&#34;?ret=js&#34; method=&#34;POST&#34; target=&#34;submit_iframe&#34;&#62;
&#60;textarea id=&#34;script&#34; name=&#34;script&#34;&#62;
&#60;?php if &#40;$script !== false&#41; : ?&#62;&#60;?= $script [...]]]></description>
			<content:encoded><![CDATA[<p>最近研究 PHP，为了方便，写了个小小的 PHP 页面用来测试简单的 PHP 代码段，为了看了更方便。虽然可能有更好的工具，不过也胡乱贴出来，呵呵~<br />
<span id="more-596"></span><br />
首先要先在这个文件的文件夹下建立一个 script_test.php 文件，还要把这个文件设为 0777（这是 Linux 的属性，用 Windows 的不用鸟……Windows 的权限设置过于宽松了……）。</p>
<p>然后是代码：</p>

<div class="wp_codebox"><table><tr id="p59662"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code" id="p596code62"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$script</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'script'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$script</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$ftest</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;script_test.php&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;wb&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ftest</span><span style="color: #339933;">,</span> <span style="color: #000088;">$script</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ftest</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ret'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'js'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;script language</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;javascript&quot;</span><span style="color: #339933;">&gt;</span>
parent<span style="color: #339933;">.</span>document<span style="color: #339933;">.</span>getElementById<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'show_test'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>contentWindow<span style="color: #339933;">.</span>location<span style="color: #339933;">.</span>reload<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">else</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;</span>style<span style="color: #339933;">&gt;</span>textarea <span style="color: #009900;">&#123;</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">%;</span> height<span style="color: #339933;">:</span> 400px<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">&lt;/</span>style<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>table width<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;100%&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>tr valign<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;top&quot;</span><span style="color: #339933;">&gt;&lt;</span>td width<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;50%&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>form action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;?ret=js&quot;</span> method<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;POST&quot;</span> target<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit_iframe&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>textarea id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;script&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;script&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$script</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: #000000; font-weight: bold;">?&gt;&lt;?=</span> <span style="color: #000088;">$script</span> <span style="color: #000000; font-weight: bold;">?&gt;&lt;?</span>php <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;/</span>textarea<span style="color: #339933;">&gt;&lt;</span>br <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Test&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>td width<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;50%&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$script</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: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;</span>iframe id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;show_test&quot;</span> src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;script_test.php&quot;</span>
 style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;border: 1px black solid; width: 100%; height: 400px;&quot;</span><span style="color: #339933;">&gt;&lt;/</span>iframe<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;/</span>td<span style="color: #339933;">&gt;&lt;/</span>tr<span style="color: #339933;">&gt;&lt;/</span>table<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>iframe id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit_iframe&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit_iframe&quot;</span> style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;display: none;&quot;</span><span style="color: #339933;">&gt;&lt;/</span>iframe<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>其中那些高度对于我的显示器效果是不错的，可以根据自己需要调整……</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/my-php-test-applet/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>赞一下 phpBB</title>
		<link>http://blog.upsuper.org/phpbb-praise/</link>
		<comments>http://blog.upsuper.org/phpbb-praise/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 14:19:13 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[琐事杂谈]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[论坛]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=594</guid>
		<description><![CDATA[好久没写日志了……因为高三了，学习要紧，在学校自然碰电脑就少一些，加上上周末是体检没回家，就有好长时间了。而且事实上，这段时间也找不到什么好写的东西，今天终于发现一个。
很早就知道有一个国外的开源论坛系统叫做 phpBB，也知道 Ubuntu 的中文论坛用的就是这套系统，今天载下来看一下，实在不得不写一篇来称赞它。
首先要称赞的，是它几乎完全是 OOP 的，这对于外表来看似乎没什么特别的意思，但作为一个程序员，我还是要称赞的，因为 OOP 意味着结构清晰，各个部分的分工明确，具有极强的组织性和易解释的特性。随意翻开 includes 文件夹里的文件，几乎都是 class。好像 WordPress 的代码也是这样的，这种代码通常我是看不懂的……因为 OOP 的思想不够深入？反正我觉得我还是很菜的……
接下去，就是它的权限管理。我觉得如果我写一套网站系统，一定要充分吸收 phpBB 的权限系统，这是我所见过的所有网站系统中最优秀的权限管理。如果我没记错的话，事实上 Zend Framework 提供了一个类似的权限系统，不过在国内的 php 程序中我几乎没有见过，自然不太了解，不知道是不是这样的系统在国外的程序中已经普遍应用了？
以上这两点已经够赞的了……不过我觉得他的界面即清晰清爽，又很强大，再赞一个。
原来看了 Discuz! 和 PHPWind 的代码，觉得写一个论坛系统是很容易的，再看看 phpBB……这种信心就彻底被摧毁了……再看看 PHPWind 官方的广告“中国领先的社区软件与方案供应商”，觉得他也只能在中国领先了……
]]></description>
			<content:encoded><![CDATA[<p>好久没写日志了……因为高三了，学习要紧，在学校自然碰电脑就少一些，加上上周末是体检没回家，就有好长时间了。而且事实上，这段时间也找不到什么好写的东西，今天终于发现一个。</p>
<p>很早就知道有一个国外的开源论坛系统叫做 phpBB，也知道 Ubuntu 的中文论坛用的就是这套系统，今天载下来看一下，实在不得不写一篇来称赞它。</p>
<p>首先要称赞的，是它几乎完全是 OOP 的，这对于外表来看似乎没什么特别的意思，但作为一个程序员，我还是要称赞的，因为 OOP 意味着结构清晰，各个部分的分工明确，具有极强的组织性和易解释的特性。随意翻开 includes 文件夹里的文件，几乎都是 class。好像 WordPress 的代码也是这样的，这种代码通常我是看不懂的……因为 OOP 的思想不够深入？反正我觉得我还是很菜的……</p>
<p>接下去，就是它的权限管理。我觉得如果我写一套网站系统，一定要充分吸收 phpBB 的权限系统，这是我所见过的所有网站系统中最优秀的权限管理。如果我没记错的话，事实上 Zend Framework 提供了一个类似的权限系统，不过在国内的 php 程序中我几乎没有见过，自然不太了解，不知道是不是这样的系统在国外的程序中已经普遍应用了？</p>
<p>以上这两点已经够赞的了……不过我觉得他的界面即清晰清爽，又很强大，再赞一个。</p>
<p>原来看了 Discuz! 和 PHPWind 的代码，觉得写一个论坛系统是很容易的，再看看 phpBB……这种信心就彻底被摧毁了……再看看 PHPWind 官方的广告“中国领先的社区软件与方案供应商”，觉得他也只能在中国领先了……</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/phpbb-praise/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>尝试一下Piwik，新的统计系统</title>
		<link>http://blog.upsuper.org/try-the-piwik-a-new-statistical-system/</link>
		<comments>http://blog.upsuper.org/try-the-piwik-a-new-statistical-system/#comments</comments>
		<pubDate>Sat, 17 May 2008 08:53:21 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[琐事杂谈]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[统计]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=93</guid>
		<description><![CDATA[今天发现一个开源的php+mysql统计系统——Piwik (demo)。这个系统看过去是相当不错，而且使用了AJAX提供良好的用户体验。于是我就下了一个传上去试一下，毕竟我对现在的Ourplus毕竟不很满意。
不过传上去后才发现，这个系统根本不支持中文，全英文的界面。
本来想，算是不错的一个这么庞大的统计系统，应该能比较容易地进行翻译，因此就看了一下。发现确实有一个名叫lang的文件夹，进去一看，果然有语言文件！可是翻译的时候发现，仅仅几条。经过侦查，发现这个系统高度插件化，几乎所有的功能都是通过插件提供的，给翻译带来了极大的困难。在翻译了几个插件以后，传上去测试，发现乱码，觉得是编码问题，就把中文的语言文件存为UTF-8，乱码问题解决。但是是在不想继续翻译了……
回到主界面，突然发现右上方写着“Piwik is a collaborative project and still Beta. If you want to help, please contact us.”。瞬间，觉得还是不用了，等着它的正式版吧！
不过要说的是，这确实应该会成为一个相当不错的统计系统，据说堪比Google Analytics！
]]></description>
			<content:encoded><![CDATA[<p>今天发现一个开源的php+mysql统计系统——<a href="http://piwik.org/" target="_blank">Piwik</a> (<a href="http://piwik.org/demo/" target="_blank">demo</a>)。这个系统看过去是相当不错，而且使用了AJAX提供良好的用户体验。于是我就下了一个传上去试一下，毕竟我对现在的Ourplus毕竟不很满意。</p>
<p>不过传上去后才发现，这个系统根本不支持中文，全英文的界面。</p>
<p>本来想，算是不错的一个这么庞大的统计系统，应该能比较容易地进行翻译，因此就看了一下。发现确实有一个名叫lang的文件夹，进去一看，果然有语言文件！可是翻译的时候发现，仅仅几条。经过侦查，发现这个系统高度插件化，几乎所有的功能都是通过插件提供的，给翻译带来了极大的困难。在翻译了几个插件以后，传上去测试，发现乱码，觉得是编码问题，就把中文的语言文件存为UTF-8，乱码问题解决。但是是在不想继续翻译了……</p>
<p>回到主界面，突然发现右上方写着“Piwik is a collaborative project and still Beta. If you want to help, please contact us.”。瞬间，觉得还是不用了，等着它的正式版吧！</p>
<p>不过要说的是，这确实应该会成为一个相当不错的统计系统，据说堪比Google Analytics！</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/try-the-piwik-a-new-statistical-system/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ubuntu之旅（一）</title>
		<link>http://blog.upsuper.org/ubuntu-trip-1/</link>
		<comments>http://blog.upsuper.org/ubuntu-trip-1/#comments</comments>
		<pubDate>Sat, 10 May 2008 15:44:10 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[探究学习]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[快捷键]]></category>
		<category><![CDATA[虚拟机]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=87</guid>
		<description><![CDATA[今天小小地探索了一下伟大的Ubuntu，使用的是刚出的Ubuntu8.04LTS。这里就来说一说吧~

本来想给我的电脑直接装上Ubuntu8.04LTS的，盘刻好了，还用分区魔术师划了些地方出来装。结果还是失败了，好像是提示什么I/O APIC的问题，Ubuntu的Linux内核根本启动不起来……所以最后只好回到Windows下用VMware了。
原来我的VMware里面就有一个Ubuntu的虚拟机，今天便把原来的内容全部消掉，重新安装了一个新的Ubuntu。安装还算顺利，就是安完还是半中文半英文，看得蛮不爽的说。
我的VMware设置为桥接到宿主所在网络，所以和在真实的网络环境一样。因为知道Ubuntu最依靠的就是网络，所以就先把网络设置好了。我家使用的是一个小型的支持DHCP的家用路由器，因此我在“系统-&#62;系统管理-&#62;网络”里面点击解锁后点击列表中的第一个，并设置其为DHCP。随后登入路由器，发现为我的Ubuntu虚拟系统分配了一个新的IP地址。Ubuntu的网络是连上了，可是我宿主机Windows的网络却不能用了，可虚拟机里面却好好的……郁闷……算了，先用虚拟机吧~
下面来处理语言的问题。经过调查，我先更新了apt的sources.list。首先点击“应用程序-&#62;附件-&#62;终端”，应用程序可能是中文，不过反正就是第一个菜单。然后输入：

1
2
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup
sudo gedit /etc/apt/sources.list

前面的sudo大约表示能够用最大权限，似乎etc目录都要用最大权限才能修改的样子，至于gedit是使用Gnome的Ubuntu下才有的命令。接下来我跟大家说说我更新以后的sources.list吧：

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
deb http://archive.ubuntu.org.cn/ubuntu-cn/ hardy main restricted universe multiverse
&#160;
# 这一套极快，每秒可以上MB级
deb http://ubuntu.cn99.com/ubuntu/ hardy main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-security main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-updates main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-security main restricted universe [...]]]></description>
			<content:encoded><![CDATA[<p>今天小小地探索了一下伟大的Ubuntu，使用的是刚出的Ubuntu8.04LTS。这里就来说一说吧~</p>
<p><span id="more-87"></span></p>
<p>本来想给我的电脑直接装上Ubuntu8.04LTS的，盘刻好了，还用分区魔术师划了些地方出来装。结果还是失败了，好像是提示什么I/O APIC的问题，Ubuntu的Linux内核根本启动不起来……所以最后只好回到Windows下用VMware了。</p>
<p>原来我的VMware里面就有一个Ubuntu的虚拟机，今天便把原来的内容全部消掉，重新安装了一个新的Ubuntu。安装还算顺利，就是安完还是半中文半英文，看得蛮不爽的说。</p>
<p>我的VMware设置为桥接到宿主所在网络，所以和在真实的网络环境一样。因为知道Ubuntu最依靠的就是网络，所以就先把网络设置好了。我家使用的是一个小型的支持DHCP的家用路由器，因此我在“系统-&gt;系统管理-&gt;网络”里面点击解锁后点击列表中的第一个，并设置其为DHCP。随后登入路由器，发现为我的Ubuntu虚拟系统分配了一个新的IP地址。Ubuntu的网络是连上了，可是我宿主机Windows的网络却不能用了，可虚拟机里面却好好的……郁闷……算了，先用虚拟机吧~</p>
<p>下面来处理语言的问题。经过调查，我先更新了apt的sources.list。首先点击“应用程序-&gt;附件-&gt;终端”，应用程序可能是中文，不过反正就是第一个菜单。然后输入：</p>

<div class="wp_codebox"><table><tr id="p8770"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p87code70"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apt<span style="color: #000000; font-weight: bold;">/</span>sources.list <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apt<span style="color: #000000; font-weight: bold;">/</span>sources.list_backup
<span style="color: #c20cb9; font-weight: bold;">sudo</span> gedit <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apt<span style="color: #000000; font-weight: bold;">/</span>sources.list</pre></td></tr></table></div>

<p>前面的sudo大约表示能够用最大权限，似乎etc目录都要用最大权限才能修改的样子，至于gedit是使用Gnome的Ubuntu下才有的命令。接下来我跟大家说说我更新以后的sources.list吧：</p>

<div class="wp_codebox"><table><tr id="p8771"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
</pre></td><td class="code" id="p87code71"><pre class="text" style="font-family:monospace;">deb http://archive.ubuntu.org.cn/ubuntu-cn/ hardy main restricted universe multiverse
&nbsp;
# 这一套极快，每秒可以上MB级
deb http://ubuntu.cn99.com/ubuntu/ hardy main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-security main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-updates main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-security main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-backports main restricted universe multiverse
&nbsp;
deb http://mirror.rootguide.org/ubuntu/ hardy main restricted universe multiverse
deb-src http://mirror.rootguide.org/ubuntu/ hardy main restricted universe multiverse
deb http://mirror.rootguide.org/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://mirror.rootguide.org/ubuntu/ hardy-updates main restricted universe multiverse
deb http://mirror.rootguide.org/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://mirror.rootguide.org/ubuntu/ hardy-backports main restricted universe multiverse
deb http://mirror.rootguide.org/ubuntu/ hardy-security main restricted universe multiverse
deb-src http://mirror.rootguide.org/ubuntu/ hardy-security main restricted universe multiverse
deb http://mirror.rootguide.org/ubuntu/ hardy-proposed main multiverse restricted universe
deb-src http://mirror.rootguide.org/ubuntu/ hardy-proposed main restricted universe multiverse
&nbsp;
# 这是官方的源
deb http://archive.ubuntu.com/ubuntu/ hardy main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ hardy-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse</pre></td></tr></table></div>

<p>接着就在终端中运行</p>

<div class="wp_codebox"><table><tr id="p8772"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p87code72"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> update</pre></td></tr></table></div>

<p>一阵等待过后（等待的时候玩Ubuntu里面的数独，发觉还是有些难度的），然后打开“系统-&gt;系统设置-&gt;语言设置”里面，找到中文打上钩，确定以后就自动完成了中文语言包的下载，重新启动后就看到了全中文的界面！然后使用Firefox上网，可以用Ctrl+Space调出中文的输入法。个人觉得里面默认的拼音输入法不亚于搜狗哈~</p>
<p>接着就觉得看过去太小了，想把分辨率调高一些。在“系统-&gt;首选项”里面看到了屏幕分辨率，打开一看，竟然有我显示器推荐使用的1440&#215;900，当即就选了。然后用Ctrl+Alt+Enter让VMware进入全屏模式，就像真的用Ubuntu一样！</p>
<p>因为这次打开Ubuntu的主要目的是学习LAMP，于是就装起了相关的东西。一开始的时候不知道新立得就有LAMP-Server，还傻傻的装了好多东西：</p>

<div class="wp_codebox"><table><tr id="p8773"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p87code73"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> apache2 mysql-server
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> php5-common php5-gd php5-mysql libapache2-mod-php5
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> phpmyadmin</pre></td></tr></table></div>

<p>其实并没有上面这条命令这么顺利的，我是绕了不少弯路。开始的时候apache2装上去然后装php5，然后我很快找到了位于/var/www/的网站目录。接着就在里面放上了一个“Hello World!”的php：</p>

<div class="wp_codebox"><table><tr id="p8774"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p87code74"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hello World!&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>但是不能解析……结果后来知道，要重启一下apache2：</p>

<div class="wp_codebox"><table><tr id="p8775"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p87code75"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart</pre></td></tr></table></div>

<p>后来装完mysql后去下载了一个phpmyadmin解压到/var/www/目录里，结果不能访问，说是php没有加载mysql模块，我就囧了。后来把这个文件夹删了，然后用apt的phpmyadmin，在/etc/apache2/sites-available/文件夹里的default文件的虚拟服务器中添加了：</p>

<div class="wp_codebox"><table><tr id="p8776"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p87code76"><pre class="apache" style="font-family:monospace;">    <span style="color: #00007f;">Alias</span> /phpmyadmin/ <span style="color: #7f007f;">&quot;/usr/share/phpmyadmin/&quot;</span>
&nbsp;
        <span style="color: #00007f;">Options</span> <span style="color: #0000ff;">none</span>
        <span style="color: #00007f;">AllowOverride</span> Limit
        <span style="color: #00007f;">Order</span> <span style="color: #00007f;">Deny</span>,<span style="color: #00007f;">Allow</span>
        <span style="color: #00007f;">Deny</span> from <span style="color: #0000ff;">all</span>
        <span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span></pre></td></tr></table></div>

<p>终于是可以用了。</p>
<p>刚刚升级了一下VMware到6.0，貌似宿主机和虚拟机可以一起上网了。另外终于是把VMware Tools给装上去了。也不知道是怎么装的，莫名其妙就装好了，所以就不写了。</p>
<p>我能这么还算顺利的做完这些事情，很大程度要感谢前辈们的指导。今天配置的过程中参考了许多来自不同地方的资料，其中帮助最广泛和最大的要数<a href="http://wiki.ubuntu.org.cn/index.php?title=Qref/Hardy&amp;variant=zh-cn" target="_blank">快速配置教程</a>了，其中的精细的指导实在是好，让我这样愚笨的人都在短时间内完成了一些东西。</p>
<p>最后赞叹一下这些伟大的自由软件的精妙和强大，实在是一个值得深究的东西啊！</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/ubuntu-trip-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>创建个个人Wiki</title>
		<link>http://blog.upsuper.org/create-a-personal-wiki/</link>
		<comments>http://blog.upsuper.org/create-a-personal-wiki/#comments</comments>
		<pubDate>Sat, 03 May 2008 07:27:58 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[雕虫小技]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wiki]]></category>
		<category><![CDATA[插件]]></category>
		<category><![CDATA[高亮]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=85</guid>
		<description><![CDATA[其实是昨天晚上就传上去了，没时间说罢了。昨晚把Wiki的首页做好了，顺便修整了一下相关的URL Rewrite。另外还研究了一下双站公用的GeSHi代码高亮系统。
我的Wordpress安装了一个WP-Codebox插件使用了GeSHi，而我用的Wiki系统——DokuWiki也有带GeSHi，又因为我对一些代码高亮有特别的要求，所以就把我上次改造过得GeSHi放到一个比较公共的目录里面，然后让两个全部指过去。

在WP-Codebox中只要修改wp-codebox.php：

28
include_once&#40;ABSPATH.&#34;./../include/geshi/geshi.php&#34;&#41;; #include_once(&#34;geshi/geshi.php&#34;);

而DokuWiki里面则要修改3处，都在inc/parserutils.php里：

642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
  if &#40;@file_exists&#40;$cache&#41; &#38;&#38; !$_REQUEST&#91;'purge'&#93; &#38;&#38;
     &#40;filemtime&#40;$cache&#41; &#62; filemtime&#40;DOKU_INC . './../include/geshi/geshi.php'&#41;&#41;&#41; &#123;
&#160;
    $highlighted_code = io_readFile&#40;$cache, false&#41;;
    @touch&#40;$cache&#41;;
&#160;
  &#125; else &#123;
&#160;
    require_once&#40;DOKU_INC . './../include/geshi/geshi.php'&#41;;
&#160;
    $geshi = new GeSHi&#40;$code, strtolower&#40;$language&#41;, DOKU_INC . './../include/geshi/geshi.php'&#41;;
    $geshi-&#62;set_encoding&#40;'utf-8'&#41;;
 [...]]]></description>
			<content:encoded><![CDATA[<p>其实是昨天晚上就传上去了，没时间说罢了。昨晚把Wiki的<a href="http://wiki.upsuper.org/首页">首页</a>做好了，顺便修整了一下相关的URL Rewrite。另外还研究了一下双站公用的GeSHi代码高亮系统。</p>
<p>我的Wordpress安装了一个WP-Codebox插件使用了GeSHi，而我用的Wiki系统——DokuWiki也有带GeSHi，又因为我对一些代码高亮有特别的要求，所以就把我上次改造过得GeSHi放到一个比较公共的目录里面，然后让两个全部指过去。<br />
<span id="more-85"></span><br />
在WP-Codebox中只要修改wp-codebox.php：</p>

<div class="wp_codebox"><table><tr id="p8579"><td class="line_numbers"><pre>28
</pre></td><td class="code" id="p85code79"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span>ABSPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;./../include/geshi/geshi.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#include_once(&quot;geshi/geshi.php&quot;);</span></pre></td></tr></table></div>

<p>而DokuWiki里面则要修改3处，都在inc/parserutils.php里：</p>

<div class="wp_codebox"><table><tr id="p8580"><td class="line_numbers"><pre>642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
</pre></td><td class="code" id="p85code80"><pre class="php" style="font-family:monospace;">  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">@</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'purge'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;&amp;</span>
     <span style="color: #009900;">&#40;</span><span style="color: #990000;">filemtime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #990000;">filemtime</span><span style="color: #009900;">&#40;</span>DOKU_INC <span style="color: #339933;">.</span> <span style="color: #0000ff;">'./../include/geshi/geshi.php'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000088;">$highlighted_code</span> <span style="color: #339933;">=</span> io_readFile<span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</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: #339933;">@</span><span style="color: #990000;">touch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span>DOKU_INC <span style="color: #339933;">.</span> <span style="color: #0000ff;">'./../include/geshi/geshi.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$geshi</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GeSHi<span style="color: #009900;">&#40;</span><span style="color: #000088;">$code</span><span style="color: #339933;">,</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$language</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> DOKU_INC <span style="color: #339933;">.</span> <span style="color: #0000ff;">'./../include/geshi/geshi.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$geshi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_encoding</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'utf-8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$geshi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enable_classes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$geshi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_header_type</span><span style="color: #009900;">&#40;</span>GESHI_HEADER_PRE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$geshi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_link_target</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$conf</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'target'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'extern'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>于是就把两个归拢了，这样以后只要改一个GeSHi就可以了。改天把GeSHi加一点功能，支持一下VS2005.NET对于C#的高亮语法，呵呵~</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/create-a-personal-wiki/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>通过了w3c认证</title>
		<link>http://blog.upsuper.org/certification-by-the-w3c/</link>
		<comments>http://blog.upsuper.org/certification-by-the-w3c/#comments</comments>
		<pubDate>Fri, 02 May 2008 13:21:30 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[雕虫小技]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[My Blog]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[w3c]]></category>
		<category><![CDATA[插件]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=84</guid>
		<description><![CDATA[今天给我的博客做了w3c认证。记得上次连Firefox里那个Web Developement的CSS测试都过不了，查一下，发现是wp-codebox插件里的一个用于IE Fix的代码Firefox不能正常识别，于是就在主CSS文件中去掉了这段，另建了一个叫ie-fix.css的文件，里面写上那个代码，再在wp-codebox的代码输出CSS引用的地方加上&#60;!&#8211;[if IE]&#62;&#8230;&#60;![endif]&#8211;&#62;，就通过了。
今天在w3c那边测，CSS是一次通过，不过有一些颜色使用上的警告，说有些颜色和背景色一致什么的……不过XHTML的测试就没那么好了，貌似错了8个地方，查一下发现又是wp-codebox！

如果用wp-codebox的朋友，想要过w3c测试，就要改两个地方，都在其main.php文件中（下面两个都是修改后的）：

135
	$output .=&#34;id=\&#34;l{$post-&#62;ID}{$codeid}\&#34;&#62;&#34;;


142
  $output .= &#34;&#60;td class=\&#34;code\&#34; id=\&#34;code{$post-&#62;ID}{$codeid}\&#34;&#62;&#34;;

现在反正是通过了，通过的标志就在侧栏的Support里面。还是蛮开心的~
]]></description>
			<content:encoded><![CDATA[<p>今天给我的博客做了w3c认证。记得上次连Firefox里那个Web Developement的CSS测试都过不了，查一下，发现是wp-codebox插件里的一个用于IE Fix的代码Firefox不能正常识别，于是就在主CSS文件中去掉了这段，另建了一个叫ie-fix.css的文件，里面写上那个代码，再在wp-codebox的代码输出CSS引用的地方加上&lt;!&#8211;[if IE]&gt;&#8230;&lt;![endif]&#8211;&gt;，就通过了。</p>
<p>今天在w3c那边测，CSS是一次通过，不过有一些颜色使用上的警告，说有些颜色和背景色一致什么的……不过XHTML的测试就没那么好了，貌似错了8个地方，查一下发现又是wp-codebox！<br />
<span id="more-84"></span><br />
如果用wp-codebox的朋友，想要过w3c测试，就要改两个地方，都在其main.php文件中（下面两个都是修改后的）：</p>

<div class="wp_codebox"><table><tr id="p8483"><td class="line_numbers"><pre>135
</pre></td><td class="code" id="p84code83"><pre class="php" style="font-family:monospace;">	<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot;id=<span style="color: #000099; font-weight: bold;">\&quot;</span>l<span style="color: #006699; font-weight: bold;">{$post-&gt;ID}</span><span style="color: #006699; font-weight: bold;">{$codeid}</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<div class="wp_codebox"><table><tr id="p8484"><td class="line_numbers"><pre>142
</pre></td><td class="code" id="p84code84"><pre class="php" style="font-family:monospace;">  <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;td class=<span style="color: #000099; font-weight: bold;">\&quot;</span>code<span style="color: #000099; font-weight: bold;">\&quot;</span> id=<span style="color: #000099; font-weight: bold;">\&quot;</span>code<span style="color: #006699; font-weight: bold;">{$post-&gt;ID}</span><span style="color: #006699; font-weight: bold;">{$codeid}</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>现在反正是通过了，通过的标志就在侧栏的Support里面。还是蛮开心的~</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/certification-by-the-w3c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>下载PHP文件</title>
		<link>http://blog.upsuper.org/download-php-file/</link>
		<comments>http://blog.upsuper.org/download-php-file/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 12:40:00 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[雕虫小技]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=33</guid>
		<description><![CDATA[今天把一个PHP文件放到下载目录去，但是会自动解析。于是就查了各种资料如何阻止Apache解析指定目录的PHP，但是查到的几种方法都不行，似乎是因为服务器的原因？httpd.conf的权限自然不是在我的。
我就换了一种想法，用URL Rewrite试试？把php文件改名后编写了一个.htaccess，把所有.php的文件rewrite到.php_file上去，终于成功实现了！

那个.htaccess代码：

1
2
3
RewriteEngine	on
RewriteBase	/
RewriteRule	^(.*)\.php$	$1\.php_file

另外，也把找到的其他方法给大家参考，都是通过编写.htaccess文件：
第一种是通过重定义php的MIMI-TYPE：

1
AddType text/html .php

第二种是通过关闭PHP引擎，这是PHP手册上所写的方法：

1
php_flag engine off

还有一种是直接禁止对一切PHP的访问：

1
2
3
4
&#60;Files  ~  &#34;.php&#34;&#62;
	Order allow, deny
	Deny from all
&#60;/Files&#62;

]]></description>
			<content:encoded><![CDATA[<p>今天把一个PHP文件放到下载目录去，但是会自动解析。于是就查了各种资料如何阻止Apache解析指定目录的PHP，但是查到的几种方法都不行，似乎是因为服务器的原因？httpd.conf的权限自然不是在我的。</p>
<p>我就换了一种想法，用URL Rewrite试试？把php文件改名后编写了一个.htaccess，把所有.php的文件rewrite到.php_file上去，终于成功实现了！<br />
<span id="more-33"></span><br />
那个.htaccess代码：</p>

<div class="wp_codebox"><table><tr id="p3389"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p33code89"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteEngine</span>	<span style="color: #0000ff;">on</span>
<span style="color: #00007f;">RewriteBase</span>	/
<span style="color: #00007f;">RewriteRule</span>	^(.*)\.php$	$<span style="color: #ff0000;">1</span>\.php_file</pre></td></tr></table></div>

<p>另外，也把找到的其他方法给大家参考，都是通过编写.htaccess文件：</p>
<p>第一种是通过重定义php的MIMI-TYPE：</p>

<div class="wp_codebox"><table><tr id="p3390"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p33code90"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">AddType</span> text/html .php</pre></td></tr></table></div>

<p>第二种是通过关闭PHP引擎，这是PHP手册上所写的方法：</p>

<div class="wp_codebox"><table><tr id="p3391"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p33code91"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">php_flag</span> engine <span style="color: #0000ff;">off</span></pre></td></tr></table></div>

<p>还有一种是直接禁止对一切PHP的访问：</p>

<div class="wp_codebox"><table><tr id="p3392"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p33code92"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">Files</span>  ~  <span style="color: #7f007f;">&quot;.php&quot;</span>&gt;
	<span style="color: #00007f;">Order</span> <span style="color: #00007f;">allow</span>, <span style="color: #00007f;">deny</span>
	<span style="color: #00007f;">Deny</span> from <span style="color: #0000ff;">all</span>
&lt;/<span style="color: #000000; font-weight:bold;">Files</span>&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/download-php-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>终于把宠物中心装好了</title>
		<link>http://blog.upsuper.org/installed-pet-cente/</link>
		<comments>http://blog.upsuper.org/installed-pet-cente/#comments</comments>
		<pubDate>Thu, 31 Jan 2008 11:37:35 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[雕虫小技]]></category>
		<category><![CDATA[Discuz!]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[插件]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=9</guid>
		<description><![CDATA[在大家的强烈支持下，我把DZ论坛的无心宠物中心插件装好了。
为了装这个宠物中心，我把include/db_mysql.class.php都改了，如果大家在安装后发现宠物中心不能启动，并且提示找不到query_first，那么查找

1
2
3
function affected_rows&#40;&#41; &#123;
	return mysql_affected_rows&#40;$this-&#62;link&#41;;
&#125;

前面加上：

1
2
3
function query_first&#40;$sql&#41; &#123;
	return $this-&#62;fetch_array&#40;$this-&#62;query&#40;$sql&#41;&#41;;
&#125;

我曾经试图修改插件的文件，结果发现，这个插件用这个文件用得太多了，干脆改论坛的核心文件了。
]]></description>
			<content:encoded><![CDATA[<p>在大家的强烈支持下，我把DZ论坛的无心宠物中心插件装好了。</p>
<p>为了装这个宠物中心，我把<em>include/db_mysql.class.php</em>都改了，如果大家在安装后发现宠物中心不能启动，并且提示找不到<em>query_first</em>，那么查找</p>

<div class="wp_codebox"><table><tr id="p995"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p9code95"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> affected_rows<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">mysql_affected_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">link</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>前面加上：</p>

<div class="wp_codebox"><table><tr id="p996"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p9code96"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> query_first<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>我曾经试图修改插件的文件，结果发现，这个插件用这个文件用得太多了，干脆改论坛的核心文件了。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/installed-pet-cente/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>我们的Online Judge</title>
		<link>http://blog.upsuper.org/our-online-judge/</link>
		<comments>http://blog.upsuper.org/our-online-judge/#comments</comments>
		<pubDate>Sat, 13 Oct 2007 11:33:28 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[我的计划]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[C/C++/C#]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Online Judge]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=27</guid>
		<description><![CDATA[和 MRain 开始编写我们信息组内部用的Online Judge。
这个Online Judge我准备做成类似Cena的网页版，准备使用PHP+MySQL+Apache+Windows2K3作为运行环境，AJAX做界面，C++程序做后台测评程序。采取类似USACO的提交立即测评，在线等待结果的测评方式。
现在我正在撰写文档，估计正式编写工作从下一周开始。
]]></description>
			<content:encoded><![CDATA[<p>和 MRain 开始编写我们信息组内部用的Online Judge。</p>
<p>这个Online Judge我准备做成类似Cena的网页版，准备使用PHP+MySQL+Apache+Windows2K3作为运行环境，AJAX做界面，C++程序做后台测评程序。采取类似USACO的提交立即测评，在线等待结果的测评方式。</p>
<p>现在我正在撰写文档，估计正式编写工作从下一周开始。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/our-online-judge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>终于把MediaWiki的公式显示弄好了</title>
		<link>http://blog.upsuper.org/finally-complete-mediawiki-math/</link>
		<comments>http://blog.upsuper.org/finally-complete-mediawiki-math/#comments</comments>
		<pubDate>Sat, 13 Oct 2007 10:45:31 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[雕虫小技]]></category>
		<category><![CDATA[MediaWiki]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=28</guid>
		<description><![CDATA[昨天总算成功的把MediaWiki的数学公式支持弄好了。这里我大概说一下做法把：
首先MediaWiki要安好（废话），然后我们要下载LaTeX，这里推荐下载CTex套装，里面包含了需要用到的3个软件——MikTex、Ghostscript和GSview，如果你仅仅是为了MediaWiki的数学公式支持的话，那么只要选这3个就可以了。
接下来要到这里去下载ImageMagick。那里有很多个版本，如果不确定要哪个的话，我选择了上面那段描述文字的最后一个链接。
安好上面两样东西后，需要编译texvc，我懒得去编译了，直接下了一个编译好的，可能旧了一点，不过能用就行，你可以点击这里下载，将其里面的texvc.exe解压到MediaWiki的目录下。
最后开始配置，首先从到MediaWiki的网站上下载Math.php并替换include/Math.php。如果不能访问MediaWiki的网站，可以点击这里下载：Math.php (15.7KB)
接下来在LocalSettings.php下插入

1
2
3
4
5
6
#ImageMagick
$wgImageMagickConvertCommand = ''D:\\wikitex\\imagick\\convert.exe'';
$wgImageMagickIdentifyCommand = ''D:\\wikitex\\imagick\\identify.exe'';
#Tex
$wgLaTexCommand = ''D:\\wikitex\\miktex\\miktex\\bin\\latex.exe'';
$wgDvipsCommand = ''D:\\wikitex\\miktex\\miktex\\bin\\dvips.exe'';

以上各个路径需根据自己安装的情况进行更改，Tex下面两项的路径到CTex的安装目录寻找（有个技巧，就是在他们的安装目录里搜索这些文件名）。接下来将LocalSettings.php里的$wgUseTeX设为true。
下面找一个页面输入&#60;math&#62;\sqrt{2}&#60;/math&#62;效果怎么样？
]]></description>
			<content:encoded><![CDATA[<p>昨天总算成功的把MediaWiki的数学公式支持弄好了。这里我大概说一下做法把：</p>
<p>首先MediaWiki要安好（废话），然后我们要下载LaTeX，这里推荐下载<a href="http://www.ctex.org/" target="_blank">CTex套装</a>，里面包含了需要用到的3个软件——MikTex、Ghostscript和GSview，如果你仅仅是为了MediaWiki的数学公式支持的话，那么只要选这3个就可以了。</p>
<p>接下来要到<a href="http://www.imagemagick.org/script/binary-releases.php#windows" target="_blank">这里</a>去下载ImageMagick。那里有很多个版本，如果不确定要哪个的话，我选择了上面那段描述文字的最后一个链接。</p>
<p>安好上面两样东西后，需要编译texvc，我懒得去编译了，直接下了一个编译好的，可能旧了一点，不过能用就行，你可以点击<a href="http://www.karottenreibe.de/math.rar" target="_blank">这里</a>下载，将其里面的texvc.exe解压到MediaWiki的目录下。</p>
<p>最后开始配置，首先从到MediaWiki的网站上下载<a href="http://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Windows/math.php" target="_blank">Math.php</a>并替换include/Math.php。如果不能访问MediaWiki的网站，可以点击这里下载：<a href="http://down.upsuper.org/Math.php">Math.php</a> (15.7KB)</p>
<p>接下来在LocalSettings.php下插入</p>

<div class="wp_codebox"><table><tr id="p2898"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p28code98"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#ImageMagick
</span><span style="color: #000088;">$wgImageMagickConvertCommand</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span>D<span style="color: #339933;">:</span>\\wikitex\\imagick\\convert<span style="color: #339933;">.</span>exe<span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wgImageMagickIdentifyCommand</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span>D<span style="color: #339933;">:</span>\\wikitex\\imagick\\identify<span style="color: #339933;">.</span>exe<span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">#Tex
</span><span style="color: #000088;">$wgLaTexCommand</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span>D<span style="color: #339933;">:</span>\\wikitex\\miktex\\miktex\\bin\\latex<span style="color: #339933;">.</span>exe<span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wgDvipsCommand</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span>D<span style="color: #339933;">:</span>\\wikitex\\miktex\\miktex\\bin\\dvips<span style="color: #339933;">.</span>exe<span style="color: #0000ff;">''</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>以上各个路径需根据自己安装的情况进行更改，Tex下面两项的路径到CTex的安装目录寻找（有个技巧，就是在他们的安装目录里搜索这些文件名）。接下来将LocalSettings.php里的$wgUseTeX设为true。</p>
<p>下面找一个页面输入<u>&lt;math&gt;\sqrt{2}&lt;/math&gt;</u>效果怎么样？</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/finally-complete-mediawiki-math/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
