Public Member Functions | |
downloadCustomOptionAction () |
Definition at line 35 of file DownloadController.php.
downloadCustomOptionAction | ( | ) |
Custom options downloader
Definition at line 41 of file DownloadController.php.
00042 { 00043 $quoteItemOptionId = $this->getRequest()->getParam('id'); 00044 $secretKey = $this->getRequest()->getParam('key'); 00045 $option = Mage::getModel('sales/quote_item_option')->load($quoteItemOptionId); 00046 00047 if ($option->getId()) { 00048 00049 try { 00050 $info = unserialize($option->getValue()); 00051 00052 if ($secretKey != $info['secret_key']) { 00053 throw new Exception(); 00054 } 00055 00056 $filePath = Mage::getBaseDir() . $info['order_path']; 00057 if (!is_file($filePath) || !is_readable($filePath)) { 00058 // try get file from quote 00059 $filePath = Mage::getBaseDir() . $info['quote_path']; 00060 if (!is_file($filePath) || !is_readable($filePath)) { 00061 throw new Exception(); 00062 } 00063 } 00064 00065 $this->getResponse() 00066 ->setHttpResponseCode(200) 00067 ->setHeader('Pragma', 'public', true) 00068 ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true) 00069 ->setHeader('Content-type', $info['type'], true) 00070 ->setHeader('Content-Length', $info['size']) 00071 ->setHeader('Content-Disposition', 'inline' . '; filename='.$info['title']); 00072 00073 $this->getResponse() 00074 ->clearBody(); 00075 $this->getResponse() 00076 ->sendHeaders(); 00077 00078 readfile($filePath); 00079 00080 } catch (Exception $e) { 00081 $this->_forward('noRoute'); 00082 } 00083 00084 } else { 00085 $this->_forward('noRoute'); 00086 } 00087 }