From 88f814a5c57246250a82ad53d43f8f90da5afb60 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 4 Nov 2003 21:54:40 +0000 Subject: [PATCH] request_var update to support 2-dimensional arrays. git-svn-id: file:///svn/phpbb/trunk@4636 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 44 ++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 70d6f014f0..a1e5ee4e8d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -12,6 +12,23 @@ // ------------------------------------------------------------- +function set_var(&$result, $var, $type) +{ + settype($var, $type); + $result = $var; + + if ($type == 'string') + { + // Prevent use of  , excess spaces or other html entity forms in profile strings, + // not generally applicable elsewhere + $result = htmlspecialchars(trim(preg_replace(array("#[ \xFF]{2,}#s", "#[\r\n]{2,}#s"), array(' ', "\n"), $result))); + if (STRIP) + { + $result = stripslashes($result); + } + } +} + function request_var($var_name, $default) { if (!isset($_REQUEST[$var_name])) @@ -27,33 +44,22 @@ function request_var($var_name, $default) { foreach ($var as $k => $v) { - settype($v, $type); - $var[$k] = $v; - - if ($type == 'string') + if (is_array($v)) { - $var[$k] = htmlspecialchars(trim(preg_replace(array("#[ \xFF]{2,}#s", "#[\r\n]{2,}#s"), array(' ', "\n"), $var[$k]))); - if (STRIP) + foreach ($v as $_k => $_v) { - $var[$k] = stripslashes($var[$k]); + set_var($var[$k][$_k], $_v, $type); } } + else + { + set_var($var[$k], $v, $type); + } } } else { - settype($var, $type); - - // Prevent use of  , excess spaces or other html entity forms in profile strings, - // not generally applicable elsewhere - if ($type == 'string') - { - $var = htmlspecialchars(trim(preg_replace(array("#[ \xFF]{2,}#s", "#[\r\n]{2,}#s"), array(' ', "\n"), $var))); - if (STRIP) - { - $var = stripslashes($var); - } - } + set_var($var, $var, $type); } return $var;