Example #1
0
 function download($backup_id)
 {
     // or fetch()
     $list = $this->getAvailableList($this->course_id);
     if (!isset($list[$backup_id])) {
         // catch the error
         //debug('does not belong to us');
         exit;
     }
     $my_backup = $list[$backup_id];
     $file_name = $my_backup['file_name'];
     header('Content-Type: application/zip');
     header('Content-transfer-encoding: binary');
     header('Content-Disposition: attachment; filename="' . htmlspecialchars($file_name) . '"');
     header('Expires: 0');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Pragma: public');
     header('Content-Length: ' . $my_backup['file_size']);
     // see the note in get.php about the use of x-Sendfile
     ob_end_clean();
     header("Content-Encoding: none");
     header('x-Sendfile: ' . AT_BACKUP_DIR . $this->course_id . DIRECTORY_SEPARATOR . $my_backup['system_file_name'] . '.zip');
     header('x-Sendfile: ', TRUE);
     // if we get here then it didn't work
     readfile_in_chunks(AT_BACKUP_DIR . $this->course_id . DIRECTORY_SEPARATOR . $my_backup['system_file_name'] . '.zip');
     exit;
 }
Example #2
0
 /**
  * Outputs the file - sends headers to browser to force download
  * Only call this after calling close() - will return false if the zip wasn't close()d yet
  * @access	public
  * @see		get_size()		in include/classes/zipfile.class.php
  * @author  Joel Kronenberg
  */
 function send_file($file_name)
 {
     if (!$this->is_closed) {
         $this->close();
     }
     $file_name = str_replace(array('"', '<', '>', '|', '?', '*', ':', '/', '\\'), '', $file_name);
     header("Content-type: archive/zip");
     header("Content-disposition: attachment; filename={$file_name}.zip");
     readfile_in_chunks($this->zipfile_dir . $this->filename . '.zip');
     exit;
 }