public static function new_comment($commid, $nowcomment) { global $wpdb; if ($nowcomment->comment_approved == 1) { if (self::$apisetting['e_usercomuser'] == 1) { if ($nowcomment->comment_parent > 0) { $comment = $wpdb->get_row("SELECT comment_post_ID,user_id FROM " . $wpdb->prefix . "comments WHERE comment_ID='" . $nowcomment->comment_parent . "' AND user_id>0", 'ARRAY_A'); if (!$comment) { return false; } $commentcount = $wpdb->get_var("SELECT COUNT(comment_ID) AS commcount FROM " . $wpdb->prefix . "comments WHERE comment_parent='" . $nowcomment->comment_parent . "' AND comment_approved='1'"); if ($commentcount > 0 and ($commentcount == 1 or $commentcount % 5 == 0)) { $subject = self::ShortString($nowcomment->comment_content, 60); $message = self::processNotifBody('e_usercomuser', $subject); smpush_sendpush::SendCronPush(array(0 => $comment['user_id']), $message, $comment['comment_post_ID']); } } } if (self::$apisetting['e_newcomment'] == 1) { $postid = $nowcomment->comment_post_ID; $commentcount = $wpdb->get_var("SELECT COUNT(comment_ID) AS commcount FROM " . $wpdb->prefix . "comments WHERE comment_post_ID='{$postid}' AND comment_approved='1'"); if ($commentcount > 0 and ($commentcount == 1 or $commentcount % 10 == 0)) { $post = $wpdb->get_row("SELECT post_title,post_author FROM " . $wpdb->prefix . "posts WHERE ID='{$postid}'", 'ARRAY_A'); $subject = self::ShortString($post['post_title'], 60); $message = self::processNotifBody('e_newcomment', $subject); smpush_sendpush::SendCronPush(array(0 => $post['post_author']), $message, $postid); } } } }
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'); } }