function output() { global $_G; $variable = array('pmid' => $GLOBALS['return'], 'message' => $_POST['show_message']); if (isset($_G['setting']['bigapp_push_config']) && is_string($_G['setting']['bigapp_push_config'])) { $_G['setting']['bigapp_push_config'] = unserialize($_G['setting']['bigapp_push_config']); } if (!isset($_G['setting']['bigapp_push_config']['push_enabled'])) { $_G['setting']['bigapp_push_config']['push_enabled'] = 1; } if ($_G['setting']['bigapp_push_config']['push_enabled']) { if ($GLOBALS['return'] > 0) { $sql = 'SELECT uid, username FROM ' . DB::table('common_member') . ' WHERE uid IN (' . $_G['uid'] . ', ' . $_REQUEST['touid'] . ')'; $query = DB::query($sql); $uid = null; $touid = null; $user = null; $touser = null; while ($tmp = DB::fetch($query)) { if ($tmp['uid'] === $_G['uid']) { $uid = $_G['uid']; $user = $tmp['username']; continue; } $touid = $tmp['uid']; $touser = $tmp['username']; } if (!is_null($uid) && !is_null($touid) && !is_null($user) && !is_null($touser) && $uid != $touid) { if (function_exists('iconv')) { $user = iconv(CHARSET, 'UTF-8//ignore', $user); $touser = iconv(CHARSET, 'UTF-8//ignore', $touser); } else { $user = mb_convert_encoding($user, 'UTF-8', CHARSET); $touser = mb_convert_encoding($touser, 'UTF-8', CHARSET); } $title = '您有新的消息,请注意查收'; $content = "用户 {$user} 向您发来新消息,详情点击查看"; $extra = array('user' => '__DONT_DICONV_TO_UTF8___' . $user, 'touser' => '__DONT_DICONV_TO_UTF8___' . $touser, 'uid' => $uid, 'touid' => $touid, 'pmid' => $GLOBALS['return'], 'message' => '__DONT_DICONV_TO_UTF8___' . $_REQUEST['message']); require_once dirname(dirname(dirname(__FILE__))) . '/libs/pushmsg.inc.php'; $ret = PushMsg::sendMessage($touid, $title, $content, 1, $extra, 1); //仅仅推送消息 $result = 'fail'; if (true === $ret) { $result = 'succ'; } runlog('bigapp', "[mobile]try to send message notice [ uid: {$uid}, touid: {$touid}, user: {$user}, touser: {$touser}, result: {$result} ]."); } } } bigapp_core::result(bigapp_core::variable($variable)); }
private function addOutput() { global $_G; $messageval = $_G['messageparam'][0]; $variable = array("status" => 1, "messageval" => $messageval, "show_message" => preg_replace("'<script[^>]*?>.*?</script>'si", "", $GLOBALS['show_message'])); if ($messageval == 'request_has_been_sent') { $variable["status"] = 0; if (isset($_G['setting']['bigapp_push_config']) && is_string($_G['setting']['bigapp_push_config'])) { $_G['setting']['bigapp_push_config'] = unserialize($_G['setting']['bigapp_push_config']); } if (!isset($_G['setting']['bigapp_push_config']['push_enabled'])) { $_G['setting']['bigapp_push_config']['push_enabled'] = 1; } if ($_G['setting']['bigapp_push_config']['push_enabled']) { $sql = 'SELECT uid, username FROM ' . DB::table('common_member') . ' WHERE uid IN (' . $_G['uid'] . ', ' . $_GET['uid'] . ')'; $query = DB::query($sql); $uid = null; $touid = null; $user = null; $touser = null; while ($tmp = DB::fetch($query)) { if ($tmp['uid'] === $_G['uid']) { $uid = $_G['uid']; $user = $tmp['username']; continue; } $touid = $tmp['uid']; $touser = $tmp['username']; } if (!is_null($uid) && !is_null($touid) && !is_null($user) && !is_null($touser) && $uid != $touid) { if (function_exists('iconv')) { $user = iconv(CHARSET, 'UTF-8//ignore', $user); $touser = iconv(CHARSET, 'UTF-8//ignore', $touser); } else { $user = mb_convert_encoding($user, 'UTF-8', CHARSET); $touser = mb_convert_encoding($touser, 'UTF-8', CHARSET); } $title = '您收到好友请求'; $content = "用户 {$user} 请求添加您为好友,详情点击查看"; $extra = array('user' => '__DONT_DICONV_TO_UTF8___' . $user, 'touser' => '__DONT_DICONV_TO_UTF8___' . $touser, 'uid' => $uid, 'touid' => $touid); require_once dirname(dirname(dirname(__FILE__))) . '/libs/pushmsg.inc.php'; $ret = PushMsg::sendMessage($touid, $title, $content, 3, $extra, 1); $result = 'fail'; if (true === $ret) { $result = 'succ'; } runlog('bigapp', "[mobile]try to send friend request message [ uid: {$uid}, touid: {$touid}, user: {$user}, touser: {$touser}, result: {$result} ]."); } } } bigapp_core::result(bigapp_core::variable($variable)); }
public function post_message($param) { global $_G; $enablePush = $this->getPushEnableStatus(); if ('post_reply_succeed' !== $param['param'][0] || !$enablePush) { runlog('bigapp', 'push condition invalid or push is disabled [ param: ' . json_encode($param) . ', enable pushed: ' . intval($enablePush) . ' ]'); return; } if (isset($param['param'][2]['fid']) && isset($param['param'][2]['pid']) && isset($param['param'][2]['tid'])) { $fid = $param['param'][2]['fid']; $tid = $param['param'][2]['tid']; $pid = $param['param'][2]['pid']; $reppid = null; if (isset($_REQUEST['reppid']) && intval($_REQUEST['reppid']) > 0) { $reppid = intval($_REQUEST['reppid']); } $uid = null; $touid = null; $user = null; $touser = null; $subject = null; if (is_null($reppid)) { $sql = 'SELECT first, author, authorid, subject FROM ' . DB::table('forum_post') . ' where tid = ' . $tid . ' AND first = 1 OR pid = ' . $pid; } else { $sql = 'SELECT pid, author, authorid, subject FROM ' . DB::table('forum_post') . ' where pid = ' . $pid . ' OR pid = ' . $reppid; } $query = DB::query($sql); while ($tmp = DB::fetch($query)) { if (isset($tmp['first']) && $tmp['first'] == 1 || !is_null($reppid) && $reppid == $tmp['pid']) { $touid = $tmp['authorid']; $touser = $tmp['author']; $subject = $tmp['subject']; continue; } $uid = $tmp['authorid']; $user = $tmp['author']; } if (!is_null($uid) && !is_null($user) && !is_null($touser) && !is_null($touid) && !is_null($subject) && $touid != $uid) { if (function_exists('iconv')) { $user = iconv(CHARSET, 'UTF-8//ignore', $user); $touser = iconv(CHARSET, 'UTF-8//ignore', $touser); $subject = iconv(CHARSET, 'UTF-8//ignore', $subject); } else { $user = mb_convert_encoding($user, 'UTF-8', CHARSET); $touser = mb_convert_encoding($touser, 'UTF-8', CHARSET); $subject = mb_convert_encoding($subject, 'UTF-8', CHARSET); } $title = '您有新的回帖'; if (is_null($reppid)) { $content = "用户 {$user} 回复了您的主题 {$subject},详情点击查看"; } else { $content = "用户 {$user} 回复了您的回帖,详情点击查看"; } $extra = array('subject' => '__DONT_DICONV_TO_UTF8___' . $subject, 'author' => $uid, 'pid' => $pid, 'fid' => $fid, 'tid' => $tid, 'authorid' => $uid); require_once dirname(__FILE__) . '/libs/pushmsg.inc.php'; $ret = PushMsg::sendMessage($touid, $title, $content, 2, $extra, 1); $result = 'fail'; if (true === $ret) { $result = 'succ'; } runlog('bigapp', "[pcweb]try to send reply message [ subject: {$subject}, author: {$user}, ownerid: {$touid}, result: {$result} ]."); } } }
function output() { global $_G; $variable = array('tid' => $_G['tid'], 'pid' => $GLOBALS['pid']); if (isset($_G['setting']['bigapp_push_config']) && is_string($_G['setting']['bigapp_push_config'])) { $_G['setting']['bigapp_push_config'] = unserialize($_G['setting']['bigapp_push_config']); } if (!isset($_G['setting']['bigapp_push_config']['push_enabled'])) { $_G['setting']['bigapp_push_config']['push_enabled'] = 1; } if ($_G['setting']['bigapp_push_config']['push_enabled']) { $reppid = null; if (isset($_REQUEST['reppid']) && intval($_REQUEST['reppid']) > 0) { $reppid = intval($_REQUEST['reppid']); } if (is_null($reppid)) { $sql = 'SELECT first, pid, fid, tid, author, authorid, subject FROM ' . DB::table('forum_post') . ' WHERE tid = ' . $_G['tid'] . ' AND first = 1 OR pid = ' . $GLOBALS['pid']; } else { $sql = 'SELECT first, pid, fid, tid, author, authorid, subject FROM ' . DB::table('forum_post') . ' where pid = ' . $GLOBALS['pid'] . ' OR pid = ' . $reppid; } runlog('bigapp', $sql); $dbRet = array(); $query = DB::query($sql); while ($tmp = DB::fetch($query)) { $dbRet[] = $tmp; } if (count($dbRet) === 2) { $subject = null; $author = null; $pid = null; $fid = null; $tid = null; $authorid = null; $ownerid = null; foreach ($dbRet as $value) { if (1 == $value['first'] || !is_null($reppid) && $reppid == $value['pid']) { $subject = $value['subject']; $ownerid = $value['authorid']; continue; } $author = $value['author']; $pid = $value['pid']; $fid = $value['fid']; $tid = $value['tid']; $authorid = $value['authorid']; } if (!is_null($subject) && !is_null($author) && $ownerid != $authorid) { if (function_exists('iconv')) { $subject = iconv(CHARSET, 'UTF-8//ignore', $subject); $author = iconv(CHARSET, 'UTF-8//ignore', $author); } else { $subject = mb_convert_encoding($subject, 'UTF-8', CHARSET); $author = mb_convert_encoding($author, 'UTF-8', CHARSET); } $title = '您有新的回帖'; if (is_null($reppid)) { $content = "用户 {$author} 回复了您的主题 {$subject},详情点击查看"; } else { $content = "用户 {$author} 回复了您的回帖,详情点击查看"; } $extra = array('subject' => '__DONT_DICONV_TO_UTF8___' . $subject, 'author' => '__DONT_DICONV_TO_UTF8___' . $author, 'pid' => $pid, 'fid' => $fid, 'tid' => $tid, 'authorid' => $authorid); require_once dirname(dirname(dirname(__FILE__))) . '/libs/pushmsg.inc.php'; $ret = PushMsg::sendMessage($ownerid, $title, $content, 2, $extra, 1); $result = 'fail'; if (true === $ret) { $result = 'succ'; } runlog('bigapp', "[mobile]try to send reply message [ subject: {$subject}, author: {$author}, ownerid: {$ownerid}, result: {$result} ]."); } } } bigapp_core::result(bigapp_core::variable($variable)); }