Merge pull request #244 from greybyte/vhost_config_variables

Variable substitution in vhost specialconfig
This commit is contained in:
Michael Kaufmann
2015-07-31 11:45:30 +02:00
committed by Michael Kaufmann (d00p)
parent 8e8c97f7f9
commit 5136824844
6 changed files with 131 additions and 19 deletions

View File

@@ -0,0 +1,38 @@
<?php
/***
* Class HttpConfigBase
*
* Base class for all HTTP server configs
*
*/
class HttpConfigBase {
/**
* 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} - evaluates to 'ssl' if domain/ip is ssl, otherwise it is an empty string
* {DOCROOT} - document root for this domain
*
* @param $template
* @return string
*/
protected function processSpecialConfigTemplate($template, $domain, $ip, $port, $is_ssl_vhost) {
$templateVars = array(
'DOMAIN' => $domain['domain'],
'CUSTOMER' => $domain['loginname'],
'IP' => $ip,
'PORT' => $port,
'SCHEME' => ($is_ssl_vhost)?'https':'http',
'DOCROOT' => $domain['documentroot']
);
return replace_variables($template, $templateVars);
}
}