diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-11-22 17:44:10 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-11-22 17:44:10 +0000 |
commit | 67cbb218cd89ac6be9d1d55ca3799080daac1f5a (patch) | |
tree | 9aabddaed61a0bda1e477cf44c69400d1590779f /modules | |
parent | d5ae71f551f0aebef1dbae518a116a1c86430ffb (diff) | |
download | ampache-67cbb218cd89ac6be9d1d55ca3799080daac1f5a.tar.gz ampache-67cbb218cd89ac6be9d1d55ca3799080daac1f5a.tar.bz2 ampache-67cbb218cd89ac6be9d1d55ca3799080daac1f5a.zip |
renamed xml-rpc acl to rpc, added default mime type of image/jpg and added config options for batch download to the fs, no garbage collection for non-completed downloads yet.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/archive/archive.lib.php | 71 |
1 files changed, 51 insertions, 20 deletions
diff --git a/modules/archive/archive.lib.php b/modules/archive/archive.lib.php index f6662c60..3e668a05 100644 --- a/modules/archive/archive.lib.php +++ b/modules/archive/archive.lib.php @@ -271,15 +271,14 @@ class archive return $files;
}
- function download_file()
- {
- if ($this->options['inmemory'] == 0)
- {
- $this->error[] = "Can only use download_file() if archive is in memory. Redirect to file otherwise, it is faster.";
- return;
- }
- switch ($this->options['type'])
- {
+ /**
+ * download_file
+ * Modified by COF
+ */
+ public function download_file() {
+
+ // Always send this header
+ switch ($this->options['type']) {
case "zip":
header("Content-Type: application/zip");
break;
@@ -291,18 +290,50 @@ class archive break;
case "tar":
header("Content-Type: application/x-tar");
+ } // end switch
+
+ if ($this->options['inmemory'] == 0) {
+
+ $full_arc_name = $this->options['basedir']."/".$this->options['name'];
+ if (file_exists($full_arc_name)) {
+ $fsize = filesize($full_arc_name);
+
+ //Send some headers which can be useful...
+ $header = "Content-Disposition: attachment; filename=\"";
+ $header .= strstr($this->options['name'], "/") ? substr($this->options['name'], strrpos($this->options['name'], "/") + 1) : $this->options['name'];
+ $header .= "\"";
+ header($header);
+ header("Content-Length: " . $fsize);
+ header("Content-Transfer-Encoding: binary");
+ header("Cache-Control: no-cache, must-revalidate, max-age=60");
+ header("Expires: Sat, 01 Jan 2000 12:00:00 GMT");
+
+ readfile($full_arc_name);
+
+ //Now delete tempory file
+ unlink($full_arc_name);
+ }
+ else {
+ debug_event('ERROR','Archive does not exist, unable to download','1');
+ return false;
+ }
+ return true;
}
- $header = "Content-Disposition: attachment; filename=\"";
- $header .= strstr($this->options['name'], "/") ? substr($this->options['name'], strrpos($this->options['name'], "/") + 1) : $this->options['name'];
- $header .= "\"";
- header($header);
- header("Content-Length: " . strlen($this->archive));
- header("Content-Transfer-Encoding: binary");
- header("Cache-Control: no-cache, must-revalidate, max-age=60");
- header("Expires: Sat, 01 Jan 2000 12:00:00 GMT");
- print($this->archive);
- }
-}
+ // else if we're doing this baby in memory
+ else {
+ $header = "Content-Disposition: attachment; filename=\"";
+ $header .= strstr($this->options['name'], "/") ? substr($this->options['name'], strrpos($this->options['name'], "/") + 1) : $this->options['name'];
+ $header .= "\"";
+ header($header);
+ header("Content-Length: " . strlen($this->archive));
+ header("Content-Transfer-Encoding: binary");
+ header("Cache-Control: no-cache, must-revalidate, max-age=60");
+ header("Expires: Sat, 01 Jan 2000 12:00:00 GMT");
+ print($this->archive);
+ }
+ } // download file
+
+} // end zip_file class
class tar_file extends archive
{
|