summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/ampache.cfg.php.dist11
-rw-r--r--lib/batch.lib.php3
-rw-r--r--modules/archive/archive.lib.php39
3 files changed, 34 insertions, 19 deletions
diff --git a/config/ampache.cfg.php.dist b/config/ampache.cfg.php.dist
index db13d68a..d791bfe9 100644
--- a/config/ampache.cfg.php.dist
+++ b/config/ampache.cfg.php.dist
@@ -158,9 +158,16 @@ require_session = "true"
; File Zip Path
; If File Zip Download is enabled this must be set to tell
-; Ampache which directory to save the file to
+; Ampache which directory to save the file to. Do not put a
+; trailing slash or this will not work.
; DEFAULT: false
-;file_zip_path= "false"
+;file_zip_path = "false"
+
+; File Zip Comment
+; This is an optional configuration option that adds a comment
+; to your zip files, this only applies if you've got allow_zip_downloads
+; DEFAULT: Ampache - Zip Batch Download
+;file_zip_comment = "Ampache - Zip Batch Download"
; This setting throttles a persons downloading to the specified
; bytes per second. This is not a 100% guaranteed function, and
diff --git a/lib/batch.lib.php b/lib/batch.lib.php
index ae919767..ce2cea1f 100644
--- a/lib/batch.lib.php
+++ b/lib/batch.lib.php
@@ -72,7 +72,8 @@ function send_zip( $name, $song_files ) {
'inmemory' => $in_memory, // create archive in memory
'basedir' => $basedir,
'storepaths' => 0, // only store file name, not full path
- 'level' => 0 // no compression
+ 'level' => 0, // no compression
+ 'comment' => Config::get('file_zip_comment')
);
$arc->set_options( $options );
diff --git a/modules/archive/archive.lib.php b/modules/archive/archive.lib.php
index 3e668a05..fa6d45d3 100644
--- a/modules/archive/archive.lib.php
+++ b/modules/archive/archive.lib.php
@@ -4,6 +4,7 @@
| By Devin Doucette
| Copyright (c) 2005 Devin Doucette
| Email: darksnoopy@shaw.ca
+ | Modification by CoF & Vollmer
+--------------------------------------------------
| Email bugs/suggestions to darksnoopy@shaw.ca
+--------------------------------------------------
@@ -12,10 +13,13 @@
| only if this copyright statement is not removed
+--------------------------------------------------*/
-class archive
-{
- function archive($name)
- {
+class archive {
+
+ /**
+ * constructor
+ * This function is the constructor for the arcive class
+ */
+ public function archive($name) {
$this->options = array (
'basedir' => ".",
'name' => $name,
@@ -35,10 +39,10 @@ class archive
$this->exclude = array ();
$this->storeonly = array ();
$this->error = array ();
- }
+ } // archive
+
+ public function set_options($options) {
- function set_options($options)
- {
foreach ($options as $key => $value)
$this->options[$key] = $value;
if (!empty ($this->options['basedir']))
@@ -59,27 +63,30 @@ class archive
$this->options['prepend'] = preg_replace("/\/+/", "/", $this->options['prepend']);
$this->options['prepend'] = preg_replace("/\/$/", "", $this->options['prepend']) . "/";
}
- }
- function create_archive()
- {
+ // Generate a tmpname
+ $this->options['tmpname'] = time() . '_' . session_id();
+
+ } // set_options
+
+ public function create_archive() {
$this->make_list();
if ($this->options['inmemory'] == 0)
{
$pwd = getcwd();
chdir($this->options['basedir']);
- if ($this->options['overwrite'] == 0 && file_exists($this->options['name'] . ($this->options['type'] == "gzip" || $this->options['type'] == "bzip" ? ".tmp" : "")))
+ if ($this->options['overwrite'] == 0 && file_exists($this->options['tmpname'] . ($this->options['type'] == "gzip" || $this->options['type'] == "bzip" ? ".tmp" : "")))
{
- $this->error[] = "File {$this->options['name']} already exists.";
+ $this->error[] = "File {$this->options['tmpname']} already exists.";
chdir($pwd);
return 0;
}
- else if ($this->archive = @fopen($this->options['name'] . ($this->options['type'] == "gzip" || $this->options['type'] == "bzip" ? ".tmp" : ""), "wb+"))
+ else if ($this->archive = @fopen($this->options['tmpname'] . ($this->options['type'] == "gzip" || $this->options['type'] == "bzip" ? ".tmp" : ""), "wb+"))
chdir($pwd);
else
{
- $this->error[] = "Could not open {$this->options['name']} for writing.";
+ $this->error[] = "Could not open {$this->options['tmpname']} for writing.";
chdir($pwd);
return 0;
}
@@ -132,7 +139,7 @@ class archive
{
fclose($this->archive);
if ($this->options['type'] == "gzip" || $this->options['type'] == "bzip")
- unlink($this->options['basedir'] . "/" . $this->options['name'] . ".tmp");
+ unlink($this->options['basedir'] . "/" . $this->options['tmpname'] . ".tmp");
}
return true;
@@ -294,7 +301,7 @@ class archive
if ($this->options['inmemory'] == 0) {
- $full_arc_name = $this->options['basedir']."/".$this->options['name'];
+ $full_arc_name = $this->options['basedir']."/".$this->options['tmpname'];
if (file_exists($full_arc_name)) {
$fsize = filesize($full_arc_name);