<?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>raptium&#039;s &#187; php</title>
	<atom:link href="http://archive.raptium.net/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://archive.raptium.net</link>
	<description>raptium&#039;s another weblog</description>
	<lastBuildDate>Fri, 15 Jul 2011 07:51:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<atom:link rel='hub' href='http://archive.raptium.net/?pushpress=hub'/>
		<item>
		<title>nginx php 错误配置导致安全漏洞</title>
		<link>http://archive.raptium.net/2011/04/17/check-your-nginx-php-configuration/</link>
		<comments>http://archive.raptium.net/2011/04/17/check-your-nginx-php-configuration/#comments</comments>
		<pubDate>Sun, 17 Apr 2011 15:42:36 +0000</pubDate>
		<dc:creator>raptium</dc:creator>
				<category><![CDATA[瞎折腾]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.raptium.net/?p=509</guid>
		<description><![CDATA[后知后觉发现了此文 Setting up PHP-FastCGI and nginx? Don’t trust the tutorials: check your configuration! 基本上是说，网上的大部分 nginx + php 配置教程中有一个错误，导致 php 会试图执行非 php 文件，甚至是用户上传的图片。 事实上看到此漏洞的描述我已经立刻想到问题之所在了，的确，之前我写的那篇配置笔记也是有此问题的。基本原理就是 nginx 配置中有这么一段 location ~ .*.php5?$ { include fastcgi_params; root /var/host/phpMyAdmin; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass unix:/var/run/php_fcgi.sock; fastcgi_index index.php; } 凡是以 .php 或者 .php5 结尾的 uri 都会被交给 php 处理，于是类似于 user.jpg/aaa.php 也会交给 php 处理，于是 user.jpg [...]]]></description>
			<content:encoded><![CDATA[<p>后知后觉发现了此文 <a href="https://nealpoole.com/blog/2011/04/setting-up-php-fastcgi-and-nginx-dont-trust-the-tutorials-check-your-configuration/">Setting up PHP-FastCGI and nginx? Don’t trust the tutorials: check your configuration!</a> 基本上是说，网上的大部分 nginx + php 配置教程中有一个错误，导致 php 会试图执行非 php 文件，甚至是用户上传的图片。</p>
<p>事实上看到此漏洞的描述我已经立刻想到问题之所在了，的确，之前我写的那篇<a href="/2009/05/01/centos-nginx-php-config-howto/">配置笔记</a>也是有此问题的。基本原理就是 nginx 配置中有这么一段</p>
<pre>location ~ .*.php5?$ {
        include fastcgi_params;
        root /var/host/phpMyAdmin;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/var/run/php_fcgi.sock;
        fastcgi_index index.php;
    }</pre>
<p>凡是以 .php 或者 .php5 结尾的 uri 都会被交给 php 处理，于是类似于 user.jpg/aaa.php 也会交给 php 处理，于是 user.jpg 就被当成 php 代码给执行了。</p>
<p>解决此问题的方法有好几种，codex.wordpress.com 上面提供的一种方式是如下修改 nginx 中有关 php 的配置。不过如果 nginx 和 php 不运行在同一台机器上时，此方法无效。</p>
<pre>location ~ \.php$ {
	# Zero-day exploit defense.
	# http://forum.nginx.org/read.php?2,88845,page=3
	# Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
	# Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine.  And then cross your fingers that you won't get hacked.
	try_files $uri =404;

	fastcgi_split_path_info ^(.+\.php)(/.+)$;
	include fastcgi_params;
	fastcgi_index index.php;
	fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#	fastcgi_intercept_errors on;
	fastcgi_pass php;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://archive.raptium.net/2011/04/17/check-your-nginx-php-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[配置笔记]CentOS + nginx + PHP</title>
		<link>http://archive.raptium.net/2009/05/01/centos-nginx-php-config-howto/</link>
		<comments>http://archive.raptium.net/2009/05/01/centos-nginx-php-config-howto/#comments</comments>
		<pubDate>Fri, 01 May 2009 17:51:07 +0000</pubDate>
		<dc:creator>raptium</dc:creator>
				<category><![CDATA[瞎折腾]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.raptium.net/?p=345</guid>
		<description><![CDATA[之前的这篇文章似乎是挖了个坑一直没填，然而每每出现这种情况的时候，都会发现还偏偏总有人通过 Google 搜索过来……一定让不少人失望了，真是过意不去～于是这次重新写一篇，但愿能把坑填上…… 和上次略有不同，这次 Linux 发行版是用的 CentOS，因为最近一段时间来其实我接触最多的还是 RHEL，所以就不写 Ubuntu 了。MySQL 也不在本文叙述范围之内，我实际应用的时候是直接 yum install mysql-server 装的，没有什么好说的。 nginx 用了 0.7.x 开发版。php 当然是通过 fastcgi 运行，不过没有用从 lighttpd 里分离出来的 spawn-fcgi，而是用了 php-fpm 这个补丁。 编译安装 nginx 用 yum 安装依赖包 yum install gcc openssl-devel pcre-devel zlib-devel 下载最新版的 nginx，并解压缩。 cd /usr/local/src wget http://sysoev.ru/nginx/nginx-0.7.53.tar.gz tar zxvf nginx-0.7.53.tar.gz rm -rf nginx-0.7.53.tar.gz 编译选项，取自 nginx wiki，这个配置适合 RHEL/CentOS，已经带了几个常用的模块。 cd [...]]]></description>
			<content:encoded><![CDATA[<p><em>之前的<a href="/2008/11/27/ubuntu-nginx-mysql-php-config/">这篇文章</a>似乎是挖了个坑一直没填，然而每每出现这种情况的时候，都会发现还偏偏总有人通过 Google 搜索过来……一定让不少人失望了，真是过意不去～于是这次重新写一篇，但愿能把坑填上……</em></p>
<p>和上次略有不同，这次 Linux 发行版是用的 CentOS，因为最近一段时间来其实我接触最多的还是 RHEL，所以就不写 Ubuntu 了。MySQL 也不在本文叙述范围之内，我实际应用的时候是直接 yum install mysql-server 装的，没有什么好说的。</p>
<p>nginx 用了 0.7.x 开发版。php 当然是通过 fastcgi 运行，不过没有用从 lighttpd 里分离出来的 spawn-fcgi，而是用了 php-fpm 这个补丁。<br />
<span id="more-345"></span><br />
<strong>编译安装 nginx</strong></p>
<p>用 yum 安装依赖包</p>
<pre>yum install gcc openssl-devel pcre-devel zlib-devel</pre>
<p>下载最新版的 nginx，并解压缩。</p>
<pre>cd /usr/local/src
wget http://sysoev.ru/nginx/nginx-0.7.53.tar.gz
tar zxvf nginx-0.7.53.tar.gz
rm -rf nginx-0.7.53.tar.gz</pre>
<p>编译选项，取自 <a href="http://wiki.nginx.org/NginxInstallOptions">nginx wiki</a>，这个配置适合 RHEL/CentOS，已经带了几个常用的模块。</p>
<pre>cd /usr/local/src/nginx-0.7.53
./configure
  --prefix=/usr
  --sbin-path=/usr/sbin/nginx
  --conf-path=/etc/nginx/nginx.conf
  --error-log-path=/var/log/nginx/error.log
  --pid-path=/var/run/nginx/nginx.pid
  --lock-path=/var/lock/nginx.lock
  --user=nginx
  --group=nginx
  --with-http_ssl_module
  --with-http_flv_module
  --with-http_gzip_static_module
  --http-log-path=/var/log/nginx/access.log
  --http-client-body-temp-path=/var/tmp/nginx/client/
  --http-proxy-temp-path=/var/tmp/nginx/proxy/
  --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/
make
make install</pre>
<p>由于编译时指定了默认用户和组都为 nginx，所以还要创建一下。</p>
<pre>groupadd nginx
useradd -d /home/nginx -g nginx nginx</pre>
<p><strong>编译安装 PHP</strong></p>
<p>php-fpm 只有针对 PHP 5.2.8 的补丁，尚不支持最新的 5.2.9，所以只能下载较旧的版本了。</p>
<pre>cd /usr/local/src
wget http://hk.php.net/distributions/php-5.2.8.tar.bz2
tar jxvf php-5.2.8.tar.bz2
rm -f php-5.2.8.tar.bz2</pre>
<p>下载 php-fpm 补丁</p>
<pre>cd /usr/local/src
wget http://php-fpm.anight.org/downloads/head/php-5.2.8-fpm-0.5.10.diff.gz
gzip -cd php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.2.8 -p1
</pre>
<p>配置安装 php</p>
<pre>cd /usr/local/src/php-5.2.8
./configure
  --enable-fastcgi
  --enable-fpm
  --with-mysql
  --with-mcrypt
  --with-zlib
make
make install</pre>
<p>这个参数至少可以运行 wordpress，如果要其他更加复杂的 php 应用，可能需要加入其他 extension。<br />
如果缺少依赖的话，试试这些</p>
<pre>yum install mysql-devel libmcrypt-devel zlib-devel libxml2-devel libtool-ltdl-devel</pre>
<p><strong>nginx 和 php-fpm 的设置</strong><br />
nginx 的配置文件位于 /ect/nginx/nginx.conf<br />
最好在 http {} 的 最后加入 include vhosts/*.conf;<br />
以后其他 virtual host 可以写在 vhosts 下面<br />
比如 一个 PHPMyAdmin 的配置可以这么写</p>
<pre>server {
    listen 80;
    server_name sql.example.net;

    location / {
        index index.php;
        root /var/host/phpMyAdmin;
    }

    location ~ .*.php5?$ {
        include fastcgi_params;
        root /var/host/phpMyAdmin;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/var/run/php_fcgi.sock;
        fastcgi_index index.php;
    }
}</pre>
<p>其中 unix:/var/run/php_fcgi.sock 要和 php-fpm 的配置相对应，php-fpm 的默认配置（/usr/local/etc/php-fpm.conf）也基本上够用了。要修改的大概只有这一段</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;listen_address&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>/var/run/php_fcgi.sock<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;listen_options&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;backlog&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>-1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;owner&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>nginx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;group&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>nginx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;mode&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>0666<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://archive.raptium.net/2009/05/01/centos-nginx-php-config-howto/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[配置笔记]Ubuntu + nginx + MySQL + PHP</title>
		<link>http://archive.raptium.net/2008/11/27/ubuntu-nginx-mysql-php-config/</link>
		<comments>http://archive.raptium.net/2008/11/27/ubuntu-nginx-mysql-php-config/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 16:49:08 +0000</pubDate>
		<dc:creator>raptium</dc:creator>
				<category><![CDATA[瞎折腾]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web Application Development]]></category>

		<guid isPermaLink="false">http://www.raptium.cn/?p=210</guid>
		<description><![CDATA[本来想写个How-To的，但是突然觉得自己没有功力教会别人，所以就不做标题党了。配置笔记，基本上是记录给自己看得，能够给别人有所帮助就更好了～ 最近不断的看到有关 nginx 的消息，基本上都是正面的，看起来性能非常好。对于性能好的东西，我通常有一种莫名的恐惧，因为这些高级货一是要用到好的硬件上，二是配置复杂，如果还有三的话，那就是我通常不需要这么高的性能。然而这次稍稍看多了些 nginx 的介绍，其实它还是轻量级的，出道也不久，却能够被不少网站重用。俄罗斯人写的程序，作者自称英文较差，不过文档却也有了多国语言版，看来这东西真是受世界各国人民的喜爱啊～ 晚上不想玩WoW，就装了个虚拟机，搞了 nginx 玩玩，记录如下。 配置表 OS: Ubuntu Linux 8.10 Server Web Server: nginx 0.6.33 Database Server: MySQL （apt源里的版本） PHP: php-cgi （apt源里的版本） 装系统，不用多说。我是装在虚拟机里的，刚开始用的VirtualBox，不过装好后出现了问题。因为Ubuntu Server的默认内核把PAE编译进去了，但是VirtualBox并不支持虚拟CPU的PAE功能，于是装好后不能启动。网上有关解决方案是修复模式下装其他内核，我发现这样又遇到更多问题……于是放弃。改用VMWare，一切安好。 Ubuntu基本上就用默认安装了，在选要什么Package的时候，除了OpenSSH Server，其他可以都不用选。真要选LAMP也行，不过到时候还是要把Apache给关掉～ 系统装好后，老习惯 sudo apt-get update sudo apt-get upgrade Ubuntu 8.10 发布没多久，不需要下多少更新，几分钟搞定。 然后准备下载编译 nginx ，不过在此之前我们要把编译环境设好。 sudo apt-get install build-essential libpcre3-dev libssl-dev 最短命令就这样了，会自动加上一堆dependency的，都按y就行了。 之后是下载编译，nginx 似乎已经出到 0.7.x 了，不过这是第一次弄，我还是选择了stable的 0.6.33 [...]]]></description>
			<content:encoded><![CDATA[<p><em>本来想写个How-To的，但是突然觉得自己没有功力教会别人，所以就不做标题党了。配置笔记，基本上是记录给自己看得，能够给别人有所帮助就更好了～</em></p>
<p>最近不断的看到有关 nginx 的消息，基本上都是正面的，看起来性能非常好。对于性能好的东西，我通常有一种莫名的恐惧，因为这些高级货一是要用到好的硬件上，二是配置复杂，如果还有三的话，那就是我通常不需要这么高的性能。然而这次稍稍看多了些 nginx 的介绍，其实它还是轻量级的，出道也不久，却能够被不少网站重用。俄罗斯人写的程序，作者自称英文较差，不过文档却也有了多国语言版，看来这东西真是受世界各国人民的喜爱啊～</p>
<p>晚上不想玩WoW，就装了个虚拟机，搞了 nginx 玩玩，记录如下。<span id="more-210"></span></p>
<p>配置表</p>
<ul>
<li>OS: Ubuntu Linux 8.10 Server</li>
<li>Web Server: nginx 0.6.33</li>
<li>Database Server: MySQL （apt源里的版本）</li>
<li>PHP: php-cgi （apt源里的版本）</li>
</ul>
<p>装系统，不用多说。我是装在虚拟机里的，刚开始用的VirtualBox，不过装好后出现了问题。因为Ubuntu Server的默认内核把PAE编译进去了，但是VirtualBox并不支持虚拟CPU的PAE功能，于是装好后不能启动。网上有关解决方案是修复模式下装其他内核，我发现这样又遇到更多问题……于是放弃。改用VMWare，一切安好。</p>
<p>Ubuntu基本上就用默认安装了，在选要什么Package的时候，除了OpenSSH Server，其他可以都不用选。真要选LAMP也行，不过到时候还是要把Apache给关掉～</p>
<p>系统装好后，老习惯</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo apt-get update
sudo apt-get upgrade</pre></div></div>

<p>Ubuntu 8.10 发布没多久，不需要下多少更新，几分钟搞定。<br />
然后准备下载编译 nginx ，不过在此之前我们要把编译环境设好。</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo apt-get install build-essential libpcre3-dev libssl-dev</pre></div></div>

<p>最短命令就这样了，会自动加上一堆dependency的，都按y就行了。</p>
<p>之后是下载编译，nginx 似乎已经出到 0.7.x 了，不过这是第一次弄，我还是选择了stable的 0.6.33</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">wget http://sysoev.ru/nginx/nginx-0.6.33.tar.gz
tar zxvf nginx-0.6.33.tar.gz
cd nginx-0.6.33
./configure --sbin-path=/usr/local/sbin --with-http_ssl_module
make
sudo make install</pre></div></div>

<p>至此 nginx 安装完毕。如果现在运行 nginx 的话，应该可以看到简陋的欢迎页面了，不过先不急，搞定别的先～</p>
<p>安装 PHP，</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo apt-get install php5-cgi</pre></div></div>

<p>因为在 nginx 上 PHP 必须以 FastCGI 的方式运行，所以就直接装这个包了。但是 nginx 有没有自己运行 CGI 的机制，所以还需要用到 spawn-fcgi 这个小程序。这是 lighttpd 里面带的，不过为了它我们并不需要装整个 lighttpd，自己编译一个 lighttpd 然后取出这个程序单独用就好了～</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">wget http://www.lighttpd.net/download/lighttpd-1.4.20.tar.gz
tar zxvf lighttpd-1.4.20
./configure
make
sudo cp src/spawn-fcgi /usr/local/bin/spawn-fcgi</pre></div></div>

<p><span style="text-decoration: line-through;">[明天继续update...]</span></p>
<p>我在公司的另一项任务中也用到了 nginx， 或许之后会另写文章记录配置过程。</p>
<p><strong>Reference</strong></p>
<ul>
<li><a href="http://articles.slicehost.com/2007/12/3/ubuntu-gutsy-installing-nginx-from-source">Ubuntu Gutsy &#8211; Installing Nginx from source</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://archive.raptium.net/2008/11/27/ubuntu-nginx-mysql-php-config/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>fanfou=好好学习，天天校内</title>
		<link>http://archive.raptium.net/2007/07/14/fanfou%e5%a5%bd%e5%a5%bd%e5%ad%a6%e4%b9%a0%ef%bc%8c%e5%a4%a9%e5%a4%a9%e6%a0%a1%e5%86%85/</link>
		<comments>http://archive.raptium.net/2007/07/14/fanfou%e5%a5%bd%e5%a5%bd%e5%ad%a6%e4%b9%a0%ef%bc%8c%e5%a4%a9%e5%a4%a9%e6%a0%a1%e5%86%85/#comments</comments>
		<pubDate>Fri, 13 Jul 2007 21:59:20 +0000</pubDate>
		<dc:creator>raptium</dc:creator>
				<category><![CDATA[瞎折腾]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[校内]]></category>
		<category><![CDATA[饭否]]></category>

		<guid isPermaLink="false">http://www.raptium.cn/2007/07/14/fanfou%e5%a5%bd%e5%a5%bd%e5%ad%a6%e4%b9%a0%ef%bc%8c%e5%a4%a9%e5%a4%a9%e6%a0%a1%e5%86%85/</guid>
		<description><![CDATA[今天ice告诉我说，校内把饭否屏蔽了，当时就想不可能。首先，我用的饭否图片插件，css中background贴上去的，总不可能屏蔽图片吧，那其他的图片也没了？再说，校内和饭否不存在什么竞争关系，人家千橡大公司不至于这么小家子气，还屏蔽饭否…… 再一细问，原来……涂鸦板里的fanfou自动替换成了好好学习，天天校内…… 真是哭笑不得，校内果然和猫扑是一家的，千橡就是牛逼，还玩这一套。我真想看哪天校内上冒出中国人民公共安全专家大学来。 然而这种拙劣的替换手段，基本上是可以无视的。好办法我是没有，不过笨办法倒是几秒种内就想了一个。然后写个程序实现，也不过是十多分钟。当然，笨办法就是笨，需要一个支持php和gd library的空间，而且……如果访问频繁，可能对服务器造成压力。先说一下原理，就是：通过某个不被屏蔽的服务器中转获取到饭否的图片。 具体实现方法 先读一下 把饭否添加到校内的简单方法 然后把原来的图片地址 比如 http://b.fanfou.com/u/raptium/multi.png 改成 http://personal.ie.cuhk.edu.hk/~hguan5/uofnaf.php?id=raptium&#38;format=multi id 后面跟你的饭否id format后面跟图片格式 比如multi或者single 当然也可以加上宽度参数 我邪恶的找了系里的服务器来放我的程序，如果谁自己有php空间的话，就可以把程序放在自己的空间上。 uofnaf.php代码是这样的 &#60;?php header&#40;'Content-type: image/png'&#41;; $fanfou = @imagecreatefrompng&#40;'http://b.fanfou.com/u/'.$_GET&#91;&#34;id&#34;&#93;.'/'.$_GET&#91;&#34;format&#34;&#93;.'.png'&#41;; if&#40;!$fanfou&#41;&#123; $fanfou = imagecreatetruecolor&#40;180, 30&#41;; $bgc = imagecolorallocate&#40;$fanfou, 255, 255, 255&#41;; $tc = imagecolorallocate&#40;$fanfou, 0, 0, 0&#41;; imagefilledrectangle&#40;$fanfou, 0, 0, 180, 30, $bgc&#41;; imagestring&#40;$fanfou, 3, 5, 5, &#34;Image Loading [...]]]></description>
			<content:encoded><![CDATA[<p>今天ice告诉我说，校内把饭否屏蔽了，当时就想不可能。首先，我用的饭否图片插件，css中background贴上去的，总不可能屏蔽图片吧，那其他的图片也没了？再说，校内和饭否不存在什么竞争关系，人家千橡大公司不至于这么小家子气，还屏蔽饭否……</p>
<p>再一细问，原来……涂鸦板里的<em>fanfou</em>自动替换成了<em>好好学习，天天校内</em>…… 真是哭笑不得，校内果然和猫扑是一家的，千橡就是牛逼，还玩这一套。我真想看哪天校内上冒出<a href="http://www.google.com/url?sa=t&amp;ct=res&amp;cd=1&amp;url=http://www.cppsu.edu.cn%2F&amp;ei=E3eXRuefIoucsAKDuonvCA&amp;usg=AFQjCNGhqmgoaU3WBM3A7cla_viPzgdMhg&amp;sig2=jmagjy7bIv3EHST01A4VKQ" title="中国人民公共安全专家大学" target="_blank">中国人民公共安全专家大学</a>来。</p>
<p>然而这种拙劣的替换手段，基本上是可以无视的。好办法我是没有，不过笨办法倒是几秒种内就想了一个。<span id="more-58"></span>然后写个程序实现，也不过是十多分钟。当然，笨办法就是笨，需要一个支持php和gd library的空间，而且……如果访问频繁，可能对服务器造成压力。先说一下原理，就是：通过某个不被屏蔽的服务器中转获取到饭否的图片。</p>
<p>具体实现方法 先读一下 <a href="http://www.raptium.cn/2007/06/22/%e6%8a%8a%e9%a5%ad%e5%90%a6%e6%b7%bb%e5%8a%a0%e5%88%b0%e6%a0%a1%e5%86%85%e7%9a%84%e7%ae%80%e5%8d%95%e6%96%b9%e6%b3%95/">把饭否添加到校内的简单方法</a> 然后把原来的图片地址 比如</p>
<pre>http://b.fanfou.com/u/raptium/multi.png</pre>
<p>改成</p>
<pre>http://personal.ie.cuhk.edu.hk/~hguan5/uofnaf.php?id=raptium&amp;format=multi</pre>
<p>id 后面跟你的饭否id format后面跟图片格式 比如multi或者single 当然也可以加上宽度参数<br />
我邪恶的找了系里的服务器来放我的程序，如果谁自己有php空间的话，就可以把程序放在自己的空间上。</p>
<p>uofnaf.php代码是这样的</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-type: image/png'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fanfou</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">imagecreatefrompng</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://b.fanfou.com/u/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;id&quot;</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: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;format&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.png'</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;">$fanfou</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$fanfou</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatetruecolor</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">180</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$bgc</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorallocate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fanfou</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$tc</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorallocate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fanfou</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><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;">imagefilledrectangle</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fanfou</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">180</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">30</span><span style="color: #339933;">,</span> <span style="color: #000088;">$bgc</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">imagestring</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fanfou</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Image Loading Error!&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tc</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #990000;">imagepng</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fanfou</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">imagedestroy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fanfou</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>最后 鄙视一下 校内 不多说了</p>
]]></content:encoded>
			<wfw:commentRss>http://archive.raptium.net/2007/07/14/fanfou%e5%a5%bd%e5%a5%bd%e5%ad%a6%e4%b9%a0%ef%bc%8c%e5%a4%a9%e5%a4%a9%e6%a0%a1%e5%86%85/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: archive.raptium.net @ 2012-02-05 22:01:41 by W3 Total Cache -->
