<?php
/*
***************************************************************************
* Function undo_magic_quotes_gpc(), used to remove unwanted slashes done  *
* by magic_quotes_gpc. Usefull if you don't have control on this.         *
* Copyright (C) 2004 The Celestial Celebi.                                *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the   *
* Free Software Foundation; either version 2 of the License, or (at your  *
* option) any later version.                                              *
* This program is distributed in the hope that it will be useful, but     *
* WITHOUT ANY WARRANTY; without even the implied warranty of              *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
* General Public License for more details.                                *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.               *
***************************************************************************
*/

/*
***************************************************************************
* @function: undo_magic_quotes_gpc(): (recursively) Removes unwanted      *
* slashes added by the magic_quotes_gpc-setting.                          *
* @param $mGetPostCookieVariable (mixed): The GPC-variable where you want *
*  to remove the slashes from. If this parameter isn't specified, the     *
*  function will automatically remove the slashes of all GPC-variables.   *
* @return mixed: Returns void if called without parameter and string or   *
*  array if called with parameter.                                        *
*-------------------------------------------------------------------------*
* @started on: 8 July 2004 at 20:00:40 by The Celestial Celebi.           *
* @last edited on: 12 August 2004 at 22:22:34 by The Celestial Celebi.    *
* @constructs used: else, if, return.                                     *
* @functions used: array_map, get_magic_quotes_gpc, stripslashes.         *
***************************************************************************
*/

function undo_magic_quotes_gpc($mGetPostCookieVariable = '')
{
	if($mGetPostCookieVariable == '' && get_magic_quotes_gpc() == 1)
	{
		$_GET = undo_magic_quotes_gpc($_GET);
		$_POST = undo_magic_quotes_gpc($_POST);
		$_COOKIE = undo_magic_quotes_gpc($_COOKIE);
		$_REQUEST = undo_magic_quotes_gpc($_REQUEST);
	}
	else
	{
		if(is_array($mGetPostCookieVariable))
		{
			return array_map('undo_magic_quotes_gpc', $mGetPostCookieVariable);
		}
		else
		{
			return stripslashes($mGetPostCookieVariable);
		}
	}
}
?>