cache_ipbanned.php 1022 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: cache_ipbanned.php 24468 2011-09-20 11:41:28Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. function build_cache_ipbanned() {
  12. C::t('common_banned')->delete_by_expiration(TIMESTAMP);
  13. $data = array();
  14. $bannedarr = C::t('common_banned')->fetch_all();
  15. if(!empty($bannedarr)) {
  16. $data['expiration'] = 0;
  17. $data['regexp'] = $separator = '';
  18. }
  19. foreach($bannedarr as $banned) {
  20. $data['expiration'] = !$data['expiration'] || $banned['expiration'] < $data['expiration'] ? $banned['expiration'] : $data['expiration'];
  21. $data['regexp'] .= $separator.
  22. ($banned['ip1'] == '-1' ? '\\d+\\.' : $banned['ip1'].'\\.').
  23. ($banned['ip2'] == '-1' ? '\\d+\\.' : $banned['ip2'].'\\.').
  24. ($banned['ip3'] == '-1' ? '\\d+\\.' : $banned['ip3'].'\\.').
  25. ($banned['ip4'] == '-1' ? '\\d+' : $banned['ip4']);
  26. $separator = '|';
  27. }
  28. savecache('ipbanned', $data);
  29. }
  30. ?>