note 78061 deleted from function.preg-match by felipe

From: Date: Sun, 23 Mar 2008 22:55:31 +0000
Subject: note 78061 deleted from function.preg-match by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-137373@lists.php.net to get a copy of this message
Note Submitter: Adlez ---- Quick function to filter input. Filters any javascript, html, sql injections, and RFI. <?php function entities($text){ $text = ""; for ( $i = 0; $i <= strlen($text) - 1; $i += 1) { $text .= "&#" .ord($text{$i}); } return $eresult; } function filter($text){ if (preg_match("#(on(.*?)\=|script|xmlns|expression| javascript|\>|\<|http)#si","$text",$ntext)){ $re = entities($ntext[1]); $text = str_replace($ntext[0],$re,$text); } $text = mysql_real_escape_string($text); return $text; } foreach ($_POST as $x => $y){ $_POST[$x] = filter($y); } foreach ($_GET as $x => $y){ $_GET[$x] = filter($y); } foreach ($_COOKIE as $x => $y){ $_COOKIE[$x] = filter($y); } ?>

« previous php.notes (#137373) next »