Recommended php general anti-injection program. Copy the code as follows: functionjk1986_checksql () {$ bad_strand | select | update | delete | insert | *; $ bad_Arrayexplode (|, $ bad_str ); ** filter the Get parameter ** foreach ($ bad _
The code is as follows:
Function jk1986_checksql ()
{
$ Bad_str = "and | select | update | '| delete | insert | *";
$ 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 ('weird 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 ('weird 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 ('weird 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
The http://www.bkjia.com/PHPjc/322907.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/322907.htmlTechArticle code is as follows: function jk1986_checksql () {$ bad_str = "and | select | update | '| delete | insert | *"; $ bad_Array = explode ("| ", $ bad_str);/** filter Get parameters **/foreach ($ bad _...