コード例 #1
0
/**
 * Creates a zip file of the album
 *
 * @param string $album album folder
 */
function createAlbumZip($album)
{
    global $_zp_zip_list;
    if (!checkAlbumPassword($album, $hint)) {
        pageError();
        exit;
    }
    $album = UTF8ToFilesystem($album);
    $rp = realpath(getAlbumFolder() . $album) . '/';
    $p = $album . '/';
    include_once 'archive.php';
    $dest = realpath(getAlbumFolder()) . '/' . urlencode($album) . ".zip";
    $persist = getOption('persistent_archive');
    if (!$persist || !file_exists($dest)) {
        if (file_exists($dest)) {
            unlink($dest);
        }
        $z = new zip_file($dest);
        $z->set_options(array('basedir' => $rp, 'inmemory' => 0, 'recurse' => 0, 'storepaths' => 1));
        if ($dh = opendir($rp)) {
            $_zp_zip_list[] = '*.*';
            while (($file = readdir($dh)) !== false) {
                if ($file != '.' && $file != '..') {
                    if (is_dir($rp . $file)) {
                        $base_a = explode("/", $album);
                        unset($base_a[count($base_a) - 1]);
                        $base = implode('/', $base_a);
                        zipAddSubalbum($rp, $base, $file, $z);
                    }
                }
            }
            closedir($dh);
        }
        $z->add_files($_zp_zip_list);
        $z->create_archive();
    }
    header('Content-Type: application/zip');
    header('Content-Disposition: attachment; filename="' . urlencode($album) . '.zip"');
    header("Content-Length: " . filesize($dest));
    printLargeFileContents($dest);
    if (!$persist) {
        unlink($dest);
    }
}
コード例 #2
0
ファイル: album-zip.php プロジェクト: hatone/zenphoto-1.4.1.4
/**
 * Creates a zip file of the album
 *
 * @param string $albumname album folder
 */
function createAlbumZip($albumname)
{
    global $_zp_zip_list, $zip_gallery;
    $zip_gallery = new Gallery();
    $album = new Album($zip_gallery, $albumname);
    if (!$album->isMyItem(LIST_RIGHTS) && !checkAlbumPassword($albumname)) {
        pageError(403, gettext("Forbidden"));
        exit;
    }
    if (!$album->exists) {
        pageError(404, gettext('Album not found'));
        exit;
    }
    $persist = $zip_gallery->getPersistentArchive();
    $dest = $album->localpath . '.zip';
    if (!$persist || !file_exists($dest)) {
        include_once 'archive.php';
        $curdir = getcwd();
        chdir($album->localpath);
        $_zp_zip_list = array();
        $z = new zip_file($dest);
        $z->set_options(array('basedir' => realpath($album->localpath . '/'), 'inmemory' => 0, 'recurse' => 0, 'storepaths' => 1));
        zipAddAlbum($album, strlen($albumname), $z);
        $z->add_files($_zp_zip_list);
        $z->create_archive();
        unset($_zp_zip_list);
        chdir($curdir);
    }
    header('Content-Type: application/zip');
    header('Content-Disposition: attachment; filename="' . pathurlencode($albumname) . '.zip"');
    header("Content-Length: " . filesize($dest));
    printLargeFileContents($dest);
    if (!$persist) {
        unlink($dest);
    }
    unset($zip_gallery);
    unset($album);
    unset($persist);
    unset($dest);
}
コード例 #3
0
                    // have to record the fact
                }
                break;
            case 'download_log':
                include_once SERVERPATH . '/' . ZENFOLDER . '/archive.php';
                $subtab = sanitize($_GET['tab'], 3);
                $dest = SERVERPATH . '/' . DATA_FOLDER . '/' . $subtab . ".zip";
                $rp = dirname($file);
                $z = new zip_file($dest);
                $z->set_options(array('basedir' => $rp, 'inmemory' => 0, 'recurse' => 0, 'storepaths' => 1));
                $z->add_files(array(basename($file)));
                $z->create_archive();
                header('Content-Type: application/zip');
                header('Content-Disposition: attachment; filename="' . $subtab . '.zip"');
                header("Content-Length: " . filesize($dest));
                printLargeFileContents($dest);
                unlink($dest);
                break;
        }
    }
}
// Print our header
$filelist = safe_glob(SERVERPATH . "/" . DATA_FOLDER . '/*.txt');
if (count($filelist) > 0) {
    $subtabs = array();
    if (isset($_GET['tab'])) {
        $default = sanitize($_GET['tab'], 3);
    } else {
        $default = NULL;
    }
    foreach ($filelist as $logfile) {