header("Pragma: public"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", FALSE); header("Cache-Control: max-age=1"); // stores for only 1 second, which helps allow SSL downloads to work more reliably in IE break; default: header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); break; } header("Content-Transfer-Encoding: binary"); // NOTE: Redirect usually will work only on Unix/Linux hosts since Windows hosts can't do symlinking in PHP versions older than 5.3.0 if (DOWNLOAD_BY_REDIRECT == 'true') { zen_unlink_temp_dir(DIR_FS_DOWNLOAD_PUBLIC); $tempdir = zen_random_name() . '-' . time(); umask(00); mkdir(DIR_FS_DOWNLOAD_PUBLIC . $tempdir, 0777); $download_link = str_replace(array('/', '\\'), '_', $browser_filename); $link_create_status = @symlink(DIR_FS_DOWNLOAD . $origin_filename, DIR_FS_DOWNLOAD_PUBLIC . $tempdir . '/' . $download_link); if ($link_create_status == true) { $zco_notifier->notify('NOTIFY_DOWNLOAD_VIA_SYMLINK___BEGINS', $download_link, $origin_filename, $tempdir); header("HTTP/1.1 303 See Other"); zen_redirect(DIR_WS_DOWNLOAD_PUBLIC . $tempdir . '/' . $download_link, 303); } } if (DOWNLOAD_BY_REDIRECT != 'true' or $link_create_status == false) { // not downloading by redirect; instead, we stream it to the browser. // This happens if the symlink couldn't happen, or if set as default in Admin if ((int) $downloadFilesize > 0) { header("Content-Length: " . (string) $downloadFilesize);
$browser_filename = substr($browser_filename, strrpos($browser_filename, '\\') + 1); } // Now send the file with header() magic // the "must-revalidate" and expiry times are used to prevent caching and fraudulent re-acquiring of files w/o redownloading. header("Expires: Mon, 26 Nov 1962 00:00:00 GMT"); header("Last-Modified: " . gmdate("D,d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); header("Content-Type: Application/octet-stream"); header("Content-disposition: attachment; filename=" . $browser_filename); header("Content-Transfer-Encoding: binary"); $zv_filesize = filesize(DIR_FS_DOWNLOAD . $origin_filename); if (DOWNLOAD_BY_REDIRECT == 'true') { // This will work only on Unix/Linux hosts zen_unlink_temp_dir(DIR_FS_DOWNLOAD_PUBLIC); $tempdir = zen_random_name(); umask(00); mkdir(DIR_FS_DOWNLOAD_PUBLIC . $tempdir, 0777); $download_link = str_replace(array('/', '\\'), '_', $browser_filename); $link_create_status = @symlink(DIR_FS_DOWNLOAD . $origin_filename, DIR_FS_DOWNLOAD_PUBLIC . $tempdir . '/' . $download_link); if ($link_create_status == true) { $zco_notifier->notify('NOTIFY_DOWNLOAD_VIA_SYMLINK___BEGINS'); header("HTTP/1.1 303 See Other"); zen_redirect(DIR_WS_DOWNLOAD_PUBLIC . $tempdir . '/' . $download_link); } } if (DOWNLOAD_BY_REDIRECT != 'true' or $link_create_status == false) { // not downloading by redirect; instead, we stream it to the browser. // This happens if the symlink couldn't happen, or if set as default in Admin header("Content-Length: " . (string) $zv_filesize); if (DOWNLOAD_IN_CHUNKS != 'true') {