PHP抓取網頁和分析

有些網頁的內容是常常變動的,但是又不可能一直盯著看,所以研究看看怎麼用 PHP 抓取網頁內容。
From:http://my.opera.com/kmgocc/blog/show.dml/322416
http://272586.blogspot.com/2007/05/php.html
http://www.fantxi.com/blog/show-618-1.html
http://www.inote.tw/2009/04/php-curl.html

繼續閱讀 »

Please follow and like us:

PHP-簡單的密碼產生器

<?php
function randomkeys($length){
$pattern = "1234567890abcdefghijklmnopqrstuvwxyz";
for($i=0;$i<$length;$i++){
$key .= $pattern{rand(0,35)};
}
return $key;
}
echo "key = ".randomkeys(8)."";
?>

$pattern:密碼要包含的字元
randomkeys(8) 裡面的 8 :希望產生的密碼長度
From:http://blog.hsdn.net/898.html

繼續閱讀 »

Please follow and like us:

PF 設定-頻寬控制

一般來說這種頻寬控管的rule都很像,先把水管大小訂出來,然後再配合firewall的rule,決定哪些packet要走哪條水管。例如下面就訂了兩條水管:

altq on $extdev cbq bandwidth 3Mb queue {def_ext, www_limit}
queue def_ext cbq(default)
queue www_limit bandwidth 300Kb cbq(red)

在$extdev上面先定一條3Mb的水管,下面再分了兩條水管:def_ext、www_limit,www_limit限流300Kb,def_ext沒有限制。altq支援兩種queue scheduler:CBQ和PRIQ,CBQ可以定頻寬寬度,PRIQ則是定封包的優先權。queue下面還可以再分多個queue,這邊只分了兩個queue。
From:
http://www.openbsd.org/faq/pf/queueing.html
http://blog.dhchen.com/2005/03/27/83

繼續閱讀 »

Please follow and like us:

PF相關指令

#pfctl -e //啟動 PF
#pfctl -d //停用 PF
#pfctl -f /etc/pf.conf //重新載入 pf.conf 設定檔
為了防止 pf 規則寫錯:
pfctl -f 的時候不忘加上 ;sleep 10; pfctl -d
#pfctl -nf /etc/pf.conf //檢查 PF 語法是否正確 (未載入)
#pfctl -Nf /etc/pf.conf //僅載入 NAT 的設定檔
#pfctl -Rf /etc/pf.conf //僅載入防火牆的過濾設定檔

繼續閱讀 »

Please follow and like us:

PF設定編寫

因 pf 是last match,..所以順序錯了,就連不上網了
Macro:定義網路介面
Tables:管理 IP List
Options:選項設定
Traffic Normalization:通訊正常化
Queueing:(ALTQ)定義頻寬控制的進出
Translation:(NAT)定義封包轉換
Packet Filtering:定義防火牆規則

繼續閱讀 »

Please follow and like us:

NAT + Firewall 設定 (FreeBSD 5.3)

第一步: 編輯 kernel,在最後方加入支援 IP firewall 的設定。
#IPFW FireWall
options IPFIREWALL #開啟基本的封包過濾功能
options IPFIREWALL_DEFAULT_TO_ACCEPT #設定 IPFIREWALL 的例外狀況
options IPFIREWALL_VERBOSE #設定記錄過濾日誌
options IPFIREWALL_VERBOSE_LIMIT=100 #設定日誌記錄檔大小的限制
options IPDIVERT #IP firewall 與 natd 的 port 定義, NAT 必要
options IPFIREWALL_FORWARD #子網域封包的傳輸轉遞
options DUMMYNET #IP firewall 限制頻寬設定必要選項
然後重新編譯 kernel 檔。
From:http://redeyeberg.blogspot.com/2007/02/nat-firewall.html

繼續閱讀 »

Please follow and like us:

FreeBSD 6.2 下的 Natd

rc.conf 裡也設定了對外轉封包的設定 (natd_interface="bge0" # bge0是伺服器對外的網卡),理應在開機後就可以自動開啟轉封包的功能,被這問題迫到我把所有的 kernel 的功能選項都打開重編核心,所有機器上沒用的硬體也都支援,依舊無解。
後來在 natd 的說明中看到了手動啟用 NAT 的指令,姑且一試吧!
# natd -interface bge0
乖乖,竟然就暢通無阻。
From:http://redeyeberg.blogspot.com/2007/04/freebsd-62-nat.html

繼續閱讀 »

Please follow and like us:

流量控管 shell script

因為 pure-ftp 沒有辦法在流量超過額度後,自動停止下載,所以就自己生了一個 shell script。
這是利用 trafd 統計流量之後,用 pureftp 的虛擬使用者來控制權限。(用其他的應該也可以,只要可以用命令列下指令就可以囉)
首先要先安裝 ports 裡面的 bpft,然後在啟動的時候加入參數:
-F /etc/trafd.filter
/etc/trafd.filter範例(只統計X大以外的流量):

(dst host 140.11x.x.x and src net ! 140.11x.0.0/16) or (src host 140.11x.x.x and dst net ! 140.11x.0.0/16)

再來就是開始寫 shell script 了。

繼續閱讀 »

Please follow and like us:
Pages: Prev 1 2 ... 6 7 8 9 10 11 12 13 Next