diff --git a/lam/lib/2factor.inc b/lam/lib/2factor.inc index d57416d2..0cbaee92 100644 --- a/lam/lib/2factor.inc +++ b/lam/lib/2factor.inc @@ -217,8 +217,6 @@ class PrivacyIDEAProvider implements TwoFactorProvider { if (($status == 'true') && ($value == 'true')) { return true; } - $errCode = isset($output->result->error) && isset($output->result->error->code) ? $output->result->error->code : ''; - $errMessage = isset($output->result->error) && isset($output->result->error->message) ? $output->result->error->message : ''; logNewMessage(LOG_DEBUG, "Unable to verify token: " . print_r($output, true)); return false; } diff --git a/lam/lib/account.inc b/lam/lib/account.inc index d70c6d65..d5247f83 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -3,7 +3,7 @@ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2003 - 2006 Tilo Lutz - 2009 - 2018 Roland Gruber + 2009 - 2019 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -341,7 +341,6 @@ function generateRandomPassword() { if ($length < 12) { $length = 12; } - $isOk = false; for ($x = 0; $x < 10000; $x++) { $password = ''; for ($i = 0; $i < $length; $i++) { diff --git a/lam/lib/import.inc b/lam/lib/import.inc index c77d49ee..2e607cd9 100644 --- a/lam/lib/import.inc +++ b/lam/lib/import.inc @@ -5,7 +5,7 @@ use \LAMException; /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2018 Roland Gruber + Copyright (C) 2018 - 2019 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -109,8 +109,7 @@ class Importer { */ public function getTasks($lines) { $chunks = $this->extractImportChunks($lines); - $tasks = $this->convertToTasks($chunks); - return $tasks; + return $this->convertToTasks($chunks); } /** @@ -297,7 +296,6 @@ class Importer { elseif ($type !== 'modify') { throw new LAMException(_('Invalid data'), htmlspecialchars($dn) . ' - changeType: ' . htmlspecialchars($type)); } - $changes = array(); $subtasks = array(); $currentLines = array(); $linesCount = sizeof($entry); @@ -337,7 +335,7 @@ class Importer { if (($delOldRdnData[Importer::KEY] !== 'deleteoldrdn') || !in_array($delOldRdnData[Importer::VALUE], array('0', '1'), true)) { throw new LAMException(_('Invalid data'), htmlspecialchars($dn) . '
' . $entry[1]); } - $delOldRdn = ($delOldRdnData[Importer::VALUE] === '0') ? false : true; + $delOldRdn = ($delOldRdnData[Importer::VALUE] !== '0'); return new RenameEntryTask($dn, $newRdn, $delOldRdn); } diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 88ca0bfe..2e910537 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -4,7 +4,7 @@ use \LAM\TYPES\TypeManager; /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2003 - 2018 Roland Gruber + Copyright (C) 2003 - 2019 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -139,8 +139,7 @@ function get_ldap_filter($typeId) { $finalFilter = "(&" . implode("", $filters['and']) . ")"; } $loginData = $_SESSION['ldap']->decrypt_login(); - $finalFilter = str_replace('@@LOGIN_DN@@', $loginData[0], $finalFilter); - return $finalFilter; + return str_replace('@@LOGIN_DN@@', $loginData[0], $finalFilter); } /** @@ -190,7 +189,9 @@ function getRDNAttributes($typeId, $selectedModules=null) { if (!in_array($attrs_normal[$i], $return)) $return[] = $attrs_normal[$i]; } for ($i = 0; $i < sizeof($attrs_low); $i++) { - if (!in_array($attrs_low[$i], $return)) $return[] = $attrs_low[$i]; + if (!in_array($attrs_low[$i], $return)) { + $return[] = $attrs_low[$i]; + } } return $return; } @@ -252,8 +253,10 @@ function check_module_depends($selected, $deps) { } } } - if (sizeof($ret) > 0) return $ret; - else return false; + if (sizeof($ret) > 0) { + return $ret; + } + return false; } /** @@ -273,8 +276,10 @@ function check_module_conflicts($selected, $deps) { } } } - if (sizeof($ret) > 0) return $ret; - else return false; + if (sizeof($ret) > 0) { + return $ret; + } + return false; } /** @@ -289,7 +294,7 @@ function getAvailableModules($scope, $mustSupportAdminInterface = false) { $dir = dir($dirname); $return = array(); // get module names. - while ($entry = $dir->read()) + while ($entry = $dir->read()) { if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($dirname . '/'.$entry)) { $entry = substr($entry, 0, strpos($entry, '.')); $temp = moduleCache::getModule($entry, $scope); @@ -300,6 +305,7 @@ function getAvailableModules($scope, $mustSupportAdminInterface = false) { $return[] = $entry; } } + } return $return; } @@ -389,7 +395,9 @@ function getHelp($module,$helpID,$scope='') { global $helpArray; if (!isset($module) || ($module == '') || ($module == 'main')) { $helpPath = "../help/help.inc"; - if (is_file("../../help/help.inc")) $helpPath = "../../help/help.inc"; + if (is_file("../../help/help.inc")) { + $helpPath = "../../help/help.inc"; + } if (!isset($helpArray)) { include_once($helpPath); } @@ -512,7 +520,9 @@ function buildUploadAccounts($type, $data, $ids, $selectedModules, htmlResponsiv break; } } - if ($newRound) continue; + if ($newRound) { + continue; + } // this point should never be reached, LAM was unable to find a correct module order $container->add(new htmlStatusMessage("ERROR", "Internal Error: Unable to find correct module order."), 12); return false; @@ -701,7 +711,9 @@ function lamCompareDescriptiveOptions(&$a, &$b) { */ function printHelpLink($entry, $number, $module = '', $scope = '', $classes = array()) { $helpPath = "../"; - if (is_file("./help.php")) $helpPath = ""; + if (is_file("./help.php")) { + $helpPath = ""; + } $title = $entry['Headline']; $message = $entry['Text']; if (isset($entry['attr'])) { @@ -736,8 +748,12 @@ class accountContainer { * @param integer $randomID random ID to avoid parallel editing (default: null) */ function __construct($type, $base, $randomID = null) { - if (!($type instanceof ConfiguredType)) trigger_error('Argument of accountContainer must be ConfiguredType.', E_USER_ERROR); - if (!is_string($base)) trigger_error('Argument of accountContainer must be string.', E_USER_ERROR); + if (!($type instanceof ConfiguredType)) { + trigger_error('Argument of accountContainer must be ConfiguredType.', E_USER_ERROR); + } + if (!is_string($base)) { + trigger_error('Argument of accountContainer must be string.', E_USER_ERROR); + } $this->type = $type; $this->base = $base; // Set startpage @@ -855,13 +871,14 @@ class accountContainer { } $oldPage = $this->current_page; $oldSubpage = $this->subpage; - $post = $_POST; $result = array(); $stopProcessing = false; // when set to true, no module options are displayed $errorsOccured = false; $typeObject = $this->type->getBaseType(); $profileLoaded = $this->loadProfileIfRequested(); - if ($this->subpage=='') $this->subpage='attributes'; + if ($this->subpage == '') { + $this->subpage='attributes'; + } if (isset($_POST['accountContainerReset'])) { $result = $this->load_account($this->dn_orig); } @@ -1225,7 +1242,7 @@ class accountContainer { $return['forcePasswordChange'] = $forcePasswordChange; if ($return['errorsOccured'] == 'false') { // set new password - foreach ($this->module as $name => $module) { + foreach ($this->module as $module) { if ($module instanceof passwordService) { $messages = $module->passwordChangeRequested($password1, $modules, $forcePasswordChange); for ($m = 0; $m < sizeof($messages); $m++) { @@ -1334,7 +1351,7 @@ class accountContainer { * @return boolean show or hide button */ private function showSetPasswordButton() { - foreach ($this->module as $name => $module) { + foreach ($this->module as $module) { if (($module instanceof passwordService) && $module->managesPasswordAttributes()) { return true; } @@ -1442,11 +1459,12 @@ class accountContainer { $this->lastLoadedProfile = $_POST['accountContainerSelectLoadProfile']; // pass profile to each module $modules = array_keys($this->module); - foreach ($modules as $module) $this->module[$module]->load_profile($profile); - if (isset($profile['ldap_rdn'][0])) { - if (in_array($profile['ldap_rdn'][0], getRDNAttributes($this->type->getId()))) { - $this->rdn = $profile['ldap_rdn'][0]; - } + foreach ($modules as $module) { + $this->module[$module]->load_profile($profile); + } + if (isset($profile['ldap_rdn'][0]) + && in_array($profile['ldap_rdn'][0], getRDNAttributes($this->type->getId()))) { + $this->rdn = $profile['ldap_rdn'][0]; } if (isset($profile['ldap_suffix'][0]) && ($profile['ldap_suffix'][0] != '-')) { $this->dnSuffix = $profile['ldap_suffix'][0]; @@ -1468,7 +1486,9 @@ class accountContainer { $buttonStatus = $this->module[$this->order[$i]]->getButtonStatus(); $alias = $this->module[$this->order[$i]]->get_alias(); // skip hidden buttons - if ($buttonStatus == 'hidden') continue; + if ($buttonStatus == 'hidden') { + continue; + } $buttonImage = $this->module[$this->order[$i]]->getIcon(); $activatedClass = ''; if ($this->order[$this->current_page] == $this->order[$i]) { @@ -1479,7 +1499,9 @@ class accountContainer { $buttonStyle = 'background-color:transparent;;border:0px solid;min-width: 200px;'; echo "