如何安全执行用户提交的PHP代码 [英] How to safely execute user-submitted PHP code

查看:74
本文介绍了如何安全执行用户提交的PHP代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
PHP沙箱/清除传递给create_function的代码

Possible Duplicate:
PHP sandbox/sanitize code passed to create_function

对于非常笼统的问题,我深表歉意,但我需要一些指导.执行用户提交的PHP代码的最理想方法是什么?想想JSFiddle for PHP.我知道有些网站可以做到这一点,例如 http://writecodeonline.com/php/,但我认为那是PHP4,并且无法使用我尝试在其上运行的一半代码.我也知道我可以简单地禁用所有风险"功能,但是,这没什么好玩的:)

I apologize for the very generalized question, but I need some guidance. What is the most ideal way to execute user-submitted PHP code? Think JSFiddle for PHP. I know there are sites that do this such as http://writecodeonline.com/php/ but I think that's PHP4 and doesn't work with half the code I try to run on it. I also know I could simply disable all the "risky" functions but, that's no fun :)

我知道拥有一个PHPFiddle.com非常方便,我们可以在StackOverflow上引用它,就像我们依赖JSfiddle或JSbin一样.

I know it would be extremely handy having a PHPFiddle.com we could refer to on StackOverflow just as we've come to rely on JSfiddle or JSbin.

我正在考虑在我的盒子上创建虚拟主机的思路,因此用户尝试使用的任何文件系统功能都将限于该沙盒.我不确定如何解决这个问题,或者不确定是否会使我的服务器中有几个正在运行.

I'm thinking something along the lines of creating a virtual host on my box so whatever filesystem functions the user tries to use will be limited to that sandbox. I'm not sure how to go about this though or if it would bring down my server having several of these running.

想法?

推荐答案

我一直想知道如果拥有一个Cloud IDE,可以托管我所有的PHP文件,对其进行测试,共享等,那将是多么的好.能够做我在计算机上所做的所有事情.直到最近,我还是偶然发现了一个非常好的Cloud IDE,名为 Kodingen .它是如此有用,并且有时方便.但是,以下是一些提供运行PHP代码的服务的列表.

I always wondered how good it would be to have a Cloud IDE where i could host all my PHP files, test it, share it etc. basically it should be able to do everything which i do in my Computer. and until recently i stumbled upon a very nice Cloud IDE called Kodingen. it is such a useful Cloud Application and so handy at times. however below is the list of some of the services which offers you to run PHP code.

  • http://kodingen.com/
  • http://www.codr.cc/
  • http://www.chopapp.com/
  • http://www.amyeditor.com/
  • https://codeanywhere.net/
  • http://www.coderun.com/
  • http://shiftedit.net/

这篇关于如何安全执行用户提交的PHP代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆