我使用file函数创建了一个php编辑器,用户可以在其中在线运行代码并在同一页面上获得结果。
executehp5.php
<form action="<?php echo $_SERVER['PHP_SELF'];?>"method="post">
<b>Write your code here</b>
<textarea name="code"></textarea>
<input type="submit"value="Run code">
</form>
<?php
$cd=stripslashes($_POST['code']);
#dont write empty textarea
if(empty($cd)) {
echo "";
} else {
$file=fopen("demo.php","w");
echo fwrite($file, $cd);
fclose($file);
}
?>
<b>Results:</b>
<hr>
<?php
error_reporting(E_ALL);
include "demo.php";
?>
demo.php是目标文件,它由表单.更新
这一切都如预期的那样。我的问题是,我想禁用这个编辑器的所有文件、目录、邮件()和ftp功能,这样用户就不会崩溃网站。
有没有办法只为我的编辑器禁用这些功能?
您可以传入disable_functions,即"在沙箱子解释器中要禁用的函数的逗号分隔列表。"
选中Runkit_Andbox。您应该使编辑器可用作沙箱。