Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

downloads acting funny


lindsayanng

Recommended Posts

Posted

I have had nothing but frustration with the super download store.. first, the split page was NOT working at all.. NOW, when a customer goes to download a product that they purchased, when they click DOWNLOAD it brings them to this page:

http://bscphoto.com/catalog/download.php?order=44&id=38

 

which is BLANK!! I dont understand why this is happening? Thefile still gets downloaded, but i dont want my custoemrs to see a blank page!

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Posted

HA! HA!

:lol:

 

Oh.. I was just laughing at your "downloads acting funny".

:blush:

 

But seriously, look at the code in download.php (shown below)

 

The only thing it's coded to show are errors.

 

So if you don't see anything, that's good.

 

This probably won't help you much other than to let you know that download.php is working best when you don't see anything.

 

I have a feeling what's supposed to happen is on your pc the dialogue window is supposed to open asking what you want to do with the file (open or save).

 

At least that's what happens on a windows machine.

 

I don't know about your Mac-attack.

 

<?php
/*
 $Id: download.php 1739 2007-12-20 00:52:16Z hpdl $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2007 osCommerce

 Released under the GNU General Public License
*/

 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, " . TABLE_ORDERS_STATUS . " os 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 != '' and o.orders_status = os.orders_status_id and os.downloads_flag = '1' and os.language_id = '" . (int)$languages_id . "'");
 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']);
if (file_exists(DIR_FS_DOWNLOAD_PUBLIC . $tempdir . '/' . $downloads['orders_products_filename'])) {
  tep_redirect(tep_href_link(DIR_WS_DOWNLOAD_PUBLIC . $tempdir . '/' . $downloads['orders_products_filename']));
}
 }

// Fallback to readfile() delivery method. This will work on all systems, but will need considerable resources
 readfile(DIR_FS_DOWNLOAD . $downloads['orders_products_filename']);
?>

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

but the WEIRD thing is that it takes you AWAY from the checkout_sucess.php page and brings you to that download page, but you dont NEED to go there..

 

On the PC (and it SHOULD be on the mac too) that when you download a file from an online source, it asks you if you want to download and where to save it.. It IS do this on the PC through IE< but not on firefox.. On firefox - with my mac - it goes to that blank page. I mean, i GUESS i should be happy that it is actually downloading the file.. but.

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Posted

Well you have to go to download.php or you don't get the download.

 

Maybe change the link to open in a new window:

 

/catalog/includes/modules/downloads.php

 

Old code:

 

		echo '			<td class="main"><a href="' . tep_href_link(FILENAME_DOWNLOAD, 'order=' . $last_order . '&id=' . $downloads['orders_products_download_id']) . '">' . $downloads['products_name'] . '</a></td>' . "\n";

Link to open in new window:

 

		echo '			<td class="main"><a target="_blank" href="' . tep_href_link(FILENAME_DOWNLOAD, 'order=' . $last_order . '&id=' . $downloads['orders_products_download_id']) . '">' . $downloads['products_name'] . '</a></td>' . "\n";

(Added target="_blank" to the link)

 

Of course since you have the "Super Downlaod Store" this probably isn't the right place to change the code!

:lol:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

i didnt have to on my PC.. i have it so that the download button shows in checkout_success.php and if you click that button, you dont really LEAVE the page (or it SHOULD do something like the checkout_process where it goes through it but the customer doesnt see it..

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Posted

checkout_success.php is where /catalog/includes/modules/downloads.php get's "included".

 

I've never bought anything as a download, so I don't know how it's supposed to look or work.

 

The closest I've came is watching my daughter get 99 cent songs from walmart online.

 

My main purpose for even replying was just to let you know that download.php isn't supposed to display anything in the browser.

;)

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

OHHH ok. so it seems that its just getting "stuck" on the download.php file.> You have actually helped me A LOT more than you know!! thanks!

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...