| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * @package Dolphin Core |
|---|
| 4 | * @copyright Copyright (c) BoonEx Pty Limited - http://www.boonex.com/ |
|---|
| 5 | * @license CC-BY - http://creativecommons.org/licenses/by/3.0/ |
|---|
| 6 | */ |
|---|
| 7 | |
|---|
| 8 | ob_start(); |
|---|
| 9 | |
|---|
| 10 | require_once('./inc/header.inc.php'); |
|---|
| 11 | |
|---|
| 12 | $sStorageObject = bx_process_input(bx_get('o')); |
|---|
| 13 | $sFile = bx_process_input(bx_get('f')); |
|---|
| 14 | $sToken = bx_process_input(bx_get('t')); |
|---|
| 15 | |
|---|
| 16 | bx_import('BxDolStorage'); |
|---|
| 17 | $oStorage = BxDolStorage::getObjectInstance($sStorageObject); |
|---|
| 18 | |
|---|
| 19 | if (!$oStorage || !method_exists($oStorage, 'download')) { |
|---|
| 20 | ob_end_clean(); |
|---|
| 21 | bx_storage_download_error_occured(); |
|---|
| 22 | exit; |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | $i = strrpos($sFile, '.'); |
|---|
| 26 | $sRemoteId = ($i !== false) ? substr($sFile, 0, $i) : $sFile; |
|---|
| 27 | if (!$sRemoteId) { |
|---|
| 28 | ob_end_clean(); |
|---|
| 29 | bx_storage_download_error_occured(); |
|---|
| 30 | exit; |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | ob_end_clean(); |
|---|
| 34 | |
|---|
| 35 | if (!$oStorage->download($sRemoteId, $sToken)) { |
|---|
| 36 | $iError = $oStorage->getErrorCode(); |
|---|
| 37 | switch ($iError) { |
|---|
| 38 | case BX_DOL_STORAGE_ERR_FILE_NOT_FOUND: |
|---|
| 39 | bx_storage_download_error_occured(); |
|---|
| 40 | exit; |
|---|
| 41 | case BX_DOL_STORAGE_ERR_PERMISSION_DENIED: |
|---|
| 42 | bx_storage_download_error_occured('displayAccessDenied'); |
|---|
| 43 | exit; |
|---|
| 44 | default: |
|---|
| 45 | bx_storage_download_error_occured('displayErrorOccured'); |
|---|
| 46 | exit; |
|---|
| 47 | } |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | function bx_storage_download_error_occured($sMethod = 'displayPageNotFound') { |
|---|
| 51 | require_once(BX_DIRECTORY_PATH_INC . "params.inc.php"); |
|---|
| 52 | require_once(BX_DIRECTORY_PATH_INC . "design.inc.php"); |
|---|
| 53 | |
|---|
| 54 | bx_import('BxDolLanguages'); |
|---|
| 55 | bx_import('BxDolTemplate'); |
|---|
| 56 | |
|---|
| 57 | $oTemplate = BxDolTemplate::getInstance(); |
|---|
| 58 | $oTemplate->$sMethod (); |
|---|
| 59 | } |
|---|
| 60 | |
|---|