Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / libraries / cleanup.lib.php
blob1fdfe35c5022f61e308e01892ee6efa3d1987952
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Functions for cleanup of user input.
6 * @package PhpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 /**
13 * Removes all variables from request except whitelisted ones.
15 * @param string &$whitelist list of variables to allow
17 * @return void
18 * @access public
20 function PMA_remove_request_vars(&$whitelist)
22 // do not check only $_REQUEST because it could have been overwritten
23 // and use type casting because the variables could have become
24 // strings
25 $keys = array_keys(
26 array_merge((array)$_REQUEST, (array)$_GET, (array)$_POST, (array)$_COOKIE)
29 foreach ($keys as $key) {
30 if (! in_array($key, $whitelist)) {
31 unset($_REQUEST[$key], $_GET[$key], $_POST[$key], $GLOBALS[$key]);
32 } else {
33 // allowed stuff could be compromised so escape it
34 // we require it to be a string
35 if (isset($_REQUEST[$key]) && ! is_string($_REQUEST[$key])) {
36 unset($_REQUEST[$key]);
38 if (isset($_POST[$key]) && ! is_string($_POST[$key])) {
39 unset($_POST[$key]);
41 if (isset($_COOKIE[$key]) && ! is_string($_COOKIE[$key])) {
42 unset($_COOKIE[$key]);
44 if (isset($_GET[$key]) && ! is_string($_GET[$key])) {
45 unset($_GET[$key]);