/** * Called when request iterated. * @return integer Status. */ public function run() { $stime = microtime(true); $this->header('Content-Type: text/html'); $sandbox = new \Runkit_Sandbox(['safe_mode' => true, 'open_basedir' => '/var/www/users/jdoe/', 'allow_url_fopen' => 'false', 'disable_functions' => 'exec,shell_exec,passthru,system', 'disable_classes' => '', 'output_handler' => [$this, 'out']]); $sandbox->ini_set('html_errors', true); $sandbox->call_user_func(function () { echo "Hello World!"; }); }
function replaceFills($string) { //get all basic variablenames and set the as global; $globalsStr = getVariablesAsGlobal($string); //get fills preg_match_all('/\\^\\s*(.*?)\\s*\\^/si', $string, $matches); if (isset($matches[1])) { if (class_exists('Runkit_Sandbox')) { //save eval! $options = array('safe_mode' => true, 'open_basedir' => '/var/www/users/jdoe/', 'allow_url_fopen' => 'false', 'disable_functions' => 'exec,shell_exec,passthru,system', 'disable_classes' => 'myAppClass'); $sandbox = new Runkit_Sandbox($options); $sandbox->ini_set('html_errors', true); } global $survey; foreach ($matches[1] as $match) { $value = isset($sandbox) ? $sandbox->eval($globalsStr . 'return ' . $match . ';') : eval($globalsStr . 'return ' . $match . ';'); $string = str_replace('^' . $match . '^', $value, $string); } } return $string; }