mirror of
https://github.com/LDAPAccountManager/lam.git
synced 2025-10-03 09:49:16 +02:00
refactoring
This commit is contained in:
parent
c997d79be9
commit
d611abedb4
8 changed files with 75 additions and 75 deletions
|
@ -11,7 +11,7 @@ use htmlStatusMessage;
|
|||
/*
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||
Copyright (C) 2020 - 2022 Roland Gruber
|
||||
Copyright (C) 2020 - 2023 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
|
||||
|
@ -79,7 +79,7 @@ if (isset($_POST['changePassword'])) {
|
|||
}
|
||||
// check password strength
|
||||
$userDn = $_SESSION['ldap']->getUserName();
|
||||
$additionalAttrs = array();
|
||||
$additionalAttrs = [];
|
||||
$rdnAttr = extractRDNAttribute($userDn);
|
||||
$userName = null;
|
||||
if ($rdnAttr === 'uid') {
|
||||
|
@ -139,7 +139,7 @@ function printContent($message = null, $showPasswordInputs = true): void {
|
|||
addSecurityTokenToMetaHTML($container);
|
||||
}
|
||||
|
||||
parseHtml(null, $container, array(), false, 'user');
|
||||
parseHtml(null, $container, [], false, 'user');
|
||||
|
||||
echo "</form><br>\n";
|
||||
echo "</div>\n";
|
||||
|
|
|
@ -11,7 +11,7 @@ use \htmlStatusMessage;
|
|||
|
||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||
Copyright (C) 2003 - 2006 Tilo Lutz
|
||||
Copyright (C) 2007 - 2022 Roland Gruber
|
||||
Copyright (C) 2007 - 2023 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
|
||||
|
@ -76,7 +76,7 @@ if (!empty($_POST)) {
|
|||
|
||||
$sessionAccountPrefix = 'deleteContainer';
|
||||
foreach ($_SESSION as $key => $value) {
|
||||
if (strpos($key, $sessionAccountPrefix) === 0) {
|
||||
if (str_starts_with($key, $sessionAccountPrefix)) {
|
||||
unset($_SESSION[$key]);
|
||||
logNewMessage(LOG_NOTICE, "del " . $key);
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ if (isset($_GET['type']) && isset($_SESSION['delete_dn'])) {
|
|||
die();
|
||||
}
|
||||
// Create account list
|
||||
$users = array();
|
||||
$users = [];
|
||||
foreach ($_SESSION['delete_dn'] as $dn) {
|
||||
$start = strpos ($dn, "=")+1;
|
||||
$end = strpos ($dn, ",");
|
||||
|
@ -137,26 +137,26 @@ if (isset($_GET['type']) && isset($_SESSION['delete_dn'])) {
|
|||
addSecurityTokenToMetaHTML($container);
|
||||
$container->add(new htmlHiddenInput('type', $type->getId()), 12);
|
||||
$container->addVerticalSpacer('1rem');
|
||||
parseHtml(null, $container, array(), false, $type->getScope());
|
||||
parseHtml(null, $container, [], false, $type->getScope());
|
||||
// Print delete rows from modules
|
||||
$modules = $_SESSION['config']->get_AccountModules($type->getId());
|
||||
$values = array();
|
||||
$values = [];
|
||||
foreach ($modules as $module) {
|
||||
$module = \moduleCache::getModule($module, $type->getScope());
|
||||
parseHtml(get_class($module), $module->display_html_delete(), $values, true, $type->getScope());
|
||||
parseHtml($module::class, $module->display_html_delete(), $values, true, $type->getScope());
|
||||
}
|
||||
$buttonContainer = new htmlResponsiveRow();
|
||||
$buttonContainer->addVerticalSpacer('1rem');
|
||||
$buttonGroup = new htmlGroup();
|
||||
$delButton = new htmlButton('delete', _('Delete'));
|
||||
$delButton->setCSSClasses(array('lam-danger'));
|
||||
$delButton->setCSSClasses(['lam-danger']);
|
||||
$buttonGroup->addElement($delButton);
|
||||
$buttonGroup->addElement(new htmlSpacer('0.5rem', null));
|
||||
$cancelButton = new htmlButton('cancel', _('Cancel'));
|
||||
$buttonGroup->addElement($cancelButton);
|
||||
$buttonContainer->add($buttonGroup, 12);
|
||||
$buttonContainer->addVerticalSpacer('1rem');
|
||||
parseHtml(null, $buttonContainer, array(), false, $type->getScope());
|
||||
parseHtml(null, $buttonContainer, [], false, $type->getScope());
|
||||
echo "</form>\n";
|
||||
echo "</div>\n";
|
||||
include '../lib/adminFooter.inc';
|
||||
|
@ -194,7 +194,7 @@ if (isset($_POST['delete'])) {
|
|||
$_SESSION[$sessionKey] = new \accountContainer($type, $sessionKey);
|
||||
// Delete dns
|
||||
$allOk = true;
|
||||
$allErrors = array();
|
||||
$allErrors = [];
|
||||
foreach ($_SESSION['delete_dn'] as $deleteDN) {
|
||||
// Set to true if an real error has happened
|
||||
$stopProcessing = false;
|
||||
|
@ -203,8 +203,8 @@ if (isset($_POST['delete'])) {
|
|||
// get commands and changes of each attribute
|
||||
$moduleNames = array_keys($_SESSION[$sessionKey]->getAccountModules());
|
||||
$modules = $_SESSION[$sessionKey]->getAccountModules();
|
||||
$attributes = array();
|
||||
$errors = array();
|
||||
$attributes = [];
|
||||
$errors = [];
|
||||
// predelete actions
|
||||
foreach ($moduleNames as $singlemodule) {
|
||||
$success = true;
|
||||
|
@ -258,7 +258,7 @@ if (isset($_POST['delete'])) {
|
|||
if (isset($attributes[$dn]['modify'])) {
|
||||
$success = ldap_mod_replace($_SESSION['ldap']->server(), $dn, $attributes[$dn]['modify']);
|
||||
if (!$success) {
|
||||
$errors[] = array ('ERROR', sprintf(_('Was unable to modify attributes from DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server()));
|
||||
$errors[] = ['ERROR', sprintf(_('Was unable to modify attributes from DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server())];
|
||||
$stopProcessing = true;
|
||||
$allOk = false;
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ if (isset($_POST['delete'])) {
|
|||
if (isset($attributes[$dn]['add']) && !$stopProcessing) {
|
||||
$success = ldap_mod_add($_SESSION['ldap']->server(), $dn, $attributes[$dn]['add']);
|
||||
if (!$success) {
|
||||
$errors[] = array ('ERROR', sprintf(_('Was unable to add attributes to DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server()));
|
||||
$errors[] = ['ERROR', sprintf(_('Was unable to add attributes to DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server())];
|
||||
$stopProcessing = true;
|
||||
$allOk = false;
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ if (isset($_POST['delete'])) {
|
|||
if (isset($attributes[$dn]['remove']) && !$stopProcessing) {
|
||||
$success = ldap_mod_del($_SESSION['ldap']->server(), $dn, $attributes[$dn]['remove']);
|
||||
if (!$success) {
|
||||
$errors[] = array ('ERROR', sprintf(_('Was unable to remove attributes from DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server()));
|
||||
$errors[] = ['ERROR', sprintf(_('Was unable to remove attributes from DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server())];
|
||||
$stopProcessing = true;
|
||||
$allOk = false;
|
||||
}
|
||||
|
@ -322,13 +322,13 @@ if (isset($_POST['delete'])) {
|
|||
$container->add(htmlStatusMessage::fromParamArray($error), 12);
|
||||
}
|
||||
}
|
||||
$allErrors = array_merge($allErrors, $errors);
|
||||
$allErrors = [...$allErrors, ...$errors];
|
||||
}
|
||||
$container->addVerticalSpacer('2rem');
|
||||
$buttonName = $allOk ? 'cancelAllOk' : 'cancel';
|
||||
$container->add(new htmlButton($buttonName, _('Back to list')), 12);
|
||||
$container->addVerticalSpacer('1rem');
|
||||
parseHtml(null, $container, array(), false, $type->getScope());
|
||||
parseHtml(null, $container, [], false, $type->getScope());
|
||||
echo "</div>\n";
|
||||
echo "</form>\n";
|
||||
?>
|
||||
|
@ -354,6 +354,6 @@ if (isset($_POST['delete'])) {
|
|||
* @return integer number of children
|
||||
*/
|
||||
function getChildCount($dn) {
|
||||
$entries = searchLDAP($dn, 'objectClass=*', array('dn'));
|
||||
$entries = searchLDAP($dn, 'objectClass=*', ['dn']);
|
||||
return (sizeof($entries) - 1);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace LAM\HELP;
|
|||
|
||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||
Copyright (C) 2003 - 2006 Michael Duergner
|
||||
2008 - 2022 Roland Gruber
|
||||
2008 - 2023 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
|
||||
|
@ -113,7 +113,7 @@ if (!isset($_GET['HelpNumber'])) {
|
|||
exit;
|
||||
}
|
||||
|
||||
$helpEntry = array();
|
||||
$helpEntry = [];
|
||||
|
||||
// module help
|
||||
if (isset($_GET['module']) && !($_GET['module'] == 'main') && !($_GET['module'] == '')) {
|
||||
|
@ -132,7 +132,7 @@ if (isset($_GET['module']) && !($_GET['module'] == 'main') && !($_GET['module']
|
|||
$helpEntry = getHelp($moduleName, $_GET['HelpNumber'], $scope);
|
||||
}
|
||||
if (!$helpEntry) {
|
||||
$variables = array(htmlspecialchars($_GET['HelpNumber']), htmlspecialchars($moduleName));
|
||||
$variables = [htmlspecialchars($_GET['HelpNumber']), htmlspecialchars($moduleName)];
|
||||
$errorMessage = _("Sorry the help id '%s' is not available for the module '%s'.");
|
||||
echoHTMLHead();
|
||||
statusMessage("ERROR", "", $errorMessage, $variables);
|
||||
|
@ -144,7 +144,7 @@ if (isset($_GET['module']) && !($_GET['module'] == 'main') && !($_GET['module']
|
|||
else {
|
||||
/* If submitted help number is not in help/help.inc print error message */
|
||||
if (!array_key_exists($_GET['HelpNumber'], $helpArray)) {
|
||||
$variables = array(htmlspecialchars($_GET['HelpNumber']));
|
||||
$variables = [htmlspecialchars($_GET['HelpNumber'])];
|
||||
$errorMessage = _("Sorry this help number ({bold}%s{endbold}) is not available.");
|
||||
echoHTMLHead();
|
||||
statusMessage("ERROR", "", $errorMessage, $variables);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/*
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||
Copyright (C) 2003 - 2022 Roland Gruber
|
||||
Copyright (C) 2003 - 2023 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
|
||||
|
@ -51,7 +51,7 @@ if (!empty($_POST)) {
|
|||
}
|
||||
|
||||
// check if user already pressed button
|
||||
$failedDNs = array();
|
||||
$failedDNs = [];
|
||||
if (isset($_POST['add_suff']) || isset($_POST['cancel'])) {
|
||||
if (isset($_POST['add_suff'])) {
|
||||
$newSuffixes = $_POST['new_suff'];
|
||||
|
@ -61,7 +61,7 @@ if (isset($_POST['add_suff']) || isset($_POST['cancel'])) {
|
|||
// add entries
|
||||
foreach ($newSuffixes as $newSuffix) {
|
||||
// check if entry is already present
|
||||
$info = @ldap_read($_SESSION['ldap']->server(), $newSuffix, "objectclass=*", array('dn'), 0, 0, 0, LDAP_DEREF_NEVER);
|
||||
$info = @ldap_read($_SESSION['ldap']->server(), $newSuffix, "objectclass=*", ['dn'], 0, 0, 0, LDAP_DEREF_NEVER);
|
||||
$res = false;
|
||||
if ($info !== false) {
|
||||
$res = ldap_get_entries($_SESSION['ldap']->server(), $info);
|
||||
|
@ -76,7 +76,7 @@ if (isset($_POST['add_suff']) || isset($_POST['cancel'])) {
|
|||
array_shift($tmp);
|
||||
$end = implode(",", $tmp);
|
||||
if ($name[0] != "ou") { // add root entry
|
||||
$attr = array();
|
||||
$attr = [];
|
||||
$attr[$name[0]] = $name[1];
|
||||
$attr['objectClass'] = 'organization';
|
||||
$dn = $suff;
|
||||
|
@ -87,7 +87,7 @@ if (isset($_POST['add_suff']) || isset($_POST['cancel'])) {
|
|||
}
|
||||
else { // add organizational unit
|
||||
$name = $name[1];
|
||||
$attr = array();
|
||||
$attr = [];
|
||||
$attr['objectClass'] = "organizationalunit";
|
||||
$attr['ou'] = $name;
|
||||
$dn = $suff;
|
||||
|
@ -95,7 +95,7 @@ if (isset($_POST['add_suff']) || isset($_POST['cancel'])) {
|
|||
// check if we have to add parent entries
|
||||
if (ldap_errno($_SESSION['ldap']->server()) == 32) {
|
||||
$dnParts = explode(",", $suff);
|
||||
$subsuffs = array();
|
||||
$subsuffs = [];
|
||||
// make list of subsuffixes
|
||||
$dnPartsCount = sizeof($dnParts);
|
||||
for ($k = 0; $k < $dnPartsCount; $k++) {
|
||||
|
@ -112,7 +112,7 @@ if (isset($_POST['add_suff']) || isset($_POST['cancel'])) {
|
|||
$subsuffCount = sizeof($subsuffs);
|
||||
for ($k = $subsuffCount - 1; $k >= 0; $k--) {
|
||||
// check if subsuffix is present
|
||||
$info = @ldap_read($_SESSION['ldap']->server(), $subsuffs[$k], "objectclass=*", array('dn'), 0, 0, 0, LDAP_DEREF_NEVER);
|
||||
$info = @ldap_read($_SESSION['ldap']->server(), $subsuffs[$k], "objectclass=*", ['dn'], 0, 0, 0, LDAP_DEREF_NEVER);
|
||||
$res = false;
|
||||
if ($info !== false) {
|
||||
$res = ldap_get_entries($_SESSION['ldap']->server(), $info);
|
||||
|
@ -121,7 +121,7 @@ if (isset($_POST['add_suff']) || isset($_POST['cancel'])) {
|
|||
$suffarray = explode(",", $subsuffs[$k]);
|
||||
$headarray = explode("=", $suffarray[0]);
|
||||
if ($headarray[0] == "ou") { // add ou entry
|
||||
$attr = array();
|
||||
$attr = [];
|
||||
$attr['objectClass'] = 'organizationalunit';
|
||||
$attr['ou'] = $headarray[1];
|
||||
$dn = $subsuffs[$k];
|
||||
|
@ -131,7 +131,7 @@ if (isset($_POST['add_suff']) || isset($_POST['cancel'])) {
|
|||
}
|
||||
}
|
||||
else { // add root entry
|
||||
$attr = array();
|
||||
$attr = [];
|
||||
$attr['objectClass'][] = 'organization';
|
||||
$attr[$headarray[0]] = $headarray[1];
|
||||
if ($headarray[0] == "dc") {
|
||||
|
@ -204,7 +204,7 @@ include __DIR__ . '/../lib/adminHeader.inc';
|
|||
$container->add($buttonContainer, 12);
|
||||
addSecurityTokenToMetaHTML($container);
|
||||
|
||||
parseHtml(null, $container, array(), false, 'user');
|
||||
parseHtml(null, $container, [], false, 'user');
|
||||
|
||||
echo "</form><br>\n";
|
||||
echo "</div>\n";
|
||||
|
|
|
@ -81,7 +81,7 @@ lam_start_session();
|
|||
session_regenerate_id(true);
|
||||
|
||||
$serverProfilePersistenceManager = new ServerProfilePersistenceManager();
|
||||
$profiles = array();
|
||||
$profiles = [];
|
||||
try {
|
||||
$profiles = $serverProfilePersistenceManager->getProfiles();
|
||||
} catch (LAMException $e) {
|
||||
|
@ -146,7 +146,7 @@ $possibleLanguages = getLanguages();
|
|||
$encoding = 'UTF-8';
|
||||
if (isset($_COOKIE['lam_last_language'])) {
|
||||
foreach ($possibleLanguages as $lang) {
|
||||
if (strpos($_COOKIE['lam_last_language'], $lang->code) === 0) {
|
||||
if (str_starts_with($_COOKIE['lam_last_language'], $lang->code)) {
|
||||
$_SESSION['language'] = $lang->code;
|
||||
$encoding = $lang->encoding;
|
||||
break;
|
||||
|
@ -156,7 +156,7 @@ if (isset($_COOKIE['lam_last_language'])) {
|
|||
elseif (!empty($_SESSION["config"])) {
|
||||
$defaultLang = $_SESSION["config"]->get_defaultLanguage();
|
||||
foreach ($possibleLanguages as $lang) {
|
||||
if (strpos($defaultLang, $lang->code) === 0) {
|
||||
if (str_starts_with($defaultLang, $lang->code)) {
|
||||
$_SESSION['language'] = $lang->code;
|
||||
$encoding = $lang->encoding;
|
||||
break;
|
||||
|
@ -168,7 +168,7 @@ else {
|
|||
}
|
||||
if (isset($_POST['language'])) {
|
||||
foreach ($possibleLanguages as $lang) {
|
||||
if (strpos($_POST['language'], $lang->code) === 0) {
|
||||
if (str_starts_with($_POST['language'], $lang->code)) {
|
||||
$_SESSION['language'] = $lang->code;
|
||||
$encoding = $lang->encoding;
|
||||
break;
|
||||
|
@ -182,9 +182,9 @@ $_SESSION['header'] .= "<meta name=\"robots\" content=\"noindex, nofollow\">\n";
|
|||
$_SESSION['header'] .= "<meta http-equiv=\"content-type\" content=\"text/html; charset=" . $encoding . "\">\n";
|
||||
$_SESSION['header'] .= "<meta http-equiv=\"pragma\" content=\"no-cache\">\n <meta http-equiv=\"cache-control\" content=\"no-cache\">";
|
||||
$manifestBaseUrl = getCallingURL();
|
||||
if (strpos($manifestBaseUrl, '/templates/login.php') !== false) {
|
||||
if (str_contains($manifestBaseUrl, '/templates/login.php')) {
|
||||
$manifestBaseUrl = substr($manifestBaseUrl, 0, strpos($manifestBaseUrl, '/templates/login.php'));
|
||||
$urlMatches = array();
|
||||
$urlMatches = [];
|
||||
if (preg_match('/^http(s)?:\\/\\/[^\\/]+(\\/.*)$/m', $manifestBaseUrl, $urlMatches)) {
|
||||
$manifestBaseUrl = htmlspecialchars($urlMatches[2]);
|
||||
$_SESSION['header'] .= '<link rel="manifest" href="' . $manifestBaseUrl . '/templates/manifest.php" crossorigin="use-credentials">';
|
||||
|
@ -273,7 +273,7 @@ function display_LoginPage(?LAMLicenseValidator $licenseValidator, ?string $erro
|
|||
$row->addLabel(new htmlLabel('username', _("User name")));
|
||||
if ($config_object->getLoginMethod() == LAMConfig::LOGIN_LIST) {
|
||||
$admins = $config_object->get_Admins();
|
||||
$adminList = array();
|
||||
$adminList = [];
|
||||
foreach ($admins as $admin) {
|
||||
$text = explode(",", $admin);
|
||||
$text = explode("=", $text[0]);
|
||||
|
@ -284,22 +284,22 @@ function display_LoginPage(?LAMLicenseValidator $licenseValidator, ?string $erro
|
|||
$adminList[$text[0]] = $admin;
|
||||
}
|
||||
}
|
||||
$selectedAdmin = array();
|
||||
$selectedAdmin = [];
|
||||
if (isset($_POST['username']) && in_array($_POST['username'], $adminList)) {
|
||||
$selectedAdmin = array($_POST['username']);
|
||||
$selectedAdmin = [$_POST['username']];
|
||||
}
|
||||
$userSelect = new htmlSelect('username', $adminList, $selectedAdmin);
|
||||
$userSelect->setHasDescriptiveElements(true);
|
||||
$userSelect->setTransformSingleSelect(false);
|
||||
if (empty($_COOKIE['lam_login_name'])) {
|
||||
$userSelect->setCSSClasses(array('lam-initial-focus'));
|
||||
$userSelect->setCSSClasses(['lam-initial-focus']);
|
||||
}
|
||||
$row->addField(new htmlDiv(null, $userSelect));
|
||||
}
|
||||
else {
|
||||
if ($config_object->getHttpAuthentication() == 'true') {
|
||||
$httpAuth = new htmlDiv(null, new htmlOutputText($_SERVER['PHP_AUTH_USER'] . ' ', false));
|
||||
$httpAuth->setCSSClasses(array('text-left', 'margin3'));
|
||||
$httpAuth->setCSSClasses(['text-left', 'margin3']);
|
||||
$row->addField($httpAuth);
|
||||
}
|
||||
else {
|
||||
|
@ -309,7 +309,7 @@ function display_LoginPage(?LAMLicenseValidator $licenseValidator, ?string $erro
|
|||
}
|
||||
$userNameInput = new htmlInputField('username', $user);
|
||||
if (empty($_COOKIE['lam_login_name'])) {
|
||||
$userNameInput->setCSSClasses(array('lam-initial-focus'));
|
||||
$userNameInput->setCSSClasses(['lam-initial-focus']);
|
||||
}
|
||||
$userInput = new htmlDiv(null, $userNameInput);
|
||||
$row->addField($userInput);
|
||||
|
@ -319,25 +319,25 @@ function display_LoginPage(?LAMLicenseValidator $licenseValidator, ?string $erro
|
|||
$row->addLabel(new htmlLabel('passwd', _("Password")));
|
||||
if (($config_object->getLoginMethod() == LAMConfig::LOGIN_SEARCH) && ($config_object->getHttpAuthentication() == 'true')) {
|
||||
$passwordInputFake = new htmlDiv(null, new htmlOutputText('**********'));
|
||||
$passwordInputFake->setCSSClasses(array('text-left', 'margin3'));
|
||||
$passwordInputFake->setCSSClasses(['text-left', 'margin3']);
|
||||
$row->addField($passwordInputFake);
|
||||
}
|
||||
else {
|
||||
$passwordInput = new htmlInputField('passwd');
|
||||
$passwordInput->setIsPassword(true);
|
||||
if (($config_object->getLoginMethod() == LAMConfig::LOGIN_SEARCH) && !empty($_COOKIE['lam_login_name'])) {
|
||||
$passwordInput->setCSSClasses(array('lam-initial-focus'));
|
||||
$passwordInput->setCSSClasses(['lam-initial-focus']);
|
||||
}
|
||||
$row->addField($passwordInput);
|
||||
}
|
||||
// language
|
||||
$row->addLabel(new htmlLabel('language', _("Language")));
|
||||
$possibleLanguages = getLanguages();
|
||||
$languageList = array();
|
||||
$defaultLanguage = array();
|
||||
$languageList = [];
|
||||
$defaultLanguage = [];
|
||||
foreach ($possibleLanguages as $lang) {
|
||||
$languageList[$lang->description] = $lang->code;
|
||||
if (strpos(trim($_SESSION["language"]), $lang->code) === 0) {
|
||||
if (str_starts_with(trim($_SESSION["language"]), $lang->code)) {
|
||||
$defaultLanguage[] = $lang->code;
|
||||
}
|
||||
}
|
||||
|
@ -356,16 +356,16 @@ function display_LoginPage(?LAMLicenseValidator $licenseValidator, ?string $erro
|
|||
$rememberGroup->addElement(new htmlSpacer('1px', null));
|
||||
$rememberGroup->addElement(new htmlOutputText(_('Remember user name')));
|
||||
$rememberDiv = new htmlDiv(null, $rememberGroup);
|
||||
$rememberDiv->setCSSClasses(array('text-left', 'margin3'));
|
||||
$rememberDiv->setCSSClasses(['text-left', 'margin3']);
|
||||
$row->add($rememberDiv, 12, 6, 6);
|
||||
}
|
||||
// login button
|
||||
$row->add(new htmlSpacer(null, '20px'), 12);
|
||||
$loginButton = new htmlButton('checklogin', _("Login"));
|
||||
$loginButton->setCSSClasses(array('lam-primary'));
|
||||
$loginButton->setCSSClasses(['lam-primary']);
|
||||
$row->add($loginButton);
|
||||
|
||||
parseHtml(null, $row, array(), false, 'user');
|
||||
parseHtml(null, $row, [], false, 'user');
|
||||
?>
|
||||
</form>
|
||||
</td>
|
||||
|
@ -386,7 +386,7 @@ function display_LoginPage(?LAMLicenseValidator $licenseValidator, ?string $erro
|
|||
$extraMessage = new htmlStatusMessage('INFO', $extraMessage);
|
||||
$row->add($extraMessage, 12);
|
||||
}
|
||||
parseHtml(null, $row, array(), false, 'user');
|
||||
parseHtml(null, $row, [], false, 'user');
|
||||
?>
|
||||
<hr class="margin20">
|
||||
</td>
|
||||
|
@ -399,13 +399,13 @@ function display_LoginPage(?LAMLicenseValidator $licenseValidator, ?string $erro
|
|||
$row->addLabel(new htmlOutputText(_("LDAP server")));
|
||||
$serverUrl = new htmlOutputText($config_object->getServerDisplayNameGUI());
|
||||
$serverUrlDiv = new htmlDiv(null, $serverUrl);
|
||||
$serverUrlDiv->setCSSClasses(array('text-left', 'margin3'));
|
||||
$serverUrlDiv->setCSSClasses(['text-left', 'margin3']);
|
||||
$row->addField($serverUrlDiv);
|
||||
$profileSelect = new htmlResponsiveSelect('profile', $profiles, array($_SESSION['config']->getName()), _("Server profile"));
|
||||
$profileSelect = new htmlResponsiveSelect('profile', $profiles, [$_SESSION['config']->getName()], _("Server profile"));
|
||||
$profileSelect->setOnchangeEvent('loginProfileChanged(this)');
|
||||
$row->add($profileSelect);
|
||||
|
||||
parseHtml(null, $row, array(), true, 'user');
|
||||
parseHtml(null, $row, [], true, 'user');
|
||||
?>
|
||||
</form>
|
||||
</td>
|
||||
|
@ -476,7 +476,7 @@ function displayLoginHeader() : void {
|
|||
<span class="padding0"><?php echo _("LAM configuration") ?></span>
|
||||
</a>
|
||||
<?php
|
||||
if (is_dir(dirname(__FILE__) . '/../docs/manual')) {
|
||||
if (is_dir(__DIR__ . '/../docs/manual')) {
|
||||
?>
|
||||
<a class="lam-menu-entry" target="_blank" href="../docs/manual/index.html">
|
||||
<span class="padding0"><?php echo _("Help") ?></span>
|
||||
|
@ -541,7 +541,7 @@ if (isset($_POST['checklogin'])) {
|
|||
$searchLDAP = new Ldap($_SESSION['config']);
|
||||
try {
|
||||
$searchLDAP->connect($searchDN, $searchPassword, true);
|
||||
$searchResult = ldap_search($searchLDAP->server(), $_SESSION['config']->getLoginSearchSuffix(), $searchFilter, array('dn'), 0, 0, 0, LDAP_DEREF_NEVER);
|
||||
$searchResult = ldap_search($searchLDAP->server(), $_SESSION['config']->getLoginSearchSuffix(), $searchFilter, ['dn'], 0, 0, 0, LDAP_DEREF_NEVER);
|
||||
if ($searchResult) {
|
||||
$searchInfo = ldap_get_entries($searchLDAP->server(), $searchResult);
|
||||
if ($searchInfo !== false) {
|
||||
|
|
|
@ -69,7 +69,7 @@ catch (Exception $e) {
|
|||
logNewMessage(LOG_ERR, 'Unable to get 2-factor serials for ' . $user . ' ' . $e->getMessage());
|
||||
printHeader();
|
||||
$scriptTag = new htmlJavaScript('window.lam.dialog.showErrorMessageAndRedirect("' . _("Unable to start 2-factor authentication.") . '", "", "' . _('Ok') . '", "login.php")');
|
||||
parseHtml(null, $scriptTag, array(), false, null);
|
||||
parseHtml(null, $scriptTag, [], false, null);
|
||||
printFooter();
|
||||
die();
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ if (empty($serials) && $config->getTwoFactorAuthenticationOptional()) {
|
|||
if (empty($serials)) {
|
||||
printHeader();
|
||||
$scriptTag = new htmlJavaScript('window.lam.dialog.showErrorMessageAndRedirect("' . _("Unable to start 2-factor authentication because no tokens were found.") . '", "", "' . _('Ok') . '", "login.php")');
|
||||
parseHtml(null, $scriptTag, array(), false, null);
|
||||
parseHtml(null, $scriptTag, [], false, null);
|
||||
printFooter();
|
||||
die();
|
||||
}
|
||||
|
@ -104,8 +104,8 @@ if (isset($_POST['submit']) || isset($_POST['sig_response']) // WebAuthn
|
|||
|| (isset($_GET['state']) && isset($_GET['code'])) // Okta
|
||||
|| (isset($_GET['state']) && isset($_GET['duo_code'])) // Duo
|
||||
|| (isset($_GET['session_state']) && isset($_GET['redirect_uri']))) { // OpenID
|
||||
$twoFactorInput = isset($_POST['2factor']) ? $_POST['2factor'] : null;
|
||||
$serial = isset($_POST['serial']) ? $_POST['serial'] : null;
|
||||
$twoFactorInput = $_POST['2factor'] ?? null;
|
||||
$serial = $_POST['serial'] ?? null;
|
||||
if (!$provider->hasCustomInputForm() && (empty($twoFactorInput) || !in_array($serial, $serials))) {
|
||||
$errorMessage = sprintf(_('Please enter "%s".'), $twoFactorLabel);
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
|
@ -216,23 +216,23 @@ echo $config->getTwoFactorAuthenticationCaption();
|
|||
$row->add(new htmlSpacer('1em', '1em'));
|
||||
if ($provider->supportsToRememberDevice()) {
|
||||
$remember = new htmlResponsiveInputCheckbox('rememberDevice', false, _('Remember device'), '560');
|
||||
$remember->setCSSClasses(array('lam-save-selection'));
|
||||
$remember->setCSSClasses(['lam-save-selection']);
|
||||
$row->add($remember);
|
||||
$row->add(new htmlSpacer('0.5em', '0.5em'));
|
||||
}
|
||||
if ($provider->isShowSubmitButton()) {
|
||||
$submit = new htmlButton('submit', _("Submit"));
|
||||
$submit->setCSSClasses(array('fullwidth'));
|
||||
$submit->setCSSClasses(['fullwidth']);
|
||||
$row->add($submit, 12, 12, 12, 'fullwidth');
|
||||
$row->add(new htmlSpacer('0.5em', '0.5em'));
|
||||
}
|
||||
$logout = new htmlButton('logout', _("Cancel"));
|
||||
$logout->setCSSClasses(array('fullwidth'));
|
||||
$logout->setCSSClasses(['fullwidth']);
|
||||
$row->add($logout);
|
||||
$group->addElement($row);
|
||||
|
||||
addSecurityTokenToMetaHTML($group);
|
||||
parseHtml(null, $group, array(), false, 'user');
|
||||
parseHtml(null, $group, [], false, 'user');
|
||||
|
||||
?>
|
||||
</div>
|
||||
|
|
|
@ -9,7 +9,7 @@ use LAMException;
|
|||
/*
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||
Copyright (C) 2003 - 2022 Roland Gruber
|
||||
Copyright (C) 2003 - 2023 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
|
||||
|
@ -59,7 +59,7 @@ $conf = $_SESSION['config'];
|
|||
// check if user password is not expired
|
||||
if (!$conf->isHidePasswordPromptForExpiredPasswords()) {
|
||||
$userDn = $_SESSION['ldap']->getUserName();
|
||||
$userData = ldapGetDN($userDn, array('*', '+', 'pwdReset', 'passwordExpirationTime'));
|
||||
$userData = ldapGetDN($userDn, ['*', '+', 'pwdReset', 'passwordExpirationTime']);
|
||||
$ldapErrorCode = ldap_errno($_SESSION['ldap']->server());
|
||||
logNewMessage(LOG_DEBUG, 'Expired password check: Reading ' . $userDn . ' with return code ' . $ldapErrorCode . ' and data: ' . print_r($userData, true));
|
||||
if (($ldapErrorCode != 32) && ($ldapErrorCode != 34)) {
|
||||
|
@ -73,12 +73,12 @@ if (!$conf->isHidePasswordPromptForExpiredPasswords()) {
|
|||
}
|
||||
|
||||
// check if all suffixes in conf-file exist
|
||||
$new_suffs = array();
|
||||
$new_suffs = [];
|
||||
// get list of active types
|
||||
$typeManager = new TypeManager();
|
||||
$types = $typeManager->getConfiguredTypes();
|
||||
foreach ($types as $type) {
|
||||
$info = @ldap_read($_SESSION['ldap']->server(), $type->getSuffix(), "(objectClass=*)", array('objectClass'), 0, 0, 0, LDAP_DEREF_NEVER);
|
||||
$info = @ldap_read($_SESSION['ldap']->server(), $type->getSuffix(), "(objectClass=*)", ['objectClass'], 0, 0, 0, LDAP_DEREF_NEVER);
|
||||
if (($info === false) && !in_array($type->getSuffix(), $new_suffs)) {
|
||||
$new_suffs[] = $type->getSuffix();
|
||||
continue;
|
||||
|
|
|
@ -3,7 +3,7 @@ namespace LAM\PWA;
|
|||
/*
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||
Copyright (C) 2019 - 2022 Roland Gruber
|
||||
Copyright (C) 2019 - 2023 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
|
||||
|
@ -38,9 +38,9 @@ if (!headers_sent()) {
|
|||
}
|
||||
|
||||
$baseUrl = getCallingURL();
|
||||
if (strpos($baseUrl, '/templates/manifest.php') !== false) {
|
||||
if (str_contains($baseUrl, '/templates/manifest.php')) {
|
||||
$baseUrl = substr($baseUrl, 0, strpos($baseUrl, '/templates/manifest.php'));
|
||||
$urlMatches = array();
|
||||
$urlMatches = [];
|
||||
if (preg_match('/http(s)?:\\/\\/[^\\/]+(\\/.*)$/m', $baseUrl, $urlMatches)) {
|
||||
$baseUrl = htmlspecialchars($urlMatches[2]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue