Example #1
0
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "config.php";
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "emoji.php";
$cookiefile = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'cookie.txt';
$pushUsername = '******' . $_SERVER['HTTP_HOST'];
$pushPassword = md5($pushUsername);
if (empty($pushAPIKey)) {
    $pushAPIKey = 'BGJbP31xBhGvXzt4fQsxtfmzMb5eYxcb';
}
if (empty($notificationName)) {
    $notificationName = 'CometChat';
}
if (isset($_REQUEST['chatroommode']) && isset($_REQUEST['displayname'])) {
    pushMobileNotification($_REQUEST['message'], $_REQUEST['displayname'], $_REQUEST['channel'], $_REQUEST['channel']);
} else {
    if ($userid > 0 && isset($_REQUEST['displayname'])) {
        pushMobileNotification($_REQUEST['message'], $_REQUEST['displayname'], $_REQUEST['channel'], $userid);
    }
}
function pushMobileNotification($msg, $displayname, $channel, $senderid)
{
    global $pushAPIKey;
    global $notificationName;
    global $cookiefile;
    $msg = checkEmoji($msg);
    if (CROSS_DOMAIN == 1) {
        $host = parse_url(BASE_URL);
        $hostname = $host['host'] ? $host['host'] : array_shift(explode('/', $host['path'], 2));
    } else {
        $hostname = $_SERVER['HTTP_HOST'];
    }
    /********************************** SETUP **********************************/
Example #2
0
    $jpg = stream_get_contents($inputSocket);
    fclose($inputSocket);
    fwrite($file, $jpg);
    fclose($file);
}
if (file_exists(dirname(dirname(dirname(__FILE__))) . "/plugins/handwrite/uploads/" . $randomImage . ".jpg")) {
    $linkToImage = BASE_URL . "plugins/handwrite/uploads/" . $randomImage . ".jpg";
    $text = '<a href="' . $linkToImage . '" target="_blank" style="display:inline-block;margin-bottom:3px;margin-top:3px;"><img src="' . $linkToImage . '" border="0" style="padding:0px;display: inline-block;border:1px solid #666;" height="90" width="134"></a>';
    if (substr($_REQUEST['tid'], 0, 1) == 'c') {
        $_REQUEST['tid'] = substr($_REQUEST['tid'], 1);
        sendChatroomMessage($_REQUEST['tid'], $handwrite_language[3] . "<br/>{$text}");
    } else {
        sendMessageTo($_REQUEST['tid'], $handwrite_language[1] . "<br/>{$text}");
        sendSelfMessage($_REQUEST['tid'], $handwrite_language[2] . "<br/>{$text}");
        if (isset($_REQUEST['sendername']) && $pushNotifications == 1) {
            pushMobileNotification($handwrite_language[2], $_REQUEST['sendername'], $_REQUEST['tid'], $_REQUEST['tid']);
        }
    }
}
$embed = '';
$embedcss = '';
$close = "setTimeout('window.close()',2000);";
if (!empty($_REQUEST['embed']) && $_REQUEST['embed'] == 'web') {
    $embed = 'web';
    $embedcss = 'embed';
    $close = "parent.closeCCPopup('handwrite');";
}
if (!empty($_REQUEST['embed']) && $_REQUEST['embed'] == 'desktop') {
    $embed = 'desktop';
    $embedcss = 'embed';
    $close = "parentSandboxBridge.closeCCPopup('handwrite');";
function sendChatroomMessage($to = 0, $message = '', $notsilent = 1)
{
    global $userid;
    global $cookiePrefix;
    global $chromeReorderFix;
    global $bannedUserIDs;
    global $lang;
    $stickersflag = 0;
    if ($to == 0 && empty($_POST['currentroom']) || $message == '' && $notsilent == 0 || isset($_POST['message']) && $_POST['message'] == '' || empty($userid) || in_array($userid, $bannedUserIDs)) {
        return;
    }
    if (isset($_POST['message']) && !empty($_POST['currentroom'])) {
        $to = mysqli_real_escape_string($GLOBALS['dbh'], $_POST['currentroom']);
        $message = $_POST['message'];
    }
    if (isset($message) && $message != '') {
        if (strpos($message, 'CC^CONTROL_') !== false) {
            $message = str_ireplace('CC^CONTROL_', '', $message);
            $message = sanitize($message);
            $controlparameters = json_decode($message, true);
            $chatroommode = $controlparameters['params']['chatroommode'];
            switch ($controlparameters['name']) {
                case 'avchat':
                    $grp = $controlparameters['params']['grp'];
                    switch ($controlparameters['method']) {
                        case 'endcall':
                            $message = 'CC^CONTROL_PLUGIN_AVCHAT_ENDCALL_' . $grp . '_' . $chatroommode;
                            break;
                        case 'rejectcall':
                            $message = 'CC^CONTROL_PLUGIN_AVCHAT_REJECTCALL_' . $grp . '_' . $chatroommode;
                            break;
                        case 'noanswer':
                            $message = 'CC^CONTROL_PLUGIN_AVCHAT_NOANSWER_' . $grp . '_' . $chatroommode;
                            break;
                        case 'canceloutgoingcall':
                            $message = 'CC^CONTROL_PLUGIN_AVCHAT_CANCELCALL_' . $grp . '_' . $chatroommode;
                            break;
                        case 'busycall':
                            $message = 'CC^CONTROL_PLUGIN_AVCHAT_BUSYCALL_' . $grp . '_' . $chatroommode;
                            break;
                        default:
                            $message = '';
                            break;
                    }
                    break;
                case 'audiochat':
                    $grp = $controlparameters['params']['grp'];
                    switch ($controlparameters['method']) {
                        case 'endcall':
                            $message = 'CC^CONTROL_PLUGIN_AUDIOCHAT_ENDCALL_' . $grp . '_' . $chatroommode;
                            break;
                        case 'rejectcall':
                            $message = 'CC^CONTROL_PLUGIN_AUDIOCHAT_REJECTCALL_' . $grp . '_' . $chatroommode;
                            break;
                        case 'noanswer':
                            $message = 'CC^CONTROL_PLUGIN_AUDIOCHAT_NOANSWER_' . $grp . '_' . $chatroommode;
                            break;
                        case 'canceloutgoingcall':
                            $message = 'CC^CONTROL_PLUGIN_AUDIOCHAT_CANCELCALL_' . $grp . '_' . $chatroommode;
                            break;
                        case 'busycall':
                            $message = 'CC^CONTROL_PLUGIN_AUDIOCHAT_BUSYCALL_' . $grp . '_' . $chatroommode;
                            break;
                        default:
                            $message = '';
                            break;
                    }
                    break;
                case 'broadcast':
                    $grp = $controlparameters['params']['grp'];
                    switch ($controlparameters['method']) {
                        case 'endcall':
                            $message = 'CC^CONTROL_PLUGIN_BROADCAST_ENDCALL_' . $grp . '_' . $chatroommode;
                            break;
                        default:
                            $message = '';
                            break;
                    }
                    break;
                case 'stickers':
                    $stickersflag = 1;
                    $message = 'CC^CONTROL_' . $message;
                    break;
                case 'chatroom':
                    $delid = $controlparameters['params']['id'];
                    switch ($controlparameters['method']) {
                        case 'deletemessage':
                            $message = 'CC^CONTROL_deletemessage_' . $delid;
                            break;
                        case 'kicked':
                            $message = 'CC^CONTROL_kicked_' . $delid;
                            break;
                        case 'banned':
                            $message = 'CC^CONTROL_banned_' . $delid;
                            break;
                        default:
                            $message = '';
                            break;
                    }
                    break;
                default:
                    break;
            }
        }
    }
    if ($notsilent !== 0 && $stickersflag == 0) {
        $message = str_ireplace('CC^CONTROL_', '', $message);
        $message = sanitize($message);
    }
    $styleStart = '';
    $styleEnd = '';
    if (!empty($_COOKIE[$cookiePrefix . 'chatroomcolor']) && preg_match('/^[a-f0-9]{6}$/i', $_COOKIE[$cookiePrefix . 'chatroomcolor']) && $notsilent == 1 && $stickersflag == 0) {
        $styleStart = '<span style="color:#' . mysqli_real_escape_string($GLOBALS['dbh'], $_COOKIE[$cookiePrefix . 'chatroomcolor']) . '">';
        $styleEnd = '</span>';
    }
    $timestamp = getTimeStamp();
    if (empty($_SESSION['cometchat']['cometchat_chatroom_' . $to])) {
        $_SESSION['cometchat']['cometchat_chatroom_' . $to] = array();
    }
    if (USE_COMET == 1 && COMET_CHATROOMS == 1) {
        if (empty($_SESSION['cometchat']['username'])) {
            $name = '';
            $sql = getUserDetails($userid);
            if ($userid > 10000000) {
                $sql = getGuestDetails($userid);
            }
            $result = mysqli_query($GLOBALS['dbh'], $sql);
            if ($row = mysqli_fetch_assoc($result)) {
                if (function_exists('processName')) {
                    $row['username'] = processName($row['username']);
                }
                $name = $row['username'];
            }
            $_SESSION['cometchat']['username'] = $name;
        } else {
            $name = $_SESSION['cometchat']['username'];
        }
        if (!empty($name)) {
            $sql = "insert into cometchat_chatroommessages (userid,chatroomid,message,sent) values ('" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "', '" . mysqli_real_escape_string($GLOBALS['dbh'], $to) . "','" . mysqli_real_escape_string($GLOBALS['dbh'], $styleStart) . mysqli_real_escape_string($GLOBALS['dbh'], $message) . mysqli_real_escape_string($GLOBALS['dbh'], $styleEnd) . "','" . $timestamp . "')";
            $query = mysqli_query($GLOBALS['dbh'], $sql);
            $insertedid = mysqli_insert_id($GLOBALS['dbh']);
            $channel = md5('chatroom_' . $to . KEY_A . KEY_B . KEY_C);
            $comet = new Comet(KEY_A, KEY_B);
            if (method_exists($comet, 'processChannel')) {
                $channel = processChannel($channel);
            }
            if (defined('DEV_MODE') && DEV_MODE == '1') {
                echo mysqli_error($GLOBALS['dbh']);
            }
            $info = $comet->publish(array('channel' => $channel, 'message' => array("id" => $insertedid, "from" => $name, "fromid" => $userid, "message" => $styleStart . $message . $styleEnd, "sent" => $timestamp * 1000, "roomid" => $to)));
            $_SESSION['cometchat']['cometchat_chatroom_' . $to][$insertedid] = array('id' => $insertedid, 'from' => $_SESSION['cometchat']['username'], 'fromid' => $userid, 'chatroomid' => $to, 'message' => $styleStart . $message . $styleEnd, 'sent' => $timestamp);
            krsort($_SESSION['cometchat']['cometchat_chatroom_' . $to]);
            if ($notsilent == 1) {
                sendCCResponse(json_encode(array("id" => $insertedid, "m" => $styleStart . $message . $styleEnd, "sent" => $timestamp)));
            }
        }
    } else {
        $sql = "insert into cometchat_chatroommessages (userid,chatroomid,message,sent) values ('" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "', '" . mysqli_real_escape_string($GLOBALS['dbh'], $to) . "','" . mysqli_real_escape_string($GLOBALS['dbh'], $styleStart) . mysqli_real_escape_string($GLOBALS['dbh'], $message) . mysqli_real_escape_string($GLOBALS['dbh'], $styleEnd) . "','" . mysqli_real_escape_string($GLOBALS['dbh'], $timestamp) . "')";
        $query = mysqli_query($GLOBALS['dbh'], $sql);
        $insertedid = mysqli_insert_id($GLOBALS['dbh']);
        if (defined('DEV_MODE') && DEV_MODE == '1') {
            echo mysqli_error($GLOBALS['dbh']);
        }
        $name = '';
        $sql = getUserDetails($userid);
        if ($userid > 10000000) {
            $sql = getGuestDetails($userid);
        }
        $result = mysqli_query($GLOBALS['dbh'], $sql);
        if ($row = mysqli_fetch_assoc($result)) {
            if (function_exists('processName')) {
                $row['username'] = processName($row['username']);
            }
            $name = $row['username'];
        }
        $_SESSION['cometchat']['cometchat_chatroom_' . $to][$insertedid] = array('id' => $insertedid, 'from' => $name, 'fromid' => $userid, 'chatroomid' => $to, 'message' => $styleStart . $message . $styleEnd, 'sent' => $timestamp);
        krsort($_SESSION['cometchat']['cometchat_chatroom_' . $to]);
        if ($notsilent == 1) {
            sendCCResponse(json_encode(array("id" => $insertedid, "m" => $styleStart . $message . $styleEnd, "sent" => $timestamp)));
        }
    }
    $parsedmessage = $message;
    if (strpos($message, 'BROADCAST_ENDCALL') !== false || strpos($message, 'jqcc.ccbroadcast.join') !== false) {
        include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "broadcast" . DIRECTORY_SEPARATOR . "lang" . DIRECTORY_SEPARATOR . $lang . ".php";
        global $broadcast_language;
        if (strpos($message, 'BROADCAST_ENDCALL') !== false) {
            $parsedmessage = $broadcast_language[24];
        }
        //This broadcast has ended
        if (strpos($message, 'jqcc.ccbroadcast.join') !== false) {
            $parsedmessage = $broadcast_language[17];
        }
        //has started a video broadcast.
    } elseif (strpos($message, 'jqcc.ccavchat.join') !== false) {
        include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "avchat" . DIRECTORY_SEPARATOR . "lang" . DIRECTORY_SEPARATOR . $lang . ".php";
        global $avchat_language;
        $parsedmessage = $avchat_language[19];
        //has started a video conversation.
    } elseif (strpos($message, 'jqcc.ccaudiochat.join') !== false) {
        include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "audiochat" . DIRECTORY_SEPARATOR . "lang" . DIRECTORY_SEPARATOR . $lang . ".php";
        global $audiochat_language;
        $parsedmessage = $audiochat_language[19];
        //has started a audio conversation.
    } elseif (strpos($message, 'CC^CONTROL_{"type":"plugins","name":"stickers","method":"sendSticker"') !== false) {
        include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "stickers" . DIRECTORY_SEPARATOR . "lang" . DIRECTORY_SEPARATOR . $lang . ".php";
        global $stickers_language;
        $parsedmessage = $stickers_language[2];
        //has sent a sticker.
    } elseif (strpos($message, 'CC^CONTROL_kicked_kicked') !== false || strpos($message, 'CC^CONTROL_banned_') !== false) {
        include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . "chatrooms" . DIRECTORY_SEPARATOR . "lang" . DIRECTORY_SEPARATOR . $lang . ".php";
        global $chatrooms_language;
        if (strpos($message, 'CC^CONTROL_kicked_kicked') !== false) {
            $parsedmessage = $chatrooms_language[36];
        }
        //You have been kicked from this chatroom.
        if (strpos($message, 'CC^CONTROL_banned_') !== false) {
            $parsedmessage = $chatrooms_language[37];
        }
        //You have been banned from chatroom
    } elseif (strpos($message, 'jqcc.ccwhiteboard.accept') !== false) {
        include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "whiteboard" . DIRECTORY_SEPARATOR . "lang" . DIRECTORY_SEPARATOR . $lang . ".php";
        global $whiteboard_language;
        $parsedmessage = $whiteboard_language[7];
        //has shared a whiteboard.
    } elseif (strpos($message, 'jqcc.ccwriteboard.accept') !== false) {
        include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "writeboard" . DIRECTORY_SEPARATOR . "lang" . DIRECTORY_SEPARATOR . $lang . ".php";
        global $writeboard_language;
        $parsedmessage = $writeboard_language[2];
        //has shared a writeboard.
    } elseif (strpos($message, 'jqcc.ccscreenshare.accept') !== false) {
        include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "screenshare" . DIRECTORY_SEPARATOR . "lang" . DIRECTORY_SEPARATOR . $lang . ".php";
        global $screenshare_language;
        $parsedmessage = $screenshare_language[2];
        //has shared his/her screen with you.
    } elseif (strpos($message, '/writable/handwrite/uploads/') !== false) {
        include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "handwrite" . DIRECTORY_SEPARATOR . "lang" . DIRECTORY_SEPARATOR . $lang . ".php";
        global $handwrite_language;
        $parsedmessage = $handwrite_language[1];
        //has successfully sent a handwritten message
    } elseif (strpos($message, 'plugins/filetransfer/download.php') !== false) {
        include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "filetransfer" . DIRECTORY_SEPARATOR . "lang" . DIRECTORY_SEPARATOR . $lang . ".php";
        global $filetransfer_language;
        $parsedmessage = $filetransfer_language[9];
        //has shared a file
    }
    pushMobileNotification($to, $insertedid, $parsedmessage, '1', 0, $timestamp);
    $sql = "update cometchat_chatrooms set lastactivity = '" . mysqli_real_escape_string($GLOBALS['dbh'], $timestamp) . "' where id = '" . mysqli_real_escape_string($GLOBALS['dbh'], $to) . "'";
    $query = mysqli_query($GLOBALS['dbh'], $sql);
    if ($notsilent == 0) {
        return $insertedid;
    }
}
    } else {
        if (!empty($isImage) && $isImage || !empty($isVideo) && $isVideo) {
            $response = sendMessage($_POST['to'], $filetransfer_language[5] . "<br/><a href=\"//" . $server_url . "plugins/filetransfer/download.php?file=" . $filename . "\" target=\"_blank\"><a class=\"imagemessage\" href=\"//" . $server_url . "plugins/filetransfer/download.php?file=" . $filename . "\" onClick=\"javascript:jqcc('div.cometchat_other > a')[0].click();return false;\" target=\"none\" imageheight=\"" . $height . "\" imagewidth=\"" . $width . "\">" . $imgtag . "</a></a>", 1);
            $processedMessage = $_SESSION['cometchat']['user']['n'] . ": " . "has sent you a file";
            parsePusher($_POST['to'], $response['id'], $processedMessage);
            $array_response = sendMessage($_POST['to'], $filetransfer_language[7] . "<br/><a href=\"//" . $server_url . "plugins/filetransfer/download.php?file=" . $filename . "\" target=\"_blank\"><a class=\"imagemessage\" href=\"//" . $server_url . "plugins/filetransfer/download.php?file=" . $filename . "\" onClick=\"javascript:jqcc('div.cometchat_other > a')[0].click();return false;\" target=\"none\"  imageheight=\"" . $height . "\" imagewidth=\"" . $width . "\">" . $imgtag . "</a></a>", 2);
            $insertedId = $array_response['id'];
        } else {
            $response = sendMessage($_POST['to'], $filetransfer_language[5] . " (" . $filename . "). <a href=\"//" . $server_url . "plugins/filetransfer/download.php?file=" . $filename . "\" target=\"_blank\"><a href=\"" . BASE_URL . "plugins/filetransfer/download.php?file=" . $filename . "\" onClick=\"return false;\" target=\"none\" " . $filetransfer_language[6] . "</a></a>", 1);
            $processedMessage = $_SESSION['cometchat']['user']['n'] . ": " . "has sent you a file";
            parsePusher($_POST['to'], $response['id'], $processedMessage);
            $array_response = sendMessage($_POST['to'], $filetransfer_language[7] . " (" . $filename . ").", 2);
            $insertedId = $array_response['id'];
        }
        if (isset($_REQUEST['sendername']) && $pushNotifications == 1) {
            pushMobileNotification($filetransfer_language[9], $_REQUEST['sendername'], $_POST['to'], $_POST['to']);
        }
    }
    if (isset($_REQUEST['callbackfn']) && $_REQUEST['callbackfn'] == 'mobileapp') {
        echo $insertedId;
        exit;
    }
    $message = $filetransfer_language[8];
}
$embed = '';
$embedcss = '';
$close = "setTimeout('window.close()',2000);";
if (!empty($_GET['embed']) && $_GET['embed'] == 'web') {
    $embed = 'web';
    $embedcss = 'embed';
    $close = "parent.closeCCPopup('filetransfer');";
Example #5
0
 } else {
     if (!empty($isImage) && $isImage || !empty($isVideo) && $isVideo || !empty($isAudio) && $isAudio) {
         $response = sendMessage($_POST['to'], $filetransfer_language[5] . "<br/><a class=\"imagemessage mediamessage\" filename=\"" . $unencryptedfilename . "\" encfilename=\"" . $md5filename . "\" mediatype=\"" . $mediaType . "\" href=\"" . $server_url . "plugins/filetransfer/download.php?file=" . $md5filename . "&amp;unencryptedfilename=" . $unencryptedfilename . "\">" . $imgtag . "</a>", 0, 'filetransfer');
         $processedMessage = $_SESSION['cometchat']['user']['n'] . ": " . $filetransfer_language[5];
         pushMobileNotification($_POST['to'], $response['id'], $processedMessage);
         if (USE_COMET == 1) {
             $cometmessage = array();
             $cometresponse = array('to' => $_POST['to'], 'message' => $filetransfer_language[5] . "<br/><a class=\"imagemessage mediamessage\" filename=\"" . $unencryptedfilename . "\" encfilename=\"" . $md5filename . "\" mediatype=\"" . $mediaType . "\" href=\"" . $server_url . "plugins/filetransfer/download.php?file=" . $md5filename . "&amp;unencryptedfilename=" . $unencryptedfilename . "\">" . $imgtag . "</a>", 'dir' => 0, 'type' => "filetransfer");
             array_push($cometmessage, $cometresponse);
             publishCometMessages($cometmessage, $response['id']);
         }
         $insertedId = $response['id'];
     } else {
         $response = sendMessage($_POST['to'], $filetransfer_language[5] . " (" . $filename . "). <a class=\"imagemessage\" href=\"" . $server_url . "plugins/filetransfer/download.php?file=" . $md5filename . "&amp;unencryptedfilename=" . $unencryptedfilename . "\" target=\"_blank\" mediatype=\"" . $mediaType . "\">" . $filetransfer_language[6] . "</a>", 0, 'filetransfer');
         $processedMessage = $_SESSION['cometchat']['user']['n'] . ": " . $filetransfer_language[5];
         pushMobileNotification($_POST['to'], $response['id'], $processedMessage);
         if (USE_COMET == 1) {
             $cometmessage = array();
             $cometresponse = array('to' => $_POST['to'], 'message' => $filetransfer_language[7] . " (" . $filename . ").<a class=\"imagemessage\" href=\"" . $server_url . "plugins/filetransfer/download.php?file=" . $md5filename . "&unencryptedfilename=" . $unencryptedfilename . "\" target=\"_blank\" mediatype=\"" . $mediaType . "\">" . $filetransfer_language[6] . "</a>", 'dir' => 0, 'type' => "filetransfer");
             array_push($cometmessage, $cometresponse);
             publishCometMessages($cometmessage, $response['id']);
         }
         $insertedId = $response['id'];
     }
     /*Uncomment to enable push notifications for CometChat Legacy Apps*/
     /*if (isset($_REQUEST['sendername']) && $pushNotifications == 1) {
     			pushMobileNotification($filetransfer_language[9], $_REQUEST['sendername'], $_POST['to'], $_POST['to']);
     		}*/
     /*Uncomment to enable push notifications for CometChat Legacy Apps*/
 }
 if (!empty($_REQUEST['callbackfn']) && $_REQUEST['callbackfn'] == 'mobileapp') {
Example #6
0
         $response = broadcastMessage($broadcast);
     }
     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'])) {
         pushMobileNotification($to, $response['id'], $_SESSION['cometchat']['user']['n'] . ": " . $response['m']);
     } else {
         if (USE_COMET == '1') {
             publishCometMessages($broadcast, $response[0]['id']);
         }
         foreach ($response as $rkey => $rvalue) {
             pushMobileNotification($rvalue['from'], $rvalue['id'], $_SESSION['cometchat']['user']['n'] . ": " . $rvalue['m']);
         }
     }
 } else {
     if (empty($_REQUEST['broadcast'])) {
         $sql = "insert into cometchat (cometchat.from,cometchat.to,cometchat.message,cometchat.sent,cometchat.read,cometchat.direction) values ('" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "', '" . mysqli_real_escape_string($GLOBALS['dbh'], $to) . "','" . mysqli_real_escape_string($GLOBALS['dbh'], sanitize($bannedMessage)) . "','" . mysqli_real_escape_string($GLOBALS['dbh'], getTimeStamp()) . "',0,2)";
         $query = mysqli_query($GLOBALS['dbh'], $sql);
         if (defined('DEV_MODE') && DEV_MODE == '1') {
             echo mysqli_error($GLOBALS['dbh']);
         }
         if (!empty($_GET['callback'])) {
             header('content-type: application/json; charset=utf-8');
             echo $_GET['callback'] . '()';
         }
     }
 }
Example #7
0
function inviteusers()
{
    global $chatrooms_language;
    global $close;
    global $embedcss;
    $post_roomid = mysqli_real_escape_string($GLOBALS['dbh'], $_POST['roomid']);
    $post_inviteid = mysqli_real_escape_string($GLOBALS['dbh'], $_POST['inviteid']);
    $post_roomname = mysqli_real_escape_string($GLOBALS['dbh'], $_POST['roomname']);
    if (!empty($_REQUEST['invite'])) {
        $blockedIds = getBlockedUserIDs();
        foreach ($blockedIds as $bid) {
            if (in_array($bid, $_REQUEST['invite'])) {
                unset($_REQUEST['invite'][array_search($bid, $_REQUEST['invite'])]);
            }
        }
        foreach ($_REQUEST['invite'] as $user) {
            $chatroomroomname = base64_decode(rawurldecode($_POST['roomname']));
            $response = sendMessage($user, "{$chatrooms_language[18]}{$chatroomroomname}. <a href=\"javascript:jqcc.cometchat.joinChatroom('{$post_roomid}','{$post_inviteid}','{$post_roomname}')\">{$chatrooms_language[19]}</a>", 1);
            addUsersToChatroom($post_roomid, $user);
            $processedMessage = $_SESSION['cometchat']['user']['n'] . ": " . "has invited you to join " . $_SESSION['cometchat']['chatroom']['n'];
            if ($response != '') {
                pushMobileNotification($user, $response['id'], $processedMessage);
            }
        }
    }
    echo <<<EOD
<!DOCTYPE html>
<html>
\t<head>
\t\t<title>{$chatrooms_language[18]}</title>
\t\t<meta name="viewport" content="user-scalable=0,width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0" />
\t\t<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
\t\t<link type="text/css" rel="stylesheet" media="all" href="../../css.php?type=module&name=chatrooms" />
\t\t<script type="text/javascript">
\t\t\tfunction closePopup(name){
\t\t\t\tvar controlparameters = {'type':'modules', 'name':'chatrooms', 'method':'closeCCPopup', 'params':{'name':'invite'}};
\t\t\t\tcontrolparameters = JSON.stringify(controlparameters);
\t\t\t\tif(typeof(parent) != 'undefined' && parent != null && parent != self){
\t\t\t\t\tparent.postMessage('CC^CONTROL_'+controlparameters,'*');
\t\t\t\t} else {
\t\t\t\t\twindow.close();
\t\t\t\t}
\t\t\t}
\t\t</script>
\t</head>
\t<body onload="{$close}">
\t\t<div class="cometchat_wrapper">
\t\t\t<div class="container_title {$embedcss}">{$chatrooms_language[21]}</div>
\t\t\t<div class="container_body {$embedcss}">
\t\t\t\t{$chatrooms_language[16]}
\t\t\t\t<div style="clear:both"></div>
\t\t\t</div>
\t\t</div>
\t</body>
</html>
EOD;
}
Example #8
0
    $file = fopen(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "writable" . DIRECTORY_SEPARATOR . "handwrite" . DIRECTORY_SEPARATOR . "uploads" . DIRECTORY_SEPARATOR . $randomImage . ".png", "w");
    fwrite($file, $png);
    fclose($file);
    if (file_exists(dirname(dirname(dirname(__FILE__))) . "/writable/handwrite/uploads/" . $randomImage . ".png")) {
        $linkToImage = BASE_URL . "writable/handwrite/uploads/" . $randomImage . ".png";
    }
}
if (isset($linkToImage)) {
    $text = '<a href="' . $linkToImage . '" target="_blank" style="display:inline-block;margin-bottom:3px;margin-top:3px;max-width:100%;"><img class="cc_handwrite_image" src="' . $linkToImage . '" border="0" style="padding:0px;display: inline-block;border:1px solid #666;" height="90" width="134"></a>';
    if (substr($_REQUEST['tid'], 0, 1) == 'c') {
        $_REQUEST['tid'] = substr($_REQUEST['tid'], 1);
        sendChatroomMessage($_REQUEST['tid'], $handwrite_language[3] . "<br/>{$text}", 0);
    } else {
        $response = sendMessage($_REQUEST['tid'], $handwrite_language[1] . "<br/>{$text}", 0, 'handwrite');
        $processedMessage = $_SESSION['cometchat']['user']['n'] . ": " . $handwrite_language[1];
        pushMobileNotification($_REQUEST['tid'], $response['id'], $processedMessage);
        if (USE_COMET == 1) {
            $cometmessage = array();
            $cometresponse = array('to' => $_REQUEST['tid'], 'message' => $handwrite_language[1] . "<br/>{$text}", 'dir' => 0, 'type' => "handwrite");
            array_push($cometmessage, $cometresponse);
            publishCometMessages($cometmessage, $response['id']);
        }
        /*Uncomment to enable push notifications for CometChat Legacy Apps*/
        /*if (isset($_REQUEST['sendername']) && $pushNotifications == 1) {
                  pushMobileNotification($handwrite_language[2], $_REQUEST['sendername'], $_REQUEST['tid'], $_REQUEST['tid']);
          }*/
        /*Uncomment to enable push notifications for CometChat Legacy Apps*/
    }
}
$embed = '';
$embedcss = '';