mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
Get web router ready for .htaccess removal
This commit is contained in:
parent
234bdbd46b
commit
947ad34153
@ -12,19 +12,39 @@ error_reporting(E_ALL | E_STRICT);
|
|||||||
|
|
||||||
if (array_key_exists('ICINGAWEB_CONFIGDIR', $_ENV)) {
|
if (array_key_exists('ICINGAWEB_CONFIGDIR', $_ENV)) {
|
||||||
$configDir = $_ENV['ICINGAWEB_CONFIGDIR'];
|
$configDir = $_ENV['ICINGAWEB_CONFIGDIR'];
|
||||||
|
} elseif (array_key_exists('ICINGAWEB_CONFIGDIR', $_SERVER)) {
|
||||||
|
$configDir = $_SERVER['ICINGAWEB_CONFIGDIR'];
|
||||||
} else {
|
} else {
|
||||||
$configDir = '/etc/icingaweb';
|
$configDir = '/etc/icingaweb';
|
||||||
}
|
}
|
||||||
|
|
||||||
$baseDir = $_SERVER['DOCUMENT_ROOT'];
|
if (isset($_SERVER['REQUEST_URI'])) {
|
||||||
$ruri = $_SERVER['REQUEST_URI'];
|
$ruri = $_SERVER['REQUEST_URI'];
|
||||||
$remove = dirname($_SERVER['PHP_SELF']);
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Workaround, PHPs internal Webserver seems to mess up SCRIPT_FILENAME
|
||||||
|
// as it prefixes it's absolute path with DOCUMENT_ROOT
|
||||||
|
if (preg_match('/^PHP .* Development Server/', $_SERVER['SERVER_SOFTWARE'])) {
|
||||||
|
$script = basename($_SERVER['SCRIPT_FILENAME']);
|
||||||
|
$_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME'] = '/' . $script;
|
||||||
|
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT']
|
||||||
|
. DIRECTORY_SEPARATOR
|
||||||
|
. $script;
|
||||||
|
}
|
||||||
|
|
||||||
|
$baseDir = $_SERVER['DOCUMENT_ROOT'];
|
||||||
|
$baseDir = dirname($_SERVER['SCRIPT_FILENAME']);
|
||||||
|
|
||||||
|
// Fix aliases
|
||||||
|
$remove = dirname($_SERVER['PHP_SELF']);
|
||||||
if (substr($ruri, 0, strlen($remove)) !== $remove) {
|
if (substr($ruri, 0, strlen($remove)) !== $remove) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ruri = ltrim(substr($ruri, strlen($remove)), '/');
|
$ruri = ltrim(substr($ruri, strlen($remove)), '/');
|
||||||
|
|
||||||
if (strpos($ruri, '?') === false) {
|
if (strpos($ruri, '?') === false) {
|
||||||
$params = '';
|
$params = '';
|
||||||
$path = $ruri;
|
$path = $ruri;
|
||||||
@ -32,28 +52,32 @@ if (strpos($ruri, '?') === false) {
|
|||||||
list($path, $params) = preg_split('/\?/', $ruri, 2);
|
list($path, $params) = preg_split('/\?/', $ruri, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
$pathParts = preg_split('~/~', $path);
|
$special = array(
|
||||||
if (count($pathParts) === 2 &&
|
'css/icinga.css',
|
||||||
($pathParts[0] === 'css' || $pathParts[0] === 'js')
|
'css/icinga.min.css',
|
||||||
) {
|
'js/icinga.dev.js',
|
||||||
|
'js/icinga.min.js'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (in_array($path, $special)) {
|
||||||
|
|
||||||
require_once __DIR__ . '/EmbeddedWeb.php';
|
require_once __DIR__ . '/EmbeddedWeb.php';
|
||||||
EmbeddedWeb::start($configDir);
|
EmbeddedWeb::start($configDir);
|
||||||
|
|
||||||
switch($pathParts[1]) {
|
switch($path) {
|
||||||
|
|
||||||
case 'icinga.css':
|
case 'css/icinga.css':
|
||||||
Stylesheet::send();
|
Stylesheet::send();
|
||||||
exit;
|
exit;
|
||||||
case 'icinga.min.css':
|
case 'css/icinga.min.css':
|
||||||
Stylesheet::sendMinified();
|
Stylesheet::sendMinified();
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
case 'icinga.dev.js':
|
case 'js/icinga.dev.js':
|
||||||
JavaScript::send();
|
JavaScript::send();
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
case 'icinga.min.js':
|
case 'js/icinga.min.js':
|
||||||
JavaScript::sendMinified();
|
JavaScript::sendMinified();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user