<?php
/*
simpleQuizz made Quizzs simple
Copyright (C) 2008 Mathieu Lory <hide@address.com>
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 3 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, see <http://www.gnu.org/licenses/>.
*/
/**
* @package simpleQuizz
* @subpackage Server
* @author Mathieu Lory <hide@address.com>
*/
if (basename($_SERVER["SCRIPT_NAME"])==basename(__FILE__))die();
/**
* Call Server::Normalize();
*
* after session_start()
* Call Server::UnregisterGlobals('_SESSION');
*
*/
class Server
{
/**
* Unregister global variables if server has register_globals on
*
* UnregisterGlobals('_POST', '_GET', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES');
* //called after session_start()
* UnregisterGlobals('_SESSION');
* @access public
* @static
*/
public static function UnregisterGlobals()
{
if (!ini_get('register_globals'))
{
return false;
}
foreach (func_get_args() as $name)
{
foreach ($GLOBALS[$name] as $key=>$value)
{
if (isset($GLOBALS[$key]))
unset($GLOBALS[$key]);
}
}
}
/**
* Undo magic quotes if magic_quotes_gpc enabled
*
* @access private
* @static
*/
private static function UndoMagicQuotes()
{
if (!ini_get('register_globals')){
return false;
}
foreach (func_get_args() as $name)
{
foreach ($GLOBALS[$name] as $key=>$value)
{
if (isset($GLOBALS[$key]))
unset($GLOBALS[$key]);
}
}
}
/**
* Invokes class functions
*
* @access private
* @static
*/
public static function Normalize()
{
self::UnregisterGlobals('_POST', '_GET', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES');
self::UndoMagicQuotes();
}
}
?>