安全过滤函数
<?php
02 /**
03 * 安全过滤函数
04 *
05 * @param $string
06 * @return string
07 */
08 function safe_replace($string) {
09 $string = str_replace('%20','',$string);
10 $string = str_replace('%27','',$string);
11 $string = str_replace('%2527','',$string);
12 $string = str_replace('*','',$string);
13 $string = str_replace('"','"',$string);
14 $string = str_replace("'",'',$string);
15 $string = str_replace('"','',$string);
16 $string = str_replace(';','',$string);
17 $string = str_replace('<','<',$string);
18 $string = str_replace('>','>',$string);
19 $string = str_replace("{",'',$string);
20 $string = str_replace('}','',$string);
21 $string = str_replace('\\','',$string);
22 return $string;
23 }
24 ?>
25 <?php
26 /**
27 * 返回经addslashes处理过的字符串或数组
28 * @param $string 需要处理的字符串或数组
29 * @return mixed
30 */
31 function new_addslashes($string) {
32 if(!is_array($string)) return addslashes($string);
33 foreach($string as $key => $val) $string[$key] = new_addslashes($val);
34 return $string;
35 }
36 ?>