Home > Backend Development > PHP Tutorial > php通用防注入程序 推荐_php技巧

php通用防注入程序 推荐_php技巧

WBOY
Release: 2016-05-17 09:21:03
Original
852 people have browsed it
复制代码 代码如下:

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
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template