I want to make some game in PHP that involves scripting. For obvious reasons I don't want players/users to use PHP that I just include
or eval
. So I decided to go with LUA.
But I've never experimented with LUA in PHP. So my questions are:
- Is allowing user LUA script in (out of the box) PHP a secure solution?
- If not, then can I (and how to) make it secure?
What I aim for:
- User writes some code with some generic root function, let's say
main()
- PHP code calls that function and evaluates the results
- LUA code should be able to call a select few methods on certain object. For example from class
Enemy::isNear()
orEnemy::getHP()
- LUA code should not be able to call other methods/access other objects/call any global php functions/access any insecure OS stuff
Again, I only scratched LUA very long time ago for, where a game in C allowed for LUA mods. No experience with LUA in PHP at all.