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)); }
public function Message($biz_content, $FuwuToken) { $UserInfo = $this->getNode($biz_content, 'UserInfo'); $FromUserId = $this->getNode($biz_content, 'FromUserId'); $AppId = $this->getNode($biz_content, 'AppId'); $CreateTime = $this->getNode($biz_content, 'CreateTime'); $Content = $this->getNode($biz_content, 'Content'); $MsgType = $this->getNode($biz_content, 'MsgType'); $EventType = $this->getNode($biz_content, 'EventType'); $AgreementId = $this->getNode($biz_content, 'AgreementId'); $ActionParam = $this->getNode($biz_content, 'ActionParam'); $AccountNo = $this->getNode($biz_content, 'AccountNo'); $push = new PushMsg(); if ($EventType) { switch ($EventType) { case 'click': $et = ''; $Content = $ActionParam; $etkey = ''; break; case 'enter': $ap = json_decode($ActionParam, true); if ($ap['scene']['sceneId'] != '') { $et = 'SCAN'; $ap = json_decode($ActionParam, true); $etkey = $ap['scene']['sceneId']; } else { exit('error'); } break; default: $et = 'subscribe'; $etkey = ''; break; } } $ApiData = array('ali' => 1, 'token' => $FuwuToken, 'eventType' => $et, 'fromUserName' => $FromUserId, 'keyword' => $Content, 'EventKey' => $etkey); $weixin = new WeixinAction(); $rt2 = $weixin->index($ApiData); if ($rt2[1] == 'text') { $text_msg = $push->mkTextMsg($rt2[0]); $biz_content = $push->mkTextBizContent($FromUserId, $text_msg); $return_msg = $push->sendRequest($biz_content); } else { if ($rt2[1] == 'news') { $image_text_msg = array(); foreach ($rt2[0] as $news) { $searchArr = array('微信'); $replaceArr = array('支付宝服务窗'); $news[0] = str_replace($searchArr, $replaceArr, $news[0]); $news[1] = str_replace($searchArr, $replaceArr, $news[1]); $linkUrl = $news[3]; $urlInfos = parse_url($linkUrl); $p1 = explode('&', $urlInfos['query']); $params = array(); foreach ($p1 as $p1item) { $p2 = explode('=', $p1item); if ($p2[0] != 'wecha_id') { $params[$p2[0]] = $p2[1]; } } $parmsStr = ''; $andStr = ''; $params['wecha_id'] = 'z_' . md5($FromUserId); $params['ali'] = 1; foreach ($params as $pk => $pv) { $parmsStr .= $andStr . $pk . '=' . $pv; $andStr = '&'; } $linkUrlArr = explode('?', $linkUrl); $linkUrl = $linkUrlArr[0] . '?' . $parmsStr; $a = $push->mkImageTextMsg($news[0], $news[1], $linkUrl, $news[2], 'loginAuth'); array_push($image_text_msg, $a); } $biz_content = $push->mkImageTextBizContent($FromUserId, $image_text_msg); $return_msg = $push->sendMsgRequest($biz_content); } else { $text_msg = $push->mkTextMsg($rt2[0] . 'zz'); $biz_content = $push->mkTextBizContent($FromUserId, $text_msg); $return_msg = $push->sendRequest($biz_content); } } }
public function do_process() { global $_GP; $settings = globaSetting(); $sign = $_REQUEST["sign"]; $sign_type = $_REQUEST["sign_type"]; $biz_content = stripslashes($_REQUEST["biz_content"]); $service = $_REQUEST["service"]; $charset = $_REQUEST["charset"]; if (empty($sign) || empty($sign_type) || empty($biz_content) || empty($service) || empty($charset)) { echo "some parameter is empty."; exit; } $as = new AlipaySign(); $sign_verify = $as->rsaCheckV2($_REQUEST, $_GP['alipay_config']['alipay_public_key_file']); if (!$sign_verify) { if ($service == "alipay.service.check") { $EventType = $this->getNode2($biz_content, "EventType"); if ($EventType == "verifygw") { $as = new AlipaySign(); $response_xml = "<success>true</success><biz_content>" . $as->getPublicKeyStr($_GP['alipay_config']['merchant_public_key_file']) . "</biz_content>"; $return_xml = $as->sign_response($response_xml, $_GP['alipay_config']['charset'], $_GP['alipay_config']['merchant_private_key_file']); echo $return_xml; exit; } } else { echo "sign verfiy fail."; exit; } } if ($service == "alipay.service.check") { $EventType = $this->getNode2($biz_content, "EventType"); if ($EventType == "verifygw") { $as = new AlipaySign(); $response_xml = "<success>true</success><biz_content>" . $as->getPublicKeyStr($_GP['alipay_config']['merchant_public_key_file']) . "</biz_content>"; $return_xml = $as->sign_response($response_xml, 'GBK', $_GP['alipay_config']['merchant_private_key_file']); file_put_contents(WEB_ROOT . "/cache/1.log", $return_xml, FILE_APPEND); echo $return_xml; exit; } } if ($service == "alipay.mobile.public.message.notify") { $UserInfo = $this->getNode($biz_content, "UserInfo"); $FromUserId = $this->getNode($biz_content, "FromUserId"); $AppId = $this->getNode($biz_content, "AppId"); $CreateTime = $this->getNode($biz_content, "CreateTime"); $MsgType = $this->getNode($biz_content, "MsgType"); $EventType = $this->getNode($biz_content, "EventType"); $AgreementId = $this->getNode($biz_content, "AgreementId"); $ActionParam = $this->getNode($biz_content, "ActionParam"); $AccountNo = $this->getNode($biz_content, "AccountNo"); $text = $this->getNode($biz_content, "Text"); $push = new PushMsg(); if ($MsgType == "text" || $MsgType == "text" || $EventType == 'click') { $key = $text; if ($EventType == 'click') { $key = $ActionParam; } if (!empty($key)) { $reply = mysqld_select('SELECT * FROM ' . table('alipay_rule') . " WHERE keywords = :keywords", array(':keywords' => $key)); } } if ($EventType == 'follow') { $reply = mysqld_select('SELECT * FROM ' . table('alipay_rule') . " WHERE keywords = :keywords", array(':keywords' => subscribe_key)); } if (empty($reply['id'])) { $reply = mysqld_select('SELECT * FROM ' . table('alipay_rule') . " WHERE keywords = :keywords", array(':keywords' => default_key)); } if ($reply['ruletype'] == 1) { $reply['content'] = htmlspecialchars_decode($reply['description']); $reply['content'] = str_replace(array('<br>', ' '), array("\n", ' '), $reply['content']); $reply['content'] = strip_tags($reply['content'], '<a>'); $text_msg = $push->mkTextMsg($reply['content']); $biz_content = $push->mkTextBizContent($FromUserId, $text_msg); $return_msg = $push->sendRequest($biz_content); file_put_contents(WEB_ROOT . "/cache/2.log", $biz_content . '|' . $return_msg, FILE_APPEND); } if ($reply['ruletype'] == 2) { $reply['content'] = htmlspecialchars_decode($reply['description']); $reply['content'] = str_replace(array('<br>', ' '), array("\n", ' '), $reply['content']); $reply['content'] = strip_tags($reply['content'], '<a>'); //WEBSITE_ROOT.'attachment/'.$reply['thumb'] $image_text_msg1 = $push->mkImageTextMsg($reply['title'], $reply['content'], $reply['url'], WEBSITE_ROOT . 'attachment/' . $reply['thumb'], "loginAuth"); $image_text_msg = array($image_text_msg1); $biz_content = $push->mkImageTextBizContent($FromUserId, $image_text_msg); $return_msg = $push->sendRequest($biz_content); file_put_contents(WEB_ROOT . "/cache/1.log", $biz_content, FILE_APPEND); } echo $this->mkAckMsg($FromUserId); exit; // file_put_contents ( WEB_ROOT . "/cache/1.log",$x , FILE_APPEND ); } }
function C10Pr($biz_content) { require './Wxin_V10C_150513/Doc/fuwuchuang/PushMsg.php'; header("Content-Type: text/xml;charset=GBK"); writeLog($biz_content); $UserInfo = $this->getNode($biz_content, "UserInfo"); $FromUserId = $this->getNode($biz_content, "FromUserId"); $AppId = $this->getNode($biz_content, "AppId"); $CreateTime = $this->getNode($biz_content, "CreateTime"); $MsgType = $this->getNode($biz_content, "MsgType"); $EventType = $this->getNode($biz_content, "EventType"); $AgreementId = $this->getNode($biz_content, "AgreementId"); $ActionParam = $this->getNode($biz_content, "ActionParam"); $AccountNo = $this->getNode($biz_content, "AccountNo"); $push = new PushMsg(); // 收到用户发送的对话消息 if ($MsgType == "text") { $text = $this->getNode($biz_content, "Text"); writeLog("收到的文本:" . $text); $text_msg = $push->mkTextMsg("你好,这是对话消息"); // 发给这个关注的用户 $biz_content = $push->mkTextBizContent($FromUserId, $text_msg); $biz_content = iconv("UTF-8", "GBK//IGNORE", $biz_content); writeLog(iconv("UTF-8", "GBK", "\r\n发送的biz_content:" . $biz_content)); // $return_msg = $push->sendMsgRequest ( $biz_content ); $return_msg = $push->sendRequest($biz_content); // 日志记录 writeLog("发送对话消息返回:" . $return_msg); } // 接收用户发送的 图片消息 if ($MsgType == "image") { $mediaId = $this->getNode($biz_content, "MediaId"); $format = $this->getNode($biz_content, "Format"); $biz_content = "{\"mediaId\":\"" . $mediaId . "\"}"; $fileName = realpath("img") . "/{$mediaId}.{$format}"; // 下载保存图片 $push->downMediaRequest($biz_content, $fileName); writeLog("收到的图片路径:" . $fileName); $text_msg = $push->mkTextMsg("你好,图片已接收。"); // 发给这个关注的用户 $biz_content = $push->mkTextBizContent($FromUserId, $text_msg); $biz_content = iconv("UTF-8", "GBK//IGNORE", $biz_content); writeLog(iconv("UTF-8", "GBK", "\r\n发送的biz_content:" . $biz_content)); // $return_msg = $push->sendMsgRequest ( $biz_content ); $return_msg = $push->sendRequest($biz_content); // 日志记录 writeLog("发送对话消息返回:" . $return_msg); } // 收到用户发送的关注消息 if ($EventType == "follow") { // 处理关注消息 // 一般情况下,可推送一条欢迎消息或使用指导的消息。 // 如: $image_text_msg1 = $push->mkImageTextMsg("标题,感谢关注", "描述", "http://wap.taobao.com", "https://i.alipayobjects.com/e/201310/1H9ctsy9oN_src.jpg", "loginAuth"); $image_text_msg2 = $push->mkImageTextMsg("标题", "描述", "http://wap.taobao.com", "https://i.alipayobjects.com/e/201310/1H9ctsy9oN_src.jpg", "loginAuth"); // 组装多条图文信息 $image_text_msg = array($image_text_msg1, $image_text_msg2); // 发给这个关注的用户 $biz_content = $push->mkImageTextBizContent($FromUserId, $image_text_msg); $return_msg = $push->sendRequest($biz_content); // 日志记录 file_put_contents("log.txt", $return_msg . "\r\n", FILE_APPEND); } elseif ($EventType == "unfollow") { // 处理取消关注消息 } elseif ($EventType == "enter") { // 处理进入消息,扫描二维码进入,获取二维码扫描传过来的参数 $arr = json_decode($ActionParam); if ($arr != null) { writeLog("二维码传来的参数:" . var_export($arr, true)); $sceneId = $arr->scene->sceneId; writeLog("二维码传来的参数,场景ID:" . $sceneId); // 这里可以根据定义场景ID时指定的规则,来处理对应事件。 // 如:跳转到某个页面,或记录从什么来源(哪种宣传方式)来关注的本服务窗 } // 处理关注消息 // 一般情况下,可推送一条欢迎消息或使用指导的消息。 // 如: $image_text_msg1 = $push->mkImageTextMsg("标题,进入服务窗", "描述:进入服务窗", "http://wap.taobao.com", "", "loginAuth"); // $image_text_msg2 = $push->mkImageTextMsg ( "标题", "描述", "http://wap.taobao.com", "https://i.alipayobjects.com/e/201310/1H9ctsy9oN_src.jpg", "loginAuth" ); // 组装多条图文信息 $image_text_msg = array($image_text_msg1); // 发给这个关注的用户 $biz_content = $push->mkImageTextBizContent($FromUserId, $image_text_msg); $return_msg = $push->sendRequest($biz_content); // 日志记录 writeLog("发送消息返回:" . var_export($return_msg, true)); } elseif ($EventType == "click") { // 处理菜单点击的消息 // 在服务窗后台配置一个菜单,菜单类型为调用服务,菜单参数为sendmsg,用户点击次菜单后,就会调用到这里 if ($ActionParam == "sendmsg") { $image_text_msg1 = $push->mkImageTextMsg("标题,发送消息测试", "描述:发送消息测试", "http://wap.taobao.com", "", "loginAuth"); // 组装多条图文信息 $image_text_msg = array($image_text_msg1); // 发给这个关注的用户 $biz_content = $push->mkImageTextBizContent($FromUserId, $image_text_msg); $return_msg = $push->sendRequest($biz_content); // 日志记录 writeLog("发送消息返回:" . var_export($return_msg, true)); } } // 给支付宝返回ACK回应消息,不然支付宝会再次重试发送消息,再调用此方法之前,不要打印输出任何内容 echo self::mkAckMsg($FromUserId); exit; }
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} ]."); } } }
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)); }
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)); }