茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1674946 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
Crystal_HD_500G_400G_E.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

PHP特區 : [轉貼]安裝 PHP bcompile 做 編譯/加密 原始碼

發表者 討論內容
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉貼]安裝 PHP bcompile 做 編譯/加密 原始碼

安裝 PHP bcompile 做 編譯/加密 原始碼

PHP 的程式在公司在交付程式中, 比較麻煩的就是要如何把原始碼編譯或加密, 免費的方案, 可以考慮用 bcompiler(PHP bytecode Compiler).

不過這套於 PHP5 的物件寫法, 繼承等等, compiler 後執行會有問題, 純 function / include 等等, 是正常的.

PHP bcompiler 安裝步驟

下述環境於 Debian / Ubuntu Linux 安裝

  1. apt-get install libbz2-dev php-pear php5-dev # 因為 pecl compile bcompiler 需要 libbz2(bz2 library)
  2. pecl install channel://pecl.php.net/bcompiler-0.8 # 因為 bcompiler 是 beta, 不是 stable, 所以需要完整路徑.
  3. echo "extension=bcompiler.so" >> /etc/php5/conf.d/bcompile.ini
  4. /etc/init.d/apache2 restart

確認 Module 是否載入

  • php -m | grep bcompiler
  • phpinfo(); # 看是否有載入 bcompiler module

PHP bcompiler 使用

先寫一個編譯程式, 準備把 example.php 編譯成 example.phb (或 xxx.php 都可以), 詳細可見:
bcompiler_write_file.

編譯其他程式用的檔案 bcompiler.php
<?php
$fh = fopen("example.phb", "w");
bcompiler_write_header($fh);
bcompiler_write_file($fh, "example.php");
bcompiler_write_footer($fh);
fclose($fh);
?>
hello.php
<?php
function hello()
{
   echo "hello\n";
}
?>
example.php
<?php
include('hello.php');
hello();
?>
  1. 編譯: php bcompiler.php # 會發現有產生出 example.phb (或於 bcompiler.php 有另外取名字的 xxx.php)
  2. 執行: php example.phb # 會秀 hello, 然後此檔案已經是編譯過的 php code.

另外查到
使用 bcompiler 來編譯(加密)您的 PHP 原始碼 這篇的作者, 寫了一個 bencoder 的好用程式, 可以 compile 整個目錄, 詳細可見: BENCODER v1.3 - Encode your PHP script using bcompiler

Bencoder 安裝使用

  1. wget http://bencoder.urdada.net/bencoder
  2. chmod +x ./bencoder
  3. vim bencoder # 修改 php 執行路徑, Debian PHP 存放路徑在 /usr/bin/php
    #!/usr/local/bin/php 改成 #!/usr/bin/php
  4. 執行: ./bencoder -f -o php/Breadcrumb_ben/ -s php/Breadcrumb/ -r
    encoded: php/Breadcrumb_ben//first.php
    encoded: php/Breadcrumb_ben//index.php
    encoded: php/Breadcrumb_ben//bread.php
    encoded: php/Breadcrumb_ben//second.php



原文出處:安裝 PHP bcompile 做 編譯/加密 原始碼 | Tsung's Blog
前一個主題 | 下一個主題 | | | |

討論串




Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|