fix some more checkstyle issues

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2018-12-24 13:21:35 +01:00
parent 35c631946d
commit 30f5902b88
16 changed files with 74 additions and 61 deletions

View File

@@ -386,8 +386,8 @@ class Apache extends HttpConfigBase
'customerroot' => $mypath 'customerroot' => $mypath
); );
} }
} // end of ssl-redirect check // end of ssl-redirect check
else { } else {
// fallback of froxlor domain-data for processSpecialConfigTemplate() // fallback of froxlor domain-data for processSpecialConfigTemplate()
$domain = array( $domain = array(
'domain' => Settings::Get('system.hostname'), 'domain' => Settings::Get('system.hostname'),
@@ -597,7 +597,9 @@ class Apache extends HttpConfigBase
} }
public function createOwnVhostStarter() public function createOwnVhostStarter()
{} {
return;
}
/** /**
* We collect all servernames and Aliases * We collect all servernames and Aliases
@@ -698,11 +700,11 @@ class Apache extends HttpConfigBase
} else { } else {
$stats_text .= ' Alias /webalizer "' . \Froxlor\FileDir::makeCorrectFile($domain['customerroot'] . '/webalizer') . '"' . "\n"; $stats_text .= ' Alias /webalizer "' . \Froxlor\FileDir::makeCorrectFile($domain['customerroot'] . '/webalizer') . '"' . "\n";
} }
} // if the docroots are equal, we still have to set an alias for awstats } elseif (Settings::Get('system.awstats_enabled') == '1') {
// if the docroots are equal, we still have to set an alias for awstats
// because the stats are in /awstats/[domain], not just /awstats/ // because the stats are in /awstats/[domain], not just /awstats/
// also, the awstats-icons are someplace else too! // also, the awstats-icons are someplace else too!
// -> webalizer does not need this! // -> webalizer does not need this!
elseif (Settings::Get('system.awstats_enabled') == '1') {
$stats_text .= ' Alias /awstats "' . \Froxlor\FileDir::makeCorrectFile($domain['documentroot'] . '/awstats/' . $domain['domain']) . '"' . "\n"; $stats_text .= ' Alias /awstats "' . \Froxlor\FileDir::makeCorrectFile($domain['documentroot'] . '/awstats/' . $domain['domain']) . '"' . "\n";
$stats_text .= ' Alias /awstats-icon "' . \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.awstats_icons')) . '"' . "\n"; $stats_text .= ' Alias /awstats-icon "' . \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.awstats_icons')) . '"' . "\n";
} }

View File

@@ -374,16 +374,24 @@ class Lighttpd extends HttpConfigBase
} }
public function createVirtualHosts() public function createVirtualHosts()
{} {
return;
}
public function createFileDirOptions() public function createFileDirOptions()
{} {
return;
}
protected function composePhpOptions($domain) protected function composePhpOptions($domain)
{} {
return;
}
public function createOwnVhostStarter() public function createOwnVhostStarter()
{} {
return;
}
protected function createLighttpdHosts($ipid, $ssl, $vhost_filename) protected function createLighttpdHosts($ipid, $ssl, $vhost_filename)
{ {
@@ -441,7 +449,7 @@ class Lighttpd extends HttpConfigBase
return $included_vhosts; return $included_vhosts;
} }
protected function getVhostContent($domain, $ssl_vhost = false, $ipid) protected function getVhostContent($domain, $ssl_vhost = false, $ipid = 0)
{ {
if ($ssl_vhost === true && $domain['ssl'] != '1' && $domain['ssl_redirect'] != '1') { if ($ssl_vhost === true && $domain['ssl'] != '1' && $domain['ssl_redirect'] != '1') {
return ''; return '';
@@ -924,11 +932,11 @@ class Lighttpd extends HttpConfigBase
} else { } else {
$stats_text .= ' alias.url = ( "/webalizer/" => "' . \Froxlor\FileDir::makeCorrectFile($domain['customerroot'] . '/webalizer/') . '" )' . "\n"; $stats_text .= ' alias.url = ( "/webalizer/" => "' . \Froxlor\FileDir::makeCorrectFile($domain['customerroot'] . '/webalizer/') . '" )' . "\n";
} }
} // if the docroots are equal, we still have to set an alias for awstats } elseif (Settings::Get('system.awstats_enabled') == '1') {
// if the docroots are equal, we still have to set an alias for awstats
// because the stats are in /awstats/[domain], not just /awstats/ // because the stats are in /awstats/[domain], not just /awstats/
// also, the awstats-icons are someplace else too! // also, the awstats-icons are someplace else too!
// -> webalizer does not need this! // -> webalizer does not need this!
elseif (Settings::Get('system.awstats_enabled') == '1') {
$stats_text .= ' alias.url = ( "/awstats/" => "' . \Froxlor\FileDir::makeCorrectFile($domain['documentroot'] . '/awstats/' . $domain['domain']) . '" )' . "\n"; $stats_text .= ' alias.url = ( "/awstats/" => "' . \Froxlor\FileDir::makeCorrectFile($domain['documentroot'] . '/awstats/' . $domain['domain']) . '" )' . "\n";
$stats_text .= ' alias.url += ( "/awstats-icon" => "' . \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.awstats_icons')) . '" )' . "\n"; $stats_text .= ' alias.url += ( "/awstats-icon" => "' . \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.awstats_icons')) . '" )' . "\n";
} }

View File

@@ -74,8 +74,7 @@ class MasterCron extends \Froxlor\Cron\FroxlorCron
define('CRON_DEBUG_FLAG', 1); define('CRON_DEBUG_FLAG', 1);
} elseif (strtolower($argv[$x]) == '--no-fork') { } elseif (strtolower($argv[$x]) == '--no-fork') {
define('CRON_NOFORK_FLAG', 1); define('CRON_NOFORK_FLAG', 1);
} } elseif (substr(strtolower($argv[$x]), 0, 2) == '--') {
elseif (substr(strtolower($argv[$x]), 0, 2) == '--') {
// --[cronname] // --[cronname]
if (strlen($argv[$x]) > 3) { if (strlen($argv[$x]) > 3) {
$cronname = substr(strtolower($argv[$x]), 2); $cronname = substr(strtolower($argv[$x]), 2);

View File

@@ -81,7 +81,7 @@ class IntegrityCheck
* *
* @return boolean * @return boolean
*/ */
public function DatabaseCharset($fix = false) public function databaseCharset($fix = false)
{ {
// get characterset // get characterset
@@ -108,7 +108,7 @@ class IntegrityCheck
} }
if ($fix) { if ($fix) {
return $this->DatabaseCharset(); return $this->databaseCharset();
} }
return true; return true;
} }
@@ -119,7 +119,7 @@ class IntegrityCheck
* @param bool $fix * @param bool $fix
* Fix everything found directly * Fix everything found directly
*/ */
public function DomainIpTable($fix = false) public function domainIpTable($fix = false)
{ {
$ips = array(); $ips = array();
$domains = array(); $domains = array();
@@ -217,7 +217,7 @@ class IntegrityCheck
} }
if ($fix) { if ($fix) {
return $this->DomainIpTable(); return $this->domainIpTable();
} else { } else {
return true; return true;
} }
@@ -313,7 +313,7 @@ class IntegrityCheck
* @param bool $fix * @param bool $fix
* Fix everything found directly * Fix everything found directly
*/ */
public function SubdomainLetsencrypt($fix = false) public function subdomainLetsencrypt($fix = false)
{ {
$ips = array(); $ips = array();
$parentdomains = array(); $parentdomains = array();
@@ -385,7 +385,7 @@ class IntegrityCheck
} }
if ($fix) { if ($fix) {
return $this->SubdomainLetsencrypt(); return $this->subdomainLetsencrypt();
} else { } else {
return true; return true;
} }
@@ -400,7 +400,7 @@ class IntegrityCheck
* *
* @return boolean * @return boolean
*/ */
public function WebserverGroupMemberForFcgidPhpFpm($fix = false) public function webserverGroupMemberForFcgidPhpFpm($fix = false)
{ {
if (Settings::Get('system.mod_fcgid') == 0 && Settings::Get('phpfpm.enabled') == 0) { if (Settings::Get('system.mod_fcgid') == 0 && Settings::Get('phpfpm.enabled') == 0) {
return true; return true;
@@ -437,7 +437,7 @@ class IntegrityCheck
} }
if ($fix) { if ($fix) {
return $this->WebserverGroupMemberForFcgidPhpFpm(); return $this->webserverGroupMemberForFcgidPhpFpm();
} }
return true; return true;
} }
@@ -452,7 +452,7 @@ class IntegrityCheck
* *
* @return boolean * @return boolean
*/ */
public function FroxlorLocalGroupMemberForFcgidPhpFpm($fix = false) public function froxlorLocalGroupMemberForFcgidPhpFpm($fix = false)
{ {
if (Settings::Get('system.mod_fcgid') == 0 && Settings::Get('phpfpm.enabled') == 0) { if (Settings::Get('system.mod_fcgid') == 0 && Settings::Get('phpfpm.enabled') == 0) {
return true; return true;
@@ -505,7 +505,7 @@ class IntegrityCheck
} }
if ($fix) { if ($fix) {
return $this->FroxlorLocalGroupMemberForFcgidPhpFpm(); return $this->froxlorLocalGroupMemberForFcgidPhpFpm();
} }
return true; return true;
} }

View File

@@ -264,10 +264,11 @@ final class Froxlor
$arr[] = '1'; // svn < dev < rc $arr[] = '1'; // svn < dev < rc
// number of dev // number of dev
$arr[] = substr($x[1], 3); $arr[] = substr($x[1], 3);
} // -svn version are deprecated } elseif (stripos($x[1], 'svn') !== false) {
elseif (stripos($x[1], 'svn') !== false) { // -svn version are deprecated
$arr[] = '-1'; $arr[] = '-1';
$arr[] = '0'; // svn < dev < rc // svn < dev < rc
$arr[] = '0';
// number of svn // number of svn
$arr[] = substr($x[1], 3); $arr[] = substr($x[1], 3);
} }

View File

@@ -98,21 +98,26 @@ class IdnaWrapper
$strlen = strlen($string); $strlen = strlen($string);
for ($i = 0; $i < $strlen; $i ++) { for ($i = 0; $i < $strlen; $i ++) {
$ord = ord($string[$i]); $ord = ord($string[$i]);
if ($ord < 0x80) if ($ord < 0x80) {
continue; // 0bbbbbbb continue; // 0bbbbbbb
elseif (($ord & 0xE0) === 0xC0 && $ord > 0xC1) } elseif (($ord & 0xE0) === 0xC0 && $ord > 0xC1) {
$n = 1; // 110bbbbb (exkl C0-C1) $n = 1; // 110bbbbb (exkl C0-C1)
elseif (($ord & 0xF0) === 0xE0) } elseif (($ord & 0xF0) === 0xE0) {
$n = 2; // 1110bbbb $n = 2; // 1110bbbb
elseif (($ord & 0xF8) === 0xF0 && $ord < 0xF5) } elseif (($ord & 0xF8) === 0xF0 && $ord < 0xF5) {
$n = 3; // 11110bbb (exkl F5-FF) $n = 3; // 11110bbb (exkl F5-FF)
else } else {
return false; // ungültiges UTF-8-Zeichen
for ($c = 0; $c < $n; $c ++) // $n Folgebytes? // 10bbbbbb
if (++ $i === $strlen || (ord($string[$i]) & 0xC0) !== 0x80)
// ungültiges UTF-8-Zeichen // ungültiges UTF-8-Zeichen
return false; return false;
} }
// $n Folgebytes? // 10bbbbbb
for ($c = 0; $c < $n; $c ++) {
if (++ $i === $strlen || (ord($string[$i]) & 0xC0) !== 0x80) {
// ungültiges UTF-8-Zeichen
return false;
}
}
}
// kein ungültiges UTF-8-Zeichen gefunden // kein ungültiges UTF-8-Zeichen gefunden
return true; return true;
} }

View File

@@ -215,11 +215,8 @@ class Crypt
$pwd_check = crypt($password, $pwd_salt); $pwd_check = crypt($password, $pwd_salt);
// check whether the hash needs to be updated // check whether the hash needs to be updated
$hash_type_chk = substr($pwd_hash, 0, 3); $hash_type_chk = substr($pwd_hash, 0, 3);
if (($systype == 1 && $hash_type_chk != '$1$') || // MD5 // MD5 || BLOWFISH || SHA256 || SHA512
($systype == 2 && $hash_type_chk != '$2$') || // BLOWFISH if (($systype == 1 && $hash_type_chk != '$1$') || ($systype == 2 && $hash_type_chk != '$2$') || ($systype == 3 && $hash_type_chk != '$5$') || ($systype == 4 && $hash_type_chk != '$6$')) {
($systype == 3 && $hash_type_chk != '$5$') || // SHA256
($systype == 4 && $hash_type_chk != '$6$')) // SHA512
{
$update_hash = true; $update_hash = true;
} }
} }

View File

@@ -19,7 +19,7 @@ class Form
if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) { if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) {
// Prefetch form fields // Prefetch form fields
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
$groupdetails['fields'][$fieldname] = self::array_merge_prefix($fielddetails, $fielddetails['type'], self::prefetchFormFieldData($fieldname, $fielddetails)); $groupdetails['fields'][$fieldname] = self::arrayMergePrefix($fielddetails, $fielddetails['type'], self::prefetchFormFieldData($fieldname, $fielddetails));
$form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname]; $form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname];
} }
@@ -76,7 +76,7 @@ class Form
if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) { if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) {
// Prefetch form fields // Prefetch form fields
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
$groupdetails['fields'][$fieldname] = self::array_merge_prefix($fielddetails, $fielddetails['type'], self::prefetchFormFieldData($fieldname, $fielddetails)); $groupdetails['fields'][$fieldname] = self::arrayMergePrefix($fielddetails, $fielddetails['type'], self::prefetchFormFieldData($fieldname, $fielddetails));
$form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname]; $form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname];
} }
@@ -104,7 +104,7 @@ class Form
if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) { if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) {
// Prefetch form fields // Prefetch form fields
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
$groupdetails['fields'][$fieldname] = self::array_merge_prefix($fielddetails, $fielddetails['type'], self::prefetchFormFieldData($fieldname, $fielddetails)); $groupdetails['fields'][$fieldname] = self::arrayMergePrefix($fielddetails, $fielddetails['type'], self::prefetchFormFieldData($fieldname, $fielddetails));
$form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname]; $form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname];
} }
} }
@@ -201,7 +201,7 @@ class Form
// Prefetch form fields // Prefetch form fields
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) { foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
if (! $only_enabledisable || ($only_enabledisable && isset($fielddetails['overview_option']))) { if (! $only_enabledisable || ($only_enabledisable && isset($fielddetails['overview_option']))) {
$groupdetails['fields'][$fieldname] = self::array_merge_prefix($fielddetails, $fielddetails['type'], self::prefetchFormFieldData($fieldname, $fielddetails)); $groupdetails['fields'][$fieldname] = self::arrayMergePrefix($fielddetails, $fielddetails['type'], self::prefetchFormFieldData($fieldname, $fielddetails));
$form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname]; $form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname];
} }
} }
@@ -508,7 +508,7 @@ class Form
return $returnvalue; return $returnvalue;
} }
private static function array_merge_prefix($array1, $key_prefix, $array2) private static function arrayMergePrefix($array1, $key_prefix, $array2)
{ {
if (is_array($array1) && is_array($array2)) { if (is_array($array1) && is_array($array2)) {
if ($key_prefix != '') { if ($key_prefix != '') {

View File

@@ -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 = array(), $init_value = 0)
{ {
if (! isset($arr[$field])) { if (! isset($arr[$field])) {
$arr[$field] = $init_value; $arr[$field] = $init_value;

View File

@@ -9,6 +9,7 @@
<rule ref="PSR2"> <rule ref="PSR2">
<exclude name="Generic.WhiteSpace.DisallowTabIndent" /> <exclude name="Generic.WhiteSpace.DisallowTabIndent" />
<exclude name="Generic.Files.LineLength" /> <exclude name="Generic.Files.LineLength" />
<exclude name="Generic.ControlStructures.InlineControlStructure.Discouraged" />
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" /> <exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
<exclude <exclude
name="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen" /> name="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen" />