<?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://clyang.net/blog/category/tech/php/feed" rel="self" type="application/rss+xml" />
	<link>http://clyang.net/blog</link>
	<description>Clyang's Murmuring</description>
	<lastBuildDate>Tue, 27 Mar 2012 20:57:41 +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>各大WordPress Plugin常用的縮圖套件出現0day</title>
		<link>http://clyang.net/blog/2011/08/03/437</link>
		<comments>http://clyang.net/blog/2011/08/03/437#comments</comments>
		<pubDate>Wed, 03 Aug 2011 12:08:04 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[timthumb 0day]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=437</guid>
		<description><![CDATA[很多套件常使用的TimThumb縮圖套件被發現0day, 可以讓惡意攻擊者植入可執行的PHP code, 影響重大, 請儘速更新到最新的版本. 以下提供快速判斷你的WordPress是否有使用到這個套件的方法: ssh進去你的伺服器 變更目錄到你的WordPress根目錄 (例如: /var/www/wp ) 使用下列指令: find . -name "*.php" -exec grep -H &#8216;TimThumb script created by Ben&#8217; {} \; 將所有找到的php檔案都更換成最新的版本即可. 再次呼籲, 有用WordPress的朋友們記得檢查一下~!]]></description>
			<content:encoded><![CDATA[<p>很多套件常使用的TimThumb縮圖套件<a href="http://markmaunder.com/2011/zero-day-vulnerability-in-many-wordpress-themes/">被發現0day</a>, 可以讓惡意攻擊者植入可執行的PHP code, 影響重大, 請儘速更新到最新的版本. 以下提供快速判斷你的WordPress是否有使用到這個套件的方法:</p>
<ol>
<li>ssh進去你的伺服器</li>
<li>變更目錄到你的WordPress根目錄 (例如: /var/www/wp )</li>
<li>使用下列指令: find . -name "*.php" -exec grep -H &#8216;TimThumb script created by Ben&#8217; {} \;</li>
<li>將所有找到的php檔案都<a href="http://timthumb.googlecode.com/svn/trunk/timthumb.php">更換成最新的版本</a>即可.</li>
</ol>
<p>再次呼籲, 有用WordPress的朋友們記得檢查一下~!</p>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2011/08/03/437/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用大陸網站提供的WordPress套件請注意</title>
		<link>http://clyang.net/blog/2011/06/17/426</link>
		<comments>http://clyang.net/blog/2011/06/17/426#comments</comments>
		<pubDate>Fri, 17 Jun 2011 15:55:35 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=426</guid>
		<description><![CDATA[這篇的宗旨不是在挑論套件的安全性, 這邊要提的是效率的問題, 這幾天在幫忙協助tune某個網站的效能, 本來都tune的差不多了, 卻發現在enable某個大陸分析文章關聯性的plugin後, 整個網站的loading驟增, 後來去trace code後, 發現套件本身其實撰寫上沒有任何問題, 效能的瓶頸在網路連線的速度. 該plugin在每個頁面被開啓的時候, 會嘗試連回大陸的伺服器去取得相關資訊, 由於網站host在美國,  對大陸的latency本來就比較高, 加上如果該廠商的網路品質似乎不太穩定, 就陷入了可怕的循環: user開啓網頁 -&#62; plugin連回大陸 -&#62; 下一個的request又來, 因為前個request還沒解決, 只好fork新的process來處理 -&#62; 重複回第一步 解決方法就是關掉該plugin, 網站的loading也就回覆正常了, 因此有了這篇文章, 紀錄一下這個經驗]]></description>
			<content:encoded><![CDATA[<p>這篇的宗旨不是在挑論套件的安全性, 這邊要提的是效率的問題, 這幾天在幫忙協助tune某個網站的效能, 本來都tune的差不多了, 卻發現在enable某個大陸分析文章關聯性的plugin後, 整個網站的loading驟增, 後來去trace code後, 發現套件本身其實撰寫上沒有任何問題, 效能的瓶頸在網路連線的速度. 該plugin在每個頁面被開啓的時候, 會嘗試連回大陸的伺服器去取得相關資訊, 由於網站host在美國,  對大陸的latency本來就比較高, 加上如果該廠商的網路品質似乎不太穩定, 就陷入了可怕的循環:</p>
<p>user開啓網頁 -&gt; plugin連回大陸 -&gt; 下一個的request又來, 因為前個request還沒解決, 只好fork新的process來處理 -&gt; 重複回第一步</p>
<p>解決方法就是關掉該plugin, 網站的loading也就回覆正常了, 因此有了這篇文章, 紀錄一下這個經驗 <img src='http://clyang.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2011/06/17/426/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>使用PHP將JPG轉換成PDF檔</title>
		<link>http://clyang.net/blog/2009/07/27/344</link>
		<comments>http://clyang.net/blog/2009/07/27/344#comments</comments>
		<pubDate>Mon, 27 Jul 2009 15:23:46 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[fpdf]]></category>
		<category><![CDATA[jpg2pdf]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=344</guid>
		<description><![CDATA[最近需要將許多個很大張的jpg檔案合併成單一個pdf檔案，實在懶的只為了這個原因就特地安裝任何一套轉換pdf的軟體，外加這些jpg檔其實都放在遠端的機器上面，想到還要抓回來本機端處理就很麻煩，還得浪費自己電腦的運算資源，就在這個想法下，突然想起大四時曾經有使用過fpdf這個PHP的Library，能夠非常方便的製作pdf檔案，不但可以在遠端的機器上面完成所有的事情，還可以善用遠端威猛的運算資源 整理步驟如下: 下載最新的fpdf，並且解壓縮取出fpdf.php 編寫下列程式碼，這邊是原始碼 &#60;? require(&#039;fpdf.php&#039;); $pdf = new FPDF(); $d=dir(&#039;.&#039;); while(($file=$d-&#62;read())!=false) { if(substr($file,-4)!=&#34;.jpg&#34;) continue; $pdf-&#62;AddPage(); $pdf-&#62;Image($file,0,0,220); } $d-&#62;close(); $pdf-&#62;Output(&#34;output.pdf&#34;); ?&#62; 最後產出的output.pdf就是我要的檔案啦! 簡單解說一下，關鍵只有一段$pdf-&#62;Image，後面的引數第一個是要匯入的jpg檔案，第二跟第三個則是代表圖片左上角的定位，最後一個則是設定圖片的寬度，沒有長度的原因是該library會自動調整長度。]]></description>
			<content:encoded><![CDATA[<p>最近需要將許多個很大張的jpg檔案合併成單一個pdf檔案，實在懶的只為了這個原因就特地安裝任何一套轉換pdf的軟體，外加這些jpg檔其實都放在遠端的機器上面，想到還要抓回來本機端處理就很麻煩，還得浪費自己電腦的運算資源，就在這個想法下，突然想起大四時曾經有使用過<a title="fpdf" href="http://www.fpdf.org/" target="_blank">fpdf</a>這個PHP的Library，能夠非常方便的製作pdf檔案，不但可以在遠端的機器上面完成所有的事情，還可以善用遠端威猛的運算資源 <img src='http://clyang.net/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  整理步驟如下:</p>
<ol>
<li><a title="download fpdf" href="http://www.fpdf.org/en/download.php" target="_blank">下載最新的fpdf</a>，並且解壓縮取出fpdf.php</li>
<li>編寫下列程式碼，<a title="convert php" href="http://clyang.net/src/convert.phps" target="_blank">這邊是原始碼</a></li>
</ol>
<p style="padding-left: 30px;">
<pre class="brush: php">
&lt;?
 require(&#039;fpdf.php&#039;);
 $pdf = new FPDF();

 $d=dir(&#039;.&#039;);
 while(($file=$d-&gt;read())!=false)
 {
  if(substr($file,-4)!=&quot;.jpg&quot;) continue;
  $pdf-&gt;AddPage();
  $pdf-&gt;Image($file,0,0,220);
 }
 $d-&gt;close();
 $pdf-&gt;Output(&quot;output.pdf&quot;);
?&gt;
</pre>
<p>最後產出的output.pdf就是我要的檔案啦!</p>
<p>簡單解說一下，關鍵只有一段$pdf-&gt;Image，後面的引數第一個是要匯入的jpg檔案，第二跟第三個則是代表圖片左上角的定位，最後一個則是設定圖片的寬度，沒有長度的原因是該library會自動調整長度。</p>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2009/07/27/344/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>你還在PHP裡面使用srand()嗎?</title>
		<link>http://clyang.net/blog/2009/02/23/246</link>
		<comments>http://clyang.net/blog/2009/02/23/246#comments</comments>
		<pubDate>Sun, 22 Feb 2009 17:22:45 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[rand]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=246</guid>
		<description><![CDATA[念資工的人多數都是由C語言起家的，只要計概教到亂數產生的function時，授課老師總是會耳提面令的提醒著要記得使用srand()來產生一個random seed，否則每次跑出來的亂數都會是相同的，相信大家應該都有這段的印象才是。 於是，當我開始寫PHP後，也自然而然的將這個習慣套用進來，總是習慣先使用srand()產生亂數種子後，再用rand()產生亂數，直到前幾天，我亂翻PHP的Manual才在srand()說明頁看到下面這句話: Note: As of PHP 4.2.0, there is no need to seed the random number generator with srand() or mt_srand() as this is now done automatically. 原來PHP 4.2.0以後，使用亂數前已經不用先指定產生亂數種子了，它會自動的幫你產生，所以自己多做無謂的事情已經有一段時間了 Orz~，雖然少這行呼叫對程式效率也不會有任何提升，但是能少打點字還是不賴啦，如果你有看到這篇文章，記得下次在寫PHP時可以直接呼叫rand()喔!]]></description>
			<content:encoded><![CDATA[<p>念資工的人多數都是由C語言起家的，只要計概教到亂數產生的function時，授課老師總是會耳提面令的提醒著要記得使用<a title="srand" href="http://tw.php.net/srand" target="_blank">srand()</a>來產生一個random seed，否則每次跑出來的亂數都會是相同的，相信大家應該都有這段的印象才是。</p>
<p>於是，當我開始寫PHP後，也自然而然的將這個習慣套用進來，總是習慣先使用<a title="srand" href="http://tw.php.net/srand" target="_blank">srand()</a>產生亂數種子後，再用<a title="rand" href="http://tw.php.net/rand" target="_blank">rand()</a>產生亂數，直到前幾天，我亂翻PHP的Manual才在<a title="srand" href="http://tw.php.net/srand" target="_blank">srand()</a>說明頁看到下面這句話:</p>
<blockquote><p>Note: As of PHP 4.2.0, there is no need to seed the random number generator with srand() or mt_srand() as this is now done automatically.</p></blockquote>
<p>原來PHP 4.2.0以後，使用亂數前已經不用先指定產生亂數種子了，它會<span style="text-decoration: underline;"><strong>自動的</strong></span>幫你產生，所以自己多做無謂的事情已經有一段時間了 Orz~，雖然少這行呼叫對程式效率也不會有任何提升，但是能少打點字還是不賴啦，如果你有看到這篇文章，記得下次在寫PHP時可以直接呼叫<a title="rand" href="http://tw.php.net/rand" target="_blank">rand()</a>喔!</p>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2009/02/23/246/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>簡單實作PHP圖片驗證</title>
		<link>http://clyang.net/blog/2009/02/23/227</link>
		<comments>http://clyang.net/blog/2009/02/23/227#comments</comments>
		<pubDate>Sun, 22 Feb 2009 17:01:24 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[captcha]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=227</guid>
		<description><![CDATA[手邊有個服務需要圖片驗證(captcha)的功能，所以翻了一下之前寫的code，順便整理一下跟大家分享。這邊的code是產生出來的圖片是最簡單的樣式，僅是四個亂數產生的字母(有字母可能重複)，外加上一些黑點雜訊來增加辨識上難度，為了避免黑點干擾造字母的辨識困難，我剔除掉一些長相相近的字母，希望增加使用者輸入正確的機率，畢竟圖片驗證是要拿來擋機器人而不是拿來刁難真正的人類阿。 進入正題，captcha在實作概念很簡單，由一隻程式動態產生圖片檔案，圖片中包含一組長度不一、有無意義均可的字串，並且將產生出來的字串值存入session中，待使用者輸入完後，在將輸入的字串與存在session中的字串相比，若是相符則通過，反之則替除。 這邊我們會使用到PHP中的GD Library，你可以透過phpinfo()來檢查你是否成功安裝該Library。此外，為了讓產生出來的字母有更多的面貌(所以你可以挑刁鑽一點的字型)，請先自備好英文的truetype字型檔，將該字型檔案更名為font.ttf，放在與產生圖片程式的相同目錄下即可。別擔心，網路上一堆免費的英文字型檔可以下載使用，這邊推薦兩個: fontspace Fonts 500 完整程式碼如下(有加上註解了，應該非常好懂): &#60;?php session_start(); Header(&#34;Content-type: image/PNG&#34;); //在session中自訂使用authstr這個變數來儲存產生的字串 $_SESSION[&#039;authstr&#039;]=&#34;&#34;; //產生一個90*30的圖檔 $im = imagecreate(90,30) or die(&#34;Cant&#039;s initialize new GD image stream!&#34;); //定義使用的顏色,紅色為字體顏色,白色為底色,灰色為黑點雜訊 //若要更動，請自行更改後面三個整數，依序為R、G、B範圍皆在0~255間 $red = ImageColorAllocate($im, 255, 0, 0); $white = ImageColorAllocate($im, 255, 255, 255); $gray &#8230; <a href="http://clyang.net/blog/2009/02/23/227">繼續閱讀 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>手邊有個服務需要圖片驗證(<a title="captcha" href="http://en.wikipedia.org/wiki/Captcha" target="_blank"><span>captcha</span></a>)的功能，所以翻了一下之前寫的code，順便整理一下跟大家分享。這邊的code是產生出來的圖片是最簡單的樣式，僅是四個亂數產生的字母(有字母可能重複)，外加上一些黑點雜訊來增加辨識上難度，為了避免黑點干擾造字母的辨識困難，我剔除掉一些長相相近的字母，希望增加使用者輸入正確的機率，畢竟圖片驗證是要拿來擋機器人而不是拿來刁難真正的人類阿。</p>
<p><span id="more-227"></span>進入正題，<a title="captcha" href="http://en.wikipedia.org/wiki/Captcha" target="_blank"><span>captcha</span></a><span>在實作概念很簡單，由一隻程式動態產生圖片檔案，圖片中包含一組長度不一、有無意義均可的字串，並且將產生出來的字串值存入session中，待使用者輸入完後，在將輸入的字串與存在session中的字串相比，若是相符則通過，反之則替除。</span></p>
<p><span>這邊我們會使用到<a title="PHP" href="http://php.net/" target="_blank">PHP</a>中的<a title="GD Library" href="http://au2.php.net/gd" target="_blank">GD Library</a>，你可以透過phpinfo()來檢查你是否成功安裝該Library。此外，為了讓產生出來的字母有更多的面貌(所以你可以挑刁鑽一點的字型)，請先自備好<span style="text-decoration: underline;"><strong>英文的truetype字型檔</strong></span>，將該字型檔案更名為<span style="text-decoration: underline;"><strong>font.ttf</strong></span>，放在與產生圖片程式的相同目錄下即可。別擔心，網路上一堆免費的英文字型檔可以下載使用，這邊推薦兩個:</span></p>
<ol>
<li><a title="Fontspace" href="http://www.fontspace.com/" target="_blank"><span>fontspace</span></a></li>
<li><span><a title="Font 500" href="http://www.fonts500.com/" target="_blank">Fonts 500</a><br />
</span></li>
</ol>
<p><span>完整程式碼如下(有加上註解了，應該非常好懂):</span></p>
<pre class="brush: php">
&lt;?php
session_start();
Header(&quot;Content-type: image/PNG&quot;);

//在session中自訂使用authstr這個變數來儲存產生的字串
$_SESSION[&#039;authstr&#039;]=&quot;&quot;;

//產生一個90*30的圖檔
$im = imagecreate(90,30) or die(&quot;Cant&#039;s initialize new GD image stream!&quot;);

//定義使用的顏色,紅色為字體顏色,白色為底色,灰色為黑點雜訊
//若要更動，請自行更改後面三個整數，依序為R、G、B範圍皆在0~255間
$red = ImageColorAllocate($im, 255, 0, 0);
$white = ImageColorAllocate($im, 255, 255, 255);
$gray = ImageColorAllocate($im,  100, 100, 100);

//將圖片底色填滿白色
imagefill($im, 0, 0, $white);

//定義候選的字母，我剔除掉一些會混淆的，如大寫I與L
$ychar=&quot;A,B,C,E,F,H,K,L,M,N,P,R,T,U,V,W,X,Y,Z&quot;;
$list=explode(&quot;,&quot;,$ychar);
$cnt = count($list)-1;

//亂數挑選四個字母，字母可重複
for($i=0;$i&lt;4;$i++){
$randnum=rand(0,$cnt);
$authnum.=$list[$randnum].&quot; &quot;;
}

//將最後挑選出來的結果存入session
$_SESSION[&#039;authstr&#039;]=str_replace(&quot; &quot;,&quot;&quot;,$authnum);

//將挑選出來的字串印在圖片上,這邊你必須自備truetype的英文字型檔
putenv(&#039;GDFONTPATH=&#039; . realpath(&#039;.&#039;));
imagettftext($im, 10, 3, 8, 24, $red, &quot;/full/path/font.ttf&quot;, $authnum);

//加入100個黑點雜訊
for($i=0;$i&lt;100;$i++)
imagesetpixel($im, rand()%90 , rand()%30 , $gray);

//最後將圖片產生並且印出來
ImagePNG($im);
ImageDestroy($im);
?&gt;
</pre>
<p>這支程式最後產生出來的成果如右，請點選<a title="captcha demo" href="http://clyang.net/src/captcha.php" target="_blank"><strong>這個連結</strong></a>。(記得按F5看看字母是否每次都不同)</p>
<p>接著，在網頁前端的部分，新增下列HTML碼(假設上面的產生程式碼檔名為captcha.php)</p>
<pre class="brush: html">
&lt;img src=&quot;captcha.php&quot; border=&quot;0&quot; alt=&quot;&quot; width=&quot;90&quot; height=&quot;30&quot; /&gt;
請輸入上面的驗證碼(皆為大寫英文字母):&lt;input id=&quot;reply_form_CODE&quot; name=&quot;reply_form_CODE&quot; type=&quot;text&quot; /&gt;
</pre>
<p>上面的步驟我們完成了產生圖片的前後端部分，最後便是驗證的部分，將下面這段php的程式碼插入你所需驗證的程式碼最上端即可完成驗證的手續:</p>
<pre class="brush: php">
$code = strtoupper($_POST[&#039;reply_form_CODE&#039;]);
if($code == &quot;&quot; || $code != $_SESSION[&#039;authstr&#039;] || strlen($code) != 4){
//開始寫輸入錯誤的處理，這邊舉例是導到yahoo!kimo
header(&quot;Location: http://tw.yahoo.com/&quot;);
}
</pre>
<p>這樣就完成了實作一個簡單的圖片驗證，這種作法可以阻擋大多數的SPAM BOT的攻擊，但是如果你的網站樹敵頗多或室<strong>"內容"</strong>豐富，那可能會吸引有實作OCR的BOT攻擊，請根據自己的需求修改產生更複雜的圖型模式。</p>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2009/02/23/227/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>當apache的errorlog出現configured request variable name length limit exceeded</title>
		<link>http://clyang.net/blog/2009/02/09/177</link>
		<comments>http://clyang.net/blog/2009/02/09/177#comments</comments>
		<pubDate>Mon, 09 Feb 2009 10:51:42 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Picasa2Wordpress]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[suhosin]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=177</guid>
		<description><![CDATA[之前在寫Picasa2Wordpress的時候，測試的時候，遇到一個詭異的問題，在我有權限能access的機器們上面跑，就是有一台跑不起來，後來查了一下apache2的log才發現，原來是php suhosin module的問題，預設最大的POST及GET變數名稱最大只能夠是64字元，但是Picasa POST出去的卻遠超過，所以就被檔下來了。 解決方法很簡單，編輯/etc/php5/apache2/conf.d/suhosin.ini，加上下面這三行即可: suhosin.request.max_varname_length=128 suhosin.get.max_name_length=128 suhosin.post.max_name_length=128 搞定收工。]]></description>
			<content:encoded><![CDATA[<p>之前在寫Picasa2Wordpress的時候，測試的時候，遇到一個詭異的問題，在我有權限能access的機器們上面跑，就是有一台跑不起來，後來查了一下apache2的log才發現，原來是php suhosin module的問題，預設最大的POST及GET變數名稱最大只能夠是64字元，但是Picasa POST出去的卻遠超過，所以就被檔下來了。</p>
<p>解決方法很簡單，編輯/etc/php5/apache2/conf.d/suhosin.ini，加上下面這三行即可:</p>
<blockquote><p>suhosin.request.max_varname_length=128<br />
suhosin.get.max_name_length=128<br />
suhosin.post.max_name_length=128</p></blockquote>
<p>搞定收工。</p>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2009/02/09/177/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>每日自動彙整Plurk至BBS及信箱</title>
		<link>http://clyang.net/blog/2009/01/31/89</link>
		<comments>http://clyang.net/blog/2009/01/31/89#comments</comments>
		<pubDate>Sat, 31 Jan 2009 06:18:03 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[plurk]]></category>
		<category><![CDATA[summary]]></category>
		<category><![CDATA[彙整]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=89</guid>
		<description><![CDATA[我是一個重度的BBS使用者，之前在Vexed大神的引薦下開始使用Plurk，每天在plurk上面亂撲後，總是希望能夠每天plurk後整理一份到BBS上面記錄(我承認我還蠻無聊的，想要備份每天的胡言亂語)。所以就著手寫了一份自娛娛人，跑了快一個月看起來應該沒甚麼問題，於是就放出來跟各位分享。(因為一開始沒打算丟出來，所以code寫得有點亂，還請見諒) 執行本程式需要在*nix下，搭配php-cli、php curl library、pear的mail及JSON套件以及crontab方可使用。(我承認對於入門者來說這樣難度有點高 XD)，如果都克服上列問題，只需下載本程式，填上plurk的帳號密碼、smtp伺服器等相關資訊即可使用。 首先，先來個有圖有真相 自動彙整plurk 使用步驟: 下載本程式到你的機器上 (plurk.php)。 在第8行到第23行中填入所需的資訊。 修改/etc/crontab，讓本程式在每天一過午夜就執行彙整前一天的plurk 1       0       *       *       *       yuwen   /usr/local/bin/php /home/clyang/plurk/plurk.php 最後，本程式中取得userid所使用的regex式取用自klcintw的PO3程式。]]></description>
			<content:encoded><![CDATA[<p>我是一個重度的BBS使用者，之前在<a title="Vexed大神" href="http://blog.xuite.net/vexed/tech" target="_blank">Vexed大神</a>的引薦下開始使用Plurk，每天在<a title="plurk" href="http://www.plurk.com/" target="_blank">plurk</a>上面亂撲後，總是希望能夠每天<a title="plurk" href="http://www.plurk.com/" target="_blank">plurk</a>後整理一份到BBS上面記錄(我承認我還蠻無聊的，想要備份每天的胡言亂語)。所以就著手寫了一份自娛娛人，跑了快一個月看起來應該沒甚麼問題，於是就放出來跟各位分享。(因為一開始沒打算丟出來，所以code寫得有點亂，還請見諒)<span id="more-89"></span></p>
<p>執行本程式需要在*nix下，搭配php-cli、<a title="php curl library" href="http://tw.php.net/curl" target="_blank">php curl library</a>、<a title="php pear" href="pear.php.net" target="_blank">pear</a>的<a title="pear mail" href="http://pear.php.net/packages.php?catpid=14&amp;catname=Mail" target="_blank">mail</a>及<a title="pear JSON" href="http://pecl.php.net/package/json" target="_blank">JSON</a>套件以及crontab方可使用。(我承認對於入門者來說這樣難度有點高 XD)，如果都克服上列問題，只需下載本程式，填上plurk的帳號密碼、smtp伺服器等相關資訊即可使用。</p>
<p>首先，先來個有圖有真相<img class="size-full wp-image-90" title="plurk" src="http://clyang.net/blog/wp-content/uploads/2009/01/plurk.png" alt="自動彙整plurk" width="667" height="440" /></p>
<div class="mceTemp mceIEcenter">
<dl id="attachment_90" class="wp-caption aligncenter" style="width: 677px;">
<dd class="wp-caption-dd">自動彙整plurk</dd>
</dl>
</div>
<p>使用步驟:</p>
<ol>
<li>下載本程式到你的機器上 (<a title="plurk summarizer" href="http://clyang.net/plurk.phps" target="_blank">plurk.php</a>)。</li>
<li>在第8行到第23行中填入所需的資訊。</li>
<li>修改/etc/crontab，讓本程式在每天一過午夜就執行彙整前一天的<a title="plurk" href="http://www.plurk.com/" target="_blank">plurk</a></li>
</ol>
<blockquote>
<p style="padding-left: 30px; ">1       0       *       *       *       yuwen   /usr/local/bin/php /home/clyang/plurk/plurk.php</p>
</blockquote>
<p>最後，本程式中取得userid所使用的regex式取用自<a title="PO3" href="http://klcin.tw/net/pop3-read" target="_blank">klcintw的PO3</a>程式。</p>
<p style="padding-left: 30px; ">
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2009/01/31/89/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How to use rtgui with PHP4</title>
		<link>http://clyang.net/blog/2009/01/11/48</link>
		<comments>http://clyang.net/blog/2009/01/11/48#comments</comments>
		<pubDate>Sun, 11 Jan 2009 08:11:40 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[rtgui]]></category>
		<category><![CDATA[rtorrent]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=48</guid>
		<description><![CDATA[rtorrent是unix下面一個lightweight but powerful的BT Client. 跟許多console mode軟體不同的是, 他提供完整的xmlrpc api讓developer可以開發自己的interface來管理使用rtorrent. 我選用了rtgui, 本來以為只要幾分鐘就可以設定好, 沒想到卻遇到不能預期的錯誤, trace一下才發現原來是 file_get_contents這個function在PHP 5.0.0以後才support $context這個參數. 所以只好自己用curl hack一個給PHP &#60; 5.0.0可以動的版本. (需要有curl extension) 目前用起來是沒遇到任何問題, 搞定收工. Here is the hack (把functions.php裡面的do_xmlrpc整段換成): function do_xmlrpc($request) { global $rpc_connect; if (version_compare(PHP_VERSION, &#039;5.0.0&#039;, &#039;&#62;=&#039;)) { $file = &#8230; <a href="http://clyang.net/blog/2009/01/11/48">繼續閱讀 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a title="rtorrent" href="http://libtorrent.rakshasa.no/" target="_blank">rtorrent</a>是unix下面一個lightweight but powerful的BT Client. 跟許多console mode軟體不同的是, 他提供完整的xmlrpc api讓developer可以開發自己的interface來管理使用rtorrent.</p>
<p>我選用了<a title="rtgui" href="http://code.google.com/p/rtgui/" target="_blank">rtgui</a>, 本來以為只要幾分鐘就可以設定好, 沒想到卻遇到不能預期的錯誤, trace一下才發現原來是 <a title="file_get_contents" href="http://tw.php.net/file_get_contents" target="_blank">file_get_contents</a>這個function在PHP 5.0.0以後才support $context這個參數.</p>
<p>所以只好自己用curl hack一個給PHP &lt; 5.0.0可以動的版本. (需要有<a title="curl extension" href="http://tw.php.net/curl">curl extension</a>) 目前用起來是沒遇到任何問題, 搞定收工.</p>
<p>Here is the hack (把functions.php裡面的do_xmlrpc整段換成):</p>
<pre class="brush: php">

function do_xmlrpc($request) {
   global $rpc_connect;
   if (version_compare(PHP_VERSION, &#039;5.0.0&#039;, &#039;&gt;=&#039;)) {
      $file = file_get_contents($rpc_connect, false, $context);
   }else if(version_compare(PHP_VERSION, &#039;5.0.0&#039;, &#039;&lt;&#039;) &amp;amp;&amp;amp;
                extension_loaded(&#039;curl&#039;)){
      $c = curl_init();
      $post_data = array(&#039;content&#039; =&gt; $request);
      curl_setopt($c, CURLOPT_URL, $rpc_connect);
      curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($c, CURLOPT_POSTFIELDS, $request);
      curl_setopt($c, CURLOPT_TIMEOUT, 5);
      curl_setopt($c, CURLE_OPERATION_TIMEOUTED, 5);
      $file = curl_exec($c);
      curl_close($c);
   }else{
       die (&quot;&lt;h1&gt;Please use PHP 5+ or enable cURL extension <img src='http://clyang.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> &lt;/h1&gt;&quot;);
   }
   $file=str_replace(&quot;i8&quot;,&quot;double&quot;,$file);

   return xmlrpc_decode($file);
}
</pre>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2009/01/11/48/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

