<?php
/* DCMS Special
 * Дата последнего редактирования 08.10.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';

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('Новинки');
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 active">Новинки</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="top.php">Топ 20</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="stats.php">Статистика</a>
        </li>
    </ul>
</div>
<?php
$q = $db->super_query("SELECT COUNT(*) as count FROM loads_list WHERE time > '" . ($time - 60 * 60 * 24) . "'");
$k_post = $q['count'];
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];

$q = $db->query("SELECT * FROM `loads_list` WHERE `time` > '" . ($time - 60 * 60 * 24) . "' ORDER BY `time` DESC LIMIT $start, $set[p_str];");
if ($db->num_rows($q) == 0) {
    $doc->NoResult();
}

while ($post = $db->get_row($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>";
}

if ($k_page > 1) {
    str('?', $k_page, $page);
} // Вывод страниц

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

