note 72665 deleted from function.htmlspecialchars by nlopess
| From: | nlopess@php.net | Date: | Tue, 30 Jan 2007 15:20:54 +0000 |
| Subject: | note 72665 deleted from function.htmlspecialchars by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-122358@lists.php.net to get a copy of this message | ||
Note Submitter: wildcats1369
----
I create this code to prevent Code Insertion in all of the forms i have created.
I hope it becomes useful.
<?
if(isset($_POST))
{
$_POST=strip_array($_POST);
}
if(isset($_GET))
{
$_GET=strip_array($_GET);
}
function strip_array($array) //recursively
{
foreach($array as $key=>$value)
{
if(is_array($value))
{
$ret[$key]=strip_array($value);
}else
{
$ret[$key]=addslashes(htmlspecialchars($value,ENT_QUOTES));
}
}
return $ret;
}
?>