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.
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() - 1 * 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($file, date("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