View file loads/inc/unzip.php

File size: 1.96Kb
<?php

if (isset($_GET['unzip'])) {
    include_once H . 'sys/classes/pclzip.class.php';
    $zip = new PclZip($dir_loads . '/' . $file);

    switch ($_GET['unzip']) {
        case 'name':$path_unzip = $dir_loads . '/' . $name;
            break;
        case 'name2':$path_unzip = $dir_loads . '/' . $name;
            $dir_n = $name2;
            break;
        default:$path_unzip = $dir_loads;
            break;
    }

    $zip->extract(PCLZIP_OPT_PATH, $path_unzip, PCLZIP_OPT_SET_CHMOD, 0777, PCLZIP_OPT_BY_PREG, "#^[^\.]+#ui");
    msg('Архив успешно распакован');

    if (isset($dir_n)) {
        if ($f = @fopen($path_unzip . '/.dirname', 'w')) {
            @fwrite($f, $dir_n);
            fclose($f);
            @chmod($path_unzip . '/.dirname', 0777);
        } else {
            $err = "Невозможно задать название папки";
        }
    }
    admin_log('Загруз-центр', 'Добавление файлов', "Распакован архив '$l/$file' в папку '" . dir_name($path_unzip) . "'");
}

if (isset($_GET['select_unzip'])) {
    echo "<div class=\"list-group-item\">";
    echo "<a href='?" . url("d=$l&amp;f=$file") . "&amp;unzip=this'>" . lang('Распаковать в текущую папку') . "</a><br />\n";
    echo "<a href='?" . url("d=$l&amp;f=$file") . "&amp;unzip=name'>" . lang('Распаковать в') . " \"$name/\"</a><br />\n";
    if ($name != $name2) {
        echo "<a href='?" . url("d=$l&amp;f=$file") . "&amp;unzip=name2'>" . lang('Распаковать в') . " \"$name2/\"</a><br />\n";
    }
    echo "<a href='?" . url("d=$l&amp;f=$file") . "&amp;$passgen'>" . lang('Отмена') . "</a><br />\n";
    echo "</div>\n";
} else {
    echo "<div class=\"list-group-item\">";
    echo "<a href='?" . url("d=$l&amp;f=$file") . "&amp;select_unzip'><i class='fa fa-file-archive-o fa-fw'></i> " . lang('Распаковать архив') . "</a><br />\n";
    echo "</div>\n";
}