Просмотр файла stats.php

Размер файла: 4.72Kb
<?php
$urls='stats.php';
error_reporting(0);
$ttl='| Статистика';
include("config.php");
include("./includes/".$ver."/banned");

$ref = rand(1000, 9999);

list($msec, $sec) = explode(chr(32), microtime()); 
$headtime = $sec + $msec;

header ("Content-type: text/html; charset=utf-8");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-relative");
include("./template/head.php");
//AUTH
$q = mysql_query("SELECT `id` FROM `chat_users` WHERE `id` = '".$id."' AND `password` = '".$password."';");
if(mysql_num_rows($q) == 0)
{
include("./reginc.php");
include("./template/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 '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?mod=top\">10 лучших!</a><br/>\n";
echo "<a href=\"stats.php?mod=clevers\">10 самых умных!</a><br/>\n";
echo "<a href=\"stats.php?mod=players\">10 самых азартных!</a><br/>\n";
echo "<a href=\"stats.php?mod=stats\">Общая статистика чата</a><br/>\n";
break;
}

if(!empty($mod)) echo "<a href=\"stats.php?ver=html\">Статистика</a><br/>\n";
echo "<br/><a href=\"index.php\">Меню чата</a><br/>\n";
include("./template/foot.php");
break;

?>