} else { $clist[$numvis][4] = 0; } if (!empty($clist[$numvis][4])) { unset($lines[$dirx[$cc]]); } $clist[$numvis][5] = $dirx[$cc]; $clist[$numvis][6] = $crating; $cview = ExAlist('chat' . $dirx[$cc]); $ccall += $cview; $clist[$numvis][7] = $cview; $numvis++; } MMC_Set('portal.stamp', time(), 900); MMC_Set('portal.clist', $clist, 900); MMC_Set('portal.popular', $lines, 900); } $numvis = count($clist); $ccall = 0; $ccv = 0; foreach ($clist as $c) { $ccall += $c[2]; $ccv += $c[3]; } MMC_Unlock('portal.lock'); if ($_REQUEST['sort'] == 'chat') { usort($clist, 'SortListChat'); } else { if ($_REQUEST['sort'] == 'active') { usort($clist, 'SortListActive'); } else {
function GenerateXML($last = 0, $info = 0) { global $realpath, $handler, $maxlines, $ctitle, $nview; header('Content-Type: text/xml'); $rez = count_mysql_query("SELECT UNIX_TIMESTAMP(MAX(posttime)) as stamp FROM uo_chat_log WHERE chat='{$realpath}'", $handler, "reader.php: GenerateXML() 1/1"); $row = mysql_fetch_assoc($rez); mysql_free_result($rez); if (!empty($last) && $last >= intval($row['stamp'])) { header('HTTP/1.1 304 Not Modified'); die; } // $last = 0; $last = intval(MMC_Get($realpath . '.xml.last')); if (empty($info) && !empty($last) && $last >= intval($row['stamp'])) { $output = MMC_Get($realpath . '.xml.output'); if (!empty($output)) { echo $output; echo '<!-- cached version -->', "\n"; die; } } MMC_Set($realpath . '.xml.last', intval($row['stamp']), 900); $tz = date('Z'); $path = mb_substr($realpath, 4); $rez = @count_mysql_query("SELECT count(chat) FROM uo_chat_ulist WHERE chat='{$realpath}' AND utime>" . (time() - 300) . "", $handler, "reader.php: GenerateXML() 1/1"); $active = mysql_fetch_row($rez); $active = intval($active[0]); mysql_free_result($rez); $rez = @count_mysql_query("SELECT count(chat) FROM uo_chat_ulist WHERE chat='{$realpath}'", $handler, "reader.php: GenerateXML() 1/1"); $chatters = mysql_fetch_row($rez); $chatters = intval($chatters[0]); mysql_free_result($rez); $output = ''; $output .= '<' . '?xml version="1.0" encoding="UTF-8"?' . ">\n"; $xinfo = <<<XMLEND <info> \t<chat>{$path}</chat> \t<title>{$ctitle}</title> \t<lastpost>{$row['stamp']}</lastpost> \t<timezone>{$tz}</timezone> \t<viewers>{$nview}</viewers> \t<chatters>{$chatters}</chatters> \t<active>{$active}</active> </info> XMLEND; if (!empty($info)) { echo $output; echo $xinfo; return; } $output .= <<<XMLEND <reader> \t{$xinfo} \t<lines> XMLEND; $rez = @count_mysql_query("SELECT\n\t\tUNIX_TIMESTAMP(posttime) as stamp,ident,username,line,rawpost,\n\t\txmlpost,color\n\t\tFROM uo_chat_log\n\t\tWHERE\n\t\tchat='{$realpath}'\n\t\tORDER BY posttime DESC LIMIT {$maxlines}\n\t\t", $handler, "reader.php: GenerateXML() 1/1"); for ($i = 0; $row = mysql_fetch_assoc($rez); $i++) { $row['line'] = EncodeLtGt($row['line']); $row['rawpost'] = EncodeLtGt($row['rawpost']); $row['xmlpost'] = EncodeLtGt($row['xmlpost']); $output .= <<<XMLEND \t\t<line> \t\t\t<id>{$i}</id> \t\t\t<ident>{$row['ident']}</ident> \t\t\t<color>#{$row['color']}</color> \t\t\t<username>{$row['username']}</username> \t\t\t<posttime>{$row['stamp']}</posttime> \t\t\t<fullpost>{$row['line']}</fullpost> \t\t\t<rawpost>{$row['rawpost']}</rawpost> \t\t\t<post>{$row['xmlpost']}</post> \t\t</line> XMLEND; } $output .= <<<XMLEND \t</lines> </reader> XMLEND; echo $output; echo '<!-- generated fresh -->', "\n"; MMC_Set($realpath . '.xml.output', $output, 900); }
/* DROP TABLE IF EXISTS tmpa ; CREATE TABLE tmpa AS SELECT T.* FROM uo_chat_threads as T LEFT JOIN uo_chat_boards as B ON (T.id=B.uid) WHERE flags IS NOT NULL ; TRUNCATE uo_chat_threads ; INSERT INTO uo_chat_threads SELECT * FROM tmpa ; //*/ /* if ($_SERVER['REMOTE_ADDR'] != '62.198.254.119') { header('HTTP/1.0 403 Temporarily Disabled'); die ('Temporarily disabled due to spam overload.'); } //*/ if (!empty($_REQUEST) && !empty($_REQUEST['post'])) { require_once '../../../chatv3/_inc/mmcache.php'; $last = intval(MMC_Get('jbb.' . $_SERVER['REMOTE_ADDR'])); MMC_Set('jbb.' . $_SERVER['REMOTE_ADDR'], max(time(), $last) + 10); if (time() < $last) { header('HTTP/1.0 403 Too Soon'); die('You cannot post again that fast.'); } sleep(2); } set_magic_quotes_runtime(0); if (get_magic_quotes_gpc()) { foreach ($_REQUEST as $key => $value) { $_REQUEST[$key] = stripslashes($value); } foreach ($_COOKIE as $key => $value) { $_COOKIE[$key] = stripslashes($value); } }
function CacheChatLines() { global $realpath, $handler, $start, $maxlines; $result = @count_mysql_query("SELECT line, posttime FROM uo_chat_log WHERE chat='{$realpath}' ORDER BY posttime DESC LIMIT {$maxlines}", $handler, "helpers.php: CacheChatLines() 1/2"); $oldest = null; $lines = array(); while ($line = @mysql_fetch_assoc($result)) { $lines[] = $line['line']; $oldest = $line['posttime']; } for ($i = 0; $i < count($lines); $i++) { $lines[$i] = str_replace("\\'", "'", $lines[$i]); } @mysql_free_result($result); @count_mysql_query("DELETE FROM uo_chat_log WHERE chat='{$realpath}' AND posttime < '{$oldest}'", $handler, "helpers.php: CacheChatLines() 2/2"); echo "\n<!-- {$realpath}.lines -->\n"; MMC_Lock("{$realpath}.lines"); $fcac = ''; // @fopen("../common/cache/$realpath.cache", "wb"); for ($cc = 0; $cc < count($lines); $cc++) { $fcac .= str_replace("`", "'", $lines[$cc]) . "\n"; } MMC_Set("{$realpath}.cache", $fcac, 60); $fcac = ''; // @fopen("../common/cache/$realpath.rache", "wb"); for ($cc = count($lines) - 1; $cc >= 0; $cc--) { $fcac .= str_replace("`", "'", $lines[$cc]) . "\n"; } MMC_Set("{$realpath}.rache", $fcac, 60); if ($exit == 0) { echo "<!-- Debug: " . round(getmicrotime() - $start, 5) . " secs / {$cqs} queries -->"; echo "<!-- {$creas} -->"; } MMC_Unlock("{$realpath}.lines"); }