<?php//php Whole station anti-injection program, need to require_once this file in public files//Judge MAGIC_QUOTES_GPC status if (@get_magic_quotes_gpc ()) {$_get = sec ($_get
);
$_post = sec ($_post);
$_cookie = sec ($_cookie);
$_files = sec ($_files);
} $_server = sec ($_server);
Function sec (& $array) {//If an array, iterate through the array, recursively call if (Is_array ($array)) {foreach ($array as $k => $v) {
$array [$k] = sec ($v);
} else if (is_string ($array)) {//Addslashes function is used to process $array = Addslashes ($array);
else if (Is_numeric ($array)) {$array = Intval ($array);
return $array; }//Integer filter functions function Num_check ($id) {if (! $id) {die (' parameter cannot be empty.
');
}//Is NULL to judge else if (Inject_check ($id)) {die (' illegal parameter ');
}//Injection to judge else if (!is_numetic ($id)) {die (' illegal parameter ');
}//Digital judgment $id = Intval ($id);
Integration return $id;
}//Character filter functions function Str_check ($STR) {if (Inject_check ($str)) {die (' illegal parameters '); }//injection judgment $STR = htmlsPecialchars ($STR);
Convert HTML return $STR;
function Search_check ($str) {$str = Str_replace ("_", "\_", $str);
The "_" filter out $str = Str_replace ("%", "\%", $str);
The "%" filter out $str = Htmlspecialchars ($STR);
Convert HTML return $STR; //Form filter functions function Post_check ($STR, $min, $max) {if (Isset ($min) && strlen ($STR) < $min) {die (' most
Less $min bytes ');
else if (isset ($max) && strlen ($STR) > $max) {die (' Maximum $max bytes ');
Return Stripslashes_array ($STR); }//anti-injection functions function Inject_check ($sql _str) {return eregi (' select|inert|update|delete|\ ' |\/\*|\*|\.\.\/|\.\/|
Union|into|load_file|outfile ', $sql _str); Www.jb51.net filter, anti-injection} function Stripslashes_array (& $array) {if Is_array ($array)) {foreach ($a
Rray as $k => $v) {$array [$k] = Stripslashes_array ($v);
} else if (is_string ($array)) {$array = Stripslashes ($array);
return $array;
}?>