summaryrefslogtreecommitdiff
path: root/inc/mod
diff options
context:
space:
mode:
authorctrlcctrlv <wizardchan@hush.com>2013-09-21 02:21:05 +0000
committerctrlcctrlv <wizardchan@hush.com>2013-09-21 02:21:05 +0000
commit0a58973631626879abeea4956b33cc2b56dea453 (patch)
tree21dfa7b4029193c3609b17dca3f0690318aa3c11 /inc/mod
parent5906af7dcd6ef1e824c14f51215cc55483e587c2 (diff)
Make it so that users can't insert code w/syntax errors into ?/config
Diffstat (limited to 'inc/mod')
-rw-r--r--inc/mod/pages.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/inc/mod/pages.php b/inc/mod/pages.php
index 3d1fd41a..40d5e395 100644
--- a/inc/mod/pages.php
+++ b/inc/mod/pages.php
@@ -2106,9 +2106,18 @@ function mod_config($board_config = false) {
if (!$readonly && isset($_POST['code'])) {
$code = $_POST['code'];
+ // Save previous instance_config if php_check_syntax fails
+ $old_code = file_get_contents($config_file);
file_put_contents($config_file, $code);
- header('Location: ?/config' . ($board_config ? '/' . $board_config : ''), true, $config['redirect_http']);
- return;
+ $resp = shell_exec_error('php -l ' . $config_file);
+ if (preg_match('/No syntax errors detected/', $resp)) {
+ header('Location: ?/config' . ($board_config ? '/' . $board_config : ''), true, $config['redirect_http']);
+ return;
+ }
+ else {
+ file_put_contents($config_file, $old_code);
+ error($config['error']['badsyntax'] . $resp);
+ }
}
$instance_config = @file_get_contents($config_file);