forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Miscellaneous => Topic started by: h3nn3s on May 03, 2007, 06:06:17 pm

Title: Download an album by zip
Post by: h3nn3s on May 03, 2007, 06:06:17 pm
Hello guys,

as requested in this thread (http://forum.coppermine-gallery.net/index.php?topic=41579.0) i´ll post my modification here.

Remember: Propably full of bugs and non-professional code. Feel free to improve it :)

What does it do?
It simply adds a button/text to your thumbnails.php to download a complete album as a zip archive without the normal_ and thumb_ pictures.

What to do?
1. Download the attached file
2. unzip and Edit line 13 in zip.php (`cpg143_pictures`)
2. upload the zip.php to your coppermine root
3. modify the theme.php from your current theme as the following

find:
Code: [Select]
    if ($sort_options) {
        $param = array('{ALBUM_NAME}' => $album_name,
            '{AID}' => $aid,
            '{PAGE}' => $page,
            '{NAME}' => $lang_thumb_view['name'],
            '{TITLE}' => $lang_thumb_view['title'],
            '{DATE}' => $lang_thumb_view['date'],
            '{SORT_TA}' => $lang_thumb_view['sort_ta'],
            '{SORT_TD}' => $lang_thumb_view['sort_td'],
            '{SORT_NA}' => $lang_thumb_view['sort_na'],
            '{SORT_ND}' => $lang_thumb_view['sort_nd'],
            '{SORT_DA}' => $lang_thumb_view['sort_da'],
            '{SORT_DD}' => $lang_thumb_view['sort_dd'],
            '{POSITION}' => $lang_thumb_view['position'],
            '{SORT_PA}' => $lang_thumb_view['sort_pa'],
            '{SORT_PD}' => $lang_thumb_view['sort_pd'],
            );

replace with:
Code: [Select]
    if ($sort_options) {
        $param = array('{ALBUM_NAME}' => $album_name,
            '{AID}' => $aid,
            '{PAGE}' => $page,
            '{NAME}' => $lang_thumb_view['name'],
            '{TITLE}' => $lang_thumb_view['title'],
            '{DATE}' => $lang_thumb_view['date'],
            '{SORT_TA}' => $lang_thumb_view['sort_ta'],
            '{SORT_TD}' => $lang_thumb_view['sort_td'],
            '{SORT_NA}' => $lang_thumb_view['sort_na'],
            '{SORT_ND}' => $lang_thumb_view['sort_nd'],
            '{SORT_DA}' => $lang_thumb_view['sort_da'],
            '{SORT_DD}' => $lang_thumb_view['sort_dd'],
            '{POSITION}' => $lang_thumb_view['position'],
            '{SORT_PA}' => $lang_thumb_view['sort_pa'],
            '{SORT_PD}' => $lang_thumb_view['sort_pd'],
            );
     // MOD - begin
$param['{ALBUM_NAME}'] .= '<a href="zip.php?aid=' . $aid . '" title="Download album as *zip archive">[ Download Album ]</a>';
// MOD - end

Thats it. I´ll hope you have fun with it :)
Title: Re: Download an album by zip
Post by: Nibbler on May 03, 2007, 06:25:55 pm
Where does pclzip.lib.php come from?

Note: use this mod at your own risk...
Title: ..
Post by: Beme on May 06, 2007, 09:03:51 pm
Hello,

thank you h3nn3s for posting your mod. But it doesn't fit to version 1.4.10. I think you use an minor version? The layout of the theme.php in the latest version seems to be completely different. In theme.php I don't have access to the variable "$aid" either.

Benjamin
Title: Re: Download an album by zip
Post by: Joachim Müller on May 07, 2007, 08:39:59 am
@Beme: your comment doesn't apply. As with all theme modifications, you'll need to copy the missing code from the sample theme into your custom theme if it doesn't exist there.



@all:

If the above mentioned section doesn't exist in themes/your_theme/theme.php, then copy
Code: [Select]
function theme_display_thumbnails(&$thumb_list, $nbThumb, $album_name, $aid, $cat, $page, $total_pages, $sort_options, $display_tabs, $mode = 'thumb')
{
    global $CONFIG;
    global $template_thumb_view_title_row,$template_fav_thumb_view_title_row, $lang_thumb_view, $template_tab_display, $template_thumbnail_view, $lang_album_list;

    static $header = '';
    static $thumb_cell = '';
    static $empty_cell = '';
    static $row_separator = '';
    static $footer = '';
    static $tabs = '';
    static $spacer = '';

    if ($header == '') {
        $thumb_cell = template_extract_block($template_thumbnail_view, 'thumb_cell');
        $tabs = template_extract_block($template_thumbnail_view, 'tabs');
        $header = template_extract_block($template_thumbnail_view, 'header');
        $empty_cell = template_extract_block($template_thumbnail_view, 'empty_cell');
        $row_separator = template_extract_block($template_thumbnail_view, 'row_separator');
        $footer = template_extract_block($template_thumbnail_view, 'footer');
        $spacer = template_extract_block($template_thumbnail_view, 'spacer');
    }

    $cat_link = is_numeric($aid) ? '' : '&amp;cat=' . $cat;
    $uid_link = (isset($_GET['uid']) && is_numeric($_GET['uid'])) ? '&amp;uid=' . $_GET['uid'] : '';

    $theme_thumb_tab_tmpl = $template_tab_display;

    if ($mode == 'thumb') {
        $theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $aid == 'lastalb' ? $lang_album_list['album_on_page'] : $lang_thumb_view['pic_on_page']));
        $theme_thumb_tab_tmpl['inactive_tab'] = strtr($theme_thumb_tab_tmpl['inactive_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . $uid_link . '&amp;page=%d'));
        $theme_thumb_tab_tmpl['inactive_next_tab'] = strtr($theme_thumb_tab_tmpl['inactive_next_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . $uid_link . '&amp;page=%d'));
        $theme_thumb_tab_tmpl['inactive_prev_tab'] = strtr($theme_thumb_tab_tmpl['inactive_prev_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . $uid_link . '&amp;page=%d'));
    } else {
        $theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $lang_thumb_view['user_on_page']));
        $theme_thumb_tab_tmpl['inactive_tab'] = strtr($theme_thumb_tab_tmpl['inactive_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&amp;page=%d'));
        $theme_thumb_tab_tmpl['inactive_next_tab'] = strtr($theme_thumb_tab_tmpl['inactive_next_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&amp;page=%d'));
        $theme_thumb_tab_tmpl['inactive_prev_tab'] = strtr($theme_thumb_tab_tmpl['inactive_prev_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&amp;page=%d'));
    }

    $thumbcols = $CONFIG['thumbcols'];
    $cell_width = ceil(100 / $CONFIG['thumbcols']) . '%';

    $tabs_html = $display_tabs ? create_tabs($nbThumb, $page, $total_pages, $theme_thumb_tab_tmpl) : '';
    // The sort order options are not available for meta albums
    if ($sort_options) {
        $param = array('{ALBUM_NAME}' => $album_name,
            '{AID}' => $aid,
            '{PAGE}' => $page,
            '{NAME}' => $lang_thumb_view['name'],
            '{TITLE}' => $lang_thumb_view['title'],
            '{DATE}' => $lang_thumb_view['date'],
            '{SORT_TA}' => $lang_thumb_view['sort_ta'],
            '{SORT_TD}' => $lang_thumb_view['sort_td'],
            '{SORT_NA}' => $lang_thumb_view['sort_na'],
            '{SORT_ND}' => $lang_thumb_view['sort_nd'],
            '{SORT_DA}' => $lang_thumb_view['sort_da'],
            '{SORT_DD}' => $lang_thumb_view['sort_dd'],
            '{POSITION}' => $lang_thumb_view['position'],
            '{SORT_PA}' => $lang_thumb_view['sort_pa'],
            '{SORT_PD}' => $lang_thumb_view['sort_pd'],
            );
        $title = template_eval($template_thumb_view_title_row, $param);
    } else if ($aid == 'favpics' && $CONFIG['enable_zipdownload'] == 1) { //Lots of stuff can be added here later
       $param = array('{ALBUM_NAME}' => $album_name,
                             '{DOWNLOAD_ZIP}'=>$lang_thumb_view['download_zip']
                               );
       $title = template_eval($template_fav_thumb_view_title_row, $param);
    }else{
        $title = $album_name;
    }


    if ($mode == 'thumb') {
        starttable('100%', $title, $thumbcols);
    } else {
        starttable('100%');
    }

    echo $header;

    $i = 0;
    foreach($thumb_list as $thumb) {
        $i++;
        if ($mode == 'thumb') {
            if ($aid == 'lastalb') {
                $params = array('{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}' => "thumbnails.php?album={$thumb['aid']}",
                    '{THUMB}' => $thumb['image'],
                    '{CAPTION}' => $thumb['caption'],
                    '{ADMIN_MENU}' => $thumb['admin_menu']
                    );
            } else {
                $params = array('{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}' => "displayimage.php?album=$aid$cat_link&amp;pos={$thumb['pos']}$uid_link",
                    '{THUMB}' => $thumb['image'],
                    '{CAPTION}' => $thumb['caption'],
                    '{ADMIN_MENU}' => $thumb['admin_menu']
                    );
            }
        } else {
            $params = array('{CELL_WIDTH}' => $cell_width,
                '{LINK_TGT}' => "index.php?cat={$thumb['cat']}",
                '{THUMB}' => $thumb['image'],
                '{CAPTION}' => $thumb['caption'],
                '{ADMIN_MENU}' => ''
                );
        }
        echo template_eval($thumb_cell, $params);

        if ((($i % $thumbcols) == 0) && ($i < count($thumb_list))) {
            echo $row_separator;
        }
    }
    for (;($i % $thumbcols); $i++) {
        echo $empty_cell;
    }
    echo $footer;

    if ($display_tabs) {
        $params = array('{THUMB_COLS}' => $thumbcols,
            '{TABS}' => $tabs_html
            );
        echo template_eval($tabs, $params);
    }

    endtable();
    echo $spacer;
}
from themes/sample/theme.php into a new line before
Code: [Select]
?>of themes/your_theme/theme.php, then apply the suggested modification.
Title: Re: Download an album by zip
Post by: alexo on May 07, 2007, 09:17:28 am
Here you can find details regarding pclzip :
http://www.phpconcept.net/pclzip/man/en/index.php?methods-delete
Title: Re: Download an album by zip
Post by: Beme on May 07, 2007, 06:35:24 pm
Thanks to GauGau and alexo for your help!  :)

If there's anybody here, who not wants to display a Downloadlink, but wants to force the clients browser to download the zipped file directly, search in zip.php:

Code: [Select]
echo "Downloadlink: <a href=\"" . $aid . ".zip\">" . $aid . ".zip</a>";
and replace it with:

Code: [Select]
$file = $aid.".zip";
$filename = basename($file);
$size = filesize($file);
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".$filename);
header("Content-Length:".$size);
readfile($file);

Title: Re: Download an album by zip
Post by: h3nn3s on May 07, 2007, 06:47:33 pm
thanks to gaugau for the quick help and to Beme for the automatic download, i`ve added it too :)
Title: Re: Download an album by zip
Post by: subgr on May 21, 2007, 03:47:51 am
Hi guys,
I always wanted to have the functionality to download the whole album and h3nn3s way was a good starting point. Because I had some problems with that I created something else.
I have modified gaugau’s zipdownload.php which is used to download the favourites as zip to work for downloading whole albums and the zip file to have the name of the album.

Instructions:

Code: [Select]
if ($sort_options) {
        $param = array('{ALBUM_NAME}' => $album_name,
            '{AID}' => $aid,
            '{PAGE}' => $page,
            '{NAME}' => $lang_thumb_view['name'],
            '{TITLE}' => $lang_thumb_view['title'],
            '{DATE}' => $lang_thumb_view['date'],
            '{SORT_TA}' => $lang_thumb_view['sort_ta'],
            '{SORT_TD}' => $lang_thumb_view['sort_td'],
            '{SORT_NA}' => $lang_thumb_view['sort_na'],
            '{SORT_ND}' => $lang_thumb_view['sort_nd'],
            '{SORT_DA}' => $lang_thumb_view['sort_da'],
            '{SORT_DD}' => $lang_thumb_view['sort_dd'],
            '{POSITION}' => $lang_thumb_view['position'],
            '{SORT_PA}' => $lang_thumb_view['sort_pa'],
            '{SORT_PD}' => $lang_thumb_view['sort_pd'],
            );
        $title = template_eval($template_thumb_view_title_row, $param);

Code: [Select]
if ($sort_options) {
        $param = array('{ALBUM_NAME}' => $album_name,
            '{AID}' => $aid,
            '{PAGE}' => $page,
            '{NAME}' => $lang_thumb_view['name'],
            '{TITLE}' => $lang_thumb_view['title'],
            '{DATE}' => $lang_thumb_view['date'],
            '{SORT_TA}' => $lang_thumb_view['sort_ta'],
            '{SORT_TD}' => $lang_thumb_view['sort_td'],
            '{SORT_NA}' => $lang_thumb_view['sort_na'],
            '{SORT_ND}' => $lang_thumb_view['sort_nd'],
            '{SORT_DA}' => $lang_thumb_view['sort_da'],
            '{SORT_DD}' => $lang_thumb_view['sort_dd'],
            '{POSITION}' => $lang_thumb_view['position'],
            '{SORT_PA}' => $lang_thumb_view['sort_pa'],
            '{SORT_PD}' => $lang_thumb_view['sort_pd'],
            );
            //mod start
if ($CONFIG['enable_zipdownload'] == 1) { //Lots of stuff can be added here later
$param['{ALBUM_NAME}'].= '&nbsp;&nbsp;<a href="zipalbum.php?album_d='.$aid.'">Download as Zip file'.$ALBUM_SET_ARRAY[0].'</a>';
}
//my mod end
        $title = template_eval($template_thumb_view_title_row, $param);

Title: Re: Download an album by zip
Post by: subgr on May 21, 2007, 04:07:29 am
Oops by mistake I posted before I finished and I can’t edit it.  ::)
The modification at the post above is wrong. This is the right one:

Code: [Select]
//mod start
if ($CONFIG['enable_zipdownload'] == 1) {
$param['{ALBUM_NAME}'].= '&nbsp;&nbsp;<a href="zipalbum.php?album_d='.$aid.'">Download as Zip file</a>';
}
//mod end

The benefits of zipalbum.php are that you don’t have to modify it to work in your installation and creates the zip file with the already included coppermine functions.
There was an issue with spaces at the albums name's, thats why spaces are being replaced by "_".
I hope it is ok with you gaugau that zipalbum.php is based on your code, otherwise I will remove it.
Title: Re: Download an album by zip
Post by: ventom on June 07, 2007, 11:04:20 pm
Hello guys,

as requested in this thread (http://forum.coppermine-gallery.net/index.php?topic=41579.0) i´ll post my modification here.

Remember: Propably full of bugs and non-professional code. Feel free to improve it :)

What does it do?
It simply adds a button/text to your thumbnails.php to download a complete album as a zip archive without the normal_ and thumb_ pictures.

What to do?
1. Download the attached file
2. unzip and Edit line 13 in zip.php (`cpg143_pictures`)
2. upload the zip.php to your coppermine root
3. modify the theme.php from your current theme as the following

find:
Code: [Select]
    if ($sort_options) {
        $param = array('{ALBUM_NAME}' => $album_name,
            '{AID}' => $aid,
            '{PAGE}' => $page,
            '{NAME}' => $lang_thumb_view['name'],
            '{TITLE}' => $lang_thumb_view['title'],
            '{DATE}' => $lang_thumb_view['date'],
            '{SORT_TA}' => $lang_thumb_view['sort_ta'],
            '{SORT_TD}' => $lang_thumb_view['sort_td'],
            '{SORT_NA}' => $lang_thumb_view['sort_na'],
            '{SORT_ND}' => $lang_thumb_view['sort_nd'],
            '{SORT_DA}' => $lang_thumb_view['sort_da'],
            '{SORT_DD}' => $lang_thumb_view['sort_dd'],
            '{POSITION}' => $lang_thumb_view['position'],
            '{SORT_PA}' => $lang_thumb_view['sort_pa'],
            '{SORT_PD}' => $lang_thumb_view['sort_pd'],
            );

replace with:
Code: [Select]
    if ($sort_options) {
        $param = array('{ALBUM_NAME}' => $album_name,
            '{AID}' => $aid,
            '{PAGE}' => $page,
            '{NAME}' => $lang_thumb_view['name'],
            '{TITLE}' => $lang_thumb_view['title'],
            '{DATE}' => $lang_thumb_view['date'],
            '{SORT_TA}' => $lang_thumb_view['sort_ta'],
            '{SORT_TD}' => $lang_thumb_view['sort_td'],
            '{SORT_NA}' => $lang_thumb_view['sort_na'],
            '{SORT_ND}' => $lang_thumb_view['sort_nd'],
            '{SORT_DA}' => $lang_thumb_view['sort_da'],
            '{SORT_DD}' => $lang_thumb_view['sort_dd'],
            '{POSITION}' => $lang_thumb_view['position'],
            '{SORT_PA}' => $lang_thumb_view['sort_pa'],
            '{SORT_PD}' => $lang_thumb_view['sort_pd'],
            );
     // MOD - begin
$param['{ALBUM_NAME}'] .= '<a href="zip.php?aid=' . $aid . '" title="Download album as *zip archive">[ Download Album ]</a>';
// MOD - end

Thats it. I´ll hope you have fun with it :)


Great post. It only needed 1 additional line of code in zip.php to make it run without errors:
 
Code: [Select]
$aid = $_GET['aid'];
Title: Re: Download an album by zip
Post by: Vincs on June 09, 2007, 04:28:17 pm
I can't make it works with my version 1.4.10 and chaoticsoul template... I can't find where I must add the line in theme.php
Title: Re: Download an album by zip
Post by: h3nn3s on June 10, 2007, 04:09:47 pm
I can't make it works with my version 1.4.10 and chaoticsoul template... I can't find where I must add the line in theme.php

look at this

@Beme: your comment doesn't apply. As with all theme modifications, you'll need to copy the missing code from the sample theme into your custom theme if it doesn't exist there.



@all:

If the above mentioned section doesn't exist in themes/your_theme/theme.php, then copy
Code: [Select]
function theme_display_thumbnails(&$thumb_list, $nbThumb, $album_name, $aid, $cat, $page, $total_pages, $sort_options, $display_tabs, $mode = 'thumb')
{
    global $CONFIG;
    global $template_thumb_view_title_row,$template_fav_thumb_view_title_row, $lang_thumb_view, $template_tab_display, $template_thumbnail_view, $lang_album_list;

    static $header = '';
    static $thumb_cell = '';
    static $empty_cell = '';
    static $row_separator = '';
    static $footer = '';
    static $tabs = '';
    static $spacer = '';

    if ($header == '') {
        $thumb_cell = template_extract_block($template_thumbnail_view, 'thumb_cell');
        $tabs = template_extract_block($template_thumbnail_view, 'tabs');
        $header = template_extract_block($template_thumbnail_view, 'header');
        $empty_cell = template_extract_block($template_thumbnail_view, 'empty_cell');
        $row_separator = template_extract_block($template_thumbnail_view, 'row_separator');
        $footer = template_extract_block($template_thumbnail_view, 'footer');
        $spacer = template_extract_block($template_thumbnail_view, 'spacer');
    }

    $cat_link = is_numeric($aid) ? '' : '&amp;cat=' . $cat;
    $uid_link = (isset($_GET['uid']) && is_numeric($_GET['uid'])) ? '&amp;uid=' . $_GET['uid'] : '';

    $theme_thumb_tab_tmpl = $template_tab_display;

    if ($mode == 'thumb') {
        $theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $aid == 'lastalb' ? $lang_album_list['album_on_page'] : $lang_thumb_view['pic_on_page']));
        $theme_thumb_tab_tmpl['inactive_tab'] = strtr($theme_thumb_tab_tmpl['inactive_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . $uid_link . '&amp;page=%d'));
        $theme_thumb_tab_tmpl['inactive_next_tab'] = strtr($theme_thumb_tab_tmpl['inactive_next_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . $uid_link . '&amp;page=%d'));
        $theme_thumb_tab_tmpl['inactive_prev_tab'] = strtr($theme_thumb_tab_tmpl['inactive_prev_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . $uid_link . '&amp;page=%d'));
    } else {
        $theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $lang_thumb_view['user_on_page']));
        $theme_thumb_tab_tmpl['inactive_tab'] = strtr($theme_thumb_tab_tmpl['inactive_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&amp;page=%d'));
        $theme_thumb_tab_tmpl['inactive_next_tab'] = strtr($theme_thumb_tab_tmpl['inactive_next_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&amp;page=%d'));
        $theme_thumb_tab_tmpl['inactive_prev_tab'] = strtr($theme_thumb_tab_tmpl['inactive_prev_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&amp;page=%d'));
    }

    $thumbcols = $CONFIG['thumbcols'];
    $cell_width = ceil(100 / $CONFIG['thumbcols']) . '%';

    $tabs_html = $display_tabs ? create_tabs($nbThumb, $page, $total_pages, $theme_thumb_tab_tmpl) : '';
    // The sort order options are not available for meta albums
    if ($sort_options) {
        $param = array('{ALBUM_NAME}' => $album_name,
            '{AID}' => $aid,
            '{PAGE}' => $page,
            '{NAME}' => $lang_thumb_view['name'],
            '{TITLE}' => $lang_thumb_view['title'],
            '{DATE}' => $lang_thumb_view['date'],
            '{SORT_TA}' => $lang_thumb_view['sort_ta'],
            '{SORT_TD}' => $lang_thumb_view['sort_td'],
            '{SORT_NA}' => $lang_thumb_view['sort_na'],
            '{SORT_ND}' => $lang_thumb_view['sort_nd'],
            '{SORT_DA}' => $lang_thumb_view['sort_da'],
            '{SORT_DD}' => $lang_thumb_view['sort_dd'],
            '{POSITION}' => $lang_thumb_view['position'],
            '{SORT_PA}' => $lang_thumb_view['sort_pa'],
            '{SORT_PD}' => $lang_thumb_view['sort_pd'],
            );
        $title = template_eval($template_thumb_view_title_row, $param);
    } else if ($aid == 'favpics' && $CONFIG['enable_zipdownload'] == 1) { //Lots of stuff can be added here later
       $param = array('{ALBUM_NAME}' => $album_name,
                             '{DOWNLOAD_ZIP}'=>$lang_thumb_view['download_zip']
                               );
       $title = template_eval($template_fav_thumb_view_title_row, $param);
    }else{
        $title = $album_name;
    }


    if ($mode == 'thumb') {
        starttable('100%', $title, $thumbcols);
    } else {
        starttable('100%');
    }

    echo $header;

    $i = 0;
    foreach($thumb_list as $thumb) {
        $i++;
        if ($mode == 'thumb') {
            if ($aid == 'lastalb') {
                $params = array('{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}' => "thumbnails.php?album={$thumb['aid']}",
                    '{THUMB}' => $thumb['image'],
                    '{CAPTION}' => $thumb['caption'],
                    '{ADMIN_MENU}' => $thumb['admin_menu']
                    );
            } else {
                $params = array('{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}' => "displayimage.php?album=$aid$cat_link&amp;pos={$thumb['pos']}$uid_link",
                    '{THUMB}' => $thumb['image'],
                    '{CAPTION}' => $thumb['caption'],
                    '{ADMIN_MENU}' => $thumb['admin_menu']
                    );
            }
        } else {
            $params = array('{CELL_WIDTH}' => $cell_width,
                '{LINK_TGT}' => "index.php?cat={$thumb['cat']}",
                '{THUMB}' => $thumb['image'],
                '{CAPTION}' => $thumb['caption'],
                '{ADMIN_MENU}' => ''
                );
        }
        echo template_eval($thumb_cell, $params);

        if ((($i % $thumbcols) == 0) && ($i < count($thumb_list))) {
            echo $row_separator;
        }
    }
    for (;($i % $thumbcols); $i++) {
        echo $empty_cell;
    }
    echo $footer;

    if ($display_tabs) {
        $params = array('{THUMB_COLS}' => $thumbcols,
            '{TABS}' => $tabs_html
            );
        echo template_eval($tabs, $params);
    }

    endtable();
    echo $spacer;
}
from themes/sample/theme.php into a new line before
Code: [Select]
?>of themes/your_theme/theme.php, then apply the suggested modification.
Title: Re: Download an album by zip
Post by: Vincs on June 10, 2007, 05:02:35 pm
When I do the modification and try to download an album I got this

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 207835 bytes) in /mnt/106/sdb/1/5/site/include/archive.php on line 445


Title: Re: Download an album by zip
Post by: h3nn3s on June 10, 2007, 06:04:26 pm
your memory size of PHP is limited to 32MB. You may have to edit the php.ini file to increase the memory size which can be used by PHP.
Title: Re: Download an album by zip
Post by: Joachim Müller on June 11, 2007, 09:04:05 am
See Trouble-shooting the upload process -> Fatal error: Allowed memory size of X bytes exhausted (http://forum.coppermine-gallery.net/index.php?topic=24088.msg110690#msg110690)
Title: Re: Download an album by zip
Post by: h3nn3s on June 11, 2007, 08:14:42 pm
jep thanks, that's what i would say :D
Title: Re: Download an album by zip
Post by: dieapokalypse on June 13, 2007, 06:51:14 pm
look at this


I do the same: copie the missing code of the function

function theme_display_thumbnails

at the end of my theme-code (above ?>), but then my gallery is empty (white)

I'm Using the macox-theme...can somebody help me

Title: Delete ZIP Files after Downloaded
Post by: michi4ever on June 25, 2007, 06:20:13 pm
Hello,

the function above is great! (with zip.php).
But, when a zip-file is downloaded, there is a "number of album".zip in the coppermine root.

Is there a way, that after the zip is downloaded, the zip file will be deleted? maybe with a cronjob?

Thanks in advance,

Mike
Title: Re: Download an album by zip
Post by: zymme on August 04, 2007, 05:00:19 pm
Please fill me in with more info, what should I type in, in the zip.php file?
"2. unzip and Edit line 13 in zip.php (`cpg143_pictures`)"
I Don´t understand:)

Thanks!


Hello guys,

as requested in this thread (http://forum.coppermine-gallery.net/index.php?topic=41579.0) i´ll post my modification here.

Remember: Propably full of bugs and non-professional code. Feel free to improve it :)

What does it do?
It simply adds a button/text to your thumbnails.php to download a complete album as a zip archive without the normal_ and thumb_ pictures.

What to do?
1. Download the attached file
2. unzip and Edit line 13 in zip.php (`cpg143_pictures`)
2. upload the zip.php to your coppermine root
3. modify the theme.php from your current theme as the following

find:
Code: [Select]
    if ($sort_options) {
        $param = array('{ALBUM_NAME}' => $album_name,
            '{AID}' => $aid,
            '{PAGE}' => $page,
            '{NAME}' => $lang_thumb_view['name'],
            '{TITLE}' => $lang_thumb_view['title'],
            '{DATE}' => $lang_thumb_view['date'],
            '{SORT_TA}' => $lang_thumb_view['sort_ta'],
            '{SORT_TD}' => $lang_thumb_view['sort_td'],
            '{SORT_NA}' => $lang_thumb_view['sort_na'],
            '{SORT_ND}' => $lang_thumb_view['sort_nd'],
            '{SORT_DA}' => $lang_thumb_view['sort_da'],
            '{SORT_DD}' => $lang_thumb_view['sort_dd'],
            '{POSITION}' => $lang_thumb_view['position'],
            '{SORT_PA}' => $lang_thumb_view['sort_pa'],
            '{SORT_PD}' => $lang_thumb_view['sort_pd'],
            );

replace with:
Code: [Select]
    if ($sort_options) {
        $param = array('{ALBUM_NAME}' => $album_name,
            '{AID}' => $aid,
            '{PAGE}' => $page,
            '{NAME}' => $lang_thumb_view['name'],
            '{TITLE}' => $lang_thumb_view['title'],
            '{DATE}' => $lang_thumb_view['date'],
            '{SORT_TA}' => $lang_thumb_view['sort_ta'],
            '{SORT_TD}' => $lang_thumb_view['sort_td'],
            '{SORT_NA}' => $lang_thumb_view['sort_na'],
            '{SORT_ND}' => $lang_thumb_view['sort_nd'],
            '{SORT_DA}' => $lang_thumb_view['sort_da'],
            '{SORT_DD}' => $lang_thumb_view['sort_dd'],
            '{POSITION}' => $lang_thumb_view['position'],
            '{SORT_PA}' => $lang_thumb_view['sort_pa'],
            '{SORT_PD}' => $lang_thumb_view['sort_pd'],
            );
     // MOD - begin
$param['{ALBUM_NAME}'] .= '<a href="zip.php?aid=' . $aid . '" title="Download album as *zip archive">[ Download Album ]</a>';
// MOD - end

Thats it. I´ll hope you have fun with it :)

Title: Re: Download an album by zip
Post by: Nibbler on August 04, 2007, 05:20:41 pm
Change to the prefix you chose during installation. Check include/config.inc.php or your database if you can't remember.
Title: Re: Download an album by zip
Post by: zymme on August 04, 2007, 05:30:41 pm
in the sql-db i can read "cpg148_pictures"
should the line be:
$sql = 'SELECT * FROM `cpg148_pictures` where `aid` = ' . $aid;
?

when i press Download Album, it only shows me a new blank white page.
nohting else, no zip file :(

thanks for your quick answer!

Change to the prefix you chose during installation. Check include/config.inc.php or your database if you can't remember.
Title: Re: Download an album by zip
Post by: sabbia on August 05, 2007, 04:01:56 pm
I can't make it working on version 1.4.12
I tried the zip.php and the zipalbum.php too, but nothing works.

For example, for the "zip.php" method I strictly followed the instructions:

1- Edited zip.php on line 13
2- Uploaded zip.php file in coppermine root
3- Copied the code from /themes/sample/theme.php
4- Pasted that in /themes/project_vii/theme.php
5- Applied the MOD code in /themes/project_vii/theme.php

But I can't see any "Download" button. Where should I find it?
Did I do something wrong?
Title: Re: Download an album by zip
Post by: sabbia on August 07, 2007, 02:42:17 pm
I can't make it working on version 1.4.12
I tried the zip.php and the zipalbum.php too, but nothing works.

For example, for the "zip.php" method I strictly followed the instructions:

1- Edited zip.php on line 13
2- Uploaded zip.php file in coppermine root
3- Copied the code from /themes/sample/theme.php
4- Pasted that in /themes/project_vii/theme.php
5- Applied the MOD code in /themes/project_vii/theme.php

But I can't see any "Download" button. Where should I find it?
Did I do something wrong?


I found the solution!
I had to modify the file /include/themes.inc.php !!!!

Now it's working perfectly!

Thank you guys
Title: Re: Download an album by zip
Post by: sabbia on August 07, 2007, 03:47:34 pm
I'm happy for solving my problems
I know it's a simple php MOD, but step by step we should solve a big security problem.

Anyone (a guest too) can download any album he wants, it's sufficient to modify the XYZ variable in the link http://www.domain.com/coppermine/zip.php?aid=XYZ (shown in the browser)

Unfortunately I don't know PHP, could somebody solve this problem (using permissions maybe)?

thanks to all
Title: Re: Download an album by zip
Post by: h3nn3s on August 07, 2007, 04:44:10 pm
I know it's a simple php MOD, but step by step we should solve a big security problem.

damn right dude, but i have no idea who to solve this problem.
I noticed this "security problem" too, but in my gallery EVERYBODY can browse all galleries and so can download all albums too.

But for sure, a security fix should be nice ;)
Title: Re: Download an album by zip
Post by: zymme on August 08, 2007, 10:58:43 am
I still have problem with my site..
please check it out on: http://zymme.com/thumbnails.php?album=11
When I push "download album" it only gives me a white page?

Can it be problem in the php-files? or some security rights, CHMOD?

Attached a zip file with the php-files I have edited.. Please have a look

Hopefully someone can help me? :)
Title: Re: Download an album by zip
Post by: h3nn3s on August 08, 2007, 02:20:06 pm
Can it be problem in the php-files? or some security rights, CHMOD?

i checked the files fastly and can't see a fault. is your coppermine root writeable?! set it to 777. I think the script couldn't write the file to the webserver.

greets
Title: Re: Download an album by zip
Post by: MoolFreet on August 19, 2007, 08:02:35 pm
Hi everyone !

As I have ever wanted to have this functionality on my gallery, I tried to include it. So I have modified slightly the "zip.php", to include those features :

By the way, as it took me some times to read all the post to know how this works, I will try to sum up the installation process :

As I have ever wanted to have this functionality on my gallery, I tried to include it. So I have modified slightly the "zip.php", to include those features :
Code: [Select]
function theme_display_thumbnails(&$thumb_list, $nbThumb, $album_name, $aid, $cat, $page, $total_pages, $sort_options, $display_tabs, $mode = 'thumb')
{
    global $CONFIG;
    global $template_thumb_view_title_row,$template_fav_thumb_view_title_row, $lang_thumb_view, $template_tab_display, $template_thumbnail_view, $lang_album_list;

    static $header = '';
    static $thumb_cell = '';
    static $empty_cell = '';
    static $row_separator = '';
    static $footer = '';
    static $tabs = '';
    static $spacer = '';

    if ($header == '') {
        $thumb_cell = template_extract_block($template_thumbnail_view, 'thumb_cell');
        $tabs = template_extract_block($template_thumbnail_view, 'tabs');
        $header = template_extract_block($template_thumbnail_view, 'header');
        $empty_cell = template_extract_block($template_thumbnail_view, 'empty_cell');
        $row_separator = template_extract_block($template_thumbnail_view, 'row_separator');
        $footer = template_extract_block($template_thumbnail_view, 'footer');
        $spacer = template_extract_block($template_thumbnail_view, 'spacer');
    }

    $cat_link = is_numeric($aid) ? '' : '&amp;cat=' . $cat;
    $uid_link = (isset($_GET['uid']) && is_numeric($_GET['uid'])) ? '&amp;uid=' . $_GET['uid'] : '';

    $theme_thumb_tab_tmpl = $template_tab_display;

    if ($mode == 'thumb') {
        $theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $aid == 'lastalb' ? $lang_album_list['album_on_page'] : $lang_thumb_view['pic_on_page']));
        $theme_thumb_tab_tmpl['inactive_tab'] = strtr($theme_thumb_tab_tmpl['inactive_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . $uid_link . '&amp;page=%d'));
        $theme_thumb_tab_tmpl['inactive_next_tab'] = strtr($theme_thumb_tab_tmpl['inactive_next_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . $uid_link . '&amp;page=%d'));
        $theme_thumb_tab_tmpl['inactive_prev_tab'] = strtr($theme_thumb_tab_tmpl['inactive_prev_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . $uid_link . '&amp;page=%d'));
    } else {
        $theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $lang_thumb_view['user_on_page']));
        $theme_thumb_tab_tmpl['inactive_tab'] = strtr($theme_thumb_tab_tmpl['inactive_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&amp;page=%d'));
        $theme_thumb_tab_tmpl['inactive_next_tab'] = strtr($theme_thumb_tab_tmpl['inactive_next_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&amp;page=%d'));
        $theme_thumb_tab_tmpl['inactive_prev_tab'] = strtr($theme_thumb_tab_tmpl['inactive_prev_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&amp;page=%d'));
    }

    $thumbcols = $CONFIG['thumbcols'];
    $cell_width = ceil(100 / $CONFIG['thumbcols']) . '%';

    $tabs_html = $display_tabs ? create_tabs($nbThumb, $page, $total_pages, $theme_thumb_tab_tmpl) : '';
    // The sort order options are not available for meta albums
    if ($sort_options) {
        $param = array('{ALBUM_NAME}' => $album_name,
            '{AID}' => $aid,
            '{PAGE}' => $page,
            '{NAME}' => $lang_thumb_view['name'],
            '{TITLE}' => $lang_thumb_view['title'],
            '{DATE}' => $lang_thumb_view['date'],
            '{SORT_TA}' => $lang_thumb_view['sort_ta'],
            '{SORT_TD}' => $lang_thumb_view['sort_td'],
            '{SORT_NA}' => $lang_thumb_view['sort_na'],
            '{SORT_ND}' => $lang_thumb_view['sort_nd'],
            '{SORT_DA}' => $lang_thumb_view['sort_da'],
            '{SORT_DD}' => $lang_thumb_view['sort_dd'],
            '{POSITION}' => $lang_thumb_view['position'],
            '{SORT_PA}' => $lang_thumb_view['sort_pa'],
            '{SORT_PD}' => $lang_thumb_view['sort_pd'],
            );
        // MOD - begin
$param['{ALBUM_NAME}'] .= '&nbsp;<a href="zip.php?aid=' . $aid . '" title="Download album as *zip archive">[ Download Album ]</a>';
// MOD - end
        $title = template_eval($template_thumb_view_title_row, $param);
    } else if ($aid == 'favpics' && $CONFIG['enable_zipdownload'] == 1) { //Lots of stuff can be added here later
       $param = array('{ALBUM_NAME}' => $album_name,
                             '{DOWNLOAD_ZIP}'=>$lang_thumb_view['download_zip']
                               );
       $title = template_eval($template_fav_thumb_view_title_row, $param);
    }else{
        $title = $album_name;
    }


    if ($mode == 'thumb') {
        starttable('100%', $title, $thumbcols);
    } else {
        starttable('100%');
    }

    echo $header;

    $i = 0;
    foreach($thumb_list as $thumb) {
        $i++;
        if ($mode == 'thumb') {
            if ($aid == 'lastalb') {
                $params = array('{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}' => "thumbnails.php?album={$thumb['aid']}",
                    '{THUMB}' => $thumb['image'],
                    '{CAPTION}' => $thumb['caption'],
                    '{ADMIN_MENU}' => $thumb['admin_menu']
                    );
            } else {
                $params = array('{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}' => "displayimage.php?album=$aid$cat_link&amp;pos={$thumb['pos']}$uid_link",
                    '{THUMB}' => $thumb['image'],
                    '{CAPTION}' => $thumb['caption'],
                    '{ADMIN_MENU}' => $thumb['admin_menu']
                    );
            }
        } else {
            $params = array('{CELL_WIDTH}' => $cell_width,
                '{LINK_TGT}' => "index.php?cat={$thumb['cat']}",
                '{THUMB}' => $thumb['image'],
                '{CAPTION}' => $thumb['caption'],
                '{ADMIN_MENU}' => ''
                );
        }
        echo template_eval($thumb_cell, $params);

        if ((($i % $thumbcols) == 0) && ($i < count($thumb_list))) {
            echo $row_separator;
        }
    }
    for (;($i % $thumbcols); $i++) {
        echo $empty_cell;
    }
    echo $footer;

    if ($display_tabs) {
        $params = array('{THUMB_COLS}' => $thumbcols,
            '{TABS}' => $tabs_html
            );
        echo template_eval($tabs, $params);
    }

    endtable();
    echo $spacer;
}
before the ?> final markup (as GauGau, and h3nn3s said) Note : you can find the
Code: [Select]
$param['{ALBUM_NAME}'] .= '&nbsp;<a href="zip.php?aid=' . $aid . '" title="Download album as *zip archive">[ Download Album ]</a>';
And that's it ! That's all I've done, and it work perfectly well with my 1.4.12 CPG :)

Now what would be terrific, is to delete the file automatically after the user have downloaded it, but I can't think of a solution ???... but I'm a PHP beginner, so I let the pro find out the solution ;)

PS : Thank you all for this great job!!
PPS : Forgive my bad english...
Title: Re: Download an album by zip
Post by: Jay-SimplePic on September 20, 2007, 03:32:53 pm
I've been all through this, but came across a problem:

Fatal error: Cannot instantiate non-existent class: zipfile in /home/.../zipalbum.php on line 58

Where line 58 = $zip = new zipfile($cwd,$flags);

So, from what I can tell it can't tell where "class zipfile {...}" is. Problem is, neither can I. If anyone could assist it would be greatly appreciated, because I don't know php.
Title: Re: Download an album by zip
Post by: Joachim Müller on September 20, 2007, 07:50:27 pm
You probably don't have zip support on your server, so you can't use this mod.
Title: Re: Download an album by zip
Post by: Nibbler on September 20, 2007, 08:25:59 pm
This mod doesn't have a file named zipalbum.php. Are you asking about something else?
Title: Re: Download an album by zip
Post by: Jay-SimplePic on September 20, 2007, 09:07:08 pm
It's quite unlikely, however i'm adding files as i go along, progressing slowly. could someone tell me where the function: addfiles is declared, so i can add it in?

I know i'm trying to force it to do something it's not designed to do, but from my experience, when i coded in c, you could easily install/add header files which would add increased functionality. You needed functions, you just #include xxx.h at the start of the program.

At any rate, if it's possible to simply include this with a file, which i've googled over and over, with little success, it looks like next I'll be looking for filedownload function.
Title: Re: Download an album by zip
Post by: Jay-SimplePic on September 20, 2007, 09:30:20 pm
I'm sorry, i was attempting the suggestion from another person in this thread to add a download link, when the first one didn't work properly, but now I've figured that it is easier for me to learn enough about the language than trying to force a canned patch on the gallery which may not have all required software. I've the correct functions, however, I'm having a problem with I believe the zip.php file, which is producing the following error:
Quote
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Looking at zip.php, which was referenced in the url in the address bar, the syntax looked different from what I had seen in other files:
Quote
include "include/config.inc.php";
In an attempt to make it more like others, i changed it to:
Quote
include('include/config.inc.php');
However, that did not fix the error. Since the first line is simply "<?php " I assumed it was referring to the second line, where it had the double quotes. I realize this is probably not the best place for me to be trying to learn php, but it's the only place I can find relevant information to what I'm trying to figure out.
Title: Re: Download an album by zip
Post by: rubenix on September 26, 2007, 02:03:11 pm
I'm sorry, i was attempting the suggestion from another person in this thread to add a download link, when the first one didn't work properly, but now I've figured that it is easier for me to learn enough about the language than trying to force a canned patch on the gallery which may not have all required software. I've the correct functions, however, I'm having a problem with I believe the zip.php file, which is producing the following error:Looking at zip.php, which was referenced in the url in the address bar, the syntax looked different from what I had seen in other files:In an attempt to make it more like others, i changed it to:However, that did not fix the error. Since the first line is simply "<?php " I assumed it was referring to the second line, where it had the double quotes. I realize this is probably not the best place for me to be trying to learn php, but it's the only place I can find relevant information to what I'm trying to figure out.

Any suggestions??  ??? ??? ???
Im having the same problem and want this mod working on my site! Thanks in advance  :P
Title: Zip Download Albums With Basic Security
Post by: erostew on October 24, 2007, 04:21:25 pm
I really wanted to start a new topic for this but it looks like I'm not allowed to do that for some reason.

I have wanted to have the functionality of users being able to download a zip of an entire album/folder for a long, long time. But I never manged to get it working on my own. That's one reason that I decided to try out CPG. So I tried out the various hacks in this thread and managed to get the zip.php version to work. The zipalbum.php version does not work at all as posted. There are errors in the scripting.

So I was happy to get zip downloads working, but there was one major problem. Lack of any kind of security. All a user had to do was replace the number in the aid portion of the url and he could download any album, including private ones. Well there can be many many reasons why that is completely unacceptable. You may have family pictures stored in your CPG that you don't want the world at large to see, etc. My main reason for needing better security is that I want to be able to make updates at anytime, and then make them active on a set day by changing the permissions from admin-only to everyone.

So I decided to use the built in user levels to secure the zip script. An album with "everyone" permissions has "0" set in the visibility colum of the cpgxxx_albums table. An "admin" gallery has a "1", etc. I figured the easiest thing to implement would be a check to see what the content of the visibility column was, and then disallow any downloads if the result was not "0". I only use admin and everyone in my CPG that works perfectly for me. You might want to change things around a bit to suit your own setup. To find out what the visibilty value is for any particular setting just change the setting in the album's properties and then check the contents of the table with phpmyadmin or MySQL Administrator.

This is tested and working on my linux, apache, mysql, php4 server. Your mileage may vary.

This script contains work by h3nn3s, Beme, and MoolFreet. My contribution was perhaps the smallest.

Detailed installation instructions:

1 ) Download the securezip.zip attached to this message.
2 ) Unzip it and upload zip.php to the root folder of your CPG installation. (Same folder as the index.php)
3 ) Open the file in your editor of choice and look for:
Code: [Select]
/* Write here the name of the folder  where the zip will be created */
$sFolderZip = "zipfiles/";
It starts on line 5. Either change the name (make sure it has the "/" on the end!) of the folder or else make a folder in the root of your CPG installation called "zipfiles". Whichever one you choose, you will probably have to chmod to 777 to get the script to work.

4 ) Navigate to the folder of the template you are using. Something like: /yourwwwfolder/CPG/templates/name_of_template.
5 ) Open template.php in your editor of choice. Copy the following code into your template.php file just above the
Code: [Select]
?> at the end of the file.
Code: [Select]
function theme_display_thumbnails(&$thumb_list, $nbThumb, $album_name, $aid, $cat, $page, $total_pages, $sort_options, $display_tabs, $mode = 'thumb')
{
    global $CONFIG;
    global $template_thumb_view_title_row,$template_fav_thumb_view_title_row, $lang_thumb_view, $template_tab_display, $template_thumbnail_view, $lang_album_list;

    static $header = '';
    static $thumb_cell = '';
    static $empty_cell = '';
    static $row_separator = '';
    static $footer = '';
    static $tabs = '';
    static $spacer = '';

    if ($header == '') {
        $thumb_cell = template_extract_block($template_thumbnail_view, 'thumb_cell');
        $tabs = template_extract_block($template_thumbnail_view, 'tabs');
        $header = template_extract_block($template_thumbnail_view, 'header');
        $empty_cell = template_extract_block($template_thumbnail_view, 'empty_cell');
        $row_separator = template_extract_block($template_thumbnail_view, 'row_separator');
        $footer = template_extract_block($template_thumbnail_view, 'footer');
        $spacer = template_extract_block($template_thumbnail_view, 'spacer');
    }

    $cat_link = is_numeric($aid) ? '' : '&amp;cat=' . $cat;
    $uid_link = (isset($_GET['uid']) && is_numeric($_GET['uid'])) ? '&amp;uid=' . $_GET['uid'] : '';

    $theme_thumb_tab_tmpl = $template_tab_display;

    if ($mode == 'thumb') {
        $theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $aid == 'lastalb' ? $lang_album_list['album_on_page'] : $lang_thumb_view['pic_on_page']));
        $theme_thumb_tab_tmpl['inactive_tab'] = strtr($theme_thumb_tab_tmpl['inactive_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . $uid_link . '&amp;page=%d'));
        $theme_thumb_tab_tmpl['inactive_next_tab'] = strtr($theme_thumb_tab_tmpl['inactive_next_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . $uid_link . '&amp;page=%d'));
        $theme_thumb_tab_tmpl['inactive_prev_tab'] = strtr($theme_thumb_tab_tmpl['inactive_prev_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . $uid_link . '&amp;page=%d'));
    } else {
        $theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $lang_thumb_view['user_on_page']));
        $theme_thumb_tab_tmpl['inactive_tab'] = strtr($theme_thumb_tab_tmpl['inactive_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&amp;page=%d'));
        $theme_thumb_tab_tmpl['inactive_next_tab'] = strtr($theme_thumb_tab_tmpl['inactive_next_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&amp;page=%d'));
        $theme_thumb_tab_tmpl['inactive_prev_tab'] = strtr($theme_thumb_tab_tmpl['inactive_prev_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&amp;page=%d'));
    }

    $thumbcols = $CONFIG['thumbcols'];
    $cell_width = ceil(100 / $CONFIG['thumbcols']) . '%';

    $tabs_html = $display_tabs ? create_tabs($nbThumb, $page, $total_pages, $theme_thumb_tab_tmpl) : '';
    // The sort order options are not available for meta albums
    if ($sort_options) {
        $param = array('{ALBUM_NAME}' => $album_name,
            '{AID}' => $aid,
            '{PAGE}' => $page,
            '{NAME}' => $lang_thumb_view['name'],
            '{TITLE}' => $lang_thumb_view['title'],
            '{DATE}' => $lang_thumb_view['date'],
            '{SORT_TA}' => $lang_thumb_view['sort_ta'],
            '{SORT_TD}' => $lang_thumb_view['sort_td'],
            '{SORT_NA}' => $lang_thumb_view['sort_na'],
            '{SORT_ND}' => $lang_thumb_view['sort_nd'],
            '{SORT_DA}' => $lang_thumb_view['sort_da'],
            '{SORT_DD}' => $lang_thumb_view['sort_dd'],
            '{POSITION}' => $lang_thumb_view['position'],
            '{SORT_PA}' => $lang_thumb_view['sort_pa'],
            '{SORT_PD}' => $lang_thumb_view['sort_pd'],
            );
        // MOD - begin
$param['{ALBUM_NAME}'] .= '&nbsp;<a href="zip.php?aid=' . $aid . '" title="Download album as *zip archive">[ Download Album ]</a>';
// MOD - end
        $title = template_eval($template_thumb_view_title_row, $param);
    } else if ($aid == 'favpics' && $CONFIG['enable_zipdownload'] == 1) { //Lots of stuff can be added here later
       $param = array('{ALBUM_NAME}' => $album_name,
                             '{DOWNLOAD_ZIP}'=>$lang_thumb_view['download_zip']
                               );
       $title = template_eval($template_fav_thumb_view_title_row, $param);
    }else{
        $title = $album_name;
    }


    if ($mode == 'thumb') {
        starttable('100%', $title, $thumbcols);
    } else {
        starttable('100%');
    }

    echo $header;

    $i = 0;
    foreach($thumb_list as $thumb) {
        $i++;
        if ($mode == 'thumb') {
            if ($aid == 'lastalb') {
                $params = array('{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}' => "thumbnails.php?album={$thumb['aid']}",
                    '{THUMB}' => $thumb['image'],
                    '{CAPTION}' => $thumb['caption'],
                    '{ADMIN_MENU}' => $thumb['admin_menu']
                    );
            } else {
                $params = array('{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}' => "displayimage.php?album=$aid$cat_link&amp;pos={$thumb['pos']}$uid_link",
                    '{THUMB}' => $thumb['image'],
                    '{CAPTION}' => $thumb['caption'],
                    '{ADMIN_MENU}' => $thumb['admin_menu']
                    );
            }
        } else {
            $params = array('{CELL_WIDTH}' => $cell_width,
                '{LINK_TGT}' => "index.php?cat={$thumb['cat']}",
                '{THUMB}' => $thumb['image'],
                '{CAPTION}' => $thumb['caption'],
                '{ADMIN_MENU}' => ''
                );
        }
        echo template_eval($thumb_cell, $params);

        if ((($i % $thumbcols) == 0) && ($i < count($thumb_list))) {
            echo $row_separator;
        }
    }
    for (;($i % $thumbcols); $i++) {
        echo $empty_cell;
    }
    echo $footer;

    if ($display_tabs) {
        $params = array('{THUMB_COLS}' => $thumbcols,
            '{TABS}' => $tabs_html
            );
        echo template_eval($tabs, $params);
    }

    endtable();
    echo $spacer;
}

This is assuming that you are using CPG 1.4.13 with the Classic or Waterdops theme. I haven't tested it in other themes. Your theme may have some or all of this code in it already. If that's the case then search the code in your theme.php for:
Code: [Select]
$param = array('{ALBUM_NAME}' => $album_name,
            '{AID}' => $aid,
            '{PAGE}' => $page,
            '{NAME}' => $lang_thumb_view['name'],
            '{TITLE}' => $lang_thumb_view['title'],
            '{DATE}' => $lang_thumb_view['date'],
            '{SORT_TA}' => $lang_thumb_view['sort_ta'],
            '{SORT_TD}' => $lang_thumb_view['sort_td'],
            '{SORT_NA}' => $lang_thumb_view['sort_na'],
            '{SORT_ND}' => $lang_thumb_view['sort_nd'],
            '{SORT_DA}' => $lang_thumb_view['sort_da'],
            '{SORT_DD}' => $lang_thumb_view['sort_dd'],
            '{POSITION}' => $lang_thumb_view['position'],
            '{SORT_PA}' => $lang_thumb_view['sort_pa'],
            '{SORT_PD}' => $lang_thumb_view['sort_pd'],
            );
and immediately after that, insert this:
Code: [Select]
// MOD - begin
$param['{ALBUM_NAME}'] .= '&nbsp;<a href="zip.php?aid=' . $aid . '" title="Download album as *zip archive">[ Download Album ]</a>';
// MOD - end
As MoolFreet pointed out you can change the formatting of the URL in that snippet to use an icon image instead of text if you like.

6 ) Download the pclzip library from http://www.phpconcept.net/pclzip/index.php#download. Unzip it and and upload pclzip.lib.php to your CPG root.
7 ) Make sure that "allow zip download of favorites" is turned on in your config panel.
8 ) You're done! If you want to test it just go to an album and click the download link on the top of the thumbnail view. If you want to test the security just set an album to anything except "everyone" in the album's properties, and then try to d/l it by changing the aid=123 portion of the zip url to anything to the aid (album ID) number of the restricted gallery. You should see a white page with a red error message.

Known Limitations:
If you change themes you will need to do the same modifications to the theme.php of your new theme.

I am NOT a coder. I struggled like hell to get this tiny bit of code to work. If you can improve it then feel free to do so. Hopefully this might make it into the next release of CPG. If you are using the "download favorites" function included in CPG you may be interested to know that it also allows the downloading of favorites without checking if the album is private  or not. However that script only downloads the files that are already present in favorites. That makes it less of a risk because if he can't see an album a user can't add an image to his favorites. However I have not checked to see if it is possible to add to favorites by changing the url around.

Enjoy!
Title: Re: Zip Download Albums With Basic Security
Post by: Joachim Müller on October 27, 2007, 11:35:20 am
I really wanted to start a new topic for this but it looks like I'm not allowed to do that for some reason.
The reasons are being explained quite clearly in various places, e.g. in the sticky thread "About this board - READ (http://forum.coppermine-gallery.net/index.php?topic=14348.0)" as well as in the sub-board description:
Quote
Modifications/Add-Ons/Hacks
The Modifications/Add-Ons/Hacks board is for actual mods and hacks contributions. It is not for requests for mods and hacks. Regular users are not able to post new threads to prevent this board from being cluttered by requests. If you want to contribute and are unable to create a new thread here, please post your contribution in the support boards under the correct version. A moderator will move the thread if it is a valid contribution. Next to each thread's subject, you'll find a little icon that says what version the mods on this sub-board have been written for or tested with (if applicable). Please do not clutter the individual threads by asking if the particular mod will or will not work with another coppermine version than the one it has originally been created with/for.
Title: Re: Zip Download Albums With Basic Security
Post by: Joachim Müller on October 27, 2007, 11:38:38 am
The reasons are being explained quite clearly in various places, e.g. in the sticky thread "About this board - READ (http://forum.coppermine-gallery.net/index.php?topic=14348.0)" as well as in the sub-board description:

You seem to have realized your mistake and started a new thread "Download a Zipped Album With Basic Security (http://forum.coppermine-gallery.net/index.php?topic=47820.0)" that has been moved to the mods board.

@all who browse this thread: please ignore erostew's previous posting in this thread - don't reply to this thread if you have questions or remarks on his contribution. Instead: visit the other thread "Download a Zipped Album With Basic Security (http://forum.coppermine-gallery.net/index.php?topic=47820.0)".
Title: Re: Zip Download Albums With Basic Security
Post by: erostew on October 27, 2007, 06:35:23 pm
The reasons are being explained quite clearly in various places, e.g. in the sticky thread
Yes I failed to read the small print. Sorry. As stated use the other thread for any replies or questions.

Regards.
Title: Re: Download an album by zip
Post by: wilrino on May 12, 2008, 01:07:11 pm
It's possible to limitate download all album?
I want to allow to download only some album.. It's possible to do?

thanks!
Title: Re: Download an album by zip
Post by: Forell on January 03, 2009, 11:57:41 pm
Hello
I´d like to work with your plugin to use the "album download" but there are many problems.
When I tried it with the "zipalbum.php" there is a error called :
Quote
" Fatal error: Cannot instantiate non-existent class: zipfile in /var/www/web7/html/coppermine/zipalbum.php on line 58 "

Where is my problem ? can anyone help me ?

I´ve tried it with the "zip.php", too. There I get the error
Quote
"Error : PCLZIP_ERR_READ_OPEN_FAIL (-2) : Unable to open archive '15.zip' in wb mode"

What is the wrong at my changes ? Or is there a newer, better possibility to include this feature ?

Please Help

P.S.: Sorry for my bad English but i try my best ;)
Title: Re: Download an album by zip
Post by: Joachim Müller on January 05, 2009, 07:31:19 am
Your server doesn't fullfill the minimum requirements - you can't use zipdownloads.
Title: Re: Download an album by zip
Post by: phantom_83 on August 11, 2010, 11:25:55 am
Sorry! i have this problem:

Quote
Fatal error: Class 'zipfile' not found in /web/htdocs/www.focalimpact.it/home/coppermine/zipalbum.php on line 58

Why?