I have created a php editor using file function, where users can run code online and get result on the same page.
executephp5.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 is the target file it is updated by the form.
This all works as expected. My problem is that I want to disable all file, directory, mail() and ftp functions for this editor so that users can not crash the site.
Is there any way to disable those functions only for my editor?