Advanced search  

News:

cpg1.5.46 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter recently discovered vulnerabilities. It is important that all users who run version cpg1.5.44 or older update to this latest version as soon as possible.
[more]

Pages: [1] 2 3 4 5 ... 7   Go Down

Author Topic: Download complete album als ZIP  (Read 67518 times)

0 Members and 1 Guest are viewing this topic.

Finswimmer

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 14
Download complete album als ZIP
« 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.


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.
« Last Edit: March 21, 2013, 01:52:55 pm by Αndré »
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15369
Re: Download complete album als ZIP
« Reply #1 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.
« Last Edit: January 27, 2012, 11:57:43 am by Αndré »
Logged

Finswimmer

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 14
Re: Download complete album als ZIP
« Reply #2 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?)
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15369
Re: Download complete album als ZIP
« Reply #3 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.
Logged

fersauce

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 42
Re: Download complete album als ZIP
« Reply #4 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.
Logged

Finswimmer

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 14
Re: Download complete album als ZIP
« Reply #5 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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15369
Re: Download complete album als ZIP
« Reply #6 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.
Logged

fersauce

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 42
Re: Download complete album als ZIP
« Reply #7 on: January 26, 2012, 11:03:51 am »

Great!  it's OK

I love you!

thank you
Logged

Finswimmer

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 14
Re: Download complete album als ZIP
« Reply #8 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
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15369
Re: Download complete album als ZIP
« Reply #9 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.
Logged

Finswimmer

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 14
Re: Download complete album als ZIP
« Reply #10 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!
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15369
Re: Download complete album als ZIP
« Reply #11 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.
Logged

Finswimmer

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 14
Re: Download complete album als ZIP
« Reply #12 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

Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15369
Re: Download complete album als ZIP
« Reply #13 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');
Logged

Finswimmer

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 14
Re: Download complete album als ZIP
« Reply #14 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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15369
Re: Download complete album als ZIP
« Reply #15 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.
Logged

Finswimmer

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 14
Re: Download complete album als ZIP
« Reply #16 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*
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15369
Re: Download complete album als ZIP
« Reply #17 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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15369
Re: Download complete album als ZIP
« Reply #18 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.
Logged

pols1337

  • Coppermine frequent poster
  • ***
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 240
Re: Download complete album als ZIP
« Reply #19 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. 
Logged
Pages: [1] 2 3 4 5 ... 7   Go Up
 

Page created in 0.023 seconds with 21 queries.