fix vhost(parts)-merging in nginx cron, fixes #669
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -250,7 +250,7 @@ class Nginx extends HttpConfigBase
|
|||||||
|
|
||||||
$aliases = "";
|
$aliases = "";
|
||||||
$froxlor_aliases = Settings::Get('system.froxloraliases');
|
$froxlor_aliases = Settings::Get('system.froxloraliases');
|
||||||
if (!empty($froxlor_aliases)) {
|
if (! empty($froxlor_aliases)) {
|
||||||
$froxlor_aliases = explode(",", $froxlor_aliases);
|
$froxlor_aliases = explode(",", $froxlor_aliases);
|
||||||
foreach ($froxlor_aliases as $falias) {
|
foreach ($froxlor_aliases as $falias) {
|
||||||
if (\Froxlor\Validate\Validate::validateDomain(trim($falias))) {
|
if (\Froxlor\Validate\Validate::validateDomain(trim($falias))) {
|
||||||
@@ -574,26 +574,38 @@ class Nginx extends HttpConfigBase
|
|||||||
return $vhost_content;
|
return $vhost_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function cleanVhostStruct($vhost = null)
|
||||||
|
{
|
||||||
|
// Remove windows linebreaks
|
||||||
|
$vhost = str_replace("\r", "\n", $vhost);
|
||||||
|
// Break blocks into lines
|
||||||
|
$vhost = str_replace(array(
|
||||||
|
"{",
|
||||||
|
"}"
|
||||||
|
), array(
|
||||||
|
" {\n",
|
||||||
|
"\n}"
|
||||||
|
), $vhost);
|
||||||
|
// Break into array items
|
||||||
|
$vhost = explode("\n", preg_replace('/[ \t]+/', ' ', trim(preg_replace('/\t+/', '', $vhost))));
|
||||||
|
// Remove empty lines
|
||||||
|
$vhost = array_filter($vhost, function ($a) {
|
||||||
|
return preg_match("#\S#", $a);
|
||||||
|
});
|
||||||
|
|
||||||
|
// remove unnecessary whitespaces
|
||||||
|
$vhost = array_map("trim", $vhost);
|
||||||
|
// re-number array keys
|
||||||
|
$vhost = array_values($vhost);
|
||||||
|
return $vhost;
|
||||||
|
}
|
||||||
|
|
||||||
protected function mergeVhostCustom($vhost_frx, $vhost_usr)
|
protected function mergeVhostCustom($vhost_frx, $vhost_usr)
|
||||||
{
|
{
|
||||||
// Clean froxlor defined settings
|
// Clean froxlor defined settings
|
||||||
$vhost_frx = explode("\n", preg_replace('/[ \t]+/', ' ', trim(preg_replace('/\t+/', '', $vhost_frx)))); // Break into array items
|
$vhost_frx = $this->cleanVhostStruct($vhost_frx);
|
||||||
$vhost_frx = array_map("trim", $vhost_frx); // remove unnecessary whitespaces
|
|
||||||
|
|
||||||
// Clean user defined settings
|
// Clean user defined settings
|
||||||
$vhost_usr = str_replace("\r", "\n", $vhost_usr); // Remove windows linebreaks
|
$vhost_usr = $this->cleanVhostStruct($vhost_usr);
|
||||||
$vhost_usr = str_replace(array(
|
|
||||||
"{ ",
|
|
||||||
" }"
|
|
||||||
), array(
|
|
||||||
"{\n",
|
|
||||||
"\n}"
|
|
||||||
), $vhost_usr); // Break blocks into lines
|
|
||||||
$vhost_usr = explode("\n", preg_replace('/[ \t]+/', ' ', trim(preg_replace('/\t+/', '', $vhost_usr)))); // Break into array items
|
|
||||||
// Remove empty lines
|
|
||||||
$vhost_usr = array_filter($vhost_usr, function ($a) {
|
|
||||||
return preg_match("#\S#", $a);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Cycle through the user defined settings
|
// Cycle through the user defined settings
|
||||||
$currentBlock = array();
|
$currentBlock = array();
|
||||||
|
|||||||
Reference in New Issue
Block a user