- added option to PMA_arrayWalkRecursive() to use function also on keys

- un-magic_quotes_gpc also keys in GPC arrays
This commit is contained in:
Sebastian Mendel
2006-04-12 16:41:27 +00:00
parent 41210b37a9
commit 2ce3cc1da9
2 changed files with 17 additions and 6 deletions

View File

@@ -6,6 +6,9 @@ $Id$
$Source$
2006-04-12 Sebastian Mendel <cybot_tm@users.sourceforge.net>
* libraries/common.lib.php:
- added option to PMA_arrayWalkRecursive() to use function also on keys
- un-magic_quotes_gpc also keys in GPC arrays
* libraries/db_table_exists.lib.php:
cleanup - what a mess; fixed several undefined variables
* tbl_printview.php:

View File

@@ -501,14 +501,22 @@ function PMA_array_merge_recursive()
* @param array $array array to walk
* @param string $function function to call for every array element
*/
function PMA_arrayWalkRecursive(&$array, $function)
function PMA_arrayWalkRecursive(&$array, $function, $apply_to_keys_also = false)
{
foreach ($array as $key => $value) {
if (is_array($value)) {
PMA_arrayWalkRecursive($array[$key], $function);
PMA_arrayWalkRecursive($array[$key], $function, $apply_to_keys_also);
} else {
$array[$key] = $function($value);
}
if ($apply_to_keys_also && is_string($key)) {
$new_key = $function($key);
if ($new_key != $key) {
$array[$new_key] = $array[$key];
unset($array[$key]);
}
}
}
}
@@ -2635,10 +2643,10 @@ if (isset($_POST['usesubform'])) {
// end check if a subform is submitted
if (get_magic_quotes_gpc()) {
PMA_arrayWalkRecursive($_GET, 'stripslashes');
PMA_arrayWalkRecursive($_POST, 'stripslashes');
PMA_arrayWalkRecursive($_COOKIE, 'stripslashes');
PMA_arrayWalkRecursive($_REQUEST, 'stripslashes');
PMA_arrayWalkRecursive($_GET, 'stripslashes', true);
PMA_arrayWalkRecursive($_POST, 'stripslashes', true);
PMA_arrayWalkRecursive($_COOKIE, 'stripslashes', true);
PMA_arrayWalkRecursive($_REQUEST, 'stripslashes', true);
}
require_once './libraries/session.inc.php';