<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="http://feeds.qzone.qq.com/rss.xsl" version="1.0"?>
<rss version="2.0" xmlns:qz="http://qzone.qq.com">
<channel>
<title><![CDATA[z.y.s]]></title>
<description><![CDATA[Ancient Forests - 原始森林]]></description>
<link>http://380881908.qzone.qq.com</link>
<lastBuildDate>Fri, 27 Nov 2009 04:20:47 GMT</lastBuildDate>
<generator>Qzone</generator>
<language>zh-cn</language>
<copyright>Copyright (C), 2005-2008, Tencent Tech. Co., Ltd.</copyright>
<pubDate>Tue, 01 Sep 2009 14:00:24 GMT</pubDate>

<item>
<title><![CDATA[我的DIY机箱侧板散热风扇]]></title>
<link>http://380881908.qzone.qq.com/blog/1251813624</link>
<description><![CDATA[一：发高烧的系统……<br>刚换的 i7 920 + intel DX58SO主板，显然，原本机箱提供的散热能力已经不足以消化i7系统的高热量，<br>cpu，cpu voltage，I/O Hub ，这几个发热高的在系统闲置状态下就达到六七十度！<br> <br><wbr /><a href="http://b24.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d573472211459159509ecd9c4840c727f52f798cc8c592bc9c4ea643f7c8a8f75d98acdbb03e9cd977d0319b25f078d5e0c30c095fcc72ba6528e3d03b881eb4f039a111fcddc4a5a955e1c" target="_blank"><img style="width:600px;height:800px;border:0;" src="http://b24.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d573472211459159509ecd9c4840c727f52f798cc8c592bc9c4ea643f7c8a8f75d98acdbb03e9cd977d0319b25f078d5e0c30c095fcc72ba6528e3d03b881eb4f039a111fcddc4a5a955e1c" /></a><wbr /><br> <br>二：改造密封侧板……<br>TT海啸机箱侧板是密封的，<br><wbr /><a href="http://b24.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d573472211459153bd2caa118962af880ad14bdf396aa9bf845f365830e8149b1fc0f06892ff3d4dcc2c52287e9c0fc186d0604056a60e26f87fceab6ed4538c9b81e9df2f84e210083b7e9" target="_blank"><img style="width:320px;height:240px;border:0;" src="http://b24.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d573472211459153bd2caa118962af880ad14bdf396aa9bf845f365830e8149b1fc0f06892ff3d4dcc2c52287e9c0fc186d0604056a60e26f87fceab6ed4538c9b81e9df2f84e210083b7e9" /></a><wbr /><br>我试过打开侧板，用电风扇对着主板吹，系统温度很高就能降到40~50℃的可接受范围，于是决定改造这块侧板……<br>逛了好久，终于在网上找到一个差不多大的机箱风扇，号称22cm，这玩意电脑城买不到(那里最多到14cm，12cm以下的为主)！<br><wbr /><a href="http://b24.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d5734722114591526f48b19ca7cf18431d88f78ab8b27faf7067b70437212f42a8ced138202de1f20de49e4885e1c2c2de835ba5ff84ac21b146ea60115069ccd8cf299abe6482361078a0c" target="_blank"><img style="width:310px;height:268px;border:0;" src="http://b24.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d5734722114591526f48b19ca7cf18431d88f78ab8b27faf7067b70437212f42a8ced138202de1f20de49e4885e1c2c2de835ba5ff84ac21b146ea60115069ccd8cf299abe6482361078a0c" /></a><wbr /> <br>给侧板开一个直径相当的圆洞，打好４个螺孔，全部的工具为：电钻一套、十字螺丝刀一把、钳子一把、铁锤一个。<br><wbr /><a href="http://b23.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d573472211459157c26057c1cf12fa7f0683a94d6e223edac795f0a896763ce3ea06b992ced924c7d8b853be559aab0b78238f02e9e70e06abbca1023ef3e1df78bcd61d6b9006276c29f18" target="_blank"><img style="width:670px;height:503px;border:0;" src="http://b23.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d573472211459157c26057c1cf12fa7f0683a94d6e223edac795f0a896763ce3ea06b992ced924c7d8b853be559aab0b78238f02e9e70e06abbca1023ef3e1df78bcd61d6b9006276c29f18" /></a><wbr /><br> <br>三：完工效果……<br>目前，系统各发热芯片温度控制在40~52℃范围，可以完全关闭侧板，终于不用再拿电风扇来吹了！<br> <br>◎　装好的风扇<br><wbr /><a href="http://b24.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d57347221145915134db7703f19f8791a37c2d5e2dae166db21ee7eaaaa013543d01b6593c919453c17e7864e7b78279e823744b4fb22bb1f9b522ded4ab02e05546a10e573906db6ccab54" target="_blank"><img style="width:670px;height:503px;border:0;" src="http://b24.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d57347221145915134db7703f19f8791a37c2d5e2dae166db21ee7eaaaa013543d01b6593c919453c17e7864e7b78279e823744b4fb22bb1f9b522ded4ab02e05546a10e573906db6ccab54" /></a><wbr /><br> <br>◎　外面的防尘罩，看上去就象原来就有的，而不是我特意改装的，色调完全融合<br><wbr /><a href="http://b23.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d57347221145915e580f7cf5db211158e802051f7fd7f99543b8f15142ee1610ea7c34819cac89e15ad1a9afb73802b726930a1995be9908efad68944b480c11df51773c2966afab969f937" target="_blank"><img style="width:670px;height:503px;border:0;" src="http://b23.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d57347221145915e580f7cf5db211158e802051f7fd7f99543b8f15142ee1610ea7c34819cac89e15ad1a9afb73802b726930a1995be9908efad68944b480c11df51773c2966afab969f937" /></a><wbr /> <br>◎　整机效果<br><wbr /><a href="http://b24.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d573472211459151894524d0593ac01b39c6489e3fd664240cc27fd548f62afc20c389cb95e034fa36365337c94963412910ca3068d7dd493e645c1a7974706cea045953bd18e85f1e7234c" target="_blank"><img style="width:670px;height:503px;border:0;" src="http://b24.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d573472211459151894524d0593ac01b39c6489e3fd664240cc27fd548f62afc20c389cb95e034fa36365337c94963412910ca3068d7dd493e645c1a7974706cea045953bd18e85f1e7234c" /></a><wbr /> <br>◎　开机运行时，可以看到主板配件发出的蓝光<br>（主要是 I/O Hub 散热小风扇发出的光，那玩意风不大，光照效果倒是不错）<br><wbr /><a href="http://b24.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d573472211459156ecee887b7b6fe527076277d3025d2958862b483e239426c73d30e8146bffda1ca02537fccf7b289d7882bb6935a93c3196a784725a889be6aada12bb8bda9571729c331" target="_blank"><img style="width:670px;height:503px;border:0;" src="http://b24.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d573472211459156ecee887b7b6fe527076277d3025d2958862b483e239426c73d30e8146bffda1ca02537fccf7b289d7882bb6935a93c3196a784725a889be6aada12bb8bda9571729c331" /></a><wbr /><br>8:30完工。<br> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[380881908@qq.com(z.y.s)]]></author>
<comments>http://380881908.qzone.qq.com/blog/1251813624#comment</comments>
<qz:effect>134218241</qz:effect>
<pubDate>Tue, 01 Sep 2009 14:00:24 GMT</pubDate>
<guid>http://380881908.qzone.qq.com/blog/1251813624</guid>
</item>

<item>
<title><![CDATA[全面认识服务器硬件]]></title>
<link>http://380881908.qzone.qq.com/blog/1250840066</link>
<description><![CDATA[文章来源：Pc online 论坛<br>链接地址<br><a href="http://itbbs.pconline.com.cn/network/10475407.html" target="_blank">http://itbbs.pconline.com.cn/network/10475407.html</a><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[380881908@qq.com(z.y.s)]]></author>
<comments>http://380881908.qzone.qq.com/blog/1250840066#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Fri, 21 Aug 2009 07:34:26 GMT</pubDate>
<guid>http://380881908.qzone.qq.com/blog/1250840066</guid>
</item>

<item>
<title><![CDATA[C++中GB2312字符串和UTF-8之间的转换]]></title>
<link>http://380881908.qzone.qq.com/blog/1250605706</link>
<description><![CDATA[<span style="font-size:18px;line-height:1.8em;">C++中GB2312字符串和UTF-8之间的转换</span><wbr /><br><br><span style="font-size:18px;line-height:1.8em;">在编程过程中需要对字符串进行不同的转换，特别是Gb2312和Utf-8直接的转换。在几个开源的魔兽私服中，很多都是老外开发的，而暴雪为了能够兼容世界上的各个字符集也使用了UTF-8。在中国使用VS（VS2005以上版本）开发基本都是使用Gb2312的Unicode字符集，所以当在编程过程中就需要进行字符转换，这样才能兼容游戏，否则就是乱码。而在控制台显示字符串时，真好相反需要将UTF-8的字符串转换成Gb2312才能正常显示。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">为了解决这个问题，本人将其代码贴出来；其实很多地方都可以使用到字符串的编码转换，代码如下：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">//UTF-8到GB2312的转换<br>char* U2G(const char* utf8)<br>{<br>int len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0);<br>wchar_t* wstr = new wchar_t[len+1];<br>memset(wstr, 0, len+1);<br>MultiByteToWideChar(CP_UTF8, 0, utf8, -1, wstr, len);<br>len = WideCharToMultiByte(CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL);<br>char* str = new char[len+1];<br>memset(str, 0, len+1);<br>WideCharToMultiByte(CP_ACP, 0, wstr, -1, str, len, NULL, NULL);<br>if(wstr) delete[ ] wstr;<br>return str;<br>}</span><wbr /><span style="font-size:18px;line-height:1.8em;">//GB2312到UTF-8的转换<br>char* G2U(const char* gb2312)<br>{<br>int len = MultiByteToWideChar(CP_ACP, 0, gb2312, -1, NULL, 0);<br>wchar_t* wstr = new wchar_t[len+1];<br>memset(wstr, 0, len+1);<br>MultiByteToWideChar(CP_ACP, 0, gb2312, -1, wstr, len);<br>len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);<br>char* str = new char[len+1];<br>memset(str, 0, len+1);<br>WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);<br>if(wstr) delete[ ] wstr;<br>return str;<br>}</span><wbr /><span style="font-size:18px;line-height:1.8em;">无论是GB2312到UTF-8的转换，还是UTF-8到GB2312的转换，都需要注意的是在使用字符串后，需要删除字符串指针；这是因为以上两个方法返回的是字符串指针，如果没有删除将会内存泄漏，可别说我没提醒你哦。</span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[380881908@qq.com(z.y.s)]]></author>
<comments>http://380881908.qzone.qq.com/blog/1250605706#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Tue, 18 Aug 2009 14:28:26 GMT</pubDate>
<guid>http://380881908.qzone.qq.com/blog/1250605706</guid>
</item>

<item>
<title><![CDATA[在PHP中执行系统外部命令]]></title>
<link>http://380881908.qzone.qq.com/blog/1250572421</link>
<description><![CDATA[<span style="font-size:13px;line-height:1.8em;">本文转载自  </span><wbr /><a href="http://hi.baidu.com/benaiwq/blog/item/cf376c25d3977a2cd40742dd.html" target="_blank"><span style="font-size:13px;line-height:1.8em;">http://hi.baidu.com/benaiwq/blog/item/cf376c25d3977a2cd40742dd.html</span><wbr /></a><wbr /><br><span style="font-size:13px;line-height:1.8em;">2009-02-19 16:57</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">PHP作为一种服务器端的脚本语言，象编写简单，或者是复杂的动态网页这样的任务，它完全能够胜任。但事情不总是如此，有时为了实现某个功能，必须借助于操作系统的外部程序(或者称之为命令)，这样可以做到事半功倍。</span><wbr /><span style="font-size:18px;line-height:1.8em;">那么，是否可以在PHP脚本中调用外部命令呢?如果能，如何去做呢?有些什么方面的顾虑呢?相信你看了本文后，肯定能够回答这些问题了。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">是否可以?</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">答案是肯定的。PHP和其它的程序设计语言一样，完全可以在程序内调用外部命令，并且是很简单的：只要用一个或几个函数即可。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">前提条件</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">由于PHP基本是用于WEB程序开发的，所以安全性成了人们考虑的一个重要方面。于是PHP的设计者们给PHP加了一个门：安全模式。如果运行在安全模式下，那么PHP脚本中将受到如下四个方面的限制：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">执行外部命令</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">在打开文件时有些限制</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">连接MySQL数据库</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">基于HTTP的认证</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">在安全模式下，只有在特定目录中的外部程序才可以被执行，对其它程序的调用将被拒绝。这个目录可以在php.ini文件中用safe_mode_exec_dir指令，或在编译PHP是加上--with-exec-dir选项来指定，默认是/usr/local/php/bin。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">如果你调用一个应该可以输出结果的外部命令(意思是PHP脚本没有错误)，得到的却是一片空白，那么很可能你的网管已经把PHP运行在安全模式下了。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">如何做?</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">在PHP中调用外部命令，可以用如下三种方法来实现：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1) 用PHP提供的专门函数</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">PHP提供共了3个专门的执行外部命令的函数：system()，exec()，passthru()。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">system()</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">原型：string system (string command [, int return_var])</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">system()函数很其它语言中的差不多，它执行给定的命令，输出和返回结果。第二个参数是可选的，用来得到命令执行后的状态码。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">例子：</span><wbr /><br><br><span style="font-size:18px;line-height:1.8em;">以下为引用的内容：</span><wbr /><span style="font-size:18px;line-height:1.8em;">system(&quot;/usr/local/bin/webalizer/webalizer&quot;);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">?&gt;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">exec()</span><wbr /><br> <br><span style="font-size:18px;line-height:1.8em;">原型：string exec (string command [, string array [, int return_var]])</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">exec()函数与system()类似，也执行给定的命令，但不输出结果，而是返回结果的最后一行。虽然它只返回命令结果的最后一行，但用第二个参数array可以得到完整的结果，方法是把结果逐行追加到array的结尾处。所以如果array不是空的，在调用之前最好用unset()最它清掉。只有指定了第二个参数时，才可以用第三个参数，用来取得命令执行的状态码。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">例子：</span><wbr /><br><br><span style="font-size:18px;line-height:1.8em;">以下为引用的内容：</span><wbr /><span style="font-size:18px;line-height:1.8em;">exec(&quot;/bin/ls -l&quot;);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">exec(&quot;/bin/ls -l&quot;, $res);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">#$res是一个数据，每个元素代表结果的一行</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">exec(&quot;/bin/ls -l&quot;, $res, $rc);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;"></span><wbr /> <br><span style="font-size:18px;line-height:1.8em;">#$rc的值是命令/bin/ls -l的状态码。成功的情况下通常是0</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">以下为引用的内容：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">?&gt;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">passthru()</span><wbr /><br><span style="font-size:18px;line-height:1.8em;"></span><wbr /> <br><span style="font-size:18px;line-height:1.8em;">原型：void passthru (string command [, int return_var])</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">passthru()只调用命令，不返回任何结果，但把命令的运行结果原样地直接输出到标准输出设备上。所以passthru()函数经常用来调用象pbmplus(Unix下的一个处理图片的工具，输出二进制的原始图片的流)这样的程序。同样它也可以得到命令执行的状态码。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">例子：</span><wbr /><br><br><span style="font-size:18px;line-height:1.8em;">以下为引用的内容：</span><wbr /><span style="font-size:18px;line-height:1.8em;">header(&quot;Content-type: image/gif&quot;);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">passthru(&quot;./ppmtogif hunte.ppm&quot;);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">?&gt;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;"></span><wbr /> <br><span style="font-size:18px;line-height:1.8em;">2) 用popen()函数打开进程</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">上面的方法只能简单地执行命令，却不能与命令交互。但有些时候必须向命令输入一些东西，如在增加Linux的系统用户时，要调用su来把当前用户换到root才行，而su命令必须要在命令行上输入root的密码。这种情况下，用上面提到的方法显然是不行的。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">popen()函数打开一个进程管道来执行给定的命令，返回一个文件句柄。既然返回的是一个文件句柄，那么就可以对它读和写了。在PHP3中，对这种句柄只能做单一的操作模式，要么写，要么读;从PHP4开始，可以同时读和写了。除非这个句柄是以一种模式(读或写)打开的，否则必须调用pclose()函数来关闭它。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">例子1：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">以下为引用的内容：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">$fp=popen(&quot;/bin/ls -l&quot;, &quot;r&quot;);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">?&gt;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;"></span><wbr /> <br><span style="font-size:18px;line-height:1.8em;"></span><wbr /> <br><span style="font-size:18px;line-height:1.8em;">例子2(本例来自PHP中国联盟网站</span><wbr /><a href="http://www.phpx.com/show.php?d=col&amp;i=51" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://www.phpx.com/show.php?d=col&amp;i=51</span><wbr /></a><wbr /><span style="font-size:18px;line-height:1.8em;">)：</span><wbr /><br><br><span style="font-size:18px;line-height:1.8em;">/* PHP中如何增加一个系统用户</span><wbr /><span style="font-size:18px;line-height:1.8em;">下面是一段例程，增加一个名字为james的用户,</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">root密码是 verygood。仅供参考</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">以下为引用的内容：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">*/</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">$sucommand = &quot;su --login root --command&quot;;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">$useradd = &quot;useradd &quot;;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">$rootpasswd = &quot;verygood&quot;;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">$user = &quot;james&quot;;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">$user_add = sprintf(&quot;%s \&quot;%s %s\&quot;&quot;,$sucommand,$useradd,$user);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">$fp = @popen($user_add,&quot;w&quot;);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">@fputs($fp,$rootpasswd);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">@pclose($fp);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">?&gt;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;"></span><wbr /> <br><span style="font-size:18px;line-height:1.8em;">3) 用反撇号(`，也就是键盘上ESC键下面的那个，和~在同一个上面)</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">这个方法以前没有归入PHP的文档，是作为一个秘技存在的。方法很简单，用两个反撇号把要执行的命令括起来作为一个表达式，这个表达式的值就是命令执行的结果。如：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">以下为引用的内容：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">$res=`/bin/ls -l`;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">echo ''; </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">'.$res.' </span><wbr /><br><br><span style="font-size:18px;line-height:1.8em;">?&gt;</span><wbr /><span style="font-size:18px;line-height:1.8em;"></span><wbr /> <br><span style="font-size:18px;line-height:1.8em;"></span><wbr /> <br><span style="font-size:18px;line-height:1.8em;">这个脚本的输出就象：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">以下为引用的内容：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">hunte.gif</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">hunte.ppm</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">jpg.htm</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">jpg.jpg</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">passthru.php</span><wbr /><br><span style="font-size:18px;line-height:1.8em;"></span><wbr /> <br><span style="font-size:18px;line-height:1.8em;">要考虑些什么?</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">要考虑两个问题：安全性和超时。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">先看安全性。比如，你有一家小型的网上商店，所以可以出售的产品列表放在一个文件中。你编写了一个有表单的HTML文件，让你的用户输入他们的EMAIL地址，然后把这个产品列表发给他们。假设你没有使用PHP的mail()函数(或者从未听说过)，你就调用Linux/Unix系统的mail程序来发送这个文件。程序就象这样：</span><wbr /><br><br><span style="font-size:18px;line-height:1.8em;">system(&quot;mail $to &lt; products.txt&quot;);</span><wbr /><span style="font-size:18px;line-height:1.8em;">echo &quot;我们的产品目录已经发送到你的信箱：$to&quot;;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">?&gt;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">用这段代码，一般的用户不会产生什么危险，但实际上存在着非常大的安全漏洞。如果有个恶意的用户输入了这样一个EMAIL地址：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">'--bla ; mail </span><wbr />[email=[ft=,4,]someone@domain.com</span><wbr />]someone@domain.com[/email]<span style="font-size:18px;line-height:1.8em;"> &lt; /etc/passwd ;'</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">那么这条命令最终变成：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">'mail --bla ; mail </span><wbr />[email=[ft=,4,]someone@domain.com</span><wbr />]someone@domain.com[/email]<span style="font-size:18px;line-height:1.8em;"> &lt; /etc/passwd ; &lt; products.txt'</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">我相信，无论哪个网络管理人员见到这样的命令，都会吓出一身冷汗来。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">幸好，PHP为我们提供了两个函数：EscapeShellCmd()和EscapeShellArg()。函数EscapeShellCmd把一个字符串中所有可能瞒过Shell而去执行另外一个命令的字符转义。这些字符在Shell中是有特殊含义的，象分号()，重定向(&gt;)和从文件读入(&lt;)等。函数EscapeShellArg是用来处理命令的参数的。它在给定的字符串两边加上单引号，并把字符串中的单引号转义，这样这个字符串就可以安全地作为命令的参数。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">再来看看超时问题。如果要执行的命令要花费很长的时间，那么应该把这个命令放到系统的后台去运行。但在默认情况下，象system()等函数要等到这个命令运行完才返回(实际上是要等命令的输出结果)，这肯定会引起PHP脚本的超时。解决的办法是把命令的输出重定向到另外一个文件或流中，如：</span><wbr /><br><br><span style="font-size:18px;line-height:1.8em;">以下为引用的内容：</span><wbr /><span style="font-size:18px;line-height:1.8em;">system(&quot;/usr/local/bin/order_proc &gt; /tmp/null &amp;&quot;);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">?&gt;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;"></span><wbr /> <br><span style="font-size:18px;line-height:1.8em;">上面的方法只能简单地执行命令，却不能与命令交互。但有些时候必须向命令输入一些东西，如在增加Linux的系统用户时，要调用su来把当前用户换到root才行，而su命令必须要在命令行上输入root的密码。这种情况下，用上面提到的方法显然是不行的。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">popen()函数打开一个进程管道来执行给定的命令，返回一个文件句柄。既然返回的是一个文件句柄，那么就可以对它读和写了。在PHP3中，对这种句柄只能做单一的操作模式，要么写，要么读;从PHP4开始，可以同时读和写了。除非这个句柄是以一种模式(读或写)打开的，否则必须调用pclose()函数来关闭它。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">例子1：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">以下为引用的内容：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">$fp=popen(&quot;/bin/ls -l&quot;, &quot;r&quot;);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">?&gt;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;"></span><wbr /> <br><span style="font-size:18px;line-height:1.8em;"></span><wbr /> <br><span style="font-size:18px;line-height:1.8em;">例子2(本例来自PHP中国联盟网站</span><wbr /><a href="http://www.phpx.com/show.php?d=col&amp;i=51" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://www.phpx.com/show.php?d=col&amp;i=51</span><wbr /></a><wbr /><span style="font-size:18px;line-height:1.8em;">)：</span><wbr /><br><br><span style="font-size:18px;line-height:1.8em;">/* PHP中如何增加一个系统用户</span><wbr /><span style="font-size:18px;line-height:1.8em;">下面是一段例程，增加一个名字为james的用户,</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">root密码是 verygood。仅供参考</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">以下为引用的内容：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">*/</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">$sucommand = &quot;su --login root --command&quot;;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">$useradd = &quot;useradd &quot;;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">$rootpasswd = &quot;verygood&quot;;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">$user = &quot;james&quot;;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">$user_add = sprintf(&quot;%s \&quot;%s %s\&quot;&quot;,$sucommand,$useradd,$user);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">$fp = @popen($user_add,&quot;w&quot;);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">@fputs($fp,$rootpasswd);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">@pclose($fp);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">?&gt;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;"></span><wbr /> <br><span style="font-size:18px;line-height:1.8em;">3) 用反撇号(`，也就是键盘上ESC键下面的那个，和~在同一个上面)</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">这个方法以前没有归入PHP的文档，是作为一个秘技存在的。方法很简单，用两个反撇号把要执行的命令括起来作为一个表达式，这个表达式的值就是命令执行的结果。如：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">以下为引用的内容：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">$res=`/bin/ls -l`;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">echo ''; </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">'.$res.' </span><wbr /><br><br><span style="font-size:18px;line-height:1.8em;">?&gt;</span><wbr /><span style="font-size:18px;line-height:1.8em;"></span><wbr /> <br><span style="font-size:18px;line-height:1.8em;"></span><wbr /> <br><span style="font-size:18px;line-height:1.8em;">这个脚本的输出就象：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">以下为引用的内容：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">hunte.gif</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">hunte.ppm</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">jpg.htm</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">jpg.jpg</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">passthru.php</span><wbr /><br><span style="font-size:18px;line-height:1.8em;"></span><wbr /> <br><span style="font-size:18px;line-height:1.8em;">要考虑些什么?</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">要考虑两个问题：安全性和超时。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">先看安全性。比如，你有一家小型的网上商店，所以可以出售的产品列表放在一个文件中。你编写了一个有表单的HTML文件，让你的用户输入他们的EMAIL地址，然后把这个产品列表发给他们。假设你没有使用PHP的mail()函数(或者从未听说过)，你就调用Linux/Unix系统的mail程序来发送这个文件。程序就象这样：</span><wbr /><br><br><span style="font-size:18px;line-height:1.8em;">system(&quot;mail $to &lt; products.txt&quot;);</span><wbr /><span style="font-size:18px;line-height:1.8em;">echo &quot;我们的产品目录已经发送到你的信箱：$to&quot;;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">?&gt;</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">用这段代码，一般的用户不会产生什么危险，但实际上存在着非常大的安全漏洞。如果有个恶意的用户输入了这样一个EMAIL地址：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">'--bla ; mail </span><wbr />[email=[ft=,4,]someone@domain.com</span><wbr />]someone@domain.com[/email]<span style="font-size:18px;line-height:1.8em;"> &lt; /etc/passwd ;'</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">那么这条命令最终变成：</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">'mail --bla ; mail </span><wbr />[email=[ft=,4,]someone@domain.com</span><wbr />]someone@domain.com[/email]<span style="font-size:18px;line-height:1.8em;"> &lt; /etc/passwd ; &lt; products.txt'</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">我相信，无论哪个网络管理人员见到这样的命令，都会吓出一身冷汗来。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">幸好，PHP为我们提供了两个函数：EscapeShellCmd()和EscapeShellArg()。函数EscapeShellCmd把一个字符串中所有可能瞒过Shell而去执行另外一个命令的字符转义。这些字符在Shell中是有特殊含义的，象分号()，重定向(&gt;)和从文件读入(&lt;)等。函数EscapeShellArg是用来处理命令的参数的。它在给定的字符串两边加上单引号，并把字符串中的单引号转义，这样这个字符串就可以安全地作为命令的参数。</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">再来看看超时问题。如果要执行的命令要花费很长的时间，那么应该把这个命令放到系统的后台去运行。但在默认情况下，象system()等函数要等到这个命令运行完才返回(实际上是要等命令的输出结果)，这肯定会引起PHP脚本的超时。解决的办法是把命令的输出重定向到另外一个文件或流中，如：</span><wbr /><br><br><span style="font-size:18px;line-height:1.8em;">以下为引用的内容：</span><wbr /><span style="font-size:18px;line-height:1.8em;">system(&quot;/usr/local/bin/order_proc &gt; /tmp/null &amp;&quot;);</span><wbr /><br><span style="font-size:18px;line-height:1.8em;">?&gt;</span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[SERVER]]></category>
<author><![CDATA[380881908@qq.com(z.y.s)]]></author>
<comments>http://380881908.qzone.qq.com/blog/1250572421#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Tue, 18 Aug 2009 05:13:41 GMT</pubDate>
<guid>http://380881908.qzone.qq.com/blog/1250572421</guid>
</item>

<item>
<title><![CDATA[新电源vs老式主板-24Pin -&gt; 20+4Pin]]></title>
<link>http://380881908.qzone.qq.com/blog/1249871022</link>
<description><![CDATA[新电源的主板和CPU供电接口为：24Pin + 8Pin（ATX_12V_2X）；<br>旧板（如GA-8IP900L）的主板和CPU供电接口为：20Pin + 4Pin（ATX_12V）；<br>1. 通常，电源的24Pin可以拆解为20+4Pin（注意，这里的4Pin和CPU供电的4Ppin是不一样的），用其中的20Pin，4Pin空着。<br>2. 将8PIn转为4Pin使用（针位排线如下图所示），取其中的3,4,7,8Pin作为旧板CPU供电的4Pin：<br><wbr /><a href="http://b10.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d57347221145915ef7fb11b46a6df81429982585dddd7d8b2be94cd58975f14385820adabb518a0257d98119149ab7c829f4953a9ec945c55bd233e198b3782ade07cf53e5c1b20752ff856" target="_blank"><img style="width:640px;height:480px;border:0;" src="http://b10.photo.store.qq.com/http_imgload.cgi?/rurl4_b=53ccf3dbc0abe2cb5d57347221145915ef7fb11b46a6df81429982585dddd7d8b2be94cd58975f14385820adabb518a0257d98119149ab7c829f4953a9ec945c55bd233e198b3782ade07cf53e5c1b20752ff856" /></a><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[380881908@qq.com(z.y.s)]]></author>
<comments>http://380881908.qzone.qq.com/blog/1249871022#comment</comments>
<qz:effect>134218241</qz:effect>
<pubDate>Mon, 10 Aug 2009 02:23:42 GMT</pubDate>
<guid>http://380881908.qzone.qq.com/blog/1249871022</guid>
</item>

<item>
<title><![CDATA[MYSQL5重置root密码]]></title>
<link>http://380881908.qzone.qq.com/blog/1249001726</link>
<description><![CDATA[MYSQL5重置root密码<br><br>MYSQL数据库版本：5.0.27<br>（1）以 系统root权限登陆<br>（2）停止MYSQL服务器：<br>          mysql.server stop<br>（3）跳过授权表执行MYSQL服务器：<br>         mysqld_safe --skip-grant-tables --skip-networking &amp;<br>        (注：参数--skip-grant-tables为跳过授权表；--skip-networking为不监听TCP/IP连接)<br>（4）执行MYSQL客户端：<br>         mysql<br>（5）使用mysql数据库<br>         use mysql;<br>（6）更新root密码<br>         update user set password=password('新密码') where user='root';<br>（7）关闭mysql服务器，用正常方试起动<br>本文非原创，也不是转贴，一部分是在书上看到的，一部分是在网上找的。如果您用的不是我这个版本，可以在mysql的安装目录中找一个适合您当前版本的mysqld_safe，后面加上--skip-grant-tables来跳过授权表，我书上所用的mysqld_safe版本为 &quot;safe_mysqld&quot;(其实写到这里我好像想起来了，在哪看到过说5.0以后把sqfe_mysqld改成mysqld_safe了，这害得我在网上找了半天) <!--v:3.2--> ]]></description>
<category><![CDATA[SERVER]]></category>
<author><![CDATA[380881908@qq.com(z.y.s)]]></author>
<comments>http://380881908.qzone.qq.com/blog/1249001726#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Fri, 31 Jul 2009 00:55:26 GMT</pubDate>
<guid>http://380881908.qzone.qq.com/blog/1249001726</guid>
</item>

<item>
<title><![CDATA[PHPMYADMIN简明安装教程]]></title>
<link>http://380881908.qzone.qq.com/blog/1247813226</link>
<description><![CDATA[PHPMYADMIN简明安装教程 <br><span style="font-size:24px;line-height:1.8em;"><span style="font-size:18px;line-height:1.8em;">简单的说，phpmyadmin就是一种mysql的管理工具，安装该工具后，即可以通过web形式直接管理mysql数据，而不需要通过执行系统命令来管理，非常适合对数据库操作命令不熟悉的数据库管理者，下面我就说下怎么安装该工具：</span><wbr /> <br></span><wbr /><span style="line-height:1.8em;"><br><span style="font-size:24px;line-height:1.8em;">1.先到网上下载phpmyadmin，再解压到可以访问的web目录下（如果是虚拟空间，可以解压后通过ftp等上传到web目录下），当然您可以修改解压后该文件的名称。 <br><br>2.配置config文件 <br>  打开libraries下的config.default.php文件，依次找到下面各项，按照说明配置即可： <br>A.访问网址 </span><wbr /><span style="font-size:24px;line-height:1.8em;">$cfg['PmaAbsoluteUri'] = '';这里填写phpmyadmin的访问网址</span><wbr /> <br></span><wbr /><span style="line-height:1.8em;"><br><span style="font-size:24px;line-height:1.8em;">B.mysql主机信息 </span><wbr /><span style="font-size:24px;line-height:1.8em;">$cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname or IP address <br>填写localhost或mysql所在服务器的ip地址，如果mysql和该phpmyadmin在同一服务器，则按默认localhost <br>$cfg['Servers'][$i]['port'] = ''; // MySQL port - leave blank for default port <br>mysql端口，如果是默认3306，保留为空即可</span><wbr /> <br></span><wbr /><span style="line-height:1.8em;"><br><span style="font-size:24px;line-height:1.8em;">C.mysql用户名和密码 </span><wbr /><span style="font-size:24px;line-height:1.8em;">$cfg['Servers'][$i]['user'] = 'root'; // MySQL user 访问phpmyadmin使用的mysql用户名 <br>fg['Servers'][$i]['password'] = ''; // MySQL password (only needed对应上述mysql用户名的密码</span><wbr /> <br><span style="font-size:24px;line-height:1.8em;">D.认证方法 </span><wbr /><span style="font-size:24px;line-height:1.8em;">$cfg['Servers'][$i]['auth_type'] = 'cookie';</span><wbr /> <br><span style="font-size:24px;line-height:1.8em;">在此有四种模式可供选择，cookie，http，HTTP，config <br>   config方式即输入phpmyadmin的访问网址即可直接进入，无需输入用户名和密码，是不安全的，不推荐使用。 <br>   当该项设置为cookie，http或HTTP时，登录phpmyadmin需要数据用户名和密码进行验证，,具体如下： <br>   PHP安装模式为Apache，可以使用http和cookie； <br>   PHP安装模式为CGI，可以使用cookie <br><br>E.短语密码(blowfish_secret)的设置 </span><wbr /><span style="font-size:24px;line-height:1.8em;">$cfg['blowfish_secret'] = '';</span><wbr /> <br><span style="font-size:24px;line-height:1.8em;">如果认证方法设置为cookie，就需要设置短语密码，置于设置为什么密码，由您自己决定[img]images/smilies/default/lol.gif[/img]  ，但是不能留空，否则会在登录phpmyadmin时提示错误 <br>  好了，到此为止，您已经成功安装了phpmyadmin，简单吧[img]images/smilies/default/smile.gif[/img] ，赶快登录体验下吧 <br><br>说明： <br>该文档说明的只是安装phpmyadmin的基本配置，关于config.default.php文件中各个配置参数的详细说明可以参考：</span><wbr /><a href="http://www.discuz.net/viewthread.php?tid=50789&amp;highlight=phpmyadmin" target="_blank"><span style="color:#000000;font-size:24px;line-height:1.8em;">http://www.discuz.net/viewthread.php?tid=50789&amp;highlight=phpmyadmin</span><wbr /></a><wbr /></span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[SERVER]]></category>
<author><![CDATA[380881908@qq.com(z.y.s)]]></author>
<comments>http://380881908.qzone.qq.com/blog/1247813226#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Fri, 17 Jul 2009 06:47:06 GMT</pubDate>
<guid>http://380881908.qzone.qq.com/blog/1247813226</guid>
</item>

<item>
<title><![CDATA[中国互联网络信息中心]]></title>
<link>http://380881908.qzone.qq.com/blog/1247468092</link>
<description><![CDATA[<span style="text-decoration:underline;"><wbr /><span style="color:#810081;line-height:1.8em;"><a href="http://research.cnnic.cn/" target="_blank">http://research.cnnic.cn/</a><wbr /></span><wbr /></span><wbr /><br><span style="text-decoration:underline;"><wbr /></span><wbr />权威的互联网咨讯机构,最新的基础数据 <!--v:3.2--> ]]></description>
<category><![CDATA[SERVER]]></category>
<author><![CDATA[380881908@qq.com(z.y.s)]]></author>
<comments>http://380881908.qzone.qq.com/blog/1247468092#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Mon, 13 Jul 2009 06:54:52 GMT</pubDate>
<guid>http://380881908.qzone.qq.com/blog/1247468092</guid>
</item>

<item>
<title><![CDATA[php开源代码站]]></title>
<link>http://380881908.qzone.qq.com/blog/1247040775</link>
<description><![CDATA[php开源代码 <br><a href="http://www.osphp.com.cn/index.php" target="_blank">http://www.osphp.com.cn/index.php</a><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[380881908@qq.com(z.y.s)]]></author>
<comments>http://380881908.qzone.qq.com/blog/1247040775#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Wed, 08 Jul 2009 08:12:55 GMT</pubDate>
<guid>http://380881908.qzone.qq.com/blog/1247040775</guid>
</item>

<item>
<title><![CDATA[网站的起始页的设置]]></title>
<link>http://380881908.qzone.qq.com/blog/1246936531</link>
<description><![CDATA[# DirectoryIndex: sets the file that Apache will serve if a directory <br># is requested. <br># <br>&lt;IfModule dir_module&gt; <br>    <span style="color:#ff0000;line-height:1.8em;"><span style="font-weight:bold"><wbr />DirectoryIndex index.html <br></span><wbr /></span><wbr />&lt;/IfModule&gt; <br><br>变更红色这一行为所需要起始页文件即可从左到右以空格分开,优先顺序为从左到右.写法如下: <br><span style="font-weight:bold"><wbr /><span style="color:#ff0000;line-height:1.8em;">DirectoryIndex index.html </span><wbr /><span style="color:#ff0000;line-height:1.8em;">test.php index.php</span><wbr /></span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[380881908@qq.com(z.y.s)]]></author>
<comments>http://380881908.qzone.qq.com/blog/1246936531#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Tue, 07 Jul 2009 03:15:31 GMT</pubDate>
<guid>http://380881908.qzone.qq.com/blog/1246936531</guid>
</item>

</channel>
</rss>

