function loadChatroomPro() { global $chatrooms_language; global $language; global $embed; global $embedcss; global $userid; global $moderatorUserIDs; global $lightboxWindows; $close = 'setTimeout("window.close()",2000);'; if (!empty($_GET['embed']) && $_GET['embed'] == 'web') { $embed = 'web'; $embedcss = 'embed'; $close = 'parent.closeCCPopup("loadChatroomPro");'; } $id = $_GET['roomid']; $uid = $_GET['inviteid']; $roomname = $_GET['roomname']; $owner = $_GET['owner']; $apiAccess = $_GET['apiAccess']; $options = ""; $caller = "window.opener."; if ($apiAccess) { $options = " <input type=button class='invitebutton' onclick=javascript:window.opener.parent.jqcc.cometchat.chatWith({$uid});{$close} value='" . $chatrooms_language[43] . "' />"; if ($lightboxWindows) { $options = " <input type=button class='invitebutton' onclick=javascript:parent.jqcc.cometchat.chatWith({$uid});{$close} value='" . $chatrooms_language[43] . "' />"; $caller = "\$('#cometchat_trayicon_chatrooms_iframe,.cometchat_embed_chatrooms',parent.document)[0].contentWindow."; } } if ($owner == 1 || in_array($userid, $moderatorUserIDs)) { $sql = "select createdby from cometchat_chatrooms where id = '" . mysql_real_escape_string($id) . "' limit 1"; $query = mysql_query($sql); $room = mysql_fetch_array($query); if (!in_array($uid, $moderatorUserIDs) && $uid != $room['createdby']) { $options = "<input type=button value='" . $chatrooms_language[40] . "' onClick=javascript:" . $caller . "kickUser({$uid},0);{$close} class='invitebutton' />\n\t\t\t<input type=button value='" . $chatrooms_language[41] . "' onClick=javascript:" . $caller . "banUser({$uid},0);{$close} class='invitebutton' />" . $options; } } if (defined('DEV_MODE') && DEV_MODE == '1') { echo mysql_error(); } $sql = getUserDetails($uid); if ($uid > 10000000) { $sql = getGuestDetails($uid); } $res = mysql_query($sql); $result = mysql_fetch_array($res); $link = fetchLink($result['link']); $avatar = getAvatar($result['avatar']); if ($link != '' && $uid < 10000000) { $options .= " <input type=button class='invitebutton' onClick=javascript:window.open('" . $link . "');" . $close . " value='" . $chatrooms_language[42] . "' />"; } echo <<<EOD <!DOCTYPE html> <html> \t<head> \t\t<title>{$result['username']}</title> \t\t<meta http-equiv="content-type" content="text/html; charset=utf-8"/> \t\t<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> \t\t<link type="text/css" rel="stylesheet" media="all" href="../../css.php?type=module&name=chatrooms" /> \t</head> \t<body> \t\t<form method="post"> \t\t\t<div class="container"> \t\t\t\t<div class="container_title {$embedcss}">{$result['username']}</div>\t \t\t\t\t<div class="chatroom_avatar"><img src="{$avatar}" height="50px" width="50px" /></div> \t\t\t\t<div class="control_buttons">{$options}</div>\t \t\t\t</div> \t\t</form> \t</body> </html> EOD; }
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ include dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "plugins.php"; if ($p_ < 2) { exit; } $id = $_GET['id']; $sql = getUserDetails($id); if ($guestsMode && $id >= 10000000) { $sql = getGuestDetails($id); } $query = mysql_query($sql); if (defined('DEV_MODE') && DEV_MODE == '1') { echo mysql_error(); } $user = mysql_fetch_array($query); if (function_exists('processName')) { $user['username'] = processName($user['username']); } $log = ''; $filename = 'Conversation with ' . $user['username'] . ' on ' . date('M jS Y'); $messages = array(); getChatboxData($id); $log .= 'Conversation with ' . $user['username'] . ' on ' . date('M jS Y'); $log .= "\r\n-------------------------------------------------------\r\n\r\n";
} $sql = "update cometchat_chatrooms set vidsession = '" . mysqli_real_escape_string($GLOBALS['dbh'], $newsessionid) . "' where id = '" . mysqli_real_escape_string($GLOBALS['dbh'], $grp) . "'"; $query = mysqli_query($GLOBALS['dbh'], $sql); $grp = $newsessionid; } else { $grp = $chatroom['vidsession']; } if (empty($_REQUEST['join'])) { sendChatroomMessage($grporg, $broadcast_language[9] . " <a href='javascript:void(0);' onclick=\"javascript:jqcc.ccbroadcast.join('" . $grporg . "');\">" . $broadcast_language[10] . "</a>", 0); } $avchat_token = $apiObj->generateToken($grp); } $name = ""; $sql = getUserDetails($userid); if ($guestsMode && $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']; } $name = urlencode($name); $baseUrl = BASE_URL; $embed = ''; $embedcss = ''; $resize = 'window.resizeTo('; $invitefunction = 'window.open'; if (!empty($_REQUEST['embed']) && $_REQUEST['embed'] == 'web') {
function getStatus() { global $response; global $userid; global $status; global $startOffline; global $processFurther; global $channelprefix; global $language; global $cookiePrefix; global $announcementpushchannel; global $bannedUserIDs; if ($userid > 10000000) { $sql = getGuestDetails($userid); } else { $sql = getUserDetails($userid); } $query = mysqli_query($GLOBALS['dbh'], $sql); if (defined('DEV_MODE') && DEV_MODE == '1') { echo mysqli_error($GLOBALS['dbh']); } if (mysqli_num_rows($query) > 0) { $chat = mysqli_fetch_assoc($query); if (!empty($_REQUEST['callbackfn'])) { $_SESSION['cometchat']['startoffline'] = 1; } if ($startOffline == 1 && empty($_SESSION['cometchat']['startoffline'])) { $_SESSION['cometchat']['startoffline'] = 1; $chat['status'] = 'offline'; setStatus('offline'); $_SESSION['cometchat']['cometchat_sessionvars']['buddylist'] = 0; $processFurther = 0; } else { if (empty($chat['status'])) { $chat['status'] = 'available'; } else { if ($chat['status'] == 'away') { $chat['status'] = 'available'; setStatus('available'); } if ($chat['status'] == 'offline') { $processFurther = 0; $_SESSION['cometchat']['cometchat_sessionvars']['buddylist'] = 0; } } } if (empty($chat['message'])) { $chat['message'] = $status[$chat['status']]; } if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . "announcements" . DIRECTORY_SEPARATOR . "config.php")) { include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . "announcements" . DIRECTORY_SEPARATOR . "config.php"; } $chat['message'] = html_entity_decode($chat['message']); $ccmobileauth = 0; if (!empty($_REQUEST['callbackfn']) && $_REQUEST['callbackfn'] == 'ccmobiletab') { $ccmobileauth = md5($_SESSION['basedata'] . 'cometchat'); } if (empty($chat['ch'])) { if (defined('KEY_A') && defined('KEY_B') && defined('KEY_C')) { $key = KEY_A . KEY_B . KEY_C; } $chat['ch'] = md5($chat['userid'] . $key); } $s = array('id' => $chat['userid'], 'n' => $chat['username'], 'l' => fetchLink($chat['link']), 'a' => getAvatar($chat['avatar']), 's' => $chat['status'], 'm' => $chat['message'], 'push_channel' => 'C_' . md5($channelprefix . "USER_" . $userid . BASE_URL), 'ccmobileauth' => $ccmobileauth, 'push_an_channel' => $announcementpushchannel, 'webrtc_prefix' => $channelprefix, 'ch' => $chat['ch'], 'ls' => $chat['lastseen'], 'lstn' => $chat['lastseensetting']); if (in_array($chat['userid'], $bannedUserIDs)) { $s['b'] = 1; } $response['userstatus'] = $_SESSION['cometchat']['user'] = $s; } else { if (USE_CCAUTH != 1) { $response['loggedout'] = '1'; $response['logout_message'] = $language[30]; setcookie($cookiePrefix . 'guest', '', time() - 3600, '/'); setcookie($cookiePrefix . 'state', '', time() - 3600, '/'); unset($_SESSION['cometchat']); } } }
function getStatus() { global $response; global $userid; global $status; global $startOffline; global $processFurther; global $chromeReorderFix; if ($userid > 10000000) { $sql = getGuestDetails($userid); } else { $sql = getUserDetails($userid); } $query = mysqli_query($GLOBALS['dbh'], $sql); if (defined('DEV_MODE') && DEV_MODE == '1') { echo mysqli_error($GLOBALS['dbh']); } $chat = mysqli_fetch_assoc($query); if (!empty($_REQUEST['callbackfn'])) { $_SESSION['cometchat']['startoffline'] = 1; } if ($startOffline == 1 && empty($_SESSION['cometchat']['startoffline'])) { $_SESSION['cometchat']['startoffline'] = 1; $chat['status'] = 'offline'; setStatus('offline'); $_SESSION['cometchat']['cometchat_sessionvars']['buddylist'] = 0; $processFurther = 0; } else { if (empty($chat['status'])) { $chat['status'] = 'available'; } else { if ($chat['status'] == 'away') { $chat['status'] = 'available'; setStatus('available'); } if ($chat['status'] == 'offline') { $processFurther = 0; $_SESSION['cometchat']['cometchat_sessionvars']['buddylist'] = 0; } } } if (empty($chat['message'])) { $chat['message'] = $status[$chat['status']]; } $chat['message'] = html_entity_decode($chat['message']); $s = array('id' => $chat['userid'], 'n' => $chat['username'], 'l' => fetchLink($chat['link']), 'a' => getAvatar($chat['userid']), 's' => $chat['status'], 'm' => $chat['message']); $response['userstatus'] = $s; }
function loadChatroomPro() { global $chatrooms_language; global $language; global $embed; global $embedcss; global $userid; global $moderatorUserIDs; global $lightboxWindows; $close = 'setTimeout("window.close()",2000);'; if (!empty($_GET['embed']) && $_GET['embed'] == 'web') { $embed = 'web'; $embedcss = 'embed'; $close = 'parent.closeCCPopup("loadChatroomPro");'; } $id = $_GET['roomid']; $cc_theme = ''; if (!empty($_GET['cc_theme'])) { $cc_theme = '&cc_theme=' . $_GET['cc_theme']; } $uid = $_GET['inviteid']; $owner = $_GET['owner']; $apiAccess = $_GET['apiAccess']; $options = ""; $status_area = ""; $caller = "window.opener."; $popoutmode = $_GET['popoutmode']; if ($apiAccess) { if ($lightboxWindows) { $caller = "\$('#cometchat_trayicon_chatrooms_iframe,.cometchat_embed_chatrooms',parent.document)[0].contentWindow."; $options = " <input type=button class='invitebutton chat' uid=" . $uid . " value='" . $chatrooms_language[43] . "' />"; if ($popoutmode && $popoutmode != 'null') { $options = " <input type=button class='invitebutton chat' uid=" . $uid . " value='" . $chatrooms_language[43] . "' />"; } } else { $options = " <input type=button class='invitebutton chat' uid=" . $uid . " value='" . $chatrooms_language[43] . "' />"; if ($popoutmode && $popoutmode != 'null') { $options = " <input type=button class='invitebutton chat' uid=" . $uid . " value='" . $chatrooms_language[43] . "' />"; } } } if ($owner == 1 || in_array($userid, $moderatorUserIDs)) { $sql = "select createdby from cometchat_chatrooms where id = '" . mysqli_real_escape_string($GLOBALS['dbh'], $id) . "' limit 1"; $query = mysqli_query($GLOBALS['dbh'], $sql); $room = mysqli_fetch_assoc($query); if (!in_array($uid, $moderatorUserIDs) && $uid != $room['createdby']) { $options = "<input type=button value='" . $chatrooms_language[40] . "' uid = " . $uid . " class='invitebutton kickBan'/>\n\t\t\t<input type=button value='" . $chatrooms_language[41] . "' uid = " . $uid . " class='invitebutton kickBan' />" . $options; } } if (defined('DEV_MODE') && DEV_MODE == '1') { echo mysqli_error($GLOBALS['dbh']); } $sql = getUserDetails($uid); if ($uid > 10000000) { $sql = getGuestDetails($uid); } $res = mysqli_query($GLOBALS['dbh'], $sql); $result = mysqli_fetch_assoc($res); $link = fetchLink($result['link']); $avatar = getAvatar($result['avatar']); $status = $result['status']; $statusMessage = $result['message']; $isDevice = $result['isdevice']; $icon = ''; if ($statusMessage == null && $status == 'available') { $statusMessage = $language[30]; } else { if ($statusMessage == null && $status == 'away') { $statusMessage = $language[34]; } else { if ($statusMessage == null && $status == 'busy') { $statusMessage = $language[31]; } else { if ($statusMessage == null && $status == 'offline') { $statusMessage = $language[32]; } else { if ($statusMessage == null && $status == 'invisible') { $statusMessage = $language[33]; } } } } } $usercontentstatus = $status; if ($isDevice == 1) { $usercontentstatus = 'mobile cometchat_mobile_' . $status; $icon = '<div class="cometchat_dot"></div>'; } $status_area = '<span class="cometchat_userscontentdot cometchat_userscontentdot_synergy cometchat_' . $usercontentstatus . ' cometchat_' . $usercontentstatus . '_synergy">' . $icon . '</span><span class="status_messagearea">' . $statusMessage . '</span>'; if ($link != '' && $uid < 10000000) { $options .= " <input type=button class='invitebutton' onClick=javascript:window.open('" . $link . "');" . $close . " value='" . $chatrooms_language[42] . "' />"; } echo <<<EOD <!DOCTYPE html> <html> \t<head> \t\t<title>{$result['username']}</title> \t\t<meta http-equiv="content-type" content="text/html; charset=utf-8"/> \t\t<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> \t\t<link type="text/css" rel="stylesheet" media="all" href="../../css.php?type=module&name=chatrooms{$cc_theme}" /> \t\t<script> \t\t\$('.kickBan').live('click',function(){ \t\t var uid = \$(this).attr('uid'); \t\t var method = \$(this).val(); \t\t if(method == 'Kick'){ \t\t \taction = 'kickChatroomUser'; \t\t } else { \t\t \taction = 'banChatroomUser'; \t\t } \t var controlparameters = {"type":"modules", "name":"cometchat", "method":action, "params":{"uid":uid, "allowed":"1", "chatroommode":"1"}}; \t controlparameters = JSON.stringify(controlparameters); \t if(typeof(parent) != 'undefined' && parent != null && parent != self){ \t \tparent.postMessage('CC^CONTROL_'+controlparameters,'*'); \t var controlparameters = {'type':'plugins', 'name':'loadChatroomPro', 'method':'closeCCPopup', 'params':{}}; controlparameters = JSON.stringify(controlparameters); parent.postMessage('CC^CONTROL_'+controlparameters,'*'); \t } else { \t \twindow.opener.postMessage('CC^CONTROL_'+controlparameters,'*'); \t \twindow.close(); \t\t\t} \t\t}); \t\t\$('.chat').live('click',function(){ \t\t\tvar uid = \$(this).attr('uid'); \t\t\tvar controlparameters = {"type":"modules", "name":"cometchat", "method":"chatWith", "params":{"uid":uid,"chatroommode":"0"}}; \t controlparameters = JSON.stringify(controlparameters); \t if(typeof(parent) != 'undefined' && parent != null && parent != self){ \t parent.postMessage('CC^CONTROL_'+controlparameters,'*'); \t var controlparameters = {'type':'plugins', 'name':'loadChatroomPro', 'method':'closeCCPopup', 'params':{}}; controlparameters = JSON.stringify(controlparameters); parent.postMessage('CC^CONTROL_'+controlparameters,'*'); \t } else { \t window.opener.postMessage('CC^CONTROL_'+controlparameters,'*'); \t window.close(); \t } \t\t}); \t\t</script> \t</head> \t<body> \t\t<form method="post"> \t\t\t<div class="container"> \t\t\t\t<div class="container_title {$embedcss}">{$result['username']}</div> \t\t\t\t<div class="container_body {$embedcss}" style='height:50px;'> \t\t\t\t\t<div class="chatroom_avatar"><img src="{$avatar}" height="50px" width="50px" /></div> \t\t\t\t\t<div class="status_container"> \t\t\t\t\t\t<div class="status_area">{$status_area}</div> \t\t\t\t\t\t<div class="control_buttons">{$options}</div> \t\t\t\t\t</div> \t\t\t\t\t<div style='clear:both'></div> \t\t\t\t</div> \t\t\t</div> \t\t</form> \t\t<script type='text/javascript'> \t\t\tif(typeof \$ != 'undefined') \t\t\t\$(document).ready(function(){ \t\t\t\tsum = 0; \t\t\t\t\$('.control_buttons input').each(function(i,o){ \t\t\t\t\tsum += \$(o).outerWidth(false); \t\t\t\t}); \t\t\t\tsetTimeout(function(){ \t\t\t\t\twindow.resizeTo(sum+140, (\$('form').outerHeight(false)+window.outerHeight-window.innerHeight+10)); \t\t\t\t\t//140 = container.padding(10*2) + avatar(50) + buttons.margin-left(20) + buttons.margin-right(20) + 30 (container margin(2%)+ inter-button spacing(taking worst case scenario)) \t\t\t\t\t//10 = container.margin(5*2) \t\t\t\t},500); \t\t\t\tif(typeof(parent) != 'undefined'){ \t\t\t\t\tvar controlparameters = {'type':'module', 'name':'chatrooms', 'method':'resizeCCPopup', 'params':{"id":"loadChatroomPro", "height":sum+140, "width":80}}; \tcontrolparameters = JSON.stringify(controlparameters); \tif(typeof(window.opener) == null){ \t\twindow.opener.postMessage('CC^CONTROL_'+controlparameters,'*'); \t}else{ \t\tparent.postMessage('CC^CONTROL_'+controlparameters,'*'); \t} \t\t\t\t} \t\t\t\t//Height 80 = container_body.height(50) + embed.padding(10*2) + container.margin(5*2) \t\t\t}); \t\t</script> \t</body> </html> EOD; }
$response = array(); $messages = array(); $status['available'] = $language[30]; $status['busy'] = $language[31]; $status['offline'] = $language[32]; $status['invisible'] = $language[33]; $status['away'] = $language[34]; if (!empty($_REQUEST['userid'])) { $fetchid = $_REQUEST['userid']; } else { $fetchid = $userid; } $time = getTimeStamp(); $sql = getUserDetails($fetchid); if ($guestsMode && $fetchid >= 10000000) { $sql = getGuestDetails($fetchid); } $query = mysql_query($sql); if (defined('DEV_MODE') && DEV_MODE == '1') { echo mysql_error(); } $chat = mysql_fetch_array($query); if ($time - processTime($chat['lastactivity']) < ONLINE_TIMEOUT && $chat['status'] != 'invisible' && $chat['status'] != 'offline') { if ($chat['status'] != 'busy' && $chat['status'] != 'away') { $chat['status'] = 'available'; } } else { $chat['status'] = 'offline'; } if ($chat['message'] == null) { $chat['message'] = $status[$chat['status']];
function sendChatroomMessage($to = 0, $message = '', $notsilent = 1) { global $userid; global $cookiePrefix; global $bannedUserIDs; 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 = mysqli_real_escape_string($GLOBALS['dbh'],$_POST['message']); $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); switch ($controlparameters['name']) { case 'avchat': $grp = $controlparameters['params']['grp']; switch ($controlparameters['method']) { case 'endcall': $message = 'CC^CONTROL_AVCHAT_END_CHATROOM_CALL' . $grp; break; case 'rejectcall': $message = 'CC^CONTROL_AVCHAT_REJECT_CHATROOM_CALL' . $grp; break; case 'noanswer': $message = 'CC^CONTROL_AVCHAT_NO_ANSWER_CHATROOM' . $grp; break; case 'canceloutgoingcall': $message = 'CC^CONTROL_AVCHAT_CANCEL_CALL' . $grp; break; case 'busycall': $message = 'CC^CONTROL_AVCHAT_BUSY_CALL' . $grp; break; default: $message = ''; break; } break; case 'audiochat': $grp = $controlparameters['params']['grp']; switch ($controlparameters['method']) { case 'endcall': $message = 'CC^CONTROL_AUDIOCHAT_END_CHATROOM_CALL' . $grp; break; case 'rejectcall': $message = 'CC^CONTROL_AUDIOCHAT_REJECT_CHATROOM_CALL' . $grp; break; case 'noanswer': $message = 'CC^CONTROL_AUDIOCHAT_NO_ANSWER_CHATROOM' . $grp; break; case 'canceloutgoingcall': $message = 'CC^CONTROL_AUDIOCHAT_CANCEL_CALL' . $grp; break; case 'busycall': $message = 'CC^CONTROL_AUDIOCHAT_BUSY_CALL' . $grp; break; default: $message = ''; break; } break; case 'broadcast': $grp = $controlparameters['params']['grp']; switch ($controlparameters['method']) { case 'endcall': $message = 'CC^CONTROL_BROADCAST_END_CHATROOM_CALL' . $grp; break; default: $message = ''; break; } 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) { $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) { $styleStart = '<span style="color:#' . mysqli_real_escape_string($GLOBALS['dbh'], $_COOKIE[$cookiePrefix . 'chatroomcolor']) . '">'; $styleEnd = '</span>'; } if (USE_COMET == 1 && COMET_CHATROOMS == 1) { $comet = new Comet(KEY_A, KEY_B); 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) . "','" . getTimeStamp() . "')"; $query = mysqli_query($GLOBALS['dbh'], $sql); $insertedid = mysqli_insert_id($GLOBALS['dbh']); if (defined('DEV_MODE') && DEV_MODE == '1') { echo mysqli_error($GLOBALS['dbh']); } $timestamp = getTimeStamp(); $info = $comet->publish(array('channel' => md5('chatroom_' . $to . KEY_A . KEY_B . KEY_C), 'message' => array("id" => $insertedid, "from" => $name, "fromid" => $userid, "message" => $styleStart . $message . $styleEnd, "sent" => getTimeStamp()))); if ($notsilent == 1) { sendCCResponse(json_encode(array("id" => $insertedid, "m" => $styleStart . $message . $styleEnd))); } } } 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'], getTimeStamp()) . "')"; $query = mysqli_query($GLOBALS['dbh'], $sql); $insertedid = mysqli_insert_id($GLOBALS['dbh']); if (defined('DEV_MODE') && DEV_MODE == '1') { echo mysqli_error($GLOBALS['dbh']); } if ($notsilent == 1) { sendCCResponse(json_encode(array("id" => $insertedid, "m" => $styleStart . $message . $styleEnd))); } } parsePusher($to, $insertedid, $message, '1'); $sql = "update cometchat_chatrooms set lastactivity = '" . mysqli_real_escape_string($GLOBALS['dbh'], getTimeStamp()) . "' where id = '" . mysqli_real_escape_string($GLOBALS['dbh'], $to) . "'"; $query = mysqli_query($GLOBALS['dbh'], $sql); if ($notsilent == 0) { return $insertedid; } }
function getStatus() { global $response; global $userid; global $status; global $startOffline; global $processFurther; if ($userid > 10000000) { $sql = getGuestDetails($userid); } else { $sql = getUserDetails($userid); } $query = mysqli_query($GLOBALS['dbh'], $sql); if (defined('DEV_MODE') && DEV_MODE == '1') { echo mysqli_error($GLOBALS['dbh']); } $chat = mysqli_fetch_assoc($query); if (!empty($_REQUEST['callbackfn'])) { $_SESSION['cometchat']['startoffline'] = 1; } if ($startOffline == 1 && empty($_SESSION['cometchat']['startoffline'])) { $_SESSION['cometchat']['startoffline'] = 1; $chat['status'] = 'offline'; setStatus('offline'); $_SESSION['cometchat']['cometchat_sessionvars']['buddylist'] = 0; $processFurther = 0; } else { if (empty($chat['status'])) { $chat['status'] = 'available'; } else { if ($chat['status'] == 'away') { $chat['status'] = 'available'; setStatus('available'); } if ($chat['status'] == 'offline') { $processFurther = 0; $_SESSION['cometchat']['cometchat_sessionvars']['buddylist'] = 0; } } } if (empty($chat['message'])) { $chat['message'] = $status[$chat['status']]; } $channelprefix = ''; if (preg_match('/www\\./', $_SERVER['HTTP_HOST'])) { $channelprefix = $_SERVER['HTTP_HOST']; } else { $channelprefix = 'www.' . $_SERVER['HTTP_HOST']; } $chat['message'] = html_entity_decode($chat['message']); $ccmobileauth = 0; if (!empty($_REQUEST['callbackfn']) && $_REQUEST['callbackfn'] == 'ccmobiletab') { $ccmobileauth = md5($userid . 'cometchat'); } $s = array('id' => $chat['userid'], 'n' => $chat['username'], 'l' => fetchLink($chat['link']), 'a' => getAvatar($chat['avatar']), 's' => $chat['status'], 'm' => $chat['message'], 'push_channel' => 'C_' . md5($channelprefix . "USER_" . $userid . BASE_URL), 'ccmobileauth' => $ccmobileauth); $response['userstatus'] = $_SESSION['cometchat']['user'] = $s; }
function sendChatroomMessage($to = 0, $message = '', $notsilent = 1) { global $userid; global $cookiePrefix; global $bannedUserIDs; 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 = $_POST['currentroom']; $message = $_POST['message']; } if ($notsilent !== 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) { $styleStart = '<span style="color:#' . $_COOKIE[$cookiePrefix . 'chatroomcolor'] . '">'; $styleEnd = '</span>'; } if (USE_COMET == 1 && COMET_CHATROOMS == 1) { $insertedid = getTimeStamp() . rand(100, 999); if ($notsilent == 1) { sendCCResponse(json_encode(array("id" => $insertedid, "m" => $styleStart . $message . $styleEnd))); } $comet = new Comet(KEY_A, KEY_B); 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)) { $info = $comet->publish(array('channel' => md5('chatroom_' . $to . KEY_A . KEY_B . KEY_C), 'message' => array("from" => $name, "fromid" => $userid, "message" => $styleStart . $message . $styleEnd, "sent" => $insertedid))); if (defined('SAVE_LOGS') && SAVE_LOGS == 1) { $sql = "insert into cometchat_chatroommessages (userid,chatroomid,message,sent) values ('" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "', '" . mysqli_real_escape_string($GLOBALS['dbh'], $to) . "','" . $styleStart . mysqli_real_escape_string($GLOBALS['dbh'], $message) . $styleEnd . "','" . getTimeStamp() . "')"; $query = mysqli_query($GLOBALS['dbh'], $sql); } } } 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) . "','" . $styleStart . mysqli_real_escape_string($GLOBALS['dbh'], $message) . $styleEnd . "','" . getTimeStamp() . "')"; $query = mysqli_query($GLOBALS['dbh'], $sql); $insertedid = mysqli_insert_id($GLOBALS['dbh']); if ($notsilent == 1) { sendCCResponse(json_encode(array("id" => $insertedid, "m" => $styleStart . $message . $styleEnd))); } if (defined('DEV_MODE') && DEV_MODE == '1') { echo mysqli_error($GLOBALS['dbh']); } } parsePusher($to, $insertedid, $message, '1'); $sql = "update cometchat_chatrooms set lastactivity = '" . getTimeStamp() . "' where id = '" . mysqli_real_escape_string($GLOBALS['dbh'], $to) . "'"; $query = mysqli_query($GLOBALS['dbh'], $sql); if ($notsilent != 0) { return $insertedid; } }
function getStatus() { global $response; global $userid; global $status; global $startOffline; global $processFurther; global $channelprefix; if ($userid > 10000000) { $sql = getGuestDetails($userid); } else { $sql = getUserDetails($userid); } $query = mysqli_query($GLOBALS['dbh'], $sql); if (defined('DEV_MODE') && DEV_MODE == '1') { echo mysqli_error($GLOBALS['dbh']); } $chat = mysqli_fetch_assoc($query); if (!empty($_REQUEST['callbackfn'])) { $_SESSION['cometchat']['startoffline'] = 1; } if ($startOffline == 1 && empty($_SESSION['cometchat']['startoffline'])) { $_SESSION['cometchat']['startoffline'] = 1; $chat['status'] = 'offline'; setStatus('offline'); $_SESSION['cometchat']['cometchat_sessionvars']['buddylist'] = 0; $processFurther = 0; } else { if (empty($chat['status'])) { $chat['status'] = 'available'; } else { if ($chat['status'] == 'away') { $chat['status'] = 'available'; setStatus('available'); } if ($chat['status'] == 'offline') { $processFurther = 0; $_SESSION['cometchat']['cometchat_sessionvars']['buddylist'] = 0; } } } if (empty($chat['message'])) { $chat['message'] = $status[$chat['status']]; } $announcementpushchannel = ''; if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . "announcements" . DIRECTORY_SEPARATOR . "config.php")) { include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . "announcements" . DIRECTORY_SEPARATOR . "config.php"; } $chat['message'] = html_entity_decode($chat['message']); $ccmobileauth = 0; if (!empty($_REQUEST['callbackfn']) && $_REQUEST['callbackfn'] == 'ccmobiletab') { $ccmobileauth = md5($_SESSION['basedata'] . 'cometchat'); } $s = array('id' => $chat['userid'], 'n' => $chat['username'], 'l' => fetchLink($chat['link']), 'a' => getAvatar($chat['avatar']), 's' => $chat['status'], 'm' => $chat['message'], 'push_channel' => 'C_' . md5($channelprefix . "USER_" . $userid . BASE_URL), 'ccmobileauth' => $ccmobileauth, 'push_an_channel' => $announcementpushchannel, 'webrtc_prefix' => $channelprefix); $response['userstatus'] = $_SESSION['cometchat']['user'] = $s; }
function loadChatroomPro() { global $chatrooms_language; global $language; global $embed; global $embedcss; global $userid; global $moderatorUserIDs; global $lightboxWindows; global $showchatbutton; global $chromeReorderFix; $close = 'setTimeout("window.close()",2000);'; $callbackfn = ''; if (!empty($_REQUEST['callbackfn'])) { $callbackfn = $_REQUEST['callbackfn']; } if (!empty($_GET['embed']) && $_GET['embed'] == 'web') { $embed = 'web'; $embedcss = 'embed'; $close = 'parent.closeCCPopup("loadChatroomPro");'; } $callerWindow = ''; if (!empty($_REQUEST['caller'])) { $callerWindow = $_REQUEST['caller']; } $id = mysqli_real_escape_string($GLOBALS['dbh'], $_GET['roomid']); $cc_theme = ''; if (!empty($_GET['cc_theme'])) { $cc_theme = '&cc_theme=' . $_GET['cc_theme']; } $uid = mysqli_real_escape_string($GLOBALS['dbh'], $_GET['inviteid']); $owner = $_GET['owner']; $apiAccess = 0; if (!empty($_GET['apiAccess']) && $_GET['apiAccess'] != 'undefined') { $apiAccess = $_GET['apiAccess']; } $options = ""; $status_area = ""; $popoutmode = $_GET['popoutmode']; $onlineCacheKey = 'all_online'; if ($userid > 10000000) { $onlineCacheKey .= 'guest'; } if (!is_array($buddyList = getCache($onlineCacheKey))) { $buddyList = array(); $sql = getFriendsList($userid, $time); if ($guestsMode) { $sql = getGuestsList($userid, $time, $sql); } $query = mysqli_query($GLOBALS['dbh'], $sql); if (defined('DEV_MODE') && DEV_MODE == '1') { echo mysqli_error($GLOBALS['dbh']); } while ($chat = mysqli_fetch_assoc($query)) { if ($time - processTime($chat['lastactivity']) < ONLINE_TIMEOUT && $chat['status'] != 'invisible' && $chat['status'] != 'offline' || $chat['isdevice'] == 1) { if ($chat['status'] != 'busy' && $chat['status'] != 'away') { $chat['status'] = 'available'; } } else { $chat['status'] = 'offline'; } $avatar = getAvatar($chat['avatar']); if (!empty($chat['username'])) { if (function_exists('processName')) { $chat['username'] = processName($chat['username']); } if (!in_array($chat['userid'], $bannedUsers) && $chat['userid'] != $userid && ($hideOffline == 0 || $hideOffline == 1 && $chat['status'] != 'offline')) { $buddyList[$chromeReorderFix . $chat['userid']] = array('id' => $chat['userid'], 'n' => $chat['username'], 'a' => $avatar, 's' => $chat['status']); } } } } if (DISPLAY_ALL_USERS == 0 && MEMCACHE != 0 && USE_CCAUTH == 0) { $tempBuddyList = array(); if (!is_array($friendIds = getCache('friend_ids_of_' . $userid)) || $force == 1) { $friendIds = array(); $sql = getFriendsIds($userid); $query = mysqli_query($GLOBALS['dbh'], $sql); if (mysqli_num_rows($query) == 1) { $buddy = mysqli_fetch_assoc($query); $friendIds = explode(',', $buddy['friendid']); } else { while ($buddy = mysqli_fetch_assoc($query)) { $friendIds[] = $buddy['friendid']; } } setCache('friend_ids_of_' . $userid, $friendIds, 30); } foreach ($friendIds as $friendId) { $friendId = $chromeReorderFix . $friendId; if (!empty($buddyList[$friendId])) { $tempBuddyList[$friendId] = $buddyList[$friendId]; } } $buddyList = $tempBuddyList; } if (function_exists('hooks_forcefriends') && is_array(hooks_forcefriends())) { $buddyList = array_merge(hooks_forcefriends(), $buddyList); } if ($apiAccess && ($showchatbutton == '0' || $showchatbutton == '1' && array_key_exists($chromeReorderFix . $uid, $buddyList))) { $options = "<input type=button class='invitebutton chat' caller='" . $callerWindow . "' uid=" . $uid . " value='" . $chatrooms_language[43] . "' />"; } if ($owner == 1 || in_array($userid, $moderatorUserIDs)) { $sql = "select createdby from cometchat_chatrooms where id = '" . mysqli_real_escape_string($GLOBALS['dbh'], $id) . "' limit 1"; $query = mysqli_query($GLOBALS['dbh'], $sql); $room = mysqli_fetch_assoc($query); if (!in_array($uid, $moderatorUserIDs) && $uid != $room['createdby']) { $options = "<input type=button id='cc_kick' value='" . $chatrooms_language[40] . "' uid = " . $uid . " class='invitebutton kickBan'/>\n\t\t\t<input type=button id='cc_ban' value='" . $chatrooms_language[41] . "' uid = " . $uid . " class='invitebutton kickBan' />" . $options; } } if (defined('DEV_MODE') && DEV_MODE == '1') { echo mysqli_error($GLOBALS['dbh']); } $sql = getUserDetails($uid); if ($uid > 10000000) { $sql = getGuestDetails($uid); } $res = mysqli_query($GLOBALS['dbh'], $sql); $result = mysqli_fetch_assoc($res); $link = fetchLink($result['link']); $avatar = getAvatar($result['avatar']); $status = $result['status']; $statusMessage = $result['message']; $isDevice = $result['isdevice']; $icon = ''; if ($statusMessage == null && $status == 'available') { $statusMessage = $language[30]; } else { if ($statusMessage == null && $status == 'away') { $statusMessage = $language[34]; } else { if ($statusMessage == null && $status == 'busy') { $statusMessage = $language[31]; } else { if ($statusMessage == null && $status == 'offline') { $statusMessage = $language[32]; } else { if ($statusMessage == null && $status == 'invisible') { $statusMessage = $language[33]; } } } } } $usercontentstatus = $status; if ($isDevice == 1) { $usercontentstatus = 'mobile cometchat_mobile_' . $status; $icon = '<div class="cometchat_dot"></div>'; } $status_area = '<span class="cometchat_userscontentdot cometchat_userscontentdot_synergy cometchat_' . $usercontentstatus . ' cometchat_' . $usercontentstatus . '_synergy">' . $icon . '</span><span class="status_messagearea">' . $statusMessage . '</span>'; if ($link != '' && $uid < 10000000 && $callbackfn != 'desktop') { $options .= " <input type=button class='invitebutton' onClick=javascript:window.open('" . $link . "');" . $close . " value='" . $chatrooms_language[42] . "' />"; } echo <<<EOD <!DOCTYPE html> <html> \t<head> \t\t<title>{$result['username']}</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<script src="../../js.php?type=core&name=jquery"></script> \t\t<script> \t\t \$ = jQuery = jqcc; \t\t</script> \t\t<link type="text/css" rel="stylesheet" media="all" href="../../css.php?type=module&name=chatrooms{$cc_theme}" /> \t\t<script> \t\t\$('.kickBan').live('click',function(){ \t\t var uid = \$(this).attr('uid'); \t\t var method = \$(this).attr('id'); \t\t if(method == 'cc_kick'){ \t\t \taction = 'kickChatroomUser'; \t\t } else { \t\t \taction = 'banChatroomUser'; \t\t } \t var controlparameters = {"type":"modules", "name":"cometchat", "method":action, "params":{"uid":uid, "allowed":"1", "chatroommode":"1"}}; \t controlparameters = JSON.stringify(controlparameters); \t if(typeof(parent) != 'undefined' && parent != null && parent != self){ \t \tparent.postMessage('CC^CONTROL_'+controlparameters,'*'); \t var controlparameters = {'type':'plugins', 'name':'chatrooms', 'method':'closeCCPopup', 'params':{'name':'loadChatroomPro'}}; controlparameters = JSON.stringify(controlparameters); parent.postMessage('CC^CONTROL_'+controlparameters,'*'); \t } else { \t \twindow.opener.postMessage('CC^CONTROL_'+controlparameters,'*'); \t \twindow.close(); \t\t\t} \t\t}); \t\t\$('.chat').live('click',function(){ \t\t\tvar uid = \$(this).attr('uid'); \t\t\tvar caller = \$(this).attr('caller'); \t\t\tvar callbackfn="<?php echo {$callbackfn}; ?>"; \t\t\tvar controlparameters = {"type":"modules", "name":"cometchat", "method":"chatWith", "params":{"uid":uid, "chatroommode":"0", "caller":caller}}; \t\t\tif(callbackfn){ \t\t\t\tcontrolparameters = {"type":"modules", "name":"cometchat", "method":"chatWith", "params":{"uid":uid, "chatroommode":"0"}}; \t\t\t} \t controlparameters = JSON.stringify(controlparameters); \t if(typeof(parent) != 'undefined' && parent != null && parent != self){ \t parent.postMessage('CC^CONTROL_'+controlparameters,'*'); \t var controlparameters = {'type':'plugins', 'name':'chatrooms', 'method':'closeCCPopup', 'params':{'name':'loadChatroomPro'}}; controlparameters = JSON.stringify(controlparameters); parent.postMessage('CC^CONTROL_'+controlparameters,'*'); \t } else { \t window.opener.postMessage('CC^CONTROL_'+controlparameters,'*'); \t window.close(); \t } \t\t}); \t\t</script> \t</head> \t<body> \t\t<form method="post"> \t\t\t<div class="cometchat_wrapper"> \t\t\t\t<div class="container_title {$embedcss}">{$result['username']}</div> \t\t\t\t<div class="container_body {$embedcss}" style='height:auto'> \t\t\t\t\t<div class="chatroom_avatar"><img src="{$avatar}" height="50px" width="50px" /></div> \t\t\t\t\t<div class="status_container"> \t\t\t\t\t\t<div class="status_area">{$status_area}</div> \t\t\t\t\t\t<div class="control_buttons">{$options}</div> \t\t\t\t\t</div> \t\t\t\t\t<div style='clear:both'></div> \t\t\t\t</div> \t\t\t</div> \t\t</form> \t\t<script type='text/javascript'> \t\t\tif(typeof \$ != 'undefined') \t\t\t\$(document).ready(function(){ \t\t\t\tsum = 0; \t\t\t\t\$('.control_buttons input').each(function(i,o){ \t\t\t\t\tsum += \$(o).outerWidth(false); \t\t\t\t}); \t\t\t\tsetTimeout(function(){ \t\t\t\t\twindow.resizeTo(sum+140, (\$('form').outerHeight(false)+window.outerHeight-window.innerHeight+10)); \t\t\t\t\t//140 = container.padding(10*2) + avatar(50) + buttons.margin-left(20) + buttons.margin-right(20) + 30 (container margin(2%)+ inter-button spacing(taking worst case scenario)) \t\t\t\t\t//10 = container.margin(5*2) \t\t\t\t},500); \t\t\t\tvar mobileDevice = navigator.userAgent.match(/ipad|ipod|iphone|android|windows ce|Windows Phone|blackberry|palm|symbian/i); \t\t\t\tif(typeof(parent) != 'undefined' && !mobileDevice){ \t\t\t\t\tvar controlparameters = {'type':'module', 'name':'chatrooms', 'method':'resizeCCPopup', 'params':{"id":"loadChatroomPro", "height":sum+178, "width":96}}; \tcontrolparameters = JSON.stringify(controlparameters); \tif(typeof(window.opener) == null){ \t\twindow.opener.postMessage('CC^CONTROL_'+controlparameters,'*'); \t}else{ \t\tparent.postMessage('CC^CONTROL_'+controlparameters,'*'); \t} \t\t\t\t} \t\t\t\t//Height 80 = container_body.height(50) + embed.padding(10*2) + container.margin(5*2) \t\t\t}); \t\t</script> \t</body> </html> EOD; }