人人商城

system.func.php 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. function getglobal($key) {
  8. global $_W;
  9. $key = explode('/', $key);
  10. $v = &$_W;
  11. foreach ($key as $k) {
  12. if (!isset($v[$k])) {
  13. return null;
  14. }
  15. $v = &$v[$k];
  16. }
  17. return $v;
  18. }
  19. function strip_gpc($values, $type = 'g') {
  20. $filter = array(
  21. 'g' => "'|(and|or)\\b.+?(>|<|=|in|like)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)",
  22. 'p' => "\\b(and|or)\\b.{1,6}?(=|>|<|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)",
  23. 'c' => "\\b(and|or)\\b.{1,6}?(=|>|<|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)",
  24. );
  25. if (!isset($values)) {
  26. return '';
  27. }
  28. if(is_array($values)) {
  29. foreach($values as $key => $val) {
  30. $values[addslashes($key)] = strip_gpc($val, $type);
  31. }
  32. } else {
  33. if (preg_match("/".$filter[$type]."/is", $values, $match) == 1) {
  34. $values = '';
  35. }
  36. }
  37. return $values;
  38. }