setting.ctrl.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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('statistics');
  8. $dos = array('display', 'edit_setting');
  9. $do = in_array($do, $dos) ? $do : 'display';
  10. permission_check_account_user('statistics_visit_setting');
  11. $statistics_setting = (array)uni_setting_load(array('statistics'), $_W['uniacid']);
  12. $statistics_setting = $statistics_setting['statistics'];
  13. if ($do == 'display') {
  14. $highest_visit = empty($statistics_setting['owner']) ? 0 : $statistics_setting['owner'];
  15. $interval = empty($statistics_setting['interval']) ? 0 : $statistics_setting['interval'];
  16. }
  17. if ($do == 'edit_setting') {
  18. $type = trim($_GPC['type']);
  19. $new_highest_visit = intval($_GPC['highest_visit']);
  20. $new_interval = intval($_GPC['interval']);
  21. if (!empty($statistics_setting)) {
  22. $highest_visit = $statistics_setting;
  23. if ($type == 'highest_visit') {
  24. $highest_visit['owner'] = $new_highest_visit;
  25. } elseif ($type == 'interval') {
  26. $highest_visit['interval'] = $new_interval;
  27. }
  28. } else {
  29. if ($type == 'highest_visit') {
  30. $highest_visit = array('owner' => $new_highest_visit);
  31. } elseif ($type == 'interval') {
  32. $highest_visit = array('interval' => $new_interval);
  33. }
  34. }
  35. $result = uni_setting_save('statistics', iserializer($highest_visit));
  36. if (!empty($result)) {
  37. cache_delete(cache_system_key('unisetting', array('uniacid' => $_W['uniacid'])));
  38. cache_delete(cache_system_key('statistics', array('uniacid' => $uniacid)));
  39. iajax(0, '修改成功!');
  40. } else {
  41. iajax(-1, '修改失败!');
  42. }
  43. }
  44. template('statistics/setting');