2006年7月18日 星期二

eAccelerator 提供的PHP加密編碼功能

eAccelerator 提供一支小程式,可對php程式加密編碼,詳細使用方法可執行

# /usr/local/bin/encoder

執行後會看到簡單的使用說明:

Usage: encoder [options] source_file_name
encoder [options] source_file_name...
encoder [options] source_directory_name...

Options:
-s suffix
encode files only with following suffix (default is "php")
-a
encode all files (no by default)
-l
follow symbolic links (no by default)
-r
encode directories recursively (no by default)
-c
copy files those shouldn't be encoded (no by default)
-f
overwrite existing files (no by default)
-w
exclude check for eaccelerator_load() and subsequent warning
-o target
If you encode only one script then 'target' specifyes an output
file name. If you encode directory or several files at once
then 'target' specifyes an output directory name.

Examples:
encoder some_file.php
encoder some_file.php -o some_encoded_file.php
encoder *.php -o some_dir
encoder ~/public_html/x -rcf -sphp -sinc -o ~/public_html/y

稍微玩一下應該就知道怎麼用了...

使用 encoder 去對 PHP 程式加密編碼,會產生另外一個檔案,你也可以對整個目錄作轉換,例如:

# encoder code -rcf -sphp -sinc -o code_encoded

這個命令會把 code/ 目錄下所有的 php / inc 結尾的檔案作編碼,並存放到 code_encoded 下面,
同時,由於指定了 -c 這個選項,其他格式、不需編碼的檔案,如 jpg/gif/html/js 等,
也會原封不動複製一份到 code_encoded 下面,這樣方便你直接以這個目錄來提供服務。

選項 -r 含底下所有子目錄