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.
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 content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.