celticweb Posted May 2, 2008 Posted May 2, 2008 Hi everyone I am 99% done with an online shop selling images. Eberything is set up and working, well almost. When doing a test run I cam across a fairly serious problem that I am not even sure is caused by OSCommece. I have some files ziped (and rarred, I have tried both. When customers click to buy and then pay and then get redirected to the page where they can download the file. Teh download link actually works and and the download seems to go through smoothly. Now here is the problem, when unzipping an un raring it says the files are empty or are corrupted. They certainly are not empty. One possible problem was the size of the files, some are over 300MB and I am testing that right now but if anyone else has got any suggestions then please let me know. I don't want to post the link as it is a site of a somewhat adult nature. Thanks in advance......
prafulkr Posted May 2, 2008 Posted May 2, 2008 Hi everyone I am 99% done with an online shop selling images. Eberything is set up and working, well almost. When doing a test run I cam across a fairly serious problem that I am not even sure is caused by OSCommece. I have some files ziped (and rarred, I have tried both. When customers click to buy and then pay and then get redirected to the page where they can download the file. Teh download link actually works and and the download seems to go through smoothly. Now here is the problem, when unzipping an un raring it says the files are empty or are corrupted. They certainly are not empty. One possible problem was the size of the files, some are over 300MB and I am testing that right now but if anyone else has got any suggestions then please let me know. I don't want to post the link as it is a site of a somewhat adult nature. Thanks in advance...... I think the main problem is in download link. please set it properly then the donloaded file will open or extracted. if download path maybe like this then files certainly works after download: header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"". "/home/archive/" . $fileName."\""); header("Content-length:".(string)(filesize($fileUri))); fpassthru($fp); When I was born, I was cryed and everyone around me was smiling. Live our life so at the end, I am the one who is smiling and everyone around me is crying.
celticweb Posted May 2, 2008 Author Posted May 2, 2008 I think the main problem is in download link. please set it properly then the donloaded file will open or extracted.if download path maybe like this then files certainly works after download: header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"". "/home/archive/" . $fileName."\""); header("Content-length:".(string)(filesize($fileUri))); fpassthru($fp); Thanks Is that in download or contribute.php Cheers
prafulkr Posted May 2, 2008 Posted May 2, 2008 Thanks Is that in download or contribute.php Cheers This will be in download page. when user clicks after redirection. will you able to post download.php page on this forum? So i can help you properly. When I was born, I was cryed and everyone around me was smiling. Live our life so at the end, I am the one who is smiling and everyone around me is crying.
celticweb Posted May 3, 2008 Author Posted May 3, 2008 This will be in download page. when user clicks after redirection. will you able to post download.php page on this forum? So i can help you properly. Thanks or your help!! Here is the download.php file <?php /* $Id: download.php,v 1.9 2003/02/13 03:01:48 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License Modified for VN2 Free Skin E by Kevin jeffery - www.vn2designs.com */ include('includes/application_top.php'); if (!tep_session_is_registered('customer_id')) die; // Check download.php was called with proper GET parameters if ((isset($HTTP_GET_VARS['order']) && !is_numeric($HTTP_GET_VARS['order'])) || (isset($HTTP_GET_VARS['id']) && !is_numeric($HTTP_GET_VARS['id'])) ) { die; } // Check that order_id, customer_id and filename match $downloads_query = tep_db_query("select date_format(o.date_purchased, '%Y-%m-%d') as date_purchased_day, opd.download_maxdays, opd.download_count, opd.download_maxdays, opd.orders_products_filename from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " opd where o.customers_id = '" . $customer_id . "' and o.orders_id = '" . (int)$HTTP_GET_VARS['order'] . "' and o.orders_id = op.orders_id and op.orders_products_id = opd.orders_products_id and opd.orders_products_download_id = '" . (int)$HTTP_GET_VARS['id'] . "' and opd.orders_products_filename != ''"); if (!tep_db_num_rows($downloads_query)) die; $downloads = tep_db_fetch_array($downloads_query); // MySQL 3.22 does not have INTERVAL list($dt_year, $dt_month, $dt_day) = explode('-', $downloads['date_purchased_day']); $download_timestamp = mktime(23, 59, 59, $dt_month, $dt_day + $downloads['download_maxdays'], $dt_year); // Die if time expired (maxdays = 0 means no time limit) if (($downloads['download_maxdays'] != 0) && ($download_timestamp <= time())) die; // Die if remaining count is <=0 if ($downloads['download_count'] <= 0) die; // Die if file is not there if (!file_exists(DIR_FS_DOWNLOAD . $downloads['orders_products_filename'])) die; // Now decrement counter tep_db_query("update " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " set download_count = download_count-1 where orders_products_download_id = '" . (int)$HTTP_GET_VARS['id'] . "'"); // Returns a random name, 16 to 20 characters long // There are more than 10^28 combinations // The directory is "hidden", i.e. starts with '.' function tep_random_name() { $letters = 'abcdefghijklmnopqrstuvwxyz'; $dirname = '.'; $length = floor(tep_rand(16,20)); for ($i = 1; $i <= $length; $i++) { $q = floor(tep_rand(1,26)); $dirname .= $letters[$q]; } return $dirname; } // Unlinks all subdirectories and files in $dir // Works only on one subdir level, will not recurse function tep_unlink_temp_dir($dir) { $h1 = opendir($dir); while ($subdir = readdir($h1)) { // Ignore non directories if (!is_dir($dir . $subdir)) continue; // Ignore . and .. and CVS if ($subdir == '.' || $subdir == '..' || $subdir == 'CVS') continue; // Loop and unlink files in subdirectory $h2 = opendir($dir . $subdir); while ($file = readdir($h2)) { if ($file == '.' || $file == '..') continue; @unlink($dir . $subdir . '/' . $file); } closedir($h2); @rmdir($dir . $subdir); } closedir($h1); } // Now send the file with header() magic 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=" . $downloads['orders_products_filename']); if (DOWNLOAD_BY_REDIRECT == 'true') { // This will work only on Unix/Linux hosts tep_unlink_temp_dir(DIR_FS_DOWNLOAD_PUBLIC); $tempdir = tep_random_name(); umask(0000); mkdir(DIR_FS_DOWNLOAD_PUBLIC . $tempdir, 0777); symlink(DIR_FS_DOWNLOAD . $downloads['orders_products_filename'], DIR_FS_DOWNLOAD_PUBLIC . $tempdir . '/' . $downloads['orders_products_filename']); tep_redirect(DIR_WS_DOWNLOAD_PUBLIC . $tempdir . '/' . $downloads['orders_products_filename']); } else { // This will work on all systems, but will need considerable resources // We could also loop with fread($fp, 4096) to save memory readfile(DIR_FS_DOWNLOAD . $downloads['orders_products_filename']); } ?>
prafulkr Posted May 3, 2008 Posted May 3, 2008 Thanks or your help!! Here is the download.php file <?php /* $Id: download.php,v 1.9 2003/02/13 03:01:48 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License Modified for VN2 Free Skin E by Kevin jeffery - www.vn2designs.com */ include('includes/application_top.php'); if (!tep_session_is_registered('customer_id')) die; // Check download.php was called with proper GET parameters if ((isset($HTTP_GET_VARS['order']) && !is_numeric($HTTP_GET_VARS['order'])) || (isset($HTTP_GET_VARS['id']) && !is_numeric($HTTP_GET_VARS['id'])) ) { die; } // Check that order_id, customer_id and filename match $downloads_query = tep_db_query("select date_format(o.date_purchased, '%Y-%m-%d') as date_purchased_day, opd.download_maxdays, opd.download_count, opd.download_maxdays, opd.orders_products_filename from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " opd where o.customers_id = '" . $customer_id . "' and o.orders_id = '" . (int)$HTTP_GET_VARS['order'] . "' and o.orders_id = op.orders_id and op.orders_products_id = opd.orders_products_id and opd.orders_products_download_id = '" . (int)$HTTP_GET_VARS['id'] . "' and opd.orders_products_filename != ''"); if (!tep_db_num_rows($downloads_query)) die; $downloads = tep_db_fetch_array($downloads_query); // MySQL 3.22 does not have INTERVAL list($dt_year, $dt_month, $dt_day) = explode('-', $downloads['date_purchased_day']); $download_timestamp = mktime(23, 59, 59, $dt_month, $dt_day + $downloads['download_maxdays'], $dt_year); // Die if time expired (maxdays = 0 means no time limit) if (($downloads['download_maxdays'] != 0) && ($download_timestamp <= time())) die; // Die if remaining count is <=0 if ($downloads['download_count'] <= 0) die; // Die if file is not there if (!file_exists(DIR_FS_DOWNLOAD . $downloads['orders_products_filename'])) die; // Now decrement counter tep_db_query("update " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " set download_count = download_count-1 where orders_products_download_id = '" . (int)$HTTP_GET_VARS['id'] . "'"); // Returns a random name, 16 to 20 characters long // There are more than 10^28 combinations // The directory is "hidden", i.e. starts with '.' function tep_random_name() { $letters = 'abcdefghijklmnopqrstuvwxyz'; $dirname = '.'; $length = floor(tep_rand(16,20)); for ($i = 1; $i <= $length; $i++) { $q = floor(tep_rand(1,26)); $dirname .= $letters[$q]; } return $dirname; } // Unlinks all subdirectories and files in $dir // Works only on one subdir level, will not recurse function tep_unlink_temp_dir($dir) { $h1 = opendir($dir); while ($subdir = readdir($h1)) { // Ignore non directories if (!is_dir($dir . $subdir)) continue; // Ignore . and .. and CVS if ($subdir == '.' || $subdir == '..' || $subdir == 'CVS') continue; // Loop and unlink files in subdirectory $h2 = opendir($dir . $subdir); while ($file = readdir($h2)) { if ($file == '.' || $file == '..') continue; @unlink($dir . $subdir . '/' . $file); } closedir($h2); @rmdir($dir . $subdir); } closedir($h1); } // Now send the file with header() magic 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=" . $downloads['orders_products_filename']); ?> 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=" /* Set here the full path of the file, means where file is located */. $downloads['orders_products_filename']); hey change red color then download will work. When I was born, I was cryed and everyone around me was smiling. Live our life so at the end, I am the one who is smiling and everyone around me is crying.
celticweb Posted May 3, 2008 Author Posted May 3, 2008 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=" /* Set here the full path of the file, means where file is located */. $downloads['orders_products_filename']); hey change red color then download will work. Great stuff thanks. I have two further questions (I really appreciate your help with this) 1. Is there inverted commas (i.e ") at one end of that statement or at both ends. 2. Do I need to edit this for each file for download or is it automatic after I set it up in Product Attributes Thanks again John
celticweb Posted May 5, 2008 Author Posted May 5, 2008 Actually didn't work!! It works fine on my system when downlading firefox. I have checked and the corrections you suggested are uploaded and on the server. When I tried to download on internet explorer it just said the files are empty, I kow that they are not. Some of the files are 300MB , do you think that this could be the problem? Thanks again
celticweb Posted May 6, 2008 Author Posted May 6, 2008 I am going to bump this one as the problem is getting fairly chronic at this stage. I will explain the problem fully here 1 I am selling digital downloads 2. The shop is set up for digital downloads and pay pal is activated and working fine. 3. When a customer chooses a product and pays for it they then get returned back to the checkout_success.php page where the download link is available 4. When the customer clicks on the download link the file is downloaded. (I have tried it with both zip and rar files) 5. After unzipping (or unraring the files open and says that there are no files present. The file structure is that there is a folder containing images and a seperate word and pdf files. they are not inside the image folder, they are inside the main folder. 6. Some customers say that when they go to my account is says that they have not made any purchases, I know that they have and they are accounted for on paypal. Any ideas what the problem might be. It is an adult site so I don't feel that ahppy posting the link in an open forum. Any ideas appreciated. Thanks
Recommended Posts
Archived
This topic is now archived and is closed to further replies.