Description:/*************************
Description
Determine if the passed variable contains illegal characters
such as $_post, $_get
Function: Anti-injection
**************************/
Copy the Code code as follows:
Illegal characters to filter on
$ArrFiltrate =array ("'", ";", "union");
The URL to jump after the error, without filling the default previous page
$STRGOURL = "";
Whether the values in the array exist
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;
}
}
Validation begins
foreach ($ArrPostAndGet as $key = = $value) {
if (Funstringexist ($value, $ArrFiltrate)) {
echo "";
if (Emptyempty ($STRGOURL)) {
echo "";
}else{
echo "";
}
Exit
}
}
?>
Save As Checkpostandget.php
Then add an include ("checkpostandget.php") to each PHP file;
Method 2
Copy the Code code as follows:
/* Filter all get over variables */
foreach ($_get as $get _key=> $get _var)
{
if (Is_numeric ($get _var)) {
$get [Strtolower ($get _key)] = Get_int ($get _var);
} else {
$get [Strtolower ($get _key)] = Get_str ($get _var);
}
}
/* Filter all post-over variables */
foreach ($_post as $post _key=> $post _var)
{
if (Is_numeric ($post _var)) {
$post [Strtolower ($post _key)] = Get_int ($post _var);
} else {
$post [Strtolower ($post _key)] = Get_str ($post _var);
}
}
/* Filter Function */
Integer Filter function
function Get_int ($number)
{
Return Intval ($number);
}
string-Type Filter function
function Get_str ($string)
{
if (!GET_MAGIC_QUOTES_GPC ()) {
Return addslashes ($string);
}
return $string;
}
The above describes the Photoshop CS5 official Chinese official original download PHP anti-injection security code, including the official Chinese official version of Photoshop CS5 download content, I hope to be interested in PHP tutorial friends helpful.