復制代碼 代碼如下:
function jk1986_checksql()
{
$bad_str = "and|select|update|'|delete|insert|*";
$bad_Array = explode("|",$bad_str);
/** 過濾Get參數 **/
foreach ($bad_Array as $bad_a)
{
foreach ($_GET as $g)
{
if (substr_count(strtolower($g),$bad_a) > 0)
{
echo "<script>alert('詭異字符,請不要嘗試注入本站! 作者:Jk1986 QQ:414028660');location.href='index.php';</script>";
exit();
}
}
}
/** 過濾Post參數 **/
foreach ($bad_Array as $bad_a)
{
foreach ($_POST as $p)
{
if (substr_count(strtolower($p),$bad_a) > 0)
{
echo "<script>alert('詭異字符,請不要嘗試注入本站! 作者:Jk1986 QQ:414028660');location.href='index.php';</script>";
exit();
}
}
}
/** 過濾Cookies參數 **/
foreach ($bad_Array as $bad_a)
{
foreach ($_COOKIE as $co)
{
if (substr_count(strtolower($co),$bad_a) > 0)
{
echo "<script>alert('詭異字符,請不要嘗試注入本站! 作者:Jk1986 QQ:414028660');location.href='index.php';</script>";
exit();
}
}
}
}
呵呵 類似asp和asp.net 思路一樣,目的就是讓懶來提高效率 .88