more and more checkstyle fixes

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2018-12-24 12:59:40 +01:00
parent 585d42f1b8
commit 35c631946d
48 changed files with 298 additions and 327 deletions

View File

@@ -23,12 +23,6 @@ use Froxlor\Settings;
class ConfigIO
{
/**
* constructor
*/
public function __construct()
{}
/**
* clean up former created configs, including (if enabled)
* awstats, fcgid, php-fpm and of course automatically created

View File

@@ -24,12 +24,6 @@ use Froxlor\Settings;
class DomainSSL
{
/**
* constructor
*/
public function __construct()
{}
/**
* read domain-related (or if empty, parentdomain-related) ssl-certificates from the database
* and (if not empty) set the corresponding array-indices (ssl_cert_file, ssl_key_file,

View File

@@ -29,7 +29,7 @@ class LetsEncrypt extends \Froxlor\Cron\FroxlorCron
{
if (Settings::Get('system.leapiversion') == '2') {
// use ACME v2 is specified
\Froxlor\Cron\Http\LetsEncrypt\LetsEncrypt_v2::run();
\Froxlor\Cron\Http\LetsEncrypt\LetsEncryptV2::run();
exit();
}

View File

@@ -22,7 +22,7 @@ use Froxlor\Settings;
* @since 0.9.35
*
*/
class LetsEncrypt_v2 extends \Froxlor\Cron\FroxlorCron
class LetsEncryptV2 extends \Froxlor\Cron\FroxlorCron
{
public static function run()
@@ -169,7 +169,7 @@ class LetsEncrypt_v2 extends \Froxlor\Cron\FroxlorCron
try {
// Initialize Lescript with documentroot
$le = new \Froxlor\Http\LetsEncrypt\LeScript_v2($cronlog, \Froxlor\Froxlor::getVersion());
$le = new \Froxlor\Http\LetsEncrypt\LeScriptV2($cronlog, \Froxlor\Froxlor::getVersion());
// Initialize Lescript
$le->initAccount($certrow, true);
@@ -251,7 +251,7 @@ class LetsEncrypt_v2 extends \Froxlor\Cron\FroxlorCron
try {
// Initialize Lescript with documentroot
$le = new \Froxlor\Http\LetsEncrypt\LeScript_v2($cronlog, \Froxlor\Froxlor::getVersion());
$le = new \Froxlor\Http\LetsEncrypt\LeScriptV2($cronlog, \Froxlor\Froxlor::getVersion());
// Initialize Lescript
$le->initAccount($certrow);

View File

@@ -323,7 +323,7 @@ class Lighttpd extends HttpConfigBase
}
}
protected function create_htaccess($domain)
protected function createHtaccess($domain)
{
$needed_htpasswds = array();
$result_htpasswds_stmt = Database::prepare("
@@ -403,11 +403,11 @@ class Lighttpd extends HttpConfigBase
// maindomain
if ((int) $domain['parentdomainid'] == 0 && \Froxlor\Domain\Domain::isCustomerStdSubdomain((int) $domain['id']) == false && ((int) $domain['ismainbutsubto'] == 0 || \Froxlor\Domain\Domain::domainMainToSubExists($domain['ismainbutsubto']) == false)) {
$vhost_no = '50';
} // sub-but-main-domain
elseif ((int) $domain['parentdomainid'] == 0 && \Froxlor\Domain\Domain::isCustomerStdSubdomain((int) $domain['id']) == false && (int) $domain['ismainbutsubto'] > 0) {
} elseif ((int) $domain['parentdomainid'] == 0 && \Froxlor\Domain\Domain::isCustomerStdSubdomain((int) $domain['id']) == false && (int) $domain['ismainbutsubto'] > 0) {
// sub-but-main-domain
$vhost_no = '51';
} // subdomains
else {
} else {
// subdomains
// number of dots in a domain specifies it's position (and depth of subdomain) starting at 89 going downwards on higher depth
$vhost_no = (string) (90 - substr_count($domain['domain'], ".") + 1);
}
@@ -427,10 +427,8 @@ class Lighttpd extends HttpConfigBase
if ((! empty($this->lighttpd_data[$vhost_filename]) && ! is_dir(Settings::Get('system.apacheconf_vhost'))) || is_dir(Settings::Get('system.apacheconf_vhost'))) {
if ($ssl == '1') {
$ssl_vhost = true;
$ips_and_ports_index = 'ssl_ipandport';
} else {
$ssl_vhost = false;
$ips_and_ports_index = 'ipandport';
}
// FIXME we get duplicate entries of a vhost if it has assigned more than one IP
@@ -501,8 +499,8 @@ class Lighttpd extends HttpConfigBase
$vhost_content .= $this->getWebroot($domain, $ssl_vhost);
if (! $only_webroot) {
if ($this->deactivated == false) {
$vhost_content .= $this->create_htaccess($domain);
$vhost_content .= $this->create_pathOptions($domain);
$vhost_content .= $this->createHtaccess($domain);
$vhost_content .= $this->createPathOptions($domain);
$vhost_content .= $this->composePhpOptions($domain);
$vhost_content .= $this->getStats($domain);
@@ -684,7 +682,7 @@ class Lighttpd extends HttpConfigBase
return $logfiles_text;
}
protected function create_pathOptions($domain)
protected function createPathOptions($domain)
{
$result_stmt = Database::prepare("
SELECT * FROM " . TABLE_PANEL_HTACCESS . "

View File

@@ -41,8 +41,8 @@ class LighttpdFcgi extends Lighttpd
$php_options_text .= "\t" . ')' . "\n";
$php_options_text .= "\t" . ')' . "\n";
$php_options_text .= ' )' . "\n";
} // vhost data for fcgid
elseif ((int) Settings::Get('system.mod_fcgid') == 1) {
} elseif ((int) Settings::Get('system.mod_fcgid') == 1) {
// vhost data for fcgid
$php_options_text = ' fastcgi.server = ( ' . "\n";
$file_extensions = explode(' ', $phpconfig['file_extensions']);
foreach ($file_extensions as $f_extension) {

View File

@@ -126,10 +126,14 @@ class Nginx extends HttpConfigBase
}
public function createVirtualHosts()
{}
{
return;
}
public function createFileDirOptions()
{}
{
return;
}
public function createIpPort()
{
@@ -512,7 +516,7 @@ class Nginx extends HttpConfigBase
if ($this->deactivated == false) {
$vhost_content = $this->mergeVhostCustom($vhost_content, $this->create_pathOptions($domain)) . "\n";
$vhost_content = $this->mergeVhostCustom($vhost_content, $this->createPathOptions($domain)) . "\n";
$vhost_content .= $this->composePhpOptions($domain, $ssl_vhost);
$vhost_content .= isset($this->needed_htpasswds[$domain['id']]) ? $this->needed_htpasswds[$domain['id']] . "\n" : '';
@@ -686,7 +690,7 @@ class Nginx extends HttpConfigBase
return $sslsettings;
}
protected function create_pathOptions($domain)
protected function createPathOptions($domain)
{
$result_stmt = Database::prepare("
SELECT * FROM " . TABLE_PANEL_HTACCESS . "
@@ -1090,7 +1094,9 @@ class Nginx extends HttpConfigBase
}
public function createOwnVhostStarter()
{}
{
return;
}
protected function getServerNames($domain)
{

View File

@@ -30,21 +30,21 @@ class Fcgid
*
* @var array
*/
private $_domain = array();
private $domain = array();
/**
* Admin-Date cache array
*
* @var array
*/
private $_admin_cache = array();
private $admin_cache = array();
/**
* main constructor
*/
public function __construct($domain)
{
$this->_domain = $domain;
$this->domain = $domain;
}
/**
@@ -58,7 +58,7 @@ class Fcgid
// create starter
$starter_file = "#!/bin/sh\n\n";
$starter_file .= "#\n";
$starter_file .= "# starter created/changed on " . date("Y.m.d H:i:s") . " for domain '" . $this->_domain['domain'] . "' with id #" . $this->_domain['id'] . " from php template '" . $phpconfig['description'] . "' with id #" . $phpconfig['id'] . "\n";
$starter_file .= "# starter created/changed on " . date("Y.m.d H:i:s") . " for domain '" . $this->domain['domain'] . "' with id #" . $this->domain['id'] . " from php template '" . $phpconfig['description'] . "' with id #" . $phpconfig['id'] . "\n";
$starter_file .= "# Do not change anything in this file, it will be overwritten by the Froxlor Cronjob!\n";
$starter_file .= "#\n\n";
$starter_file .= "umask " . $phpconfig['mod_fcgid_umask'] . "\n";
@@ -66,8 +66,8 @@ class Fcgid
$starter_file .= "export PHPRC\n";
// set number of processes for one domain
if ((int) $this->_domain['mod_fcgid_starter'] != - 1) {
$starter_file .= "PHP_FCGI_CHILDREN=" . (int) $this->_domain['mod_fcgid_starter'] . "\n";
if ((int) $this->domain['mod_fcgid_starter'] != - 1) {
$starter_file .= "PHP_FCGI_CHILDREN=" . (int) $this->domain['mod_fcgid_starter'] . "\n";
} else {
if ((int) $phpconfig['mod_fcgid_starter'] != - 1) {
$starter_file .= "PHP_FCGI_CHILDREN=" . (int) $phpconfig['mod_fcgid_starter'] . "\n";
@@ -79,8 +79,8 @@ class Fcgid
$starter_file .= "export PHP_FCGI_CHILDREN\n";
// set number of maximum requests for one domain
if ((int) $this->_domain['mod_fcgid_maxrequests'] != - 1) {
$starter_file .= "PHP_FCGI_MAX_REQUESTS=" . (int) $this->_domain['mod_fcgid_maxrequests'] . "\n";
if ((int) $this->domain['mod_fcgid_maxrequests'] != - 1) {
$starter_file .= "PHP_FCGI_MAX_REQUESTS=" . (int) $this->domain['mod_fcgid_maxrequests'] . "\n";
} else {
if ((int) $phpconfig['mod_fcgid_maxrequests'] != - 1) {
$starter_file .= "PHP_FCGI_MAX_REQUESTS=" . (int) $phpconfig['mod_fcgid_maxrequests'] . "\n";
@@ -103,7 +103,7 @@ class Fcgid
fwrite($starter_file_handler, $starter_file);
fclose($starter_file_handler);
\Froxlor\FileDir::safe_exec('chmod 750 ' . escapeshellarg($this->getStarterFile()));
\Froxlor\FileDir::safe_exec('chown ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($this->getStarterFile()));
\Froxlor\FileDir::safe_exec('chown ' . $this->domain['guid'] . ':' . $this->domain['guid'] . ' ' . escapeshellarg($this->getStarterFile()));
\Froxlor\FileDir::setImmutable($this->getStarterFile());
}
@@ -117,7 +117,7 @@ class Fcgid
$openbasedir = '';
$openbasedirc = ';';
if ($this->_domain['openbasedir'] == '1') {
if ($this->domain['openbasedir'] == '1') {
$openbasedirc = '';
$_phpappendopenbasedir = '';
@@ -132,10 +132,10 @@ class Fcgid
$_phpappendopenbasedir .= \Froxlor\Domain\Domain::appendOpenBasedirPath($cobd);
}
if ($this->_domain['openbasedir_path'] == '0' && strstr($this->_domain['documentroot'], ":") === false) {
$openbasedir = \Froxlor\Domain\Domain::appendOpenBasedirPath($this->_domain['documentroot'], true);
if ($this->domain['openbasedir_path'] == '0' && strstr($this->domain['documentroot'], ":") === false) {
$openbasedir = \Froxlor\Domain\Domain::appendOpenBasedirPath($this->domain['documentroot'], true);
} else {
$openbasedir = \Froxlor\Domain\Domain::appendOpenBasedirPath($this->_domain['customerroot'], true);
$openbasedir = \Froxlor\Domain\Domain::appendOpenBasedirPath($this->domain['customerroot'], true);
}
$openbasedir .= \Froxlor\Domain\Domain::appendOpenBasedirPath($this->getTempDir());
@@ -145,26 +145,26 @@ class Fcgid
$openbasedirc = ';';
}
$admin = $this->getAdminData($this->_domain['adminid']);
$admin = $this->getAdminData($this->domain['adminid']);
$php_ini_variables = array(
'SAFE_MODE' => 'Off', // keep this for compatibility, just in case
'PEAR_DIR' => Settings::Get('system.mod_fcgid_peardir'),
'TMP_DIR' => $this->getTempDir(),
'CUSTOMER_EMAIL' => $this->_domain['email'],
'CUSTOMER_EMAIL' => $this->domain['email'],
'ADMIN_EMAIL' => $admin['email'],
'DOMAIN' => $this->_domain['domain'],
'CUSTOMER' => $this->_domain['loginname'],
'DOMAIN' => $this->domain['domain'],
'CUSTOMER' => $this->domain['loginname'],
'ADMIN' => $admin['loginname'],
'OPEN_BASEDIR' => $openbasedir,
'OPEN_BASEDIR_C' => $openbasedirc,
'OPEN_BASEDIR_GLOBAL' => Settings::Get('system.phpappendopenbasedir'),
'DOCUMENT_ROOT' => \Froxlor\FileDir::makeCorrectDir($this->_domain['documentroot']),
'CUSTOMER_HOMEDIR' => \Froxlor\FileDir::makeCorrectDir($this->_domain['customerroot'])
'DOCUMENT_ROOT' => \Froxlor\FileDir::makeCorrectDir($this->domain['documentroot']),
'CUSTOMER_HOMEDIR' => \Froxlor\FileDir::makeCorrectDir($this->domain['customerroot'])
);
// insert a small header for the file
$phpini_file = ";\n";
$phpini_file .= "; php.ini created/changed on " . date("Y.m.d H:i:s") . " for domain '" . $this->_domain['domain'] . "' with id #" . $this->_domain['id'] . " from php template '" . $phpconfig['description'] . "' with id #" . $phpconfig['id'] . "\n";
$phpini_file .= "; php.ini created/changed on " . date("Y.m.d H:i:s") . " for domain '" . $this->domain['domain'] . "' with id #" . $this->domain['id'] . " from php template '" . $phpconfig['description'] . "' with id #" . $phpconfig['id'] . "\n";
$phpini_file .= "; Do not change anything in this file, it will be overwritten by the Froxlor Cronjob!\n";
$phpini_file .= ";\n\n";
$phpini_file .= \Froxlor\PhpHelper::replace_variables($phpconfig['phpsettings'], $php_ini_variables);
@@ -187,11 +187,11 @@ class Fcgid
*/
public function getConfigDir($createifnotexists = true)
{
$configdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.mod_fcgid_configdir') . '/' . $this->_domain['loginname'] . '/' . $this->_domain['domain'] . '/');
$configdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.mod_fcgid_configdir') . '/' . $this->domain['loginname'] . '/' . $this->domain['domain'] . '/');
if (! is_dir($configdir) && $createifnotexists) {
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg($configdir));
\Froxlor\FileDir::safe_exec('chown ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($configdir));
\Froxlor\FileDir::safe_exec('chown ' . $this->domain['guid'] . ':' . $this->domain['guid'] . ' ' . escapeshellarg($configdir));
}
return $configdir;
@@ -207,11 +207,11 @@ class Fcgid
*/
public function getTempDir($createifnotexists = true)
{
$tmpdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.mod_fcgid_tmpdir') . '/' . $this->_domain['loginname'] . '/');
$tmpdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.mod_fcgid_tmpdir') . '/' . $this->domain['loginname'] . '/');
if (! is_dir($tmpdir) && $createifnotexists) {
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg($tmpdir));
\Froxlor\FileDir::safe_exec('chown -R ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($tmpdir));
\Froxlor\FileDir::safe_exec('chown -R ' . $this->domain['guid'] . ':' . $this->domain['guid'] . ' ' . escapeshellarg($tmpdir));
\Froxlor\FileDir::safe_exec('chmod 0750 ' . escapeshellarg($tmpdir));
}
@@ -252,13 +252,13 @@ class Fcgid
{
$adminid = intval($adminid);
if (! isset($this->_admin_cache[$adminid])) {
if (! isset($this->admin_cache[$adminid])) {
$stmt = Database::prepare("
SELECT `email`, `loginname` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid` = :id");
$this->_admin_cache[$adminid] = Database::pexecute_first($stmt, array(
$this->admin_cache[$adminid] = Database::pexecute_first($stmt, array(
'id' => $adminid
));
}
return $this->_admin_cache[$adminid];
return $this->admin_cache[$adminid];
}
}

View File

@@ -30,21 +30,21 @@ class Fpm
*
* @var array
*/
private $_domain = array();
private $domain = array();
/**
* fpm config
*
* @var array
*/
private $_fpm_cfg = array();
private $fpm_cfg = array();
/**
* Admin-Date cache array
*
* @var array
*/
private $_admin_cache = array();
private $admin_cache = array();
/**
* defines what can be used for pool-config from php.ini
@@ -52,7 +52,7 @@ class Fpm
*
* @var array
*/
private $_ini = array();
private $ini = array();
/**
* main constructor
@@ -62,14 +62,14 @@ class Fpm
if (! isset($domain['fpm_config_id']) || empty($domain['fpm_config_id'])) {
$domain['fpm_config_id'] = 1;
}
$this->_domain = $domain;
$this->domain = $domain;
$this->readFpmConfig($domain['fpm_config_id']);
$this->buildIniMapping();
}
private function buildIniMapping()
{
$this->_ini = array(
$this->ini = array(
'php_flag' => explode("\n", Settings::Get('phpfpm.ini_flags')),
'php_value' => explode("\n", Settings::Get('phpfpm.ini_values')),
'php_admin_flag' => explode("\n", Settings::Get('phpfpm.ini_admin_flags')),
@@ -80,7 +80,7 @@ class Fpm
private function readFpmConfig($fpm_config_id)
{
$stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` WHERE `id` = :id");
$this->_fpm_cfg = Database::pexecute_first($stmt, array(
$this->fpm_cfg = Database::pexecute_first($stmt, array(
'id' => $fpm_config_id
));
}
@@ -97,48 +97,48 @@ class Fpm
if ($fh) {
if ($phpconfig['override_fpmconfig'] == 1) {
$this->_fpm_cfg['pm'] = $phpconfig['pm'];
$this->_fpm_cfg['max_children'] = $phpconfig['max_children'];
$this->_fpm_cfg['start_servers'] = $phpconfig['start_servers'];
$this->_fpm_cfg['min_spare_servers'] = $phpconfig['min_spare_servers'];
$this->_fpm_cfg['max_spare_servers'] = $phpconfig['max_spare_servers'];
$this->_fpm_cfg['max_requests'] = $phpconfig['max_requests'];
$this->_fpm_cfg['idle_timeout'] = $phpconfig['idle_timeout'];
$this->_fpm_cfg['limit_extensions'] = $phpconfig['limit_extensions'];
$this->fpm_cfg['pm'] = $phpconfig['pm'];
$this->fpm_cfg['max_children'] = $phpconfig['max_children'];
$this->fpm_cfg['start_servers'] = $phpconfig['start_servers'];
$this->fpm_cfg['min_spare_servers'] = $phpconfig['min_spare_servers'];
$this->fpm_cfg['max_spare_servers'] = $phpconfig['max_spare_servers'];
$this->fpm_cfg['max_requests'] = $phpconfig['max_requests'];
$this->fpm_cfg['idle_timeout'] = $phpconfig['idle_timeout'];
$this->fpm_cfg['limit_extensions'] = $phpconfig['limit_extensions'];
}
$fpm_pm = $this->_fpm_cfg['pm'];
$fpm_children = (int) $this->_fpm_cfg['max_children'];
$fpm_start_servers = (int) $this->_fpm_cfg['start_servers'];
$fpm_min_spare_servers = (int) $this->_fpm_cfg['min_spare_servers'];
$fpm_max_spare_servers = (int) $this->_fpm_cfg['max_spare_servers'];
$fpm_requests = (int) $this->_fpm_cfg['max_requests'];
$fpm_process_idle_timeout = (int) $this->_fpm_cfg['idle_timeout'];
$fpm_limit_extensions = $this->_fpm_cfg['limit_extensions'];
$fpm_pm = $this->fpm_cfg['pm'];
$fpm_children = (int) $this->fpm_cfg['max_children'];
$fpm_start_servers = (int) $this->fpm_cfg['start_servers'];
$fpm_min_spare_servers = (int) $this->fpm_cfg['min_spare_servers'];
$fpm_max_spare_servers = (int) $this->fpm_cfg['max_spare_servers'];
$fpm_requests = (int) $this->fpm_cfg['max_requests'];
$fpm_process_idle_timeout = (int) $this->fpm_cfg['idle_timeout'];
$fpm_limit_extensions = $this->fpm_cfg['limit_extensions'];
if ($fpm_children == 0) {
$fpm_children = 1;
}
$fpm_config = ';PHP-FPM configuration for "' . $this->_domain['domain'] . '" created on ' . date("Y.m.d H:i:s") . "\n";
$fpm_config .= '[' . $this->_domain['domain'] . ']' . "\n";
$fpm_config = ';PHP-FPM configuration for "' . $this->domain['domain'] . '" created on ' . date("Y.m.d H:i:s") . "\n";
$fpm_config .= '[' . $this->domain['domain'] . ']' . "\n";
$fpm_config .= 'listen = ' . $this->getSocketFile() . "\n";
if ($this->_domain['loginname'] == 'froxlor.panel') {
$fpm_config .= 'listen.owner = ' . $this->_domain['guid'] . "\n";
$fpm_config .= 'listen.group = ' . $this->_domain['guid'] . "\n";
if ($this->domain['loginname'] == 'froxlor.panel') {
$fpm_config .= 'listen.owner = ' . $this->domain['guid'] . "\n";
$fpm_config .= 'listen.group = ' . $this->domain['guid'] . "\n";
} else {
$fpm_config .= 'listen.owner = ' . $this->_domain['loginname'] . "\n";
$fpm_config .= 'listen.group = ' . $this->_domain['loginname'] . "\n";
$fpm_config .= 'listen.owner = ' . $this->domain['loginname'] . "\n";
$fpm_config .= 'listen.group = ' . $this->domain['loginname'] . "\n";
}
// see #1418 why this is 0660
$fpm_config .= 'listen.mode = 0660' . "\n";
if ($this->_domain['loginname'] == 'froxlor.panel') {
$fpm_config .= 'user = ' . $this->_domain['guid'] . "\n";
$fpm_config .= 'group = ' . $this->_domain['guid'] . "\n";
if ($this->domain['loginname'] == 'froxlor.panel') {
$fpm_config .= 'user = ' . $this->domain['guid'] . "\n";
$fpm_config .= 'group = ' . $this->domain['guid'] . "\n";
} else {
$fpm_config .= 'user = ' . $this->_domain['loginname'] . "\n";
$fpm_config .= 'group = ' . $this->_domain['loginname'] . "\n";
$fpm_config .= 'user = ' . $this->domain['loginname'] . "\n";
$fpm_config .= 'group = ' . $this->domain['loginname'] . "\n";
}
$fpm_config .= 'pm = ' . $fpm_pm . "\n";
@@ -172,15 +172,15 @@ class Fpm
if ($phpconfig['fpm_slowlog'] == '1') {
$fpm_config .= 'request_terminate_timeout = ' . $phpconfig['fpm_reqterm'] . "\n";
$fpm_config .= 'request_slowlog_timeout = ' . $phpconfig['fpm_reqslow'] . "\n";
$slowlog = \Froxlor\FileDir::makeCorrectFile(Settings::Get('system.logfiles_directory') . '/' . $this->_domain['loginname'] . '-php-slow.log');
$slowlog = \Froxlor\FileDir::makeCorrectFile(Settings::Get('system.logfiles_directory') . '/' . $this->domain['loginname'] . '-php-slow.log');
$fpm_config .= 'slowlog = ' . $slowlog . "\n";
$fpm_config .= 'catch_workers_output = yes' . "\n";
}
$fpm_config .= ';chroot = ' . \Froxlor\FileDir::makeCorrectDir($this->_domain['documentroot']) . "\n";
$fpm_config .= ';chroot = ' . \Froxlor\FileDir::makeCorrectDir($this->domain['documentroot']) . "\n";
$fpm_config .= 'security.limit_extensions = ' . $fpm_limit_extensions . "\n";
$tmpdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->_domain['loginname'] . '/');
$tmpdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->domain['loginname'] . '/');
if (! is_dir($tmpdir)) {
$this->getTempDir();
}
@@ -194,8 +194,8 @@ class Fpm
$fpm_config .= 'env[TEMP] = ' . $tmpdir . "\n";
$openbasedir = '';
if ($this->_domain['loginname'] != 'froxlor.panel') {
if ($this->_domain['openbasedir'] == '1') {
if ($this->domain['loginname'] != 'froxlor.panel') {
if ($this->domain['openbasedir'] == '1') {
$_phpappendopenbasedir = '';
$_custom_openbasedir = explode(':', Settings::Get('phpfpm.peardir'));
foreach ($_custom_openbasedir as $cobd) {
@@ -207,34 +207,34 @@ class Fpm
$_phpappendopenbasedir .= \Froxlor\Domain\Domain::appendOpenBasedirPath($cobd);
}
if ($this->_domain['openbasedir_path'] == '0' && strstr($this->_domain['documentroot'], ":") === false) {
$openbasedir = \Froxlor\Domain\Domain::appendOpenBasedirPath($this->_domain['documentroot'], true);
if ($this->domain['openbasedir_path'] == '0' && strstr($this->domain['documentroot'], ":") === false) {
$openbasedir = \Froxlor\Domain\Domain::appendOpenBasedirPath($this->domain['documentroot'], true);
} else {
$openbasedir = \Froxlor\Domain\Domain::appendOpenBasedirPath($this->_domain['customerroot'], true);
$openbasedir = \Froxlor\Domain\Domain::appendOpenBasedirPath($this->domain['customerroot'], true);
}
$openbasedir .= \Froxlor\Domain\Domain::appendOpenBasedirPath($this->getTempDir());
$openbasedir .= $_phpappendopenbasedir;
}
}
$fpm_config .= 'php_admin_value[session.save_path] = ' . \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->_domain['loginname'] . '/') . "\n";
$fpm_config .= 'php_admin_value[upload_tmp_dir] = ' . \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->_domain['loginname'] . '/') . "\n";
$fpm_config .= 'php_admin_value[session.save_path] = ' . \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->domain['loginname'] . '/') . "\n";
$fpm_config .= 'php_admin_value[upload_tmp_dir] = ' . \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->domain['loginname'] . '/') . "\n";
$admin = $this->getAdminData($this->_domain['adminid']);
$admin = $this->getAdminData($this->domain['adminid']);
$php_ini_variables = array(
'SAFE_MODE' => 'Off', // keep this for compatibility, just in case
'PEAR_DIR' => Settings::Get('phpfpm.peardir'),
'TMP_DIR' => $this->getTempDir(),
'CUSTOMER_EMAIL' => $this->_domain['email'],
'CUSTOMER_EMAIL' => $this->domain['email'],
'ADMIN_EMAIL' => $admin['email'],
'DOMAIN' => $this->_domain['domain'],
'CUSTOMER' => $this->_domain['loginname'],
'DOMAIN' => $this->domain['domain'],
'CUSTOMER' => $this->domain['loginname'],
'ADMIN' => $admin['loginname'],
'OPEN_BASEDIR' => $openbasedir,
'OPEN_BASEDIR_C' => '',
'OPEN_BASEDIR_GLOBAL' => Settings::Get('system.phpappendopenbasedir'),
'DOCUMENT_ROOT' => \Froxlor\FileDir::makeCorrectDir($this->_domain['documentroot']),
'CUSTOMER_HOMEDIR' => \Froxlor\FileDir::makeCorrectDir($this->_domain['customerroot'])
'DOCUMENT_ROOT' => \Froxlor\FileDir::makeCorrectDir($this->domain['documentroot']),
'CUSTOMER_HOMEDIR' => \Froxlor\FileDir::makeCorrectDir($this->domain['customerroot'])
);
$phpini = \Froxlor\PhpHelper::replace_variables($phpconfig['phpsettings'], $php_ini_variables);
@@ -243,7 +243,7 @@ class Fpm
$fpm_config .= "\n\n";
foreach ($phpini_array as $inisection) {
$is = explode("=", $inisection);
foreach ($this->_ini as $sec => $possibles) {
foreach ($this->ini as $sec => $possibles) {
if (in_array(trim($is[0]), $possibles)) {
// check explicitly for open_basedir
if (trim($is[0]) == 'open_basedir' && $openbasedir == '') {
@@ -257,7 +257,7 @@ class Fpm
// now check if 'sendmail_path' has not beed set in the custom-php.ini
// if not we use our fallback-default as usual
if (strpos($fpm_config, 'php_admin_value[sendmail_path]') === false) {
$fpm_config .= 'php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f ' . $this->_domain['email'] . "\n";
$fpm_config .= 'php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f ' . $this->domain['email'] . "\n";
}
fwrite($fh, $fpm_config, strlen($fpm_config));
@@ -286,8 +286,8 @@ class Fpm
*/
public function getConfigFile($createifnotexists = true)
{
$configdir = $this->_fpm_cfg['config_dir'];
$config = \Froxlor\FileDir::makeCorrectFile($configdir . '/' . $this->_domain['domain'] . '.conf');
$configdir = $this->fpm_cfg['config_dir'];
$config = \Froxlor\FileDir::makeCorrectFile($configdir . '/' . $this->domain['domain'] . '.conf');
if (! is_dir($configdir) && $createifnotexists) {
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg($configdir));
@@ -308,7 +308,7 @@ class Fpm
{
$socketdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.fastcgi_ipcdir'));
// add fpm-config-id to filename so it's unique for the fpm-daemon and doesn't interfere with running configs when reuilding
$socket = strtolower(\Froxlor\FileDir::makeCorrectFile($socketdir . '/' . $this->_domain['fpm_config_id'] . '-' . $this->_domain['loginname'] . '-' . $this->_domain['domain'] . '-php-fpm.socket'));
$socket = strtolower(\Froxlor\FileDir::makeCorrectFile($socketdir . '/' . $this->domain['fpm_config_id'] . '-' . $this->domain['loginname'] . '-' . $this->domain['domain'] . '-php-fpm.socket'));
if (! is_dir($socketdir) && $createifnotexists) {
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg($socketdir));
@@ -328,11 +328,11 @@ class Fpm
*/
public function getTempDir($createifnotexists = true)
{
$tmpdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->_domain['loginname'] . '/');
$tmpdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->domain['loginname'] . '/');
if (! is_dir($tmpdir) && $createifnotexists) {
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg($tmpdir));
\Froxlor\FileDir::safe_exec('chown -R ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($tmpdir));
\Froxlor\FileDir::safe_exec('chown -R ' . $this->domain['guid'] . ':' . $this->domain['guid'] . ' ' . escapeshellarg($tmpdir));
\Froxlor\FileDir::safe_exec('chmod 0750 ' . escapeshellarg($tmpdir));
}
@@ -355,10 +355,10 @@ class Fpm
Settings::Set('phpfpm.aliasconfigdir', '/var/www/php-fpm');
}
$configdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.aliasconfigdir') . '/' . $this->_domain['loginname'] . '/' . $this->_domain['domain'] . '/');
$configdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.aliasconfigdir') . '/' . $this->domain['loginname'] . '/' . $this->domain['domain'] . '/');
if (! is_dir($configdir) && $createifnotexists) {
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg($configdir));
\Froxlor\FileDir::safe_exec('chown ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($configdir));
\Froxlor\FileDir::safe_exec('chown ' . $this->domain['guid'] . ':' . $this->domain['guid'] . ' ' . escapeshellarg($configdir));
}
return $configdir;
@@ -397,13 +397,13 @@ pm.max_children = 1
{
$adminid = intval($adminid);
if (! isset($this->_admin_cache[$adminid])) {
if (! isset($this->admin_cache[$adminid])) {
$stmt = Database::prepare("
SELECT `email`, `loginname` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid` = :id");
$this->_admin_cache[$adminid] = Database::pexecute_first($stmt, array(
$this->admin_cache[$adminid] = Database::pexecute_first($stmt, array(
'id' => $adminid
));
}
return $this->_admin_cache[$adminid];
return $this->admin_cache[$adminid];
}
}

View File

@@ -30,28 +30,28 @@ class PhpInterface
*
* @var array
*/
private $_domain = array();
private $domain = array();
/**
* Interface object
*
* @var object
*/
private $_interface = null;
private $interface = null;
/**
* Admin-User data array
*
* @var array
*/
private $_admin_cache = array();
private $admin_cache = array();
/**
* main constructor
*/
public function __construct($domain)
{
$this->_domain = $domain;
$this->domain = $domain;
$this->setInterface();
}
@@ -61,7 +61,7 @@ class PhpInterface
*/
public function getInterface()
{
return $this->_interface;
return $this->interface;
}
/**
@@ -73,9 +73,9 @@ class PhpInterface
{
// php-fpm
if ((int) Settings::Get('phpfpm.enabled') == 1) {
$this->_interface = new Fpm($this->_domain);
$this->interface = new Fpm($this->domain);
} elseif ((int) Settings::Get('system.mod_fcgid') == 1) {
$this->_interface = new Fcgid($this->_domain);
$this->interface = new Fcgid($this->domain);
}
}

View File

@@ -74,8 +74,9 @@ class MasterCron extends \Froxlor\Cron\FroxlorCron
define('CRON_DEBUG_FLAG', 1);
} elseif (strtolower($argv[$x]) == '--no-fork') {
define('CRON_NOFORK_FLAG', 1);
} // --[cronname]
}
elseif (substr(strtolower($argv[$x]), 0, 2) == '--') {
// --[cronname]
if (strlen($argv[$x]) > 3) {
$cronname = substr(strtolower($argv[$x]), 2);
array_push($jobs_to_run, $cronname);
@@ -86,7 +87,7 @@ class MasterCron extends \Froxlor\Cron\FroxlorCron
$jobs_to_run = array_unique($jobs_to_run);
$cronlog->setCronDebugFlag(defined('CRON_DEBUG_FLAG'));
\Froxlor\FroxlorLogger::getInstanceOf()->setCronDebugFlag(defined('CRON_DEBUG_FLAG'));
$tasks_cnt_stmt = \Froxlor\Database\Database::query("SELECT COUNT(*) as jobcnt FROM `panel_tasks`");
$tasks_cnt = $tasks_cnt_stmt->fetch(\PDO::FETCH_ASSOC);
@@ -125,7 +126,7 @@ class MasterCron extends \Froxlor\Cron\FroxlorCron
* in case the admin installed new software which added a new user
* so users in the database don't conflict with system users
*/
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Checking system\'s last guid');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_NOTICE, 'Checking system\'s last guid');
\Froxlor\System\Cronjob::checkLastGuid();
// shutdown cron

View File

@@ -51,13 +51,13 @@ class BackupCron extends \Froxlor\Cron\FroxlorCron
file_put_contents($BackupLock, $BackupPid);
// unnecessary to recreate database connection here
return 0;
} // Child
elseif ($BackupPid == 0) {
} elseif ($BackupPid == 0) {
// Child
posix_setsid();
// re-create db
Database::needRoot(false);
} // Fork failed
else {
} else {
// Fork failed
return 1;
}
} else {
@@ -120,7 +120,7 @@ class BackupCron extends \Froxlor\Cron\FroxlorCron
* @return void
*
*/
private static function createCustomerBackup($data = null, $customerdocroot = null, &$cronlog)
private static function createCustomerBackup($data = null, $customerdocroot = null, &$cronlog = null)
{
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Creating Backup for user "' . $data['loginname'] . '"');

View File

@@ -416,8 +416,8 @@ class TasksCron extends \Froxlor\Cron\FroxlorCron
} else {
\Froxlor\FileDir::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) {
// The user quota in Froxlor is different than on the filesystem
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_NOTICE, "Setting quota for " . $row['loginname'] . " from " . $usedquota[$row['guid']]['block']['hard'] . " to " . $row['diskspace']);
if (\Froxlor\FileDir::isFreeBSD()) {
\Froxlor\FileDir::safe_exec(Settings::Get('system.diskquota_quotatool_path') . " -e " . escapeshellarg(Settings::Get('system.diskquota_customer_partition')) . ":" . $row['diskspace'] . ":" . $row['diskspace'] . " " . $row['guid']);

View File

@@ -275,7 +275,7 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
$tg = $customer['traffic'] / 1048576;
$str = sprintf('%00.1f GB ( %00.1f %% )', $t, $p);
$mail_body .= sprintf('%-15s', $customer['loginname']) . ' ' . sprintf('%-25s', $str) . ' ' . sprintf('%00.1f GB', $tg) . "\n";
} else if ($customer['traffic'] == 0) {
} elseif ($customer['traffic'] == 0) {
$str = sprintf('%00.1f GB ( - )', $t);
$mail_body .= sprintf('%-15s', $customer['loginname']) . ' ' . sprintf('%-25s', $str) . ' ' . '0' . "\n";
} else {
@@ -292,7 +292,7 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
$tg = $row['traffic'] / 1048576;
$str = sprintf('%00.1f GB ( %00.1f %% )', $t, $p);
$mail_body .= sprintf('%-15s', $row['loginname']) . ' ' . sprintf('%-25s', $str) . ' ' . sprintf('%00.1f GB', $tg) . "\n";
} else if ($row['traffic'] == 0) {
} elseif ($row['traffic'] == 0) {
$str = sprintf('%00.1f GB ( - )', $t);
$mail_body .= sprintf('%-15s', $row['loginname']) . ' ' . sprintf('%-25s', $str) . ' ' . '0' . "\n";
} else {

View File

@@ -50,13 +50,13 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
file_put_contents($TrafficLock, $TrafficPid);
// unnecessary to recreate database connection here
return 0;
} // Child
elseif ($TrafficPid == 0) {
} elseif ($TrafficPid == 0) {
// Child
posix_setsid();
// re-create db
Database::needRoot(false);
} // Fork failed
else {
} else {
// Fork failed
return 1;
}
} else {
@@ -716,43 +716,39 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
$nav_file = \Froxlor\FileDir::makeCorrectFile($nav_file);
// Write the index file
{
// 'index.html' used to be a symlink (ignore errors in case this is the first run and no index.html exists yet)
@unlink(\Froxlor\FileDir::makeCorrectFile($outputdir . '/' . 'index.html'));
// 'index.html' used to be a symlink (ignore errors in case this is the first run and no index.html exists yet)
@unlink(\Froxlor\FileDir::makeCorrectFile($outputdir . '/' . 'index.html'));
$awstats_index_file = fopen(\Froxlor\FileDir::makeCorrectFile($outputdir . '/' . 'index.html'), 'w');
$awstats_index_tpl = fopen($index_file, 'r');
$awstats_index_file = fopen(\Froxlor\FileDir::makeCorrectFile($outputdir . '/' . 'index.html'), 'w');
$awstats_index_tpl = fopen($index_file, 'r');
// Write the header
fwrite($awstats_index_file, $header);
// Write the header
fwrite($awstats_index_file, $header);
// Write the configuration file
while (($line = fgets($awstats_index_tpl, 4096)) !== false) {
if (! preg_match('/^#/', $line) && trim($line) != '') {
fwrite($awstats_index_file, preg_replace($regex, $replace, $line));
}
// Write the configuration file
while (($line = fgets($awstats_index_tpl, 4096)) !== false) {
if (! preg_match('/^#/', $line) && trim($line) != '') {
fwrite($awstats_index_file, preg_replace($regex, $replace, $line));
}
fclose($awstats_index_file);
fclose($awstats_index_tpl);
}
fclose($awstats_index_file);
fclose($awstats_index_tpl);
// Write the nav file
{
$awstats_nav_file = fopen(\Froxlor\FileDir::makeCorrectFile($outputdir . '/' . 'nav.html'), 'w');
$awstats_nav_tpl = fopen($nav_file, 'r');
$awstats_nav_file = fopen(\Froxlor\FileDir::makeCorrectFile($outputdir . '/' . 'nav.html'), 'w');
$awstats_nav_tpl = fopen($nav_file, 'r');
// Write the header
fwrite($awstats_nav_file, $header);
// Write the header
fwrite($awstats_nav_file, $header);
// Write the configuration file
while (($line = fgets($awstats_nav_tpl, 4096)) !== false) {
if (! preg_match('/^#/', $line) && trim($line) != '') {
fwrite($awstats_nav_file, preg_replace($regex, $replace, $line));
}
// Write the configuration file
while (($line = fgets($awstats_nav_tpl, 4096)) !== false) {
if (! preg_match('/^#/', $line) && trim($line) != '') {
fwrite($awstats_nav_file, preg_replace($regex, $replace, $line));
}
fclose($awstats_nav_file);
fclose($awstats_nav_tpl);
}
fclose($awstats_nav_file);
fclose($awstats_nav_tpl);
return;
}