Re: form cleaning class

From: Date: Tue, 22 Jan 2008 04:46:14 +0000
Subject: Re: form cleaning class
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-267814@lists.php.net to get a copy of this message
On Mon, 2008-01-21 at 23:39 -0500, nihilism machine wrote: > now my debug shows that with the following code, all of the > $_POST['whatever'] values are blank. > > > class forms { > > var $UserInput; > > // Forms to variables > function forms() { > if (count($_POST) > 0) { > foreach($_POST as $curPostKey => $curPostVal) { > $_POST[$curPostKey] = forms::CleanInput($curPostVal); > } > } > // Debug > print_r($_POST); > } > > // Clean XSS > function CleanInput($UserInput) { > $allowedtags = > > "<strong><em><a><ul><li><pre><hr><blockquote><img><span>"; > $notallowedattribs = array("@javascript:|onclick|ondblclick| > onmousedown|onmouseup" > ."|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown| > onkeyup@si"); > $changexssto = ''; > $UserInput = preg_replace($notallowedattribs, $changexssto, > $UserInput); > $UserInput = strip_tags($text, $allowedtags); I think $text should be $UserInput :) > $UserInput = nl2br($UserInput); > return $UserInput; > } > } Cheers, Rob. -- ........................................................... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ...........................................................

« previous php.general (#267814) next »