= 95) { SQL_EmptyQuery("DELETE FROM {$GLOBALS['sql_prefix']}online WHERE utime<(now() - INTERVAL '{$GLOBALS['chatlist_viewlimit']} seconds')", __FILE__.' : '.__LINE__.' : '.__FUNCTION__); } $uid = PChoose($_SESSION['chats'][$id]['id'], $_SESSION['chats'][0]['id'])+0; if ($uid==0) $uid='NULL'; $rez = SQL_SingleQuery("UPDATE {$GLOBALS['sql_prefix']}online SET uid={$uid},utime=now() WHERE chat={$id} AND ips='{$_SERVER['REMOTE_ADDR']}'", NULL, __FILE__.' : '.__LINE__.' : '.__FUNCTION__); if (SQL_AffectedRows($rez) == 0) SQL_EmptyQuery("INSERT INTO {$GLOBALS['sql_prefix']}online (chat,session_id,ips,uid) VALUES ({$id},{$ip},'{$_SERVER['REMOTE_ADDR']}', {$uid})", __FILE__.' : '.__LINE__.' : '.__FUNCTION__); SQL_FreeResult($rez); } function GetViewers($id=0) { if ($id == 0) $id = $GLOBALS['id']; $id = SQL_EscapeString($id)+0; $num = 0; $rez = SQL_SingleQuery("SELECT DISTINCT chat,ips FROM {$GLOBALS['sql_prefix']}online WHERE chat={$id} AND utime>(now() - INTERVAL '{$GLOBALS['chatlist_viewlimit']} seconds')", NULL, __FILE__.' : '.__LINE__.' : '.__FUNCTION__); $num = SQL_NumRows($rez); SQL_FreeResult($rez); return $num; } function ShowChatLog($id=0, $chan=0) { if ($id == 0) $id = $GLOBALS['id']; $id = SQL_EscapeString($id)+0; if ($chan == 0) $chan = $_SESSION['chats'][$id]['chan']; $chan = SQL_EscapeString($chan)+0; $out = ''; if ($_SESSION['chats'][$id]['reload'] == 1) { unset($_SESSION['chats'][$id]['reload']); $out .= << parent.frames['Console'].location = '?p=console'; PHPEND; } else if ($_SESSION['chats'][$id]['reload'] == 2) { unset($_SESSION['chats'][$id]['reload']); $out .= << parent.frames['Console'].location = '?p=logout'; PHPEND; } //AddToViewers(); //$out .= GetFile("{$GLOBALS['level']}_inc/data/announce.default"); if (count($_SESSION['chats'][$id]['ignore']) > 0 && !CheckFlags($GLOBALS['chat']['flags'], 'I')) { $query = "SELECT line,ident,stamp FROM {$GLOBALS['sql_prefix']}log WHERE chat={$id} AND channel={$chan} EXCEPT ALL (SELECT l.line,l.ident,l.stamp FROM {$GLOBALS['sql_prefix']}log AS l JOIN {$GLOBALS['sql_prefix']}ban AS b ON (l.channel={$chan} AND (l.chat=b.chat OR b.chat=0) AND (l.flags IS NULL OR (l.flags IS NOT NULL AND l.flags NOT ILIKE '%M%')) AND (l.ident=b.ident OR l.userid=b.uid OR l.username ILIKE b.hmask OR text(l.ip) LIKE b.ipmask) AND (b.expires>now() OR b.perm='yes') AND b.type='ignore' AND b.authid='{$_SESSION['session_id']}')) "; if (CheckFlags($_SESSION['chats'][$id]['style'], 'R')) { $result = SQL_SingleQuery($query."ORDER BY stamp ASC LIMIT {$GLOBALS['chat']['s_chatlines']}", NULL, __FILE__.' : '.__LINE__.' : '.__FUNCTION__); } else { $result = SQL_SingleQuery($query."ORDER BY stamp DESC LIMIT {$GLOBALS['chat']['s_chatlines']}", NULL, __FILE__.' : '.__LINE__.' : '.__FUNCTION__); } $num = SQL_NumRows($result); for($i=0;$i<$num;$i++) { $line = SQL_FetchAssoc($result, $i); if ($GLOBALS['use_zlib']) $line['line'] = gzuncompress($line['line']); $out .= $line['line']."\n"; } SQL_FreeResult($result); } else { if (!file_exists("_inc/cache/cache.{$id}.{$chan}.log")) CacheChatLines($id, $chan); if (CheckFlags($_SESSION['chats'][$id]['style'], 'R')) { $out .= GetFile("_inc/cache/rcache.{$id}.{$chan}.log"); } else { $out .= GetFile("_inc/cache/cache.{$id}.{$chan}.log"); } } if (CheckFlags($_SESSION['chats'][$id]['style'], 'R')) { $out .= << SCRIPT; } if (CheckFlags($_SESSION['chats'][$id]['style'], 'C')) { $out = preg_replace('@(color=([^>\s]+))@is', '', $out); $out = preg_replace('@(color:([^;<}]+))@is', '', $out); } return $out; } ?>