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

@@ -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);

View File

@@ -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;
}

View File

@@ -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);
}
}

View File

@@ -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();
}
/**

View File

@@ -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;

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

@@ -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,7 +716,6 @@ 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'));
@@ -734,10 +733,8 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
}
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');
@@ -752,7 +749,6 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
}
fclose($awstats_nav_file);
fclose($awstats_nav_tpl);
}
return;
}

View File

@@ -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;
}
/**

View File

@@ -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();

View File

@@ -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());
}
}
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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'] . "'";
}

View File

@@ -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();

View File

@@ -0,0 +1,21 @@
<?php
namespace Froxlor\System;
/**
* 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
{
public function getChildren()
{
try {
return new IgnorantRecursiveDirectoryIterator($this->getPathname());
} catch (\UnexpectedValueException $e) {
return new \RecursiveArrayIterator(array());
}
}
}

View File

@@ -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();

View File

@@ -126,7 +126,7 @@ 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"';
} elseif (isset($_SESSION['requestData'][$name])) {
$checked = 'checked="checked"';

View File

@@ -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();

View File

@@ -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'));
}

View File

@@ -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;
}
}

View File

@@ -1,29 +0,0 @@
<?php
require dirname(__DIR__) . '/vendor/autoload.php';
// Includes the Functions
require \Froxlor\Froxlor::getInstallDir() . '/lib/functions/constant.formfields.php';
require \Froxlor\Froxlor::getInstallDir() . '/lib/functions/constant.logger.php';
// Includes the MySQL-Tabledefinitions etc.
require \Froxlor\Froxlor::getInstallDir() . '/lib/tables.inc.php';
$functions = get_defined_functions();
$calls = array();
foreach ($functions['user'] as $func) {
// grep for function
exec('grep -ir "'.$func.'" '.dirname(__DIR__).'/lib/', $output);
exec('grep -ir "'.$func.'" '.dirname(__DIR__).'/install/', $output);
exec('grep -ir "'.$func.'" '.dirname(__DIR__).'/actions/', $output);
exec('grep -ir "'.$func.'" '.dirname(__DIR__).'/*.php', $output);
echo "***********************************************".PHP_EOL;
echo "******* ". $func." ************************".PHP_EOL;
echo "***********************************************".PHP_EOL;
foreach ($output as $file) {
echo str_replace(dirname(__DIR__), "", $file) . PHP_EOL;
}
echo PHP_EOL;
$output = array();
}