Home > Backend Development > PHP Tutorial > photoshop cs5 official Chinese official original download PHP anti-injection security code

photoshop cs5 official Chinese official original download PHP anti-injection security code

WBOY
Release: 2016-07-29 08:37:54
Original
1088 people have browsed it

Brief description: /*************************
Description:
Determine whether the passed variable contains illegal characters
Such as $_POST, $_GET
Function: Anti-injection
* *************************/

Copy code The code is as follows:


//Illegal characters to be filtered
$ArrFiltrate=array("'",";" ,"union");
//The url to jump to after an error occurs. If not filled in, the previous page will be defaulted.
$StrGoUrl="";
//Whether there is a value in the array.
function FunStringExist($StrFiltrate,$ArrFiltrate) {
foreach ($ArrFiltrate as $key=>$value){
if (eregi($value,$StrFiltrate)){
return true;
}
}
return false ;    
}    
//Merge $_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($ArrPostAndGet as $key=>$value ){
if (FunStringExist($value,$ArrFiltrate)){
echo ""; if (emptyempty($StrGoUrl ; location="".$StrGoUrl."";";                                                                                               
Then add include( before each php file "checkpostandget.php"); then
Method 2



Copy the code

The code is as follows:
G/*Filter all Get variables*/

Foreach ($_Get as $ get_key = & gt; $ get_var) {
(inumeric ($ get_var)) {
$ get [StrTolower ($ GET_KEY)]] et_int ( $get_var);
} else {
$get[strtolower($get_key)] = get_str($get_var);
}
/* Filter all POST 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 filter function
function get_str($string)                                                                                                                                                 

​​​

The above introduces the photoshop cs5 official Chinese official original download PHP anti-injection security code, including the photoshop cs5 official Chinese official original download content. I hope it will be helpful to friends who are interested in PHP tutorials.


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template