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

64 lines
1.7KB

  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. // var_dump($svar);
  44. if (is_array($svar)) {
  45. foreach ($svar as $key => $value) {
  46. $svar[$key] = addslashes($svar[$key]);
  47. }
  48. } else {
  49. $svar = addslashes($svar);
  50. }
  51. }
  52. return $svar;
  53. }
  54. /* 对_GET,_POST,_COOKIE进行过滤 */
  55. foreach(Array('_GET','_POST','_COOKIE') as $_request)
  56. {
  57. foreach($$_request as $_k => $_v)
  58. {
  59. ${$_k} = _FilterAll($_k,$_v);
  60. }
  61. }