login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Handige scripts > undo_magic_quotes_gpc()

undo_magic_quotes_gpc()

Auteur: CelestialCelebi - 01 september 2004 - 19:30 - Gekeurd door: Dennisvb - Hits: 2166 - Aantal punten: 2.67 (3 stemmen)



Nou eh, zie uitleg maar weer.. Deze haalt alle slashes die magic_quotes_gpc toevoegt, weg. Één keer aanroepen kan je doen, dan ben je er vanaf.. Maar je kunt hem ook aanroepen met alleen $_POST of alleen $_GET.. Of wat jij wilt.
En hij doet dit alleen als magic_quotes_gpc() ook echt aan staat.

Bijv. zo:
  1. <?php
  2. undo_magic_quotes_gpc(); // alles weg, indien het aan staat
  3. ?>


Of zo:
  1. <?php
  2. undo_magic_quotes_gpc($_GET); // haalt alle slashes van $_GET weg, indien het aan staat
  3. ?>


Etc.

Code:
  1. <?php
  2. /*
  3. ***************************************************************************
  4. * Function undo_magic_quotes_gpc(), used to remove unwanted slashes done *
  5. * by magic_quotes_gpc. Usefull if you don't have control on this. *
  6. * Copyright (C) 2004 The Celestial Celebi. *
  7. * This program is free software; you can redistribute it and/or modify it *
  8. * under the terms of the GNU General Public License as published by the *
  9. * Free Software Foundation; either version 2 of the License, or (at your *
  10. * option) any later version. *
  11. * This program is distributed in the hope that it will be useful, but *
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of *
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
  14. * General Public License for more details. *
  15. * You should have received a copy of the GNU General Public License along *
  16. * with this program; if not, write to the Free Software Foundation, Inc., *
  17. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  18. ***************************************************************************
  19. */
  20.  
  21. /*
  22. ***************************************************************************
  23. * @function: undo_magic_quotes_gpc(): (recursively) Removes unwanted *
  24. * slashes added by the magic_quotes_gpc-setting. *
  25. * @param $mGetPostCookieVariable (mixed): The GPC-variable where you want *
  26. * to remove the slashes from. If this parameter isn't specified, the *
  27. * function will automatically remove the slashes of all GPC-variables. *
  28. * @return mixed: Returns void if called without parameter and string or *
  29. * array if called with parameter. *
  30. *-------------------------------------------------------------------------*
  31. * @started on: 8 July 2004 at 20:00:40 by The Celestial Celebi. *
  32. * @last edited on: 12 August 2004 at 22:22:34 by The Celestial Celebi. *
  33. * @constructs used: else, if, return. *
  34. * @functions used: array_map, get_magic_quotes_gpc, stripslashes. *
  35. ***************************************************************************
  36. */
  37.  
  38. function undo_magic_quotes_gpc($mGetPostCookieVariable = '')
  39. {
  40. if($mGetPostCookieVariable == '' && get_magic_quotes_gpc() == 1)
  41. {
  42. $_GET = undo_magic_quotes_gpc($_GET);
  43. $_POST = undo_magic_quotes_gpc($_POST);
  44. $_COOKIE = undo_magic_quotes_gpc($_COOKIE);
  45. $_REQUEST = undo_magic_quotes_gpc($_REQUEST);
  46. }
  47. else
  48. {
  49. if(is_array($mGetPostCookieVariable))
  50. {
  51. return array_map('undo_magic_quotes_gpc', $mGetPostCookieVariable);
  52. }
  53. else
  54. {
  55. return stripslashes($mGetPostCookieVariable);
  56. }
  57. }
  58. }
  59. ?>
Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (1)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.039s