$bsize = sizeof($broadcasttemp); for ($i = 0; $i < $bsize; $i++) { array_push($broadcast_toids, $broadcasttemp[$i]); $tempa = array('to' => $broadcasttemp[$i], 'message' => $broadcasttemp[++$i], 'dir' => 0); array_push($broadcast, $tempa); } } else { $to = $_REQUEST['to']; $message = $_REQUEST['message']; } if ($userid > 0) { if (!in_array($userid, $bannedUserIDs) && !in_array($_SERVER['REMOTE_ADDR'], $bannedUserIPs)) { if (empty($_REQUEST['broadcast'])) { $response = sendMessage($to, $message, 0); } else { $response = broadcastMessage($broadcast); } if (!empty($_REQUEST['callbackfn']) && $_REQUEST['callbackfn'] == 'mobileapp' && empty($_REQUEST['v2'])) { $response = $response['id']; } if (!empty($_GET['callback'])) { header('content-type: application/json; charset=utf-8'); sendCCResponse($_GET['callback'] . '(' . json_encode($response) . ')'); } else { sendCCResponse(json_encode($response)); } if (empty($_REQUEST['broadcast'])) { parsePusher($to, $response['id'], $_SESSION['cometchat']['user']['n'] . ": " . $response['m']); } else { if (USE_COMET == '1') { publishCometMessages($broadcast, $response[0]['id']);
function sendbroadcast() { global $userid; global $bannedUserIDs; global $bannedUserIPs; $message = $_REQUEST['message']; $broadcast_toids = explode(",", $_REQUEST['to']); $message = sanitize($_REQUEST['message']); $broadcast = array(); if (!in_array($userid, $bannedUserIDs) && !in_array($_SERVER['REMOTE_ADDR'], $bannedUserIPs)) { for ($i = 0; $i < sizeof($broadcast_toids); $i++) { $tempMsg = array('to' => $broadcast_toids[$i], 'message' => $message, 'dir' => 0); array_push($broadcast, $tempMsg); } $_REQUEST['broadcast'] = 1; $response = broadcastMessage($broadcast, $broadcast_toids); if (isset($_GET['callback'])) { header('content-type: application/json; charset=utf-8'); sendCCResponse($_GET['callback'] . '(' . json_encode($response) . ')'); } else { sendCCResponse(json_encode($response)); } publishCometMessages($broadcast); foreach ($response as $rkey => $rvalue) { parsePusher($to, $rvalue['id'], $_SESSION['cometchat']['user']['n'] . ": " . $rvalue['m']); } } }