protected function compile($text, $sandbox = false)
{
// disable php in sandbox mode
if ($sandbox) {
$text = str_replace(array("<?", "?>"), array("<?", "?>"), $text);
}
foreach ($this->compilers as $compiler) {
$method = "compile_{$compiler}";
$text = $this->{$method}($text);
}
if ($sandbox) {
$lines = explode("\n", $text);
foreach ($lines as $ln => &$line) {
if ($errors = $this->check_security($line)) {
return 'illegal call(s): ' . implode(", ", $errors) . " - on line " . $ln . ($this->srcinfo ? ' (' . $this->srcinfo . ') ' : '');
}
}
}
if ($errors = $this->check_syntax($text)) {
if ($this->srcinfo) {
$errors[] = '(' . $this->srcinfo . ')';
}
return implode("\n", $errors);
}
return $text;
}