使用APC来 加密php代码

来源:互联网 发布:java开发erp系统 编辑:程序博客网 时间:2024/06/06 18:18

原理 其实很简单,就是将许多php文件 代码  使用apc_bin_dumpfile生 成opcode的文件 ;使用时将apc_bin_loadfile加载 opcode文件 .原代码 文件 清空。


生成 opcode单一文件 ;注意 apc.ini中设置 为 ,apc.stat =off;


var_dump(ini_get('apc.stat'));$arr_files = glob_recursive("/var/www/html/models/*.php");//echo '<pre>';print_r($arr_files );var_dump(__DIR__.'/models.bin');foreach ($arr_files as $filename) {    //echo "$filename size " . filesize($filename) . "\n<br />";        @require_once $filename;    //$output = str_replace('/models/', '/models2/', $filename);    //echo $output;exit;    //@mkdir(dirname($output),true);    //file_put_contents($output, '');}foreach($arr_files as $filename){//recompile again,maybe not usableapc_compile_file($filename);}$flag = @apc_bin_dumpfile($arr_files, array(), __DIR__.'/models.bin');var_dump($flag);




使用时,然后 就可以 使用了。

$flag = apc_bin_loadfile( BAOGG_ROOT.'models.bin');set_include_path(get_include_path() . PATH_SEPARATOR . ‘/var/www/html/models/’);




参考:

http://www.laruence.com/2012/08/16/2701.html

http://hi.baidu.com/leolance/item/d115f9f6475208ca531c2693