home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / phpMyAdmin / libraries / cleanup.lib.php < prev    next >
Encoding:
PHP Script  |  2008-06-23  |  1.4 KB  |  46 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  * Functions for cleanup of user input.
  5.  *
  6.  * @version $Id: cleanup.lib.php 10723 2007-10-05 09:46:30Z cybot_tm $
  7.  */
  8.  
  9. /**
  10.  * Removes all variables from request except whitelisted ones.
  11.  *
  12.  * @param string list of variables to allow
  13.  * @return nothing
  14.  * @access public
  15.  * @author  Michal Cihar (michal@cihar.com)
  16.  */
  17. function PMA_remove_request_vars(&$whitelist)
  18. {
  19.     // do not check only $_REQUEST because it could have been overwritten
  20.     // and use type casting because the variables could have become
  21.     // strings
  22.     $keys = array_keys(array_merge((array)$_REQUEST, (array)$_GET, (array)$_POST, (array)$_COOKIE));
  23.  
  24.     foreach($keys as $key) {
  25.         if (! in_array($key, $whitelist)) {
  26.             unset($_REQUEST[$key], $_GET[$key], $_POST[$key], $GLOBALS[$key]);
  27.         } else {
  28.             // allowed stuff could be compromised so escape it
  29.             // we require it to be a string
  30.             if (isset($_REQUEST[$key]) && ! is_string($_REQUEST[$key])) {
  31.                 unset($_REQUEST[$key]);
  32.             }
  33.             if (isset($_POST[$key]) && ! is_string($_POST[$key])) {
  34.                 unset($_POST[$key]);
  35.             }
  36.             if (isset($_COOKIE[$key]) && ! is_string($_COOKIE[$key])) {
  37.                 unset($_COOKIE[$key]);
  38.             }
  39.             if (isset($_GET[$key]) && ! is_string($_GET[$key])) {
  40.                 unset($_GET[$key]);
  41.             }
  42.         }
  43.     }
  44. }
  45. ?>
  46.