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') ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| 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? |
| Sponsored Links | ||
| ||
| |
| Thread Tools | |
| |
| ||||
| 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 |