No more need to set the SUBDIR in config, its getting extracted from the FRONTEND_BASE_PATH

This commit is contained in:
ohartl 2016-02-20 23:34:30 +01:00
parent 7dfaa0c22e
commit d3c56b815c
3 changed files with 30 additions and 24 deletions

View file

@ -215,25 +215,19 @@ WebMUM will then show a larger field for source addresses in the frontend and yo
### Paths
Define the URL of the web application, and it's subfolder:
The `FRONTEND_BASE_PATH` is the URL your WebMUM installation is accessible from outside, this also includes subfolders if you installed it in a subfolder for that specific domain.
```php
/*
* Frontend paths
*/
define("FRONTEND_BASE_PATH", "http://mydomain.tld/webmum/");
define("SUBDIR", "webmum/");
```
In the example above, WebMUM is located in a subfolder named "webmum/". If you don't want to use a subfolder, but install WebMUM directly into the domain root,
set the settings like this:
In the example above, WebMUM is located in a subfolder named "webmum/". If your WebMUM installation is directly accessible from a domain (has its own domain), then set the `FRONTEND_BASE_PATH` to something like this:
```php
define("FRONTEND_BASE_PATH", "http://webmum.mydomain.tld/");
define("SUBDIR", "");
```
### Admin e-mail address
Only users with one of the specified email addresses will have access to the administrator's dashboard and will be able to create, edit and delete users, domains and redirects.

View file

@ -57,7 +57,6 @@ define("DBC_ALIASES_DESTINATION", "destination");
*/
define("FRONTEND_BASE_PATH", "http://localhost/webmum/");
define("SUBDIR", "webmum/");
/*

View file

@ -93,25 +93,38 @@ function loadPageByRoute($url)
die('Page file "'.$file.'" could not be found');
}
/**
* @param bool $removeGetParameters
*
* @return string
*/
function getCurrentUrlPath($removeGetParameters = true)
{
$baseUrl = parse_url(FRONTEND_BASE_PATH);
$basePath = isset($baseUrl['path']) ? rtrim($baseUrl['path'], '/') : '';
$url = $_SERVER['REQUEST_URI'];
if($removeGetParameters) {
$url = preg_replace('/\?.*/', '', $url); // Trim GET Parameters
}
// Trim all leading slashes
$url = rtrim($url, '/');
if(!empty($basePath) && ($basePathPos = strpos($url, $basePath)) === 0){
$url = substr($url, strlen($basePath));
}
return $url;
}
/**
* @return string
*/
function preparedUrlForRouting()
{
$url = $_SERVER['REQUEST_URI'];
// Remove GET Parameters
$url = preg_replace('/\?.*/', '', $url);
// Remove prescending directory part e.g. webmum/ defined in SUBDIR
$url = preg_replace("#".SUBDIR."#", '', $url);
// Webserver should add trailing slash, but if there is no trailing slash for any reason, add one ;)
if(strrpos($url, '/') != strlen($url) - 1){
$url = $url.'/';
}
return $url;
return getCurrentUrlPath(true).'/';
}