Фильтр SqlInj и XSS
Код:
function sql_xss_filt($str){
$str = strtolower($str);
$str = str_replace("*","",$str);
$str = str_replace("/","",$str);
$str = str_replace("\\","",$str);
$str = str_replace("+","",$str);
$str = str_replace("-","",$str);
$str = str_replace("(","",$str);
$str = str_replace(")","",$str);
$str = str_replace("<","",$str);
$str = str_replace(">","",$str);
$str = str_replace("%2a","",$str);
$str = str_replace("%2f","",$str);
$str = str_replace("%5c","",$str);
$str = str_replace("%2b","",$str);
$str = str_replace("%2d","",$str);
$str = str_replace("%28","",$str);
$str = str_replace("%29","",$str);
$str = str_replace("%3c","",$str);
$str = str_replace("%3e","",$str);
$str = str_replace("union","",$str);
$str = str_replace("select","",$str);
$str = str_replace("or","",$str);
$str = str_replace("and","",$str);
$str = str_replace("char","",$str);
$str = str_replace("order","",$str);
$str = str_replace("by","",$str);
$str = str_replace("%75%6e%69%6f%6e","",$str);
$str = str_replace("%73%65%6c%65%63%74","",$str);
$str = str_replace("%6f%72","",$str);
$str = str_replace("%61%6e%64","",$str);
$str = str_replace("%63%68%61%72","",$str);
$str = str_replace("%6f%72%64%65%72","",$str);
$str = str_replace("%62%79","",$str);
$str = str_replace("%25","",$str);
$str = str_replace("%","",$str);
return $str;
}
$str = strtolower($str);
$str = str_replace("*","",$str);
$str = str_replace("/","",$str);
$str = str_replace("\\","",$str);
$str = str_replace("+","",$str);
$str = str_replace("-","",$str);
$str = str_replace("(","",$str);
$str = str_replace(")","",$str);
$str = str_replace("<","",$str);
$str = str_replace(">","",$str);
$str = str_replace("%2a","",$str);
$str = str_replace("%2f","",$str);
$str = str_replace("%5c","",$str);
$str = str_replace("%2b","",$str);
$str = str_replace("%2d","",$str);
$str = str_replace("%28","",$str);
$str = str_replace("%29","",$str);
$str = str_replace("%3c","",$str);
$str = str_replace("%3e","",$str);
$str = str_replace("union","",$str);
$str = str_replace("select","",$str);
$str = str_replace("or","",$str);
$str = str_replace("and","",$str);
$str = str_replace("char","",$str);
$str = str_replace("order","",$str);
$str = str_replace("by","",$str);
$str = str_replace("%75%6e%69%6f%6e","",$str);
$str = str_replace("%73%65%6c%65%63%74","",$str);
$str = str_replace("%6f%72","",$str);
$str = str_replace("%61%6e%64","",$str);
$str = str_replace("%63%68%61%72","",$str);
$str = str_replace("%6f%72%64%65%72","",$str);
$str = str_replace("%62%79","",$str);
$str = str_replace("%25","",$str);
$str = str_replace("%","",$str);
return $str;
}
А во-вторых, ваша функция вообще не нужна:
От инъекций
http://ru2.php.net/manual/en/function.mysql-real-escape-string.php
От XSS
http://ru2.php.net/manual/en/function.htmlspecialchars.php