bcompiler php,使用 bcompiler 来加密PHP源代码

系统版本 FreeBSD 6.3-RELEASE

PHP版本 5.2.17(cd

/usr/ports/lang/php52;make install clean)

需要安装的PHP扩展 bz2(cd

/usr/ports/lang/php52-extensions;make install clean)

bcompiler 是一個收容於 PECL 的 PHP extension,您可以直接使用 pecl 這個命令來安裝,而

pecl 的使用方法與 pear

相同,因此你必須先安裝 pear

:

# cd /usr/ports/devel/pear ; make install clean

pear 安裝好後,同時會有一個 pecl 命令可用 (/usr/locel/bin/pecl),可用它來安裝

bcompiler

pecl install channel://pecl.php.net/bcompiler-1.0.2.tgz 目前最新的版本(http://pecl.php.net/package/bcompiler 可以自己看看需要哪一个版本)

安裝好後,記得要改設定把 bcompiler 這個 extension 載入

echo "extension=bcompiler.so" >>

/usr/local/etc/php/extensions.ini

bcompiler 全名是 PHP bytecode Compiler,詳細的使用方法可以參考 PHP 網站上的詳細說明:

PHP bytecode Compiler: http://www.php.net/manual/en/ref.bcompiler.php

看不懂的話,bcompiler_write_file() 這個 function

的說明裡面有範例:

$fh = fopen("example.phb", "w");

bcompiler_write_header($fh);

bcompiler_write_file($fh, "example.php");

bcompiler_write_footer($fh);

fclose($fh);

这里有一個簡單的 script,使用方法如下:

# bencoder

BENCODER v1.6 - Encode your PHP script using bcompiler

Usage: bencoder [-f] [-t] [-q] -o FILE file1.php

bencoder [-f] [-t] [-q] -o OUTDIR file1.php file2.php ...

bencoder [-f] [-t] [-q] -o OUTDIR -s SRCDIR [-e SUFFIX] [-r] [-c] [-l]

-o FILE : the file name to write the encoded script

(default to '-encoded.XXX' suffix)

-o OUTDIR : the directory to write all encoded files

-s SRCDIR

-a SRCDIR : encode all files from this source directory

-r : encode directories recursively (no by default)

-f : force overwriting even if the target exists

-t : truncate/keep only the basename of the file into the bytecode

-e SUFFIX : encode the files with the SUFFIX extension only (default: php)

(regular expression allowed, ex: "php|inc")

-c : copy files those shouldn't be encoded (no by default)

-l : follow symbolic link (no by default)

-q : do not print the file name while encoding or copying

-b

-bz2 : compress the encoded files with bz2 (needs bzip2-extension)

想用的人到 這邊 自己抓回去玩玩看吧

# fetch http://bencoder.urdada.net/bencoder

# chmod 755 bencoder

# mv bencoder /usr/local/bin/

在把程式使用 bcompiler 編碼之後,執行的時候發覺 $_SERVER 以及 $_ENV

的變數都不見了,後來查了資料,才發現要把 auto_globals_jit 關掉 (Off) 才行,請直接修改您的 php.ini

; When enabled, the SERVER and ENV variables are created when they're first

; used (Just In Time) instead of when the script starts. If these variables

; are not used within a script, having this directive on will result in a

; performance gain. The PHP directives register_globals, register_long_arrays,

; and register_argc_argv must be disabled for this directive to have any affect.

auto_globals_jit = Off

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值