<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">博客园_一剑飞虹</title><subtitle type="text">道可道非常道，名可名非常名</subtitle><id>http://feed.cnblogs.com/blog/u/14860/rss</id><updated>2012-01-17T16:27:55Z</updated><author><name>greatqn</name><uri>http://www.cnblogs.com/greatqn/</uri></author><generator>CNBlogs BlogServer</generator><link rel="alternate" type="text/html" href="http://www.cnblogs.com/greatqn/"/><link rel="self" type="application/atom+xml" href="http://feed.cnblogs.com/blog/u/14860/rss"/><entry><id>http://www.cnblogs.com/greatqn/archive/2012/01/17/2324765.html</id><title type="text">花瓣采集js解析</title><summary type="text">第一步：收藏夹段jsjavascript:void(function(d,a,c,b){a[c]&amp;amp;&amp;amp;typeof a[c].showValidImages==&amp;#39;function&amp;#39;?a[c].showValidImages():(b=a.createElement(&amp;#39;script&amp;#39;),b.id=&amp;#39;huaban_script&amp;#39;,b.setAttribute(&amp;#39;charset&amp;#39;,&amp;#39;utf-8&amp;#39;),b.src=&amp;#39;http://huaban.com/js/pinmarklet.js?&amp;#39;+Mat</summary><published>2012-01-17T08:04:00Z</published><updated>2012-01-17T08:04:00Z</updated><author><name>greatqn</name><uri>http://www.cnblogs.com/greatqn/</uri></author><link rel="alternate" href="http://www.cnblogs.com/greatqn/archive/2012/01/17/2324765.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/greatqn/archive/2012/01/17/2324765.html"/><content type="html">&lt;p&gt;第一步：收藏夹段js&lt;/p&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;javascript:&lt;span style="color: #0000ff;"&gt;void&lt;/span&gt;(&lt;span style="color: #0000ff;"&gt;function&lt;/span&gt;(d,a,c,b){a[c]&amp;amp;&amp;amp;&lt;span style="color: #0000ff;"&gt;typeof&lt;/span&gt; a[c].showValidImages=='function'?a[c].showValidImages():(b=a.createElement('script'),b.id='huaban_script',b.setAttribute('charset','utf-8'),b.src='http://huaban.com/js/pinmarklet.js?'+Math.floor(+&lt;span style="color: #0000ff;"&gt;new&lt;/span&gt; Date/1E7),a.body.appendChild(b))}(window,document,'__huaban'));&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;如果js已经加载，就运行showValidImages()的方法。&lt;br /&gt;没有，则加载js:http://huaban.com/js/pinmarklet.js&lt;br /&gt;对a标签下的img能识别出来。&lt;br /&gt;&lt;br /&gt;第二步：提取pinmarklet.js&lt;br /&gt;把线上的js保存到本地huaban.js。&lt;br /&gt;43K,一千多行的代码，经过初步的压缩。&lt;br /&gt;从第一步的效果看，功能是遍历页面，组装成采集页面，再提交采集。&lt;br /&gt;&lt;br /&gt;线索：变量"__huaban" var global="__huaban";&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;document[global]._loaded=!0,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;document[global].showValidImages=showImagesAndInitPinBtn&lt;br /&gt;&lt;br /&gt;_loaded 初始化标记。&lt;br /&gt;&lt;br /&gt;线索：showValidImages方法。&lt;br /&gt;document[global].showValidImages=showImagesAndInitPinBtn&lt;br /&gt;&lt;br /&gt;方法1：showImagesAndInitPinBtn 字面意思明显。很好的命名。&lt;br /&gt;var a=getCurrentPageImagesWithEncapsulation();&lt;br /&gt;showImages(a),initPinBtn(a),window.scroll(0,0)&lt;br /&gt;a的数据结构：&lt;/p&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;w=242 h=284 src=http:&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;s4.42qu.us/img/jpg/book/3.jpg img=[object HTMLImageElement] alt= img2=[object HTMLImageElement] _parentNode=null&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;[{container:c,w:b.width,h:b.height,src:b.src,img:b,description:e+(d&amp;amp;&amp;amp;d.innerText||""),img2:b}]&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;方法2：getCurrentPageImagesWithEncapsulation&lt;br /&gt;参数初始&lt;br /&gt;var _document=d||document;eImages=eImages||[],opts=opts||{};&lt;br /&gt;遍历img&lt;/p&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;span style="color: #0000ff;"&gt;for&lt;/span&gt;(i=0;i&amp;lt;_document.images.length;i++){&lt;br /&gt;&lt;span style="color: #0000ff;"&gt;  var&lt;/span&gt; img=_document.images[i];&lt;br /&gt;  //alert(img);&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;[object HTMLImageElement]&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;}&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;isValidImage(img)&amp;amp;&amp;amp;(img=encapsulateImage(img),opts&amp;amp;&amp;amp;(img._parentNode=opts.parentNode||&lt;span style="color: #0000ff;"&gt;null&lt;/span&gt;),eImages.push(img))&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;span style="color: #0000ff;"&gt;function&lt;/span&gt; isValidImage(a){&lt;span style="color: #0000ff;"&gt;return&lt;/span&gt; a.style.display=="none"||a.className=="ImageToPin"||a.width&amp;lt;100||a.height&amp;lt;100?!1:!0}&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;如果img上加上class ImageToPin,就可以跳过被花瓣抓的命运。:)&lt;br /&gt;&lt;br /&gt;getVideoOnCustomerPage(_document,eImages);&lt;br /&gt;一些视频的处理。&lt;br /&gt;&lt;br /&gt;eImages.push(img)&lt;br /&gt;&lt;br /&gt;遍历背景图background-image等。&lt;br /&gt;checkbgimgs&lt;br /&gt;&lt;br /&gt;filters&lt;br /&gt;bgimgs&lt;br /&gt;&lt;br /&gt;遍历iframes&lt;/p&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;span style="color: #0000ff;"&gt;var&lt;/span&gt; iframes=_document.getElementsByTagName("iframe");&lt;br /&gt;&lt;span style="color: #0000ff;"&gt;for&lt;/span&gt;(&lt;span style="color: #0000ff;"&gt;var&lt;/span&gt; i=0;i&amp;lt;iframes.length;i++)&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;方法3：function showImages(a)&lt;br /&gt;c.onclick=function(){return pinImage(a),b()};&lt;br /&gt;&lt;br /&gt;方法4：function initPinBtn(a){generatePinBtn(),registerImagesForPinBtn(a)}&lt;br /&gt;&lt;br /&gt;方法5：generatePinBtn 生成采集按钮。&lt;br /&gt;&lt;br /&gt;方法6：registerImagesForPinBtn(a) 注册鼠标事件。&lt;br /&gt;&lt;br /&gt;方法7：取消按钮：&lt;/p&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;span style="color: #0000ff;"&gt;var&lt;/span&gt; b=&lt;span style="color: #0000ff;"&gt;function&lt;/span&gt;(){&lt;br /&gt;    &lt;span style="color: #0000ff;"&gt;return&lt;/span&gt; c.parentNode.removeChild(c),&lt;br /&gt;    d.parentNode.removeChild(d),&lt;br /&gt;    showingImage=!1,&lt;br /&gt;    selectedText="",&lt;br /&gt;    showFlash(),&lt;br /&gt;    window.scroll(0,lastScrollY),&lt;br /&gt;    !1&lt;br /&gt;},&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;方法8：采集按钮：pinImage&lt;br /&gt;http://www.w3school.com.cn/htmldom/met_win_open.asp&lt;/p&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;span style="color: #0000ff;"&gt;var&lt;/span&gt; e={&lt;br /&gt;    media:a.big_img?a.big_img.src:d.src,&lt;br /&gt;    url:c,&lt;br /&gt;    w:a.big_img?a.big_img.width:d.width,&lt;br /&gt;    h:a.big_img?a.big_img.height:d.height,&lt;br /&gt;    alt:d.alt,&lt;br /&gt;    title:a.title||document.title,&lt;br /&gt;    description:a.description||"",&lt;br /&gt;    media_type:a.media_type||"",&lt;br /&gt;    video:a.video||""&lt;br /&gt;};&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;全局参数：&lt;/p&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;span style="color: #0000ff;"&gt;var&lt;/span&gt; siteDomain="huaban.com",主域&lt;br /&gt;imageRoot="http://"+siteDomain+"/img",图片路径&lt;br /&gt;bookmarkletUrl="http://"+siteDomain+"/bookmarklet/",书签路径&lt;br /&gt;domChanged=!1,&lt;br /&gt;selectedText="",&lt;br /&gt;lastScrollY=0,&lt;br /&gt;isShareBtn=!1,&lt;br /&gt;pinBtn=&lt;span style="color: #0000ff;"&gt;null&lt;/span&gt;,&lt;br /&gt;hidePinBtnTimer=&lt;span style="color: #0000ff;"&gt;null&lt;/span&gt;,&lt;br /&gt;currentImage=&lt;span style="color: #0000ff;"&gt;null&lt;/span&gt;,&lt;br /&gt;imageDesc="",&lt;br /&gt;showingImage=!1,&lt;br /&gt;itemUrl="",&lt;br /&gt;skip=!1,&lt;br /&gt;skiphrefs=["http://www.diandian.com/wall"];&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;技巧1：&lt;br /&gt;(function(){alert("test");})();&lt;br /&gt;定义个方法，直接运行。好处是把一些临时变量圈起来了，不容易和其它代码发生冲突。&lt;br /&gt;&lt;br /&gt;技巧2：alert("\u4f60\u73b0");&lt;br /&gt;js文件里，避免出现中文。&lt;br /&gt;&lt;br /&gt;技巧3：!0 代替 true &lt;br /&gt;&lt;br /&gt;技巧4：|| &amp;amp;&amp;amp; 语法。&lt;br /&gt;&lt;br /&gt;基础方法：&lt;br /&gt;function isIE(){return/msie/i.test(navigator.userAgent)&amp;amp;&amp;amp;!/opera/i.test(navigator.userAgent)}&lt;br /&gt;function isSafari(){return/Safari/.test(navigator.userAgent)&amp;amp;&amp;amp;!/Chrome/.test(navigator.userAgent)}&lt;br /&gt;function isPinable(a) 判断是否局域网地址。&lt;br /&gt;function generateTag(a,b){var c=document.createElement(b||"div");return c.id=global+"_"+a,c}生成一个节点。&lt;br /&gt;&lt;br /&gt;正则表达式：&lt;br /&gt;http://hzjavaeyer.group.iteye.com/group/wiki/2276-JavaScript-Core&lt;br /&gt;&lt;br /&gt;看js代码，用的是MyEclipse,有括号对应功能。&lt;/p&gt;&#xD;
&lt;p&gt;存疑：代码里用了大量的','号。不知道和';'号比，有什么优势。&lt;/p&gt;&lt;img src="http://www.cnblogs.com/greatqn/aggbug/2324765.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/greatqn/archive/2012/01/17/2324765.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/greatqn/archive/2011/11/07/2239337.html</id><title type="text">Gearman安装，测试笔记</title><summary type="text">官网：http://gearman.org/gearman-0.7.0.tgz php扩展gearman-mysql-udf-0.5.tar.gzgearmand-0.14.tar.gz c版的server[还有java，perl版的]yugene-Gearman-Monitor-ed34347.zip 监控https://github.com/yugene/Gearman-Monitor 监控http://baike.baidu.com/view/2926980.htmhttp://www.cnblogs.com/cocowool/archive/2011/08/18/2145144.htm</summary><published>2011-11-07T07:48:00Z</published><updated>2011-11-07T07:48:00Z</updated><author><name>greatqn</name><uri>http://www.cnblogs.com/greatqn/</uri></author><link rel="alternate" href="http://www.cnblogs.com/greatqn/archive/2011/11/07/2239337.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/greatqn/archive/2011/11/07/2239337.html"/><content type="html">&lt;p&gt;官网：http://gearman.org/&lt;br /&gt;&lt;br /&gt;gearman-0.7.0.tgz php扩展&lt;br /&gt;gearman-mysql-udf-0.5.tar.gz&lt;br /&gt;gearmand-0.14.tar.gz&amp;nbsp; c版的server[还有java，perl版的]&lt;br /&gt;yugene-Gearman-Monitor-ed34347.zip 监控&lt;br /&gt;https://github.com/yugene/Gearman-Monitor 监控&lt;br /&gt;&lt;br /&gt;http://baike.baidu.com/view/2926980.htm&lt;br /&gt;http://www.cnblogs.com/cocowool/archive/2011/08/18/2145144.html&lt;br /&gt;&lt;br /&gt;跨多种环境部署 Gearman&lt;br /&gt;http://www.ibm.com/developerworks/cn/opensource/os-gearman/index.html&lt;br /&gt;利用开源的Gearman框架构建分布式图片处理平台－张宴&lt;br /&gt;http://blog.s135.com/dips/&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Gearman是一个用来把工作委派给其他机器、分布式的调用更适合做某项工作的机器、并发的做某项工作在多个调用间做负载均衡、或用来在调用其它语言的函数的系统。&lt;br /&gt;Gearman提供了一种通用的程序框架来将你的任务分发到不同的机器或者不同的进程当中。它提供了你进行并行工作的能力、负载均衡处理的能力，以及在不同程序语言之间沟通的能力。Gearman能够应用的领域非常广泛，从高可用的网站到数据库的复制任务。总之，Gearman就是负责分发处理的中枢系统，它的优点包括：&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 开源：Gearman免费并且开源而且有一个非常活跃的开源社区，如果你想来做一些贡献，请点击 。&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 多语言支持：Gearman支持的语言种类非常丰富。让我们能够用一种语言来编写Worker程序，但是用另外一种语言编写Client程序。&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 灵活：不必拘泥于固定的形式。您可以采用你希望的任何形式，例如 Map/Reduce。&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 快速：Gearman的协议非常简单，并且有一个用C语言实现的，经过优化的服务器，保证应用的负载在非常低的水平。&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 可植入：因为Gearman非常小巧、灵活。因此您可以将他置入到现有的任何系统中。&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 没有单点：Gearman不仅可以帮助扩展系统，同样可以避免系统的失败。&lt;br /&gt;&lt;br /&gt;目录&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Gearman 简介&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Gearman运行过程&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Gearman新版本介绍&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 安装 Gearman&lt;br /&gt;展开&lt;br /&gt;&lt;br /&gt;Gearman 简介&lt;br /&gt;　　通常，多语言多系统之间的集成是个大问题，一般来说，人们多半会采用 WebService 的方式来处理此类集成问题，但不管采用何种风格的 WebService，如 RPC 风格，或者 REST 风格，其本身都有一定的复杂性。相比之下，Gearman 也能实现类似的作用，而且更简单易用。&lt;br /&gt;Gearman运行过程&lt;br /&gt;　　一个Gearman请求的处理过程涉及三个角色：Client -&amp;gt; Job -&amp;gt; Worker。&lt;br /&gt;　　Client：请求的发起者，可以是 C，PHP，Perl，MySQL UDF 等等。&lt;br /&gt;　　Job：请求的调度者，用来负责协调把 Client 发出的请求转发给合适的 Work。&lt;br /&gt;　　Worker：请求的处理者，可以是 C，PHP，Perl 等等。&lt;br /&gt;　　因为 Client，Worker 并不限制用一样的语言，所以有利于多语言多系统之间的集成。&lt;br /&gt;　　甚至我们通过增加更多的 Worker，可以很方便的实现应用程序的分布式负载均衡架构。&lt;br /&gt;Gearman新版本介绍&lt;br /&gt;　　Gearman 1 月 16 日发布了 c 语言的 0.2 版本，gearman 提供了一个 work 传递其他机器，或者调用其他机器功能的框架，通过 gearman 你可以实现并行的工作，负载均衡处理，调用其他语言的函数。它可以应用在多种场合，从高可用性的 web 服务到数据库复制，换句话说，它是分布式处理的中枢神经。gearman 早期是 sixpart 实现的 perl 语言开发的版本，名字来源于&amp;ldquo;Manager&amp;rdquo;，这一框架只负责分发要做的工作，本身并不做任何实际的工作。（这点与 spread toolkit 相同 译者注）。&lt;br /&gt;安装 Gearman&lt;br /&gt;安装 Gearman server and library&lt;br /&gt;　　tar zxf gearmand-0.8.tar.gz[1]&lt;br /&gt;　　cd gearmand-0.8&lt;br /&gt;　　./configure&lt;br /&gt;　　make&lt;br /&gt;　　make install&lt;br /&gt;安装 Gearman PHP extension&lt;br /&gt;　　tar zxf gearman-0.4.0.tgz&lt;br /&gt;　　cd gearman-0.4.0&lt;br /&gt;　　phpize&lt;br /&gt;　　./configure&lt;br /&gt;　　make&lt;br /&gt;　　make install&lt;br /&gt;　　编辑 php.ini 配置文件加载相应模块并使之生效：&lt;br /&gt;　　extension = "gearman.so"&lt;br /&gt;&lt;br /&gt;/www/wdlinux/php/bin/phpize&lt;br /&gt;./configure --with-php-config=/www/wdlinux/php/bin/php-config &lt;br /&gt;make &amp;amp;&amp;amp; make install&lt;br /&gt;&lt;br /&gt;/www/wdlinux/php/bin/php --info | grep gearman&lt;br /&gt;2. In another terminal, change to this source directory and run:&lt;br /&gt;&lt;br /&gt;/www/wdlinux/php/bin/php examples/reverse_worker.php&lt;br /&gt;&lt;br /&gt;3. In another terminal, change to this source directory and run:&lt;br /&gt;&lt;br /&gt;/www/wdlinux/php/bin/php examples/reverse_client.php&lt;br /&gt;&lt;br /&gt;　　启动Job：&lt;br /&gt;　　gearmand -d&lt;br /&gt;　　如果当前用户是 root 的话，则需要这样操作：&lt;br /&gt;　　gearmand -d -u root&lt;br /&gt;　　缺省会使用 4730 端口，下面会用到。&lt;br /&gt;　　注意：如果找不到 gearmand 命令的路径，别忘了用 whereis gearmand 确认。gearmand: /usr/local/sbin/gearmand&lt;br /&gt;&lt;br /&gt;以守护进程启动：&lt;br /&gt;gearmand -L 192.168.0.1 -p 4730&amp;nbsp; -u root -d&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;编写 Worker&lt;br /&gt;　　worker.php 文件内容如下：&lt;br /&gt;　　&amp;lt;?php&lt;br /&gt;　　$worker= new GearmanWorker();&lt;br /&gt;　　$worker-&amp;gt;addServer('127.0.0.1', 4730);&lt;br /&gt;　　$worker-&amp;gt;addFunction('reverse', 'my_reverse_function');&lt;br /&gt;　　while ($worker-&amp;gt;work());&lt;br /&gt;　　function my_reverse_function($job) {&lt;br /&gt;　　return strrev($job-&amp;gt;workload());&lt;br /&gt;　　}&lt;br /&gt;　　?&amp;gt;&lt;br /&gt;设置后台运行 work&lt;br /&gt;　　php worker.php &amp;amp;&lt;br /&gt;编写 Client&lt;br /&gt;　　client.php 文件内容如下：&lt;br /&gt;　　&amp;lt;?php&lt;br /&gt;　　$client= new GearmanClient();&lt;br /&gt;　　$client-&amp;gt;addServer('127.0.0.1', 4730);&lt;br /&gt;　　echo $client-&amp;gt;do('reverse', 'Hello World!'), "\n";&lt;br /&gt;　　?&amp;gt;&lt;br /&gt;运行 client&lt;br /&gt;　　php client.php&lt;br /&gt;　　输出：!dlroW olleH&lt;br /&gt;　　出于方便的考虑，Worker，Client 使用的都是PHP，但这并不影响演示，实际应用中，你完全可以通过 Gearman 集成不同语言实现的 Worker，Client。或许此时你还想了解前面提到的负载均衡功能：很简单，只要增加多个 Worker 即可，你可以按照 worker.php 的样子多写几个类似的文件，并设置不同的返回值用以识别演示效果。然后依次启动这几个 Worker 文件，并多次使用 client.php 去请求，你就会发现 Job 会把 Client 请求转发给不同的 Worker。&lt;br /&gt;命令行工具&lt;br /&gt;　　如果你觉得安装 PHP 之类的东西太麻烦的话，你也可以仅仅通过命令行工具来体验 Gearman 的功能：&lt;br /&gt;　　启动 Worker：gearman -w -f wc -- wc -l &amp;amp;&lt;br /&gt;　　运行 Client：gearman -f wc &amp;lt; /etc/passwd&lt;br /&gt;&lt;br /&gt;--一些意外，我没遇到。&lt;br /&gt;1 program_options需要编译或者引用libs/program_options目录的源代码 &amp;nbsp;&lt;br /&gt;2 编绎时要用g++ -o simple simple.cpp -lboost_program_options -L/usr/local/lib &lt;br /&gt;http://www.cnblogs.com/cocowool/archive/2011/08/18/2144142.html&lt;br /&gt;Linux上安装Boost C++ Libraries&lt;br /&gt;Gearman要依赖于 Boost C++ Libraries 中的 program_options 库，并且需要的版本大于 1.39。笔者的CentOS 5.2 系统中自带的 1.33 不能满足需求，在自己安装的过程中会遇到一些问题，建议参考 Boost 官方手册中的 Easy Build and Install 这部分。&lt;br /&gt;&lt;br /&gt;安装Gearman之后，第一次启用可能会遇到 error while loading shared libraries: libgearman.so.1 这个问题。可以用下面的方法解决：&lt;br /&gt;当运行 /usr/local/sbin/gearmand -d 时出现 error while loading shared libraries: libgearman.so.1&lt;br /&gt;运行一下 /sbin/ldconfig -v ，然后再去运行gearman就可以了&lt;br /&gt;&lt;br /&gt;ldconfig命令的用途,主要是在默认搜寻目录(/lib和/usr/lib)以及动态库配置文件/etc/ld.so.conf内所列的目录 下,搜索出可共享的动态链接库(格式如前介绍,lib*.so*),进而创建出动态装入程序(ld.so)所需的连接和缓存文件.缓存文件默认为/etc /ld.so.cache,此文件保存已排好序的动态链接库名字列表.&lt;br /&gt;ldconfig通常在系统启动时运行,而当用户安装了一个新的动态链接库时,就需要手工运行这个命令.&lt;br /&gt;&lt;br /&gt;需要小心的一件事情是数据的共享。Gearman 不进行所交换数据的任何转换或操作。对于这里使用的简单字符串和整数没有问题，但是不能共享 PHP 中的数组值并期望能在 Java 语言中被理解。对于这种类型的交互，可以使用很多结构化数据标准中的一种，比如 JavaScript Object Notation (JSON) 或 XML。另外，如果您在处理来自数据库的信息，只要共享 ID 或者找到需要处理的数据时要用到的信息即可，或者使用 memcached 这样的透明方法（尽管可能仍然需要 JSON 或等价物）。&lt;br /&gt;&lt;br /&gt;－－－－－－－－－－－－－&lt;br /&gt;test -z "/usr/local/lib/pkgconfig" || /bin/mkdir -p "/usr/local/lib/pkgconfig"&lt;br /&gt;&amp;nbsp;/usr/bin/install -c -m 644 support/gearmand.pc '/usr/local/lib/pkgconfig'&lt;br /&gt;&lt;br /&gt;Installing shared extensions:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /www/wdlinux/php-5.2.17/lib/php/extensions/no-debug-non-zts-20060613/&lt;br /&gt;&lt;br /&gt;/www/wdlinux/php/bin/php examples/reverse_worker.php [可运行多个，实现负载]&lt;br /&gt;/www/wdlinux/php/bin/php examples/reverse_client.php &lt;br /&gt;&lt;br /&gt;1.传值一个name,一个序列化参数。&lt;/p&gt;&#xD;
&lt;p&gt;Gearman 的高级特性&lt;br /&gt;在一个 Web 应用程序内可能有许多地方都会用到 Gearman。可以导入大量数据、发送许多电子邮件、编码视频文件、挖据数据并构建一个中央日志设施 &amp;mdash; 所有这些均不会影响站点的体验和响应性。可以并行地处理数据。而且，由于 Gearman 协议是独立于语言和平台的，所以您可以在解决方案中混合编程语言。比如，可以用 PHP 编写一个 producer，用 C、Ruby 或其他任何支持 Gearman 库的语言编写 worker。&lt;br /&gt;&lt;br /&gt;一个连接客户机和 worker 的 Gearman 网络实际上可以使用任何您能想象得到的结构。很多配置能够运行多个代理并将 worker 分配到许多机器上。负载均衡是隐式的：每个可操作的可用 worker（可能是每个 worker 主机具有多个 worker）从队列中拉出作业。一个作业能够同步或异步运行并具有优先级。&lt;br /&gt;&lt;br /&gt;Gearman 的最新版本已经将系统特性扩展到了包含持久的作业队列和用一个新协议来通过 HTTP 提交工作请求。对于前者，Gearman 工作队列保存在内存并在一个关系型数据库内存有备份。这样一来，如果 Gearman 守护程序故障，它就可以在重启后重新创建这个工作队列。另一个最新的改良通过一个 memcached 集群增加队列持久性。memcached 存储也依赖于内存，但被分散于几个机器以避免单点故障。&lt;br /&gt;&lt;br /&gt;Gearman 是一个刚刚起步却很有实力的工作分发系统。据 Gearman 的作者 Eric Day 介绍，Yahoo! 在 60 或更多的服务器上使用 Gearman 每天处理 600 万个作业。新闻聚合器 Digg 也已构建了一个相同规模的 Gearman 网络，每天可处理 400,000 个作业。Gearman 的一个出色例子可以在 Narada 这个开源搜索引擎（参见 参考资料）中找到。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/greatqn/aggbug/2239337.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/greatqn/archive/2011/11/07/2239337.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/greatqn/archive/2011/10/29/2228439.html</id><title type="text">自己写过的一个vba脚本，用于移动copy一点数据。</title><summary type="text">Sub Macro1() Sheets(&amp;quot;Sheet1&amp;quot;).Select Range(&amp;quot;A1&amp;quot;).Select Selection.Copy Sheets(&amp;quot;公式&amp;quot;).Select Range(&amp;quot;A1&amp;quot;).Select ActiveSheet.Paste Range(&amp;quot;D1&amp;quot;).Select Application.CutCopyMode = False Selection.Copy &amp;#39;拷贝日期 Sheets(&amp;quot;ALL&amp;quot;).Select Call moveEmpty </summary><published>2011-10-29T03:26:00Z</published><updated>2011-10-29T03:26:00Z</updated><author><name>greatqn</name><uri>http://www.cnblogs.com/greatqn/</uri></author><link rel="alternate" href="http://www.cnblogs.com/greatqn/archive/2011/10/29/2228439.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/greatqn/archive/2011/10/29/2228439.html"/><content type="html">&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;span style="color: #0000ff;"&gt;Sub&lt;/span&gt; Macro1()&lt;br /&gt;    Sheets(&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;Sheet1&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;).Select&lt;br /&gt;    Range(&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;A1&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;).Select&lt;br /&gt;    Selection.Copy&lt;br /&gt;    Sheets(&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;公式&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;).Select&lt;br /&gt;    Range(&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;A1&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;).Select&lt;br /&gt;    ActiveSheet.Paste&lt;br /&gt;    Range(&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;D1&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;).Select&lt;br /&gt;    Application.CutCopyMode = &lt;span style="color: #0000ff;"&gt;False&lt;/span&gt;&lt;br /&gt;    Selection.Copy  &lt;span style="color: #008000;"&gt;'&lt;/span&gt;&lt;span style="color: #008000;"&gt;拷贝日期&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;    &lt;br /&gt;    Sheets(&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;ALL&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;).Select&lt;br /&gt;    &lt;span style="color: #0000ff;"&gt;Call&lt;/span&gt; moveEmpty&lt;br /&gt;    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _&lt;br /&gt;        :=&lt;span style="color: #0000ff;"&gt;False&lt;/span&gt;, Transpose:=&lt;span style="color: #0000ff;"&gt;False&lt;/span&gt;&lt;br /&gt;    Application.CutCopyMode = &lt;span style="color: #0000ff;"&gt;False&lt;/span&gt;&lt;br /&gt;    ActiveCell.FormulaR1C1 = ActiveCell.Value&lt;br /&gt;    &lt;br /&gt;    Selection.Copy&lt;br /&gt;    &lt;span style="color: #0000ff;"&gt;Call&lt;/span&gt; copyData(&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;Service&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000;"&gt;'&lt;/span&gt;&lt;span style="color: #008000;"&gt;---------------拷贝数据----&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;    &lt;span style="color: #0000ff;"&gt;Call&lt;/span&gt; copyImpl(&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;all classes&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;, &lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;ALL&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;)&lt;br /&gt;        &lt;br /&gt;&lt;span style="color: #0000ff;"&gt;End Sub&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff;"&gt;Sub&lt;/span&gt; copyData(sheetName)&lt;br /&gt;    Sheets(sheetName).Select&lt;br /&gt;    &lt;span style="color: #0000ff;"&gt;Call&lt;/span&gt; moveEmpty&lt;br /&gt;    ActiveSheet.Paste&lt;br /&gt;&lt;span style="color: #0000ff;"&gt;End Sub&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff;"&gt;Sub&lt;/span&gt; copyImpl(strNamespace, sheetName)&lt;br /&gt;    Sheets(&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;Sheet1&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;).Select&lt;br /&gt;    selectRange (strNamespace)&lt;br /&gt;    Application.CutCopyMode = &lt;span style="color: #0000ff;"&gt;False&lt;/span&gt;&lt;br /&gt;    Selection.Copy&lt;br /&gt;    Sheets(sheetName).Select&lt;br /&gt;    ActiveCell.Offset(&lt;span style="color: #800080;"&gt;0&lt;/span&gt;, &lt;span style="color: #800080;"&gt;1&lt;/span&gt;).Select&lt;br /&gt;    ActiveSheet.Paste&lt;br /&gt;&lt;span style="color: #0000ff;"&gt;End Sub&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff;"&gt;Sub&lt;/span&gt; selectRange(stringv)&lt;br /&gt;&lt;br /&gt;    Range(&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;A1&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;).Select&lt;br /&gt;    &lt;span style="color: #0000ff;"&gt;Dim&lt;/span&gt; i &lt;span style="color: #0000ff;"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;Integer&lt;/span&gt;&lt;br /&gt;    i = &lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff;"&gt;While&lt;/span&gt; (ActiveCell.Value &amp;lt;&amp;gt; stringv)&lt;br /&gt;        ActiveCell.Offset(&lt;span style="color: #800080;"&gt;1&lt;/span&gt;, &lt;span style="color: #800080;"&gt;0&lt;/span&gt;).Select&lt;br /&gt;        i = i + &lt;span style="color: #800080;"&gt;1&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff;"&gt;If&lt;/span&gt; i &amp;gt; &lt;span style="color: #800080;"&gt;200&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;Then&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: #0000ff;"&gt;GoTo&lt;/span&gt; ttt&lt;br /&gt;        &lt;span style="color: #0000ff;"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;If&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff;"&gt;Wend&lt;/span&gt;&lt;br /&gt;ttt:&lt;br /&gt;    &lt;span style="color: #0000ff;"&gt;Dim&lt;/span&gt; cell&lt;br /&gt;    &lt;span style="color: #0000ff;"&gt;Set&lt;/span&gt; cell = ActiveCell.Cells&lt;br /&gt;    &lt;br /&gt;    Debug.Print cell.Row&lt;br /&gt;    Debug.Print cell.Column&lt;br /&gt;    Range(cell, Cells(cell.Row, cell.Column + &lt;span style="color: #800080;"&gt;4&lt;/span&gt;)).Select&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff;"&gt;End Sub&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;'&lt;/span&gt;&lt;span style="color: #008000;"&gt;移动到空行&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;Sub&lt;/span&gt; moveEmpty()&lt;br /&gt;    &lt;span style="color: #0000ff;"&gt;Dim&lt;/span&gt; i &lt;span style="color: #0000ff;"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;Integer&lt;/span&gt;&lt;br /&gt;    i = &lt;span style="color: #800080;"&gt;2&lt;/span&gt;&lt;br /&gt;    Cells(i, &lt;span style="color: #800080;"&gt;1&lt;/span&gt;).Select&lt;br /&gt;    &lt;span style="color: #0000ff;"&gt;While&lt;/span&gt; (ActiveCell.Value &amp;lt;&amp;gt; &lt;span style="color: #800000;"&gt;""&lt;/span&gt;)&lt;br /&gt;        i = i + &lt;span style="color: #800080;"&gt;1&lt;/span&gt;&lt;br /&gt;        Cells(i, &lt;span style="color: #800080;"&gt;1&lt;/span&gt;).Select&lt;br /&gt;    &lt;span style="color: #0000ff;"&gt;Wend&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff;"&gt;End Sub&lt;/span&gt;&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;用了有一阵子了，希望下次写时，能少查一点vba的资料。&lt;/p&gt;&#xD;
&lt;p&gt;基本上用宏录制，再略改改就帮忙做一些重复工作了。&lt;/p&gt;&lt;img src="http://www.cnblogs.com/greatqn/aggbug/2228439.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/greatqn/archive/2011/10/29/2228439.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/greatqn/archive/2011/10/09/2203428.html</id><title type="text">jquery代码收藏</title><summary type="text">1. 如何创建嵌套的过滤器：//允许你减少集合中的匹配元素的过滤器，//只剩下那些与给定的选择器匹配的部分。在这种情况下，//查询删除了任何没（:not）有（:has）//包含class为“selected”（.selected）的子节点。.filter(&amp;quot;:not(:has(.selected))&amp;quot;)2. 如何重用元素搜索var allItems = $(&amp;quot;div.item&amp;quot;);var keepList = $(&amp;quot;div#container1 div.item&amp;quot;);//现在你可以继续使用这些jQuery对象来工作了。例如，//基于复</summary><published>2011-10-09T03:19:00Z</published><updated>2011-10-09T03:19:00Z</updated><author><name>greatqn</name><uri>http://www.cnblogs.com/greatqn/</uri></author><link rel="alternate" href="http://www.cnblogs.com/greatqn/archive/2011/10/09/2203428.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/greatqn/archive/2011/10/09/2203428.html"/><content type="html">&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;1. 如何创建嵌套的过滤器：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;//允许你减少集合中的匹配元素的过滤器，&#xD;
//只剩下那些与给定的选择器匹配的部分。在这种情况下，&#xD;
//查询删除了任何没（:not）有（:has）&#xD;
//包含class为&amp;ldquo;selected&amp;rdquo;（.selected）的子节点。&#xD;
.filter(":not(:has(.selected))")&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;2. 如何重用元素搜索&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;var allItems = $("div.item");&#xD;
var keepList = $("div#container1 div.item");&#xD;
//现在你可以继续使用这些jQuery对象来工作了。例如，&#xD;
//基于复选框裁剪&amp;ldquo;keep list&amp;rdquo;，复选框的名称&#xD;
//符合&#xD;
&amp;lt; DIV &amp;gt;class names:&#xD;
$(formToLookAt + " input:checked").each(function() {&#xD;
        keepList = keepList.filter("." + $(this).attr("name"));&#xD;
});&#xD;
&amp;lt; /DIV&amp;gt;&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;3. 任何使用has()来检查某个元素是否包含某个类或是元素：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;//jQuery 1.4.*包含了对这一has方法的支持。该方法找出&#xD;
//某个元素是否包含了其他另一个元素类或是其他任何的&#xD;
//你正在查找并要在其之上进行操作的东东。&#xD;
$("input").has(".email").addClass("email_icon");&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;4. 如何使用jQuery来切换样式表&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;//找出你希望切换的媒体类型（media-type），然后把href设置成新的样式表。&#xD;
$('link[media='screen']').attr('href', 'Alternative.css');&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;5. 如何限制选择范围（基于优化目的）：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;//尽可能使用标签名来作为类名的前缀，&#xD;
//这样jQuery就不需要花费更多的时间来搜索&#xD;
//你想要的元素。还要记住的一点是，&#xD;
//针对于你的页面上的元素的操作越具体化，&#xD;
//就越能降低执行和搜索的时间。&#xD;
var in_stock = $('#shopping_cart_items input.is_in_stock');&#xD;
&#xD;
&amp;lt;ul id="shopping_cart_items"&amp;gt;&#xD;
&amp;lt;li&amp;gt;&amp;lt;input type="radio" value="Item-X" name="item"  /&amp;gt; Item X&amp;lt;/li&amp;gt;&#xD;
&amp;lt;li&amp;gt;&amp;lt;input type="radio" value="Item-Y" name="item"  /&amp;gt; Item Y&amp;lt;/li&amp;gt;&#xD;
&amp;lt;li&amp;gt;&amp;lt;input type="radio" value="Item-Z" name="item"  /&amp;gt; Item Z&amp;lt;/li&amp;gt;&#xD;
&amp;lt;/ul&amp;gt;&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;6. 如何正确地使用ToggleClass：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;//切换（toggle）类允许你根据某个类的&#xD;
//是否存在来添加或是删除该类。&#xD;
//这种情况下有些开发者使用：&#xD;
a.hasClass('blueButton') ? a.removeClass('blueButton') : a.addClass('blueButton');&#xD;
//toggleClass允许你使用下面的语句来很容易地做到这一点&#xD;
a.toggleClass('blueButton');&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;7. 如何设置IE特有的功能：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;if ($.browser.msie) {&#xD;
// Internet Explorer就是个虐待狂&#xD;
}&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;8. 如何使用jQuery来代替一个元素：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;$('#thatdiv').replaceWith('fnuh');&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;9. 如何验证某个元素是否为空：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;if ($('#keks').html()) {&#xD;
//什么都没有找到;&#xD;
}&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;10. 如何从一个未排序的集合中找出某个元素的索引号&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;$("ul &amp;gt; li").click(function () {&#xD;
        var index = $(this).prevAll().length;&#xD;
});&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;11. 如何把函数绑定到事件上：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;$('#foo').bind('click', function() {&#xD;
        alert('User clicked on "foo."');&#xD;
});&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;12. 如何追加或是添加html到元素中：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;$('#lal').append('sometext');&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;13. 在创建元素时，如何使用对象字面量（literal）来定义属性&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;var e = $("", { href: "#", class: "a-class another-class", title: "..." });&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;14. 如何使用多个属性来进行过滤&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;//在使用许多相类似的有着不同类型的input元素时，&#xD;
//这种基于精确度的方法很有用&#xD;
var elements = $('#someid input[type=sometype][value=somevalue]').get();&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;15. 如何使用jQuery来预加载图像&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;jQuery.preloadImages = function() {&#xD;
        for(var i = 0; i &amp;lt; arguments.length; i++) {&#xD;
                $("&amp;lt;img /&amp;gt;").attr('src', arguments[i]);&#xD;
        }&#xD;
};&#xD;
//用法&#xD;
$.preloadImages('image1.gif', '/path/to/image2.png', 'some/image3.jpg');&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;table style="word-wrap: break-word; empty-cells: show; border-collapse: collapse; table-layout: fixed; width: 757px;" cellpadding="0" cellspacing="0"&gt;&#xD;
&lt;tbody style="word-wrap: break-word;"&gt;&#xD;
&lt;tr style="word-wrap: break-word;"&gt;&#xD;
&lt;td  id="postmessage_30951" style="word-wrap: break-word; font-size: 14px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;16. 如何为任何与选择器相匹配的元素设置事件处理程序：&lt;/strong&gt;&lt;/td&gt;&#xD;
&lt;/tr&gt;&#xD;
&lt;/tbody&gt;&#xD;
&lt;/table&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;$('button.someClass').live('click', someFunction);&#xD;
//注意，在jQuery 1.4.2中，delegate和undelegate选项&#xD;
//被引入代替live，因为它们提供了更好的上下文支持&#xD;
//例如，就table来说，以前你会用&#xD;
//.live()&#xD;
$("table").each(function(){&#xD;
        $("td", this).live("hover", function(){&#xD;
                $(this).toggleClass("hover");&#xD;
        });&#xD;
});&#xD;
//现在用&#xD;
$("table").delegate("td", "hover", function(){&#xD;
        $(this).toggleClass("hover");&#xD;
});&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;17. 如何找到一个已经被选中的option元素：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;$('#someElement').find('option:selected');&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;18. 如何隐藏一个包含了某个值文本的元素：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;$("p.value:contains('thetextvalue')").hide();&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;19. 如何自动滚动到页面中的某区域&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;jQuery.fn.autoscroll = function(selector) {&#xD;
        $('html,body').animate(&#xD;
                {scrollTop: $(selector).offset().top},&#xD;
                500&#xD;
        };&#xD;
}&#xD;
//然后像这样来滚动到你希望去到的class/area上。&#xD;
$('.area_name').autoscroll();&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;20. 如何检测各种浏览器：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;检测Safari (if( $.browser.safari)),&#xD;
检测IE6及之后版本 (if ($.browser.msie &amp;amp;&amp;amp; $.browser.version &amp;gt; 6 )),&#xD;
检测IE6及之前版本 (if ($.browser.msie &amp;amp;&amp;amp; $.browser.version &amp;lt;= 6 )),&#xD;
检测FireFox 2及之后版本 (if ($.browser.mozilla &amp;amp;&amp;amp; $.browser.version &amp;gt;= '1.8' ))&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;21. 如何替换串中的词:&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;var el = $('#id');&#xD;
        el.html(el.html().replace(/word/ig, ''));&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;22. 如何禁用右键单击上下文菜单：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;$(document).bind('contextmenu',function(e){&#xD;
        return false;&#xD;
});&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;23. 如何定义一个定制的选择器&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;$.expr[':'].mycustomselector = function(element, index, meta, stack){&#xD;
// element- 一个DOM元素&#xD;
// index &amp;ndash; 栈中的当前循环索引&#xD;
// meta &amp;ndash; 有关选择器的元数据&#xD;
// stack &amp;ndash; 要循环的所有元素的栈&#xD;
// 如果包含了当前元素就返回true&#xD;
// 如果不包含当前元素就返回false };&#xD;
// 定制选择器的用法：&#xD;
$('.someClasses:test').doSomething();&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;24. 如何检查某个元素是否存在:&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;if ($('#someDiv').length) {&#xD;
//万岁！！！它存在&amp;hellip;&amp;hellip;&#xD;
}&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;25. 如何使用jQuery来检测右键和左键的鼠标单击两种情况&lt;/strong&gt;：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;$("#someelement").live('click', function(e) {&#xD;
        if( (!$.browser.msie &amp;amp;&amp;amp; e.button == 0) || ($.browser.msie &amp;amp;&amp;amp; e.button == 1) ) {&#xD;
                alert("Left Mouse Button Clicked");&#xD;
        } else if(e.button == 2) {&#xD;
                alert("Right Mouse Button Clicked");&#xD;
        }&#xD;
});&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;table style="word-wrap: break-word; empty-cells: show; border-collapse: collapse; table-layout: fixed; width: 757px;" cellpadding="0" cellspacing="0"&gt;&#xD;
&lt;tbody style="word-wrap: break-word;"&gt;&#xD;
&lt;tr style="word-wrap: break-word;"&gt;&#xD;
&lt;td  id="postmessage_30952" style="word-wrap: break-word; border-width: 0px; font-size: 14px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;26. 如何显示或是删除input域中的默认值&lt;/strong&gt;&lt;/td&gt;&#xD;
&lt;/tr&gt;&#xD;
&lt;/tbody&gt;&#xD;
&lt;/table&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;//这段代码展示了在用户未输入值时，&#xD;
//如何在文本类型的input域中保留&#xD;
//一个默认值&#xD;
wap_val = [];&#xD;
$(".swap").each(function(i){&#xD;
        wap_val[i] = $(this).val();&#xD;
        $(this).focusin(function(){&#xD;
                if ($(this).val() == swap_val[i]) {&#xD;
                        $(this).val("");&#xD;
                }&#xD;
        }).focusout(function(){&#xD;
                if ($.trim($(this).val()) == "") {&#xD;
                        $(this).val(swap_val[i]);&#xD;
                }});});&#xD;
&#xD;
&amp;lt;input type="text" value="Enter Username here.."  /&amp;gt;&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;27. 如何在一段时间之后自动隐藏或关闭元素（支持1.4版本）：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;//这是1.3.2中我们使用setTimeout来实现的方式&#xD;
setTimeout(function() {&#xD;
  $('.mydiv').hide('blind', {}, 500)&#xD;
}, 5000);&#xD;
//而这是在1.4中可以使用delay()这一功能来实现的方式（这很像是休眠）&#xD;
$(".mydiv").delay(5000).hide('blind', {}, 500);&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;28. 如何把已创建的元素动态地添加到DOM中：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;var newDiv = $('');&#xD;
        newDiv.attr('id','myNewDiv').appendTo('body');&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;29. 如何限制&amp;ldquo;Text-Area&amp;rdquo;域中的字符的个数：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;jQuery.fn.maxLength = function(max){&#xD;
        this.each(function(){&#xD;
                var type = this.tagName.toLowerCase();&#xD;
                var inputType = this.type? this.type.toLowerCase() : null;&#xD;
                if(type == "input" &amp;amp;&amp;amp; inputType == "text" || inputType == "password"){&#xD;
                        //Apply the standard maxLength&#xD;
                        this.maxLength = max;&#xD;
                }&#xD;
                else if(type == "textarea"){&#xD;
                        this.onkeypress = function(e){&#xD;
                                var ob = e || event;&#xD;
                                var keyCode = ob.keyCode;&#xD;
                                var hasSelection = document.selection? document.selection.createRange().text.length &amp;gt; 0 : this.selectionStart != this.selectionEnd;&#xD;
                                return !(this.value.length &amp;gt;= max &amp;amp;&amp;amp; (keyCode &amp;gt; 50 || keyCode == 32 || keyCode == 0 || keyCode == 13) &amp;amp;&amp;amp; !ob.ctrlKey &amp;amp;&amp;amp; !ob.altKey &amp;amp;&amp;amp; !hasSelection);&#xD;
                        };&#xD;
                        this.onkeyup = function(){&#xD;
                                if(this.value.length &amp;gt; max){&#xD;
                                        this.value = this.value.substring(0,max);&#xD;
                                }&#xD;
                        };&#xD;
                }&#xD;
        });&#xD;
};&#xD;
//用法&#xD;
$('#mytextarea').maxLength(500);&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;30. 如何为函数创建一个基本的测试&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;//把测试单独放在模块中&#xD;
module("Module B");&#xD;
test("some other test", function() {&#xD;
        //指明测试内部预期有多少要运行的断言&#xD;
        expect(2);&#xD;
        //一个比较断言，相当于JUnit的assertEquals&#xD;
        equals( true, false, "failing test" );&#xD;
        equals( true, true, "passing test" );&#xD;
});&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;31. 如何在jQuery中克隆一个元素：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;var cloned = $('#somediv').clone();&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;32. 在jQuery中如何测试某个元素是否可见&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;if($(element).is(':visible') == 'true') {&#xD;
        //该元素是可见的&#xD;
}&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;33. 如何把一个元素放在屏幕的中心位置：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;jQuery.fn.center = function () {&#xD;
        this.css('position','absolute');&#xD;
        this.css('top', ( $(window).height() - this.height() ) / +$(window).scrollTop() + 'px');&#xD;
        this.css('left', ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + 'px');&#xD;
        return this;&#xD;
}&#xD;
//这样来使用上面的函数：&#xD;
$(element).center();&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;34. 如何把有着某个特定名称的所有元素的值都放到一个数组中：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;var arrInputValues = new Array();&#xD;
$("input[name='table[]']").each(function(){&#xD;
        arrInputValues.push($(this).val());&#xD;
});&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;35. 如何从元素中除去html&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;(function($) {&#xD;
        $.fn.stripHtml = function() {&#xD;
                var regexp = /&amp;lt;("[^"]*"|'[^']*'|[^'"&amp;gt;])*&amp;gt;/gi;&#xD;
                this.each(function() {&#xD;
                        $(this).html( $(this).html().replace(regexp,&amp;rdquo;") );&#xD;
                });&#xD;
                return $(this);&#xD;
        }&#xD;
})(jQuery);&#xD;
//用法：&#xD;
$('p').stripHtml();&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;36. 如何使用closest来取得父元素&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;$('#searchBox').closest('div');&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;37. 如何使用Firebug和Firefox来记录jQuery事件日志：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;// 允许链式日志记录&#xD;
// 用法：&#xD;
$('#someDiv').hide().log('div hidden').addClass('someClass');&#xD;
jQuery.log = jQuery.fn.log = function (msg) {&#xD;
        if (console){&#xD;
                console.log("%s: %o", msg, this);&#xD;
        }&#xD;
        return this;&#xD;
};&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;38. 如何强制在弹出窗口中打开链接:&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;jQuery('a.popup').live('click', function(){&#xD;
        newwindow=window.open($(this).attr('href'),'','height=200,width=150');&#xD;
        if (window.focus) {&#xD;
                newwindow.focus();&#xD;
        }&#xD;
        return false;&#xD;
});&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;39. 如何强制在新的选项卡中打开链接：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;jQuery('a.newTab').live('click', function(){&#xD;
        newwindow=window.open($(this).href);&#xD;
        jQuery(this).target = "_blank";&#xD;
        return false;&#xD;
});&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;40. 在jQuery中如何使用.siblings()来选择同辈元素&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;// 不这样做&#xD;
$('#nav li').click(function(){&#xD;
        $('#nav li').removeClass('active');&#xD;
        $(this).addClass('active');&#xD;
});&#xD;
//替代做法是&#xD;
$('#nav li').click(function(){&#xD;
        $(this).addClass('active').siblings().removeClass('active');&#xD;
});&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;41. 如何切换页面上的所有复选框：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;var tog = false;&#xD;
// 或者为true，如果它们在加载时为被选中状态的话&#xD;
$('a').click(function() {&#xD;
        $("input[type=checkbox]").attr("checked",!tog);&#xD;
        tog = !tog;&#xD;
});&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;42. 如何基于一些输入文本来过滤一个元素列表：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;//如果元素的值和输入的文本相匹配的话&#xD;
//该元素将被返回&#xD;
$('.someClass').filter(function() {&#xD;
        return $(this).attr('value') == $('input#someId').val();&#xD;
})&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;43. 如何获得鼠标垫光标位置x和y:&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;$(document).ready(function() {&#xD;
        $(document).mousemove(function(e){&#xD;
                $(&amp;rsquo;#XY&amp;rsquo;).html(&amp;rdquo;X Axis : &amp;rdquo; + e.pageX + &amp;rdquo; | Y Axis &amp;rdquo; + e.pageY);&#xD;
        });&#xD;
});&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;44. 如何把整个的列表元素（List Element，LI）变成可点击的&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;$("ul li").click(function(){&#xD;
  window.location=$(this).find("a").attr("href");&#xD;
  return false;&#xD;
});&#xD;
&#xD;
&amp;lt;ul&amp;gt;&#xD;
&amp;lt;li&amp;gt;&amp;lt;a href="#"&amp;gt;Link 1&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&#xD;
&amp;lt;li&amp;gt;&amp;lt;a href="#"&amp;gt;Link 2&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&#xD;
&amp;lt;li&amp;gt;&amp;lt;a href="#"&amp;gt;Link 3&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&#xD;
&amp;lt;li&amp;gt;&amp;lt;a href="#"&amp;gt;Link 4&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&#xD;
&amp;lt;/ul&amp;gt;&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;45. 如何使用jQuery来解析XML（基本的例子）：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;function parseXml(xml) {&#xD;
        //找到每个Tutorial并打印出author&#xD;
        $(xml).find("Tutorial").each(function() {&#xD;
                $("#output").append($(this).attr("author") + "");&#xD;
        });&#xD;
}&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;46. 如何检查图像是否已经被完全加载进来&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;$('#theImage').attr('src', 'image.jpg').load(function() {&#xD;
        alert('This Image Has Been Loaded');&#xD;
});&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;47. 如何使用jQuery来为事件指定命名空间：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;//事件可以这样绑定命名空间&#xD;
$('input').bind('blur.validation', function(e){&#xD;
// ...&#xD;
});&#xD;
//data方法也接受命名空间&#xD;
$('input').data('validation.isValid', true);&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;48. 如何检查cookie是否启用&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;var dt = new Date();&#xD;
dt.setSeconds(dt.getSeconds() + 60);&#xD;
document.cookie = "cookietest=1; expires=" + dt.toGMTString();&#xD;
var cookiesEnabled = document.cookie.indexOf("cookietest=") != -1;&#xD;
if(!cookiesEnabled) {&#xD;
//没有启用cookie&#xD;
}&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;49. 如何让cookie过期：&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;var date = new Date();&#xD;
date.setTime(date.getTime() + (x * 60 * 1000));&#xD;
$.cookie('example', 'foo', { expires: date });&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;50. 如何使用一个可点击的链接来替换页面中任何的URL&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;$.fn.replaceUrl = function() {&#xD;
        var regexp = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&amp;amp;%@!\-\/]))?)/gi;&#xD;
        this.each(function() {&#xD;
                $(this).html(&#xD;
                        $(this).html().replace(regexp,'$1&amp;lsquo;)&#xD;
                );&#xD;
        });&#xD;
        return $(this);&#xD;
}&#xD;
//用法　&#xD;
$('p').replaceUrl();&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span  style="border-collapse: separate; color: #000000; font-family: Simsun; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span  style="border-collapse: collapse; color: #444444; font-family: Tahoma,Helvetica,SimSun,sans-serif; font-size: 14px; line-height: 21px;"&gt;&lt;strong style="word-wrap: break-word; font-weight: bold;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/greatqn/aggbug/2203428.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/greatqn/archive/2011/10/09/2203428.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/greatqn/archive/2011/09/23/2186350.html</id><title type="text">[php代码]从svn获取指定版本，并同步到ftp上。</title><summary type="text">1.从svn获取指定版本。命令行：svn update svnworkpath --username xxx --password xxx -r head$cmd = &amp;quot;svn update...&amp;quot;$ar = array(); $status = 0; exec($cmd, $ar, $status); 返回的结果包含以下内容：A 002/ftp_upload.phpU 002/main.phpD 002/config.php2.处理成本地路径和服务器上传路径：function svnMessage($remoteArr,$localArr,$CONFIG_PG,$C...</summary><published>2011-09-23T08:14:00Z</published><updated>2011-09-23T08:14:00Z</updated><author><name>greatqn</name><uri>http://www.cnblogs.com/greatqn/</uri></author><link rel="alternate" href="http://www.cnblogs.com/greatqn/archive/2011/09/23/2186350.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/greatqn/archive/2011/09/23/2186350.html"/><content type="html">&lt;p&gt;1.从svn获取指定版本。&lt;/p&gt;&#xD;
&lt;p&gt;命令行：svn update&amp;nbsp; svnworkpath --username xxx --password xxx -r head&lt;/p&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;span style="color: #800080;"&gt;$cmd&lt;/span&gt; = "svn update..."&lt;br /&gt;&lt;span style="color: #800080;"&gt;$ar&lt;/span&gt; = &lt;span style="color: #0000ff;"&gt;array&lt;/span&gt;();   &lt;br /&gt;&lt;span style="color: #800080;"&gt;$status&lt;/span&gt; = 0;   &lt;br /&gt;&lt;span style="color: #008080;"&gt;exec&lt;/span&gt;(&lt;span style="color: #800080;"&gt;$cmd&lt;/span&gt;, &lt;span style="color: #800080;"&gt;$ar&lt;/span&gt;, &lt;span style="color: #800080;"&gt;$status&lt;/span&gt;); &lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;返回的结果包含以下内容：&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;A    002/ftp_upload.php&#xD;
U    002/main.php&#xD;
D    002/config.php&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;2.处理成本地路径和服务器上传路径：&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;function svnMessage($remoteArr,$localArr,$CONFIG_PG,$CONFIG_DIR)   &#xD;
{   &#xD;
/*  &#xD;
* local dir  &#xD;
*/   &#xD;
for($ctr = 0;$ctr &amp;lt; count($localArr)-1; $ctr++)   &#xD;
{   &#xD;
//$localArr[$ctr] = str_replace ($CONFIG_FLG,'',$localArr[$ctr]);   &#xD;
$istr = stripos($localArr[$ctr], $CONFIG_PG);   &#xD;
$localArr[$ctr] = substr($localArr[$ctr],$istr);   &#xD;
$localArr[$ctr] = str_replace ('\\','/',$localArr[$ctr]);   &#xD;
}   &#xD;
echo "本地路径:&amp;lt;br /&amp;gt;\r\n";   &#xD;
for($ctr = 0;$ctr &amp;lt; count($localArr)-1; $ctr++)   &#xD;
{   &#xD;
echo $localArr[$ctr];   &#xD;
echo "&amp;lt;br /&amp;gt;\r\n";&#xD;
}   &#xD;
  &#xD;
/*  &#xD;
* remote dir  &#xD;
*/   &#xD;
for($i = 0;$i &amp;lt; count($remoteArr)-1; $i++)   &#xD;
{   &#xD;
//$remoteArr[$i] = str_replace ($CONFIG_PG,'',$remoteArr[$i]);   &#xD;
$imstr = stripos($remoteArr[$i], $CONFIG_PG);   &#xD;
$remoteArr[$i] = substr($remoteArr[$i],$imstr+strlen($CONFIG_PG));   &#xD;
$remoteArr[$i] = $CONFIG_DIR.str_replace ('\\','/',$remoteArr[$i]);   &#xD;
}   &#xD;
echo "&amp;lt;br /&amp;gt;\r\n上传路径:&amp;lt;br /&amp;gt;\r\n";   &#xD;
for($i = 0;$i &amp;lt; count($remoteArr)-1; $i++)   &#xD;
{   &#xD;
echo $remoteArr[$i];   &#xD;
echo "&amp;lt;br /&amp;gt;\r\n";   &#xD;
}   &#xD;
} &#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;3.连接到ftp&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;$conn = ftp_connect($ftp_ip) or die("Could not connect");   &#xD;
ftp_login($conn,$ftp_user,$ftp_pass);  &#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;4.上传时区分A,U,D和文件或文件夹&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;function ftp_handle_one($conn,$aud,$localfile,$remotefile)&#xD;
{&#xD;
	echo "$aud,$localfile,$remotefile\r\n";&#xD;
	$r= true;&#xD;
	if($aud == 'D'){&#xD;
		//删除时，找不到本地文件，无法判断是否文件夹。&#xD;
		try{&#xD;
			$r = ftp_delete($conn,$remotefile);&#xD;
			echo "删除文件 $remotefile --&amp;gt; $r\r\n";&#xD;
			if(!$r){&#xD;
				$r = removeDir($conn,$remotefile);&#xD;
				echo "删除目录 $remotefile --&amp;gt; $r\r\n";&#xD;
			}&#xD;
		}catch(Exception $e){&#xD;
			echo '捕获异常: ' . $e-&amp;gt;getmessage() . "&amp;lt;br/&amp;gt;错误代码：" . $e-&amp;gt;getcode().'&amp;lt;br/&amp;gt;\r\n';&#xD;
			echo "------\r\n";&#xD;
		}&#xD;
	}else if($aud == 'A'){&#xD;
		if(is_dir($localfile)){&#xD;
			$r = ftp_mkdir($conn,$remotefile);&#xD;
			echo "创建目录 $remotefile --&amp;gt; $r\r\n";&#xD;
		}else{&#xD;
			$r = ftp_upload_one($conn,$localfile,$remotefile);&#xD;
			echo "创建文件 $remotefile --&amp;gt; $r\r\n";&#xD;
		}&#xD;
	}else if($aud == 'U'){&#xD;
		if(is_dir($localfile)){&#xD;
			//ftp_rmdir($conn,$remotefile);&#xD;
		}else{&#xD;
			$r = ftp_upload_one($conn,$localfile,$remotefile);&#xD;
			echo "更新文件 $remotefile --&amp;gt; $r\r\n";&#xD;
		}&#xD;
	}&#xD;
}&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;5.递归删除一个目录&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;function removeDir($conn, $dirName )&#xD;
{&#xD;
   $arr = ftp_rawlist($conn,$dirName);&#xD;
   //是个目录时，默认会有三行&#xD;
   //array(3) {&#xD;
//  [0]=&amp;gt;string(7) "total 0"&#xD;
//  [1]=&amp;gt;string(56) "drw-rw-rw-   1 user     group           0 Sep 23 13:56 ."&#xD;
//  [2]=&amp;gt;string(57) "drw-rw-rw-   1 user     group           0 Sep 23 13:56 .."&#xD;
//}&#xD;
	if(count($arr)&amp;gt;=3)&#xD;
	{&#xD;
		for($i = 3;$i &amp;lt; count($arr); $i++)&#xD;
		{&#xD;
			$isdir =  substr($arr[$i],0,1);&#xD;
			$filename = substr($arr[$i],55);//取文件名。&#xD;
			$filename = "$dirName/$filename";&#xD;
&#xD;
			echo "$isdir||$filename";&#xD;
			echo "\r\n";&#xD;
			if($isdir =="d")&#xD;
			{&#xD;
				removeDir($conn,$filename);&#xD;
&#xD;
			}else{&#xD;
				ftp_delete($conn,$filename);&#xD;
			}&#xD;
		}&#xD;
		ftp_rmdir($conn,$dirName);&#xD;
		return true;&#xD;
	}else{&#xD;
		return false;&#xD;
	}&#xD;
} &#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;6.上传一个文件&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;function ftp_upload_one($conn,$localfile,$remotefile)&#xD;
{&#xD;
	// 开始   &#xD;
	$fp = fopen($localfile, 'r');   &#xD;
	$ret = ftp_nb_fput($conn, $remotefile, $fp, FTP_BINARY);   &#xD;
	while ($ret == FTP_MOREDATA)   &#xD;
	{   &#xD;
	   // 加入其它要执行的代码   &#xD;
	   echo "....";   &#xD;
	   // 继续传送...   &#xD;
	   $ret = ftp_nb_continue ($conn);   &#xD;
	}   &#xD;
	if ($ret != FTP_FINISHED)   &#xD;
	{   &#xD;
	   echo "上传文件中发生错误...";   &#xD;
	   exit(1);   &#xD;
	}&#xD;
	return true;&#xD;
}&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;感觉php对ftp,命令行支持得很好。脚本写得很方便。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/greatqn/aggbug/2186350.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/greatqn/archive/2011/09/23/2186350.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/greatqn/archive/2011/09/23/2119569.html</id><title type="text">jquery表格jqGrid操作笔记。</title><summary type="text">1.引用&amp;lt;link type=&amp;quot;text/css&amp;quot; href=&amp;quot;css/ui-lightness/jquery-ui-1.8.14.custom.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; /&amp;gt;&amp;lt;link type=&amp;quot;text/css&amp;quot; href=&amp;quot;css/ui.jqgrid.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; /&amp;gt;	&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;js/jquery-</summary><published>2011-09-23T07:55:00Z</published><updated>2011-09-23T07:55:00Z</updated><author><name>greatqn</name><uri>http://www.cnblogs.com/greatqn/</uri></author><link rel="alternate" href="http://www.cnblogs.com/greatqn/archive/2011/09/23/2119569.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/greatqn/archive/2011/09/23/2119569.html"/><content type="html">&lt;p&gt;1.引用&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;&amp;lt;link type="text/css" href="css/ui-lightness/jquery-ui-1.8.14.custom.css" rel="stylesheet" /&amp;gt;&#xD;
&amp;lt;link type="text/css" href="css/ui.jqgrid.css" rel="stylesheet" /&amp;gt;	&#xD;
&amp;lt;script type="text/javascript" src="js/jquery-1.5.1.min.js"&amp;gt;&amp;lt;/script&amp;gt;&#xD;
&amp;lt;script type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"&amp;gt;&amp;lt;/script&amp;gt;&#xD;
&amp;lt;script type="text/javascript" src="js/grid.locale-cn.js"&amp;gt;&amp;lt;/script&amp;gt;&#xD;
&amp;lt;script type="text/javascript" src="js/jquery.jqGrid.min.js"&amp;gt;&amp;lt;/script&amp;gt;&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;注意jqGrid放grid.locale-cn.js的后面。否则会报错。&lt;/p&gt;&#xD;
&lt;p&gt;2.纯js示例&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;jQuery("#editgrid").jqGrid({&#xD;
                datatype: "local",&#xD;
                height: 450,&#xD;
                colNames:['编号','用户名', '性别', '邮箱', 'QQ','手机号','出生日期'],&#xD;
                colModel:[&#xD;
                        {name:'id',index:'id', width:200, sorttype:"int"},&#xD;
                        {name:'userName',index:'userName', width:200},&#xD;
                        {name:'gender',index:'gender', width:90},&#xD;
                        {name:'email',index:'email', width:125,sorttype:"string"},&#xD;
                        {name:'QQ',index:'QQ', width:100},                &#xD;
                        {name:'mobilePhone',index:'mobilePhone', width:120},                &#xD;
                        {name:'birthday',index:'birthday', width:100, sorttype:"date"}                &#xD;
                ],&#xD;
                sortname:'id',&#xD;
                sortorder:'asc',&#xD;
                viewrecords:true,&#xD;
                rowNum:10,&#xD;
                rowList:[10,20,30],&#xD;
                pager:"#gridPager",&#xD;
                caption: ""&#xD;
        }).navGrid('#gridPager',{edit:true,add:true,del:true});&#xD;
&#xD;
        var mydata = [&#xD;
                {id:"1",userName:"polaris",gender:"男",email:"fef@163.com",QQ:"33334444",mobilePhone:"13223423424",birthday:"1985-10-01"},&#xD;
                {id:"2",userName:"李四",gender:"女",email:"faf@gmail.com",QQ:"222222222",mobilePhone:"13223423",birthday:"1986-07-01"},&#xD;
                {id:"3",userName:"王五",gender:"男",email:"fae@163.com",QQ:"99999999",mobilePhone:"1322342342",birthday:"1985-10-01"},&#xD;
                {id:"4",userName:"马六",gender:"女",email:"aaaa@gmail.com",QQ:"23333333",mobilePhone:"132234662",birthday:"1987-05-01"}&#xD;
                ];&#xD;
        for(var i=0;i&amp;lt;=mydata.length;i++)&#xD;
                jQuery("#editgrid").jqGrid('addRowData',i+1,mydata[i]);&lt;br /&gt;&lt;br /&gt;&amp;lt;table id="editgrid"&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&amp;lt;div id="gridPager"&amp;gt;&amp;lt;/div&amp;gt; &lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;3.可编辑字段的配置&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;colModel:[&#xD;
   		{name:'id',index:'id', width:55,editable:false,editoptions:{readonly:true,size:10},formatter: 'integer', formatoptions:{thousandsSeparator:","}},&#xD;
   		{name:'invdate',index:'invdate', width:80,editable:true,editoptions:{size:10},formatter:'date', formatoptions: {srcformat:'Y-m-d',newformat:'Y/m/d'}},&#xD;
   		{name:'name',index:'name', width:90,editable:true,editoptions:{size:25}},&#xD;
   		{name:'amount',index:'amount', width:60, align:"right",editable:true,formatter:'currency',formatoptions:{thousandsSeparator:" ", decimalSeparator:",", prefix:"&amp;euro;"}},&#xD;
   		{name:'tax',index:'tax', width:60, align:"right",editable:true,editoptions:{size:10}},		&#xD;
   		{name:'total',index:'total', width:60,align:"right",editable:true,editoptions:{size:10}},&#xD;
		{name:'closed',index:'closed',width:55,align:'center',editable:true,edittype:"checkbox",editoptions:{value:"Yes:No"}},&#xD;
		{name:'ship_via',index:'ship_via',width:70, editable: true,edittype:"select",editoptions:{value:"FE:FedEx;TN:TNT"}},&#xD;
   		{name:'note',index:'note', width:100, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"2",cols:"20"}}		&#xD;
   	],&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;4.服务器返回的json格式&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;$responce-&amp;gt;page = 2;//当前页&#xD;
$responce-&amp;gt;total = 3;//总页&#xD;
$responce-&amp;gt;records = 20;//总条数&#xD;
for($i=0;$i&amp;lt;10;$i++){&#xD;
	$responce-&amp;gt;rows[$i]['id']=$i;&#xD;
	$responce-&amp;gt;rows[$i]['cell']=array($i,date("Y-m-d H:i:s"),'中主');&#xD;
}&#xD;
echo json_encode($responce);&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;5.xml格式&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;echo "&amp;lt;?xml version='1.0' encoding='utf-8'?$et\n";&#xD;
		echo "&amp;lt;rows&amp;gt;";&#xD;
		echo "&amp;lt;page&amp;gt;1&amp;lt;/page&amp;gt;";&#xD;
		echo "&amp;lt;total&amp;gt;1&amp;lt;/total&amp;gt;";&#xD;
		echo "&amp;lt;records&amp;gt;1&amp;lt;/records&amp;gt;";&#xD;
		// be sure to put text data in CDATA&#xD;
		while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {&#xD;
			echo "&amp;lt;row&amp;gt;";			&#xD;
			echo "&amp;lt;cell&amp;gt;". $row[account_id]."&amp;lt;/cell&amp;gt;";&#xD;
			echo "&amp;lt;cell&amp;gt;". $row[name]."&amp;lt;/cell&amp;gt;";&#xD;
			echo "&amp;lt;cell&amp;gt;". $row[acc_num]."&amp;lt;/cell&amp;gt;";&#xD;
			echo "&amp;lt;cell&amp;gt;". $row[debit]."&amp;lt;/cell&amp;gt;";&#xD;
			echo "&amp;lt;cell&amp;gt;". $row[credit]."&amp;lt;/cell&amp;gt;";&#xD;
			echo "&amp;lt;cell&amp;gt;". $row[balance]."&amp;lt;/cell&amp;gt;";&#xD;
			echo "&amp;lt;cell&amp;gt;". rand(0,1)."&amp;lt;/cell&amp;gt;";&#xD;
			echo "&amp;lt;cell&amp;gt;". $row[level]."&amp;lt;/cell&amp;gt;";&#xD;
			echo "&amp;lt;cell&amp;gt;". $row[lft]."&amp;lt;/cell&amp;gt;";&#xD;
			echo "&amp;lt;cell&amp;gt;". $row[rgt]."&amp;lt;/cell&amp;gt;";&#xD;
			if($row[rgt] == $row[lft]+1) $leaf = 'true';else $leaf='false';&#xD;
			echo "&amp;lt;cell&amp;gt;".$leaf."&amp;lt;/cell&amp;gt;";&#xD;
			echo "&amp;lt;cell&amp;gt;true&amp;lt;/cell&amp;gt;";&#xD;
			echo "&amp;lt;/row&amp;gt;";&#xD;
		}&#xD;
		echo "&amp;lt;/rows&amp;gt;";	&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;6.提交的数据&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;_search	false&#xD;
nd	1311834540399&#xD;
page	1&#xD;
rows	10&#xD;
sidx	id&#xD;
sord	desc&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;_search	true&#xD;
filters	&#xD;
nd	1311836578173&#xD;
page	1&#xD;
rows	10&#xD;
searchField	id&#xD;
searchOper	eq&#xD;
searchString	&#xD;
sidx	id&#xD;
sord	desc&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;7.单元格编辑&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;cellurl:"&amp;lt;?php echo site_url("admin/demo/edit2")?&amp;gt;",&#xD;
	cellEdit: true,&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;br /&gt;参考：&lt;/p&gt;&#xD;
&lt;p&gt;&lt;a href="http://blog.sina.com.cn/s/blog_4496b0890100ri4d.html"&gt;http://blog.sina.com.cn/s/blog_4496b0890100ri4d.html&lt;/a&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;a href="http://blog.csdn.net/gengv/article/details/5714834"&gt;http://blog.csdn.net/gengv/article/details/5714834&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/greatqn/aggbug/2119569.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/greatqn/archive/2011/09/23/2119569.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/greatqn/archive/2011/07/12/2103297.html</id><title type="text">C#登录https网站并下载文件</title><summary type="text">.net很久没用了，最近要做个小工具下载一个https的内容，想来想去还是.net的环境最方便。java要装jdk，python也要python的环境，php有php的环境。主要功能代码都从网上收集，这里记录一些片段，用作备份。1.登录https if (url.StartsWith(&amp;quot;https&amp;quot;, StringComparison.OrdinalIgnoreCase)) { ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(C</summary><published>2011-07-12T01:55:00Z</published><updated>2011-07-12T01:55:00Z</updated><author><name>greatqn</name><uri>http://www.cnblogs.com/greatqn/</uri></author><link rel="alternate" href="http://www.cnblogs.com/greatqn/archive/2011/07/12/2103297.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/greatqn/archive/2011/07/12/2103297.html"/><content type="html">&lt;p&gt;.net很久没用了，最近要做个小工具下载一个https的内容，想来想去还是.net的环境最方便。java要装jdk，python也要python的环境，php有php的环境。&lt;/p&gt;&#xD;
&lt;p&gt;主要功能代码都从网上收集，这里记录一些片段，用作备份。&lt;/p&gt;&#xD;
&lt;p&gt;1.登录https&lt;/p&gt;&#xD;
&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))&#xD;
            {&#xD;
                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);&#xD;
                request = WebRequest.Create(url) as HttpWebRequest;&#xD;
                request.ProtocolVersion = HttpVersion.Version10;&#xD;
            }&#xD;
            else&#xD;
            {&#xD;
                request = WebRequest.Create(url) as HttpWebRequest;&#xD;
            }&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)&#xD;
        {&#xD;
            return true; //总是接受&#xD;
        }&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
本来想着https的连接需要证书的，原来还可以跳过证书的验证，直接返回true就行了，实践证明可以连接成功。&lt;a href="http://www.infoq.com/cn/articles/HTTPS-Connection-Jeff-Moser" rel="permalink"&gt;HTTPS连接最初的若干毫秒&lt;/a&gt;&#xD;
&#xD;
&lt;p&gt;2.继续访问&lt;/p&gt;&#xD;
&lt;p&gt;完成登录后，要保持这个session,查看response.Headers["Set-Cookie"]，可以看到cookie里的session信息，只要把这些cookie内容在下一次请求时带上就行了。&lt;/p&gt;&#xD;
&lt;p&gt;请求时cookie的转换代码：&lt;/p&gt;&#xD;
&lt;p&gt;&lt;div &gt;&#xD;
&lt;pre &gt;string cookieString = response.Headers["Set-Cookie"];&#xD;
            CookieCollection cookies = new CookieCollection();&#xD;
            Regex re = new Regex("([^;,]+)=([^;,]+); path=([^;,]+); expires=([^;,]+)", RegexOptions.IgnoreCase);//视具体内容进行调整&#xD;
            foreach (Match m in re.Matches(cookieString))&#xD;
            {&#xD;
                Cookie c = new Cookie(m.Groups[1].Value, m.Groups[2].Value);&#xD;
                c.Domain = "yourDomain";//放你要访问网站的域名&#xD;
                cookies.Add(c);&#xD;
            }&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;3.下载文件&lt;/p&gt;&#xD;
&lt;p&gt;请求的是一个下载链接，另存为的文件名，在response.Headers里。通过字符串操作把它提取出来。&lt;/p&gt;&#xD;
&lt;p&gt;文件内容要通过流的方式，把它读出来，保存成文件。&lt;/p&gt;&#xD;
&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;Stream stream = response.GetResponseStream();&#xD;
FileStream fs = new FileStream(file, FileMode.Create);&#xD;
BinaryWriter bw = new BinaryWriter(fs);&#xD;
BinaryReader br = new BinaryReader(stream);&#xD;
&#xD;
byte[] nbytes = new byte[2048];&#xD;
int nReadSize = 0;&#xD;
nReadSize = br.Read(nbytes, 0, 2048);&#xD;
while (nReadSize &amp;gt; 0)&#xD;
{&#xD;
      bw.Write(nbytes, 0, nReadSize);&#xD;
      nReadSize = br.Read(nbytes, 0, 2048);&#xD;
}&#xD;
bw.Close();&#xD;
br.Close();&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;img src="http://www.cnblogs.com/greatqn/aggbug/2103297.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/greatqn/archive/2011/07/12/2103297.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/greatqn/archive/2011/06/23/2088269.html</id><title type="text">js调试工具</title><summary type="text">js日志：var msg_id = 0;function wl(msg){msg_id++;$(&amp;#39;#log&amp;#39;).append(&amp;quot;&amp;quot;+msg_id+&amp;quot;:&amp;quot;+msg+&amp;quot;&amp;lt;br/&amp;gt;&amp;quot;);}查看对象所有属性：function allPrpos(obj) { var props = &amp;quot;&amp;quot;; for(var p in obj){ if(typeof(obj[p])==&amp;quot;function&amp;quot;){ obj[p](); }else{ props+= p + &amp;quot;=&amp;quot; +</summary><published>2011-06-23T08:53:00Z</published><updated>2011-06-23T08:53:00Z</updated><author><name>greatqn</name><uri>http://www.cnblogs.com/greatqn/</uri></author><link rel="alternate" href="http://www.cnblogs.com/greatqn/archive/2011/06/23/2088269.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/greatqn/archive/2011/06/23/2088269.html"/><content type="html">&lt;p&gt;js日志：&lt;/p&gt;&#xD;
&lt;p&gt;&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;div&gt;&lt;span style="color: #000000;"&gt;var msg_id &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;function wl(msg){&lt;br /&gt;msg_id&lt;/span&gt;&lt;span style="color: #000000;"&gt;++&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;$(&lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #800000;"&gt;#log&lt;/span&gt;&lt;span style="color: #800000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;).append(&lt;/span&gt;&lt;span style="color: #800000;"&gt;""&lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt;msg_id&lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;:&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt;msg&lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;lt;br/&amp;gt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;查看对象所有属性：&lt;/p&gt;&#xD;
&lt;p&gt;&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;div&gt;&lt;span style="color: #000000;"&gt;function allPrpos(obj) { &lt;br /&gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;    var props &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;""&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;for&lt;/span&gt;&lt;span style="color: #000000;"&gt;(var p &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;in&lt;/span&gt;&lt;span style="color: #000000;"&gt; obj){ &lt;br /&gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000;"&gt;(obj[p])&lt;/span&gt;&lt;span style="color: #000000;"&gt;==&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;function&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;){ &lt;br /&gt;            obj[p]();&lt;br /&gt;        }&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;else&lt;/span&gt;&lt;span style="color: #000000;"&gt;{ &lt;br /&gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;            props&lt;/span&gt;&lt;span style="color: #000000;"&gt;+=&lt;/span&gt;&lt;span style="color: #000000;"&gt; p &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; obj[p] &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #800000;"&gt;\t&lt;/span&gt;&lt;span style="color: #800000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        } &lt;br /&gt;    } &lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; 显示所有的属性&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;    wl(props);&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;/p&gt;&lt;img src="http://www.cnblogs.com/greatqn/aggbug/2088269.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/greatqn/archive/2011/06/23/2088269.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/greatqn/archive/2011/06/03/2072061.html</id><title type="text">ci_sae 监控项目示例</title><summary type="text">一，楔子SAE平台上的应用，使用的是PHP语言。这么好的环境，不禁手痒。做一个WEB监控来测试一下吧。需求：设置一些URL和字符，定时去获取内容，验证字符。记录获取内容的用时，验证通过表示正常，验证不通过表示异常。将会用到SAE的Cron,FetchURL和Mysql.二，框架内置应用的框架中，就ci_sae有过了解，那就用它了。进入SAE-&amp;gt;我的应用-&amp;gt;应用向导，找到ci_sae，点击安装。会有一个弹窗向导，选择应用[ertong]，选择版本[2]，下一步。框架就安装好了。运行SDK,把代码同步到本地。目录一般在这里：/sdk目录/apps/ertong/2code 项目代码目录</summary><published>2011-06-03T08:45:00Z</published><updated>2011-06-03T08:45:00Z</updated><author><name>greatqn</name><uri>http://www.cnblogs.com/greatqn/</uri></author><link rel="alternate" href="http://www.cnblogs.com/greatqn/archive/2011/06/03/2072061.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/greatqn/archive/2011/06/03/2072061.html"/><content type="html">一，楔子&lt;br /&gt;&#xD;
SAE平台上的应用，使用的是PHP语言。这么好的环境，不禁手痒。做一个WEB监控来测试一下吧。&lt;br /&gt;&#xD;
需求：设置一些URL和字符，定时去获取内容，验证字符。记录获取内容的用时，验证通过表示正常，验证不通过表示异常。&lt;br /&gt;&#xD;
将会用到SAE的Cron,FetchURL和Mysql.&lt;br /&gt;&#xD;
&lt;br /&gt;&#xD;
二，框架&lt;br /&gt;&#xD;
内置应用的框架中，就ci_sae有过了解，那就用它了。&lt;br /&gt;&#xD;
进入SAE-&amp;gt;我的应用-&amp;gt;应用向导，找到ci_sae，点击安装。会有一个弹窗向导，选择应用[ertong]，选择版本[2]，下一步。框架就安装好了。&lt;br /&gt;&#xD;
运行SDK,把代码同步到本地。目录一般在这里：/sdk目录/apps/ertong/2&lt;br /&gt;&#xD;
code 项目代码目录&lt;br /&gt;&#xD;
config.yaml 项目配置信息&lt;br /&gt;&#xD;
deploy.dat 好象是对比线上线下文件用的，放了些md5的信息。上传时，只上传更新过的文件。&lt;br /&gt;&#xD;
&lt;br /&gt;&#xD;
三，升级&lt;br /&gt;&#xD;
查看system\codeigniter\CodeIgniter.php,版本是1.7.2，在http://codeigniter.org.cn&#xD;
/上版本是2.0.2，文档也更新了。反正两个版本都不熟，那就用新的吧。SAE上，mysql,本地文件的处理方式不一样，所以得对2.0做下升级。把&#xD;
下载的1.7.2版的system/database下的文件copy到2.0下。更新application/config&#xD;
/database.php,升级就完成了。就是这么简单。仔细对比下两版的文件，会发现sae版里的mysql的实现，换成了SaeMysql。这些就&#xD;
交给CI去处理了。&lt;br /&gt;&#xD;
&lt;br /&gt;&#xD;
四，建库&lt;br /&gt;&#xD;
一张记录监控站点的信息，一张记录监控的日志。&lt;br /&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;div&gt;&lt;span style="color: #0000ff;"&gt;CREATE&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;TABLE&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;IF&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;NOT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;EXISTS&lt;/span&gt;&lt;span style="color: #000000;"&gt; `jk_site` (&lt;br /&gt;  `id` &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;bigint&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;20&lt;/span&gt;&lt;span style="color: #000000;"&gt;) &lt;/span&gt;&lt;span style="color: #808080;"&gt;NOT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;NULL&lt;/span&gt;&lt;span style="color: #000000;"&gt; AUTO_INCREMENT,&lt;br /&gt;  `name` &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;varchar&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;64&lt;/span&gt;&lt;span style="color: #000000;"&gt;) &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;DEFAULT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;NULL&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;br /&gt;  `url` &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;varchar&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;256&lt;/span&gt;&lt;span style="color: #000000;"&gt;) &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;DEFAULT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;NULL&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;br /&gt;  `category` &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;varchar&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;64&lt;/span&gt;&lt;span style="color: #000000;"&gt;) &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;DEFAULT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;NULL&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;br /&gt;  `pattern_str` &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;varchar&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;64&lt;/span&gt;&lt;span style="color: #000000;"&gt;) &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;DEFAULT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;NULL&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;br /&gt;  `state` &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;11&lt;/span&gt;&lt;span style="color: #000000;"&gt;) &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;DEFAULT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;NULL&lt;/span&gt;&lt;span style="color: #000000;"&gt; ,&lt;br /&gt;  `last_modify_date` &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;datetime&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;DEFAULT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;NULL&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;br /&gt;  `is_deleted` &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;11&lt;/span&gt;&lt;span style="color: #000000;"&gt;) &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;DEFAULT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;NULL&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;PRIMARY&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;KEY&lt;/span&gt;&lt;span style="color: #000000;"&gt; (`id`)&lt;br /&gt;) ;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;CREATE&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;TABLE&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;IF&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;NOT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;EXISTS&lt;/span&gt;&lt;span style="color: #000000;"&gt; `jk_site_log` (&lt;br /&gt;  `id` &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;bigint&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;20&lt;/span&gt;&lt;span style="color: #000000;"&gt;) &lt;/span&gt;&lt;span style="color: #808080;"&gt;NOT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;NULL&lt;/span&gt;&lt;span style="color: #000000;"&gt; AUTO_INCREMENT,&lt;br /&gt;  `site_id` &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;bigint&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;20&lt;/span&gt;&lt;span style="color: #000000;"&gt;) &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;DEFAULT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;NULL&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;br /&gt;  `name` &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;varchar&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;64&lt;/span&gt;&lt;span style="color: #000000;"&gt;) &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;DEFAULT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;NULL&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;br /&gt;  `content_lenght` &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;11&lt;/span&gt;&lt;span style="color: #000000;"&gt;) &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;DEFAULT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;NULL&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;br /&gt;  `elapsed_time` &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;double&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;DEFAULT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;NULL&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;br /&gt;  `state` &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;11&lt;/span&gt;&lt;span style="color: #000000;"&gt;) &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;DEFAULT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;NULL&lt;/span&gt;&lt;span style="color: #000000;"&gt; ,&lt;br /&gt;  `last_modify_date` &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;datetime&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;DEFAULT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;NULL&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;br /&gt;  `is_deleted` &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800000; font-weight: bold;"&gt;11&lt;/span&gt;&lt;span style="color: #000000;"&gt;) &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;DEFAULT&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;NULL&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;PRIMARY&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;KEY&lt;/span&gt;&lt;span style="color: #000000;"&gt; (`id`)&lt;br /&gt;) ;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
用phpMyadmin对jk_site表写入一些数据。&lt;br /&gt;&#xD;
&lt;br /&gt;&#xD;
五，查询&lt;br /&gt;&#xD;
现在我们用ci来展示jk_site的数据。&lt;br /&gt;&#xD;
先按MVC的目录，在application下分别建好对应的文件。&lt;br /&gt;&#xD;
/controllers/site.php&lt;br /&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;div&gt;&lt;span style="color: #0000ff;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; Site &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;extends&lt;/span&gt;&lt;span style="color: #000000;"&gt; CI_Controller {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt; __construct()&lt;br /&gt;    {&lt;br /&gt;        parent&lt;/span&gt;&lt;span style="color: #000000;"&gt;::&lt;/span&gt;&lt;span style="color: #000000;"&gt;__construct();&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;load&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;helper(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;url&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;控制URL&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;load&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;library(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;pagination&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;分页&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;    }&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt; index(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$offset&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;load&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;model(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;site_model&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: #800080;"&gt;$data&lt;/span&gt;&lt;span style="color: #000000;"&gt;[&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;query&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;] &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;site_model&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;get();&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;load&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;view(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;site_message&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #800080;"&gt;$data&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;    }&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
/models/site_model.php&lt;br /&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;div&gt;&lt;span style="color: #0000ff;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; Site_model &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;extends&lt;/span&gt;&lt;span style="color: #000000;"&gt; CI_Model {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt; __construct()&lt;br /&gt;    {&lt;br /&gt;        parent&lt;/span&gt;&lt;span style="color: #000000;"&gt;::&lt;/span&gt;&lt;span style="color: #000000;"&gt;__construct();&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;load&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;database();&lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;加载数据库&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;    }&lt;br /&gt;       &lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt; get()&lt;br /&gt;    {&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;db&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;from(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;site&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;$db['default']['dbprefix'] = 'jk_'; 这个配置可以设置表前缀。&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;             &lt;/span&gt;&lt;span style="color: #800080;"&gt;$query&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;db&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;get();&lt;br /&gt;             &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$query&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;result();&lt;br /&gt;    }&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
/views/site_message.php&lt;br /&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;div&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;table &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;list issues&lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;tr&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;序号&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;名字&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;URL&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;状态&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;更新时间&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;操作&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;tr&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #000000;"&gt;php &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;foreach&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$query&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;as&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$item&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;/span&gt;&lt;span style="color: #000000;"&gt;:&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;?&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;tr&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #000000;"&gt;php &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;echo&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$item&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;id &lt;/span&gt;&lt;span style="color: #000000;"&gt;?&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #000000;"&gt;php &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;echo&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$item&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;name &lt;/span&gt;&lt;span style="color: #000000;"&gt;?&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #000000;"&gt;php &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;echo&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$item&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;url &lt;/span&gt;&lt;span style="color: #000000;"&gt;?&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #000000;"&gt;php &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;echo&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$item&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;state &lt;/span&gt;&lt;span style="color: #000000;"&gt;?&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #000000;"&gt;php &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;echo&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$item&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;last_modify_date &lt;/span&gt;&lt;span style="color: #000000;"&gt;?&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;a href&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;?php echo site_url('site/logs/'.&lt;/span&gt;&lt;span style="color: #800080;"&gt;$item&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;id) ?&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;日志&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;a&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;td&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;tr&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #000000;"&gt;php &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;endforeach&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;/span&gt;&lt;span style="color: #000000;"&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
用SDK上传后，用http://2.ertong.sinaapp.com/index.php/site 进行访问，应该就能看到数据库里的数据了。&lt;br /&gt;&#xD;
&lt;br /&gt;&#xD;
六，URLRewrite&lt;br /&gt;&#xD;
SEA的环境不支持htaccess,不过它有替代方案。在config.yaml里写如下语句：&lt;br /&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;div&gt;&lt;span style="color: #000000;"&gt;handle:&lt;br /&gt;  - rewrite: &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #000000;"&gt;!is_dir&lt;/span&gt;&lt;span style="color: #000000;"&gt;()&lt;/span&gt;&lt;span style="color: #000000;"&gt; &amp;amp;&amp;amp; !is_file&lt;/span&gt;&lt;span style="color: #000000;"&gt;())&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;goto&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;index.php?%{QUERY_STRING}&lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;br /&gt;&#xD;
这样就可以用 http://2.ertong.sinaapp.com/site进行访问了。&lt;br /&gt;&#xD;
&lt;br /&gt;&#xD;
七，定时器&lt;br /&gt;&#xD;
在config.yaml里写如下语句：&lt;br /&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;div&gt;&lt;span style="color: #000000;"&gt;cron:&lt;br /&gt;    - description: test&lt;br /&gt;    url: site&lt;/span&gt;&lt;span style="color: #000000;"&gt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;jiankong&lt;br /&gt;    schedule: every &lt;/span&gt;&lt;span style="color: #000000;"&gt;5&lt;/span&gt;&lt;span style="color: #000000;"&gt; mins&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;br /&gt;&#xD;
则每5分钟会请求 http://ertong.sinaapp.com/site/jiankong 一次。注意仅对默认版本有效。&lt;br /&gt;&#xD;
&lt;br /&gt;&#xD;
八，监控&lt;br /&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;div&gt;&lt;span style="color: #0000ff;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt; check_site(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$site&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;{&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;监控URL&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;benchmark&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;mark(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;check_site_begin&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$content&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;getUrl(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$site&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;url);&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;benchmark&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;mark(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;check_site_end&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;       &lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$findstr&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #008080;"&gt;iconv&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;GB2312&lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;UTF-8//IGNORE&lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #800080;"&gt;$site&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;pattern_str) ;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$state&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #008080;"&gt;strpos&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$content&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #800080;"&gt;$findstr&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;?&lt;/span&gt;&lt;span style="color: #000000;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;:&lt;/span&gt;&lt;span style="color: #000000;"&gt;1&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;   &lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;记录监控日志&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #800080;"&gt;$data&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;array&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;br /&gt;               &lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;site_id&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$site&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;id&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;               &lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;name&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$site&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;name&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;               &lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;content_lenght&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #008080;"&gt;strlen&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$content&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;               &lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;elapsed_time&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;benchmark&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;elapsed_time(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;check_site_begin&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;check_site_end&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;               &lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;state&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$state&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;               &lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;last_modify_date&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #008080;"&gt;date&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;Y-m-d H:i:s&lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;               &lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;is_deleted&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            );&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;db&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;insert(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;site_log&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$data&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;更新站点状态&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$data&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;array&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;br /&gt;               &lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;state&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$state&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;               &lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;last_modify_date&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #008080;"&gt;date&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;Y-m-d H:i:s&lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;            );&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;db&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;where(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;id&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$site&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;id);&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;db&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;update(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;site&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$data&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt; getUrl(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$url&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;{&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: #800080;"&gt;$f&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; SaeFetchurl();&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: #800080;"&gt;$content&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$f&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;fetch(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$url&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$f&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;errno() &lt;/span&gt;&lt;span style="color: #000000;"&gt;==&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;)  &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$content&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;else&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$f&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;errmsg();&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
SAE里通过$this-&amp;gt;benchmark-&amp;gt;mark进行计时，SaeFetchurl的使用也超简单。&lt;br /&gt;&#xD;
&lt;br /&gt;&#xD;
九，分页&lt;br /&gt;&#xD;
/controllers/site.php&lt;br /&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;div&gt;&lt;span style="color: #0000ff;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt; logs(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$siteid&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #800080;"&gt;$offset&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$config&lt;/span&gt;&lt;span style="color: #000000;"&gt;[&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;total_rows&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;] &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;800&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;切换成读取数据量。&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$config&lt;/span&gt;&lt;span style="color: #000000;"&gt;[&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;base_url&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;] &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;/site/logs/&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;.&lt;/span&gt;&lt;span style="color: #800080;"&gt;$siteid&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$config&lt;/span&gt;&lt;span style="color: #000000;"&gt;[&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;per_page&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;] &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;20&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;每页多少条&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$config&lt;/span&gt;&lt;span style="color: #000000;"&gt;[&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;uri_segment&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;] &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;4&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;页码的字段位置&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;pagination&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;initialize(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$config&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$pagery&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;pagination&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;create_links();&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$per_page&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;pagination&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;per_page;&lt;br /&gt;       &lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;load&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;model(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;site_model&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: #800080;"&gt;$data&lt;/span&gt;&lt;span style="color: #000000;"&gt;[&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;query&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;] &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;site_model&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;getlog_pages(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$siteid&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #800080;"&gt;$per_page&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$offset&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: #800080;"&gt;$data&lt;/span&gt;&lt;span style="color: #000000;"&gt;[&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;pagery&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;] &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$pagery&lt;/span&gt;&lt;span style="color: #000000;"&gt;; &lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;load&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;view(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;sitelog_message&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #800080;"&gt;$data&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;    }&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
/models/site_model.php&lt;br /&gt;&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;div&gt;&lt;span style="color: #0000ff;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt; getlog_pages(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$siteid&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #800080;"&gt;$num&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;10&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$offset&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;    {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;db&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;from(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;site_log&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;db&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;where(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;site_id&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #800080;"&gt;$siteid&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;db&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;limit(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$num&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$offset&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;db&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;order_by(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;id desc&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;         &lt;/span&gt;&lt;span style="color: #800080;"&gt;$query&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$this&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;db&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;get();&lt;br /&gt;         &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$query&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;result();&lt;br /&gt;    }&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;br /&gt;&#xD;
/views/sitelog_message.php&#xD;
&lt;/p&gt;&#xD;
&#xD;
&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&#xD;
&lt;pre&gt;&lt;div&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;div id&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;pager&lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #000000;"&gt;php &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;echo&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$pagery&lt;/span&gt;&lt;span style="color: #000000;"&gt;; &lt;/span&gt;&lt;span style="color: #000000;"&gt;?&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;br &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;clear&lt;/span&gt;&lt;span style="color: #000000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;div&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&#xD;
&lt;div &gt;&#xD;
&lt;/div&gt;&lt;img src="http://www.cnblogs.com/greatqn/aggbug/2072061.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/greatqn/archive/2011/06/03/2072061.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/greatqn/archive/2011/06/02/2068752.html</id><title type="text">Sina App Engine 初级入门</title><summary type="text">偶然间发现了SAE，用google搜索“Sina App Engine”，发现文章大都是2009年11月的。看来有些来迟了，现在不火啦？我发现的时候，已经正式开放注册了。那就进去体验一下吧。一。LOADING...地址：http://sae.sina.com.cn用新浪微博帐号可直接登录，然后通过邮箱，手机两重验证。就算进入SEA的环境了。免费帐户可建10个应用，每个应用可放10个版本，相当于可以放100份代码在上面。十分给力啊。二。新应用下载SDK,http://sae.sina.com.cn/?m=sdk,这是一个上下传代码的工具，解压后直接运行am.exe即可。首先要新建app,这一步要</summary><published>2011-06-02T09:35:00Z</published><updated>2011-06-02T09:35:00Z</updated><author><name>greatqn</name><uri>http://www.cnblogs.com/greatqn/</uri></author><link rel="alternate" href="http://www.cnblogs.com/greatqn/archive/2011/06/02/2068752.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/greatqn/archive/2011/06/02/2068752.html"/><content type="html">&lt;p&gt;偶然间发现了SAE，用google搜索&amp;ldquo;Sina App Engine&amp;rdquo;，发现文章大都是2009年11月的。看来有些来迟了，现在不火啦？我发现的时候，已经正式开放注册了。那就进去体验一下吧。&lt;br /&gt;&lt;br /&gt;一。LOADING...&lt;br /&gt;地址：http://sae.sina.com.cn&lt;br /&gt;用新浪微博帐号可直接登录，然后通过邮箱，手机两重验证。就算进入SEA的环境了。&lt;br /&gt;免费帐户可建10个应用，每个应用可放10个版本，相当于可以放100份代码在上面。十分给力啊。&lt;br /&gt;&lt;br /&gt;二。新应用&lt;br /&gt;下载SDK,http://sae.sina.com.cn/?m=sdk,这是一个上下传代码的工具，解压后直接运行am.exe即可。&lt;br /&gt;首先要新建app,这一步要在线上操作。就是建一个sinaapp.com的二级域名。是一个应用的唯一标识，后面用到的地方可多了。先假设我们新建的app的名字是ertong。&lt;br /&gt;线上创建app成功后，在SDK左侧商口里就能看到ertong。然后点"+"按钮，为app新建一个版本。版本号只能正数字。先输入1。里面有一个index.php文件。&amp;ldquo;hello world&amp;rdquo;赫然在目。这里访问http://ertong.sinaapp.com,就能看到这页的内容了。气定神闲对index.php进行修改。然后点&amp;ldquo;更新上传&amp;rdquo;按钮。SDK就把代码部署到线上。提示：Finished! Deploy successful, Please visit http://1.ertong.sinaapp.com。这个URL前面多了个1，为什么？这对应的是版本号，10个版本里有一个是默认的，可以用http://ertong.sinaapp.com进行访问。见过hello world,再试下phpinfo().可以看到服务器的一些信息。PHP Version 5.3.3等。&lt;br /&gt;&lt;br /&gt;回顾：创建app之后，一个网站就诞生了。相比自购服务器，装系统，装nginx,装mysql，ftp上传代码，设置目录等。这个SAE的体验太爽了，内牛满面。要是自家系统也能达到这个高度就好了！&lt;br /&gt;&lt;br /&gt;三。现成的应用&lt;br /&gt;在SAE后台，我的应用里，有一些现成的应用，可供安装。拿来学习也不错。推荐应用有Xweibo,Wordpress,TeamToy。应用向导里有Mini2SAE,yunphp,LazyPHP,ci-sae等开发框架，已经移植到SAE平台下，可以直接用哦。框架套平台，自己的应用都不用大改哦，就可以用了。安装了下Wordpress，发现没，数据库全自动帮你搞定，一分钟就建好了。&lt;br /&gt;&lt;br /&gt;四。数据库&lt;br /&gt;数据库啊，咱技术人最少不了的一部份。在SAE里，有个内置的phpMyadmin,菜单位置在应用管理页，服务管理-&amp;gt;MySQL,这里可以开启，禁用，管理MySQL。点击管理按钮，需要进行一次安全验证。然后就进入熟悉的phpMyAdmin的管理界面。掌控了数据库，功力恢复一半了哇。&lt;br /&gt;&lt;br /&gt;五。后续&lt;br /&gt;SAE提供的服务有：&lt;br /&gt;分布式文件存储服务 - Storage&lt;br /&gt;本地临时文件读写模块 - TmpFS&lt;br /&gt;分布式数据库集群 - RDC (MySql)&lt;br /&gt;分布式图像处理服务 - Image&lt;br /&gt;分布式缓存服务 - Memcache&lt;br /&gt;分布式邮件服务 - Mail&lt;br /&gt;分布式定时服务 - Cron&lt;br /&gt;分布式网页抓取服务 - FetchURL&lt;br /&gt;异步轻量级任务队列服务 - TaskQueue&lt;br /&gt;异步大任务延迟队列服务 - DeferredJob&lt;br /&gt;分布式计数器服务 - Counter&lt;br /&gt;好想全部占为已有啊。&lt;br /&gt;在"开发者中心"菜单下，这些服务的说明文档还算齐全，调用也简单。&lt;br /&gt;&lt;br /&gt;不过这么好的东西，社区在哪里？只有一个意见反馈有点互动，其它都是些文档性质。&lt;/p&gt;&lt;img src="http://www.cnblogs.com/greatqn/aggbug/2068752.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/greatqn/archive/2011/06/02/2068752.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry></feed>
