public function send_notification() { $this->CheckParams(array('message')); $_REQUEST = array_map('urldecode', $_REQUEST); $setting = array(); if (!empty($_REQUEST['expire'])) { $setting['expire'] = $_REQUEST['expire']; } if (!empty($_REQUEST['ios_slide'])) { $setting['ios_slide'] = $_REQUEST['ios_slide']; } if (!empty($_REQUEST['ios_badge'])) { $setting['ios_badge'] = $_REQUEST['ios_badge']; } if (!empty($_REQUEST['ios_sound'])) { $setting['ios_sound'] = $_REQUEST['ios_sound']; } if (!empty($_REQUEST['ios_cavailable'])) { $setting['ios_cavailable'] = $_REQUEST['ios_cavailable']; } if (!empty($_REQUEST['ios_launchimg'])) { $setting['ios_launchimg'] = $_REQUEST['ios_launchimg']; } if (!empty($_REQUEST['customparams'])) { $setting['extra_type'] = 'json'; $setting['extravalue'] = $_REQUEST['customparams']; } if (!empty($_REQUEST['android_customparams'])) { $setting['and_extra_type'] = 'json'; $setting['and_extravalue'] = $_REQUEST['android_customparams']; } if (!empty($_REQUEST['sendtime'])) { $sendtime = strtotime($_REQUEST['sendtime'], current_time('timestamp', 1)); } else { $sendtime = 0; } if (!empty($_REQUEST['device_token'])) { $this->CheckParams(array('device_token', 'device_type')); smpush_sendpush::SendPushMessage($_REQUEST['device_token'], $_REQUEST['device_type'], $_REQUEST['message'], $setting, $sendtime); $this->output(1, 'Message sent successfully'); } elseif (!empty($_REQUEST['user_id'])) { $tokeninfo = self::$pushdb->get_row(self::parse_query("SELECT {token_name} AS device_token,{type_name} AS device_type FROM {tbname} WHERE userid='{$_REQUEST['user_id']}' AND {active_name}='1'")); if ($tokeninfo) { smpush_sendpush::SendPushMessage($tokeninfo->device_token, $tokeninfo->device_type, $_REQUEST['message'], $setting, $sendtime); $this->output(1, 'Message sent successfully'); } else { $this->output(0, 'Did not find data about this user or the user is inactive'); } } elseif (!empty($_REQUEST['channel'])) { if ($_REQUEST['channel'] == 'all') { smpush_sendpush::SendCronPush('all', $_REQUEST['message'], '', '', $setting, $sendtime); } else { smpush_sendpush::SendCronPush($_REQUEST['channel'], $_REQUEST['message'], '', 'channel', $setting, $sendtime); } $this->output(1, 'Message sent successfully'); } }