Example #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);
    }
}
Example #2
0
/**
 * 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);
}
Example #3
0
$image_path = $_zp_current_image->localpath;
$suffix = strtolower(substr(strrchr($image_path, "."), 1));
$cache_file = $_zp_current_album->name . "/" . substr($_zp_current_image->filename, 0, -strlen($suffix) - 1) . '_FULL.' . $suffix;
switch ($suffix) {
    case 'bmp':
        $suffix = 'wbmp';
        break;
    case 'jpg':
        $suffix = 'jpeg';
        break;
    case 'png':
    case 'gif':
    case 'jpeg':
        break;
    default:
        pageError(405, gettext("Method Not Allowed"));
        exit;
}
if (getOption('cache_full_image')) {
    $cache_path = SERVERCACHE . '/' . UTF8ToFilesystem($cache_file);
} else {
    $cache_path = NULL;
}
if (!getOption('watermark_image')) {
    // no processing needed
    if (getOption('album_folder_class') != 'external' && !getOption('protect_full_image') == 'Download') {
        // local album system, return the image directly
        header('Content-Type: image/' . $suffix);
        header("Location: " . getAlbumFolder(FULLWEBPATH) . pathurlencode($_zp_current_album->name) . "/" . rawurlencode($_zp_current_image->filename));
        exit;
    } else {
Example #4
0
 */
// force UTF-8 Ø
if (!defined('OFFSET_PATH')) {
    define('OFFSET_PATH', 2);
}
// don't need any admin tabs
require_once dirname(__FILE__) . "/functions.php";
require_once dirname(__FILE__) . "/functions-image.php";
if (isset($_GET['dsp'])) {
    $disposal = sanitize($_GET['dsp']);
} else {
    $disposal = getOption('protect_full_image');
}
if ($disposal == 'No access') {
    // illegal use of the script!
    pageError(403, gettext("Forbidden"));
    exit;
}
// Check for minimum parameters.
if (!isset($_GET['a']) || !isset($_GET['i'])) {
    header("HTTP/1.0 404 Not Found");
    header("Status: 404 Not Found");
    imageError(gettext("Too few arguments! Image not found."), 'err-imagenotfound.png');
}
list($ralbum, $rimage) = rewrite_get_album_image('a', 'i');
$ralbum = internalToFilesystem($ralbum);
$rimage = internalToFilesystem($rimage);
$album = str_replace('..', '', sanitize_path($ralbum));
$image = str_replace(array('/', "\\"), '', sanitize_path($rimage));
$album8 = filesystemToInternal($album);
$image8 = filesystemToInternal($image);
		pageError('An Error Occured: ' . $row);

this may look bizarre, but what's happening is that $row is getting the fetch_row value, and if
that is false, gets the value of mysql_error()
now, fetch_row should always return an array, so if it didn't, it either returned false or a mysql error
the string from the error message makes the value not false so we know there was an error only if
$row is not an array and still evaluates to true
this messy syntax is a nice way of displaying clear error messages that the user doesn't have to search
for admist the other html and javascript (that's the worst, when the error is hidden in javascript code and
so it doesn't appear on the screen!  you have been warned of that!!!)
*/
// same as above with no formatting...
function db_fetch_plain($query_id, $nofreeresult = false)
{
Example #6
0
function reload()
{
    header("Location: ./");
    pageError("Redirect...");
}