123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <?php
- defined('InShopNC') or exit('Access Invalid!');
- class refill_eventControl extends SystemControl
- {
- public function __construct()
- {
- parent::__construct();
- }
- public function indexOp()
- {
- $channels_reader = function ($input)
- {
- $ches = [];
- $data = explode(',', $input);
- foreach ($data as $val)
- {
- $val = trim($val);
- if (!empty($val)) {
- $ches[] = $val;
- }
- }
- return implode(',', $ches);
- };
- $cacher = Cache::getInstance('cacheredis');
- $cfgs = $cacher->get('event-config', 'refill-');
- if (!empty($cfgs)) {
- $cfgs = unserialize($cfgs);
- }
- if (empty($cfgs['cfgs_crash']))
- {
- $cfgs['open_crash'] = false;
- $cfgs['cfgs_crash'] = [
- 'channels' => "",
- 'succ_interval' => 900
- ];
- }
- if (chksubmit())
- {
- $channels = $channels_reader($_POST['channels']);
- $cfgs['open_crash'] = boolval($_POST['open_crash'] ?? false);
- $cfgs['cfgs_crash'] = [
- 'channels' => $channels,
- 'succ_interval' => intval($_POST['succ_interval'])
- ];
- $cacher->set('event-config', serialize($cfgs), 'refill-');
- showMessage('编辑成功');
- }
- Tpl::output('cfgs', $cfgs);
- Tpl::showpage('refill_event.index');
- }
- public function notifyOp()
- {
- $osns_reader = function ($input)
- {
- $sns = [];
- $data = explode(',', $input);
- foreach ($data as $val)
- {
- $val = trim($val);
- if (!empty($val)) {
- $sns[] = $val;
- }
- }
- return implode(',', $sns);
- };
- $mchids_reader = function ($input)
- {
- $ids = [];
- $data = explode(',', $input);
- foreach ($data as $val)
- {
- $val = trim($val);
- $val = intval($val);
- if ($val > 0) {
- $ids[] = $val;
- }
- }
- return implode(',', $ids);
- };
- $cacher = Cache::getInstance('cacheredis');
- $cfgs = $cacher->get('event-config', 'refill-');
- if (!empty($cfgs)) {
- $cfgs = unserialize($cfgs);
- }
- if (empty($cfgs['cfgs_notify_osn']))
- {
- $cfgs['open_notify_osn'] = false;
- $cfgs['cfgs_notify_osn'] = [
- 'exclude_sns_start' => '',
- 'exclude_mchids' => ''
- ];
- }
- if (empty($cfgs['cfgs_sms']))
- {
- $cfgs['open_sms'] = false;
- $cfgs['cfgs_sms'] = [
- 'include_mchids' => ''
- ];
- }
- if (chksubmit())
- {
- $cfgs['open_notify_osn'] = boolval($_POST['open_notify_osn'] ?? false);
- $cfgs['cfgs_notify_osn'] = [
- 'exclude_sns_start' => $osns_reader($_POST['exclude_sns_start']),
- 'exclude_mchids' => $mchids_reader($_POST['exclude_mchids'])
- ];
- $cfgs['open_sms'] = boolval($_POST['open_sms'] ?? false);
- $cfgs['cfgs_sms'] = [
- 'include_mchids' => $mchids_reader($_POST['include_mchids'])
- ];
- $cacher->set('event-config', serialize($cfgs), 'refill-');
- showMessage('编辑成功');
- }
- Tpl::output('cfgs', $cfgs);
- Tpl::showpage('refill_event.notify');
- }
- public function delcacheOp()
- {
- }
- }
|