move the merging-code for location-/ sections to the end of all possible location-blocks; fixes #1193

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2013-04-16 07:57:58 +02:00
parent e29068f0d8
commit d51977af65

View File

@@ -422,18 +422,6 @@ class nginx
if ($this->_deactivated == false) {
$vhost_content.= $this->create_pathOptions($domain);
$vhost_content.= $this->composePhpOptions($domain, $ssl_vhost);
$l_regex1="/(location\ \/\ \{)(.*)(\})/smU";
$l_regex2="/(location\ \/\ \{.*\})/smU";
$replace_by="";
$replacements=preg_match_all($l_regex1,$vhost_content,$out);
if ($replacements>1){
foreach ($out[2] as $val) {
$replace_by.=$val."\n";
}
$vhost_content=preg_replace($l_regex2,"",$vhost_content,$replacements-1);
$vhost_content=preg_replace($l_regex2,"location / {"."\n\t\t". $replace_by ."\t}"."\n",$vhost_content);
}
if ($domain['specialsettings'] != "") {
$vhost_content.= $domain['specialsettings'] . "\n";
@@ -446,7 +434,19 @@ class nginx
if ($this->settings['system']['default_vhostconf'] != '') {
$vhost_content.= $this->settings['system']['default_vhostconf'] . "\n";
}
}
// merge duplicate / sections, #1193
$l_regex1="/(location\ \/\ \{)(.*)(\})/smU";
$l_regex2="/(location\ \/\ \{.*\})/smU";
$replace_by="";
$replacements=preg_match_all($l_regex1,$vhost_content,$out);
if ($replacements > 1) {
foreach ($out[2] as $val) {
$replace_by.=$val."\n";
}
$vhost_content=preg_replace($l_regex2, "", $vhost_content, $replacements-1);
$vhost_content=preg_replace($l_regex2, "location / {\n\t\t". $replace_by ."\t}\n", $vhost_content);
}
}
$vhost_content.= '}' . "\n\n";