/include/filter.inc.php
01
/**
02
* 过滤不相关内容
03
*
04
* @access public
05
* @param string $fk 过滤键
06
* @param string $svar 过滤值
07
* @return string
08
*/
09
$magic_quotes_gpc
=
ini_get
(
'magic_quotes_gpc'
);
10
function
_FilterAll(
$fk
, &
$svar
)
11
{
12
global
$cfg_notallowstr
,
$cfg_replacestr
;
13
if
(
is_array
(
$svar
) )
14
{
15
foreach
(
$svar
as
$_k
=>
$_v
)
16
{
17
$svar
[
$_k
] = _FilterAll(
$fk
,
$_v
);
18
}
19
}
20
else
21
{
22
if
(
$cfg_notallowstr
!=
''
&& preg_match(
"#"
.
$cfg_notallowstr
.
"#i"
,
$svar
))
23
{
24
ShowMsg(
" $fk has not allow words!"
,
'-1'
);
25
exit
();
26
}
27
if
(
$cfg_replacestr
!=
''
)
28
{
29
$svar
= preg_replace(
'/'
.
$cfg_replacestr
.
'/i'
,
"***"
,
$svar
);
30
}
31
}
32
if
(!
$magic_quotes_gpc
) {
33
$svar
=
addslashes
(
$svar
);
34
}
35
return
addslashes
(
$svar
);
36
// return $svar;
37
}
如果本文对你有帮助,欢迎打赏本站