ipwhitelist.ctrl.php 1.4 KB

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