<?php

$q = $db->super_query("SELECT COUNT(*) as count FROM loads_list WHERE time > '" . (time() - 86400) . "'");
$k_new = $q['count'];
$k_page = k_page($k_new, $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() - 86400) . "' ORDER BY time DESC LIMIT 3");

if ($k_new != 0) {
    echo "<div class='list-group-item-null list-group-item-info'><span style='float: right'><i class='fa fa-file-text fa-lg'></i></span>" . lang('Новые файлы') . "</div>";
    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 = htmlspecialchars($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 ($ras == 'zip' || $ras == 'rar') {
            $r = "<i class='fa fa-file-archive-o fa-fw'></i>";
        } elseif ($ras == 'png' || $ras == 'jpg' || $ras == 'jpeg' || $ras == 'gif') {
            $r = "<i class='fa fa-file-image-o fa-fw'></i>";
        } elseif ($ras == 'mp3') {
            $r = "<i class='fa fa-file-audio-o fa-fw'></i>";
        } elseif ($ras == 'txt') {
            $r = "<i class='fa fa-file-text-o fa-fw'></i>";
        } elseif ($ras == 'mp4' || $ras == 'avi' || $ras == '3gp') {
            $r = "<i class='fa fa-file-video-o fa-fw'></i>";
        } elseif ($ras == 'php') {
            $r = "<i class='fa fa-file-code-o fa-fw'></i>";
        } else {
            $r = "<i class='fa fa-file-o fa-fw'></i>";
        }

        echo "<a href='/loads/?d=" . urlencode("$l") . "&amp;scr=1&amp;f=" . urlencode("$dirlist[$i]") . "'>$r " . utf8_substr($name2, 30) . ".$ras</a> <small style='color: green'>" . size_file($size) . "</small>\n";
        echo "<br />\n";
        echo '<small style="color: grey">Загружен ' . date::times(filectime($dir_loads . '/' . $dirlist[$i])) . "</small>\n";
        echo "</td></tr></table>\n";
        echo "<div class='hr'></div>";
    }
}
