Beispiel #1
0
function data()
{
    global $guestsMode;
    global $guestnamePrefix;
    $usertable = TABLE_PREFIX . DB_USERTABLE;
    $usertable_username = DB_USERTABLE_NAME;
    $usertable_userid = DB_USERTABLE_USERID;
    $guestpart = "";
    $criteria = "cometchat.id > '" . mysqli_real_escape_string($GLOBALS['dbh'], $_POST['timestamp']) . "' and ";
    $criteria2 = 'desc';
    if ($guestsMode) {
        $guestpart = "UNION (select cometchat.id id, cometchat.from, cometchat.to, cometchat.message, cometchat.sent, cometchat.read,CONCAT('{$guestnamePrefix}',f.name) fromu, CONCAT('{$guestnamePrefix}',t.name) tou from cometchat, cometchat_guests f, cometchat_guests t where {$criteria} f.id = cometchat.from and t.id = cometchat.to) UNION (select cometchat.id id, cometchat.from, cometchat.to, cometchat.message, cometchat.sent, cometchat.read, f." . $usertable_username . " fromu, CONCAT('{$guestnamePrefix}',t.name) tou from cometchat, " . $usertable . " f, cometchat_guests t where {$criteria} f." . $usertable_userid . " = cometchat.from and t.id = cometchat.to) UNION (select cometchat.id id, cometchat.from, cometchat.to, cometchat.message, cometchat.sent, cometchat.read, CONCAT('{$guestnamePrefix}',f.name) fromu, t." . $usertable_username . " tou from cometchat, cometchat_guests f, " . $usertable . " t where {$criteria} f.id = cometchat.from and t." . $usertable_userid . " = cometchat.to) ";
    }
    $response = array();
    $messages = array();
    if (empty($_POST['timestamp'])) {
        $criteria = '';
        $criteria2 = 'desc limit 20';
    }
    $sql = "(select cometchat.id id, cometchat.from, cometchat.to, cometchat.message, cometchat.sent, cometchat.read, f.{$usertable_username} fromu, t.{$usertable_username} tou from cometchat, {$usertable} f, {$usertable} t where {$criteria} f.{$usertable_userid} = cometchat.from and t.{$usertable_userid} = cometchat.to ) " . $guestpart . " order by id {$criteria2}";
    $query = mysqli_query($GLOBALS['dbh'], $sql);
    $timestamp = $_POST['timestamp'];
    while ($chat = mysqli_fetch_assoc($query)) {
        if (function_exists('processName')) {
            $chat['fromu'] = processName($chat['fromu']);
            $chat['tou'] = processName($chat['tou']);
        }
        $time = $chat['sent'] * 1000;
        if (strpos($chat['message'], 'CC^CONTROL_') === false) {
            array_unshift($messages, array('id' => $chat['id'], 'from' => $chat['from'], 'to' => $chat['to'], 'fromu' => $chat['fromu'], 'tou' => $chat['tou'], 'message' => $chat['message'], 'time' => $time));
        } elseif (strpos($chat['message'], 'sendSticker')) {
            $message = str_replace('CC^CONTROL_', '', $chat['message']);
            $message = json_decode($message);
            $category = $message->params->category;
            $key = $message->params->key;
            $image = '<img class="cometchat_stickerImage" type="image" src="' . BASE_URL . '/plugins/stickers/images/' . $category . '/' . $key . '.png">';
            array_unshift($messages, array('id' => $chat['id'], 'from' => $chat['from'], 'to' => $chat['to'], 'fromu' => $chat['fromu'], 'tou' => $chat['tou'], 'message' => $image, 'time' => $time));
        }
        if ($chat['id'] > $timestamp) {
            $timestamp = $chat['id'];
        }
    }
    $response['timestamp'] = $timestamp;
    $response['online'] = onlineusers();
    if (!empty($messages)) {
        $response['messages'] = $messages;
    }
    header('Content-type: application/json; charset=utf-8');
    echo json_encode($response);
    exit;
}
Beispiel #2
0
function unban()
{
    global $userid;
    global $chatrooms_language;
    global $language;
    global $embed;
    global $embedcss;
    global $guestsMode;
    global $basedata;
    global $chromeReorderFix;
    $status['available'] = $language[30];
    $status['busy'] = $language[31];
    $status['offline'] = $language[32];
    $status['invisible'] = $language[33];
    $status['away'] = $language[34];
    if (!empty($_REQUEST['callbackfn']) && $_REQUEST['callbackfn'] == 'mobileapp') {
        $id = mysqli_real_escape_string($GLOBALS['dbh'], $_REQUEST['roomid']);
    } else {
        $id = mysqli_real_escape_string($GLOBALS['dbh'], $_GET['roomid']);
        $inviteid = mysqli_real_escape_string($GLOBALS['dbh'], $_GET['inviteid']);
        $roomname = mysqli_real_escape_string($GLOBALS['dbh'], $_GET['roomname']);
        $popoutmode = mysqli_real_escape_string($GLOBALS['dbh'], $_GET['popoutmode']);
    }
    $cc_theme = '';
    if (!empty($_GET['cc_theme'])) {
        $cc_theme = '&cc_theme=' . $_GET['cc_theme'];
    }
    $time = getTimeStamp();
    $buddyList = array();
    $sql = "select DISTINCT " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " userid, " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_NAME . " username, " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_NAME . " link, " . DB_AVATARFIELD . " avatar, cometchat_status.lastactivity lastactivity, cometchat_status.isdevice isdevice, cometchat_status.status, cometchat_status.message from " . TABLE_PREFIX . DB_USERTABLE . " left join cometchat_status on " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " = cometchat_status.userid right join cometchat_chatrooms_users on " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " =cometchat_chatrooms_users.userid " . DB_AVATARTABLE . " where " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " <> '" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "' and cometchat_chatrooms_users.chatroomid = '" . mysqli_real_escape_string($GLOBALS['dbh'], $id) . "' and cometchat_chatrooms_users.isbanned ='1' group by userid order by username asc";
    if ($guestsMode) {
        $sql = getChatroomBannedGuests($id, $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)) {
        $avatar = getAvatar($chat['avatar']);
        if (!empty($chat['username'])) {
            if (function_exists('processName')) {
                $chat['username'] = processName($chat['username']);
            }
            $buddyList[$chromeReorderFix . $chat['userid']] = array('id' => $chat['userid'], 'n' => $chat['username'], 'a' => $avatar);
        }
    }
    if (!empty($_REQUEST['callbackfn']) && $_REQUEST['callbackfn'] == 'mobileapp') {
        $response['unban'] = $buddyList;
        echo json_encode($response);
        exit;
    }
    $s['count'] = '';
    foreach ($buddyList as $buddy) {
        $s['count'] .= '<div class="invite_1" onclick="javascript:document.getElementById(\'check_' . $buddy['id'] . '\').checked = document.getElementById(\'check_' . $buddy['id'] . '\').checked?false:true;"><div class="invite_2"><img height=30 width=30 src="' . $buddy['a'] . '" /></div><div class="invite_3"><span class="invite_name">' . $buddy['n'] . '</span><br/></div><input type="checkbox" onclick="javascript:document.getElementById(\'check_' . $buddy['id'] . '\').checked = document.getElementById(\'check_' . $buddy['id'] . '\').checked?false:true;" name="unban[]" value="' . $buddy['id'] . '" id="check_' . $buddy['id'] . '" class="invite_4" /></div>';
    }
    if ($s['count'] == '') {
        $s['count'] = $chatrooms_language[44];
    }
    echo <<<EOD
<!DOCTYPE html>
<html>
\t<head>
\t\t<title>{$chatrooms_language[21]}</title>
\t\t<meta name="viewport" content="user-scalable=0,width=device-width, height=device-heigth 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{$cc_theme}" />
\t\t<script src="../../js.php?type=core&name=jquery"></script>
\t\t<script>
\t\t\t\$ = jQuery = jqcc;
\t\t\t\$(function(){
\t\t\t\t\$('.invite_1').click(function() {
\t\t\t\t    var checked = \$( "input:checked" ).length;
\t\t\t\t    if(checked > 0){
\t\t\t\t    \t\$('.invitebutton').attr("disabled", false);
\t\t\t\t    }else{
\t\t\t\t    \t\$('.invitebutton').attr("disabled", true);
\t\t\t\t    }
\t\t\t\t});
\t\t\t});
\t\t</script>
\t</head>
\t<body>
\t\t<form method="post" action="chatrooms.php?action=unbanusers&embed={$embed}&basedata={$basedata}&popoutmode={&popoutmode}">
\t\t\t<div class="cometchat_wrapper">
\t\t\t\t<div class="container_title {$embedcss}">{$chatrooms_language[21]}</div>
\t\t\t\t<div class="container_body {$embedcss}">
\t\t\t\t\t{$s['count']}
\t\t\t\t\t<div style="clear:both"></div>
\t\t\t\t</div>
\t\t\t\t<div class="container_sub {$embedcss}">
\t\t\t\t\t<input type=submit value="Unban Users" class="invitebutton" disabled />
\t\t\t\t</div>
\t\t\t</div>
\t\t\t<input type="hidden" name="roomid" value="{$id}" />
\t\t\t<input type="hidden" name="inviteid" value="{$inviteid}" />
\t\t\t<input type="hidden" name="roomname" value="{$roomname}" />
\t\t</form>
\t</body>
</html>
EOD;
}
Beispiel #3
0
function unban()
{
    global $userid;
    global $chatrooms_language;
    global $language;
    global $embed;
    global $embedcss;
    $status['available'] = $language[30];
    $status['busy'] = $language[31];
    $status['offline'] = $language[32];
    $status['invisible'] = $language[33];
    $status['away'] = $language[34];
    $id = $_GET['roomid'];
    $inviteid = $_GET['inviteid'];
    $roomname = $_GET['roomname'];
    $time = getTimeStamp();
    $buddyList = array();
    $sql = "select DISTINCT " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " userid, " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_NAME . " username, " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_LASTACTIVITY . " lastactivity, " . DB_AVATARFIELD . " avatar, " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_NAME . " link,  cometchat_status.message, cometchat_status.status from " . TABLE_PREFIX . DB_USERTABLE . " left join cometchat_status on " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " = cometchat_status.userid right join cometchat_chatrooms_users on " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " =cometchat_chatrooms_users.userid " . DB_AVATARTABLE . " where " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " <> '" . mysql_real_escape_string($userid) . "' and cometchat_chatrooms_users.chatroomid = '" . mysql_real_escape_string($id) . "' and cometchat_chatrooms_users.isbanned ='1' order by username asc";
    $query = mysql_query($sql);
    if (defined('DEV_MODE') && DEV_MODE == '1') {
        echo mysql_error();
    }
    while ($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';
        }
        $avatar = getAvatar($chat['avatar']);
        if (!empty($chat['username'])) {
            if (function_exists('processName')) {
                $chat['username'] = processName($chat['username']);
            }
            $buddyList[] = array('id' => $chat['userid'], 'n' => $chat['username'], 's' => $chat['status'], 'a' => $avatar);
        }
    }
    if (function_exists('hooks_forcefriends') && is_array(hooks_forcefriends())) {
        $buddyList = array_merge(hooks_forcefriends(), $buddyList);
    }
    $s['available'] = '';
    $s['away'] = '';
    $s['busy'] = '';
    $s['offline'] = '';
    foreach ($buddyList as $buddy) {
        $s[$buddy['s']] .= '<div class="invite_1"><div class="invite_2" onclick="javascript:document.getElementById(\'check_' . $buddy['id'] . '\').checked = document.getElementById(\'check_' . $buddy['id'] . '\').checked?false:true;"><img height=30 width=30 src="' . $buddy['a'] . '" /></div><div class="invite_3" onclick="javascript:document.getElementById(\'check_' . $buddy['id'] . '\').checked = document.getElementById(\'check_' . $buddy['id'] . '\').checked?false:true;"><span class="invite_name">' . $buddy['n'] . '</span><br/><span class="invite_5">' . $status[$buddy['s']] . '</span></div><input type="checkbox" name="unban[]" value="' . $buddy['id'] . '" id="check_' . $buddy['id'] . '" class="invite_4" /></div>';
    }
    if ($s['available'] == '' && $s['busy'] == '' && $s['away'] == '' && $s['offline'] == '') {
        $s['available'] = $chatrooms_language[44];
    }
    echo <<<EOD
<!DOCTYPE html>
<html>
\t<head>
\t\t<title>{$chatrooms_language[21]}</title> 
\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</head>
\t<body>
\t\t<form method="post" action="chatrooms.php?action=unbanusers&embed={$embed}">
\t\t\t<div class="container">
\t\t\t\t<div class="container_title {$embedcss}">{$chatrooms_language[21]}</div>
\t\t\t\t<div class="container_body {$embedcss}">
\t\t\t\t\t{$s['available']}{$s['busy']}{$s['away']}{$s['offline']}
\t\t\t\t\t<div style="clear:both"></div>
\t\t\t\t</div>
\t\t\t\t<div class="container_sub {$embedcss}">
\t\t\t\t\t<input type=submit value="Unban Users" class="invitebutton" />
\t\t\t\t</div>
\t\t\t</div>\t
\t\t\t<input type="hidden" name="roomid" value="{$id}" />
\t\t\t<input type="hidden" name="inviteid" value="{$inviteid}" />
\t\t\t<input type="hidden" name="roomname" value="{$roomname}" />
\t\t</form>
\t</body>
</html>
EOD;
}
Beispiel #4
0
         $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') {
     $embed = 'web';
     $resize = "parent.resizeCCPopup('broadcast',";
     $embedcss = 'embed';
     $invitefunction = 'parent.loadCCPopup';
 }
Beispiel #5
0
function searchlogs()
{
    global $ts;
    global $usertable_userid;
    global $usertable_username;
    global $usertable;
    global $navigation;
    global $body;
    global $moderatorUserIDs;
    include_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'chatrooms' . DIRECTORY_SEPARATOR . 'config.php';
    $username = $_REQUEST['susername'];
    if (empty($username)) {
        // Base 64 Encoded
        $username = '******';
    }
    $sql = "select {$usertable_userid} id, {$usertable_username} username from {$usertable} where {$usertable_username} LIKE '%" . mysqli_real_escape_string($GLOBALS['dbh'], sanitize_core($username)) . "%'";
    $query = mysqli_query($GLOBALS['dbh'], $sql);
    $userslist = '';
    while ($user = mysqli_fetch_assoc($query)) {
        if (function_exists('processName')) {
            $user['username'] = processName($user['username']);
        }
        $moderator = '<a style="font-size: 11px; margin-top: 2px; margin-left: 5px; float: right; font-weight: bold; color: #0F5D7E;" href="?module=chatrooms&amp;action=makemoderatorprocess&amp;susername='******'&amp;moderatorid=' . $user['id'] . '&amp;ts=' . $ts . '"><img style="width: 16px;" title="Make Moderator" src="images/add_moderator.png"></a>';
        if (in_array($user['id'], $moderatorUserIDs)) {
            $moderator = '<a style="font-size: 11px; margin-top: 2px; margin-left: 5px; float: right; font-weight: bold; color: #0F5D7E;" href="?module=chatrooms&amp;action=removemoderatorprocess&amp;susername='******'&amp;moderatorid=' . $user['id'] . '&amp;ts=' . $ts . '"><img style="width: 16px;" title="Remove Moderator" src="images/remove_moderator.png"></a>';
        }
        $userslist .= '<li class="ui-state-default cursor_default"><span style="font-size:11px;float:left;margin-top:2px;margin-left:5px;">' . $user['username'] . ' - ' . $user['id'] . '</span>' . $moderator . '<div style="clear:both"></div></li>';
    }
    $body = <<<EOD
\t{$navigation}

\t<div id="rightcontent" style="float:left;width:720px;border-left:1px dotted #ccc;padding-left:20px;">
\t\t<h2>Search results</h2>
\t\t<h3>Please find the user id next to each username. <a href="?module=chatrooms&amp;action=finduser&amp;ts={$ts}">Click here to search again</a></h3>

\t\t<div>
\t\t\t<ul id="modules_logs">
\t\t\t\t{$userslist}
\t\t\t</ul>
\t\t</div>

\t\t<div style="clear:both;padding:7.5px;"></div>
\t</div>

\t<div style="clear:both"></div>

EOD;
    template();
}
Beispiel #6
0
<?php

include dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "modules.php";
$response = array();
$sql = "select DISTINCT " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " userid, " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_NAME . " username, " . DB_AVATARFIELD . " avatar , score, games from " . TABLE_PREFIX . DB_USERTABLE . " " . DB_AVATARTABLE . " join cometchat_games on " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " = cometchat_games.userid order by score desc";
$query = mysql_query($sql);
while ($game = mysql_fetch_array($query)) {
    if (function_exists('processName')) {
        $game['username'] = processName($game['username']);
    }
    $response[] = array('id' => $game['userid'], 'n' => $game['username'], 'a' => getAvatar($game['avatar']), 'gc' => $game['games'], 'tsc' => $game['score']);
}
echo json_encode($response);
Beispiel #7
0
        $embedcss = 'embed';
    }
    if (!empty($_GET['embed']) && $_GET['embed'] == 'desktop') {
        $embed = 'desktop';
        $embedcss = 'embed';
    }
    $usertable = TABLE_PREFIX . DB_USERTABLE;
    $usertable_username = DB_USERTABLE_NAME;
    $usertable_userid = DB_USERTABLE_USERID;
    $body = '';
    $number = 0;
    $sql = "select distinct(m.{$usertable_userid}) `id`, m.{$usertable_username} `name` from cometchat_block, {$usertable} m where m.{$usertable_userid} = toid and fromid = '" . mysql_real_escape_string($userid) . "'";
    $query = mysql_query($sql);
    while ($chat = mysql_fetch_array($query)) {
        if (function_exists('processName')) {
            $chat['name'] = processName($chat['name']);
        }
        ++$number;
        $body = <<<EOD
 {$body}
<div class="chat">
\t\t\t<div class="chatrequest"><b>{$number}</b></div> 
\t\t\t<div class="chatmessage">{$chat['name']}</div>
\t\t\t<div class="chattime"><a href="?action=unblock&id={$chat['id']}&basedata={$_REQUEST['basedata']}&embed={$embed}">{$block_language[4]}</a></div>
\t\t\t<div style="clear:both"></div>
</div> 

EOD;
    }
    if ($number == 0) {
        $body = <<<EOD
function getBuddyList()
{
    global $response;
    global $userid;
    global $db;
    global $status;
    global $hideOffline;
    global $plugins;
    global $guestsMode;
    $time = getTimeStamp();
    $buddyList = array();
    if (empty($_SESSION['cometchat']['cometchat_buddytime']) || $_REQUEST['initialize'] == 1 || $_REQUEST['f'] == 1 || !empty($_SESSION['cometchat']['cometchat_buddytime']) && $time - $_SESSION['cometchat']['cometchat_buddytime'] >= REFRESH_BUDDYLIST) {
        if ($_REQUEST['initialize'] == 1 && !empty($_SESSION['cometchat']['cometchat_buddyblh']) && $time - $_SESSION['cometchat']['cometchat_buddytime'] < REFRESH_BUDDYLIST) {
            $response['buddylist'] = $_SESSION['cometchat']['cometchat_buddyresult'];
            $response['blh'] = $_SESSION['cometchat']['cometchat_buddyblh'];
        } else {
            $blockList = array();
            if (in_array('block', $plugins)) {
                $sql = "(select toid as id from cometchat_block where fromid = '" . mysql_real_escape_string($userid) . "') union (select fromid as id from cometchat_block where toid = '" . mysql_real_escape_string($userid) . "') ";
                $query = mysql_query($sql);
                while ($user = mysql_fetch_array($query)) {
                    array_push($blockList, $user['id']);
                }
            }
            $sql = getFriendsList($userid, $time);
            if ($guestsMode) {
                $sql = getGuestsList($userid, $time, $sql);
            }
            $query = mysql_query($sql);
            if (defined('DEV_MODE') && DEV_MODE == '1') {
                echo mysql_error();
            }
            while ($chat = mysql_fetch_array($query)) {
                if (!in_array($chat['userid'], $blockList)) {
                    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']];
                    }
                    $link = getLink($chat['link']);
                    $avatar = getAvatar($chat['avatar']);
                    if (function_exists('processName')) {
                        $chat['username'] = processName($chat['username']);
                    }
                    if (empty($chat['grp'])) {
                        $chat['grp'] = '';
                    }
                    if (!empty($chat['username']) && ($hideOffline == 0 || $hideOffline == 1 && $chat['status'] != 'offline')) {
                        $buddyList[] = array('id' => $chat['userid'], 'n' => $chat['username'], 's' => $chat['status'], 'm' => $chat['message'], 'g' => $chat['grp'], 'a' => $avatar, 'l' => $link);
                    }
                }
            }
            if (function_exists('hooks_forcefriends') && is_array(hooks_forcefriends())) {
                $buddyList = array_merge(hooks_forcefriends(), $buddyList);
            }
            $buddyOrder = array();
            $buddyGroup = array();
            $buddyStatus = array();
            $buddyName = array();
            $buddyGuest = array();
            foreach ($buddyList as $key => $row) {
                if (empty($row['g'])) {
                    $row['g'] = '';
                }
                $buddyGroup[$key] = strtolower($row['g']);
                $buddyStatus[$key] = strtolower($row['s']);
                $buddyName[$key] = strtolower($row['n']);
                if ($row['g'] == '') {
                    $buddyOrder[$key] = 1;
                } else {
                    $buddyOrder[$key] = 0;
                }
                $buddyGuest[$key] = 0;
                if ($row['id'] > 10000000) {
                    $buddyGuest[$key] = 1;
                }
            }
            array_multisort($buddyOrder, SORT_ASC, $buddyGroup, SORT_STRING, $buddyStatus, SORT_STRING, $buddyGuest, SORT_ASC, $buddyName, SORT_STRING, $buddyList);
            $_SESSION['cometchat']['cometchat_buddytime'] = $time;
            $blh = md5(serialize($buddyList));
            if (empty($_REQUEST['blh']) || !empty($_REQUEST['blh']) && $blh != $_REQUEST['blh']) {
                $response['buddylist'] = $buddyList;
                $response['blh'] = $blh;
            }
            $_SESSION['cometchat']['cometchat_buddyresult'] = $buddyList;
            $_SESSION['cometchat']['cometchat_buddyblh'] = $blh;
        }
    }
}
Beispiel #9
0
function data()
{
    if (USE_COMET == 1 && SAVE_LOGS == 0) {
        echo 0;
    } else {
        global $guestsMode;
        global $guestnamePrefix;
        if (!empty($guestnamePrefix)) {
            $guestnamePrefix .= '-';
        }
        $usertable = TABLE_PREFIX . DB_USERTABLE;
        $usertable_username = DB_USERTABLE_NAME;
        $usertable_userid = DB_USERTABLE_USERID;
        $guestpart = "";
        $criteria = "cometchat.id > '" . mysqli_real_escape_string($GLOBALS['dbh'], $_POST['timestamp']) . "' and ";
        $criteria2 = 'desc';
        if ($guestsMode) {
            $guestpart = "UNION (select cometchat.id id, cometchat.from, cometchat.to, cometchat.message, cometchat.sent, cometchat.read,CONCAT('{$guestnamePrefix}',f.name) fromu, CONCAT('{$guestnamePrefix}',t.name) tou from cometchat, cometchat_guests f, cometchat_guests t where {$criteria} f.id = cometchat.from and t.id = cometchat.to) UNION (select cometchat.id id, cometchat.from, cometchat.to, cometchat.message, cometchat.sent, cometchat.read, f." . $usertable_username . " fromu, CONCAT('{$guestnamePrefix}',t.name) tou from cometchat, " . $usertable . " f, cometchat_guests t where {$criteria} f." . $usertable_userid . " = cometchat.from and t.id = cometchat.to) UNION (select cometchat.id id, cometchat.from, cometchat.to, cometchat.message, cometchat.sent, cometchat.read, CONCAT('{$guestnamePrefix}',f.name) fromu, t." . $usertable_username . " tou from cometchat, cometchat_guests f, " . $usertable . " t where {$criteria} f.id = cometchat.from and t." . $usertable_userid . " = cometchat.to) ";
        }
        $response = array();
        $messages = array();
        if (empty($_POST['timestamp'])) {
            $criteria = '';
            $criteria2 = 'desc limit 20';
        }
        $sql = "(select cometchat.id id, cometchat.from, cometchat.to, cometchat.message, cometchat.sent, cometchat.read, f.{$usertable_username} fromu, t.{$usertable_username} tou from cometchat, {$usertable} f, {$usertable} t where {$criteria} f.{$usertable_userid} = cometchat.from and t.{$usertable_userid} = cometchat.to ) " . $guestpart . " order by id {$criteria2}";
        $query = mysqli_query($GLOBALS['dbh'], $sql);
        $timestamp = $_POST['timestamp'];
        while ($chat = mysqli_fetch_assoc($query)) {
            if (function_exists('processName')) {
                $chat['fromu'] = processName($chat['fromu']);
                $chat['tou'] = processName($chat['tou']);
            }
            $time = $chat['sent'] * 1000;
            if (strpos($chat['message'], 'CC^CONTROL_') === false) {
                array_unshift($messages, array('id' => $chat['id'], 'from' => $chat['from'], 'to' => $chat['to'], 'fromu' => $chat['fromu'], 'tou' => $chat['tou'], 'message' => $chat['message'], 'time' => $time));
            }
            if ($chat['id'] > $timestamp) {
                $timestamp = $chat['id'];
            }
        }
        $response['timestamp'] = $timestamp;
        $response['online'] = onlineusers();
        if (!empty($messages)) {
            $response['messages'] = $messages;
        }
        header('Content-type: application/json; charset=utf-8');
        echo json_encode($response);
    }
    exit;
}
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;
    }
}
Beispiel #11
0
\t<body>
\t<div class="container">
\t<div class="container_title {$embedcss}" >{$block_language[3]}</div>

\t<div class="container_body {$embedcss}">

\t{$body}

\t</div>
\t</div>
\t</div>
\t</body>
\t</html>
EOD;
    } else {
        $response = array();
        while ($chat = mysqli_fetch_assoc($query)) {
            if (function_exists('processName')) {
                $blockedName = processName($chat['name']);
            } else {
                $blockedName = $chat['name'];
            }
            $blockedID = $chat['id'];
            $response[$blockedID] = array('id' => $blockedID, 'name' => $blockedName);
        }
        if (empty($response)) {
            $response = json_decode('{}');
        }
        echo json_encode($response);
    }
}
function getBuddyList()
{
    global $response;
    global $userid;
    global $db;
    global $status;
    global $hideOffline;
    global $plugins;
    global $guestsMode;
    global $cookiePrefix;
    global $chromeReorderFix;
    global $blockpluginmode;
    global $bannedUserIDs;
    $time = getTimeStamp();
    if (empty($_SESSION['cometchat']['cometchat_buddytime']) || $_REQUEST['initialize'] == 1 || $_REQUEST['f'] == 1 || !empty($_SESSION['cometchat']['cometchat_buddytime']) && ($time - $_SESSION['cometchat']['cometchat_buddytime'] >= REFRESH_BUDDYLIST || MEMCACHE != 0)) {
        if ($_REQUEST['initialize'] == 1 && !empty($_SESSION['cometchat']['cometchat_buddyblh']) && $time - $_SESSION['cometchat']['cometchat_buddytime'] < REFRESH_BUDDYLIST && !defined('TAPATALK')) {
            $response['buddylist'] = $_SESSION['cometchat']['cometchat_buddyresult'];
            $response['blh'] = $_SESSION['cometchat']['cometchat_buddyblh'];
        } else {
            $onlineCacheKey = 'all_online';
            if ($userid > 10000000) {
                $onlineCacheKey .= 'guest';
            }
            if (!is_array($buddyList = getCache($onlineCacheKey)) || $_REQUEST['f'] == 1 || defined('TAPATALK')) {
                $buddyList = array();
                $sql = getFriendsList($userid, $time);
                if ($guestsMode) {
                    $sql = getGuestsList($userid, $time, $sql);
                }
                if (!empty($_REQUEST['activeChatboxIds'])) {
                    $activeChatboxIds = "'" . str_replace(",", "','", $_REQUEST['activeChatboxIds']) . "'";
                    $sql = getActivechatboxdetails($activeChatboxIds) . " UNION " . $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 (in_array($chat['userid'], $bannedUserIDs)) {
                        continue;
                    }
                    if (($time - processTime($chat['lastactivity']) < ONLINE_TIMEOUT || $chat['isdevice'] == 1) && $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']];
                    }
                    $link = fetchLink($chat['link']);
                    $avatar = getAvatar($chat['avatar']);
                    if (function_exists('processName')) {
                        $chat['username'] = processName($chat['username']);
                    }
                    if (empty($chat['isdevice'])) {
                        $chat['isdevice'] = "0";
                    }
                    if (empty($chat['grp'])) {
                        $chat['grp'] = '';
                    }
                    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);
                    }
                    if (defined('TAPATALK')) {
                        global $integration;
                        $chat['message'] = $integration->hooks_processMessageBuddylist($chat['message']);
                    }
                    if (!empty($chat['username']) && ($hideOffline == 0 || $hideOffline == 1 && $chat['status'] != 'offline') || in_array($chat['userid'], explode(",", $_REQUEST['activeChatboxIds']))) {
                        $buddyList[$chromeReorderFix . $chat['userid']] = array('id' => $chat['userid'], 'n' => $chat['username'], 'l' => $link, 'a' => $avatar, 'd' => $chat['isdevice'], 's' => $chat['status'], 'm' => $chat['message'], 'g' => $chat['grp'], 'ls' => $chat['lastseen'], 'lstn' => $chat['lastseensetting'], 'ch' => $chat['ch']);
                    }
                }
                setCache($onlineCacheKey, $buddyList, 30);
            }
            if (DISPLAY_ALL_USERS == 0 && MEMCACHE != 0 && USE_CCAUTH == 0) {
                $tempBuddyList = array();
                if (!is_array($friendIds = getCache('friend_ids_of_' . $userid) || $_REQUEST['f'] == 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;
            }
            $blockList = array();
            if (in_array('block', $plugins)) {
                if ($blockpluginmode == 1) {
                    $blockedIds = getBlockedUserIDs(1);
                } else {
                    $blockedIds = getBlockedUserIDs();
                }
                foreach ($blockedIds as $bid) {
                    array_push($blockList, $bid);
                    if (!empty($buddyList[$chromeReorderFix . $bid])) {
                        if ($blockpluginmode == 1) {
                            if (defined('TAPATALK') && (!empty($_REQUEST['callbackfn']) && $_REQUEST['callbackfn'] == 'mobileapp')) {
                                $buddyList[$chromeReorderFix . $bid]['s'] = 'banned';
                            } else {
                                $buddyList[$chromeReorderFix . $bid]['s'] = 'blocked';
                            }
                        } else {
                            unset($buddyList[$chromeReorderFix . $bid]);
                        }
                    }
                }
            }
            if (!empty($buddyList[$chromeReorderFix . $userid])) {
                if (empty($_SESSION['cometchat']['user']) || !empty($_SESSION['cometchat']['user']) && $_SESSION['cometchat']['user']['s'] != $buddyList[$chromeReorderFix . $userid]['s']) {
                    array_merge($_SESSION['cometchat']['user'], $buddyList[$chromeReorderFix . $userid]);
                }
                unset($buddyList[$chromeReorderFix . $userid]);
            }
            if (function_exists('hooks_forcefriends') && is_array(hooks_forcefriends())) {
                $buddyList = array_merge(hooks_forcefriends(), $buddyList);
            }
            $buddyOrder = array();
            $buddyGroup = array();
            $buddyStatus = array();
            $buddyName = array();
            $buddyGuest = array();
            foreach ($buddyList as $key => $row) {
                if (empty($row['g'])) {
                    $row['g'] = '';
                }
                $buddyGroup[$key] = strtolower($row['g']);
                $buddyStatus[$key] = strtolower($row['s']);
                $buddyName[$key] = strtolower($row['n']);
                if ($row['g'] == '') {
                    $buddyOrder[$key] = 1;
                } else {
                    $buddyOrder[$key] = 0;
                }
                $buddyGuest[$key] = 0;
                if ($row['id'] > 10000000) {
                    $buddyGuest[$key] = 1;
                }
            }
            if (!defined('TAPATALK')) {
                array_multisort($buddyOrder, SORT_ASC, $buddyGroup, SORT_STRING, $buddyStatus, SORT_STRING, $buddyGuest, SORT_ASC, $buddyName, SORT_STRING, $buddyList);
            }
            $_SESSION['cometchat']['cometchat_buddytime'] = $time;
            $blh = md5(serialize($buddyList));
            if (empty($_REQUEST['blh']) || !empty($_REQUEST['blh']) && $blh != $_REQUEST['blh'] || $_REQUEST['f'] == 1) {
                $response['buddylist'] = $buddyList;
                $response['blh'] = $blh;
            }
            $_SESSION['cometchat']['cometchat_buddyresult'] = $buddyList;
            $_SESSION['cometchat']['cometchat_buddyblh'] = $blh;
        }
    }
}
Beispiel #13
0
function viewuserconversation()
{
    checktoken();
    global $db;
    global $body;
    global $trayicon;
    global $navigation;
    global $usertable_userid;
    global $usertable_username;
    global $usertable;
    $userid = $_GET['data'];
    $userid2 = $_GET['data2'];
    $sql = "select {$usertable_username} username from {$usertable} where {$usertable_userid} = '" . mysql_real_escape_string($userid) . "'";
    $query = mysql_query($sql);
    $usern = mysql_fetch_array($query);
    $sql = "select {$usertable_username} username from {$usertable} where {$usertable_userid} = '" . mysql_real_escape_string($userid2) . "'";
    $query = mysql_query($sql);
    $usern2 = mysql_fetch_array($query);
    $sql = "(select m.*  from cometchat m where  (m.from = '" . mysql_real_escape_string($userid) . "' and m.to = '" . mysql_real_escape_string($userid2) . "') or (m.to = '" . mysql_real_escape_string($userid) . "' and m.from = '" . mysql_real_escape_string($userid2) . "'))\n\torder by id desc";
    $query = mysql_query($sql);
    $userslist = '';
    while ($chat = mysql_fetch_array($query)) {
        $time = date('g:iA M dS', $chat['sent']);
        if ($userid == $chat['from']) {
            $dir = '>';
        } else {
            $dir = '<';
        }
        $userslist .= '<li class="ui-state-default"><span style="font-size:11px;float:left;margin-top:2px;margin-left:0px;width:10px;margin-right:10px;color:#fff;background-color:#333;padding:0px;-moz-border-radius:5px;-webkit-border-radius:5px;"><b>' . $dir . '</b></span><span style="font-size:11px;float:left;margin-top:2px;margin-left:5px;width:560px;">&nbsp; ' . $chat['message'] . '</span><span style="font-size:11px;float:right;width:100px;overflow:hidden;margin-top:2px;margin-left:10px;">' . $time . '</span><div style="clear:both"></div></li>';
    }
    if (function_exists('processName')) {
        $usern['username'] = processName($usern['username']);
        $usern2['username'] = processName($usern2['username']);
    }
    $body = <<<EOD
\t{$navigation}
\t<form action="?module=logs&action=newlogprocess" method="post" enctype="multipart/form-data">
\t<div id="rightcontent" style="float:left;width:720px;border-left:1px dotted #ccc;padding-left:20px;">
\t\t<h2>Log between {$usern['username']} and {$usern2['username']}</h2>
\t\t<h3>To see other conversations of {$usern['username']}, <a href="?module=logs&action=viewuser&data={$userid}">click here</a></h3>

\t\t<div>
\t\t\t<ul id="modules_logslong">
\t\t\t\t{$userslist}
\t\t\t</ul>
\t\t</div>
\t</div>

\t<div style="clear:both"></div>

EOD;
    template();
}
Beispiel #14
0
function viewuserchatroomconversation()
{
    global $ts;
    global $body;
    global $navigation;
    global $usertable_userid;
    global $usertable_username;
    global $usertable;
    global $guestsMode;
    global $guestnamePrefix;
    if (!empty($guestnamePrefix)) {
        $guestnamePrefix .= '-';
    }
    if ($guestsMode) {
        $usertable = "(select " . $usertable_userid . ", " . $usertable_username . "  from " . $usertable . " union select id " . $usertable_userid . ",concat('" . $guestnamePrefix . "',name) " . $usertable_username . " from cometchat_guests)";
    }
    $chatroomid = $_GET['data'];
    $sql = "select name chatroomname from cometchat_chatrooms where id = '" . mysqli_real_escape_string($GLOBALS['dbh'], $chatroomid) . "'";
    $query = mysqli_query($GLOBALS['dbh'], $sql);
    $chatroomn = mysqli_fetch_assoc($query);
    $sql = "select cometchat_chatroommessages.*, f." . $usertable_username . " username  from cometchat_chatroommessages join " . $usertable . " f on cometchat_chatroommessages.userid = f." . $usertable_userid . " where chatroomid = '" . mysqli_real_escape_string($GLOBALS['dbh'], $chatroomid) . "' order by id desc LIMIT 200";
    $query = mysqli_query($GLOBALS['dbh'], $sql);
    $chatroomlog = '';
    while ($chat = mysqli_fetch_assoc($query)) {
        if (function_exists('processName')) {
            $chatroomn['chatroomname'] = processName($chatroomn['chatroomname']);
        }
        $time = $chat['sent'];
        $chatroomlog .= '<li class="ui-state-default"><span style="font-size: 11px; float: left; margin-top: 2px; margin-left: 0px; width: 8em; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; padding: 0px; text-align: center;">' . $chat["username"] . '</span><span style="font-size:11px;float:left;margin-top:2px;margin-left:5px;width:495px;">&nbsp; ' . $chat['message'] . '</span><span style="font-size:11px;float:right;width:100px;overflow:hidden;margin-top:2px;margin-left:10px;"><span class="chat_time" timestamp="' . $time . '"></span></span><div style="clear:both"></div></li>';
    }
    $body = <<<EOD
\t{$navigation}
        <link href="../css.php?admin=1" media="all" rel="stylesheet" type="text/css" />
\t<form action="?module=logs&action=newlogprocess&ts={$ts}" method="post" enctype="multipart/form-data">
\t<div id="rightcontent" style="float:left;width:720px;border-left:1px dotted #ccc;padding-left:20px;">
\t\t<h2>Log of  in {$chatroomn['chatroomname']} chatroom</h2>
\t\t<h3>To see other conversations of  in other chatrooms, <a href="?module=logs&action=chatroomlog&ts={$ts}">click here</a></h3>

\t\t<div>
\t\t\t<ul id="modules_logslong">
\t\t\t\t{$chatroomlog}
\t\t\t</ul>
\t\t</div>
\t</div>

\t<div style="clear:both"></div>

EOD;
    template();
}
Beispiel #15
0
function logs()
{
    global $db;
    $usertable = TABLE_PREFIX . DB_USERTABLE;
    $usertable_username = DB_USERTABLE_NAME;
    $usertable_userid = DB_USERTABLE_USERID;
    global $body;
    global $userid;
    global $chathistory_language;
    if (!empty($_GET['id'])) {
        logsview();
    }
    $sql = "select m1.*, f.{$usertable_username} fromu, t.{$usertable_username} tou from cometchat m1, {$usertable} f, {$usertable} t  \n\twhere  f.{$usertable_userid} = m1.from and t.{$usertable_userid} = m1.to and ((m1.from = '" . mysql_real_escape_string($userid) . "') or (m1.to = '" . mysql_real_escape_string($userid) . "')) and (m1.sent) > ALL\n\t(select (m2.sent)+1800 from cometchat m2\n\twhere ((m2.to = m1.to and m2.from = m1.from) or (m2.to = m1.from and m2.from = m1.to))\n\tand m2.sent <= m1.sent and m2.id < m1.id) order by id desc";
    if (!empty($_GET['history'])) {
        $history = $_GET['history'];
        $sql = "select m1.*, f.{$usertable_username} fromu, t.{$usertable_username} tou from cometchat m1, {$usertable} f, {$usertable} t  \n\twhere  f.{$usertable_userid} = m1.from and t.{$usertable_userid} = m1.to and ((m1.from = '" . mysql_real_escape_string($userid) . "' and m1.to = '" . mysql_real_escape_string($history) . "') or (m1.to = '" . mysql_real_escape_string($userid) . "' and m1.from = '" . mysql_real_escape_string($history) . "')) and (m1.sent) > ALL\n\t(select (m2.sent)+1800 from cometchat m2\n\twhere ((m2.to = m1.to and m2.from = m1.from) or (m2.to = m1.from and m2.from = m1.to))\n\tand m2.sent <= m1.sent and m2.id < m1.id) order by id desc";
    }
    $query = mysql_query($sql);
    $chatdata = '<table>';
    $previd = 1000000;
    while ($chat = mysql_fetch_array($query)) {
        if (function_exists('processName')) {
            $chat['fromu'] = processName($chat['fromu']);
            $chat['tou'] = processName($chat['tou']);
        }
        $requester = $chat['fromu'];
        if ($chat['from'] == '1') {
            $requester = $chat['tou'];
            $chat['fromu'] = $chathistory_language[1];
        }
        $time = date('g:iA M dS', $chat['sent'] + $_SESSION['cometchat']['timedifference']);
        $chat['message'] = strip_tags($chat['message']);
        $encode = base64_encode($chat['id'] . "," . $previd);
        $chatdata = <<<EOD
 {$chatdata}
<div class="chat" id="{$encode}">
\t\t\t<div class="chatrequest"><b>{$chat['fromu']}</b></div> 
\t\t\t<div class="chatmessage chatmessage_short">{$chat['message']}</div>
\t\t\t<div class="chattime">{$time}</div>
\t\t\t<div style="clear:both"></div>
</div> 

EOD;
        $previd = $chat['id'];
    }
    $chatdata .= '</table>';
    $history = '';
    if (!empty($_GET['history'])) {
        $history = '+"&history=' . $_GET['history'] . '"';
    }
    if (!empty($_GET['embed']) && $_GET['embed'] == 'web') {
        $history .= '+"&embed=web"';
    }
    if (!empty($_GET['embed']) && $_GET['embed'] == 'desktop') {
        $history .= '+"&embed=desktop"';
    }
    $baseData = $_REQUEST['basedata'];
    $body = <<<EOD
\t<script>
\t\tjQuery(document).ready(function () {
\t\t\t\$('.chat').mouseover(function() {
\t\t\t\t\$(this).addClass('chatbg');
\t\t\t});

\t\t\t\$('.chat').mouseout(function() {
\t\t\t\t\$(this).removeClass('chatbg');
\t\t\t});

\t\t\t\$('.chat').click(function() {
\t\t\t\tvar id = \$(this).attr('id');
\t\t\t\tlocation.href = "?action=logs&basedata={$baseData}&id="+id{$history};
\t\t\t});
\t\t});
\t</script>\t
\t{$chatdata}
EOD;
    template();
}
Beispiel #16
0
function invite()
{
    global $userid;
    global $avchat_language;
    global $language;
    global $embed;
    global $embedcss;
    global $lightboxWindows;
    global $guestsMode;
    global $cookiePrefix;
    global $chromeReorderFix;
    if ($lightboxWindows == '1') {
        $embed = 'web';
        $embedcss = 'embed';
    }
    $status['available'] = $language[30];
    $status['busy'] = $language[31];
    $status['offline'] = $language[32];
    $status['invisible'] = $language[33];
    $status['away'] = $language[34];
    $id = $_GET['roomid'];
    if (empty($id)) {
        exit;
    }
    $time = getTimeStamp();
    $buddyList = array();
    $onlineCacheKey = 'all_online';
    if ($userid > 10000000) {
        $onlineCacheKey .= 'guest';
    }
    if ($onlineUsers = getCache($cookiePrefix . $onlineCacheKey, 30)) {
        $buddyList = unserialize($onlineUsers);
    } else {
        $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 ($chat['userid'] != $userid) {
                    $buddyList[$chromeReorderFix . $chat['userid']] = array('id' => $chat['userid'], 'n' => $chat['username'], 'a' => $avatar, 's' => $chat['status']);
                }
            }
        }
    }
    if (DISPLAY_ALL_USERS == 0 && MEMCACHE != 0) {
        $tempBuddyList = array();
        if ($onlineFrnds = getCache($cookiePrefix . 'friend_ids_of_' . $userid, 30)) {
            $friendIds = unserialize($onlineFrnds);
        } else {
            $sql = getFriendsIds($userid);
            $res = mysqli_query($GLOBALS['dbh'], $sql);
            $result = mysqli_fetch_assoc($res);
            if (!empty($result['friends'])) {
                $friendIds = explode(',', $result['friends']);
            }
            setCache($cookiePrefix . 'friend_ids_of_' . $userid, serialize($friendIds), 30);
        }
        foreach ($friendIds as $friendId) {
            $friendId = $chromeReorderFix . $friendId;
            if (isset($buddyList[$friendId])) {
                $tempBuddyList[$friendId] = $buddyList[$friendId];
            }
        }
        $buddyList = $tempBuddyList;
    }
    if (function_exists('hooks_forcefriends') && is_array(hooks_forcefriends())) {
        $buddyList = array_merge(hooks_forcefriends(), $buddyList);
    }
    $s['available'] = '';
    $s['away'] = '';
    $s['busy'] = '';
    $s['offline'] = '';
    foreach ($buddyList as $buddy) {
        $s[$buddy['s']] .= '<div class="invite_1"><div class="invite_2" onclick="javascript:document.getElementById(\'check_' . $buddy['id'] . '\').checked = document.getElementById(\'check_' . $buddy['id'] . '\').checked?false:true;"><img height=30 width=30 src="' . $buddy['a'] . '"></div><div class="invite_3" onclick="javascript:document.getElementById(\'check_' . $buddy['id'] . '\').checked = document.getElementById(\'check_' . $buddy['id'] . '\').checked?false:true;"><span class="invite_name">' . $buddy['n'] . '</span><br/><span class="invite_5">' . $status[$buddy['s']] . '</span></div><input type="checkbox" name="invite[]" value="' . $buddy['id'] . '" id="check_' . $buddy['id'] . '" class="invite_4"></div>';
    }
    $inviteContent = '';
    $invitehide = '';
    $inviteContent = $s['available'] . "" . $s['away'] . "" . $s['offline'];
    if (empty($inviteContent)) {
        $inviteContent = $avchat_language[25];
        $invitehide = 'style="display:none;"';
    }
    echo <<<EOD
<!DOCTYPE html>
<html>
<head>
<title>{$avchat_language[18]}</title> 
<meta http-equiv="content-type" content="text/html; charset=utf-8"/> 
<link type="text/css" rel="stylesheet" media="all" href="../../css.php?type=plugin&name=avchat" /> 
</head>
<body>
<form method="post" action="invite.php?action=inviteusers&embed={$embed}">
<div class="container">
\t<div class="container_title {$embedcss}">{$avchat_language[16]}</div>
\t<div class="container_body {$embedcss}">
\t\t{$inviteContent}
\t\t<div style="clear:both"></div>
\t</div>
\t<div class="container_sub" {$invitehide}>
\t\t<input type=submit value="{$avchat_language[17]}" class="invitebutton">
\t</div>
</div>\t
<input type="hidden" name="roomid" value="{$id}">
</form>
</body>
</html>
EOD;
}
function searchlogs()
{
    checktoken();
    global $usertable_userid;
    global $usertable_username;
    global $usertable;
    global $navigation;
    global $body;
    $username = $_POST['susername'];
    if (empty($username)) {
        // Base 64 Encoded
        $username = '******';
    }
    $sql = "select {$usertable_userid} id, {$usertable_username} username from {$usertable} where {$usertable_username} LIKE '%" . mysql_real_escape_string(sanitize_core($username)) . "%'";
    $query = mysql_query($sql);
    $userslist = '';
    while ($user = mysql_fetch_array($query)) {
        if (function_exists('processName')) {
            $user['username'] = processName($user['username']);
        }
        $userslist .= '<li class="ui-state-default"><span style="font-size:11px;float:left;margin-top:2px;margin-left:5px;">' . $user['username'] . ' - ' . $user['id'] . '</span><div style="clear:both"></div></li>';
    }
    $body = <<<EOD
\t{$navigation}

\t<div id="rightcontent" style="float:left;width:720px;border-left:1px dotted #ccc;padding-left:20px;">
\t\t<h2>Search results</h2>
\t\t<h3>Please find the user id next to each username. <a href="?module=chatrooms&action=finduser">Click here to search again</a></h3>

\t\t<div>
\t\t\t<ul id="modules_logs">
\t\t\t\t{$userslist}
\t\t\t</ul>
\t\t</div>

\t\t<div style="clear:both;padding:7.5px;"></div>
\t</div>

\t<div style="clear:both"></div>

EOD;
    template();
}
Beispiel #18
0
function viewuserchatroomconversation()
{
    global $db;
    global $body;
    global $trayicon;
    global $navigation;
    global $usertable_userid;
    global $usertable_username;
    global $usertable;
    $chatroomid = $_GET['data'];
    $sql = "select name chatroomname , id  from cometchat_chatrooms where id = '" . mysql_real_escape_string($chatroomid) . "'";
    $query = mysql_query($sql);
    $chatroomn = mysql_fetch_array($query);
    $sql = "select cometchat_chatroommessages.*, {$usertable}.{$usertable_username} username  from cometchat_chatroommessages join {$usertable} on cometchat_chatroommessages.userid = {$usertable}.{$usertable_userid} where chatroomid = '" . mysql_real_escape_string($chatroomid) . "' order by id desc LIMIT 200";
    $query = mysql_query($sql);
    $num = mysql_num_rows($query);
    $chatroomlog = '';
    while ($chat = mysql_fetch_array($query)) {
        if (function_exists('processName')) {
            $chat['username'] = processName($chat['username']);
            $chatroomn['chatroomname'] = processName($chatroomn['chatroomname']);
        }
        $time = date('g:iA M dS', $chat['sent']);
        $chatroomlog .= '<li class="ui-state-default"><span style="font-size: 11px; float: left; margin-top: 2px; margin-left: 0px; width: 8em; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; padding: 0px; text-align: center;">' . $chat["username"] . '</span><span style="font-size:11px;float:left;margin-top:2px;margin-left:5px;width:495px;">&nbsp; ' . $chat['message'] . '</span><span style="font-size:11px;float:right;width:100px;overflow:hidden;margin-top:2px;margin-left:10px;">' . $time . '</span><div style="clear:both"></div></li>';
    }
    $body = <<<EOD
\t{$navigation}
\t<form action="?module=logs&action=newlogprocess" method="post" enctype="multipart/form-data">
\t<div id="rightcontent" style="float:left;width:720px;border-left:1px dotted #ccc;padding-left:20px;">
\t\t<h2>Log of  in {$chatroomn['chatroomname']} chatroom</h2>
\t\t<h3>To see other conversations of  in other chatrooms, <a href="?module=logs&action=chatroomlog">click here</a></h3>

\t\t<div>
\t\t\t<ul id="modules_logslong">
\t\t\t\t{$chatroomlog}
\t\t\t</ul>
\t\t</div>
\t</div>

\t<div style="clear:both"></div>

EOD;
    template();
}
Beispiel #19
0
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']];
}
$link = getLink($chat['link']);
$avatar = getAvatar($chat['avatar']);
if (function_exists('processName')) {
    $chat['username'] = processName($chat['username']);
}
$response = array('id' => $chat['userid'], 'n' => $chat['username'], 's' => $chat['status'], 'm' => $chat['message'], 'a' => $avatar, 'l' => $link);
header('Content-type: application/json; charset=utf-8');
if (!empty($_GET['callback'])) {
    echo $_GET['callback'] . '(' . json_encode($response) . ')';
} else {
    echo json_encode($response);
}
exit;
function sendChatroomMessage($to, $message)
{
    global $userid;
    if (!empty($to) && !empty($message)) {
        if ($userid != '') {
            if (USE_COMET == 1 && COMET_CHATROOMS == 1) {
                $comet = new Comet(KEY_A, KEY_B);
                if (empty($_SESSION['cometchat']['username'])) {
                    $name = '';
                    $sql = getUserDetails($userid);
                    $result = mysql_query($sql);
                    if ($row = mysql_fetch_array($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, "message" => $message, "sent" => getTimeStamp())));
                }
                $insertedid = getTimeStamp() . rand(0, 1000000);
            } else {
                $sql = "insert into cometchat_chatroommessages (userid,chatroomid,message,sent) values ('" . mysql_real_escape_string($userid) . "', '" . mysql_real_escape_string($to) . "','" . mysql_real_escape_string($message) . "','" . getTimeStamp() . "')";
                $query = mysql_query($sql);
                if (defined('DEV_MODE') && DEV_MODE == '1') {
                    echo mysql_error();
                }
            }
        }
    }
}
function getChatroomData($chatroomid, $prelimit = 0, $lastMessages = 0)
{
    global $guestsMode, $crguestsMode, $guestnamePrefix;
    global $language;
    global $userid;
    global $cookiePrefix;
    $usertable = TABLE_PREFIX . DB_USERTABLE;
    $usertable_username = DB_USERTABLE_NAME;
    $usertable_userid = DB_USERTABLE_USERID;
    $messages = array();
    $moremessages = array();
    $guestpart = '';
    $prependCondition = '';
    $limitClause = " limit " . mysqli_real_escape_string($GLOBALS['dbh'], $lastMessages) . " ";
    if (empty($prelimit) && empty($lastMessages)) {
        if (!empty($_SESSION['cometchat']['cometchat_chatroom_' . $chatroomid])) {
            $moremessages = $moremessages + $_SESSION['cometchat']['cometchat_chatroom_' . $chatroomid];
        }
        $messages = $messages + $moremessages;
        krsort($messages);
        return $messages;
    } else {
        if ($prelimit != '-1') {
            $prelimit = bigintval($prelimit);
            $prependCondition = "and (cometchat_chatroommessages.id < '" . mysqli_real_escape_string($GLOBALS['dbh'], $prelimit) . "')";
        }
        if ($guestsMode && $crguestsMode) {
            $guestpart = " UNION select DISTINCT cometchat_chatroommessages.id id, cometchat_chatroommessages.message, cometchat_chatroommessages.sent, CONCAT('" . $guestnamePrefix . "',m.name) `from`, cometchat_chatroommessages.userid fromid, m.id userid from cometchat_chatroommessages join cometchat_guests m on m.id = cometchat_chatroommessages.userid where cometchat_chatroommessages.chatroomid = '" . mysqli_real_escape_string($GLOBALS['dbh'], $chatroomid) . "' and cometchat_chatroommessages.message not like '%banned_%' and cometchat_chatroommessages.message not like '%kicked_%' and cometchat_chatroommessages.message not like '%deletemessage_%' " . $prependCondition;
        }
        $sql = "select DISTINCT cometchat_chatroommessages.id id, cometchat_chatroommessages.message, cometchat_chatroommessages.sent, m.{$usertable_username} `from`, cometchat_chatroommessages.userid fromid, m.{$usertable_userid} userid from cometchat_chatroommessages join {$usertable} m on m.{$usertable_userid} = cometchat_chatroommessages.userid  where cometchat_chatroommessages.chatroomid = '" . mysqli_real_escape_string($GLOBALS['dbh'], $chatroomid) . "' and cometchat_chatroommessages.message not like '%banned_%' and cometchat_chatroommessages.message not like '%kicked_%' and cometchat_chatroommessages.message not like '%deletemessage_%' " . $prependCondition . $guestpart . " order by id desc " . $limitClause;
        $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 (function_exists('processName')) {
                $chat['from'] = processName($chat['from']);
            }
            if ($lastMessages == 0) {
                $chat['message'] = '';
            }
            if ($userid == $chat['userid']) {
                $chat['from'] = $language[10];
            } else {
                if (!empty($_COOKIE[$cookiePrefix . 'lang']) && !(strpos($chat['message'], "CC^CONTROL_") > -1)) {
                    $translated = text_translate($chat['message'], '', $_COOKIE[$cookiePrefix . 'lang']);
                    if ($translated != '') {
                        $chat['message'] = strip_tags($translated) . ' <span class="untranslatedtext">(' . $chat['message'] . ')</span>';
                    }
                }
            }
            $messages[$chat['id']] = array('id' => $chat['id'], 'from' => $chat['from'], 'fromid' => $chat['fromid'], 'message' => $chat['message'], 'sent' => $chat['sent']);
        }
    }
    header('Content-type: application/json; charset=utf-8');
    echo json_encode($messages);
}
Beispiel #22
0
function userSelection($silent = 0)
{
    $baseUrl = BASE_URL;
    global $userid;
    global $broadcastmessage_language;
    global $language;
    global $embed;
    global $embedcss;
    global $guestsMode;
    global $basedata;
    global $sleekScroller;
    global $inviteContent;
    global $chromeReorderFix;
    global $hideOffline;
    global $plugins;
    $status['available'] = $language[30];
    $status['busy'] = $language[31];
    $status['offline'] = $language[32];
    $status['invisible'] = $language[33];
    $status['away'] = $language[34];
    $time = getTimeStamp();
    $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 ($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))) {
            $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 (isset($buddyList[$friendId])) {
                $tempBuddyList[$friendId] = $buddyList[$friendId];
            }
        }
        $buddyList = $tempBuddyList;
    }
    if (function_exists('hooks_forcefriends') && is_array(hooks_forcefriends())) {
        $buddyList = array_merge(hooks_forcefriends(), $buddyList);
    }
    $blockList = array();
    if (in_array('block', $plugins)) {
        $blockedIds = getBlockedUserIDs();
        foreach ($blockedIds as $bid) {
            array_push($blockList, $bid);
            if (isset($buddyList[$chromeReorderFix . $bid])) {
                unset($buddyList[$chromeReorderFix . $bid]);
            }
        }
    }
    if (isset($buddyList[$chromeReorderFix . $userid])) {
        unset($buddyList[$chromeReorderFix . $userid]);
    }
    if (empty($silent)) {
        $buddyOrder = array();
        $buddyGroup = array();
        $buddyStatus = array();
        $buddyName = array();
        $buddyGuest = array();
        foreach ($buddyList as $key => $row) {
            if (empty($row['g'])) {
                $row['g'] = '';
            }
            $buddyGroup[$key] = strtolower($row['g']);
            $buddyStatus[$key] = strtolower($row['s']);
            $buddyName[$key] = strtolower($row['n']);
            if ($row['g'] == '') {
                $buddyOrder[$key] = 1;
            } else {
                $buddyOrder[$key] = 0;
            }
            $buddyGuest[$key] = 0;
            if ($row['id'] > 10000000) {
                $buddyGuest[$key] = 1;
            }
        }
        array_multisort($buddyOrder, SORT_ASC, $buddyGroup, SORT_STRING, $buddyStatus, SORT_STRING, $buddyGuest, SORT_ASC, $buddyName, SORT_STRING, $buddyList);
        $response['buddyList'] = $buddyList;
        $response['status'] = $status;
    } else {
        $s['available'] = '';
        $s['away'] = '';
        $s['busy'] = '';
        $s['offline'] = '';
        foreach ($buddyList as $buddy) {
            $s[$buddy['s']] .= '<div class="invite_1"><div class="invite_2" onclick="javascript:document.getElementById(\'check_' . $buddy['id'] . '\').checked = document.getElementById(\'check_' . $buddy['id'] . '\').checked?false:true;"><img height=30 width=30 src="' . $buddy['a'] . '" /></div><div class="invite_3" onclick="javascript:document.getElementById(\'check_' . $buddy['id'] . '\').checked = document.getElementById(\'check_' . $buddy['id'] . '\').checked?false:true;"><span class="invite_name">' . $buddy['n'] . '</span><br/><span class="invite_5">' . $status[$buddy['s']] . '</span></div><input type="checkbox" name="to[]" value="' . $buddy['id'] . '" id="check_' . $buddy['id'] . '" class="invite_4" /></div>';
        }
        $inviteContent = '';
        $invitehide = '';
        $inviteContent = $s['available'] . "" . $s['away'] . "" . $s['offline'];
        if (empty($inviteContent)) {
            $inviteContent = '<div style= "padding-top:6px">' . $broadcastmessage_language[2] . '</div>';
            $invitehide = 'style="display:none;"';
        }
    }
    if (empty($silent)) {
        header('content-type: application/json; charset=utf-8');
        echo $_GET['callback'] . '(' . json_encode($response) . ')';
    } else {
        return $inviteContent;
    }
}
Beispiel #23
0
function getBuddyList()
{
    global $response;
    global $userid;
    global $db;
    global $status;
    global $hideOffline;
    global $plugins;
    global $guestsMode;
    global $cookiePrefix;
    global $chromeReorderFix;
    $time = getTimeStamp();
    $buddyList = array();
    if (empty($_SESSION['cometchat']['cometchat_buddytime']) || $_REQUEST['initialize'] == 1 || $_REQUEST['f'] == 1 || !empty($_SESSION['cometchat']['cometchat_buddytime']) && ($time - $_SESSION['cometchat']['cometchat_buddytime'] >= REFRESH_BUDDYLIST || MEMCACHE != 0)) {
        if ($_REQUEST['initialize'] == 1 && !empty($_SESSION['cometchat']['cometchat_buddyblh']) && $time - $_SESSION['cometchat']['cometchat_buddytime'] < REFRESH_BUDDYLIST) {
            $response['buddylist'] = $_SESSION['cometchat']['cometchat_buddyresult'];
            $response['blh'] = $_SESSION['cometchat']['cometchat_buddyblh'];
        } else {
            $onlineCacheKey = 'all_online';
            if ($userid > 10000000) {
                $onlineCacheKey .= 'guest';
            }
            if ($onlineUsers = getCache($cookiePrefix . $onlineCacheKey, 30)) {
                $buddyList = unserialize($onlineUsers);
            } else {
                $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['isdevice'] == 1) && $chat['status'] != 'invisible' && $chat['status'] != 'offline') {
                        if ($chat['status'] != 'busy' && $chat['status'] != 'away' || $chat['isdevice'] == 1) {
                            $chat['status'] = 'available';
                        }
                    } else {
                        $chat['status'] = 'offline';
                    }
                    if ($chat['message'] == null) {
                        $chat['message'] = $status[$chat['status']];
                    }
                    $link = fetchLink($chat['link']);
                    $avatar = getAvatar($chat['userid']);
                    if (function_exists('processName')) {
                        $chat['username'] = processName($chat['username']);
                    }
                    if (empty($chat['grp'])) {
                        $chat['grp'] = '';
                    }
                    if (!empty($chat['username']) && ($hideOffline == 0 || $hideOffline == 1 && $chat['status'] != 'offline')) {
                        $buddyList[$chromeReorderFix . $chat['userid']] = array('id' => $chat['userid'], 'n' => $chat['username'], 'l' => $link, 'a' => $avatar, 'd' => $chat['isdevice'], 's' => $chat['status'], 'm' => $chat['message'], 'g' => $chat['grp']);
                    }
                }
                setCache($cookiePrefix . $onlineCacheKey, serialize($buddyList), 30);
            }
            if (DISPLAY_ALL_USERS == 0 && MEMCACHE != 0) {
                $tempBuddyList = array();
                $friendIds = array();
                if ($onlineFrnds = getCache($cookiePrefix . 'friend_ids_of_' . $userid, 30)) {
                    $friendIds = unserialize($onlineFrnds);
                } else {
                    $sql = getFriendsIds($userid);
                    $res = mysqli_query($GLOBALS['dbh'], $sql);
                    $result = mysqli_fetch_assoc($res);
                    if (!empty($result['myfrndids'])) {
                        $friendIds = explode(',', $result['myfrndids']);
                    }
                    setCache($cookiePrefix . 'friend_ids_of_' . $userid, serialize($friendIds), 30);
                }
                foreach ($friendIds as $friendId) {
                    $friendId = $chromeReorderFix . $friendId;
                    if (isset($buddyList[$friendId])) {
                        $tempBuddyList[$friendId] = $buddyList[$friendId];
                    }
                }
                $buddyList = $tempBuddyList;
            }
            $blockList = array();
            if (in_array('block', $plugins)) {
                $blockId = array();
                if ($blockedUsers = getCache($cookiePrefix . 'blocked_id_of_' . $userid, 30)) {
                    $blockId = unserialize($blockedUsers);
                } else {
                    $sql = "select group_concat(blockedid) blockedids from (select fromid as blockedid from cometchat_block where toid = '" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "' UNION select toid as blockedid from cometchat_block where fromid = '" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "') as blocked";
                    $query = mysqli_query($GLOBALS['dbh'], $sql);
                    $blockIds = mysqli_fetch_assoc($query);
                    if (!empty($blockIds['blockedids'])) {
                        $blockId = explode(',', $blockIds['blockedids']);
                    }
                    setCache($cookiePrefix . 'blocked_id_of_' . $userid, serialize($blockId), 3600);
                }
                foreach ($blockId as $bid) {
                    array_push($blockList, $bid);
                    if (isset($buddyList[$chromeReorderFix . $bid])) {
                        unset($buddyList[$chromeReorderFix . $bid]);
                    }
                }
            }
            if (isset($buddyList[$chromeReorderFix . $userid])) {
                unset($buddyList[$chromeReorderFix . $userid]);
            }
            if (function_exists('hooks_forcefriends') && is_array(hooks_forcefriends())) {
                $buddyList = array_merge(hooks_forcefriends(), $buddyList);
            }
            $buddyOrder = array();
            $buddyGroup = array();
            $buddyStatus = array();
            $buddyName = array();
            $buddyGuest = array();
            foreach ($buddyList as $key => $row) {
                if (empty($row['g'])) {
                    $row['g'] = '';
                }
                $buddyGroup[$key] = strtolower($row['g']);
                $buddyStatus[$key] = strtolower($row['s']);
                $buddyName[$key] = strtolower($row['n']);
                if ($row['g'] == '') {
                    $buddyOrder[$key] = 1;
                } else {
                    $buddyOrder[$key] = 0;
                }
                $buddyGuest[$key] = 0;
                if ($row['id'] > 10000000) {
                    $buddyGuest[$key] = 1;
                }
            }
            array_multisort($buddyOrder, SORT_ASC, $buddyGroup, SORT_STRING, $buddyStatus, SORT_STRING, $buddyGuest, SORT_ASC, $buddyName, SORT_STRING, $buddyList);
            $_SESSION['cometchat']['cometchat_buddytime'] = $time;
            $blh = md5(serialize($buddyList));
            if (empty($_REQUEST['blh']) || !empty($_REQUEST['blh']) && $blh != $_REQUEST['blh']) {
                $response['buddylist'] = $buddyList;
                $response['blh'] = $blh;
            }
            $_SESSION['cometchat']['cometchat_buddyresult'] = $buddyList;
            $_SESSION['cometchat']['cometchat_buddyblh'] = $blh;
        }
    }
}
Beispiel #24
0
                                 }
                             }
                         }
                         if (!$isFailed) {
                             $isSucceed = true;
                             $rand = md5(rand(1000, 99999) . '-' . $dir);
                             $rand = substr($rand, 0, strlen($rand) >> 1);
                             foreach ($entry as $e) {
                                 $entryPath = $dir . '/' . $e;
                                 @rename($entryPath, $entryPath . '-' . $rand);
                             }
                             foreach ($entry as $k => $e) {
                                 $entryPath = $dir . '/' . $e;
                                 $entryLabel = is_dir($entryPath) ? 'thư mục' : 'tập tin';
                                 $entryCss = is_dir($entryPath) ? 'folder' : 'file';
                                 if (!@rename($entryPath . '-' . $rand, $dir . '/' . processName($modifier[$k]))) {
                                     $isSucceed = false;
                                     echo '<div class="notice_failure">Đổi tên ' . $entryLabel . ' <strong class="' . $entryCss . '_name_rename_action">' . $e . '</strong> <strong>=></strong> <strong class="' . $entryCss . '_name_rename_action">' . $modifier[$k] . '</strong> thất bại</div>';
                                 } else {
                                     $entry[$k] = $modifier[$k];
                                     echo '<div class="notice_succeed">Đổi tên ' . $entryLabel . ' <strong class="' . $entryCss . '_name_rename_action">' . $e . '</strong> <strong>=></strong> <strong class="' . $entryCss . '_name_rename_action">' . $modifier[$k] . '</strong> thành công</div>';
                                 }
                             }
                         }
                         if (!$isFailed && $isSucceed) {
                             goURL('index.php?dir=' . $dirEncode . $pages['paramater_1']);
                         }
                     }
                     echo $entryHtmlList;
                     echo '<div class="list ellipsis break-word">
 <span>' . printPath($dir, true) . '</span><hr/>
Beispiel #25
0
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";
foreach ($messages as $chat) {
    $chat['message'] = strip_tags($chat['message']);
    if ($chat['self'] == 1) {
        $log .= '(' . date('g:iA', $chat['sent']) . ") " . $language[10] . ': ' . $chat['message'] . "\r\n";
    } else {
        $log .= '(' . date('g:iA', $chat['sent']) . ") " . $user['username'] . ': ' . $chat['message'] . "\r\n";
    }
}
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;
    }
}
Beispiel #27
0
function data()
{
    checktoken();
    global $db;
    $usertable = TABLE_PREFIX . DB_USERTABLE;
    $usertable_username = DB_USERTABLE_NAME;
    $usertable_userid = DB_USERTABLE_USERID;
    $response = array();
    $messages = array();
    $criteria = "cometchat.id > '" . mysql_real_escape_string($_POST['timestamp']) . "' and ";
    $criteria2 = 'desc';
    if (empty($_POST['timestamp'])) {
        $criteria = '';
        $criteria2 = 'desc limit 20';
    }
    $sql = "select cometchat.id, cometchat.from, cometchat.to, cometchat.message, cometchat.sent, cometchat.read, f.{$usertable_username} fromu, t.{$usertable_username} tou from cometchat, {$usertable} f, {$usertable} t where {$criteria} f.{$usertable_userid} = cometchat.from and t.{$usertable_userid} = cometchat.to order by cometchat.id {$criteria2}";
    $query = mysql_query($sql);
    $timestamp = $_POST['timestamp'];
    while ($chat = mysql_fetch_array($query)) {
        if (function_exists('processName')) {
            $chat['fromu'] = processName($chat['fromu']);
            $chat['tou'] = processName($chat['tou']);
        }
        $time = date('g:iA M dS', $chat['sent']);
        array_unshift($messages, array('id' => $chat['id'], 'from' => $chat['from'], 'to' => $chat['to'], 'fromu' => $chat['fromu'], 'tou' => $chat['tou'], 'message' => $chat['message'], 'time' => $time));
        if ($chat['id'] > $timestamp) {
            $timestamp = $chat['id'];
        }
    }
    $response['timestamp'] = $timestamp;
    if (!empty($messages)) {
        $response['messages'] = $messages;
    }
    header('Content-type: application/json; charset=utf-8');
    echo json_encode($response);
    exit;
}
Beispiel #28
0
function invite()
{
    global $userid;
    global $broadcast_language;
    global $language;
    global $embed;
    global $embedcss;
    global $lightboxWindows;
    if ($lightboxWindows == '1') {
        $embed = 'web';
        $embedcss = 'embed';
    }
    $status['available'] = $language[30];
    $status['busy'] = $language[31];
    $status['offline'] = $language[32];
    $status['invisible'] = $language[33];
    $status['away'] = $language[34];
    $id = $_GET['roomid'];
    if (empty($id)) {
        exit;
    }
    $time = getTimeStamp();
    $buddyList = array();
    $sql = getFriendsList($userid, $time);
    $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') {
            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 ($chat['userid'] != $userid) {
                $buddyList[] = array('id' => $chat['userid'], 'n' => $chat['username'], 's' => $chat['status'], 'a' => $avatar);
            }
        }
    }
    if (function_exists('hooks_forcefriends') && is_array(hooks_forcefriends())) {
        $buddyList = array_merge(hooks_forcefriends(), $buddyList);
    }
    $s['available'] = '';
    $s['away'] = '';
    $s['busy'] = '';
    $s['offline'] = '';
    foreach ($buddyList as $buddy) {
        $s[$buddy['s']] .= '<div class="invite_1"><div class="invite_2" onclick="javascript:document.getElementById(\'check_' . $buddy['id'] . '\').checked = document.getElementById(\'check_' . $buddy['id'] . '\').checked?false:true;"><img height=30 width=30 src="' . $buddy['a'] . '"></div><div class="invite_3" onclick="javascript:document.getElementById(\'check_' . $buddy['id'] . '\').checked = document.getElementById(\'check_' . $buddy['id'] . '\').checked?false:true;">' . $buddy['n'] . '<br/><span class="invite_5">' . $status[$buddy['s']] . '</span></div><input type="checkbox" name="invite[]" value="' . $buddy['id'] . '" id="check_' . $buddy['id'] . '" class="invite_4"></div>';
    }
    $inviteContent = '';
    $invitehide = '';
    $inviteContent = $s['available'] . "" . $s['away'] . "" . $s['offline'];
    if (empty($inviteContent)) {
        $inviteContent = $broadcast_language[18];
        $invitehide = 'style="display:none;"';
    }
    echo <<<EOD
<!DOCTYPE html>
<html>
<head>
<title>{$broadcast_language[13]}</title> 
<meta http-equiv="content-type" content="text/html; charset=utf-8"/> 
<link type="text/css" rel="stylesheet" media="all" href="../../css.php?type=plugin&name=broadcast" /> 
</head>
<body>
<form method="post" action="invite.php?action=inviteusers&embed={$embed}">
<div class="container">
\t<div class="container_title {$embedcss}">{$broadcast_language[11]}</div>
\t<div class="container_body {$embedcss}">
\t\t{$inviteContent}
\t\t<div style="clear:both"></div>
\t</div>
\t<div class="container_sub" {$invitehide}>
\t\t<input type=submit value="{$broadcast_language[12]}" class="invitebutton">
\t</div>
</div>\t
<input type="hidden" name="roomid" value="{$id}">
</form>
</body>
</html>
EOD;
}
Beispiel #29
0
function invite()
{
    global $userid;
    global $chatrooms_language;
    global $language;
    global $embed;
    global $embedcss;
    $status['available'] = $language[30];
    $status['busy'] = $language[31];
    $status['offline'] = $language[32];
    $status['invisible'] = $language[33];
    $status['away'] = $language[34];
    $id = $_GET['roomid'];
    $inviteid = $_GET['inviteid'];
    $roomname = $_GET['roomname'];
    $time = getTimeStamp();
    $buddyList = array();
    $sql = getFriendsList($userid, $time);
    $query = mysql_query($sql);
    if (defined('DEV_MODE') && DEV_MODE == '1') {
        echo mysql_error();
    }
    while ($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';
        }
        $avatar = getAvatar($chat['avatar']);
        if (!empty($chat['username'])) {
            if (function_exists('processName')) {
                $chat['username'] = processName($chat['username']);
            }
            $buddyList[] = array('id' => $chat['userid'], 'n' => $chat['username'], 's' => $chat['status'], 'a' => $avatar);
        }
    }
    if (function_exists('hooks_forcefriends') && is_array(hooks_forcefriends())) {
        $buddyList = array_merge(hooks_forcefriends(), $buddyList);
    }
    $number = 0;
    $s['available'] = '';
    $s['away'] = '';
    $s['busy'] = '';
    $s['offline'] = '';
    foreach ($buddyList as $buddy) {
        ++$number;
        if (strlen($buddy['n']) > 14) {
            $buddy['n'] = substr($buddy['n'], 0, 12) . '...';
        }
        $s[$buddy['s']] .= '<div class="invite_1"><div class="invite_2" onclick="javascript:document.getElementById(\'check_' . $buddy['id'] . '\').checked = document.getElementById(\'check_' . $buddy['id'] . '\').checked?false:true;"><img height=30 width=30 src="' . $buddy['a'] . '"></div><div class="invite_3" onclick="javascript:document.getElementById(\'check_' . $buddy['id'] . '\').checked = document.getElementById(\'check_' . $buddy['id'] . '\').checked?false:true;">' . $buddy['n'] . '<br/><span class="invite_5">' . $status[$buddy['s']] . '</span></div><input type="checkbox" name="invite[]" value="' . $buddy['id'] . '" id="check_' . $buddy['id'] . '" class="invite_4"></div>';
        if ($number % 2 == 0) {
            echo '<div style="clear:both"></div>';
            $number = 0;
        }
    }
    echo <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>{$chatrooms_language[22]}</title> 
<meta http-equiv="content-type" content="text/html; charset=utf-8"/> 
<link type="text/css" rel="stylesheet" media="all" href="../../css.php?type=module&name=chatrooms" /> 
</head>
<body>
<form method="post" action="chatrooms.php?action=inviteusers&embed={$embed}">
<div class="container">
\t<div class="container_title {$embedcss}">{$chatrooms_language[21]}</div>
\t<div class="container_body {$embedcss}">
\t\t{$s['available']}{$s['away']}{$s['offline']}
\t\t<div style="clear:both"></div>
\t</div>
\t<div class="container_sub {$embedcss}">
\t\t<input type=submit value="{$chatrooms_language[20]}" class="invitebutton">
\t</div>
</div>\t
<input type="hidden" name="roomid" value="{$id}">
<input type="hidden" name="inviteid" value="{$inviteid}">
<input type="hidden" name="roomname" value="{$roomname}"></form>
</body>
</html>
EOD;
}
Beispiel #30
0
function logview()
{
    $usertable = TABLE_PREFIX . DB_USERTABLE;
    $usertable_username = DB_USERTABLE_NAME;
    $usertable_userid = DB_USERTABLE_USERID;
    global $history;
    global $userid;
    global $chathistory_language;
    global $guestsMode;
    global $guestnamePrefix;
    global $limit;
    global $response;
    $data = array();
    $requester = '';
    $limit = 13;
    $preuserid = 0;
    if (!empty($guestnamePrefix)) {
        $guestnamePrefix .= '-';
    }
    if (!empty($_REQUEST['range'])) {
        $data = explode("|", $_REQUEST['range']);
    }
    if (!empty($_REQUEST['histrory'])) {
        $history = $_REQUEST['histrory'];
    }
    $data[0] = intval($data[0]);
    $data[1] = intval($data[1]);
    if (isset($_REQUEST['lastidfrom'])) {
        $lastidfrom = $_REQUEST['lastidfrom'];
    }
    $guestpart = "";
    if (!empty($_REQUEST['chatroommode'])) {
        if ($guestsMode == '1') {
            $guestpart = "union (select m1.*, m2.name chatroom, concat('" . $guestnamePrefix . "',f.name) fromu from cometchat_chatroommessages m1, cometchat_chatrooms m2, cometchat_guests f where  f.id = m1.userid and m1.chatroomid=m2.id and m1.chatroomid=" . $history . " and m1.id >= " . $data[0] . " and m1.id < " . $data[1] . " and m1.message not like 'CC^CONTROL_deletemessage_%')";
        }
        $sql = "(select m1.*, m2.name chatroom, f." . $usertable_username . " fromu from cometchat_chatroommessages m1, cometchat_chatrooms m2, " . $usertable . " f where  f." . $usertable_userid . " = m1.userid and m1.chatroomid=m2.id and m1.chatroomid='" . $history . "' and m1.id >= " . $data[0] . " and m1.id < " . $data[1] . " and m1.message not like 'CC^CONTROL_deletemessage_%') " . $guestpart . " order by id limit " . $limit . "";
    } else {
        if ($guestsMode == '1') {
            $guestpart = "union (select m1.*, concat('" . $guestnamePrefix . "',f.name) fromu, concat('" . $guestnamePrefix . "',t.name) tou from cometchat m1, cometchat_guests f, cometchat_guests t where f.id = m1.from and t.id = m1.to and ((m1.from = '" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "' and m1.to = '" . mysqli_real_escape_string($GLOBALS['dbh'], $history) . "') or (m1.to = '" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "' and m1.from = '" . mysqli_real_escape_string($GLOBALS['dbh'], $history) . "')) and m1.id >= " . $data[0] . " and m1.id < " . $data[1] . " and m1.direction <> 2) union (select m1.*, concat('" . $guestnamePrefix . "',f.name) fromu, t." . $usertable_username . " tou from cometchat m1, cometchat_guests f, " . $usertable . " t where f.id = m1.from and t." . $usertable_userid . " = m1.to and ((m1.from = '" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "' and m1.to = '" . mysqli_real_escape_string($GLOBALS['dbh'], $history) . "') or (m1.to = '" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "' and m1.from = '" . mysqli_real_escape_string($GLOBALS['dbh'], $history) . "')) and m1.id >= " . $data[0] . " and m1.id < " . $data[1] . " and m1.direction <> 2) union (select m1.*, f." . $usertable_username . " fromu, concat('" . $guestnamePrefix . "',t.name) tou from cometchat m1, " . $usertable . " f, cometchat_guests t where f." . $usertable_userid . " = m1.from and t.id = m1.to and ((m1.from = '" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "' and m1.to = '" . mysqli_real_escape_string($GLOBALS['dbh'], $history) . "') or (m1.to = '" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "' and m1.from = '" . mysqli_real_escape_string($GLOBALS['dbh'], $history) . "')) and m1.id >= " . $data[0] . " and m1.id < " . $data[1] . " and m1.direction <> 2)";
        }
        $sql = "(select m1.*, f." . $usertable_username . " fromu, t." . $usertable_username . " tou from cometchat m1, " . $usertable . " f, " . $usertable . " t  where  f." . $usertable_userid . " = m1.from and t." . $usertable_userid . " = m1.to and ((m1.from = '" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "' and m1.to = '" . mysqli_real_escape_string($GLOBALS['dbh'], $history) . "') or (m1.to = '" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "' and m1.from = '" . mysqli_real_escape_string($GLOBALS['dbh'], $history) . "')) and m1.id >= " . $data[0] . " and m1.id < " . $data[1] . " and m1.direction <> 2) " . $guestpart . " order by id limit " . $limit . "";
    }
    $query = mysqli_query($GLOBALS['dbh'], $sql);
    $previd = '';
    $lines = 0;
    $s = 0;
    if (mysqli_num_rows($query) > 0) {
        while ($chat = mysqli_fetch_assoc($query)) {
            if (function_exists('processName')) {
                $chat['fromu'] = processName($chat['fromu']);
                if (empty($_REQUEST['chatroommode'])) {
                    $chat['tou'] = processName($chat['tou']);
                }
            }
            if ($s == 0) {
                $s = $chat['sent'];
            }
            $requester = $chat['fromu'];
            if (!empty($_REQUEST['chatroommode'])) {
                $chathistory_language[2] = $chathistory_language[7];
                $requester = $chat['chatroom'];
                if ($chat['userid'] == $userid) {
                    $chat['fromu'] = $chathistory_language[1];
                }
                if ($chat['userid'] == $preuserid) {
                    $chat['fromu'] = '';
                }
                $preuserid = $chat['userid'];
            } else {
                if ($chat['from'] == $userid) {
                    $chat['fromu'] = $chathistory_language[1];
                }
            }
            if (strpos($chat['message'], 'CC^CONTROL_deletemessage_') <= -1) {
                $chatmes = $chat['message'];
            }
            if (!empty($_REQUEST['chatroommode'])) {
                if (isset($_REQUEST['lastidfrom']) && $lastidfrom == $chat['userid']) {
                    $chat['fromu'] = '';
                }
            } else {
                if (isset($_REQUEST['lastidfrom']) && $lastidfrom == $chat['from']) {
                    $chat['fromu'] = '';
                }
            }
            $lines++;
            $previd = 1000000;
            if (isset($chat['userid'])) {
                $lastidfrom = $chat['userid'];
            } else {
                if (isset($chat['from'])) {
                    $lastidfrom = $chat['from'];
                }
            }
            $response['_' . $chat['id']] = array('id' => $chat['id'], 'previd' => $previd, 'from' => $chat['fromu'], 'requester' => $requester, 'message' => $chatmes, 'sent' => $chat['sent'] * 1000, 'userid' => $lastidfrom);
        }
        echo json_encode($response);
        exit;
    } else {
        echo '0';
        exit;
    }
}