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

  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 DedeCMS.Libraries
  7. * @copyright Copyright (c) 2007 - 2020, DesDev, Inc.
  8. * @license http://help.dedecms.com/usersguide/license.html
  9. * @link http://www.dedecms.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. {
  25. foreach($svar as $_k => $_v)
  26. {
  27. $svar[$_k] = _FilterAll($fk,$_v);
  28. }
  29. }
  30. else
  31. {
  32. if($cfg_notallowstr!='' && preg_match("#".$cfg_notallowstr."#i", $svar))
  33. {
  34. ShowMsg(" $fk has not allow words!",'-1');
  35. exit();
  36. }
  37. if($cfg_replacestr!='')
  38. {
  39. $svar = preg_replace('/'.$cfg_replacestr.'/i', "***", $svar);
  40. }
  41. }
  42. if (!$magic_quotes_gpc) {
  43. $svar = addslashes($svar);
  44. }
  45. return $svar;
  46. }
  47. /* 对_GET,_POST,_COOKIE进行过滤 */
  48. foreach(Array('_GET','_POST','_COOKIE') as $_request)
  49. {
  50. foreach($$_request as $_k => $_v)
  51. {
  52. ${$_k} = _FilterAll($_k,$_v);
  53. }
  54. }