<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>PHP</title><link>http://blog.blueshop.com.tw/guancheng713/category/2401.aspx</link><description>PHP</description><managingEditor>Aery</managingEditor><dc:language>zh-TW</dc:language><generator>.Text Version 0.95.2004.101</generator><item><dc:creator>Aery</dc:creator><title>在Ubuntu 裡安裝 PDT + Xdebug + 決解在8.04的錯誤</title><link>http://blog.blueshop.com.tw/guancheng713/archive/2008/05/07/54966.aspx</link><pubDate>Wed, 07 May 2008 01:19:00 GMT</pubDate><guid>http://blog.blueshop.com.tw/guancheng713/archive/2008/05/07/54966.aspx</guid><wfw:comment>http://blog.blueshop.com.tw/guancheng713/comments/54966.aspx</wfw:comment><comments>http://blog.blueshop.com.tw/guancheng713/archive/2008/05/07/54966.aspx#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://blog.blueshop.com.tw/guancheng713/comments/commentRss/54966.aspx</wfw:commentRss><trackback:ping>http://blog.blueshop.com.tw/guancheng713/services/trackbacks/54966.aspx</trackback:ping><description>&lt;pre id="line1"&gt;PDT 1.0 + Xdebug in Ubuntu 安裝過程 [討論區 - 程式編輯器]&lt;br&gt;&lt;a href="http://twpug.net/modules/newbb/viewtopic.php?topic_id=2887"&gt;http://twpug.net/modules/newbb/viewtopic.php?topic_id=2887&lt;/a&gt;&lt;br&gt;&lt;/pre&gt;我是照這篇去做的，完成之後會出現一個錯誤訊息如下：&lt;br&gt;Could not initialize the application's security component. The most likely cause is problems with files in your application's profile directory. Please check that this directory has no read/write restrictions and your hard disk is not full or close to full. It is recommended that you exit the application and fix the problem. If you continue to use this session, you might see incorrect application behaviour when accessing security features.&lt;br&gt;&lt;br&gt;解決方法很簡單，手動建立$HOME/.mozilla/eclipse這個目錄即可&lt;br&gt;來源：&lt;a href="https://bugs.launchpad.net/ubuntu/+source/eclipse/+bug/188380"&gt;https://bugs.launchpad.net/ubuntu/+source/eclipse/+bug/188380&lt;/a&gt;&lt;br&gt;&lt;img src ="http://blog.blueshop.com.tw/guancheng713/aggbug/54966.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Aery</dc:creator><title>UTF-8與session_start()</title><link>http://blog.blueshop.com.tw/guancheng713/archive/2008/01/13/54052.aspx</link><pubDate>Sun, 13 Jan 2008 19:24:00 GMT</pubDate><guid>http://blog.blueshop.com.tw/guancheng713/archive/2008/01/13/54052.aspx</guid><wfw:comment>http://blog.blueshop.com.tw/guancheng713/comments/54052.aspx</wfw:comment><comments>http://blog.blueshop.com.tw/guancheng713/archive/2008/01/13/54052.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://blog.blueshop.com.tw/guancheng713/comments/commentRss/54052.aspx</wfw:commentRss><trackback:ping>http://blog.blueshop.com.tw/guancheng713/services/trackbacks/54052.aspx</trackback:ping><description>&lt;P&gt;剛剛發生了一件很怪的事&lt;BR&gt;我已經把session_start();放到設定檔的最前面了&lt;BR&gt;甚至是刪到只剩session_start();他還是會發生錯誤&lt;BR&gt;Warning: session_start(): Cannot send session cookie - headers already sent by ......&lt;/P&gt;
&lt;P&gt;之前遇到這個就是把output buffer打開&lt;BR&gt;今天心血來潮找了一下原因~~~~~&lt;BR&gt;原來是UTF-8的BOM搞的鬼&lt;BR&gt;我這個檔案是用Notepad++開的&lt;/P&gt;
&lt;P&gt;解決方式：&lt;BR&gt;再用Nodepad++開啟然後&amp;nbsp;&amp;nbsp; 格式 =&amp;gt; 編譯成 UTF-8 碼〈檔首無 BOM〉=&amp;gt; 存檔&lt;BR&gt;&lt;/P&gt;&lt;img src ="http://blog.blueshop.com.tw/guancheng713/aggbug/54052.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Aery</dc:creator><title>關閉指定目錄的PHP</title><link>http://blog.blueshop.com.tw/guancheng713/archive/2007/12/24/53822.aspx</link><pubDate>Mon, 24 Dec 2007 18:38:00 GMT</pubDate><guid>http://blog.blueshop.com.tw/guancheng713/archive/2007/12/24/53822.aspx</guid><wfw:comment>http://blog.blueshop.com.tw/guancheng713/comments/53822.aspx</wfw:comment><comments>http://blog.blueshop.com.tw/guancheng713/archive/2007/12/24/53822.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://blog.blueshop.com.tw/guancheng713/comments/commentRss/53822.aspx</wfw:commentRss><trackback:ping>http://blog.blueshop.com.tw/guancheng713/services/trackbacks/53822.aspx</trackback:ping><description>&lt;SPAN class=postbody&gt;apache的設定： &lt;BR&gt;&amp;lt;Directory /usr/local/apache/htdocs/upload&amp;gt; &lt;BR&gt;php_flag engine off &lt;BR&gt;#如果是php3換成php3_engine off &lt;BR&gt;&amp;lt;/Directory&amp;gt;&lt;/SPAN&gt;&lt;img src ="http://blog.blueshop.com.tw/guancheng713/aggbug/53822.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Aery</dc:creator><title>用php下載指定檔案並重新命名(另存新檔)</title><link>http://blog.blueshop.com.tw/guancheng713/archive/2007/12/24/53816.aspx</link><pubDate>Mon, 24 Dec 2007 18:16:00 GMT</pubDate><guid>http://blog.blueshop.com.tw/guancheng713/archive/2007/12/24/53816.aspx</guid><wfw:comment>http://blog.blueshop.com.tw/guancheng713/comments/53816.aspx</wfw:comment><comments>http://blog.blueshop.com.tw/guancheng713/archive/2007/12/24/53816.aspx#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://blog.blueshop.com.tw/guancheng713/comments/commentRss/53816.aspx</wfw:commentRss><trackback:ping>http://blog.blueshop.com.tw/guancheng713/services/trackbacks/53816.aspx</trackback:ping><description>&lt;P&gt;&lt;SPAN class=postbody&gt;上傳的程式碼(放在表單後的JavaScript)：&lt;/SPAN&gt;&lt;SPAN class=postbody&gt;&lt;TEXTAREA class=jscript name=code rows=6 cols=50&gt;&amp;lt;script language="javascript"&amp;gt;
function validate()
{
  // 切割檔案路徑
  var Ary = document.getElementById('file').value.split('\\');
 
  // 建立隱藏標籤
  var hideTag = document.createElement("input");
  hideTag.setAttribute('name', 'filename');
  hideTag.setAttribute('type', 'hidden');
  document.getElementById('form1').appendChild(hideTag);
 
  // 置入檔名到隱藏標籤
  hideTag.value=Ary[Ary.length-1];
 
  return true;
}
document.getElementById('form1').onsubmit = function() { return validate(); };
&amp;lt;/script&amp;gt; &lt;/TEXTAREA&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=postbody&gt;&lt;/SPAN&gt;&lt;SPAN class=postbody&gt;&lt;SPAN class=postbody&gt;上傳的程式碼(接收上傳檔案的PHP)：&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=postbody&gt;&lt;SPAN class=postbody&gt;&amp;nbsp;&lt;TEXTAREA class=php name=code rows=6 cols=50&gt;&amp;lt;?php
function ch_filename($name)
{
   $arr = explode('.', $name);
   $arr[0] = (rand()%100).substr(md5($arr[0]), 0, 28);
   return join('.', $arr);
}

if($_FILES['file']['size'] &amp;gt; 0)
{
   $filename = ch_filename($_POST['filename']);
   move_uploaded_file($_FILES['file']['tmp_name'],'upload/'.$filename);
   
   // 新增資料到資料庫(filepath|filename)
   $db-&amp;gt;query("UPDATE `news` SET `file` = '".$_POST['filename']."|upload/".$filename."';");
}
?&amp;gt;&lt;/TEXTAREA&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=postbody&gt;&lt;SPAN class=postbody&gt;&lt;SPAN class=postbody&gt;下載的超連結：&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=postbody&gt;&lt;SPAN class=postbody&gt;&lt;SPAN class=postbody&gt;&lt;TEXTAREA class=xml name=code rows=6 cols=50&gt;&amp;lt;a href="get_file.php?path=&amp;lt;?=$filepath?&amp;gt;&amp;amp;filename=&amp;lt;?=urlencode($filename)?&amp;gt;"&amp;gt;&amp;lt;?=$filename?&amp;gt;&amp;lt;/a&amp;gt;&lt;/TEXTAREA&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=postbody&gt;&lt;SPAN class=postbody&gt;&lt;SPAN class=postbody&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=postbody&gt;&lt;SPAN class=postbody&gt;&lt;SPAN class=postbody&gt;&lt;SPAN class=postbody&gt;&amp;nbsp;get_file.php 程式碼： &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=postbody&gt;&lt;SPAN class=postbody&gt;&lt;SPAN class=postbody&gt;&lt;SPAN class=postbody&gt;&lt;TEXTAREA class=php name=code rows=6 cols=50&gt;&amp;lt;?php
if(empty($_GET['path']) || empty($_GET['filename']))
{
   echo '非正常路途徑進入本頁或參數錯誤';
   exit();
}

if(file_exists($_GET['path']))
{
   $FILEname = urlencode($_GET['filename']);
   
   if(ini_get('zlib.output_compression'))
      ini_set('zlib.output_compression', 'Off');
   
   header("Content-Type: application/octetstream; name=$FILEname"); //for IE &amp;amp; Opera
   
   header("Content-Type: application/octet-stream; name=$FILEname"); //for the rest
   
   header("Content-Disposition: attachment; filename=$FILEname;");
   
   header("Content-Transfer-Encoding: binary");
   header("Cache-Control: cache, must-revalidate");
   header("Pragma: public");
   header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
   header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
   
   readfile($_GET['path']);
}
else
   echo '檔案不存在';
?&amp;gt;&lt;/TEXTAREA&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src ="http://blog.blueshop.com.tw/guancheng713/aggbug/53816.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Aery</dc:creator><title>用PHP正則表達式清除字符串的空白</title><link>http://blog.blueshop.com.tw/guancheng713/archive/2007/12/24/53813.aspx</link><pubDate>Mon, 24 Dec 2007 18:09:00 GMT</pubDate><guid>http://blog.blueshop.com.tw/guancheng713/archive/2007/12/24/53813.aspx</guid><wfw:comment>http://blog.blueshop.com.tw/guancheng713/comments/53813.aspx</wfw:comment><comments>http://blog.blueshop.com.tw/guancheng713/archive/2007/12/24/53813.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://blog.blueshop.com.tw/guancheng713/comments/commentRss/53813.aspx</wfw:commentRss><trackback:ping>http://blog.blueshop.com.tw/guancheng713/services/trackbacks/53813.aspx</trackback:ping><description>&lt;P&gt;&lt;TEXTAREA class=php name=code rows=6 cols=50&gt;&amp;lt;?php
$str = " This line contains\tliberal \r\n use of whitespace.\n\n";

// First remove the leading/trailing whitespace
//去掉開始和結束的空白
$str = trim($str);

// Now remove any doubled-up whitespace
//去掉跟隨別的擠在一塊的空白
$str = preg_replace('/\s(?=\s)/', '', $str);

// Finally, replace any non-space whitespace, with a space
//最後，去掉非space 的空白，用一個空格代替
$str = preg_replace('/[\n\r\t]/', ' ', $str);

// Echo out: 'This line contains liberal use of whitespace.'
echo "&amp;lt;pre&amp;gt;{$str}&amp;lt;/pre&amp;gt;";
?&amp;gt;
&lt;/TEXTAREA&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=postbody&gt;&amp;nbsp;參考來源：&lt;a href="http://xwarez.com.ru/html/3/33/PHPgengbingaicai.html"&gt;http://xwarez.com.ru/html/3/33/PHPgengbingaicai.html&lt;/a&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src ="http://blog.blueshop.com.tw/guancheng713/aggbug/53813.aspx" width = "1" height = "1" /&gt;</description></item></channel></rss>
