Re: sanitizing get vars

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/2/05, Sebastian <sebastian@xxxxxxxxxxxxxxxxxxx> wrote:
> what is a safe way to clean a post/get before echoing it.
> example. input form, user enters some text, hits enter.

set_magic_quotes_runtime( 0 );

if( get_magic_quotes_gpc() == 0 )
{
   $_GET    = isset( $_GET )    ? array_map( 'slashes', $_GET )     : array();
   $_POST   = isset( $_POST )   ? array_map( 'slashes', $_POST )    : array();
   $_COOKIE = isset( $_COOKIE ) ? array_map( 'slashes', $_COOKIE )  : array();
}

function slashes( $var )
{
    if( is_array( $var ) )
    {
		return array_map( 'slashes', $var );
    }
	
    return addslashes( $var );
}


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux