note 78061 added to function.preg-match

From: Date: Wed, 26 Sep 2007 10:22:58 +0000
Subject: note 78061 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-130796@lists.php.net to get a copy of this message
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); } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 64.195.83.210 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match.php Edit -- https://master.php.net/note/edit/78061 Del: integrated -- https://master.php.net/note/delete/78061/integrated Del: useless -- https://master.php.net/note/delete/78061/useless Del: bad code -- https://master.php.net/note/delete/78061/bad+code Del: spam -- https://master.php.net/note/delete/78061/spam Del: non-english -- https://master.php.net/note/delete/78061/non-english Del: in docs -- https://master.php.net/note/delete/78061/in+docs Del: other reasons-- https://master.php.net/note/delete/78061 Reject -- https://master.php.net/note/reject/78061 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#130796) next »