<?php

/**-----------------------------------------------
*
* Rooty, 2018 <rooty@rooty.me>
*
*
* This software is protected by copyright, please
* read the file COPYRIGHT.
* 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. Please
* read the file LICENCE.
*
* Fichier MagicQuoteGpc.php
*
* Ce fichier contient la classe MagicQuoteGpc
*<BR>
* @author Initiance <www.initiance.com|martial@initiance.com>
* @copyright Copyright &copy; 2009-2018, Rooty 
* @since 2004/06/07
* @version 0.3
* @link www.rooty.me
* @package object_plugin
* @subpackage MagicQuoteGpc 
*/

if ( !defined('SYSTEM_IN') )
{
 die("Hacking attempt");
}

/**
* Classe MagicQuoteGPC
*<p>Cette classe permet la recuperation de les MagicQuoteGPC</p>
* @package object_plugin
* @subpackage MagicQuoteGpc 
*/
class MagicQuoteGpc extends Plugin
{
	//
	// Constructor
	//

/**
* Constructeur de la classe Plugin
* @access public
*/
	function MagicQuoteGPC()
	{
		$this->__construct();
	}

	function __construct()
	{
		parent::__construct("1.0", "Olivier DEVAINE", "gestion des addslashes pour toutes les variables récupérées");
	}

/**
* __beforeSessionStart : methode executée avant que la session commence
*permet de gérer les "addslashes" à toutes les variables récupérés...
* @access public
* @return booleen
*/
	function __beforeSessionStart()
	{
		if( !get_magic_quotes_runtime() && !get_magic_quotes_gpc() )
		{
			if( is_array($_GET) )
			{
				while( list($k, $v) = each($_GET) )
				{
					if( is_array($_GET[$k]) )
					{
						while( list($k2, $v2) = each($_GET[$k]) )
						{
							$_GET[$k][$k2] = addslashes($v2);
						}
					@reset($_GET[$k]);
					}
					else
					{
						$_GET[$k] = addslashes($v);
					}
				}
				@reset($_GET);
			}

			if( is_array($_POST) )
			{
				while( list($k, $v) = each($_POST) )
				{
					//echo "<br>".$k;
					if( is_array($_POST[$k]) )
					{
						while( list($k2, $v2) = each($_POST[$k]) )
						{
							$_POST[$k][$k2] = addslashes($v2);
						}
					@reset($_POST[$k]);
					}
					else
					{
						$_POST[$k] = addslashes($v);
						//$_POST[substr($k, 4, (strlen($k)))] = addslashes($v);
						//$_POST[$k] = "";
					}
				}
				@reset($_POST);
			}

			if( is_array($_COOKIE) )
			{
				while( list($k, $v) = each($_COOKIE) )
				{
					if( is_array($_COOKIE[$k]) )
					{
						while( list($k2, $v2) = each($_COOKIE[$k]) )
						{
							$_COOKIE[$k][$k2] = addslashes($v2);
						}
					@reset($_COOKIE[$k]);
					}
					else
					{
						$_COOKIE[$k] = addslashes($v);
					}
				}
				@reset($_COOKIE);
			}
		}
		return true;
	}
}
?>