Browse Source

禁用词优化

tags/6.1.9
tianya 2 years ago
parent
commit
2f1388be14
2 changed files with 3 additions and 14 deletions
  1. +2
    -13
      src/system/filter.inc.php
  2. +1
    -1
      src/system/helpers/filter.helper.php

+ 2
- 13
src/system/filter.inc.php View File

@@ -17,33 +17,22 @@ if (!defined('DEDEINC')) exit('dedebiz');
* @param string $svar 过滤值 * @param string $svar 过滤值
* @return string * @return string
*/ */
$magic_quotes_gpc = ini_get('magic_quotes_gpc');
function _FilterAll($fk, &$svar) function _FilterAll($fk, &$svar)
{ {
global $cfg_notallowstr, $cfg_replacestr, $magic_quotes_gpc;
global $cfg_notallowstr, $cfg_replacestr;
if (is_array($svar)) { if (is_array($svar)) {
foreach ($svar as $_k => $_v) { foreach ($svar as $_k => $_v) {
$svar[$_k] = _FilterAll($fk, $_v); $svar[$_k] = _FilterAll($fk, $_v);
} }
} else { } else {
if ($cfg_notallowstr != '' && preg_match("#".$cfg_notallowstr."#i", $svar)) { if ($cfg_notallowstr != '' && preg_match("#".$cfg_notallowstr."#i", $svar)) {
ShowMsg(" $fk has not allow words!", '-1');
ShowMsg("{$fk}字段中包含禁用词!", '-1');
exit(); exit();
} }
if ($cfg_replacestr != '') { if ($cfg_replacestr != '') {
$svar = preg_replace('/'.$cfg_replacestr.'/i', "***", $svar); $svar = preg_replace('/'.$cfg_replacestr.'/i', "***", $svar);
} }
} }
if (!$magic_quotes_gpc) {
//var_dump($svar);
if (is_array($svar)) {
foreach ($svar as $key => $value) {
$svar[$key] = addslashes($svar[$key]);
}
} else {
$svar = addslashes($svar);
}
}
return $svar; return $svar;
} }
/* 对_GET,_POST,_COOKIE进行过滤 */ /* 对_GET,_POST,_COOKIE进行过滤 */


+ 1
- 1
src/system/helpers/filter.helper.php View File

@@ -3,7 +3,7 @@ if (!defined('DEDEINC')) exit('dedebiz');
/** /**
* 过滤小助手 * 过滤小助手
* *
* @version $Id: time.filter.php 1 2010-07-05 11:43:09Z tianya $
* @version $Id: filter.helper.php 1 2010-07-05 11:43:09Z tianya $
* @package DedeBIZ.Helpers * @package DedeBIZ.Helpers
* @copyright Copyright (c) 2022, DedeBIZ.COM * @copyright Copyright (c) 2022, DedeBIZ.COM
* @license https://www.dedebiz.com/license * @license https://www.dedebiz.com/license


Loading…
Cancel
Save