Файл: statistic.php
Строк: 400
<?php
require 'system/sid.php';
require 'system/config.php';
include 'system/user.php';
include 'system/head.php';
include 'system/navigator.php';
whorm(0, 'stat');
$do = isset($_GET['do']) ? $_GET['do'] : NULL;
switch($do) {
default:
echo $div_title . 'Статистика' . $div_end;
$users = mysql_result(mysql_query("SELECT COUNT(id) FROM users"), 0);
$usersNew = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE date = '" . date('d-m-y') . "'"), 0);
$elite = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE level > '0'"), 0);
$journalists = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE journalist = '1'"), 0);
$today = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE visit LIKE '" . date('d/m/y') . "%'"), 0);
$birthday = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE birth LIKE '" . date('j.n.') . "%'"), 0);
$active = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE activity != '0'"), 0);
function calcPeriod($date_start, $date_finish) {
$st = explode('-', date('d-m-Y-H-i-s', $date_start));
$fin = explode('-', date('d-m-Y-H-i-s', $date_finish));
if (($seconds = $fin[5] - $st[5]) < 0) {
$fin[4]--;
$seconds += 60;
}
if (($minutes = $fin[4] - $st[4]) < 0) {
$fin[3]--;
$minutes += 60;
}
if (($hours = $fin[3] - $st[3]) < 0) {
$fin[0]--;
$hours += 24;
}
if (($days = $fin[0] - $st[0]) < 0) {
$fin[1]--;
$days = date('t', mktime(1, 0, 0, $st[1], $st[0], $st[2])) - $st[0] + $fin[0];
}
if (($months = $fin[1] - $st[1]) < 0) {
$fin[2]--;
$months += 12;
}
$years = $fin[2] - $st[2];
return array($seconds, $minutes, $hours, $days, $months, $years);
}
$date_finish = strtotime('now');
$date_start = strtotime('15-12-2012');
$result = calcPeriod($date_start, $date_finish);
echo '<div><a class="mlink" href="?do=users">» Список пользователей (' . $users . (!empty($usersNew) ? '+' . $usersNew : '') . ')</a></div>
<div><a class="mlink" href="?do=elite">» Администрация (' . $elite . ')</a></div>
<div><a class="mlink" href="?do=journalists">» Журналисты (' . $journalists . ')</a></div>
<div><a class="mlink" href="?do=today">» Посетители за сегодня (' . $today . ')</a></div>
<div><a class="mlink" href="?do=birthday">» Именинники (' . $birthday . ')</a></div>
<div><a class="mlink" href="?do=act">» Активные (' . $active . ')</a></div>
<div><a class="mlink" href="?do=avtoritet">» Авторитеты</a></div>
<div><a class="mlink" href="?do=know">» Деятели</a></div>';
echo $div_tworazdel . 'День рождения сайта ' . date('d-m-Y', $date_start) . '<br/>
до сегодняшней даты ' . date('d-m-Y', $date_finish) .'
прошло: ' . (!empty($result[5]) ? $result[5] . plural($result[5], ' год', ' года', ' лет') . ',' : '') . '
' . (!empty($result[4]) ? $result[4] . plural($result[4], ' месяц и ', ' месяца и ', ' месяцев и ') : '') . $result[3] . plural($result[3], ' день!', ' дня!', ' дней!') . $div_end;
break;
case users:
echo $div_title . 'Список пользователей' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM users"), 0);
if ($count != 0)
{
$n = new navigator($count, 10, '?do=users&');
$res = mysql_query("SELECT id, date FROM users ORDER BY id DESC {$n->limit}");
$cols = 0;
while($q = mysql_fetch_assoc($res))
{
++$cols;
$num = ($n->start + $cols);
echo $div_razdel . $num . '. ' . us($q['id']) . $div_end . 'Дата регистрации: ' . $q['date'] . '<br/>';
}
echo $n->navi();
} else {
echo 'Пользователей нет.';
}
break;
case elite:
echo $div_title . 'Администрация' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE level > '0'"), 0);
if ($count != 0)
{
$n = new navigator($count, 10, '?do=elite&');
$res = mysql_query("SELECT id FROM users WHERE level > '0' ORDER BY level DESC, id ASC {$n->limit}");
$cols = 0;
$i = 0;
while($q = mysql_fetch_assoc($res))
{
++$cols;
$num = ($n->start + $cols);
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $num . '. ' . us($q['id']) . ' ' . elite($q['id']) . $div_end;
}
echo $n->navi();
} else {
echo 'Администрации нет.';
}
break;
case journalists:
echo $div_title . 'Журналисты' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE journalist = '1'"), 0);
if ($count != 0)
{
$n = new navigator($count, 10, '?do=journalists&');
$res = mysql_query("SELECT id FROM users WHERE journalist = '1' ORDER BY id DESC {$n->limit}");
$cols = 0;
$i = 0;
while($q = mysql_fetch_assoc($res))
{
++$cols;
$num = ($n->start + $cols);
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $num . '. ' . us($q['id']) . $div_end;
}
echo $n->navi();
} else {
echo 'Журналистов нет.';
}
break;
case today:
echo $div_title . 'Посетители за сегодня' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE visit LIKE '" . date('d/m/y') . "%'"), 0);
if ($count != 0)
{
$n = new navigator($count, 10, '?do=today&');
$res = mysql_query("SELECT id, visit FROM users WHERE visit LIKE '" . date('d/m/y') . "%' ORDER BY visit DESC {$n->limit}");
$cols = 0;
while($q = mysql_fetch_assoc($res))
{
++$cols;
$num = ($n->start + $cols);
echo $div_razdel . $num . '. ' . us($q['id']) . $div_end . (user_inf($q['id'], 'onl') + 300 > time() ? 'Сейчас онлайн' : '<b>Последний визит:</b> ' . user_inf($q['id'], 'visit')) . '<br/>';
}
echo $n->navi();
} else {
echo 'Посетителей за сегодня нет.';
}
break;
case birthday:
echo $div_title . 'Именинники' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE birth LIKE '" . date('j.n.') . "%'"), 0);
if ($count != 0)
{
$n = new navigator($count, 10, '?do=birthday&');
$res = mysql_query("SELECT id, birth FROM users WHERE birth LIKE '" . date('j.n.') . "%' ORDER BY birth DESC {$n->limit}");
$cols = 0;
while($q = mysql_fetch_assoc($res))
{
++$cols;
$num = ($n->start + $cols);
echo $div_razdel . $num . '. ' . us($q['id']) . ' (' . calc_age($q['birth']) . ')' . $div_end;
}
$res2 = mysql_query("SELECT id, birth FROM users WHERE birth LIKE '" . date('j.n.') . "%' ORDER BY birth DESC {$n->limit}");
while($q = mysql_fetch_assoc($res2))
{
echo $block . '
<b>Быстрое поздравление</b><br/>
<form method="post" action="?do=birthday">
<select name="pzd">
<option value="'.$q['id'].'">' . user_inf($q['id'], 'user') . '</option>
</select>
<br/>
<textarea name="text" cols="50" rows="5" style="width: 99%;" placeholder="Ваше поздравление"></textarea>
<br/>
<input type="submit" name="ok" value="Поздравить"/>
</form>';
}
echo $n->navi();
} else {
echo 'Именинников нет.';
}
break;
case avtoritet:
echo $div_title . 'Авторитеты' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE rating_plus > '0'"), 0);
if ($count != 0)
{
$n = new navigator($count, 10, '?do=avtoritet&');
$res = mysql_query("SELECT id, rating_plus, rating_minus FROM users WHERE rating_plus > '0' ORDER BY rating_plus - rating_minus DESC, id DESC {$n->limit}");
$cols = 0;
while($q = mysql_fetch_assoc($res))
{
++$cols;
$num = ($n->start + $cols);
echo $div_razdel . $num . '. ' . us($q['id']) . $div_end . '<b>Авторитет:</b> ' . ($q['rating_plus'] - $q['rating_minus']) . '<br/>';
}
echo $n->navi();
} else {
echo 'Авторитетов нет.';
}
break;
case act:
echo $div_title . 'Активные' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE activity != '0'"), 0);
if ($count != 0)
{
$n = new navigator($count, 10, '?do=act&');
$res = mysql_query("SELECT id, activity FROM users WHERE activity != '0' ORDER BY activity DESC {$n->limit}");
$cols = 0;
while($q = mysql_fetch_assoc($res))
{
++$cols;
$num = ($n->start + $cols);
echo $div_razdel . $num . '. ' . us($q['id']) . $div_end . '<b>Активность:</b> ' . $q['activity'] . '%<br/>';
}
echo $n->navi();
} else {
echo 'Активных пользователей нет.';
}
break;
case know:
echo $div_title . 'Деятели' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE know != '0'"), 0);
echo '<b>Все</b> |
<a href="?do=knowCoders">Кодеры</a> |
<a href="?do=knowDesigners">Дизайнеры</a> |
<a href="?do=knowMasters">Мастера</a> |
<a href="?do=knowSales">Продавцы</a> |
<a href="?do=knowLenders">Кредиторы</a>';
if ($count != 0)
{
$n = new navigator($count, 10, '?do=know&');
$res = mysql_query("SELECT id, know, rating_plus, rating_minus FROM users WHERE know != '0' ORDER BY rating_plus - rating_minus DESC, id DESC {$n->limit}");
$cols = 0;
while($q = mysql_fetch_assoc($res))
{
if ($q['know'] == 1) $Kn = 'Кодер';
elseif ($q['know'] == 2) $Kn = 'Дизайнер';
elseif ($q['know'] == 3) $Kn = 'Мастер';
elseif ($q['know'] == 4) $Kn = 'Продавец';
elseif ($q['know'] == 5) $Kn = 'Кредитор';
++$cols;
$num = ($n->start + $cols);
echo $div_razdel . $num . '. ' . us($q['id']) . ' (' . $Kn . ')' . $div_end . '<b>Авторитет:</b> ' . ($q['rating_plus'] - $q['rating_minus']) . '<br/>';
}
echo $n->navi();
} else {
echo '<br/>Деятелей нет.';
}
break;
case knowCoders:
echo $div_title . 'Кодеры' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE know = '1'"), 0);
echo '<a href="?do=know">Все</a> |
<b>Кодеры</b> |
<a href="?do=knowDesigners">Дизайнеры</a> |
<a href="?do=knowMasters">Мастера</a> |
<a href="?do=knowSales">Продавцы</a> |
<a href="?do=knowLenders">Кредиторы</a>';
if ($count != 0)
{
$n = new navigator($count, 10, '?do=knowCoders&');
$res = mysql_query("SELECT id, rating_plus, rating_minus FROM users WHERE know = '1' ORDER BY rating_plus - rating_minus DESC, id DESC {$n->limit}");
$cols = 0;
while($q = mysql_fetch_assoc($res))
{
++$cols;
$num = ($n->start + $cols);
echo $div_razdel . $num . '. ' . us($q['id']) . ' (Кодер)' . $div_end . '<b>Авторитет:</b> ' . ($q['rating_plus'] - $q['rating_minus']) . '<br/>';
}
echo $n->navi();
} else {
echo '<br/>Кодеров нет.';
}
break;
case knowDesigners:
echo $div_title . 'Дизайнеры' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE know = '2'"), 0);
echo '<a href="?do=know">Все</a> |
<a href="?do=knowCoders">Кодеры</a> |
<b>Дизайнеры</b> |
<a href="?do=knowMasters">Мастера</a> |
<a href="?do=knowSales">Продавцы</a> |
<a href="?do=knowLenders">Кредиторы</a>';
if ($count != 0)
{
$n = new navigator($count, 10, '?do=knowDesigners&');
$res = mysql_query("SELECT id, rating_plus, rating_minus FROM users WHERE know = '2' ORDER BY rating_plus - rating_minus DESC, id DESC {$n->limit}");
$cols = 0;
while($q = mysql_fetch_assoc($res))
{
++$cols;
$num = ($n->start + $cols);
echo $div_razdel . $num . '. ' . us($q['id']) . ' (Дизайнер)' . $div_end . '<b>Авторитет:</b> ' . ($q['rating_plus'] - $q['rating_minus']) . '<br/>';
}
echo $n->navi();
} else {
echo '<br/>Дизайнеров нет.';
}
break;
case knowMasters:
echo $div_title . 'Мастера' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE know = '3'"), 0);
echo '<a href="?do=know">Все</a> |
<a href="?do=knowCoders">Кодеры</a> |
<a href="?do=knowDesigners">Дизайнеры</a> |
<b>Мастера</b> |
<a href="?do=knowSales">Продавцы</a> |
<a href="?do=knowLenders">Кредиторы</a>';
if ($count != 0)
{
$n = new navigator($count, 10, '?do=knowMasters&');
$res = mysql_query("SELECT id, rating_plus, rating_minus FROM users WHERE know = '3' ORDER BY rating_plus - rating_minus DESC, id DESC {$n->limit}");
$cols = 0;
while($q = mysql_fetch_assoc($res))
{
++$cols;
$num = ($n->start + $cols);
echo $div_razdel . $num . '. ' . us($q['id']) . ' (Мастер)' . $div_end . '<b>Авторитет:</b> ' . ($q['rating_plus'] - $q['rating_minus']) . '<br/>';
}
echo $n->navi();
} else {
echo '<br/>Мастеров нет.';
}
break;
case knowSales:
echo $div_title . 'Продавцы' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE know = '4'"), 0);
echo '<a href="?do=know">Все</a> |
<a href="?do=knowCoders">Кодеры</a> |
<a href="?do=knowDesigners">Дизайнеры</a> |
<a href="?do=knowMasters">Мастера</a> |
<b>Продавцы</b> |
<a href="?do=knowLenders">Кредиторы</a>';
if ($count != 0)
{
$n = new navigator($count, 10, '?do=knowSales&');
$res = mysql_query("SELECT id, rating_plus, rating_minus FROM users WHERE know = '4' ORDER BY rating_plus - rating_minus DESC, id DESC {$n->limit}");
$cols = 0;
while($q = mysql_fetch_assoc($res))
{
++$cols;
$num = ($n->start + $cols);
echo $div_razdel . $num . '. ' . us($q['id']) . ' (Продавец)' . $div_end . '<b>Авторитет:</b> ' . ($q['rating_plus'] - $q['rating_minus']) . '<br/>';
}
echo $n->navi();
} else {
echo '<br/>Продавцов нет.';
}
break;
case knowLenders:
echo $div_title . 'Кредиторы' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE know = '5'"), 0);
echo '<a href="?do=know">Все</a> |
<a href="?do=knowCoders">Кодеры</a> |
<a href="?do=knowDesigners">Дизайнеры</a> |
<a href="?do=knowMasters">Мастера</a> |
<a href="?do=knowSales">Продавцы</a> |
<b>Кредиторы</b>';
if ($count != 0)
{
$n = new navigator($count, 10, '?do=knowLenders&');
$res = mysql_query("SELECT id, rating_plus, rating_minus FROM users WHERE know = '5' ORDER BY rating_plus - rating_minus DESC, id DESC {$n->limit}");
$cols = 0;
while($q = mysql_fetch_assoc($res))
{
++$cols;
$num = ($n->start + $cols);
echo $div_razdel . $num . '. ' . us($q['id']) . ' (Кредитор)' . $div_end . '<b>Авторитет:</b> ' . ($q['rating_plus'] - $q['rating_minus']) . '<br/>';
}
echo $n->navi();
} else {
echo '<br/>Кредиторов нет.';
}
break;
}
include 'system/foot.php';
?>