various minor bugfixes; composer requirements update

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-08-10 00:17:11 +02:00
parent 31500522ce
commit 50e35e149c
45 changed files with 397 additions and 354 deletions

View File

@@ -40,16 +40,10 @@ use Froxlor\Validate\Validate;
use Froxlor\System\Crypt;
use PDO;
/**
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
*/
class Apache extends HttpConfigBase
{
// protected
protected $known_vhostfilenames = [];
protected $known_diroptionsfilenames = [];
protected $known_htpasswdsfilenames = [];
@@ -1460,8 +1454,6 @@ class Apache extends HttpConfigBase
// Write a single file for every vhost
foreach ($this->virtualhosts_data as $vhosts_filename => $vhosts_file) {
$this->known_vhostfilenames[] = 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;
$vhosts_file_handler = fopen($vhosts_filename, 'w');

View File

@@ -65,10 +65,10 @@ class AcmeSh extends FroxlorCron
/**
* run the task
*
* @param boolean $internal
* @param bool $internal
* @return number
*/
public static function run($internal = false)
public static function run(bool $internal = false)
{
// usually, this is action is called from within the tasks-jobs
if (!defined('CRON_IS_FORCED') && !defined('CRON_DEBUG_FLAG') && $internal == false) {
@@ -201,6 +201,7 @@ class AcmeSh extends FroxlorCron
} else {
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, "No new certificates or certificate updates found");
}
return 0;
}
/**

View File

@@ -29,6 +29,7 @@ use Froxlor\Cron\Http\Php\PhpInterface;
use Froxlor\Customer\Customer;
use Froxlor\Database\Database;
use Froxlor\Domain\Domain;
use Froxlor\Froxlor;
use Froxlor\FileDir;
use Froxlor\FroxlorLogger;
use Froxlor\Http\Directory;
@@ -36,14 +37,9 @@ use Froxlor\Http\Statistics;
use Froxlor\Settings;
use Froxlor\Validate\Validate;
use Froxlor\System\Crypt;
use Froxlor\Idna\IdnaWrapper;
use PDO;
/**
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
*
* @todo ssl-redirect to non-standard port
*/
class Lighttpd extends HttpConfigBase
{
@@ -81,7 +77,7 @@ class Lighttpd extends HttpConfigBase
$ipv6 = '';
}
$this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, 'lighttpd::createIpPort: creating ip/port settings for ' . $ip . ":" . $port);
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, 'lighttpd::createIpPort: creating ip/port settings for ' . $ip . ":" . $port);
$vhost_filename = FileDir::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])) {
@@ -126,13 +122,13 @@ class Lighttpd extends HttpConfigBase
if (!$is_redirect) {
// protect lib/userdata.inc.php
$this->lighttpd_data[$vhosts_filename] .= ' $HTTP["host"] =~ "' . rtrim(Froxlor::getInstallDir(), "/") . '/lib" {' . "\n";
$this->lighttpd_data[$vhosts_filename] .= ' url.access-deny = ("userdata.inc.php")' . "\n";
$this->lighttpd_data[$vhosts_filename] .= ' }' . "\n";
$this->lighttpd_data[$vhost_filename] .= ' $HTTP["host"] =~ "' . rtrim(Froxlor::getInstallDir(), "/") . '/lib" {' . "\n";
$this->lighttpd_data[$vhost_filename] .= ' url.access-deny = ("userdata.inc.php")' . "\n";
$this->lighttpd_data[$vhost_filename] .= ' }' . "\n";
// protect bin/
$this->lighttpd_data[$vhosts_filename] .= ' $HTTP["host"] =~ "' . rtrim(Froxlor::getInstallDir(), "/") . '/bin" {' . "\n";
$this->lighttpd_data[$vhosts_filename] .= ' url.access-deny = ("")' . "\n";
$this->lighttpd_data[$vhosts_filename] .= ' }' . "\n";
$this->lighttpd_data[$vhost_filename] .= ' $HTTP["host"] =~ "' . rtrim(Froxlor::getInstallDir(), "/") . '/bin" {' . "\n";
$this->lighttpd_data[$vhost_filename] .= ' url.access-deny = ("")' . "\n";
$this->lighttpd_data[$vhost_filename] .= ' }' . "\n";
/**
* dirprotection, see #72
@@ -222,7 +218,7 @@ class Lighttpd extends HttpConfigBase
if (($row_ipsandports['ssl_cert_file'] == '' || !file_exists($row_ipsandports['ssl_cert_file'])) && (Settings::Get('system.le_froxlor_enabled') == '0' || $this->froxlorVhostHasLetsEncryptCert() == false)) {
$row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
if (!file_exists($row_ipsandports['ssl_cert_file'])) {
$this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Creating self-signed certificate...');
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Creating self-signed certificate...');
Crypt::createSelfSignedCertificate();
}
}
@@ -264,7 +260,7 @@ class Lighttpd extends HttpConfigBase
if ($domain['ssl_cert_file'] != '') {
// check for existence, #1485
if (!file_exists($domain['ssl_cert_file'])) {
$this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_ERR, $ip . ':' . $port . ' :: certificate file "' . $domain['ssl_cert_file'] . '" does not exist! Cannot create ssl-directives');
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_ERR, $ip . ':' . $port . ' :: certificate file "' . $domain['ssl_cert_file'] . '" does not exist! Cannot create ssl-directives');
echo $ip . ':' . $port . ' :: certificate file "' . $domain['ssl_cert_file'] . '" does not exist! Cannot create SSL-directives' . "\n";
} else {
$this->lighttpd_data[$vhost_filename] .= 'ssl.engine = "enable"' . "\n";
@@ -286,7 +282,7 @@ class Lighttpd extends HttpConfigBase
if ($domain['ssl_ca_file'] != '') {
// check for existence, #1485
if (!file_exists($domain['ssl_ca_file'])) {
$this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_ERR, $ip . ':' . $port . ' :: certificate CA file "' . $domain['ssl_ca_file'] . '" does not exist! Cannot create ssl-directives');
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_ERR, $ip . ':' . $port . ' :: certificate CA file "' . $domain['ssl_ca_file'] . '" does not exist! Cannot create ssl-directives');
echo $ip . ':' . $port . ' :: certificate CA file "' . $domain['ssl_ca_file'] . '" does not exist! SSL-directives might not be working' . "\n";
} else {
$this->lighttpd_data[$vhost_filename] .= 'ssl.ca-file = "' . FileDir::makeCorrectFile($domain['ssl_ca_file']) . '"' . "\n";
@@ -571,21 +567,19 @@ class Lighttpd extends HttpConfigBase
$this->deactivated = true;
} else {
if ($ssl === false && $domain['ssl_redirect'] == '1') {
$redirect_domain = $this->idnaConvert->encode('https://' . $domain['domain']);
$webroot_text .= ' url.redirect = (' . "\n";
$webroot_text .= "\t" . '"^/(.*)" => "' . $redirect_domain . '/$1",' . "\n";
$webroot_text .= "\t" . '"" => "' . $redirect_domain . '",' . "\n";
$webroot_text .= "\t" . '"/" => "' . $redirect_domain . '"' . "\n";
$webroot_text .= ' )' . "\n";
$redirect_domain = (new IdnaWrapper)->encode('https://' . $domain['domain']);
} 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";
$webroot_text .= "\t" . '"" => "' . $redirect_domain . '",' . "\n";
$webroot_text .= "\t" . '"/" => "' . $redirect_domain . '"' . "\n";
$webroot_text .= ' )' . "\n";
$redirect_domain = (new IdnaWrapper)->encode($domain['documentroot']);
} else {
$webroot_text .= ' server.document-root = "' . FileDir::makeCorrectDir($domain['documentroot']) . "\"\n";
$redirect_domain = '';
}
if (!empty($redirect_domain)) {
$webroot_text .= ' url.redirect = (' . "\n";
$webroot_text .= "\t" . '"^/(.*)" => "' . $redirect_domain . '/$1",' . "\n";
$webroot_text .= "\t" . '"" => "' . $redirect_domain . '",' . "\n";
$webroot_text .= "\t" . '"/" => "' . $redirect_domain . '"' . "\n";
$webroot_text .= ' )' . "\n";
}
$this->deactivated = false;
}
@@ -765,7 +759,7 @@ class Lighttpd extends HttpConfigBase
if (!file_exists($domain['ssl_cert_file'])) {
// explicitly disable ssl for this vhost
$domain['ssl_cert_file'] = "";
$this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Disabling SSL-vhost for "' . $domain['domain'] . '"');
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Disabling SSL-vhost for "' . $domain['domain'] . '"');
}
}
@@ -923,7 +917,7 @@ class Lighttpd extends HttpConfigBase
public function writeConfigs()
{
$this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, "lighttpd::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_vhost'));
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, "lighttpd::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_vhost'));
$vhostDir = new Directory(Settings::Get('system.apacheconf_vhost'));
if (!$vhostDir->isConfigDir()) {
@@ -950,14 +944,12 @@ class Lighttpd extends HttpConfigBase
fclose($vhosts_file_handler);
} else {
if (!file_exists(Settings::Get('system.apacheconf_vhost'))) {
$this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_NOTICE, 'lighttpd::writeConfigs: mkdir ' . escapeshellarg(FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_NOTICE, 'lighttpd::writeConfigs: mkdir ' . escapeshellarg(FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
FileDir::safe_exec('mkdir ' . escapeshellarg(FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
}
// Write a single file for every vhost
foreach ($this->lighttpd_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;

View File

@@ -29,6 +29,7 @@ use Froxlor\Cron\Http\Php\PhpInterface;
use Froxlor\Customer\Customer;
use Froxlor\Database\Database;
use Froxlor\Domain\Domain;
use Froxlor\Froxlor;
use Froxlor\FileDir;
use Froxlor\FroxlorLogger;
use Froxlor\Http\Directory;
@@ -50,8 +51,7 @@ class Nginx extends HttpConfigBase
protected $known_htpasswdsfilenames = [];
protected $mod_accesslog_loaded = '0';
protected $vhost_root_autoindex = false;
protected $known_vhostfilenames = [];
private $nginx_server = [];
/**
* indicator whether a customer is deactivated or not
* if yes, only the webroot will be generated
@@ -60,11 +60,6 @@ class Nginx extends HttpConfigBase
*/
private $deactivated = false;
public function __construct($nginx_server = [])
{
$this->nginx_server = $nginx_server;
}
public function createVirtualHosts()
{
return;
@@ -220,14 +215,14 @@ class Nginx extends HttpConfigBase
$this->nginx_data[$vhost_filename] .= "\t" . '}' . "\n";
// protect lib/userdata.inc.php
$this->nginx_data[$vhosts_filename] .= "\t" . 'location = ' . rtrim(Froxlor::getInstallDir(), "/") . '/lib/userdata.inc.php {' . "\n";
$this->nginx_data[$vhosts_filename] .= "\t" . ' deny all;' . "\n";
$this->nginx_data[$vhosts_filename] .= "\t" . '}' . "\n";
$this->nginx_data[$vhost_filename] .= "\t" . 'location = ' . rtrim(Froxlor::getInstallDir(), "/") . '/lib/userdata.inc.php {' . "\n";
$this->nginx_data[$vhost_filename] .= "\t" . ' deny all;' . "\n";
$this->nginx_data[$vhost_filename] .= "\t" . '}' . "\n";
// protect bin/
$this->nginx_data[$vhosts_filename] .= "\t" . 'location = ' . rtrim(Froxlor::getInstallDir(), "/") . '/bin {' . "\n";
$this->nginx_data[$vhosts_filename] .= "\t" . ' deny all;' . "\n";
$this->nginx_data[$vhosts_filename] .= "\t" . '}' . "\n";
$this->nginx_data[$vhost_filename] .= "\t" . 'location = ' . rtrim(Froxlor::getInstallDir(), "/") . '/bin {' . "\n";
$this->nginx_data[$vhost_filename] .= "\t" . ' deny all;' . "\n";
$this->nginx_data[$vhost_filename] .= "\t" . '}' . "\n";
}
if ($row_ipsandports['specialsettings'] != '' && ($row_ipsandports['ssl'] == '0' || ($row_ipsandports['ssl'] == '1' && Settings::Get('system.use_ssl') == '1' && $row_ipsandports['include_specialsettings'] == '1'))) {
@@ -1252,8 +1247,6 @@ class Nginx extends HttpConfigBase
// Write a single file for every vhost
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;

View File

@@ -46,11 +46,11 @@ class PhpInterface
private $interface = null;
/**
* Admin-User data array
* PHP-Config data array
*
* @var array
*/
private $admin_cache = [];
private $php_configs_cache = [];
/**
* main constructor
@@ -93,10 +93,8 @@ class PhpInterface
*
* @return array
*/
public function getPhpConfig($php_config_id)
public function getPhpConfig(int $php_config_id)
{
$php_config_id = intval($php_config_id);
// If domain has no config, we will use the default one.
if ($php_config_id == 0) {
$php_config_id = 1;
@@ -104,24 +102,26 @@ class PhpInterface
if (!isset($this->php_configs_cache[$php_config_id])) {
$stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = :id");
$this->_php_configs_cache[$php_config_id] = Database::pexecute_first($stmt, [
SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = :id
");
$this->php_configs_cache[$php_config_id] = Database::pexecute_first($stmt, [
'id' => $php_config_id
]);
if ((int)Settings::Get('phpfpm.enabled') == 1) {
$stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` WHERE `id` = :id");
$this->_php_configs_cache[$php_config_id]['fpm_settings'] = Database::pexecute_first($stmt, [
'id' => $this->_php_configs_cache[$php_config_id]['fpmsettingid']
SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` WHERE `id` = :id
");
$this->php_configs_cache[$php_config_id]['fpm_settings'] = Database::pexecute_first($stmt, [
'id' => $this->php_configs_cache[$php_config_id]['fpmsettingid']
]);
// override fpm daemon settings if set in php-config
if ($this->_php_configs_cache[$php_config_id]['override_fpmconfig'] == 1) {
$this->_php_configs_cache[$php_config_id]['fpm_settings']['limit_extensions'] = $this->_php_configs_cache[$php_config_id]['limit_extensions'];
$this->_php_configs_cache[$php_config_id]['fpm_settings']['idle_timeout'] = $this->_php_configs_cache[$php_config_id]['idle_timeout'];
if ($this->php_configs_cache[$php_config_id]['override_fpmconfig'] == 1) {
$this->php_configs_cache[$php_config_id]['fpm_settings']['limit_extensions'] = $this->php_configs_cache[$php_config_id]['limit_extensions'];
$this->php_configs_cache[$php_config_id]['fpm_settings']['idle_timeout'] = $this->php_configs_cache[$php_config_id]['idle_timeout'];
}
}
}
return $this->_php_configs_cache[$php_config_id];
return $this->php_configs_cache[$php_config_id];
}
}