<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>翱翔白鹭 &#187; PHP</title>
	<atom:link href="http://yanglu.org/category/makepage/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://yanglu.org</link>
	<description>天高任鸟飞，海阔凭鱼跃！</description>
	<lastBuildDate>Wed, 23 Nov 2011 06:04:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHPExcel导出xls文件时冻结行或列</title>
		<link>http://yanglu.org/phpexcel_freeze_column_row/</link>
		<comments>http://yanglu.org/phpexcel_freeze_column_row/#comments</comments>
		<pubDate>Sat, 19 Mar 2011 17:23:31 +0000</pubDate>
		<dc:creator>yanglu</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHPExcel]]></category>

		<guid isPermaLink="false">http://yanglu.org/?p=358</guid>
		<description><![CDATA[在使用PHPExcel导出xls文件时可以使用FreezePane方法像excel那样冻结窗格，使用方法： $objPHPExcel = new PHPExcel&#40;&#41;; &#160; $objPHPExcel-&#62;getActiveSheet&#40;&#41;-&#62;FreezePane&#40;'A2'&#41;;  //冻结首行 $objPHPExcel-&#62;getActiveSheet&#40;&#41;-&#62;FreezePane&#40;'B1'&#41;;  //冻结首列,A列 $objPHPExcel-&#62;getActiveSheet&#40;&#41;-&#62;FreezePane&#40;'B2'&#41;; // 冻结首行和首列]]></description>
			<content:encoded><![CDATA[<p>在使用PHPExcel导出xls文件时可以使用FreezePane方法像excel那样冻结窗格，使用方法：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$objPHPExcel</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PHPExcel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$objPHPExcel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getActiveSheet</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">FreezePane</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'A2'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">//冻结首行</span>
<span style="color: #000088;">$objPHPExcel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getActiveSheet</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">FreezePane</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'B1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">//冻结首列,A列</span>
<span style="color: #000088;">$objPHPExcel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getActiveSheet</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">FreezePane</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'B2'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 冻结首行和首列</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://yanglu.org/phpexcel_freeze_column_row/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ssh使用命令nohup php-cgi后台运行PHP</title>
		<link>http://yanglu.org/ssh_nohup_php_cgi/</link>
		<comments>http://yanglu.org/ssh_nohup_php_cgi/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 09:44:48 +0000</pubDate>
		<dc:creator>yanglu</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://yanglu.org/?p=346</guid>
		<description><![CDATA[使用ssh远程登录服务器的时候，要进行后台任务操作（比如采集），可以用命令nohup php-cgi来运行php，这样就可以关掉ssh客户端后还会在服务器上运行，运行的输出结果记录在用户目录下的nohup.out文件。]]></description>
			<content:encoded><![CDATA[<p>使用ssh远程登录服务器的时候，要进行后台任务操作（比如采集），可以用命令nohup php-cgi来运行php，这样就可以关掉ssh客户端后还会在服务器上运行，运行的输出结果记录在用户目录下的nohup.out文件。</p>
]]></content:encoded>
			<wfw:commentRss>http://yanglu.org/ssh_nohup_php_cgi/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SMARTY模板中如何使用get,post,request,cookies,session,server变量</title>
		<link>http://yanglu.org/smarty_get_post_request_cookie_ssession_server/</link>
		<comments>http://yanglu.org/smarty_get_post_request_cookie_ssession_server/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 05:54:11 +0000</pubDate>
		<dc:creator>yanglu</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[smarty]]></category>

		<guid isPermaLink="false">http://yanglu.org/?p=325</guid>
		<description><![CDATA[{$smarty}保留变量不需要从PHP脚本中分配，是可以在模板中直接访问的数组类型变量，通常被用于访问一些特殊的模板变量。例如，直接在模板中访问页面请求变量、获取访问模板时的时间邮戳、直接访问PHP中的常量、从配置文件中读取变量等。该保留变量中的部分访问介绍如下。 1．在模板中访问页面请求变量 我们可以在PHP脚本中，通过超级全局数组$_GET、$_POST、$_REQUEST获取在客户端以不同方法提交给服务器的数据，也可以通过$_COOKIE或$_SESSION在多个脚本之间跟踪变量，或是通过$_ENV和$_SERVER获取系统环境变量。如果在模板中需要这些数组，可以调用Smarty对象中的assign()方法分配给模板。但在Smarty模板中，直接就可以通过{$smarty}保留变量访问这些页面请求变量。在模板中使用的示例如下所示： 1.  {$smarty.get.page}            {* PHP方式：$_GET["page"] *}   2.  {$smarty.post.page}           {* PHP方式：$_POST["page"] *}   3.  {$smarty.cookies.username}    {* PHP方式：$_COOKIE["username"] *}   4.  {$smarty.session.id}          {* PHP方式：$_SESSION["id"] *}   5.  {$smarty.server.SERVER_NAME}  {* PHP方式：$_SERVER["SERVER_NAME"] *}   6.  {$smarty.env.PATH}            {* PHP方式：$_ENV["PATH"]*}   7.  {$smarty.request.username}    {* PHP方式：$_REQUEST["username"] *}  2．在模板中访问PHP中的变量 在PHP脚本中有系统常量和自定义常量两种，同样这两种常量在Smarty模板中也可以被访问，而且不需要从PHP中分配，只要通过{$smarty}保留变量就可以直接输出常量的值。在模板中输出常量的示例如下所示： 1.  {$smarty.const._MY_CONST_VAL} {* 输出PHP脚本中自定义的常量 *}   2.  {$smarty.const.__FILE__}     {* 通过保留变量数组直接输出系统常量 *}]]></description>
			<content:encoded><![CDATA[<p>{$smarty}保留变量不需要从PHP脚本中分配，是可以在模板中直接访问的数组类型变量，通常被用于访问一些特殊的模板变量。例如，直接在模板中访问页面请求变量、获取访问模板时的时间邮戳、直接访问PHP中的常量、从配置文件中读取变量等。该保留变量中的部分访问介绍如下。</p>
<p><strong>1</strong><strong>．在模板中访问页面请求变量</strong></p>
<p>我们可以在PHP脚本中，通过超级全局数组$_GET、$_POST、$_REQUEST获取在客户端以不同方法提交给服务器的数据，也可以通过$_COOKIE或$_SESSION在多个脚本之间跟踪变量，或是通过$_ENV和$_SERVER获取系统环境变量。如果在模板中需要这些数组，可以调用Smarty对象中的assign()方法分配给模板。但在Smarty模板中，直接就可以通过{$smarty}保留变量访问这些页面请求变量。在模板中使用的示例如下所示：<span id="more-325"></span></p>
<pre>1.  {$smarty.get.page}             {* PHP方式：$_GET["page"] *}  </pre>
<pre>2.  {$smarty.post.page}            {* PHP方式：$_POST["page"] *}  </pre>
<pre>3.  {$smarty.cookies.username}     {* PHP方式：$_COOKIE["username"] *}  </pre>
<pre>4.  {$smarty.session.id}           {* PHP方式：$_SESSION["id"] *}  </pre>
<pre>5.  {$smarty.server.SERVER_NAME}   {* PHP方式：$_SERVER["SERVER_NAME"] *}  </pre>
<pre>6.  {$smarty.env.PATH}             {* PHP方式：$_ENV["PATH"]*}  </pre>
<pre>7.  {$smarty.request.username}     {* PHP方式：$_REQUEST["username"] *} </pre>
<p><strong>2</strong><strong>．在模板中访问PHP中的变量</strong></p>
<p>在PHP脚本中有系统常量和自定义常量两种，同样这两种常量在Smarty模板中也可以被访问，而且不需要从PHP中分配，只要通过{$smarty}保留变量就可以直接输出常量的值。在模板中输出常量的示例如下所示：</p>
<pre>1.  {$smarty.<strong>const</strong>._MY_CONST_VAL} {* 输出PHP脚本中自定义的常量 *}  </pre>
<pre>2.  {$smarty.<strong>const</strong>.<strong>__FILE__</strong>}     {* 通过保留变量数组直接输出系统常量 *}</pre>
]]></content:encoded>
			<wfw:commentRss>http://yanglu.org/smarty_get_post_request_cookie_ssession_server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>使用CDN加速后对PHP获取IP的影响</title>
		<link>http://yanglu.org/discuz_real_ip_cdn/</link>
		<comments>http://yanglu.org/discuz_real_ip_cdn/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 03:30:38 +0000</pubDate>
		<dc:creator>yanglu</dc:creator>
				<category><![CDATA[Discuz!]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[cdn]]></category>
		<category><![CDATA[ip]]></category>

		<guid isPermaLink="false">http://yanglu.org/?p=321</guid>
		<description><![CDATA[一直都是使用DISCUZ的获取客户端IP的函数，但今日发现网站使用CDN加速后，网站统计出了问题，获取到的IP有部分是CDN节点的IP，而程序统计是以唯一IP判断，导致统计到的IP比实际IP少很多。改动获取IP的函数后恢复正常。 原获取IP的方法： if&#40;getenv&#40;'HTTP_CLIENT_IP'&#41; &#38;&#38; strcasecmp&#40;getenv&#40;'HTTP_CLIENT_IP'&#41;, 'unknown'&#41;&#41; &#123; $onlineip = getenv&#40;'HTTP_CLIENT_IP'&#41;; &#125; elseif&#40;getenv&#40;'HTTP_X_FORWARDED_FOR'&#41; &#38;&#38; strcasecmp&#40;getenv&#40;'HTTP_X_FORWARDED_FOR'&#41;, 'unknown'&#41;&#41; &#123; $onlineip = getenv&#40;'HTTP_X_FORWARDED_FOR'&#41;; &#125; elseif&#40;getenv&#40;'REMOTE_ADDR'&#41; &#38;&#38; strcasecmp&#40;getenv&#40;'REMOTE_ADDR'&#41;, 'unknown'&#41;&#41; &#123; $onlineip = getenv&#40;'REMOTE_ADDR'&#41;; &#125; elseif&#40;isset&#40;$_SERVER&#91;'REMOTE_ADDR'&#93;&#41; &#38;&#38; $_SERVER&#91;'REMOTE_ADDR'&#93; &#38;&#38; strcasecmp&#40;$_SERVER&#91;'REMOTE_ADDR'&#93;, 'unknown'&#41;&#41; &#123; $onlineip = $_SERVER&#91;'REMOTE_ADDR'&#93;; &#125; &#8230; <a href="http://yanglu.org/discuz_real_ip_cdn/">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>一直都是使用DISCUZ的获取客户端IP的函数，但今日发现网站使用CDN加速后，网站统计出了问题，获取到的IP有部分是CDN节点的IP，而程序统计是以唯一IP判断，导致统计到的IP比实际IP少很多。改动获取IP的函数后恢复正常。<br />
原获取IP的方法：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTTP_CLIENT_IP'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">strcasecmp</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTTP_CLIENT_IP'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'unknown'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$onlineip</span> <span style="color: #339933;">=</span> <span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTTP_CLIENT_IP'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTTP_X_FORWARDED_FOR'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">strcasecmp</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTTP_X_FORWARDED_FOR'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'unknown'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$onlineip</span> <span style="color: #339933;">=</span> <span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTTP_X_FORWARDED_FOR'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">strcasecmp</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'unknown'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$onlineip</span> <span style="color: #339933;">=</span> <span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">strcasecmp</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'unknown'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$onlineip</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/[\d\.]{7,15}/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$onlineip</span><span style="color: #339933;">,</span> <span style="color: #000088;">$onlineipmatches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$onlineip</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$onlineipmatches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> ? <span style="color: #000088;">$onlineipmatches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'unknown'</span><span style="color: #339933;">;</span>
<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$onlineipmatches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><span id="more-321"></span><br />
改成如下：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> get_real_ip<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
       <span style="color: #000088;">$ip</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
       <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;HTTP_CLIENT_IP&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
       <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$ip</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;HTTP_CLIENT_IP&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>
       <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_X_FORWARDED_FOR'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
       <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$ips</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_X_FORWARDED_FOR'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                     <span style="color: #990000;">array_unshift</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ips</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$ip</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ips</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                     <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">eregi</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;^(10|172\.16|192\.168)\.&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ips</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                     <span style="color: #009900;">&#123;</span>
                               <span style="color: #000088;">$ip</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ips</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                               <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
                     <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
       <span style="color: #009900;">&#125;</span>
       <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span> ? <span style="color: #000088;">$ip</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$onlineip</span> <span style="color: #339933;">=</span> get_real_ip<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://yanglu.org/discuz_real_ip_cdn/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>MySQL创建、删除、重建和查看索引</title>
		<link>http://yanglu.org/mysql_index_alter/</link>
		<comments>http://yanglu.org/mysql_index_alter/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 02:42:34 +0000</pubDate>
		<dc:creator>yanglu</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://yanglu.org/?p=317</guid>
		<description><![CDATA[MySQL创建、删除、重建和查看索引命令、掌握创建索引、删除索引、重建索引和查看索引的命今。 1，创建索引（PRIMARY KEY，INDEX，UNIQUE） 支持创建主键索引，联合索引和普通索引命令 mysql&#62;ALTER TABLE tbl_name ADD INDEX index_name &#40;column list&#41;; mysql&#62;ALTER TABLE tbl_name ADD UNIQUE index_name &#40;column list&#41;; mysql&#62;ALTER TABLE tbl_name ADD PRIMARY KEY index_name &#40;column list&#41;; 2，删除索引（PRIMARY KEY，INDEX，UNIQUE） 支持删除主键索引，联合索引和普通索引命令 mysql&#62;ALTER TABLE tbl_name DROP INDEX index_name &#40;column list&#41;; &#8230; <a href="http://yanglu.org/mysql_index_alter/">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>MySQL创建、删除、重建和查看索引命令、掌握创建索引、删除索引、重建索引和查看索引的命今。</p>
<p><strong>1，创建索引（PRIMARY KEY，INDEX，UNIQUE）</strong><br />
支持创建主键索引，联合索引和普通索引命令</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span>ALTER <span style="color: #990099; font-weight: bold;">TABLE</span> tbl_name <span style="color: #990099; font-weight: bold;">ADD</span> <span style="color: #990099; font-weight: bold;">INDEX</span> index_name <span style="color: #FF00FF;">&#40;</span><span style="color: #990099; font-weight: bold;">column</span> list<span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
mysql<span style="color: #CC0099;">&gt;</span>ALTER <span style="color: #990099; font-weight: bold;">TABLE</span> tbl_name <span style="color: #990099; font-weight: bold;">ADD</span> <span style="color: #FF9900; font-weight: bold;">UNIQUE</span> index_name <span style="color: #FF00FF;">&#40;</span><span style="color: #990099; font-weight: bold;">column</span> list<span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
mysql<span style="color: #CC0099;">&gt;</span>ALTER <span style="color: #990099; font-weight: bold;">TABLE</span> tbl_name <span style="color: #990099; font-weight: bold;">ADD</span> <span style="color: #990099; font-weight: bold;">PRIMARY KEY</span> index_name <span style="color: #FF00FF;">&#40;</span><span style="color: #990099; font-weight: bold;">column</span> list<span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></div></div>

<p><strong>2，删除索引（PRIMARY KEY，INDEX，UNIQUE）</strong><br />
支持删除主键索引，联合索引和普通索引命令</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span>ALTER <span style="color: #990099; font-weight: bold;">TABLE</span> tbl_name <span style="color: #990099; font-weight: bold;">DROP</span> <span style="color: #990099; font-weight: bold;">INDEX</span> index_name <span style="color: #FF00FF;">&#40;</span><span style="color: #990099; font-weight: bold;">column</span> list<span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
mysql<span style="color: #CC0099;">&gt;</span>ALTER <span style="color: #990099; font-weight: bold;">TABLE</span> tbl_name <span style="color: #990099; font-weight: bold;">DROP</span> <span style="color: #FF9900; font-weight: bold;">UNIQUE</span> index_name <span style="color: #FF00FF;">&#40;</span><span style="color: #990099; font-weight: bold;">column</span> list<span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
mysql<span style="color: #CC0099;">&gt;</span>ALTER <span style="color: #990099; font-weight: bold;">TABLE</span> tbl_name <span style="color: #990099; font-weight: bold;">DROP</span> <span style="color: #990099; font-weight: bold;">PRIMARY KEY</span> index_name <span style="color: #FF00FF;">&#40;</span><span style="color: #990099; font-weight: bold;">column</span> list<span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></div></div>

<p><strong><span id="more-317"></span>3，重建索引</strong></p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> REPAIR <span style="color: #990099; font-weight: bold;">TABLE</span> tbl_name <span style="color: #990099; font-weight: bold;">QUICK</span><span style="color: #000033;">;</span></pre></div></div>

<p><strong>4，查看某个数据表的索引</strong></p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">SHOW</span> <span style="color: #990099; font-weight: bold;">INDEX</span> <span style="color: #990099; font-weight: bold;">FROM</span> tbl_name<span style="color: #000033;">;</span></pre></div></div>

<p>其中tbl_name表示数据表名，index_name表示索引名，column list表示字段列表</p>
]]></content:encoded>
			<wfw:commentRss>http://yanglu.org/mysql_index_alter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php正则匹配中文</title>
		<link>http://yanglu.org/php_preg_match_chinese/</link>
		<comments>http://yanglu.org/php_preg_match_chinese/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 00:44:39 +0000</pubDate>
		<dc:creator>yanglu</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[正则]]></category>

		<guid isPermaLink="false">http://yanglu.org/?p=300</guid>
		<description><![CDATA[php正则匹配中文的方法： $str = &#34;04aol汉字&#34;; $pattern = &#34;/^(\d{2})([A-Za-z]{3})([&#34;.chr&#40;0xa1&#41;.&#34;-&#34;.chr&#40;0xff&#41;.&#34;]+)$/&#34;; if&#40;preg_match&#40;$pattern, $str, $tmp&#41;&#41; &#123; 　　var_export&#40;$tmp&#41;; &#125; 显示结果： array &#40; 　　0 =&#62; '04aol汉字', 　　1 =&#62; '04', 　　2 =&#62; 'aol', 　　3 =&#62; '汉字', &#41;]]></description>
			<content:encoded><![CDATA[<p>php正则匹配中文的方法：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;04aol汉字&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/^(\d{2})([A-Za-z]{3})([&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0xa1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0xff</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;]+)$/&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tmp</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
　　<span style="color: #990000;">var_export</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tmp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>显示结果：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span>
　　<span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'04aol汉字'</span><span style="color: #339933;">,</span>
　　<span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'04'</span><span style="color: #339933;">,</span>
　　<span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'aol'</span><span style="color: #339933;">,</span>
　　<span style="color: #cc66cc;">3</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'汉字'</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://yanglu.org/php_preg_match_chinese/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ignore_user_abort实现计划任务</title>
		<link>http://yanglu.org/phpignore_user_abort/</link>
		<comments>http://yanglu.org/phpignore_user_abort/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 07:30:37 +0000</pubDate>
		<dc:creator>yanglu</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://yanglu.org/?p=295</guid>
		<description><![CDATA[ignore_user_abort，这个函数可以帮助我们实现像linux中的cron一样实现计划任务，用户关掉浏览器后还可以执行。 使用方法：先使用函数set_time_limit(0)设置程序的执行时间为无限制。 例： 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 &#60;?php // Ignore user aborts and allow &#8230; <a href="http://yanglu.org/phpignore_user_abort/">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>ignore_user_abort，这个函数可以帮助我们实现像linux中的cron一样实现计划任务，用户关掉浏览器后还可以执行。<br />
使用方法：先使用函数set_time_limit(0)设置程序的执行时间为无限制。<br />
例：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Ignore user aborts and allow the script</span>
<span style="color: #666666; font-style: italic;">// to run forever</span>
<span style="color: #990000;">ignore_user_abort</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">set_time_limit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Testing connection handling in PHP'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Run a pointless loop that sometime</span>
<span style="color: #666666; font-style: italic;">// hopefully will make us click away from</span>
<span style="color: #666666; font-style: italic;">// page or click the &quot;Stop&quot; button.</span>
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Did the connection fail?</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">connection_status</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> CONNECTION_NORMAL<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Sleep for 10 seconds</span>
    <span style="color: #990000;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// If this is reached, then the 'break'</span>
<span style="color: #666666; font-style: italic;">// was triggered from inside the while loop</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// So here we can log, or perform any other tasks</span>
<span style="color: #666666; font-style: italic;">// we need without actually being dependent on the</span>
<span style="color: #666666; font-style: italic;">// browser.</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://yanglu.org/phpignore_user_abort/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>phpCB批量转换php文件视图</title>
		<link>http://yanglu.org/phpcb_batch_view/</link>
		<comments>http://yanglu.org/phpcb_batch_view/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 01:17:04 +0000</pubDate>
		<dc:creator>yanglu</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[phpCB]]></category>

		<guid isPermaLink="false">http://yanglu.org/?p=285</guid>
		<description><![CDATA[　　最近需要整理一个整站的php代码规范视图，前几天发现phpCB整理视图非常好，但有个缺点是不能批量处理，使用过程中发现phpCB是一个CMD程序，马上就想到php的system函数调用cmd，想到就做，下面是phpCB批量转换的php程序： 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 &#8230; <a href="http://yanglu.org/phpcb_batch_view/">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>　　最近需要整理一个整站的php代码规范视图，前几天发现phpCB整理视图非常好，但有个缺点是不能批量处理，使用过程中发现phpCB是一个CMD程序，马上就想到php的system函数调用cmd，想到就做，下面是phpCB批量转换的php程序：<br />
<span id="more-285"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: text/html; charset=gb2312&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ROOT_PATH'</span><span style="color: #339933;">,</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$topath</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;ww&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//要格式化视图的目录名，前后都不要“/”</span>
<span style="color: #000088;">$path</span><span style="color: #339933;">=</span>ROOT_PATH<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$topath</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$arr</span><span style="color: #339933;">=</span>get_all_files<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span>count<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000088;">$phpext</span><span style="color: #339933;">=</span>fileext<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$phpext</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;php&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$cmd</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;phpCB.exe &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &gt; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.phpCB&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">system</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cmd</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">unlink</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #339933;">@</span><span style="color: #990000;">rename</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.phpCB&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> get_all_files<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$list</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">glob</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/*'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$list</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$list</span> <span style="color: #339933;">,</span> get_all_files<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$item</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$list</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$list</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> fileext<span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strrchr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>　　使用方法：把phpCB.exe(不清楚的朋友可以看我的上篇博文：<a href="http://yanglu.org/phpcodebeautifier_view/">php格式化代码视图工具-phpCodeBeautifier</a>)放在windows/system32/目录下，php执行程序和要转换的文件夹放同一级路径，先配置$topath，然后在浏览器里访问本程序，没有结果输出。</p>
]]></content:encoded>
			<wfw:commentRss>http://yanglu.org/phpcb_batch_view/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>php格式化代码视图工具-phpCodeBeautifier</title>
		<link>http://yanglu.org/phpcodebeautifier_view/</link>
		<comments>http://yanglu.org/phpcodebeautifier_view/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 05:35:12 +0000</pubDate>
		<dc:creator>yanglu</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[phpCB]]></category>

		<guid isPermaLink="false">http://yanglu.org/?p=279</guid>
		<description><![CDATA[　　用phpCodeBeautifier工具可以帮你格式化代码视图，规范代码缩进习惯，很实用的一个工具。 　　用法：DOS窗口打开phpCodeBeautifier工具目录，语法格式为: phpCB.exe [options] [filename]  　　下载地址：http://www.waterproof.fr/products/phpCodeBeautifier/ 语法还可以这样用“phpCB.exe  index.php  &#62; new.php” 这样就把当前目录下的index.php格式化到新文件new.php]]></description>
			<content:encoded><![CDATA[<p>　　用phpCodeBeautifier工具可以帮你格式化代码视图，规范代码缩进习惯，很实用的一个工具。</p>
<p>　　用法：DOS窗口打开phpCodeBeautifier工具目录，语法格式为:</p>
<blockquote><p>phpCB.exe [options] [filename] </p></blockquote>
<p>　　<span id="more-279"></span>下载地址：<a title="phpCodeBeautifier" href="http://www.waterproof.fr/products/phpCodeBeautifier/" target="_blank">http://www.waterproof.fr/products/phpCodeBeautifier/</a></p>
<p>语法还可以这样用“phpCB.exe  index.php  &gt; new.php” 这样就把当前目录下的index.php格式化到新文件new.php</p>
]]></content:encoded>
			<wfw:commentRss>http://yanglu.org/phpcodebeautifier_view/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>php配置变量写入配置文件的方法</title>
		<link>http://yanglu.org/php_discuz_file_get_put/</link>
		<comments>http://yanglu.org/php_discuz_file_get_put/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 07:51:47 +0000</pubDate>
		<dc:creator>yanglu</dc:creator>
				<category><![CDATA[Discuz!]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://yanglu.org/?p=277</guid>
		<description><![CDATA[有些常用的配置变量写入MYSQL比较麻烦，可以写入一个php配置文件，在需要的地方引入这个配置文件即可。写入方法如下(摘入)： $configfile = @file_get_contents&#40;'./config.inc.php'&#41;; $configfile = trim&#40;$configfile&#41;; $configfile = preg_replace&#40;&#34;/[$]dbhost\s*\=\s*[\&#34;'].*?[\&#34;'];/is&#34;, &#34;\$dbhost = '$dbhost';&#34;, $configfile&#41;; $configfile = preg_replace&#40;&#34;/[$]dbuser\s*\=\s*[\&#34;'].*?[\&#34;'];/is&#34;, &#34;\$dbuser = '$dbuser';&#34;, $configfile&#41;; $configfile = preg_replace&#40;&#34;/[$]dbpw\s*\=\s*[\&#34;'].*?[\&#34;'];/is&#34;, &#34;\$dbpw = '$dbpw';&#34;, $configfile&#41;; $configfile = preg_replace&#40;&#34;/[$]dbname\s*\=\s*[\&#34;'].*?[\&#34;'];/is&#34;, &#34;\$dbname = '$dbname';&#34;, $configfile&#41;; $configfile = preg_replace&#40;&#34;/[$]adminemail\s*\=\s*[\&#34;'].*?[\&#34;'];/is&#34;, &#34;\$adminemail = &#8230; <a href="http://yanglu.org/php_discuz_file_get_put/">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>有些常用的配置变量写入MYSQL比较麻烦，可以写入一个php配置文件，在需要的地方引入这个配置文件即可。写入方法如下(摘入)：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$configfile</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'./config.inc.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$configfile</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$configfile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$configfile</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/[$]dbhost\s*\=\s*[<span style="color: #000099; font-weight: bold;">\&quot;</span>'].*?[<span style="color: #000099; font-weight: bold;">\&quot;</span>'];/is&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\$</span>dbhost = '<span style="color: #006699; font-weight: bold;">$dbhost</span>';&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$configfile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$configfile</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/[$]dbuser\s*\=\s*[<span style="color: #000099; font-weight: bold;">\&quot;</span>'].*?[<span style="color: #000099; font-weight: bold;">\&quot;</span>'];/is&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\$</span>dbuser = '<span style="color: #006699; font-weight: bold;">$dbuser</span>';&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$configfile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$configfile</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/[$]dbpw\s*\=\s*[<span style="color: #000099; font-weight: bold;">\&quot;</span>'].*?[<span style="color: #000099; font-weight: bold;">\&quot;</span>'];/is&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\$</span>dbpw = '<span style="color: #006699; font-weight: bold;">$dbpw</span>';&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$configfile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$configfile</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/[$]dbname\s*\=\s*[<span style="color: #000099; font-weight: bold;">\&quot;</span>'].*?[<span style="color: #000099; font-weight: bold;">\&quot;</span>'];/is&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\$</span>dbname = '<span style="color: #006699; font-weight: bold;">$dbname</span>';&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$configfile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$configfile</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/[$]adminemail\s*\=\s*[<span style="color: #000099; font-weight: bold;">\&quot;</span>'].*?[<span style="color: #000099; font-weight: bold;">\&quot;</span>'];/is&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\$</span>adminemail = '<span style="color: #006699; font-weight: bold;">$adminemail</span>';&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$configfile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$configfile</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/[$]tablepre\s*\=\s*[<span style="color: #000099; font-weight: bold;">\&quot;</span>'].*?[<span style="color: #000099; font-weight: bold;">\&quot;</span>'];/is&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\$</span>tablepre = '<span style="color: #006699; font-weight: bold;">$tablepre</span>';&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$configfile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$configfile</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/[$]cookiepre\s*\=\s*[<span style="color: #000099; font-weight: bold;">\&quot;</span>'].*?[<span style="color: #000099; font-weight: bold;">\&quot;</span>'];/is&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\$</span>cookiepre = '&quot;</span><span style="color: #339933;">.</span>random<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;_';&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$configfile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #339933;">@</span><span style="color: #990000;">file_put_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'./config.inc.php'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$configfile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://yanglu.org/php_discuz_file_get_put/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

