refill_event.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. defined('InShopNC') or exit('Access Invalid!');
  3. class refill_eventControl extends SystemControl
  4. {
  5. public function __construct()
  6. {
  7. parent::__construct();
  8. }
  9. public function indexOp()
  10. {
  11. $channels_reader = function ($input)
  12. {
  13. $ches = [];
  14. $data = explode(',', $input);
  15. foreach ($data as $val)
  16. {
  17. $val = trim($val);
  18. if (!empty($val)) {
  19. $ches[] = $val;
  20. }
  21. }
  22. return implode(',', $ches);
  23. };
  24. $cacher = Cache::getInstance('cacheredis');
  25. $cfgs = $cacher->get('event-config', 'refill-');
  26. if (!empty($cfgs)) {
  27. $cfgs = unserialize($cfgs);
  28. }
  29. if (empty($cfgs['cfgs_crash']))
  30. {
  31. $cfgs['open_crash'] = false;
  32. $cfgs['cfgs_crash'] = [
  33. 'channels' => "",
  34. 'succ_interval' => 900
  35. ];
  36. }
  37. if (chksubmit())
  38. {
  39. $channels = $channels_reader($_POST['channels']);
  40. $cfgs['open_crash'] = boolval($_POST['open_crash'] ?? false);
  41. $cfgs['cfgs_crash'] = [
  42. 'channels' => $channels,
  43. 'succ_interval' => intval($_POST['succ_interval'])
  44. ];
  45. $cacher->set('event-config', serialize($cfgs), 'refill-');
  46. showMessage('编辑成功');
  47. }
  48. Tpl::output('cfgs', $cfgs);
  49. Tpl::showpage('refill_event.index');
  50. }
  51. public function notifyOp()
  52. {
  53. $osns_reader = function ($input)
  54. {
  55. $sns = [];
  56. $data = explode(',', $input);
  57. foreach ($data as $val)
  58. {
  59. $val = trim($val);
  60. if (!empty($val)) {
  61. $sns[] = $val;
  62. }
  63. }
  64. return implode(',', $sns);
  65. };
  66. $mchids_reader = function ($input)
  67. {
  68. $ids = [];
  69. $data = explode(',', $input);
  70. foreach ($data as $val)
  71. {
  72. $val = trim($val);
  73. $val = intval($val);
  74. if ($val > 0) {
  75. $ids[] = $val;
  76. }
  77. }
  78. return implode(',', $ids);
  79. };
  80. $cacher = Cache::getInstance('cacheredis');
  81. $cfgs = $cacher->get('event-config', 'refill-');
  82. if (!empty($cfgs)) {
  83. $cfgs = unserialize($cfgs);
  84. }
  85. if (empty($cfgs['cfgs_notify_osn']))
  86. {
  87. $cfgs['open_notify_osn'] = false;
  88. $cfgs['cfgs_notify_osn'] = [
  89. 'exclude_sns_start' => '',
  90. 'exclude_mchids' => ''
  91. ];
  92. }
  93. if (empty($cfgs['cfgs_sms']))
  94. {
  95. $cfgs['open_sms'] = false;
  96. $cfgs['cfgs_sms'] = [
  97. 'include_mchids' => ''
  98. ];
  99. }
  100. if (chksubmit())
  101. {
  102. $cfgs['open_notify_osn'] = boolval($_POST['open_notify_osn'] ?? false);
  103. $cfgs['cfgs_notify_osn'] = [
  104. 'exclude_sns_start' => $osns_reader($_POST['exclude_sns_start']),
  105. 'exclude_mchids' => $mchids_reader($_POST['exclude_mchids'])
  106. ];
  107. $cfgs['open_sms'] = boolval($_POST['open_sms'] ?? false);
  108. $cfgs['cfgs_sms'] = [
  109. 'include_mchids' => $mchids_reader($_POST['include_mchids'])
  110. ];
  111. $cacher->set('event-config', serialize($cfgs), 'refill-');
  112. showMessage('编辑成功');
  113. }
  114. Tpl::output('cfgs', $cfgs);
  115. Tpl::showpage('refill_event.notify');
  116. }
  117. public function delcacheOp()
  118. {
  119. }
  120. }