<?php
//POWERED by ILI
// ICQ : 197042
//site: ili.wab.ru
// ilichat v4.0
error_reporting(0);
require_once"./includes/functions/gzip.php";
include('start.php');
include("config.php");
include("./includes/".$ver."/banned");
$ref = rand(1000, 9999);
list($msec, $sec) = explode(chr(32), microtime());
$headtime = $sec + $msec;
switch($ver)
{
////////////////////////////////////////////////////////
//WML VERSION
////////////////////////////////////////////////////////
case 'wml':
header("Content-type:text/vnd.wap.wml; charset=utf-8");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-revalidate");
//AUTH
$id = intval($_SESSION['id']);
$password = mysql_escape_string($_SESSION['password']);
$q = mysql_query("SELECT `id` FROM `chat_users` WHERE `id` = '".$id."' AND `password` = '".md5($password)."';");
if(mysql_num_rows($q) == 0)
{
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\" \"http://www.wapforum.org/DTD/wml13.dtd\"><wml>\n";
echo "<card title=\"ERROR\" ontimer=\"index.php?ver=wml\"><timer value=\"15\"/><p align=\"left\">\n";
echo "<small>Ошибка авторизации!<br/>\n";
list($msec, $sec) = explode(chr(32), microtime());
echo "<br/>[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
echo "</small>";
require_once "includes/functions/gzip_foot.php";
echo "</p></card></wml>";
ob_end_flush();
exit();
}
//END AUTH
//ONLINE
$online = time() + 60;
$update = mysql_query("UPDATE `chat_users` SET `time` = '".$online."', `place` = 0, `ip` = '".getenv('REMOTE_ADDR')."', `ua` = '".htmlspecialchars(getenv('HTTP_USER_AGENT'))."' WHERE `id` = '".$id."';");
//END ONLINE
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\" \"http://www.wapforum.org/DTD/wml13.dtd\"><wml>\n";
echo "<card title=\"Статистика\"><p align=\"left\">\n";
if(isset($_GET['mod']))
{
$mod = $_GET['mod'];
}
else
{
$mod = "";
}
switch($mod)
{
case 'top':
echo "10-ка лучших:<br/>\n";
$q = mysql_query("SELECT `nickname`, `posts` FROM `chat_users` ORDER BY `posts` DESC LIMIT 10;");
$c = 1;
while($user = mysql_fetch_array($q))
{
$nickname = $user['nickname'];
$posts = $user['posts'];
echo "$c. $nickname - $posts<br/>\n";
$c++;
}
break;
case 'last':
echo "10-ка последних зарегистрировавшихся:<br/>\n";
$q = mysql_query("SELECT `nickname`, `id` FROM `chat_users` ORDER BY `id` DESC LIMIT 10;");
$c = 1;
while($user = mysql_fetch_array($q))
{
$nickname = $user['nickname'];
$id = $user['id'];
echo "$c. $nickname - $id<br/>\n";
$c++;
}
break;
case 'clevers':
echo "Самые умные:<br/>\n";
$q = mysql_query("SELECT `nickname`, `answers` FROM `chat_users` ORDER BY `answers` DESC LIMIT 10;");
$c = 1;
while($user = mysql_fetch_array($q))
{
$nickname = $user['nickname'];
$answers = $user['answers'];
echo "$c. $nickname - $answers<br/>\n";
$c++;
}
break;
case 'players':
echo "Самые азартные:<br/>\n";
$q = mysql_query("SELECT `nickname`, `gbalans` FROM `chat_users` ORDER BY `gbalans` DESC LIMIT 10;");
$c = 1;
while($user = mysql_fetch_array($q))
{
$nickname = $user['nickname'];
$gbalans = $user['gbalans'];
echo "$c. $nickname - $gbalans<br/>\n";
$c++;
}
break;
case 'stats':
$q = mysql_query("SELECT COUNT(*) FROM `chat_users`;");
$users = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(*) FROM `chat`;");
$posts = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(*) FROM `chat_users` WHERE `kick` > ".time().";");
$kicks = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(*) FROM `chat_banned`;");
$banned = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(*) FROM `chat_users` WHERE `fsize` = 0;");
$small_fsize = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(*) FROM `chat_users` WHERE `fsize` = 1;");
$medium_fsize = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(*) FROM `chat_users` WHERE `fsize` = 2;");
$big_fsize = mysql_result($q, 0);
$small_fsize = sprintf("%01.1f%s", $small_fsize/$users * 100, "%");
$medium_fsize = sprintf("%01.1f%s", $medium_fsize/$users * 100, "%");
$big_fsize = sprintf("%01.1f%s", $big_fsize/$users * 100, "%");
$q = mysql_query("SELECT COUNT(*) FROM `chat_users` WHERE `security` = 0;");
$off_security = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(*) FROM `chat_users` WHERE `security` = 1;");
$on_security = mysql_result($q, 0);
$off_security = sprintf("%01.1f%s", $off_security/$users * 100, "%");
$on_security = sprintf("%01.1f%s", $on_security/$users * 100, "%");
$q = mysql_query("SELECT COUNT(*) FROM `chat_users` WHERE `smiles` = 0;");
$smiles_on = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(*) FROM `chat_users` WHERE `smiles` != 0;");
$smiles_off = mysql_result($q, 0);
$smiles_on = sprintf("%01.1f%s", $smiles_on/$users * 100, "%");
$smiles_off = sprintf("%01.1f%s", $smiles_off/$users * 100, "%");
echo "В чате зарегистрировано <b>$users</b> пользователей";
if($kicks != 0) echo ", <b>$kicks</b> из которых выпнуто";
if($banned != 0) echo " и <b>$banned</b> из них забанено";
echo ".\n<br/>";
echo "<b>$small_fsize</b> используют маленький шрифт, <b>$medium_fsize</b> - средний, а большой <b>$big_fsize</b>.<br/>\n";
echo "<b>$on_security</b> включили систему безопастности, а <b>$off_security</b> выключили.<br/>\n";
echo "У <b>$smiles_on</b> участников чата включены смайлы, а у <b>$smiles_off</b> выключены.<br/>\n";
break;
default:
echo "<a href=\"stats.php?".SID."&ver=wml&mod=top\">10 лучших!</a><br/>\n";
echo "<a href=\"stats.php?".SID."&ver=wml&mod=clevers\">10 самых умных!</a><br/>\n";
echo "<a href=\"stats.php?".SID."&ver=wml&mod=players\">10 самых азартных!</a><br/>\n";
echo "<a href=\"stats.php?".SID."&ver=wml&mod=last\">10-ка последних зарегистрировавшихся</a><br/>\n";
echo "<a href=\"stats.php?".SID."&ver=wml&mod=stats\">Общая статистика чата</a><br/>\n";
break;
}
if(!empty($mod)) echo "<a href=\"stats.php?".SID."&ver=wml\">Статистика</a><br/>\n";
echo "<br/><a href=\"menu.php?".SID."&ver=wml\">Меню чата</a><br/>\n";
list($msec, $sec) = explode(chr(32), microtime());
echo "<br/><small>[".round(($sec+$msec)-$headtime, 5)."] sec</small><br/>\n";
require_once "includes/functions/gzip_foot.php";
echo "</p></card></wml>";
ob_end_flush();
break;
////////////////////////////////////////////////////////
//HTML VERSION
////////////////////////////////////////////////////////
case 'html':
$my_title = "Stats";
if(!isset($_COOKIE['theme'])) $_COOKIE['theme'] = 1;
include_once "themes/".intval($_COOKIE['theme'])."/index.php";
//AUTH
$id = intval($_SESSION['id']);
$password = mysql_escape_string($_SESSION['password']);
$q = mysql_query("SELECT `id` FROM `chat_users` WHERE `id` = '".$id."' AND `password` = '".md5($password)."';");
if(mysql_num_rows($q) == 0)
{
echo "Ошибка авторизации!<br/>\n";
include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
exit();
}
//END AUTH
//ONLINE
$online = time() + 60;
$update = mysql_query("UPDATE `chat_users` SET `time` = '".$online."', `place` = 0, `ip` = '".getenv('REMOTE_ADDR')."', `ua` = '".htmlspecialchars(getenv('HTTP_USER_AGENT'))."' WHERE `id` = '".$id."';");
//END ONLINE
if(isset($_GET['mod']))
{
$mod = $_GET['mod'];
}
else
{
$mod = "";
}
switch($mod)
{
case 'top':
echo "10-ка лучших:<br/>\n";
$q = mysql_query("SELECT `nickname`, `posts` FROM `chat_users` ORDER BY `posts` DESC LIMIT 10;");
$c = 1;
while($user = mysql_fetch_array($q))
{
$nickname = $user['nickname'];
$posts = $user['posts'];
echo "$c. $nickname - $posts<br/>\n";
$c++;
}
break;
case 'last':
echo "10-ка последних зарегистрировавшихся:<br/>\n";
$q = mysql_query("SELECT `nickname`, `id` FROM `chat_users` ORDER BY `id` DESC LIMIT 10;");
$c = 1;
while($user = mysql_fetch_array($q))
{
$nickname = $user['nickname'];
$id = $user['id'];
echo "$c. $nickname - $id<br/>\n";
$c++;
}
break;
case 'clevers':
echo "Самые умные:<br/>\n";
$q = mysql_query("SELECT `nickname`, `answers` FROM `chat_users` ORDER BY `answers` DESC LIMIT 10;");
$c = 1;
while($user = mysql_fetch_array($q))
{
$nickname = $user['nickname'];
$answers = $user['answers'];
echo "$c. $nickname - $answers<br/>\n";
$c++;
}
break;
case 'players':
echo "Самые азартные:<br/>\n";
$q = mysql_query("SELECT `nickname`, `gbalans` FROM `chat_users` ORDER BY `gbalans` DESC LIMIT 10;");
$c = 1;
while($user = mysql_fetch_array($q))
{
$nickname = $user['nickname'];
$gbalans = $user['gbalans'];
echo "$c. $nickname - $gbalans<br/>\n";
$c++;
}
break;
case 'stats':
$q = mysql_query("SELECT COUNT(*) FROM `chat_users`;");
$users = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(*) FROM `chat`;");
$posts = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(*) FROM `chat_users` WHERE `kick` > ".time().";");
$kicks = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(*) FROM `chat_banned`;");
$banned = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(*) FROM `chat_users` WHERE `fsize` = 0;");
$small_fsize = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(*) FROM `chat_users` WHERE `fsize` = 1;");
$medium_fsize = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(*) FROM `chat_users` WHERE `fsize` = 2;");
$big_fsize = mysql_result($q, 0);
$small_fsize = sprintf("%01.1f%s", $small_fsize/$users * 100, "%");
$medium_fsize = sprintf("%01.1f%s", $medium_fsize/$users * 100, "%");
$big_fsize = sprintf("%01.1f%s", $big_fsize/$users * 100, "%");
$q = mysql_query("SELECT COUNT(*) FROM `chat_users` WHERE `security` = 0;");
$off_security = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(*) FROM `chat_users` WHERE `security` = 1;");
$on_security = mysql_result($q, 0);
$off_security = sprintf("%01.1f%s", $off_security/$users * 100, "%");
$on_security = sprintf("%01.1f%s", $on_security/$users * 100, "%");
$q = mysql_query("SELECT COUNT(*) FROM `chat_users` WHERE `smiles` = 0;");
$smiles_on = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(*) FROM `chat_users` WHERE `smiles` != 0;");
$smiles_off = mysql_result($q, 0);
$smiles_on = sprintf("%01.1f%s", $smiles_on/$users * 100, "%");
$smiles_off = sprintf("%01.1f%s", $smiles_off/$users * 100, "%");
echo "В чате зарегистрировано <b>$users</b> пользователей";
if($kicks != 0) echo ", <b>$kicks</b> из которых выпнуто";
if($banned != 0) echo " и <b>$banned</b> из них забанено";
echo ".\n<br/>";
echo "<b>$small_fsize</b> используют маленький шрифт, <b>$medium_fsize</b> - средний, а большой <b>$big_fsize</b>.<br/>\n";
echo "<b>$on_security</b> включили систему безопастности, а <b>$off_security</b> выключили.<br/>\n";
echo "У <b>$smiles_on</b> участников чата включены смайлы, а у <b>$smiles_off</b> выключены.<br/>\n";
break;
default:
echo "<a href=\"stats.php?".SID."&ver=html&mod=top\">10 лучших!</a><br/>\n";
echo "<a href=\"stats.php?".SID."&ver=html&mod=clevers\">10 самых умных!</a><br/>\n";
echo "<a href=\"stats.php?".SID."&ver=html&mod=players\">10 самых азартных!</a><br/>\n";
echo "<a href=\"stats.php?".SID."&ver=html&mod=last\">10-ка последних зарегистрировавшихся</a><br/>\n";
echo "<a href=\"stats.php?".SID."&ver=html&mod=stats\">Общая статистика чата</a><br/>\n";
break;
}
if(!empty($mod)) echo "<a href=\"stats.php?".SID."&ver=html\">Статистика</a><br/>\n";
echo "<br/><a href=\"menu.php?".SID."&ver=html\">Меню чата</a><br/>\n";
include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
break;
}
?>