<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:gAcl="http://schemas.google.com/acl/2007" xmlns:sites="http://schemas.google.com/sites/2008" xmlns:gs="http://schemas.google.com/spreadsheets/2006" xmlns:dc="http://purl.org/dc/terms" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0"><id>http://sites.google.com/feeds/content/hetao.name/hetao</id><updated>2010-07-29T20:22:28.591Z</updated><title>Posts of 技术文章</title><link rel="next" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao?start-index=26&amp;parent=1926919826722808076&amp;kind=announcement" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao" /><link rel="http://schemas.google.com/g/2005#post" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao" /><link rel="http://schemas.google.com/g/2005#batch" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/batch" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao?parent=1926919826722808076&amp;kind=announcement" /><generator version="1" uri="http://sites.google.com">Google Sites</generator><openSearch:startIndex>1</openSearch:startIndex><entry gd:etag="&quot;YD0peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/4342924278269783770</id><published>2009-09-28T08:58:03.411Z</published><updated>2009-09-28T09:00:13.816Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-28T09:00:13.792Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>jquery 1.3.2</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">jQuery 是一个JavaScript 库，它有助于简化 JavaScript™ 以及 Asynchronous JavaScript +
XML (Ajax) 编程。<br />与类似的 JavaScript 库不同，jQuery 具有独特的基本原理，可以简洁地表示常见的复杂代码。<br />学习
jQuery 基本原理，探索其特性和功能，执行一些常见的 Ajax 任务并掌握如何使用插件扩展 jQuery。<br /><br /><a href="http://jquery.com/" target="_blank" rel="nofollow">http://jquery.com/</a><br /><br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/jquery132" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/4342924278269783770" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/4342924278269783770" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/4342924278269783770" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>jquery132</sites:pageName><sites:revision>1</sites:revision></entry><entry gd:etag="&quot;YD0peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/5021977551317230456</id><published>2009-09-03T02:18:42.362Z</published><updated>2009-09-03T02:20:35.088Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-03T02:20:35.070Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>查看网页元素简单工具</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">查看网页元素简单工具<br /><br />1.打开任意网站<br />2.在地址栏里拷贝这代码并回车<br />3.点网页里的各元素<br /><br />javascript:function%20loadScript(scriptURL)%20{%20var%20scriptElem%20=%20document.createElement('SCRIPT');%20scriptElem.setAttribute('language',%20'JavaScript');%20scriptElem.setAttribute('src',%20scriptURL);%20document.body.appendChild(scriptElem);}loadScript('http://westciv.com/xray/thexray.js');<br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/page-3" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/5021977551317230456" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/5021977551317230456" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/5021977551317230456" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>page-3</sites:pageName><sites:revision>1</sites:revision></entry><entry gd:etag="&quot;YD0peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/353354565333699021</id><published>2009-08-27T05:20:49.115Z</published><updated>2009-08-27T05:22:23.189Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-27T05:22:23.178Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>mysu.c</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr"><div class="sites-embed-align-left-wrapping-off"><div class="sites-embed-border-on sites-embed sites-embed-full-width" style="width:100%;"><h4 class="sites-embed-title">mysu.c</h4><div class="sites-embed-content sites-embed-type-text"><div class="sites-embed-content-textbox"><div dir="ltr">#include&lt;stdio.h&gt;<br />int main(){<br />                setuid(0);<br />                setsid(0);<br />                system("bash");<br />                return 0;<br />}<br /></div></div></div></div></div><br />执行如下命令：<br />1. gcc -o mysu mysu.c<br />2. chown root:root mysu<br />3. chmod 7777 mysu<br />以后就不用在输入root密码了，不过一般情况下请不要用这种不安全的方式。<br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/mysuc" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/353354565333699021" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/353354565333699021" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/353354565333699021" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>mysuc</sites:pageName><sites:revision>1</sites:revision></entry><entry gd:etag="&quot;YD4peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/1541689550964991219</id><published>2009-08-24T07:34:13.329Z</published><updated>2009-08-24T07:35:48.487Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-24T07:35:48.486Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>Xdebug教程之WinCacheGrind</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">有时候代码没有明显的编写错误，没有显示任何错误信息（如error、warning、notice等），但是这不表明代码就是正确无误的。有时候可能某
段代码执行时间过长，占用内存过多以致于影响整个系统的效率，我们没有办法直接看出来是哪部份代码出了问题。这时候我们希望把代码的每个阶段的运行情况都
监控起来，写到日志文件中去，运行一段时间后再进行分析，找到问题所在。<br />
<br />
回忆一下，之前我们编辑php.ini文件<br />
加入<div><code>[Xdebug]<br />
xdebug.profiler_enable=on<br />
xdebug.trace_output_dir="I:\Projects\xdebug"<br />
xdebug.profiler_output_dir="I:\Projects\xdebug" </code><br />
</div>这几行，目的就在于把执行情况的分析文件写入到”I:\Projects\xdebug”目录中去（你可以替换成任何你想设定的目录）。如果
你执行某段程序后，再打开相应的目录，可以发现生成了一堆文件，例如cachegrind.out.1169585776这种格式命名的文件。这些就是
Xdebug生成的分析文件。用编辑器打开你可以看到很多程序运行的相关细节信息，不过很显然这样看太累了，我们需要用图形化的软件来查看。<br />
<br />
<b>WinCacheGrind下载</b><br />
在Windows平台下，可以用WinCacheGrind(wincachegrind.souceforge.net)这个软件来打开这些文件。可以直观漂亮地显示其中内容：<br />
<img src="http://www.phpq.net/bbs/attachment.php?aid=11" /><br />
哇，非常漂亮，我们很直观地看到index.php中我们调用了一个函数testXdebug()，testXdebug()中又调用了requireFile()函数。这样我们就可以非常方便地查看整个脚本的程序结构。<br />
另外，我们还可以看到每个函数被调用的次数及执行所花费的时间！这对于测试程序性能非常有用。<br />
<img src="http://www.phpq.net/bbs/attachment.php?aid=12" /><br />
好了，这么一个简单的程序不太能显示出Xdebug+WinCacheGrind的强大，我给出一个稍大点的例子（一个基于Zend Framework的CMS的index.php）：<br />
<img src="http://www.phpq.net/bbs/attachment.php?aid=13" /><br />
从上图可以看到：整个程序的结构，每个函数被调用的次数，执行时间都一目了然。<br />
<img src="http://www.phpq.net/bbs/attachment.php?aid=14" /><br />
<b>WinCacheGrind小结</b>：<br />
Xdebug提供了各种自带的函数，并对已有的某些PHP函数进行覆写，可以方便地用于调试排错；Xdebug还可以跟踪程序的运行，通过对日志文件的分析，我们可以迅速找到程序运行的瓶颈所在，提高程序效率，从而提高整个系统的性能。<br /><br /><br />内容来自：http://www.phpq.net/tutorial/xdebug-wincachegrind.html<br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/page-2" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/1541689550964991219" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1541689550964991219" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1541689550964991219" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>page-2</sites:pageName><sites:revision>2</sites:revision></entry><entry gd:etag="&quot;YD4peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/8602418347867570433</id><published>2009-08-24T07:26:22.825Z</published><updated>2009-08-24T07:33:41.471Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-24T07:33:41.470Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>Xdebug教程（安装和调试）</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr"><div>
	<div><b>一、安装</b><br /><br />使用Xdebug调试和优化PHP程序系列教程之Xdebug安装，详细介绍了什么是Xdebug，为什么要用Xdebug，以及如何安装Xdebug。<br /><br /></div>
		<b>为什么需要Xdebug</b><br />
很多PHP程序员调试使用echo、print_r()、var_dump()、printf()等，其实对于有较丰富开发经验的程序员来说这些也已经足
够了，他们往往可以在程序执行的过程中，通过输出特定变量的值可以判断程序执行是否正确，甚至效率高低也可以看出来（当然可能还需要使用一些时间函数）。
那么我们为什么还需要一个专门的调试程序来监控我们的程序运行呢？ 这个问题的答案不妨留到后面来揭晓。<br />
 <br />
<b>什么是Xdebug</b><br />
Xdebug是一个开放源代码的PHP程序调试器(即一个Debug工具)，可以用来跟踪，调试和分析PHP程序的运行状况。Xdebug现在的最新版本是xdebug 2.0.0beta6，支持PHP4/PHP5。<br />
 <br />
如何<b>安装Xdebug</b><br />
以PHP5.1.4，Windows平台为例（其它PHP版本，其它平台请参看官网文档）：<br />
1． 登录<a href="http://www.xdebug.org/" rel="nofollow" target="_blank">www.xdebug.org</a>，在首页右侧有一个Windows modules，选择其中的PHP5.1.2+，下载php_xdebug-5.1.2-2.0.0beta6.dll文件； <br />
2． 将下载的php_xdebug-5.1.2-2.0.0beta6.dll放到C:\php5\ext目录，重命名为php_xdebug.dll；<br />
3． 编辑php.ini，加入下面几行：<div><code>extension=php_xdebug.dll<br />
[Xdebug]<br />
xdebug.profiler_enable=on<br />
xdebug.trace_output_dir="I:\Projects\xdebug"<br />
xdebug.profiler_output_dir="I:\Projects\xdebug" </code><br />
</div>后面的目录“I:\Projects\xdebug”为你想要放置Xdebug输出的数据文件的目录，可自由设置。<br />
4． 重启Apache；<br />
5． 写一个test.php，内容为&lt;?php phpinfo(); ?&gt;，如果输出的内容中有看到xdebug，说明安装配置成功。<br />
<img src="http://www.phpq.net/bbs/attachment.php?aid=6" /><br /><br /><br /><b>二、调试</b><br /><br /><b>Xdebug使用</b>之开始调试：<br />
<br />
我们先写一个可以导致执行出错的程序，例如尝试包含一个不存在的文件。<br />
testXdebug.php<div><code>&lt;?php<br />
require_once(‘abc.php’);<br />
?&gt;</code><br />
</div>然后通过浏览器访问，我们惊奇地发现，出错信息变成了彩色的了：<br />
<img src="http://www.phpq.net/bbs/attachment.php?aid=7" /><br />
<br />
<br />
<br />
不过除了样式改变，和我们平时打印的出错信息内容没什么不同，意义不大。好，我们继续改写程序：<br />
testXdebug2.php<div><code>&lt;?php<br />
testXdebug();<br />
function testXdebug() {<br />
<br />
       require_once('abc.php');<br />
<br />
}<br />
?&gt;</code><br />
</div>输出信息：<br />
<img src="http://www.phpq.net/bbs/attachment.php?aid=8" /><br />
<br />
发现了什么？　Xdebug跟踪代码的执行，找到了出错的函数testXdebug()。<br />
<br />
我们把代码再写得复杂一些：　<br />
testXdebug3.php<div><code>&lt;?php<br />
<br />
testXdebug();<br />
<br />
function testXdebug() {<br />
<br />
       requireFile();     <br />
<br />
}<br />
function requireFile() {<br />
<br />
       require_once('abc.php');<br />
<br />
}<br />
?&gt;</code><br />
</div>输出信息：<br />
<img src="http://www.phpq.net/bbs/attachment.php?aid=9" /><br />
<br />
呵呵，也就是说Xdebug具有类似于Java的Exception的“跟踪回溯”的功能，可以根据程序的执行一步步跟踪到出错的具体位置，哪怕程序中的调用很复杂，我们也可以通过这个功能来理清代码关系，迅速定位，快速排错。	<br /><br /><br />内容来自：http://www.phpq.net/tutorial/xdebug.html<br /><br />	</div></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/page" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/8602418347867570433" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/8602418347867570433" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/8602418347867570433" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>page</sites:pageName><sites:revision>2</sites:revision></entry><entry gd:etag="&quot;YD0peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/5527133414682482816</id><published>2009-08-24T07:31:04.824Z</published><updated>2009-08-24T07:33:08.374Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-24T07:33:08.360Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>Xdebug教程（配置和调试）</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr"><strong>一、Xdebug配置</strong><br />
<br />
第一部分：<strong>安装</strong><br />
预编译模块<br />
安装预编译模块是很容易的。只需要将它们放到一个目录中，并将下面的内容添加到php.ini中：（不要忘记更改路径和文件名为你自己的值，并确信你使用的是完整路）<br />
zend_extension_ts = "c:/php/modules/php_xdebug.dll"<br />
<br />
第二部分：<strong>基本特征</strong>:<br />
相关参数设置<br />
xdebug.default_enable<br />
类型：布尔型 默认值：On<br />
如果这项设置为On，堆栈跟踪将被默认的显示在错误事件中。你可以通过在代码中使用xdebug_disable()来禁止堆叠跟踪的显示。因为这是xdebug基本功能之一，将这项参数设置为On是比较明智的。<br />
<br />
xdebug.max_nesting_level<br />
类型：整型 默认值：100<br />
The value of this setting is the maximum level of nested functions that are allowed before the script will be aborted.<br />
限制无限递归的访问深度。这项参数设置的值是脚本失败前所允许的嵌套程序的最大访问深度。<br />
<br />
第三部分：<strong>堆栈跟踪</strong>:<br />
相关参数设置<br />
xdebug.dump_globals<br />
类型：布尔型 默认值：1<br />
限制是否显示被xdebug.dump.*设置定义的超全局变量的值<br />
例如，xdebug.dump.SERVER = REQUEST_METHOD,REQUEST_URI,HTTP_USER_AGENT 将打印
PHP 超全局变量 $_SERVER['REQUEST_METHOD']、$_SERVER['REQUEST_URI'] 和
$_SERVER['HTTP_USER_AGENT']。<br />
<br />
xdebug.dump_once<br />
类型：布尔型 默认值：1<br />
限制是否超全局变量的值应该转储在所有出错环境(设置为Off时)或仅仅在开始的地方(设置为On时)<br />
<br />
xdebug.dump_undefined<br />
类型：布尔型 默认值：0<br />
如果你想从超全局变量中转储未定义的值，你应该把这个参数设置成On，否则就设置成Off<br />
<br />
xdebug.show_exception_trace<br />
类型：整型 默认值：0<br />
当这个参数被设置为1时，即使捕捉到异常，xdebug仍将强制执行异常跟踪当一个异常出现时。<br />
<br />
xdebug.show_local_vars<br />
类型：整型 默认值：0<br />
当这个参数被设置为不等于0时，xdebug在错环境中所产生的堆栈转储还将显示所有局部变量，包括尚未初始化的变量在最上面。要注意的是这将产生大量的信息，也因此默认情况下是关闭的。<br />
<br />
第四部分：<strong>分析PHP脚本</strong><br />
相关参数设置<br />
xdebug.profiler_append<br />
类型：整型 默认值：0<br />
当这个参数被设置为1时，文件将不会被追加当一个新的需求到一个相同的文件时(依靠xdebug.profiler_output_name的设置)。相反的设置的话，文件将被附加成一个新文件。<br />
<br />
xdebug.profiler_enable<br />
类型：整型 默认值：0<br />
开放xdebug文件的权限，就是在文件输出目录中创建文件。那些文件可以通过KCacheGrind来阅读来展现你的数据。这个设置不能通过在你的脚本中调用ini_set()来设置。<br />
<br />
xdebug.profiler_output_dir<br />
类型：字符串 默认值：/tmp<br />
这个文件是profiler文件输出写入的，确信PHP用户对这个目录有写入的权限。这个设置不能通过在你的脚本中调用ini_set()来设置。<br />
<br />
xdebug.profiler_output_name<br />
类型：字符串 默认值：cachegrind.out%p<br />
这个设置决定了转储跟踪写入的文件的名称。<br />
<br />
第五部分：<strong>远程Debug</strong><br />
相关参数设置<br />
xdebug.remote_autostart<br />
类型：布尔型 默认值：0<br />
一般来说，你需要使用明确的HTTP GET/POST变量来开启远程debug。而当这个参数设置为On，xdebug将经常试图去开启一个远程debug session并试图去连接客户端，即使GET/POST/COOKIE变量不是当前的。<br />
<br />
xdebug.remote_enable<br />
类型：布尔型 默认值：0<br />
这个开关控制xdebug是否应该试着去连接一个按照xdebug.remote_host和xdebug.remote_port来设置监听主机和端口的debug客户端。<br />
<br />
xdebug.remote_host<br />
类型：字符串 默认值：localhost<br />
选择debug客户端正在运行的主机，你不仅可以使用主机名还可以使用IP地址<br />
<br />
xdebug.remote_port<br />
类型：整型 默认值：9000<br />
这个端口是xdebug试着去连接远程主机的。9000是一般客户端和被绑定的debug客户端默认的端口。许多客户端都使用这个端口数字，最好不要去修改这个设置。<br />
<br />
注意：所有以上参数修改后，要重启Apache才能生效！<br /><br />二、调试<br /><br />其实PHP函数debug_backtrace()也有类似的功能，但是要注意debug_backtrace()函数只在PHP4.3.0之后版本及<br />
PHP5中才生效。这个函数是PHP开发团队在PHP5中新增的函数，然后又反向移植到PHP4.3中。<br />
 <br />
<strong>Xdebug使调试信息更加美观 </strong><br />
Xdebug扩展加载后，Xdebug会对原有的某些PHP函数进行覆写，以便好更好地进行Debug。比如var_dump()函数，我们知道通常我们
需要在函数前后加上”&lt;pre&gt;…&lt;/pre&gt;”才能够让输出的变量信息比较美观、可读性好。但是加载了Xdebug后，我们不
再需要这样做了，Xdebug不但自动给我们加上了&lt;pre&gt;标签，还给变量加上颜色。 <br />
例：<div><code>&lt;?php<br />
$arrTest=array(<br />
       "test"=&gt;"abc",<br />
       "test2"=&gt;"abc2"<br />
);<br />
 <br />
var_dump($arrTest);<br />
?&gt;</code><br />
</div>输出：<br />
<img src="http://www.phpq.net/bbs/attachment.php?aid=10" /> <br />
看到了吗？　数组元素的值自动显示颜色。<br />
 <br />
<strong>Xdebug测试脚本执行时间</strong> <br />
测试某段脚本的执行时间，通常我们都需要用到microtime()函数来确定当前时间。例如PHP手册上的例子：<div><code>&lt;?php<br />
/**<br />
* Simple function to replicate PHP 5 behaviour<br />
*/<br />
function microtime_float()<br />
{<br />
    list($usec, $sec) = explode(" ", microtime());<br />
return ((float)$usec + (float)$sec);<br />
}<br />
<br />
$time_start = microtime_float();<br />
// Sleep for a while<br />
usleep(100);<br />
$time_end = microtime_float();<br />
$time = $time_end - $time_start;<br />
echo "Did nothing in $time seconds\n";<br />
?&gt;</code><br />
</div>但是microtime()返回的值是微秒数及绝对时间戳（例如“0.03520000 1153122275”），没有可读性。所以如上程序，我们需要另外写一个函数microtime_float()，来将两者相加。<br />
Xdebug自带了一个函数xdebug_time_index()来显示时间。<br />
 <br />
 <br />
<strong>PHP脚本占用的内存</strong><br />
有时候我们想知道程序执行到某个特定阶段时到底占用了多大内存，为此PHP提供了函数memory_get_usage()。这个函数只有当PHP编译时使用了--enable-memory-limit参数时才有效。　<br />
 <br />
Xdebug同样提供了一个函数xdebug_memory_usage()来实现这样的功能，另外xdebug还提供了一个xdebug_peak_memory_usage()函数来查看内存占用的峰值。<br /><br /><br /><br />内容来自：http://www.phpq.net/tutorial/xdebug.html<br /><br /><br /><br /><br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/page-1" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/5527133414682482816" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/5527133414682482816" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/5527133414682482816" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>page-1</sites:pageName><sites:revision>1</sites:revision></entry><entry gd:etag="&quot;YD0peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/3783597308763065760</id><published>2009-08-19T08:21:46.862Z</published><updated>2009-08-19T08:22:34.117Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-19T08:22:34.107Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>flash如何直接获取网页地址</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">flash获取当前网页地址：<br />String(ExternalInterface.call("window.location.href.toString"));<br /><br />flash获取当前网页来源：<br />String(ExternalInterface.call("window.location.referrer.toString"));</div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/flashruhezhijiehuoquwangyedezhi" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/3783597308763065760" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/3783597308763065760" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/3783597308763065760" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>flashruhezhijiehuoquwangyedezhi</sites:pageName><sites:revision>1</sites:revision></entry><entry gd:etag="&quot;YD0peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/5048582525848331782</id><published>2009-07-17T06:43:15.333Z</published><updated>2009-07-17T06:44:55.809Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-17T06:44:55.791Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>基于stream的PHP的TcpServer类</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">这个类，现在在linux下，只能高于5.2的版本才能正常使用。<br /><div class="sites-embed-align-left-wrapping-off"><div class="sites-embed-border-on sites-embed sites-embed-full-width" style="width:100%;"><h4 class="sites-embed-title">例子</h4><div class="sites-embed-content sites-embed-type-text"><div class="sites-embed-content-textbox"><div dir="ltr">&lt;?php<br />include("TcpServer.class.php");<br /><br />class Security extends TcpServerHandle{<br /><br />    var $init_string ='&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;cross-domain-policy&gt;&lt;allow-access-from domain="*" to-ports="80,999<br />8,10000,10001,10002"/&gt;&lt;/cross-domain-policy&gt;';<br />    public function HandleNewConnection(){<br />    //  print_r("CT:".count($this-&gt;getClients())."\n");<br />        $this-&gt;write("Welcome...\n");<br />        //$this-&gt;close();<br />    }<br />    public function HandleData($data){<br />            echo "RECV{{$data}},LEN{".strlen($data)."}\n";<br />            $this-&gt;write("You Send:$data");<br />    }<br />}<br />$server = new TcpServer($argv[1]);<br />$server-&gt;max_clients = 1000;<br />$server-&gt;bind("Security");<br />$server-&gt;run();<br />?&gt;<br /></div></div></div></div></div><br /><br />TcpServer类<br /><div class="sites-embed-align-left-wrapping-off"><div class="sites-embed-border-on sites-embed sites-embed-full-width" style="width:100%;"><h4 class="sites-embed-title">TcpServer</h4><div class="sites-embed-content sites-embed-type-text"><div class="sites-embed-content-textbox"><div dir="ltr">&lt;?php<br />/*<br />  +----------------------------------------------------------------------+<br />  | PHP Version 5                                                        |<br />  +----------------------------------------------------------------------+<br />  | Copyright (c) 1997-2008 The PHP Group                                |<br />  +----------------------------------------------------------------------+<br />  | This source file is subject to version 3.01 of the PHP license,      |<br />  | that is bundled with this package in the file LICENSE, and is        |<br />  | available through the world-wide-web at the following url:           |<br />  | http://www.php.net/license/3_01.txt                                  |<br />  | If you did not receive a copy of the PHP license and are unable to   |<br />  | obtain it through the world-wide-web, please send a note to          |<br />  | license@php.net so we can mail you a copy immediately.               |<br />  +----------------------------------------------------------------------+<br />  | Authors: Hetal <br />  +----------------------------------------------------------------------+<br />*/<br /><br /><br />class TcpServerHandle{<br />    /**<br />     * 所有属性全是只读，请不要修改<br />     **/<br /><br />    /**<br />     * 当前所有连接<br />     **/<br />    //var  $_clients;//所有在线的人的sock<br />    /**<br />     * 当前连接socket<br />     **/<br />    var  $_sock;<br />    /**<br />     * 当前连接的ID号<br />     **/<br />    var  $id;<br />    /**<br />     * 当前连接的客户端ip<br />     **/<br />    var  $ip;<br />    /**<br />     * 当前连接的客户端磁口<br />     */<br />    var  $port;<br />    <br />    /**<br />     * 新连接进入时调用<br />     **/<br />    public function HandleNewConnection(){<br />    }<br />    /**<br />     * 有数据可读时调用<br />     **/<br />    public function HandleData($data){<br />    }<br /><br />    /**<br />     * 连接断开时调用<br />     **/<br />    public function HandledisConnected(){<br /><br />    }<br />    /**<br />     * 写数据<br />     **/<br />    public function write($data){<br />        return stream_socket_sendto($this-&gt;_sock,$data);<br />    }<br />    /**<br />     * 关闭连接<br />     **/<br />    public function close(){<br />        fclose($this-&gt;_sock);<br />        unset(TcpServer::$_clients[$this-&gt;_sock]);<br />        unset(TcpServer::$_objects[$this-&gt;_sock]);<br />    }<br />    /**<br />     * 获取服务端所有连接<br />     **/<br />    public function getClients(){<br />        return TcpServer::$_clients;<br />    }<br />}<br /><br />/**<br /> *<br /> */<br /><br />class TcpServer{<br /><br />    /**<br />     * 最大连接数，linux支持1000<br />     **/<br />    var $max_clients = 150; <br />    <br />    /**<br />     * 主要socket<br />     **/<br />    private  $_sock;<br />    private  $_objectName;<br />    private $_port;<br />    static  $_objects;<br />    static  $_clients;<br />    public function __construct($port=9999){<br />        $this-&gt;_port = $port;<br />    }<br />    public function __desctruct(){<br />        fclose($this-&gt;_sock);<br />    }<br />    public function bind($objectName){<br />        $this-&gt;_objectName = $objectName;<br />    }<br />    public function run(){<br />        $this-&gt;_sock = stream_socket_server("tcp://0.0.0.0:".$this-&gt;_port, $errno, $errstr);<br />        if(!$this-&gt;_sock){<br />            die( "$errstr ($errno)&lt;br /&gt;\n");<br />        }<br />        stream_set_blocking ($this-&gt;_sock,1);<br /><br />        TcpServer::$_clients = array();<br />        TcpServer::$_clients[$this-&gt;_sock] = $this-&gt;_sock;<br /><br />        while (true) {<br /><br />            $read = TcpServer::$_clients;<br />            if (false===($num_changed_streams = stream_select($read, $write = NULL, $except = NULL, NULL))){<br />                continue;<br />            }elseif($num_changed_streams&gt;0){<br />                for ($i = 0; $i &lt; $num_changed_streams; ++$i) {<br />                    if ($read[$i] === $this-&gt;_sock) {<br />                        //新连接<br /><br />                        if(false !==($newsock = stream_socket_accept($this-&gt;_sock))){<br />                            if(count(TcpServer::$_clients)&gt;$this-&gt;max_clients){<br />                                echo count(TcpServer::$_clients).":"."超过了限制[".$this-&gt;max_clients."]了\n";<br />                                fclose($newsock);<br />                            }else{<br />                                stream_set_timeout($newsock, 2);<br /><br />                                $socket_name = explode(":", stream_socket_get_name($newsock,true));<br />                                <br />                                TcpServer::$_objects[$newsock] = new $this-&gt;_objectName;<br />                                TcpServer::$_objects[$newsock]-&gt;_sock = $newsock;<br />                                TcpServer::$_objects[$newsock]-&gt;id = (int)$newsock;<br />                                TcpServer::$_objects[$newsock]-&gt;ip = $socket_name[0];<br />                                TcpServer::$_objects[$newsock]-&gt;port = $socket_name[1];<br /><br />                                TcpServer::$_clients[$newsock] = $newsock;<br /><br />                                $command="HandleNewConnection";<br />                                if(method_exists (TcpServer::$_objects[$newsock],$command)){<br />                                    call_user_func_array(array(&amp;TcpServer::$_objects[$newsock], $command), array());<br />                                }<br />                            }<br />                        }<br /><br />                    }else{<br />                        $read_sock = $read[$i];<br />                        $data = "";<br />                        while(($c=fgetc($read_sock))!==false &amp;&amp; $c!="\0" &amp;&amp; $c!="\n" &amp;&amp; $c!="\r"){<br />                            $data .=$c;<br />                        }<br />                        if ($c === false) {<br /><br />                            $info = stream_get_meta_data($read_sock);<br />                            if ($info['timed_out']) {<br />                                fclose($read_sock);<br />                            }<br />                            $command="HandledisConnected";<br />                            if(method_exists (TcpServer::$_objects[$read_sock],$command)){<br />                                call_user_func_array(array(&amp;TcpServer::$_objects[$read_sock], $command), array());//, array($read_sock));<br />                            }<br />            <br />                            unset(TcpServer::$_objects[$read_sock]);<br />                            unset(TcpServer::$_clients[$read_sock]);<br />                            continue;<br />                        }elseif($data!=""){<br />                            $command = "HandleData";<br />                            if(method_exists (TcpServer::$_objects[$read_sock],$command)){<br />                                call_user_func_array(array(&amp;TcpServer::$_objects[$read_sock], $command), array($data));<br />                            }<br />                        }<br /><br /><br />                    }<br />                }<br />            }<br />        }<br />    }<br />}<br />?&gt;<br /></div></div></div></div></div><br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/jiyustreamdephpdetcpserverlei" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/5048582525848331782" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/5048582525848331782" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/5048582525848331782" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>jiyustreamdephpdetcpserverlei</sites:pageName><sites:revision>1</sites:revision></entry><entry gd:etag="&quot;YD4peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/5954850469563313990</id><published>2009-05-22T02:06:05.558Z</published><updated>2009-05-22T04:18:06.688Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-22T04:18:06.688Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>Google Sites里增加留言板功能</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">我看过其它的一些留言板，感觉太麻烦了，而且还要到其它网站去注册，于是自己做了一个留言板，你可以到下面地址去试试：<br /><a href="http://www.hetao.name/gei-wo-liu-yan" target="_blank" rel="nofollow">http://www.hetao.name/gei-wo-liu-yan</a><br /><br />下面我介绍使用方法，这个和在google sites加视频功能类似。<br /><br />1.打开开发人工具，这个地址：<br /><a href="http://code.google.com/intl/zh-CN/apis/gadgets/docs/tools.html" target="_blank">http://code.google.com/intl/zh-CN/apis/gadgets/docs/tools.html</a><br />找到“<i><b>通过 Google 小工具编辑器进行托管</b></i>”这一项目，把下面的代码去替换“Hello, World”<br />
        
        
        
      
        

        

      
        
        
      
        
        
      
          
        
        
        
      
        

        

      
        
        
      
        
        
      
          <div class="sites-embed-align-left-wrapping-off"><div class="sites-embed-border-on sites-embed sites-embed-full-width" style="width:100%;"><h4 class="sites-embed-title">替换代码</h4><div class="sites-embed-content sites-embed-type-text"><div class="sites-embed-content-textbox"><div dir="ltr">&lt;embed src="http://api.hetao.name/guestbook/main.swf?toName=<b style="color:rgb(255, 0, 0)">yourName</b>&amp;toEmail=<b style="color:rgb(255, 0, 0)">yourEmail</b>&amp;subject=<b><span style="color:rgb(255, 0, 0)">yourSubject</span></b>&amp;locale=<b style="color:rgb(255, 0, 0)">zh_CN</b>" quality="high" width="100%" height="100%" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;<br /></div></div></div></div></div>
        
      
        
      <br />找到上面红色的部分，换成你的参数，然后<b>保存</b>，并<b>发布</b>，你会得到一个地址。下面是参数说明：<br />yourName 你的名字，这个名字会在你的收件箱里显示出来。<br />yourEmail 你的邮箱，留言会自动发送到你的邮箱里<br />yourSubject 你的留言的主题，你的邮件标题会是这个<br />locale 界面语言 zh_CN ,en_US，中文和英文，现在只支持中文。<br /><br /><br />2.然后在你的google sites里“插入”，“更多小工具...”把它加进去，大小可以自己调整，我用的是高400，宽600.<br /><br />3.如果还有什么不明白的，请参考如何加入视频 <a href="http://www.hetao.name/ji-shu-wen-zhang/ruhezaigooglexiezuopingtaicharuyoukushipin" target="_blank" rel="nofollow">http://www.hetao.name/ji-shu-wen-zhang/ruhezaigooglexiezuopingtaicharuyoukushipin</a><br />或者给我留言 <a href="http://www.hetao.name/gei-wo-liu-yan" target="_blank" rel="nofollow">http://www.hetao.name/gei-wo-liu-yan</a> <br /><br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/googlesiteslizengjialiuyanbangongneng" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/5954850469563313990" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/5954850469563313990" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/5954850469563313990" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>googlesiteslizengjialiuyanbangongneng</sites:pageName><sites:revision>2</sites:revision></entry><entry gd:etag="&quot;YD8peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/4047414697383806865</id><published>2009-05-15T03:17:05.441Z</published><updated>2009-05-15T03:28:31.447Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-15T03:28:31.446Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>CSS Sprite解决小图标问题</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">看看google首页，logo是 <a href="http://www.google.cn/images/nav_logo4.png" target="_blank">http://www.google.cn/images/nav_logo4.png<br /><br /></a><br /><div style="display:block;text-align:left"><a href="http://www.google.cn/images/nav_logo4.png" imageanchor="1"><img border="0" src="http://www.google.cn/images/nav_logo4.png" /></a><br /><br />把所有小图片合在一起，用css去定位其它地方用到的图片<br /><br />先定议一个csb的样式<br /><pre>&lt;<span>style</span>&gt;<span><br /></span>.csb,.ss{background:url(/images/nav_logo4.png) no-repeat 0 0;height:26px;display:block}<br />&lt;/style&gt;<span>    </span></pre>其它地方用的时候，根据位置去算出来。<br /><pre>&lt;<span>span</span><span> class</span>=<span>"csb" </span><span>style</span>=<span>"background-position:-26px 0;width:18px"</span>&gt;&lt;/<span>span</span>&gt;<br /><br />这样做的好处有：<br />1.图标全在一起方便管理和控制<br />2.减少网络开销，和请求数，提高性能，这是最主要的。<br /><br />这样的方式现在优酷也一直在用，我想会越来越流行的。<br /><br />下面是收集的一些更多资料：<br /><br />这个介绍很详细     <br /><a href="http://www.yeeyan.com/articles/view/oc/39032" target="_blank" rel="nofollow">http://www.yeeyan.com/articles/view/oc/39032</a><br /><br /><a href="http://www.a18zhizao.cn/y2009/850_transgenic-css-sprite-research-and-implementation-of-using.html" target="_blank" rel="nofollow">http://www.a18zhizao.cn/y2009/850_transgenic-css-sprite-research-and-implementation-of-using.html</a><br /></pre></div><br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/cssspritejiejuexiaotubiaowenti" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/4047414697383806865" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/4047414697383806865" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/4047414697383806865" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>cssspritejiejuexiaotubiaowenti</sites:pageName><sites:revision>3</sites:revision></entry><entry gd:etag="&quot;YD4peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/7449326764020384270</id><published>2009-04-28T02:32:10.400Z</published><updated>2009-04-28T03:18:30.188Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-28T03:18:30.187Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>应用程序无法启动，因为应用程序的并行配置不正确的解决办法</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">出现这个错误的原因主要是你的程序是用vc动态的方式运行库，而你确没有对应的dll文件，所以你应该装上这些dll，可以通过下面的地址下载并安装：<br /><br /><a href="http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&amp;FamilyID=32bc1bee-a3f9-4c13-9c99-220b62a191ee" target="_blank" rel="nofollow">http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&amp;FamilyID=32bc1bee-a3f9-4c13-9c99-220b62a191ee</a><br /><br />如果你自己有源码的话，建议给别人运行时关上debug就好了。<br /><br /><h4><a name="TOC-1" />概述</h4>
<div><span>Microsoft Visual C++ 2005 
Redistributable Package (x86) 安装在未安装 Visual C++ 2005 的计算机上运行使用 Visual C++ 
开发的应用程序所需的 Visual C++ 库的运行时组件。<br /><br />此软件包安装 C Runtime (CRT)、Standard 
C++、ATL、MFC、OpenMP 和 MSDIA 库的运行时组件。对于支持并行部署模式的库（CRT、SCL、ATL、MFC 和 
OpenMP），这些运行时组件安装在支持并行程序集的 Windows 操作系统版本的本机程序集缓存中，这一缓存也称为 WinSxS 文件夹。<br /><br /></span></div><br /><span><b>重要事项：<br /></b>如果已安装了以前的 Visual C++ 2005 或 Visual Studio 2005 预发布版本，例如测试版 1、测试版 2 
或社区技术预览（Community Technical 
Preview，CTP）版本，则必须先在“控制面板”中通过“添加/删除程序”来卸载这些版本，然后再安装最终发布版本。</span><br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/yingyongchengxuwufaqidongyinweiyingyongchengxudebingxingpeizhibuzhengquedejiejuebanfa" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/7449326764020384270" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/7449326764020384270" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/7449326764020384270" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>yingyongchengxuwufaqidongyinweiyingyongchengxudebingxingpeizhibuzhengquedejiejuebanfa</sites:pageName><sites:revision>2</sites:revision></entry><entry gd:etag="&quot;YD4peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/1147514650350174388</id><published>2009-04-27T08:06:05.637Z</published><updated>2009-04-27T08:10:03.144Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-27T08:10:03.133Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>搜狐博客自动发贴</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">
        
        
        
      
        

        

      
        
        
      
        
        
      
          <div class="sites-embed-align-left-wrapping-off"><div class="sites-embed-border-on sites-embed sites-embed-full-width" style="width:100%;"><h4 class="sites-embed-title">源码</h4><div class="sites-embed-content sites-embed-type-text"><div class="sites-embed-content-textbox"><div dir="ltr"><code><span style="color:rgb(0, 0, 0)"><span style="color:rgb(0, 0, 187)">&lt;?php  <br /><br /></span><span style="color:rgb(255, 128, 0)">/**  <br />* sohu博客自动发BLOG机 本代码只供学习交流用，请不要用于非法用途 <br />* author : hetal  <br />* qq     : 231073376 <br />* <br />*/ <br /></span><span style="color:rgb(0, 0, 187)">$a </span><span style="color:rgb(0, 119, 0)">= new </span><span style="color:rgb(0, 0, 187)">Sohu_Blog</span><span style="color:rgb(0, 119, 0)">;  <br /></span><span style="color:rgb(0, 0, 187)">$title</span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(221, 0, 0)">"T条比啊"</span><span style="color:rgb(0, 119, 0)">; <br /></span><span style="color:rgb(0, 0, 187)">$text</span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(221, 0, 0)">"&lt;a href='ddd'&gt;xxxxxjfxx&lt;/a&gt;另 是只吸w"</span><span style="color:rgb(0, 119, 0)">; <br /></span><span style="color:rgb(255, 128, 0)">//1.登录  <br /></span><span style="color:rgb(0, 119, 0)">if(</span><span style="color:rgb(0, 0, 187)">$a</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">login</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"username"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">"password"</span><span style="color:rgb(0, 119, 0)">)){  <br />    echo </span><span style="color:rgb(221, 0, 0)">"Login Success\n"</span><span style="color:rgb(0, 119, 0)">; <br />}else{ <br />    die(</span><span style="color:rgb(221, 0, 0)">"Login Fail\n"</span><span style="color:rgb(0, 119, 0)">);  <br />} <br /></span><span style="color:rgb(255, 128, 0)">//$a-&gt;_postInit(); <br />//exit;  <br />//2.发贴 <br /></span><span style="color:rgb(0, 0, 187)">$r</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$a</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">post</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$title</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$text</span><span style="color:rgb(0, 119, 0)">); <br />if(</span><span style="color:rgb(0, 0, 187)">$r</span><span style="color:rgb(0, 119, 0)">==-</span><span style="color:rgb(0, 0, 187)">1</span><span style="color:rgb(0, 119, 0)">){  <br />    echo </span><span style="color:rgb(221, 0, 0)">"POST FAIL"</span><span style="color:rgb(0, 119, 0)">; <br />}else{ <br />    echo </span><span style="color:rgb(221, 0, 0)">"POST OK"</span><span style="color:rgb(0, 119, 0)">;  <br />    echo </span><span style="color:rgb(221, 0, 0)">"\n"</span><span style="color:rgb(0, 119, 0)">; <br />    echo </span><span style="color:rgb(221, 0, 0)">"$r"</span><span style="color:rgb(0, 119, 0)">;  <br />    echo </span><span style="color:rgb(221, 0, 0)">"\n"</span><span style="color:rgb(0, 119, 0)">; <br />} <br /><br />class </span><span style="color:rgb(0, 0, 187)">Sohu_Blog</span><span style="color:rgb(0, 119, 0)">{  <br />    var </span><span style="color:rgb(0, 0, 187)">$proxyPort</span><span style="color:rgb(0, 119, 0)">; <br />    var </span><span style="color:rgb(0, 0, 187)">$proxyHost</span><span style="color:rgb(0, 119, 0)">;  <br />    var </span><span style="color:rgb(0, 0, 187)">$cookie</span><span style="color:rgb(0, 119, 0)">; <br />    var </span><span style="color:rgb(0, 0, 187)">$_error</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">0</span><span style="color:rgb(0, 119, 0)">;  <br />    </span><span style="color:rgb(255, 128, 0)">//设置代理 <br />    </span><span style="color:rgb(0, 119, 0)">function </span><span style="color:rgb(0, 0, 187)">setProxy</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$proxyHost</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$proxyPort</span><span style="color:rgb(0, 119, 0)">){  <br />        </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyPort</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$proxyPort</span><span style="color:rgb(0, 119, 0)">;  <br />        </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyHost</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$proxyHost</span><span style="color:rgb(0, 119, 0)">; <br />    }  <br />    </span><span style="color:rgb(255, 128, 0)">//登录 <br />    </span><span style="color:rgb(0, 119, 0)">function </span><span style="color:rgb(0, 0, 187)">login</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$user</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$pass</span><span style="color:rgb(0, 119, 0)">){  <br />        </span><span style="color:rgb(0, 0, 187)">$post_data </span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"userid=$user&amp;password="</span><span style="color:rgb(0, 119, 0)">.</span><span style="color:rgb(0, 0, 187)">md5</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$pass</span><span style="color:rgb(0, 119, 0)">).</span><span style="color:rgb(221, 0, 0)">"&amp;appid=9999&amp;persistentcookie=0&amp;isSLogin=1&amp;s="</span><span style="color:rgb(0, 119, 0)">.</span><span style="color:rgb(0, 0, 187)">time</span><span style="color:rgb(0, 119, 0)">().</span><span style="color:rgb(221, 0, 0)">"&amp;b=5&amp;w=1280&amp;pwdtype=1"</span><span style="color:rgb(0, 119, 0)">; <br />        </span><span style="color:rgb(0, 0, 187)">$url </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(221, 0, 0)">"http://passport.sohu.com/sso/login.jsp?"</span><span style="color:rgb(0, 119, 0)">.</span><span style="color:rgb(0, 0, 187)">$post_data</span><span style="color:rgb(0, 119, 0)">;  <br />        </span><span style="color:rgb(0, 0, 187)">$rt </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">_getUrl</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$url</span><span style="color:rgb(0, 119, 0)">);  <br />        if(</span><span style="color:rgb(0, 0, 187)">strpos</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">"success"</span><span style="color:rgb(0, 119, 0)">)){  <br />            return </span><span style="color:rgb(0, 0, 187)">true</span><span style="color:rgb(0, 119, 0)">; <br />        }else{ <br />            return </span><span style="color:rgb(0, 0, 187)">false</span><span style="color:rgb(0, 119, 0)">; <br />        }  <br />    } <br /><br /><br />    function </span><span style="color:rgb(0, 0, 187)">_postInit</span><span style="color:rgb(0, 119, 0)">(){  <br />        </span><span style="color:rgb(0, 0, 187)">$url </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(221, 0, 0)">"http://blog.sohu.com/manage/entry.do?m=add"</span><span style="color:rgb(0, 119, 0)">; <br />        </span><span style="color:rgb(0, 0, 187)">$rt </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">_getUrl</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$url</span><span style="color:rgb(0, 119, 0)">);  <br />        </span><span style="color:rgb(0, 0, 187)">preg_match_all </span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"/\&lt;input(.+?)\&gt;/i"</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$_matches</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">PREG_SET_ORDER</span><span style="color:rgb(0, 119, 0)">);  <br />        </span><span style="color:rgb(0, 0, 187)">$inputs</span><span style="color:rgb(0, 119, 0)">=array(); <br />        foreach(</span><span style="color:rgb(0, 0, 187)">$_matches </span><span style="color:rgb(0, 119, 0)">as </span><span style="color:rgb(0, 0, 187)">$_matche</span><span style="color:rgb(0, 119, 0)">){  <br />            </span><span style="color:rgb(0, 0, 187)">preg_match</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"/name\=\"(.+?)\"/i"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$_matche</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">0</span><span style="color:rgb(0, 119, 0)">],</span><span style="color:rgb(0, 0, 187)">$_name</span><span style="color:rgb(0, 119, 0)">); <br />            </span><span style="color:rgb(0, 0, 187)">preg_match</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"/value\=\"(.*?)\"/i"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$_matche</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">0</span><span style="color:rgb(0, 119, 0)">],</span><span style="color:rgb(0, 0, 187)">$_value</span><span style="color:rgb(0, 119, 0)">); <br />            </span><span style="color:rgb(0, 0, 187)">$inputs</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">$_name</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">1</span><span style="color:rgb(0, 119, 0)">]] = @</span><span style="color:rgb(0, 0, 187)">$_value</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">1</span><span style="color:rgb(0, 119, 0)">]; <br />        }  <br />         <br />        if(</span><span style="color:rgb(0, 0, 187)">strpos</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">"c_codeInputBox"</span><span style="color:rgb(0, 119, 0)">)){  <br />             <br />            </span><span style="color:rgb(0, 0, 187)">$rt2 </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">_getUrl</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"http://blog.sohu.com/service/vcode.jsp?nocache="</span><span style="color:rgb(0, 119, 0)">.</span><span style="color:rgb(0, 0, 187)">time</span><span style="color:rgb(0, 119, 0)">().</span><span style="color:rgb(221, 0, 0)">"&amp;_="</span><span style="color:rgb(0, 119, 0)">);  <br />            </span><span style="color:rgb(0, 0, 187)">str_replace</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"\r"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">"\n"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$rt2</span><span style="color:rgb(0, 119, 0)">); <br />            </span><span style="color:rgb(0, 0, 187)">$tmp </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">split</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"close"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$rt2</span><span style="color:rgb(0, 119, 0)">);  <br />            </span><span style="color:rgb(0, 0, 187)">$code </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">trim</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$tmp</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">1</span><span style="color:rgb(0, 119, 0)">]); <br />            </span><span style="color:rgb(0, 0, 187)">$img </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">file_get_contents</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"http://blog.sohu.com/rand?vcode=$code"</span><span style="color:rgb(0, 119, 0)">); <br />            </span><span style="color:rgb(0, 0, 187)">file_put_contents</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"vcode.jpg"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$img</span><span style="color:rgb(0, 119, 0)">); <br />             <br /><br />            echo </span><span style="color:rgb(221, 0, 0)">"请输入验证码(请打开vcode.jpg):\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$stdin</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">fopen</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"php://stdin"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">"r"</span><span style="color:rgb(0, 119, 0)">); <br />            while(</span><span style="color:rgb(0, 0, 187)">true</span><span style="color:rgb(0, 119, 0)">)  <br />            { <br />                </span><span style="color:rgb(0, 0, 187)">$d </span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">fgets</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$stdin</span><span style="color:rgb(0, 119, 0)">);  <br />                if(</span><span style="color:rgb(0, 0, 187)">strlen</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$d</span><span style="color:rgb(0, 119, 0)">)&gt;</span><span style="color:rgb(0, 0, 187)">0</span><span style="color:rgb(0, 119, 0)">) <br />                {  <br />                    </span><span style="color:rgb(0, 0, 187)">$ext</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">trim</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$d</span><span style="color:rgb(0, 119, 0)">); <br />                    break; <br />                }  <br />            } <br /><br /><br /><br />            </span><span style="color:rgb(0, 0, 187)">$inputs</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'vcode'</span><span style="color:rgb(0, 119, 0)">] = </span><span style="color:rgb(0, 0, 187)">$ext</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$inputs</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'vcodeEn'</span><span style="color:rgb(0, 119, 0)">] = </span><span style="color:rgb(0, 0, 187)">$code</span><span style="color:rgb(0, 119, 0)">; <br /><br />        } <br />        </span><span style="color:rgb(255, 128, 0)">//print_r($inputs); <br />        </span><span style="color:rgb(0, 119, 0)">return </span><span style="color:rgb(0, 0, 187)">$inputs</span><span style="color:rgb(0, 119, 0)">; <br />    }  <br /><br />    function </span><span style="color:rgb(0, 0, 187)">post</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$title</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$text</span><span style="color:rgb(0, 119, 0)">){ <br />        </span><span style="color:rgb(0, 0, 187)">$inputs </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">_postInit</span><span style="color:rgb(0, 119, 0)">();  <br />        </span><span style="color:rgb(0, 0, 187)">$inputs</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'entrycontent'</span><span style="color:rgb(0, 119, 0)">] = </span><span style="color:rgb(0, 0, 187)">urlencode</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$text</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">$inputs</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'categoryId'</span><span style="color:rgb(0, 119, 0)">] = </span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">; <br />        </span><span style="color:rgb(0, 0, 187)">$inputs</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'excerpt'</span><span style="color:rgb(0, 119, 0)">] = </span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">; <br />        </span><span style="color:rgb(0, 0, 187)">$inputs</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'entrytitle'</span><span style="color:rgb(0, 119, 0)">] = </span><span style="color:rgb(0, 0, 187)">urlencode</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$title</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">$post_data</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">; <br />        foreach(</span><span style="color:rgb(0, 0, 187)">$inputs </span><span style="color:rgb(0, 119, 0)">as </span><span style="color:rgb(0, 0, 187)">$key</span><span style="color:rgb(0, 119, 0)">=&gt;</span><span style="color:rgb(0, 0, 187)">$value</span><span style="color:rgb(0, 119, 0)">){  <br />            </span><span style="color:rgb(0, 0, 187)">$post_data</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(0, 0, 187)">$key</span><span style="color:rgb(0, 119, 0)">.</span><span style="color:rgb(221, 0, 0)">"="</span><span style="color:rgb(0, 119, 0)">.</span><span style="color:rgb(0, 0, 187)">$value</span><span style="color:rgb(0, 119, 0)">.</span><span style="color:rgb(221, 0, 0)">"&amp;"</span><span style="color:rgb(0, 119, 0)">; <br />        } <br />        </span><span style="color:rgb(0, 0, 187)">$cookie</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">cookie</span><span style="color:rgb(0, 119, 0)">;  <br />        </span><span style="color:rgb(0, 0, 187)">$post_data_le </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">strlen</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$post_data</span><span style="color:rgb(0, 119, 0)">);  <br />        if(!empty(</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyPort</span><span style="color:rgb(0, 119, 0)">) and !empty(</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyHost</span><span style="color:rgb(0, 119, 0)">)){  <br />            </span><span style="color:rgb(0, 0, 187)">$post_url</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"http://blog.sohu.com/manage/entry.do"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$post_port</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyPort</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">$connect</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"Proxy-Connection"</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">$post_host</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyHost</span><span style="color:rgb(0, 119, 0)">;  <br />        }else{ <br />            </span><span style="color:rgb(0, 0, 187)">$post_url</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"/manage/entry.do"</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">$post_port</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">80</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$connect</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"Connection"</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">$post_host</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"blog.sohu.com"</span><span style="color:rgb(0, 119, 0)">;  <br />        } <br />        </span><span style="color:rgb(0, 0, 187)">$data</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"POST $post_url HTTP/1.1\nAccept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*\nAccept-Language: zh-cn\nContent-Type: application/x-www-form-urlencoded\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Alexa Toolbar)\nHost: blog.sohu.com\nContent-Length: $post_data_le\nConnection: Close\nCache-Control: no-cache\nCookie: $cookie\n\n$post_data\n"</span><span style="color:rgb(0, 119, 0)">; <br />        </span><span style="color:rgb(0, 0, 187)">$sock </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">fsockopen</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$post_host</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$post_port</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$errno</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$error</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">3</span><span style="color:rgb(0, 119, 0)">); <br />        if(empty(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">)){  <br />            return -</span><span style="color:rgb(0, 0, 187)">2</span><span style="color:rgb(0, 119, 0)">; <br />        } <br />        </span><span style="color:rgb(0, 0, 187)">fputs</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$data</span><span style="color:rgb(0, 119, 0)">);  <br />        </span><span style="color:rgb(0, 0, 187)">stream_set_timeout</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">3</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">stream_get_contents</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">str_replace</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"\n"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">str_replace</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"\t"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">fclose</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">);  <br />        </span><span style="color:rgb(255, 128, 0)">//echo $rt;  <br />        </span><span style="color:rgb(0, 0, 187)">preg_match_all </span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"/Set-Cookie: (.+?)=(.+?);/"</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$_matches</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">PREG_SET_ORDER</span><span style="color:rgb(0, 119, 0)">);  <br />        </span><span style="color:rgb(0, 0, 187)">$tmp</span><span style="color:rgb(0, 119, 0)">=array(); <br />        for(</span><span style="color:rgb(0, 0, 187)">$i</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">0</span><span style="color:rgb(0, 119, 0)">;</span><span style="color:rgb(0, 0, 187)">$i</span><span style="color:rgb(0, 119, 0)">&lt;</span><span style="color:rgb(0, 0, 187)">count</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$_matches</span><span style="color:rgb(0, 119, 0)">);</span><span style="color:rgb(0, 0, 187)">$i</span><span style="color:rgb(0, 119, 0)">++){ <br />            if(</span><span style="color:rgb(0, 0, 187)">$_matches</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">$i</span><span style="color:rgb(0, 119, 0)">][</span><span style="color:rgb(0, 0, 187)">1</span><span style="color:rgb(0, 119, 0)">] == </span><span style="color:rgb(221, 0, 0)">"msg"</span><span style="color:rgb(0, 119, 0)">){  <br />                </span><span style="color:rgb(0, 0, 187)">preg_match</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"/http(.+?)([0-9]{3,})\.html/"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">urldecode</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$_matches</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">$i</span><span style="color:rgb(0, 119, 0)">][</span><span style="color:rgb(0, 0, 187)">2</span><span style="color:rgb(0, 119, 0)">]),</span><span style="color:rgb(0, 0, 187)">$_matches2</span><span style="color:rgb(0, 119, 0)">);  <br />                if(@</span><span style="color:rgb(0, 0, 187)">$_matches2</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">0</span><span style="color:rgb(0, 119, 0)">]){ <br />                    return </span><span style="color:rgb(0, 0, 187)">$_matches2</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">0</span><span style="color:rgb(0, 119, 0)">]; <br />                } <br />            } <br />        }  <br />        return -</span><span style="color:rgb(0, 0, 187)">1</span><span style="color:rgb(0, 119, 0)">; <br /><br />    } <br />    function </span><span style="color:rgb(0, 0, 187)">_getUrl</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$url</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$referer</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">){  <br />        </span><span style="color:rgb(0, 0, 187)">$purl</span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">parse_url</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$url</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">$host  </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">$purl</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">"host"</span><span style="color:rgb(0, 119, 0)">];  <br />        if(!empty(</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyHost</span><span style="color:rgb(0, 119, 0)">) and !empty(</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyPort</span><span style="color:rgb(0, 119, 0)">)){  <br />            </span><span style="color:rgb(0, 0, 187)">$port</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyPort</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">$post_host</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyHost</span><span style="color:rgb(0, 119, 0)">;  <br />        }else{ <br />            </span><span style="color:rgb(0, 0, 187)">$post_host</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$purl</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'host'</span><span style="color:rgb(0, 119, 0)">]; <br />            if(empty(</span><span style="color:rgb(0, 0, 187)">$purl</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'port'</span><span style="color:rgb(0, 119, 0)">])){  <br />                </span><span style="color:rgb(0, 0, 187)">$port</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">80</span><span style="color:rgb(0, 119, 0)">; <br />            }else{ <br />                </span><span style="color:rgb(0, 0, 187)">$port</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$purl</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'port'</span><span style="color:rgb(0, 119, 0)">];  <br />            } <br />        } <br />        </span><span style="color:rgb(0, 0, 187)">$cookie </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">cookie</span><span style="color:rgb(0, 119, 0)">;  <br />        </span><span style="color:rgb(0, 0, 187)">$path</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$purl</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'path'</span><span style="color:rgb(0, 119, 0)">]; <br />        </span><span style="color:rgb(0, 0, 187)">$query</span><span style="color:rgb(0, 119, 0)">=empty(</span><span style="color:rgb(0, 0, 187)">$purl</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'query'</span><span style="color:rgb(0, 119, 0)">])?</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">:</span><span style="color:rgb(0, 0, 187)">$purl</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'query'</span><span style="color:rgb(0, 119, 0)">]; <br />        if(!empty(</span><span style="color:rgb(0, 0, 187)">$proxyhost</span><span style="color:rgb(0, 119, 0)">) and !empty(</span><span style="color:rgb(0, 0, 187)">$proxyport</span><span style="color:rgb(0, 119, 0)">)){  <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"GET $url HTTP/1.0\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Accept: */*\r\n"</span><span style="color:rgb(0, 119, 0)">;  <br />            if(!empty(</span><span style="color:rgb(0, 0, 187)">$referer</span><span style="color:rgb(0, 119, 0)">))  <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Referer: $referer\r\n"</span><span style="color:rgb(0, 119, 0)">; <br /><br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Accept-Language: zh-cn\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Proxy-Connection: Close\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Host: $host\r\n"</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Pragma: no-cache\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Cookie: $cookie\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"\r\n\r\n"</span><span style="color:rgb(0, 119, 0)">;  <br />        }else{ <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">;  <br />            if(!empty(</span><span style="color:rgb(0, 0, 187)">$query</span><span style="color:rgb(0, 119, 0)">)) <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"GET $path?$query HTTP/1.0\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            else <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"GET $path HTTP/1.0\r\n"</span><span style="color:rgb(0, 119, 0)">; <br /><br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Accept: */*\r\n"</span><span style="color:rgb(0, 119, 0)">;  <br />            if(!empty(</span><span style="color:rgb(0, 0, 187)">$referer</span><span style="color:rgb(0, 119, 0)">))  <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Referer: $referer\r\n"</span><span style="color:rgb(0, 119, 0)">; <br /><br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Accept-Language: zh-cn\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Connection: Close\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Host: $host\r\n"</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Pragma: no-cache\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Cookie: $cookie\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"\r\n\r\n"</span><span style="color:rgb(0, 119, 0)">;  <br />        } <br />        </span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">fsockopen </span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$post_host</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$port</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$errno</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$errstr</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">3</span><span style="color:rgb(0, 119, 0)">); <br />        if(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">){  <br />            </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">_error</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">0</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">fwrite</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">); <br />        }else{ <br />            </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">_error</span><span style="color:rgb(0, 119, 0)">++;  <br />            if(</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">error</span><span style="color:rgb(0, 119, 0)">&gt;</span><span style="color:rgb(0, 0, 187)">5</span><span style="color:rgb(0, 119, 0)">){  <br />                return </span><span style="color:rgb(0, 0, 187)">null</span><span style="color:rgb(0, 119, 0)">; <br />            }else{  <br />                return </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">_getUrl</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$url</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$referer</span><span style="color:rgb(0, 119, 0)">);  <br />            } <br />        } <br />        </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">stream_get_contents</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">); <br />         <br />        </span><span style="color:rgb(0, 0, 187)">preg_match_all </span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"/Set-Cookie: (.+?)=(.+?);/"</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$_matches</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">PREG_SET_ORDER</span><span style="color:rgb(0, 119, 0)">);  <br />        </span><span style="color:rgb(0, 0, 187)">$tmp</span><span style="color:rgb(0, 119, 0)">=array(); <br />        for(</span><span style="color:rgb(0, 0, 187)">$i</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">0</span><span style="color:rgb(0, 119, 0)">;</span><span style="color:rgb(0, 0, 187)">$i</span><span style="color:rgb(0, 119, 0)">&lt;</span><span style="color:rgb(0, 0, 187)">count</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$_matches</span><span style="color:rgb(0, 119, 0)">);</span><span style="color:rgb(0, 0, 187)">$i</span><span style="color:rgb(0, 119, 0)">++){ <br />            </span><span style="color:rgb(0, 0, 187)">$tmp</span><span style="color:rgb(0, 119, 0)">[]=</span><span style="color:rgb(0, 0, 187)">$_matches</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">$i</span><span style="color:rgb(0, 119, 0)">][</span><span style="color:rgb(0, 0, 187)">1</span><span style="color:rgb(0, 119, 0)">].</span><span style="color:rgb(221, 0, 0)">"="</span><span style="color:rgb(0, 119, 0)">.</span><span style="color:rgb(0, 0, 187)">$_matches</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">$i</span><span style="color:rgb(0, 119, 0)">][</span><span style="color:rgb(0, 0, 187)">2</span><span style="color:rgb(0, 119, 0)">]; <br />        } <br />        </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">cookie</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$cookie</span><span style="color:rgb(0, 119, 0)">.</span><span style="color:rgb(221, 0, 0)">";"</span><span style="color:rgb(0, 119, 0)">.</span><span style="color:rgb(0, 0, 187)">implode</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">';'</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$tmp</span><span style="color:rgb(0, 119, 0)">);  <br /><br />        </span><span style="color:rgb(0, 0, 187)">fclose</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">); <br />        return </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">; <br />    }  <br /><br /><br />} <br /></span><span style="color:rgb(0, 0, 187)">?&gt;</span>  </span></code></div></div></div></div></div>
        
      <br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/souhubokezidongfatie" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/1147514650350174388" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1147514650350174388" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1147514650350174388" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>souhubokezidongfatie</sites:pageName><sites:revision>2</sites:revision></entry><entry gd:etag="&quot;YD4peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/3589845807224131167</id><published>2009-04-27T03:55:35.856Z</published><updated>2009-04-27T08:05:59.250Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-27T08:05:59.250Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>新浪博客自动发贴机（更新版本）</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr"><div class="sites-embed-align-left-wrapping-off"><div class="sites-embed-border-on sites-embed sites-embed-full-width" style="width:100%;"><h4 class="sites-embed-title">源码</h4><div class="sites-embed-content sites-embed-type-text"><div class="sites-embed-content-textbox"><div dir="ltr"><code><span style="color:rgb(0, 0, 0)"><span style="color:rgb(0, 0, 187)">&lt;?php  <br /><br /></span><span style="color:rgb(255, 128, 0)">/**  <br />* sina 新浪博客自动发BLOG机 本代码只供学习交流用，请不要用于非法用途 <br />* author : hetal  <br />* qq     : 231073376 <br />* <br />*/ <br /></span><span style="color:rgb(0, 0, 187)">$a </span><span style="color:rgb(0, 119, 0)">= new </span><span style="color:rgb(0, 0, 187)">Sina_Blog</span><span style="color:rgb(0, 119, 0)">;  <br /></span><span style="color:rgb(0, 0, 187)">$title</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">mb_convert_encoding </span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"T条比啊"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">"utf8"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">"utf8,gbk"</span><span style="color:rgb(0, 119, 0)">);  <br /></span><span style="color:rgb(0, 0, 187)">$text</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">mb_convert_encoding </span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"&lt;a href='ddd'&gt;xxxxxjfxx&lt;/a&gt;另 是只吸w"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">"utf8"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">"utf8,gbk"</span><span style="color:rgb(0, 119, 0)">);  <br /></span><span style="color:rgb(255, 128, 0)">//1.登录 <br /></span><span style="color:rgb(0, 119, 0)">if(</span><span style="color:rgb(0, 0, 187)">$a</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">login</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"username"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">"password"</span><span style="color:rgb(0, 119, 0)">)){  <br />    echo </span><span style="color:rgb(221, 0, 0)">"Login Success\n"</span><span style="color:rgb(0, 119, 0)">; <br />}else{ <br />    die(</span><span style="color:rgb(221, 0, 0)">"Login Fail\n"</span><span style="color:rgb(0, 119, 0)">);  <br />} <br /></span><span style="color:rgb(255, 128, 0)">//2.发贴 <br /></span><span style="color:rgb(0, 0, 187)">$r</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$a</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">post</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$title</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$text</span><span style="color:rgb(0, 119, 0)">);  <br />if(</span><span style="color:rgb(0, 0, 187)">$r</span><span style="color:rgb(0, 119, 0)">==-</span><span style="color:rgb(0, 0, 187)">1</span><span style="color:rgb(0, 119, 0)">){ <br />echo </span><span style="color:rgb(221, 0, 0)">"POST FAIL"</span><span style="color:rgb(0, 119, 0)">;  <br />}else{ <br />echo </span><span style="color:rgb(221, 0, 0)">"POST OK"</span><span style="color:rgb(0, 119, 0)">; <br />echo </span><span style="color:rgb(221, 0, 0)">"\n"</span><span style="color:rgb(0, 119, 0)">;  <br />echo </span><span style="color:rgb(221, 0, 0)">"http://blog.sina.com.cn/s/blog_$r.html"</span><span style="color:rgb(0, 119, 0)">; <br />echo </span><span style="color:rgb(221, 0, 0)">"\n"</span><span style="color:rgb(0, 119, 0)">; <br />}  <br /><br />class </span><span style="color:rgb(0, 0, 187)">Sina_Blog</span><span style="color:rgb(0, 119, 0)">{ <br />    var </span><span style="color:rgb(0, 0, 187)">$proxyPort</span><span style="color:rgb(0, 119, 0)">;  <br />    var </span><span style="color:rgb(0, 0, 187)">$proxyHost</span><span style="color:rgb(0, 119, 0)">; <br />    var </span><span style="color:rgb(0, 0, 187)">$cookie</span><span style="color:rgb(0, 119, 0)">;  <br />    var </span><span style="color:rgb(0, 0, 187)">$_error</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">0</span><span style="color:rgb(0, 119, 0)">; <br />    </span><span style="color:rgb(255, 128, 0)">//设置代理  <br />    </span><span style="color:rgb(0, 119, 0)">function </span><span style="color:rgb(0, 0, 187)">setProxy</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$proxyHost</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$proxyPort</span><span style="color:rgb(0, 119, 0)">){  <br />        </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyPort</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$proxyPort</span><span style="color:rgb(0, 119, 0)">;  <br />        </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyHost</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$proxyHost</span><span style="color:rgb(0, 119, 0)">; <br />    }  <br />    </span><span style="color:rgb(255, 128, 0)">//登录 <br />    </span><span style="color:rgb(0, 119, 0)">function </span><span style="color:rgb(0, 0, 187)">login</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$user</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$pass</span><span style="color:rgb(0, 119, 0)">){  <br />        </span><span style="color:rgb(0, 0, 187)">$cookie</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">cookie</span><span style="color:rgb(0, 119, 0)">;  <br />        </span><span style="color:rgb(0, 0, 187)">$post_data </span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"act=1&amp;entry=blog&amp;username=$user&amp;password=$pass"</span><span style="color:rgb(0, 119, 0)">; <br /><br />        </span><span style="color:rgb(0, 0, 187)">$post_data_le </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">strlen</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$post_data</span><span style="color:rgb(0, 119, 0)">);  <br />        if(!empty(</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyPort</span><span style="color:rgb(0, 119, 0)">) and !empty(</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyHost</span><span style="color:rgb(0, 119, 0)">)){  <br />            </span><span style="color:rgb(0, 0, 187)">$post_url</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"http://login.sina.com.cn/hd/signin.php"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$post_port</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyPort</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">$post_host</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyHost</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">$connect</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"Proxy-Connection"</span><span style="color:rgb(0, 119, 0)">;  <br />        }else{ <br />            </span><span style="color:rgb(0, 0, 187)">$post_url</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"/hd/signin.php"</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">$post_port</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">80</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$connect</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"Connection"</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">$post_host</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"login.sina.com.cn"</span><span style="color:rgb(0, 119, 0)">;  <br />        } <br />        </span><span style="color:rgb(0, 0, 187)">$data</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"POST $post_url HTTP/1.1\nAccept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*\nReferer: http://www.sina.com.cn\nAccept-Language: zh-cn\nContent-Type: application/x-www-form-urlencoded\nAccept-Encoding: gzip, deflate\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Alexa Toolbar)\nHost: passport.baidu.com\nContent-Length: $post_data_le\n$connect: Close\nCache-Control: no-cache\nCookie: $cookie\n\n$post_data\n"</span><span style="color:rgb(0, 119, 0)">; <br />        </span><span style="color:rgb(0, 0, 187)">$sock </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">fsockopen</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$post_host</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$post_port</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$errno</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$error</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">3</span><span style="color:rgb(0, 119, 0)">); <br />        if(!</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">){return </span><span style="color:rgb(0, 0, 187)">false</span><span style="color:rgb(0, 119, 0)">;}  <br />        </span><span style="color:rgb(0, 0, 187)">fputs</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$data</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">stream_set_timeout</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">3</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">stream_get_contents</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">str_replace</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"\n"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">str_replace</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"\t"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">fclose</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">);  <br />        </span><span style="color:rgb(0, 0, 187)">preg_match_all </span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"/Set-Cookie: (.+?)=(.+?);/"</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$_matches</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">PREG_SET_ORDER</span><span style="color:rgb(0, 119, 0)">);  <br />        </span><span style="color:rgb(0, 0, 187)">$tmp</span><span style="color:rgb(0, 119, 0)">=array(); <br />        for(</span><span style="color:rgb(0, 0, 187)">$i</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">0</span><span style="color:rgb(0, 119, 0)">;</span><span style="color:rgb(0, 0, 187)">$i</span><span style="color:rgb(0, 119, 0)">&lt;</span><span style="color:rgb(0, 0, 187)">count</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$_matches</span><span style="color:rgb(0, 119, 0)">);</span><span style="color:rgb(0, 0, 187)">$i</span><span style="color:rgb(0, 119, 0)">++){ <br />            </span><span style="color:rgb(0, 0, 187)">$tmp</span><span style="color:rgb(0, 119, 0)">[]=</span><span style="color:rgb(0, 0, 187)">$_matches</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">$i</span><span style="color:rgb(0, 119, 0)">][</span><span style="color:rgb(0, 0, 187)">1</span><span style="color:rgb(0, 119, 0)">].</span><span style="color:rgb(221, 0, 0)">"="</span><span style="color:rgb(0, 119, 0)">.</span><span style="color:rgb(0, 0, 187)">$_matches</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">$i</span><span style="color:rgb(0, 119, 0)">][</span><span style="color:rgb(0, 0, 187)">2</span><span style="color:rgb(0, 119, 0)">]; <br />        } <br />        </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">cookie</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$cookie</span><span style="color:rgb(0, 119, 0)">.</span><span style="color:rgb(221, 0, 0)">";"</span><span style="color:rgb(0, 119, 0)">.</span><span style="color:rgb(0, 0, 187)">implode</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">';'</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$tmp</span><span style="color:rgb(0, 119, 0)">);  <br />        if(</span><span style="color:rgb(0, 0, 187)">stripos</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">cookie</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">"UNIPROU"</span><span style="color:rgb(0, 119, 0)">)!==</span><span style="color:rgb(0, 0, 187)">false</span><span style="color:rgb(0, 119, 0)">){ <br />            return </span><span style="color:rgb(0, 0, 187)">true</span><span style="color:rgb(0, 119, 0)">;  <br />        }else{ <br />            return </span><span style="color:rgb(0, 0, 187)">false</span><span style="color:rgb(0, 119, 0)">; <br />        }  <br />    } <br /><br /><br />    function </span><span style="color:rgb(0, 0, 187)">_postInit</span><span style="color:rgb(0, 119, 0)">(){  <br />        </span><span style="color:rgb(0, 0, 187)">$url </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(221, 0, 0)">"http://control.blog.sina.com.cn/admin/article/article_add.php"</span><span style="color:rgb(0, 119, 0)">; <br />        </span><span style="color:rgb(0, 0, 187)">$rt </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">_getUrl</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$url</span><span style="color:rgb(0, 119, 0)">);  <br />        </span><span style="color:rgb(0, 0, 187)">preg_match_all </span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"/\&lt;input(.+?)\&gt;/i"</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$_matches</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">PREG_SET_ORDER</span><span style="color:rgb(0, 119, 0)">);  <br />        </span><span style="color:rgb(0, 0, 187)">$inputs</span><span style="color:rgb(0, 119, 0)">=array(); <br />        foreach(</span><span style="color:rgb(0, 0, 187)">$_matches </span><span style="color:rgb(0, 119, 0)">as </span><span style="color:rgb(0, 0, 187)">$_matche</span><span style="color:rgb(0, 119, 0)">){  <br />            </span><span style="color:rgb(0, 0, 187)">preg_match</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"/name\=\"(.+?)\"/i"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$_matche</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">0</span><span style="color:rgb(0, 119, 0)">],</span><span style="color:rgb(0, 0, 187)">$_name</span><span style="color:rgb(0, 119, 0)">); <br />            </span><span style="color:rgb(0, 0, 187)">preg_match</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"/value\=\"(.*?)\"/i"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$_matche</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">0</span><span style="color:rgb(0, 119, 0)">],</span><span style="color:rgb(0, 0, 187)">$_value</span><span style="color:rgb(0, 119, 0)">); <br />            </span><span style="color:rgb(0, 0, 187)">$inputs</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">$_name</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">1</span><span style="color:rgb(0, 119, 0)">]] = @</span><span style="color:rgb(0, 0, 187)">$_value</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">1</span><span style="color:rgb(0, 119, 0)">]; <br />        }  <br />        return </span><span style="color:rgb(0, 0, 187)">$inputs</span><span style="color:rgb(0, 119, 0)">; <br />    } <br /><br />    function </span><span style="color:rgb(0, 0, 187)">post</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$title</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$text</span><span style="color:rgb(0, 119, 0)">){  <br />        </span><span style="color:rgb(0, 0, 187)">$inputs </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">_postInit</span><span style="color:rgb(0, 119, 0)">();  <br />        </span><span style="color:rgb(0, 0, 187)">$inputs</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'blog_body'</span><span style="color:rgb(0, 119, 0)">] = </span><span style="color:rgb(0, 0, 187)">urlencode</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$text</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">$inputs</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'blog_class'</span><span style="color:rgb(0, 119, 0)">] = </span><span style="color:rgb(0, 0, 187)">0</span><span style="color:rgb(0, 119, 0)">; <br />        </span><span style="color:rgb(0, 0, 187)">$inputs</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'sina_sort_id'</span><span style="color:rgb(0, 119, 0)">] = </span><span style="color:rgb(0, 0, 187)">117</span><span style="color:rgb(0, 119, 0)">; <br />        </span><span style="color:rgb(0, 0, 187)">$inputs</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'blog_title'</span><span style="color:rgb(0, 119, 0)">] = </span><span style="color:rgb(0, 0, 187)">urlencode</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$title</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">$post_data</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">; <br />        foreach(</span><span style="color:rgb(0, 0, 187)">$inputs </span><span style="color:rgb(0, 119, 0)">as </span><span style="color:rgb(0, 0, 187)">$key</span><span style="color:rgb(0, 119, 0)">=&gt;</span><span style="color:rgb(0, 0, 187)">$value</span><span style="color:rgb(0, 119, 0)">){  <br />            </span><span style="color:rgb(0, 0, 187)">$post_data</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(0, 0, 187)">$key</span><span style="color:rgb(0, 119, 0)">.</span><span style="color:rgb(221, 0, 0)">"="</span><span style="color:rgb(0, 119, 0)">.</span><span style="color:rgb(0, 0, 187)">$value</span><span style="color:rgb(0, 119, 0)">.</span><span style="color:rgb(221, 0, 0)">"&amp;"</span><span style="color:rgb(0, 119, 0)">; <br />        } <br />        </span><span style="color:rgb(0, 0, 187)">$cookie</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">cookie</span><span style="color:rgb(0, 119, 0)">;  <br />        </span><span style="color:rgb(0, 0, 187)">$post_data_le </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">strlen</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$post_data</span><span style="color:rgb(0, 119, 0)">);  <br />        if(!empty(</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyPort</span><span style="color:rgb(0, 119, 0)">) and !empty(</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyHost</span><span style="color:rgb(0, 119, 0)">)){  <br />            </span><span style="color:rgb(0, 0, 187)">$post_url</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"http://control.blog.sina.com.cn/admin/article/article_post.php"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$post_port</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyPort</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">$connect</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"Proxy-Connection"</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">$post_host</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyHost</span><span style="color:rgb(0, 119, 0)">;  <br />        }else{ <br />            </span><span style="color:rgb(0, 0, 187)">$post_url</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"/admin/article/article_post.php"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$post_port</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">80</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$connect</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"Connection"</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">$post_host</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"control.blog.sina.com.cn"</span><span style="color:rgb(0, 119, 0)">; <br />        } <br />        </span><span style="color:rgb(0, 0, 187)">$data</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">"POST $post_url HTTP/1.1\nAccept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*\nAccept-Language: zh-cn\nContent-Type: application/x-www-form-urlencoded\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Alexa Toolbar)\nHost: tiebacommit.baidu.com\nContent-Length: $post_data_le\nConnection: Close\nCache-Control: no-cache\nCookie: $cookie\n\n$post_data\n"</span><span style="color:rgb(0, 119, 0)">; <br />        </span><span style="color:rgb(0, 0, 187)">$sock </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">fsockopen</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$post_host</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$post_port</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$errno</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$error</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">3</span><span style="color:rgb(0, 119, 0)">); <br />        if(empty(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">)){  <br />            return -</span><span style="color:rgb(0, 0, 187)">2</span><span style="color:rgb(0, 119, 0)">; <br />        } <br />        </span><span style="color:rgb(0, 0, 187)">fputs</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$data</span><span style="color:rgb(0, 119, 0)">);  <br />        </span><span style="color:rgb(0, 0, 187)">stream_set_timeout</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">3</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">stream_get_contents</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">str_replace</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"\n"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">str_replace</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"\t"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">fclose</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">);  <br /><br />        </span><span style="color:rgb(0, 0, 187)">preg_match</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"/data\"\:(.+?)\}/"</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$_match</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">$rt </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">str_replace</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"\""</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$_match</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">1</span><span style="color:rgb(0, 119, 0)">]); <br />        if(</span><span style="color:rgb(0, 0, 187)">strlen</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">)&lt;</span><span style="color:rgb(0, 0, 187)">10</span><span style="color:rgb(0, 119, 0)">){  <br />            return -</span><span style="color:rgb(0, 0, 187)">1</span><span style="color:rgb(0, 119, 0)">; <br />        }else{ <br />            return </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">; <br />        }  <br />    } <br />    function </span><span style="color:rgb(0, 0, 187)">_getUrl</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$url</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$referer</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">){  <br />        </span><span style="color:rgb(0, 0, 187)">$purl</span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">parse_url</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$url</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">$host  </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">$purl</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">"host"</span><span style="color:rgb(0, 119, 0)">];  <br />        if(!empty(</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyHost</span><span style="color:rgb(0, 119, 0)">) and !empty(</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyPort</span><span style="color:rgb(0, 119, 0)">)){  <br />            </span><span style="color:rgb(0, 0, 187)">$port</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyPort</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">$post_host</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">proxyHost</span><span style="color:rgb(0, 119, 0)">;  <br />        }else{ <br />            </span><span style="color:rgb(0, 0, 187)">$post_host</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$purl</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'host'</span><span style="color:rgb(0, 119, 0)">]; <br />            if(empty(</span><span style="color:rgb(0, 0, 187)">$purl</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'port'</span><span style="color:rgb(0, 119, 0)">])){  <br />                </span><span style="color:rgb(0, 0, 187)">$port</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">80</span><span style="color:rgb(0, 119, 0)">; <br />            }else{ <br />                </span><span style="color:rgb(0, 0, 187)">$port</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$purl</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'port'</span><span style="color:rgb(0, 119, 0)">];  <br />            } <br />        } <br />        </span><span style="color:rgb(0, 0, 187)">$cookie </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">cookie</span><span style="color:rgb(0, 119, 0)">;  <br />        </span><span style="color:rgb(0, 0, 187)">$path</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">$purl</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'path'</span><span style="color:rgb(0, 119, 0)">]; <br />        </span><span style="color:rgb(0, 0, 187)">$query</span><span style="color:rgb(0, 119, 0)">=empty(</span><span style="color:rgb(0, 0, 187)">$purl</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'query'</span><span style="color:rgb(0, 119, 0)">])?</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">:</span><span style="color:rgb(0, 0, 187)">$purl</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'query'</span><span style="color:rgb(0, 119, 0)">]; <br />        if(!empty(</span><span style="color:rgb(0, 0, 187)">$proxyhost</span><span style="color:rgb(0, 119, 0)">) and !empty(</span><span style="color:rgb(0, 0, 187)">$proxyport</span><span style="color:rgb(0, 119, 0)">)){  <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"GET $url HTTP/1.0\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Accept: */*\r\n"</span><span style="color:rgb(0, 119, 0)">;  <br />            if(!empty(</span><span style="color:rgb(0, 0, 187)">$referer</span><span style="color:rgb(0, 119, 0)">))  <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Referer: $referer\r\n"</span><span style="color:rgb(0, 119, 0)">; <br /><br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Accept-Language: zh-cn\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Proxy-Connection: Close\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Host: $host\r\n"</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Pragma: no-cache\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Cookie: $cookie\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"\r\n\r\n"</span><span style="color:rgb(0, 119, 0)">;  <br />        }else{ <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">;  <br />            if(!empty(</span><span style="color:rgb(0, 0, 187)">$query</span><span style="color:rgb(0, 119, 0)">)) <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"GET $path?$query HTTP/1.0\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            else <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"GET $path HTTP/1.0\r\n"</span><span style="color:rgb(0, 119, 0)">; <br /><br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Accept: */*\r\n"</span><span style="color:rgb(0, 119, 0)">;  <br />            if(!empty(</span><span style="color:rgb(0, 0, 187)">$referer</span><span style="color:rgb(0, 119, 0)">))  <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Referer: $referer\r\n"</span><span style="color:rgb(0, 119, 0)">; <br /><br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Accept-Language: zh-cn\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Connection: Close\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Host: $host\r\n"</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Pragma: no-cache\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"Cookie: $cookie\r\n"</span><span style="color:rgb(0, 119, 0)">; <br />            </span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">.=</span><span style="color:rgb(221, 0, 0)">"\r\n\r\n"</span><span style="color:rgb(0, 119, 0)">;  <br />        } <br />        </span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">fsockopen </span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$post_host</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$port</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$errno</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$errstr</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">3</span><span style="color:rgb(0, 119, 0)">); <br />        if(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">){  <br />            </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">_error</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">0</span><span style="color:rgb(0, 119, 0)">;  <br />            </span><span style="color:rgb(0, 0, 187)">fwrite</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$content</span><span style="color:rgb(0, 119, 0)">); <br />        }else{ <br />            </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">_error</span><span style="color:rgb(0, 119, 0)">++;  <br />            if(</span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">error</span><span style="color:rgb(0, 119, 0)">&gt;</span><span style="color:rgb(0, 0, 187)">5</span><span style="color:rgb(0, 119, 0)">){  <br />                return </span><span style="color:rgb(0, 0, 187)">null</span><span style="color:rgb(0, 119, 0)">; <br />            }else{  <br />                return </span><span style="color:rgb(0, 0, 187)">$this</span><span style="color:rgb(0, 119, 0)">-&gt;</span><span style="color:rgb(0, 0, 187)">_getUrl</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$url</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$referer</span><span style="color:rgb(0, 119, 0)">);  <br />            } <br />        } <br />        </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">stream_get_contents</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">); <br />        </span><span style="color:rgb(0, 0, 187)">fclose</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$sock</span><span style="color:rgb(0, 119, 0)">);  <br />        return </span><span style="color:rgb(0, 0, 187)">$rt</span><span style="color:rgb(0, 119, 0)">; <br />    } <br /><br /><br />} <br /></span><span style="color:rgb(0, 0, 187)">?&gt;</span> </span></code></div></div></div></div></div><br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/xinlangbokezidongfatiejigengxinbanben-sina" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/3589845807224131167" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/3589845807224131167" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/3589845807224131167" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>xinlangbokezidongfatiejigengxinbanben-sina</sites:pageName><sites:revision>2</sites:revision></entry><entry gd:etag="&quot;YD4peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/3626616519772055303</id><published>2009-04-17T09:26:49.736Z</published><updated>2009-04-17T09:34:22.544Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-17T09:34:22.543Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>javascript下的iframe的跨域解决办法</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">这种方法，适合于相同父域，如xxx.hetao.name，和bbb.hetao.name，在调用页里和iframe里的被调用页面里加上<br />document.domain="hetao.name"<br />这样的代码就好了<br /><br />详细参考：<a href="http://msdn.microsoft.com/en-us/library/cc196989%28VS.85%29.aspx" target="_blank" rel="nofollow">http://msdn.microsoft.com/en-us/library/cc196989(VS.85).aspx</a><br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/javascriptxiadeiframedekuayujiejuebanfa" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/3626616519772055303" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/3626616519772055303" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/3626616519772055303" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>javascriptxiadeiframedekuayujiejuebanfa</sites:pageName><sites:revision>2</sites:revision></entry><entry gd:etag="&quot;YD8peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/4035002191409884875</id><published>2009-04-07T11:55:26.946Z</published><updated>2009-04-07T12:11:55.686Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-07T12:11:55.685Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>QT的QNetworkCookie::parseCookies的一个bug</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">如果字符串有,号，会分析失败<br />如下面的：<br />

<p style="margin:0px;text-indent:0px" />
<p style="margin:0px;text-indent:0px">qDebug()&lt;&lt;"TT:"&lt;&lt;QNetworkCookie::parseCookies("PS=0;path=/;").length();</p>
<p style="margin:0px;text-indent:0px">qDebug()&lt;&lt;"TT:"&lt;&lt;QNetworkCookie::parseCookies("PS=0;path=/;, SU=0,878;path=/;,").length();</p><p style="margin:0px;text-indent:0px"><br /></p><p style="margin:0px;text-indent:0px">下面是返回结果：</p><p style="margin:0px;text-indent:0px"><br /></p><p style="margin:0px;text-indent:0px">TT: 1<br />TT: 0</p><p style="margin:0px;text-indent:0px"><br /></p><p style="margin:0px;text-indent:0px">下面这个就会解析失败！</p><p style="margin:0px;text-indent:0px"><br /></p><p style="margin:0px;text-indent:0px">而且这个重大bug会导致很多和header和cookie相关的方法都出现问题，如</p><p style="margin:0px;text-indent:0px"><span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:Arial;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-size:16px;font-weight:bold">QNetworkReply::header()</span></span></p><p style="margin:0px;text-indent:0px"><br /></p></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/qtdeqnetworkcookieparsecookiesdeyigebug" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/4035002191409884875" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/4035002191409884875" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/4035002191409884875" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>qtdeqnetworkcookieparsecookiesdeyigebug</sites:pageName><sites:revision>3</sites:revision></entry><entry gd:etag="&quot;YD4peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/2565218227875420002</id><published>2009-02-24T03:01:42.170Z</published><updated>2009-02-24T03:12:24.628Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-24T03:12:24.627Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>TSRMLS_D  TSRMLS_DC TSRMLS_C  TSRMLS_CC的使用方法</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">php模块的编写有个线程安全问题，有可能你的模块能很好的运行，但是如果加了线程安全的时候，你有可能会得到如下错误：<br /><br /><b>error: `tsrm_ls' undeclared (first use in this function)</b><br /><br />这种原因官方有2种解决办法（在ext/xsl/php_xsl.h文件中有说明）：<br /><br />
        
        
        
      
        

        

      
        
        
      
        
        
      
          <div class="sites-embed-align-left-wrapping-off"><div class="sites-embed-border-on sites-embed sites-embed-full-width" style="width:100%;"><div class="sites-embed-content sites-embed-type-text"><div class="sites-embed-content-textbox"><html xmlns:jot="http://www.google.com/ns/jotspot/srvtmpl/"><div dir="ltr">1) Add TSRM_FETCH(); calls to the functions where the tsrm_ls function is needed. This should be added as the first statement after variable declarations.<br /><br />2) Change the functions to include the magick TSRM_CC/TSRM_DC parameters.This will cause the tsrm_ls symbol to be passed when the function is called. This method might be time consuming depending on the number of functions and function calls in the code.</div></html></div></div></div></div>
        
      <br />在TSRM/TSRM.h文件中有如下定义：<br /><br />
        
        
        
      
        

        

      
        
        
      
        
        
      
          <div class="sites-embed-align-left-wrapping-off"><div class="sites-embed-border-on sites-embed sites-embed-full-width" style="width:100%;"><div class="sites-embed-content sites-embed-type-text"><div class="sites-embed-content-textbox"><html xmlns:jot="http://www.google.com/ns/jotspot/srvtmpl/"><div dir="ltr">#define TSRMLS_FETCH()                  void ***tsrm_ls = (void ***) ts_resource_ex(0, NULL)<br />#define TSRMLS_FETCH_FROM_CTX(ctx)      void ***tsrm_ls = (void ***) ctx<br />#define TSRMLS_SET_CTX(ctx)             ctx = (void ***) tsrm_ls<br />#define TSRMG(id, type, element)        (((type) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(id)])-&gt;element)<br />#define TSRMLS_D        void ***tsrm_ls<br />#define TSRMLS_DC       , TSRMLS_D<br />#define TSRMLS_C        tsrm_ls<br />#define TSRMLS_CC       , TSRMLS_C<br /></div></html></div></div></div></div>
        
      <br />我推荐用第二种，使用方法很简单：<br />1.在方法定义时加上TSRMLS_D（如果方法没有参数用这个）或者TSRMLS_DC（有1个以上的参数）<br />2.在方法调用时用TSRMLS_C（如果方法没有参数用这个）或者TSRMLS_CC（有1个以上的参数）<br /><br /><br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/tsrmlsdtsrmlsdctsrmlsctsrmlsccdeshiyongfangfa" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/2565218227875420002" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/2565218227875420002" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/2565218227875420002" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>tsrmlsdtsrmlsdctsrmlsctsrmlsccdeshiyongfangfa</sites:pageName><sites:revision>2</sites:revision></entry><entry gd:etag="&quot;YD8peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/1447704097502085140</id><published>2009-01-13T03:26:15.779Z</published><updated>2009-01-13T03:34:56.463Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-13T03:34:56.463Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>nginx和lvs的一些对比</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">上周6，同事peak参加了cu（chinaunix）举行的一个技术研讨会，主要讨论了数据库的优化，负载均衡等相关技术，其中最热之一就是lvs。我们现在系统可以说是将lvs用到了极致，可是一直都没有深入的研究，主要是运维同事在做这个，也上网查了些资料，了解了一些。同时他们也谈到了nginx做负载均衡。mail list里也有同事说这事，网上找了下，这篇文章很不错，于是就转过来<br /><br />
        
        
        
      
        

        

      
        
        
      
        
        
      
          
        
        
        
      
        

        

      
        
        
      
        
        
      
          <div class="sites-embed-align-left-wrapping-off"><div class="sites-embed-border-on sites-embed sites-embed-full-width" style="width:100%;"><h4 class="sites-embed-title">﻿nginx负载均衡和lvs负载均衡的比较分析</h4><div class="sites-embed-content sites-embed-type-text"><div class="sites-embed-content-textbox"><div dir="ltr">lvs和nginx都可以用作多机负载的方案，它们各有优缺，在生产环境中需要好好分析实际情况并加以利用。<br /> <br /> 首先提醒，做技术切不可人云亦云，我云即你云；同时也不可太趋向保守，过于相信旧有方式而等别人来帮你做垫被测试。把所有即时听说到的好东西加以钻研，从而提高自己对技术的认知和水平，乃是一个好习惯。<br /> <br /> 下面来分析一下两者：<br /> <br /> 一、lvs的优势：<br /> <br /> 1、抗负载能力强，因为lvs工作方式的逻辑是非常之简单，而且工作在网络4层仅做请求分发之用，没有流量，所以在效率上基本不需要太过考虑。在我手里的 lvs，仅仅出过一次问题：在并发最高的一小段时间内均衡器出现丢包现象，据分析为网络问题，即网卡或linux2.4内核的承载能力已到上限，内存和 cpu方面基本无消耗。<br /> <br /> 2、配置性低，这通常是一大劣势，但同时也是一大优势，因为没有太多可配置的选项，所以除了增减服务器，并不需要经常去触碰它，大大减少了人为出错的几率。<br /> <br /> 3、工作稳定，因为其本身抗负载能力很强，所以稳定性高也是顺理成章，另外各种lvs都有完整的双机热备方案，所以一点不用担心均衡器本身会出什么问题，节点出现故障的话，lvs会自动判别，所以系统整体是非常稳定的。<br /> <br /> 4、无流量，上面已经有所提及了。lvs仅仅分发请求，而流量并不从它本身出去，所以可以利用它这点来做一些线路分流之用。没有流量同时也保住了均衡器的IO性能不会受到大流量的影响。<br /> <br /> 5、基本上能支持所有应用，因为lvs工作在4层，所以它可以对几乎所有应用做负载均衡，包括http、数据库、聊天室等等。<br /> <br /> 另：lvs也不是完全能判别节点故障的，譬如在wlc分配方式下，集群里有一个节点没有配置VIP，会使整个集群不能使用，这时使用wrr分配方式则会丢掉一台机。目前这个问题还在进一步测试中。所以，用lvs也得多多当心为妙。<br /> <br /> 二、nginx和lvs作对比的结果<br /> <br /> 1、nginx工作在网络的7层，所以它可以针对http应用本身来做分流策略，比如针对域名、目录结构等，相比之下lvs并不具备这样的功能，所以 nginx单凭这点可利用的场合就远多于lvs了；但nginx有用的这些功能使其可调整度要高于lvs，所以经常要去触碰触碰，由lvs的第2条优点 看，触碰多了，人为出问题的几率也就会大。<br /> <br /> 2、nginx对网络的依赖较小，理论上只要ping得通，网页访问正常，nginx就能连得通，nginx同时还能区分内外网，如果是同时拥有内外网的 节点，就相当于单机拥有了备份线路；lvs就比较依赖于网络环境，目前来看服务器在同一网段内并且lvs使用direct方式分流，效果较能得到保证。另 外注意，lvs需要向托管商至少申请多一个ip来做Visual IP，貌似是不能用本身的IP来做VIP的。要做好LVS管理员，确实得跟进学习很多有关网络通信方面的知识，就不再是一个HTTP那么简单了。<br /> <br /> 3、nginx安装和配置比较简单，测试起来也很方便，因为它基本能把错误用日志打印出来。lvs的安装和配置、测试就要花比较长的时间了，因为同上所述，lvs对网络依赖比较大，很多时候不能配置成功都是因为网络问题而不是配置问题，出了问题要解决也相应的会麻烦得多。<br /> <br /> 4、nginx也同样能承受很高负载且稳定，但负载度和稳定度差lvs还有几个等级：nginx处理所有流量所以受限于机器IO和配置；本身的bug也还是难以避免的；nginx没有现成的双机热备方案，所以跑在单机上还是风险较大，单机上的事情全都很难说。<br /> <br /> 5、nginx可以检测到服务器内部的故障，比如根据服务器处理网页返回的状态码、超时等等，并且会把返回错误的请求重新提交到另一个节点。目前lvs中 ldirectd也能支持针对服务器内部的情况来监控，但lvs的原理使其不能重发请求。重发请求这点，譬如用户正在上传一个文件，而处理该上传的节点刚 好在上传过程中出现故障，nginx会把上传切到另一台服务器重新处理，而lvs就直接断掉了，如果是上传一个很大的文件或者很重要的文件的话，用户可能 会因此而恼火。<br /> <br /> 6、nginx对请求的异步处理可以帮助节点服务器减轻负载，假如使用apache直接对外服务，那么出现很多的窄带链接时apache服务器将会占用大 量内存而不能释放，使用多一个nginx做apache代理的话，这些窄带链接会被nginx挡住，apache上就不会堆积过多的请求，这样就减少了相 当多的内存占用。这点使用squid也有相同的作用，即使squid本身配置为不缓存，对apache还是有很大帮助的。lvs没有这些功能，也就无法能 比较。<br /> <br /> 7、nginx能支持http和email（email的功能估计比较少人用），lvs所支持的应用在这点上会比nginx更多。<br /> <br /> 在使用上，一般最前端所采取的策略应是lvs，也就是DNS的指向应为lvs均衡器，lvs的优点令它非常适合做这个任务。<br /> <br /> 重要的ip地址，最好交由lvs托管，比如数据库的ip、webservice服务器的ip等等，这些ip地址随着时间推移，使用面会越来越大，如果更换ip则故障会接踵而至。所以将这些重要ip交给lvs托管是最为稳妥的，这样做的唯一缺点是需要的VIP数量会比较多。<br /> <br /> nginx可作为lvs节点机器使用，一是可以利用nginx的功能，二是可以利用nginx的性能。当然这一层面也可以直接使用squid，squid的功能方面就比nginx弱不少了，性能上也有所逊色于nginx。<br /> <br /> nginx也可作为中层代理使用，这一层面nginx基本上无对手，唯一可以撼动nginx的就只有lighttpd了，不过lighttpd目前还没有 能做到nginx完全的功能，配置也不那么清晰易读。另外，中层代理的IP也是重要的，所以中层代理也拥有一个VIP和lvs是最完美的方案了。<br /> <br /> nginx也可作为网页静态服务器，不过超出了本文讨论的范畴，简单提一下。<br /> <br /> 具体的应用还得具体分析，如果是比较小的网站（日PV&lt;1000万），用nginx就完全可以了，如果机器也不少，可以用DNS轮询，lvs所耗费的机器还是比较多的；大型网站或者重要的服务，机器不发愁的时候，要多多考虑利用lvs。<br /><br />原文：<a href="http://www.sudone.com/nginx/nginx_vs_lvs.html" target="_blank" rel="nofollow">http://www.sudone.com/nginx/nginx_vs_lvs.html</a><br /></div></div></div></div></div>
        
      
        
      <br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/nginxhelvsdeyixieduibi" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/1447704097502085140" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1447704097502085140" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1447704097502085140" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>nginxhelvsdeyixieduibi</sites:pageName><sites:revision>3</sites:revision></entry><entry gd:etag="&quot;YD0peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/2468640662242002501</id><published>2009-01-12T04:27:51.659Z</published><updated>2009-01-12T04:29:13.894Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-12T04:29:13.894Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>2009年1月9号ChinaUnix的ppt</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr"><a href="http://sites.google.com/a/peak.name/files/2009-1-9-chinaunix" target="_blank">http://sites.google.com/a/peak.name/files/2009-1-9-chinaunix</a><br /><br />准备详细了解下lvs<br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/2009nian1yue9haochinaunixdeppt" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/2468640662242002501" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/2468640662242002501" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/2468640662242002501" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>2009nian1yue9haochinaunixdeppt</sites:pageName><sites:revision>1</sites:revision></entry><entry gd:etag="&quot;YDkpeyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/710319614228241567</id><published>2009-01-04T08:51:49.900Z</published><updated>2009-01-04T08:57:34.448Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-04T08:57:34.447Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>curl的get和post方法（支持ssl协议）</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">
        
        
        
      
        

        

      
        
        
      
        
        
      
          
        
        
        
      
        

        

      
        
        
      
        
        
      
          <div class="sites-embed-align-left-wrapping-off"><div class="sites-embed-border-on sites-embed sites-embed-full-width" style="width:100%;"><h4 class="sites-embed-title">源代码</h4><div class="sites-embed-content sites-embed-type-text"><div class="sites-embed-content-textbox"><div dir="ltr"><code><span style="color:rgb(0, 0, 0)"><span style="color:rgb(0, 0, 187)">&lt;?php<br /></span><span style="color:rgb(0, 119, 0)">class </span><span style="color:rgb(0, 0, 187)">net</span><span style="color:rgb(0, 119, 0)">{<br />    function </span><span style="color:rgb(0, 0, 187)">getIP</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$long</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">false</span><span style="color:rgb(0, 119, 0)">){<br />        if (</span><span style="color:rgb(0, 0, 187)">getenv</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"HTTP_CLIENT_IP"</span><span style="color:rgb(0, 119, 0)">) &amp;&amp; </span><span style="color:rgb(0, 0, 187)">strcasecmp</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">getenv</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"HTTP_CLIENT_IP"</span><span style="color:rgb(0, 119, 0)">), </span><span style="color:rgb(221, 0, 0)">"unknown"</span><span style="color:rgb(0, 119, 0)">))<br />            </span><span style="color:rgb(0, 0, 187)">$ip </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">getenv</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"HTTP_CLIENT_IP"</span><span style="color:rgb(0, 119, 0)">);<br />        else if (</span><span style="color:rgb(0, 0, 187)">getenv</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"HTTP_X_FORWARDED_FOR"</span><span style="color:rgb(0, 119, 0)">) &amp;&amp; </span><span style="color:rgb(0, 0, 187)">strcasecmp</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">getenv</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"HTTP_X_FORWARDED_FOR"</span><span style="color:rgb(0, 119, 0)">), </span><span style="color:rgb(221, 0, 0)">"unknown"</span><span style="color:rgb(0, 119, 0)">))<br />            </span><span style="color:rgb(0, 0, 187)">$ip </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">getenv</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"HTTP_X_FORWARDED_FOR"</span><span style="color:rgb(0, 119, 0)">);<br />        else if (</span><span style="color:rgb(0, 0, 187)">getenv</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"REMOTE_ADDR"</span><span style="color:rgb(0, 119, 0)">) &amp;&amp; </span><span style="color:rgb(0, 0, 187)">strcasecmp</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">getenv</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"REMOTE_ADDR"</span><span style="color:rgb(0, 119, 0)">), </span><span style="color:rgb(221, 0, 0)">"unknown"</span><span style="color:rgb(0, 119, 0)">))<br />            </span><span style="color:rgb(0, 0, 187)">$ip </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">getenv</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"REMOTE_ADDR"</span><span style="color:rgb(0, 119, 0)">);<br />        else if (isset(</span><span style="color:rgb(0, 0, 187)">$_SERVER</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'REMOTE_ADDR'</span><span style="color:rgb(0, 119, 0)">]) &amp;&amp; </span><span style="color:rgb(0, 0, 187)">$_SERVER</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'REMOTE_ADDR'</span><span style="color:rgb(0, 119, 0)">] &amp;&amp; </span><span style="color:rgb(0, 0, 187)">strcasecmp</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$_SERVER</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'REMOTE_ADDR'</span><span style="color:rgb(0, 119, 0)">], </span><span style="color:rgb(221, 0, 0)">"unknown"</span><span style="color:rgb(0, 119, 0)">))<br />            </span><span style="color:rgb(0, 0, 187)">$ip </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">$_SERVER</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'REMOTE_ADDR'</span><span style="color:rgb(0, 119, 0)">];<br />        else<br />            </span><span style="color:rgb(0, 0, 187)">$ip </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(221, 0, 0)">"unknow"</span><span style="color:rgb(0, 119, 0)">;<br /><br />        if ( </span><span style="color:rgb(0, 0, 187)">preg_match </span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(221, 0, 0)">"/(\d+\.\d+\.\d+\.\d+)$/"</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$ip</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$matchs</span><span style="color:rgb(0, 119, 0)">) ){<br />                </span><span style="color:rgb(0, 0, 187)">$ip </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">$matchs</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(0, 0, 187)">0</span><span style="color:rgb(0, 119, 0)">];<br />        }<br />        if(</span><span style="color:rgb(0, 0, 187)">$long</span><span style="color:rgb(0, 119, 0)">){<br />                </span><span style="color:rgb(0, 0, 187)">$ip</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">ip2long</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ip</span><span style="color:rgb(0, 119, 0)">);<br />        }<br />        return </span><span style="color:rgb(0, 0, 187)">$ip</span><span style="color:rgb(0, 119, 0)">;<br />    }<br /><br />    </span><span style="color:rgb(255, 128, 0)">//cookie的格式是 a=b;c=d这样的<br />    <br />    </span><span style="color:rgb(0, 119, 0)">function </span><span style="color:rgb(0, 0, 187)">get</span><span style="color:rgb(0, 119, 0)">( </span><span style="color:rgb(0, 0, 187)">$url</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$cookie</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$returnHeader</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">true</span><span style="color:rgb(0, 119, 0)">)<br />    {<br />        </span><span style="color:rgb(0, 0, 187)">$ch </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">curl_init</span><span style="color:rgb(0, 119, 0)">();<br /><br />        </span><span style="color:rgb(0, 0, 187)">$url_parts </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">parse_url</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$url</span><span style="color:rgb(0, 119, 0)">);<br />        if(</span><span style="color:rgb(0, 0, 187)">$url_parts</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'scheme'</span><span style="color:rgb(0, 119, 0)">]==</span><span style="color:rgb(221, 0, 0)">"https"</span><span style="color:rgb(0, 119, 0)">){<br />            </span><span style="color:rgb(0, 0, 187)">curl_setopt</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">CURLOPT_SSL_VERIFYHOST</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">false</span><span style="color:rgb(0, 119, 0)">);<br />            </span><span style="color:rgb(0, 0, 187)">curl_setopt</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">CURLOPT_SSL_VERIFYPEER</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">false</span><span style="color:rgb(0, 119, 0)">); <br />        }<br /><br />        if(!empty(</span><span style="color:rgb(0, 0, 187)">$cookie</span><span style="color:rgb(0, 119, 0)">)){<br />            </span><span style="color:rgb(0, 0, 187)">curl_setopt</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">CURLOPT_COOKIE</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$cookie</span><span style="color:rgb(0, 119, 0)">); <br />        }<br /><br />        </span><span style="color:rgb(0, 0, 187)">curl_setopt</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">CURLOPT_URL</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$url</span><span style="color:rgb(0, 119, 0)">);<br />        </span><span style="color:rgb(0, 0, 187)">curl_setopt</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">CURLOPT_HEADER</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$returnHeader</span><span style="color:rgb(0, 119, 0)">);<br />        </span><span style="color:rgb(0, 0, 187)">curl_setopt</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">CURLOPT_RETURNTRANSFER</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">true</span><span style="color:rgb(0, 119, 0)">);<br />        </span><span style="color:rgb(0, 0, 187)">$data </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">curl_exec</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">);<br />        </span><span style="color:rgb(0, 0, 187)">curl_close</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">);<br />        return </span><span style="color:rgb(0, 0, 187)">$data</span><span style="color:rgb(0, 119, 0)">;<br /><br /><br />    }<br />    </span><span style="color:rgb(255, 128, 0)">//data array ;array("key1"=&gt;value1,"key2"=&gt;value2....);<br /><br />    </span><span style="color:rgb(0, 119, 0)">function </span><span style="color:rgb(0, 0, 187)">post</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$url</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$data </span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$cookie</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$returnHeader</span><span style="color:rgb(0, 119, 0)">=</span><span style="color:rgb(0, 0, 187)">true</span><span style="color:rgb(0, 119, 0)">)<br />    {<br /><br /><br />        </span><span style="color:rgb(0, 0, 187)">$ch </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">curl_init</span><span style="color:rgb(0, 119, 0)">();<br /><br />        </span><span style="color:rgb(0, 0, 187)">$url_parts </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">parse_url</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$url</span><span style="color:rgb(0, 119, 0)">);<br />        if(</span><span style="color:rgb(0, 0, 187)">$url_parts</span><span style="color:rgb(0, 119, 0)">[</span><span style="color:rgb(221, 0, 0)">'scheme'</span><span style="color:rgb(0, 119, 0)">]==</span><span style="color:rgb(221, 0, 0)">"https"</span><span style="color:rgb(0, 119, 0)">){<br />            </span><span style="color:rgb(0, 0, 187)">curl_setopt</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">CURLOPT_SSL_VERIFYHOST</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">false</span><span style="color:rgb(0, 119, 0)">);<br />            </span><span style="color:rgb(0, 0, 187)">curl_setopt</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">CURLOPT_SSL_VERIFYPEER</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">false</span><span style="color:rgb(0, 119, 0)">); <br />        }<br /><br />        if(!empty(</span><span style="color:rgb(0, 0, 187)">$cookie</span><span style="color:rgb(0, 119, 0)">)){<br />            </span><span style="color:rgb(0, 0, 187)">curl_setopt</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">CURLOPT_COOKIE</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$cookie</span><span style="color:rgb(0, 119, 0)">); <br />        }<br />        </span><span style="color:rgb(0, 0, 187)">curl_setopt</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">CURLOPT_URL</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$url</span><span style="color:rgb(0, 119, 0)">);<br />        </span><span style="color:rgb(0, 0, 187)">curl_setopt</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">CURLOPT_HEADER</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$returnHeader</span><span style="color:rgb(0, 119, 0)">);<br />        </span><span style="color:rgb(0, 0, 187)">curl_setopt</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">CURLOPT_RETURNTRANSFER</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">true</span><span style="color:rgb(0, 119, 0)">);<br />        </span><span style="color:rgb(0, 0, 187)">curl_setopt</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">CURLOPT_POST</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">true</span><span style="color:rgb(0, 119, 0)">);<br />        </span><span style="color:rgb(0, 0, 187)">$encoded </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">;<br />        while (list(</span><span style="color:rgb(0, 0, 187)">$k</span><span style="color:rgb(0, 119, 0)">,</span><span style="color:rgb(0, 0, 187)">$v</span><span style="color:rgb(0, 119, 0)">) = </span><span style="color:rgb(0, 0, 187)">each</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$data</span><span style="color:rgb(0, 119, 0)">))<br />        {<br />                </span><span style="color:rgb(0, 0, 187)">$encoded </span><span style="color:rgb(0, 119, 0)">.= (</span><span style="color:rgb(0, 0, 187)">$encoded </span><span style="color:rgb(0, 119, 0)">? </span><span style="color:rgb(221, 0, 0)">"&amp;" </span><span style="color:rgb(0, 119, 0)">: </span><span style="color:rgb(221, 0, 0)">""</span><span style="color:rgb(0, 119, 0)">);<br />                </span><span style="color:rgb(0, 0, 187)">$encoded </span><span style="color:rgb(0, 119, 0)">.= </span><span style="color:rgb(0, 0, 187)">rawurlencode</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$k</span><span style="color:rgb(0, 119, 0)">).</span><span style="color:rgb(221, 0, 0)">"="</span><span style="color:rgb(0, 119, 0)">.</span><span style="color:rgb(0, 0, 187)">rawurlencode</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$v</span><span style="color:rgb(0, 119, 0)">);<br />        }<br />        </span><span style="color:rgb(0, 0, 187)">curl_setopt</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">CURLOPT_POSTFIELDS</span><span style="color:rgb(0, 119, 0)">, </span><span style="color:rgb(0, 0, 187)">$encoded</span><span style="color:rgb(0, 119, 0)">);<br />        </span><span style="color:rgb(0, 0, 187)">$data </span><span style="color:rgb(0, 119, 0)">= </span><span style="color:rgb(0, 0, 187)">curl_exec</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">);<br />        </span><span style="color:rgb(0, 0, 187)">curl_close</span><span style="color:rgb(0, 119, 0)">(</span><span style="color:rgb(0, 0, 187)">$ch</span><span style="color:rgb(0, 119, 0)">);<br />        return </span><span style="color:rgb(0, 0, 187)">$data</span><span style="color:rgb(0, 119, 0)">;<br /><br /><br /><br />    }<br />}<br /></span><span style="color:rgb(0, 0, 187)">?&gt;</span></span></code></div></div></div></div></div>
        
      
        
      <br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/curl-get-post-ssl-https" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/710319614228241567" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/710319614228241567" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/710319614228241567" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>curl-get-post-ssl-https</sites:pageName><sites:revision>5</sites:revision></entry><entry gd:etag="&quot;YD0peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/2319485807416222096</id><published>2008-12-12T03:51:37.459Z</published><updated>2008-12-12T03:51:31.491Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-12T03:51:31.491Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>彻底隐藏滚动条：解决IE下滚动条的自适应隐藏(转载)</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr"><p>如何让IE下的滚动条在内容少的时候隐藏得更彻底呢？</p>
<p>滚动条的出现使固定的有限空间能够展示更多的内容。但是当展示内容很少的时候，滚动条还需要吗？这个情况下,Firefox会将滚动条隐藏得很彻底，但是，IE做不到这样，还留有滚动条的灰色痕迹。对比图如下：<br />
Firefox 3.0.1:<br />
<img align="middle" alt="Firefox隐藏滚动条" height="518" src="http://v.886.cn/5Zzn/134973803/134973803_32267.png" width="500" /></p>
<p>IE7为例，IE6是同样的状况：<br />
<img align="middle" alt="IE下滚动条隐藏得不彻底" height="518" src="http://v.886.cn/5Zzn/134973801/134973801_12731.png" width="500" /></p>
<p>解决这个问题，采用&lt;body scroll=”no”&gt;的方法不妥，将使这个窗口始终没有滚动条，多出的内容会被隐藏，看不到。</p>
<p>我们需要这样的一种解决方案：当展示内容没有超出当前窗口范围时，将滚动条隐藏得无影无踪（就像FF做得到的那样）；当内容超出当前窗口范围时，滚动条要出来发挥作用（scroll=”no”）没做到。</p>
<p>采用JS实现的完整代码如下：<br />
<code><br />
<font color="#993300">&lt;!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;<br />
&lt;html xmlns=”http://www.w3.org/1999/xhtml”&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;解决IE下的滚动条显示与隐藏的自适应&lt;/title&gt;<br />
&lt;meta http-equiv=”content-type” content=”text/html; charset=utf-8″ /&gt;<br />
&lt;meta name=”keywords” content=”" /&gt;<br />
&lt;meta name=”description” content=”" /&gt;<br />
&lt;link rel=”stylesheet” type=”text/css” media=”screen” href=”" mce_href=”" /&gt;<br />
&lt;style&gt;<br />
body{margin:0;padding:0;}<br />
&lt;/style&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;div&gt;<br />
&lt;p&gt;testtesttesttesttesttesttesttesttestte ssttesttesttesttes testtesttestte sttestte sttesttestt esttest&lt;/p&gt;<br />
&lt;p&gt;test&lt;/p&gt;<br />
&lt;p&gt;test&lt;/p&gt;<br />
&lt;p&gt;test&lt;/p&gt;<br />
&lt;p&gt;test&lt;/p&gt;<br />
&lt;p&gt;test&lt;/p&gt;<br />
&lt;p&gt;test&lt;/p&gt;<br />
&lt;p&gt;test&lt;/p&gt;<br />
&lt;p&gt;test&lt;/p&gt;<br />
&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
&lt;SCRIPT LANGUAGE=”JavaScript”&gt;<br />
&lt;!–<br />
function autoScrollResize() {<br />
var content_h = document.body.clientHeight; // 内容高度<br />
var content_w = document.body.clientWidth;<br />
var broswer_h = document.documentElement.clientHeight; // 浏览器窗口的可视高度<br />
var broswer_w = document.documentElement.clientWidth;<br />
if(content_h &lt; broswer_h &amp;&amp; content_w &lt; broswer_w) {<br />
document.getElementsByTagName(’body’)[0].style.overflow = ‘hidden’;<br />
document.getElementsByTagName(’html’)[0].style.overflow = ‘hidden’; // 在DTD标准下，为html元素设置overflow:hidden才能去掉滚动条<br />
} else{<br />
document.getElementsByTagName(’html’)[0].style.overflow = ‘auto’;<br />
}<br />
}<br />
window.onload = function() {<br />
if(window.ActiveXObject) { // 针对IE<br />
autoScrollResize();<br />
window.attachEvent(”onresize”, autoScrollResize); // 使用ie的resize时事件监听<br />
}<br />
}<br />
//–&gt;<br />
&lt;/SCRIPT&gt;</font><br />
对代码进行的简要分析如下：</code></p>
<ol><li>只是需要对IE做这个调整，<font color="#993300">if(window.ActiveXObject)</font>只对IE起作用。</li><li>onresize事件保证了在窗口缩放的时候，能够对内容是否超出窗口范围进行判断。这个事件的监听需要使用到<font color="#993300" face="Courier New">window.attachEvent()</font>方式才对IE起作用。</li><li><font color="#993300" face="Courier New">document.body.clientHeight</font>获得展示内容的高度，<font color="#993300" face="Courier New">document.documentElement.clientHeight</font>获得浏览器窗口的高度。</li><li>一般情况下，给body标签加上“overflow:hidden”属性即可，但好像不起作用，原因在于文档头引入了DTD标准，这个时候需要给html标签设置“overflow:hidden”属性，这样就可以完全隐藏滚动条了。</li></ol>
<p>至此，解决，附图一张：</p>
<p><img align="middle" alt="IE内容未超出 隐藏滚动条" height="518" src="http://v.886.cn/5Zzn/134973804/134973804_1612.png" width="500" /></p>
<p><img align="middle" alt="ie内容超出 显示滚动条" height="386" src="http://v.886.cn/5Zzn/134966541/134966541_170.png" width="479" /></p><p><br /></p><p>原文件：<a href="http://www.iaiau.cn/2008/08-08/ie-yincang-gundongtiao/" target="_blank" rel="nofollow">http://www.iaiau.cn/2008/08-08/ie-yincang-gundongtiao/</a><br /></p></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/chediyincanggundongtiaojiejueiexiagundongtiaodezishiyingyincangzhuanzai" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/2319485807416222096" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/2319485807416222096" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/2319485807416222096" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>chediyincanggundongtiaojiejueiexiagundongtiaodezishiyingyincangzhuanzai</sites:pageName><sites:revision>1</sites:revision></entry><entry gd:etag="&quot;YDkpeyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/1075357839181871943</id><published>2008-12-05T09:26:11.004Z</published><updated>2008-12-08T05:45:29.029Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-08T05:45:29.028Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>php扩展实现初始化一个类，并自动执行构造方法（实现php的new运算符）</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">php扩展实现php的new运算符。<br />这个过程有2个步骤，一个是生成zend_class_entry的一个指针，另一步是执行构造方法<br /><br /><br />
        
        
        
      
        

        

      
        
        
      
        
        
      
          
        
        
        
      
        

        

      
        
        
      
        
        
      
          <div class="sites-embed-align-left-wrapping-off"><div class="sites-embed-border-on sites-embed sites-embed-full-width" style="width:100%;"><h4 class="sites-embed-title">源代码</h4><div class="sites-embed-content sites-embed-type-text"><div class="sites-embed-content-textbox"><div dir="ltr">zend_class_entry *ce = ZEND_STANDARD_CLASS_DEF_PTR;<br />//加载一个类名为name的类，这是new的第一步<br />if((ce = zend_fetch_class(Z_STRVAL_P(name), Z_STRLEN_P(name), ZEND_FETCH_CLASS_AUTO TSRMLS_CC))==NULL){<br />    php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not find class '%s'", name);<br />    return NULL;<br />}<br />//把zend_class_entry转换成一个zval<br />zval *object;<br />MAKE_STD_ZVAL(object);<br />object_init_ex(object,ce);<br />//判断是否有构造方法<br />if (ce-&gt;constructor) {<br />    zval method;<br />    INIT_ZVAL(method);<br />    //ZVAL_STRING(&amp;method, "run", 0);<br />    ZVAL_STRING(&amp;method, ce-&gt;constructor-&gt;common.function_name, 0);<br />    zval *rt;<br />    MAKE_STD_ZVAL(rt);<br />    //执行构造方法<br />    if(call_user_function_ex(NULL, &amp;object, &amp;method, &amp;rt, 0, NULL, 0,NULL TSRMLS_DC)!=SUCCESS){<br />    zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "Could not execute %s::%s()", ce-&gt;name, ce-&gt;constructor-&gt;common.function_name);<br />    }else{}<br />    //返回执行结果<br />    return_value = rt;<br />    zval_copy_ctor(return_value);<br />    zval_dtor(rt);<br />}<br />zval_dtor(object);<br /><br /></div></div></div></div></div>
        
      
        
      <br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/php-kuozhan-shixian-chushihua-yigelei-bing-zidong-zhixing-gouzao-fangfa-new" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/1075357839181871943" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1075357839181871943" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1075357839181871943" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>php-kuozhan-shixian-chushihua-yigelei-bing-zidong-zhixing-gouzao-fangfa-new</sites:pageName><sites:revision>5</sites:revision></entry><entry gd:etag="&quot;YD8peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/6654290251819567472</id><published>2008-12-03T04:13:21.694Z</published><updated>2008-12-08T04:40:25.092Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-08T04:40:25.091Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>PHP扩展实现include_once(__autoload)的功能</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">
        
        
        
      
        

        

      
        
        
      
        
        
      
          
        
        
        
      
        

        

      
        
        
      
        
        
      
          <div class="sites-embed-align-left-wrapping-off"><div class="sites-embed-border-on sites-embed sites-embed-full-width" style="width:100%;"><h4 class="sites-embed-title">源代码</h4><div class="sites-embed-content sites-embed-type-text"><div class="sites-embed-content-textbox"><div dir="ltr">/**<br /> * 自定义规则，加载php文件<br /> * @param zval *class_name 类名<br /> * @return int<br /> **/<br /><br />int SlightPHP_load(zval*class_name){<br />    zend_bool failure_retval=0;<br /><br />    zend_file_handle file_handle;<br />    zend_op_array *new_op_array=NULL;<br />    zval **original_return_value = EG(return_value_ptr_ptr);<br />    zval *inc_filename;<br />    //修复一个段错误<br />    MAKE_STD_ZVAL(inc_filename);<br /><br />    //这里是把类名转换成文件名，如果类名为myObject，他就会去找myObject.class.php的文件<br />    int l = spprintf(&amp;Z_STRVAL_P(inc_filename),0,"%s%s",Z_STRVAL_P(class_name),".class.php");<br /><br />    if (IS_ABSOLUTE_PATH(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename))) {<br />        cwd_state state;<br /><br />        state.cwd_length = 0;<br />        state.cwd = malloc(1);<br />        state.cwd[0] = 0;<br />        //这里判断是否已经加载过，如果不用判断的话，就实现了inluce或者require的功能<br />        failure_retval = (!virtual_file_ex(&amp;state, Z_STRVAL_P(inc_filename), NULL, 1) &amp;&amp;<br />            zend_hash_exists(&amp;EG(included_files), state.cwd, state.cwd_length+1));<br /><br />        free(state.cwd);<br />    }<br />    //打开php文件<br />    if (failure_retval) {<br />        /* do nothing */<br />    } else if (SUCCESS == zend_stream_open(Z_STRVAL_P(inc_filename), &amp;file_handle TSRMLS_CC)) {<br /><br />        if (!file_handle.opened_path) {<br />            file_handle.opened_path = estrndup(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename));<br />        }<br />        //加入到included_files里<br />        if (zend_hash_add_empty_element(&amp;EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1)==SUCCESS) {<br />            //编译php文件<br />            new_op_array = zend_compile_file(&amp;file_handle, ZEND_REQUIRE TSRMLS_CC);<br />            zend_destroy_file_handle(&amp;file_handle TSRMLS_CC);<br />        } else {<br />            zend_file_handle_dtor(&amp;file_handle);<br />            failure_retval=1;<br />        }<br />    } else {<br />        //zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));<br />    }<br />    if (new_op_array) {<br />        //执行php代码<br />        zend_execute(new_op_array TSRMLS_CC);<br />        destroy_op_array(new_op_array TSRMLS_CC);<br />        efree(new_op_array);<br />        //捕获异常<br />        if (EG(exception)) {<br />            zend_throw_exception_internal(NULL TSRMLS_CC);<br />        }<br />    }<br />    zval_dtor(inc_filename);<br /><br />    EG(return_value_ptr_ptr) = original_return_value;<br />}<br />                    <br /></div></div></div></div></div>
        
      
        
      <br /><br />
        
        
        
      
        

        

      
        
        
      
        
        
      
          
        
        
        
      
        

        

      
        
        
      
        
        
      
          <div class="sites-embed-align-left-wrapping-off"><div class="sites-embed-border-on sites-embed sites-embed-full-width" style="width:100%;"><h4 class="sites-embed-title">使用方法</h4><div class="sites-embed-content sites-embed-type-text"><div class="sites-embed-content-textbox"><div dir="ltr">zval *name;<br />....<br />SlightPHP_load(name);<br /></div></div></div></div></div>
        
      
        
      <br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/phpkuozhanshixianincludeonceautoloaddegongneng" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/6654290251819567472" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/6654290251819567472" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/6654290251819567472" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>phpkuozhanshixianincludeonceautoloaddegongneng</sites:pageName><sites:revision>3</sites:revision></entry><entry gd:etag="&quot;YD8peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/1484524249390649073</id><published>2008-12-05T06:42:26.620Z</published><updated>2008-12-05T10:02:15.848Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-05T06:58:30.276Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>zend_parse_parameters 参数分析</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">New parameter parsing functions<br />/*Zend扩展的参数获取*/<br />===============================<br /><br />It should be easier to parse input parameters to an extension function.<br />Hence, borrowing from Python's example, there are now a set of functions<br />that given the string of type specifiers, can parse the input parameters<br />and store the results in the user specified variables. This avoids most<br />of the IS_* checks and convert_to_* conversions. The functions also<br />check for the appropriate number of parameters, and try to output<br />meaningful error messages.<br /><br /><br />Prototypes<br />----------<br />/* Implemented. */<br />int zend_parse_parameters(int num_args TSRMLS_DC, char *type_spec, ...);<br />int zend_parse_parameters_ex(int flags, int num_args TSRMLS_DC, char *type_spec, ...);<br /><br />The zend_parse_parameters() function takes the number of parameters<br />passed to the extension function, the type specifier string, and the<br />list of pointers to variables to store the results in. The _ex() version<br />also takes 'flags' argument -- current only ZEND_PARSE_PARAMS_QUIET can<br />be used as 'flags' to specify that the function should operate quietly<br />and not output any error messages.<br /><br />Both functions return SUCCESS or FAILURE depending on the result.<br />/*2个方法成功返回SUCCESS，失败返回FAILURE*/<br /><br />The auto-conversions are performed as necessary. Arrays, objects, and<br />resources cannot be auto-converted.<br /><br /><br /><br />Type specifiers<br />//变量类型列表<br />---------------<br /> a        - array //数组<br /> b        - boolean, stored in zend_bool //boolean，存在zend_bool结构中<br /> d        - double<br /> f         - function or array containing php method call info (returned as zend_fcall_info* and zend_fcall_info_cache*)//方法<br /> h        - array (returned as HashTable*)//数组<br /> l         - long //长整型<br /> o        - object (of any type)//任意类型对象<br /> O       - object (of specific type, specified by class entry)//指定具体类型的对象，<font size="2"><span>需要提供目标对象的类类型</span></font><br /> r         - resource (stored in zval)//资源，如文件指针，数据库连接<br /> s        - string (with possible null bytes) and its length//字符串，需要指定长度<br /> z        - the actual zval//<font size="3"><font size="2"><span>无任何操作的</span></font><span><font face="Times New Roman"><font size="2">zval </font><br /></font></span></font><br /><br /> The following characters also have a meaning in the specifier string:<br />//特殊字符<br />        | - indicates that the remaining parameters are optional, they<br />            should be initialized to default values by the extension since they<br />            will not be touched by the parsing function if they are not<br />            passed to it.<br />        表示这个参数是可选项，这个参数如果没有，就会被设置成默认值<br /><br /><br />        / - use SEPARATE_ZVAL_IF_NOT_REF() on the parameter it follows<br />       表示是否是引用参数<br /><br /><br />        ! - the parameter it follows can be of specified type or NULL (only applies<br />        to 's', 'a', 'o', 'O', 'r', 'h', 'C', 'z', and 'Z'). If NULL is passed,<br />                 the results pointer is set to NULL as well.<br />        暗示NULL参数<br /><br />Examples<br />举例<br />--------<br />/* Gets a long, a string and its length, and a zval */<br />/* 获取长整型，字符串(字符串必须指定长度)，和zval类型*/<br />long l;<br />char *s;<br />int s_len;<br />zval *param;<br />if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lsz", &amp;l, &amp;s, &amp;s_len, &amp;param) == FAILURE) {<br />        return;<br />}<br /><br /><br />/* Gets an object of class specified by my_ce, and an optional double. */<br />/* 获取指定类类型的对象，和一个可选double*/<br />zval *obj;<br />double d = 0.5;<br />zend_class_entry *my_ce;<br />if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|d",&amp;obj, my_ce, &amp;d) == FAILURE) {<br />        return;<br />}<br /><br /><br />/* Gets an object or null, and an array. If null is passed for object, obj will be set to NULL. */<br />/* 获取一个可以为null的对象，一个数组*/<br />zval *obj;<br />zval *arr;<br />if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o!a",&amp;obj, &amp;arr) == FAILURE) {<br />        return;<br />}<br /><br /><br />/* Gets a separated array which can also be null. */<br />zval *arr;<br />if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/!",&amp;arr) == FAILURE) {<br />        return;<br />}<br /><br /><br />/* Get only the first three parameters (useful for varargs functions). */<br />zval *z;<br />zend_bool b;<br />zval *r;<br />if (zend_parse_parameters(3 TSRMLS_CC, "zbr!",<br />                          &amp;z, &amp;b, &amp;r) == FAILURE) {<br />        return;<br />}<br /><br /><br />/* Get either a set of 3 longs or a string. */<br />long l1, l2, l3;<br />char *s;<br />/* <br /> * The function expects a pointer to a integer in this case, not a long<br /> * or any other type.  If you specify a type which is larger<br /> * than a 'int', the upper bits might not be initialized<br /> * properly, leading to random crashes on platforms like<br /> * Tru64 or Linux/Alpha.<br /> */<br />int length;<br /><br />if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC,<br />                                 "lll", &amp;l1, &amp;l2, &amp;l3) == SUCCESS) {<br />        /* manipulate longs */<br />} else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC,<br />                                        "s", &amp;s, &amp;length) == SUCCESS) {<br />        /* manipulate string */<br />} else {<br />        /* output error */<br /><br />        return;<br />}<br /><br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/zend-parse-parameters-canshu-fenxi" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/1484524249390649073" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1484524249390649073" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1484524249390649073" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>zend-parse-parameters-canshu-fenxi</sites:pageName><sites:revision>3</sites:revision></entry><entry gd:etag="&quot;YDgpeyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/7259226477627131482</id><published>2008-12-05T08:50:21.693Z</published><updated>2008-12-05T09:24:06.731Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-05T09:24:06.730Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>CodeGen中如何使用可变参数（不固定参数）</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">CodeGen中如何使用可变参数（不固定参数）<br /><br />找到这个文件<br />pear/CodeGen/PECL/Element/Function.php<br />把204行的<br />protected $varargs = false;<br />改成<br />protected $varargs = true;<br /><br />然后你就可以在你最新生成的代码中找到新的3个变量<br /><br />int varargc; //可变参数的个数<br />zval ***real_argv;  //实际所有参数<br />zval ***varargv;      //可变参数<br /><br />获取的方法可以是<br />
*varargv[0]<br />
*varargv[1]<br />...<br />类似，不过索引只能小于ZEND_NUM_ARGS()返回的值。<br /><br />这种方法会改变全部方法的生成模式，还没有找到只改变其中一个的方法<br /><br /><div class="sites-embed-align-left-wrapping-off"><div class="sites-embed-border-on sites-embed sites-embed-full-width" style="width:100%;"><h4 class="sites-embed-title">源代码示例</h4><div class="sites-embed-content sites-embed-type-text"><div class="sites-embed-content-textbox"><div dir="ltr">PHP_METHOD(SlightPHP, parameters)<br />{<br />    zend_class_entry * _this_ce;<br /><br />    zval * _this_zval = NULL;<br /><br />    int varargc;<br />    zval ***real_argv;<br />    zval ***varargv;<br /><br />    if (zend_parse_method_parameters(MIN(ZEND_NUM_ARGS(), 0) TSRMLS_CC, getThis(), "O", &amp;_this_zval, SlightPHP_ce_ptr) == FAILURE) {<br />        return;<br />    }<br /><br />    _this_ce = Z_OBJCE_P(_this_zval);<br /><br /><br />    <br />    varargc = ZEND_NUM_ARGS();<br />    real_argv = (zval ***)calloc(sizeof(zval **), varargc);<br />    zend_get_parameters_array_ex(varargc, real_argv);<br />    varargc -= 0;<br />    varargv = real_argv + 0;<br />    do { <br />        array_init(return_value);<br />        int i=0;<br />        for(i=0; i&lt;varargc; i++) {<br />            add_next_index_zval(return_value, *real_argv[i]);<br />            //convert_to_string(*real_argv[i]);<br />            //zend_printf("%s\n",Z_STRVAL_P(*real_argv[i]));<br />        } <br />        zval_copy_ctor(return_value);<br />    } while (0);<br /><br />    free(real_argv);<br />}<br />/* }}} parameters */<br /></div></div></div></div></div><br /><br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/codegen-zhong-ruhe-shiyong-kebian-canshu-buguding-canshu" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/7259226477627131482" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/7259226477627131482" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/7259226477627131482" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>codegen-zhong-ruhe-shiyong-kebian-canshu-buguding-canshu</sites:pageName><sites:revision>4</sites:revision></entry><entry gd:etag="&quot;YD8peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/226154934115491610</id><published>2008-12-05T09:08:02.017Z</published><updated>2008-12-05T09:12:04.978Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-05T09:12:04.978Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>php扩展类型转换函数</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">参数类型转换函数     <br />convert_to_boolean_ex() <br />强制转换为布尔类型。<br />若原来是布尔值则保留，不做改动。长整型值0、双精度型值0.0、空字符串或字符串‘0’还有空值 NULL 都将被转换为 FALSE（本质上是一个整数 0）。数组和对象若为空则转换为 FALSE，否则转为 TRUE。除此之外的所有值均转换为 TRUE（本质上是一个整数 1）。<br /><br />convert_to_long_ex()<br />强制转换为长整型，这也是默认的整数类型。<br />如果原来是空值NULL、布尔型、资源当然还有长整型，则其值保持不变（因为本质上都是整数 0）。双精度型则被简单取整。包含有一个整数的字符串将会被转换为对应的整数，否则转换为 0。空的数组和对象将被转换为 0，否则将被转换为 1。 <br /><br />convert_to_double_ex()<br />强制转换为一个双精度型，这是默认的浮点数类型。<br />如果原来是空值 NULL 、布尔值、资源和双精度型则其值保持不变（只变一下变量类型）。包含有一个数字的字符串将被转换成相应的数字，否则被转换为 0.0。空的数组和对象将被转换为 0.0，否则将被转换为 1.0。<br /><br />convert_to_string_ex() <br />强制转换为字符串。空值 NULL 将被转换为空字符串。<br />布尔值 TRUE 将被转换为 ‘1’，FALSE 则被转为一个空字符串。长整型和双精度型会被分别转换为对应的字符串，数组将会被转换为字符串‘Array’，而对象则被转换为字符串‘Object’。 <br /><br />convert_to_array_ex(value) <br /> 强制转换为数组。若原来就是一数组则不作改动。<br />对象将被转换为一个以其属性为键名，以其属性值为键值的数组。（方法将会被转化为一个‘scalar’键，键值为方法名？待验证）空值 NULL 将被转换为一个空数组。除此之外的所有值都将被转换为仅有一个元素（下标为0）的数组，并且该元素即为该值。<br /><br />convert_to_object_ex(value)<br />强制转换为对象。若原来就是对象则不作改动。<br />空值NULL 将被转换为一个空对象。数组将被转换为一个以其键名为属性，键值为其属性值的对象。其他类型则被转换为一个具有‘scalar’属性的对象，‘scalar’属性的值即为该值本身。<br /><br />convert_to_null_ex(value)<br />强制转换为空值 NULL。<br /><br />在你的参数上使用这些函数可以确保传递给你的数据都是类型安全的。<br />如果提供的类型不是需要的类型，PHP 就会强制性地返回一个相应的伪值（比如空字符串、空的数组或对象、数值0或布尔值的 FALSE 等）来确保结果是一个已定义的状态。<br /><br />下面的代码是从前面讨论过的模块中摘录的，其中用到了这些转换函数：<br /><br />zval **parameter;<br /><br />if((ZEND_NUM_ARGS() != 1) || (zend_get_parameters_ex(1, &amp;parameter) != SUCCESS))<br />{<br />   WRONG_PARAM_COUNT;<br />}<br /><br />convert_to_long_ex(parameter);<br /><br />RETURN_LONG(Z_LVAL_P(parameter));<br /><br />这些方法非常实用，其实就是php类型转换的原生函数！<br /></div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/php-kuozhan-leixing-zhuanhuan-hanshu-extension-extensions" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/226154934115491610" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/226154934115491610" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/226154934115491610" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>php-kuozhan-leixing-zhuanhuan-hanshu-extension-extensions</sites:pageName><sites:revision>3</sites:revision></entry><entry gd:etag="&quot;YD8peyA.&quot;"><id>http://sites.google.com/feeds/content/hetao.name/hetao/1039507826718533673</id><published>2008-12-03T08:38:18.968Z</published><updated>2008-12-03T08:46:10.462Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-03T08:46:10.461Z</app:edited><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/sites/2008#announcement" label="announcement" /><title>Ext.MessageBox修改按钮默认名称的例子</title><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><table cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr">Ext.MessageBox内置好几种默认按钮，主要有：<br />
<font>Ext.Msg.OK,</font><code><br />
</code>Ext.Msg.OKCANCEL,<code><br />
</code>Ext.Msg.CANCEL,<code><br />
</code>Ext.Msg.YESNO,<code><br />
</code>Ext.Msg.YESNOCANCEL<br />
<br />

而他们的名字都是英文，我们想要中文，或者改成其它的名字，<font>自定义按钮上面的字：{"ok","我本来是ok的"}。<br /><br /></font><br />
<br />
        
        
        
      
        

        

      
        
        
      
        
        
      
          
        
        
        
      
        

        

      
        
        
      
        
        
      
          <div class="sites-embed-align-left-wrapping-off"><div class="sites-embed-border-on sites-embed sites-embed-full-width" style="width:100%;"><h4 class="sites-embed-title">源代码</h4><div class="sites-embed-content sites-embed-type-text"><div class="sites-embed-content-textbox"><div dir="ltr">function myExit(){<br />    if(!Ext){<br />        setTimeout(myExit,300)<br />    }else{<br />        Ext.onReady( function(){ <br />            Ext.MessageBox.show({ title: '提示信息标题', msg: '内容', width:300, buttons: {yes:"你点确定嘛",no:"取消",}, closable:false,fn: function(btn, text) { if(btn=="yes"){'}else{}}<br />            });<br />        });<br />    }<br />}<br />myExit();<br /></div></div></div></div></div>
        
      
        
      <br />
</div></td></tr></tbody></table></div></content><link rel="http://schemas.google.com/sites/2008#parent" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1926919826722808076" /><link rel="alternate" type="text/html" href="http://sites.google.com/a/hetao.name/hetao/ji-shu-wen-zhang/extmessageboxxiugaimorenanniumingchengdelizi" /><link rel="http://schemas.google.com/sites/2008#revision" type="application/atom+xml" href="http://sites.google.com/feeds/revision/hetao.name/hetao/1039507826718533673" /><link rel="self" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1039507826718533673" /><link rel="edit" type="application/atom+xml" href="http://sites.google.com/feeds/content/hetao.name/hetao/1039507826718533673" /><author><name>何涛</name><email>hetao@hetao.name</email></author><sites:pageName>extmessageboxxiugaimorenanniumingchengdelizi</sites:pageName><sites:revision>3</sites:revision></entry></feed>
