List Info

Thread: note 78061 added to function.preg-match




note 78061 added to function.preg-match
user name
2007-09-26 05:22:58
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",$nte
xt)){
  $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  -- h
ttps://master.php.net/note/delete/78061/integrated
Del: useless     -- http
s://master.php.net/note/delete/78061/useless
Del: bad code    -- htt
ps://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     -- http
s://master.php.net/note/delete/78061/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/78061
Reject      -- https://mast
er.php.net/note/reject/78061
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )