migrating more files to new Settings-class makes me dance, refs #1325

Signed-off-by: Roman Schmerold (BNoiZe) <bnoize@froxlor.org>
This commit is contained in:
Roman Schmerold (BNoiZe)
2013-12-15 15:51:25 +01:00
parent e7c53e4abb
commit 121669ee69
15 changed files with 1107 additions and 767 deletions

View File

@@ -32,7 +32,7 @@ while ($maildir = $maildirs_stmt->fetch(PDO::FETCH_ASSOC)) {
$_maildir = makeCorrectDir($maildir['maildirpath']);
if (file_exists($_maildir)
if (file_exists($_maildir)
&& is_dir($_maildir)
) {
$back = safe_exec('du -sk ' . escapeshellarg($_maildir) . '');

View File

@@ -17,37 +17,34 @@
*
*/
class bind
{
class bind {
public $logger = false;
public $debugHandler = false;
public $settings = array();
public $nameservers = array();
public $mxservers = array();
public $axfrservers = array();
public function __construct($logger, $debugHandler, $settings) {
public function __construct($logger, $debugHandler) {
$this->logger = $logger;
$this->debugHandler = $debugHandler;
$this->settings = $settings;
if ($this->settings['system']['nameservers'] != '') {
$nameservers = explode(',', $this->settings['system']['nameservers']);
if (Settings::Get('system.nameservers') != '') {
$nameservers = explode(',', Settings::Get('system.nameservers'));
foreach ($nameservers as $nameserver) {
$nameserver_ip = gethostbyname(trim($nameserver));
if (substr($nameserver, -1, 1) != '.') {
$nameserver.= '.';
}
$this->nameservers[] = array(
'hostname' => trim($nameserver),
'ip' => trim($nameserver_ip)
'hostname' => trim($nameserver),
'ip' => trim($nameserver_ip)
);
}
}
if ($this->settings['system']['mxservers'] != '') {
$mxservers = explode(',', $this->settings['system']['mxservers']);
if (Settings::Get('system.mxservers') != '') {
$mxservers = explode(',', Settings::Get('system.mxservers'));
foreach ($mxservers as $mxserver) {
if (substr($mxserver, -1, 1) != '.') {
$mxserver.= '.';
@@ -57,28 +54,27 @@ class bind
}
// AXFR server #100
if ($this->settings['system']['axfrservers'] != '') {
$axfrservers = explode(',', $this->settings['system']['axfrservers']);
if (Settings::Get('system.axfrservers') != '') {
$axfrservers = explode(',', Settings::Get('system.axfrservers'));
foreach ($axfrservers as $axfrserver) {
$this->axfrservers[] = trim($axfrserver);
}
}
}
public function writeConfigs()
{
public function writeConfigs() {
fwrite($this->debugHandler, ' cron_tasks: Task4 started - Rebuilding froxlor_bind.conf' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'Task4 started - Rebuilding froxlor_bind.conf');
if(!file_exists(makeCorrectDir($this->settings['system']['bindconf_directory'] . '/domains/')))
{
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['bindconf_directory'] . '/domains/')));
safe_exec('mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['bindconf_directory'] . '/domains/')));
if (!file_exists(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/'))) {
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/')));
safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/')));
}
$known_filenames = array();
$bindconf_file = '# ' . $this->settings['system']['bindconf_directory'] . 'froxlor_bind.conf' . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n";
$bindconf_file = '# ' . Settings::Get('system.bindconf_directory') . 'froxlor_bind.conf' . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n";
$result_domains_stmt = Database::query("
SELECT `d`.`id`, `d`.`domain`, `d`.`iswildcarddomain`, `d`.`wwwserveralias`, `d`.`customerid`, `d`.`zonefile`, `d`.`bindserial`, `d`.`dkim`, `d`.`dkim_id`, `d`.`dkim_pubkey`, `c`.`loginname`, `c`.`guid`
FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`)
@@ -90,11 +86,10 @@ class bind
fwrite($this->debugHandler, ' cron_tasks: Task4 - Writing ' . $domain['id'] . '::' . $domain['domain'] . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'Writing ' . $domain['id'] . '::' . $domain['domain']);
if($domain['zonefile'] == '')
{
if ($domain['zonefile'] == '') {
$zonefile = $this->generateZone($domain);
$domain['zonefile'] = 'domains/' . $domain['domain'] . '.zone';
$zonefile_name = makeCorrectFile($this->settings['system']['bindconf_directory'] . '/' . $domain['zonefile']);
$zonefile_name = makeCorrectFile(Settings::Get('system.bindconf_directory') . '/' . $domain['zonefile']);
$known_filenames[] = basename($zonefile_name);
$zonefile_handler = fopen($zonefile_name, 'w');
fwrite($zonefile_handler, $zonefile);
@@ -105,11 +100,11 @@ class bind
$bindconf_file.= '# Domain ID: ' . $domain['id'] . ' - CustomerID: ' . $domain['customerid'] . ' - CustomerLogin: ' . $domain['loginname'] . "\n";
$bindconf_file.= 'zone "' . $domain['domain'] . '" in {' . "\n";
$bindconf_file.= ' type master;' . "\n";
$bindconf_file.= ' file "' . makeCorrectFile($this->settings['system']['bindconf_directory'] . '/' . $domain['zonefile']) . '";' . "\n";
$bindconf_file.= ' file "' . makeCorrectFile(Settings::Get('system.bindconf_directory') . '/' . $domain['zonefile']) . '";' . "\n";
$bindconf_file.= ' allow-query { any; };' . "\n";
if (count($this->nameservers) > 0
|| count($this->axfrservers) > 0
|| count($this->axfrservers) > 0
) {
// open allow-transfer
$bindconf_file.= ' allow-transfer {' . "\n";
@@ -135,31 +130,28 @@ class bind
$bindconf_file.= "\n";
}
$bindconf_file_handler = fopen(makeCorrectFile($this->settings['system']['bindconf_directory'] . '/froxlor_bind.conf'), 'w');
$bindconf_file_handler = fopen(makeCorrectFile(Settings::Get('system.bindconf_directory') . '/froxlor_bind.conf'), 'w');
fwrite($bindconf_file_handler, $bindconf_file);
fclose($bindconf_file_handler);
fwrite($this->debugHandler, ' cron_tasks: Task4 - froxlor_bind.conf written' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'froxlor_bind.conf written');
safe_exec(escapeshellcmd($this->settings['system']['bindreload_command']));
safe_exec(escapeshellcmd(Settings::Get('system.bindreload_command')));
fwrite($this->debugHandler, ' cron_tasks: Task4 - Bind9 reloaded' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'Bind9 reloaded');
$domains_dir = makeCorrectDir($this->settings['system']['bindconf_directory'] . '/domains/');
$domains_dir = makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/');
if(file_exists($domains_dir)
&& is_dir($domains_dir))
{
if (file_exists($domains_dir)
&& is_dir($domains_dir)) {
$domain_file_dirhandle = opendir($domains_dir);
while(false !== ($domain_filename = readdir($domain_file_dirhandle)))
{
while (false !== ($domain_filename = readdir($domain_file_dirhandle))) {
$full_filename = makeCorrectFile($domains_dir . '/' . $domain_filename);
if($domain_filename != '.'
&& $domain_filename != '..'
&& !in_array($domain_filename, $known_filenames)
&& is_file($full_filename)
&& file_exists($full_filename))
{
if ($domain_filename != '.'
&& $domain_filename != '..'
&& !in_array($domain_filename, $known_filenames)
&& is_file($full_filename)
&& file_exists($full_filename)) {
fwrite($this->debugHandler, ' cron_tasks: Task4 - unlinking ' . $domain_filename . "\n");
$this->logger->logAction(CRON_ACTION, LOG_WARNING, 'Deleting ' . $domain_filename);
unlink(makeCorrectFile($domains_dir . '/' . $domain_filename));
@@ -168,13 +160,13 @@ class bind
}
}
protected function generateZone($domain)
{
protected function generateZone($domain) {
// Array to save all ips needed in the records (already including IN A/AAAA)
$ip_a_records = array();
// Array to save DNS records
$records = array();
$result_ip_stmt = Database::prepare("
SELECT `p`.`ip` AS `ip`
FROM `".TABLE_PANEL_IPSANDPORTS."` `p`, `".TABLE_DOMAINTOIP."` `di`
@@ -182,9 +174,9 @@ class bind
GROUP BY `p`.`ip`;
");
Database::pexecute($result_ip_stmt, array('domainid' => $domain['id']));
while ($ip = $result_ip_stmt->fetch(PDO::FETCH_ASSOC)) {
if (filter_var($ip['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
$ip_a_records[] = "A\t\t" . $ip['ip'];
}
@@ -206,11 +198,11 @@ class bind
");
Database::pexecute($upd_stmt, array('serial' => $bindserial, 'id' => $domain['id']));
$zonefile = '$TTL ' . (int)$this->settings['system']['defaultttl'] . "\n";
$zonefile = '$TTL ' . (int)Settings::Get('system.defaultttl') . "\n";
if (count($this->nameservers) == 0) {
$zonefile.= '@ IN SOA ns ' . str_replace('@', '.', $this->settings['panel']['adminmail']) . '. (' . "\n";
$zonefile.= '@ IN SOA ns ' . str_replace('@', '.', Settings::Get('panel.adminmail')) . '. (' . "\n";
} else {
$zonefile.= '@ IN SOA ' . $this->nameservers[0]['hostname'] . ' ' . str_replace('@', '.', $this->settings['panel']['adminmail']) . '. (' . "\n";
$zonefile.= '@ IN SOA ' . $this->nameservers[0]['hostname'] . ' ' . str_replace('@', '.', Settings::Get('panel.adminmail')) . '. (' . "\n";
}
$zonefile.= ' ' . $bindserial . ' ; serial' . "\n" . ' 8H ; refresh' . "\n" . ' 2H ; retry' . "\n" . ' 1W ; expiry' . "\n" . ' 11h) ; minimum' . "\n";
@@ -240,7 +232,7 @@ class bind
$zonefile.= '@ IN MX ' . trim($mxserver) . "\n";
}
if ($this->settings['system']['dns_createmailentry'] == '1') {
if (Settings::Get('system.dns_createmailentry') == '1') {
$records[] = 'mail';
if ($domain['iswildcarddomain'] != '1') {
$records[] = 'imap';
@@ -253,12 +245,12 @@ class bind
/*
* @TODO domain-based spf-settings
*/
if ($this->settings['spf']['use_spf'] == '1'
/*&& $domain['spf'] == '1' */
if (Settings::Get('spf.use_spf') == '1'
/*&& $domain['spf'] == '1' */
) {
$zonefile.= $this->settings['spf']['spf_entry'] . "\n";
$zonefile.= Settings::Get('spf.spf_entry') . "\n";
if (in_array('mail', $records)) {
$zonefile.= str_replace('@', 'mail', $this->settings['spf']['spf_entry']) . "\n";
$zonefile.= str_replace('@', 'mail', Settings::Get('spf.spf_entry')) . "\n";
}
}
@@ -303,11 +295,11 @@ class bind
Database::pexecute($subdomains_stmt, array('domainid' => $domain['id']));
while ($subdomain = $subdomains_stmt->fetch(PDO::FETCH_ASSOC)) {
// Listing domains is enough as there currently is no support for choosing
// Listing domains is enough as there currently is no support for choosing
// different ips for a subdomain => use same IPs as toplevel
$records[] = str_replace('.' . $domain['domain'], '', $subdomain['domain']);
// Check whether to add a www.-prefix
// Check whether to add a www.-prefix
if ($domain['wwwserveralias'] == '1') {
$records[] = str_replace('.' . $domain['domain'], '', $subdomain['domain']);
}
@@ -324,19 +316,18 @@ class bind
return $zonefile;
}
private function generateDkim($domain)
{
private function generateDkim($domain) {
$zone_dkim = '';
if($this->settings['dkim']['use_dkim'] == '1'
&& $domain['dkim'] == '1'
&& $domain['dkim_pubkey'] != '')
{
if (Settings::Get('dkim.use_dkim') == '1'
&& $domain['dkim'] == '1'
&& $domain['dkim_pubkey'] != '') {
// start
$dkim_txt = 'v=DKIM1;';
// algorithm
$algorithm = explode(',', $this->settings['dkim']['dkim_algorithm']);
$algorithm = explode(',', Settings::Get('dkim.dkim_algorithm'));
$alg = '';
foreach ($algorithm as $a) {
if ($a == 'all') {
@@ -352,16 +343,16 @@ class bind
}
// notes
if (trim($this->settings['dkim']['dkim_notes'] != '')) {
$dkim_txt.= 'n='.trim($this->settings['dkim']['dkim_notes']).';';
if (trim(Settings::Get('dkim.dkim_notes') != '')) {
$dkim_txt.= 'n='.trim(Settings::Get('dkim.dkim_notes')).';';
}
// key
$dkim_txt.= 'k=rsa;p='.trim(preg_replace('/-----BEGIN PUBLIC KEY-----(.+)-----END PUBLIC KEY-----/s', '$1', str_replace("\n", '', $domain['dkim_pubkey']))).';';
// service-type
if ($this->settings['dkim']['dkim_servicetype'] == '1') {
$dkim_txt.= 's=email;';
if (Settings::Get('dkim.dkim_servicetype') == '1') {
$dkim_txt.= 's=email;';
}
// end-part
@@ -378,20 +369,19 @@ class bind
$zone_dkim .= 'dkim_' . $domain['dkim_id'] . '._domainkey IN TXT ' . $txt_record_split;
// adsp-entry
if ($this->settings['dkim']['dkim_add_adsp'] == "1") {
if (Settings::Get('dkim.dkim_add_adsp') == "1") {
$zone_dkim .= '_adsp._domainkey IN TXT "dkim=';
switch((int)$this->settings['dkim']['dkim_add_adsppolicy'])
{
case 0:
$zone_dkim .= 'unknown"'. "\n";
break;
case 1:
$zone_dkim .= 'all"'. "\n";
break;
case 2:
$zone_dkim .= 'discardable"'. "\n";
break;
switch ((int)Settings::Get('dkim.dkim_add_adsppolicy')) {
case 0:
$zone_dkim .= 'unknown"'. "\n";
break;
case 1:
$zone_dkim .= 'all"'. "\n";
break;
case 2:
$zone_dkim .= 'discardable"'. "\n";
break;
}
}
}
@@ -399,14 +389,12 @@ class bind
return $zone_dkim;
}
public function writeDKIMconfigs()
{
if($this->settings['dkim']['use_dkim'] == '1')
{
if(!file_exists(makeCorrectDir($this->settings['dkim']['dkim_prefix'])))
{
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir -p ' . escapeshellarg(makeCorrectDir($this->settings['dkim']['dkim_prefix'])));
safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir($this->settings['dkim']['dkim_prefix'])));
public function writeDKIMconfigs() {
if (Settings::Get('dkim.use_dkim') == '1') {
if (!file_exists(makeCorrectDir(Settings::Get('dkim.dkim_prefix')))) {
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('dkim.dkim_prefix'))));
safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('dkim.dkim_prefix'))));
}
$dkimdomains = '';
@@ -418,20 +406,19 @@ class bind
while ($domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
$privkey_filename = makeCorrectFile($this->settings['dkim']['dkim_prefix'] . '/dkim_' . $domain['dkim_id']);
$pubkey_filename = makeCorrectFile($this->settings['dkim']['dkim_prefix'] . '/dkim_' . $domain['dkim_id'] . '.public');
$privkey_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id']);
$pubkey_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id'] . '.public');
if($domain['dkim_privkey'] == ''
|| $domain['dkim_pubkey'] == '')
{
if ($domain['dkim_privkey'] == ''
|| $domain['dkim_pubkey'] == '') {
$max_dkim_id_stmt = Database::query("SELECT MAX(`dkim_id`) as `max_dkim_id` FROM `" . TABLE_PANEL_DOMAINS . "`");
$max_dkim_id = $max_dkim_id_stmt->fetch(PDO::FETCH_ASSOC);
$domain['dkim_id'] = (int)$max_dkim_id['max_dkim_id'] + 1;
$privkey_filename = makeCorrectFile($this->settings['dkim']['dkim_prefix'] . '/dkim_' . $domain['dkim_id']);
safe_exec('openssl genrsa -out ' . escapeshellarg($privkey_filename) . ' ' . $this->settings['dkim']['dkim_keylength']);
$privkey_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id']);
safe_exec('openssl genrsa -out ' . escapeshellarg($privkey_filename) . ' ' . Settings::Get('dkim.dkim_keylength'));
$domain['dkim_privkey'] = file_get_contents($privkey_filename);
safe_exec("chmod 0640 " . escapeshellarg($privkey_filename));
$pubkey_filename = makeCorrectFile($this->settings['dkim']['dkim_prefix'] . '/dkim_' . $domain['dkim_id'] . '.public');
$pubkey_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id'] . '.public');
safe_exec('openssl rsa -in ' . escapeshellarg($privkey_filename) . ' -pubout -outform pem -out ' . escapeshellarg($pubkey_filename));
$domain['dkim_pubkey'] = file_get_contents($pubkey_filename);
safe_exec("chmod 0664 " . escapeshellarg($pubkey_filename));
@@ -451,18 +438,16 @@ class bind
Database::pexecute($upd_stmt, $upd_data);
}
if(!file_exists($privkey_filename)
&& $domain['dkim_privkey'] != '')
{
if (!file_exists($privkey_filename)
&& $domain['dkim_privkey'] != '') {
$privkey_file_handler = fopen($privkey_filename, "w");
fwrite($privkey_file_handler, $domain['dkim_privkey']);
fclose($privkey_file_handler);
safe_exec("chmod 0640 " . escapeshellarg($privkey_filename));
}
if(!file_exists($pubkey_filename)
&& $domain['dkim_pubkey'] != '')
{
if (!file_exists($pubkey_filename)
&& $domain['dkim_pubkey'] != '') {
$pubkey_file_handler = fopen($pubkey_filename, "w");
fwrite($pubkey_file_handler, $domain['dkim_pubkey']);
fclose($pubkey_file_handler);
@@ -473,18 +458,20 @@ class bind
$dkimkeys.= "*@" . $domain['domain'] . ":" . $domain['domain'] . ":" . $privkey_filename . "\n";
}
$dkimdomains_filename = makeCorrectFile($this->settings['dkim']['dkim_prefix'] . '/' . $this->settings['dkim']['dkim_domains']);
$dkimdomains_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/' . Settings::Get('dkim.dkim_domains'));
$dkimdomains_file_handler = fopen($dkimdomains_filename, "w");
fwrite($dkimdomains_file_handler, $dkimdomains);
fclose($dkimdomains_file_handler);
$dkimkeys_filename = makeCorrectFile($this->settings['dkim']['dkim_prefix'] . '/' . $this->settings['dkim']['dkim_dkimkeys']);
$dkimkeys_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/' . Settings::Get('dkim.dkim_dkimkeys'));
$dkimkeys_file_handler = fopen($dkimkeys_filename, "w");
fwrite($dkimkeys_file_handler, $dkimkeys);
fclose($dkimkeys_file_handler);
safe_exec(escapeshellcmd($this->settings['dkim']['dkimrestart_command']));
safe_exec(escapeshellcmd(Settings::Get('dkim.dkimrestart_command')));
fwrite($this->debugHandler, ' cron_tasks: Task4 - Dkim-milter reloaded' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'Dkim-milter reloaded');
}
}
}

View File

@@ -17,14 +17,12 @@
*
*/
class apache
{
class apache {
private $logger = false;
private $debugHandler = false;
private $idnaConvert = false;
// protected
protected $settings = array();
// protected
protected $known_vhostfilenames = array();
protected $known_diroptionsfilenames = array();
protected $known_htpasswdsfilenames = array();
@@ -40,43 +38,40 @@ class apache
*/
private $_deactivated = false;
public function __construct($logger, $debugHandler, $idnaConvert, $settings)
{
public function __construct($logger, $debugHandler, $idnaConvert) {
$this->logger = $logger;
$this->debugHandler = $debugHandler;
$this->idnaConvert = $idnaConvert;
$this->settings = $settings;
}
public function reload()
{
if((int)$this->settings['phpfpm']['enabled'] == 1)
{
public function reload() {
if ((int)Settings::Get('phpfpm.enabled') == 1) {
fwrite($this->debugHandler, ' apache::reload: reloading php-fpm' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm');
safe_exec(escapeshellcmd($this->settings['phpfpm']['reload']));
safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload')));
}
fwrite($this->debugHandler, ' apache::reload: reloading apache' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading apache');
safe_exec(escapeshellcmd($this->settings['system']['apachereload_command']));
safe_exec(escapeshellcmd(Settings::Get('system.apachereload_command')));
}
/**
* define a standard <Directory>-statement, bug #32
*/
private function _createStandardDirectoryEntry()
{
private function _createStandardDirectoryEntry() {
$vhosts_folder = '';
if (is_dir($this->settings['system']['apacheconf_vhost'])) {
$vhosts_folder = makeCorrectDir($this->settings['system']['apacheconf_vhost']);
if (is_dir(Settings::Get('system.apacheconf_vhost'))) {
$vhosts_folder = makeCorrectDir(Settings::Get('system.apacheconf_vhost'));
} else {
$vhosts_folder = makeCorrectDir(dirname($this->settings['system']['apacheconf_vhost']));
$vhosts_folder = makeCorrectDir(dirname(Settings::Get('system.apacheconf_vhost')));
}
$vhosts_filename = makeCorrectFile($vhosts_folder . '/05_froxlor_dirfix_nofcgid.conf');
if ($this->settings['system']['mod_fcgid'] == '1'
|| $this->settings['phpfpm']['enabled'] == '1'
if (Settings::Get('system.mod_fcgid') == '1'
|| Settings::Get('phpfpm.enabled') == '1'
) {
// if we use fcgid or php-fpm we don't need this file
if (file_exists($vhosts_filename)) {
@@ -89,9 +84,9 @@ class apache
$this->virtualhosts_data[$vhosts_filename] = '';
}
$this->virtualhosts_data[$vhosts_filename].= ' <Directory "' . makeCorrectDir($this->settings['system']['documentroot_prefix']) . '">' . "\n";
$this->virtualhosts_data[$vhosts_filename].= ' <Directory "' . makeCorrectDir(Settings::Get('system.documentroot_prefix')) . '">' . "\n";
// >=apache-2.4 enabled?
if ($this->settings['system']['apache24'] == '1') {
if (Settings::Get('system.apache24') == '1') {
$this->virtualhosts_data[$vhosts_filename].= ' Require all granted' . "\n";
} else {
$this->virtualhosts_data[$vhosts_filename].= ' Order allow,deny' . "\n";
@@ -101,22 +96,22 @@ class apache
}
}
/**
* define a default ErrorDocument-statement, bug #unknown-yet
*/
private function _createStandardErrorHandler()
{
if ($this->settings['defaultwebsrverrhandler']['enabled'] == '1'
&& ($this->settings['defaultwebsrverrhandler']['err401'] != ''
|| $this->settings['defaultwebsrverrhandler']['err403'] != ''
|| $this->settings['defaultwebsrverrhandler']['err404'] != ''
|| $this->settings['defaultwebsrverrhandler']['err500'] != '')
private function _createStandardErrorHandler() {
if (Settings::Get('defaultwebsrverrhandler.enabled') == '1'
&& (Settings::Get('defaultwebsrverrhandler.err401') != ''
|| Settings::Get('defaultwebsrverrhandler.err403') != ''
|| Settings::Get('defaultwebsrverrhandler.err404') != ''
|| Settings::Get('defaultwebsrverrhandler.err500') != '')
) {
$vhosts_folder = '';
if (is_dir($this->settings['system']['apacheconf_vhost'])) {
$vhosts_folder = makeCorrectDir($this->settings['system']['apacheconf_vhost']);
if (is_dir(Settings::Get('system.apacheconf_vhost'))) {
$vhosts_folder = makeCorrectDir(Settings::Get('system.apacheconf_vhost'));
} else {
$vhosts_folder = makeCorrectDir(dirname($this->settings['system']['apacheconf_vhost']));
$vhosts_folder = makeCorrectDir(dirname(Settings::Get('system.apacheconf_vhost')));
}
$vhosts_filename = makeCorrectFile($vhosts_folder . '/05_froxlor_default_errorhandler.conf');
@@ -127,8 +122,8 @@ class apache
$statusCodes = array('401', '403', '404', '500');
foreach ($statusCodes as $statusCode) {
if ($this->settings['defaultwebsrverrhandler']['err' . $statusCode] != '') {
$defhandler = $this->settings['defaultwebsrverrhandler']['err' . $statusCode];
if (Settings::Get('defaultwebsrverrhandler.err' . $statusCode) != '') {
$defhandler = Settings::Get('defaultwebsrverrhandler.err' . $statusCode);
if (!validateUrl($defhandler)) {
if (substr($defhandler, 0, 1) != '"' && substr($defhandler, -1, 1) != '"') {
$defhandler = '"'.makeCorrectFile($defhandler).'"';
@@ -140,8 +135,8 @@ class apache
}
}
public function createIpPort()
{
public function createIpPort() {
$result_ipsandports_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` ORDER BY `ip` ASC, `port` ASC");
while ($row_ipsandports = $result_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
@@ -153,7 +148,7 @@ class apache
fwrite($this->debugHandler, ' apache::createIpPort: creating ip/port settings for ' . $ipport . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating ip/port settings for ' . $ipport);
$vhosts_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf');
$vhosts_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf');
if (!isset($this->virtualhosts_data[$vhosts_filename])) {
$this->virtualhosts_data[$vhosts_filename] = '';
@@ -166,7 +161,7 @@ class apache
if ($row_ipsandports['namevirtualhost_statement'] == '1') {
// >=apache-2.4 enabled?
if ($this->settings['system']['apache24'] == '1') {
if (Settings::Get('system.apache24') == '1') {
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, $ipport . ' :: namevirtualhost-statement no longer needed for apache-2.4');
} else {
$this->virtualhosts_data[$vhosts_filename].= 'NameVirtualHost ' . $ipport . "\n";
@@ -181,7 +176,7 @@ class apache
/**
* add 'real'-vhost content here, like doc-root :)
*/
if ($this->settings['system']['froxlordirectlyviahostname']) {
if (Settings::Get('system.froxlordirectlyviahostname')) {
$mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__))));
} else {
$mypath = makeCorrectDir(dirname(dirname(dirname(dirname(__FILE__)))));
@@ -194,36 +189,36 @@ class apache
$this->virtualhosts_data[$vhosts_filename] .= 'DocumentRoot "'.$mypath.'"'."\n";
if ($row_ipsandports['vhostcontainer_servername_statement'] == '1') {
$this->virtualhosts_data[$vhosts_filename] .= ' ServerName ' . $this->settings['system']['hostname'] . "\n";
$this->virtualhosts_data[$vhosts_filename] .= ' ServerName ' . Settings::Get('system.hostname') . "\n";
}
// create fcgid <Directory>-Part (starter is created in apache_fcgid)
if ($this->settings['system']['mod_fcgid_ownvhost'] == '1'
&& $this->settings['system']['mod_fcgid'] == '1'
if (Settings::Get('system.mod_fcgid_ownvhost') == '1'
&& Settings::Get('system.mod_fcgid') == '1'
) {
$configdir = makeCorrectDir($this->settings['system']['mod_fcgid_configdir'] . '/froxlor.panel/' . $this->settings['system']['hostname']);
$this->virtualhosts_data[$vhosts_filename] .= ' FcgidIdleTimeout ' . $this->settings['system']['mod_fcgid_idle_timeout'] . "\n";
if ((int)$this->settings['system']['mod_fcgid_wrapper'] == 0) {
$this->virtualhosts_data[$vhosts_filename] .= ' SuexecUserGroup "' . $this->settings['system']['mod_fcgid_httpuser'] . '" "' . $this->settings['system']['mod_fcgid_httpgroup'] . '"' . "\n";
$configdir = makeCorrectDir(Settings::Get('system.mod_fcgid_configdir') . '/froxlor.panel/' . Settings::Get('system.hostname'));
$this->virtualhosts_data[$vhosts_filename] .= ' FcgidIdleTimeout ' . Settings::Get('system.mod_fcgid_idle_timeout') . "\n";
if ((int)Settings::Get('system.mod_fcgid_wrapper') == 0) {
$this->virtualhosts_data[$vhosts_filename] .= ' SuexecUserGroup "' . Settings::Get('system.mod_fcgid_httpuser') . '" "' . Settings::Get('system.mod_fcgid_httpgroup') . '"' . "\n";
$this->virtualhosts_data[$vhosts_filename] .= ' ScriptAlias /php/ ' . $configdir . "\n";
} else {
$domain = array(
'id' => 'none',
'domain' => $this->settings['system']['hostname'],
'domain' => Settings::Get('system.hostname'),
'adminid' => 1, /* first admin-user (superadmin) */
'mod_fcgid_starter' => -1,
'mod_fcgid_maxrequests' => -1,
'guid' => $this->settings['phpfpm']['vhost_httpuser'],
'guid' => Settings::Get('phpfpm.vhost_httpuser'),
'openbasedir' => 0,
'email' => $this->settings['panel']['adminmail'],
'email' => Settings::Get('panel.adminmail'),
'loginname' => 'froxlor.panel',
'documentroot' => $mypath
);
$php = new phpinterface($domain);
$phpconfig = $php->getPhpConfig($this->settings['system']['mod_fcgid_defaultini_ownvhost']);
$phpconfig = $php->getPhpConfig(Settings::Get('system.mod_fcgid_defaultini_ownvhost'));
$starter_filename = makeCorrectFile($configdir . '/php-fcgi-starter');
$this->virtualhosts_data[$vhosts_filename] .= ' SuexecUserGroup "' . $this->settings['system']['mod_fcgid_httpuser'] . '" "' . $this->settings['system']['mod_fcgid_httpgroup'] . '"' . "\n";
$this->virtualhosts_data[$vhosts_filename] .= ' SuexecUserGroup "' . Settings::Get('system.mod_fcgid_httpuser') . '" "' . Settings::Get('system.mod_fcgid_httpgroup') . '"' . "\n";
$this->virtualhosts_data[$vhosts_filename].= ' <Directory "' . $mypath . '">' . "\n";
$file_extensions = explode(' ', $phpconfig['file_extensions']);
$this->virtualhosts_data[$vhosts_filename].= ' <FilesMatch "\.(' . implode('|', $file_extensions) . ')$">' . "\n";
@@ -234,7 +229,7 @@ class apache
$this->virtualhosts_data[$vhosts_filename].= ' Options +ExecCGI' . "\n";
$this->virtualhosts_data[$vhosts_filename].= ' </FilesMatch>' . "\n";
// >=apache-2.4 enabled?
if ($this->settings['system']['apache24'] == '1') {
if (Settings::Get('system.apache24') == '1') {
$this->virtualhosts_data[$vhosts_filename].= ' Require all granted' . "\n";
} else {
$this->virtualhosts_data[$vhosts_filename].= ' Order allow,deny' . "\n";
@@ -244,27 +239,27 @@ class apache
}
}
// create php-fpm <Directory>-Part (config is created in apache_fcgid)
elseif ($this->settings['phpfpm']['enabled'] == '1') {
elseif (Settings::Get('phpfpm.enabled') == '1') {
$domain = array(
'id' => 'none',
'domain' => $this->settings['system']['hostname'],
'domain' => Settings::Get('system.hostname'),
'adminid' => 1, /* first admin-user (superadmin) */
'mod_fcgid_starter' => -1,
'mod_fcgid_maxrequests' => -1,
'guid' => $this->settings['phpfpm']['vhost_httpuser'],
'guid' => Settings::Get('phpfpm.vhost_httpuser'),
'openbasedir' => 0,
'email' => $this->settings['panel']['adminmail'],
'email' => Settings::Get('panel.adminmail'),
'loginname' => 'froxlor.panel',
'documentroot' => $mypath,
);
$php = new phpinterface($domain);
$phpconfig = $php->getPhpConfig($this->settings['phpfpm']['vhost_defaultini']);
$phpconfig = $php->getPhpConfig(Settings::Get('phpfpm.vhost_defaultini'));
$srvName = substr(md5($ipport),0,4).'.fpm.external';
if ($row_ipsandports['ssl']) {
$srvName = substr(md5($ipport),0,4).'.ssl-fpm.external';
}
$this->virtualhosts_data[$vhosts_filename] .= ' FastCgiExternalServer ' . $php->getInterface()->getAliasConfigDir() . $srvName .' -socket ' . $php->getInterface()->getSocketFile() . ' -idle-timeout ' . $this->settings['phpfpm']['idle_timeout'] . "\n";
$this->virtualhosts_data[$vhosts_filename] .= ' FastCgiExternalServer ' . $php->getInterface()->getAliasConfigDir() . $srvName .' -socket ' . $php->getInterface()->getSocketFile() . ' -idle-timeout ' . Settings::Get('phpfpm.idle_timeout') . "\n";
$this->virtualhosts_data[$vhosts_filename] .= ' <Directory "' . $mypath . '">' . "\n";
$file_extensions = explode(' ', $phpconfig['file_extensions']);
$this->virtualhosts_data[$vhosts_filename] .= ' <FilesMatch "\.(' . implode('|', $file_extensions) . ')$">' . "\n";
@@ -273,7 +268,7 @@ class apache
$this->virtualhosts_data[$vhosts_filename].= ' Options +ExecCGI' . "\n";
$this->virtualhosts_data[$vhosts_filename].= ' </FilesMatch>' . "\n";
// >=apache-2.4 enabled?
if ($this->settings['system']['apache24'] == '1') {
if (Settings::Get('system.apache24') == '1') {
$this->virtualhosts_data[$vhosts_filename] .= ' Require all granted' . "\n";
} else {
$this->virtualhosts_data[$vhosts_filename] .= ' Order allow,deny' . "\n";
@@ -286,15 +281,15 @@ class apache
/**
* dirprotection, see #72
* @TODO deferred until 0.9.5, needs more testing
$this->virtualhosts_data[$vhosts_filename] .= "\t<Directory \"'.$mypath.'(images|packages|templates)\">\n";
$this->virtualhosts_data[$vhosts_filename] .= "\t\tAllow from all\n";
$this->virtualhosts_data[$vhosts_filename] .= "\t\tOptions -Indexes\n";
$this->virtualhosts_data[$vhosts_filename] .= "\t</Directory>\n";
$this->virtualhosts_data[$vhosts_filename] .= "\t<Directory \"'.$mypath.'(images|packages|templates)\">\n";
$this->virtualhosts_data[$vhosts_filename] .= "\t\tAllow from all\n";
$this->virtualhosts_data[$vhosts_filename] .= "\t\tOptions -Indexes\n";
$this->virtualhosts_data[$vhosts_filename] .= "\t</Directory>\n";
$this->virtualhosts_data[$vhosts_filename] .= "\t<Directory \"'.$mypath.'*\">\n";
$this->virtualhosts_data[$vhosts_filename] .= "\t\tOrder Deny,Allow\n";
$this->virtualhosts_data[$vhosts_filename] .= "\t\tDeny from All\n";
$this->virtualhosts_data[$vhosts_filename] .= "\t</Directory>\n";
$this->virtualhosts_data[$vhosts_filename] .= "\t<Directory \"'.$mypath.'*\">\n";
$this->virtualhosts_data[$vhosts_filename] .= "\t\tOrder Deny,Allow\n";
$this->virtualhosts_data[$vhosts_filename] .= "\t\tDeny from All\n";
$this->virtualhosts_data[$vhosts_filename] .= "\t</Directory>\n";
* end of dirprotection
*/
@@ -302,29 +297,29 @@ class apache
$this->virtualhosts_data[$vhosts_filename] .= $row_ipsandports['specialsettings'] . "\n";
}
if ($row_ipsandports['ssl'] == '1' && $this->settings['system']['use_ssl'] == '1') {
if ($row_ipsandports['ssl'] == '1' && Settings::Get('system.use_ssl') == '1') {
if ($row_ipsandports['ssl_cert_file'] == '') {
$row_ipsandports['ssl_cert_file'] = $this->settings['system']['ssl_cert_file'];
$row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
}
if ($row_ipsandports['ssl_key_file'] == '') {
$row_ipsandports['ssl_key_file'] = $this->settings['system']['ssl_key_file'];
$row_ipsandports['ssl_key_file'] = Settings::Get('system.ssl_key_file');
}
if ($row_ipsandports['ssl_ca_file'] == '') {
$row_ipsandports['ssl_ca_file'] = $this->settings['system']['ssl_ca_file'];
$row_ipsandports['ssl_ca_file'] = Settings::Get('system.ssl_ca_file');
}
// #418
if ($row_ipsandports['ssl_cert_chainfile'] == '') {
$row_ipsandports['ssl_cert_chainfile'] = $this->settings['system']['ssl_cert_chainfile'];
$row_ipsandports['ssl_cert_chainfile'] = Settings::Get('system.ssl_cert_chainfile');
}
if ($row_ipsandports['ssl_cert_file'] != '') {
$this->virtualhosts_data[$vhosts_filename] .= ' SSLEngine On' . "\n";
// this makes it more secure, thx to Marcel (08/2013)
$this->virtualhosts_data[$vhosts_filename] .= ' SSLHonorCipherOrder On' . "\n";
$this->virtualhosts_data[$vhosts_filename] .= ' SSLCipherSuite ' . $this->settings['system']['ssl_cipher_list'] . "\n";
$this->virtualhosts_data[$vhosts_filename] .= ' SSLCipherSuite ' . Settings::Get('system.ssl_cipher_list') . "\n";
$this->virtualhosts_data[$vhosts_filename] .= ' SSLVerifyDepth 10' . "\n";
$this->virtualhosts_data[$vhosts_filename] .= ' SSLCertificateFile ' . makeCorrectFile($row_ipsandports['ssl_cert_file']) . "\n";
@@ -360,16 +355,16 @@ class apache
$this->_createStandardErrorHandler();
}
/**
* We put together the needed php options in the virtualhost entries
*
*
* @param array $domain
* @param bool $ssl_vhost
*
* @return string
*/
protected function composePhpOptions($domain, $ssl_vhost = false)
{
protected function composePhpOptions($domain, $ssl_vhost = false) {
$php_options_text = '';
if ($domain['phpenabled'] == '1') {
@@ -378,7 +373,7 @@ class apache
if ($domain['openbasedir'] == '1') {
$_phpappendopenbasedir = appendOpenBasedirPath($domain['customerroot'], true);
$_custom_openbasedir = explode(':', $this->settings['system']['phpappendopenbasedir']);
$_custom_openbasedir = explode(':', Settings::Get('system.phpappendopenbasedir'));
foreach ($_custom_openbasedir as $cobd) {
$_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
}
@@ -393,13 +388,14 @@ class apache
return $php_options_text;
}
public function createOwnVhostStarter() {}
/**
* We collect all servernames and Aliases
*/
protected function getServerNames($domain)
{
protected function getServerNames($domain) {
$servernames_text = ' ServerName ' . $domain['domain'] . "\n";
$server_alias = '';
@@ -438,20 +434,20 @@ class apache
return $servernames_text;
}
/**
* Let's get the webroot
* Let's get the webroot
*/
protected function getWebroot($domain)
{
protected function getWebroot($domain) {
$webroot_text = '';
$domain['customerroot'] = makeCorrectDir($domain['customerroot']);
$domain['documentroot'] = makeCorrectDir($domain['documentroot']);
if ($domain['deactivated'] == '1'
&& $this->settings['system']['deactivateddocroot'] != ''
&& Settings::Get('system.deactivateddocroot') != ''
) {
$webroot_text .= ' # Using docroot for deactivated users...' . "\n";
$webroot_text .= ' DocumentRoot "' . makeCorrectDir($this->settings['system']['deactivateddocroot']) . "\"\n";
$webroot_text .= ' DocumentRoot "' . makeCorrectDir(Settings::Get('system.deactivateddocroot')) . "\"\n";
$this->_deactivated = true;
} else {
$webroot_text .= ' DocumentRoot "' . $domain['documentroot'] . "\"\n";
@@ -461,26 +457,26 @@ class apache
return $webroot_text;
}
/**
* Lets set the text part for the stats software
* Lets set the text part for the stats software
*/
protected function getStats($domain)
{
protected function getStats($domain) {
$stats_text = '';
if ($domain['speciallogfile'] == '1') {
$statDomain = ($domain['parentdomainid'] == '0') ? $domain['domain'] : $domain['parentdomain'];
if ($this->settings['system']['awstats_enabled'] == '1') {
if (Settings::Get('system.awstats_enabled') == '1') {
$stats_text .= ' Alias /awstats "' . makeCorrectFile($domain['customerroot'] . '/awstats/' . $statDomain) . '"' . "\n";
$stats_text .= ' Alias /awstats-icon "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '"' . "\n";
$stats_text .= ' Alias /awstats-icon "' . makeCorrectDir(Settings::Get('system.awstats_icons')) . '"' . "\n";
} else {
$stats_text .= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer/' . $statDomain) . '"' . "\n";
}
} else {
if ($domain['customerroot'] != $domain['documentroot']) {
if ($this->settings['system']['awstats_enabled'] == '1') {
if (Settings::Get('system.awstats_enabled') == '1') {
$stats_text.= ' Alias /awstats "' . makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['domain']) . '"' . "\n";
$stats_text.= ' Alias /awstats-icon "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '"' . "\n";
$stats_text.= ' Alias /awstats-icon "' . makeCorrectDir(Settings::Get('system.awstats_icons')) . '"' . "\n";
} else {
$stats_text.= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer') . '"' . "\n";
}
@@ -489,15 +485,16 @@ class apache
// because the stats are in /awstats/[domain], not just /awstats/
// also, the awstats-icons are someplace else too!
// -> webalizer does not need this!
elseif ($this->settings['system']['awstats_enabled'] == '1') {
elseif (Settings::Get('system.awstats_enabled') == '1') {
$stats_text.= ' Alias /awstats "' . makeCorrectFile($domain['documentroot'] . '/awstats/' . $domain['domain']) . '"' . "\n";
$stats_text.= ' Alias /awstats-icon "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '"' . "\n";
$stats_text.= ' Alias /awstats-icon "' . makeCorrectDir(Settings::Get('system.awstats_icons')) . '"' . "\n";
}
}
return $stats_text;
}
/**
* Lets set the logfiles
*/
@@ -516,22 +513,22 @@ class apache
}
// The normal access/error - logging is enabled
$error_log = makeCorrectFile($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-error.log');
$error_log = makeCorrectFile(Settings::Get('system.logfiles_directory') . $domain['loginname'] . $speciallogfile . '-error.log');
// Create the logfile if it does not exist (fixes #46)
touch($error_log);
chown($error_log, $this->settings['system']['httpuser']);
chgrp($error_log, $this->settings['system']['httpgroup']);
chown($error_log, Settings::Get('system.httpuser'));
chgrp($error_log, Settings::Get('system.httpgroup'));
$access_log = makeCorrectFile($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log');
$access_log = makeCorrectFile(Settings::Get('system.logfiles_directory') . $domain['loginname'] . $speciallogfile . '-access.log');
// Create the logfile if it does not exist (fixes #46)
touch($access_log);
chown($access_log, $this->settings['system']['httpuser']);
chgrp($access_log, $this->settings['system']['httpgroup']);
chown($access_log, Settings::Get('system.httpuser'));
chgrp($access_log, Settings::Get('system.httpgroup'));
$logfiles_text .= ' ErrorLog "' . $error_log . "\"\n";
$logfiles_text .= ' CustomLog "' . $access_log .'" combined' . "\n";
if ($this->settings['system']['awstats_enabled'] == '1') {
if (Settings::Get('system.awstats_enabled') == '1') {
if ((int)$domain['parentdomainid'] == 0) {
// prepare the aliases and subdomains for stats config files
$server_alias = '';
@@ -564,22 +561,22 @@ class apache
// be sure to build the awstats conf file as well
// and chown it using $awstats_params, #258
// Bug 960 + Bug 970 : Use full $domain instead of custom $awstats_params as following classes depend on the informations
createAWStatsConf($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log', $domain['domain'], $alias . $server_alias, $domain['customerroot'], $domain);
createAWStatsConf(Settings::Get('system.logfiles_directory') . $domain['loginname'] . $speciallogfile . '-access.log', $domain['domain'], $alias . $server_alias, $domain['customerroot'], $domain);
}
}
return $logfiles_text;
}
/**
* Get the filename for the virtualhost
* Get the filename for the virtualhost
*/
protected function getVhostFilename($domain, $ssl_vhost = false)
{
protected function getVhostFilename($domain, $ssl_vhost = false) {
if ((int)$domain['parentdomainid'] == 0
&& isCustomerStdSubdomain((int)$domain['id']) == false
&& ((int)$domain['ismainbutsubto'] == 0
|| domainMainToSubExists($domain['ismainbutsubto']) == false)
|| domainMainToSubExists($domain['ismainbutsubto']) == false)
) {
$vhost_no = '22';
} elseif ((int)$domain['parentdomainid'] == 0
@@ -592,31 +589,31 @@ class apache
}
if ($ssl_vhost === true) {
$vhost_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/'.$vhost_no.'_froxlor_ssl_vhost_' . $domain['domain'] . '.conf');
$vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/'.$vhost_no.'_froxlor_ssl_vhost_' . $domain['domain'] . '.conf');
} else {
$vhost_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/'.$vhost_no.'_froxlor_normal_vhost_' . $domain['domain'] . '.conf');
$vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/'.$vhost_no.'_froxlor_normal_vhost_' . $domain['domain'] . '.conf');
}
return $vhost_filename;
}
/**
* We compose the virtualhost entry for one domain
* We compose the virtualhost entry for one domain
*/
protected function getVhostContent($domain, $ssl_vhost = false)
{
protected function getVhostContent($domain, $ssl_vhost = false) {
if ($ssl_vhost === true
&& ($domain['ssl_redirect'] != '1'
&& $domain['ssl'] != '1')
&& ($domain['ssl_redirect'] != '1'
&& $domain['ssl'] != '1')
) {
return '';
}
$query = "SELECT * FROM `".TABLE_PANEL_IPSANDPORTS."` `i`, `".TABLE_DOMAINTOIP."` `dip`
$query = "SELECT * FROM `".TABLE_PANEL_IPSANDPORTS."` `i`, `".TABLE_DOMAINTOIP."` `dip`
WHERE dip.id_domain = :domainid AND i.id = dip.id_ipandports ";
if ($ssl_vhost === true
&& ($domain['ssl'] == '1' || $domain['ssl_redirect'] == '1')
&& ($domain['ssl'] == '1' || $domain['ssl_redirect'] == '1')
) {
// by ordering by cert-file the row with filled out SSL-Fields will be shown last, thus it is enough to fill out 1 set of SSL-Fields
$query .= "AND i.ssl = '1' ORDER BY i.ssl_cert_file ASC;";
@@ -663,9 +660,9 @@ class apache
$vhost_content .= '<VirtualHost ' . trim($ipportlist) . '>' . "\n";
$vhost_content.= $this->getServerNames($domain);
if(($ssl_vhost == false
&& $domain['ssl'] == '1'
&& $domain['ssl_redirect'] == '1')
if (($ssl_vhost == false
&& $domain['ssl'] == '1'
&& $domain['ssl_redirect'] == '1')
) {
// We must not check if our port differs from port 443,
// but if there is a destination-port != 443
@@ -691,29 +688,29 @@ class apache
if ($ssl_vhost === true
&& $domain['ssl'] == '1'
&& $this->settings['system']['use_ssl'] == '1'
&& Settings::Get('system.use_ssl') == '1'
) {
if ($domain['ssl_cert_file'] == '') {
$domain['ssl_cert_file'] = $this->settings['system']['ssl_cert_file'];
$domain['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
}
if ($domain['ssl_key_file'] == '') {
$domain['ssl_key_file'] = $this->settings['system']['ssl_key_file'];
$domain['ssl_key_file'] = Settings::Get('system.ssl_key_file');
}
if ($domain['ssl_ca_file'] == '') {
$domain['ssl_ca_file'] = $this->settings['system']['ssl_ca_file'];
$domain['ssl_ca_file'] = Settings::Get('system.ssl_ca_file');
}
if ($domain['ssl_cert_chainfile'] == '') {
$domain['ssl_cert_chainfile'] = $this->settings['system']['ssl_cert_chainfile'];
$domain['ssl_cert_chainfile'] = Settings::Get('system.ssl_cert_chainfile');
}
if ($domain['ssl_cert_file'] != '') {
$vhost_content .= ' SSLEngine On' . "\n";
// this makes it more secure, thx to Marcel (08/2013)
$vhost_content .= ' SSLHonorCipherOrder On' . "\n";
$vhost_content .= ' SSLCipherSuite ' . $this->settings['system']['ssl_cipher_list'] . "\n";
$vhost_content .= ' SSLCipherSuite ' . Settings::Get('system.ssl_cipher_list') . "\n";
$vhost_content .= ' SSLVerifyDepth 10' . "\n";
$vhost_content .= ' SSLCertificateFile ' . makeCorrectFile($domain['ssl_cert_file']) . "\n";
@@ -769,8 +766,8 @@ class apache
$vhost_content .= $_vhost_content;
}
if ($this->settings['system']['default_vhostconf'] != '') {
$vhost_content .= $this->settings['system']['default_vhostconf'] . "\n";
if (Settings::Get('system.default_vhostconf') != '') {
$vhost_content .= Settings::Get('system.default_vhostconf') . "\n";
}
}
@@ -779,8 +776,9 @@ class apache
return $vhost_content;
}
/**
* We compose the virtualhost entries for the domains
* We compose the virtualhost entries for the domains
*/
public function createVirtualHosts() {
@@ -795,7 +793,7 @@ class apache
$this->virtualhosts_data[$vhosts_filename] = '# Domain ID: ' . $domain['id'] . ' - CustomerID: ' . $domain['customerid'] . ' - CustomerLogin: ' . $domain['loginname'] . "\n";
if ($domain['deactivated'] != '1'
|| $this->settings['system']['deactivateddocroot'] != ''
|| Settings::Get('system.deactivateddocroot') != ''
) {
// Create vhost without ssl
$this->virtualhosts_data[$vhosts_filename].= $this->getVhostContent($domain, false);
@@ -812,11 +810,11 @@ class apache
}
}
/**
* We compose the diroption entries for the paths
* We compose the diroption entries for the paths
*/
public function createFileDirOptions()
{
public function createFileDirOptions() {
$result_stmt = Database::query("
SELECT `htac`.*, `c`.`guid`, `c`.`documentroot` AS `customerroot`
FROM `" . TABLE_PANEL_HTACCESS . "` `htac`
@@ -827,8 +825,8 @@ class apache
while ($row_diroptions = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($row_diroptions['customerid'] != 0
&& isset($row_diroptions['customerroot'])
&& $row_diroptions['customerroot'] != ''
&& isset($row_diroptions['customerroot'])
&& $row_diroptions['customerroot'] != ''
) {
$diroptions[$row_diroptions['path']] = $row_diroptions;
$diroptions[$row_diroptions['path']]['htpasswds'] = array();
@@ -844,8 +842,8 @@ class apache
while ($row_htpasswds = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($row_htpasswds['customerid'] != 0
&& isset($row_htpasswds['customerroot'])
&& $row_htpasswds['customerroot'] != ''
&& isset($row_htpasswds['customerroot'])
&& $row_htpasswds['customerroot'] != ''
) {
if (!isset($diroptions[$row_htpasswds['path']]) || !is_array($diroptions[$row_htpasswds['path']])) {
$diroptions[$row_htpasswds['path']] = array();
@@ -862,7 +860,7 @@ class apache
foreach ($diroptions as $row_diroptions) {
$row_diroptions['path'] = makeCorrectDir($row_diroptions['path']);
mkDirWithCorrectOwnership($row_diroptions['customerroot'], $row_diroptions['path'], $row_diroptions['guid'], $row_diroptions['guid']);
$diroptions_filename = makeCorrectFile($this->settings['system']['apacheconf_diroptions'] . '/40_froxlor_diroption_' . md5($row_diroptions['path']) . '.conf');
$diroptions_filename = makeCorrectFile(Settings::Get('system.apacheconf_diroptions') . '/40_froxlor_diroption_' . md5($row_diroptions['path']) . '.conf');
if (!isset($this->diroptions_data[$diroptions_filename])) {
$this->diroptions_data[$diroptions_filename] = '';
@@ -874,7 +872,7 @@ class apache
$this->diroptions_data[$diroptions_filename] .= '<Directory "' . $row_diroptions['path'] . '">' . "\n";
if (isset($row_diroptions['options_indexes'])
&& $row_diroptions['options_indexes'] == '1'
&& $row_diroptions['options_indexes'] == '1'
) {
$this->diroptions_data[$diroptions_filename] .= ' Options +Indexes';
@@ -891,7 +889,7 @@ class apache
}
if (isset($row_diroptions['options_indexes'])
&& $row_diroptions['options_indexes'] == '0'
&& $row_diroptions['options_indexes'] == '0'
) {
$this->diroptions_data[$diroptions_filename] .= ' Options -Indexes';
@@ -929,7 +927,7 @@ class apache
$this->diroptions_data[$diroptions_filename] .= ' AllowOverride None' . "\n";
$this->diroptions_data[$diroptions_filename] .= ' AddHandler cgi-script .cgi .pl' . "\n";
// >=apache-2.4 enabled?
if ($this->settings['system']['apache24'] == '1') {
if (Settings::Get('system.apache24') == '1') {
$this->diroptions_data[$diroptions_filename] .= ' Require all granted' . "\n";
} else {
$this->diroptions_data[$diroptions_filename] .= ' Order allow,deny' . "\n";
@@ -938,10 +936,10 @@ class apache
fwrite($this->debugHandler, ' cron_tasks: Task3 - Enabling perl execution' . "\n");
// check for suexec-workaround, #319
if ((int)$this->settings['perl']['suexecworkaround'] == 1) {
if ((int)Settings::Get('perl.suexecworkaround') == 1) {
// symlink this directory to suexec-safe-path
$loginname = getCustomerDetail($row_diroptions['customerid'], 'loginname');
$suexecpath = makeCorrectDir($this->settings['perl']['suexecpath'].'/'.$loginname.'/'.md5($row_diroptions['path']).'/');
$suexecpath = makeCorrectDir(Settings::Get('perl.suexecpath').'/'.$loginname.'/'.md5($row_diroptions['path']).'/');
if (!file_exists($suexecpath)) {
safe_exec('mkdir -p '.escapeshellarg($suexecpath));
@@ -959,9 +957,9 @@ class apache
} else {
// if no perl-execution is enabled but the workaround is,
// we have to remove the symlink and folder in suexecpath
if ((int)$this->settings['perl']['suexecworkaround'] == 1) {
if ((int)Settings::Get('perl.suexecworkaround') == 1) {
$loginname = getCustomerDetail($row_diroptions['customerid'], 'loginname');
$suexecpath = makeCorrectDir($this->settings['perl']['suexecpath'].'/'.$loginname.'/'.md5($row_diroptions['path']).'/');
$suexecpath = makeCorrectDir(Settings::Get('perl.suexecpath').'/'.$loginname.'/'.md5($row_diroptions['path']).'/');
$perlsymlink = makeCorrectFile($row_diroptions['path'].'/cgi-bin');
// remove symlink
@@ -976,7 +974,7 @@ class apache
}
if (count($row_diroptions['htpasswds']) > 0) {
$htpasswd_filename = makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $row_diroptions['customerid'] . '-' . md5($row_diroptions['path']) . '.htpasswd');
$htpasswd_filename = makeCorrectFile(Settings::Get('system.apacheconf_htpasswddir') . '/' . $row_diroptions['customerid'] . '-' . md5($row_diroptions['path']) . '.htpasswd');
if (!isset($this->htpasswds_data[$htpasswd_filename])) {
$this->htpasswds_data[$htpasswd_filename] = '';
@@ -997,17 +995,17 @@ class apache
}
}
/**
* We write the configs
* We write the configs
*/
public function writeConfigs()
{
public function writeConfigs() {
// Write diroptions
fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . $this->settings['system']['apacheconf_diroptions'] . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . $this->settings['system']['apacheconf_diroptions']);
fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_diroptions') . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_diroptions'));
if (count($this->diroptions_data) > 0) {
if (!isConfigDir($this->settings['system']['apacheconf_diroptions'])) {
if (!isConfigDir(Settings::Get('system.apacheconf_diroptions'))) {
// Save one big file
$diroptions_file = '';
@@ -1015,7 +1013,7 @@ class apache
$diroptions_file.= $diroptions_content . "\n\n";
}
$diroptions_filename = $this->settings['system']['apacheconf_diroptions'];
$diroptions_filename = Settings::Get('system.apacheconf_diroptions');
// Apply header
$diroptions_file = '# ' . basename($diroptions_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $diroptions_file;
@@ -1023,10 +1021,10 @@ class apache
fwrite($diroptions_file_handler, $diroptions_file);
fclose($diroptions_file_handler);
} else {
if (!file_exists($this->settings['system']['apacheconf_diroptions'])) {
fwrite($this->debugHandler, ' apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_diroptions'])) . "\n");
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_diroptions'])));
safe_exec('mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_diroptions'])));
if (!file_exists(Settings::Get('system.apacheconf_diroptions'))) {
fwrite($this->debugHandler, ' apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))) . "\n");
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))));
safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))));
}
// Write a single file for every diroption
@@ -1043,18 +1041,18 @@ class apache
}
// Write htpasswds
fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . $this->settings['system']['apacheconf_htpasswddir'] . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . $this->settings['system']['apacheconf_htpasswddir']);
fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_htpasswddir') . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_htpasswddir'));
if (count($this->htpasswds_data) > 0) {
if (!file_exists($this->settings['system']['apacheconf_htpasswddir'])) {
if (!file_exists(Settings::Get('system.apacheconf_htpasswddir'))) {
$umask = umask();
umask(0000);
mkdir($this->settings['system']['apacheconf_htpasswddir'], 0751);
mkdir(Settings::Get('system.apacheconf_htpasswddir'), 0751);
umask($umask);
}
if (isConfigDir($this->settings['system']['apacheconf_htpasswddir'], true)) {
if (isConfigDir(Settings::Get('system.apacheconf_htpasswddir'), true)) {
foreach ($this->htpasswds_data as $htpasswd_filename => $htpasswd_file) {
$this->known_htpasswdsfilenames[] = basename($htpasswd_filename);
$htpasswd_file_handler = fopen($htpasswd_filename, 'w');
@@ -1062,18 +1060,18 @@ class apache
fclose($htpasswd_file_handler);
}
} else {
fwrite($this->debugHandler, ' cron_tasks: WARNING!!! ' . $this->settings['system']['apacheconf_htpasswddir'] . ' is not a directory. htpasswd directory protection is disabled!!!' . "\n");
echo 'WARNING!!! ' . $this->settings['system']['apacheconf_htpasswddir'] . ' is not a directory. htpasswd directory protection is disabled!!!';
$this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . $this->settings['system']['apacheconf_htpasswddir'] . ' is not a directory. htpasswd directory protection is disabled!!!');
fwrite($this->debugHandler, ' cron_tasks: WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!' . "\n");
echo 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!';
$this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!');
}
}
// Write virtualhosts
fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . $this->settings['system']['apacheconf_vhost'] . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . $this->settings['system']['apacheconf_vhost']);
fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_vhost') . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_vhost'));
if (count($this->virtualhosts_data) > 0) {
if (!isConfigDir($this->settings['system']['apacheconf_vhost'])) {
if (!isConfigDir(Settings::Get('system.apacheconf_vhost'))) {
// Save one big file
$vhosts_file = '';
@@ -1089,11 +1087,11 @@ class apache
}
// Include diroptions file in case it exists
if (file_exists($this->settings['system']['apacheconf_diroptions'])) {
$vhosts_file.= "\n" . 'Include ' . $this->settings['system']['apacheconf_diroptions'] . "\n\n";
if (file_exists(Settings::Get('system.apacheconf_diroptions'))) {
$vhosts_file.= "\n" . 'Include ' . Settings::Get('system.apacheconf_diroptions') . "\n\n";
}
$vhosts_filename = $this->settings['system']['apacheconf_vhost'];
$vhosts_filename = Settings::Get('system.apacheconf_vhost');
// Apply header
$vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $vhosts_file;
@@ -1101,10 +1099,10 @@ class apache
fwrite($vhosts_file_handler, $vhosts_file);
fclose($vhosts_file_handler);
} else {
if (!file_exists($this->settings['system']['apacheconf_vhost'])) {
fwrite($this->debugHandler, ' apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])) . "\n");
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])));
safe_exec('mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])));
if (!file_exists(Settings::Get('system.apacheconf_vhost'))) {
fwrite($this->debugHandler, ' apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))) . "\n");
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
}
// Write a single file for every vhost
@@ -1120,4 +1118,6 @@ class apache
}
}
}
}

View File

@@ -28,7 +28,7 @@ class apache_fcgid extends apache
$php = new phpinterface($domain);
$phpconfig = $php->getPhpConfig((int)$domain['phpsettingid']);
if((int)$this->settings['phpfpm']['enabled'] == 1)
if((int)Settings::Get('phpfpm.enabled') == 1)
{
$srvName = 'fpm.external';
if ($domain['ssl'] == 1 && $ssl_vhost) {
@@ -39,7 +39,7 @@ class apache_fcgid extends apache
if (customerHasPerlEnabled($domain['customerid'])) {
$php_options_text.= ' SuexecUserGroup "' . $domain['loginname'] . '" "' . $domain['loginname'] . '"' . "\n";
}
$php_options_text.= ' FastCgiExternalServer ' . $php->getInterface()->getAliasConfigDir() . $srvName . ' -socket ' . $php->getInterface()->getSocketFile() . ' -idle-timeout ' . $this->settings['phpfpm']['idle_timeout'] . "\n";
$php_options_text.= ' FastCgiExternalServer ' . $php->getInterface()->getAliasConfigDir() . $srvName . ' -socket ' . $php->getInterface()->getSocketFile() . ' -idle-timeout ' . Settings::Get('phpfpm.idle_timeout') . "\n";
$php_options_text.= ' <Directory "' . makeCorrectDir($domain['documentroot']) . '">' . "\n";
$php_options_text.= ' <FilesMatch "\.php$">' . "\n";
$php_options_text.= ' SetHandler php5-fastcgi'. "\n";
@@ -47,7 +47,7 @@ class apache_fcgid extends apache
$php_options_text.= ' Options +ExecCGI' . "\n";
$php_options_text.= ' </FilesMatch>' . "\n";
// >=apache-2.4 enabled?
if ($this->settings['system']['apache24'] == '1') {
if (Settings::Get('system.apache24') == '1') {
$php_options_text.= ' Require all granted' . "\n";
} else {
$php_options_text.= ' Order allow,deny' . "\n";
@@ -58,8 +58,8 @@ class apache_fcgid extends apache
}
else
{
$php_options_text.= ' FcgidIdleTimeout ' . $this->settings['system']['mod_fcgid_idle_timeout'] . "\n";
if((int)$this->settings['system']['mod_fcgid_wrapper'] == 0)
$php_options_text.= ' FcgidIdleTimeout ' . Settings::Get('system.mod_fcgid_idle_timeout') . "\n";
if((int)Settings::Get('system.mod_fcgid_wrapper') == 0)
{
$php_options_text.= ' SuexecUserGroup "' . $domain['loginname'] . '" "' . $domain['loginname'] . '"' . "\n";
$php_options_text.= ' ScriptAlias /php/ ' . $php->getInterface()->getConfigDir() . "\n";
@@ -78,7 +78,7 @@ class apache_fcgid extends apache
$php_options_text.= ' Options +ExecCGI' . "\n";
$php_options_text.= ' </FilesMatch>' . "\n";
// >=apache-2.4 enabled?
if ($this->settings['system']['apache24'] == '1') {
if (Settings::Get('system.apache24') == '1') {
$php_options_text.= ' Require all granted' . "\n";
} else {
$php_options_text.= ' Order allow,deny' . "\n";
@@ -105,33 +105,33 @@ class apache_fcgid extends apache
public function createOwnVhostStarter()
{
if ($this->settings['system']['mod_fcgid_ownvhost'] == '1'
|| ($this->settings['phpfpm']['enabled'] == '1'
&& $this->settings['phpfpm']['enabled_ownvhost'] == '1')
if (Settings::Get('system.mod_fcgid_ownvhost') == '1'
|| (Settings::Get('phpfpm.enabled') == '1'
&& Settings::Get('phpfpm.enabled_ownvhost') == '1')
) {
$mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__)))); // /var/www/froxlor, needed for chown
if ($this->settings['system']['mod_fcgid_ownvhost'] == '1')
if (Settings::Get('system.mod_fcgid_ownvhost') == '1')
{
$user = $this->settings['system']['mod_fcgid_httpuser'];
$group = $this->settings['system']['mod_fcgid_httpgroup'];
$user = Settings::Get('system.mod_fcgid_httpuser');
$group = Settings::Get('system.mod_fcgid_httpgroup');
}
elseif($this->settings['phpfpm']['enabled'] == '1'
&& $this->settings['phpfpm']['enabled_ownvhost'] == '1'
elseif(Settings::Get('phpfpm.enabled') == '1'
&& Settings::Get('phpfpm.enabled_ownvhost') == '1'
) {
$user = $this->settings['phpfpm']['vhost_httpuser'];
$group = $this->settings['phpfpm']['vhost_httpgroup'];
$user = Settings::Get('phpfpm.vhost_httpuser');
$group = Settings::Get('phpfpm.vhost_httpgroup');
}
$domain = array(
'id' => 'none',
'domain' => $this->settings['system']['hostname'],
'domain' => Settings::Get('system.hostname'),
'adminid' => 1, /* first admin-user (superadmin) */
'mod_fcgid_starter' => -1,
'mod_fcgid_maxrequests' => -1,
'guid' => $user,
'openbasedir' => 0,
'email' => $this->settings['panel']['adminmail'],
'email' => Settings::Get('panel.adminmail'),
'loginname' => 'froxlor.panel',
'documentroot' => $mypath
);
@@ -144,12 +144,12 @@ class apache_fcgid extends apache
$php = new phpinterface($domain);
// get php-config
if ($this->settings['phpfpm']['enabled'] == '1') {
if (Settings::Get('phpfpm.enabled') == '1') {
// fpm
$phpconfig = $php->getPhpConfig($this->settings['phpfpm']['vhost_defaultini']);
$phpconfig = $php->getPhpConfig(Settings::Get('phpfpm.vhost_defaultini'));
} else {
// fcgid
$phpconfig = $php->getPhpConfig($this->settings['system']['mod_fcgid_defaultini_ownvhost']);
$phpconfig = $php->getPhpConfig(Settings::Get('system.mod_fcgid_defaultini_ownvhost'));
}
// create starter-file | config-file

View File

@@ -18,14 +18,12 @@
* @TODO ssl-redirect to non-standard port
*/
class lighttpd
{
class lighttpd {
private $logger = false;
private $debugHandler = false;
private $idnaConvert = false;
// protected
protected $settings = array();
// protected
protected $lighttpd_data = array();
protected $needed_htpasswds = array();
protected $auth_backend_loaded = false;
@@ -40,28 +38,26 @@ class lighttpd
*/
private $_deactivated = false;
public function __construct($logger, $debugHandler, $idnaConvert, $settings)
{
public function __construct($logger, $debugHandler, $idnaConvert) {
$this->logger = $logger;
$this->debugHandler = $debugHandler;
$this->idnaConvert = $idnaConvert;
$this->settings = $settings;
}
public function reload()
{
if ((int)$this->settings['phpfpm']['enabled'] == 1) {
public function reload() {
if ((int)Settings::Get('phpfpm.enabled') == 1) {
fwrite($this->debugHandler, ' lighttpd::reload: reloading php-fpm' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm');
safe_exec(escapeshellcmd($this->settings['phpfpm']['reload']));
safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload')));
}
fwrite($this->debugHandler, ' lighttpd::reload: reloading lighttpd' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading lighttpd');
safe_exec(escapeshellcmd($this->settings['system']['apachereload_command']));
safe_exec(escapeshellcmd(Settings::Get('system.apachereload_command')));
}
public function createIpPort()
{
public function createIpPort() {
$result_ipsandports_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` ORDER BY `ip` ASC, `port` ASC");
while ($row_ipsandports = $result_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
@@ -77,7 +73,7 @@ class lighttpd
fwrite($this->debugHandler, ' lighttpd::createIpPort: creating ip/port settings for ' . $ip . ":" . $port . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating ip/port settings for ' . $ip . ":" . $port);
$vhost_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf');
$vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf');
if (!isset($this->lighttpd_data[$vhost_filename])) {
$this->lighttpd_data[$vhost_filename] = '';
@@ -92,12 +88,12 @@ class lighttpd
}
if ($row_ipsandports['vhostcontainer'] == '1') {
$myhost = str_replace('.', '\.', $this->settings['system']['hostname']);
$myhost = str_replace('.', '\.', Settings::Get('system.hostname'));
$this->lighttpd_data[$vhost_filename].= '# Froxlor default vhost' . "\n";
$this->lighttpd_data[$vhost_filename].= '$HTTP["host"] =~ "^(?:www\.|)' . $myhost . '$" {' . "\n";
if ($row_ipsandports['docroot'] == '') {
if ($this->settings['system']['froxlordirectlyviahostname']) {
if (Settings::Get('system.froxlordirectlyviahostname')) {
$mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__))));
} else {
$mypath = makeCorrectDir(dirname(dirname(dirname(dirname(__FILE__)))));
@@ -113,24 +109,24 @@ class lighttpd
* dirprotection, see #72
* @TODO use better regex for this, deferred until 0.9.5
*
$this->lighttpd_data[$vhost_filename].= ' $HTTP["url"] =~ "^/(.+)\/(.+)\.php" {' . "\n";
$this->lighttpd_data[$vhost_filename].= ' url.access-deny = ("")' . "\n";
$this->lighttpd_data[$vhost_filename].= ' }' . "\n";
*/
$this->lighttpd_data[$vhost_filename].= ' $HTTP["url"] =~ "^/(.+)\/(.+)\.php" {' . "\n";
$this->lighttpd_data[$vhost_filename].= ' url.access-deny = ("")' . "\n";
$this->lighttpd_data[$vhost_filename].= ' }' . "\n";
*/
/**
* own php-fpm vhost
*/
if ((int)$this->settings['phpfpm']['enabled'] == 1) {
if ((int)Settings::Get('phpfpm.enabled') == 1) {
$domain = array(
'id' => 'none',
'domain' => $this->settings['system']['hostname'],
'domain' => Settings::Get('system.hostname'),
'adminid' => 1, /* first admin-user (superadmin) */
'mod_fcgid_starter' => -1,
'mod_fcgid_maxrequests' => -1,
'guid' => $this->settings['phpfpm']['vhost_httpuser'],
'guid' => Settings::Get('phpfpm.vhost_httpuser'),
'openbasedir' => 0,
'email' => $this->settings['panel']['adminmail'],
'email' => Settings::Get('panel.adminmail'),
'loginname' => 'froxlor.panel',
'documentroot' => $mypath
);
@@ -138,14 +134,14 @@ class lighttpd
$php = new phpinterface($domain);
$this->lighttpd_data[$vhost_filename].= ' fastcgi.server = ( '."\n";
$this->lighttpd_data[$vhost_filename].= "\t".'".php" => ('."\n";
$this->lighttpd_data[$vhost_filename].= "\t\t".'"localhost" => ('."\n";
$this->lighttpd_data[$vhost_filename].= "\t\t".'"socket" => "'.$php->getInterface()->getSocketFile().'",'."\n";
$this->lighttpd_data[$vhost_filename].= "\t\t".'"check-local" => "enable",'."\n";
$this->lighttpd_data[$vhost_filename].= "\t\t".'"disable-time" => 1'."\n";
$this->lighttpd_data[$vhost_filename].= "\t".')'."\n";
$this->lighttpd_data[$vhost_filename].= "\t".')'."\n";
$this->lighttpd_data[$vhost_filename].= ' )'."\n";
$this->lighttpd_data[$vhost_filename].= "\t".'".php" => ('."\n";
$this->lighttpd_data[$vhost_filename].= "\t\t".'"localhost" => ('."\n";
$this->lighttpd_data[$vhost_filename].= "\t\t".'"socket" => "'.$php->getInterface()->getSocketFile().'",'."\n";
$this->lighttpd_data[$vhost_filename].= "\t\t".'"check-local" => "enable",'."\n";
$this->lighttpd_data[$vhost_filename].= "\t\t".'"disable-time" => 1'."\n";
$this->lighttpd_data[$vhost_filename].= "\t".')'."\n";
$this->lighttpd_data[$vhost_filename].= "\t".')'."\n";
$this->lighttpd_data[$vhost_filename].= ' )'."\n";
}
if ($row_ipsandports['specialsettings'] != '') {
@@ -157,17 +153,17 @@ class lighttpd
if ($row_ipsandports['ssl'] == '1') {
if ($row_ipsandports['ssl_cert_file'] == '') {
$row_ipsandports['ssl_cert_file'] = $this->settings['system']['ssl_cert_file'];
$row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
}
if ($row_ipsandports['ssl_ca_file'] == '') {
$row_ipsandports['ssl_ca_file'] = $this->settings['system']['ssl_ca_file'];
$row_ipsandports['ssl_ca_file'] = Settings::Get('system.ssl_ca_file');
}
if ($row_ipsandports['ssl_cert_file'] != '') {
$this->lighttpd_data[$vhost_filename].= 'ssl.engine = "enable"' . "\n";
$this->lighttpd_data[$vhost_filename].= 'ssl.use-sslv2 = "disable"' . "\n";
$this->lighttpd_data[$vhost_filename].= 'ssl.cipher-list = "' . $this->settings['system']['ssl_cipher_list'] . '"' . "\n";
$this->lighttpd_data[$vhost_filename].= 'ssl.cipher-list = "' . Settings::Get('system.ssl_cipher_list') . '"' . "\n";
$this->lighttpd_data[$vhost_filename].= 'ssl.honor-cipher-order = "enable"' . "\n";
$this->lighttpd_data[$vhost_filename].= 'ssl.pemfile = "' . makeCorrectFile($row_ipsandports['ssl_cert_file']) . '"' . "\n";
@@ -179,7 +175,7 @@ class lighttpd
/**
* this function will create a new file which will be included
* if $this->settings['system']['apacheconf_vhost'] is a folder
* if Settings::Get('system.apacheconf_vhost') is a folder
* refs #70
*/
$vhosts = $this->createLighttpdHosts($row_ipsandports['id'], $row_ipsandports['ssl'], $vhost_filename);
@@ -201,21 +197,21 @@ class lighttpd
$this->_createStandardErrorHandler();
}
/**
* define a default server.error-handler-404-statement, bug #unknown-yet
*/
private function _createStandardErrorHandler()
{
if ($this->settings['defaultwebsrverrhandler']['enabled'] == '1'
&& $this->settings['defaultwebsrverrhandler']['err404'] != ''
private function _createStandardErrorHandler() {
if (Settings::Get('defaultwebsrverrhandler.enabled') == '1'
&& Settings::Get('defaultwebsrverrhandler.err404') != ''
) {
$vhost_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/05_froxlor_default_errorhandler.conf');
$vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/05_froxlor_default_errorhandler.conf');
if (!isset($this->lighttpd_data[$vhost_filename])) {
$this->lighttpd_data[$vhost_filename] = '';
}
$defhandler = $this->settings['defaultwebsrverrhandler']['err404'];
$defhandler = Settings::Get('defaultwebsrverrhandler.err404');
if (!validateUrl($defhandler)) {
$defhandler = makeCorrectFile($defhandler);
}
@@ -223,8 +219,8 @@ class lighttpd
}
}
protected function create_htaccess($domain)
{
protected function create_htaccess($domain) {
$needed_htpasswds = array();
$result_htpasswds_stmt = Database::prepare("
SELECT * FROM " . TABLE_PANEL_HTPASSWDS . "
@@ -236,7 +232,7 @@ class lighttpd
while ($row_htpasswds = $result_htpasswds_stmt->fetch(PDO::FETCH_ASSOC)) {
$row_htpasswds['path'] = makeCorrectDir($row_htpasswds['path']);
mkDirWithCorrectOwnership($domain['documentroot'], $row_htpasswds['path'], $domain['guid'], $domain['guid']);
$filename = $row_htpasswds['customerid'] . '-' . md5($row_htpasswds['path']) . '.htpasswd';
if (!in_array($row_htpasswds['path'], $needed_htpasswds)) {
@@ -253,7 +249,7 @@ class lighttpd
$htaccess_text.= ' $HTTP["url"] =~ "^'.$htaccess_path.'" {' . "\n";
$htaccess_text.= ' auth.backend = "htpasswd"' . "\n";
$htaccess_text.= ' auth.backend.htpasswd.userfile = "' . makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $filename) . '"' . "\n";
$htaccess_text.= ' auth.backend.htpasswd.userfile = "' . makeCorrectFile(Settings::Get('system.apacheconf_htpasswddir') . '/' . $filename) . '"' . "\n";
$htaccess_text.= ' auth.require = ( ' . "\n";
$htaccess_text.= ' "' . $htaccess_path . '" =>' . "\n";
$htaccess_text.= ' (' . "\n";
@@ -271,47 +267,48 @@ class lighttpd
return $htaccess_text;
}
public function createVirtualHosts()
{
public function createVirtualHosts() {
}
public function createFileDirOptions()
{
public function createFileDirOptions() {
}
protected function composePhpOptions($domain)
{
protected function composePhpOptions($domain) {
}
public function createOwnVhostStarter()
{
public function createOwnVhostStarter() {
}
protected function createLighttpdHosts($ipid, $ssl, $vhost_filename) {
$domains = WebserverBase::getVhostsToCreate();
foreach ($domains as $domain) {
if (is_dir($this->settings['system']['apacheconf_vhost'])) {
safe_exec('mkdir -p '.escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'].'/vhosts/')));
if (is_dir(Settings::Get('system.apacheconf_vhost'))) {
safe_exec('mkdir -p '.escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost').'/vhosts/')));
// determine correct include-path:
// e.g. '/etc/lighttpd/conf-enabled/vhosts/ has to become'
// 'conf-enabled/vhosts/' (damn debian, but luckily works too on other distros)
$_tmp_path = substr(makeCorrectDir($this->settings['system']['apacheconf_vhost']), 0, -1);
$_tmp_path = substr(makeCorrectDir(Settings::Get('system.apacheconf_vhost')), 0, -1);
$_pos = strrpos($_tmp_path, '/');
$_inc_path = substr($_tmp_path, $_pos+1);
// subdomain
if((int)$domain['parentdomainid'] == 0
if ((int)$domain['parentdomainid'] == 0
&& isCustomerStdSubdomain((int)$domain['id']) == false
&& ((int)$domain['ismainbutsubto'] == 0
|| domainMainToSubExists($domain['ismainbutsubto']) == false)
|| domainMainToSubExists($domain['ismainbutsubto']) == false)
) {
$vhost_no = '50';
}
// sub-but-main-domain
elseif((int)$domain['parentdomainid'] == 0
elseif ((int)$domain['parentdomainid'] == 0
&& isCustomerStdSubdomain((int)$domain['id']) == false
&& (int)$domain['ismainbutsubto'] > 0
) {
@@ -326,7 +323,7 @@ class lighttpd
$vhost_no = (int)$vhost_no += 10;
}
$vhost_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'].'/vhosts/'.$vhost_no.'_'.$domain['domain'].'.conf');
$vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost').'/vhosts/'.$vhost_no.'_'.$domain['domain'].'.conf');
$included_vhosts[] = $_inc_path.'/vhosts/'.$vhost_no.'_'.$domain['domain'].'.conf';
}
@@ -335,8 +332,8 @@ class lighttpd
}
if ((!empty($this->lighttpd_data[$vhost_filename])
&& !is_dir($this->settings['system']['apacheconf_vhost']))
|| is_dir($this->settings['system']['apacheconf_vhost'])
&& !is_dir(Settings::Get('system.apacheconf_vhost')))
|| is_dir(Settings::Get('system.apacheconf_vhost'))
) {
if ($ssl == '1') {
$ssl_vhost = true;
@@ -356,8 +353,8 @@ class lighttpd
return $included_vhosts;
}
protected function getVhostContent($domain, $ssl_vhost = false, $ipid)
{
protected function getVhostContent($domain, $ssl_vhost = false, $ipid) {
if ($ssl_vhost === true
&& $domain['ssl'] != '1'
&& $domain['ssl_redirect'] != '1'
@@ -449,8 +446,8 @@ class lighttpd
$vhost_content.= $ipandport['default_vhostconf_domain'] . "\n";
}
if ($this->settings['system']['default_vhostconf'] != '') {
$vhost_content.= $this->settings['system']['default_vhostconf'] . "\n";
if (Settings::Get('system.default_vhostconf') != '') {
$vhost_content.= Settings::Get('system.default_vhostconf') . "\n";
}
}
$vhost_content.= $this->getLogFiles($domain);
@@ -462,26 +459,26 @@ class lighttpd
return $vhost_content;
}
protected function getSslSettings($domain, $ssl_vhost)
{
protected function getSslSettings($domain, $ssl_vhost) {
$ssl_settings = '';
if($ssl_vhost === true
if ($ssl_vhost === true
&& $domain['ssl'] == '1'
&& (int)$this->settings['system']['use_ssl'] == 1
&& (int)Settings::Get('system.use_ssl') == 1
) {
if ($domain['ssl_cert_file'] == '') {
$domain['ssl_cert_file'] = $this->settings['system']['ssl_cert_file'];
$domain['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
}
if ($domain['ssl_ca_file'] == '') {
$domain['ssl_ca_file'] = $this->settings['system']['ssl_ca_file'];
$domain['ssl_ca_file'] = Settings::Get('system.ssl_ca_file');
}
if ($domain['ssl_cert_file'] != '') {
$ssl_settings.= 'ssl.engine = "enable"' . "\n";
$ssl_settings.= 'ssl.use-sslv2 = "disable"' . "\n";
$ssl_settings.= 'ssl.cipher-list = "' . $this->settings['system']['ssl_cipher_list'] . '"' . "\n";
$ssl_settings.= 'ssl.cipher-list = "' . Settings::Get('system.ssl_cipher_list') . '"' . "\n";
$ssl_settings.= 'ssl.honor-cipher-order = "enable"' . "\n";
$ssl_settings.= 'ssl.pemfile = "' . makeCorrectFile($domain['ssl_cert_file']) . '"' . "\n";
@@ -493,10 +490,11 @@ class lighttpd
return $ssl_settings;
}
protected function getLogFiles($domain) {
$logfiles_text = '';
$speciallogfile = '';
if ($domain['speciallogfile'] == '1') {
if ($domain['parentdomainid'] == '0') {
@@ -509,15 +507,15 @@ class lighttpd
// The normal access/error - logging is enabled
// error log cannot be set conditionally see
// https://redmine.lighttpd.net/issues/665
$access_log = makeCorrectFile($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log');
$access_log = makeCorrectFile(Settings::Get('system.logfiles_directory') . $domain['loginname'] . $speciallogfile . '-access.log');
// Create the logfile if it does not exist (fixes #46)
touch($access_log);
chown($access_log, $this->settings['system']['httpuser']);
chgrp($access_log, $this->settings['system']['httpgroup']);
chown($access_log, Settings::Get('system.httpuser'));
chgrp($access_log, Settings::Get('system.httpgroup'));
$logfiles_text.= ' accesslog.filename = "' . $access_log . '"' . "\n";
if ($this->settings['system']['awstats_enabled'] == '1') {
if (Settings::Get('system.awstats_enabled') == '1') {
if ((int)$domain['parentdomainid'] == 0) {
// prepare the aliases and subdomains for stats config files
@@ -528,11 +526,11 @@ class lighttpd
WHERE `aliasdomain` = :domainid OR `parentdomainid` = :domainid
");
Database::pexecute($alias_domains_stmt, array('domainid' => $domain['id']));
while (($alias_domain = $alias_domains_stmt->fetch(PDO::FETCH_ASSOC)) !== false) {
$server_alias.= ' ' . $alias_domain['domain'] . ' ';
if ($alias_domain['iswildcarddomain'] == '1') {
$server_alias.= '*.' . $domain['domain'];
} else {
@@ -543,7 +541,7 @@ class lighttpd
}
}
}
if ($domain['iswildcarddomain'] == '1') {
$alias = '*.' . $domain['domain'];
} else {
@@ -553,20 +551,20 @@ class lighttpd
$alias = '';
}
}
// After inserting the AWStats information,
// After inserting the AWStats information,
// be sure to build the awstats conf file as well
// and chown it using $awstats_params, #258
// Bug 960 + Bug 970 : Use full $domain instead of custom $awstats_params as following classes depend on the informations
createAWStatsConf($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log', $domain['domain'], $alias . $server_alias, $domain['customerroot'], $domain);
createAWStatsConf(Settings::Get('system.logfiles_directory') . $domain['loginname'] . $speciallogfile . '-access.log', $domain['domain'], $alias . $server_alias, $domain['customerroot'], $domain);
}
}
return $logfiles_text;
}
protected function create_pathOptions($domain)
{
protected function create_pathOptions($domain) {
$result_stmt = Database::prepare("
SELECT * FROM " . TABLE_PANEL_HTACCESS . "
WHERE `path` LIKE :docroot
@@ -594,7 +592,7 @@ class lighttpd
}
$path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
// We need to remove the last slash, otherwise the regex wouldn't work
if ($row['path'] != $domain['documentroot']) {
@@ -611,16 +609,16 @@ class lighttpd
&& $row['options_cgi'] != '0'
) {
$path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
// We need to remove the last slash, otherwise the regex wouldn't work
if($row['path'] != $domain['documentroot']) {
if ($row['path'] != $domain['documentroot']) {
$path = substr($path, 0, -1);
}
$path_options.= ' $HTTP["url"] =~ "^' . $path . '($|/)" {' . "\n";
$path_options.= "\t" . 'cgi.assign = (' . "\n";
$path_options.= "\t\t" . '".pl" => "'.makeCorrectFile($this->settings['system']['perl_path']).'",' . "\n";
$path_options.= "\t\t" . '".cgi" => "'.makeCorrectFile($this->settings['system']['perl_path']).'"' . "\n";
$path_options.= "\t\t" . '".pl" => "'.makeCorrectFile(Settings::Get('system.perl_path')).'",' . "\n";
$path_options.= "\t\t" . '".cgi" => "'.makeCorrectFile(Settings::Get('system.perl_path')).'"' . "\n";
$path_options.= "\t" . ')' . "\n";
$path_options.= ' }' . "\n\n";
}
@@ -629,8 +627,8 @@ class lighttpd
return $path_options;
}
protected function getDirOptions($domain)
{
protected function getDirOptions($domain) {
$result_stmt = Database::prepare("
SELECT * FROM " . TABLE_PANEL_HTPASSWDS . "
WHERE `customerid` = :customerid
@@ -646,14 +644,14 @@ class lighttpd
if ($this->auth_backend_loaded[$domain['ipandport']] != 'yes') {
$auth_backend_loaded[$domain['ipandport']] = 'yes';
$diroption_text.= 'auth.backend = "htpasswd"' . "\n";
$diroption_text.= 'auth.backend.htpasswd.userfile = "' . makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $filename) . '"' . "\n";
$diroption_text.= 'auth.backend.htpasswd.userfile = "' . makeCorrectFile(Settings::Get('system.apacheconf_htpasswddir') . '/' . $filename) . '"' . "\n";
$this->needed_htpasswds[$filename] = $row_htpasswds['username'] . ':' . $row_htpasswds['password'] . "\n";
$diroption_text.= 'auth.require = ( ' . "\n";
$previous_domain_id = '1';
} elseif($this->auth_backend_loaded[$domain['ssl_ipandport']] != 'yes') {
} elseif ($this->auth_backend_loaded[$domain['ssl_ipandport']] != 'yes') {
$auth_backend_loaded[$domain['ssl_ipandport']] = 'yes';
$diroption_text.= 'auth.backend= "htpasswd"' . "\n";
$diroption_text.= 'auth.backend.htpasswd.userfile = "' . makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $filename) . '"' . "\n";
$diroption_text.= 'auth.backend.htpasswd.userfile = "' . makeCorrectFile(Settings::Get('system.apacheconf_htpasswddir') . '/' . $filename) . '"' . "\n";
$this->needed_htpasswds[$filename] = $row_htpasswds['username'] . ':' . $row_htpasswds['password'] . "\n";
$diroption_text.= 'auth.require = ( ' . "\n";
$previous_domain_id = '1';
@@ -676,11 +674,11 @@ class lighttpd
}
}
return ' auth.backend.htpasswd.userfile = "' . makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $filename) . '"' . "\n";
return ' auth.backend.htpasswd.userfile = "' . makeCorrectFile(Settings::Get('system.apacheconf_htpasswddir') . '/' . $filename) . '"' . "\n";
}
protected function getServerNames($domain)
{
protected function getServerNames($domain) {
$server_string = array();
$domain_name = str_replace('.', '\.', $domain['domain']);
@@ -721,7 +719,7 @@ class lighttpd
if (sizeof($server_string) > 1) {
if ($i == 0) {
$servernames_text = '(' . $data . '|';
} elseif(sizeof($server_string) - 1 == $i) {
} elseif (sizeof($server_string) - 1 == $i) {
$servernames_text .= $data . ')';
} else {
$servernames_text .= $data . '|';
@@ -742,15 +740,15 @@ class lighttpd
return $servernames_text;
}
protected function getWebroot($domain, $ssl)
{
protected function getWebroot($domain, $ssl) {
$webroot_text = '';
if ($domain['deactivated'] == '1'
&& $this->settings['system']['deactivateddocroot'] != ''
&& Settings::Get('system.deactivateddocroot') != ''
) {
$webroot_text.= ' # Using docroot for deactivated users...' . "\n";
$webroot_text.= ' server.document-root = "' . makeCorrectDir($this->settings['system']['deactivateddocroot']) . "\"\n";
$webroot_text.= ' server.document-root = "' . makeCorrectDir(Settings::Get('system.deactivateddocroot')) . "\"\n";
$this->_deactivated = true;
} else {
if ($ssl === false
@@ -762,7 +760,7 @@ class lighttpd
$webroot_text.= "\t" . '"" => "' . $redirect_domain . '",' . "\n";
$webroot_text.= "\t" . '"/" => "' . $redirect_domain . '"' . "\n";
$webroot_text.= ' )'."\n";
} elseif(preg_match("#^https?://#i", $domain['documentroot'])) {
} elseif (preg_match("#^https?://#i", $domain['documentroot'])) {
$redirect_domain = $this->idnaConvert->encode($domain['documentroot']);
$webroot_text.= ' url.redirect = ('."\n";
$webroot_text.= "\t" . '"^/(.*)" => "' . $redirect_domain . '/$1",' . "\n";
@@ -777,35 +775,35 @@ class lighttpd
return $webroot_text;
}
/**
* Lets set the text part for the stats software
*/
protected function getStats($domain)
{
protected function getStats($domain) {
$stats_text = '';
if ($domain['speciallogfile'] == '1') {
if ($domain['parentdomainid'] == '0') {
if ($this->settings['system']['awstats_enabled'] == '1') {
if (Settings::Get('system.awstats_enabled') == '1') {
$stats_text.= ' alias.url = ( "/awstats/" => "'.makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['domain']).'" )' . "\n";
$stats_text.= ' alias.url += ( "/awstats-icon" => "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '" )' . "\n";
$stats_text.= ' alias.url += ( "/awstats-icon" => "' . makeCorrectDir(Settings::Get('system.awstats_icons')) . '" )' . "\n";
} else {
$stats_text.= ' alias.url = ( "/webalizer/" => "'.makeCorrectFile($domain['customerroot'] . '/webalizer/' . $domain['domain']).'/" )' . "\n";
$stats_text.= ' alias.url = ( "/webalizer/" => "'.makeCorrectFile($domain['customerroot'] . '/webalizer/' . $domain['domain']).'/" )' . "\n";
}
} else {
if ($this->settings['system']['awstats_enabled'] == '1') {
if (Settings::Get('system.awstats_enabled') == '1') {
$stats_text.= ' alias.url = ( "/awstats/" => "'.makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['parentdomain']).'" )' . "\n";
$stats_text.= ' alias.url += ( "/awstats-icon" => "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '" )' . "\n";
$stats_text.= ' alias.url += ( "/awstats-icon" => "' . makeCorrectDir(Settings::Get('system.awstats_icons')) . '" )' . "\n";
} else {
$stats_text.= ' alias.url = ( "/webalizer/" => "'.makeCorrectFile($domain['customerroot'] . '/webalizer/' . $domain['parentdomain']).'/" )' . "\n";
}
}
} else {
if ($domain['customerroot'] != $domain['documentroot']) {
if ($this->settings['system']['awstats_enabled'] == '1') {
if (Settings::Get('system.awstats_enabled') == '1') {
$stats_text.= ' alias.url = ( "/awstats/" => "'.makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['domain']).'" )' . "\n";
$stats_text.= ' alias.url += ( "/awstats-icon" => "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '" )' . "\n";
$stats_text.= ' alias.url += ( "/awstats-icon" => "' . makeCorrectDir(Settings::Get('system.awstats_icons')) . '" )' . "\n";
} else {
$stats_text.= ' alias.url = ( "/webalizer/" => "'.makeCorrectFile($domain['customerroot'] . '/webalizer/').'" )' . "\n";
}
@@ -814,21 +812,21 @@ class lighttpd
// because the stats are in /awstats/[domain], not just /awstats/
// also, the awstats-icons are someplace else too!
// -> webalizer does not need this!
elseif ($this->settings['system']['awstats_enabled'] == '1') {
elseif (Settings::Get('system.awstats_enabled') == '1') {
$stats_text.= ' alias.url = ( "/awstats/" => "'.makeCorrectFile($domain['documentroot'] . '/awstats/' . $domain['domain']).'" )' . "\n";
$stats_text.= ' alias.url += ( "/awstats-icon" => "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '" )' . "\n";
$stats_text.= ' alias.url += ( "/awstats-icon" => "' . makeCorrectDir(Settings::Get('system.awstats_icons')) . '" )' . "\n";
}
}
return $stats_text;
}
public function writeConfigs()
{
fwrite($this->debugHandler, ' lighttpd::writeConfigs: rebuilding ' . $this->settings['system']['apacheconf_vhost'] . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . $this->settings['system']['apacheconf_vhost']);
if (!isConfigDir($this->settings['system']['apacheconf_vhost'])) {
public function writeConfigs() {
fwrite($this->debugHandler, ' lighttpd::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_vhost') . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_vhost'));
if (!isConfigDir(Settings::Get('system.apacheconf_vhost'))) {
// Save one big file
$vhosts_file = '';
@@ -843,7 +841,7 @@ class lighttpd
$vhosts_file.= $vhost_content . "\n\n";
}
$vhosts_filename = $this->settings['system']['apacheconf_vhost'];
$vhosts_filename = Settings::Get('system.apacheconf_vhost');
// Apply header
$vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $vhosts_file;
@@ -851,10 +849,10 @@ class lighttpd
fwrite($vhosts_file_handler, $vhosts_file);
fclose($vhosts_file_handler);
} else {
if (!file_exists($this->settings['system']['apacheconf_vhost'])) {
fwrite($this->debugHandler, ' lighttpd::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])) . "\n");
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])));
safe_exec('mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])));
if (!file_exists(Settings::Get('system.apacheconf_vhost'))) {
fwrite($this->debugHandler, ' lighttpd::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))) . "\n");
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
}
// Write a single file for every vhost
@@ -873,13 +871,13 @@ class lighttpd
}
// Write the diroptions
if (isConfigDir($this->settings['system']['apacheconf_htpasswddir'])) {
if (isConfigDir(Settings::Get('system.apacheconf_htpasswddir'))) {
foreach ($this->needed_htpasswds as $key => $data) {
if (!is_dir($this->settings['system']['apacheconf_htpasswddir'])) {
mkdir(makeCorrectDir($this->settings['system']['apacheconf_htpasswddir']));
if (!is_dir(Settings::Get('system.apacheconf_htpasswddir'))) {
mkdir(makeCorrectDir(Settings::Get('system.apacheconf_htpasswddir')));
}
$filename = makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $key);
$filename = makeCorrectFile(Settings::Get('system.apacheconf_htpasswddir') . '/' . $key);
$htpasswd_handler = fopen($filename, 'w');
fwrite($htpasswd_handler, $data);
fclose($htpasswd_handler);

View File

@@ -27,7 +27,7 @@ class lighttpd_fcgid extends lighttpd
$phpconfig = $php->getPhpConfig((int)$domain['phpsettingid']);
// vhost data for php-fpm
if((int)$this->settings['phpfpm']['enabled'] == 1)
if((int)Settings::Get('phpfpm.enabled') == 1)
{
$php_options_text = ' fastcgi.server = ( '."\n";
$php_options_text.= "\t".'".php" => ('."\n";
@@ -40,7 +40,7 @@ class lighttpd_fcgid extends lighttpd
$php_options_text.= ' )'."\n";
}
// vhost data for fcgid
elseif((int)$this->settings['system']['mod_fcgid'] == 1)
elseif((int)Settings::Get('system.mod_fcgid') == 1)
{
$php_options_text = ' fastcgi.server = ( '."\n";
$file_extensions = explode(' ', $phpconfig['file_extensions']);
@@ -63,7 +63,7 @@ class lighttpd_fcgid extends lighttpd
}
else
{
$php_options_text.= "\t\t\t".'"PHP_FCGI_CHILDREN" => "' . (int)$this->settings['system']['mod_fcgid_starter'] . '",'."\n";
$php_options_text.= "\t\t\t".'"PHP_FCGI_CHILDREN" => "' . (int)Settings::Get('system.mod_fcgid_starter') . '",'."\n";
}
}
@@ -79,7 +79,7 @@ class lighttpd_fcgid extends lighttpd
}
else
{
$php_options_text.= "\t\t\t".'"PHP_FCGI_MAX_REQUESTS" => "' . (int)$this->settings['system']['mod_fcgid_maxrequests'] . '"'."\n";
$php_options_text.= "\t\t\t".'"PHP_FCGI_MAX_REQUESTS" => "' . (int)Settings::Get('system.mod_fcgid_maxrequests') . '"'."\n";
}
}
@@ -108,23 +108,23 @@ class lighttpd_fcgid extends lighttpd
public function createOwnVhostStarter()
{
if ($this->settings['phpfpm']['enabled'] == '1'
&& $this->settings['phpfpm']['enabled_ownvhost'] == '1'
if (Settings::Get('phpfpm.enabled') == '1'
&& Settings::Get('phpfpm.enabled_ownvhost') == '1'
) {
$mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__)))); // /var/www/froxlor, needed for chown
$user = $this->settings['phpfpm']['vhost_httpuser'];
$group = $this->settings['phpfpm']['vhost_httpgroup'];
$user = Settings::Get('phpfpm.vhost_httpuser');
$group = Settings::Get('phpfpm.vhost_httpgroup');
$domain = array(
'id' => 'none',
'domain' => $this->settings['system']['hostname'],
'domain' => Settings::Get('system.hostname'),
'adminid' => 1, /* first admin-user (superadmin) */
'mod_fcgid_starter' => -1,
'mod_fcgid_maxrequests' => -1,
'guid' => $user,
'openbasedir' => 0,
'email' => $this->settings['panel']['adminmail'],
'email' => Settings::Get('panel.adminmail'),
'loginname' => 'froxlor.panel',
'documentroot' => $mypath
);
@@ -137,12 +137,12 @@ class lighttpd_fcgid extends lighttpd
$php = new phpinterface($domain);
// get php-config
if ($this->settings['phpfpm']['enabled'] == '1') {
if (Settings::Get('phpfpm.enabled') == '1') {
// fpm
$phpconfig = $php->getPhpConfig($this->settings['phpfpm']['vhost_defaultini']);
$phpconfig = $php->getPhpConfig(Settings::Get('phpfpm.vhost_defaultini'));
} else {
// fcgid
$phpconfig = $php->getPhpConfig($this->settings['system']['mod_fcgid_defaultini_ownvhost']);
$phpconfig = $php->getPhpConfig(Settings::Get('system.mod_fcgid_defaultini_ownvhost'));
}
// create starter-file | config-file

View File

@@ -15,15 +15,13 @@
*
*/
class nginx
{
class nginx {
private $logger = false;
private $debugHandler = false;
private $idnaConvert = false;
private $nginx_server = array();
// protected
protected $settings = array();
// protected
protected $nginx_data = array();
protected $needed_htpasswds = array();
protected $auth_backend_loaded = false;
@@ -40,34 +38,32 @@ class nginx
*/
private $_deactivated = false;
public function __construct($logger, $debugHandler, $idnaConvert, $settings, $nginx_server=array())
{
public function __construct($logger, $debugHandler, $idnaConvert, $nginx_server=array()) {
$this->logger = $logger;
$this->debugHandler = $debugHandler;
$this->idnaConvert = $idnaConvert;
$this->settings = $settings;
$this->nginx_server = $nginx_server;
}
public function reload()
{
public function reload() {
fwrite($this->debugHandler, ' nginx::reload: reloading nginx' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading nginx');
safe_exec($this->settings['system']['apachereload_command']);
safe_exec(Settings::Get('system.apachereload_command'));
/**
* nginx does not auto-spawn fcgi-processes
*/
if ($this->settings['system']['phpreload_command'] != ''
&& (int)$this->settings['phpfpm']['enabled'] == 0
if (Settings::Get('system.phpreload_command') != ''
&& (int)Settings::Get('phpfpm.enabled') == 0
) {
fwrite($this->debugHandler, ' nginx::reload: restarting php processes' . "\n");
fwrite($this->debugHandler, ' nginx::reload: restarting php processes' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'restarting php processes');
safe_exec($this->settings['system']['phpreload_command']);
} elseif ((int)$this->settings['phpfpm']['enabled'] == 1) {
safe_exec(Settings::Get('system.phpreload_command'));
} elseif ((int)Settings::Get('phpfpm.enabled') == 1) {
fwrite($this->debugHandler, ' nginx::reload: reloading php-fpm' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm');
safe_exec(escapeshellcmd($this->settings['phpfpm']['reload']));
safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload')));
}
}
@@ -75,19 +71,18 @@ class nginx
/**
* define a default ErrorDocument-statement, bug #unknown-yet
*/
private function _createStandardErrorHandler()
{
if ($this->settings['defaultwebsrverrhandler']['enabled'] == '1'
&& ($this->settings['defaultwebsrverrhandler']['err401'] != ''
|| $this->settings['defaultwebsrverrhandler']['err403'] != ''
|| $this->settings['defaultwebsrverrhandler']['err404'] != ''
|| $this->settings['defaultwebsrverrhandler']['err500'] != '')
private function _createStandardErrorHandler() {
if (Settings::Get('defaultwebsrverrhandler.enabled') == '1'
&& (Settings::Get('defaultwebsrverrhandler.err401') != ''
|| Settings::Get('defaultwebsrverrhandler.err403') != ''
|| Settings::Get('defaultwebsrverrhandler.err404') != ''
|| Settings::Get('defaultwebsrverrhandler.err500') != '')
) {
$vhosts_folder = '';
if (is_dir($this->settings['system']['apacheconf_vhost'])) {
$vhosts_folder = makeCorrectDir($this->settings['system']['apacheconf_vhost']);
if (is_dir(Settings::Get('system.apacheconf_vhost'))) {
$vhosts_folder = makeCorrectDir(Settings::Get('system.apacheconf_vhost'));
} else {
$vhosts_folder = makeCorrectDir(dirname($this->settings['system']['apacheconf_vhost']));
$vhosts_folder = makeCorrectDir(dirname(Settings::Get('system.apacheconf_vhost')));
}
$vhosts_filename = makeCorrectFile($vhosts_folder . '/05_froxlor_default_errorhandler.conf');
@@ -98,8 +93,8 @@ class nginx
$statusCodes = array('401', '403', '404', '500');
foreach ($statusCodes as $statusCode) {
if ($this->settings['defaultwebsrverrhandler']['err' . $statusCode] != '') {
$defhandler = $this->settings['defaultwebsrverrhandler']['err' . $statusCode];
if (Settings::Get('defaultwebsrverrhandler.err' . $statusCode) != '') {
$defhandler = Settings::Get('defaultwebsrverrhandler.err' . $statusCode);
if (!validateUrl($defhandler)) {
$defhandler = makeCorrectFile($defhandler);
}
@@ -109,16 +104,16 @@ class nginx
}
}
public function createVirtualHosts()
{
public function createVirtualHosts() {
}
public function createFileDirOptions()
{
public function createFileDirOptions() {
}
public function createIpPort()
{
public function createIpPort() {
$result_ipsandports_stmt = Database::query("
SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` ORDER BY `ip` ASC, `port` ASC
");
@@ -133,7 +128,7 @@ class nginx
fwrite($this->debugHandler, ' nginx::createIpPort: creating ip/port settings for ' . $ip . ":" . $port . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating ip/port settings for ' . $ip . ":" . $port);
$vhost_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf');
$vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf');
if (!isset($this->nginx_data[$vhost_filename])) {
$this->nginx_data[$vhost_filename] = '';
@@ -148,13 +143,13 @@ class nginx
$ssl_vhost = false;
if ($row_ipsandports['ssl'] == '1') {
if ($row_ipsandports['ssl_cert_file'] == '') {
$row_ipsandports['ssl_cert_file'] = $this->settings['system']['ssl_cert_file'];
$row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
}
if ($row_ipsandports['ssl_key_file'] == '') {
$row_ipsandports['ssl_key_file'] = $this->settings['system']['ssl_key_file'];
$row_ipsandports['ssl_key_file'] = Settings::Get('system.ssl_key_file');
}
if ($row_ipsandports['ssl_ca_file'] == '') {
$row_ipsandports['ssl_ca_file'] = $this->settings['system']['ssl_ca_file'];
$row_ipsandports['ssl_ca_file'] = Settings::Get('system.ssl_ca_file');
}
if ($row_ipsandports['ssl_cert_file'] != '') {
$ssl_vhost = true;
@@ -167,7 +162,7 @@ class nginx
$this->nginx_data[$vhost_filename] .= "\t". 'listen ' . $ip . ':' . $port . ' default'. ($ssl_vhost == true ? ' ssl' : '') . ';' . "\n";
$this->nginx_data[$vhost_filename] .= "\t".'# Froxlor default vhost' . "\n";
$this->nginx_data[$vhost_filename] .= "\t".'server_name ' . $this->settings['system']['hostname'] . ';' . "\n";
$this->nginx_data[$vhost_filename] .= "\t".'server_name ' . Settings::Get('system.hostname') . ';' . "\n";
$this->nginx_data[$vhost_filename] .= "\t".'access_log /var/log/nginx/access.log;' . "\n";
$mypath = '';
@@ -176,7 +171,7 @@ class nginx
if ($row_ipsandports['docroot'] == '') {
// check whether the hostname should directly point to
// the froxlor-installation or not
if ($this->settings['system']['froxlordirectlyviahostname']) {
if (Settings::Get('system.froxlordirectlyviahostname')) {
$mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__))));
} else {
$mypath = makeCorrectDir(dirname(dirname(dirname(dirname(__FILE__)))));
@@ -207,23 +202,23 @@ class nginx
$this->nginx_data[$vhost_filename] .= "\t\t\t".'return 404;'."\n";
$this->nginx_data[$vhost_filename] .= "\t\t".'}'."\n";
$this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_index index.php;'."\n";
$this->nginx_data[$vhost_filename] .= "\t\t".'include '.$this->settings['nginx']['fastcgiparams'].';'."\n";
$this->nginx_data[$vhost_filename] .= "\t\t".'include '.Settings::Get('nginx.fastcgiparams').';'."\n";
$this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;'."\n";
if ($row_ipsandports['ssl'] == '1') {
$this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_param HTTPS on;'."\n";
}
if ((int)$this->settings['phpfpm']['enabled'] == 1
&& (int)$this->settings['phpfpm']['enabled_ownvhost'] == 1
if ((int)Settings::Get('phpfpm.enabled') == 1
&& (int)Settings::Get('phpfpm.enabled_ownvhost') == 1
) {
$domain = array(
'id' => 'none',
'domain' => $this->settings['system']['hostname'],
'domain' => Settings::Get('system.hostname'),
'adminid' => 1, /* first admin-user (superadmin) */
'mod_fcgid_starter' => -1,
'mod_fcgid_maxrequests' => -1,
'guid' => $this->settings['phpfpm']['vhost_httpuser'],
'guid' => Settings::Get('phpfpm.vhost_httpuser'),
'openbasedir' => 0,
'email' => $this->settings['panel']['adminmail'],
'email' => Settings::Get('panel.adminmail'),
'loginname' => 'froxlor.panel',
'documentroot' => $mypath,
);
@@ -231,7 +226,7 @@ class nginx
$php = new phpinterface($domain);
$this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_pass unix:' . $php->getInterface()->getSocketFile() . ';' . "\n";
} else {
$this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_pass ' . $this->settings['system']['nginx_php_backend'] . ';' . "\n";
$this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_pass ' . Settings::Get('system.nginx_php_backend') . ';' . "\n";
}
$this->nginx_data[$vhost_filename] .= "\t".'}'."\n";
$this->nginx_data[$vhost_filename] .= '}' . "\n\n";
@@ -247,6 +242,7 @@ class nginx
$this->_createStandardErrorHandler();
}
/**
* create vhosts
*/
@@ -255,8 +251,8 @@ class nginx
$domains = WebserverBase::getVhostsToCreate();
foreach ($domains as $domain) {
if (is_dir($this->settings['system']['apacheconf_vhost'])) {
safe_exec('mkdir -p '.escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])));
if (is_dir(Settings::Get('system.apacheconf_vhost'))) {
safe_exec('mkdir -p '.escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
}
$vhost_filename = $this->getVhostFilename($domain);
@@ -265,9 +261,9 @@ class nginx
$this->nginx_data[$vhost_filename] = '';
}
if ((!empty($this->nginx_data[$vhost_filename])
&& !is_dir($this->settings['system']['apacheconf_vhost']))
|| is_dir($this->settings['system']['apacheconf_vhost'])
if ((!empty($this->nginx_data[$vhost_filename])
&& !is_dir(Settings::Get('system.apacheconf_vhost')))
|| is_dir(Settings::Get('system.apacheconf_vhost'))
) {
// Create non-ssl host
$this->nginx_data[$vhost_filename].= $this->getVhostContent($domain, false);
@@ -283,8 +279,8 @@ class nginx
}
}
protected function getVhostFilename($domain, $ssl_vhost = false)
{
protected function getVhostFilename($domain, $ssl_vhost = false) {
if ((int)$domain['parentdomainid'] == 0
&& isCustomerStdSubdomain((int)$domain['id']) == false
&& ((int)$domain['ismainbutsubto'] == 0
@@ -301,16 +297,16 @@ class nginx
}
if ($ssl_vhost === true) {
$vhost_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/'.$vhost_no.'_froxlor_ssl_vhost_' . $domain['domain'] . '.conf');
$vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/'.$vhost_no.'_froxlor_ssl_vhost_' . $domain['domain'] . '.conf');
} else {
$vhost_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/'.$vhost_no.'_froxlor_normal_vhost_' . $domain['domain'] . '.conf');
$vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/'.$vhost_no.'_froxlor_normal_vhost_' . $domain['domain'] . '.conf');
}
return $vhost_filename;
}
protected function getVhostContent($domain, $ssl_vhost = false)
{
protected function getVhostContent($domain, $ssl_vhost = false) {
if ($ssl_vhost === true
&& $domain['ssl'] != '1'
&& $domain['ssl_redirect'] != '1'
@@ -324,10 +320,10 @@ class nginx
$query = "SELECT * FROM `".TABLE_PANEL_IPSANDPORTS."` `i`, `".TABLE_DOMAINTOIP."` `dip`
WHERE dip.id_domain = :domainid AND i.id = dip.id_ipandports ";
if ($ssl_vhost === true
&& ($domain['ssl'] == '1' || $domain['ssl_redirect'] == '1')
if ($ssl_vhost === true
&& ($domain['ssl'] == '1' || $domain['ssl_redirect'] == '1')
) {
// by ordering by cert-file the row with filled out SSL-Fields will be shown last,
// by ordering by cert-file the row with filled out SSL-Fields will be shown last,
// thus it is enough to fill out 1 set of SSL-Fields
$query .= "AND i.ssl = 1 ORDER BY i.ssl_cert_file ASC;";
} else {
@@ -356,7 +352,7 @@ class nginx
// if the domain has customer-defined ssl-certificates
$dssl->setDomainSSLFilesArray($domain);
}
if (filter_var($domain['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$ipport = '[' . $domain['ip'] . ']:' . $domain['port'];
} else {
@@ -376,8 +372,7 @@ class nginx
// respect ssl_redirect settings, #542
if ($ssl_vhost == false
&& $domain['ssl'] == '1'
&& $domain['ssl_redirect'] == '1')
{
&& $domain['ssl_redirect'] == '1') {
// We must not check if our port differs from port 443,
// but if there is a destination-port != 443
$_sslport = '';
@@ -412,8 +407,8 @@ class nginx
if ($this->_deactivated == false) {
if ($ssl_vhost === true
&& $domain['ssl'] == '1'
&& $this->settings['system']['use_ssl'] == '1'
&& $domain['ssl'] == '1'
&& Settings::Get('system.use_ssl') == '1'
) {
$vhost_content.= $this->composeSslSettings($domain);
}
@@ -430,8 +425,8 @@ class nginx
$vhost_content .= $_vhost_content;
}
if ($this->settings['system']['default_vhostconf'] != '') {
$vhost_content .= $this->settings['system']['default_vhostconf'] . "\n";
if (Settings::Get('system.default_vhostconf') != '') {
$vhost_content .= Settings::Get('system.default_vhostconf') . "\n";
}
}
}
@@ -439,11 +434,12 @@ class nginx
return $this->mergeVhostBlocks($vhost_content);
}
protected function mergeVhostBlocks($vhost_content) {
$vhost_content = explode("\n", preg_replace('/[ \t]+/', ' ', trim(preg_replace('/\t+/', '', $vhost_content))));
$vhost_content = array_filter($vhost_content, create_function('$a','return preg_match("#\S#", $a);'));
// Merge similar blocks
$new_vhost_content = array();
$isOpen = false;
@@ -480,7 +476,7 @@ class nginx
$new_vhost_content[] = $line;
}
}
// Fix idention
$nextLevel = 0;
for ($i = 0; $i < count($new_vhost_content); $i++) {
@@ -496,36 +492,37 @@ class nginx
$nextLevel += 1;
}
}
return implode("\n", $new_vhost_content);
}
protected function composeSslSettings($domain) {
$sslsettings = '';
if ($domain['ssl_cert_file'] == '') {
$domain['ssl_cert_file'] = $this->settings['system']['ssl_cert_file'];
$domain['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
}
if ($domain['ssl_key_file'] == '') {
$domain['ssl_key_file'] = $this->settings['system']['ssl_key_file'];
$domain['ssl_key_file'] = Settings::Get('system.ssl_key_file');
}
if ($domain['ssl_ca_file'] == '') {
$domain['ssl_ca_file'] = $this->settings['system']['ssl_ca_file'];
$domain['ssl_ca_file'] = Settings::Get('system.ssl_ca_file');
}
// #418
if ($domain['ssl_cert_chainfile'] == '') {
$domain['ssl_cert_chainfile'] = $this->settings['system']['ssl_cert_chainfile'];
$domain['ssl_cert_chainfile'] = Settings::Get('system.ssl_cert_chainfile');
}
if ($domain['ssl_cert_file'] != '') {
// obsolete: ssl on now belongs to the listen block as 'ssl' at the end
//$sslsettings .= "\t" . 'ssl on;' . "\n";
$sslsettings .= "\t" . 'ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;' . "\n";
$sslsettings .= "\t" . 'ssl_ciphers ' . $this->settings['system']['ssl_cipher_list'] . ';' . "\n";
$sslsettings .= "\t" . 'ssl_ciphers ' . Settings::Get('system.ssl_cipher_list') . ';' . "\n";
$sslsettings .= "\t" . 'ssl_prefer_server_ciphers on;' . "\n";
$sslsettings .= "\t" . 'ssl_certificate ' . makeCorrectFile($domain['ssl_cert_file']) . ';' . "\n";
@@ -541,8 +538,8 @@ class nginx
return $sslsettings;
}
protected function create_pathOptions($domain)
{
protected function create_pathOptions($domain) {
$has_location = false;
$result_stmt = Database::prepare("
@@ -580,55 +577,55 @@ class nginx
$path_options .= "\t".'error_page 500 502 503 504 ' . $defhandler . ';' . "\n";
}
// if ($row['options_indexes'] != '0') {
$path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
// if ($row['options_indexes'] != '0') {
$path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
$path_options .= "\t".'# '.$path."\n";
if ($path == '/') {
$this->vhost_root_autoindex = true;
$path_options .= "\t".'location ' . $path . ' {' . "\n";
if($this->vhost_root_autoindex) {
$path_options .= "\t\t" . 'autoindex on;' . "\n";
$this->vhost_root_autoindex = false;
}
$path_options.= "\t\t" . 'index index.php index.html index.htm;'."\n";
// $path_options.= "\t\t" . 'try_files $uri $uri/ @rewrites;'."\n";
// check if we have a htpasswd for this path
// (damn nginx does not like more than one
// 'location'-part with the same path)
if (count($htpasswds) > 0) {
foreach ($htpasswds as $idx => $single) {
switch ($single['path']) {
case '/awstats/':
case '/webalizer/':
// no stats-alias in "location /"-context
break;
default:
if ($single['path'] == '/') {
$path_options .= "\t\t" . 'auth_basic "Restricted Area";' . "\n";
$path_options .= "\t\t" . 'auth_basic_user_file ' . makeCorrectFile($single['usrf']) . ';'."\n";
// remove already used entries so we do not have doubles
unset($htpasswds[$idx]);
}
$path_options .= "\t".'# '.$path."\n";
if ($path == '/') {
$this->vhost_root_autoindex = true;
$path_options .= "\t".'location ' . $path . ' {' . "\n";
if ($this->vhost_root_autoindex) {
$path_options .= "\t\t" . 'autoindex on;' . "\n";
$this->vhost_root_autoindex = false;
}
$path_options.= "\t\t" . 'index index.php index.html index.htm;'."\n";
// $path_options.= "\t\t" . 'try_files $uri $uri/ @rewrites;'."\n";
// check if we have a htpasswd for this path
// (damn nginx does not like more than one
// 'location'-part with the same path)
if (count($htpasswds) > 0) {
foreach ($htpasswds as $idx => $single) {
switch ($single['path']) {
case '/awstats/':
case '/webalizer/':
// no stats-alias in "location /"-context
break;
default:
if ($single['path'] == '/') {
$path_options .= "\t\t" . 'auth_basic "Restricted Area";' . "\n";
$path_options .= "\t\t" . 'auth_basic_user_file ' . makeCorrectFile($single['usrf']) . ';'."\n";
// remove already used entries so we do not have doubles
unset($htpasswds[$idx]);
}
}
}
$path_options .= "\t".'}' . "\n";
$this->vhost_root_autoindex = false;
} else {
$path_options .= "\t".'location ' . $path . ' {' . "\n";
if ($this->vhost_root_autoindex) {
$path_options .= "\t\t" . 'autoindex on;' . "\n";
$this->vhost_root_autoindex = false;
}
$path_options .= "\t\t" . 'index index.php index.html index.htm;'."\n";
$path_options .= "\t".'} ' . "\n";
}
// }
$path_options .= "\t".'}' . "\n";
$this->vhost_root_autoindex = false;
} else {
$path_options .= "\t".'location ' . $path . ' {' . "\n";
if ($this->vhost_root_autoindex) {
$path_options .= "\t\t" . 'autoindex on;' . "\n";
$this->vhost_root_autoindex = false;
}
$path_options .= "\t\t" . 'index index.php index.html index.htm;'."\n";
$path_options .= "\t".'} ' . "\n";
}
// }
/**
* Perl support
* required the fastCGI wrapper to be running to receive the CGI requests.
@@ -645,30 +642,30 @@ class nginx
}
$path_options .= "\t" . 'location ~ \(.pl|.cgi)$ {' . "\n";
$path_options .= "\t\t" . 'gzip off; #gzip makes scripts feel slower since they have to complete before getting gzipped' . "\n";
$path_options .= "\t\t" . 'fastcgi_pass '. $this->settings['system']['perl_server'] . ';' . "\n";
$path_options .= "\t\t" . 'fastcgi_index index.cgi;' . "\n";
$path_options .= "\t\t" . 'include '.$this->settings['nginx']['fastcgiparams'].';'."\n";
$path_options .= "\t\t" . 'fastcgi_pass '. Settings::Get('system.perl_server') . ';' . "\n";
$path_options .= "\t\t" . 'fastcgi_index index.cgi;' . "\n";
$path_options .= "\t\t" . 'include '.Settings::Get('nginx.fastcgiparams').';'."\n";
$path_options .= "\t" . '}' . "\n";
}
}
// now the rest of the htpasswds
if (count($htpasswds) > 0) {
foreach ($htpasswds as $idx => $single) {
//if ($single['path'] != '/') {
switch ($single['path']) {
case '/awstats/':
case '/webalizer/':
$path_options .= $this->getStats($domain,$single);
unset($htpasswds[$idx]);
break;
default:
$path_options .= "\t" . 'location ' . makeCorrectDir($single['path']) . ' {' . "\n";
$path_options .= "\t\t" . 'auth_basic "Restricted Area";' . "\n";
$path_options .= "\t\t" . 'auth_basic_user_file ' . makeCorrectFile($single['usrf']) . ';'."\n";
$path_options .= "\t".'}' . "\n";
}
switch ($single['path']) {
case '/awstats/':
case '/webalizer/':
$path_options .= $this->getStats($domain,$single);
unset($htpasswds[$idx]);
break;
default:
$path_options .= "\t" . 'location ' . makeCorrectDir($single['path']) . ' {' . "\n";
$path_options .= "\t\t" . 'auth_basic "Restricted Area";' . "\n";
$path_options .= "\t\t" . 'auth_basic_user_file ' . makeCorrectFile($single['usrf']) . ';'."\n";
$path_options .= "\t".'}' . "\n";
}
//}
unset($htpasswds[$idx]);
}
@@ -677,6 +674,7 @@ class nginx
return $path_options;
}
protected function getHtpasswds($domain) {
$result_stmt = Database::prepare("
@@ -691,7 +689,7 @@ class nginx
$x = 0;
while ($row_htpasswds = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if (count($row_htpasswds) > 0) {
$htpasswd_filename = makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $row_htpasswds['customerid'] . '-' . md5($row_htpasswds['path']) . '.htpasswd');
$htpasswd_filename = makeCorrectFile(Settings::Get('system.apacheconf_htpasswddir') . '/' . $row_htpasswds['customerid'] . '-' . md5($row_htpasswds['path']) . '.htpasswd');
// ensure we can write to the array with index $htpasswd_filename
if (!isset($this->htpasswds_data[$htpasswd_filename])) {
@@ -720,17 +718,17 @@ class nginx
return $returnval;
}
protected function composePhpOptions($domain, $ssl_vhost = false)
{
protected function composePhpOptions($domain, $ssl_vhost = false) {
$phpopts = '';
if ($domain['phpenabled'] == '1') {
$phpopts = "\t".'location ~ \.php$ {'."\n";
$phpopts.= "\t\t".'try_files $uri =404;'."\n";
$phpopts.= "\t\t".'fastcgi_split_path_info ^(.+\.php)(/.+)$;'."\n";
$phpopts.= "\t\t".'fastcgi_index index.php;'."\n";
$phpopts.= "\t\t".'fastcgi_pass ' . $this->settings['system']['nginx_php_backend'] . ';' . "\n";
$phpopts.= "\t\t".'fastcgi_pass ' . Settings::Get('system.nginx_php_backend') . ';' . "\n";
$phpopts.= "\t\t".'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;'."\n";
$phpopts.= "\t\t".'include '.$this->settings['nginx']['fastcgiparams'].';'."\n";
$phpopts.= "\t\t".'include '.Settings::Get('nginx.fastcgiparams').';'."\n";
if ($domain['ssl'] == '1' && $ssl_vhost) {
$phpopts.= "\t\t".'fastcgi_param HTTPS on;'."\n";
}
@@ -739,15 +737,15 @@ class nginx
return $phpopts;
}
protected function getWebroot($domain, $ssl)
{
protected function getWebroot($domain, $ssl) {
$webroot_text = '';
if ($domain['deactivated'] == '1'
&& $this->settings['system']['deactivateddocroot'] != ''
&& Settings::Get('system.deactivateddocroot') != ''
) {
$webroot_text .= "\t".'# Using docroot for deactivated users...' . "\n";
$webroot_text .= "\t".'root '.makeCorrectDir($this->settings['system']['deactivateddocroot']).';'."\n";
$webroot_text .= "\t".'root '.makeCorrectDir(Settings::Get('system.deactivateddocroot')).';'."\n";
$this->_deactivated = true;
} else {
$webroot_text .= "\t".'root '.makeCorrectDir($domain['documentroot']).';'."\n";
@@ -771,12 +769,12 @@ class nginx
return $webroot_text;
}
protected function getStats($domain, $single)
{
protected function getStats($domain, $single) {
$stats_text = '';
// define basic path to the stats
if ($this->settings['system']['awstats_enabled'] == '1') {
if (Settings::Get('system.awstats_enabled') == '1') {
$alias_dir = makeCorrectFile($domain['customerroot'] . '/awstats/');
} else {
$alias_dir = makeCorrectFile($domain['customerroot'] . '/webalizer/');
@@ -789,7 +787,7 @@ class nginx
$alias_dir = makeCorrectDir($alias_dir.'/'.$domain['parentdomain']);
}
if ($this->settings['system']['awstats_enabled'] == '1') {
if (Settings::Get('system.awstats_enabled') == '1') {
// awstats
$stats_text .= "\t" . 'location /awstats {' . "\n";
} else {
@@ -802,18 +800,18 @@ class nginx
$stats_text .= "\t\t" . 'auth_basic_user_file ' . makeCorrectFile($single['usrf']) . ';'."\n";
$stats_text .= "\t" . '}' . "\n\n";
// awstats icons
if ($this->settings['system']['awstats_enabled'] == '1') {
$stats_text .= "\t" . 'location ~ ^/awstats-icon/(.*)$ {' . "\n";
$stats_text .= "\t\t" . 'alias ' . makeCorrectDir($this->settings['system']['awstats_icons']) . '$1;' . "\n";
$stats_text .= "\t" . '}' . "\n\n";
}
// awstats icons
if (Settings::Get('system.awstats_enabled') == '1') {
$stats_text .= "\t" . 'location ~ ^/awstats-icon/(.*)$ {' . "\n";
$stats_text .= "\t\t" . 'alias ' . makeCorrectDir(Settings::Get('system.awstats_icons')) . '$1;' . "\n";
$stats_text .= "\t" . '}' . "\n\n";
}
return $stats_text;
}
protected function getLogFiles($domain)
{
protected function getLogFiles($domain) {
$logfiles_text = '';
$speciallogfile = '';
@@ -826,22 +824,22 @@ class nginx
}
// The normal access/error - logging is enabled
$error_log = makeCorrectFile($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-error.log');
$error_log = makeCorrectFile(Settings::Get('system.logfiles_directory') . $domain['loginname'] . $speciallogfile . '-error.log');
// Create the logfile if it does not exist (fixes #46)
touch($error_log);
chown($error_log, $this->settings['system']['httpuser']);
chgrp($error_log, $this->settings['system']['httpgroup']);
chown($error_log, Settings::Get('system.httpuser'));
chgrp($error_log, Settings::Get('system.httpgroup'));
$access_log = makeCorrectFile($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log');
$access_log = makeCorrectFile(Settings::Get('system.logfiles_directory') . $domain['loginname'] . $speciallogfile . '-access.log');
// Create the logfile if it does not exist (fixes #46)
touch($access_log);
chown($access_log, $this->settings['system']['httpuser']);
chgrp($access_log, $this->settings['system']['httpgroup']);
chown($access_log, Settings::Get('system.httpuser'));
chgrp($access_log, Settings::Get('system.httpgroup'));
$logfiles_text .= "\t".'access_log ' . $access_log . ' combined;' . "\n";
$logfiles_text .= "\t".'error_log ' . $error_log . ' error;' . "\n";
if ($this->settings['system']['awstats_enabled'] == '1') {
if (Settings::Get('system.awstats_enabled') == '1') {
if ((int)$domain['parentdomainid'] == 0) {
// prepare the aliases and subdomains for stats config files
$server_alias = '';
@@ -877,19 +875,19 @@ class nginx
// be sure to build the awstats conf file as well
// and chown it using $awstats_params, #258
// Bug 960 + Bug 970 : Use full $domain instead of custom $awstats_params as following classes depend on the informations
createAWStatsConf($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log', $domain['domain'], $alias . $server_alias, $domain['customerroot'], $domain);
createAWStatsConf(Settings::Get('system.logfiles_directory') . $domain['loginname'] . $speciallogfile . '-access.log', $domain['domain'], $alias . $server_alias, $domain['customerroot'], $domain);
}
}
return $logfiles_text;
}
public function createOwnVhostStarter()
{
public function createOwnVhostStarter() {
}
protected function getServerNames($domain)
{
protected function getServerNames($domain) {
$server_alias = '';
if ($domain['iswildcarddomain'] == '1') {
@@ -924,26 +922,26 @@ class nginx
return $servernames_text;
}
public function writeConfigs()
{
fwrite($this->debugHandler, ' nginx::writeConfigs: rebuilding ' . $this->settings['system']['apacheconf_vhost'] . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . $this->settings['system']['apacheconf_vhost']);
if (!isConfigDir($this->settings['system']['apacheconf_vhost'])) {
public function writeConfigs() {
fwrite($this->debugHandler, ' nginx::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_vhost') . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_vhost'));
if (!isConfigDir(Settings::Get('system.apacheconf_vhost'))) {
// Save one big file
$vhosts_file = '';
// sort by filename so the order is:
// 1. subdomains
// 2. subdomains as main-domains
// 3. main-domains
ksort($this->nginx_data);
foreach ($this->nginx_data as $vhosts_filename => $vhost_content) {
$vhosts_file.= $vhost_content . "\n\n";
}
$vhosts_filename = $this->settings['system']['apacheconf_vhost'];
$vhosts_filename = Settings::Get('system.apacheconf_vhost');
// Apply header
$vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $vhosts_file;
@@ -951,10 +949,10 @@ class nginx
fwrite($vhosts_file_handler, $vhosts_file);
fclose($vhosts_file_handler);
} else {
if (!file_exists($this->settings['system']['apacheconf_vhost'])) {
fwrite($this->debugHandler, ' nginx::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])) . "\n");
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])));
safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])));
if (!file_exists(Settings::Get('system.apacheconf_vhost'))) {
fwrite($this->debugHandler, ' nginx::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))) . "\n");
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
}
// Write a single file for every vhost
@@ -975,18 +973,18 @@ class nginx
// htaccess stuff
if (count($this->htpasswds_data) > 0) {
if (!file_exists($this->settings['system']['apacheconf_htpasswddir'])) {
if (!file_exists(Settings::Get('system.apacheconf_htpasswddir'))) {
$umask = umask();
umask(0000);
mkdir($this->settings['system']['apacheconf_htpasswddir'], 0751);
mkdir(Settings::Get('system.apacheconf_htpasswddir'), 0751);
umask($umask);
} elseif (!is_dir($this->settings['system']['apacheconf_htpasswddir'])) {
fwrite($this->debugHandler, ' cron_tasks: WARNING!!! ' . $this->settings['system']['apacheconf_htpasswddir'] . ' is not a directory. htpasswd directory protection is disabled!!!' . "\n");
echo 'WARNING!!! ' . $this->settings['system']['apacheconf_htpasswddir'] . ' is not a directory. htpasswd directory protection is disabled!!!';
$this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . $this->settings['system']['apacheconf_htpasswddir'] . ' is not a directory. htpasswd directory protection is disabled!!!');
} elseif (!is_dir(Settings::Get('system.apacheconf_htpasswddir'))) {
fwrite($this->debugHandler, ' cron_tasks: WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!' . "\n");
echo 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!';
$this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!');
}
if (is_dir($this->settings['system']['apacheconf_htpasswddir'])) {
if (is_dir(Settings::Get('system.apacheconf_htpasswddir'))) {
foreach ($this->htpasswds_data as $htpasswd_filename => $htpasswd_file) {
$this->known_htpasswdsfilenames[] = basename($htpasswd_filename);
$htpasswd_file_handler = fopen($htpasswd_filename, 'w');

View File

@@ -17,22 +17,20 @@
class nginx_phpfpm extends nginx
{
protected function composePhpOptions($domain, $ssl_vhost = false)
{
protected function composePhpOptions($domain, $ssl_vhost = false) {
$php_options_text = '';
if($domain['phpenabled'] == '1')
{
if ($domain['phpenabled'] == '1') {
$php = new phpinterface($domain);
$phpconfig = $php->getPhpConfig((int)$domain['phpsettingid']);
$php_options_text = "\t".'location ~ \.php$ {'."\n";
$php_options_text.= "\t\t".'try_files $uri =404;'."\n";
$php_options_text.= "\t\t".'fastcgi_split_path_info ^(.+\.php)(/.+)$;'."\n";
$php_options_text.= "\t\t".'fastcgi_pass unix:' . $php->getInterface()->getSocketFile() . ';' . "\n";
$php_options_text.= "\t\t".'fastcgi_index index.php;'."\n";
$php_options_text.= "\t\t".'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;'."\n";
$php_options_text.= "\t\t".'include '.$this->settings['nginx']['fastcgiparams'].';'."\n";
$php_options_text.= "\t\t".'include '.Settings::Get('nginx.fastcgiparams').';'."\n";
if ($domain['ssl'] == '1' && $ssl_vhost) {
$php_options_text.= "\t\t".'fastcgi_param HTTPS on;'."\n";
}
@@ -40,38 +38,37 @@ class nginx_phpfpm extends nginx
// create starter-file | config-file
$php->getInterface()->createConfig($phpconfig);
// create php.ini (fpm does nothing here, as it
// defines ini-settings in its pool config)
$php->getInterface()->createIniFile($phpconfig);
}
else
{
else {
$php_options_text.= ' # PHP is disabled for this vHost' . "\n";
}
return $php_options_text;
}
public function createOwnVhostStarter()
{
if ($this->settings['phpfpm']['enabled'] == '1'
&& $this->settings['phpfpm']['enabled_ownvhost'] == '1'
public function createOwnVhostStarter() {
if (Settings::Get('phpfpm.enabled') == '1'
&& Settings::Get('phpfpm.enabled_ownvhost') == '1'
) {
$mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__)))); // /var/www/froxlor, needed for chown
$user = $this->settings['phpfpm']['vhost_httpuser'];
$group = $this->settings['phpfpm']['vhost_httpgroup'];
$user = Settings::Get('phpfpm.vhost_httpuser');
$group = Settings::Get('phpfpm.vhost_httpgroup');
$domain = array(
'id' => 'none',
'domain' => $this->settings['system']['hostname'],
'domain' => Settings::Get('system.hostname'),
'adminid' => 1, /* first admin-user (superadmin) */
'mod_fcgid_starter' => -1,
'mod_fcgid_maxrequests' => -1,
'guid' => $user,
'openbasedir' => 0,
'email' => $this->settings['panel']['adminmail'],
'email' => Settings::Get('panel.adminmail'),
'loginname' => 'froxlor.panel',
'documentroot' => $mypath
);
@@ -79,25 +76,27 @@ class nginx_phpfpm extends nginx
// all the files and folders have to belong to the local user
// now because we also use fcgid for our own vhost
safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath));
// get php.ini for our own vhost
$php = new phpinterface($domain);
// get php-config
if ($this->settings['phpfpm']['enabled'] == '1') {
if (Settings::Get('phpfpm.enabled') == '1') {
// fpm
$phpconfig = $php->getPhpConfig($this->settings['phpfpm']['vhost_defaultini']);
$phpconfig = $php->getPhpConfig(Settings::Get('phpfpm.vhost_defaultini'));
} else {
// fcgid
$phpconfig = $php->getPhpConfig($this->settings['system']['mod_fcgid_defaultini_ownvhost']);
$phpconfig = $php->getPhpConfig(Settings::Get('system.mod_fcgid_defaultini_ownvhost'));
}
// create starter-file | config-file
$php->getInterface()->createConfig($phpconfig);
// create php.ini (fpm does nothing here, as it
// defines ini-settings in its pool config)
$php->getInterface()->createIniFile($phpconfig);
}
}
}

View File

@@ -56,24 +56,24 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
$configio->cleanUp();
if (!isset($webserver)) {
if ($settings['system']['webserver'] == "apache2") {
if (Settings::Get('system.webserver') == "apache2") {
$websrv = 'apache';
if ($settings['system']['mod_fcgid'] == 1 || $settings['phpfpm']['enabled'] == 1) {
if (Settings::Get('system.mod_fcgid') == 1 || Settings::Get('phpfpm.enabled') == 1) {
$websrv .= '_fcgid';
}
} elseif ($settings['system']['webserver'] == "lighttpd") {
} elseif (Settings::Get('system.webserver') == "lighttpd") {
$websrv = 'lighttpd';
if ($settings['system']['mod_fcgid'] == 1 || $settings['phpfpm']['enabled'] == 1) {
if (Settings::Get('system.mod_fcgid') == 1 || Settings::Get('phpfpm.enabled') == 1) {
$websrv .= '_fcgid';
}
} elseif($settings['system']['webserver'] == "nginx") {
} elseif (Settings::Get('system.webserver') == "nginx") {
$websrv = 'nginx';
if ($settings['phpfpm']['enabled'] == 1) {
if (Settings::Get('phpfpm.enabled') == 1) {
$websrv .= '_phpfpm';
}
}
$webserver = new $websrv($cronlog, $debugHandler, $idna_convert, $settings);
$webserver = new $websrv($cronlog, $debugHandler, $idna_convert);
}
if (isset($webserver)) {
@@ -91,18 +91,17 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
/**
* TYPE=2 MEANS TO CREATE A NEW HOME AND CHOWN
*/
elseif ($row['type'] == '2')
{
elseif ($row['type'] == '2') {
fwrite($debugHandler, ' cron_tasks: Task2 started - create new home' . "\n");
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task2 started - create new home');
if (is_array($row['data'])) {
// define paths
$userhomedir = makeCorrectDir($settings['system']['documentroot_prefix'] . '/' . $row['data']['loginname'] . '/');
$usermaildir = makeCorrectDir($settings['system']['vmail_homedir'] . '/' . $row['data']['loginname'] . '/');
$userhomedir = makeCorrectDir(Settings::Get('system.documentroot_prefix') . '/' . $row['data']['loginname'] . '/');
$usermaildir = makeCorrectDir(Settings::Get('system.vmail_homedir') . '/' . $row['data']['loginname'] . '/');
// stats directory
if ($settings['system']['awstats_enabled'] == '1') {
if (Settings::Get('system.awstats_enabled') == '1') {
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: mkdir -p ' . escapeshellarg($userhomedir . 'awstats'));
safe_exec('mkdir -p ' . escapeshellarg($userhomedir . 'awstats'));
// in case we changed from the other stats -> remove old
@@ -137,20 +136,20 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
safe_exec('chown -R ' . (int)$row['data']['uid'] . ':' . (int)$row['data']['gid'] . ' ' . escapeshellarg($userhomedir));
// don't allow others to access the directory (webserver will be in the users' group)
safe_exec('chmod 0750 ' . escapeshellarg($userhomedir));
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: chown -R ' . (int)$settings['system']['vmail_uid'] . ':' . (int)$settings['system']['vmail_gid'] . ' ' . escapeshellarg($usermaildir));
safe_exec('chown -R ' . (int)$settings['system']['vmail_uid'] . ':' . (int)$settings['system']['vmail_gid'] . ' ' . escapeshellarg($usermaildir));
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: chown -R ' . (int)Settings::Get('system.vmail_uid') . ':' . (int)Settings::Get('system.vmail_gid') . ' ' . escapeshellarg($usermaildir));
safe_exec('chown -R ' . (int)Settings::Get('system.vmail_uid') . ':' . (int)Settings::Get('system.vmail_gid') . ' ' . escapeshellarg($usermaildir));
}
}
/**
* TYPE=4 MEANS THAT SOMETHING IN THE BIND CONFIG HAS CHANGED. REBUILD froxlor_bind.conf IF BIND IS ENABLED
*/
elseif ($row['type'] == '4' && (int)$settings['system']['bind_enable'] != 0) {
elseif ($row['type'] == '4' && (int)Settings::Get('system.bind_enable') != 0) {
if (!isset($nameserver)) {
$nameserver = new bind($cronlog, $debugHandler, $settings);
$nameserver = new bind($cronlog, $debugHandler);
}
if ($settings['dkim']['use_dkim'] == '1') {
if (Settings::Get('dkim.use_dkim') == '1') {
$nameserver->writeDKIMconfigs();
}
@@ -182,52 +181,52 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
if (is_array($row['data'])) {
if (isset($row['data']['loginname'])) {
// remove homedir
$homedir = makeCorrectDir($settings['system']['documentroot_prefix'] . '/' . $row['data']['loginname']);
$homedir = makeCorrectDir(Settings::Get('system.documentroot_prefix') . '/' . $row['data']['loginname']);
if (file_exists($homedir)
&& $homedir != '/'
&& $homedir != $settings['system']['documentroot_prefix']
&& substr($homedir, 0, strlen($settings['system']['documentroot_prefix'])) == $settings['system']['documentroot_prefix']
&& $homedir != Settings::Get('system.documentroot_prefix')
&& substr($homedir, 0, strlen(Settings::Get('system.documentroot_prefix'))) == Settings::Get('system.documentroot_prefix')
) {
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($homedir));
safe_exec('rm -rf '.escapeshellarg($homedir));
}
// remove maildir
$maildir = makeCorrectDir($settings['system']['vmail_homedir'] . '/' . $row['data']['loginname']);
$maildir = makeCorrectDir(Settings::Get('system.vmail_homedir') . '/' . $row['data']['loginname']);
if (file_exists($maildir)
&& $maildir != '/'
&& $maildir != $settings['system']['vmail_homedir']
&& substr($maildir, 0, strlen($settings['system']['vmail_homedir'])) == $settings['system']['vmail_homedir']
&& $maildir != Settings::Get('system.vmail_homedir')
&& substr($maildir, 0, strlen(Settings::Get('system.vmail_homedir'))) == Settings::Get('system.vmail_homedir')
&& is_dir($maildir)
&& fileowner($maildir) == $settings['system']['vmail_uid']
&& filegroup($maildir) == $settings['system']['vmail_gid']
&& fileowner($maildir) == Settings::Get('system.vmail_uid')
&& filegroup($maildir) == Settings::Get('system.vmail_gid')
) {
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($maildir));
safe_exec('rm -rf '.escapeshellarg($maildir));
}
// remove tmpdir if it exists
$tmpdir = makeCorrectDir($settings['system']['mod_fcgid_tmpdir'] . '/' . $row['data']['loginname'] . '/');
$tmpdir = makeCorrectDir(Settings::Get('system.mod_fcgid_tmpdir') . '/' . $row['data']['loginname'] . '/');
if (file_exists($tmpdir)
&& is_dir($tmpdir)
&& $tmpdir != "/"
&& $tmpdir != $settings['system']['mod_fcgid_tmpdir']
&& substr($tmpdir, 0, strlen($settings['system']['mod_fcgid_tmpdir'])) == $settings['system']['mod_fcgid_tmpdir']
&& $tmpdir != Settings::Get('system.mod_fcgid_tmpdir')
&& substr($tmpdir, 0, strlen(Settings::Get('system.mod_fcgid_tmpdir'))) == Settings::Get('system.mod_fcgid_tmpdir')
) {
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($tmpdir));
safe_exec('rm -rf '.escapeshellarg($tmpdir));
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($tmpdir));
safe_exec('rm -rf '.escapeshellarg($tmpdir));
}
// webserver logs
$logsdir = makeCorrectFile($settings['system']['logfiles_directory'].'/'.$row['data']['loginname']);
$logsdir = makeCorrectFile(Settings::Get('system.logfiles_directory').'/'.$row['data']['loginname']);
if (file_exists($logsdir)
&& $logsdir != '/'
&& $logsdir != makeCorrectDir($settings['system']['logfiles_directory'])
&& substr($logsdir, 0, strlen($settings['system']['logfiles_directory'])) == $settings['system']['logfiles_directory']
&& $logsdir != makeCorrectDir(Settings::Get('system.logfiles_directory'))
&& substr($logsdir, 0, strlen(Settings::Get('system.logfiles_directory'))) == Settings::Get('system.logfiles_directory')
) {
// build up wildcard for webX-{access,error}.log{*}
$logfiles .= '-*';
@@ -256,39 +255,39 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
}
$email_user = substr($email_full,0,strrpos($email_full,"@"));
$email_domain = substr($email_full,strrpos($email_full,"@")+1);
$maildirname = trim($settings['system']['vmail_maildirname']);
$maildirname = trim(Settings::Get('system.vmail_maildirname'));
// Add trailing slash to Maildir if needed
$maildirpath = $maildirname;
if (!empty($maildirname) and substr($maildirname,-1) != "/") {
$maildirpath .= "/";
}
$maildir = makeCorrectDir($settings['system']['vmail_homedir'] .'/'. $row['data']['loginname'] .'/'. $email_domain .'/'. $email_user);
$maildir = makeCorrectDir(Settings::Get('system.vmail_homedir') .'/'. $row['data']['loginname'] .'/'. $email_domain .'/'. $email_user);
if ($maildir != '/'
&& !empty($maildir)
&& !empty($email_full)
&& $maildir != $settings['system']['vmail_homedir']
&& substr($maildir, 0, strlen($settings['system']['vmail_homedir'])) == $settings['system']['vmail_homedir']
&& $maildir != Settings::Get('system.vmail_homedir')
&& substr($maildir, 0, strlen(Settings::Get('system.vmail_homedir'))) == Settings::Get('system.vmail_homedir')
&& is_dir($maildir)
&& is_dir(makeCorrectDir($maildir.'/'.$maildirpath))
&& fileowner($maildir) == $settings['system']['vmail_uid']
&& filegroup($maildir) == $settings['system']['vmail_gid']
&& fileowner($maildir) == Settings::Get('system.vmail_uid')
&& filegroup($maildir) == Settings::Get('system.vmail_gid')
) {
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($maildir));
safe_exec('rm -rf '.escapeshellarg($maildir));
} else {
// backward-compatibility for old folder-structure
$maildir_old = makeCorrectDir($settings['system']['vmail_homedir'] .'/'. $row['data']['loginname'] .'/'. $row['data']['email']);
$maildir_old = makeCorrectDir(Settings::Get('system.vmail_homedir') .'/'. $row['data']['loginname'] .'/'. $row['data']['email']);
if ($maildir_old != '/'
&& !empty($maildir_old)
&& $maildir_old != $settings['system']['vmail_homedir']
&& substr($maildir_old, 0, strlen($settings['system']['vmail_homedir'])) == $settings['system']['vmail_homedir']
&& $maildir_old != Settings::Get('system.vmail_homedir')
&& substr($maildir_old, 0, strlen(Settings::Get('system.vmail_homedir'))) == Settings::Get('system.vmail_homedir')
&& is_dir($maildir_old)
&& fileowner($maildir_old) == $settings['system']['vmail_uid']
&& filegroup($maildir_old) == $settings['system']['vmail_gid']
&& fileowner($maildir_old) == Settings::Get('system.vmail_uid')
&& filegroup($maildir_old) == Settings::Get('system.vmail_gid')
) {
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($maildir_old));
safe_exec('rm -rf '.escapeshellarg($maildir_old));
@@ -313,11 +312,11 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
) {
// remove specific homedir
$ftphomedir = makeCorrectDir($row['data']['homedir']);
$customerdocroot = makeCorrectDir($settings['system']['documentroot_prefix'].'/'.$row['data']['loginname'].'/');
$customerdocroot = makeCorrectDir(Settings::Get('system.documentroot_prefix').'/'.$row['data']['loginname'].'/');
if(file_exists($ftphomedir)
if (file_exists($ftphomedir)
&& $ftphomedir != '/'
&& $ftphomedir != $settings['system']['documentroot_prefix']
&& $ftphomedir != Settings::Get('system.documentroot_prefix')
&& $ftphomedir != $customerdocroot
) {
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($ftphomedir));
@@ -330,7 +329,7 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
/**
* TYPE=10 Set the filesystem - quota
*/
elseif ($row['type'] == '10' && (int)$settings['system']['diskquota_enabled'] != 0) {
elseif ($row['type'] == '10' && (int)Settings::Get('system.diskquota_enabled') != 0) {
fwrite($debugHandler, ' cron_tasks: Task10 started - setting filesystem quota' . "\n");
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task10 started - setting filesystem quota');
@@ -343,18 +342,18 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
// We do not want to set a quota for root by accident
if ($row['guid'] != 0) {
// The user has no quota in Froxlor, but on the filesystem
if (($row['diskspace'] == 0 || $row['diskspace'] == -1024)
&& $usedquota[$row['guid']]['block']['hard'] != 0
if (($row['diskspace'] == 0 || $row['diskspace'] == -1024)
&& $usedquota[$row['guid']]['block']['hard'] != 0
) {
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, "Disabling quota for " . $row['loginname']);
safe_exec($settings['system']['diskquota_quotatool_path'] . " -u " . $row['guid'] . " -bl 0 -q 0 " . escapeshellarg($settings['system']['diskquota_customer_partition']));
safe_exec(Settings::Get('system.diskquota_quotatool_path') . " -u " . $row['guid'] . " -bl 0 -q 0 " . escapeshellarg(Settings::Get('system.diskquota_customer_partition')));
}
// The user quota in Froxlor is different than on the filesystem
elseif ($row['diskspace'] != $usedquota[$row['guid']]['block']['hard']
&& $row['diskspace'] != -1024
elseif ($row['diskspace'] != $usedquota[$row['guid']]['block']['hard']
&& $row['diskspace'] != -1024
) {
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, "Setting quota for " . $row['loginname'] . " from " . $usedquota[$row['guid']]['block']['hard'] . " to " . $row['diskspace']);
safe_exec($settings['system']['diskquota_quotatool_path'] . " -u " . $row['guid'] . " -bl " . $row['diskspace'] . " -q " . $row['diskspace'] . " " . escapeshellarg($settings['system']['diskquota_customer_partition']));
safe_exec(Settings::Get('system.diskquota_quotatool_path') . " -u " . $row['guid'] . " -bl " . $row['diskspace'] . " -q " . $row['diskspace'] . " " . escapeshellarg(Settings::Get('system.diskquota_customer_partition')));
}
}
}

View File

@@ -27,16 +27,16 @@ $result_tickets_stmt = Database::query("
);
$archiving_count = 0;
while($row_ticket = $result_tickets_stmt->fetch(PDO::FETCH_ASSOC)) {
while ($row_ticket = $result_tickets_stmt->fetch(PDO::FETCH_ASSOC)) {
$lastchange = $row_ticket['lastchange'];
$now = time();
$days = (int)(($now - $lastchange) / 86400);
if ($days >= $settings['ticket']['archiving_days']) {
if ($days >= Settings::Get('ticket.archiving_days')) {
fwrite($debugHandler, 'archiving ticket "' . $row_ticket['subject'] . '" (ID #' . $row_ticket['id'] . ')' . "\n");
$mainticket = ticket::getInstanceOf(null, $settings, (int)$row_ticket['id']);
$mainticket = ticket::getInstanceOf(null, (int)$row_ticket['id']);
$mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '1', true, true);
$mainticket->Set('status', '3', true, true);

View File

@@ -19,10 +19,10 @@
function awstatsDoSingleDomain($domain, $outputdir) {
global $cronlog, $settings, $theme;
global $cronlog, $theme;
$returnval = 0;
$domainconfig = makeCorrectFile($settings['system']['awstats_conf'].'/awstats.' . $domain . '.conf');
$domainconfig = makeCorrectFile(Settings::Get('system.awstats_conf').'/awstats.' . $domain . '.conf');
if (file_exists($domainconfig)) {
@@ -33,18 +33,18 @@ function awstatsDoSingleDomain($domain, $outputdir) {
}
//check for correct path of awstats_buildstaticpages.pl
$awbsp = makeCorrectFile($settings['system']['awstats_path'].'/awstats_buildstaticpages.pl');
$awprog = makeCorrectFile($settings['system']['awstats_awstatspath'].'/awstats.pl');
$awbsp = makeCorrectFile(Settings::Get('system.awstats_path').'/awstats_buildstaticpages.pl');
$awprog = makeCorrectFile(Settings::Get('system.awstats_awstatspath').'/awstats.pl');
if (!file_exists($awbsp)) {
echo "WANRING: Necessary awstats_buildstaticpages.pl script could not be found, no traffic is being calculated and no stats are generated. Please check your AWStats-Path setting";
$cronlog->logAction(CRON_ACTION, LOG_WARNING, "Necessary awstats_buildstaticpages.pl script could not be found, no traffic is being calculated and no stats are generated. Please check your AWStats-Path setting");
exit;
exit;
}
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Running awstats_buildstaticpages.pl for domain '".$domain."' (Output: '".$outputdir."')");
safe_exec($awbsp.' -awstatsprog='.escapeshellarg($awprog).' -update -month=' . date('n') . ' -year=' . date('Y') . ' -config=' . $domain . ' -dir='.escapeshellarg($outputdir));
// index file is saved like 'awstats.[domain].html',
// so link a index.html to it
$original_index = makeCorrectFile($outputdir.'/awstats.'.$domain.'.html');
@@ -62,7 +62,7 @@ function awstatsDoSingleDomain($domain, $outputdir) {
$content = @file_get_contents($file);
if ($content !== false) {
$content_array = explode("\n", $content);
$count_bdw = false;
foreach ($content_array as $line) {
// skip empty lines and comments
@@ -97,6 +97,7 @@ function awstatsDoSingleDomain($domain, $outputdir) {
return $returnval;
}
function callAwstatsGetTraffic($customerid, $outputdir, $usersdomainlist) {
global $cronlog;
@@ -146,6 +147,7 @@ function callAwstatsGetTraffic($customerid, $outputdir, $usersdomainlist) {
return floatval($returnval);
}
/**
* Function which make webalizer statistics and returns used traffic since last run
*
@@ -157,11 +159,11 @@ function callAwstatsGetTraffic($customerid, $outputdir, $usersdomainlist) {
*/
function callWebalizerGetTraffic($logfile, $outputdir, $caption, $usersdomainlist) {
global $settings, $cronlog;
global $cronlog;
$returnval = 0;
$logfile = makeCorrectFile($settings['system']['logfiles_directory'] . $logfile . '-access.log');
$logfile = makeCorrectFile(Settings::Get('system.logfiles_directory') . $logfile . '-access.log');
if (file_exists($logfile)) {
$domainargs = '';
foreach ($usersdomainlist as $domainid => $domain) {
@@ -185,14 +187,14 @@ function callWebalizerGetTraffic($logfile, $outputdir, $caption, $usersdomainlis
}
$verbosity = '';
if ($settings['system']['webalizer_quiet'] == '1') {
if (Settings::Get('system.webalizer_quiet') == '1') {
$verbosity = '-q';
} elseif($settings['system']['webalizer_quiet'] == '2') {
} elseif (Settings::Get('system.webalizer_quiet') == '2') {
$verbosity = '-Q';
}
$we = '/usr/bin/webalizer';
// FreeBSD uses other paths, #140
if (!file_exists($we)) {
$we = '/usr/local/bin/webalizer';
@@ -267,7 +269,7 @@ function callWebalizerGetTraffic($logfile, $outputdir, $caption, $usersdomainlis
foreach ($months as $month => $traffic) {
if (!isset($httptrafficlast[$year][$month])) {
$returnval+= $traffic;
} elseif($httptrafficlast[$year][$month] < $httptraffic[$year][$month]) {
} elseif ($httptrafficlast[$year][$month] < $httptraffic[$year][$month]) {
$returnval+= ($httptraffic[$year][$month] - $httptrafficlast[$year][$month]);
}
}

View File

@@ -143,7 +143,7 @@ while ($row_database = $databases_stmt->fetch(PDO::FETCH_ASSOC)) {
Database::needRoot(false);
// We are using the file-system quota, this will speed up the diskusage - collection
if ($settings['system']['diskquota_enabled']) {
if (Settings::Get('system.diskquota_enabled')) {
$usedquota = getFilesystemQuota();
}
@@ -157,8 +157,8 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$httptraffic = 0;
if (isset($domainlist[$row['customerid']])
&& is_array($domainlist[$row['customerid']])
&& count($domainlist[$row['customerid']]) != 0
&& is_array($domainlist[$row['customerid']])
&& count($domainlist[$row['customerid']]) != 0
) {
// Examining which caption to use for default webalizer stats...
if ($row['standardsubdomain'] != '0') {
@@ -172,7 +172,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
foreach ($domainlist[$row['customerid']] as $domainid => $domain) {
if (!isset($speciallogfile_domainlist[$row['customerid']])
|| !isset($speciallogfile_domainlist[$row['customerid']][$domainid])
|| !isset($speciallogfile_domainlist[$row['customerid']][$domainid])
) {
$caption = $domain;
break;
@@ -184,11 +184,11 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
reset($domainlist[$row['customerid']]);
if (isset($speciallogfile_domainlist[$row['customerid']])
&& is_array($speciallogfile_domainlist[$row['customerid']])
&& count($speciallogfile_domainlist[$row['customerid']]) != 0
&& is_array($speciallogfile_domainlist[$row['customerid']])
&& count($speciallogfile_domainlist[$row['customerid']]) != 0
) {
reset($speciallogfile_domainlist[$row['customerid']]);
if ($settings['system']['awstats_enabled'] == '0') {
if (Settings::Get('system.awstats_enabled') == '0') {
foreach ($speciallogfile_domainlist[$row['customerid']] as $domainid => $domain) {
$httptraffic+= floatval(callWebalizerGetTraffic($row['loginname'] . '-' . $domain, $row['documentroot'] . '/webalizer/' . $domain . '/', $domain, $domainlist[$row['customerid']]));
}
@@ -201,7 +201,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
// *not* also in the special-logfiles-loop, because the function
// will iterate through all customer-domains and the awstats-configs
// know the logfile-name, #246
if ($settings['system']['awstats_enabled'] == '1') {
if (Settings::Get('system.awstats_enabled') == '1') {
$httptraffic+= floatval(callAwstatsGetTraffic($row['customerid'], $row['documentroot'] . '/awstats/', $domainlist[$row['customerid']]));
} else {
$httptraffic+= floatval(callWebalizerGetTraffic($row['loginname'], $row['documentroot'] . '/webalizer/', $caption, $domainlist[$row['customerid']]));
@@ -306,7 +306,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$webspaceusage = 0;
// Using repquota, it's faster using this tool than using du traversing the complete directory
if ($settings['system']['diskquota_enabled']
if (Settings::Get('system.diskquota_enabled')
&& isset($usedquota[$row['guid']]['block']['used'])
&& $usedquota[$row['guid']]['block']['used'] >= 1
) {
@@ -338,7 +338,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
fwrite($debugHandler, 'calculating mailspace usage for ' . $row['loginname'] . "\n");
$emailusage = 0;
$maildir = makeCorrectDir($settings['system']['vmail_homedir'] . $row['loginname']);
$maildir = makeCorrectDir(Settings::Get('system.vmail_homedir') . $row['loginname']);
if (file_exists($maildir) && is_dir($maildir)) {
$back = safe_exec('du -sk ' . escapeshellarg($maildir) . '');
foreach ($back as $backrow) {
@@ -430,7 +430,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$upd_data = array(
'biu' => ($current_diskspace['all'] * 1024),
'loginname' => $row['loginname'],
'loginnamelike' => $row['loginname'] . $settings['customer']['ftpprefix'] . "%"
'loginnamelike' => $row['loginname'] . Settings::Get('customer.ftpprefix') . "%"
);
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_FTP_QUOTATALLIES . "` SET
@@ -441,7 +441,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
/**
* Pureftpd Quota
*/
if ($settings['system']['ftpserver'] == "pureftpd") {
if (Settings::Get('system.ftpserver') == "pureftpd") {
$result_quota_stmt = Database::prepare("
SELECT homedir FROM `" . TABLE_FTP_USERS . "` WHERE customerid = :customerid
@@ -449,7 +449,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
Database::pexecute($result_quota_stmt, array('customerid' => $row['customerid']));
// get correct user
if ($settings['system']['mod_fcgid'] == 1
if (Settings::Get('system.mod_fcgid') == 1
&& $row['deactivated'] == '0'
) {
$user = $row['loginname'];

View File

@@ -33,7 +33,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if (isset($row['diskspace'])
&& $row['diskspace_used'] != null
&& $row['diskspace_used'] > 0
&& (($row['diskspace_used'] * 100) / $row['diskspace']) >= (int)$settings['system']['report_webmax']
&& (($row['diskspace_used'] * 100) / $row['diskspace']) >= (int)Settings::Get('system.report_webmax')
) {
$rep_userinfo = array(
@@ -47,7 +47,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
'DISKAVAILABLE' => round(($row['diskspace'] / 1024), 2), /* traffic is stored in KB, template uses MB */
'DISKUSED' => round($row['diskspace_used'] / 1024, 2), /* traffic is stored in KB, template uses MB */
'USAGE_PERCENT' => round(($row['diskspace_used'] * 100) / $row['diskspace'], 2),
'MAX_PERCENT' => $settings['system']['report_webmax']
'MAX_PERCENT' => Settings::Get('system.report_webmax')
);
$lngfile_stmt = Database::prepare("
@@ -59,7 +59,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($lngfile !== null) {
$langfile = $lngfile['file'];
} else {
$lngfile = Database::pexecute_first($lngfile_stmt, array('deflang' => $settings['panel']['standardlanguage']));
$lngfile = Database::pexecute_first($lngfile_stmt, array('deflang' => Settings::Get('panel.standardlanguage')));
$langfile = $lngfile['file'];
}
@@ -129,7 +129,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if (isset($row['diskspace'])
&& $row['diskspace_used'] != null
&& $row['diskspace_used'] > 0
&& (($row['diskspace_used'] * 100) / $row['diskspace']) >= (int)$settings['system']['report_webmax']
&& (($row['diskspace_used'] * 100) / $row['diskspace']) >= (int)Settings::Get('system.report_webmax')
) {
$replace_arr = array(
@@ -137,7 +137,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
'DISKAVAILABLE' => ($row['diskspace'] / 1024), /* traffic is stored in KB, template uses MB */
'DISKUSED' => round($row['diskspace_used'] / 1024, 2), /* traffic is stored in KB, template uses MB */
'USAGE_PERCENT' => ($row['diskspace_used'] * 100) / $row['diskspace'],
'MAX_PERCENT' => $settings['system']['report_webmax']
'MAX_PERCENT' => Settings::Get('system.report_webmax')
);
$lngfile_stmt = Database::prepare("
@@ -149,7 +149,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($lngfile !== null) {
$langfile = $lngfile['file'];
} else {
$lngfile = Database::pexecute_first($lngfile_stmt, array('deflang' => $settings['panel']['standardlanguage']));
$lngfile = Database::pexecute_first($lngfile_stmt, array('deflang' => Settings::Get('panel.standardlanguage')));
$langfile = $lngfile['file'];
}

View File

@@ -26,7 +26,7 @@ $yesterday = time() - (60 * 60 * 24);
$mail = new PHPMailer(true);
$mail->CharSet = "UTF-8";
$mail->SetFrom($settings['panel']['adminmail'], 'Froxlor Administrator');
$mail->SetFrom(Settings::Get('panel.adminmail'), 'Froxlor Administrator');
// Warn the customers at xx% traffic-usage
@@ -54,7 +54,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if (isset($row['traffic'])
&& $row['traffic'] > 0
&& $row['traffic_used'] != null
&& (($row['traffic_used'] * 100) / $row['traffic']) >= (int)$settings['system']['report_trafficmax']
&& (($row['traffic_used'] * 100) / $row['traffic']) >= (int)Settings::Get('system.report_trafficmax')
) {
$rep_userinfo = array(
'name' => $row['name'],
@@ -67,7 +67,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
'TRAFFIC' => round(($row['traffic'] / 1024), 2), /* traffic is stored in KB, template uses MB */
'TRAFFICUSED' => round(($row['traffic_used'] / 1024), 2), /* traffic is stored in KB, template uses MB */
'USAGE_PERCENT' => round(($row['traffic_used'] * 100) / $row['traffic'], 2),
'MAX_PERCENT' => $settings['system']['report_trafficmax']
'MAX_PERCENT' => Settings::Get('system.report_trafficmax')
);
$lngfile_stmt = Database::prepare("
@@ -79,7 +79,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($lngfile !== null) {
$langfile = $lngfile['file'];
} else {
$lngfile = Database::pexecute_first($lngfile_stmt, array('deflang' => $settings['panel']['standardlanguage']));
$lngfile = Database::pexecute_first($lngfile_stmt, array('deflang' => Settings::Get('panel.standardlanguage')));
$langfile = $lngfile['file'];
}
@@ -96,9 +96,9 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
AND `templategroup` = 'mails' AND `varname` = :varname
");
$resul2_data = array(
'adminid' => $row['adminid'],
'lang' => $row['def_language'],
'varname' => 'trafficmaxpercent_subject'
'adminid' => $row['adminid'],
'lang' => $row['def_language'],
'varname' => 'trafficmaxpercent_subject'
);
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_subject = html_entity_decode(replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr));
@@ -106,7 +106,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$resul2_data['varname'] = 'trafficmaxpercent_mailbody';
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_body = html_entity_decode(replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr));
$_mailerror = false;
try {
$mail->SetFrom($row['adminmail'], $row['adminname']);
@@ -148,8 +148,8 @@ $result_stmt = Database::prepare("
");
$result_data = array(
'year' => date("Y", $yesterday),
'month' => date("m", $yesterday)
'year' => date("Y", $yesterday),
'month' => date("m", $yesterday)
);
Database::pexecute($result_stmt, $result_data);
@@ -157,7 +157,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if (isset($row['traffic'])
&& $row['traffic'] > 0
&& (($row['traffic_used_total'] * 100) / $row['traffic']) >= (int)$settings['system']['report_trafficmax']
&& (($row['traffic_used_total'] * 100) / $row['traffic']) >= (int)Settings::Get('system.report_trafficmax')
) {
$replace_arr = array(
@@ -165,7 +165,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
'TRAFFIC' => round(($row['traffic'] / 1024), 2), /* traffic is stored in KB, template uses MB */
'TRAFFICUSED' => round(($row['traffic_used_total'] / 1024), 2), /* traffic is stored in KB, template uses MB */
'USAGE_PERCENT' => round(($row['traffic_used_total'] * 100) / $row['traffic'], 2),
'MAX_PERCENT' => $settings['system']['report_trafficmax']
'MAX_PERCENT' => Settings::Get('system.report_trafficmax')
);
$lngfile_stmt = Database::prepare("
@@ -177,7 +177,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($lngfile !== null) {
$langfile = $lngfile['file'];
} else {
$lngfile = Database::pexecute_first($lngfile_stmt, array('deflang' => $settings['panel']['standardlanguage']));
$lngfile = Database::pexecute_first($lngfile_stmt, array('deflang' => Settings::Get('panel.standardlanguage')));
$langfile = $lngfile['file'];
}
@@ -194,9 +194,9 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
AND `templategroup` = 'mails' AND `varname` = :varname
");
$resul2_data = array(
'adminid' => $row['adminid'],
'lang' => $row['def_language'],
'varname' => 'trafficmaxpercent_subject'
'adminid' => $row['adminid'],
'lang' => $row['def_language'],
'varname' => 'trafficmaxpercent_subject'
);
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_subject = html_entity_decode(replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr));
@@ -266,7 +266,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$mail_body.= '---------------------------------------------' . "\n";
$mail_body.= sprintf('%-15s', $row['loginname']) . ' ' . sprintf('%-12d', $row['traffic_used_total']) . ' (' . sprintf('%00.3f%%', (($row['traffic_used_total'] * 100) / $row['traffic'])) . ') ' . $row['traffic'] . "\n";
$_mailerror = false;
try {
$mail->SetFrom($row['email'], $row['name']);

357
scripts/settings Normal file
View File

@@ -0,0 +1,357 @@
jobs/cron_tasks.inc.dns.10.bind.php: $this->logger = $logger;
jobs/cron_tasks.inc.dns.10.bind.php: $this->debugHandler = $debugHandler;
jobs/cron_tasks.inc.dns.10.bind.php: $this->nameservers[] = array(
jobs/cron_tasks.inc.dns.10.bind.php: $this->mxservers[] = $mxserver;
jobs/cron_tasks.inc.dns.10.bind.php: $this->axfrservers[] = trim($axfrserver);
jobs/cron_tasks.inc.dns.10.bind.php: fwrite($this->debugHandler, ' cron_tasks: Task4 started - Rebuilding froxlor_bind.conf' . "\n");
jobs/cron_tasks.inc.dns.10.bind.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Task4 started - Rebuilding froxlor_bind.conf');
jobs/cron_tasks.inc.dns.10.bind.php: $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/')));
jobs/cron_tasks.inc.dns.10.bind.php: fwrite($this->debugHandler, ' cron_tasks: Task4 - Writing ' . $domain['id'] . '::' . $domain['domain'] . "\n");
jobs/cron_tasks.inc.dns.10.bind.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Writing ' . $domain['id'] . '::' . $domain['domain']);
jobs/cron_tasks.inc.dns.10.bind.php: $zonefile = $this->generateZone($domain);
jobs/cron_tasks.inc.dns.10.bind.php: fwrite($this->debugHandler, ' cron_tasks: Task4 - `' . $zonefile_name . '` zone written' . "\n");
jobs/cron_tasks.inc.dns.10.bind.php: if (count($this->nameservers) > 0
jobs/cron_tasks.inc.dns.10.bind.php: || count($this->axfrservers) > 0
jobs/cron_tasks.inc.dns.10.bind.php: if (count($this->nameservers) > 0) {
jobs/cron_tasks.inc.dns.10.bind.php: foreach ($this->nameservers as $ns) {
jobs/cron_tasks.inc.dns.10.bind.php: if (count($this->axfrservers) > 0) {
jobs/cron_tasks.inc.dns.10.bind.php: foreach ($this->axfrservers as $axfrserver) {
jobs/cron_tasks.inc.dns.10.bind.php: fwrite($this->debugHandler, ' cron_tasks: Task4 - froxlor_bind.conf written' . "\n");
jobs/cron_tasks.inc.dns.10.bind.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, 'froxlor_bind.conf written');
jobs/cron_tasks.inc.dns.10.bind.php: fwrite($this->debugHandler, ' cron_tasks: Task4 - Bind9 reloaded' . "\n");
jobs/cron_tasks.inc.dns.10.bind.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Bind9 reloaded');
jobs/cron_tasks.inc.dns.10.bind.php: fwrite($this->debugHandler, ' cron_tasks: Task4 - unlinking ' . $domain_filename . "\n");
jobs/cron_tasks.inc.dns.10.bind.php: $this->logger->logAction(CRON_ACTION, LOG_WARNING, 'Deleting ' . $domain_filename);
jobs/cron_tasks.inc.dns.10.bind.php: if (count($this->nameservers) == 0) {
jobs/cron_tasks.inc.dns.10.bind.php: $zonefile.= '@ IN SOA ' . $this->nameservers[0]['hostname'] . ' ' . str_replace('@', '.', Settings::Get('panel.adminmail')) . '. (' . "\n";
jobs/cron_tasks.inc.dns.10.bind.php: if (count($this->nameservers) == 0) {
jobs/cron_tasks.inc.dns.10.bind.php: foreach ($this->nameservers as $nameserver) {
jobs/cron_tasks.inc.dns.10.bind.php: if (count($this->mxservers) == 0) {
jobs/cron_tasks.inc.dns.10.bind.php: foreach ($this->mxservers as $mxserver) {
jobs/cron_tasks.inc.dns.10.bind.php: $zonefile.= $this->generateDkim($domain);
jobs/cron_tasks.inc.dns.10.bind.php: if (count($this->nameservers) == 0) {
jobs/cron_tasks.inc.dns.10.bind.php: foreach ($this->nameservers as $nameserver) {
jobs/cron_tasks.inc.dns.10.bind.php: $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('dkim.dkim_prefix'))));
jobs/cron_tasks.inc.dns.10.bind.php: fwrite($this->debugHandler, ' cron_tasks: Task4 - Dkim-milter reloaded' . "\n");
jobs/cron_tasks.inc.dns.10.bind.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Dkim-milter reloaded');
jobs/cron_tasks.inc.http.10.apache.php: $this->logger = $logger;
jobs/cron_tasks.inc.http.10.apache.php: $this->debugHandler = $debugHandler;
jobs/cron_tasks.inc.http.10.apache.php: $this->idnaConvert = $idnaConvert;
jobs/cron_tasks.inc.http.10.apache.php: fwrite($this->debugHandler, ' apache::reload: reloading php-fpm' . "\n");
jobs/cron_tasks.inc.http.10.apache.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm');
jobs/cron_tasks.inc.http.10.apache.php: fwrite($this->debugHandler, ' apache::reload: reloading apache' . "\n");
jobs/cron_tasks.inc.http.10.apache.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading apache');
jobs/cron_tasks.inc.http.10.apache.php: fwrite($this->debugHandler, ' apache::_createStandardDirectoryEntry: unlinking ' . basename($vhosts_filename) . "\n");
jobs/cron_tasks.inc.http.10.apache.php: $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'unlinking ' . basename($vhosts_filename));
jobs/cron_tasks.inc.http.10.apache.php: if (!isset($this->virtualhosts_data[$vhosts_filename])) {
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] = '';
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= ' <Directory "' . makeCorrectDir(Settings::Get('system.documentroot_prefix')) . '">' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= ' Require all granted' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= ' Order allow,deny' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= ' allow from all' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= ' </Directory>' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: if (!isset($this->virtualhosts_data[$vhosts_filename])) {
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] = '';
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= 'ErrorDocument ' . $statusCode . ' ' . $defhandler . "\n";
jobs/cron_tasks.inc.http.10.apache.php: fwrite($this->debugHandler, ' apache::createIpPort: creating ip/port settings for ' . $ipport . "\n");
jobs/cron_tasks.inc.http.10.apache.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating ip/port settings for ' . $ipport);
jobs/cron_tasks.inc.http.10.apache.php: if (!isset($this->virtualhosts_data[$vhosts_filename])) {
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] = '';
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= 'Listen ' . $ipport . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->logger->logAction(CRON_ACTION, LOG_DEBUG, $ipport . ' :: inserted listen-statement');
jobs/cron_tasks.inc.http.10.apache.php: $this->logger->logAction(CRON_ACTION, LOG_NOTICE, $ipport . ' :: namevirtualhost-statement no longer needed for apache-2.4');
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= 'NameVirtualHost ' . $ipport . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->logger->logAction(CRON_ACTION, LOG_DEBUG, $ipport . ' :: inserted namevirtualhost-statement');
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= '<VirtualHost ' . $ipport . '>' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= 'DocumentRoot "'.$mypath.'"'."\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' ServerName ' . Settings::Get('system.hostname') . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' FcgidIdleTimeout ' . Settings::Get('system.mod_fcgid_idle_timeout') . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' SuexecUserGroup "' . Settings::Get('system.mod_fcgid_httpuser') . '" "' . Settings::Get('system.mod_fcgid_httpgroup') . '"' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' ScriptAlias /php/ ' . $configdir . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' SuexecUserGroup "' . Settings::Get('system.mod_fcgid_httpuser') . '" "' . Settings::Get('system.mod_fcgid_httpgroup') . '"' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= ' <Directory "' . $mypath . '">' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= ' <FilesMatch "\.(' . implode('|', $file_extensions) . ')$">' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= ' SetHandler fcgid-script' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= ' FcgidWrapper ' . $starter_filename . ' .' . $file_extension . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= ' Options +ExecCGI' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= ' </FilesMatch>' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= ' Require all granted' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= ' Order allow,deny' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= ' allow from all' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= ' </Directory>' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' FastCgiExternalServer ' . $php->getInterface()->getAliasConfigDir() . $srvName .' -socket ' . $php->getInterface()->getSocketFile() . ' -idle-timeout ' . Settings::Get('phpfpm.idle_timeout') . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' <Directory "' . $mypath . '">' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' <FilesMatch "\.(' . implode('|', $file_extensions) . ')$">' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' AddHandler php5-fastcgi .php'. "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' Action php5-fastcgi /fastcgiphp' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= ' Options +ExecCGI' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= ' </FilesMatch>' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' Require all granted' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' Order allow,deny' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' allow from all' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' </Directory>' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' Alias /fastcgiphp ' . $php->getInterface()->getAliasConfigDir() . $srvName . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= "\t<Directory \"'.$mypath.'(images|packages|templates)\">\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= "\t\tAllow from all\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= "\t\tOptions -Indexes\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= "\t</Directory>\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= "\t<Directory \"'.$mypath.'*\">\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= "\t\tOrder Deny,Allow\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= "\t\tDeny from All\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= "\t</Directory>\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= $row_ipsandports['specialsettings'] . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' SSLEngine On' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' SSLHonorCipherOrder On' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' SSLCipherSuite ' . Settings::Get('system.ssl_cipher_list') . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' SSLVerifyDepth 10' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' SSLCertificateFile ' . makeCorrectFile($row_ipsandports['ssl_cert_file']) . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' SSLCertificateKeyFile ' . makeCorrectFile($row_ipsandports['ssl_key_file']) . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' SSLCACertificateFile ' . makeCorrectFile($row_ipsandports['ssl_ca_file']) . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= ' SSLCertificateChainFile ' . makeCorrectFile($row_ipsandports['ssl_cert_chainfile']) . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= '</VirtualHost>' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->logger->logAction(CRON_ACTION, LOG_DEBUG, $ipport . ' :: inserted vhostcontainer');
jobs/cron_tasks.inc.http.10.apache.php: $this->_createStandardDirectoryEntry();
jobs/cron_tasks.inc.http.10.apache.php: $this->_createStandardErrorHandler();
jobs/cron_tasks.inc.http.10.apache.php: $this->_deactivated = true;
jobs/cron_tasks.inc.http.10.apache.php: $this->_deactivated = false;
jobs/cron_tasks.inc.http.10.apache.php: $vhost_content.= $this->getServerNames($domain);
jobs/cron_tasks.inc.http.10.apache.php: $corrected_docroot = $this->idnaConvert->encode($domain['documentroot']);
jobs/cron_tasks.inc.http.10.apache.php: $vhost_content .= ' Redirect '.$code.' / ' . $this->idnaConvert->encode($domain['documentroot']) . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $vhost_content .= $this->getWebroot($domain);
jobs/cron_tasks.inc.http.10.apache.php: if ($this->_deactivated == false) {
jobs/cron_tasks.inc.http.10.apache.php: $vhost_content .= $this->composePhpOptions($domain,$ssl_vhost);
jobs/cron_tasks.inc.http.10.apache.php: $vhost_content .= $this->getStats($domain);
jobs/cron_tasks.inc.http.10.apache.php: $vhost_content .= $this->getLogfiles($domain);
jobs/cron_tasks.inc.http.10.apache.php: fwrite($this->debugHandler, ' apache::createVirtualHosts: creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname'] . "\n");
jobs/cron_tasks.inc.http.10.apache.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname']);
jobs/cron_tasks.inc.http.10.apache.php: $vhosts_filename = $this->getVhostFilename($domain);
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] = '# Domain ID: ' . $domain['id'] . ' - CustomerID: ' . $domain['customerid'] . ' - CustomerLogin: ' . $domain['loginname'] . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename].= $this->getVhostContent($domain, false);
jobs/cron_tasks.inc.http.10.apache.php: $vhosts_filename_ssl = $this->getVhostFilename($domain, true);
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename_ssl] = '# Domain ID: ' . $domain['id'] . ' (SSL) - CustomerID: ' . $domain['customerid'] . ' - CustomerLogin: ' . $domain['loginname'] . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename_ssl] .= $this->getVhostContent($domain, true);
jobs/cron_tasks.inc.http.10.apache.php: $this->virtualhosts_data[$vhosts_filename] .= '# Customer deactivated and a docroot for deactivated users hasn\'t been set.' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: if (!isset($this->diroptions_data[$diroptions_filename])) {
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] = '';
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] .= '<Directory "' . $row_diroptions['path'] . '">' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] .= ' Options +Indexes';
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] .= ' ExecCGI -MultiViews +SymLinksIfOwnerMatch +FollowSymLinks'."\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] .= "\n";
jobs/cron_tasks.inc.http.10.apache.php: fwrite($this->debugHandler, ' cron_tasks: Task3 - Setting Options +Indexes' . "\n");
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] .= ' Options -Indexes';
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] .= ' ExecCGI -MultiViews +SymLinksIfOwnerMatch +FollowSymLinks'."\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] .= "\n";
jobs/cron_tasks.inc.http.10.apache.php: fwrite($this->debugHandler, ' cron_tasks: Task3 - Setting Options -Indexes' . "\n");
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename].= ' ErrorDocument ' . $statusCode . ' ' . $defhandler . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] .= ' AllowOverride None' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] .= ' AddHandler cgi-script .cgi .pl' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] .= ' Require all granted' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] .= ' Order allow,deny' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] .= ' Allow from all' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: fwrite($this->debugHandler, ' cron_tasks: Task3 - Enabling perl execution' . "\n");
jobs/cron_tasks.inc.http.10.apache.php: if (!isset($this->htpasswds_data[$htpasswd_filename])) {
jobs/cron_tasks.inc.http.10.apache.php: $this->htpasswds_data[$htpasswd_filename] = '';
jobs/cron_tasks.inc.http.10.apache.php: $this->htpasswds_data[$htpasswd_filename] .= $row_htpasswd['username'] . ':' . $row_htpasswd['password'] . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] .= ' AuthType Basic' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] .= ' AuthName "'.$row_htpasswd['authname'].'"' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] .= ' AuthUserFile ' . $htpasswd_filename . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] .= ' require valid-user' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: $this->diroptions_data[$diroptions_filename] .= '</Directory>' . "\n";
jobs/cron_tasks.inc.http.10.apache.php: fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_diroptions') . "\n");
jobs/cron_tasks.inc.http.10.apache.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_diroptions'));
jobs/cron_tasks.inc.http.10.apache.php: if (count($this->diroptions_data) > 0) {
jobs/cron_tasks.inc.http.10.apache.php: foreach ($this->diroptions_data as $diroptions_filename => $diroptions_content) {
jobs/cron_tasks.inc.http.10.apache.php: fwrite($this->debugHandler, ' apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))) . "\n");
jobs/cron_tasks.inc.http.10.apache.php: $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))));
jobs/cron_tasks.inc.http.10.apache.php: foreach ($this->diroptions_data as $diroptions_filename => $diroptions_file) {
jobs/cron_tasks.inc.http.10.apache.php: $this->known_diroptionsfilenames[] = basename($diroptions_filename);
jobs/cron_tasks.inc.http.10.apache.php: fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_htpasswddir') . "\n");
jobs/cron_tasks.inc.http.10.apache.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_htpasswddir'));
jobs/cron_tasks.inc.http.10.apache.php: if (count($this->htpasswds_data) > 0) {
jobs/cron_tasks.inc.http.10.apache.php: foreach ($this->htpasswds_data as $htpasswd_filename => $htpasswd_file) {
jobs/cron_tasks.inc.http.10.apache.php: $this->known_htpasswdsfilenames[] = basename($htpasswd_filename);
jobs/cron_tasks.inc.http.10.apache.php: fwrite($this->debugHandler, ' cron_tasks: WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!' . "\n");
jobs/cron_tasks.inc.http.10.apache.php: $this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!');
jobs/cron_tasks.inc.http.10.apache.php: fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_vhost') . "\n");
jobs/cron_tasks.inc.http.10.apache.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_vhost'));
jobs/cron_tasks.inc.http.10.apache.php: if (count($this->virtualhosts_data) > 0) {
jobs/cron_tasks.inc.http.10.apache.php: ksort($this->virtualhosts_data);
jobs/cron_tasks.inc.http.10.apache.php: foreach ($this->virtualhosts_data as $vhosts_filename => $vhost_content) {
jobs/cron_tasks.inc.http.10.apache.php: fwrite($this->debugHandler, ' apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))) . "\n");
jobs/cron_tasks.inc.http.10.apache.php: $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
jobs/cron_tasks.inc.http.10.apache.php: foreach ($this->virtualhosts_data as $vhosts_filename => $vhosts_file) {
jobs/cron_tasks.inc.http.10.apache.php: $this->known_vhostfilenames[] = basename($vhosts_filename);
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->logger = $logger;
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->debugHandler = $debugHandler;
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->idnaConvert = $idnaConvert;
jobs/cron_tasks.inc.http.20.lighttpd.php: fwrite($this->debugHandler, ' lighttpd::reload: reloading php-fpm' . "\n");
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm');
jobs/cron_tasks.inc.http.20.lighttpd.php: fwrite($this->debugHandler, ' lighttpd::reload: reloading lighttpd' . "\n");
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading lighttpd');
jobs/cron_tasks.inc.http.20.lighttpd.php: fwrite($this->debugHandler, ' lighttpd::createIpPort: creating ip/port settings for ' . $ip . ":" . $port . "\n");
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating ip/port settings for ' . $ip . ":" . $port);
jobs/cron_tasks.inc.http.20.lighttpd.php: if (!isset($this->lighttpd_data[$vhost_filename])) {
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename] = '';
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= '$SERVER["socket"] == "' . $ip . ':' . $port . '" {' . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= 'server.port = ' . $port . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= 'server.bind = "' . $ip . '"' . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= $ipv6;
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= '# Froxlor default vhost' . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= '$HTTP["host"] =~ "^(?:www\.|)' . $myhost . '$" {' . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= ' server.document-root = "'.$mypath.'"'."\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= ' $HTTP["url"] =~ "^/(.+)\/(.+)\.php" {' . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= ' url.access-deny = ("")' . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= ' }' . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= ' fastcgi.server = ( '."\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= "\t".'".php" => ('."\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= "\t\t".'"localhost" => ('."\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= "\t\t".'"socket" => "'.$php->getInterface()->getSocketFile().'",'."\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= "\t\t".'"check-local" => "enable",'."\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= "\t\t".'"disable-time" => 1'."\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= "\t".')'."\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= "\t".')'."\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= ' )'."\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= $row_ipsandports['specialsettings'] . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= '}' . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= 'ssl.engine = "enable"' . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= 'ssl.use-sslv2 = "disable"' . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= 'ssl.cipher-list = "' . Settings::Get('system.ssl_cipher_list') . '"' . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= 'ssl.honor-cipher-order = "enable"' . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= 'ssl.pemfile = "' . makeCorrectFile($row_ipsandports['ssl_cert_file']) . '"' . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= 'ssl.ca-file = "' . makeCorrectFile($row_ipsandports['ssl_ca_file']) . '"' . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $vhosts = $this->createLighttpdHosts($row_ipsandports['id'], $row_ipsandports['ssl'], $vhost_filename);
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= ' include "'.$vhost.'"'."\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename].= '}' . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->_createStandardErrorHandler();
jobs/cron_tasks.inc.http.20.lighttpd.php: if (!isset($this->lighttpd_data[$vhost_filename])) {
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename] = '';
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename] = 'server.error-handler-404 = "'.$defhandler.'"';
jobs/cron_tasks.inc.http.20.lighttpd.php: if (!isset($this->needed_htpasswds[$filename])) {
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->needed_htpasswds[$filename] = '';
jobs/cron_tasks.inc.http.20.lighttpd.php: if (!strstr($this->needed_htpasswds[$filename], $row_htpasswds['username'] . ':' . $row_htpasswds['password'])) {
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->needed_htpasswds[$filename].= $row_htpasswds['username'] . ':' . $row_htpasswds['password'] . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: if (!isset($this->lighttpd_data[$vhost_filename])) {
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename] = '';
jobs/cron_tasks.inc.http.20.lighttpd.php: if ((!empty($this->lighttpd_data[$vhost_filename])
jobs/cron_tasks.inc.http.20.lighttpd.php: if ($this->lighttpd_data[$vhost_filename] == '') {
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->lighttpd_data[$vhost_filename] .= $this->getVhostContent($domain, $ssl_vhost, $ipid);
jobs/cron_tasks.inc.http.20.lighttpd.php: $vhost_content.= $this->getServerNames($domain) . " {\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $vhost_content.= ' "^/(.*)$" => "'. $this->idnaConvert->encode($domain['documentroot']) . '$1"'. "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: $vhost_content.= $this->getWebroot($domain, $ssl_vhost);
jobs/cron_tasks.inc.http.20.lighttpd.php: if ($this->_deactivated == false) {
jobs/cron_tasks.inc.http.20.lighttpd.php: $vhost_content.= $this->create_htaccess($domain);
jobs/cron_tasks.inc.http.20.lighttpd.php: $vhost_content.= $this->create_pathOptions($domain);
jobs/cron_tasks.inc.http.20.lighttpd.php: $vhost_content.= $this->composePhpOptions($domain);
jobs/cron_tasks.inc.http.20.lighttpd.php: $vhost_content.= $this->getStats($domain);
jobs/cron_tasks.inc.http.20.lighttpd.php: $vhost_content.= $this->getSslSettings($domain, $ssl_vhost);
jobs/cron_tasks.inc.http.20.lighttpd.php: $vhost_content.= $this->getLogFiles($domain);
jobs/cron_tasks.inc.http.20.lighttpd.php: if ($this->auth_backend_loaded[$domain['ipandport']] != 'yes') {
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->needed_htpasswds[$filename] = $row_htpasswds['username'] . ':' . $row_htpasswds['password'] . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: } elseif ($this->auth_backend_loaded[$domain['ssl_ipandport']] != 'yes') {
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->needed_htpasswds[$filename] = $row_htpasswds['username'] . ':' . $row_htpasswds['password'] . "\n";
jobs/cron_tasks.inc.http.20.lighttpd.php: if ($this->auth_backend_loaded[$domain['ssl_ipandport']] == 'yes') {
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->needed_htpasswds[$domain['ssl_ipandport']].= $diroption_text;
jobs/cron_tasks.inc.http.20.lighttpd.php: if ($this->auth_backend_loaded[$domain['ipandport']] != 'yes') {
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->needed_htpasswds[$domain['ipandport']].= $diroption_text;
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->_deactivated = true;
jobs/cron_tasks.inc.http.20.lighttpd.php: $redirect_domain = $this->idnaConvert->encode('https://' . $domain['domain']);
jobs/cron_tasks.inc.http.20.lighttpd.php: $redirect_domain = $this->idnaConvert->encode($domain['documentroot']);
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->_deactivated = false;
jobs/cron_tasks.inc.http.20.lighttpd.php: fwrite($this->debugHandler, ' lighttpd::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_vhost') . "\n");
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_vhost'));
jobs/cron_tasks.inc.http.20.lighttpd.php: ksort($this->lighttpd_data);
jobs/cron_tasks.inc.http.20.lighttpd.php: foreach ($this->lighttpd_data as $vhosts_filename => $vhost_content) {
jobs/cron_tasks.inc.http.20.lighttpd.php: fwrite($this->debugHandler, ' lighttpd::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))) . "\n");
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
jobs/cron_tasks.inc.http.20.lighttpd.php: foreach ($this->lighttpd_data as $vhosts_filename => $vhosts_file) {
jobs/cron_tasks.inc.http.20.lighttpd.php: $this->known_filenames[] = basename($vhosts_filename);
jobs/cron_tasks.inc.http.20.lighttpd.php: foreach ($this->needed_htpasswds as $key => $data) {
jobs/cron_tasks.inc.http.30.nginx.php: $this->logger = $logger;
jobs/cron_tasks.inc.http.30.nginx.php: $this->debugHandler = $debugHandler;
jobs/cron_tasks.inc.http.30.nginx.php: $this->idnaConvert = $idnaConvert;
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_server = $nginx_server;
jobs/cron_tasks.inc.http.30.nginx.php: fwrite($this->debugHandler, ' nginx::reload: reloading nginx' . "\n");
jobs/cron_tasks.inc.http.30.nginx.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading nginx');
jobs/cron_tasks.inc.http.30.nginx.php: fwrite($this->debugHandler, ' nginx::reload: restarting php processes' . "\n");
jobs/cron_tasks.inc.http.30.nginx.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, 'restarting php processes');
jobs/cron_tasks.inc.http.30.nginx.php: fwrite($this->debugHandler, ' nginx::reload: reloading php-fpm' . "\n");
jobs/cron_tasks.inc.http.30.nginx.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm');
jobs/cron_tasks.inc.http.30.nginx.php: if (!isset($this->nginx_data[$vhosts_filename])) {
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhosts_filename] = '';
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhosts_filename].= 'error_page ' . $statusCode . ' ' . $defhandler . ';' . "\n";
jobs/cron_tasks.inc.http.30.nginx.php: fwrite($this->debugHandler, ' nginx::createIpPort: creating ip/port settings for ' . $ip . ":" . $port . "\n");
jobs/cron_tasks.inc.http.30.nginx.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating ip/port settings for ' . $ip . ":" . $port);
jobs/cron_tasks.inc.http.30.nginx.php: if (!isset($this->nginx_data[$vhost_filename])) {
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] = '';
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= 'server { ' . "\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t". 'listen ' . $ip . ':' . $port . ' default'. ($ssl_vhost == true ? ' ssl' : '') . ';' . "\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t".'# Froxlor default vhost' . "\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t".'server_name ' . Settings::Get('system.hostname') . ';' . "\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t".'access_log /var/log/nginx/access.log;' . "\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t".'root '.$mypath.';'."\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t".'location / {'."\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t\t".'index index.php index.html index.htm;'."\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t".'}'."\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename].= $row_ipsandports['specialsettings'] . "\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename].=$this->composeSslSettings($row_ipsandports);
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t".'location ~ \.php$ {'."\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t\t".' if (!-f $request_filename) {'."\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t\t\t".'return 404;'."\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t\t".'}'."\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_index index.php;'."\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t\t".'include '.Settings::Get('nginx.fastcgiparams').';'."\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;'."\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_param HTTPS on;'."\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_pass unix:' . $php->getInterface()->getSocketFile() . ';' . "\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_pass ' . Settings::Get('system.nginx_php_backend') . ';' . "\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= "\t".'}'."\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] .= '}' . "\n\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->createNginxHosts();
jobs/cron_tasks.inc.http.30.nginx.php: $this->_createStandardErrorHandler();
jobs/cron_tasks.inc.http.30.nginx.php: $vhost_filename = $this->getVhostFilename($domain);
jobs/cron_tasks.inc.http.30.nginx.php: if (!isset($this->nginx_data[$vhost_filename])) {
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename] = '';
jobs/cron_tasks.inc.http.30.nginx.php: if ((!empty($this->nginx_data[$vhost_filename])
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename].= $this->getVhostContent($domain, false);
jobs/cron_tasks.inc.http.30.nginx.php: $vhost_filename_ssl = $this->getVhostFilename($domain, true);
jobs/cron_tasks.inc.http.30.nginx.php: if (!isset($this->nginx_data[$vhost_filename_ssl])) {
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename_ssl] = '';
jobs/cron_tasks.inc.http.30.nginx.php: $this->nginx_data[$vhost_filename_ssl] .= $this->getVhostContent($domain, true);
jobs/cron_tasks.inc.http.30.nginx.php: $vhost_content .= $this->getServerNames($domain);
jobs/cron_tasks.inc.http.30.nginx.php: $vhost_content .= "\t".'rewrite ^(.*) '.$this->idnaConvert->encode($domain['documentroot']).'$1 permanent;'."\n";
jobs/cron_tasks.inc.http.30.nginx.php: $vhost_content .= $this->getLogFiles($domain);
jobs/cron_tasks.inc.http.30.nginx.php: $vhost_content .= $this->getWebroot($domain, $ssl_vhost);
jobs/cron_tasks.inc.http.30.nginx.php: if ($this->_deactivated == false) {
jobs/cron_tasks.inc.http.30.nginx.php: $vhost_content.= $this->composeSslSettings($domain);
jobs/cron_tasks.inc.http.30.nginx.php: $vhost_content.= $this->create_pathOptions($domain);
jobs/cron_tasks.inc.http.30.nginx.php: $vhost_content.= $this->composePhpOptions($domain, $ssl_vhost);
jobs/cron_tasks.inc.http.30.nginx.php: $vhost_content.= isset($this->needed_htpasswds[$domain['id']]) ? $this->needed_htpasswds[$domain['id']] . "\n" : '';
jobs/cron_tasks.inc.http.30.nginx.php: return $this->mergeVhostBlocks($vhost_content);
jobs/cron_tasks.inc.http.30.nginx.php: $htpasswds = $this->getHtpasswds($domain);
jobs/cron_tasks.inc.http.30.nginx.php: $this->vhost_root_autoindex = true;
jobs/cron_tasks.inc.http.30.nginx.php: if ($this->vhost_root_autoindex) {
jobs/cron_tasks.inc.http.30.nginx.php: $this->vhost_root_autoindex = false;
jobs/cron_tasks.inc.http.30.nginx.php: $this->vhost_root_autoindex = false;
jobs/cron_tasks.inc.http.30.nginx.php: if ($this->vhost_root_autoindex) {
jobs/cron_tasks.inc.http.30.nginx.php: $this->vhost_root_autoindex = false;
jobs/cron_tasks.inc.http.30.nginx.php: $path_options .= $this->getStats($domain,$single);
jobs/cron_tasks.inc.http.30.nginx.php: if (!isset($this->htpasswds_data[$htpasswd_filename])) {
jobs/cron_tasks.inc.http.30.nginx.php: $this->htpasswds_data[$htpasswd_filename] = '';
jobs/cron_tasks.inc.http.30.nginx.php: $this->htpasswds_data[$htpasswd_filename].= $row_htpasswds['username'] . ':' . $row_htpasswds['password'] . "\n";
jobs/cron_tasks.inc.http.30.nginx.php: $this->_deactivated = true;
jobs/cron_tasks.inc.http.30.nginx.php: $this->_deactivated = false;
jobs/cron_tasks.inc.http.30.nginx.php: if ($this->vhost_root_autoindex) {
jobs/cron_tasks.inc.http.30.nginx.php: $this->vhost_root_autoindex = false;
jobs/cron_tasks.inc.http.30.nginx.php: fwrite($this->debugHandler, ' nginx::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_vhost') . "\n");
jobs/cron_tasks.inc.http.30.nginx.php: $this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_vhost'));
jobs/cron_tasks.inc.http.30.nginx.php: ksort($this->nginx_data);
jobs/cron_tasks.inc.http.30.nginx.php: foreach ($this->nginx_data as $vhosts_filename => $vhost_content) {
jobs/cron_tasks.inc.http.30.nginx.php: fwrite($this->debugHandler, ' nginx::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))) . "\n");
jobs/cron_tasks.inc.http.30.nginx.php: $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
jobs/cron_tasks.inc.http.30.nginx.php: foreach ($this->nginx_data as $vhosts_filename => $vhosts_file) {
jobs/cron_tasks.inc.http.30.nginx.php: $this->known_filenames[] = basename($vhosts_filename);
jobs/cron_tasks.inc.http.30.nginx.php: if (count($this->htpasswds_data) > 0) {
jobs/cron_tasks.inc.http.30.nginx.php: fwrite($this->debugHandler, ' cron_tasks: WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!' . "\n");
jobs/cron_tasks.inc.http.30.nginx.php: $this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!');
jobs/cron_tasks.inc.http.30.nginx.php: foreach ($this->htpasswds_data as $htpasswd_filename => $htpasswd_file) {
jobs/cron_tasks.inc.http.30.nginx.php: $this->known_htpasswdsfilenames[] = basename($htpasswd_filename);