function pushMobileNotification($to, $insertedid, $message, $isChatroom = '0', $isWRTC = '0', $sent = '0') { if (strpos($message, 'CC^CONTROL_deletemessage_') !== false) { return; } if (empty($sent)) { $sent = $insertedid; } $emojiUTF8 = (include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "extensions" . DIRECTORY_SEPARATOR . "mobileapp" . DIRECTORY_SEPARATOR . "emoji_notification.php"); if (strpos($message, 'cometchat_smiley') !== false) { preg_match_all('/<img[^>]+\\>/i', $message, $matches); for ($i = 0; $i < sizeof($matches[0]); $i++) { $msgpart = explode('/writable/images/smileys/', $matches[0][$i]); $imagenamearr = explode('"', $msgpart[1]); $imagename = $imagenamearr[0]; $smileynamearr = explode('.', $imagename); $smileyname = $smileynamearr[0]; if (!empty($imagename) && !empty($emojiUTF8[$imagename])) { $message = str_replace($matches[0][$i], $emojiUTF8[$imagename], $message); } else { $message = str_replace($matches[0][$i], ':' . $smileyname . ':', $message); } } } global $userid; global $channelprefix; if ($isChatroom === '0') { $rawMessage = array("name" => $_SESSION['cometchat']['user']['n'], "fid" => $userid, "m" => $message, "sent" => $sent); if (strlen($insertedid) < 13) { $rawMessage['id'] = $insertedid; } $channel = md5($channelprefix . "USER_" . $to . BASE_URL); } else { $chatroom_name = base64_decode($_SESSION['cometchat']['chatroom']['n']); $parsedmessage = $_SESSION['cometchat']['user']['n'] . "@" . $chatroom_name . ": " . $message; if (strpos($message, "has shared a file") !== false) { $parsedmessage = $_SESSION['cometchat']['user']['n'] . "@" . $chatroom_name . ": " . "has shared a file"; } $rawMessage = array("id" => $insertedid, "from" => $_SESSION['cometchat']['user']['n'], "fid" => $userid, "m" => sanitize($parsedmessage), "sent" => $sent, "cid" => $to); $channel = md5($channelprefix . "CHATROOM_" . $to . BASE_URL); } if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . "extensions" . DIRECTORY_SEPARATOR . "mobileapp" . DIRECTORY_SEPARATOR . "FireBasePushNotification.php")) { include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "extensions" . DIRECTORY_SEPARATOR . "mobileapp" . DIRECTORY_SEPARATOR . "FireBasePushNotification.php"; } if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . "extensions" . DIRECTORY_SEPARATOR . "mobileapp" . DIRECTORY_SEPARATOR . "config.php")) { include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "extensions" . DIRECTORY_SEPARATOR . "mobileapp" . DIRECTORY_SEPARATOR . "config.php"; } $pushnotifier = new FireBasePushNotification($firebaseauthserverkey); return $pushnotifier->sendNotification($channel, $rawMessage, $isChatroom, 0, $isWRTC); }
function pushMobileAnnouncement($zero, $sent, $message, $isAnnouncement = '0', $insertedid) { global $userid; global $firebaseauthserverkey; if (file_exists(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "extensions" . DIRECTORY_SEPARATOR . "mobileapp" . DIRECTORY_SEPARATOR . "FireBasePushNotification.php")) { include_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "extensions" . DIRECTORY_SEPARATOR . "mobileapp" . DIRECTORY_SEPARATOR . "FireBasePushNotification.php"; $announcementpushchannel = ''; if (file_exists(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . "announcements" . DIRECTORY_SEPARATOR . "config.php")) { include_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . "announcements" . DIRECTORY_SEPARATOR . "config.php"; } if (!empty($isAnnouncement)) { $rawMessage = array("m" => $message, "sent" => $sent, "id" => $insertedid); } $pushnotifier = new FireBasePushNotification($firebaseauthserverkey); $pushnotifier->sendNotification($announcementpushchannel, $rawMessage, 0, 1); } }