From 9f1f14fbf1c50179ff0f4f2aa0975616ed4044e6 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 10 Apr 2014 10:33:04 +0530 Subject: major changes done, updating to github --- download.inc | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'download.inc') 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'); -- cgit