<?php Tutorial
/*************************
Description
Determines whether the passed variable contains illegal characters
such as $_post, $_get
Function:
Anti-injection
**************************/
Illegal characters to filter this filtered character can also be increased
$arrfiltrate =array ("'", ";", "union");
The URL to jump after an error is not filled in the default previous page
$strgourl = "";
Whether the value in the array exists
function Funstringexist ($strfiltrate, $arrfiltrate) {
foreach ($arrfiltrate as $key => $value) {
if (eregi ($value, $strfiltrate)) {
return true;
}
}
return false;
}
Merging $_post and $_get
if (function_exists (Array_merge)) {
$arrpostandget =array_merge ($http _post_vars, $http _get_vars);
}else{
foreach ($http _post_vars as $key => $value) {
$arrpostandget []= $value;
}
foreach ($http _get_vars as $key => $value) {
$arrpostandget []= $value;
}
}
//Authentication start
foreach ($arrpostandget as $key => $value) {
if (funstringexist ($value, $arrfiltrate)) {
Echo <script language= "Web Effects" >alert ("illegal character");</script> ";
if (empty ($strgourl)) {
echo "<script language=" JavaScript ">history.go ( -1);</script>";
}else{
Echo "<script language=" JavaScript ">window.location=". $strgourl. ""; </script> ";
}
Exit;
}
}
?