aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--plugins/LocalFilesEditor/functions.inc.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/plugins/LocalFilesEditor/functions.inc.php b/plugins/LocalFilesEditor/functions.inc.php
index 63162d5d4..97813dce0 100644
--- a/plugins/LocalFilesEditor/functions.inc.php
+++ b/plugins/LocalFilesEditor/functions.inc.php
@@ -30,9 +30,22 @@
function eval_syntax($code)
{
$code = str_replace(array('<?php', '?>'), '', $code);
- if (!@eval('return true;' . $code))
+ if (function_exists('token_get_all'))
{
- return false;
+ $b = 0;
+ foreach (token_get_all($code) as $token)
+ {
+ if ('{' == $token) ++$b;
+ else if ('}' == $token) --$b;
+ }
+ if ($b) return false;
+ else
+ {
+ ob_start();
+ $eval = eval('if(0){' . $code . '}');
+ ob_end_clean();
+ if ($eval === false) return false;
+ }
}
return '<?php' . $code . '?>';
}