<?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>运达&#039;s  blog &#187; Thinkphp</title>
	<atom:link href="https://www.yunda51.com/?feed=rss2&#038;tag=thinkphp" rel="self" type="application/rss+xml" />
	<link>https://www.yunda51.com</link>
	<description>运达的博客</description>
	<lastBuildDate>Wed, 12 Nov 2025 07:58:26 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0.19</generator>
	<item>
		<title>thinkphp如何导出Excel</title>
		<link>https://www.yunda51.com/?p=1204</link>
		<comments>https://www.yunda51.com/?p=1204#comments</comments>
		<pubDate>Wed, 12 Feb 2014 05:30:03 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[php技术]]></category>
		<category><![CDATA[Thinkphp]]></category>
		<category><![CDATA[Excl]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1204</guid>
		<description><![CDATA[用php导出Excel,这样更能清楚明了!废话不多说了,直接代码! /*导出xls用户个人信息*/ funct<a href="https://www.yunda51.com/?p=1204" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>用php导出Excel,这样更能清楚明了!废话不多说了,直接代码!</p>
<pre class="wp-code-highlight prettyprint">
/*导出xls用户个人信息*/
function export(){   		  
	      header(&quot;Content-type:application/octet-stream&quot;);
              header(&quot;Accept-Ranges:bytes&quot;);
              header(&quot;Content-type:application/vnd.ms-excel&quot;);  
              header(&quot;Content-Disposition:attachment;filename=用户信息表&quot;.date(&quot;Y-m-d&quot;).&quot;.xls&quot;);
              header(&quot;Pragma: no-cache&quot;);
              header(&quot;Expires: 0&quot;);
              //导出xls 开始
	      $tag0 = iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;,&#039;用户ID&#039;);
              $tag1 = iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;,&#039;用户名&#039;);
              $tag2 = iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;,&#039;待领取&#039;);
	      $tag3 = iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;,&#039;奖金总数&#039;);
	      $tag4 = iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;,&#039;开户行&#039;);
	      $tag5 = iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;,&#039;开户城市&#039;);
	      $tag6 = iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;,&#039;开户行地址&#039;);
	      $tag7 = iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;,&#039;银行卡号&#039;);
	      $tag8 = iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;,&#039;持卡人姓名&#039;);
	      echo &quot;$tag0\t$tag1\t$tag2\t$tag3\t$tag4\t$tag5\t$tag6\t$tag7\n&quot;;
	      ////查询的一张表
//$arr=M (&#039;textpage&#039;)-&gt;field(&#039;username,count(id) as allcount,sum(price) as allprice &#039;)-&gt;group(&#039;username&#039;)-&gt;select();
$field=&quot;crowd_textpage.tid,crowd_textpage.username,users.bankName,users.city,users.bankAddress,
users.bankCard,users.bankUsr,count(crowd_textpage.id) as allcount,sum(crowd_textpage.price) as allprice&quot;;
		$arr = M (&#039;textpage&#039;)-&gt;field($field)
				     -&gt;join(&#039;crowd_user as users ON crowd_textpage.username=users.username&#039;)
				     -&gt;group(&#039;crowd_textpage.username&#039;)
				     -&gt;select();			  
			  //dump(M (&#039;textpage&#039;)-&gt;getLastSql());die;	   			  
			  foreach($arr as $key=&gt;$val){
			  //$date        =    date(&#039;Y-m-d&#039;,$val[&#039;pay_time&#039;]);
			  $tid    =    iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;, $val[&#039;tid&#039;]);
			  $tid=$tid?$tid:&#039;-&#039;;
			  $username    =    iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;, $val[&#039;username&#039;]);
			  $username=$username?$username:&#039;-&#039;;
			  $allcount    =    iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;, $val[&#039;allcount&#039;]);
			  $allcount=$allcount?$allcount:&#039;-&#039;;
			  $allprice    =    iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;, $val[&#039;allprice&#039;]);
			  $allprice=$allprice?$allprice:&#039;-&#039;;
			  $bankName    =    iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;, $val[&#039;bankName&#039;]);
			  $bankName=$bankName?$bankName:&#039;-&#039;;
			  $city    =    iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;, $val[&#039;city&#039;]);
			  $city=$city?$city:&#039;-&#039;;
			  $bankAddress    =    iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;, $val[&#039;bankAddress&#039;]);
			  $bankAddress=$bankAddress?$bankAddress:&#039;-&#039;;
			  $bankCard    =    iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;, $val[&#039;bankCard&#039;]);
			  $bankCard=$bankCard?$bankCard:&#039;-&#039;;
			  $bankUsr    =    iconv(&quot;UTF-8&quot;, &quot;GB2312&quot;, $val[&#039;bankUsr&#039;]);
		          $bankUsr=$bankUsr?$bankUsr:&#039;-&#039;;
			  echo &quot;$tid\t$username\t$allcount\t$allprice\t$bankName\t$city
\t$bankAddress\t&#039;$bankCard\t$bankUsr\n&quot;;
		}
} 
</pre>
<p>这样就ok了!<br />
转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a>  原文地址：<a href="http://www.yunda51.com/1204.html">http://www.yunda51.com/1204.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1204</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>curl抓取(thinkphp自动审核)</title>
		<link>https://www.yunda51.com/?p=1190</link>
		<comments>https://www.yunda51.com/?p=1190#comments</comments>
		<pubDate>Tue, 21 Jan 2014 07:23:30 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[php技术]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[gzip编码]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Thinkphp]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1190</guid>
		<description><![CDATA[最近在做Thinkphp项目的时候需要写一个自动审核数据的功能,根据Curl来抓取对比,并且每隔十秒会自动刷新<a href="https://www.yunda51.com/?p=1190" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>最近在做Thinkphp项目的时候需要写一个自动审核数据的功能,根据Curl来抓取对比,并且每隔十秒会自动刷新页面审核!<br />
代码如下:<br />
首先创建:textpageAction.class.php</p>
<pre class="wp-code-highlight prettyprint">
//检测字符串编码的方法,将编码$code转换为utf-8编码!
function safeEncoding($str){
	$code=mb_detect_encoding($str,array(&#039;GB2312&#039;,&#039;GBK&#039;,&#039;UTF-8&#039;,&#039;ASCII&#039;));//检测字符串编码
	if($code==&quot;CP936&quot;){
		$result=$str;
	}else{
		//$result=mb_convert_encoding($str,&#039;UTF-8&#039;,$code);//将编码$code转换为utf-8编码
		$result=iconv($code,&quot;UTF-8&quot;,$str);
	}
		return $result;
}
///这个方法可以用来测试用
function ceshi(){
	include(&#039;simple_html_dom.php&#039;);
	$ch = curl_init();
		$timeout = 10; 
		curl_setopt ($ch, CURLOPT_URL, &quot;http://bj.ohqly.com/1511/2014011548894568v0.html&quot;);
                ////模式器,如果别人网站拦截了,加上这句话就ok了////
                curl_setopt ( $ch, CURLOPT_USERAGENT, &#039;Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1)&#039;);
		curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
		curl_setopt($curl, CURLOPT_BINARYTRANSFER, true) ;
		curl_setopt($curl, CURLOPT_ENCODING, &#039;gzip,deflate&#039;);
		curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
		$html = curl_exec($ch);
		curl_close($ch);
		$html=$this-&gt;safeEncoding($html);
		var_dump($html);
		//dump($html);
		$html=str_get_html($html);
		foreach($html-&gt;find(&#039;h1&#039;) as $e) {
			echo $e-&gt;innertext . &#039;&lt;br&gt;&#039;;
			$val= $e-&gt;innertext;
			//$val=rtrim($val);
			//$val=ltrim($val);
			dump(stripos(&quot;本田思域 2009款 1.8 VTI 自动豪华版&quot;,$val)!==false);
		}
	exit();
}

///自动审核
function tongguo(){
	include(&#039;simple_html_dom.php&#039;);//这个引文可以在下面下载!
   	$time = $_REQUEST[&#039;where&#039;];
 	$time = explode(&quot;,&quot;,$time);
 	$result = M(&#039;textpage&#039;);
 	$where[&#039;_string&#039;] = &quot; time &gt;=&#039;{$time[0]}&#039; and time &lt;=&#039;{$time[1]}&#039;&quot;;
	$where[&#039;status&#039;] = 2;
	
	 $renwu = M(&#039;textpage&#039;);
	$list = $result-&gt;where($where)-&gt;limit(10)-&gt;select();
 	if(!$list){
		$this-&gt;assign(&#039;jump&#039;,&#039;0&#039;);
 	}else{
 		$this-&gt;assign(&#039;jump&#039;,&#039;1&#039;);
	} ///$wangzhan=array(&#039;liebiao.com&#039;,&#039;58.com&#039;,&#039;ohqly.com&#039;,&#039;ganji.com&#039;,&#039;lieju.com&#039;,
&#039;favolist.com&#039;,&#039;go007.com&#039;,&#039;gd8.com&#039;,&#039;fenlei168.com&#039;,&#039;kvov.com&#039;,&#039;ffjzw.com&#039;);
	foreach($list as $v){
		//$html=file_get_contents();
		$ch = curl_init();
		$timeout = 10; 
		curl_setopt ($ch, CURLOPT_URL, $v[&#039;url&#039;]);
		curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
		curl_setopt($curl, CURLOPT_BINARYTRANSFER, true) ;
		curl_setopt($curl, CURLOPT_ENCODING, &#039;gzip,deflate&#039;);
		curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
		$html = curl_exec($ch);
		curl_close($ch);
		if($this-&gt;safeEncoding($html)==false){
			$html=$this-&gt;gzdecode($html);
			$html=$this-&gt;safeEncoding($html);
		}else{
			$html=$this-&gt;safeEncoding($html);
		}
		//dump($html);die;
		if(!$html){
			if($html==&#039;&#039;){
				$data[&#039;reason&#039;]= &quot;超时&quot;;
			}else{
				$data[&#039;reason&#039;]= &quot;文章不存在!&quot;;
			}
			$data[&#039;status&#039;] = 3;
			
			$con[&#039;id&#039;] = $v[&#039;id&#039;];
			$result = $renwu-&gt;where($con)-&gt;save($data);
			if($result){
			     echo $v[&#039;id&#039;] .$v[&#039;textname&#039;] .$v[&#039;url&#039;] .&quot;【文章不存在--未通过】&lt;br /&gt;&quot;;
			}
		}else{
			 if(stripos($v[&#039;url&#039;],&#039;liebiao.com&#039;)!==false){
			//$html=$this-&gt;gzdecode($html);
			}
			$html = str_get_html($html);
 			if(is_object($html)===false){
				$data[&#039;status&#039;] = 3;
				$data[&#039;reason&#039;]= &quot;链接不存在!&quot;;
				 $con[&#039;id&#039;] = $v[&#039;id&#039;];
				$result = $renwu-&gt;where($con)-&gt;save($data);
				if($result){
				   echo $v[&#039;id&#039;] .$v[&#039;textname&#039;] .$v[&#039;url&#039;] .&quot;【链接不存在--未通过】&lt;br /&gt;&quot;;
				}
			}else{
				$tf=false;
				if(stripos($v[&#039;url&#039;],&#039;lieju.com&#039;)!==false){
					$tit=$html-&gt;find(&#039;span&#039;);
					foreach($tit as $e) {
						$val= $e-&gt;innertext;
						if(stripos($val,$v[&#039;textname&#039;])!==false){
							$tf=true;
							break;
						}
					}

				}else if(stripos($v[&#039;url&#039;],&#039;baixing.com&#039;)!==false){
					foreach($html-&gt;find(&#039;h2&#039;) as $e) {
						$val=str_replace(&#039;&amp;nbsp&#039;,&#039;&#039;,strip_tags($e-&gt;innertext));
						//$val=trim(strip_tags($e-&gt;innertext));
						//$dump($val);die;
						if(stripos($val,$v[&#039;textname&#039;])!==false){
							$tf=true;
							break;
						}
					}
				}else{
					foreach($html-&gt;find(&#039;h1&#039;) as $e) {
						//$val=str_replace(&#039; &#039;,&#039;&#039;,strip_tags($e-&gt;innertext));
					        //$val= $e-&gt;innertext;
						$val=trim(strip_tags($e-&gt;innertext));/////去空格以及去掉html标签
						//$dump($val);die;
						if(stripos($val,$v[&#039;textname&#039;])!==false){
							$tf=true;
							break;
						}
					}
				}
				if($tf){
					$data[&#039;status&#039;] = 4;
					$data[&#039;reason&#039;]= &quot;&quot;;
					$con[&#039;id&#039;] = $v[&#039;id&#039;];
					$result = $renwu-&gt;where($con)-&gt;save($data);
					if($result){
						echo $v[&#039;id&#039;] .$v[&#039;textname&#039;] .$v[&#039;url&#039;] .&quot;【通过】&lt;br /&gt;&quot;;
					}
				}else{
					
					$data[&#039;status&#039;] = 3;
					$data[&#039;reason&#039;]= &quot;标题错误!&quot;;
					$con[&#039;id&#039;] = $v[&#039;id&#039;];
					$result = $renwu-&gt;where($con)-&gt;save($data);
					if($result){
						echo $v[&#039;id&#039;] .$v[&#039;textname&#039;] .$v[&#039;url&#039;] .&quot;【标题错误--未通过】&lt;br /&gt;&quot;;
					}
				}
			}
		}
}
	$this-&gt;display(&#039;tongguo&#039;);

}
//gzip压缩编码的解决方法
 function gzdecode($data) {
             $len = strlen($data);
             if ($len &lt; 18 || strcmp(substr($data,0,2),&quot;\x1f\x8b&quot;)) {
             return null;  // Not GZIP format (See RFC 1952)
           }
            $method = ord(substr($data,2,1));  // Compression method
            $flags  = ord(substr($data,3,1));  // Flags
            if ($flags &amp; 31 != $flags) {
            // Reserved bits are set -- NOT ALLOWED by RFC 1952
             return null;
          }
            // NOTE: $mtime may be negative (PHP integer limitations)
            $mtime = unpack(&quot;V&quot;, substr($data,4,4));
            $mtime = $mtime[1];
            $xfl   = substr($data,8,1);
            $os    = substr($data,8,1);
            $headerlen = 10;
            $extralen  = 0;
            $extra     = &quot;&quot;;
            if ($flags &amp; 4) {
           // 2-byte length prefixed EXTRA data in header
           if ($len - $headerlen - 2 &lt; 8) {
           return false;    // Invalid format
          }
           $extralen = unpack(&quot;v&quot;,substr($data,8,2));
           $extralen = $extralen[1];
           if ($len - $headerlen - 2 - $extralen &lt; 8) {
           return false;    // Invalid format
          }
           $extra = substr($data,10,$extralen);
           $headerlen += 2 + $extralen;
  }

          $filenamelen = 0;
          $filename = &quot;&quot;;
          if ($flags &amp; 8) {
          // C-style string file NAME data in header
          if ($len - $headerlen - 1 &lt; 8) {
          return false;    // Invalid format
        }
           $filenamelen = strpos(substr($data,8+$extralen),chr(0));
           if ($filenamelen === false || $len - $headerlen - $filenamelen - 1 &lt; 8) {
           return false;    // Invalid format
    }
           $filename = substr($data,$headerlen,$filenamelen);
           $headerlen += $filenamelen + 1;
  }

           $commentlen = 0;
           $comment = &quot;&quot;;
          if ($flags &amp; 16) {
          // C-style string COMMENT data in header
          if ($len - $headerlen - 1 &lt; 8) {
           return false;    // Invalid format
     }
           $commentlen = strpos(substr($data,8+$extralen+$filenamelen),chr(0));
           if ($commentlen === false || $len - $headerlen - $commentlen - 1 &lt; 8) {
           return false;    // Invalid header format
    }
          $comment = substr($data,$headerlen,$commentlen);
          $headerlen += $commentlen + 1;
  }

          $headercrc = &quot;&quot;;
          if ($flags &amp; 1) {
          // 2-bytes (lowest order) of CRC32 on header present
          if ($len - $headerlen - 2 &lt; 8) {
          return false;    // Invalid format
    }
          $calccrc = crc32(substr($data,0,$headerlen)) &amp; 0xffff;
          $headercrc = unpack(&quot;v&quot;, substr($data,$headerlen,2));
          $headercrc = $headercrc[1];
          if ($headercrc != $calccrc) {
          return false;    // Bad header CRC
    }
         $headerlen += 2;
  }

        // GZIP FOOTER - These be negative due to PHP&#039;s limitations
        $datacrc = unpack(&quot;V&quot;,substr($data,-8,4));
        $datacrc = $datacrc[1];
        $isize = unpack(&quot;V&quot;,substr($data,-4));
        $isize = $isize[1];

       // Perform the decompression:
       $bodylen = $len-$headerlen-8;
       if ($bodylen &lt; 1) {
      // This should never happen - IMPLEMENTATION BUG!
      return null;
   }
      $body = substr($data,$headerlen,$bodylen);
      $data = &quot;&quot;;
      if ($bodylen &gt; 0) {
      switch ($method) {
      case 8:
        // Currently the only supported compression method:
        $data = gzinflate($body);
        break;
      default:
        // Unknown compression method
        return false;
    }
  } else {
        // I&#039;m not sure if zero-byte body content is allowed.
        // Allow it for now...  Do nothing...
  }

       // Verifiy decompressed size and CRC32:
      // NOTE: This may fail with large data sizes depending on how
     //  PHP&#039;s integer limitations affect strlen() since $isize
    //  may be negative for large sizes.
        if ($isize != strlen($data) || crc32($data) != $datacrc) {
       // Bad format!  Length or CRC doesn&#039;t match!
        return false;
  }
        return $data;
	}
}//end
?&gt;
</pre>
<p>然后创建模板shenhe.html</p>
<pre class="wp-code-highlight prettyprint">
&lt;html&gt;
          &lt;if condition=&quot; $on neq NULL &quot; &gt;&lt;a href=&quot;{:U(&#039;/Textpage/tongguo&#039;,
           array(&#039;where&#039;=&gt;$time))}&quot;&gt;&lt;h4&gt;自动审核&lt;/h4&gt;&lt;/a&gt;&lt;/if&gt;
&lt;/html&gt;
</pre>
<p>最后创建模板tongguo.html</p>
<pre class="wp-code-highlight prettyprint">
&lt;html&gt;
         &lt;script type=&quot;text/javascript&quot;&gt;
         var jump=&quot;{$jump}&quot;;
         window.onload = function(){
	 if(jump==&#039;1&#039;){
		setTimeout(function(){
		location.reload();
                },60000);//60秒自动刷新页面
	}else{
		
		alert(&#039;审核完毕&#039;);
		//location.href=&quot;{U:(Textpage/submit)}&quot;;
	}
	
};
        &lt;/script&gt;
&lt;/html&gt;
</pre>
<p><a href="http://pan.baidu.com/s/1c0EHipU" target="&quot;_blank"><img class="alignnone size-full wp-image-1075" title="btn_load" src="http://www.yunda51.com/wp-content/uploads/2013/11/btn_load3.png" alt="" width="86" height="28" /></a><br />
转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a> 原文地址：<a href="http://www.yunda51.com/1190.html">http://www.yunda51.com/1190.html</a>   </p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1190</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>如何解决gzip编码html的问题</title>
		<link>https://www.yunda51.com/?p=1182</link>
		<comments>https://www.yunda51.com/?p=1182#comments</comments>
		<pubDate>Fri, 17 Jan 2014 09:33:06 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[php技术]]></category>
		<category><![CDATA[gzip编码]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Thinkphp]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1182</guid>
		<description><![CDATA[最近搞网站html的抓取问题,结果出现乱编,既不是GBK,GB2312也不是utf-8的问题,后来经过检查原来<a href="https://www.yunda51.com/?p=1182" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>最近搞网站html的抓取问题,结果出现乱编,既不是GBK,GB2312也不是utf-8的问题,后来经过检查原来是gzip编码的问题,那么如何来解决gzip编码html的问题?<br />
代码如下: </p>
<pre class="wp-code-highlight prettyprint">
function gzdecode($data) {
  $len = strlen($data);
  if ($len &lt; 18 || strcmp(substr($data,0,2),&quot;\x1f\x8b&quot;)) {
    return null;  // Not GZIP format (See RFC 1952)
  }
  $method = ord(substr($data,2,1));  // Compression method
  $flags  = ord(substr($data,3,1));  // Flags
  if ($flags &amp; 31 != $flags) {
    // Reserved bits are set -- NOT ALLOWED by RFC 1952
    return null;
  }
  // NOTE: $mtime may be negative (PHP integer limitations)
  $mtime = unpack(&quot;V&quot;, substr($data,4,4));
  $mtime = $mtime[1];
  $xfl   = substr($data,8,1);
  $os    = substr($data,8,1);
  $headerlen = 10;
  $extralen  = 0;
  $extra     = &quot;&quot;;
  if ($flags &amp; 4) {
    // 2-byte length prefixed EXTRA data in header
    if ($len - $headerlen - 2 &lt; 8) {
      return false;    // Invalid format
    }
    $extralen = unpack(&quot;v&quot;,substr($data,8,2));
    $extralen = $extralen[1];
    if ($len - $headerlen - 2 - $extralen &lt; 8) {
      return false;    // Invalid format
    }
    $extra = substr($data,10,$extralen);
    $headerlen += 2 + $extralen;
  }

  $filenamelen = 0;
  $filename = &quot;&quot;;
  if ($flags &amp; 8) {
    // C-style string file NAME data in header
    if ($len - $headerlen - 1 &lt; 8) {
      return false;    // Invalid format
    }
    $filenamelen = strpos(substr($data,8+$extralen),chr(0));
    if ($filenamelen === false || $len - $headerlen - $filenamelen - 1 &lt; 8) {
      return false;    // Invalid format
    }
    $filename = substr($data,$headerlen,$filenamelen);
    $headerlen += $filenamelen + 1;
  }

  $commentlen = 0;
  $comment = &quot;&quot;;
  if ($flags &amp; 16) {
    // C-style string COMMENT data in header
    if ($len - $headerlen - 1 &lt; 8) {
      return false;    // Invalid format
    }
    $commentlen = strpos(substr($data,8+$extralen+$filenamelen),chr(0));
    if ($commentlen === false || $len - $headerlen - $commentlen - 1 &lt; 8) {
      return false;    // Invalid header format
    }
    $comment = substr($data,$headerlen,$commentlen);
    $headerlen += $commentlen + 1;
  }

  $headercrc = &quot;&quot;;
  if ($flags &amp; 1) {
    // 2-bytes (lowest order) of CRC32 on header present
    if ($len - $headerlen - 2 &lt; 8) {
      return false;    // Invalid format
    }
    $calccrc = crc32(substr($data,0,$headerlen)) &amp; 0xffff;
    $headercrc = unpack(&quot;v&quot;, substr($data,$headerlen,2));
    $headercrc = $headercrc[1];
    if ($headercrc != $calccrc) {
      return false;    // Bad header CRC
    }
    $headerlen += 2;
  }

  // GZIP FOOTER - These be negative due to PHP&#039;s limitations
  $datacrc = unpack(&quot;V&quot;,substr($data,-8,4));
  $datacrc = $datacrc[1];
  $isize = unpack(&quot;V&quot;,substr($data,-4));
  $isize = $isize[1];

  // Perform the decompression:
  $bodylen = $len-$headerlen-8;
  if ($bodylen &lt; 1) {
    // This should never happen - IMPLEMENTATION BUG!
    return null;
  }
  $body = substr($data,$headerlen,$bodylen);
  $data = &quot;&quot;;
  if ($bodylen &gt; 0) {
    switch ($method) {
      case 8:
        // Currently the only supported compression method:
        $data = gzinflate($body);
        break;
      default:
        // Unknown compression method
        return false;
    }
  } else {
    // I&#039;m not sure if zero-byte body content is allowed.
    // Allow it for now...  Do nothing...
  }

  // Verifiy decompressed size and CRC32:
  // NOTE: This may fail with large data sizes depending on how
  //       PHP&#039;s integer limitations affect strlen() since $isize
  //       may be negative for large sizes.
  if ($isize != strlen($data) || crc32($data) != $datacrc) {
    // Bad format!  Length or CRC doesn&#039;t match!
    return false;
  }
  return $data;
	}
</pre>
<p>转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a>  原文地址：<a href="http://www.yunda51.com/1182.html">http://www.yunda51.com/1182.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1182</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>thinkphp地区管理功能</title>
		<link>https://www.yunda51.com/?p=1136</link>
		<comments>https://www.yunda51.com/?p=1136#comments</comments>
		<pubDate>Mon, 06 Jan 2014 03:49:03 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[php技术]]></category>
		<category><![CDATA[Thinkphp]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1136</guid>
		<description><![CDATA[thinkphp地区管理功能的实现，实现效果图： 数据库结构： CREATE TABLE `sp_region<a href="https://www.yunda51.com/?p=1136" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>thinkphp地区管理功能的实现，实现效果图：<a href="http://www.yunda51.com/wp-content/uploads/2014/01/52c5030733619.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2014/01/52c5030733619.jpg" alt="" title="52c5030733619" width="1181" height="312" class="alignnone size-full wp-image-1137" /></a><br />
<strong>数据库结构：</strong></p>
<pre class="wp-code-highlight prettyprint">
    CREATE TABLE `sp_region` (
      `Id` INT(11) NOT NULL AUTO_INCREMENT,
      `parent_id` INT(11) DEFAULT NULL,
      `region_name` VARCHAR(120) CHARACTER SET gbk DEFAULT NULL,
      `region_type` SMALLINT(5) DEFAULT NULL,
      `agency_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT &#039;0&#039;,
      `is_show` SMALLINT(5) NOT NULL DEFAULT &#039;0&#039;,
      PRIMARY KEY (`Id`)
    ) ENGINE=MYISAM AUTO_INCREMENT=3417 DEFAULT CHARSET=utf8 COLLATE=utf8_bin
</pre>
<p><strong>前台代码：</strong></p>
<pre class="wp-code-highlight prettyprint">
     &lt;form name=&quot;form1&quot; method=&quot;post&quot; id=&quot;myfrom&quot; action=&quot;__URL__/add&quot;&gt;
        &lt;table class=&quot;table_form&quot; style=&quot;border:0;&quot;&gt;
            &lt;tr&gt;
                &lt;th align=&quot;left&quot;&gt;
                {if $region_type=3}{$regionts}：
                    &lt;input type=&quot;text&quot; class=&quot;text-input&quot; name=&quot;region_name&quot; &gt;
                    &lt;input type=&quot;hidden&quot; name=&quot;region_type&quot; value=&quot;{$region_type}&quot; /&gt;
                    &lt;input type=&quot;hidden&quot; name=&quot;parent_id&quot; value=&quot;{$Id}&quot; /&gt;
                    &lt;input type=&quot;submit&quot; class=&quot;buttonAdd&quot; value=&quot;提交操作&quot;/&gt;
                {/if}
                    &lt;a href=&quot;{:U(&#039;Association/region&#039;,array(&quot;regiontype&quot;=&gt;$region_typeyuanshi,&#039;parentid&#039;=&gt;$fuID))}&quot;&gt;返回上一级&lt;/a&gt;
                &lt;/th&gt;
            &lt;/tr&gt;
        &lt;/table&gt;
    &lt;/form&gt;
    &lt;div class=&quot;fl&quot; style=&quot;border:1px solid #66CCFF;&quot;&gt;
        &lt;table width=&quot;100%&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; &gt;
            &lt;tr&gt;&lt;td height=&quot;15&quot; style=&quot;background:#66CCFF; margin-top:0px; &quot;&gt;{$region_type}&lt;/td&gt;&lt;/tr&gt;
            &lt;tr bgcolor=&quot;#FFFFFF&quot;&gt;
                &lt;td&gt;
                    &lt;present name=&quot;list&quot;&gt;
                    &lt;volist name=&quot;list&quot; id=&quot;vo&quot;&gt;
                        &lt;div class=&#039;regionys&#039;&gt;&lt;span id=&quot;regionname{$vo[&#039;Id&#039;]}&quot;&gt;{$vo[&#039;region_name&#039;]}&lt;/span&gt;&lt;span&gt;|&lt;/span&gt;
                        {if $region_type=3}
                            &lt;a href=&quot;{:U(&#039;Association/region&#039;,array(&quot;regiontype&quot;=&gt;$region_type,&#039;parentid&#039;=&gt;$vo[&#039;Id&#039;]))}&quot;&gt;管理&lt;/a&gt;
                        {/if}
                        &lt;a href=&quot;{:U(&#039;Association/delRegion&#039;,array(&quot;regionid&quot;=&gt;$vo[&#039;Id&#039;],&#039;parentid&#039;=&gt;$vo[&#039;Id&#039;]))}&quot; &gt;删除&lt;/a&gt;&lt;/div&gt;
                    &lt;/volist&gt;
                    &lt;else /&gt;
                        &lt;div class=&#039;regionys&#039;&gt;暂无地区&lt;/div&gt;
                    &lt;/present&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;&lt;td height=&quot;5&quot; style=&quot;background:#fff; margin-top:0px; &quot;&gt;&lt;/td&gt;&lt;/tr&gt;
        &lt;/table&gt;
    &lt;/div&gt;
    &lt;p class=&quot;i&quot;&gt;
        &lt;font color=&quot;red&quot;&gt;注视：&lt;/font&gt;1级地区：国家 2级地区：省份 3级地区：市级 4级地区：县/区
    &lt;/p&gt;
</pre>
<pre class="wp-code-highlight prettyprint">
  public function region(){
        $parent_id = intval(trim($_GET[&#039;parentid&#039;]));//父ID
        $region = D(&quot;region&quot;);
        $regionarr = $region-&gt;where(&quot; parent_id=&quot;.$parent_id)-&gt;select();
        if( $_GET[&#039;regiontype&#039;]==&quot;&quot;  ){
            $region_type = &#039;0&#039;;
            $regionts = &quot;新增1级地区&quot;;
        }else{
            if($regionarr[0][&#039;Id&#039;] == &quot;&quot;){
                //取出上一级的region_type
                $regiontypearr = $region-&gt;where(&#039;id=&#039;.$parent_id)-&gt;field(&#039;region_type&#039;)-&gt;find();
                $region_type = $regiontypearr[&#039;region_type&#039;]+1;
            }else{
                $region_type = $regionarr[0][&#039;region_type&#039;];
            }
            $regionts = $region_type+1;
            $regionts = &quot;新增&quot;.$regionts.&quot;级地区&quot;;
        }
        $this-&gt;assign(&quot;region_type&quot;,$region_type);//属于省份还是市
        $region_typeyuanshi=$region_type-1;
        $this-&gt;assign(&quot;region_typeyuanshi&quot;,$region_typeyuanshi);
        $this-&gt;assign(&quot;regionts&quot;,$regionts);//文字提示
        if(  $regionarr[0][&#039;parent_id&#039;] != 0){
            $fuidarr = $region-&gt;where(&quot;id=&quot;.$regionarr[0][&#039;parent_id&#039;])-&gt;find();//用fuID去取fuID的parent_id;
            $this-&gt;assign(&quot;fuID&quot;,  $fuidarr[&#039;parent_id&#039;]  );//返回上一级的时候，取的fuID
        }
        if( $region_type == 0 ){
            $this-&gt;assign(&#039;Id&#039;,  &#039;0&#039; );
        }else{
            $this-&gt;assign(&#039;Id&#039;, $parent_id );
        }
        $this-&gt;assign(&#039;list&#039;,$regionarr);
        $this-&gt;display();
    }
    function delRegion(){
        $region = D(&quot;Region&quot;);
        //删除
        if( $_GET[&#039;regionid&#039;] != &quot;&quot; ){
            //先判断是否有子分类
            $regionid= intval( $_GET[&#039;regionid&#039;] );
            $ziarr = $region-&gt;where(&quot;parent_id=&quot;.$regionid)-&gt;select();
            if( $ziarr[0][&#039;Id&#039;] != &quot;&quot; ){
                $this-&gt;error(&quot;请先删除子分类！&quot;);
            }else{
                $region-&gt;Id=$regionid;
                if($region-&gt;delete()){
                    $this-&gt;success();
                }else{
                    $this-&gt;error(&quot;删除失败&quot;);
                }
            }
        }
    }
    public function add(){
        $Region = D(&#039;Region&#039;);
        $region_name=trim($_POST[&#039;region_name&#039;]);
        if(!$region_name) $this-&gt;error(&quot;新增地区不能为空！&quot;);
        $Region-&gt;region_name = $region_name;
        $Region-&gt;region_type = trim($_POST[&#039;region_type&#039;]);
        $Region-&gt;parent_id   = trim($_POST[&#039;parent_id&#039;]);
        if($Region-&gt;add()){
            $this-&gt;success(&#039;添加成功！&#039;);
        }else{
            $this-&gt;error($Region-&gt;getError());
        }
    }
</pre>
<p>转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a>  原文地址：<a href="http://www.yunda51.com/1136.html">http://www.yunda51.com/1136.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1136</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>解决Thinkphp内存不足的方法</title>
		<link>https://www.yunda51.com/?p=849</link>
		<comments>https://www.yunda51.com/?p=849#comments</comments>
		<pubDate>Tue, 12 Mar 2013 02:47:22 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[php技术]]></category>
		<category><![CDATA[Thinkphp]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=849</guid>
		<description><![CDATA[解决Thinkphp允许内存大小8388608字节用尽怎么解决呢，其实很简单，只要在.htaccess中添加如<a href="https://www.yunda51.com/?p=849" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>解决Thinkphp允许内存大小8388608字节用尽怎么解决呢，其实很简单，只要在.htaccess中添加如下代码就可以了：</p>
<div class="buy shortcodestyle">
php_value max_execution_time 1200<br />
php_value memory_limit 200M<br />
php_value post_max_size 200M<br />
php_value upload_max_filesize 200M
</div>
<p>这样就ok了！<br />
&nbsp;<br />
转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a>  原文地址：<a href="http://www.yunda51.com/849.html">http://www.yunda51.com/849.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=849</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>thinkphp3.0入口文件的写法</title>
		<link>https://www.yunda51.com/?p=839</link>
		<comments>https://www.yunda51.com/?p=839#comments</comments>
		<pubDate>Fri, 08 Mar 2013 10:07:42 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Thinkphp]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=839</guid>
		<description><![CDATA[thinkphp3.0入口文件的写法跟thinkphp2.0的写法有所不同。今天用thinkphp3.0版本的<a href="https://www.yunda51.com/?p=839" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>thinkphp3.0入口文件的写法跟thinkphp2.0的写法有所不同。今天用thinkphp3.0版本的时候就出现了问题。以前thinkphp2.0的入口文件如下：</p>
<div class="buy shortcodestyle">&lt;?php<br />
//定义 ThinkPHP 框架路径<br />
define( 'THINK_PATH' , './ThinkPHP/' );<br />
//定义项目名称和路径<br />
define( 'APP_NAME' , 'home' );<br />
define( 'APP_PATH' , './home' );<br />
//加载框架入口文件<br />
require(THINK_PATH."/ThinkPHP.php");<br />
?&gt;</div>
<p>现在thinkphp3.0入口文件如下：</p>
<div class="buy shortcodestyle">&lt;?php<br />
//定义 ThinkPHP 框架路径<br />
require(THINK_PATH."/ThinkPHP.php");<br />
?&gt;</div>
<p>转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a>  原文地址：<a href="http://www.yunda51.com/839.html">http://www.yunda51.com/839.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=839</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Thinkphp里关于U函数生成URL伪静态</title>
		<link>https://www.yunda51.com/?p=688</link>
		<comments>https://www.yunda51.com/?p=688#comments</comments>
		<pubDate>Fri, 04 Jan 2013 09:52:16 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Thinkphp]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=688</guid>
		<description><![CDATA[在 Thinkphp支持伪静态URL设置，可以通过设置URL_HTML_SUFFIX参数随意在URL的最后增加<a href="https://www.yunda51.com/?p=688" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>在 Thinkphp支持伪静态URL设置，可以通过设置URL_HTML_SUFFIX参数随意在URL的最后增加你想要的静态后缀，而不会影响当前操作的正常执行。例如，我们设置</p>
<ul type="1">
<li>'URL_HTML_SUFFIX'=&gt;'shtml'的话，我们可以把下面的URL</li>
<li>http://serverName/Tp/revise/id/1 变成 http://serverName/Tp/revise/id/1.shtml</li>
</ul>
<p>后者更具有静态页面的URL特征，但是具有和前面的URL相同的执行效果，并且不会影响原来参数的使用。 注意：伪静态后缀设置时可以不包含后缀中的“.”。所以，下面的配置其实是等效的：</p>
<ul type="1">
<li>'URL_HTML_SUFFIX'=&gt;'.shtml'伪静态设置后，如果需要动态生成一致的URL，可以使用U方法在模板文件里面生成URL。</li>
</ul>
<p><strong>关于多伪静态后缀的支持同时有效，可以使用下面的方式进行配置：</strong></p>
<p>'URL_HTML_SUFFIX'=&gt;'(shtml|html|xml)'</p>
<p>这样网站就能够支持多个伪静态后缀设置：</p>
<ul type="1">
<li>http://serverName/Tp/revise/1.shtml</li>
<li>http://serverName/Tp/revise/1.html</li>
<li>http://serverName/Tp/revise/1.xml</li>
</ul>
<p>配置多个伪静态后缀并不会导致自动判断后缀执行不同的方法。     例 如：&lt;a href=“{:U("News/revise/id/$vo[id]")}”&gt;标题&lt;/a&gt;</p>
<p>生成</p>
<p>&lt;a href="Tp/News/revise/id/1.html"&gt;标题&lt;/a&gt;，这样就完事了，但是大家一定要看清单引号和双引号，否则会让人很惆怅！</p>
<p>转载请注明转自:<a href="http://www.yunda51.com/">运达's blog</a>（原文地址：<a href="http://www.yunda51.com/?p=688">http://www.yunda51.com/?p=688</a>）</p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=688</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Thinkphp里URL重写</title>
		<link>https://www.yunda51.com/?p=551</link>
		<comments>https://www.yunda51.com/?p=551#comments</comments>
		<pubDate>Mon, 24 Dec 2012 02:18:34 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Thinkphp]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=551</guid>
		<description><![CDATA[话说伪静态是网站最常用的，通常的URL里面含有index.php,为了达到更好的SEO效果可能需要去掉URL里<a href="https://www.yunda51.com/?p=551" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>话说伪静态是网站最常用的，通常的URL里面含有index.php,为了达到更好的SEO效果可能需要去掉URL里面的index.php ,通过URL重写的方式可以达到这种效果，通常需要服务器开启URL_REWRITE模块才能支持。</p>
<p>下面是Apache的配置过程，可以参考下：</p>
<p>1、httpd.conf配置文件中加载了mod_rewrite.so模块</p>
<p>2、AllowOverride None 将None改为 All</p>
<p>3、确保'URL_MODEL' =&gt;  2, // 如果你的环境不支持PATHINFO 请设置为3</p>
<p>4、创建.htaccess文件，并且把.htaccess文件放到入口文件的同级目录下</p>
<p>&lt;IfModule mod_rewrite.c&gt;</p>
<p>RewriteEngine on</p>
<p>RewriteCond %{REQUEST_FILENAME} !-d</p>
<p>RewriteCond %{REQUEST_FILENAME} !-f</p>
<p>RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]</p>
<p>&lt;/IfModule&gt;</p>
<p>这样就Ok了！</p>
<p>转载请注明转自:<a href="http://www.yunda51.com/">运达's blog</a>（原文地址：<a href="http://www.yunda51.com/?p=551">http://www.yunda51.com/?p=551</a>）</p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=551</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>thinkphp访问安全问题</title>
		<link>https://www.yunda51.com/?p=452</link>
		<comments>https://www.yunda51.com/?p=452#comments</comments>
		<pubDate>Sun, 09 Dec 2012 14:51:42 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Thinkphp]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=452</guid>
		<description><![CDATA[用了一段时间ThinkPHP框架后，感觉这是一个挺不错的PHP框架，用着舒服，但了解深入一点之后，感觉在安全性<a href="https://www.yunda51.com/?p=452" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>用了一段时间ThinkPHP框架后，感觉这是一个挺不错的PHP框架，用着舒服，但了解深入一点之后，感觉在安全性</p>
<p>方面还有一点事情要做做。对于ThinkPHP框架，他有固定的文件目录和一些固定的文件名称，所以，对于一个应用，</p>
<p>有很多文件名称和目录是可以猜测出来的，这样我们就可以通过该文件的URL直接访问，绕过了ThinkPHP框架的访</p>
<p>问模式，特别是在Tpl目录和Lib目录，这两个地方都是关键地方，如何才能阻止直接对这几个目录进行访问呢？我用</p>
<p>到的方法是Apache服务器的Rewrite。</p>
<p>首先，在http.conf配置文件中启用和配置好Rewrite模块。在该文件中增加如下配置信息：</p>
<p>（1）LoadModule rewrite_module Modules/mod_rewrite.so</p>
<p>（2）注意&lt;Directory /&gt;配置字段中的AllowOverride和Options，我配置的如下：<br />
&lt;Directory /&gt;<br />
AllowOverride FileInfo<br />
Options FollowSymLinks<br />
Order allow,deny<br />
Allow from all<br />
&lt;/Directory&gt;</p>
<p>然后，在Lib目录新建一个.htaccess的文件，内容如下：<br />
RewriteEngine on<br />
RewriteRule ^(.*)$ /index.php<br />
将对该目录的所有访问转到项目的启动文件上，从而屏蔽掉对该目录的访问。</p>
<p>对于Tpl目录设置有点不同，因为该目录还存放其他文件，比如图片文件(*.jpg)等，而我们要阻止的仅仅是</p>
<p>html文件的访问，所有在default目录下新建的.htaccess文件中的内容如下：<br />
RewriteEngine on<br />
RewriteRule ^(.*\.html)$ \index.php [NC]<br />
将对该目录下所有html文件的访问转到项目的启动文件上，对于其他文件不变。</p>
<p>上面只是我的一些测试方法，对于这两个目录的安全性是不是真有问题，也还得进一步验证，权且当作是对</p>
<p>Rewrite的一次练习吧。</p>
<p>转载请注明转自:<a href="http://www.yunda51.com/">运达's blog</a>（原文地址：<a title="原文链接" href="http://www.yunda51.com/?p=452">http://www.yunda51.com/?p=452</a>）</p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=452</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Thinkphp登陆判断</title>
		<link>https://www.yunda51.com/?p=448</link>
		<comments>https://www.yunda51.com/?p=448#comments</comments>
		<pubDate>Sun, 09 Dec 2012 14:46:23 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Thinkphp]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=448</guid>
		<description><![CDATA[我觉的有一部分人对thinkphp的model理解不大对，tinkphp的model和你说的ci的model是<a href="https://www.yunda51.com/?p=448" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>我觉的有一部分人对thinkphp的model理解不大对，tinkphp的model和你说的ci的model是不一样的<br />
tinkphp里的model是用来封装数据库模型的，而你要实现的是控制用户请求，这已经属于控制器的范畴了，所以</p>
<p>不能这样$a = M('isonline');而应该是写一个全局的action，比如globalAction，让它继承tp的action，然后在</p>
<p>globalAction的_initialize()方法中session判断，然后所有的需要权限判断的Action都继承globalAction，而</p>
<p>不是系统的action，这样每次实例化action的时候都会先检查用户session我对thinkphp理解的也不是很透彻，</p>
<p>但tp源码就是这么写的，系统Action的构造函数：</p>
<p>public function __construct()<br />
{<br />
//实例化视图类<br />
$this-&gt;view = Think::instance('View');<br />
//控制器初始化<br />
if(method_exists($this,'_initialize'))<br />
$this-&gt;_initialize();<br />
}<br />
它会检查是否有_initialize方法。。。，有的话就调用initialize</p>
<p>转载请注明转自:<a href="http://www.yunda51.com/">运达's blog</a>（原文地址：<a href="http://www.yunda51.com/?p=448">http://www.yunda51.com/?p=448</a>）</p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=448</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
