<?php

include '../system/sys.php';
include '../system/funcs.php';

if (!isset ($us)) {
        header ('location: /');    
        exit;
}

H ('Статистика', 'Статистика');

echo '<div class="lst">';
echo '<b>Изменения в вашем рейтинге (форум):</b><br/>';
echo '<b>Итого за сутки: </b><br/>';
echo 'Всего плюсов в форуме: <b>' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_vote` WHERE (`us`='" . $us['id'] . "') AND (`vot`='za') AND (`t`>'" . (time () - 86400) . "')") . '</b><br/>';
echo 'Всего минусов в форуме: <b>' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_vote` WHERE (`us`='" . $us['id'] . "') AND (`vot`='protiv') AND (`t`>'" . (time () - 86400) . "')") . '</b><br/>';
echo 'Всего заработано в форуме: <b>' . ( ( DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_vote` WHERE (`us`='" . $us['id'] . "') AND (`vot`='za')") * 0.01 ) - ( DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_vote` WHERE (`us`='" . $us['id'] . "') AND (`vot`='protiv')") * 0.01 ) ) . '</b> рейтинга';
echo '</div>';
echo '<div class="lst"><b>Изменение  рейтинга вами (форум):</b></div>';
echo '<div class="lst">';
echo '<b>Изменения в рейтинге за сегодня:</b><br/>';
echo '<table cols="3">';
echo '<tr>';
echo '<td>Форум<br/><b>' . ( ( DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_vote` WHERE (`us`='" . $us['id'] . "') AND (`vot`='za') AND (`t`>'" . (time () - 86400) . "')") * 0.01 ) - ( DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_vote` WHERE (`us`='" . $us['id'] . "') AND (`vot`='protiv') AND (`t`>'" . (time () - 86400) . "')") * 0.01 ) ) . '</b></td>';
echo '<td>Файлы:<br/><b>' . ( ( DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `zc_vote` WHERE (`us`='" . $us['id'] . "') AND (`vot`='za') AND (`t`>'" . (time () - 86400) . "')") * 0.1 ) - ( DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `zc_vote` WHERE (`us`='" . $us['id'] . "') AND (`vot`='protiv') AND (`t`>'" . (time () - 86400) . "')") * 0.1 ) ) . '</b></td>';
echo '</tr>';
echo '</table>';
echo 'Итого: <b>' . ( ( ( DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_vote` WHERE (`us`='" . $us['id'] . "') AND (`vot`='za') AND (`t`>'" . (time () - 86400) . "')") * 0.01 ) - ( DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_vote` WHERE (`us`='" . $us['id'] . "') AND (`vot`='protiv') AND (`t`>'" . (time () - 86400) . "')") * 0.01 ) ) + ( ( DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `zc_vote` WHERE (`us`='" . $us['id'] . "') AND (`vot`='za') AND (`t`>'" . (time () - 86400) . "')") * 0.1 ) - ( DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `zc_vote` WHERE (`us`='" . $us['id'] . "') AND (`vot`='protiv') AND (`t`>'" . (time () - 86400) . "')") * 0.1 ) ) ) . '</b>';
 echo '</div>';
echo '<div class="lst"><b>Другое:</b><br/>';
echo 'Постов в форуме: <b>' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_p` WHERE (`us`='" . $us['id'] . "') AND (`del`='0')") . '</b> (' . round ( (100 / (DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_p` WHERE (`del`='0')") / DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_p` WHERE (`us`='" . $us['id'] . "') AND (`del`='0')") ) ), 2) . '%)<br/>';
echo 'Постов в форуме за сегодня: <b>' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_p` WHERE (`us`='" . $us['id'] . "') AND (`time`>'" . (time () - 86400) . "') AND (`del`='0')") . '</b> (' . round ( (100 / (DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_p` WHERE (`time`>'" . (time () - 86400) . "') AND (`del`='0')") / DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_p` WHERE (`us`='" . $us['id'] . "') AND (`time`>'" . (time () - 86400) . "') AND  (`del`='0')") ) ), 2) . '%)<br/>';
echo 'Файлов в загруз центре: <b>' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `zc_f` WHERE (`us`='" . $us['id'] . "')") . '</b> (' . round ( (100 / (DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `zc_f` WHERE (`dop`='da')") / DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `zc_f` WHERE (`us`='" . $us['id'] . "') AND (`dop`='da')") ) ), 2) . '%)<br/>';
echo 'Комментариев: <b>' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `news_komm` WHERE (`us`='" . $us['id'] . "')") . '</b> (' . round ( (100 / (DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `news_komm`") / DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `news_komm` WHERE (`us`='" . $us['id'] . "')") ) ), 2) . '%)<br/>';
echo 'Отправлено личных сообщений за сегодня: <b>' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `msg` WHERE (`kem`='" . $us['id'] . "') AND (`time`>'" . (time () - 86400) . "')") . '</b>';
echo '</div>';

F ();
