<?php
/* DCMS Special
 * Дата последнего редактирования 25.09.2016
 * Модифицировал densnet
 */

foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'user') as $inc) {
    require_once "../sys/inc/$inc.php";
}

$set['title'] = lang('Статистика файлов'); // заголовок страницы
include_once H . 'sys/inc/thead.php';

aut();

#Навигация
echo "<div class='list-group-item-null list-group-item-grey'><small>";
echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
echo "<a href='/loads/'>" . lang('Загрузки') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
echo lang('Статистика');
echo "</small></div><br />";
?>
<div class='list-group-item-null list-group-item-grey'>
    <ul class="nav nav-pills">
        <li class="nav-item">
            <a class="nav-link" href="new.php">Новинки</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="top.php">Топ 20</a>
        </li>
        <li class="nav-item">
            <a class="nav-link active">Статистика</a>
        </li>
    </ul>
</div>
<?php
$all_size = mysql_fetch_row(mysql_query('SELECT SUM(`size`) FROM `loads_list` WHERE `size` > 0'));

if ($all_size[0] < 1048576) {
    $all_size[0] = round($all_size[0] / 1024, 2) . 'Kb';
} else {
    $all_size[0] = round($all_size[0] / 1024 / 1024, 2) . 'Mb';
}

$all_size_dop = mysql_fetch_row(mysql_query('SELECT SUM(`size`) FROM `loads_dop` WHERE `size` > 0'));

if ($all_size_dop[0] < 1048576) {
    $all_size_dop[0] = round($all_size_dop[0] / 1024, 2) . 'Kb';
} else {
    $all_size_dop[0] = round($all_size_dop[0] / 1024 / 1024, 2) . 'Mb';
}

$all_files = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `loads_list` WHERE `size` > 0'));
$all_files_dop = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `loads_dop` WHERE `size` > 0'));
$all_loads = mysql_fetch_row(mysql_query('SELECT SUM(`loads`) FROM `loads_list` WHERE `size` > 0'));

$och_fal = $all_files[0] + $all_files_dop[0];

echo "<div class='list-group-item-null'>";
echo 'Всего файлов: ' . $och_fal . '<br/>';
$obs = $all_size[0] + $all_size_dop[0];
echo 'Общий размер файлов: ' . $obs . ' MB<br/>';

echo '</div>';

include_once H . 'sys/inc/tfoot.php';
