<?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'] = 'Топ 20';
include_once '../sys/inc/thead.php';
err();
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('Топ 20');
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 active">Топ 20</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="stats.php">Статистика</a>
        </li>
    </ul>
</div>
<?php
$q = mysql_query("SELECT * FROM `loads_list` ORDER BY `loads` DESC LIMIT 20;");

if (mysql_num_rows($q) == 0) {
    $doc->NoResult();
}

while ($post = mysql_fetch_assoc($q)) {
    $i = passgen();
    $l = $post['path'];
    $l = preg_replace("#\./|/\.#", NULL, $l);
    $l = preg_replace("#(/){1,}#", "/", $l);
    $l = preg_replace("#(^(/){1,})|((/){1,}$)#", "", $l);

    $dir_loads = H . 'sys/loads/files/' . $l;
    $dirlist[$i] = $post['name'];
    if (function_exists('iconv')) {
        $dirlist[$i] = iconv('utf-8', 'windows-1251', $dirlist[$i]);
    }
    $ras = strtolower(preg_replace('#^.*\.#i', NULL, $dirlist[$i]));
    $name = preg_replace('#\.[^\.]*$#i', NULL, $dirlist[$i]);

    if (is_file($dir_loads . '/' . $dirlist[$i] . '.name')) {
        $name2 = trim(esc(file_get_contents($dir_loads . '/' . $dirlist[$i] . '.name')));
    } elseif (function_exists('iconv')) {
        $name2 = iconv('windows-1251', 'utf-8', $name);
    } else {
        $name2 = $name;
    }
    $name2 = toOutput($name2);
    $size = $post['size'];

    echo "<table class='list-group-item-null'><tr><td class='icon14'>";
    include H . 'loads/inc/icon48.php';
    echo "</td><td class='null'>";
    if ($set['echo_rassh'] == 1) {
        $ras2 = ".$ras";
    } else {
        $ras2 = NULL;
    }
    echo "<a href='/loads/?d=" . urlencode("$l") . "&amp;scr=1&amp;f=" . urlencode("$dirlist[$i]") . "'>$name2$ras2</a>\n";
    echo "<br />\n";
    include H . 'loads/inc/opis.php';
    echo "</td></tr></table>\n";
    echo "<div class='hr'></div>";
}

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

