From 35c631946d7532729297adee466d20cd0f9d6c81 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Mon, 24 Dec 2018 12:59:40 +0100 Subject: [PATCH] more and more checkstyle fixes Signed-off-by: Michael Kaufmann --- lib/Froxlor/Api/Commands/DirOptions.php | 4 +- lib/Froxlor/Api/Commands/Froxlor.php | 12 +- lib/Froxlor/Api/Commands/HostingPlans.php | 20 ++- lib/Froxlor/Cli/Action.php | 2 +- lib/Froxlor/Cli/CmdLineHandler.php | 6 +- lib/Froxlor/Config/ConfigDaemon.php | 8 +- lib/Froxlor/Cron/Http/ConfigIO.php | 6 - lib/Froxlor/Cron/Http/DomainSSL.php | 6 - .../Cron/Http/LetsEncrypt/LetsEncrypt.php | 2 +- .../{LetsEncrypt_v2.php => LetsEncryptV2.php} | 6 +- lib/Froxlor/Cron/Http/Lighttpd.php | 18 ++- lib/Froxlor/Cron/Http/LighttpdFcgi.php | 4 +- lib/Froxlor/Cron/Http/Nginx.php | 16 ++- lib/Froxlor/Cron/Http/Php/Fcgid.php | 54 ++++---- lib/Froxlor/Cron/Http/Php/Fpm.php | 126 +++++++++--------- lib/Froxlor/Cron/Http/Php/PhpInterface.php | 14 +- lib/Froxlor/Cron/MasterCron.php | 7 +- lib/Froxlor/Cron/System/BackupCron.php | 10 +- lib/Froxlor/Cron/System/TasksCron.php | 4 +- lib/Froxlor/Cron/Traffic/ReportsCron.php | 4 +- lib/Froxlor/Cron/Traffic/TrafficCron.php | 56 ++++---- .../Database/Manager/DbManagerMySQL.php | 4 +- lib/Froxlor/Dns/Dns.php | 4 +- lib/Froxlor/Dns/PowerDNS.php | 2 +- lib/Froxlor/Domain/Domain.php | 2 +- lib/Froxlor/Domain/IpAddr.php | 2 +- lib/Froxlor/FileDir.php | 24 +--- lib/Froxlor/Froxlor.php | 6 +- lib/Froxlor/FroxlorLogger.php | 4 +- lib/Froxlor/Http/Directory.php | 16 +-- lib/Froxlor/Http/LetsEncrypt/LeScript.php | 4 +- .../{LeScript_v2.php => LeScriptV2.php} | 30 ++--- lib/Froxlor/Http/PhpConfig.php | 2 +- lib/Froxlor/System/Cronjob.php | 40 +++--- lib/Froxlor/System/Crypt.php | 12 +- .../IgnorantRecursiveDirectoryIterator.php | 21 +++ lib/Froxlor/System/Mailer.php | 2 +- lib/Froxlor/UI/Data.php | 2 +- lib/Froxlor/UI/Fields.php | 2 +- lib/Froxlor/UI/Form.php | 6 +- lib/Froxlor/UI/HTML.php | 4 +- lib/Froxlor/UI/HtmlForm.php | 4 +- lib/Froxlor/UI/Template.php | 2 +- lib/Froxlor/Validate/Check.php | 6 +- lib/Froxlor/Validate/Form.php | 2 +- lib/Froxlor/Validate/Form/Data.php | 2 +- lib/Froxlor/Validate/Validate.php | 6 +- tests/linting.php | 29 ---- 48 files changed, 298 insertions(+), 327 deletions(-) rename lib/Froxlor/Cron/Http/LetsEncrypt/{LetsEncrypt_v2.php => LetsEncryptV2.php} (97%) rename lib/Froxlor/Http/LetsEncrypt/{LeScript_v2.php => LeScriptV2.php} (95%) create mode 100644 lib/Froxlor/System/IgnorantRecursiveDirectoryIterator.php delete mode 100644 tests/linting.php diff --git a/lib/Froxlor/Api/Commands/DirOptions.php b/lib/Froxlor/Api/Commands/DirOptions.php index de9b90f6..aafb7f75 100644 --- a/lib/Froxlor/Api/Commands/DirOptions.php +++ b/lib/Froxlor/Api/Commands/DirOptions.php @@ -402,8 +402,8 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc if (! substr($errdoc, 0, 1) == '/') { $errdoc = '/' . $errdoc; } - } // a string (check for ending ") - else { + } else { + // a string (check for ending ") // string won't work for lighty if (Settings::Get('system.webserver') == 'lighttpd') { \Froxlor\UI\Response::standard_error('stringerrordocumentnotvalidforlighty', '', $throw_exception); diff --git a/lib/Froxlor/Api/Commands/Froxlor.php b/lib/Froxlor/Api/Commands/Froxlor.php index 9a9d4ec4..c132f677 100644 --- a/lib/Froxlor/Api/Commands/Froxlor.php +++ b/lib/Froxlor/Api/Commands/Froxlor.php @@ -340,8 +340,8 @@ class Froxlor extends \Froxlor\Api\ApiCommand 'desc' => (isset($r[3]) ? trim($r['3']) : '') ); $param_desc = true; - } // check access-section - elseif (strpos($c, '@access')) { + } elseif (strpos($c, '@access')) { + // check access-section preg_match('/^\*\s\@access\s(.*)/', $c, $r); if (! isset($r[0]) || empty($r[0])) { $r[1] = 'This function has no restrictions'; @@ -349,8 +349,8 @@ class Froxlor extends \Froxlor\Api\ApiCommand $result['access'] = array( 'groups' => (isset($r[1]) ? trim($r[1]) : '') ); - } // check return-section - elseif (strpos($c, '@return')) { + } elseif (strpos($c, '@return')) { + // check return-section preg_match('/^\*\s\@return\s(\w+)(\s.*)?/', $c, $r); if (! isset($r[0]) || empty($r[0])) { $r[1] = 'null'; @@ -360,8 +360,8 @@ class Froxlor extends \Froxlor\Api\ApiCommand 'type' => $r[1], 'desc' => (isset($r[2]) ? trim($r[2]) : '') ); - } // check throws-section - elseif (! empty($c) && strpos($c, '@throws') === false) { + } elseif (! empty($c) && strpos($c, '@throws') === false) { + // check throws-section if (substr($c, 0, 3) == "/**") { continue; } diff --git a/lib/Froxlor/Api/Commands/HostingPlans.php b/lib/Froxlor/Api/Commands/HostingPlans.php index a6de6285..60b275f3 100644 --- a/lib/Froxlor/Api/Commands/HostingPlans.php +++ b/lib/Froxlor/Api/Commands/HostingPlans.php @@ -20,17 +20,27 @@ class HostingPlans extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou { public function add() - {} + { + throw new \Exception('noop', 303); + } public function get() - {} + { + throw new \Exception('noop', 303); + } public function update() - {} + { + throw new \Exception('noop', 303); + } public function listing() - {} + { + throw new \Exception('noop', 303); + } public function delete() - {} + { + throw new \Exception('noop', 303); + } } diff --git a/lib/Froxlor/Cli/Action.php b/lib/Froxlor/Cli/Action.php index 91974c2c..3f079d48 100644 --- a/lib/Froxlor/Cli/Action.php +++ b/lib/Froxlor/Cli/Action.php @@ -15,4 +15,4 @@ abstract class Action } abstract public function run(); -} \ No newline at end of file +} diff --git a/lib/Froxlor/Cli/CmdLineHandler.php b/lib/Froxlor/Cli/CmdLineHandler.php index ab1b471c..1cb3fe46 100644 --- a/lib/Froxlor/Cli/CmdLineHandler.php +++ b/lib/Froxlor/Cli/CmdLineHandler.php @@ -30,7 +30,7 @@ abstract class CmdLineHandler * * @var \Froxlor\Cli\Action */ - private $_action = null; + private $action = null; /** * Returns a CmdLineHandler object with given @@ -60,8 +60,8 @@ abstract class CmdLineHandler private function __construct($argc, $argv) { self::$args = $this->parseArgs($argv); - $this->_action = $this->createAction(); - $this->_action->run(); + $this->action = $this->createAction(); + $this->action->run(); } /** diff --git a/lib/Froxlor/Config/ConfigDaemon.php b/lib/Froxlor/Config/ConfigDaemon.php index fddd84b9..3bd22862 100644 --- a/lib/Froxlor/Config/ConfigDaemon.php +++ b/lib/Froxlor/Config/ConfigDaemon.php @@ -71,7 +71,7 @@ class ConfigDaemon /** * cache of sql-data if used */ - private $_sqldata_cache = null; + private $sqldata_cache = null; /** * Human - readable title of this service @@ -441,15 +441,15 @@ class ConfigDaemon return ''; } } elseif (preg_match('/^sql\.(.*)$/', $matches[1], $match)) { - if (is_null($this->_sqldata_cache)) { + if (is_null($this->sqldata_cache)) { // read in sql-data (if exists) if (file_exists(\Froxlor\Froxlor::getInstallDir() . "/lib/userdata.inc.php")) { require \Froxlor\Froxlor::getInstallDir() . "/lib/userdata.inc.php"; unset($sql_root); - $this->_sqldata_cache = $sql; + $this->sqldata_cache = $sql; } } - return isset($this->_sqldata_cache[$match[1]]) ? $this->_sqldata_cache[$match[1]] : ''; + return isset($this->sqldata_cache[$match[1]]) ? $this->sqldata_cache[$match[1]] : ''; } }, $content); return $content; diff --git a/lib/Froxlor/Cron/Http/ConfigIO.php b/lib/Froxlor/Cron/Http/ConfigIO.php index 0d8a8630..a87e7a72 100644 --- a/lib/Froxlor/Cron/Http/ConfigIO.php +++ b/lib/Froxlor/Cron/Http/ConfigIO.php @@ -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 diff --git a/lib/Froxlor/Cron/Http/DomainSSL.php b/lib/Froxlor/Cron/Http/DomainSSL.php index 158fd42b..ca4eed73 100644 --- a/lib/Froxlor/Cron/Http/DomainSSL.php +++ b/lib/Froxlor/Cron/Http/DomainSSL.php @@ -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, diff --git a/lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncrypt.php b/lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncrypt.php index 96e913e7..26ab0e2d 100644 --- a/lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncrypt.php +++ b/lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncrypt.php @@ -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(); } diff --git a/lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncrypt_v2.php b/lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncryptV2.php similarity index 97% rename from lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncrypt_v2.php rename to lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncryptV2.php index d8af907a..c6caf895 100644 --- a/lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncrypt_v2.php +++ b/lib/Froxlor/Cron/Http/LetsEncrypt/LetsEncryptV2.php @@ -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); diff --git a/lib/Froxlor/Cron/Http/Lighttpd.php b/lib/Froxlor/Cron/Http/Lighttpd.php index feb5ad3c..fcabf3aa 100644 --- a/lib/Froxlor/Cron/Http/Lighttpd.php +++ b/lib/Froxlor/Cron/Http/Lighttpd.php @@ -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 . " diff --git a/lib/Froxlor/Cron/Http/LighttpdFcgi.php b/lib/Froxlor/Cron/Http/LighttpdFcgi.php index 62018dba..03dc0689 100644 --- a/lib/Froxlor/Cron/Http/LighttpdFcgi.php +++ b/lib/Froxlor/Cron/Http/LighttpdFcgi.php @@ -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) { diff --git a/lib/Froxlor/Cron/Http/Nginx.php b/lib/Froxlor/Cron/Http/Nginx.php index 63a29f1e..9bf12a06 100644 --- a/lib/Froxlor/Cron/Http/Nginx.php +++ b/lib/Froxlor/Cron/Http/Nginx.php @@ -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) { diff --git a/lib/Froxlor/Cron/Http/Php/Fcgid.php b/lib/Froxlor/Cron/Http/Php/Fcgid.php index 44060ea7..f93c8442 100644 --- a/lib/Froxlor/Cron/Http/Php/Fcgid.php +++ b/lib/Froxlor/Cron/Http/Php/Fcgid.php @@ -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]; } } diff --git a/lib/Froxlor/Cron/Http/Php/Fpm.php b/lib/Froxlor/Cron/Http/Php/Fpm.php index 8ea7af32..49b4bd34 100644 --- a/lib/Froxlor/Cron/Http/Php/Fpm.php +++ b/lib/Froxlor/Cron/Http/Php/Fpm.php @@ -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]; } } diff --git a/lib/Froxlor/Cron/Http/Php/PhpInterface.php b/lib/Froxlor/Cron/Http/Php/PhpInterface.php index 0be9b440..7d85cea8 100644 --- a/lib/Froxlor/Cron/Http/Php/PhpInterface.php +++ b/lib/Froxlor/Cron/Http/Php/PhpInterface.php @@ -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); } } diff --git a/lib/Froxlor/Cron/MasterCron.php b/lib/Froxlor/Cron/MasterCron.php index dc703e3b..c678618f 100644 --- a/lib/Froxlor/Cron/MasterCron.php +++ b/lib/Froxlor/Cron/MasterCron.php @@ -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 diff --git a/lib/Froxlor/Cron/System/BackupCron.php b/lib/Froxlor/Cron/System/BackupCron.php index 3a4f8b43..97753cd1 100644 --- a/lib/Froxlor/Cron/System/BackupCron.php +++ b/lib/Froxlor/Cron/System/BackupCron.php @@ -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'] . '"'); diff --git a/lib/Froxlor/Cron/System/TasksCron.php b/lib/Froxlor/Cron/System/TasksCron.php index 22578810..812106ed 100644 --- a/lib/Froxlor/Cron/System/TasksCron.php +++ b/lib/Froxlor/Cron/System/TasksCron.php @@ -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']); diff --git a/lib/Froxlor/Cron/Traffic/ReportsCron.php b/lib/Froxlor/Cron/Traffic/ReportsCron.php index 35d31d99..22a7c49c 100644 --- a/lib/Froxlor/Cron/Traffic/ReportsCron.php +++ b/lib/Froxlor/Cron/Traffic/ReportsCron.php @@ -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 { diff --git a/lib/Froxlor/Cron/Traffic/TrafficCron.php b/lib/Froxlor/Cron/Traffic/TrafficCron.php index 117ea922..a92b528f 100644 --- a/lib/Froxlor/Cron/Traffic/TrafficCron.php +++ b/lib/Froxlor/Cron/Traffic/TrafficCron.php @@ -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; } diff --git a/lib/Froxlor/Database/Manager/DbManagerMySQL.php b/lib/Froxlor/Database/Manager/DbManagerMySQL.php index f140371f..2014ae60 100644 --- a/lib/Froxlor/Database/Manager/DbManagerMySQL.php +++ b/lib/Froxlor/Database/Manager/DbManagerMySQL.php @@ -41,7 +41,7 @@ class DbManagerMySQL * * @var object */ - private $_log = null; + private $log = null; /** * main constructor @@ -50,7 +50,7 @@ class DbManagerMySQL */ public function __construct(&$log = null) { - $this->_log = $log; + $this->log = $log; } /** diff --git a/lib/Froxlor/Dns/Dns.php b/lib/Froxlor/Dns/Dns.php index 444d6ee7..77a7cf51 100644 --- a/lib/Froxlor/Dns/Dns.php +++ b/lib/Froxlor/Dns/Dns.php @@ -7,7 +7,7 @@ use Froxlor\Settings; class Dns { - public static function getAllowedDomainEntry($domain_id, $area = 'customer', $userinfo) + public static function getAllowedDomainEntry($domain_id, $area = 'customer', $userinfo = array()) { $dom_data = array( 'did' => $domain_id @@ -321,7 +321,7 @@ class Dns return $zone; } - private static function addRequiredEntry($record = '@', $type = 'A', &$required) + private static function addRequiredEntry($record = '@', $type = 'A', &$required = array()) { if (! isset($required[$type])) { $required[$type] = array(); diff --git a/lib/Froxlor/Dns/PowerDNS.php b/lib/Froxlor/Dns/PowerDNS.php index ece8b214..b8ba6692 100644 --- a/lib/Froxlor/Dns/PowerDNS.php +++ b/lib/Froxlor/Dns/PowerDNS.php @@ -134,4 +134,4 @@ class PowerDNS )); } } -} \ No newline at end of file +} diff --git a/lib/Froxlor/Domain/Domain.php b/lib/Froxlor/Domain/Domain.php index bb3bfcc6..97940ff4 100644 --- a/lib/Froxlor/Domain/Domain.php +++ b/lib/Froxlor/Domain/Domain.php @@ -332,4 +332,4 @@ class Domain } return ''; } -} \ No newline at end of file +} diff --git a/lib/Froxlor/Domain/IpAddr.php b/lib/Froxlor/Domain/IpAddr.php index 2037970f..62f9fea4 100644 --- a/lib/Froxlor/Domain/IpAddr.php +++ b/lib/Froxlor/Domain/IpAddr.php @@ -80,4 +80,4 @@ class IpAddr '' => $lng['panel']['none_value'] ) + self::getIpPortCombinations(true); } -} \ No newline at end of file +} diff --git a/lib/Froxlor/FileDir.php b/lib/Froxlor/FileDir.php index 9590b2bf..ffad0c9f 100644 --- a/lib/Froxlor/FileDir.php +++ b/lib/Froxlor/FileDir.php @@ -494,7 +494,7 @@ class FileDir }; // create RecursiveIteratorIterator - $its = new \RecursiveIteratorIterator(new \RecursiveCallbackFilterIterator(new IgnorantRecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), $filter)); + $its = new \RecursiveIteratorIterator(new \RecursiveCallbackFilterIterator(new System\IgnorantRecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), $filter)); // we can limit the recursion-depth, but will it be helpful or // will people start asking "why do I only see 2 subdirectories, i want to use /a/b/c" // let's keep this in mind and see whether it will be useful @@ -595,11 +595,12 @@ class FileDir } // Fetch all quota in the desired partition + $repquota = array(); exec(Settings::Get('system.diskquota_repquota_path') . " " . $repquota_params . " " . escapeshellarg(Settings::Get('system.diskquota_customer_partition')), $repquota); $usedquota = array(); foreach ($repquota as $tmpquota) { - + $matches = null; // Let's see if the line matches a quota - line if (preg_match($quota_line_regex, $tmpquota, $matches)) { @@ -626,22 +627,3 @@ class FileDir return false; } } - -/** - * If you use RecursiveDirectoryIterator with RecursiveIteratorIterator and run - * into UnexpectedValueException you may use this little hack to ignore those - * directories, such as lost+found on linux. - * (User "antennen" @ http://php.net/manual/en/class.recursivedirectoryiterator.php#101654) - */ -class IgnorantRecursiveDirectoryIterator extends \RecursiveDirectoryIterator -{ - - function getChildren() - { - try { - return new IgnorantRecursiveDirectoryIterator($this->getPathname()); - } catch (\UnexpectedValueException $e) { - return new \RecursiveArrayIterator(array()); - } - } -} diff --git a/lib/Froxlor/Froxlor.php b/lib/Froxlor/Froxlor.php index b48b9205..23db6ff3 100644 --- a/lib/Froxlor/Froxlor.php +++ b/lib/Froxlor/Froxlor.php @@ -234,7 +234,7 @@ final class Froxlor // if B matches A to this depth, compare the values if ($aVal > $b[$depth]) { return 1; // A > B - } else if ($aVal < $b[$depth]) { + } elseif ($aVal < $b[$depth]) { return - 1; // B > A } // an equal result is inconclusive at this point @@ -259,13 +259,13 @@ final class Froxlor $arr[] = '2'; // rc > dev > svn // number of rc $arr[] = substr($x[1], 2); - } else if (stripos($x[1], 'dev') !== false) { + } elseif (stripos($x[1], 'dev') !== false) { $arr[] = '-1'; $arr[] = '1'; // svn < dev < rc // number of dev $arr[] = substr($x[1], 3); } // -svn version are deprecated - else if (stripos($x[1], 'svn') !== false) { + elseif (stripos($x[1], 'svn') !== false) { $arr[] = '-1'; $arr[] = '0'; // svn < dev < rc // number of svn diff --git a/lib/Froxlor/FroxlorLogger.php b/lib/Froxlor/FroxlorLogger.php index c4182349..16d30f23 100644 --- a/lib/Froxlor/FroxlorLogger.php +++ b/lib/Froxlor/FroxlorLogger.php @@ -116,8 +116,8 @@ class FroxlorLogger echo "[" . $this->getLogLevelDesc($type) . "] " . $text . PHP_EOL; } - if (Settings::Get('logger.log_cron') == '0' && $action == CRON_ACTION && $type > LOG_WARNING) // warnings, errors and critical mesages WILL be logged - { + // warnings, errors and critical mesages WILL be logged + if (Settings::Get('logger.log_cron') == '0' && $action == CRON_ACTION && $type > LOG_WARNING) { return; } diff --git a/lib/Froxlor/Http/Directory.php b/lib/Froxlor/Http/Directory.php index 742fd360..ce7327c8 100644 --- a/lib/Froxlor/Http/Directory.php +++ b/lib/Froxlor/Http/Directory.php @@ -36,7 +36,7 @@ class Directory * * @var string */ - private $_dir = null; + private $dir = null; /** * class constructor, optionally set directory @@ -45,7 +45,7 @@ class Directory */ public function __construct($dir = null) { - $this->_dir = $dir; + $this->dir = $dir; } /** @@ -57,7 +57,7 @@ class Directory SELECT COUNT(`id`) as `usropts` FROM `" . TABLE_PANEL_HTACCESS . "` WHERE `path` = :dir "); $uo_res = Database::pexecute_first($uo_stmt, array( - 'dir' => FileDir::makeCorrectDir($this->_dir) + 'dir' => FileDir::makeCorrectDir($this->dir) )); if ($uo_res != false && isset($uo_res['usropts'])) { return ($uo_res['usropts'] > 0 ? true : false); @@ -74,7 +74,7 @@ class Directory SELECT COUNT(`id`) as `usrprot` FROM `" . TABLE_PANEL_HTPASSWDS . "` WHERE `path` = :dir "); $up_res = Database::pexecute_first($up_stmt, array( - 'dir' => FileDir::makeCorrectDir($this->_dir) + 'dir' => FileDir::makeCorrectDir($this->dir) )); if ($up_res != false && isset($up_res['usrprot'])) { return ($up_res['usrprot'] > 0 ? true : false); @@ -93,20 +93,20 @@ class Directory */ public function isConfigDir($ifexists = false) { - if (is_null($this->_dir)) { + if (is_null($this->dir)) { trigger_error(__CLASS__ . '::' . __FUNCTION__ . ' has been called with a null value', E_USER_WARNING); return false; } - if (file_exists($this->_dir)) { - if (is_dir($this->_dir)) { + if (file_exists($this->dir)) { + if (is_dir($this->dir)) { $returnval = true; } else { $returnval = false; } } else { if (! $ifexists) { - if (substr($this->_dir, - 1) == '/') { + if (substr($this->dir, - 1) == '/') { $returnval = true; } else { $returnval = false; diff --git a/lib/Froxlor/Http/LetsEncrypt/LeScript.php b/lib/Froxlor/Http/LetsEncrypt/LeScript.php index 5b6d7d05..9626069a 100644 --- a/lib/Froxlor/Http/LetsEncrypt/LeScript.php +++ b/lib/Froxlor/Http/LetsEncrypt/LeScript.php @@ -107,7 +107,7 @@ class LeScript $response = $this->postNewReg(); if ($this->client->getLastCode() == 409) { $this->log('The key was already registered. Using existing account.'); - } else if ($this->client->getLastCode() == 201) { + } elseif ($this->client->getLastCode() == 201) { $this->log('New account registered.'); } else { throw new \RuntimeException("Account not initialized, probably due to rate limiting. Whole response: " . json_encode($response)); @@ -302,7 +302,7 @@ class LeScript $this->log("Certificate generation pending, sleeping 1s"); sleep(1); - } else if ($this->client->getLastCode() == 200) { + } elseif ($this->client->getLastCode() == 200) { $this->log("Got certificate! YAY!"); $certificates[] = $this->parsePemFromBody($result); diff --git a/lib/Froxlor/Http/LetsEncrypt/LeScript_v2.php b/lib/Froxlor/Http/LetsEncrypt/LeScriptV2.php similarity index 95% rename from lib/Froxlor/Http/LetsEncrypt/LeScript_v2.php rename to lib/Froxlor/Http/LetsEncrypt/LeScriptV2.php index a2d13de6..290cf8d9 100644 --- a/lib/Froxlor/Http/LetsEncrypt/LeScript_v2.php +++ b/lib/Froxlor/Http/LetsEncrypt/LeScriptV2.php @@ -31,7 +31,7 @@ use Froxlor\Settings; // This file is copied from https://github.com/analogic/lescript // and modified to work without files and integrate in Froxlor -class LeScript_v2 +class LeScriptV2 { // https://letsencrypt.org/repository/ @@ -49,9 +49,9 @@ class LeScript_v2 private $version; - private $_req_uris = array(); + private $req_uris = array(); - private $_acc_location = null; + private $acc_location = null; public function __construct($logger, $version = '2') { @@ -67,10 +67,10 @@ class LeScript_v2 // get request-uris from /directory $response = $this->client->get('/directory'); - $this->_req_uris['newAccount'] = $response['newAccount']; - $this->_req_uris['newOrder'] = $response['newOrder']; - $this->_req_uris['newNonce'] = $response['newNonce']; - $this->_req_uris['revokeCert'] = $response['revokeCert']; + $this->req_uris['newAccount'] = $response['newAccount']; + $this->req_uris['newOrder'] = $response['newOrder']; + $this->req_uris['newNonce'] = $response['newNonce']; + $this->req_uris['revokeCert'] = $response['revokeCert']; } public function initAccount($certrow, $isFroxlorVhost = false) @@ -80,7 +80,7 @@ class LeScript_v2 $this->customerId = (! $isFroxlorVhost ? $certrow['customerid'] : null); $this->isFroxlorVhost = $isFroxlorVhost; $this->isLeProduction = (Settings::Get('system.letsencryptca') == 'production'); - $this->_acc_location = $certrow['leaccount']; + $this->acc_location = $certrow['leaccount']; $leregistered = $certrow['leregistered']; @@ -124,7 +124,7 @@ class LeScript_v2 } else { throw new \RuntimeException("Account not initialized, probably due to rate limiting. Whole response: " . json_encode($response)); } - $this->_acc_location = $this->client->getLastLocation(); + $this->acc_location = $this->client->getLastLocation(); $leregistered = 1; $this->setLeRegisteredState($leregistered); @@ -165,13 +165,13 @@ class LeScript_v2 } // Send new-order request - $response = $this->signedRequest($this->_req_uris['newOrder'], array( + $response = $this->signedRequest($this->req_uris['newOrder'], array( "identifiers" => $domains_in_order ), false); if ($this->client->getLastCode() == 403) { $this->log("Got status 403 - setting LE status to unregistered."); - $this->_acc_location = ''; + $this->acc_location = ''; $this->setLeRegisteredState(0); throw new \RuntimeException("Got 'unauthorized' response - we need to re-register at next run. Whole response: " . json_encode($response)); } @@ -353,12 +353,12 @@ class LeScript_v2 if ($this->isLeProduction) { if ($this->isFroxlorVhost) { Settings::Set('system.leregistered', $state); - Settings::Set('system.leaccount', $this->_acc_location); + Settings::Set('system.leaccount', $this->acc_location); } else { $upd_stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `leregistered` = :registered, `leaccount` = :kid WHERE `customerid` = :customerid;"); Database::pexecute($upd_stmt, array( 'registered' => $state, - 'kid' => $this->_acc_location, + 'kid' => $this->acc_location, 'customerid' => $this->customerId )); } @@ -380,7 +380,7 @@ class LeScript_v2 } $this->log('Sending registration to letsencrypt server'); - return $this->signedRequest($this->_req_uris['newAccount'], array( + return $this->signedRequest($this->req_uris['newAccount'], array( 'termsOfServiceAgreed' => true )); } @@ -467,7 +467,7 @@ keyUsage = nonRepudiation, digitalSignature, keyEncipherment'); ); } else { // need account-url - $header["kid"] = $this->_acc_location; + $header["kid"] = $this->acc_location; } $protected = $header; diff --git a/lib/Froxlor/Http/PhpConfig.php b/lib/Froxlor/Http/PhpConfig.php index cfb0dd52..ff7550ea 100644 --- a/lib/Froxlor/Http/PhpConfig.php +++ b/lib/Froxlor/Http/PhpConfig.php @@ -32,4 +32,4 @@ class PhpConfig } return $configs_array; } -} \ No newline at end of file +} diff --git a/lib/Froxlor/System/Cronjob.php b/lib/Froxlor/System/Cronjob.php index ce939cbb..1920feee 100644 --- a/lib/Froxlor/System/Cronjob.php +++ b/lib/Froxlor/System/Cronjob.php @@ -242,50 +242,50 @@ class Cronjob // rebuilding webserver-configuration if ($row['type'] == '1') { $task_desc = $lng['tasks']['rebuild_webserverconfig']; - } // adding new user/ - elseif ($row['type'] == '2') { + } elseif ($row['type'] == '2') { + // adding new user/ $loginname = ''; if (is_array($row['data'])) { $loginname = $row['data']['loginname']; } $task_desc = $lng['tasks']['adding_customer']; $task_desc = str_replace('%loginname%', $loginname, $task_desc); - } // rebuilding bind-configuration - elseif ($row['type'] == '4') { + } elseif ($row['type'] == '4') { + // rebuilding bind-configuration $task_desc = $lng['tasks']['rebuild_bindconfig']; - } // creating ftp-user directory - elseif ($row['type'] == '5') { + } elseif ($row['type'] == '5') { + // creating ftp-user directory $task_desc = $lng['tasks']['creating_ftpdir']; - } // deleting user-files - elseif ($row['type'] == '6') { + } elseif ($row['type'] == '6') { + // deleting user-files $loginname = ''; if (is_array($row['data'])) { $loginname = $row['data']['loginname']; } $task_desc = $lng['tasks']['deleting_customerfiles']; $task_desc = str_replace('%loginname%', $loginname, $task_desc); - } // deleting email-account - elseif ($row['type'] == '7') { + } elseif ($row['type'] == '7') { + // deleting email-account $task_desc = $lng['tasks']['remove_emailacc_files']; - } // deleting ftp-account - elseif ($row['type'] == '8') { + } elseif ($row['type'] == '8') { + // deleting ftp-account $task_desc = $lng['tasks']['remove_ftpacc_files']; - } // Set FS - quota - elseif ($row['type'] == '10') { + } elseif ($row['type'] == '10') { + // Set FS - quota $task_desc = $lng['tasks']['diskspace_set_quota']; - } // deleting user-files - elseif ($row['type'] == '20') { + } elseif ($row['type'] == '20') { + // deleting user-files $loginname = ''; if (is_array($row['data'])) { $loginname = $row['data']['loginname']; } $task_desc = $lng['tasks']['backup_customerfiles']; $task_desc = str_replace('%loginname%', $loginname, $task_desc); - } // re-generating of cron.d-file - elseif ($row['type'] == '99') { + } elseif ($row['type'] == '99') { + // re-generating of cron.d-file $task_desc = $lng['tasks']['regenerating_crond']; - } // unknown - else { + } else { + // unknown $task_desc = "ERROR: Unknown task type '" . $row['type'] . "'"; } diff --git a/lib/Froxlor/System/Crypt.php b/lib/Froxlor/System/Crypt.php index 383a30f5..a88b4c34 100644 --- a/lib/Froxlor/System/Crypt.php +++ b/lib/Froxlor/System/Crypt.php @@ -20,24 +20,24 @@ class Crypt $special = Settings::Get('panel.password_special_char'); $length = Settings::Get('panel.password_min_length') > 3 ? Settings::Get('panel.password_min_length') : 10; - $pw = self::special_shuffle($alpha_lower); + $pw = self::specialShuffle($alpha_lower); $n = floor(($length) / 4); if (Settings::Get('panel.password_alpha_upper')) { - $pw .= mb_substr(self::special_shuffle($alpha_upper), 0, $n); + $pw .= mb_substr(self::specialShuffle($alpha_upper), 0, $n); } if (Settings::Get('panel.password_numeric')) { - $pw .= mb_substr(self::special_shuffle($numeric), 0, $n); + $pw .= mb_substr(self::specialShuffle($numeric), 0, $n); } if (Settings::Get('panel.password_special_char_required') && ! $isSalt) { - $pw .= mb_substr(self::special_shuffle($special), 0, $n); + $pw .= mb_substr(self::specialShuffle($special), 0, $n); } $pw = mb_substr($pw, - $length); - return self::special_shuffle($pw); + return self::specialShuffle($pw); } /** @@ -47,7 +47,7 @@ class Crypt * * @return string */ - private static function special_shuffle($str = null) + private static function specialShuffle($str = null) { $len = mb_strlen($str); $sploded = array(); diff --git a/lib/Froxlor/System/IgnorantRecursiveDirectoryIterator.php b/lib/Froxlor/System/IgnorantRecursiveDirectoryIterator.php new file mode 100644 index 00000000..97f8a6ba --- /dev/null +++ b/lib/Froxlor/System/IgnorantRecursiveDirectoryIterator.php @@ -0,0 +1,21 @@ +getPathname()); + } catch (\UnexpectedValueException $e) { + return new \RecursiveArrayIterator(array()); + } + } +} diff --git a/lib/Froxlor/System/Mailer.php b/lib/Froxlor/System/Mailer.php index e4e015bb..56b8930f 100644 --- a/lib/Froxlor/System/Mailer.php +++ b/lib/Froxlor/System/Mailer.php @@ -40,4 +40,4 @@ class Mailer extends \PHPMailer\PHPMailer\PHPMailer } } } -} \ No newline at end of file +} diff --git a/lib/Froxlor/UI/Data.php b/lib/Froxlor/UI/Data.php index 0a278857..a32ffa31 100644 --- a/lib/Froxlor/UI/Data.php +++ b/lib/Froxlor/UI/Data.php @@ -60,4 +60,4 @@ class Data return $newfieldvalue; } -} \ No newline at end of file +} diff --git a/lib/Froxlor/UI/Fields.php b/lib/Froxlor/UI/Fields.php index 76c1f2f7..c138538a 100644 --- a/lib/Froxlor/UI/Fields.php +++ b/lib/Froxlor/UI/Fields.php @@ -105,4 +105,4 @@ class Fields eval("\$returnvalue = \"" . \Froxlor\UI\Template::getTemplate("formfields/bool", true) . "\";"); return $returnvalue; } -} \ No newline at end of file +} diff --git a/lib/Froxlor/UI/Form.php b/lib/Froxlor/UI/Form.php index 027169c7..d9242475 100644 --- a/lib/Froxlor/UI/Form.php +++ b/lib/Froxlor/UI/Form.php @@ -45,8 +45,8 @@ class Form if (isset($groupdetails['title']) && $groupdetails['title'] != '') { $fields .= self::getFormOverviewGroupOutput($groupname, $groupdetails); } - } // only show one section - elseif ($part != '' && ($groupname == $part || $part == 'all')) { + } elseif ($part != '' && ($groupname == $part || $part == 'all')) { + // only show one section /** * this part checks for the 'websrv_avail' entry in the settings-array * if found, we check if the current webserver is in the array. @@ -188,7 +188,7 @@ class Form } } - public static function processFormEx(&$form, &$input, $url_params = array(), $part, $settings_all, $settings_part, $only_enabledisable) + public static function processFormEx(&$form, &$input, $url_params = array(), $part = null, $settings_all = array(), $settings_part = null, $only_enabledisable = false) { if (\Froxlor\Validate\Form::validateFormDefinition($form)) { $submitted_fields = array(); diff --git a/lib/Froxlor/UI/HTML.php b/lib/Froxlor/UI/HTML.php index 1e7652e9..2ae1e534 100644 --- a/lib/Froxlor/UI/HTML.php +++ b/lib/Froxlor/UI/HTML.php @@ -126,9 +126,9 @@ class HTML */ public static function makecheckbox($name, $title, $value, $break = false, $selvalue = null, $title_trusted = false, $value_trusted = false) { - if ($selvalue !== NULL && $value == $selvalue) { + if ($selvalue !== null && $value == $selvalue) { $checked = 'checked="checked"'; - } else if (isset($_SESSION['requestData'][$name])) { + } elseif (isset($_SESSION['requestData'][$name])) { $checked = 'checked="checked"'; } else { $checked = ''; diff --git a/lib/Froxlor/UI/HtmlForm.php b/lib/Froxlor/UI/HtmlForm.php index 74ec5398..0858585c 100644 --- a/lib/Froxlor/UI/HtmlForm.php +++ b/lib/Froxlor/UI/HtmlForm.php @@ -122,7 +122,7 @@ class HtmlForm return self::textArea($fieldname, $data); break; case 'checkbox': - return self::_checkbox($fieldname, $data); + return self::checkbox($fieldname, $data); break; case 'file': return self::file($fieldname, $data); @@ -250,7 +250,7 @@ class HtmlForm * @param array $data * contains the data array */ - public static function _checkbox($fieldname = '', $data = array()) + private static function checkbox($fieldname = '', $data = array()) { // $data['value'] contains checked items $checked = array(); diff --git a/lib/Froxlor/UI/Template.php b/lib/Froxlor/UI/Template.php index 4d327ff9..338672e0 100644 --- a/lib/Froxlor/UI/Template.php +++ b/lib/Froxlor/UI/Template.php @@ -122,4 +122,4 @@ class Template } return false; } -} \ No newline at end of file +} diff --git a/lib/Froxlor/Validate/Check.php b/lib/Froxlor/Validate/Check.php index d6da9902..2115c98e 100644 --- a/lib/Froxlor/Validate/Check.php +++ b/lib/Froxlor/Validate/Check.php @@ -134,8 +134,8 @@ class Check if ($fieldname == "system_mod_fcgid_configdir") { $newdir = \Froxlor\FileDir::makeCorrectDir($newfieldvalue); $cdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.documentroot_prefix')); - } // customer-doc-prefix has changed -> check against fcgid-configdir - elseif ($fieldname == "system_documentroot_prefix") { + } elseif ($fieldname == "system_documentroot_prefix") { + // customer-doc-prefix has changed -> check against fcgid-configdir $newdir = \Froxlor\FileDir::makeCorrectDir($newfieldvalue); $cdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.mod_fcgid_configdir')); } @@ -202,4 +202,4 @@ class Check } return $returnvalue; } -} \ No newline at end of file +} diff --git a/lib/Froxlor/Validate/Form.php b/lib/Froxlor/Validate/Form.php index 7891c115..6593dfc3 100644 --- a/lib/Froxlor/Validate/Form.php +++ b/lib/Froxlor/Validate/Form.php @@ -39,4 +39,4 @@ class Form } return $returnvalue; } -} \ No newline at end of file +} diff --git a/lib/Froxlor/Validate/Form/Data.php b/lib/Froxlor/Validate/Form/Data.php index 28ec9c4b..71a2c122 100644 --- a/lib/Froxlor/Validate/Form/Data.php +++ b/lib/Froxlor/Validate/Form/Data.php @@ -338,4 +338,4 @@ class Data return $returnvalue; } -} \ No newline at end of file +} diff --git a/lib/Froxlor/Validate/Validate.php b/lib/Froxlor/Validate/Validate.php index c9786096..ff8bf780 100644 --- a/lib/Froxlor/Validate/Validate.php +++ b/lib/Froxlor/Validate/Validate.php @@ -140,10 +140,8 @@ class Validate $char_validation = '([a-z\d\_](-*[a-z\d\_])*)(\.([a-z\d\_](-*[a-z\d])*))*(\.?([a-z\d](-*[a-z\d])*))+\.([a-z\d])+'; } - if (preg_match("/^" . $char_validation . "$/i", $domainname) && // valid chars check - preg_match("/^.{1,253}$/", $domainname) && // overall length check - preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domainname)) // length of each label - { + // valid chars check && overall length check && length of each label + if (preg_match("/^" . $char_validation . "$/i", $domainname) && preg_match("/^.{1,253}$/", $domainname) && preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domainname)) { return $domainname; } } diff --git a/tests/linting.php b/tests/linting.php deleted file mode 100644 index ebc9734e..00000000 --- a/tests/linting.php +++ /dev/null @@ -1,29 +0,0 @@ -