2008年9月24日 星期三

常用網路資訊查詢

Vendor/Ethernet MAC Address Lookup and Search http://www.coffer.com/mac_find/

台灣地區網際網路路由查測 http://trace.twnic.net.tw/

台灣地區連線網路頻寬查詢系統 http://map.twnic.net.tw/

rsync error

出現 rsync error:error in rsync protocol data stream (code 12) at io.c(165) 錯誤訊息

原因是 /etc/rsyncd.secrets 權限沒有設為 r--

檢查被執行的 PHP Script 是否是被 INCLUDE/INCLUDE_ONCE/REQUEST/REQUEST_ONCE 的檔案

if(str_replace("/", "\", $_SERVER["SCRIPT_FILENAME"]) !=__FILE__) echo "run as included file";

重新安裝 grub

輸入 grub update 或 grub

進入 grub 命令提示列
root (hd0,x)
setup (hd0)

指令說明:
root:設定啟動的分割區
  hd0 指第一顆硬碟,不分SATA,PATA界面
  x 設定 boot 分割區位置,編號從 0 開始

setup:將grub 設定寫入指定硬碟

2008年8月29日 星期五

Big5編碼的URL,無法瀏覽的問題

Big5編碼的url,瀏覽器會自動轉成UTF-8的編碼,而造成無法連結的問題,PHP中可以使用rawurlencode() 函式將Big5的URL先行編碼,就不會有無法連結的問題。

2008年4月2日 星期三

Squid Proxy 限制只能瀏覽特定網站

使用Squid Proxy 限制只能瀏覽特定網站,編輯 /etc/squid.conf 設定檔

acl alldst_ip dst 0.0.0.0/0.0.0.0
acl MS dstdomain .microsoft.com .microsoft.com.tw .windowsupdate.com
acl symantec dstdomain .symantec.com
acl AB dstdomain .ab.com
acl ip1 dst 192.168.1.1/255.255.255.255
acl cd dst www.cd.org

http_access allow MS
http_access allow symantec
http_access allow AB
http_access allow ip1
http_access allow cd
http_access deny alldst_ip

#
# And finally deny all other access to this proxy
http_access allow all
http_access deny all

2008年3月21日 星期五

PHP _SERVER相關變數檔案名稱的差異

PHP $_SERVER中可以取得PHP檔案名稱的變數有:$_SERVER['PHP_SELF']、$_SERVER['SCRIPT_NAME']、$_SERVER["REQUEST_URI"] 等,其中這三個變數雖然都是根據URL來決定值的,但接收不同的URL會有不同的結果,$_SERVER['REQUEST_URI']會原封不動的反映網址本身,而$_SERVER['PHP_SELF'] 會對網址進行一次urldecode操作,網址中的%3C將會變成字元"<",某些情況的結果會相同,有時卻會不同。

PHP 不是以 CGI 方式執行,$_SERVER 變數在不同URL結果的差異

URL

$_SERVER['PHP_SELF']$_SERVER['REQUEST_URI'] $_SERVER['SCRIPT_NAME']
http://localhost/example//example/index.php //example/index.php
http://localhost/example/index.php/example/index.php /example/index.php/example/index.php
http://localhost/example/index.php?a=test/example/index.php/example/index.php?a=test/example/index.php
http://localhost/example/index.php/dir/test/dir/test /example/index.php/dir/test/example/index.php

若是以 CGI 方式執行
$_SERVER['SCRIPT_NAME'] 結果是執行PHP script的程式,如 /cgi-bin/php.cgi

其它:
一、PHP中支援 INCLUDE/INCLUDE_ONCE/REQUEST/REQUEST_ONCE 功能,傳入的URL並不一定是實際執行的PHP SCRIPT,因此如果想取得目前真正被執行PHP SCRIPT檔案名稱應該使用 __FILE__ 這個變數。

二、$_SERVER['PHP_SELF']有跨站腳本攻擊的問題,不應直接顯示在網頁上,改以下方式
1.以 htmlentities($_SERVER['PHP_SELF']) 取代 $_SERVER['PHP_SELF']。
2.以 $_SERVER['REQUEST_URI']來替代$_SERVER['PHP_SELF']。