note 103863 deleted from function.get-magic-quotes-gpc by danbrown
| From: | danbrown@php.net | Date: | Sat, 07 May 2011 14:16:04 +0000 |
| Subject: | note 103863 deleted from function.get-magic-quotes-gpc by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-179523@lists.php.net to get a copy of this message | ||
Note Submitter: Yousef Ismaeil
----
<?php
/**
* return to addslahes without any problems
*
* @param string the posts , gets and cookies ... etc values
* @autohr Yousef Ismaeil - cliprz AT gmail DOT com
*/
function magic_slashes ($string)
{
if (function_exists('get_magic_quotes_gpc'))
{
if (get_magic_quotes_gpc())
{
$result = $string;
}
else
{
if (function_exists('addslashes'))
{
$result = addslashes($string);
}
else
{
$result = mysql_real_escape_string($string);
}
}
}
return $result;
}
?>
other way to kill slashes from posts like bottom func
@Warning : bottom functions Have not been tested carefully .
<?php
/**
* return to remove magic quotes gpc slashes and addslashes from user
*
* @param string
* @autohr Yousef Ismaeil - cliprz AT gmail DOT com
*/
function kill_magic ($string)
{
// check magic_quotes_gpc if exists and its on
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc())
{
// magic_quotes will be stripslahes if striped addslashes from user not MG gpc
$result = stripslashes(addslashes($string));
}
else
{
if (function_exists('addslashes'))
{
$result = addslashes($string);
}
else
{
$result = mysql_real_escape_string($string);
}
}
return $result;
}
?>