php sql语句过滤,php如何做sql过滤
php如何做sql過(guò)濾
SQL注入攻擊指的是通過(guò)構(gòu)建特殊的輸入作為參數(shù)傳入Web應(yīng)用程序,而這些輸入大都是SQL語(yǔ)法里的一些組合,通過(guò)執(zhí)行SQL語(yǔ)句進(jìn)而執(zhí)行攻擊者所要的操作,其主要原因是程序沒(méi)有細(xì)致地過(guò)濾用戶輸入的數(shù)據(jù),致使非法數(shù)據(jù)侵入系統(tǒng)。因此,在執(zhí)行sql語(yǔ)句前,一定要對(duì)用戶輸入的數(shù)據(jù)進(jìn)行過(guò)濾處理。
防止sql注入的函數(shù),過(guò)濾掉那些非法的字符,提高sql安全性,同時(shí)也可以過(guò)濾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("
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的php sql语句过滤,php如何做sql过滤的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: word电子签名工具_电子签名是您不会想
- 下一篇: graphpad7.04多组比较p值_同