summaryrefslogtreecommitdiff
path: root/download.inc
diff options
context:
space:
mode:
authorroot2014-04-10 10:33:04 +0530
committerroot2014-04-10 10:33:04 +0530
commit9f1f14fbf1c50179ff0f4f2aa0975616ed4044e6 (patch)
tree95b90612cda885fe86061cfe77e0ca191e995f2d /download.inc
parenta37654c53a9c2ccf4980f65f9398c23688f089bd (diff)
downloadscilab_textbook_companion-9f1f14fbf1c50179ff0f4f2aa0975616ed4044e6.tar.gz
scilab_textbook_companion-9f1f14fbf1c50179ff0f4f2aa0975616ed4044e6.tar.bz2
scilab_textbook_companion-9f1f14fbf1c50179ff0f4f2aa0975616ed4044e6.zip
major changes done, updating to github
Diffstat (limited to 'download.inc')
-rwxr-xr-xdownload.inc27
1 files changed, 22 insertions, 5 deletions
diff --git a/download.inc b/download.inc
index da597d2..68d7d68 100755
--- a/download.inc
+++ b/download.inc
@@ -24,6 +24,7 @@ function textbook_companion_download_dependency_file()
header('Content-Type: ' . $dependency_file_data->filemime);
header('Content-disposition: attachment; filename="' . $dependency_file_data->filename . '"');
header('Content-Length: ' . filesize($root_path . $dependency_file_data->filepath));
+ var_dump($root_path . $dependency_file_data->filepath); die;
readfile($root_path . $dependency_file_data->filepath);
}
@@ -174,11 +175,27 @@ function textbook_companion_download_book()
if ($zip_file_count > 0)
{
/* download zip file */
- header('Content-Type: application/zip');
- header('Content-disposition: attachment; filename="' . $book_data->book . '.zip"');
- header('Content-Length: ' . filesize($zip_filename));
- readfile($zip_filename);
- unlink($zip_filename);
+ global $user;
+ if($user->uid){
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="' . $book_data->book . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ ob_clean();
+ readfile($zip_filename);
+ unlink($zip_filename);
+ }else{
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="' . $book_data->book . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ header("Content-Transfer-Encoding: binary");
+ header('Expires: 0');
+ header('Pragma: no-cache');
+ ob_end_flush();
+ ob_clean();
+ flush();
+ readfile($zip_filename);
+ unlink($zip_filename);
+ }
} else {
drupal_set_message("There are no examples in this book to download", 'error');
drupal_goto('textbook_run');