osCommerce and osCMax shopping cart software forums

Shopping Cart Software

osCommerce with teeth!

 
 

download.php code questions

This is a discussion on download.php code questions within the osCMax v2 Customization/Mods forums, part of the osCMax v2.0 Forums category; I have two issues with the implementation of download-by-redirect. Here is the relevant code from download.php: if (DOWNLOAD_BY_REDIRECT == 'true') ...


Go Back   osCommerce and osCMax shopping cart software forums > osCMax v2.0 Forums > osCMax v2 Customization/Mods

Register FAQ Members List Calendar Mark Forums Read


Free community membership! Fast easy FREE membership
Closed Thread

 

LinkBack Thread Tools
  #1  
Old 11-01-2006, 12:03 PM
New Member
 
Join Date: Sep 2006
Posts: 21
Thanks: 3
Thanked 13 Times in 5 Posts
Rep Power: 0
brendanl79 will become famous soon enough
Default download.php code questions

I have two issues with the implementation of download-by-redirect. Here is the relevant code from download.php:

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']);
}

First:

Why the call to tep_unlink_temp_dir, which removes all hidden folders in DIR_FS_DOWNLOAD_PUBLIC (usually "pub")? The code here is supposed to handle ONE user's download request, but unlink_temp_dir wipes out ALL users' pending downloads, not to mention any other hidden directories that may have been placed in DIR_FS_DOWNLOAD_PUBLIC for other reasons.

Furthermore, if you don't sell any downloadable products for a month, or a year, the link for the last purchase before your drought is just going to sit there.

Some sort of automated cleanup of the generated symlinks is required, of course. But this seems like the wrong way to do it.

Second:

With respect to the use of umask(). Quoting from the PHP Manual:

Note: Avoid using this function in multithreaded webservers. It is better to change the file permissions with chmod() after creating the file. Using umask() can lead to unexpected behavior of concurrently running scripts and the webserver itself because they all use the same umask.

I assume that most servers running OSC/OSCMax shops are nowhere near heavily-trafficked enough for this to be an issue. But it seems straightforward to use chmod() instead of umask(), so why not do so?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Sponsored Links
Advertisement
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Product download count deducted when canceling download GeorgeW osCMax v2 Installation issues 1 11-06-2005 08:12 PM
Download questions rick osCMax v1.7 Discussion 0 12-27-2004 07:31 AM
Just a few QUESTIONS for You kellycog osCommerce 2.2 Modification Help 3 07-03-2004 11:45 AM
A Few Questions ckeeper osCommerce 2.2 Modification Help 0 07-01-2003 06:12 PM
Shipping Questions... Axe osCommerce 2.2 Modification Help 0 10-16-2002 12:55 PM


All times are GMT -8. The time now is 02:48 PM.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO
http://www.oscmax.com/forums/
Copyright 2008 osCMax