forum.coppermine-gallery.net

Support => cpg1.5 plugins => cpg1.5.x Support => cpg1.5 plugin contributions => Topic started by: Finswimmer on January 18, 2012, 09:33:00 am

Title: Download complete album als ZIP
Post by: Finswimmer on January 18, 2012, 09:33:00 am
Hi,

I have modified the download script, which lets one download all favorite images.

What to do:
1) copy zip.txt (see attachments) to your coppermine-root
2) rename it to zip.php
3) edit include/themes.inc.php
Find: $param['{ALBUM_NAME}'] = $album_name (around line 2893)
Replace with: $param['{ALBUM_NAME}'] = $album_name . ' <a href=zip.php?aid='.$aid.'>Download album as ZIP-Archive;

Download and install the plugin package as described in the plugin docs (http://documentation.coppermine-gallery.net/en/plugins.htm).


I know, that this is quick and dirty.

Possible improvements:
- Turn on/off in settings
- Language support
- Better position

But this took me 10minutes to create and I wanted to share it.
Title: Re: Download complete album als ZIP
Post by: Αndré on January 18, 2012, 02:09:10 pm
Thank you for your contribution. As this is no genuine plugin but a mod, this thread won't be moved to the plugin contributions board.
Title: Re: Download complete album als ZIP
Post by: Finswimmer on January 18, 2012, 03:17:31 pm
I have changed the naming of the resulting zip archive.
It is now the album name with spaces replaced by "_".
(I hope no one tries to use special chars as album name...)

Attached is the new file.
(Maybe someone can change the one in the first post with this one?)
Title: Re: Download complete album als ZIP
Post by: Αndré on January 18, 2012, 03:26:04 pm
Attached is the new file.
(Maybe someone can change the one in the first post with this one?)
I just added you to the Contributor group, so you can do this yourself from now on.


I hope no one tries to use special chars as album name...
You can use the function replace_forbidden to automatically replace such characters.
Title: Re: Download complete album als ZIP
Post by: fersauce on January 26, 2012, 09:29:19 am
Hello Finswimmer

I Tried your contribution in my test-server but after modifiying the include/themes.inc.php I get a blank screen...
I open the include/themes.inc.php with dreamweaver and just after replacing your code, I get a lot of bugs (see attachements)

Please, I need that function in my server. Please, can you help me?

this is my original post http://forum.coppermine-gallery.net/index.php/topic,74287.msg357653.html#msg357653

Thank you.
Title: Re: Download complete album als ZIP
Post by: Finswimmer on January 26, 2012, 09:59:25 am
@fersauce:
I am sorry the replacing line is incomplete.
Try it with: $param['{ALBUM_NAME}'] = $album_name . ' <a href=zip.php?aid='.$aid.'>Download album as ZIP-Archive';

Notice the last ' in front of ;

@André: Although you have addey me to the Contributor group I cannnot change the attachement nor edit my first post.
Title: Re: Download complete album als ZIP
Post by: Αndré on January 26, 2012, 10:47:01 am
@André: Although you have addey me to the Contributor group I cannnot change the attachement nor edit my first post.
I just re-checked the permissions. It seems that the additional privileges for "Contributors" are just granted in the contribution boards. However, it's very easy to convert this mod to a plugin by using the plugin hook
Code: [Select]
$param = CPGPluginAPI::filter('theme_thumbnails_title', $param);

Don't hesitate to ask for help while creating the plugin.
Title: Re: Download complete album als ZIP
Post by: fersauce on January 26, 2012, 11:03:51 am
Great!  it's OK

I love you!

thank you
Title: Re: Download complete album als ZIP
Post by: Finswimmer on January 27, 2012, 10:09:10 am
@Andre:

The plugin is working so far with i18n for the "download" string.
But my zip.php is now in plugins/albumdownload/ (before it was in coppermine_root_dir).
So now php complains at
  require('include/init.inc.php');
  include('include/archive.php');
which is the very first part of zip.php (as seen on zipdownload.php)

switching it to:
  require('../../include/init.inc.php');
  include('../../include/archive.php');
results in:
PHP Warning:  require_once(include/inspekt.php): failed to open stream: No such file or directory in /var/www/vhosts/default/htdocs/fotos/include/init.inc.php on line 45
PHP Fatal error:  require_once(): Failed opening required 'include/inspekt.php' (include_path='.:') in /var/www/vhosts/default/htdocs/fotos/include/init.inc.php on line 45

It tries to access include/inspekt.php from within plugins/albumdownloads, which cannot work...

How can I solve this?
Thank you!
Tobi
Title: Re: Download complete album als ZIP
Post by: Αndré on January 27, 2012, 10:41:00 am
Remove
Code: [Select]
  require('../../include/init.inc.php');and access the file via
Code: [Select]
index.php?file=albumdownload/zip
That way the file runs in cpg's context and init.inc.php has already been included.
Title: Re: Download complete album als ZIP
Post by: Finswimmer on January 27, 2012, 11:02:30 am
Now it navigates to root_dir/fotos/index.php?file=albumdownload/albumZip.php?aid=2
and shows the normal index.php

Starting the file directly via Firefox leads to:
Notice: Undefined variable: superCage in /var/www/vhosts/default/htdocs/fotos/plugins/albumdownload/albumZip.php on line 31 Notice: Trying to get property of non-object in /var/www/vhosts/default/htdocs/fotos/plugins/albumdownload/albumZip.php on line 31 Fatal error: Call to a member function getInt() on a non-object in /var/www/vhosts/default/htdocs/fotos/plugins/albumdownload/albumZip.php on line 31

I guess this is fine as init.inc.php is not "executed", but why does the redirect via index.php?... does not work?

Thanks!
Title: Re: Download complete album als ZIP
Post by: Αndré on January 27, 2012, 11:10:19 am
Code: [Select]
root_dir/fotos/index.php?file=albumdownload/albumZip.php?aid=2should be something like
Code: [Select]
root_dir/fotos/index.php?file=albumdownload/zip&aid=2
Attaching the current plugin files might help, so I can have a look at the code and test, too.
Title: Re: Download complete album als ZIP
Post by: Finswimmer on January 27, 2012, 11:20:14 am
This leads to a long list with the files, ended by:
Fatal error: Class 'zip_file' not found in /var/www/vhosts/default/htdocs/fotos/plugins/albumdownload/albumZip.php on line 42

Function zip_file is in include/archive.php which should be included...

BTW: Normally, it is foo.php?firstParamater=bar&secondParamater=bar
Is this coppermine-specific?

http://tobiaskaminsky.de/albumdownload.zip

Title: Re: Download complete album als ZIP
Post by: Αndré on January 27, 2012, 11:35:22 am
In albumZip.php, find
Code: [Select]
include('../../include/archive.php');and replace with
Code: [Select]
require('include/archive.php');
Title: Re: Download complete album als ZIP
Post by: Finswimmer on January 27, 2012, 11:44:33 am
Great!
Now it works.

Thank you.

I will post the final version of this plugin this afternoon.
Title: Re: Download complete album als ZIP
Post by: Αndré on January 27, 2012, 11:54:54 am
Moving this thread to the plugin contributions board, so you can use and maintain it as announcement thread.

Some suggestions:
1. The "install & configure" actions (and the corresponding functions) aren't need at all IMHO, as they just add extra click to install the plugins. Most plugins without configuration options directly install the plugins.
2. The current albumZip.php file doesn't check if the current user is allowed to view the album and subsequent files. The best way would be to use
Code: [Select]
$RESTRICTEDWHERE ANDinstead of
Code: [Select]
WHEREin albumZip.php, but you have to insert something like
Code: [Select]
get_meta_album_set(0);before the first occurrence of that variable. I haven't checked that in detail.
Title: Re: Download complete album als ZIP
Post by: Finswimmer on January 28, 2012, 11:29:28 pm
Hmm.
For non-admin user I need $html['{ALBUM_ID}'].
But it is not written to the array (see include/themes.inc.php:2893).

So what can I do?
I am not allowed to edit this line, or?

Thanks
Tobi

Ps: I still cannot edit my first post *weird*
Title: Re: Download complete album als ZIP
Post by: Αndré on January 30, 2012, 04:06:38 pm
You can get the album ID from the URL. Changing
Code: [Select]
$html['{ALBUM_NAME}'] = $html['{ALBUM_NAME}'] . ' <a href="index.php?file=albumdownload/albumZip&aid='.$html['{ALBUM_ID}'].'">'.$lang_plugin_albumdownload['albumDownload'].'zip</a>';to
Code: [Select]
    $superCage = Inspekt::makeSuperCage();
    if ($superCage->get->getInt('album') > 0) {
        $html['{ALBUM_NAME}'] = $html['{ALBUM_NAME}'] . ' <a href="index.php?file=albumdownload/albumZip&aid='.$superCage->get->getInt('album').'">'.$lang_plugin_albumdownload['albumDownload'].'zip</a>';
    }
should work for all users (haven't tested it). I also added a check to include the buttons just for 'real' album, but not for meta albums.
Title: Re: Download complete album als ZIP
Post by: Αndré on February 02, 2012, 09:12:35 am
The version I got from you breaks the upload function, as it adds white spaces to the HTML output. Removing the trailing spaces and blank lines from codebase.php fixes that issue.
Title: Re: Download complete album als ZIP
Post by: pols1337 on February 04, 2012, 09:14:37 am
This is an interesting plug-in.  While I haven't installed it yet since it seems like it's still under development, I /support!  Many of my users really want this functionality. 
Title: Re: Download complete album als ZIP
Post by: fersauce on February 09, 2012, 07:24:39 pm
@Finswimmer

Hello.
Thank you for your contribution.

Its´s posible to show a message while script is creating the zip file? Something like " wait a moment please" 

Thank you
Title: Re: Download complete album als ZIP
Post by: Tatome on May 07, 2012, 10:35:02 am
Hi,

not much seems to have happened on this one, lately.  In particular I don't find the plugin in the repo. 

I'd really appreciate the functionality, but I can't get it to work: first, when I install the last version in this thread, I get
Code: [Select]
Fatal error: require(): Failed opening required './plugins/albumdownload/lang/english.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/coppermine/plugins/albumdownload/initialize.inc.php on line 6 With an empty english.php in the lang directory, nothing happens at all---the thumbnail view is unchanged from without the plugin.

Does anyone have any ideas how to fix this?

Cheers,
Johannes

PS: Kudos for implementing it in the first place, Finswimmer!
Title: Re: Download complete album als ZIP
Post by: Αndré on May 07, 2012, 12:26:46 pm
With an empty english.php in the lang directory, nothing happens at all---the thumbnail view is unchanged from without the plugin.
When I install the plugin with an empty english.php language file the word "zip" is appended to the album name. A short look at the code shows, that it will not added for meta albums:
Code: [Select]
if ($superCage->get->getInt('album') > 0) {

However, when I open the URL I just get an error like
Quote
Fatal error: Class 'zip_file' not found in C:\xampplite\htdocs\svn_cpg15x_trunk\plugins\albumdownload\albumZip.php on line 42

To fix that issue, open albumZip.php, find
Code: [Select]
include('../../include/archive.php');and replace with
Code: [Select]
include('include/archive.php');
Title: Re: Download complete album als ZIP
Post by: Tatome on May 07, 2012, 02:29:01 pm
Thanks, Αndré.  At first, I didn't see any change, but after I actually put something meaningful into english.php:
Code: [Select]
<?php
if (!defined('IN_COPPERMINE')) { die('Not in Coppermine...'); }
$lang_plugin_albumdownload = array(
        
'albumDownload' => 'Download Album as ZIP file.'
    
);
?>
it seemed to work.  "seemed", because, when I clicked the link, I got a list of files (presumably the zip file preamble), and
Code: [Select]
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 3230366 bytes) in /var/www/coppermine/include/archive.php on line 651
Presumably this is because the zip file is built in-memory.  So, nothing we can do about this save re-implement the whole thing?

Cheers,
Johannes
Title: Re: Download complete album als ZIP
Post by: Αndré on May 07, 2012, 03:02:42 pm
Presumably this is because the zip file is built in-memory.  So, nothing we can do about this save re-implement the whole thing?
You could try to apply that changes (http://coppermine.svn.sourceforge.net/viewvc/coppermine/trunk/cpg1.6.x/zipdownload.php?r1=8035&r2=8034&pathrev=8035) to the albumZip.php file.
Title: Re: Download complete album als ZIP
Post by: Tatome on May 07, 2012, 03:35:17 pm
That would be a change to a file in the coppermine distribution as oppose to something in the plugin, right?

Thanks again, I'll check it out when I'm home.
Title: Re: Download complete album als ZIP
Post by: Tatome on May 07, 2012, 03:37:38 pm
You could try to apply that changes (http://coppermine.svn.sourceforge.net/viewvc/coppermine/trunk/cpg1.6.x/zipdownload.php?r1=8035&r2=8034&pathrev=8035) to the albumZip.php file.

Never mind my last comment.

Wer lesen kann...
Title: Re: Download complete album als ZIP
Post by: Tatome on May 07, 2012, 03:44:39 pm
That kind of worked.  I get a different error now:
Code: [Select]
Maximum execution time of 60 seconds exceeded in /var/www/coppermine/include/archive.php on line 65
This probably means I have to change my php settings.  I'll try it out when I get home.

Cheers,
Johannes
Title: Re: Download complete album als ZIP
Post by: Αndré on May 07, 2012, 03:55:28 pm
It should also be possible to distribute the zip file creation to bypass the execution limit, e.g. just add 5 files at a time to the archive and then start the script from the beginning.
Title: Re: Download complete album als ZIP
Post by: Tatome on May 07, 2012, 05:52:50 pm
Interesting idea...

You mean like the bulk image update functions: the user would click for each batch of images being added to the archive? 

Or would it even be possible to keep the restart transparent to the user?

Cheers,
Johannes
Title: Re: Download complete album als ZIP
Post by: Tatome on May 08, 2012, 11:30:30 am
Hi,

I fixed the code and it works in my installation.  I think I even improved it somewhat such that not only those images are included in the archive whose `home' album is the album in question, but also those included via the album tag.

Can I upload my version of the plugin?  How about the copyright?

Cheers,
Johannes
Title: Re: Download complete album als ZIP
Post by: Αndré on May 08, 2012, 11:46:58 am
Please share your version with the community.
Title: Re: Download complete album als ZIP
Post by: Tatome on May 08, 2012, 03:55:24 pm
Oops, sorry, I made it sound like I was concerned about my copyright.  Of course I'll gladly share what little contribution I can make.

I was referring to the OP's copyright.  After all, it's still mostly his code.

Cheers,
Johannes
Title: Re: Download complete album als ZIP
Post by: Finswimmer on May 08, 2012, 09:18:38 pm
Oops, sorry, I made it sound like I was concerned about my copyright.  Of course I'll gladly share what little contribution I can make.

I was referring to the OP's copyright.  After all, it's still mostly his code.

Cheers,
Johannes

It is ok as long as it remains "opensource". All changes must be contributed with this forum.

Thank you for your improvements!
Title: Re: Download complete album als ZIP
Post by: Tatome on May 09, 2012, 01:06:10 pm
Here goes.

BTW: I don't think there's anything in this plugin that checks user permissions, is there?
Title: Re: Download complete album als ZIP
Post by: Αndré on May 09, 2012, 01:39:55 pm
I don't think there's anything in this plugin that checks user permissions

Correct, but should be quite easy by replacing
Code: [Select]
$result = cpg_db_query("SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} WHERE aid = " . $aid );with something like
Code: [Select]
$result = cpg_db_query("SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} $RESTRICTEDWHERE AND r.aid = " . $aid );in albumZip.php (not tested).
Title: Re: Download complete album als ZIP
Post by: Tatome on May 09, 2012, 02:04:23 pm
Cool, thanks.  I'll check it out.

Of course that's only making it difficult to get the images, not impossible, for anyone who doesn't have access rights, as long as full size images are served directly.  But there's a plugin that serves images after checking access rights as well, right?
Title: Re: Download complete album als ZIP
Post by: Αndré on May 09, 2012, 02:15:37 pm
I just added the plugin to our SVN repository and currently merging your contribution. So please don't improve your current code until I submitted the new version to the repository.
Title: Re: Download complete album als ZIP
Post by: Tatome on May 09, 2012, 02:17:14 pm
"Don't improve your code..."
That's a tough request, you know  ;-)
Title: Re: Download complete album als ZIP
Post by: Αndré on May 09, 2012, 02:39:39 pm
until
... ;) I just wanted to avoid unnecessary merging effort.


Latest plugin version can be downloaded here (http://coppermine.svn.sourceforge.net/viewvc/coppermine/branches/cpg1.5.x/plugins/albumdownload/). Please use it for further improvements. I'll add any contributed improvements to the repository.
Title: Re: Download complete album als ZIP
Post by: fersauce on May 21, 2012, 03:35:53 pm
Yesterday I upgrade to the last Coppermine version and now this pluging doesn´t works. Can you help me?
Title: Re: Download complete album als ZIP
Post by: Tatome on May 21, 2012, 03:37:04 pm
Depends.  What's the problem?
Title: Re: Download complete album als ZIP
Post by: fersauce on May 21, 2012, 04:30:43 pm
I get this message from the firefox

Not Found
The requested document was not found on this server.

Web Server at h1989637.stratoserver.net

Do you need something else?
Title: Re: Download complete album als ZIP
Post by: Tatome on May 21, 2012, 04:37:46 pm
Hmm...  That doesn't ring a bell.

Is this an apache server?

When you try to download a zip file for an album with a lot of pictures, do you get the message immediately, or does it take some time?

Does the plugin for downloading favorite pictures as zip file work?
Title: Re: Download complete album als ZIP
Post by: fersauce on May 21, 2012, 04:44:34 pm
Yes it´s an apache server.

The pluging worked perfectil until the upgrade.

Yes. The favourites zip works perfectly.

????


Title: Re: Download complete album als ZIP
Post by: Tatome on May 21, 2012, 04:54:29 pm
Do you have access to the server logs?

Could you post the last 30 lines in the logs after trying to download an album?
Title: Re: Download complete album als ZIP
Post by: Tatome on May 21, 2012, 04:56:18 pm
Again: does the browser redirect you to the 404 page immediately, or does sit there for a while, waiting for the server to respond?
Title: Re: Download complete album als ZIP
Post by: fersauce on May 21, 2012, 06:54:37 pm
The browser redirect me inmediatly to the 404 error page.
And .... I dont know why, but... I have no logs! The log page it's empty  :(
Title: Re: Download complete album als ZIP
Post by: Tatome on May 21, 2012, 09:36:29 pm
Sounds a bit like an installation problem.  Can you check if there is a file named albumZIP.php in the same directory as codebase.php and initialize.inc.php?  (I think it should be in the directory plugins/albumdownload/ below the main coppermine directory).
Title: Re: Download complete album als ZIP
Post by: fersauce on May 21, 2012, 09:52:40 pm
Yes.  All of them...
Title: Re: Download complete album als ZIP
Post by: Tatome on May 21, 2012, 09:59:08 pm
And I suppose uninstalling and re-installing didn't help?

Can you tell me what's the precise URL that the album download link points to minus your domain name?
Same for the the URL after login minus your domain name?
Title: Re: Download complete album als ZIP
Post by: sebbo_ on May 27, 2012, 05:07:31 pm
Hello,

first of all thanks for the great work. I set up coppermine gallery three days ago and am still impressed about the smooth and easy handling!

Now i tried to install the albumdownload plugin. I dont get any errors and can start the download as zip. But unfortunately it doesnt work. The resulting zipfile is always empty and the name doesnt contain the name of the album, its always something like pictures-4fc1609ee78b7.zip. Uninstalling and reinstalling the plugin doesnt help either.

Environment:
Debian Squeeze
Apache 2.2.16-6
PHP 5.3.3-7
cpg1.5.20

Any ideas?
Thanks and regards
Sebastian
Title: Re: Download complete album als ZIP
Post by: Tatome on May 27, 2012, 05:57:16 pm
Hi,

is that for all albums or is it only for albums which don't have pictures on their own (only via album tags or whatever they're called)?

I suspect I broke something just before uploading the plugin zip; I'll post an update later.

Cheers,
Johannes
Title: Re: Download complete album als ZIP
Post by: Tatome on May 27, 2012, 06:20:16 pm
Hi,

seems like I did break the plugin just before updating it.  Pictures that are not included via album tags should still get into the zip file, but zips for albums which only include pictures would be empty.

I'm attaching a patch (administrators --- could you apply this, please?).

Cheers,
Johannes
Title: Re: Download complete album als ZIP
Post by: sebbo_ on May 27, 2012, 07:12:53 pm
Hi Johannes,

thanks i will try the patch and keep you informed.
Concerning your question: I only have albums which contain images, no album tags (to be honest i dont know all features yet, for example album tags  ;) )

Regards
Sebastian
Title: Re: Download complete album als ZIP
Post by: sebbo_ on May 27, 2012, 07:40:11 pm
Hi Johannes,

i replaced $query of albumZip.php with the one of your patch, but nothing changed, its still an empty zipfile. I uninstalled and reinstalled the plugin, restarted the apache httpd, still no change.

Regards
Sebastian
Title: Re: Download complete album als ZIP
Post by: Tatome on May 27, 2012, 07:44:02 pm
Hey Sebastian,

could you change the script so it prints out all the file names instead of creating a zip file?

I don't suppose there are any error messages in the logs...

Cheers,
Johannes
Title: Re: Download complete album als ZIP
Post by: sebbo_ on May 27, 2012, 08:22:58 pm
Hi Johannes,

no there are no errormessages.
I'm not a php-pro, so i tried my best with the help of Mr. Google  ;)
I dumped the content of $filelist to a logfile (with var_dump), and the result was

array(0) {
}

Regards
Sebastian
Title: Re: Download complete album als ZIP
Post by: Tatome on May 27, 2012, 09:40:35 pm
Hi Sebastian,

I'm not a php-pro, so i tried my best with the help of Mr. Google  ;)
Best way to learn it.  To be honest, I'm only messing around, too.

I dumped the content of $filelist to a logfile (with var_dump), and the result was
array(0) {
}
So, nothing found.  The thing is, that same code works fine on my side, but I haven't updated Coppermine.

Come to think of it: one thing you could also check is whether the variable $aid is set correctly.  What does it say if you dump that one?

You could also dump the SQL statement and debug directly on the database.

Cheers,
Johannes
Title: Re: Download complete album als ZIP
Post by: sebbo_ on May 28, 2012, 08:56:26 am
Hi Johannes,

i checked $aid and whatever album i try, its value is always 1. I also checked the content of cpg15x_albums and there is no album with aid = 1. So i suppose $aid = $superCage->get->getInt('aid'); doesnt work anymore the way it used to.

Regards
Sebastian
Title: Re: Download complete album als ZIP
Post by: Αndré on May 29, 2012, 11:22:26 am
I'm attaching a patch (administrators --- could you apply this, please?).
Committed in SVN revision 8431.


i checked $aid and whatever album i try, its value is always 1
Please post a link to your gallery.
Title: Re: Download complete album als ZIP
Post by: Cainte on June 05, 2012, 04:38:28 pm
Hello,

I really tried to understand how to "install" this helpful plugin, but somehow I'm afraid to crash my gallery. I downloaded the files from your link André and I don't know where to place all the files, or which files just include the changes to make... sorry.

I'd be very grateful for some help...

Cainte
Title: Re: Download complete album als ZIP
Post by: Αndré on June 05, 2012, 05:02:26 pm
Create a new directory albumdownload inside the plugins directory in your Coppermine directory with your FTP client and download all files to that new directory. Then, install the plugin as described in the docs.
Title: Re: Download complete album als ZIP
Post by: Cainte on June 05, 2012, 05:09:08 pm
Thank you Andre. :-)
Title: Re: Download complete album als ZIP
Post by: Cainte on June 05, 2012, 08:06:24 pm
now I installed it succesfully and it works. Thx again Andre.

A new problem now is that no matter in which album I push the ZIP Button it's always the same Album that gets downloaded with the same filename. It's the album with id 1

When I go over the ZIP Button the link is wrong it shows  .../index.php?file=albumdownload/albumZip&aid=1
But the album id of this album is 22

cpg version is 1.5.20
Title: Re: Download complete album als ZIP
Post by: Αndré on June 06, 2012, 08:31:24 am
Please try the latest codebase.php file from the SVN repository (revision 8445).
Title: Re: Download complete album als ZIP
Post by: Cainte on June 06, 2012, 12:19:27 pm
Thx Andre. Now everything works fine!!
Title: Re: Download complete album als ZIP
Post by: tuxyso on June 08, 2012, 11:24:42 am
Great plugin, congratualations! It is exactly the plugin I have looking for a long time. But I think in the current implementation it breaks the access control policies of coppermine. At the moment there are basically 3 access levels:

I expected that albumZip.php sticks to these levels. Independently which access for an album is configured, the direct url
 
Code: [Select]
http://<mybaseurl>/index.php?file=albumdownload/albumZip&aid=<albumnr>
leads to a download of the complete album. Is there a future plan to prevent such an access? If not, albumZip is a serious security hole, because the album ids are predictable, starting with id 1 with an increment of 1.

At the current state one workaround might be an Apache .htaccess based on a special RegexMatch pattern. A special username and password is given to users who want to download complete zip files. For coppermine random album ids (e.g. hash values) could improve the situation. The best way, of course, would the consideration of security levels by the album download plugin.
Title: Re: Download complete album als ZIP
Post by: Αndré on June 08, 2012, 12:03:34 pm
Open albumZip.php, find
Code: [Select]
$query = "SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} AS pictures , (SELECT keyword FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '" . $aid . "' ) AS keyword WHERE pictures.aid = '" . $aid . "' OR ( keyword.keyword <> '' AND CONCAT(';', keywords, ';') LIKE CONCAT('%;', keyword.keyword, ';%'))";and replace with
Code: [Select]
get_meta_album_set(0);
$query = "SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} AS pictures , (SELECT keyword FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '" . $aid . "' ) AS keyword, {$CONFIG['TABLE_ALBUMS']} AS r $RESTRICTEDWHERE AND r.aid = pictures.aid AND (pictures.aid = '" . $aid . "' OR ( keyword.keyword <> '' AND CONCAT(';', keywords, ';') LIKE CONCAT('%;', keyword.keyword, ';%')))";

This will currently offer an empty zip file for albums with restricted access or invalid album IDs, which could of course be optimized. Please report if the code change works as expected for you.
Title: Re: Download complete album als ZIP
Post by: tuxyso on June 08, 2012, 12:11:46 pm
The code works for me in all cases:

Thanks for your fast reply.



Title: Re: Download complete album als ZIP
Post by: hiddenvalley390 on October 09, 2012, 10:36:45 pm
Thanks for the great plugin.

The plugin works fine when I download an album with not many pics in it but when I try to download an album with a large amount of files (100+) it just lists the filenames of the picutes.  I dont get any error and the zip isn't created.

Do you have any ideas on how to try and get this working for albums with a large amount of pics?
Title: Re: Download complete album als ZIP
Post by: Αndré on October 10, 2012, 09:56:25 am
when I try to download an album with a large amount of files (100+) it just lists the filenames of the picutes.
I guess that's some kind of timeout issue. The display of the filenames seems to be a debugging leftover. Please try the latest revision of albumZip.php from our SVN repository (http://coppermine.svn.sourceforge.net/viewvc/coppermine/branches/cpg1.5.x/plugins/albumdownload/albumZip.php), it probably won't fix your issue but will give us some information at which step the script stops.


the zip isn't created.
Have you checked that manually by looking at the albums/edit/ directory?
Title: Re: Download complete album als ZIP
Post by: hiddenvalley390 on October 10, 2012, 03:20:26 pm
Have you checked that manually by looking at the albums/edit/ directory?

I have checked and there is no zip file located in albums/edit.

One of the albums takes a while but it then downloads a zip of 0 bytes. I have also got a few connection reset errors in chrome this morning when trying it. I have also gotten a no data received error once.
Title: Re: Download complete album als ZIP
Post by: Macelskie on December 03, 2012, 08:51:29 pm
Hello,
I love this Plug-In, it works very well.
But is there an option that the Zip file will be deleted after downloading it?
Because after many downloads my webspace will be full.

Thank you.
Title: Re: Download complete album als ZIP
Post by: Αndré on December 04, 2012, 10:48:00 am
Please check the latest SVN revision. I just added some code that will delete zip files that are older than 48 hours on each new zip file creation in revision 8517 (http://coppermine.svn.sourceforge.net/viewvc/coppermine/branches/cpg1.5.x/plugins/albumdownload/albumZip.php?r1=8517&r2=8516&pathrev=8517).
Title: Re: Download complete album als ZIP
Post by: Macelskie on December 04, 2012, 10:51:59 am
Thanks.
Is it possible to change a value that this files will be deleted after about 15 minutes?
Title: Re: Download complete album als ZIP
Post by: Αndré on December 04, 2012, 12:11:30 pm
Sure. Replace
Code: [Select]
2 * CPG_DAYwith
Code: [Select]
900but IMHO 15 minutes may be too short for slow connections.
Title: Re: Download complete album als ZIP
Post by: Rainakthx on January 31, 2013, 05:24:39 pm
Hi,

First I wanted to say THANK YOU for this plugin. It is amazing and exactly what I needed. I run a really large gallery where people are always wanting Zip downloads of the files we add and as I live in Australia my upload speed is almost in the minuses and it takes hours to upload one zip file to Mediafire.

I was able to get it working fine on one Gallery, however it the name it gives the zip is pictures-510a....etc. It would be great if the name given to the Zip file was the album name. Is there any chance you could tell me how to do this?

Thanks again!!

Raina
Title: Re: Download complete album as ZIP
Post by: Rainakthx on January 31, 2013, 06:36:47 pm
Sorry to double post - can't seem to edit my previous one. Is there a way to check how many times something has been downloaded? Some kind of log? Thanks!
Title: Re: Download complete album als ZIP
Post by: Αndré on February 01, 2013, 12:18:02 pm
the name it gives the zip is pictures-510a....etc. It would be great if the name given to the Zip file was the album name. Is there any chance you could tell me how to do this?

Open zip.php, find
Code: [Select]
$filename = 'edit/pictures-' . uniqid(null) . '.zip';and replace it with something like
Code: [Select]
require_once('include/transliteration.inc.php');
$filename = 'edit/' . preg_replace('/[^0-9a-zA-Z]/', '_', transliteration_process(mysql_result(cpg_db_query("SELECT title FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = $aid"), 0))) . '.zip';

This will of course break:
code that will delete zip files that are older than 48 hours
as the file names doesn't match
Code: [Select]
/^pictures-[0-9a-f]+.zip$/
This could be fixed if you decide to add a static prefix like
Code: [Select]
pictures-to each file.
Title: Re: Download complete album as ZIP
Post by: Αndré on February 01, 2013, 12:20:35 pm
Is there a way to check how many times something has been downloaded? Some kind of log?

That feature currently doesn't exist, but it could be added easily by adding a simple query to zip.php. You either need to add a new table to the database or add a new column to the albums table. In each case you need to create an interface which displays the stats for you if you don't want to do that directly in PHPMyAdmin or a similar tool.
Title: Re: Download complete album als ZIP
Post by: Rainakthx on February 02, 2013, 09:25:34 am
Thanks for the answers! I'll leave it as is.

Could you please tell me where the zip downloads are stored?

In the past 24 hours they've taken up 100GB's of space so I want to delete them. I've altered the albumZip.php to delete the files after 15 minutes now (as per your post).
Title: Re: Download complete album als ZIP
Post by: Αndré on February 02, 2013, 07:08:44 pm
They're stored in albums/edit/.
Title: Re: Download complete album als ZIP
Post by: Rainakthx on February 06, 2013, 08:09:07 am
Thanks again. Another issue I've encountered:

Fatal error: Maximum execution time of 30 seconds exceeded in /home/username/site/movies-2/include/archive.php on line 651

Anyway to fix this?
Title: Re: Re: Download complete album als ZIP
Post by: Αndré on February 06, 2013, 09:46:19 am
It should also be possible to distribute the zip file creation to bypass the execution limit, e.g. just add 5 files at a time to the archive and then start the script from the beginning.
Alternatively you have to increase the max_execution_time limit.

How much files did you try to archive and what's the archive's expected file size?
Title: Re: Download complete album als ZIP
Post by: Rainakthx on February 06, 2013, 11:35:48 am
8,474 files. A lot, I know. It seems to be able to handle up to around 5,000.

I'm sorry, would you mind explaining how to increase the max_execution_time limit? I tried searching that phrase in both AlbumZip.php and archive.php but couldn't locate it.

Thank you, I'd really like to be able to offer this zip feature for large sized albums. My site is on its own dedicated box so there is no issues with bandwidth and my hdd space is fine.
Title: Re: Download complete album als ZIP
Post by: Αndré on February 06, 2013, 11:39:12 am
It's a PHP setting (http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time).
Title: Re: Download complete album als ZIP
Post by: Rainakthx on February 06, 2013, 11:53:56 am
Thank you! Found it and was about to post to ignore my last message. Thanks again!
Title: Re: Download complete album als ZIP
Post by: faticod on March 20, 2013, 03:56:05 am
Hi

Really thank you for this great JOB i installed the last revision  , but i try to change the access.. how i can block the guest download?


regards!
Title: Re: Download complete album als ZIP
Post by: faticod on March 21, 2013, 06:12:24 am
Hi

Really thank you for this great JOB i installed the last revision  , but i try to change the access.. how i can block the guest download?


regards!

Ready i found the solution :

albumZIP.php

search:

Code: [Select]
include('include/archive.php');
add after :

Code: [Select]
include('include/archive.php');

if (!USER_ID && ($CONFIG['allow_unlogged_access'] <= 1)) {

    $redirect = 'login.php';

    if ($matches = $superCage->server->getMatched('QUERY_STRING', '/^[a-zA-Z0-9&=_\/.-]+$/')) {
        $redirect .= '?force_login=1&referer='.urlencode('index.php?cat=0'.$matches[0]);
    }

    header("Location: $redirect");
    exit();
}

You need ENABLE OPTION :

ADMIN->CONFIG->USER SETTINGS ->

Allow unlogged users (guest or anonymous) access -> Yes: thumbnail only


NOW THE GUEST CANN'T DOWNLOAD ALBUMS NEED REGISTER


Best Regards  ::)
Title: Re: Download complete album als ZIP
Post by: Αndré on March 21, 2013, 10:34:35 am
It seems that you're using an outdated plugin version, as the file albumZIP.php doesn't exist in the latest version.
Title: Re: Download complete album als ZIP
Post by: philg_27 on March 22, 2013, 02:48:46 pm
Where is the latest version please? - I can only fnd this one:

http://coppermine.svn.sourceforge.net/viewvc/coppermine/branches/cpg1.5.x/plugins/albumdownload/

which still seems to have the albumZip.php file

Thanks
Title: Re: Download complete album als ZIP
Post by: Αndré on March 22, 2013, 02:54:05 pm
Unfortunately SourceForge migrated our SVN repository to a new platform, so the links points to the outdated repository. Even worse the new web frontend doesn't provide the option to download tarballs. I just added a plugin package to the plugin announcement thread.
Title: Re: Download complete album als ZIP
Post by: philg_27 on March 22, 2013, 04:43:26 pm
Hi - thanks for the quick response. I'm probably being obtuse but I'm still having trouble finding it. Any chance you could post a link to it?
Many thanks
Title: Re: Download complete album als ZIP
Post by: Αndré on March 22, 2013, 04:55:22 pm
At the bottom of this post: http://forum.coppermine-gallery.net/index.php/topic,74257.0.html
Title: Re: Download complete album als ZIP
Post by: philg_27 on March 23, 2013, 03:51:18 pm
Hello,

I uninstalled and removed the old version and installed your newer one and it works great - thanks. What I can't manage at the moment though is to get it to disallow unlogged-in guests to download the full size image zipfile. I tried modifying the zip.php file as suggested further back by "faticod" for the earlier albumZip.php but that didn't have any effect - if I'm in the thumbnail view unlogged-in I can still download the full size image zipfile. What I'd like to try and achieve is for unlogged-in guests to be able to view the album thumbnails and intermediate images but not be able to download the full size zipfile. Do you have any suggestions how this might be achieved?

Many thanks
Title: Re: Download complete album als ZIP
Post by: phill104 on March 23, 2013, 09:22:25 pm
It would be possible to hide the zip button for unlogged users or even only to admin users but that would require a bit of modification to the code. Another option would to restrict the fullsize image to unlogged users completely using Andre's eccelent plugin - http://forum.coppermine-gallery.net/index.php/topic,74870.0.html
Title: Re: Download complete album als ZIP
Post by: philg_27 on March 24, 2013, 04:31:56 pm
Thanks - I'll give that a try
Title: Re: Re: Download complete album als ZIP
Post by: Αndré on March 25, 2013, 11:59:56 am
Andre's eccelent plugin
I haven't created that plugin, I just ported that plugin to cpg1.5.x ;)


To hide the button for guests, open codebase.php, find
Code: [Select]
if ($superCage->get->getInt('album') > 0) {and replace with
Code: [Select]
if (USER_ID && $superCage->get->getInt('album') > 0) {
open zip.php, find
Code: [Select]
<?phpand below, add
Code: [Select]
if (!USER_ID) {
    cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
}
Title: Re: Download complete album als ZIP
Post by: faticod on March 26, 2013, 05:03:07 am
Coppermine version 1.5.9
This my version from album zip download .. works fine for me i add other modifications and lines.

For block guest download REMEMBER ADMIN->CONFIG->USER SETTINGS ->

Allow unlogged users (guest or anonymous) access -> Yes: thumbnail only  <<--- select this and save

if not enable the plugin doesn't work.
Title: Re: Download complete album als ZIP
Post by: phill104 on March 26, 2013, 04:57:55 pm
Coppermine version 1.5.9

Please update to the latest release asap.
Title: Re: Re: Re: Download complete album als ZIP
Post by: philg_27 on March 26, 2013, 06:13:04 pm
I haven't created that plugin, I just ported that plugin to cpg1.5.x ;)


To hide the button for guests, open codebase.php, find
Code: [Select]
if ($superCage->get->getInt('album') > 0) {and replace with
Code: [Select]
if (USER_ID && $superCage->get->getInt('album') > 0) {
open zip.php, find
Code: [Select]
<?phpand below, add
Code: [Select]
if (!USER_ID) {
    cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
}

This works brillliantly, thanks Andre. Thanks also to the others for their suggestions.
Title: Re: Download complete album als ZIP
Post by: N2GetherNow on July 20, 2013, 09:16:02 pm
Hello there,
i've installed this plug-in but seem to not work. When i hit "zip" button it returns this error:
Quote
Critical error
There was an error while processing a database query
I'm running cpg 1.5.24 revision 8570 on Win7, Apache 1.3.7 (PHP v.4.3.2, MySQL v.3.23.49).
Favorites zip download works perfect. Ideas?:(
Title: Re: Download complete album als ZIP
Post by: N2GetherNow on July 20, 2013, 09:25:04 pm
I can't edit previous post so...
I found this in cpg database logs
Quote
    Юли 20, 2013 at 09:21 PM - While executing query 'SELECT filepath, filename FROM cpg_fairs_pictures AS pictures , (SELECT keyword FROM cpg_fairs_albums WHERE aid = '5' ) AS keyword, cpg_fairs_albums AS r WHERE (1) AND r.aid = pictures.aid AND (pictures.aid = '5' OR ( keyword.keyword <> '' AND CONCAT(';', keywords, ';') LIKE CONCAT('%;', keyword.keyword, ';%')))' in plugins\albumdownload\zip.php on line 28 the following error was encountered:
    You have an error in your SQL syntax near '(SELECT keyword FROM cpg_fairs_albums WHERE aid = '5' ) AS keyword, cpg_fairs_al' at line 1
Title: Re: Download complete album als ZIP
Post by: Αndré on August 19, 2013, 05:02:14 pm
Please enable debug mode and post the extended Coppermine error message (including file and line).
Title: Re: Download complete album als ZIP
Post by: Vorms on January 19, 2014, 05:16:56 pm
Hello,
to avoid a timeout in php, I modify the script:

function create_zip()
  {
    $files = 0;
    $offset = 0;
    $central = "";

    if (!empty ($this->options['sfx']))
      if ($fp = @fopen($this->options['sfx'], "rb"))
      {
        $temp = fread($fp, filesize($this->options['sfx']));
        fclose($fp);
        $this->add_data($temp);
        $offset += strlen($temp);
        unset ($temp);
      }
      else
        $this->error[] = "Could not open sfx module from {$this->options['sfx']}.";

    $pwd = getcwd();
    chdir($this->options['basedir']);

    foreach ($this->files as $current)
    {
      if ($current['name'] == $this->options['name'])
        continue;
        ......


just after the foreach add the following line:
 set_time_limit(60); // modified by Thierry

This line solve timeout problemes.

Thierry



Title: Re: Download complete album als ZIP
Post by: MarioLaul on February 02, 2014, 02:54:29 pm
i don't see zip logo anywhere. What can i wrong?
Title: Re: Download complete album als ZIP
Post by: Αndré on February 03, 2014, 12:40:31 pm
Please post a link to your gallery. Is the plugin still installed?
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on May 16, 2014, 06:39:00 pm
Hi!

Does anyone know how to change the file name  to take the name of the album?
thank you
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on June 09, 2014, 08:59:01 pm
Hello, if anybody is interested in my solution, i will put a very simple solution for my problem:  :)

Code: [Select]
//Add this query to discover the name(title) of the current album
$resultado = cpg_db_query("SELECT title, aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '" . $aid . "'" );
if (mysql_num_rows($resultado) > 0) {
$CURRENT_ALBUM_DATA = mysql_fetch_assoc($resultado);
}
mysql_free_result($resultado);
$album = $CURRENT_ALBUM_DATA['title'];
echo '<p>Creating zip file...</p>';
$filename = 'edit/' . $album . '.zip';
$zip = new zip_file($filename);
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on June 09, 2014, 09:01:03 pm
sorry, the above code must be set in the albumdownload/zip.php file.
Title: Re: Download complete album als ZIP
Post by: pols1337 on December 31, 2014, 06:05:48 am
Should we use the plugin from the first post, or from the SVN? 
Title: Re: Download complete album als ZIP
Post by: Αndré on December 31, 2014, 10:13:24 am
Feel free to check yourself which is the more recent version or if they differ at all.
Title: Re: Download complete album als ZIP
Post by: pols1337 on December 31, 2014, 08:49:10 pm
Feel free to check yourself which is the more recent version or if they differ at all.

The SVN respository shows v1.0, which is the same as the first post here.  However ... there have also been quite a lot of small updates and code tweaks in the six pages of forum posts here, and I'm wondering if any of that was ever updated into the original file. 

Title: Re: Download all the images included in every album in zip format
Post by: MarioLaul on January 09, 2015, 02:38:25 pm
Hi,

I installed that plugin, but i don't see download link logo.
Title: Re: Download complete album als ZIP
Post by: Αndré on January 09, 2015, 02:57:00 pm
Please post a link to your gallery.
Title: Re: Download complete album als ZIP
Post by: MarioLaul on January 09, 2015, 03:04:31 pm
http://rescue.nsc.ee
Title: Re: Download complete album als ZIP
Post by: Αndré on January 09, 2015, 05:04:49 pm
Please try if it works with a default theme, like curve or water_drop.
Title: Re: Download complete album als ZIP
Post by: fran86 on April 29, 2015, 04:45:53 am
This works beautifully! Thank you :) Question: Is there a way to make it only available for logged in/registered users only? Otherwise spam or guests may use this too much and crash my bandwidth.
Title: Re: Download complete album als ZIP
Post by: ron4mac on April 29, 2015, 05:01:58 pm
This works beautifully! Thank you :) Question: Is there a way to make it only available for logged in/registered users only? Otherwise spam or guests may use this too much and crash my bandwidth.

You can try making this change to the codebase.php file:
Code: [Select]
function downloadZip_header($html) {
    if (!USER_ID) return $html;  // add this line to inhibit use by guests
    $lang_plugin_albumdownload = albumdownload_language();
Title: Re: Re: Download complete album als ZIP
Post by: fran86 on April 29, 2015, 08:33:48 pm
You can try making this addition to the codebase.php file:
Code: [Select]
function downloadZip_header($html) {
    if (!USER_ID) return $html;  // add this line to inhibit use by guests
    $lang_plugin_albumdownload = albumdownload_language();

Where abouts do I add it? I just got an error when adding just before the ?> Thank you very much for the help!
Code: [Select]
Parse error: syntax error, unexpected end of file in /home/username/public_html/photos/plugins/albumdownload/codebase.php on line 24
Title: Re: Download complete album als ZIP
Post by: allvip on April 29, 2015, 10:30:45 pm
More simple:

Open codebase.php file, find:

Code: [Select]
function downloadZip_header($html) {

and bellow (under it) add:

Code: [Select]
    if (!USER_ID) return $html;  // add this line to inhibit use by guests

That what ron4mac was trying to say when he added the comment: "// add this line to inhibit use by guests". To add to the code just that line under: "function downloadZip_header($html) {" .

I test it and it works.
Title: Re: Download complete album als ZIP
Post by: fran86 on April 30, 2015, 01:52:45 pm
More simple:

Open codebase.php file, find:

Code: [Select]
function downloadZip_header($html) {

and bellow (under it) add:

Code: [Select]
    if (!USER_ID) return $html;  // add this line to inhibit use by guests

That what ron4mac was trying to say when he added the comment: "// add this line to inhibit use by guests". To add to the code just that line under: "function downloadZip_header($html) {" .

I test it and it works.

Thank you very much, works as you said. :) Sorry for not understanding the first time.
Title: Re: Download complete album als ZIP
Post by: nambroque on April 20, 2016, 10:50:17 pm
I have detected that this plugin does not work right with keyword based linked files.
When you download an album which "contains" linked files, some of them will be downloaded, but some other of them will not...  :-\
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on June 13, 2016, 12:08:19 pm
I have detected that this plugin does not work right with keyword based linked files.
When you download an album which "contains" linked files, some of them will be downloaded, but some other of them will not...  :-\

Hello,
Your problem is that the selection of photos that does is only to 1 album, you should take the following restriction and try again:

Code: [Select]
[u]File: albumdownload/zip.php[/u]
(Original, Line 27):
$query = "SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} AS pictures , (SELECT keyword FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '" . $aid . "' ) AS keyword, {$CONFIG['TABLE_ALBUMS']} AS r $RESTRICTEDWHERE AND r.aid = pictures.aid AND (pictures.aid = '" . $aid . "' OR ( keyword.keyword <> '' AND CONCAT(';', keywords, ';') LIKE CONCAT('%;', keyword.keyword, ';%')))";

(Modified, Line 27):
$query = "SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} AS pictures , (SELECT keyword FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '" . $aid . "' ) AS keyword, {$CONFIG['TABLE_ALBUMS']} AS r $RESTRICTEDWHERE AND (pictures.aid = '" . $aid . "' OR ( keyword.keyword <> '' AND CONCAT(';', keywords, ';') LIKE CONCAT('%;', keyword.keyword, ';%')))";




That selection restricts the images are in the selected album , bearing the same AID files the album . In your case to have images from different albums, you must remove that restriction not to equate the AID photo album with AID.[/font][/size]

[/font][/size]

[/font][/size]
Please feel free to contact me (in Spanish) if my response [/font][/size]has not been clear.
Title: Re: Download complete album als ZIP
Post by: nambroque on June 13, 2016, 01:01:07 pm
Thanks
I have changed the line 27 in zip.php as you say, and it didn't work
Please, may you try in my gallery and see what happens?

Thanks also for the offer of writing you, but I tried and it says I'm not allowed to send personal messages. (I don't know the reason)
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on June 13, 2016, 02:54:16 pm
Thanks
I have changed the line 27 in zip.php as you say, and it didn't work
Please, may you try in my gallery and see what happens?

Thanks also for the offer of writing you, but I tried and it says I'm not allowed to send personal messages. (I don't know the reason)

Ok, I can see your gallery. You use and "dynamic albums".
Can you try this query:
Code: [Select]
$query = "SELECT filepath,filename, (SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '" . $aid . "') FROM {$CONFIG['TABLE_PICTURES']}";
Or something similar, because you need to create the query link like a function search.
Search all images from table_pictures like AID (album identificator) as album_where_you_stay

Title: Re: Download complete album als ZIP
Post by: nambroque on June 13, 2016, 03:22:36 pm
Thanks
Changed... I have checked and it started downloading more than 800 Mb
So, it seems it selects too many files now  ::)
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on June 13, 2016, 03:29:59 pm
Thanks
Changed... I have checked and it started downloading more than 800 Mb
So, it seems it selects too many files now  ::)

Ok, this indicate that it works, but the query is selecting all photos because you don´t have a field that relationships both tables.

Try this code:
Code: [Select]
$query = "SELECT filepath,filename, (SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} as albums WHERE aid = '" . $aid . "') FROM {$CONFIG['TABLE_PICTURES']} as pictures and albums.aid = pictures.aid";
I'm trying to figure out the SQL statement but it is complicated without test directly on the bbdd.

Title: Re: Download complete album als ZIP
Post by: nambroque on June 13, 2016, 04:44:08 pm
No luck... when trying to download it says:
Critical error
There was an error while processing a database query

In case you want me to check/do anything in the database please let me know
Thank you very much
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on June 13, 2016, 05:38:05 pm
No luck... when trying to download it says:
Critical error
There was an error while processing a database query

In case you want me to check/do anything in the database please let me know
Thank you very much

Ok, I will try to reproduce your situation in my gallery and I found this query to this function, in my case its works, please try on your gallery.

Code: [Select]
SELECT pictures.aid,filepath,filename,keywords
FROM {$CONFIG['TABLE_PICTURES']} as pictures
LEFT JOIN {$CONFIG['TABLE_ALBUMS']} as albums ON pictures.aid=albums.aid
WHERE aid = '" . $aid . "'
AND pictures.keywords=albums.keyword
Title: Re: Download complete album als ZIP
Post by: nambroque on June 13, 2016, 05:54:23 pm
Now appears this:

Code: [Select]
Parse error: syntax error, unexpected T_STRING in /var/www/vhosts/ame-web.org/fotometeo/plugins/albumdownload/zip.php on line 27
In zip.php (lines 23 to 33) currently there is this:

Code: [Select]
echo '<p>Creating file list...</p>';
$filelist = array();
$aid = $superCage->get->getInt('aid');
get_meta_album_set(0);
SELECT pictures.aid,filepath,filename,keywords
FROM {$CONFIG['TABLE_PICTURES']} as pictures
LEFT JOIN {$CONFIG['TABLE_ALBUMS']} as albums ON pictures.aid=albums.aid
WHERE aid = '" . $aid . "'
AND pictures.keywords=albums.keyword
$result = cpg_db_query($query);
$rowset = cpg_db_fetch_rowset($result);

Thanks again
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on June 13, 2016, 05:59:21 pm
oh sorry, you need to put the query in the right sintax:

Code: [Select]
$query = "SELECT pictures.aid,filepath,filename,keywords
FROM {$CONFIG['TABLE_PICTURES']} as pictures
LEFT JOIN {$CONFIG['TABLE_ALBUMS']} as albums ON pictures.aid=albums.aid
WHERE aid = '" . $aid . "'
AND pictures.keywords=albums.keyword"
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on June 13, 2016, 06:24:18 pm
I can't know you implement the "meta albums" but this thread can help you to define the albums and looks more "oem" to solve the issue

http://forum.coppermine-gallery.net/index.php/topic,63706.40.html (http://forum.coppermine-gallery.net/index.php/topic,63706.40.html)
Title: Re: Download complete album als ZIP
Post by: nambroque on June 13, 2016, 09:14:43 pm
Currently (lines 23 to 33):

Code: [Select]
echo '<p>Creating file list...</p>';
$filelist = array();
$aid = $superCage->get->getInt('aid');
get_meta_album_set(0);
$query = "SELECT pictures.aid,filepath,filename,keywords
FROM {$CONFIG['TABLE_PICTURES']} as pictures
LEFT JOIN {$CONFIG['TABLE_ALBUMS']} as albums ON pictures.aid=albums.aid
WHERE aid = '" . $aid . "'
AND pictures.keywords=albums.keyword"
$result = cpg_db_query($query);
$rowset = cpg_db_fetch_rowset($result)

But doesn´t work...  :-[
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on June 14, 2016, 06:35:21 pm
Ok, simplify the code:

Code: [Select]
echo '<p>Creating file list...</p>';
$filelist = array();
$aid = $superCage->get->getInt('aid');
get_meta_album_set(0);
[b]$query = "SELECT pictures.aid,filepath,filename
FROM {$CONFIG['TABLE_PICTURES']} as pictures
LEFT JOIN {$CONFIG['TABLE_ALBUMS']} as albums ON pictures.aid=albums.aid
WHERE aid = '" . $aid . "'"[/b]
$result = cpg_db_query($query);
$rowset = cpg_db_fetch_rowset($result)

with this select, you select all pictures where the AID=AID album, and this is the unique identification number...
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on June 14, 2016, 06:36:42 pm
sorry, put name any of the albums that not download all the photos to see if it gives me a clue, thank you
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on June 14, 2016, 06:41:59 pm
Hello again,

in the code, you have the aid before the query, use it.
Try this simply query:

Code: [Select]
echo '<p>Creating file list...</p>';
$filelist = array();
$aid = $superCage->get->getInt('aid');
get_meta_album_set(0);
$query = "SELECT aid,filepath,filename FROM {$CONFIG['TABLE_PICTURES']} WHERE aid = '" . $aid . "'"
$result = cpg_db_query($query);
$rowset = cpg_db_fetch_rowset($result)
Title: Re: Download complete album als ZIP
Post by: alainlizotte on September 14, 2016, 11:26:34 pm
Would it be possible to add a cache feature ?

My albums are quite big and the process to build the file takes a long time.
I would like this delay to only happen once.

Thank you !


My Album:
http://www.lemordudurc.com/photos/
Title: Re: Download complete album als ZIP
Post by: bigdrago on September 25, 2017, 05:45:20 pm
I would also like a cache function.

Some of the albums is too big and cannot be downloaded due to resource scaling with my provider. The site locks down when it gets too heavy loaded :/
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on March 09, 2018, 12:34:58 am
Hi!

Please, żAnyone can update this plugin to CPG 1.6.3?
I can't make working well with this update code:

Thank you in advance!


Code: [Select]
<?php

if (!USER_ID) {
    
cpg_die(ERROR$lang_errors['access_denied'], __FILE____LINE__);
}

error_reporting(E_ALL);
ini_set('display_errors''1');

define('IN_COPPERMINE'true);
define('THUMBNAILS_PHP'true);
define('INDEX_PHP'true);

include(
'include/archive.php');

echo 
'<p>Deleting old zip files...</p>';
$dir $CONFIG['fullpath'].'edit/';

if (
$handle opendir($dir)) {
    while (
false !== ($entry readdir($handle))) {
        if (
preg_match('/^album_[0-9a-f]+.zip$/'$entry) && filemtime($dir.$entry) < time() - CPG_DAY) {
            
unlink($dir.$entry);
        }
    }
    
closedir($handle);
}

echo 
'<p>Creating file list...</p>';
$filelist = array();
$aid $superCage->get->getInt('aid');
get_meta_album_set(0);
$query "SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} AS pictures , (SELECT keyword FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '" $aid "' ) AS keyword, {$CONFIG['TABLE_ALBUMS']} AS r $RESTRICTEDWHERE AND r.aid = pictures.aid AND (pictures.aid = '" $aid "' OR ( keyword.keyword <> '' AND CONCAT(';', keywords, ';') LIKE CONCAT('%;', keyword.keyword, ';%')))";
$result cpg_db_query($query);
$rowset cpg_db_fetch_rowset($result);

foreach (
$rowset as $row) {
    
$fileentry $row['filepath'].$row['filename'];
    
$filelist[] = $fileentry;
}
$resultado cpg_db_query("SELECT title, aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '" $aid "'" );
if (
cpg_db_num_rows($resultado) > 0) {
$CURRENT_ALBUM_DATA cpg_db_fetch_assoc($resultado);
}
cpg_db_free_result($resultado);
$album $CURRENT_ALBUM_DATA['title'];

echo 
'<p>Creating zip file...</p>';
$filename 'edit/' $album '.zip';

$zip = new ZipArchive(); 
$zip->open$filenameZipArchive::CREATE ); 
$zip->addFromString$filelist$filelist );
$zip->close(); 

// Stream the file to the client 
header("Content-Type: application/zip"); 
header("Content-Length: " filesize($file)); 
header("Content-Disposition: attachment; filename=\"'$filename'\""); 
readfile($filename); 
unlink($filename);

echo 
'<p>Downloading...</p>';

ob_end_clean();

header('Location: ' $CONFIG['site_url'] . $CONFIG['fullpath'] . $filename);

?>
Title: Re: Download complete album als ZIP
Post by: ron4mac on March 09, 2018, 02:55:37 am
The original plugin works with CPG 1.6.03 without problem.

The only change in your file that I see could be an issue is using ZipArchive(). Your new PHP version (7) may not have the ZIpArchive extension enabled.
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on March 09, 2018, 01:53:33 pm
Thank you for the reply!

Before publishing my message yesterday I made sure that my flags are still correct, and PHP has enabled the ZIP extension in Cpanel.
I have also tried with PHP 7.0, 7.1 and 7.2 versions (cpanel flags.png)

As you can see in the image, the original plugin gives me this error (error.png)

So I went to review the documentation of the function:
http://php.net/manual/en/book.zip.php

And I see that there is the ZipArchive () method, which is what I've been testing. But it does not work either.
In any case, I have reinstalled the original plugin, but the same error of the first capture still comes out

Thanks in advance!
Title: Re: Download complete album als ZIP
Post by: ron4mac on March 09, 2018, 04:38:22 pm
It would seem that include/archive.php is not being included.

At the top of zip.php in the plugin, change:
Code: [Select]
include('include/archive.php');to:
Code: [Select]
require_once 'include/archive.php';
That may reveal more of the situation.
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on March 12, 2018, 10:49:06 am
It's true, I do not know where that file is or why it references but I do not have it on my server.

I have tried several solutions rereading the whole thread and searching the internet and nothing. I do not know why the plugin stopped working.

The new error with the require_once is:
Quote
Fatal error: require_once(): Failed opening required 'include/archive.php' (include_path='.:/opt/cpanel/ea-php70/root/usr/share/pear') in /xxxxxxx/plugins/albumdownload/zip.php on line 10

thanks in advance
Title: Re: Download complete album als ZIP
Post by: ron4mac on March 12, 2018, 01:10:43 pm
It would be easy for you to do a quick re-install.
http://forum.coppermine-gallery.net/index.php/topic,79013.msg383037.html#msg383037

I'm recommending that people use the bottom (red) choice for what to install to get all the latest changes.
Title: Re: Re: Download complete album als ZIP
Post by: FrA1l3 on March 12, 2018, 06:35:45 pm
It would be easy for you to do a quick re-install.
http://forum.coppermine-gallery.net/index.php/topic,79013.msg383037.html#msg383037

I'm recommending that people use the bottom (red) choice for what to install to get all the latest changes.

Thank you! Thank you! Thank you!  ;D ;D ;D ;D

It had not occurred to me to reinstall. I've done it as you said and now it works perfect again.
I owe you a beer (or two), best regards!!
Title: Re: Download complete album als ZIP
Post by: Johnfromhere on March 16, 2018, 04:37:14 pm
I have read all the posts in this thread but may have got lost! (Download complete album as a ZIP file)

Can you please tell me which version of the plugin to download and install.

Also - can it be limited to certain 'groups' of users (it would appear that it can?) and certain albums?

I am running cpg1.5.46.

Many thanks.

John.

Title: Re: Download complete album als ZIP
Post by: Johnfromhere on March 18, 2018, 11:19:35 pm
Please ignore my previous posting. I had another read,  installed it and it works great. 

Many thanks.

It would be nice if it wrote the details of which user downloaded which album to a log file (are we ever satisfied?  :))  ;D)

Cheers John.
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on March 19, 2018, 01:49:40 pm
Please ignore my previous posting. I had another read,  installed it and it works great. 

Many thanks.

It would be nice if it wrote the details of which user downloaded which album to a log file (are we ever satisfied?  :))  ;D)

Cheers John.

Hello John!
You can add a simple mod to the zip.php file to create your personal download's log.
I will try quickly this code and works perfect!

Code: [Select]
<?php
// FrA1l3 - Register DOWNLOADS
$file_name "././logs/access.log.php";
$message "ALBUM DOWNLOAD: The user '" USER_NAME "' has downloaded the album '$album'.";

 if(
$file fopen($file_name"a"))
    {
        
fwrite($filedate("d m Y H:m:s") . " " $message "\n");
        
fclose($file);
    } 
// END modification LOG
?>

To view the log simply go to  http://your_coppermine_url/viewlog.php (1.png)

Keep in mind that the modification is on my own modified version of the plugin, worth the redundancy.
That's why I use the variable $album again for the log file too.

regards!
Title: Re: Download complete album als ZIP
Post by: Johnfromhere on March 19, 2018, 07:02:47 pm
Thanks for that.

I modded zip.php and it works fine except that it doesn't give the name of the album which was downloaded.

I don't know much about php but I assume that the $album variable has not been given a value?

I should be most grateful if you could offer a fix.

Many thanks.

John.
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on March 19, 2018, 11:04:39 pm
Thanks for that.

I modded zip.php and it works fine except that it doesn't give the name of the album which was downloaded.

I don't know much about php but I assume that the $album variable has not been given a value?

I should be most grateful if you could offer a fix.

Many thanks.

John.

Good night John,
Here is the piece of code where I retrieve the name of the album and assign it to the variable, put this code before the previous one and everything works for you.
If you have any problems, tell me.

Code: [Select]
<?php
$result 
cpg_db_query("SELECT title, aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '" $aid "'" );
if (
cpg_db_num_rows($result) > 0) {
$CURRENT_ALBUM_DATA cpg_db_fetch_assoc($result);
}
cpg_db_free_result($result);
$album $CURRENT_ALBUM_DATA['title'];
?>


regards,
George
Title: Re: Download complete album als ZIP
Post by: Johnfromhere on March 20, 2018, 09:33:06 am
Many thanks, George.

I modded zip.php and tested it but the album name is still missing.

Just to check, here is are the lines I inserted at the beginning of zip.php:-
Code: [Select]
// FrA1l3 - Register DOWNLOADS
$result = cpg_db_query("SELECT title, aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '" . $aid . "'" );
if (cpg_db_num_rows($result) > 0) {
$CURRENT_ALBUM_DATA = cpg_db_fetch_assoc($result);
}
cpg_db_free_result($result);
$album = $CURRENT_ALBUM_DATA['title'];
$file_name = "././logs/access.log.php";
$message = "ALBUM DOWNLOAD: The user '" . USER_NAME . "' has downloaded the album '$album'.";

 if($file = fopen($file_name, "a"))
    {
        fwrite($file, date("d m Y H:m:s") . " " . $message . "\n");
        fclose($file);
    }
// END modification LOG

Cheers.

John.
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on March 20, 2018, 09:46:05 am
Hello @Johnfromhere!

I put the entire zip.php file, please backup first your file and copy all of this quote to the original file (replace all of the code)
It is working well on my server.

Code: [Select]
application/x-httpd-php zip.php ( PHP script, ASCII text, with very long lines )
<?php

if (!USER_ID) {
    
cpg_die(ERROR$lang_errors['access_denied'], __FILE____LINE__);
}

error_reporting(E_ALL);
ini_set('display_errors''1');

define('IN_COPPERMINE'true);
define('THUMBNAILS_PHP'true);
define('INDEX_PHP'true);

require_once 
'include/archive.php';

echo 
'<p>Deleting old zip files...</p>';
$dir $CONFIG['fullpath'].'edit/';
if (
$handle opendir($dir)) {
    while (
false !== ($entry readdir($handle))) {
//FrA1l3 - file name change
//if (preg_match('/^pictures-[0-9a-f]+.zip$/', $entry) && filemtime($dir.$entry) < time() - 2 * CPG_DAY) {
        
if (preg_match('/^album_[0-9a-f]+.zip$/'$entry) && filemtime($dir.$entry) < time() - CPG_DAY) {
            
unlink($dir.$entry);
        }
    }
    
closedir($handle);
}

echo 
'<p>Creating file list...</p>';
$filelist = array();
$aid $superCage->get->getInt('aid');
get_meta_album_set(0);
$query "SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} AS pictures , (SELECT keyword FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '" $aid "' ) AS keyword, {$CONFIG['TABLE_ALBUMS']} AS r $RESTRICTEDWHERE AND r.aid = pictures.aid AND (pictures.aid = '" $aid "' OR ( keyword.keyword <> '' AND CONCAT(';', keywords, ';') LIKE CONCAT('%;', keyword.keyword, ';%')))";
$result cpg_db_query($query);
$rowset cpg_db_fetch_rowset($result);

foreach (
$rowset as $row) {
    
$fileentry $row['filepath'].$row['filename'];
    
$filelist[] = $fileentry;
}

//FrA1l3 - query to search album name for filename
/*****************************************************/
$resultado cpg_db_query("SELECT title, aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '" $aid "'" );
if (
cpg_db_num_rows($resultado) > 0) {
$CURRENT_ALBUM_DATA cpg_db_fetch_assoc($resultado);
}
cpg_db_free_result($resultado);
$album $CURRENT_ALBUM_DATA['title'];
/*****************************************************/

echo '<p>Creating zip file...</p>';
//FrA1l3 - change filename to albumname
//$filename = 'edit/pictures-' . uniqid(null) . '.zip';
$filename 'edit/' $album '.zip';
$zip = new zip_file($filename);

$options = array(
    
'basedir'    => "./{$CONFIG['fullpath']}",
    
'recurse'    => 0,
    
'storepaths' => 0,
);

$zip->set_options($options);
$zip->add_files($filelist);
$zip->create_archive();

echo 
'<p>Downloading...</p>';

// FrA1l3 - Register DOWNLOADS
$file_name "././logs/access.log.php";
$message "ALBUM DOWNLOAD: The user '" USER_NAME "' has downloaded the album '$album'.";

 if(
$file fopen($file_name"a"))
    {
fwrite($filedate("d m Y H:m:s") . " " $message "\n");
        
fclose($file);
    } 
// END modification LOG
ob_end_clean();

header('Location: ' $CONFIG['site_url'] . $CONFIG['fullpath'] . $filename);

?>


best regards
Title: Re: Download complete album als ZIP
Post by: Johnfromhere on March 20, 2018, 03:03:49 pm
Many thanks, George.

There were several differences between your file and the one I had as zip.php.

I have now replaced it with your version and it works fine!

Many thanks.

John.
Title: Re: Download complete album als ZIP
Post by: JonPurpleHaze on March 27, 2020, 02:33:06 am
Hello, I had this plugin working with CPG 1.6.07, I just updated to 1.6.08 and it's not working anymore, I now receive this message, somewhat edited for site information:

Deleting old zip files...

Creating file list...

Creating zip file...

Fatal error: Uncaught Error: Call to undefined method zip_file::archive() in /home/cpg/include/archive.php:580 Stack trace: #0 /home/cpg/plugins/albumdownload/zip.php(38): zip_file->__construct('edit/pictures-5...') #1 /home/cpg/index.php(75): include_once('/home/...') #2 {main} thrown in /home/cpg/include/archive.php on line 580

Wondering if anyone has it working with 1.6.08, I might have edited some things based on suggestions in this thread to get it to work in 1.6.07 but I don't remember.
File check mentions that archive.php was changed since 1.6.07, here is line 580 and 581:

    $this->archive($name);
    $this->options['type'] = "zip";

Thank You
Title: Re: Download complete album als ZIP
Post by: ron4mac on March 27, 2020, 02:33:06 pm
Our apologies ...
User submitted changes were made that were apparently not fully tested.

Please replace include/archive.php with the attached (unzipped) file.

Corrected file will be in next release (1.6.09).
Title: Re: Download complete album als ZIP
Post by: JonPurpleHaze on March 28, 2020, 12:22:32 am
Our apologies ...
User submitted changes were made that were apparently not fully tested.

Please replace include/archive.php with the attached (unzipped) file.

Corrected file will be in next release (1.6.09).
It's working again on 1.6.08!
I must mention that I'm very surprised and impressed that I even received a response to my post which was over 2 years since the last one and about a plugin that was releases for cpg 1.5.

Thank You All!
Title: Re: Download complete album als ZIP
Post by: exekutive on February 02, 2021, 02:02:36 am
I'm getting an error when installing this from the plugin manager: " A valid form token could not be found. "
Am I doing something wrong?

Title: Re: Download complete album als ZIP
Post by: exekutive on February 02, 2021, 02:13:04 am
ok I made this change:
https://forum.coppermine-gallery.net/index.php/topic,74257.msg384726.html#msg384726

and then it installed propertly.
Title: Re: Download complete album als ZIP
Post by: skivik on April 15, 2021, 07:44:12 am
Good day. When I click download, only one file from the album is downloaded. Dont understand why.
Title: Re: Download complete album als ZIP
Post by: FrA1l3 on May 04, 2021, 03:50:40 pm
It is working like a charm in 1.6.12!  ;D

Thank you!