<?php

$ras1 = strtoupper(preg_replace('#^.*\.#i', NULL, $file));
$name = preg_replace('#\.[^\.]*$#i', NULL, $file); // имя файла без расширения
if (!isset($set['downloads_select']) || $set['downloads_select'] == '0') { {
        echo "<div class='list-group-item-null'>";

        echo "<center><a href=\"/loads/down/" . url2("$l/$file") . "\" class='btn btn-info'><i class='fa fa-save fa-fw'></i> " . lang('Скачать') . "</a>";
        if (!isset($set['prosm_select']) || $set['prosm_select'] == '0') {
            if (is_file($dir_loads . '/' . $name . '.mp3')) {
                echo ' <span class="btn btn-info btn-sm">'
                . '<object id="audioplayer56" type="application/x-shockwave-flash" data="/sys/uppod-audio.swf" width="20" height="20">'
                . '<param name="bgcolor" value="#000000" /><param name="allowScriptAccess" value="always" />'
                . '<param name="movie" value="/sys/uppod-audio.swf" />'
                . '<param name="flashvars" value="comment=dfgh&amp;st=/loads/st/audio145-1103.txt&amp;file=/loads/down/' . $l . '/' . $file . '" />'
                . '</object></span>';
            }
        }
        echo "<br />\n";
        if (is_file($dir_loads . '/' . $name . '.99.99.jad')) {
            echo " <a href=\"/loads/down/$l/$name.99.99.jad\" title='Скачать JAD к $file'><b>JAD</b></a> (" . size_file(filesize("$dir_loads/$file")) . ") <b>(" . k_loads($file, $size) . ")</b>\n";
            if (access('loads_file_delete')) {
                echo "<a href=\"?" . url("d=$l&amp;act=delete&amp;f=$file&amp;page=$_SESSION[page]") . "\"><small><i class='fa fa-trash-o'></i></small></a><br />\n";
            }
        } else {
            echo "<small style='color: grey;'>" . size_file(filesize("$dir_loads/$file")) . " <b>(" . k_loads($file, $size) . ")</b></small>";
            if (access('loads_file_edit')) {
                echo " <a href=\"?" . url("d=$l&amp;act=osnov&amp;f=$file&amp;page=$_SESSION[page]") . "\" class='hint--right' data-hint='" . lang('Редактировать файл') . "'><small><i class='fa fa-edit'></i></small></a> \n";
            }
            if (access('loads_file_delete')) {
                echo " <a href=\"?" . url("d=$l&amp;act=delete&amp;f=$file&amp;page=$_SESSION[page]") . "\" class='hint--right' data-hint='" . lang('Удалить файл') . "'><small><i class='fa fa-trash-o'></i></small></a><br />\n";
            }
        }

        echo "</center></div>";
    }
    $dir_l = '../sys/loads/files_dop/' . $l . '/' . $file;

    function recount_loads($dir_l) {
        global $added;
        global $set;
        $opendir = @opendir($dir_l);
        while ($readdir = @readdir($opendir)) {
            if (!preg_match("#^\.|\.99.99.name|\.name$|\.db$|\.dat$|\.99.99.jad$#i", $readdir) && !preg_match("#\.1.JPG$|\.1.PNG$|\.1.GIF$|\.2.JPG$|\.2.PNG$|\.2.GIF$|\.3.JPG$|\.3.PNG$|\.3.GIF$#", $readdir)) {
                if (is_dir($dir_l . '/' . $readdir)) {
                    recount_loads($dir_l . '/' . $readdir);
                } elseif (is_file($dir_l . '/' . $readdir)) {
                    $nam = (function_exists('iconv')) ? iconv('windows-1251', 'utf-8', $readdir) : $readdir;
                    $namess = preg_replace('#\.[^\.]*$#i', NULL, $nam); // имя файла без расширения
                    $size = @filesize($dir . '/' . $readdir);
                    $file_time = @filectime($dir . '/' . $readdir);
                    $ras1 = strtoupper(preg_replace('#^.*\.#i', NULL, $nam));
                    $l = preg_replace("#\.{2,}#", NULL, esc(urldecode($_GET['d'])));
                    $l = preg_replace("#\./|/\.#", NULL, $l);
                    $l = preg_replace("#(/){1,}#", "/", $l);
                    $l = preg_replace("#(^(/){1,})|((/){1,}$)#", "", $l);
                    $file = preg_replace("#.*/#", NULL, urldecode($_GET['f'])); // получение имени файла
                    $dir_loads = "../sys/loads/files/$l";
                    $tim = mysql_result(mysql_query("SELECT `loads` FROM `loads_dop` WHERE (`name` = '$nam' AND `path` = '/$l/$file/')"), 0);

                    if (!is_file($dir_l . '/' . $namess . '.jar')) {
                        
                    } elseif (!is_file($dir_l . '/' . $namess . '.99.99.jad')) {
                        include_once H . 'sys/classes/pclzip.class.php';
                        $zip = new PclZip($dir_l . '/' . $nam);
                        $content = $zip->extract(PCLZIP_OPT_BY_NAME, "META-INF/MANIFEST.MF", PCLZIP_OPT_EXTRACT_AS_STRING);
                        $jad = preg_replace("#(MIDlet-Jar-URL:( )*[^(\n|\r)]*)#i", NULL, $content[0]['content']);
                        $jad = preg_replace("#(MIDlet-Jar-Size:( )*[^(\n|\r)]*)(\n|\r)#i", NULL, $jad);
                        $jad = trim($jad);
                        $jad .= "\r\nMIDlet-Jar-Size: " . filesize($dir_l . '/' . $nam) . "";
                        $jad .= "\r\nMIDlet-Jar-URL: $namess.jar";
                        $jad = br($jad, "\r\n");
                        file_put_contents($dir_l . '/' . $namess . '.99.99.jad', $jad);
                        @chmod($dir_l . '/' . $nameess . '.99.99.jad', 0777);
                    }
                    echo "<div class=\"list-group-item-null list-group-item-info\">";

                    if (is_file($dir_loads . '/' . $nam . '.99.99.name')) {
                        echo toOutput(file_get_contents($dir_loads . '/' . $nam . '.99.99.name')) . "\n";
                    } else {
                        echo toOutput(file_get_contents($dir_l . '/' . $nam . '.99.99.name')) . "\n";
                    }
                    if (!isset($set['prosm_select']) || $set['prosm_select'] == '1') {
                        if (is_file($dir_l . '/' . $namess . '.mp3')) {
                            echo '<object id="audioplayer56" type="application/x-shockwave-flash" data="/sys/uppod-audio.swf" width="20" height="20"><param name="bgcolor" value="#000000" /><param name="allowScriptAccess" value="always" /><param name="movie" value="/sys/uppod-audio.swf" /><param name="flashvars" value="comment=dfgh&amp;st=/loads/st/audio145-1103.txt&amp;file=/loads/dom/' . $l . '/' . $file . '/' . $nam . '" /></object>';
                        }
                    }
                    /*
                    if (access('loads_file_edit')) {
                        echo "<a href=\"?" . url("d=$l&amp;act=edit&amp;fil=$nam&amp;f=$file&amp;page=$_SESSION[page]") . "\" title='Редактировать $nam' style='float: right'><i class='fa fa-edit'></i></a>\n";
                    }
                     * 
                     */
                    echo file_new($dir_l . '/' . $nam) . "<br />";

                    if ($set['info_select'] == '1') {
                        include 'files/ff_video.php';
                    }

                    echo "<a href=\"/loads/dom/$l/$file/$nam\" title='Скачать $nam'><i class='fa fa-save fa-fw'></i> $nam</a><b></b>\n";
                    if (is_file($dir_l . '/' . $namess . '.99.99.jad')) {
                        echo " <a href=\"/loads/dom/$l/$file/$namess.99.99.jad\" title='Скачать JAD к $nam'><b>JAD</b></a> (" . size_file(filesize("$dir_l/$nam")) . ") <b>($tim)</b>\n";
                        if (access('loads_file_delete')) {
                            echo " <a href=\"?" . url("d=$l&amp;act=deletet&amp;fil=$nam&amp;f=$file&amp;page=$_SESSION[page]") . "\" title='Удалить $nam' style='float: right'><i class='fa fa-trash-o'></i></a><br />\n";
                        }
                    } else {
                        echo "<small>(" . size_file(filesize("$dir_l/$nam")) . ") <b>($tim)</b></small>";
                        if (access('loads_file_delete')) {
                            echo " <a href=\"?" . url("d=$l&amp;act=deletet&amp;fil=$nam&amp;f=$file&amp;page=$_SESSION[page]") . "\" title='Удалить $nam' style='float: right'><i class='fa fa-trash-o'></i></a><br />\n";
                        }
                    }

                    echo "</div>";
                }
            }
        }
        @closedir($opendir);
    }

    recount_loads(urldecode($dir_l));
} elseif (isset($user) && $set['downloads_select'] == '1') {
    
} elseif ($user['activity'] >= 10 && $set['downloads_select'] == '2') {
    
} else {
    if ($set['downloads_select'] == '2') {
        echo 'Скачивание и прослушывание доступно только пользователям, набравшим более 10 активности<br />';
    }
    if ($set['downloads_select'] == '1') {
        echo 'Для скачивания и прослушывания файлов необходимо авторизоваться или зарегистрироваться<br />';
    }
}
$file = preg_replace("#.*/#", NULL, urldecode($_GET['f'])); // получение имени файла
