more checkstyle fixes

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2018-12-24 12:02:26 +01:00
parent c3d44b4558
commit 585d42f1b8
25 changed files with 263 additions and 261 deletions

View File

@@ -175,7 +175,7 @@ abstract class BulkAction
* *
* @return array * @return array
*/ */
protected function _parseImportFile($separator = ";") protected function parseImportFile($separator = ";")
{ {
if (empty($this->impFile)) { if (empty($this->impFile)) {
throw new \Exception("No file was given for import"); throw new \Exception("No file was given for import");
@@ -223,7 +223,7 @@ abstract class BulkAction
*/ */
protected function preImport() protected function preImport()
{ {
$this->_readCustomerData(); $this->readCustomerData();
if ($this->custId <= 0) { if ($this->custId <= 0) {
throw new \Exception("Invalid customer selected"); throw new \Exception("Invalid customer selected");
@@ -239,7 +239,7 @@ abstract class BulkAction
* *
* @return bool * @return bool
*/ */
protected function _readCustomerData() protected function readCustomerData()
{ {
$cust_stmt = \Froxlor\Database\Database::prepare("SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `customerid` = :cid"); $cust_stmt = \Froxlor\Database\Database::prepare("SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `customerid` = :cid");
$this->custData = \Froxlor\Database\Database::pexecute_first($cust_stmt, array( $this->custData = \Froxlor\Database\Database::pexecute_first($cust_stmt, array(

View File

@@ -72,7 +72,7 @@ class DomainBulkAction extends BulkAction
} }
try { try {
$domain_array = $this->_parseImportFile($separator); $domain_array = $this->parseImportFile($separator);
} catch (\Exception $e) { } catch (\Exception $e) {
throw $e; throw $e;
} }

View File

@@ -147,7 +147,7 @@ class ConfigParser
* *
* @return bool * @return bool
*/ */
private function _parse() private function parse()
{ {
// We only want to parse the stuff one time // We only want to parse the stuff one time
if ($this->isparsed == true) { if ($this->isparsed == true) {
@@ -184,7 +184,7 @@ class ConfigParser
public function getServices() public function getServices()
{ {
// Let's parse this shit(!) // Let's parse this shit(!)
$this->_parse(); $this->parse();
// Return our carefully searched for services // Return our carefully searched for services
return $this->services; return $this->services;

View File

@@ -75,7 +75,7 @@ class ConfigService
$service = $this->fullxml->xpath($this->xpath); $service = $this->fullxml->xpath($this->xpath);
$attributes = $service[0]->attributes(); $attributes = $service[0]->attributes();
if ($attributes['title'] != '') { if ($attributes['title'] != '') {
$this->title = $this->_parseContent((string) $attributes['title']); $this->title = $this->parseContent((string) $attributes['title']);
} }
} }
@@ -84,7 +84,7 @@ class ConfigService
* *
* @return bool * @return bool
*/ */
private function _parse() private function parse()
{ {
// We only want to parse the stuff one time // We only want to parse the stuff one time
if ($this->isparsed == true) { if ($this->isparsed == true) {
@@ -131,9 +131,10 @@ class ConfigService
* @param string $content * @param string $content
* @return string $content w/o placeholder * @return string $content w/o placeholder
*/ */
private function _parseContent($content) private function parseContent($content)
{ {
$content = preg_replace_callback('/\{\{(.*)\}\}/Ui', function ($matches) { $content = preg_replace_callback('/\{\{(.*)\}\}/Ui', function ($matches) {
$match = null;
if (preg_match('/^settings\.(.*)$/', $matches[1], $match)) { if (preg_match('/^settings\.(.*)$/', $matches[1], $match)) {
return \Froxlor\Settings::Get($match[1]); return \Froxlor\Settings::Get($match[1]);
} elseif (preg_match('/^lng\.(.*)(?:\.(.*)(?:\.(.*)))$/U', $matches[1], $match)) { } elseif (preg_match('/^lng\.(.*)(?:\.(.*)(?:\.(.*)))$/U', $matches[1], $match)) {
@@ -153,7 +154,7 @@ class ConfigService
public function getDaemons() public function getDaemons()
{ {
$this->_parse(); $this->parse();
return $this->daemons; return $this->daemons;
} }
} }

View File

@@ -122,7 +122,7 @@ class PowerDNS extends DnsBase
return $lastid; return $lastid;
} }
private function insertRecords($domainid = 0, $records, $origin) private function insertRecords($domainid = 0, $records = array(), $origin = "")
{ {
$changedate = date('Ymds', time()); $changedate = date('Ymds', time());

View File

@@ -44,7 +44,7 @@ class Apache extends HttpConfigBase
* *
* @var bool * @var bool
*/ */
private $_deactivated = false; private $deactivated = false;
public function reload() public function reload()
{ {
@@ -73,7 +73,7 @@ class Apache extends HttpConfigBase
/** /**
* define a standard <Directory>-statement, bug #32 * define a standard <Directory>-statement, bug #32
*/ */
private function _createStandardDirectoryEntry() private function createStandardDirectoryEntry()
{ {
$vhosts_folder = ''; $vhosts_folder = '';
if (is_dir(Settings::Get('system.apacheconf_vhost'))) { if (is_dir(Settings::Get('system.apacheconf_vhost'))) {
@@ -119,7 +119,7 @@ class Apache extends HttpConfigBase
/** /**
* define a default ErrorDocument-statement, bug #unknown-yet * define a default ErrorDocument-statement, bug #unknown-yet
*/ */
private function _createStandardErrorHandler() private function createStandardErrorHandler()
{ {
if (Settings::Get('defaultwebsrverrhandler.enabled') == '1' && (Settings::Get('defaultwebsrverrhandler.err401') != '' || Settings::Get('defaultwebsrverrhandler.err403') != '' || Settings::Get('defaultwebsrverrhandler.err404') != '' || Settings::Get('defaultwebsrverrhandler.err500') != '')) { if (Settings::Get('defaultwebsrverrhandler.enabled') == '1' && (Settings::Get('defaultwebsrverrhandler.err401') != '' || Settings::Get('defaultwebsrverrhandler.err403') != '' || Settings::Get('defaultwebsrverrhandler.err404') != '' || Settings::Get('defaultwebsrverrhandler.err500') != '')) {
$vhosts_folder = ''; $vhosts_folder = '';
@@ -539,12 +539,12 @@ class Apache extends HttpConfigBase
/** /**
* bug #32 * bug #32
*/ */
$this->_createStandardDirectoryEntry(); $this->createStandardDirectoryEntry();
/** /**
* bug #unknown-yet * bug #unknown-yet
*/ */
$this->_createStandardErrorHandler(); $this->createStandardErrorHandler();
} }
/** /**
@@ -666,10 +666,10 @@ class Apache extends HttpConfigBase
$webroot_text .= ' allow from all' . "\n"; $webroot_text .= ' allow from all' . "\n";
} }
$webroot_text .= ' </Directory>' . "\n"; $webroot_text .= ' </Directory>' . "\n";
$this->_deactivated = true; $this->deactivated = true;
} else { } else {
$webroot_text .= ' DocumentRoot "' . $domain['documentroot'] . "\"\n"; $webroot_text .= ' DocumentRoot "' . $domain['documentroot'] . "\"\n";
$this->_deactivated = false; $this->deactivated = false;
} }
return $webroot_text; return $webroot_text;
@@ -1049,7 +1049,7 @@ class Apache extends HttpConfigBase
\Froxlor\FileDir::mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true, true); \Froxlor\FileDir::mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true, true);
$vhost_content .= $this->getWebroot($domain); $vhost_content .= $this->getWebroot($domain);
if ($this->_deactivated == false) { if ($this->deactivated == false) {
$vhost_content .= $this->composePhpOptions($domain, $ssl_vhost); $vhost_content .= $this->composePhpOptions($domain, $ssl_vhost);
$vhost_content .= $this->getStats($domain); $vhost_content .= $this->getStats($domain);
} }

View File

@@ -40,28 +40,28 @@ class ConfigIO
{ {
// old error logs // old error logs
$this->_cleanErrLogs(); $this->cleanErrLogs();
// awstats files // awstats files
$this->_cleanAwstatsFiles(); $this->cleanAwstatsFiles();
// fcgid files // fcgid files
$this->_cleanFcgidFiles(); $this->cleanFcgidFiles();
// php-fpm files // php-fpm files
$this->_cleanFpmFiles(); $this->cleanFpmFiles();
// clean webserver-configs // clean webserver-configs
$this->_cleanWebserverConfigs(); $this->cleanWebserverConfigs();
// old htpasswd files // old htpasswd files
$this->_cleanHtpasswdFiles(); $this->cleanHtpasswdFiles();
// customer-specified ssl-certificates // customer-specified ssl-certificates
$this->_cleanCustomerSslCerts(); $this->cleanCustomerSslCerts();
} }
private function _cleanErrLogs() private function cleanErrLogs()
{ {
$err_dir = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir() . "/logs/"); $err_dir = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir() . "/logs/");
if (@is_dir($err_dir)) { if (@is_dir($err_dir)) {
@@ -78,7 +78,7 @@ class ConfigIO
* *
* @return null * @return null
*/ */
private function _cleanCustomerSslCerts() private function cleanCustomerSslCerts()
{ {
/* /*
@@ -86,7 +86,7 @@ class ConfigIO
*/ */
if (Settings::Get('system.use_ssl') == '1') { if (Settings::Get('system.use_ssl') == '1') {
// get correct directory // get correct directory
$configdir = $this->_getFile('system', 'customer_ssl_path'); $configdir = $this->getFile('system', 'customer_ssl_path');
if ($configdir !== false) { if ($configdir !== false) {
$configdir = \Froxlor\FileDir::makeCorrectDir($configdir); $configdir = \Froxlor\FileDir::makeCorrectDir($configdir);
@@ -106,16 +106,16 @@ class ConfigIO
* *
* @return null * @return null
*/ */
private function _cleanWebserverConfigs() private function cleanWebserverConfigs()
{ {
// get directories // get directories
$configdirs = array(); $configdirs = array();
$dir = $this->_getFile('system', 'apacheconf_vhost'); $dir = $this->getFile('system', 'apacheconf_vhost');
if ($dir !== false) if ($dir !== false)
$configdirs[] = \Froxlor\FileDir::makeCorrectDir($dir); $configdirs[] = \Froxlor\FileDir::makeCorrectDir($dir);
$dir = $this->_getFile('system', 'apacheconf_diroptions'); $dir = $this->getFile('system', 'apacheconf_diroptions');
if ($dir !== false) if ($dir !== false)
$configdirs[] = \Froxlor\FileDir::makeCorrectDir($dir); $configdirs[] = \Froxlor\FileDir::makeCorrectDir($dir);
@@ -149,11 +149,11 @@ class ConfigIO
* *
* @return null * @return null
*/ */
private function _cleanHtpasswdFiles() private function cleanHtpasswdFiles()
{ {
// get correct directory // get correct directory
$configdir = $this->_getFile('system', 'apacheconf_htpasswddir'); $configdir = $this->getFile('system', 'apacheconf_htpasswddir');
if ($configdir !== false) { if ($configdir !== false) {
$configdir = \Froxlor\FileDir::makeCorrectDir($configdir); $configdir = \Froxlor\FileDir::makeCorrectDir($configdir);
@@ -172,7 +172,7 @@ class ConfigIO
* *
* @return null * @return null
*/ */
private function _cleanAwstatsFiles() private function cleanAwstatsFiles()
{ {
if (Settings::Get('system.awstats_enabled') == '0') { if (Settings::Get('system.awstats_enabled') == '0') {
return; return;
@@ -182,7 +182,7 @@ class ConfigIO
$awstatsclean = array(); $awstatsclean = array();
$awstatsclean['header'] = "## GENERATED BY FROXLOR\n"; $awstatsclean['header'] = "## GENERATED BY FROXLOR\n";
$awstatsclean['headerold'] = "## GENERATED BY SYSCP\n"; $awstatsclean['headerold'] = "## GENERATED BY SYSCP\n";
$awstatsclean['path'] = $this->_getFile('system', 'awstats_conf'); $awstatsclean['path'] = $this->getFile('system', 'awstats_conf');
/** /**
* don't do anything if the directory does not exist * don't do anything if the directory does not exist
@@ -218,14 +218,14 @@ class ConfigIO
* *
* @return null * @return null
*/ */
private function _cleanFcgidFiles() private function cleanFcgidFiles()
{ {
if (Settings::Get('system.mod_fcgid') == '0') { if (Settings::Get('system.mod_fcgid') == '0') {
return; return;
} }
// get correct directory // get correct directory
$configdir = $this->_getFile('system', 'mod_fcgid_configdir'); $configdir = $this->getFile('system', 'mod_fcgid_configdir');
if ($configdir !== false) { if ($configdir !== false) {
$configdir = \Froxlor\FileDir::makeCorrectDir($configdir); $configdir = \Froxlor\FileDir::makeCorrectDir($configdir);
@@ -258,7 +258,7 @@ class ConfigIO
* *
* @return null * @return null
*/ */
private function _cleanFpmFiles() private function cleanFpmFiles()
{ {
if (Settings::Get('phpfpm.enabled') == '0') { if (Settings::Get('phpfpm.enabled') == '0') {
return; return;
@@ -282,7 +282,7 @@ class ConfigIO
} }
// also remove aliasconfigdir #1273 // also remove aliasconfigdir #1273
$aliasconfigdir = $this->_getFile('phpfpm', 'aliasconfigdir'); $aliasconfigdir = $this->getFile('phpfpm', 'aliasconfigdir');
if ($aliasconfigdir !== false) { if ($aliasconfigdir !== false) {
$aliasconfigdir = \Froxlor\FileDir::makeCorrectDir($aliasconfigdir); $aliasconfigdir = \Froxlor\FileDir::makeCorrectDir($aliasconfigdir);
if (@is_dir($aliasconfigdir)) { if (@is_dir($aliasconfigdir)) {
@@ -304,7 +304,7 @@ class ConfigIO
* *
* @return string|boolean complete path including filename if any or false on error * @return string|boolean complete path including filename if any or false on error
*/ */
private function _getFile($group, $varname, $check_exists = true) private function getFile($group, $varname, $check_exists = true)
{ {
// read from settings // read from settings

View File

@@ -43,7 +43,7 @@ class Lighttpd extends HttpConfigBase
* *
* @var bool * @var bool
*/ */
private $_deactivated = false; private $deactivated = false;
public function reload() public function reload()
{ {
@@ -300,13 +300,13 @@ class Lighttpd extends HttpConfigBase
/** /**
* bug #unknown-yet * bug #unknown-yet
*/ */
$this->_createStandardErrorHandler(); $this->createStandardErrorHandler();
} }
/** /**
* define a default server.error-handler-404-statement, bug #unknown-yet * define a default server.error-handler-404-statement, bug #unknown-yet
*/ */
private function _createStandardErrorHandler() private function createStandardErrorHandler()
{ {
if (Settings::Get('defaultwebsrverrhandler.enabled') == '1' && Settings::Get('defaultwebsrverrhandler.err404') != '') { if (Settings::Get('defaultwebsrverrhandler.enabled') == '1' && Settings::Get('defaultwebsrverrhandler.err404') != '') {
$vhost_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/05_froxlor_default_errorhandler.conf'); $vhost_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/05_froxlor_default_errorhandler.conf');
@@ -500,7 +500,7 @@ class Lighttpd extends HttpConfigBase
$vhost_content .= $this->getWebroot($domain, $ssl_vhost); $vhost_content .= $this->getWebroot($domain, $ssl_vhost);
if (! $only_webroot) { if (! $only_webroot) {
if ($this->_deactivated == false) { if ($this->deactivated == false) {
$vhost_content .= $this->create_htaccess($domain); $vhost_content .= $this->create_htaccess($domain);
$vhost_content .= $this->create_pathOptions($domain); $vhost_content .= $this->create_pathOptions($domain);
$vhost_content .= $this->composePhpOptions($domain); $vhost_content .= $this->composePhpOptions($domain);
@@ -870,7 +870,7 @@ class Lighttpd extends HttpConfigBase
if ($domain['deactivated'] == '1' && Settings::Get('system.deactivateddocroot') != '') { if ($domain['deactivated'] == '1' && Settings::Get('system.deactivateddocroot') != '') {
$webroot_text .= ' # Using docroot for deactivated users...' . "\n"; $webroot_text .= ' # Using docroot for deactivated users...' . "\n";
$webroot_text .= ' server.document-root = "' . \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.deactivateddocroot')) . "\"\n"; $webroot_text .= ' server.document-root = "' . \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.deactivateddocroot')) . "\"\n";
$this->_deactivated = true; $this->deactivated = true;
} else { } else {
if ($ssl === false && $domain['ssl_redirect'] == '1') { if ($ssl === false && $domain['ssl_redirect'] == '1') {
$redirect_domain = $this->idnaConvert->encode('https://' . $domain['domain']); $redirect_domain = $this->idnaConvert->encode('https://' . $domain['domain']);
@@ -889,7 +889,7 @@ class Lighttpd extends HttpConfigBase
} else { } else {
$webroot_text .= ' server.document-root = "' . \Froxlor\FileDir::makeCorrectDir($domain['documentroot']) . "\"\n"; $webroot_text .= ' server.document-root = "' . \Froxlor\FileDir::makeCorrectDir($domain['documentroot']) . "\"\n";
} }
$this->_deactivated = false; $this->deactivated = false;
} }
return $webroot_text; return $webroot_text;

View File

@@ -48,7 +48,7 @@ class Nginx extends HttpConfigBase
* *
* @var bool * @var bool
*/ */
private $_deactivated = false; private $deactivated = false;
public function __construct($nginx_server = array()) public function __construct($nginx_server = array())
{ {
@@ -91,7 +91,7 @@ class Nginx extends HttpConfigBase
/** /**
* define a default ErrorDocument-statement, bug #unknown-yet * define a default ErrorDocument-statement, bug #unknown-yet
*/ */
private function _createStandardErrorHandler() private function createStandardErrorHandler()
{ {
if (Settings::Get('defaultwebsrverrhandler.enabled') == '1' && (Settings::Get('defaultwebsrverrhandler.err401') != '' || Settings::Get('defaultwebsrverrhandler.err403') != '' || Settings::Get('defaultwebsrverrhandler.err404') != '' || Settings::Get('defaultwebsrverrhandler.err500') != '')) { if (Settings::Get('defaultwebsrverrhandler.enabled') == '1' && (Settings::Get('defaultwebsrverrhandler.err401') != '' || Settings::Get('defaultwebsrverrhandler.err403') != '' || Settings::Get('defaultwebsrverrhandler.err404') != '' || Settings::Get('defaultwebsrverrhandler.err500') != '')) {
$vhosts_folder = ''; $vhosts_folder = '';
@@ -327,7 +327,7 @@ class Nginx extends HttpConfigBase
/** /**
* standard error pages * standard error pages
*/ */
$this->_createStandardErrorHandler(); $this->createStandardErrorHandler();
} }
/** /**
@@ -510,7 +510,7 @@ class Nginx extends HttpConfigBase
$vhost_content .= $this->getLogFiles($domain); $vhost_content .= $this->getLogFiles($domain);
$vhost_content .= $this->getWebroot($domain, $ssl_vhost); $vhost_content .= $this->getWebroot($domain, $ssl_vhost);
if ($this->_deactivated == false) { if ($this->deactivated == false) {
$vhost_content = $this->mergeVhostCustom($vhost_content, $this->create_pathOptions($domain)) . "\n"; $vhost_content = $this->mergeVhostCustom($vhost_content, $this->create_pathOptions($domain)) . "\n";
$vhost_content .= $this->composePhpOptions($domain, $ssl_vhost); $vhost_content .= $this->composePhpOptions($domain, $ssl_vhost);
@@ -928,10 +928,10 @@ class Nginx extends HttpConfigBase
if ($domain['deactivated'] == '1' && Settings::Get('system.deactivateddocroot') != '') { if ($domain['deactivated'] == '1' && Settings::Get('system.deactivateddocroot') != '') {
$webroot_text .= "\t" . '# Using docroot for deactivated users...' . "\n"; $webroot_text .= "\t" . '# Using docroot for deactivated users...' . "\n";
$webroot_text .= "\t" . 'root ' . \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.deactivateddocroot')) . ';' . "\n"; $webroot_text .= "\t" . 'root ' . \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.deactivateddocroot')) . ';' . "\n";
$this->_deactivated = true; $this->deactivated = true;
} else { } else {
$webroot_text .= "\t" . 'root ' . \Froxlor\FileDir::makeCorrectDir($domain['documentroot']) . ';' . "\n"; $webroot_text .= "\t" . 'root ' . \Froxlor\FileDir::makeCorrectDir($domain['documentroot']) . ';' . "\n";
$this->_deactivated = false; $this->deactivated = false;
} }
$webroot_text .= "\n\t" . 'location / {' . "\n"; $webroot_text .= "\n\t" . 'location / {' . "\n";

View File

@@ -145,7 +145,7 @@ class Fcgid
$openbasedirc = ';'; $openbasedirc = ';';
} }
$admin = $this->_getAdminData($this->_domain['adminid']); $admin = $this->getAdminData($this->_domain['adminid']);
$php_ini_variables = array( $php_ini_variables = array(
'SAFE_MODE' => 'Off', // keep this for compatibility, just in case 'SAFE_MODE' => 'Off', // keep this for compatibility, just in case
'PEAR_DIR' => Settings::Get('system.mod_fcgid_peardir'), 'PEAR_DIR' => Settings::Get('system.mod_fcgid_peardir'),
@@ -248,7 +248,7 @@ class Fcgid
* *
* @return array * @return array
*/ */
private function _getAdminData($adminid) private function getAdminData($adminid)
{ {
$adminid = intval($adminid); $adminid = intval($adminid);

View File

@@ -63,11 +63,11 @@ class Fpm
$domain['fpm_config_id'] = 1; $domain['fpm_config_id'] = 1;
} }
$this->_domain = $domain; $this->_domain = $domain;
$this->_readFpmConfig($domain['fpm_config_id']); $this->readFpmConfig($domain['fpm_config_id']);
$this->_buildIniMapping(); $this->buildIniMapping();
} }
private function _buildIniMapping() private function buildIniMapping()
{ {
$this->_ini = array( $this->_ini = array(
'php_flag' => explode("\n", Settings::Get('phpfpm.ini_flags')), 'php_flag' => explode("\n", Settings::Get('phpfpm.ini_flags')),
@@ -77,7 +77,7 @@ class Fpm
); );
} }
private function _readFpmConfig($fpm_config_id) private function readFpmConfig($fpm_config_id)
{ {
$stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` WHERE `id` = :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(
@@ -220,7 +220,7 @@ class Fpm
$fpm_config .= 'php_admin_value[session.save_path] = ' . \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"; $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( $php_ini_variables = array(
'SAFE_MODE' => 'Off', // keep this for compatibility, just in case 'SAFE_MODE' => 'Off', // keep this for compatibility, just in case
'PEAR_DIR' => Settings::Get('phpfpm.peardir'), 'PEAR_DIR' => Settings::Get('phpfpm.peardir'),
@@ -393,7 +393,7 @@ pm.max_children = 1
* *
* @return array * @return array
*/ */
private function _getAdminData($adminid) private function getAdminData($adminid)
{ {
$adminid = intval($adminid); $adminid = intval($adminid);

View File

@@ -52,7 +52,7 @@ class PhpInterface
public function __construct($domain) public function __construct($domain)
{ {
$this->_domain = $domain; $this->_domain = $domain;
$this->_setInterface(); $this->setInterface();
} }
/** /**
@@ -69,7 +69,7 @@ class PhpInterface
* php-interface: fcgid or php-fpm * php-interface: fcgid or php-fpm
* sets private $_interface variable * sets private $_interface variable
*/ */
private function _setInterface() private function setInterface()
{ {
// php-fpm // php-fpm
if ((int) Settings::Get('phpfpm.enabled') == 1) { if ((int) Settings::Get('phpfpm.enabled') == 1) {

View File

@@ -25,17 +25,17 @@ class Extrausers
// passwd // passwd
$passwd = '/var/lib/extrausers/passwd'; $passwd = '/var/lib/extrausers/passwd';
$sql = "SELECT username,'x' as password,uid,gid,'Froxlor User' as comment,homedir,shell, login_enabled FROM ftp_users ORDER BY uid ASC"; $sql = "SELECT username,'x' as password,uid,gid,'Froxlor User' as comment,homedir,shell, login_enabled FROM ftp_users ORDER BY uid ASC";
self::_generateFile($passwd, $sql, $cronlog); self::generateFile($passwd, $sql, $cronlog);
// group // group
$group = '/var/lib/extrausers/group'; $group = '/var/lib/extrausers/group';
$sql = "SELECT groupname,'x' as password,gid,members FROM ftp_groups ORDER BY gid ASC"; $sql = "SELECT groupname,'x' as password,gid,members FROM ftp_groups ORDER BY gid ASC";
self::_generateFile($group, $sql, $cronlog); self::generateFile($group, $sql, $cronlog);
// shadow // shadow
$shadow = '/var/lib/extrausers/shadow'; $shadow = '/var/lib/extrausers/shadow';
$sql = "SELECT username,password FROM ftp_users ORDER BY gid ASC"; $sql = "SELECT username,password FROM ftp_users ORDER BY gid ASC";
self::_generateFile($shadow, $sql, $cronlog); self::generateFile($shadow, $sql, $cronlog);
// set correct permissions // set correct permissions
@chmod('/var/lib/extrausers/', 0755); @chmod('/var/lib/extrausers/', 0755);
@@ -44,7 +44,7 @@ class Extrausers
@chmod('/var/lib/extrausers/shadow', 0640); @chmod('/var/lib/extrausers/shadow', 0640);
} }
private static function _generateFile($file, $query, &$cronlog) private static function generateFile($file, $query, &$cronlog)
{ {
$type = basename($file); $type = basename($file);
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Creating ' . $type . ' file'); $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Creating ' . $type . ' file');

View File

@@ -43,29 +43,29 @@ class Database
* *
* @var object * @var object
*/ */
private static $_link = null; private static $link = null;
/** /**
* indicator whether to use root-connection or not * indicator whether to use root-connection or not
*/ */
private static $_needroot = false; private static $needroot = false;
/** /**
* indicator which database-server we're on (not really used) * indicator which database-server we're on (not really used)
*/ */
private static $_dbserver = 0; private static $dbserver = 0;
/** /**
* used database-name * used database-name
*/ */
private static $_dbname = null; private static $dbname = null;
/** /**
* sql-access data * sql-access data
*/ */
private static $_needsqldata = false; private static $needsqldata = false;
private static $_sqldata = null; private static $sqldata = null;
/** /**
* Wrapper for PDOStatement::execute so we can catch the PDOException * Wrapper for PDOStatement::execute so we can catch the PDOException
@@ -82,7 +82,7 @@ class Database
try { try {
$stmt->execute($params); $stmt->execute($params);
} catch (\PDOException $e) { } catch (\PDOException $e) {
self::_showerror($e, $showerror, $json_response, $stmt); self::showerror($e, $showerror, $json_response, $stmt);
} }
} }
@@ -122,7 +122,7 @@ class Database
*/ */
public static function getDbName() public static function getDbName()
{ {
return self::$_dbname; return self::$dbname;
} }
/** /**
@@ -139,8 +139,8 @@ class Database
{ {
// force re-connecting to the db with corresponding user // force re-connecting to the db with corresponding user
// and set the $dbserver (mostly to 0 = default) // and set the $dbserver (mostly to 0 = default)
self::_setServer($dbserver); self::setServer($dbserver);
self::$_needroot = $needroot; self::$needroot = $needroot;
} }
/** /**
@@ -153,9 +153,9 @@ class Database
*/ */
public static function needSqlData() public static function needSqlData()
{ {
self::$_needsqldata = true; self::$needsqldata = true;
self::$_sqldata = array(); self::$sqldata = array();
self::$_link = null; self::$link = null;
// we need a connection here because // we need a connection here because
// if getSqlData() is called RIGHT after // if getSqlData() is called RIGHT after
// this function and no "real" PDO // this function and no "real" PDO
@@ -174,11 +174,11 @@ class Database
public static function getSqlData() public static function getSqlData()
{ {
$return = false; $return = false;
if (self::$_sqldata !== null && is_array(self::$_sqldata) && isset(self::$_sqldata['user'])) { if (self::$sqldata !== null && is_array(self::$sqldata) && isset(self::$sqldata['user'])) {
$return = self::$_sqldata; $return = self::$sqldata;
// automatically disable sql-data // automatically disable sql-data
self::$_sqldata = null; self::$sqldata = null;
self::$_needsqldata = false; self::$needsqldata = false;
} }
return $return; return $return;
} }
@@ -202,7 +202,7 @@ class Database
try { try {
$result = call_user_func_array($callback, $args); $result = call_user_func_array($callback, $args);
} catch (\PDOException $e) { } catch (\PDOException $e) {
self::_showerror($e); self::showerror($e);
} }
return $result; return $result;
} }
@@ -212,10 +212,10 @@ class Database
* *
* @param int $dbserver * @param int $dbserver
*/ */
private static function _setServer($dbserver = 0) private static function setServer($dbserver = 0)
{ {
self::$_dbserver = $dbserver; self::$dbserver = $dbserver;
self::$_link = null; self::$link = null;
} }
/** /**
@@ -229,20 +229,20 @@ class Database
private static function getDB() private static function getDB()
{ {
if (! extension_loaded('pdo') || in_array("mysql", \PDO::getAvailableDrivers()) == false) { if (! extension_loaded('pdo') || in_array("mysql", \PDO::getAvailableDrivers()) == false) {
self::_showerror(new \Exception("The php PDO extension or PDO-MySQL driver is not available")); self::showerror(new \Exception("The php PDO extension or PDO-MySQL driver is not available"));
} }
// do we got a connection already? // do we got a connection already?
if (self::$_link) { if (self::$link) {
// return it // return it
return self::$_link; return self::$link;
} }
// include userdata.inc.php // include userdata.inc.php
require \Froxlor\Froxlor::getInstallDir() . "/lib/userdata.inc.php"; require \Froxlor\Froxlor::getInstallDir() . "/lib/userdata.inc.php";
// le format // le format
if (self::$_needroot == true && isset($sql['root_user']) && isset($sql['root_password']) && (! isset($sql_root) || ! is_array($sql_root))) { if (self::$needroot == true && isset($sql['root_user']) && isset($sql['root_password']) && (! isset($sql_root) || ! is_array($sql_root))) {
$sql_root = array( $sql_root = array(
0 => array( 0 => array(
'caption' => 'Default', 'caption' => 'Default',
@@ -257,13 +257,13 @@ class Database
} }
// either root or unprivileged user // either root or unprivileged user
if (self::$_needroot) { if (self::$needroot) {
$caption = $sql_root[self::$_dbserver]['caption']; $caption = $sql_root[self::$dbserver]['caption'];
$user = $sql_root[self::$_dbserver]['user']; $user = $sql_root[self::$dbserver]['user'];
$password = $sql_root[self::$_dbserver]['password']; $password = $sql_root[self::$dbserver]['password'];
$host = $sql_root[self::$_dbserver]['host']; $host = $sql_root[self::$dbserver]['host'];
$socket = isset($sql_root[self::$_dbserver]['socket']) ? $sql_root[self::$_dbserver]['socket'] : null; $socket = isset($sql_root[self::$dbserver]['socket']) ? $sql_root[self::$dbserver]['socket'] : null;
$port = isset($sql_root[self::$_dbserver]['port']) ? $sql_root[self::$_dbserver]['port'] : '3306'; $port = isset($sql_root[self::$dbserver]['port']) ? $sql_root[self::$dbserver]['port'] : '3306';
} else { } else {
$caption = 'localhost'; $caption = 'localhost';
$user = $sql["user"]; $user = $sql["user"];
@@ -274,8 +274,8 @@ class Database
} }
// save sql-access-data if needed // save sql-access-data if needed
if (self::$_needsqldata) { if (self::$needsqldata) {
self::$_sqldata = array( self::$sqldata = array(
'user' => $user, 'user' => $user,
'passwd' => $password, 'passwd' => $password,
'host' => $host, 'host' => $host,
@@ -308,7 +308,7 @@ class Database
$dbconf["dsn"]['port'] = $port; $dbconf["dsn"]['port'] = $port;
} }
self::$_dbname = $sql["db"]; self::$dbname = $sql["db"];
// add options to dsn-string // add options to dsn-string
foreach ($dbconf["dsn"] as $k => $v) { foreach ($dbconf["dsn"] as $k => $v) {
@@ -320,25 +320,25 @@ class Database
// try to connect // try to connect
try { try {
self::$_link = new \PDO($dsn, $user, $password, $options); self::$link = new \PDO($dsn, $user, $password, $options);
} catch (\PDOException $e) { } catch (\PDOException $e) {
self::_showerror($e); self::showerror($e);
} }
// set attributes // set attributes
foreach ($attributes as $k => $v) { foreach ($attributes as $k => $v) {
self::$_link->setAttribute(constant("PDO::" . $k), constant("PDO::" . $v)); self::$link->setAttribute(constant("PDO::" . $k), constant("PDO::" . $v));
} }
$version_server = self::$_link->getAttribute(\PDO::ATTR_SERVER_VERSION); $version_server = self::$link->getAttribute(\PDO::ATTR_SERVER_VERSION);
$sql_mode = 'NO_ENGINE_SUBSTITUTION'; $sql_mode = 'NO_ENGINE_SUBSTITUTION';
if (version_compare($version_server, '8.0.11', '<')) { if (version_compare($version_server, '8.0.11', '<')) {
$sql_mode .= ',NO_AUTO_CREATE_USER'; $sql_mode .= ',NO_AUTO_CREATE_USER';
} }
self::$_link->exec('SET sql_mode = "' . $sql_mode . '"'); self::$link->exec('SET sql_mode = "' . $sql_mode . '"');
// return PDO instance // return PDO instance
return self::$_link; return self::$link;
} }
/** /**
@@ -348,7 +348,7 @@ class Database
* @param bool $showerror * @param bool $showerror
* if set to false, the error will be logged but we go on * if set to false, the error will be logged but we go on
*/ */
private static function _showerror($error, $showerror = true, $json_response = false, \PDOStatement $stmt = null) private static function showerror($error, $showerror = true, $json_response = false, \PDOStatement $stmt = null)
{ {
global $userinfo, $theme, $linker; global $userinfo, $theme, $linker;
@@ -377,9 +377,9 @@ class Database
$error_message = $error->getMessage(); $error_message = $error->getMessage();
$error_trace = $error->getTraceAsString(); $error_trace = $error->getTraceAsString();
// error-message // error-message
$error_message = self::_substitute($error_message, $substitutions); $error_message = self::substitute($error_message, $substitutions);
// error-trace // error-trace
$error_trace = self::_substitute($error_trace, $substitutions); $error_trace = self::substitute($error_trace, $substitutions);
if ($error->getCode() == 2003) { if ($error->getCode() == 2003) {
$error_message = "Unable to connect to database. Either the mysql-server is not running or your user/password is wrong."; $error_message = "Unable to connect to database. Either the mysql-server is not running or your user/password is wrong.";
@@ -471,12 +471,12 @@ class Database
* @param int $minLength * @param int $minLength
* @return string * @return string
*/ */
private static function _substitute($content, array $substitutions, $minLength = 6) private static function substitute($content, array $substitutions, $minLength = 6)
{ {
$replacements = array(); $replacements = array();
foreach ($substitutions as $search => $replace) { foreach ($substitutions as $search => $replace) {
$replacements = $replacements + self::_createShiftedSubstitutions($search, $replace, $minLength); $replacements = $replacements + self::createShiftedSubstitutions($search, $replace, $minLength);
} }
$content = str_replace(array_keys($replacements), array_values($replacements), $content); $content = str_replace(array_keys($replacements), array_values($replacements), $content);
@@ -501,7 +501,7 @@ class Database
* @param int $minLength * @param int $minLength
* @return array * @return array
*/ */
private static function _createShiftedSubstitutions($search, $replace, $minLength) private static function createShiftedSubstitutions($search, $replace, $minLength)
{ {
$substitutions = array(); $substitutions = array();
$length = strlen($search); $length = strlen($search);

View File

@@ -41,14 +41,14 @@ class DbManager
* *
* @var object * @var object
*/ */
private $_log = null; private $log = null;
/** /**
* Manager object * Manager object
* *
* @var object * @var object
*/ */
private $_manager = null; private $manager = null;
/** /**
* main constructor * main constructor
@@ -57,8 +57,8 @@ class DbManager
*/ */
public function __construct($log = null) public function __construct($log = null)
{ {
$this->_log = $log; $this->log = $log;
$this->_setManager(); $this->setManager();
} }
/** /**
@@ -98,12 +98,12 @@ class DbManager
// now create the database itself // now create the database itself
$this->getManager()->createDatabase($username); $this->getManager()->createDatabase($username);
$this->_log->logAction(USR_ACTION, LOG_INFO, "created database '" . $username . "'"); $this->log->logAction(USR_ACTION, LOG_INFO, "created database '" . $username . "'");
// and give permission to the user on every access-host we have // and give permission to the user on every access-host we have
foreach (array_map('trim', explode(',', Settings::Get('system.mysql_access_host'))) as $mysql_access_host) { foreach (array_map('trim', explode(',', Settings::Get('system.mysql_access_host'))) as $mysql_access_host) {
$this->getManager()->grantPrivilegesTo($username, $password, $mysql_access_host); $this->getManager()->grantPrivilegesTo($username, $password, $mysql_access_host);
$this->_log->logAction(USR_ACTION, LOG_NOTICE, "grant all privileges for '" . $username . "'@'" . $mysql_access_host . "'"); $this->log->logAction(USR_ACTION, LOG_NOTICE, "grant all privileges for '" . $username . "'@'" . $mysql_access_host . "'");
} }
$this->getManager()->flushPrivileges(); $this->getManager()->flushPrivileges();
@@ -119,7 +119,7 @@ class DbManager
*/ */
public function getManager() public function getManager()
{ {
return $this->_manager; return $this->manager;
} }
/** /**
@@ -128,10 +128,10 @@ class DbManager
* *
* sets private $_manager variable * sets private $_manager variable
*/ */
private function _setManager() private function setManager()
{ {
// TODO read different dbms from settings later // TODO read different dbms from settings later
$this->_manager = new \Froxlor\Database\Manager\DbManagerMySQL($this->_log); $this->manager = new \Froxlor\Database\Manager\DbManagerMySQL($this->log);
} }
public static function correctMysqlUsers($mysql_access_host_array) public static function correctMysqlUsers($mysql_access_host_array)

View File

@@ -27,7 +27,7 @@ class IntegrityCheck
public $available = array(); public $available = array();
// logger object // logger object
private $_log = null; private $log = null;
/** /**
* Constructor * Constructor
@@ -41,7 +41,7 @@ class IntegrityCheck
'loginname' => 'integrity-check' 'loginname' => 'integrity-check'
); );
} }
$this->_log = \Froxlor\FroxlorLogger::getInstanceOf($userinfo); $this->log = \Froxlor\FroxlorLogger::getInstanceOf($userinfo);
$this->available = get_class_methods($this); $this->available = get_class_methods($this);
unset($this->available[array_search('__construct', $this->available)]); unset($this->available[array_search('__construct', $this->available)]);
unset($this->available[array_search('checkAll', $this->available)]); unset($this->available[array_search('checkAll', $this->available)]);
@@ -91,7 +91,7 @@ class IntegrityCheck
)); ));
$charset = isset($resp['default_character_set_name']) ? $resp['default_character_set_name'] : null; $charset = isset($resp['default_character_set_name']) ? $resp['default_character_set_name'] : null;
if (! empty($charset) && strtolower($charset) != 'utf8') { if (! empty($charset) && strtolower($charset) != 'utf8') {
$this->_log->logAction(ADM_ACTION, LOG_NOTICE, "database charset seems to be different from UTF-8, integrity-check can fix that"); $this->log->logAction(ADM_ACTION, LOG_NOTICE, "database charset seems to be different from UTF-8, integrity-check can fix that");
if ($fix) { if ($fix) {
// fix database // fix database
Database::query('ALTER DATABASE `' . Database::getDbName() . '` CHARACTER SET utf8 COLLATE utf8_general_ci'); Database::query('ALTER DATABASE `' . Database::getDbName() . '` CHARACTER SET utf8 COLLATE utf8_general_ci');
@@ -101,7 +101,7 @@ class IntegrityCheck
$table = $row[0]; $table = $row[0];
Database::query('ALTER TABLE `' . $table . '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;'); Database::query('ALTER TABLE `' . $table . '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;');
} }
$this->_log->logAction(ADM_ACTION, LOG_WARNING, "database charset was different from UTF-8, integrity-check fixed that"); $this->log->logAction(ADM_ACTION, LOG_WARNING, "database charset was different from UTF-8, integrity-check fixed that");
} else { } else {
return false; return false;
} }
@@ -176,9 +176,9 @@ class IntegrityCheck
'domainid' => $row['id_domain'], 'domainid' => $row['id_domain'],
'ipandportid' => $row['id_ipandports'] 'ipandportid' => $row['id_ipandports']
)); ));
$this->_log->logAction(ADM_ACTION, LOG_WARNING, "found an ip/port-id in domain <> ip table which does not exist, integrity check fixed this"); $this->log->logAction(ADM_ACTION, LOG_WARNING, "found an ip/port-id in domain <> ip table which does not exist, integrity check fixed this");
} else { } else {
$this->_log->logAction(ADM_ACTION, LOG_NOTICE, "found an ip/port-id in domain <> ip table which does not exist, integrity check can fix this"); $this->log->logAction(ADM_ACTION, LOG_NOTICE, "found an ip/port-id in domain <> ip table which does not exist, integrity check can fix this");
return false; return false;
} }
} }
@@ -188,9 +188,9 @@ class IntegrityCheck
'domainid' => $row['id_domain'], 'domainid' => $row['id_domain'],
'ipandportid' => $row['id_ipandports'] 'ipandportid' => $row['id_ipandports']
)); ));
$this->_log->logAction(ADM_ACTION, LOG_WARNING, "found a domain-id in domain <> ip table which does not exist, integrity check fixed this"); $this->log->logAction(ADM_ACTION, LOG_WARNING, "found a domain-id in domain <> ip table which does not exist, integrity check fixed this");
} else { } else {
$this->_log->logAction(ADM_ACTION, LOG_NOTICE, "found a domain-id in domain <> ip table which does not exist, integrity check can fix this"); $this->log->logAction(ADM_ACTION, LOG_NOTICE, "found a domain-id in domain <> ip table which does not exist, integrity check can fix this");
return false; return false;
} }
} }
@@ -208,9 +208,9 @@ class IntegrityCheck
'ipandportid' => $defaultip 'ipandportid' => $defaultip
)); ));
} }
$this->_log->logAction(ADM_ACTION, LOG_WARNING, "found a domain-id with no entry in domain <> ip table, integrity check fixed this"); $this->log->logAction(ADM_ACTION, LOG_WARNING, "found a domain-id with no entry in domain <> ip table, integrity check fixed this");
} else { } else {
$this->_log->logAction(ADM_ACTION, LOG_NOTICE, "found a domain-id with no entry in domain <> ip table, integrity check can fix this"); $this->log->logAction(ADM_ACTION, LOG_NOTICE, "found a domain-id with no entry in domain <> ip table, integrity check can fix this");
return false; return false;
} }
} }
@@ -292,10 +292,10 @@ class IntegrityCheck
Database::pexecute($upd_stmt, array( Database::pexecute($upd_stmt, array(
'domainid' => $id 'domainid' => $id
)); ));
$this->_log->logAction(ADM_ACTION, LOG_WARNING, "found a subdomain with ssl_redirect=1 but parent-domain has ssl=0, integrity check fixed this"); $this->log->logAction(ADM_ACTION, LOG_WARNING, "found a subdomain with ssl_redirect=1 but parent-domain has ssl=0, integrity check fixed this");
} else { } else {
// It's just the check, let the function fail // It's just the check, let the function fail
$this->_log->logAction(ADM_ACTION, LOG_NOTICE, "found a subdomain with ssl_redirect=1 but parent-domain has ssl=0, integrity check can fix this"); $this->log->logAction(ADM_ACTION, LOG_NOTICE, "found a subdomain with ssl_redirect=1 but parent-domain has ssl=0, integrity check can fix this");
return false; return false;
} }
} }
@@ -376,10 +376,10 @@ class IntegrityCheck
Database::pexecute($upd_stmt, array( Database::pexecute($upd_stmt, array(
'domainid' => $id 'domainid' => $id
)); ));
$this->_log->logAction(ADM_ACTION, LOG_WARNING, "found a subdomain with letsencrypt=1 but parent-domain has ssl=0, integrity check fixed this"); $this->log->logAction(ADM_ACTION, LOG_WARNING, "found a subdomain with letsencrypt=1 but parent-domain has ssl=0, integrity check fixed this");
} else { } else {
// It's just the check, let the function fail // It's just the check, let the function fail
$this->_log->logAction(ADM_ACTION, LOG_NOTICE, "found a subdomain with letsencrypt=1 but parent-domain has ssl=0, integrity check can fix this"); $this->log->logAction(ADM_ACTION, LOG_NOTICE, "found a subdomain with letsencrypt=1 but parent-domain has ssl=0, integrity check can fix this");
return false; return false;
} }
} }
@@ -415,7 +415,7 @@ class IntegrityCheck
)); ));
if ($cwg_stmt->rowCount() > 0) { if ($cwg_stmt->rowCount() > 0) {
$this->_log->logAction(ADM_ACTION, LOG_NOTICE, "Customers are missing the webserver-user as group-member, integrity-check can fix that"); $this->log->logAction(ADM_ACTION, LOG_NOTICE, "Customers are missing the webserver-user as group-member, integrity-check can fix that");
if ($fix) { if ($fix) {
// prepare update statement // prepare update statement
$upd_stmt = Database::prepare(" $upd_stmt = Database::prepare("
@@ -430,7 +430,7 @@ class IntegrityCheck
$upd_data['id'] = $cwg_row['id']; $upd_data['id'] = $cwg_row['id'];
Database::pexecute($upd_stmt, $upd_data); Database::pexecute($upd_stmt, $upd_data);
} }
$this->_log->logAction(ADM_ACTION, LOG_NOTICE, "Customers were missing the webserver-user as group-member, integrity-check fixed that"); $this->log->logAction(ADM_ACTION, LOG_NOTICE, "Customers were missing the webserver-user as group-member, integrity-check fixed that");
} else { } else {
return false; return false;
} }
@@ -483,7 +483,7 @@ class IntegrityCheck
)); ));
if ($cwg_stmt->rowCount() > 0) { if ($cwg_stmt->rowCount() > 0) {
$this->_log->logAction(ADM_ACTION, LOG_NOTICE, "Customers are missing the local froxlor-user as group-member, integrity-check can fix that"); $this->log->logAction(ADM_ACTION, LOG_NOTICE, "Customers are missing the local froxlor-user as group-member, integrity-check can fix that");
if ($fix) { if ($fix) {
// prepare update statement // prepare update statement
$upd_stmt = Database::prepare(" $upd_stmt = Database::prepare("
@@ -498,7 +498,7 @@ class IntegrityCheck
$upd_data['id'] = $cwg_row['id']; $upd_data['id'] = $cwg_row['id'];
Database::pexecute($upd_stmt, $upd_data); Database::pexecute($upd_stmt, $upd_data);
} }
$this->_log->logAction(ADM_ACTION, LOG_NOTICE, "Customers were missing the local froxlor-user as group-member, integrity-check fixed that"); $this->log->logAction(ADM_ACTION, LOG_NOTICE, "Customers were missing the local froxlor-user as group-member, integrity-check fixed that");
} else { } else {
return false; return false;
} }

View File

@@ -217,8 +217,8 @@ final class Froxlor
$a = explode(".", $a); $a = explode(".", $a);
$b = explode(".", $b); $b = explode(".", $b);
self::_parseVersionArray($a); self::parseVersionArray($a);
self::_parseVersionArray($b); self::parseVersionArray($b);
while (count($a) != count($b)) { while (count($a) != count($b)) {
if (count($a) < count($b)) { if (count($a) < count($b)) {
@@ -248,7 +248,7 @@ final class Froxlor
return (count($a) < count($b)) ? - 1 : 0; return (count($a) < count($b)) ? - 1 : 0;
} }
private static function _parseVersionArray(&$arr = null) private static function parseVersionArray(&$arr = null)
{ {
// -svn or -dev or -rc ? // -svn or -dev or -rc ?
if (stripos($arr[count($arr) - 1], '-') !== false) { if (stripos($arr[count($arr) - 1], '-') !== false) {

View File

@@ -16,7 +16,7 @@ class FroxlorLogger
* *
* @var \Monolog\Logger * @var \Monolog\Logger
*/ */
private static $_ml = null; private static $ml = null;
/** /**
* LogTypes Array * LogTypes Array
@@ -55,10 +55,10 @@ class FroxlorLogger
switch ($logger) { switch ($logger) {
case 'syslog': case 'syslog':
self::$_ml->pushHandler(new SyslogHandler('froxlor', LOG_USER, Logger::DEBUG)); self::$ml->pushHandler(new SyslogHandler('froxlor', LOG_USER, Logger::DEBUG));
break; break;
case 'file': case 'file':
self::$_ml->pushHandler(new StreamHandler(Settings::Get('logger.logfile'), Logger::DEBUG)); self::$ml->pushHandler(new StreamHandler(Settings::Get('logger.logfile'), Logger::DEBUG));
break; break;
case 'mysql': case 'mysql':
// @fixme add MySQL-Handler // @fixme add MySQL-Handler
@@ -87,11 +87,11 @@ class FroxlorLogger
*/ */
private function initMonolog() private function initMonolog()
{ {
if (empty(self::$_ml)) { if (empty(self::$ml)) {
// get Theme object // get Theme object
self::$_ml = new Logger('froxlor'); self::$ml = new Logger('froxlor');
} }
return self::$_ml; return self::$ml;
} }
/** /**
@@ -108,7 +108,7 @@ class FroxlorLogger
return; return;
} }
if (empty(self::$_ml)) { if (empty(self::$ml)) {
$this->initMonolog(); $this->initMonolog();
} }
@@ -123,32 +123,32 @@ class FroxlorLogger
switch ($type) { switch ($type) {
case LOG_DEBUG: case LOG_DEBUG:
self::$_ml->addDebug($text, array( self::$ml->addDebug($text, array(
'source' => $this->getActionTypeDesc($action) 'source' => $this->getActionTypeDesc($action)
)); ));
break; break;
case LOG_INFO: case LOG_INFO:
self::$_ml->addInfo($text, array( self::$ml->addInfo($text, array(
'source' => $this->getActionTypeDesc($action) 'source' => $this->getActionTypeDesc($action)
)); ));
break; break;
case LOG_NOTICE: case LOG_NOTICE:
self::$_ml->addNotice($text, array( self::$ml->addNotice($text, array(
'source' => $this->getActionTypeDesc($action) 'source' => $this->getActionTypeDesc($action)
)); ));
break; break;
case LOG_WARNING: case LOG_WARNING:
self::$_ml->addWarning($text, array( self::$ml->addWarning($text, array(
'source' => $this->getActionTypeDesc($action) 'source' => $this->getActionTypeDesc($action)
)); ));
break; break;
case LOG_ERR: case LOG_ERR:
self::$_ml->addError($text, array( self::$ml->addError($text, array(
'source' => $this->getActionTypeDesc($action) 'source' => $this->getActionTypeDesc($action)
)); ));
break; break;
default: default:
self::$_ml->addDebug($text, array( self::$ml->addDebug($text, array(
'source' => $this->getActionTypeDesc($action) 'source' => $this->getActionTypeDesc($action)
)); ));
} }

View File

@@ -54,19 +54,19 @@ class MailLogParser
// Parse MTA traffic // Parse MTA traffic
if (Settings::Get("system.mtaserver") == "postfix") { if (Settings::Get("system.mtaserver") == "postfix") {
$this->_parsePostfixLog(Settings::Get("system.mtalog")); $this->parsePostfixLog(Settings::Get("system.mtalog"));
$this->_parsePostfixLog(Settings::Get("system.mtalog") . ".1"); $this->parsePostfixLog(Settings::Get("system.mtalog") . ".1");
} elseif (Settings::Get("system.mtaserver") == "exim4") { } elseif (Settings::Get("system.mtaserver") == "exim4") {
$this->_parseExim4Log(Settings::Get("system.mtalog")); $this->parseExim4Log(Settings::Get("system.mtalog"));
} }
// Parse MDA traffic // Parse MDA traffic
if (Settings::Get("system.mdaserver") == "dovecot") { if (Settings::Get("system.mdaserver") == "dovecot") {
$this->_parseDovecotLog(Settings::Get("system.mdalog")); $this->parseDovecotLog(Settings::Get("system.mdalog"));
$this->_parsePostfixLog(Settings::Get("system.mdalog") . ".1"); $this->parsePostfixLog(Settings::Get("system.mdalog") . ".1");
} elseif (Settings::Get("system.mdaserver") == "courier") { } elseif (Settings::Get("system.mdaserver") == "courier") {
$this->_parseCourierLog(Settings::Get("system.mdalog")); $this->parseCourierLog(Settings::Get("system.mdalog"));
$this->_parsePostfixLog(Settings::Get("system.mdalog") . ".1"); $this->parsePostfixLog(Settings::Get("system.mdalog") . ".1");
} }
} }
@@ -74,10 +74,10 @@ class MailLogParser
* parsePostfixLog * parsePostfixLog
* parses the traffic from a postfix logfile * parses the traffic from a postfix logfile
* *
* @param * @param string $logFile
* logFile * logFile
*/ */
private function _parsePostfixLog($logFile) private function parsePostfixLog($logFile)
{ {
// Check if file exists // Check if file exists
if (! file_exists($logFile)) { if (! file_exists($logFile)) {
@@ -99,7 +99,7 @@ class MailLogParser
unset($matches); unset($matches);
$line = fgets($file_handle); $line = fgets($file_handle);
$timestamp = $this->_getLogTimestamp($line); $timestamp = $this->getLogTimestamp($line);
if ($this->startTime < $timestamp) { if ($this->startTime < $timestamp) {
if (preg_match("/postfix\/qmgr.*(?::|\])\s([A-Z\d]+).*from=<?(?:.*\@([a-z\A-Z\d\.\-]+))?>?, size=(\d+),/", $line, $matches)) { if (preg_match("/postfix\/qmgr.*(?::|\])\s([A-Z\d]+).*from=<?(?:.*\@([a-z\A-Z\d\.\-]+))?>?, size=(\d+),/", $line, $matches)) {
// Postfix from // Postfix from
@@ -117,12 +117,12 @@ class MailLogParser
if (in_array($mail["domainFrom"], $this->myDomains) || in_array($mail["domainTo"], $this->myDomains)) { if (in_array($mail["domainFrom"], $this->myDomains) || in_array($mail["domainTo"], $this->myDomains)) {
// Outgoing traffic // Outgoing traffic
if (array_key_exists("domainFrom", $mail)) { if (array_key_exists("domainFrom", $mail)) {
$this->_addDomainTraffic($mail["domainFrom"], $mail["size"], $timestamp); $this->addDomainTraffic($mail["domainFrom"], $mail["size"], $timestamp);
} }
// Incoming traffic // Incoming traffic
if (array_key_exists("domainTo", $mail) && in_array($mail["domainTo"], $this->myDomains)) { if (array_key_exists("domainTo", $mail) && in_array($mail["domainTo"], $this->myDomains)) {
$this->_addDomainTraffic($mail["domainTo"], $mail["size"], $timestamp); $this->addDomainTraffic($mail["domainTo"], $mail["size"], $timestamp);
} }
} }
unset($mail); unset($mail);
@@ -138,10 +138,10 @@ class MailLogParser
* parseExim4Log * parseExim4Log
* parses the smtp traffic from a exim4 logfile * parses the smtp traffic from a exim4 logfile
* *
* @param * @param string $logFile
* logFile * logFile
*/ */
private function _parseExim4Log($logFile) private function parseExim4Log($logFile)
{ {
// Check if file exists // Check if file exists
if (! file_exists($logFile)) { if (! file_exists($logFile)) {
@@ -163,14 +163,14 @@ class MailLogParser
unset($matches); unset($matches);
$line = fgets($file_handle); $line = fgets($file_handle);
$timestamp = $this->_getLogTimestamp($line); $timestamp = $this->getLogTimestamp($line);
if ($this->startTime < $timestamp) { if ($this->startTime < $timestamp) {
if (preg_match("/<= .*@([a-z0-9.\-]+) .*S=(\d+)/i", $line, $matches)) { if (preg_match("/<= .*@([a-z0-9.\-]+) .*S=(\d+)/i", $line, $matches)) {
// Outgoing traffic // Outgoing traffic
$this->_addDomainTraffic($matches[1], $matches[2], $timestamp); $this->addDomainTraffic($matches[1], $matches[2], $timestamp);
} elseif (preg_match("/=> .*<?.*@([a-z0-9.\-]+)>? .*S=(\d+)/i", $line, $matches)) { } elseif (preg_match("/=> .*<?.*@([a-z0-9.\-]+)>? .*S=(\d+)/i", $line, $matches)) {
// Incoming traffic // Incoming traffic
$this->_addDomainTraffic($matches[1], $matches[2], $timestamp); $this->addDomainTraffic($matches[1], $matches[2], $timestamp);
} }
} }
} }
@@ -182,10 +182,10 @@ class MailLogParser
* parseDovecotLog * parseDovecotLog
* parses the dovecot imap/pop3 traffic from logfile * parses the dovecot imap/pop3 traffic from logfile
* *
* @param * @param string $logFile
* logFile * logFile
*/ */
private function _parseDovecotLog($logFile) private function parseDovecotLog($logFile)
{ {
// Check if file exists // Check if file exists
if (! file_exists($logFile)) { if (! file_exists($logFile)) {
@@ -207,14 +207,14 @@ class MailLogParser
unset($matches); unset($matches);
$line = fgets($file_handle); $line = fgets($file_handle);
$timestamp = $this->_getLogTimestamp($line); $timestamp = $this->getLogTimestamp($line);
if ($this->startTime < $timestamp) { if ($this->startTime < $timestamp) {
if (preg_match("/dovecot.*(?::|\]) imap\(.*@([a-z0-9\.\-]+)\):.*(?:in=(\d+) out=(\d+)|bytes=(\d+)\/(\d+))/i", $line, $matches)) { if (preg_match("/dovecot.*(?::|\]) imap\(.*@([a-z0-9\.\-]+)\):.*(?:in=(\d+) out=(\d+)|bytes=(\d+)\/(\d+))/i", $line, $matches)) {
// Dovecot IMAP // Dovecot IMAP
$this->_addDomainTraffic($matches[1], (int) $matches[2] + (int) $matches[3], $timestamp); $this->addDomainTraffic($matches[1], (int) $matches[2] + (int) $matches[3], $timestamp);
} elseif (preg_match("/dovecot.*(?::|\]) pop3\(.*@([a-z0-9\.\-]+)\):.*in=(\d+).*out=(\d+)/i", $line, $matches)) { } elseif (preg_match("/dovecot.*(?::|\]) pop3\(.*@([a-z0-9\.\-]+)\):.*in=(\d+).*out=(\d+)/i", $line, $matches)) {
// Dovecot POP3 // Dovecot POP3
$this->_addDomainTraffic($matches[1], (int) $matches[2] + (int) $matches[3], $timestamp); $this->addDomainTraffic($matches[1], (int) $matches[2] + (int) $matches[3], $timestamp);
} }
} }
} }
@@ -226,10 +226,10 @@ class MailLogParser
* parseCourierLog * parseCourierLog
* parses the dovecot imap/pop3 traffic from logfile * parses the dovecot imap/pop3 traffic from logfile
* *
* @param * @param string $logFile
* logFile * logFile
*/ */
private function _parseCourierLog($logFile) private function parseCourierLog($logFile)
{ {
// Check if file exists // Check if file exists
if (! file_exists($logFile)) { if (! file_exists($logFile)) {
@@ -251,11 +251,11 @@ class MailLogParser
unset($matches); unset($matches);
$line = fgets($file_handle); $line = fgets($file_handle);
$timestamp = $this->_getLogTimestamp($line); $timestamp = $this->getLogTimestamp($line);
if ($this->startTime < $timestamp) { if ($this->startTime < $timestamp) {
if (preg_match("/(?:imapd|pop3d)(?:-ssl)?.*(?::|\]).*user=.*@([a-z0-9\.\-]+),.*rcvd=(\d+), sent=(\d+),/i", $line, $matches)) { if (preg_match("/(?:imapd|pop3d)(?:-ssl)?.*(?::|\]).*user=.*@([a-z0-9\.\-]+),.*rcvd=(\d+), sent=(\d+),/i", $line, $matches)) {
// Courier IMAP & POP3 // Courier IMAP & POP3
$this->_addDomainTraffic($matches[1], (int) $matches[2] + (int) $matches[3], $timestamp); $this->addDomainTraffic($matches[1], (int) $matches[2] + (int) $matches[3], $timestamp);
} }
} }
} }
@@ -272,7 +272,7 @@ class MailLogParser
* @param * @param
* int traffic * int traffic
*/ */
private function _addDomainTraffic($domain, $traffic, $timestamp) private function addDomainTraffic($domain, $traffic, $timestamp)
{ {
$date = date("Y-m-d", $timestamp); $date = date("Y-m-d", $timestamp);
if (in_array($domain, $this->myDomains)) { if (in_array($domain, $this->myDomains)) {
@@ -294,8 +294,9 @@ class MailLogParser
* string line * string line
* return int * return int
*/ */
private function _getLogTimestamp($line) private function getLogTimestamp($line)
{ {
$matches = null;
if (preg_match("/((?:[A-Z]{3}\s{1,2}\d{1,2}|\d{4}-\d{2}-\d{2}) \d{2}:\d{2}:\d{2})/i", $line, $matches)) { if (preg_match("/((?:[A-Z]{3}\s{1,2}\d{1,2}|\d{4}-\d{2}-\d{2}) \d{2}:\d{2}:\d{2})/i", $line, $matches)) {
$timestamp = strtotime($matches[1]); $timestamp = strtotime($matches[1]);
if ($timestamp > ($this->startTime + 60 * 60 * 24)) { if ($timestamp > ($this->startTime + 60 * 60 * 24)) {

View File

@@ -40,7 +40,7 @@ class SImExporter
* *
* @var array * @var array
*/ */
private static $_no_export = [ private static $no_export = [
'panel.adminmail', 'panel.adminmail',
'admin.show_news_feed', 'admin.show_news_feed',
'system.lastaccountnumber', 'system.lastaccountnumber',
@@ -66,7 +66,7 @@ class SImExporter
$_data = array(); $_data = array();
while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
$index = $row['settinggroup'] . "." . $row['varname']; $index = $row['settinggroup'] . "." . $row['varname'];
if (! in_array($index, self::$_no_export)) { if (! in_array($index, self::$no_export)) {
$_data[$index] = $row['value']; $_data[$index] = $row['value'];
} }
} }

View File

@@ -41,14 +41,14 @@ class Settings
* *
* @var array * @var array
*/ */
private static $_data = null; private static $data = null;
/** /**
* changed and unsaved settings data * changed and unsaved settings data
* *
* @var array * @var array
*/ */
private static $_updatedata = null; private static $updatedata = null;
/** /**
* prepared statement for updating the * prepared statement for updating the
@@ -56,19 +56,19 @@ class Settings
* *
* @var \PDOStatement * @var \PDOStatement
*/ */
private static $_updstmt = null; private static $updstmt = null;
/** /**
* private constructor, reads in all settings * private constructor, reads in all settings
*/ */
private static function init() private static function init()
{ {
if (empty(self::$_data)) { if (empty(self::$data)) {
self::_readSettings(); self::readSettings();
self::$_updatedata = array(); self::$updatedata = array();
// prepare statement // prepare statement
self::$_updstmt = Database::prepare(" self::$updstmt = Database::prepare("
UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = :value UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = :value
WHERE `settinggroup` = :group AND `varname` = :varname WHERE `settinggroup` = :group AND `varname` = :varname
"); ");
@@ -79,15 +79,15 @@ class Settings
* Read in all settings from the database * Read in all settings from the database
* and set the internal $_data array * and set the internal $_data array
*/ */
private static function _readSettings() private static function readSettings()
{ {
$result_stmt = Database::query(" $result_stmt = Database::query("
SELECT `settingid`, `settinggroup`, `varname`, `value` SELECT `settingid`, `settinggroup`, `varname`, `value`
FROM `" . TABLE_PANEL_SETTINGS . "` FROM `" . TABLE_PANEL_SETTINGS . "`
"); ");
self::$_data = array(); self::$data = array();
while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
self::$_data[$row['settinggroup']][$row['varname']] = $row['value']; self::$data[$row['settinggroup']][$row['varname']] = $row['value'];
} }
return true; return true;
} }
@@ -99,14 +99,14 @@ class Settings
* @param string $varname * @param string $varname
* @param string $value * @param string $value
*/ */
private static function _storeSetting($group = null, $varname = null, $value = null) private static function storeSetting($group = null, $varname = null, $value = null)
{ {
$upd_data = array( $upd_data = array(
'group' => $group, 'group' => $group,
'varname' => $varname, 'varname' => $varname,
'value' => $value 'value' => $value
); );
Database::pexecute(self::$_updstmt, $upd_data); Database::pexecute(self::$updstmt, $upd_data);
} }
/** /**
@@ -126,8 +126,8 @@ class Settings
return null; return null;
} }
$result = null; $result = null;
if (isset(self::$_data[$sstr[0]][$sstr[1]])) { if (isset(self::$data[$sstr[0]][$sstr[1]])) {
$result = self::$_data[$sstr[0]][$sstr[1]]; $result = self::$data[$sstr[0]][$sstr[1]];
} }
return $result; return $result;
} }
@@ -173,21 +173,21 @@ class Settings
if (! isset($sstr[1])) { if (! isset($sstr[1])) {
return false; return false;
} }
self::$_data[$sstr[0]][$sstr[1]] = $value; self::$data[$sstr[0]][$sstr[1]] = $value;
// should we store to db instantly? // should we store to db instantly?
if ($instant_save) { if ($instant_save) {
self::_storeSetting($sstr[0], $sstr[1], $value); self::storeSetting($sstr[0], $sstr[1], $value);
} else { } else {
// set temporary data for usage // set temporary data for usage
if (! isset(self::$_data[$sstr[0]]) || ! is_array(self::$_data[$sstr[0]])) { if (! isset(self::$data[$sstr[0]]) || ! is_array(self::$data[$sstr[0]])) {
self::$_data[$sstr[0]] = array(); self::$data[$sstr[0]] = array();
} }
self::$_data[$sstr[0]][$sstr[1]] = $value; self::$data[$sstr[0]][$sstr[1]] = $value;
// set update-data when invoking Flush() // set update-data when invoking Flush()
if (! isset(self::$_updatedata[$sstr[0]]) || ! is_array(self::$_updatedata[$sstr[0]])) { if (! isset(self::$updatedata[$sstr[0]]) || ! is_array(self::$updatedata[$sstr[0]])) {
self::$_updatedata[$sstr[0]] = array(); self::$updatedata[$sstr[0]] = array();
} }
self::$_updatedata[$sstr[0]][$sstr[1]] = $value; self::$updatedata[$sstr[0]][$sstr[1]] = $value;
} }
return true; return true;
} }
@@ -227,7 +227,7 @@ class Settings
); );
Database::pexecute($ins_stmt, $ins_data); Database::pexecute($ins_stmt, $ins_data);
// also set new value to internal array and make it available // also set new value to internal array and make it available
self::$_data[$sstr[0]][$sstr[1]] = $value; self::$data[$sstr[0]][$sstr[1]] = $value;
return true; return true;
} }
return false; return false;
@@ -240,17 +240,17 @@ class Settings
public static function Flush() public static function Flush()
{ {
self::init(); self::init();
if (is_array(self::$_updatedata) && count(self::$_updatedata) > 0) { if (is_array(self::$updatedata) && count(self::$updatedata) > 0) {
// save all un-saved changes to the settings // save all un-saved changes to the settings
foreach (self::$_updatedata as $group => $vargroup) { foreach (self::$updatedata as $group => $vargroup) {
foreach ($vargroup as $varname => $value) { foreach ($vargroup as $varname => $value) {
self::_storeSetting($group, $varname, $value); self::storeSetting($group, $varname, $value);
} }
} }
// now empty the array // now empty the array
self::$_updatedata = array(); self::$updatedata = array();
// re-read in all settings // re-read in all settings
return self::_readSettings(); return self::readSettings();
} }
return false; return false;
} }
@@ -262,7 +262,7 @@ class Settings
{ {
self::init(); self::init();
// empty update array // empty update array
self::$_updatedata = array(); self::$updatedata = array();
} }
public static function loadSettingsInto(&$settings_data) public static function loadSettingsInto(&$settings_data)

View File

@@ -23,16 +23,16 @@ class HtmlForm
* *
* @var string * @var string
*/ */
private static $_form = ''; private static $form = '';
private static $_filename = ''; private static $filename = '';
public static function genHTMLForm($data = array()) public static function genHTMLForm($data = array())
{ {
global $lng, $theme; global $lng, $theme;
$nob = false; $nob = false;
self::$_form = ''; self::$form = '';
foreach ($data as $fdata) { foreach ($data as $fdata) {
$sections = $fdata['sections']; $sections = $fdata['sections'];
@@ -64,8 +64,8 @@ class HtmlForm
$label = $fielddata['label']; $label = $fielddata['label'];
$desc = (isset($fielddata['desc']) ? $fielddata['desc'] : ''); $desc = (isset($fielddata['desc']) ? $fielddata['desc'] : '');
$style = (isset($fielddata['style']) ? ' class="' . $fielddata['style'] . '"' : ''); $style = (isset($fielddata['style']) ? ' class="' . $fielddata['style'] . '"' : '');
$mandatory = self::_getMandatoryFlag($fielddata); $mandatory = self::getMandatoryFlag($fielddata);
$data_field = self::_parseDataField($fieldname, $fielddata); $data_field = self::parseDataField($fieldname, $fielddata);
if (isset($fielddata['has_nextto'])) { if (isset($fielddata['has_nextto'])) {
$nexto = array( $nexto = array(
'field' => $fieldname 'field' => $fieldname
@@ -76,10 +76,10 @@ class HtmlForm
} }
eval("self::\$_form .= \"" . Template::getTemplate("misc/form/table_row", "1") . "\";"); eval("self::\$_form .= \"" . Template::getTemplate("misc/form/table_row", "1") . "\";");
} else { } else {
$data_field = self::_parseDataField($fieldname, $fielddata); $data_field = self::parseDataField($fieldname, $fielddata);
$data_field = str_replace("\t", "", $data_field); $data_field = str_replace("\t", "", $data_field);
$data_field = $fielddata['next_to_prefix'] . $data_field; $data_field = $fielddata['next_to_prefix'] . $data_field;
self::$_form = str_replace('{NEXTTOFIELD_' . $fielddata['next_to'] . '}', $data_field, self::$_form); self::$form = str_replace('{NEXTTOFIELD_' . $fielddata['next_to'] . '}', $data_field, self::$form);
$nexto = false; $nexto = false;
} }
} }
@@ -91,49 +91,49 @@ class HtmlForm
eval("self::\$_form .= \"" . Template::getTemplate("misc/form/table_end", "1") . "\";"); eval("self::\$_form .= \"" . Template::getTemplate("misc/form/table_end", "1") . "\";");
} }
return self::$_form; return self::$form;
} }
private static function _parseDataField($fieldname, $data = array()) private static function parseDataField($fieldname, $data = array())
{ {
switch ($data['type']) { switch ($data['type']) {
case 'text': case 'text':
return self::_textBox($fieldname, $data); return self::textBox($fieldname, $data);
break; break;
case 'textul': case 'textul':
return self::_textBox($fieldname, $data, 'text', true); return self::textBox($fieldname, $data, 'text', true);
break; break;
case 'password': case 'password':
return self::_textBox($fieldname, $data, 'password'); return self::textBox($fieldname, $data, 'password');
break; break;
case 'hidden': case 'hidden':
return self::_textBox($fieldname, $data, 'hidden'); return self::textBox($fieldname, $data, 'hidden');
break; break;
case 'yesno': case 'yesno':
return self::_yesnoBox($data); return self::yesnoBox($data);
break; break;
case 'select': case 'select':
return self::_selectBox($fieldname, $data); return self::selectBox($fieldname, $data);
break; break;
case 'label': case 'label':
return self::_labelField($data); return self::labelField($data);
break; break;
case 'textarea': case 'textarea':
return self::_textArea($fieldname, $data); return self::textArea($fieldname, $data);
break; break;
case 'checkbox': case 'checkbox':
return self::_checkbox($fieldname, $data); return self::_checkbox($fieldname, $data);
break; break;
case 'file': case 'file':
return self::_file($fieldname, $data); return self::file($fieldname, $data);
break; break;
case 'int': case 'int':
return self::_int($fieldname, $data); return self::int($fieldname, $data);
break; break;
} }
} }
private static function _getMandatoryFlag($data = array()) private static function getMandatoryFlag($data = array())
{ {
if (isset($data['mandatory'])) { if (isset($data['mandatory'])) {
return '&nbsp;<span class="red">*</span>'; return '&nbsp;<span class="red">*</span>';
@@ -143,7 +143,7 @@ class HtmlForm
return ''; return '';
} }
private static function _textBox($fieldname = '', $data = array(), $type = 'text', $unlimited = false) private static function textBox($fieldname = '', $data = array(), $type = 'text', $unlimited = false)
{ {
$return = ''; $return = '';
$extras = ''; $extras = '';
@@ -175,7 +175,7 @@ class HtmlForm
return $return; return $return;
} }
private static function _textArea($fieldname = '', $data = array()) private static function textArea($fieldname = '', $data = array())
{ {
$return = ''; $return = '';
$extras = ''; $extras = '';
@@ -200,17 +200,17 @@ class HtmlForm
return $return; return $return;
} }
private static function _yesnoBox($data = array()) private static function yesnoBox($data = array())
{ {
return $data['yesno_var']; return $data['yesno_var'];
} }
private static function _labelField($data = array()) private static function labelField($data = array())
{ {
return $data['value']; return $data['value'];
} }
private static function _selectBox($fieldname = '', $data = array()) private static function selectBox($fieldname = '', $data = array())
{ {
// add support to save reloaded forms // add support to save reloaded forms
if (isset($data['select_var'])) { if (isset($data['select_var'])) {
@@ -298,7 +298,7 @@ class HtmlForm
return $output; return $output;
} }
private static function _file($fieldname = '', $data = array()) private static function file($fieldname = '', $data = array())
{ {
$return = ''; $return = '';
$extras = ''; $extras = '';
@@ -323,7 +323,7 @@ class HtmlForm
return $return; return $return;
} }
private static function _int($fieldname = '', $data = array()) private static function int($fieldname = '', $data = array())
{ {
$return = ''; $return = '';
$extras = ''; $extras = '';

View File

@@ -103,7 +103,7 @@ class Paging
*/ */
private $natSorting = false; private $natSorting = false;
private $_limit = 0; private $limit = 0;
/** /**
* Class constructor. * Class constructor.
@@ -226,7 +226,7 @@ class Paging
); );
\Froxlor\Database\Database::pexecute($upd_stmt, $upd_data); \Froxlor\Database\Database::pexecute($upd_stmt, $upd_data);
$this->_limit = $limit; $this->limit = $limit;
} }
/** /**
@@ -384,9 +384,9 @@ class Paging
*/ */
public function getSqlLimit() public function getSqlLimit()
{ {
if ($this->_limit > 0) { if ($this->limit > 0) {
$_offset = ($this->pageno - 1) * $this->_limit; $_offset = ($this->pageno - 1) * $this->limit;
return ' LIMIT ' . $_offset . ',' . $this->_limit; return ' LIMIT ' . $_offset . ',' . $this->limit;
} }
/** /**
* currently not in use * currently not in use

View File

@@ -71,17 +71,17 @@ class Template
$filename = \Froxlor\Froxlor::getInstallDir() . 'templates/' . $theme . '/' . $template . '.tpl'; $filename = \Froxlor\Froxlor::getInstallDir() . 'templates/' . $theme . '/' . $template . '.tpl';
// check the current selected theme for the template // check the current selected theme for the template
$templatefile = self::_checkAndParseTpl($filename); $templatefile = self::checkAndParseTpl($filename);
if ($templatefile == false && $theme != $fallback_theme) { if ($templatefile == false && $theme != $fallback_theme) {
// check fallback // check fallback
$_filename = \Froxlor\Froxlor::getInstallDir() . 'templates/' . $fallback_theme . '/' . $template . '.tpl'; $_filename = \Froxlor\Froxlor::getInstallDir() . 'templates/' . $fallback_theme . '/' . $template . '.tpl';
$templatefile = self::_checkAndParseTpl($_filename); $templatefile = self::checkAndParseTpl($_filename);
if ($templatefile == false) { if ($templatefile == false) {
// check for old layout // check for old layout
$_filename = \Froxlor\Froxlor::getInstallDir() . 'templates/' . $template . '.tpl'; $_filename = \Froxlor\Froxlor::getInstallDir() . 'templates/' . $template . '.tpl';
$templatefile = self::_checkAndParseTpl($_filename); $templatefile = self::checkAndParseTpl($_filename);
if ($templatefile == false) { if ($templatefile == false) {
// not found // not found
@@ -104,7 +104,7 @@ class Template
* *
* @return string|bool content on success, else false * @return string|bool content on success, else false
*/ */
private static function _checkAndParseTpl($filename) private static function checkAndParseTpl($filename)
{ {
$templatefile = ""; $templatefile = "";

View File

@@ -111,8 +111,8 @@ class User
$admin_resources[$cur_adm] = array(); $admin_resources[$cur_adm] = array();
} }
self::_addResourceCountEx($admin_resources[$cur_adm], $customer, 'diskspace_used', 'diskspace'); self::addResourceCountEx($admin_resources[$cur_adm], $customer, 'diskspace_used', 'diskspace');
self::_addResourceCountEx($admin_resources[$cur_adm], $customer, 'traffic_used', 'traffic_used'); // !!! yes, USED and USED self::addResourceCountEx($admin_resources[$cur_adm], $customer, 'traffic_used', 'traffic_used'); // !!! yes, USED and USED
foreach (array( foreach (array(
'mysqls', 'mysqls',
@@ -123,7 +123,7 @@ class User
'email_quota', 'email_quota',
'subdomains' 'subdomains'
) as $field) { ) as $field) {
self::_addResourceCount($admin_resources[$cur_adm], $customer, $field . '_used', $field); self::addResourceCount($admin_resources[$cur_adm], $customer, $field . '_used', $field);
} }
$customer_mysqls_stmt = Database::prepare('SELECT COUNT(*) AS `number_mysqls` FROM `' . TABLE_PANEL_DATABASES . '` $customer_mysqls_stmt = Database::prepare('SELECT COUNT(*) AS `number_mysqls` FROM `' . TABLE_PANEL_DATABASES . '`
@@ -241,7 +241,7 @@ class User
'email_quota_used', 'email_quota_used',
'subdomains_used' 'subdomains_used'
) as $field) { ) as $field) {
self::_initArrField($field, $admin_resources[$cur_adm], 0); self::initArrField($field, $admin_resources[$cur_adm], 0);
$admin[$field . '_new'] = $admin_resources[$cur_adm][$field]; $admin[$field . '_new'] = $admin_resources[$cur_adm][$field];
} }
@@ -295,9 +295,9 @@ class User
* *
* @return void * @return void
*/ */
private static function _addResourceCount(&$arr, $customer_arr, $used_field = null, $field = null) private static function addResourceCount(&$arr, $customer_arr, $used_field = null, $field = null)
{ {
self::_initArrField($used_field, $arr, 0); self::initArrField($used_field, $arr, 0);
if ($customer_arr[$field] != '-1') { if ($customer_arr[$field] != '-1') {
$arr[$used_field] += intval($customer_arr[$used_field]); $arr[$used_field] += intval($customer_arr[$used_field]);
} }
@@ -317,9 +317,9 @@ class User
* *
* @return void * @return void
*/ */
private static function _addResourceCountEx(&$arr, $customer_arr, $used_field = null, $field = null) private static function addResourceCountEx(&$arr, $customer_arr, $used_field = null, $field = null)
{ {
self::_initArrField($used_field, $arr, 0); self::initArrField($used_field, $arr, 0);
if ($field == 'diskspace' && ($customer_arr[$field] / 1024) != '-1') { if ($field == 'diskspace' && ($customer_arr[$field] / 1024) != '-1') {
$arr[$used_field] += intval($customer_arr[$used_field]); $arr[$used_field] += intval($customer_arr[$used_field]);
} elseif ($field == 'traffic_used') { } elseif ($field == 'traffic_used') {
@@ -337,7 +337,7 @@ class User
* *
* @return void * @return void
*/ */
private static function _initArrField($field = null, &$arr, $init_value = 0) private static function initArrField($field = null, &$arr, $init_value = 0)
{ {
if (! isset($arr[$field])) { if (! isset($arr[$field])) {
$arr[$field] = $init_value; $arr[$field] = $init_value;