From 558b77994463b1ac39699b125f470e44b89905b2 Mon Sep 17 00:00:00 2001 From: Chris Vigelius Date: Mon, 6 Jul 2015 13:28:09 +0200 Subject: [PATCH 1/7] allow variables in special config --- .../jobs/cron_tasks.inc.http.10.apache.php | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/scripts/jobs/cron_tasks.inc.http.10.apache.php b/scripts/jobs/cron_tasks.inc.http.10.apache.php index 9d6887b9..0e26c48b 100644 --- a/scripts/jobs/cron_tasks.inc.http.10.apache.php +++ b/scripts/jobs/cron_tasks.inc.http.10.apache.php @@ -42,7 +42,7 @@ class apache { $this->logger = $logger; $this->debugHandler = $debugHandler; $this->idnaConvert = $idnaConvert; - + $this->templateVars = array(); } @@ -315,7 +315,7 @@ class apache { */ if ($row_ipsandports['specialsettings'] != '') { - $this->virtualhosts_data[$vhosts_filename] .= $row_ipsandports['specialsettings'] . "\n"; + $this->virtualhosts_data[$vhosts_filename] .= $this->processSpecialConfigTemplate($row_ipsandports['specialsettings']) . "\n"; } if ($row_ipsandports['ssl'] == '1' && Settings::Get('system.use_ssl') == '1') { @@ -629,6 +629,24 @@ class apache { return $vhost_filename; } + /** + * process special config as template, by substituting {VARIABLE} with the + * respective value. + * + * The following variables are known at the moment: + * + * {DOMAIN} - domain name + * {IP} - IP for this domain + * {PORT} - Port for the domain + * {CUSTOMER} - customer name + * {IS_SSL} - '1' if domain/ip is ssl, '' otherwise + * + * @param $template + * @return string + */ + protected function processSpecialConfigTemplate($template) { + return replace_variables($template, $this->templateVars); + } /** * We compose the virtualhost entry for one domain @@ -661,6 +679,13 @@ class apache { $_vhost_content = ''; while ($ipandport = $result_stmt->fetch(PDO::FETCH_ASSOC)) { + // set up template variables for specialconfig processing + $this->templateVars['DOMAIN'] = $domain['domain']; + $this->templateVars['CUSTOMER'] = $domain['loginname']; + $this->templateVars['IP'] = $ipandport['ip']; + $this->templateVars['PORT'] = $ipandport['port']; + $this->templateVars['IS_SSL'] = $domain['ssl']; + $ipport = ''; $domain['ip'] = $ipandport['ip']; $domain['port'] = $ipandport['port']; @@ -684,7 +709,7 @@ class apache { } if ($ipandport['default_vhostconf_domain'] != '') { - $_vhost_content .= $ipandport['default_vhostconf_domain'] . "\n"; + $_vhost_content .= $this->processSpecialConfigTemplate($ipandport['default_vhostconf_domain']) . "\n"; } $ipportlist .= $ipport; } @@ -794,7 +819,7 @@ class apache { $vhost_content .= $this->getLogfiles($domain); if ($domain['specialsettings'] != '') { - $vhost_content .= $domain['specialsettings'] . "\n"; + $vhost_content .= $this->processSpecialConfigTemplate($domain['specialsettings']) . "\n"; } if ($_vhost_content != '') { @@ -802,7 +827,7 @@ class apache { } if (Settings::Get('system.default_vhostconf') != '') { - $vhost_content .= Settings::Get('system.default_vhostconf') . "\n"; + $vhost_content .= $this->processSpecialConfigTemplate(Settings::Get('system.default_vhostconf')) . "\n"; } } From d9e0854bb773de366675511c2be1cedd70fe9c23 Mon Sep 17 00:00:00 2001 From: Chris Vigelius Date: Mon, 6 Jul 2015 13:45:10 +0200 Subject: [PATCH 2/7] add docroot --- scripts/jobs/cron_tasks.inc.http.10.apache.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/jobs/cron_tasks.inc.http.10.apache.php b/scripts/jobs/cron_tasks.inc.http.10.apache.php index 0e26c48b..d5a7ecd9 100644 --- a/scripts/jobs/cron_tasks.inc.http.10.apache.php +++ b/scripts/jobs/cron_tasks.inc.http.10.apache.php @@ -637,9 +637,10 @@ class apache { * * {DOMAIN} - domain name * {IP} - IP for this domain - * {PORT} - Port for the domain + * {PORT} - Port for this domain * {CUSTOMER} - customer name * {IS_SSL} - '1' if domain/ip is ssl, '' otherwise + * {DOCROOT} - document root for this domain * * @param $template * @return string @@ -685,6 +686,7 @@ class apache { $this->templateVars['IP'] = $ipandport['ip']; $this->templateVars['PORT'] = $ipandport['port']; $this->templateVars['IS_SSL'] = $domain['ssl']; + $this->templateVars['DOCROOT'] = $domain['documentroot']; $ipport = ''; $domain['ip'] = $ipandport['ip']; From de84419035155b3bdc9e8bdb81e0c75b0c998945 Mon Sep 17 00:00:00 2001 From: Chris Vigelius Date: Mon, 6 Jul 2015 14:15:01 +0200 Subject: [PATCH 3/7] add nginx and lighttpd support, refactor into common base class --- scripts/classes/class.HttpConfigBase.php | 38 +++++++++++++ .../jobs/cron_tasks.inc.http.10.apache.php | 53 +++++++------------ .../jobs/cron_tasks.inc.http.20.lighttpd.php | 25 +++++++-- scripts/jobs/cron_tasks.inc.http.30.nginx.php | 28 ++++++++-- 4 files changed, 100 insertions(+), 44 deletions(-) create mode 100644 scripts/classes/class.HttpConfigBase.php diff --git a/scripts/classes/class.HttpConfigBase.php b/scripts/classes/class.HttpConfigBase.php new file mode 100644 index 00000000..2e65e607 --- /dev/null +++ b/scripts/classes/class.HttpConfigBase.php @@ -0,0 +1,38 @@ + $domain['domain'], + 'CUSTOMER' => $domain['loginname'], + 'IP' => $ipandport['ip'], + 'PORT' => $ipandport['port'], + 'IS_SSL' => $domain['ssl'], + 'DOCROOT' => $domain['documentroot'] + ); + return replace_variables($template, $templateVars); + } + +} \ No newline at end of file diff --git a/scripts/jobs/cron_tasks.inc.http.10.apache.php b/scripts/jobs/cron_tasks.inc.http.10.apache.php index d5a7ecd9..3454f39d 100644 --- a/scripts/jobs/cron_tasks.inc.http.10.apache.php +++ b/scripts/jobs/cron_tasks.inc.http.10.apache.php @@ -17,7 +17,9 @@ * */ -class apache { +include('../classes/class.HttpConfigBase.php'); + +class apache extends HttpConfigBase { private $logger = false; private $debugHandler = false; private $idnaConvert = false; @@ -42,7 +44,6 @@ class apache { $this->logger = $logger; $this->debugHandler = $debugHandler; $this->idnaConvert = $idnaConvert; - $this->templateVars = array(); } @@ -315,7 +316,10 @@ class apache { */ if ($row_ipsandports['specialsettings'] != '') { - $this->virtualhosts_data[$vhosts_filename] .= $this->processSpecialConfigTemplate($row_ipsandports['specialsettings']) . "\n"; + $this->virtualhosts_data[$vhosts_filename] .= $this->processSpecialConfigTemplate( + $row_ipsandports['specialsettings'], + $row_ipsandports, + $domain) . "\n"; } if ($row_ipsandports['ssl'] == '1' && Settings::Get('system.use_ssl') == '1') { @@ -629,26 +633,6 @@ class apache { return $vhost_filename; } - /** - * process special config as template, by substituting {VARIABLE} with the - * respective value. - * - * The following variables are known at the moment: - * - * {DOMAIN} - domain name - * {IP} - IP for this domain - * {PORT} - Port for this domain - * {CUSTOMER} - customer name - * {IS_SSL} - '1' if domain/ip is ssl, '' otherwise - * {DOCROOT} - document root for this domain - * - * @param $template - * @return string - */ - protected function processSpecialConfigTemplate($template) { - return replace_variables($template, $this->templateVars); - } - /** * We compose the virtualhost entry for one domain */ @@ -680,14 +664,6 @@ class apache { $_vhost_content = ''; while ($ipandport = $result_stmt->fetch(PDO::FETCH_ASSOC)) { - // set up template variables for specialconfig processing - $this->templateVars['DOMAIN'] = $domain['domain']; - $this->templateVars['CUSTOMER'] = $domain['loginname']; - $this->templateVars['IP'] = $ipandport['ip']; - $this->templateVars['PORT'] = $ipandport['port']; - $this->templateVars['IS_SSL'] = $domain['ssl']; - $this->templateVars['DOCROOT'] = $domain['documentroot']; - $ipport = ''; $domain['ip'] = $ipandport['ip']; $domain['port'] = $ipandport['port']; @@ -711,7 +687,10 @@ class apache { } if ($ipandport['default_vhostconf_domain'] != '') { - $_vhost_content .= $this->processSpecialConfigTemplate($ipandport['default_vhostconf_domain']) . "\n"; + $_vhost_content .= $this->processSpecialConfigTemplate( + $ipandport['default_vhostconf_domain'], + $ipandport, + $domain) . "\n"; } $ipportlist .= $ipport; } @@ -821,7 +800,10 @@ class apache { $vhost_content .= $this->getLogfiles($domain); if ($domain['specialsettings'] != '') { - $vhost_content .= $this->processSpecialConfigTemplate($domain['specialsettings']) . "\n"; + $vhost_content .= $this->processSpecialConfigTemplate( + $domain['specialsettings'], + $ipandport, + $domain) . "\n"; } if ($_vhost_content != '') { @@ -829,7 +811,10 @@ class apache { } if (Settings::Get('system.default_vhostconf') != '') { - $vhost_content .= $this->processSpecialConfigTemplate(Settings::Get('system.default_vhostconf')) . "\n"; + $vhost_content .= $this->processSpecialConfigTemplate( + Settings::Get('system.default_vhostconf'), + $ipandport, + $domain) . "\n"; } } diff --git a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php index f1cf1038..5b5ff41a 100644 --- a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php +++ b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php @@ -18,7 +18,9 @@ * @TODO ssl-redirect to non-standard port */ -class lighttpd { +include('../classes/class.HttpConfigBase.php'); + +class lighttpd extends HttpConfigBase { private $logger = false; private $debugHandler = false; private $idnaConvert = false; @@ -145,7 +147,11 @@ class lighttpd { } if ($row_ipsandports['specialsettings'] != '') { - $this->lighttpd_data[$vhost_filename].= $row_ipsandports['specialsettings'] . "\n"; + $this->lighttpd_data[$vhost_filename].= $this->processSpecialConfigTemplate( + $row_ipsandports['specialsettings'], + $row_ipsandports, + $domain + ). "\n"; } $this->lighttpd_data[$vhost_filename].= '}' . "\n"; @@ -439,15 +445,24 @@ class lighttpd { $vhost_content.= $this->getSslSettings($domain, $ssl_vhost); if ($domain['specialsettings'] != "") { - $vhost_content.= $domain['specialsettings'] . "\n"; + $vhost_content.= $this->processSpecialConfigTemplate( + $domain['specialsettings'], + $ipandport, + $domain). "\n"; } if ($ipandport['default_vhostconf_domain'] != '') { - $vhost_content.= $ipandport['default_vhostconf_domain'] . "\n"; + $vhost_content.= $this->processSpecialConfigTemplate( + $ipandport['default_vhostconf_domain'], + $ipandport, + $domain) . "\n"; } if (Settings::Get('system.default_vhostconf') != '') { - $vhost_content.= Settings::Get('system.default_vhostconf') . "\n"; + $vhost_content.= $this->processSpecialConfigTemplate( + Settings::Get('system.default_vhostconf'), + $ipandport, + $domain). "\n"; } } $vhost_content.= $this->getLogFiles($domain); diff --git a/scripts/jobs/cron_tasks.inc.http.30.nginx.php b/scripts/jobs/cron_tasks.inc.http.30.nginx.php index 758e504a..44c59d70 100644 --- a/scripts/jobs/cron_tasks.inc.http.30.nginx.php +++ b/scripts/jobs/cron_tasks.inc.http.30.nginx.php @@ -15,7 +15,9 @@ * */ -class nginx { +include('../classes/class.HttpConfigBase.php'); + +class nginx extends HttpConfigBase { private $logger = false; private $debugHandler = false; private $idnaConvert = false; @@ -187,7 +189,12 @@ class nginx { $this->nginx_data[$vhost_filename] .= "\t".'}'."\n"; if ($row_ipsandports['specialsettings'] != '') { - $this->nginx_data[$vhost_filename].= $row_ipsandports['specialsettings'] . "\n"; + $this->nginx_data[$vhost_filename].= $this->processSpecialConfigTemplate( + $row_ipsandports['specialsettings'], + $row_ipsandports, + array('domain'=> Settings::Get('system.hostname'), + 'loginname' => Settings::Get('phpfpm.vhost_httpuser'), + 'documentroot'=> $mypath)). "\n"; } /** @@ -363,7 +370,10 @@ class nginx { } if ($ipandport['default_vhostconf_domain'] != '') { - $_vhost_content .= $ipandport['default_vhostconf_domain'] . "\n"; + $_vhost_content .= $this->processSpecialConfigTemplate( + $ipandport['default_vhostconf_domain'], + $ipandport, + $domain). "\n"; } $vhost_content.= "\t" . 'listen ' . $ipport . ($ssl_vhost == true ? ' ssl' : '') . ';' . "\n"; @@ -425,7 +435,11 @@ class nginx { $vhost_content.= isset($this->needed_htpasswds[$domain['id']]) ? $this->needed_htpasswds[$domain['id']] . "\n" : ''; if ($domain['specialsettings'] != "") { - $vhost_content = $this->mergeVhostCustom($vhost_content, $domain['specialsettings']); + $vhost_content = $this->mergeVhostCustom($vhost_content, $this->processSpecialConfigTemplate( + $domain['specialsettings'], + $ipandport, + $domain + )); } if ($_vhost_content != '') { @@ -433,7 +447,11 @@ class nginx { } if (Settings::Get('system.default_vhostconf') != '') { - $vhost_content = $this->mergeVhostCustom($vhost_content, Settings::Get('system.default_vhostconf')."\n"); + $vhost_content = $this->mergeVhostCustom($vhost_content, + $this->processSpecialConfigTemplate( + Settings::Get('system.default_vhostconf'), + $ipandport, + $domain)."\n"); } } } From c2d75c703026b39ccfab3155352d6e57a3d36668 Mon Sep 17 00:00:00 2001 From: Chris Vigelius Date: Mon, 6 Jul 2015 15:09:13 +0200 Subject: [PATCH 4/7] add description and normalize {IS_SSL} value --- lng/english.lng.php | 3 +++ lng/german.lng.php | 3 +++ scripts/classes/class.HttpConfigBase.php | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lng/english.lng.php b/lng/english.lng.php index 7904fc16..37ef01f8 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -1843,3 +1843,6 @@ $lng['admin']['configfiles']['commands'] = 'Commands: T $lng['admin']['configfiles']['files'] = 'Configfiles: This is an example of the contents of a configuration file. The commands before these textfields should open an editor with the target file. Just copy and paste the contents into the editor and save the file.

Please note: The MySQL-password has not been replaced for security reasons. Please replace "MYSQL_PASSWORD" on your own. If you forgot your MySQL-password you\'ll find it in "lib/userdata.inc.php"'; $lng['serversettings']['apache_itksupport']['title'] = 'Use modifications for Apache ITK-MPM'; $lng['serversettings']['apache_itksupport']['description'] = 'ATTENTION: use only if you acutally have apache itk-mpm enabled
otherwise your webserver will not be able to start'; +$lng['admin']['specialsettings_replacements'] = "You can use the following variables:
{DOMAIN}, {DOCROOT}, {CUSTOMER}, {IP}, {PORT}, {IS_SSL}
"; +$lng['serversettings']['default_vhostconf']['description'] = 'The content of this field will be included into this ip/port vHost container directly. '.$lng['admin']['specialsettings_replacements'].' Attention: The code won\'t be checked for any errors. If it contains errors, webserver might not start again!'; +$lng['serversettings']['default_vhostconf_domain']['description'] = 'The content of this field will be included into the domain vHost container directly. '.$lng['admin']['specialsettings_replacements'].' Attention: The code won\'t be checked for any errors. If it contains errors, webserver might not start again!'; \ No newline at end of file diff --git a/lng/german.lng.php b/lng/german.lng.php index bd5e8027..1f20f6e2 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -1570,3 +1570,6 @@ $lng['admin']['configfiles']['commands'] = 'Kommandos: $lng['admin']['configfiles']['files'] = 'Konfigurationsdateien: Dies ist der Inhalt einer Konfigurationsdatei. Der Befehl direkt vor dem Textfeld sollte einen Editor mit der Zeildatei öffnen. Der Inhalt kann nun einfach kopiert und in den Editor eingefügt und die Datei gespeichert werden.

Beachten Sie: Das MySQL-Passwort wurde aus Sicherheitsgründen nicht ersetzt. Bitte ersetzen Sie "MYSQL_PASSWORD" manuell durch das entsprechende Passwort. Falls Sie es vergessen haben sollten, finden Sie es in der Datei "lib/userdata.inc.php".'; $lng['serversettings']['apache_itksupport']['title'] = 'Anpassungen für Apache ITK-MPM verwenden'; $lng['serversettings']['apache_itksupport']['description'] = '
Achtung: Bitte nur verwenden, wenn wirklich Apache itk-mpm verwendet wird, ansonsten wird der Webserver nicht starten.
'; +$lng['admin']['specialsettings_replacements'] = "Die folgenden Variablen können verwendet werden:
{DOMAIN}, {DOCROOT}, {CUSTOMER}, {IP}, {PORT}, {IS_SSL}
"; +$lng['serversettings']['default_vhostconf']['description'] = 'Der Inhalt dieses Feldes wird direkt in den IP/Port-vHost-Container übernommen. '.$lng['admin']['specialsettings_replacements'].'
ACHTUNG: Der Code wird nicht auf Fehler geprüft. Etwaige Fehler werden also auch übernommen. Der Webserver könnte nicht mehr starten!'; +$lng['serversettings']['default_vhostconf_domain']['description'] = 'Der Inhalt dieses Feldes wird direkt in jeden Domain-vHost-Container übernommen. '. $lng['admin']['specialsettings_replacements'].'ACHTUNG: Der Code wird nicht auf Fehler geprüft. Etwaige Fehler werden also auch übernommen. Der Webserver könnte nicht mehr starten!'; diff --git a/scripts/classes/class.HttpConfigBase.php b/scripts/classes/class.HttpConfigBase.php index 2e65e607..a03001e4 100644 --- a/scripts/classes/class.HttpConfigBase.php +++ b/scripts/classes/class.HttpConfigBase.php @@ -17,7 +17,7 @@ class HttpConfigBase { * {IP} - IP for this domain * {PORT} - Port for this domain * {CUSTOMER} - customer name - * {IS_SSL} - '1' if domain/ip is ssl, '' otherwise + * {IS_SSL} - evaluates to 'ssl' if domain/ip is ssl, otherwise it is an empty string * {DOCROOT} - document root for this domain * * @param $template @@ -29,7 +29,7 @@ class HttpConfigBase { 'CUSTOMER' => $domain['loginname'], 'IP' => $ipandport['ip'], 'PORT' => $ipandport['port'], - 'IS_SSL' => $domain['ssl'], + 'IS_SSL' => ($domain['ssl'])?'ssl':'', 'DOCROOT' => $domain['documentroot'] ); return replace_variables($template, $templateVars); From ed9e524e039298f1d475641448aaf0e48b9b133a Mon Sep 17 00:00:00 2001 From: Chris Vigelius Date: Mon, 6 Jul 2015 17:09:49 +0200 Subject: [PATCH 5/7] use absolute path and require_once, instead of relative include --- scripts/jobs/cron_tasks.inc.http.10.apache.php | 2 +- scripts/jobs/cron_tasks.inc.http.20.lighttpd.php | 2 +- scripts/jobs/cron_tasks.inc.http.30.nginx.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/jobs/cron_tasks.inc.http.10.apache.php b/scripts/jobs/cron_tasks.inc.http.10.apache.php index 3454f39d..4cd96393 100644 --- a/scripts/jobs/cron_tasks.inc.http.10.apache.php +++ b/scripts/jobs/cron_tasks.inc.http.10.apache.php @@ -17,7 +17,7 @@ * */ -include('../classes/class.HttpConfigBase.php'); +require_once(dirname(__FILE__).'/../classes/class.HttpConfigBase.php'); class apache extends HttpConfigBase { private $logger = false; diff --git a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php index 5b5ff41a..b80b9614 100644 --- a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php +++ b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php @@ -18,7 +18,7 @@ * @TODO ssl-redirect to non-standard port */ -include('../classes/class.HttpConfigBase.php'); +require_once(dirname(__FILE__).'/../classes/class.HttpConfigBase.php'); class lighttpd extends HttpConfigBase { private $logger = false; diff --git a/scripts/jobs/cron_tasks.inc.http.30.nginx.php b/scripts/jobs/cron_tasks.inc.http.30.nginx.php index 44c59d70..853ec191 100644 --- a/scripts/jobs/cron_tasks.inc.http.30.nginx.php +++ b/scripts/jobs/cron_tasks.inc.http.30.nginx.php @@ -15,7 +15,7 @@ * */ -include('../classes/class.HttpConfigBase.php'); +require_once(dirname(__FILE__).'/classes/class.HttpConfigBase.php'); class nginx extends HttpConfigBase { private $logger = false; From 9dbc04678ccbbb029384a50bb88f0d0eb883c2f1 Mon Sep 17 00:00:00 2001 From: Chris Vigelius Date: Mon, 6 Jul 2015 17:16:49 +0200 Subject: [PATCH 6/7] correct path for nginx --- scripts/jobs/cron_tasks.inc.http.30.nginx.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/jobs/cron_tasks.inc.http.30.nginx.php b/scripts/jobs/cron_tasks.inc.http.30.nginx.php index 853ec191..a06067cd 100644 --- a/scripts/jobs/cron_tasks.inc.http.30.nginx.php +++ b/scripts/jobs/cron_tasks.inc.http.30.nginx.php @@ -15,7 +15,7 @@ * */ -require_once(dirname(__FILE__).'/classes/class.HttpConfigBase.php'); +require_once(dirname(__FILE__).'/../classes/class.HttpConfigBase.php'); class nginx extends HttpConfigBase { private $logger = false; From 89c4b969d1bd3a0d7d89886c827796fcf4277324 Mon Sep 17 00:00:00 2001 From: Chris Vigelius Date: Mon, 6 Jul 2015 21:21:07 +0200 Subject: [PATCH 7/7] make sure we fill all context parameters in any case --- scripts/classes/class.HttpConfigBase.php | 8 +++---- .../jobs/cron_tasks.inc.http.10.apache.php | 24 ++++++++++++------- .../jobs/cron_tasks.inc.http.20.lighttpd.php | 24 ++++++++++++------- scripts/jobs/cron_tasks.inc.http.30.nginx.php | 24 ++++++++++++------- 4 files changed, 52 insertions(+), 28 deletions(-) diff --git a/scripts/classes/class.HttpConfigBase.php b/scripts/classes/class.HttpConfigBase.php index a03001e4..fb91a098 100644 --- a/scripts/classes/class.HttpConfigBase.php +++ b/scripts/classes/class.HttpConfigBase.php @@ -23,13 +23,13 @@ class HttpConfigBase { * @param $template * @return string */ - protected function processSpecialConfigTemplate($template, $ipandport, $domain) { + protected function processSpecialConfigTemplate($template, $domain, $ip, $port, $is_ssl_vhost) { $templateVars = array( 'DOMAIN' => $domain['domain'], 'CUSTOMER' => $domain['loginname'], - 'IP' => $ipandport['ip'], - 'PORT' => $ipandport['port'], - 'IS_SSL' => ($domain['ssl'])?'ssl':'', + 'IP' => $ip, + 'PORT' => $port, + 'IS_SSL' => ($is_ssl_vhost)?'ssl':'', 'DOCROOT' => $domain['documentroot'] ); return replace_variables($template, $templateVars); diff --git a/scripts/jobs/cron_tasks.inc.http.10.apache.php b/scripts/jobs/cron_tasks.inc.http.10.apache.php index 4cd96393..08528b6c 100644 --- a/scripts/jobs/cron_tasks.inc.http.10.apache.php +++ b/scripts/jobs/cron_tasks.inc.http.10.apache.php @@ -318,8 +318,10 @@ class apache extends HttpConfigBase { if ($row_ipsandports['specialsettings'] != '') { $this->virtualhosts_data[$vhosts_filename] .= $this->processSpecialConfigTemplate( $row_ipsandports['specialsettings'], - $row_ipsandports, - $domain) . "\n"; + $domain, + $row_ipsandports['ip'], + $row_ipsandports['port'], + $row_ipsandports['ssl'] == '1') . "\n"; } if ($row_ipsandports['ssl'] == '1' && Settings::Get('system.use_ssl') == '1') { @@ -689,8 +691,10 @@ class apache extends HttpConfigBase { if ($ipandport['default_vhostconf_domain'] != '') { $_vhost_content .= $this->processSpecialConfigTemplate( $ipandport['default_vhostconf_domain'], - $ipandport, - $domain) . "\n"; + $domain, + $domain['ip'], + $domain['port'], + $ssl_vhost) . "\n"; } $ipportlist .= $ipport; } @@ -802,8 +806,10 @@ class apache extends HttpConfigBase { if ($domain['specialsettings'] != '') { $vhost_content .= $this->processSpecialConfigTemplate( $domain['specialsettings'], - $ipandport, - $domain) . "\n"; + $domain, + $domain['ip'], + $domain['port'], + $ssl_vhost) . "\n"; } if ($_vhost_content != '') { @@ -813,8 +819,10 @@ class apache extends HttpConfigBase { if (Settings::Get('system.default_vhostconf') != '') { $vhost_content .= $this->processSpecialConfigTemplate( Settings::Get('system.default_vhostconf'), - $ipandport, - $domain) . "\n"; + $domain, + $domain['ip'], + $domain['port'], + $ssl_vhost) . "\n"; } } diff --git a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php index b80b9614..e93270f6 100644 --- a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php +++ b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php @@ -149,8 +149,10 @@ class lighttpd extends HttpConfigBase { if ($row_ipsandports['specialsettings'] != '') { $this->lighttpd_data[$vhost_filename].= $this->processSpecialConfigTemplate( $row_ipsandports['specialsettings'], - $row_ipsandports, - $domain + $domain, + $row_ipsandports['ip'], + $row_ipsandports['port'], + $row_ipsandports['ssl'] == '1' ). "\n"; } @@ -447,22 +449,28 @@ class lighttpd extends HttpConfigBase { if ($domain['specialsettings'] != "") { $vhost_content.= $this->processSpecialConfigTemplate( $domain['specialsettings'], - $ipandport, - $domain). "\n"; + $domain, + $domain['ip'], + $domain['port'], + $ssl_vhost). "\n"; } if ($ipandport['default_vhostconf_domain'] != '') { $vhost_content.= $this->processSpecialConfigTemplate( $ipandport['default_vhostconf_domain'], - $ipandport, - $domain) . "\n"; + $domain, + $domain['ip'], + $domain['port'], + $ssl_vhost) . "\n"; } if (Settings::Get('system.default_vhostconf') != '') { $vhost_content.= $this->processSpecialConfigTemplate( Settings::Get('system.default_vhostconf'), - $ipandport, - $domain). "\n"; + $domain, + $domain['ip'], + $domain['port'], + $ssl_vhost). "\n"; } } $vhost_content.= $this->getLogFiles($domain); diff --git a/scripts/jobs/cron_tasks.inc.http.30.nginx.php b/scripts/jobs/cron_tasks.inc.http.30.nginx.php index a06067cd..700dd220 100644 --- a/scripts/jobs/cron_tasks.inc.http.30.nginx.php +++ b/scripts/jobs/cron_tasks.inc.http.30.nginx.php @@ -191,10 +191,12 @@ class nginx extends HttpConfigBase { if ($row_ipsandports['specialsettings'] != '') { $this->nginx_data[$vhost_filename].= $this->processSpecialConfigTemplate( $row_ipsandports['specialsettings'], - $row_ipsandports, array('domain'=> Settings::Get('system.hostname'), 'loginname' => Settings::Get('phpfpm.vhost_httpuser'), - 'documentroot'=> $mypath)). "\n"; + 'documentroot'=> $mypath), + $row_ipsandports['ip'], + $row_ipsandports['port'], + $row_ipsandports['ssl'] == '1'). "\n"; } /** @@ -372,8 +374,10 @@ class nginx extends HttpConfigBase { if ($ipandport['default_vhostconf_domain'] != '') { $_vhost_content .= $this->processSpecialConfigTemplate( $ipandport['default_vhostconf_domain'], - $ipandport, - $domain). "\n"; + $domain, + $domain['ip'], + $domain['port'], + $ssl_vhost). "\n"; } $vhost_content.= "\t" . 'listen ' . $ipport . ($ssl_vhost == true ? ' ssl' : '') . ';' . "\n"; @@ -437,8 +441,10 @@ class nginx extends HttpConfigBase { if ($domain['specialsettings'] != "") { $vhost_content = $this->mergeVhostCustom($vhost_content, $this->processSpecialConfigTemplate( $domain['specialsettings'], - $ipandport, - $domain + $domain, + $domain['ip'], + $domain['port'], + $ssl_vhost )); } @@ -450,8 +456,10 @@ class nginx extends HttpConfigBase { $vhost_content = $this->mergeVhostCustom($vhost_content, $this->processSpecialConfigTemplate( Settings::Get('system.default_vhostconf'), - $ipandport, - $domain)."\n"); + $domain, + $domain['ip'], + $domain['port'], + $ssl_vhost)."\n"); } } }