if('*' == $value || false !== strpos($value, '(') || false !== strpos($value, '.') || false !== strpos
( $value, '`')) {
//不处理包含*
或者 使用了 sql 方法。
} else {
$value = '`'.trim($value).'`';
}
return $value;
}
function str_filter($str) {
$str = htmlspecialchars ( $str );
if (! get_magic_quotes_gpc ()) {
$str = addslashes ( $str );
}
//过滤危险字符
return preg_replace ( "/["'=]|(and)|(or)|(create)|(update)|(alter)|(delete)|(insert)|(load_file)|(outfile)|
(count)|(%20)|(char)/i", "", $str );
}
/*
函数名称:str_check()
函数作用:对提交的字符串进行过滤
参 数:$var: 要处理的字符串
返 回 值:返回过滤后的字符串
*/
function str_check($str) {
if (! get_magic_quotes_gpc ()) { // 判断 magic_quotes_gpc 是否打开
$str = addslashes ( $str ); // 进行过滤
}
$str = str_replace ( "_", "_", $str ); //
把 '_'过滤掉
$str = str_replace ( "%", "%", $str ); //
把 '%'过滤掉
return $str;
}
/*
函数名称:post_check()
函数作用:对提交的编辑内容进行处理
参 数:$post: 要提交的内容
返 回 值:$post: 返回过滤后的内容
*/
function post_check($post) {
if (! get_magic_quotes_gpc ()) { // 判断 magic_quotes_gpc 是否为打开
$post = addslashes ( $post ); // 进行 magic_quotes_gpc 没有打开的情况对提交数据的过滤
}
$post = str_replace ( "_", "_", $post ); //
把 '_'过滤掉
$post = str_replace ( "%", "%", $post ); //
把 '%'过滤掉