mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-06-04 14:00:12 +02:00
Update Module img_ route to get image subfolders
This commit is contained in:
parent
2112d45c3c
commit
7386ae5ef5
@ -61,10 +61,17 @@ class StaticController extends ActionController
|
|||||||
$module = $this->_getParam('module_name');
|
$module = $this->_getParam('module_name');
|
||||||
// TODO: This is more than dangerous, must be fixed!!
|
// TODO: This is more than dangerous, must be fixed!!
|
||||||
$file = $this->_getParam('file');
|
$file = $this->_getParam('file');
|
||||||
|
|
||||||
$basedir = Icinga::app()->getModuleManager()->getModule($module)->getBaseDir();
|
$basedir = Icinga::app()->getModuleManager()->getModule($module)->getBaseDir();
|
||||||
|
|
||||||
$filePath = $basedir . '/public/img/' . $file;
|
$filePath = realpath($basedir . '/public/img/' . $file);
|
||||||
|
|
||||||
|
if (strpos($filePath, $basedir) === false) {
|
||||||
|
throw new ActionException(sprintf(
|
||||||
|
'%s does not exist',
|
||||||
|
$filePath
|
||||||
|
), 404);
|
||||||
|
}
|
||||||
|
|
||||||
if (! file_exists($filePath)) {
|
if (! file_exists($filePath)) {
|
||||||
throw new ActionException(sprintf(
|
throw new ActionException(sprintf(
|
||||||
'%s does not exist',
|
'%s does not exist',
|
||||||
|
@ -8,6 +8,7 @@ use Exception;
|
|||||||
use Zend_Config;
|
use Zend_Config;
|
||||||
use Zend_Controller_Router_Route_Abstract;
|
use Zend_Controller_Router_Route_Abstract;
|
||||||
use Zend_Controller_Router_Route as Route;
|
use Zend_Controller_Router_Route as Route;
|
||||||
|
use Zend_Controller_Router_Route_Regex as RegexRoute;
|
||||||
use Icinga\Application\ApplicationBootstrap;
|
use Icinga\Application\ApplicationBootstrap;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
@ -821,12 +822,15 @@ class Module
|
|||||||
);
|
);
|
||||||
$router->addRoute(
|
$router->addRoute(
|
||||||
$this->name . '_img',
|
$this->name . '_img',
|
||||||
new Route(
|
new RegexRoute(
|
||||||
'img/' . $this->name . '/:file',
|
'img/' . $this->name . '/(.+)',
|
||||||
array(
|
array(
|
||||||
'controller' => 'static',
|
'controller' => 'static',
|
||||||
'action' => 'img',
|
'action' => 'img',
|
||||||
'module_name' => $this->name
|
'module_name' => $this->name
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
1 => 'file'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user