Advanced search  

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

Pages: 1 ... 4 5 6 7 [8] 9   Go Down

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

0 Members and 2 Guests are viewing this topic.

FrA1l3

  • Translator
  • Coppermine regular visitor
  • **
  • Country: es
  • Offline Offline
  • Posts: 78
    • ACMSB
Re: Download complete album als ZIP
« Reply #140 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);

?>
Logged

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2026
Re: Download complete album als ZIP
« Reply #141 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.
Logged

FrA1l3

  • Translator
  • Coppermine regular visitor
  • **
  • Country: es
  • Offline Offline
  • Posts: 78
    • ACMSB
Re: Download complete album als ZIP
« Reply #142 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!
Logged

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2026
Re: Download complete album als ZIP
« Reply #143 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.
Logged

FrA1l3

  • Translator
  • Coppermine regular visitor
  • **
  • Country: es
  • Offline Offline
  • Posts: 78
    • ACMSB
Re: Download complete album als ZIP
« Reply #144 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
Logged

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2026
Re: Download complete album als ZIP
« Reply #145 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.
Logged

FrA1l3

  • Translator
  • Coppermine regular visitor
  • **
  • Country: es
  • Offline Offline
  • Posts: 78
    • ACMSB
Re: Re: Download complete album als ZIP
« Reply #146 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!!
Logged

Johnfromhere

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 77
Re: Download complete album als ZIP
« Reply #147 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.

Logged

Johnfromhere

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 77
Re: Download complete album als ZIP
« Reply #148 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.
Logged

FrA1l3

  • Translator
  • Coppermine regular visitor
  • **
  • Country: es
  • Offline Offline
  • Posts: 78
    • ACMSB
Re: Download complete album als ZIP
« Reply #149 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!
« Last Edit: March 19, 2018, 02:59:42 pm by FrA1l3 »
Logged

Johnfromhere

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 77
Re: Download complete album als ZIP
« Reply #150 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.
Logged

FrA1l3

  • Translator
  • Coppermine regular visitor
  • **
  • Country: es
  • Offline Offline
  • Posts: 78
    • ACMSB
Re: Download complete album als ZIP
« Reply #151 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
Logged

Johnfromhere

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 77
Re: Download complete album als ZIP
« Reply #152 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.
Logged

FrA1l3

  • Translator
  • Coppermine regular visitor
  • **
  • Country: es
  • Offline Offline
  • Posts: 78
    • ACMSB
Re: Download complete album als ZIP
« Reply #153 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
Logged

Johnfromhere

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 77
Re: Download complete album als ZIP
« Reply #154 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.
Logged

JonPurpleHaze

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
    • Pinball Nirvana
Re: Download complete album als ZIP
« Reply #155 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

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2026
Re: Download complete album als ZIP
« Reply #156 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).
« Last Edit: March 27, 2020, 09:36:41 pm by ron4mac »
Logged

JonPurpleHaze

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
    • Pinball Nirvana
Re: Download complete album als ZIP
« Reply #157 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!

exekutive

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Download complete album als ZIP
« Reply #158 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?

Logged

exekutive

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Download complete album als ZIP
« Reply #159 on: February 02, 2021, 02:13:04 am »

Logged
Pages: 1 ... 4 5 6 7 [8] 9   Go Up
 

Page created in 0.03 seconds with 19 queries.