Source for file www.classic.php

Documentation is available at www.classic.php

  1. <?php
  2. /**
  3. * @package    jelix-modules
  4. * @subpackage jelix
  5. * @author     Laurent Jouanneau
  6. * @copyright  2011-2012 Laurent Jouanneau
  7. * @licence    http://www.gnu.org/licenses/gpl.html GNU General Public Licence, see LICENCE file
  8. */
  9.  
  10. /**
  11.  * @package    jelix-modules
  12.  * @subpackage jelix
  13.  */
  14. class wwwCtrl extends jController {
  15.     
  16.     public function getfile() {
  17.         $module = $this->param('targetmodule');
  18.  
  19.         if (!jApp::isModuleEnabled($module) || jApp::config()->modules[$module.'.access'] < 2) {
  20.             throw new jException('jelix~errors.module.untrusted',$module);
  21.         }
  22.  
  23.         $rep = $this->getResponse('binary');
  24.         $rep->doDownload = false;
  25.         $dir = jApp::getModulePath($module).'www/';
  26.         $rep->fileName = realpath($dir.str_replace('..', '', $this->param('file')));
  27.  
  28.         if (!is_file($rep->fileName)) {
  29.             $rep = $this->getResponse('html', true);
  30.             $rep->bodyTpl = 'jelix~404.html';
  31.             $rep->setHttpStatus('404', 'Not Found');
  32.             return $rep;
  33.         }
  34.         $rep->mimeType = jFile::getMimeTypeFromFilename($rep->fileName);
  35.         return $rep;
  36.     }
  37. }

Documentation generated on Wed, 04 Jan 2017 22:59:35 +0100 by phpDocumentor 1.4.3