Removing old documentation
[openemr.git] / phpmyadmin / libraries / cleanup.lib.php
blob8db63cb56e64f3534801bdcedef4e0f659251201
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_removeRequestVars(&$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 continue;
35 // allowed stuff could be compromised so escape it
36 // we require it to be a string
37 if (isset($_REQUEST[$key]) && ! is_string($_REQUEST[$key])) {
38 unset($_REQUEST[$key]);
40 if (isset($_POST[$key]) && ! is_string($_POST[$key])) {
41 unset($_POST[$key]);
43 if (isset($_COOKIE[$key]) && ! is_string($_COOKIE[$key])) {
44 unset($_COOKIE[$key]);
46 if (isset($_GET[$key]) && ! is_string($_GET[$key])) {
47 unset($_GET[$key]);