Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberroland committed Jan 23, 2024
1 parent 1d1ee2a commit e2b5e60
Show file tree
Hide file tree
Showing 27 changed files with 474 additions and 474 deletions.
4 changes: 2 additions & 2 deletions lam/lib/2factor.inc
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class PrivacyIDEAProvider extends BaseProvider {
$errMessage = isset($output->result->error) && isset($output->result->error->message) ? $output->result->error->message : '';
throw new Exception("Unable to get serials: " . $errCode . ' ' . $errMessage);
}
$serials = array();
$serials = [];
foreach ($output->result->value->tokens as $tokenEntry) {
if (!isset($tokenEntry->active) || ($tokenEntry->active != 1) || !isset($tokenEntry->serial)) {
continue;
Expand Down Expand Up @@ -360,7 +360,7 @@ class YubicoProvider extends BaseProvider {
$handle = getLDAPServerHandle();
$ldapData = ldapGetDN($loginDn, array($keyAttributeName), $handle);
if (empty($ldapData[$keyAttributeName])) {
return array();
return [];
}
return array(implode(', ', $ldapData[$keyAttributeName]));
}
Expand Down
32 changes: 16 additions & 16 deletions lam/lib/account.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ use LAM\PLUGINS\EXTRA_INVALID_CREDENTIALS\ExtraInvalidCredentials;
function array_delete($values, $array) {
// Loop for every entry and check if it should be removed
if (is_array($array)) {
$return = array();
$return = [];
foreach ($array as $array_value) {
if (!@in_array($array_value, $values)) {
$return[] = $array_value;
}
}
return $return;
}
return array();
return [];
}


Expand Down Expand Up @@ -224,7 +224,7 @@ function getHashType(?string $hash): string {
if (empty($hash)) {
return 'PLAIN';
}
$matches = array();
$matches = [];
if (!preg_match('/\\{([A-Z0-9-]+)\\}.+/', $hash, $matches)) {
return 'PLAIN';
}
Expand Down Expand Up @@ -496,7 +496,7 @@ function search_domains($server = null, $suffix = null) {
if ($suffix == null) {
$suffix = $_SESSION['config']->get_Suffix('smbDomain');
}
$ret = array();
$ret = [];
$attr = array("DN", "sambaDomainName", "sambaSID", "sambaNextRid", "sambaNextGroupRid",
"sambaNextUserRid", "sambaAlgorithmicRidBase", 'sambaMinPwdAge', 'sambaMaxPwdAge',
'sambaPwdHistoryLength'
Expand Down Expand Up @@ -802,10 +802,10 @@ function connectToLDAP($serverURL, $startTLS) {
* @return array list of found entries
*/
function searchLDAPByAttribute($name, $value, $objectClass, $attributes, $scopes) {
$return = array();
$return = [];
// build filter
$filter = '';
$filterParts = array();
$filterParts = [];
if ($name != null) {
$filterParts[] = '(' . $name . '=' . ldap_escape($value, '*', LDAP_ESCAPE_FILTER) . ')';
}
Expand Down Expand Up @@ -845,7 +845,7 @@ function searchLDAPByAttribute($name, $value, $objectClass, $attributes, $scopes
* @return array list of found entries
*/
function searchLDAPByFilter($filter, $attributes, $scopes, $attrsOnly = false) {
$return = array();
$return = [];
$readAttributesOnly = 0;
if ($attrsOnly) {
$readAttributesOnly = 1;
Expand Down Expand Up @@ -928,13 +928,13 @@ function searchLDAPPaged($server, $dn, $filter, $attributes, $attrsOnly, $limit)
if ($sr) {
$entries = ldap_get_entries($server, $sr);
if (!$entries) {
return array();
return [];
}
cleanLDAPResult($entries);
return $entries;
}
else {
return array();
return [];
}
}
$pageSize = 999;
Expand All @@ -945,7 +945,7 @@ function searchLDAPPaged($server, $dn, $filter, $attributes, $attrsOnly, $limit)
'size' => $pageSize,
'cookie' => $cookie)
);
$return = array();
$return = [];
do {
$sr = @ldap_search($server, $dn, $filter, $attributes, $attrsOnly, $limit,
0, LDAP_DEREF_NEVER, $controls);
Expand Down Expand Up @@ -1026,7 +1026,7 @@ function ldapListDN($dn, $filter = '(objectclass=*)', $attributes = array('dn'),
* @return array error messages
*/
function deleteDN($dn, $recursive) {
$errors = array();
$errors = [];
if (($dn == null) || ($dn == '')) {
$errors[] = array('ERROR', _('Entry does not exist'));
return $errors;
Expand Down Expand Up @@ -1485,7 +1485,7 @@ function sendPasswordMail($pwd, $user, $recipient = null) {
$subject = $mailSubject;
$body = $mailText;
$body = str_replace('@@newPassword@@', $pwd, $body);
$results = array();
$results = [];
$found = preg_match('/\@\@[^\@]+\@\@/', $body, $results);
while ($found == 1) {
$attr = str_replace('@', '', $results[0]);
Expand Down Expand Up @@ -1632,7 +1632,7 @@ function isCommandlineSafeEmailAddress($address) {
class moduleCache {

/** module cache ("name:scope" => module) */
private static $cache = array();
private static $cache = [];

/**
* Returns a new/cached module with the given name and scope.
Expand Down Expand Up @@ -1906,7 +1906,7 @@ function unformatShortFormatToSeconds($text) {
if (empty($text)) {
return $text;
}
$matches = array();
$matches = [];
if (preg_match('/^(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?$/', $text, $matches)) {
$newValue = 0;
if (!empty($matches[2])) {
Expand Down Expand Up @@ -1962,7 +1962,7 @@ function printHeaderContents($title, $prefix) {
// include CSS files
$cssDirName = __DIR__ . '/../style';
$cssDir = dir($cssDirName);
$cssFiles = array();
$cssFiles = [];
$cssEntry = $cssDir->read();
while ($cssEntry !== false) {
if (substr($cssEntry, strlen($cssEntry) - 4, 4) == '.css') {
Expand All @@ -1986,7 +1986,7 @@ function printHeaderContents($title, $prefix) {
function printJsIncludes($prefix) {
$jsDirName = __DIR__ . '/../templates/lib';
$jsDir = dir($jsDirName);
$jsFiles = array();
$jsFiles = [];
$jsEntry = $jsDir->read();
while ($jsEntry !== false) {
if ((substr($jsEntry, strlen($jsEntry) - 3, 3) == '.js') || (substr($jsEntry, strlen($jsEntry) - 4, 4) == '.php')) {
Expand Down
8 changes: 4 additions & 4 deletions lam/lib/adminHeader.inc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function printHeader(string $headerPrefix): void {
// get tool list
$availableTools = getTools();
// sort tools
$toSort = array();
$toSort = [];
foreach ($availableTools as $myTool) {
if ($myTool->getRequiresWriteAccess() && !checkIfWriteAccessIsAllowed()) {
continue;
Expand All @@ -94,7 +94,7 @@ function printHeader(string $headerPrefix): void {
$toSort[$toolClass] = $myTool->getPosition();
}
asort($toSort);
$tools = array();
$tools = [];
foreach ($toSort as $key => $value) {
$tools[] = new $key();
}
Expand Down Expand Up @@ -159,7 +159,7 @@ function printHeader(string $headerPrefix): void {
$accountTypesDiv = new htmlDiv('lam-navigation-types', $accountTypeEntriesDiv, array('lam-navigation-layer zeroHeight'));
$accountTypesGroup->addElement($accountTypesDiv);

parseHtml(null, $accountTypesGroup, array(), false, null);
parseHtml(null, $accountTypesGroup, [], false, null);
}
if (sizeof($tools) > 0) {
$toolGroup = new htmlGroup();
Expand All @@ -179,7 +179,7 @@ function printHeader(string $headerPrefix): void {
$toolDiv = new htmlDiv('lam-navigation-tools', $toolEntriesDiv, array('lam-navigation-layer zeroHeight'));
$toolGroup->addElement($toolDiv);

parseHtml(null, $toolGroup, array(), false, null);
parseHtml(null, $toolGroup, [], false, null);
}
if (is_dir(__DIR__ . '/../docs/manual')) {
?>
Expand Down
Loading

0 comments on commit e2b5e60

Please sign in to comment.