<?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>毛毛虫’s 博客</title>
	<atom:link href="http://www.wangchong.org/feed" rel="self" type="application/rss+xml" />
	<link>http://www.wangchong.org</link>
	<description>平凡的生活，默默的期待，等待蜕变的到来......</description>
	<lastBuildDate>Fri, 15 Apr 2011 13:24:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>中文汉字的正则字符编码范围</title>
		<link>http://www.wangchong.org/spider/35.html</link>
		<comments>http://www.wangchong.org/spider/35.html#comments</comments>
		<pubDate>Tue, 12 Jan 2010 02:34:52 +0000</pubDate>
		<dc:creator>毛毛虫</dc:creator>
				<category><![CDATA[Spider]]></category>

		<guid isPermaLink="false">http://www.wangchong.org/spider/35.html</guid>
		<description><![CDATA[中文编码范围，中文汉字的正则也许用的着。 双字节字符编码范围： 1. GBK (GB2312/GB18030) ?View Code TXT1 2 3 4 \x00-\xff GBK双字节编码范围 \x20-\x7f ASCII \xa1-\xff 中文gb2312 \x80-\xff 中文 gbk 2. UTF-8 (Unicode) ?View Code TXT1 2 3 4 \u4e00-\u9fa5 (中文) \x3130-\x318F (韩文) \xAC00-\xD7A3 (韩文) \u0800-\u4e00 (日文)]]></description>
			<content:encoded><![CDATA[<p>中文编码范围，中文汉字的正则也许用的着。</p>
<p>双字节字符编码范围：</p>
<p>1. GBK (GB2312/GB18030)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p35code3'); return false;">View Code</a> TXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p353"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p35code3"><pre class="txt" style="font-family:monospace;">\x00-\xff GBK双字节编码范围
\x20-\x7f ASCII
\xa1-\xff 中文gb2312
\x80-\xff 中文 gbk</pre></td></tr></table></div>

<p>2. UTF-8 (Unicode)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p35code4'); return false;">View Code</a> TXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p354"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p35code4"><pre class="txt" style="font-family:monospace;">\u4e00-\u9fa5 (中文)
\x3130-\x318F (韩文)
\xAC00-\xD7A3 (韩文)
\u0800-\u4e00 (日文)</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.wangchong.org/spider/35.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP完整删除文件夹函数</title>
		<link>http://www.wangchong.org/phpmysql/34.html</link>
		<comments>http://www.wangchong.org/phpmysql/34.html#comments</comments>
		<pubDate>Fri, 27 Nov 2009 09:02:06 +0000</pubDate>
		<dc:creator>毛毛虫</dc:creator>
				<category><![CDATA[PHP&MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[删除文件夹]]></category>

		<guid isPermaLink="false">http://www.wangchong.org/phpmysql/34.html</guid>
		<description><![CDATA[?View Code PHP1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 /** * 删除指定目录 * * @param string $dirname 路径 * @return void */ function rmdir_rf&#40;$dirname&#41; &#123; if &#40;$dirHandle = opendir&#40;$dirname&#41;&#41; &#123; chdir&#40;$dirname&#41;; //该处很多地方都写$file = readdir($dirHandle))，当$file = 0时，函数失效 while &#40;false !== &#40;$file = readdir&#40;$dirHandle&#41;&#41;&#41; [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p34code6'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p346"><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
</pre></td><td class="code" id="p34code6"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * 删除指定目录
 *
 * @param string $dirname 路径
 * @return void
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> rmdir_rf<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirname</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirHandle</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/opendir"><span style="color: #990000;">opendir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirname</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<a href="http://www.php.net/chdir"><span style="color: #990000;">chdir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirname</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//该处很多地方都写$file = readdir($dirHandle))，当$file = 0时，函数失效</span>
		<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">!==</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/readdir"><span style="color: #990000;">readdir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirHandle</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>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'.'</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'..'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_dir"><span style="color: #990000;">is_dir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>rmdir_rf<span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">else</span> <a href="http://www.php.net/unlink"><span style="color: #990000;">unlink</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<a href="http://www.php.net/chdir"><span style="color: #990000;">chdir</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'..'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.php.net/rmdir"><span style="color: #990000;">rmdir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirname</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.php.net/closedir"><span style="color: #990000;">closedir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirHandle</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>该函数在PHP手册中有人写过，但当while语句中的遍历写的有点小问题，在使用中发现函数失效，就随后记下来吧，好像一年多没更新过博客了，惭愧……</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wangchong.org/phpmysql/34.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Snoopy中文手册（毛毛虫翻译）</title>
		<link>http://www.wangchong.org/spider/32.html</link>
		<comments>http://www.wangchong.org/spider/32.html#comments</comments>
		<pubDate>Sun, 27 Apr 2008 10:37:18 +0000</pubDate>
		<dc:creator>毛毛虫</dc:creator>
				<category><![CDATA[Spider]]></category>
		<category><![CDATA[Snoopy]]></category>
		<category><![CDATA[中文手册]]></category>
		<category><![CDATA[毛毛虫，毛毛虫翻译]]></category>

		<guid isPermaLink="false">http://www.wangchong.org/spider/32.html</guid>
		<description><![CDATA[?View Code PHP1 2 3 4 5 6 7 /** * @name Snoopy手册中文版 * @author 毛毛虫 wangchong1985@gmail.com * @version Snoopy - the PHP net client v1.2.2 * @link http://www.wangchong.org * @since 2008-04-27 */ 名称: Snoopy &#8211; the PHP net client v1.2.2 概要: ?View Code PHP1 2 3 4 5 6 7 8 9 10 11 [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p32code13'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p3213"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p32code13"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * @name Snoopy手册中文版
 * @author 毛毛虫 wangchong1985@gmail.com
 * @version Snoopy - the PHP net client v1.2.2
 * @link http://www.wangchong.org
 * @since 2008-04-27
 */</span></pre></td></tr></table></div>

<p>名称:</p>
<p>	Snoopy &#8211; the PHP net client v1.2.2</p>
<p>概要:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p32code14'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p3214"><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="p32code14"><pre class="php" style="font-family:monospace;">&nbsp;
	<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">&quot;Snoopy.class.php&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$snoopy</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Snoopy<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchtext</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.php.net/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">print</span> <span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchlinks</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.phpbuilder.com/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">print</span> <span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$submit_url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://lnk.ispi.net/texis/scripts/msearch/netsearch.html&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$submit_vars</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;q&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;amiga&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$submit_vars</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;submit&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Search!&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$submit_vars</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;searchhost&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Altavista&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$submit_url</span><span style="color: #339933;">,</span><span style="color: #000088;">$submit_vars</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">print</span> <span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">maxframes</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.ispi.net/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/htmlentities"><span style="color: #990000;">htmlentities</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/htmlentities"><span style="color: #990000;">htmlentities</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/htmlentities"><span style="color: #990000;">htmlentities</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchform</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.altavista.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">print</span> <span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>描述:</p>
<p>	Snoopy是什么?</p>
<p>	Snoopy是一个php类，用来模仿web浏览器的功能，它能完成获取网页内容和发送表单的任务。</p>
<p>	Snoopy的一些特点:</p>
<p>	* 方便抓取网页的内容<br />
	* 方便抓取网页的文本内容 (去除HTML标签)<br />
	* 方便抓取网页的链接<br />
	* 支持代理主机<br />
	* 支持基本的用户名/密码验证<br />
	* 支持设置 user_agent, referer(来路), cookies 和 header content(头文件)<br />
	* 支持浏览器转向，并能控制转向深度<br />
	* 能把网页中的链接扩展成高质量的url(默认)<br />
	* 方便提交数据并且获取返回值<br />
	* 支持跟踪HTML框架(v0.92增加)<br />
	* 支持再转向的时候传递cookies (v0.92增加)<br />
<span id="more-32"></span><br />
要求:</p>
<p>	Snoopy requires PHP with PCRE (Perl Compatible Regular Expressions),<br />
	which should be PHP 3.0.9 and up. For read timeout support, it requires<br />
	PHP 4 Beta 4 or later. Snoopy was developed and tested with PHP 3.0.12.</p>
<p>类方法:</p>
<p>	fetch($URI)<br />
	&#8212;&#8212;&#8212;&#8211;</p>
<p>	这是为了抓取网页的内容而使用的方法。<br />
	$URI参数是被抓取网页的URL地址。<br />
	抓取的结果被存储在 $this->results 中。<br />
	如果你正在抓取的是一个框架，Snoopy将会将每个框架追踪后存入数组中，然后存入 $this->results。</p>
<p>	fetchtext($URI)<br />
	&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>	本方法类似于fetch()，唯一不同的就是本方法会去除HTML标签和其他的无关数据，只返回网页中的文字内容。</p>
<p>	fetchform($URI)<br />
	&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>	本方法类似于fetch()，唯一不同的就是本方法会去除HTML标签和其他的无关数据，只返回网页中表单内容(form)。</p>
<p>	fetchlinks($URI)<br />
	&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>	本方法类似于fetch()，唯一不同的就是本方法会去除HTML标签和其他的无关数据，只返回网页中链接(link)。<br />
	默认情况下，相对链接将自动补全，转换成完整的URL。</p>
<p>	submit($URI,$formvars)<br />
	&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>	本方法向$URL指定的链接地址发送确认表单。$formvars是一个存储表单参数的数组。</p>
<p>	submittext($URI,$formvars)<br />
	&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>	本方法类似于submit()，唯一不同的就是本方法会去除HTML标签和其他的无关数据，只返回登陆后网页中的文字内容。</p>
<p>	submitlinks($URI)<br />
	&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>	本方法类似于submit()，唯一不同的就是本方法会去除HTML标签和其他的无关数据，只返回网页中链接(link)。<br />
	默认情况下，相对链接将自动补全，转换成完整的URL。</p>
<p>类属性:	(缺省值在括号里)</p>
<p>	$host			连接的主机<br />
	$port			连接的端口<br />
	$proxy_host		使用的代理主机，如果有的话<br />
	$proxy_port		使用的代理主机端口，如果有的话<br />
	$agent			用户代理伪装 (Snoopy v0.1)<br />
	$referer		来路信息，如果有的话<br />
	$cookies		cookies， 如果有的话<br />
	$rawheaders		其他的头信息, 如果有的话<br />
	$maxredirs		最大重定向次数， 0=不允许 (5)<br />
	$offsiteok		whether or not to allow redirects off-site. (true)<br />
	$expandlinks	        是否将链接都补全为完整地址 (true)<br />
	$user			认证用户名, 如果有的话<br />
	$pass			认证用户名, 如果有的话<br />
	$accept			http 接受类型 (image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*)<br />
	$error			哪里报错, 如果有的话<br />
	$response_code		从服务器返回的响应代码<br />
	$headers		从服务器返回的头信息<br />
	$maxlength		最长返回数据长度<br />
	$read_timeout		读取操作超时 (requires PHP 4 Beta 4+)<br />
				设置为0为没有超时<br />
	$timed_out		如果一次读取操作超时了，本属性返回 true (requires PHP 4 Beta 4+)<br />
	$maxframes		允许追踪的框架最大数量<br />
	$status			抓取的http的状态<br />
	$temp_dir		网页服务器能够写入的临时文件目录 (/tmp)<br />
	$curl_path		cURL binary 的目录, 如果没有cURL binary就设置为 false</p>
<p>例子:</p>
<p>	例子: 	抓取一个页面并显示他的头信息和页面内容 (去掉HTML标签的页面):</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p32code15'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p3215"><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="p32code15"><pre class="php" style="font-family:monospace;">&nbsp;
	<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">&quot;Snoopy.class.php&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$snoopy</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Snoopy<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;joe&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;bloe&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.slashdot.org/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;response code: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">response_code</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/each"><span style="color: #990000;">each</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headers</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$key</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$val</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;p&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/htmlspecialchars"><span style="color: #990000;">htmlspecialchars</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;error fetching document: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">error</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>	例子:	提交一个表单并且打印出头信息和去掉HTML标签的页面:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p32code16'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p3216"><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
</pre></td><td class="code" id="p32code16"><pre class="php" style="font-family:monospace;">&nbsp;
	<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">&quot;Snoopy.class.php&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$snoopy</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Snoopy<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$submit_url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://lnk.ispi.net/texis/scripts/msearch/netsearch.html&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$submit_vars</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;q&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;amiga&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$submit_vars</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;submit&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Search!&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$submit_vars</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;searchhost&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Altavista&quot;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$submit_url</span><span style="color: #339933;">,</span><span style="color: #000088;">$submit_vars</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/each"><span style="color: #990000;">each</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headers</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$key</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$val</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;p&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/htmlspecialchars"><span style="color: #990000;">htmlspecialchars</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;error fetching document: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">error</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>	例子:	展示所有属性的功能:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p32code17'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p3217"><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
</pre></td><td class="code" id="p32code17"><pre class="php" style="font-family:monospace;">&nbsp;
	<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">&quot;Snoopy.class.php&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$snoopy</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Snoopy<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">proxy_host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;my.proxy.host&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">proxy_port</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;8080&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">agent</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;(compatible; MSIE 4.01; MSN 2.5; AOL 4.0; Windows 98)&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">referer</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.microsnot.com/&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cookies</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;SessionID&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> 238472834723489l<span style="color: #339933;">;</span>
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cookies</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;favoriteColor&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;RED&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rawheaders</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;Pragma&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;no-cache&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">maxredirs</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">offsiteok</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">expandlinks</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;joe&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;bloe&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchtext</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.phpbuilder.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/each"><span style="color: #990000;">each</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headers</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$key</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$val</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;p&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/htmlspecialchars"><span style="color: #990000;">htmlspecialchars</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;error fetching document: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">error</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>	例子: 	抓取框架内容并展示结果：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p32code18'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p3218"><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="p32code18"><pre class="php" style="font-family:monospace;">&nbsp;
	<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">&quot;Snoopy.class.php&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$snoopy</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Snoopy<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">maxframes</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.ispi.net/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/htmlspecialchars"><span style="color: #990000;">htmlspecialchars</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/htmlspecialchars"><span style="color: #990000;">htmlspecialchars</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/htmlspecialchars"><span style="color: #990000;">htmlspecialchars</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;error fetching document: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">error</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>COPYRIGHT:<br />
	Copyright(c) 1999,2000 ispi. All rights reserved.<br />
	This software is released under the GNU General Public License.<br />
	Please read the disclaimer at the top of the Snoopy.class.php file.</p>
<p>THANKS:<br />
	Special Thanks to:<br />
	Peter Sorger <sorgo@cool.sk> help fixing a redirect bug<br />
	Andrei Zmievski <andrei@ispi.net> implementing time out functionality<br />
	Patric Sandelin
<patric@kajen.com> help with fetchform debugging<br />
	Carmelo <carmelo@meltingsoft.com> misc bug fixes with frames</p>
<p>Snoopy中文手册下载：<a href='http://www.wangchong.org/wp-content/uploads/2008/04/snoopy_cn.txt' title='snoopy中文手册.txt'>snoopy中文手册.txt</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.wangchong.org/spider/32.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>仿QQ等级显示函数</title>
		<link>http://www.wangchong.org/phpmysql/28.html</link>
		<comments>http://www.wangchong.org/phpmysql/28.html#comments</comments>
		<pubDate>Fri, 11 Apr 2008 06:19:03 +0000</pubDate>
		<dc:creator>毛毛虫</dc:creator>
				<category><![CDATA[PHP&MySQL]]></category>
		<category><![CDATA[PHP函数]]></category>
		<category><![CDATA[QQ等级]]></category>

		<guid isPermaLink="false">http://www.wangchong.org/phpmysql/28.html</guid>
		<description><![CDATA[开头先引述下QQ等级的算法： 设当前等级为N，达到当前等级最少需要的活跃天数为D，当前活跃天数为Dc，升级剩余天数为Dr，则： 从而推出: 好了，引述完成，懒得写字了，贴出代码： 以上就是显示类，再来个简单的调用实例：]]></description>
			<content:encoded><![CDATA[<p>开头先引述下QQ等级的算法：<br />
设当前等级为N，达到当前等级最少需要的活跃天数为D，当前活跃天数为Dc，升级剩余天数为Dr，则：</p>
<p><img src='http://184.82.233.34/wp-content/uploads/2008/04/mimetex.gif' alt='mimetex.gif' /></p>
<p>从而推出:</p>
<p><img src='http://184.82.233.34/wp-content/uploads/2008/04/mimetex1.gif' alt='mimetex1.gif' /></p>
<p>好了，引述完成，懒得写字了，贴出代码：</p>
<p><coolcode lang="php"><br />
<?php<br />
/**<br />
*<br />
* showRank.php<br />
* QQ等级输出类库<br />
* @author 毛毛虫 <wangchong1985@gmail.com><br />
* @version 1.0 2008-04-09<br />
*<br />
*/<br />
class showRank {</p>
<p>	/**<br />
	 * 第一级图片显示字段<br />
	 */<br />
	public $mImage1;</p>
<p>	/**<br />
	 * 第二级图片显示字段<br />
	 */<br />
	public $mImage2;</p>
<p>	/**<br />
	 * 第三级图片显示字段<br />
	 */<br />
	public $mImage3;</p>
<p>	/**<br />
	 * 构造函数：传入图片值<br />
	 * @return 无<br />
	 */<br />
	function __construct($pImage1 = &#8216;★&#8217;,$pImage2 = &#8216;▲&#8217;,$pImage3 = &#8216;●&#8217;) {<br />
		$this->mImage1 = $pImage1;<br />
		$this->mImage2 = $pImage2;<br />
		$this->mImage3 = $pImage3;<br />
	}</p>
<p>	/**<br />
	 * 根据活跃天数计算用户等级。(模仿QQ的升级方式)<br />
	 * @return int<br />
	 * @access public<br />
	 */<br />
	function get_rank($pScore) {<br />
		$temp = $pScore+4;<br />
		$tRank = sqrt($temp)-2;<br />
		$tRank = floor($tRank);<br />
		return $tRank;<br />
	}</p>
<p>	/**<br />
	 * 用户等级标志,根据用户等级显示用户标志<br />
	 * 仿照QQ等级的四进制显示<br />
	 * @return str<br />
	 * @access public<br />
	 */<br />
	function get_score($pScore) {<br />
		$str = &#8221;;<br />
		$tRank = $this->get_rank($pScore);//根据分数取得等级<br />
		$tPicNum = base_convert($tRank,10,4);//转化为四进制<br />
		$tPicNum = strrev($tPicNum);//翻转字符串<br />
		$tArray = str_split($tPicNum);//转化为数组<br />
		$tNum = count($tArray);<br />
		if($tNum<=3) {<br />
			for($i=$tNum-1;$i>=0;$i&#8211;){<br />
				switch($i){<br />
					case &#8217;0&#8242;:<br />
						for($j=0;$j<$tArray[$i];$j++){<br />
							$str .= $this->mImage1;<br />
						}<br />
					break;<br />
					case &#8217;1&#8242;:<br />
						for($j=0;$j<$tArray[$i];$j++){<br />
							$str .= $this->mImage2;<br />
						}<br />
					break;<br />
					case &#8217;2&#8242;:<br />
						for($j=0;$j<$tArray[$i];$j++){<br />
							$str .= $this->mImage3;<br />
						}<br />
					break;<br />
					default:<br />
						//$str = ;<br />
					break;<br />
				}<br />
			}<br />
		}else {<br />
			$str = 	$this->mImage3.$this->mImage3.$this->mImage3.$this->mImage3;<br />
		}<br />
		return $str;</p>
<p>	}</p>
<p>}<br />
?><br />
</coolcode><br />
<span id="more-28"></span><br />
以上就是显示类，再来个简单的调用实例：</p>
<p><coolcode lang="php"><br />
<?php<br />
require_once('showRank.php');<br />
//定义等级图片<br />
$tImage1 = '<img src="images/time_star.gif">&#8216;;<br />
$tImage2 = &#8216;<img src="images/time_yueliang.gif">&#8216;;<br />
$tImage3 = &#8216;<img src="images/time_sun.gif">&#8216;;<br />
//实例化并传输等级图片<br />
$tShow = new showRank($tImage1,$tImage2,$tImage3);<br />
//输入的活跃天数<br />
$tScore = 1009;<br />
$echo = $tShow->get_score($tScore);<br />
//输出显示效果<br />
print &#8216;
<div align=center>&#8216;.$echo.&#8217;</div>
<p>&#8216;;<br />
?><br />
</coolcode><br />
本文到此接受，呵呵，提供程序打包下载，包括使用的太阳，月亮，星星图标：</p>
<p><strong>演示地址：</strong><a href='http://www.wangchong.org/lab/showrank/' title='QQ等级显示函数演示程序'>http://www.wangchong.org/lab/showrank/</a><br />
<strong>下载地址：</strong><a href='http://www.wangchong.org/wp-content/uploads/2008/04/showrank.rar' title='showrank.rar'>http://www.wangchong.org/wp-content/uploads/2008/04/showrank.rar</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.wangchong.org/phpmysql/28.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP实现‘服务器推’（flush函数使用）</title>
		<link>http://www.wangchong.org/phpmysql/27.html</link>
		<comments>http://www.wangchong.org/phpmysql/27.html#comments</comments>
		<pubDate>Tue, 12 Feb 2008 04:54:57 +0000</pubDate>
		<dc:creator>毛毛虫</dc:creator>
				<category><![CDATA[PHP&MySQL]]></category>
		<category><![CDATA[flush]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[服务器推]]></category>
		<category><![CDATA[输出缓冲]]></category>

		<guid isPermaLink="false">http://www.wangchong.org/phpmysql/27.html</guid>
		<description><![CDATA[最近一直在做自己的图书站，分别使用过杰奇和读吧两套不同的系统，对于这两套系统也是又爱又恨，爱的是他们的功能强大，恨他们都同属没有开源精神的产物。呵呵，作为一名穷程序员，俺可以理解作者的苦衷，这里就不批判了。 年假期间，无事可做，翻看自己以前的采集代码，发现很多可以优化和提升的地方，就简单做了下优化，其中也使用了用户体验更加优秀的服务器推技术，这里简单的介绍下核心的函数：flush。 先看看手册中的解释： flush — 刷新输出缓冲； 说明： void flush ( void ) 刷新PHP程序的缓冲，而不论PHP执行在何种情况下（CGI ，web服务器等等）。该函数将当前为止程序的所有输出发送到用户的浏览器。 flush() 函数不会对服务器或客户端浏览器的缓存模式产生影响。因此，必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。 个别web服务器程序，特别是Win32下的web服务器程序，在发送结果到浏览器之前，仍然会缓存脚本的输出，直到程序结束为止。 有些Apache的模块，比如mod_gzip，可能自己进行输出缓存，这将导致flush()函数产生的结果不会立即被发送到客户端浏览器。 甚至浏览器也会在显示之前，缓存接收到的内容。例如 Netscape 浏览器会在接受到换行或 html 标记的开头之前缓存内容，并且在接受到 标记之前，不会显示出整个表格。 一些版本的 Microsoft Internet Explorer 只有当接受到的256个字节以后才开始显示该页面，所以必须发送一些额外的空格来让这些浏览器显示页面内容。 根据上面的解释，我们简单的使用flush函数来实现一个例子： 上面的这段代码，应该隔一秒钟输出一次$i。但是实际中却不一定是这样。有可能是等了10秒钟后，所有的输出同时呈现出来，后面的输出开始正常。PHP手册中对此也做出了解释，就是各种缓存在起作用，那我们该如何解决呢？！ 答案来了：^_^ 一、 二、 写到这里，发现一个哥们的文章，比我写的更加透彻，在次引用： 剖析PHP中的输出缓冲 最近想整理下自己的代码，搞个专门的站点放着，暂定名为：毛毛虫的实验室 大家敬请期待，肯定都是好玩的东西，呵呵！]]></description>
			<content:encoded><![CDATA[<p>最近一直在做自己的图书站，分别使用过杰奇和读吧两套不同的系统，对于这两套系统也是又爱又恨，爱的是他们的功能强大，恨他们都同属没有开源精神的产物。呵呵，作为一名穷程序员，俺可以理解作者的苦衷，这里就不批判了。<br />
年假期间，无事可做，翻看自己以前的采集代码，发现很多可以优化和提升的地方，就简单做了下优化，其中也使用了用户体验更加优秀的服务器推技术，这里简单的介绍下核心的函数：flush。<br />
<span id="more-27"></span><br />
先看看手册中的解释：<br />
flush — 刷新输出缓冲；<br />
说明：<br />
void flush ( void )<br />
刷新PHP程序的缓冲，而不论PHP执行在何种情况下（CGI ，web服务器等等）。该函数将当前为止程序的所有输出发送到用户的浏览器。</p>
<p>flush() 函数不会对服务器或客户端浏览器的缓存模式产生影响。因此，必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。</p>
<p>个别web服务器程序，特别是Win32下的web服务器程序，在发送结果到浏览器之前，仍然会缓存脚本的输出，直到程序结束为止。</p>
<p>有些Apache的模块，比如mod_gzip，可能自己进行输出缓存，这将导致flush()函数产生的结果不会立即被发送到客户端浏览器。</p>
<p>甚至浏览器也会在显示之前，缓存接收到的内容。例如 Netscape 浏览器会在接受到换行或 html 标记的开头之前缓存内容，并且在接受到 </table>
<p> 标记之前，不会显示出整个表格。</p>
<p>一些版本的 Microsoft Internet Explorer 只有当接受到的256个字节以后才开始显示该页面，所以必须发送一些额外的空格来让这些浏览器显示页面内容。</p>
<p>根据上面的解释，我们简单的使用flush函数来实现一个例子：<br />
<coolcode lang="php"><br />
<?php<br />
for ($i=10; $i>0; $i&#8211;)<br />
{<br />
    echo $i;<br />
    flush();<br />
    sleep(1);<br />
}<br />
?><br />
</coolcode><br />
上面的这段代码，应该隔一秒钟输出一次$i。但是实际中却不一定是这样。有可能是等了10秒钟后，所有的输出同时呈现出来，后面的输出开始正常。PHP手册中对此也做出了解释，就是各种缓存在起作用，那我们该如何解决呢？！<br />
答案来了：^_^<br />
一、<br />
<coolcode lang="php"><br />
<?php<br />
ob_end_clean();//修改部分<br />
for ($i=10; $i>0; $i&#8211;)<br />
{<br />
    echo $i;<br />
    flush();<br />
    sleep(1);<br />
}<br />
?><br />
</coolcode><br />
二、<br />
<coolcode lang="php"><br />
<?php<br />
for ($i=10; $i>0; $i&#8211;)<br />
{<br />
    echo $i;<br />
    ob_flush();//修改部分<br />
    flush();<br />
    sleep(1);<br />
}<br />
?><br />
</coolcode><br />
写到这里，发现一个哥们的文章，比我写的更加透彻，在次引用：<br />
<a href="http://hi.baidu.com/imdao/blog/item/723e7e8b589b5e11c8fc7ada.html">剖析PHP中的输出缓冲</a><br />
最近想整理下自己的代码，搞个专门的站点放着，暂定名为：毛毛虫的实验室<br />
大家敬请期待，肯定都是好玩的东西，呵呵！</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wangchong.org/phpmysql/27.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>杰奇小说连载系统sitemap生成插件</title>
		<link>http://www.wangchong.org/phpmysql/25.html</link>
		<comments>http://www.wangchong.org/phpmysql/25.html#comments</comments>
		<pubDate>Fri, 01 Feb 2008 16:52:52 +0000</pubDate>
		<dc:creator>毛毛虫</dc:creator>
				<category><![CDATA[PHP&MySQL]]></category>
		<category><![CDATA[sitemap]]></category>
		<category><![CDATA[下载]]></category>
		<category><![CDATA[插件]]></category>
		<category><![CDATA[杰奇小说]]></category>

		<guid isPermaLink="false">http://www.wangchong.org/phpmysql/25.html</guid>
		<description><![CDATA[最近为自己的书站最终选择了杰奇小说连载系统，但是这个系统并不是开源的程序，无法自由修改，很是不爽，但熟悉了几天后，还是忍不住做些扩展的开发，这是我写的一个sitemap的生成程序，在这里放出来给大家用用吧。 sitemap.php $txt_name=&#8217;sitemap.xml&#8217;; writeStatistic_set_name($txt_name); $sql=&#8221;select * from jieqi_article_article &#8220;; $db->query($sql); for($i=1;$inum_rows();$i++){ $db->next_record(); $siteid = $db->f(siteid); $articleid = $db->f(articleid); $url = &#8220; http://www.iobug.com/files/article/html/$siteid/$articleid/index.html &#8220;; writeStatistic($url,$txt_name); } $db->free(); $over=&#8217;&#8216;; writeStatistic($over,$txt_name); print &#8220;alert(\"sitemap生成结束！\");&#8220;; exit; 杰奇小说连载系统sitemap生成插件下载： 杰奇小说sitemap生成插件下载]]></description>
			<content:encoded><![CDATA[<p>最近为自己的书站最终选择了杰奇小说连载系统，但是这个系统并不是开源的程序，无法自由修改，很是不爽，但熟悉了几天后，还是忍不住做些扩展的开发，这是我写的一个sitemap的生成程序，在这里放出来给大家用用吧。<br />
<strong>sitemap.php</strong><br />
<coolcode lang="php"><br />
$txt_name=&#8217;sitemap.xml&#8217;;<br />
writeStatistic_set_name($txt_name);<br />
$sql=&#8221;select * from jieqi_article_article &#8220;;<br />
$db->query($sql);<br />
for($i=1;$i<= $db->num_rows();$i++){<br />
	$db->next_record();<br />
	$siteid = $db->f(siteid);<br />
	$articleid = $db->f(articleid);<br />
	$url = &#8220;<url><br />
		<loc>http://www.iobug.com/files/article/html/$siteid/$articleid/index.html</loc><br />
	</url>&#8220;;<br />
	writeStatistic($url,$txt_name);<br />
}<br />
$db->free();<br />
$over=&#8217;</urlset>&#8216;;<br />
writeStatistic($over,$txt_name);<br />
print &#8220;<script>alert(\"sitemap生成结束！\");</script>&#8220;;<br />
exit;<br />
</coolcode></p>
<p><strong>杰奇小说连载系统sitemap生成插件下载：</strong><br />
<a href='http://www.wangchong.org/wp-content/uploads/2008/02/xml.rar' title='杰奇小说sitemap生成插件下载'>杰奇小说sitemap生成插件下载</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.wangchong.org/phpmysql/25.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>snoopy与htmlsql实例（盗墓笔记采集）</title>
		<link>http://www.wangchong.org/spider/24.html</link>
		<comments>http://www.wangchong.org/spider/24.html#comments</comments>
		<pubDate>Fri, 01 Feb 2008 16:22:27 +0000</pubDate>
		<dc:creator>毛毛虫</dc:creator>
				<category><![CDATA[Spider]]></category>
		<category><![CDATA[htmlsql]]></category>
		<category><![CDATA[Snoopy]]></category>
		<category><![CDATA[txt]]></category>
		<category><![CDATA[实例]]></category>
		<category><![CDATA[盗墓笔记]]></category>

		<guid isPermaLink="false">http://www.wangchong.org/spider/23.html</guid>
		<description><![CDATA[snoopy这个采集类库是个很好玩的东西，简单而且使用，一般的采集应付起来绰绰有余。 最近一个哥们要看盗墓笔记的全本TXT文档，让我帮他采集，想了下决定用snoopy和一个好玩的类库htmlsql来做，htmlsql第一次使用，感觉比较好玩，写SQL的感觉非常有趣，就是灵活性上不是很突出，但做这种小的采集足够了，可能是因为第一次使用这个类库，并不是很顺利，写了两个多钟头，才搞定这个采集，这里放出源码供大家下载吧，想玩玩的可以拿去参考下。 展示部分代码： 程序包下载： snoopy与htmlsql实例程序包]]></description>
			<content:encoded><![CDATA[<p>snoopy这个采集类库是个很好玩的东西，简单而且使用，一般的采集应付起来绰绰有余。<br />
最近一个哥们要看盗墓笔记的全本TXT文档，让我帮他采集，想了下决定用snoopy和一个好玩的类库htmlsql来做，htmlsql第一次使用，感觉比较好玩，写SQL的感觉非常有趣，就是灵活性上不是很突出，但做这种小的采集足够了，可能是因为第一次使用这个类库，并不是很顺利，写了两个多钟头，才搞定这个采集，这里放出源码供大家下载吧，想玩玩的可以拿去参考下。<br />
展示部分代码：<br />
<coolcode lang="php"><br />
<?php<br />
include_once("./snoopy.class.php");<br />
include_once("./htmlsql.class.php");<br />
require_once("./function.php");<br />
//防止页面超时<br />
set_time_limit(0);<br />
//生成文本文档名称<br />
$name="怒海潜沙";//自定义文件名(注意自己修改)<br />
$txt_name=$name.".txt";<br />
$zhangjie="nu-hai-qian-sha";//这个程序写的并不是很智能，每个章节的链接地址还要自己修改下(注意自己修改)<br />
$max="46";//最大采集章节数(注意自己修改)<br />
$wsql = new htmlsql();<br />
for($i=1;$i<=$max;$i++){<br />
	$a=sprintf("%02d", $i);<br />
	$url="http://www.daomubiji.com/$zhangjie-$a.html";<br />
	// connect to a URL<br />
	if (!$wsql->connect(&#8216;url&#8217;, $url)){<br />
		print &#8216;Error while connecting: &#8216; . $wsql->error;<br />
		exit;<br />
	}</p>
<p>	if(!$wsql->query(&#8216;SELECT * FROM h1&#8242;)){<br />
		print &#8220;Query error: &#8221; . $wsql->error;<br />
		exit;<br />
	}</p>
<p>	// show results:<br />
	foreach($wsql->fetch_array() as $row){<br />
		writeStatistic(&#8220;\r\n&#8221;.$row['text'].&#8221;\r\n&#8221;,$txt_name);<br />
		$echo=iconv(&#8220;UTF-8&#8243;, &#8220;GBK&#8221;, $row['text']);<br />
		//print_r($row);<br />
	}</p>
<p>	$wsql->isolate_content(&#8216;<script src=http://busjs.vodone.cn/bus/ownerjs/advjs_47/47093/47093_56564_p7_.js></script>&#8216;,&#8217;
<p align="center">&#8216;);</p>
<p>	if (!$wsql->query(&#8216;SELECT * FROM *&#8217;)){<br />
		print &#8220;Query error: &#8221; . $wsql->error;<br />
		exit;<br />
	}</p>
<p>	// show results:<br />
	foreach($wsql->fetch_array() as $row){<br />
		writeStatistic(strip_tags($row['text']).&#8221;\r\n&#8221;,$txt_name);<br />
		//print_r($row);<br />
	}<br />
	print &#8220;$i. 章节： $echo 采集完成&#8230;..<br />&#8220;;<br />
	print &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />&#8220;;<br />
	flush();<br />
}<br />
print &#8220;卷：$name 全部采集完成&#8230;&#8230;&#8221;;<br />
?><br />
</coolcode><br />
<strong>程序包下载：</strong><br />
<a href='http://www.wangchong.org/wp-content/uploads/2008/02/yaba.rar' title='snoopy与htmlsql实例程序包'>snoopy与htmlsql实例程序包</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.wangchong.org/spider/24.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>mysql出错表</title>
		<link>http://www.wangchong.org/phpmysql/23.html</link>
		<comments>http://www.wangchong.org/phpmysql/23.html#comments</comments>
		<pubDate>Thu, 24 Jan 2008 08:43:15 +0000</pubDate>
		<dc:creator>毛毛虫</dc:creator>
				<category><![CDATA[PHP&MySQL]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[错误]]></category>

		<guid isPermaLink="false">http://www.wangchong.org/phpmysql/22.html</guid>
		<description><![CDATA[1005：创建表失败 1006：创建数据库失败 1007：数据库已存在，创建数据库失败 1008：数据库不存在，删除数据库失败 1009：不能删除数据库文件导致删除数据库失败 1010：不能删除数据目录导致删除数据库失败 1011：删除数据库文件失败 1012：不能读取系统表中的记录 1020：记录已被其他用户修改 1021：硬盘剩余空间不足，请加大硬盘可用空间 1022：关键字重复，更改记录失败 1023：关闭时发生错误 1024：读文件错误 1025：更改名字时发生错误 1026：写文件错误 1032：记录不存在 1036：数据表是只读的，不能对它进行修改 1037：系统内存不足，请重启数据库或重启服务器 1038：用于排序的内存不足，请增大排序缓冲区 1040：已到达数据库的最大连接数，请加大数据库可用连接数 1041：系统内存不足 1042：无效的主机名 1043：无效连接 1044：当前用户没有访问数据库的权限 1045：不能连接数据库，用户名或密码错误 1048：字段不能为空 1049：数据库不存在 1050：数据表已存在 1051：数据表不存在 1054：字段不存在 1065：无效的SQL语句，SQL语句为空 1081：不能建立Socket连接 1114：数据表已满，不能容纳任何记录 1116：打开的数据表太多 1129：数据库出现异常，请重启数据库 1130：连接数据库失败，没有连接数据库的权限 1133：数据库用户不存在 1141：当前用户无权访问数据库 1142：当前用户无权访问数据表 1143：当前用户无权访问数据表中的字段 1146：数据表不存在 1147：未定义用户对数据表的访问权限 1149：SQL语句语法错误 1158：网络错误，出现读错误，请检查网络连接状况 1159：网络错误，读超时，请检查网络连接状况 1160：网络错误，出现写错误，请检查网络连接状况 1161：网络错误，写超时，请检查网络连接状况 1062：字段值重复，入库失败 1169：字段值重复，更新记录失败 1177：打开数据表失败 1180：提交事务失败 1181：回滚事务失败 1203：当前用户和数据库建立的连接已到达数据库的最大连接数，请增大可用的数据库连接数或重启数据库 1205：加锁超时 1211：当前用户没有创建用户的权限 [...]]]></description>
			<content:encoded><![CDATA[<p>1005：创建表失败<br />
1006：创建数据库失败<br />
1007：数据库已存在，创建数据库失败<br />
1008：数据库不存在，删除数据库失败<br />
1009：不能删除数据库文件导致删除数据库失败<br />
1010：不能删除数据目录导致删除数据库失败<br />
1011：删除数据库文件失败<br />
1012：不能读取系统表中的记录<br />
1020：记录已被其他用户修改<br />
1021：硬盘剩余空间不足，请加大硬盘可用空间<br />
1022：关键字重复，更改记录失败<br />
1023：关闭时发生错误<br />
1024：读文件错误<br />
1025：更改名字时发生错误<br />
1026：写文件错误<br />
1032：记录不存在<br />
1036：数据表是只读的，不能对它进行修改<br />
1037：系统内存不足，请重启数据库或重启服务器<br />
1038：用于排序的内存不足，请增大排序缓冲区<br />
1040：已到达数据库的最大连接数，请加大数据库可用连接数<br />
1041：系统内存不足<br />
1042：无效的主机名<br />
1043：无效连接<br />
1044：当前用户没有访问数据库的权限<br />
1045：不能连接数据库，用户名或密码错误<br />
1048：字段不能为空<br />
1049：数据库不存在<br />
1050：数据表已存在<br />
1051：数据表不存在 <span id="more-23"></span><br />
1054：字段不存在<br />
1065：无效的SQL语句，SQL语句为空<br />
1081：不能建立Socket连接<br />
1114：数据表已满，不能容纳任何记录<br />
1116：打开的数据表太多<br />
1129：数据库出现异常，请重启数据库<br />
1130：连接数据库失败，没有连接数据库的权限<br />
1133：数据库用户不存在<br />
1141：当前用户无权访问数据库<br />
1142：当前用户无权访问数据表<br />
1143：当前用户无权访问数据表中的字段<br />
1146：数据表不存在<br />
1147：未定义用户对数据表的访问权限<br />
1149：SQL语句语法错误<br />
1158：网络错误，出现读错误，请检查网络连接状况<br />
1159：网络错误，读超时，请检查网络连接状况<br />
1160：网络错误，出现写错误，请检查网络连接状况<br />
1161：网络错误，写超时，请检查网络连接状况<br />
1062：字段值重复，入库失败<br />
1169：字段值重复，更新记录失败<br />
1177：打开数据表失败<br />
1180：提交事务失败<br />
1181：回滚事务失败<br />
1203：当前用户和数据库建立的连接已到达数据库的最大连接数，请增大可用的数据库连接数或重启数据库<br />
1205：加锁超时<br />
1211：当前用户没有创建用户的权限<br />
1216：外键约束检查失败，更新子表记录失败<br />
1217：外键约束检查失败，删除或修改主表记录失败<br />
1226：当前用户使用的资源已超过所允许的资源，请重启数据库或重启服务器<br />
1227：权限不足，您无权进行此操作<br />
1235：MySQL版本过低，不具有本功能</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wangchong.org/phpmysql/23.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用PHP取得文件后缀名的两个办法</title>
		<link>http://www.wangchong.org/phpmysql/21.html</link>
		<comments>http://www.wangchong.org/phpmysql/21.html#comments</comments>
		<pubDate>Thu, 17 Jan 2008 02:20:34 +0000</pubDate>
		<dc:creator>毛毛虫</dc:creator>
				<category><![CDATA[PHP&MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[文件后缀名]]></category>

		<guid isPermaLink="false">http://www.wcphp.com/?p=13</guid>
		<description><![CDATA[1、pathinfo函数: 2、end函数:]]></description>
			<content:encoded><![CDATA[<p>1、pathinfo函数:<br />
<coolcode lang="php"><br />
<?php<br />
$name = 'http://www.wangchong.org/ad_banner-1199957657.gif';<br />
$path_parts = pathinfo($name);<br />
echo $path_parts['extension'];<br />
?><br />
</coolcode><br />
2、end函数:<br />
<coolcode lang="php"><br />
<?php<br />
$name = 'http://www.wangchong.org/ad_banner-1199957657.gif';<br />
echo(end(explode(".",$name)));<br />
?><br />
</coolcode></p>
]]></content:encoded>
			<wfw:commentRss>http://www.wangchong.org/phpmysql/21.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Apache服务器配置技巧</title>
		<link>http://www.wangchong.org/other/20.html</link>
		<comments>http://www.wangchong.org/other/20.html#comments</comments>
		<pubDate>Sat, 29 Dec 2007 05:10:12 +0000</pubDate>
		<dc:creator>毛毛虫</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[技巧]]></category>
		<category><![CDATA[配置]]></category>

		<guid isPermaLink="false">http://www.wcphp.com/?p=20</guid>
		<description><![CDATA[Apache服务器配置技巧 本文简要介绍了十几个Apache 的配置技巧： 　　1、如何设 置请求等待时间 　　在httpd.conf里面设置： 　　TimeOut n 　　其中n为整数，单位是秒。 　　设置这个TimeOut适用于三种情况： 　　2、如何接收一个get请求的总时间 　　接收一个post和put请求的TCP包之间的时间 　　TCP包传输中的响应（ack）时间间隔 　　3、如何使得apache监听在特定的端口 　　修改httpd.conf里面关于Listen的选项，例如： 　　Listen 8000 　　是使apache监听在8000端口 　　而如果要同时指定监听端口和监听地址，可以使用： 　　Listen 192.170.2.1:80 　　Listen 192.170.2.5:8000 　　这样就使得apache同时监听在192.170.2.1的80端口和192.170.2.5的8000端口。 　　当然也可以在httpd.conf里面设置： 　　Port 80 　　这样来实现类似的效果。 　　4、如何设置apache的最大空闲进程数 　　修改httpd.conf，在里面设置： 　　MaxSpareServers n 　　其中n是一个整数。这样当空闲进程超过n的时候，apache主进程会杀掉多余的空闲进程而保持空闲进程在n，节省了系统资源。如果在一个apache非常繁忙的站点调节这个参数才是必要的，但是在任何时候把这个参数调到很大都不是一个好主意。 　　同时也可以设置： 　　MinSpareServers n 　　来限制最少空闲进程数目来加快反应速度。 　　5、apache如何设置启动时的子服务进程个数 　　在httpd.conf里面设置： 　　StartServers 5 　　这样启动apache后就有5个空闲子进程等待接受请求。 　　也可以参考MinSpareServers和MaxSpareServers设置。 6、如何在apache中设置每个连接的最大请求数 　　在httpd.conf里面设置： 　　MaxKeepAliveRequests 100 　　这样就能保证在一个连接中，如果同时请求数达到100就不再响应这个连接的新请求，保证了系统资源不会被某个连接大量占用。但是在实际配置中要求尽量把这个数值调高来获得较高的系统性能。 　　7、如何在apache中设置session的持续时间 　　在apache1.2以上的版本中，可以在httpd.conf里面设置： 　　KeepAlive on 　　KeepAliveTimeout 15 　　这样就能限制每个session的保持时间是15秒。session的使用可以使得很多请求都可以通过同一个tcp连接来发送，节约了网络资源和系统资源。 [...]]]></description>
			<content:encoded><![CDATA[<p>Apache服务器配置技巧<br />
本文简要介绍了十几个Apache 的配置技巧：<br />
　　1、如何设 置请求等待时间</p>
<p>　　在httpd.conf里面设置：</p>
<p>　　TimeOut n</p>
<p>　　其中n为整数，单位是秒。</p>
<p>　　设置这个TimeOut适用于三种情况：</p>
<p>　　2、如何接收一个get请求的总时间<br />
<span id="more-20"></span><br />
　　接收一个post和put请求的TCP包之间的时间</p>
<p>　　TCP包传输中的响应（ack）时间间隔</p>
<p>　　3、如何使得apache监听在特定的端口</p>
<p>　　修改httpd.conf里面关于Listen的选项，例如：</p>
<p>　　Listen 8000</p>
<p>　　是使apache监听在8000端口</p>
<p>　　而如果要同时指定监听端口和监听地址，可以使用：</p>
<p>　　Listen 192.170.2.1:80<br />
　　Listen 192.170.2.5:8000</p>
<p>　　这样就使得apache同时监听在192.170.2.1的80端口和192.170.2.5的8000端口。</p>
<p>　　当然也可以在httpd.conf里面设置：</p>
<p>　　Port 80</p>
<p>　　这样来实现类似的效果。</p>
<p>　　4、如何设置apache的最大空闲进程数</p>
<p>　　修改httpd.conf，在里面设置：</p>
<p>　　MaxSpareServers n</p>
<p>　　其中n是一个整数。这样当空闲进程超过n的时候，apache主进程会杀掉多余的空闲进程而保持空闲进程在n，节省了系统资源。如果在一个apache非常繁忙的站点调节这个参数才是必要的，但是在任何时候把这个参数调到很大都不是一个好主意。</p>
<p>　　同时也可以设置：</p>
<p>　　MinSpareServers n</p>
<p>　　来限制最少空闲进程数目来加快反应速度。</p>
<p>　　5、apache如何设置启动时的子服务进程个数</p>
<p>　　在httpd.conf里面设置：</p>
<p>　　StartServers 5</p>
<p>　　这样启动apache后就有5个空闲子进程等待接受请求。</p>
<p>　　也可以参考MinSpareServers和MaxSpareServers设置。</p>
<p>6、如何在apache中设置每个连接的最大请求数</p>
<p>　　在httpd.conf里面设置：</p>
<p>　　MaxKeepAliveRequests 100</p>
<p>　　这样就能保证在一个连接中，如果同时请求数达到100就不再响应这个连接的新请求，保证了系统资源不会被某个连接大量占用。但是在实际配置中要求尽量把这个数值调高来获得较高的系统性能。</p>
<p>　　7、如何在apache中设置session的持续时间</p>
<p>　　在apache1.2以上的版本中，可以在httpd.conf里面设置：</p>
<p>　　KeepAlive on<br />
　　KeepAliveTimeout 15</p>
<p>　　这样就能限制每个session的保持时间是15秒。session的使用可以使得很多请求都可以通过同一个tcp连接来发送，节约了网络资源和系统资源。</p>
<p>　　8、如何使得apache对客户端进行域名验证</p>
<p>　　可以在httpd.conf里面设置：</p>
<p>　　HostnameLookups on|off|double</p>
<p>　　如果是使用on，那么只有进行一次反查，如果用double，那么进行反查之后还要进行一次正向解析，只有两次的结果互相符合才行，而off就是不进行域名验证。</p>
<p>　　如果为了安全，建议使用double；为了加快访问速度，建议使用off。</p>
<p>　　9、如何使得apache只监听在特定的ip</p>
<p>　　修改httpd.conf，在里面使用</p>
<p>　　BindAddress 192.168.0.1</p>
<p>　　这样就能使得apache只监听外界对192.168.0.1的http请求。如果使用：</p>
<p>　　BindAddress *</p>
<p>　　就表明apache监听所有网络接口上的http请求。</p>
<p>　　当然用防火墙也可以实现。</p>
<p>10、apache中如何限制http请求的消息主体的大小</p>
<p>　　在httpd.conf里面设置：</p>
<p>　　LimitRequestBody n</p>
<p>　　n是整数，单位是byte。</p>
<p>　　cgi脚本一般把表单里面内容作为消息的主体提交给服务器处理，所以现在消息主体的大小在使用cgi的时候很有用。比如使用cgi来上传文件，如果有设置：</p>
<p>　　LimitRequestBody 102400</p>
<p>　　那么上传文件超过100k的时候就会报错。</p>
<p>　　11、如何修改apache的文档根目录</p>
<p>　　修改httpd.conf里面的DocumentRoot选项到指定的目录，比如：</p>
<p>　　DocumentRoot /www/htdocs</p>
<p>　　这样http://localhost/index.html就是对应/www/htdocs/index.html</p>
<p>　　12、如何修改apache的最大连接数</p>
<p>　　在httpd.conf中设置：</p>
<p>　　MaxClients n</p>
<p>　　n是整数，表示最大连接数，取值范围在1和256之间，如果要让apache支持更多的连接数，那么需要修改源码中的httpd.h文件，把定义的HARD_SERVER_LIMIT值改大然后再编译。</p>
<p>　　13、如何使每个用户有独立的cgi-bin目录</p>
<p>　　有两种可选择的方法：</p>
<p>　　(1)在Apache配置文件里面关于public_html的设置后面加入下面的属性：</p>
<p>　　ScriptAliasMatch ^/~([^/]*)/cgi-bin/(.*) /home/$1/cgi-bin/$2</p>
<p>　　(2)在Apache配置文件里面关于public_html的设置里面加入下面的属性：</p>
<p>　　<directory /home/*/public_html/cgi-bin><br />
　　　　Options ExecCGI<br />
　　　　SetHandler cgi-script<br />
　　</directory></p>
<p>14、如何调整Apache的最大进程数</p>
<p>Apache允许为请求开的最大进程数是256,MaxClients的限制是256.如果用户多了，用户就只能看到Waiting for reply&#8230;.然后等到下一个可用进程的出现。这个最大数，是Apache的程序决定的&#8211;它的NT版可以有1024，但Unix版只有256，你可以在src/include/httpd.h中看到：</p>
<p>#ifndef HARD_SERVER_LIMIT<br />
#ifdef WIN32<br />
#define HARD_SERVER_LIMIT 1024<br />
#else<br />
#define HARD_SERVER_LIMIT 256<br />
#endif<br />
#endif</p>
<p>你可以把它调到1024，然后再编译你的系统。</p>
<p>　　15、如何屏蔽来自某个Internet地址的用户访问Apache服务器</p>
<p>　　可以使用deny和allow来限制访问，比如要禁止202.202.202.xx网络的用户访问：</p>
<p>　　<directory /www/htdocs><br />
　　order deny,allow<br />
　　deny from 202.202.202.0/24<br />
　　</directory></p>
<p>　　16、如何在日志里面记录apache浏览器和引用信息</p>
<p>　　你需要把mod_log_config编译到你的Apache服务器中，然后使用下面类似的配置：</p>
<p>　　CustomLog logs/access_log &#8220;%h %l %u %t &#8220;%r&#8221; %s %b &#8220;%{Referer}i&#8221; &#8220;%{User-Agent}i&#8221;"</p>
<p>　　17、如何修改Apache返回的头部信息</p>
<p>　　问题分析：当客户端连接到Apache服务器的时候，Apache一般会返回服务器版本、非缺省模块等信息，例如：</p>
<p>　　Server: Apache/1.3.26 (Unix) mod_perl/1.26</p>
<p>　　解决：</p>
<p>　　你可以在Apache的配置文件里面作如下设置让它返回的关于服务器的信息减少到最少：</p>
<p>　　ServerTokens Prod</p>
<p>　　注意：</p>
<p>　　这样设置以后Apache还会返回一定的服务器信息，比如：</p>
<p>　　Server: Apache</p>
<p>　　但是这个不会对服务器安全产生太多的影响，因为很多扫描软件是扫描的时候是不顾你服务器返回的头部信息的。你如果想把服务器返回的相关信息变成：</p>
<p>　　Server: It iS a nOnE-aPaCHe Server</p>
<p>　　那么你就要去修改源码了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wangchong.org/other/20.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

