See http://www.bkjia.com/article/200511/7117.htmlfor details.
Today, the entire php project has been completed, and many security issues have been raised. during the development process, parameters are not filtered out. Therefore, the following anti-injection program is indispensable for injection.
Function jk1986_checksql ()
{
$ Bad_str = "andselectupdatedeleteinsert *";
$ Bad_Array = explode ("", $ bad_str );
/** Filter Get parameters **/
Foreach ($ bad_Array as $ bad_a)
{
Foreach ($ _ GET as $ g)
{
If (substr_count (strtolower ($ g), $ bad_a)> 0)
{
Echo "<script> alert (Strange character, please do not try to inject this site! Author: Jk1986 QQ: 414028660); location. href = index. php; </script> ";
Exit ();
}
}
}
/** Filter Post parameters **/
Foreach ($ bad_Array as $ bad_a)
{
Foreach ($ _ POST as $ p)
{
If (substr_count (strtolower ($ p), $ bad_a)> 0)
{
Echo "<script> alert (Strange character, please do not try to inject this site! Author: Jk1986 QQ: 414028660); location. href = index. php; </script> ";
Exit ();
}
}
}
/** Filter cookie parameters **/
Foreach ($ bad_Array as $ bad_a)
{
Foreach ($ _ COOKIE as $ co)
{
If (substr_count (strtolower ($ co), $ bad_a)> 0)
{
Echo "<script> alert (Strange character, please do not try to inject this site! Author: Jk1986 QQ: 414028660); location. href = index. php; </script> ";
Exit ();
}
}
}
}
Like asp and asp.net, the goal is to make lazy and improve efficiency. 88