<?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; Administration</title>
	<atom:link href="http://blog.pptpb.org/category/working/administration/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.pptpb.org</link>
	<description>那就可以開始期待下一個天晴了。</description>
	<lastBuildDate>Sun, 04 Sep 2011 11:52:33 +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>實做 Web-UI ftp browser (Apache, PHP, Perl)</title>
		<link>http://blog.pptpb.org/2010/05/18/200/%e5%af%a6%e5%81%9a-web-ui-ftp-browser-apache-php-perl</link>
		<comments>http://blog.pptpb.org/2010/05/18/200/%e5%af%a6%e5%81%9a-web-ui-ftp-browser-apache-php-perl#comments</comments>
		<pubDate>Tue, 18 May 2010 00:23:48 +0000</pubDate>
		<dc:creator>pptpb</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[程式設計]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.pptpb.org/?p=200</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 70px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
這篇只是當作 comment 用，因為我實在沒有邊 coding 邊寫 comment 的習慣。 狀況提要 幫某個團體架設的 ftp 站，以 pure-ftpd 管理，並使用 utf-8 編碼。但使用成員大多不熟悉 ftp client 使用，就算會用也因為編碼問題常常看到亂碼。 想法 於是上個週末用一個晚上試著寫寫看能不能利用 Web browser 實做 ftp 瀏覽 (read only) 的功能。我知道 Apache 有 Options Indexes 的功能，搭配基本的認證可以達到限定特定使用者存取，但因此法的帳號密碼會被瀏覽器 cache 住，且也無法登出，所以才想自行動手。 作法 先用 Perl (cgi like) &#8230; <a href="http://blog.pptpb.org/2010/05/18/200/%e5%af%a6%e5%81%9a-web-ui-ftp-browser-apache-php-perl">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 70px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
<p>這篇只是當作 comment 用，因為我實在沒有邊 coding 邊寫 comment 的習慣。</p>
<h4>狀況提要</h4>
<p>幫某個團體架設的 ftp 站，以 <a href="http://www.pureftpd.org" class="external">pure-ftpd</a> 管理，並使用 utf-8 編碼。但使用成員大多不熟悉 ftp client 使用，就算會用也因為編碼問題常常看到亂碼。</p>
<h4>想法</h4>
<p>於是上個週末用一個晚上試著寫寫看能不能利用 Web browser 實做 ftp 瀏覽 (read only) 的功能。我知道 Apache 有<a href="http://httpd.apache.org/docs/1.3/mod/core.html#options" class="external external"> Options Indexes</a> 的功能，搭配基本的<a href="http://httpd.apache.org/docs/1.3/howto/auth.html" >認證</a>可以達到限定特定使用者存取，但因此法的帳號密碼會<a href="http://httpd.apache.org/docs/1.3/howto/auth.html#basicworks" class="external external">被瀏覽器 cache 住</a>，且也<a title="Apache: How do I logout?" href="http://httpd.apache.org/docs/1.3/howto/auth.html#logout" >無法登出</a>，所以才想自行動手。<span id="more-200"></span></p>
<h4>作法</h4>
<p>先用 Perl (cgi like) 實做 file listing 與 directory traversal 的基本操作，再以 PHP session 檢查使用者是否已登入，決定是否開放頁面存取。</p>
<h4>問題解決</h4>
<ol>
<li>使用 Apache <a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html">mod_rewrite</a> 蓋掉PHP內部的 get method sending，使瀏覽網址與實際使用 ftp 時所見目錄路徑一致。</li>
<li>ftp 實際檔案位置不應放在網頁伺服器根路徑下，否則知道檔案路徑的人就能抓到檔案。下載檔案時使用 PHP <a href="http://php.net/manual/en/function.readfile.php" class="external">readfile()</a> 處理。但 readfile 遇到大檔案時有 buffer 限制，要注意一下。</li>
<li>承上，因為放不同路徑，所以檔案讀取權限要設定一下，讓 ftp 與 www server 能同時讀取檔案。（該伺服器架在 Fedora 上，設權限時其實遇到了些懸疑困難，我到現在還是不知道為什麼。後來是用有點 dirty 的方法解掉。）</li>
<li>避免未登入使用者得知Perl程式路徑而直接讀取，該 script 不放在 cgi-bin 目錄下，而是另外存放，以 PHP <a href="http://php.net/manual/en/function.system.php" class="external">system()</a> 呼叫。</li>
</ol>
<h4>改進</h4>
<ol>
<li>使用<a href="http://tinyurl.com" class="external"> Tinyurl</a> 的服務，讓每個網頁、檔案都能取得縮址，方便到其他地方（BBS, &#8230;）貼上與團體內部分享。</li>
<li>Perl script 部份有空應該改用 Apache <a href="http://perl.apache.org/docs/" class="external">mod_perl</a> 處理。</li>
<li>有時間再加個上傳功能吧，但上面提到的檔案權限問題其實有點棘手。</li>
</ol>
<h4>後記</h4>
<p>早知道這篇寫得那麼落落長，我當初就應該乖乖地寫 comment&#8230;</p>
<p>Screenshot:</p>
<p><a href="http://blog.pptpb.org/wp-content/uploads/2010/05/snapshot17.png" rel="lightbox[200]"><img class="alignnone size-medium wp-image-208" title="snapshot" src="http://blog.pptpb.org/wp-content/uploads/2010/05/snapshot17-300x225.png" alt="" width="300" height="225" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.pptpb.org/2010/05/18/200/%e5%af%a6%e5%81%9a-web-ui-ftp-browser-apache-php-perl/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>換裝硬碟心得</title>
		<link>http://blog.pptpb.org/2009/12/06/134/%e6%8f%9b%e8%a3%9d%e7%a1%ac%e7%a2%9f%e5%bf%83%e5%be%97</link>
		<comments>http://blog.pptpb.org/2009/12/06/134/%e6%8f%9b%e8%a3%9d%e7%a1%ac%e7%a2%9f%e5%bf%83%e5%be%97#comments</comments>
		<pubDate>Sun, 06 Dec 2009 07:51:34 +0000</pubDate>
		<dc:creator>pptpb</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[FreeBSD]]></category>

		<guid isPermaLink="false">http://blog.pptpb.org/?p=134</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 70px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
還算新手的我，前些日子有幸摸到一台不知多古老版本的 FreeBSD 機器。 據稱是之前硬碟滿了，不想重灌系統，然後請了*外面的電腦公司*來處理。結果電腦公司的人好像是直接用新硬碟對拷&#8230;。聽了我下巴差點沒掉下來，這不叫換湯不換藥嗎（喂！這成語是這樣用的嗎 XD），對拷後原本空間不夠的磁碟分割區還是不夠啊。 然後另一個點是，他們壓根兒就忘了root密碼，而這謎樣版本的 FreeBSD 沒有開機選單，進 Single user mode 也沒有多餘指令可用（重申：我是新手）。基於以上原因，我給他們的建議是拿顆硬碟備份，然後重灌系統。 由於沒有準備，我身邊包包裡剛好只找到 7.0-Release boot-only 的開機片，進 commit 時，ftp site 上好像又都沒有可用的資料了，因此決定賭他一把。在 commit 前，進 option 把版本號改成 8.0-Release，然後安裝。 一下子後，看起來是一切 okay 了，鬆了口氣。 然後把舊的硬碟掛上去，搬資料，重分割，就差不多了。 雖然是新手，但在沒有後援的狀況下，還是硬裝得像老手一般 :p 順便加強一下太久沒用遺忘掉的觀念。]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 70px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
<p>還算新手的我，前些日子有幸摸到一台不知多古老版本的 FreeBSD 機器。</p>
<p>據稱是之前硬碟滿了，不想重灌系統，然後請了*外面的電腦公司*來處理。結果電腦公司的人好像是直接用新硬碟對拷&#8230;。聽了我下巴差點沒掉下來，這不叫換湯不換藥嗎（喂！這成語是這樣用的嗎 XD），對拷後原本空間不夠的磁碟分割區還是不夠啊。</p>
<p>然後另一個點是，他們壓根兒就忘了root密碼，而這謎樣版本的 FreeBSD 沒有開機選單，進 Single user mode 也沒有多餘指令可用（重申：我是新手）。基於以上原因，我給他們的建議是拿顆硬碟備份，然後重灌系統。</p>
<p>由於沒有準備，我身邊包包裡剛好只找到 7.0-Release boot-only 的開機片，進 commit 時，ftp site 上好像又都沒有可用的資料了，因此決定賭他一把。在 commit 前，進 option 把版本號改成 8.0-Release，然後安裝。</p>
<p>一下子後，看起來是一切 okay 了，鬆了口氣。</p>
<p>然後把舊的硬碟掛上去，搬資料，重分割，就差不多了。</p>
<p>雖然是新手，但在沒有後援的狀況下，還是硬裝得像老手一般 :p 順便加強一下太久沒用遺忘掉的觀念。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.pptpb.org/2009/12/06/134/%e6%8f%9b%e8%a3%9d%e7%a1%ac%e7%a2%9f%e5%bf%83%e5%be%97/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

