国内流行的内容管理系统(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.

56 lines
1.6KB

  1. <?php if (!defined('DEDEINC')) exit("Request Error!");
  2. /**
  3. * 过滤核心处理文件
  4. *
  5. * @version $Id: filter.inc.php 1 15:59 2010年7月5日Z tianya $
  6. * @package DedeBIZ.Libraries
  7. * @copyright Copyright (c) 2020, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. /**
  12. * 过滤不相关内容
  13. *
  14. * @access public
  15. * @param string $fk 过滤键
  16. * @param string $svar 过滤值
  17. * @return string
  18. */
  19. $magic_quotes_gpc = ini_get('magic_quotes_gpc');
  20. function _FilterAll($fk, &$svar)
  21. {
  22. global $cfg_notallowstr, $cfg_replacestr, $magic_quotes_gpc;
  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 has not allow words!", '-1');
  30. exit();
  31. }
  32. if ($cfg_replacestr != '') {
  33. $svar = preg_replace('/' . $cfg_replacestr . '/i', "***", $svar);
  34. }
  35. }
  36. if (!$magic_quotes_gpc) {
  37. // var_dump($svar);
  38. if (is_array($svar)) {
  39. foreach ($svar as $key => $value) {
  40. $svar[$key] = addslashes($svar[$key]);
  41. }
  42. } else {
  43. $svar = addslashes($svar);
  44. }
  45. }
  46. return $svar;
  47. }
  48. /* 对_GET,_POST,_COOKIE进行过滤 */
  49. foreach (array('_GET', '_POST', '_COOKIE') as $_request) {
  50. foreach ($$_request as $_k => $_v) {
  51. ${$_k} = _FilterAll($_k, $_v);
  52. }
  53. }