2016-08-02 76 views
-2

在php中有很多代碼保護庫,但是他們需要安裝額外的php模塊,這是我無法承受的,因爲應用程序將在我沒有的服務器上運行。所以我想我可以自己做。PHP代碼保護庫

我想要做什麼:

$source = file_get_contents("encryptedPhpFile.php"); 
$source = decrypt($source, "mySecretKey"); 
//$source now contains decrypted source code which needs to be included 

//I cant use eval($source); because that code also contains 
//html/css/opening and closing php tags ... which eval() does 
//not know how to render 

//I cant write the source into temporary file and then include 
//that file because as soon as I write decrypted source to a disk, 
//it is exposed and it can be copyed 

我能做些什麼?有什麼建議麼?

+2

沒什麼可靠的。您唯一的選擇是評估或編寫一個包含源文件的文件。但是,這不以任何方式「安全」。在'decrypt'調用之後,所有人都必須做'echo $ source',並且他們有你的全部源碼。 –

+1

標題並不能真正恰當地描述問題。你能改善它嗎? –

+2

爲什麼你需要「保護」你的代碼呢?除非整個服務器受到攻擊,否則人們無法下載您的php腳本源,此時我懷疑任何保護措施都有幫助。 –

回答

6

這些庫是模塊的原因。您將無法在「代碼空間」中完全模擬它們。你的嘗試將是笨拙的(不是你的錯),並使你的代碼庫不那麼令人愉快/可維護。

您應該專注於獲得安裝它們的權限,遷移到允許您控制服務器到有用程度的主機,或者啓動並運行自己的服務器。