Lets say a user submits
That input would need to change to$_POST['body'] wrote:Hi
Bye
Code: Select all
Hi<br>
<br>
ByeModerator: General Moderators
That input would need to change to$_POST['body'] wrote:Hi
Bye
Code: Select all
Hi<br>
<br>
ByeCode: Select all
nl2br()Code: Select all
stripslashes()Code: Select all
static public function antiMagicQuote()
{
if (get_magic_quotes_gpc()) {
$superStrip = create_function('&$toStrip', '$toStrip = stripslashes($toStrip)');
$_POST = array_walk_recursive($superStrip, $_POST);
$_GET = array_walk_recursive($superStrip, $_GET);
$_COOKIE = array_walk_recursive($superStrip, $_COOKIE);
}
}Code: Select all
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}
?>Code: Select all
static public function antiMagicQuote()
{
$superStrip = create_function('&$toStrip', '$toStrip = stripslashes($toStrip);');
array_walk_recursive($_POST, $superStrip);
array_walk_recursive($_GET, $superStrip);
array_walk_recursive($_COOKIE, $superStrip);
}Code: Select all
$_POST['foo'] = array('a' => '\"', 'b' => '\"');
$_POST['bar'] = '\"';
OF::antiMagicQuote();
$this->assertEqual($_POST['foo']['a'], '"');
$this->assertEqual($_POST['foo']['b'], '"');
$this->assertEqual($_POST['bar'], '"');