Skip to content

Commit

Permalink
fix some more checkstyle issues
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kaufmann <[email protected]>
  • Loading branch information
d00p committed Dec 24, 2018
1 parent 35c6319 commit 30f5902
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 61 deletions.
18 changes: 10 additions & 8 deletions lib/Froxlor/Cron/Http/Apache.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ public function createIpPort()
'customerroot' => $mypath
);
}
} // end of ssl-redirect check
else {
// end of ssl-redirect check
} else {
// fallback of froxlor domain-data for processSpecialConfigTemplate()
$domain = array(
'domain' => Settings::Get('system.hostname'),
Expand Down Expand Up @@ -597,7 +597,9 @@ protected function composePhpOptions($domain, $ssl_vhost = false)
}

public function createOwnVhostStarter()
{}
{
return;
}

/**
* We collect all servernames and Aliases
Expand Down Expand Up @@ -698,11 +700,11 @@ protected function getStats($domain)
} else {
$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
// because the stats are in /awstats/[domain], not just /awstats/
// also, the awstats-icons are someplace else too!
// -> webalizer does not need this!
elseif (Settings::Get('system.awstats_enabled') == '1') {
} 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/
// also, the awstats-icons are someplace else too!
// -> webalizer does not need this!
$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";
}
Expand Down
28 changes: 18 additions & 10 deletions lib/Froxlor/Cron/Http/Lighttpd.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,16 +374,24 @@ protected function createHtaccess($domain)
}

public function createVirtualHosts()
{}
{
return;
}

public function createFileDirOptions()
{}
{
return;
}

protected function composePhpOptions($domain)
{}
{
return;
}

public function createOwnVhostStarter()
{}
{
return;
}

protected function createLighttpdHosts($ipid, $ssl, $vhost_filename)
{
Expand Down Expand Up @@ -441,7 +449,7 @@ protected function createLighttpdHosts($ipid, $ssl, $vhost_filename)
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') {
return '';
Expand Down Expand Up @@ -924,11 +932,11 @@ protected function getStats($domain)
} else {
$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
// because the stats are in /awstats/[domain], not just /awstats/
// also, the awstats-icons are someplace else too!
// -> webalizer does not need this!
elseif (Settings::Get('system.awstats_enabled') == '1') {
} 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/
// also, the awstats-icons are someplace else too!
// -> webalizer does not need this!
$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";
}
Expand Down
5 changes: 2 additions & 3 deletions lib/Froxlor/Cron/MasterCron.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public static function run()
define('CRON_DEBUG_FLAG', 1);
} elseif (strtolower($argv[$x]) == '--no-fork') {
define('CRON_NOFORK_FLAG', 1);
}
elseif (substr(strtolower($argv[$x]), 0, 2) == '--') {
} elseif (substr(strtolower($argv[$x]), 0, 2) == '--') {
// --[cronname]
if (strlen($argv[$x]) > 3) {
$cronname = substr(strtolower($argv[$x]), 2);
Expand Down Expand Up @@ -157,4 +156,4 @@ private static function getCronModule($cronname)
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_ERROR, "Requested cronjob '" . $cronname . "' could not be found.");
return false;
}
}
}
20 changes: 10 additions & 10 deletions lib/Froxlor/Database/IntegrityCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function fixAll()
*
* @return boolean
*/
public function DatabaseCharset($fix = false)
public function databaseCharset($fix = false)
{

// get characterset
Expand All @@ -108,7 +108,7 @@ public function DatabaseCharset($fix = false)
}

if ($fix) {
return $this->DatabaseCharset();
return $this->databaseCharset();
}
return true;
}
Expand All @@ -119,7 +119,7 @@ public function DatabaseCharset($fix = false)
* @param bool $fix
* Fix everything found directly
*/
public function DomainIpTable($fix = false)
public function domainIpTable($fix = false)
{
$ips = array();
$domains = array();
Expand Down Expand Up @@ -217,7 +217,7 @@ public function DomainIpTable($fix = false)
}

if ($fix) {
return $this->DomainIpTable();
return $this->domainIpTable();
} else {
return true;
}
Expand Down Expand Up @@ -313,7 +313,7 @@ public function SubdomainSslRedirect($fix = false)
* @param bool $fix
* Fix everything found directly
*/
public function SubdomainLetsencrypt($fix = false)
public function subdomainLetsencrypt($fix = false)
{
$ips = array();
$parentdomains = array();
Expand Down Expand Up @@ -385,7 +385,7 @@ public function SubdomainLetsencrypt($fix = false)
}

if ($fix) {
return $this->SubdomainLetsencrypt();
return $this->subdomainLetsencrypt();
} else {
return true;
}
Expand All @@ -400,7 +400,7 @@ public function SubdomainLetsencrypt($fix = false)
*
* @return boolean
*/
public function WebserverGroupMemberForFcgidPhpFpm($fix = false)
public function webserverGroupMemberForFcgidPhpFpm($fix = false)
{
if (Settings::Get('system.mod_fcgid') == 0 && Settings::Get('phpfpm.enabled') == 0) {
return true;
Expand Down Expand Up @@ -437,7 +437,7 @@ public function WebserverGroupMemberForFcgidPhpFpm($fix = false)
}

if ($fix) {
return $this->WebserverGroupMemberForFcgidPhpFpm();
return $this->webserverGroupMemberForFcgidPhpFpm();
}
return true;
}
Expand All @@ -452,7 +452,7 @@ public function WebserverGroupMemberForFcgidPhpFpm($fix = false)
*
* @return boolean
*/
public function FroxlorLocalGroupMemberForFcgidPhpFpm($fix = false)
public function froxlorLocalGroupMemberForFcgidPhpFpm($fix = false)
{
if (Settings::Get('system.mod_fcgid') == 0 && Settings::Get('phpfpm.enabled') == 0) {
return true;
Expand Down Expand Up @@ -505,7 +505,7 @@ public function FroxlorLocalGroupMemberForFcgidPhpFpm($fix = false)
}

if ($fix) {
return $this->FroxlorLocalGroupMemberForFcgidPhpFpm();
return $this->froxlorLocalGroupMemberForFcgidPhpFpm();
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Froxlor/Dns/Dns.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,4 +422,4 @@ private static function generateDkimEntries($domain)

return $zone_dkim;
}
}
}
9 changes: 5 additions & 4 deletions lib/Froxlor/Froxlor.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,12 @@ private static function parseVersionArray(&$arr = null)
$arr[] = '1'; // svn < dev < rc
// number of dev
$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[] = '0'; // svn < dev < rc
// number of svn
// svn < dev < rc
$arr[] = '0';
// number of svn
$arr[] = substr($x[1], 3);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Froxlor/Http/LetsEncrypt/LeScriptV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function initAccount($certrow, $isFroxlorVhost = false)
$response = $this->postNewReg();
if ($this->client->getLastCode() == 409) {
$this->log('The key was already registered. Using existing account.');
} else if ($this->client->getLastCode() == 201) {
} elseif ($this->client->getLastCode() == 201) {
$this->log('New account registered.');
} else {
throw new \RuntimeException("Account not initialized, probably due to rate limiting. Whole response: " . json_encode($response));
Expand Down
2 changes: 1 addition & 1 deletion lib/Froxlor/Http/Statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ public static function makeChownWithNewStats($row)
\Froxlor\FileDir::safe_exec('chown -R ' . escapeshellarg($user) . ':' . escapeshellarg($group) . ' ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir($dir)));
}
}
}
}
21 changes: 13 additions & 8 deletions lib/Froxlor/Idna/IdnaWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,25 @@ private function is_utf8($string = null)
$strlen = strlen($string);
for ($i = 0; $i < $strlen; $i ++) {
$ord = ord($string[$i]);
if ($ord < 0x80)
if ($ord < 0x80) {
continue; // 0bbbbbbb
elseif (($ord & 0xE0) === 0xC0 && $ord > 0xC1)
} elseif (($ord & 0xE0) === 0xC0 && $ord > 0xC1) {
$n = 1; // 110bbbbb (exkl C0-C1)
elseif (($ord & 0xF0) === 0xE0)
} elseif (($ord & 0xF0) === 0xE0) {
$n = 2; // 1110bbbb
elseif (($ord & 0xF8) === 0xF0 && $ord < 0xF5)
} elseif (($ord & 0xF8) === 0xF0 && $ord < 0xF5) {
$n = 3; // 11110bbb (exkl F5-FF)
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)
} else {
// ungültiges UTF-8-Zeichen
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
return true;
Expand Down
2 changes: 1 addition & 1 deletion lib/Froxlor/System/Cronjob.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,4 @@ public static function dieWithMail($message, $subject = "[froxlor] Cronjob error

die($message);
}
}
}
7 changes: 2 additions & 5 deletions lib/Froxlor/System/Crypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,8 @@ public static function validatePasswordLogin($userinfo = null, $password = null,
$pwd_check = crypt($password, $pwd_salt);
// check whether the hash needs to be updated
$hash_type_chk = substr($pwd_hash, 0, 3);
if (($systype == 1 && $hash_type_chk != '$1$') || // MD5
($systype == 2 && $hash_type_chk != '$2$') || // BLOWFISH
($systype == 3 && $hash_type_chk != '$5$') || // SHA256
($systype == 4 && $hash_type_chk != '$6$')) // SHA512
{
// MD5 || BLOWFISH || SHA256 || SHA512
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$')) {
$update_hash = true;
}
}
Expand Down
10 changes: 5 additions & 5 deletions lib/Froxlor/UI/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static function buildForm($form)
if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) {
// Prefetch form fields
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];
}

Expand Down Expand Up @@ -76,7 +76,7 @@ public static function buildFormEx($form, $part = '')
if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) {
// Prefetch form fields
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];
}

Expand Down Expand Up @@ -104,7 +104,7 @@ public static function processForm(&$form, &$input, $url_params = array())
if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) {
// Prefetch form fields
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];
}
}
Expand Down Expand Up @@ -201,7 +201,7 @@ public static function processFormEx(&$form, &$input, $url_params = array(), $pa
// Prefetch form fields
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
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];
}
}
Expand Down Expand Up @@ -508,7 +508,7 @@ public static function checkPlausibilityFormField($fieldname, $fielddata, $newfi
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 ($key_prefix != '') {
Expand Down
2 changes: 1 addition & 1 deletion lib/Froxlor/UI/HTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,4 @@ public static function ask_yesno_withcheckbox($text, $chk_text, $yesfile, $param
eval("echo \"" . Template::getTemplate('misc/question_yesno_checkbox', '1') . "\";");
exit();
}
}
}
2 changes: 1 addition & 1 deletion lib/Froxlor/UI/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,4 @@ public static function standard_success($success_message = '', $replacer = '', $
eval("echo \"" . Template::getTemplate('misc/success', '1') . "\";");
exit();
}
}
}
4 changes: 2 additions & 2 deletions lib/Froxlor/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,10 @@ private static function addResourceCountEx(&$arr, $customer_arr, $used_field = n
*
* @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])) {
$arr[$field] = $init_value;
}
}
}
}
1 change: 1 addition & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<rule ref="PSR2">
<exclude name="Generic.WhiteSpace.DisallowTabIndent" />
<exclude name="Generic.Files.LineLength" />
<exclude name="Generic.ControlStructures.InlineControlStructure.Discouraged" />
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
<exclude
name="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen" />
Expand Down

0 comments on commit 30f5902

Please sign in to comment.