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(); }
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(); } if (!empty($_GET['chatroommode'])) { if (!empty($_GET['history'])) { $history = $_GET['history']; $sql = "select m1.*, f.{$usertable_username} fromu from cometchat_chatroommessages m1, {$usertable} f where f.{$usertable_userid} = m1.userid and m1.chatroomid='" . $history . "' and (m1.sent) > ALL(select (m2.sent)+1800 from cometchat_chatroommessages m2 where m1.chatroomid = m2.chatroomid and m2.sent <= m1.sent and m2.id < m1.id) order by id desc"; } } else { $sql = "select m1.*, f.{$usertable_username} fromu, t.{$usertable_username} tou from cometchat m1, {$usertable} f, {$usertable} t \n\t\t\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(select (m2.sent)+1800 from cometchat m2 where ((m2.to = m1.to and m2.from = m1.from) or (m2.to = m1.from and m2.from = m1.to)) and 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\t\t\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\t\t(select (m2.sent)+1800 from cometchat m2 where ((m2.to = m1.to and m2.from = m1.from) or (m2.to = m1.from and m2.from = m1.to))and m2.sent <= m1.sent and m2.id < m1.id) order by id desc"; } } $query = mysql_query($sql); $chatdata = ''; $previd = 1000000; if (mysql_num_rows($query) > 0) { while ($chat = mysql_fetch_array($query)) { if (function_exists('processName')) { $chat['fromu'] = processName($chat['fromu']); if (empty($_GET['chatroommode'])) { $chat['tou'] = processName($chat['tou']); } } $requester = $chat['fromu']; if (empty($_GET['chatroommode'])) { if ($chat['from'] == $userid) { $chat['fromu'] = $chathistory_language[1]; } } else { if ($chat['userid'] == $userid) { $chat['fromu'] = $chathistory_language[1]; } } $chat['message'] = $chat['message']; $encode = base64_encode($chat['id'] . "," . $previd); $chatdata = <<<EOD \t\t\t{$chatdata} \t\t\t<div class="chat" id="{$encode}" title="{$chathistory_language[8]}"> \t\t\t\t<div class="chatrequest"><b>{$chat['fromu']}</b></div> \t\t\t\t<div class="chatmessage chatmessage_short">{$chat['message']}</div> \t\t\t\t<div class="chattime" timestamp={$chat['sent']}></div> \t\t\t\t<div style="clear:both"></div> \t\t\t</div> EOD; $previd = $chat['id']; } } else { echo "<div class='norecords'>" . $chathistory_language[9] . "</div>"; } $chatdata .= ''; $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"'; } if (!empty($_GET['chatroommode'])) { $history .= '+"&chatroommode=1"'; } $baseData = $_REQUEST['basedata']; $body = <<<EOD \t\t \t<script> \t\tjqcc(document).ready(function () { \t\t\tjqcc('.chat').click(function() {\t\t\t \t\t\t\tvar id = jqcc(this).attr('id'); \t\t\t\tlocation.href = "?action=logs&basedata={$baseData}&id="+id{$history}; \t\t\t}); \t\t}); \t</script> \t{$chatdata} EOD; template(); }