functions.compat.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /* $Id: functions.compat.php 1488 2006-11-04 20:59:50Z b4rt $ */
  3. /*******************************************************************************
  4. LICENSE
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License (GPL)
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. To read the license please visit http://www.gnu.org/copyleft/gpl.html
  14. *******************************************************************************/
  15. /**
  16. * unregister_GLOBALS
  17. *
  18. * function is taken from :
  19. * http://php.net/manual/pl/faq.misc.php#faq.misc.registerglobals
  20. *
  21. */
  22. function unregister_GLOBALS() {
  23. // Might want to change this perhaps to a nicer error
  24. if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS']))
  25. die('GLOBALS overwrite attempt detected');
  26. // Variables that shouldn't be unset
  27. $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES');
  28. $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES,
  29. isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
  30. foreach ($input as $k => $v) {
  31. if (!in_array($k, $noUnset) && isset($GLOBALS[$k]))
  32. unset($GLOBALS[$k]);
  33. }
  34. }
  35. ?>