国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.2KB

  1. <?php
  2. if (!defined('DEDEINC')) exit('dedebiz');
  3. /**
  4. * 过滤核心处理文件
  5. *
  6. * @version $Id: filter.inc.php 1 15:59 2010年7月5日Z tianya $
  7. * @package DedeBIZ.Libraries
  8. * @copyright Copyright (c) 2022, DedeBIZ.COM
  9. * @license https://www.dedebiz.com/license
  10. * @link https://www.dedebiz.com
  11. */
  12. /**
  13. * 过滤不相关内容
  14. *
  15. * @access public
  16. * @param string $fk 过滤键
  17. * @param string $svar 过滤值
  18. * @return string
  19. */
  20. function _FilterAll($fk, &$svar)
  21. {
  22. global $cfg_notallowstr, $cfg_replacestr;
  23. if (is_array($svar)) {
  24. foreach ($svar as $_k => $_v) {
  25. $svar[$_k] = _FilterAll($fk, $_v);
  26. }
  27. } else {
  28. if ($cfg_notallowstr != '' && preg_match("#".$cfg_notallowstr."#i", $svar)) {
  29. ShowMsg("{$fk}字段中包含禁用词!", '-1');
  30. exit();
  31. }
  32. if ($cfg_replacestr != '') {
  33. $svar = preg_replace('/'.$cfg_replacestr.'/i', "***", $svar);
  34. }
  35. }
  36. return $svar;
  37. }
  38. /* 对_GET,_POST,_COOKIE进行过滤 */
  39. foreach (array('_GET', '_POST', '_COOKIE') as $_request) {
  40. foreach ($$_request as $_k => $_v) {
  41. ${$_k} = _FilterAll($_k, $_v);
  42. }
  43. }