From f9297794b644dc58d392932c5494e3e22a10b0fd Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 15 Sep 2006 14:08:48 +0000 Subject: implement bare-bone validation for config variables... git-svn-id: file:///svn/phpbb/trunk@6367 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/index.php | 78 +++++++++++++++++++++++++++++++++++++++++ phpBB/adm/style/acp_board.html | 7 ++++ phpBB/adm/style/acp_forums.html | 16 ++++----- 3 files changed, 93 insertions(+), 8 deletions(-) (limited to 'phpBB/adm') diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php index e84e1c5e36..5576098cef 100644 --- a/phpBB/adm/index.php +++ b/phpBB/adm/index.php @@ -376,4 +376,82 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars) return $tpl; } +/** +* Going through a config array and validate values, writing errors to $error. +*/ +function validate_config_vars($config_vars, &$cfg_array, &$error) +{ + global $phpbb_root_path, $user; + + foreach ($config_vars as $config_name => $config_definition) + { + if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) + { + continue; + } + + if (!isset($config_definition['validate'])) + { + continue; + } + + // Validate a bit. ;) String is already checked through request_var(), therefore we do not check this again + switch ($config_definition['validate']) + { + case 'bool': + $cfg_array[$config_name] = ($cfg_array[$config_name]) ? 1 : 0; + break; + + case 'int': + $cfg_array[$config_name] = (int) $cfg_array[$config_name]; + break; + + case 'rpath': + if (!$cfg_array[$config_name]) + { + break; + } + + $destination = $cfg_array[$config_name]; + + // Adjust destination path (no trailing slash) + if ($destination{(sizeof($destination)-1)} == '/' || $destination{(sizeof($destination)-1)} == '\\') + { + $destination = substr($destination, 0, sizeof($destination)-2); + } + + $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination); + if ($destination && ($destination{0} == '/' || $destination{0} == "\\")) + { + $destination = ''; + } + + $cfg_array[$config_name] = $destination; + + case 'path': + + if (!$cfg_array[$config_name]) + { + break; + } + + $cfg_array[$config_name] = trim($cfg_array[$config_name]); + + if (!file_exists($phpbb_root_path . $cfg_array[$config_name])) + { + $error[] = sprintf($user->lang['DIRECTORY_DOES_NOT_EXIST'], $cfg_array[$config_name]); + } + + if (file_exists($phpbb_root_path . $cfg_array[$config_name]) && !is_dir($phpbb_root_path . $cfg_array[$config_name])) + { + $error[] = sprintf($user->lang['DIRECTORY_NOT_DIR'], $cfg_array[$config_name]); + } + + break; + } + } + + return; +} + ?> \ No newline at end of file diff --git a/phpBB/adm/style/acp_board.html b/phpBB/adm/style/acp_board.html index 02cb055a74..dd29017cb1 100644 --- a/phpBB/adm/style/acp_board.html +++ b/phpBB/adm/style/acp_board.html @@ -6,6 +6,13 @@

{L_TITLE_EXPLAIN}

+ +
+

{L_WARNING}

+

{ERROR_MSG}

+
+ +
diff --git a/phpBB/adm/style/acp_forums.html b/phpBB/adm/style/acp_forums.html index 24febd120d..9b203023d4 100644 --- a/phpBB/adm/style/acp_forums.html +++ b/phpBB/adm/style/acp_forums.html @@ -96,6 +96,14 @@
{L_FORUM_IMAGE}
+
+

{L_FORUM_PASSWORD_EXPLAIN}
+
+
+
+

{L_FORUM_PASSWORD_CONFIRM_EXPLAIN}
+
+
@@ -149,14 +157,6 @@

{L_FORUM_TOPICS_PAGE_EXPLAIN}
-
-

{L_FORUM_PASSWORD_EXPLAIN}
-
-
-
-

{L_FORUM_PASSWORD_CONFIRM_EXPLAIN}
-
-
-- cgit v1.2.1