문제

I don't want to give my code to client. I know there is no any such way which make my code 100% secure from client or editing by other developers but at least i think from may clients i can hide my code, for this i am using the following way:

For example, I have the following code:

$php = base64_encode('<?php function add($a,$b){echo($a+$b);} add(30,40); ?>');

The above line produces the following code of my php code:

PD9waHAgZnVuY3Rpb24gYWRkKCRhLCRiKXtlY2hvKCRhKyRiKTt9IGFkZCgzMCw0MCk7ID8+

I used gzencode() method to compress the above generated code like this:

$txt = "PD9waHAgZnVuY3Rpb24gYWRkKCRhLCRiKXtlY2hvKCRhKyRiKTt9IGFkZCgzMCw0MCk7ID8+";
$ph = gzencode($txt,8);

I can get the Original php code by using the following code:

echo(base64_decode($ph));

It produces:

<?php function add($a,$b){echo($a+$b);} add(30,40); ?>

Now, this code shows in the source code in the browser but i want to run this code like the original php code, so, what i have to do to make this executable?

Thanks

도움이 되었습니까?

해결책

You can use eval to run the string as inline code. Check this (eval) You can also create an anonymous function which your string code should be inside (create_function)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top