Interpret text input as PHP

I want users to test my PHP class, which, among other things, visits and resizes images.

I want them to write PHP code in a text box, send the form, and then their code will be run. How can i do this?

Or are these other safe ways to give users (anyone) a PHP demo class?

+2
source share
7 answers

Yes. You can use the eval expression in php (previously associated with John http://us2.php.net/manual/en/function.eval.php ), however be very careful. You really do not want users to be free to run code on your computer.

My recommendation will try to come up with a different approach to the demo - maybe some flexible examples ... but don't let them run the code directly

+4
source

I would spawn a PHP process using a user account with the following permissions. Give read and write access to the same directory, but that.

You still open yourself up for DoS attacks with endless loops, etc., but if you absolutely need it, run the code in this very low resolution environment like IE and Chrome.

EVAL, , .

+5

eval(), . .

"" , PHP . .

, , /.

+3

, eval, . , , , , , , HTML-.

+2

PHP , , . (DSL), .

, . , . , , , . .

, . , - , (, Smarty ?) PHP?

resize(rotate("foo.png", 90), 50)

, , , :

"foo.png" 90 rotate 50 resize

, XML, , :

<resize percent="50"><rotate degrees="90"><img src="foo.png"></rotate></resize>

DSL , , , - , . , DSL - , , script.

0

eval, - .

"", "", :

... .

0

All Articles