Download an album by zip - Page 2 Download an album by zip - Page 2
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Download an album by zip

Started by h3nn3s, May 03, 2007, 06:06:17 PM

Previous topic - Next topic

0 Members and 5 Guests are viewing this topic.

zymme

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!

Quote from: 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.

sabbia

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?

sabbia

Quote from: 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?


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

Now it's working perfectly!

Thank you guys

sabbia

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

h3nn3s

Quote from: sabbia on August 07, 2007, 03:47:34 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 ;)

zymme

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? :)

h3nn3s

Quote from: zymme on August 08, 2007, 10:58:43 AM
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

MoolFreet

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 :

  • First, you don't need anymore to precise the extension of your sql tables (cpgxxx_), it retrieve it from the configuration include   file
  • Then I have included the "force download" script from Beme, thanks to you  ;)
  • I have made so that when you are downloading the zip file, it's name is no more the album id you are downloading, but the name of the album (protected through the 'urlencode' php function)
  • Finally I have included a var that you can modify, to select where the zip files would be created (so it would be easy to delete them after a while, to save some space on your server...)

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 :

  • First, rename the attached 'zip.php.txt' file into 'zip.php' and upload it to your gallery root (for those, like me who don't understand why they don't see the attached file, register and login ;), this attchement contain my modifications, and translated comments in english...)
  • Then download here http://www.phpconcept.net/pclzip/index.php#download the pclzip library, and upload it to your gallery root
  • Finally, modify your /gallerie_path/themes/your_theme/theme.php by inserting
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) ? '' : '&cat=' . $cat;
    $uid_link = (isset($_GET['uid']) && is_numeric($_GET['uid'])) ? '&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 . '&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 . '&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 . '&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 . '&page=%d'));
        $theme_thumb_tab_tmpl['inactive_next_tab'] = strtr($theme_thumb_tab_tmpl['inactive_next_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&page=%d'));
        $theme_thumb_tab_tmpl['inactive_prev_tab'] = strtr($theme_thumb_tab_tmpl['inactive_prev_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&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 $param['{ALBUM_NAME}'] .= '&nbsp;<a href="zip.php?aid=' . $aid . '" title="Download album as *zip archive">[ Download Album ]</a>';
    line, to modify the link as you wish (maybe insert a picture or anything else :))[/li]

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...

Jay-SimplePic

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.

Joachim Müller

You probably don't have zip support on your server, so you can't use this mod.

Nibbler

This mod doesn't have a file named zipalbum.php. Are you asking about something else?

Jay-SimplePic

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.

Jay-SimplePic

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:
Quoteinclude "include/config.inc.php";
In an attempt to make it more like others, i changed it to:
Quoteinclude('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.

rubenix

Quote from: 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: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

erostew

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:
/* 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
?>
at the end of the file.
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:
$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:
// 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 are logged in as admin you will still see the "Download Album" link, but if you click it permission will be denied. Personally I don't have any need to download a zip. I am the only one allowed to upload to my site.
  • As written ONLY albums with permission set to "Everyone" can be downloaded.
  • The coding of the error message is inelegant, but it works.
  • If you change themes you will need to do the same modifications to the theme.php of your new theme.
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!

Joachim Müller

Quote from: 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.
The reasons are being explained quite clearly in various places, e.g. in the sticky thread "About this board - READ" as well as in the sub-board description:
QuoteModifications/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.

Joachim Müller

Quote from: GauGau on October 27, 2007, 11:35:20 AM
The reasons are being explained quite clearly in various places, e.g. in the sticky thread "About this board - READ" 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" 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".

erostew

Quote from: GauGau on October 27, 2007, 11:35:20 AM
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.

wilrino

It's possible to limitate download all album?
I want to allow to download only some album.. It's possible to do?

thanks!

Forell

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 ;)