00001 <?php
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once dirname(__FILE__) . '/../Action.php';
00026 require_once dirname(__FILE__) . '/../FileCache.php';
00027
00028
00029
00030
00041
00042 class FF_Action_Download extends FF_Action {
00043
00044
00051 function run()
00052 {
00053 $o_fileCache =& FF_FileCache::singleton();
00054 $a_parts = array();
00055 if (FF_Request::getParam('path', 'g', false)) {
00056 $a_parts['subdir'] = FF_Request::getParam('path', 'g');
00057 }
00058
00059 if (FF_Request::getParam('id', 'g', false)) {
00060 $a_parts['id'] = FF_Request::getParam('id', 'g');
00061 }
00062
00063 $a_parts['name'] = FF_Request::getParam('name', 'g');
00064
00065 if (!$o_fileCache->exists($a_parts, FF_Request::getParam('useApp', 'g', false))) {
00066 $this->o_output->setMessage(_('The specified file could not be found.'), FASTFRAME_ERROR_MESSAGE, true);
00067 $this->o_nextAction->setActionId(ACTION_PROBLEM);
00068 return $this->o_nextAction;
00069 }
00070
00071 $s_file = $o_fileCache->getPath($a_parts, FF_Request::getParam('useApp', 'g', false));
00072
00073 header('Pragma: public');
00074 header('Expires: 0');
00075 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
00076 if (!FF_Request::getParam('displayFile', 'g', false)) {
00077 header('Content-Type: application/force-download');
00078 header('Content-Disposition: attachment; filename="' . $a_parts['name'] . '"');
00079 header('Content-Description: File Transfer');
00080 }
00081 else {
00082 header('Content-Type: ' . $o_fileCache->getContentType($a_parts['name']));
00083 }
00084
00085 header('Accept-Ranges: bytes');
00086 header('Content-Length: ' . filesize($s_file));
00087 @readfile($s_file);
00088 exit;
00089 }
00090
00091
00092 }
00093 ?>