function parse() { ?> <table class=tb> <tr> <td colspan="2" align="center"><span id="storagetext">正 在 推 送 信 息...</span></td> </tr> <tr> <td colspan="2" align="center">推送信息状态 <div id="refreshlentext" align="left"></div> </td> </tr> </table> <?php global $db, $parse_appid_restkey; $t_id = be("all", "ids"); if (!isN($t_id)) { $sql = "SELECT a.channels as channels, vod.d_remarks ,vod.d_state, a.id as id, vod.webUrls as webUrls, vod.d_type as d_type, vod.d_name as vod_name,vod.d_id as vod_id FROM {pre}vod_pasre_item a,{pre}vod vod where a.prod_id=vod.d_id AND id in (" . $t_id . ")"; $rs = $db->query($sql); $list = array(); while ($row = $db->fetch_array($rs)) { $msg = new Notification(); $id = $row["id"]; $vod_id = $row["vod_id"]; $d_type = $row["d_type"]; if (!isN($row["d_remarks"])) { $d_remarks = $row["d_remarks"]; } if (!isN($row["d_state"])) { $d_state = $row["d_state"]; } if ($d_type === '1') { $content = '亲,您想看的《' . $row["vod_name"] . '》已经上线啦,快来看看哦~'; } else { if ($d_type === '3') { $content = '亲,你关注的《' . $row["vod_name"] . '》有更新啦,'; if (!isN($d_state) && !isN($row["webUrls"])) { $itemArray = explode("{Array}", $row["webUrls"]); $flag = true; foreach ($itemArray as $itemName) { $nameUrls = explode("\$", $itemName); if (strpos($nameUrls[0], $d_state) !== false) { $names = trim(replaceStr($nameUrls[0], $d_state, '')); if ($names) { $flag = false; $content .= $names; break; } } } if ($flag) { $content = '亲,你关注的《' . $row["vod_name"] . '》更新到了' . $d_state . '期,快来收看吧~'; } } } else { if (!isN($d_state) && $d_state !== $d_remarks) { $content = '亲,你关注的《' . $row["vod_name"] . '》更新到了第' . $d_state . '集,快来收看吧~'; } else { $content = '亲,你关注的《' . $row["vod_name"] . '》已更新完结,快来收看吧~'; } } } $msg->alert = $content; $msg->prod_id = $vod_id; $msg->prod_type = $d_type; $msg->push_type = '2'; $msg->channels = array('CHANNEL_PROD_' . $vod_id); $channels = $row["channels"]; if (isN($channels)) { $appKeys = array_keys($parse_appid_restkey); $channels = implode(",", $appKeys); } else { $appKeys = explode(",", $channels); } $pushFlag = true; foreach ($appKeys as $appkey) { if ($appkey == null || trim($appkey) == '') { } else { $msg->appid = $parse_appid_restkey[$appkey]['appid']; $msg->restkey = $parse_appid_restkey[$appkey]['restkey']; $result = NotificationsManager::push($msg); if ($result['code'] . '' == '200') { $channels = replaceStr($channels, $appkey . ',', ''); $channels = replaceStr($channels, $appkey, ''); appendMsg($content . "====消息推送 到 [" . $parse_appid_restkey[$appkey]['appname'] . "] 成功 "); writetofile("parsemsg.log", $content . "====消息推送 到 [" . $parse_appid_restkey[$appkey]['appname'] . "] 成功 "); } else { $pushFlag = false; appendMsg($content . "====消息推送 到 [" . $parse_appid_restkey[$appkey]['appname'] . "] 失败:" . $result['response']); writetofile("parsemsg.log", $content . "====消息推送 到 [" . $parse_appid_restkey[$appkey]['appname'] . "] 失败:" . $result['response']); } } } if ($pushFlag) { $list[] = $id; } else { $db->query("update {pre}vod_pasre_item set channels='" . $channels . "' where id in (" . $id . ")"); } } unset($rs); if (is_array($list) && count($list) > 0) { $ids = implode(",", $list); $db->query('delete from {pre}vod_pasre_item where id in (' . $ids . ')'); } echo "推送完毕"; } else { echo "你至少需要选择一个视频"; } }
function notifyMsg() { $d_id = be("all", "notify_msg_prod_id"); $prod_type = be("all", "notify_msg_prod_type"); global $parse_appid_restkey, $parse_appid_restkey_baidu; $can_search_device = be("all", "channel"); if (!isN($can_search_device)) { $content = be("all", "content"); $msg = new Notification(); $msg->alert = $content; $msg->prod_id = $d_id; $msg->prod_type = $prod_type; $msg->push_type = '1'; $msg->channels = explode(",", $can_search_device); $isoFlag = false; $androidFlag = false; if (strpos($can_search_device, 'CHANNEL_ANDROID') !== false || strpos($can_search_device, 'CHANNEL_TV') !== false) { $androidFlag = true; } if (strpos($can_search_device, 'CHANNEL_IOS') !== false || strpos($can_search_device, 'CHANNEL_IPAD') !== false || strpos($can_search_device, 'CHANNEL_IPHONE') !== false) { $isoFlag = true; } if ($isoFlag && !$androidFlag) { $msg->type = NotificationsManager::DEVICE_ISO; } if ($androidFlag && !$isoFlag) { $msg->type = NotificationsManager::DEVICE_ANDROID; } if (strpos($can_search_device, '_BAIDU') === false) { $appname = $parse_appid_restkey[$can_search_device]['appname']; $msg->appid = $parse_appid_restkey[$can_search_device]['appid']; $msg->restkey = $parse_appid_restkey[$can_search_device]['restkey']; $result = NotificationsManager::push($msg); $appname = $parse_appid_restkey[$can_search_device]['appname']; } else { if ($isoFlag && !$androidFlag) { $msg->iosCertPath = $parse_appid_restkey_baidu[$can_search_device]['iosCertPath']; $msg->iosCertPathRel = $parse_appid_restkey_baidu[$can_search_device]['iosCertPathRel']; } $appname = $parse_appid_restkey_baidu[$can_search_device]['appname']; $msg->appid = $parse_appid_restkey_baidu[$can_search_device]['appid']; $msg->restkey = $parse_appid_restkey_baidu[$can_search_device]['restkey']; // var_dump($parse_appid_restkey_baidu); $result = NotificationsManager::pushBaidu($msg); } if ($result['code'] . '' == '200') { echo "消息推送到 [" . $appname . "] 成功"; } else { echo "消息推送到 [" . $appname . "] 失败:" . $result['response']; } } else { echo "你必须要选择一个频道发送"; } }
function notifyMsg() { $d_id = be("get", "prod_id"); $prod_type = be("get", "prod_type"); $device_type = be("get", "device_type"); $content = be("get", "content"); $msg = new Notification(); $msg->alert = $content; $msg->prod_id = $d_id; $msg->prod_type = $prod_type; if (isset($device_type) && !is_null($device_type)) { $msg->type = $device_type; } // $msg->action='com.joyplus.UPDATE_PROGRAM'; //$manager = new NotificationsManager(); $result = NotificationsManager::push($msg); // var_dump($result['response']); if ($result['code'] . '' == '200') { echo "消息推送成功"; } else { echo "消息推送失败:" . $result['response']; } }