title: How to secure php online editor in php?
body: <p>I have created a php editor using file function, where users can run code online and get result on the same page.</p>
  
  <p>executephp5.php</p>
  
  <pre><code>&lt;form action="&lt;?php echo $_SERVER['PHP_SELF'];?&gt;"method="post"&gt;
    &lt;b&gt;Write your code here&lt;/b&gt;
    &lt;textarea name="code"&gt;&lt;/textarea&gt;
    &lt;input type="submit"value="Run code"&gt;
  &lt;/form&gt;
  &lt;?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);
  }
  ?&gt;
  
  &lt;b&gt;Results:&lt;/b&gt;
  &lt;hr&gt;
  &lt;?php
    error_reporting(E_ALL);
    include "demo.php";
  ?&gt;
  </code></pre>
  
  <p>demo.php is the target file it is updated by the form.</p>
  
  <p>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. </p>
  
  <p>Is there any way to disable those functions only for my editor?</p>