人人商城

ipwhitelist.ctrl.php 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. load()->model('site');
  8. load()->model('setting');
  9. $dos = array('display', 'change_status', 'add', 'delete');
  10. $do = in_array($_GPC['do'], $dos)? $do : 'display';
  11. $_W['page']['title'] = '站点管理 - 设置 - IP白名单';
  12. $ip_lists = setting_load('ip_white_list');
  13. $ip_lists = $ip_lists['ip_white_list'];
  14. if ($do == 'display') {
  15. $keyword = trim($_GPC['keyword']);
  16. $lists = $ip_lists;
  17. if (!empty($keyword)) {
  18. $lists = array();
  19. foreach ($ip_lists as $ip => $ip_info) {
  20. if (strexists($ip, $keyword)) {
  21. $lists[$ip] = $ip_info;
  22. }
  23. }
  24. }
  25. }
  26. if ($do == 'change_status') {
  27. $ip = trim($_GPC['ip']);
  28. $status = $ip_lists[$ip]['status'];
  29. $status = empty($status) ? 1 : 0;
  30. $ip_lists[$ip]['status'] = $status;
  31. $update = setting_save($ip_lists, 'ip_white_list');
  32. if ($update) {
  33. iajax(0, '');
  34. }
  35. iajax(-1, '更新失败', url('system/ipwhitelist'));
  36. }
  37. if ($do == 'add') {
  38. $ips = $_GPC['ips'];
  39. $ip_data = site_ip_add($ips);
  40. if (is_error($ip_data)) {
  41. iajax(-1, $ip_data['message']);
  42. }
  43. iajax(0, '添加成功', url('system/ipwhitelist'));
  44. }
  45. if ($do == 'delete') {
  46. $ip = trim($_GPC['ip']);
  47. if (empty($ip)) {
  48. itoast('参数错误');
  49. }
  50. unset($ip_lists[$ip]);
  51. $update = setting_save($ip_lists, 'ip_white_list');
  52. itoast('删除成功', url('system/ipwhitelist'));
  53. }
  54. template('system/ip-list');