php sql语句过滤,php如何做sql过滤
php如何做sql過濾
SQL注入攻擊指的是通過構建特殊的輸入作為參數傳入Web應用程序,而這些輸入大都是SQL語法里的一些組合,通過執行SQL語句進而執行攻擊者所要的操作,其主要原因是程序沒有細致地過濾用戶輸入的數據,致使非法數據侵入系統。因此,在執行sql語句前,一定要對用戶輸入的數據進行過濾處理。
防止sql注入的函數,過濾掉那些非法的字符,提高sql安全性,同時也可以過濾XSS的攻擊。function filter($str)
{
if (empty($str)) return false;
$str = htmlspecialchars($str);
$str = str_replace( '/', "", $str);
$str = str_replace( '"', "", $str);
$str = str_replace( '(', "", $str);
$str = str_replace( ')', "", $str);
$str = str_replace( 'CR', "", $str);
$str = str_replace( 'ASCII', "", $str);
$str = str_replace( 'ASCII 0x0d', "", $str);
$str = str_replace( 'LF', "", $str);
$str = str_replace( 'ASCII 0x0a', "", $str);
$str = str_replace( ',', "", $str);
$str = str_replace( '%', "", $str);
$str = str_replace( ';', "", $str);
$str = str_replace( 'eval', "", $str);
$str = str_replace( 'open', "", $str);
$str = str_replace( 'sysopen', "", $str);
$str = str_replace( 'system', "", $str);
$str = str_replace( '$', "", $str);
$str = str_replace( "'", "", $str);
$str = str_replace( "'", "", $str);
$str = str_replace( 'ASCII 0x08', "", $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_replace("", "", $str);
$str = str_replace("
$str = str_replace("", "", $str);
$str = str_replace("select","",$str);
$str = str_replace("join","",$str);
$str = str_replace("union","",$str);
$str = str_replace("where","",$str);
$str = str_replace("insert","",$str);
$str = str_replace("delete","",$str);
$str = str_replace("update","",$str);
$str = str_replace("like","",$str);
$str = str_replace("drop","",$str);
$str = str_replace("DROP","",$str);
$str = str_replace("create","",$str);
$str = str_replace("modify","",$str);
$str = str_replace("rename","",$str);
$str = str_replace("alter","",$str);
$str = str_replace("cas","",$str);
$str = str_replace("&","",$str);
$str = str_replace(">","",$str);
$str = str_replace("
$str = str_replace(" ",chr(32),$str);
$str = str_replace(" ",chr(9),$str);
$str = str_replace(" ",chr(9),$str);
$str = str_replace("&",chr(34),$str);
$str = str_replace("'",chr(39),$str);
$str = str_replace("
",chr(13),$str);
$str = str_replace("''","'",$str);
$str = str_replace("css","'",$str);
$str = str_replace("CSS","'",$str);
$str = str_replace("
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的php sql语句过滤,php如何做sql过滤的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: word电子签名工具_电子签名是您不会想
- 下一篇: graphpad7.04多组比较p值_同