Update cron_tasks.inc.http.30.nginx.php
This commit is contained in:
@@ -38,7 +38,7 @@ class nginx
|
||||
protected $auth_backend_loaded = false;
|
||||
protected $htpasswds_data = array();
|
||||
protected $known_htpasswdsfilenames = array();
|
||||
protected $mod_accesslog_loaded = "0";
|
||||
protected $mod_accesslog_loaded = '0';
|
||||
protected $vhost_root_autoindex = false;
|
||||
protected $known_vhostfilenames = array();
|
||||
/**
|
||||
@@ -79,9 +79,7 @@ class nginx
|
||||
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)
|
||||
{
|
||||
} elseif ((int)$this->settings['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']));
|
||||
@@ -101,8 +99,7 @@ class nginx
|
||||
|| $this->settings['defaultwebsrverrhandler']['err500'] != '')
|
||||
) {
|
||||
$vhosts_folder = '';
|
||||
if(is_dir($this->settings['system']['apacheconf_vhost']))
|
||||
{
|
||||
if (is_dir($this->settings['system']['apacheconf_vhost'])) {
|
||||
$vhosts_folder = makeCorrectDir($this->settings['system']['apacheconf_vhost']);
|
||||
} else {
|
||||
$vhosts_folder = makeCorrectDir(dirname($this->settings['system']['apacheconf_vhost']));
|
||||
@@ -110,48 +107,29 @@ class nginx
|
||||
|
||||
$vhosts_filename = makeCorrectFile($vhosts_folder . '/05_froxlor_default_errorhandler.conf');
|
||||
|
||||
if(!isset($this->nginx_data[$vhosts_filename]))
|
||||
{
|
||||
if (!isset($this->nginx_data[$vhosts_filename])) {
|
||||
$this->nginx_data[$vhosts_filename] = '';
|
||||
}
|
||||
|
||||
if ($this->settings['defaultwebsrverrhandler']['err401'] != '') {
|
||||
$defhandler = $this->settings['defaultwebsrverrhandler']['err401'];
|
||||
$statusCodes = array('401', '403', '404', '500');
|
||||
foreach ($statusCodes as $statusCode) {
|
||||
if ($this->settings['defaultwebsrverrhandler']['err' . $statusCode] != '') {
|
||||
$defhandler = $this->settings['defaultwebsrverrhandler']['err' . $statusCode];
|
||||
if (!validateUrl($defhandler)) {
|
||||
$defhandler = makeCorrectFile($defhandler);
|
||||
}
|
||||
$this->nginx_data[$vhosts_filename].= 'error_page 401 ' . $defhandler . ';' . "\n";
|
||||
$this->nginx_data[$vhosts_filename].= 'error_page ' . $statusCode . ' ' . $defhandler . ';' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->settings['defaultwebsrverrhandler']['err403'] != '') {
|
||||
$defhandler = $this->settings['defaultwebsrverrhandler']['err403'];
|
||||
if (!validateUrl($defhandler)) {
|
||||
$defhandler = makeCorrectFile($defhandler);
|
||||
}
|
||||
$this->nginx_data[$vhosts_filename].= 'error_page 403 ' . $defhandler . ';' . "\n";
|
||||
public function createVirtualHosts()
|
||||
{
|
||||
}
|
||||
|
||||
if ($this->settings['defaultwebsrverrhandler']['err404'] != '') {
|
||||
$defhandler = $this->settings['defaultwebsrverrhandler']['err404'];
|
||||
if (!validateUrl($defhandler)) {
|
||||
$defhandler = makeCorrectFile($defhandler);
|
||||
}
|
||||
$this->nginx_data[$vhosts_filename].= 'error_page 404 ' . $defhandler . ';' . "\n";
|
||||
}
|
||||
|
||||
if ($this->settings['defaultwebsrverrhandler']['err500'] != '') {
|
||||
$defhandler = $this->settings['defaultwebsrverrhandler']['err500'];
|
||||
if (!validateUrl($defhandler)) {
|
||||
$defhandler = makeCorrectFile($defhandler);
|
||||
}
|
||||
$this->nginx_data[$vhosts_filename].= 'error_page 500 ' . $defhandler . ';' . "\n";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public function createVirtualHosts(){
|
||||
}
|
||||
public function createFileDirOptions(){
|
||||
public function createFileDirOptions()
|
||||
{
|
||||
}
|
||||
|
||||
public function createIpPort()
|
||||
@@ -160,7 +138,6 @@ class nginx
|
||||
$result_ipsandports = $this->db->query($query);
|
||||
|
||||
while ($row_ipsandports = $this->db->fetch_array($result_ipsandports)) {
|
||||
|
||||
if (filter_var($row_ipsandports['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
||||
$ip = '[' . $row_ipsandports['ip'] . ']';
|
||||
} else {
|
||||
@@ -268,7 +245,6 @@ class nginx
|
||||
|
||||
$php = new phpinterface($this->getDB(), $this->settings, $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";
|
||||
}
|
||||
@@ -290,27 +266,23 @@ class nginx
|
||||
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `ip` = '" . $ip . "' AND `port` = '" . $port . "'";
|
||||
$ipandport = $this->db->query_first($query);
|
||||
|
||||
if($ssl == '0')
|
||||
{
|
||||
$query2 = "SELECT `d`.*, `pd`.`domain` AS `parentdomain`, `c`.`loginname`, `c`.`guid`, `c`.`email`, `c`.`documentroot` AS `customerroot`, `c`.`deactivated`, `c`.`phpenabled` AS `phpenabled` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON (`pd`.`id` = `d`.`parentdomainid`) WHERE `d`.`ipandport`='" . $ipandport['id'] . "' AND `d`.`aliasdomain` IS NULL AND `d`.`email_only` <> 1 ORDER BY `d`.`iswildcarddomain`, `d`.`domain` ASC";
|
||||
}
|
||||
else
|
||||
{
|
||||
$query2 = "SELECT `d`.*, `pd`.`domain` AS `parentdomain`, `c`.`loginname`, `c`.`guid`, `c`.`email`, `c`.`documentroot` AS `customerroot`, `c`.`deactivated`, `c`.`phpenabled` AS `phpenabled` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON (`pd`.`id` = `d`.`parentdomainid`) WHERE `d`.`ssl_ipandport`='" . $ipandport['id'] . "' AND `d`.`aliasdomain` IS NULL AND `d`.`email_only` <> 1 ORDER BY `d`.`iswildcarddomain`, `d`.`domain` ASC";
|
||||
$query2 = "SELECT `d`.*, `pd`.`domain` AS `parentdomain`, `c`.`loginname`, `c`.`guid`, `c`.`email`, `c`.`documentroot` AS `customerroot`, `c`.`deactivated`, `c`.`phpenabled` AS `phpenabled` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON (`pd`.`id` = `d`.`parentdomainid`) ";
|
||||
if ($ssl == '0') {
|
||||
$query2 .= "WHERE `d`.`ipandport` = '" . $ipandport['id'] . "' ";
|
||||
} else {
|
||||
$query2 .= "WHERE `d`.`ssl_ipandport` = '" . $ipandport['id'] . "' ";
|
||||
}
|
||||
$query2 .= "AND `d`.`aliasdomain` IS NULL AND `d`.`email_only` <> 1 ORDER BY `d`.`iswildcarddomain`, `d`.`domain` ASC";
|
||||
|
||||
$included_vhosts = array();
|
||||
$result_domains = $this->db->query($query2);
|
||||
while($domain = $this->db->fetch_array($result_domains))
|
||||
{
|
||||
if (is_dir($this->settings['system']['apacheconf_vhost']))
|
||||
{
|
||||
while ($domain = $this->db->fetch_array($result_domains)) {
|
||||
if (is_dir($this->settings['system']['apacheconf_vhost'])) {
|
||||
safe_exec('mkdir -p '.escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])));
|
||||
$vhost_filename = $this->getVhostFilename($domain);
|
||||
}
|
||||
|
||||
if(!isset($this->nginx_data[$vhost_filename]))
|
||||
{
|
||||
if (!isset($this->nginx_data[$vhost_filename])) {
|
||||
$this->nginx_data[$vhost_filename] = '';
|
||||
}
|
||||
|
||||
@@ -321,15 +293,12 @@ class nginx
|
||||
$domain['ssl_cert_file'] = $ipandport['ssl_cert_file'];
|
||||
|
||||
if ((!empty($this->nginx_data[$vhost_filename]) && !is_dir($this->settings['system']['apacheconf_vhost']))
|
||||
|| is_dir($this->settings['system']['apacheconf_vhost']))
|
||||
{
|
||||
if($ssl == '1')
|
||||
{
|
||||
|| is_dir($this->settings['system']['apacheconf_vhost'])
|
||||
) {
|
||||
if ($ssl == '1') {
|
||||
$ssl_vhost = true;
|
||||
$ips_and_ports_index = 'ssl_ipandport';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$ssl_vhost = false;
|
||||
$ips_and_ports_index = 'ipandport';
|
||||
}
|
||||
@@ -348,24 +317,18 @@ class nginx
|
||||
|| domainMainToSubExists($domain['ismainbutsubto']) == false)
|
||||
) {
|
||||
$vhost_no = '22';
|
||||
}
|
||||
elseif((int)$domain['parentdomainid'] == 0
|
||||
} elseif ((int)$domain['parentdomainid'] == 0
|
||||
&& isCustomerStdSubdomain((int)$domain['id']) == false
|
||||
&& (int)$domain['ismainbutsubto'] > 0
|
||||
) {
|
||||
$vhost_no = '21';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$vhost_no = '20';
|
||||
}
|
||||
|
||||
if($ssl_vhost === true)
|
||||
{
|
||||
if ($ssl_vhost === true) {
|
||||
$vhost_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/'.$vhost_no.'_froxlor_ssl_vhost_' . $domain['domain'] . '.conf');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$vhost_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/'.$vhost_no.'_froxlor_normal_vhost_' . $domain['domain'] . '.conf');
|
||||
}
|
||||
|
||||
@@ -375,18 +338,16 @@ class nginx
|
||||
protected function getVhostContent($domain, $ssl_vhost = false)
|
||||
{
|
||||
if ($ssl_vhost === true
|
||||
&& $domain['ssl'] != '1')
|
||||
{
|
||||
&& $domain['ssl'] != '1'
|
||||
) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($ssl_vhost === true
|
||||
&& $domain['ssl'] == '1')
|
||||
{
|
||||
&& $domain['ssl'] == '1'
|
||||
) {
|
||||
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `id`='" . $domain['ssl_ipandport'] . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `id`='" . $domain['ipandport'] . "'";
|
||||
}
|
||||
|
||||
@@ -395,12 +356,9 @@ class nginx
|
||||
$domain['port'] = $ipandport['port'];
|
||||
$domain['ssl_cert_file'] = $ipandport['ssl_cert_file'];
|
||||
|
||||
if(filter_var($domain['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
|
||||
{
|
||||
if (filter_var($domain['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
||||
$ipport = '[' . $domain['ip'] . ']:' . $domain['port'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$ipport = $domain['ip'] . ':' . $domain['port'];
|
||||
}
|
||||
|
||||
@@ -451,7 +409,7 @@ class nginx
|
||||
// merge duplicate / sections, #1193
|
||||
$l_regex1 = "/(location\ \/\ \{)(.*)(\})/smU";
|
||||
$l_regex2 = "/(location\ \/\ \{.*\})/smU";
|
||||
$replace_by="";
|
||||
$replace_by = '';
|
||||
$replacements = preg_match_all($l_regex1,$vhost_content,$out);
|
||||
if ($replacements > 1) {
|
||||
foreach ($out[2] as $val) {
|
||||
@@ -466,7 +424,8 @@ class nginx
|
||||
return $vhost_content;
|
||||
}
|
||||
|
||||
protected function create_pathOptions($domain) {
|
||||
protected function create_pathOptions($domain)
|
||||
{
|
||||
$has_location = false;
|
||||
|
||||
$query = "SELECT * FROM " . TABLE_PANEL_HTACCESS . " WHERE `path` LIKE '" . $domain['documentroot'] . "%'";
|
||||
@@ -477,7 +436,6 @@ class nginx
|
||||
|
||||
// for each entry in the htaccess table
|
||||
while ($row = $this->db->fetch_array($result)) {
|
||||
|
||||
if (!empty($row['error404path'])) {
|
||||
$defhandler = $row['error404path'];
|
||||
if (!validateUrl($defhandler)) {
|
||||
@@ -502,8 +460,7 @@ class nginx
|
||||
$path_options .= "\t".'error_page 500 502 503 504 ' . $defhandler . ';' . "\n";
|
||||
}
|
||||
|
||||
// if($row['options_indexes'] != '0')
|
||||
// {
|
||||
// if ($row['options_indexes'] != '0') {
|
||||
$path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
|
||||
|
||||
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
|
||||
@@ -521,10 +478,8 @@ class nginx
|
||||
// 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)
|
||||
{
|
||||
if (count($htpasswds) > 0) {
|
||||
foreach ($htpasswds as $idx => $single) {
|
||||
switch ($single['path']) {
|
||||
case '/awstats/':
|
||||
case '/webalizer/':
|
||||
@@ -543,9 +498,7 @@ class nginx
|
||||
$path_options .= "\t".'}' . "\n";
|
||||
|
||||
$this->vhost_root_autoindex = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$path_options .= "\t".'location ' . $path . ' {' . "\n";
|
||||
if ($this->vhost_root_autoindex) {
|
||||
$path_options .= "\t\t" . 'autoindex on;' . "\n";
|
||||
@@ -561,8 +514,8 @@ class nginx
|
||||
* required the fastCGI wrapper to be running to receive the CGI requests.
|
||||
*/
|
||||
if (customerHasPerlEnabled($domain['customerid'])
|
||||
&& $row['options_cgi'] != '0')
|
||||
{
|
||||
&& $row['options_cgi'] != '0'
|
||||
) {
|
||||
$path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
|
||||
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
|
||||
|
||||
@@ -583,14 +536,10 @@ class nginx
|
||||
/*
|
||||
* now the rest of the htpasswds
|
||||
*/
|
||||
if(count($htpasswds) > 0)
|
||||
{
|
||||
foreach($htpasswds as $idx => $single)
|
||||
{
|
||||
//if($single['path'] != "/")
|
||||
//{
|
||||
switch($single['path'])
|
||||
{
|
||||
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);
|
||||
@@ -623,7 +572,6 @@ class nginx
|
||||
$returnval = array();
|
||||
$x = 0;
|
||||
while ($row_htpasswds = $this->db->fetch_array($result)) {
|
||||
|
||||
if (count($row_htpasswds) > 0) {
|
||||
$htpasswd_filename = makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $row_htpasswds['customerid'] . '-' . md5($row_htpasswds['path']) . '.htpasswd');
|
||||
|
||||
@@ -657,8 +605,7 @@ class nginx
|
||||
protected function composePhpOptions($domain, $ssl_vhost = false)
|
||||
{
|
||||
$phpopts = '';
|
||||
if($domain['phpenabled'] == '1')
|
||||
{
|
||||
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";
|
||||
@@ -679,14 +626,12 @@ class nginx
|
||||
$webroot_text = '';
|
||||
|
||||
if ($domain['deactivated'] == '1'
|
||||
&& $this->settings['system']['deactivateddocroot'] != '')
|
||||
{
|
||||
&& $this->settings['system']['deactivateddocroot'] != ''
|
||||
) {
|
||||
$webroot_text .= "\t".'# Using docroot for deactivated users...' . "\n";
|
||||
$webroot_text .= "\t".'root '.makeCorrectDir($this->settings['system']['deactivateddocroot']).';'."\n";
|
||||
$this->_deactivated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$webroot_text .= "\t".'root '.makeCorrectDir($domain['documentroot']).';'."\n";
|
||||
$this->_deactivated = false;
|
||||
}
|
||||
@@ -708,8 +653,8 @@ class nginx
|
||||
return $webroot_text;
|
||||
}
|
||||
|
||||
protected function getStats($domain, $single) {
|
||||
|
||||
protected function getStats($domain, $single)
|
||||
{
|
||||
$stats_text = '';
|
||||
|
||||
// define basic path to the stats
|
||||
@@ -742,19 +687,17 @@ class nginx
|
||||
return $stats_text;
|
||||
}
|
||||
|
||||
protected function getLogFiles($domain) {
|
||||
|
||||
protected function getLogFiles($domain)
|
||||
{
|
||||
$logfiles_text = '';
|
||||
|
||||
$speciallogfile = '';
|
||||
if ($domain['speciallogfile'] == '1') {
|
||||
|
||||
if ($domain['parentdomainid'] == '0') {
|
||||
$speciallogfile = '-' . $domain['domain'];
|
||||
} else {
|
||||
$speciallogfile = '-' . $domain['parentdomain'];
|
||||
}
|
||||
} else {
|
||||
$speciallogfile = '';
|
||||
}
|
||||
|
||||
// The normal access/error - logging is enabled
|
||||
@@ -795,14 +738,11 @@ class nginx
|
||||
}
|
||||
}
|
||||
|
||||
$alias = '';
|
||||
if ($domain['iswildcarddomain'] == '1') {
|
||||
$alias = '*.' . $domain['domain'];
|
||||
} else {
|
||||
if ($domain['wwwserveralias'] == '1') {
|
||||
} elseif ($domain['wwwserveralias'] == '1') {
|
||||
$alias = 'www.' . $domain['domain'];
|
||||
} else {
|
||||
$alias = '';
|
||||
}
|
||||
}
|
||||
|
||||
// After inserting the AWStats information,
|
||||
@@ -824,44 +764,26 @@ class nginx
|
||||
{
|
||||
$server_alias = '';
|
||||
|
||||
if($domain['iswildcarddomain'] == '1')
|
||||
{
|
||||
if ($domain['iswildcarddomain'] == '1') {
|
||||
$server_alias = '*.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($domain['wwwserveralias'] == '1')
|
||||
{
|
||||
} elseif ($domain['wwwserveralias'] == '1') {
|
||||
$server_alias = 'www.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$server_alias = '';
|
||||
}
|
||||
}
|
||||
|
||||
$alias_domains = $this->db->query('SELECT `domain`, `iswildcarddomain`, `wwwserveralias` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `aliasdomain`=\'' . $domain['id'] . '\'');
|
||||
|
||||
while(($alias_domain = $this->db->fetch_array($alias_domains)) !== false)
|
||||
{
|
||||
while (($alias_domain = $this->db->fetch_array($alias_domains)) !== false) {
|
||||
$server_alias .= ' ' . $alias_domain['domain'];
|
||||
|
||||
if($alias_domain['iswildcarddomain'] == '1')
|
||||
{
|
||||
if ($alias_domain['iswildcarddomain'] == '1') {
|
||||
$server_alias .= ' *.' . $alias_domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($alias_domain['wwwserveralias'] == '1')
|
||||
{
|
||||
} elseif ($alias_domain['wwwserveralias'] == '1') {
|
||||
$server_alias.= ' www.' . $alias_domain['domain'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$servernames_text = "\t".'server_name '.$domain['domain'];
|
||||
if(trim($server_alias) != '')
|
||||
{
|
||||
if (trim($server_alias) != '') {
|
||||
$servernames_text .= ' '.$server_alias;
|
||||
}
|
||||
$servernames_text .= ';' . "\n";
|
||||
@@ -874,8 +796,7 @@ class nginx
|
||||
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']))
|
||||
{
|
||||
if (!isConfigDir($this->settings['system']['apacheconf_vhost'])) {
|
||||
// Save one big file
|
||||
$vhosts_file = '';
|
||||
|
||||
@@ -885,41 +806,32 @@ class nginx
|
||||
// 3. main-domains
|
||||
ksort($this->nginx_data);
|
||||
|
||||
foreach($this->nginx_data as $vhosts_filename => $vhost_content)
|
||||
{
|
||||
foreach ($this->nginx_data as $vhosts_filename => $vhost_content) {
|
||||
$vhosts_file.= $vhost_content . "\n\n";
|
||||
}
|
||||
|
||||
$vhosts_filename = $this->settings['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;
|
||||
$vhosts_file_handler = fopen($vhosts_filename, 'w');
|
||||
fwrite($vhosts_file_handler, $vhosts_file);
|
||||
fclose($vhosts_file_handler);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!file_exists($this->settings['system']['apacheconf_vhost']))
|
||||
{
|
||||
} 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'])));
|
||||
}
|
||||
|
||||
// Write a single file for every vhost
|
||||
|
||||
foreach($this->nginx_data as $vhosts_filename => $vhosts_file)
|
||||
{
|
||||
foreach ($this->nginx_data as $vhosts_filename => $vhosts_file) {
|
||||
$this->known_filenames[] = basename($vhosts_filename);
|
||||
|
||||
// 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;
|
||||
|
||||
if(!empty($vhosts_filename))
|
||||
{
|
||||
if (!empty($vhosts_filename)) {
|
||||
$vhosts_file_handler = fopen($vhosts_filename, 'w');
|
||||
fwrite($vhosts_file_handler, $vhosts_file);
|
||||
fclose($vhosts_file_handler);
|
||||
@@ -931,26 +843,20 @@ class nginx
|
||||
/*
|
||||
* htaccess stuff
|
||||
*/
|
||||
if(count($this->htpasswds_data) > 0)
|
||||
{
|
||||
if(!file_exists($this->settings['system']['apacheconf_htpasswddir']))
|
||||
{
|
||||
if (count($this->htpasswds_data) > 0) {
|
||||
if (!file_exists($this->settings['system']['apacheconf_htpasswddir'])) {
|
||||
$umask = umask();
|
||||
umask(0000);
|
||||
mkdir($this->settings['system']['apacheconf_htpasswddir'], 0751);
|
||||
umask($umask);
|
||||
}
|
||||
elseif(!is_dir($this->settings['system']['apacheconf_htpasswddir']))
|
||||
{
|
||||
} 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!!!');
|
||||
}
|
||||
|
||||
if(is_dir($this->settings['system']['apacheconf_htpasswddir']))
|
||||
{
|
||||
foreach($this->htpasswds_data as $htpasswd_filename => $htpasswd_file)
|
||||
{
|
||||
if (is_dir($this->settings['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');
|
||||
fwrite($htpasswd_file_handler, $htpasswd_file);
|
||||
|
||||
Reference in New Issue
Block a user