| 1 |
<?php |
| 2 |
|
| 3 |
namespace LAM\CONFIG; |
| 4 |
|
| 5 |
use LAM\LIB\TWO_FACTOR\TwoFactorProviderService; |
| 6 |
use LAM\REMOTE\Remote; |
| 7 |
use LAMCfgMain; |
| 8 |
use LAMConfig; |
| 9 |
use htmlTable; |
| 10 |
use htmlAccordion; |
| 11 |
use htmlSpacer; |
| 12 |
use DateTimeZone; |
| 13 |
use htmlStatusMessage; |
| 14 |
use htmlOutputText; |
| 15 |
use htmlInputCheckbox; |
| 16 |
use htmlHelpLink; |
| 17 |
use htmlSubTitle; |
| 18 |
use htmlButton; |
| 19 |
use htmlResponsiveRow; |
| 20 |
use htmlResponsiveInputField; |
| 21 |
use htmlResponsiveSelect; |
| 22 |
use htmlResponsiveInputCheckbox; |
| 23 |
use htmlResponsiveInputTextarea; |
| 24 |
use htmlGroup; |
| 25 |
use LAMException; |
| 26 |
use ServerProfilePersistenceManager; |
| 27 |
|
| 28 |
/* |
| 29 |
|
| 30 |
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) |
| 31 |
Copyright (C) 2003 - 2026 Roland Gruber |
| 32 |
|
| 33 |
This program is free software; you can redistribute it and/or modify |
| 34 |
it under the terms of the GNU General Public License as published by |
| 35 |
the Free Software Foundation; either version 2 of the License, or |
| 36 |
(at your option) any later version. |
| 37 |
|
| 38 |
This program is distributed in the hope that it will be useful, |
| 39 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 40 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 41 |
GNU General Public License for more details. |
| 42 |
|
| 43 |
You should have received a copy of the GNU General Public License |
| 44 |
along with this program; if not, write to the Free Software |
| 45 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 46 |
|
| 47 |
*/ |
| 48 |
|
| 49 |
|
| 50 |
/** |
| 51 |
* Main page of configuration |
| 52 |
* |
| 53 |
* @package configuration |
| 54 |
* @author Roland Gruber |
| 55 |
* @author Thomas Manninger |
| 56 |
*/ |
| 57 |
|
| 58 |
|
| 59 |
/** Access to config functions */ |
| 60 |
include_once(__DIR__ . "/../../lib/config.inc"); |
| 61 |
/** access to module settings */ |
| 62 |
include_once(__DIR__ . "/../../lib/modules.inc"); |
| 63 |
/** access to tools */ |
| 64 |
include_once(__DIR__ . "/../../lib/tools.inc"); |
| 65 |
/** 2-factor */ |
| 66 |
include_once __DIR__ . '/../../lib/2factor.inc'; |
| 67 |
/** common functions */ |
| 68 |
include_once __DIR__ . '/../../lib/configPages.inc'; |
| 69 |
|
| 70 |
// start session |
| 71 |
if (isFileBasedSession()) { |
| 72 |
session_save_path("../../sess"); |
| 73 |
} |
| 74 |
lam_start_session(); |
| 75 |
|
| 76 |
setlanguage(); |
| 77 |
|
| 78 |
// get password |
| 79 |
$passwd = null; |
| 80 |
if (isset($_POST['passwd'])) { |
| 81 |
$passwd = $_POST['passwd']; |
| 82 |
} |
| 83 |
|
| 84 |
// check if password was entered |
| 85 |
// if not: load login page |
| 86 |
if (!isset($passwd) && !(isset($_SESSION['conf_isAuthenticated']) && isset($_SESSION['conf_config']))) { |
| 87 |
$_SESSION['conf_message'] = new htmlStatusMessage('ERROR', _("No password was entered!")); |
| 88 |
/** go back to login if password is empty */ |
| 89 |
metaRefresh('conflogin.php'); |
| 90 |
exit; |
| 91 |
} |
| 92 |
|
| 93 |
$serverProfilePersistenceManager = new ServerProfilePersistenceManager(); |
| 94 |
|
| 95 |
if (!isset($_SESSION['conf_config']) && isset($_POST['filename'])) { |
| 96 |
try { |
| 97 |
$_SESSION['conf_config'] = $serverProfilePersistenceManager->loadProfile($_POST['filename']); |
| 98 |
} |
| 99 |
catch (LAMException $e) { |
| 100 |
$_SESSION['conf_message'] = new htmlStatusMessage('ERROR', $e->getTitle()); |
| 101 |
metaRefresh('conflogin.php'); |
| 102 |
exit; |
| 103 |
} |
| 104 |
} |
| 105 |
$conf = &$_SESSION['conf_config']; |
| 106 |
|
| 107 |
// check if password is valid |
| 108 |
// if not: load login page |
| 109 |
if ((!isset($_SESSION['conf_isAuthenticated']) || ($_SESSION['conf_isAuthenticated'] !== $conf->getName())) |
| 110 |
&& !$conf->check_Passwd($passwd)) { |
| 111 |
$sessionKeys = array_keys($_SESSION); |
| 112 |
foreach ($sessionKeys as $sessionKey) { |
| 113 |
if (str_starts_with($sessionKey, "conf_")) { |
| 114 |
unset($_SESSION[$sessionKey]); |
| 115 |
} |
| 116 |
} |
| 117 |
$_SESSION['conf_message'] = new htmlStatusMessage('ERROR', _("The password is invalid! Please try again.")); |
| 118 |
/** go back to login if password is invalid */ |
| 119 |
metaRefresh('conflogin.php'); |
| 120 |
exit; |
| 121 |
} |
| 122 |
$_SESSION['conf_isAuthenticated'] = $conf->getName(); |
| 123 |
|
| 124 |
// check if user canceled editing |
| 125 |
if (isset($_POST['cancelSettings'])) { |
| 126 |
metaRefresh("../login.php"); |
| 127 |
exit; |
| 128 |
} |
| 129 |
|
| 130 |
$errorsToDisplay = []; |
| 131 |
if (isset($_SESSION['conf_messages']) && is_array($_SESSION['conf_messages'])) { |
| 132 |
$errorsToDisplay = array_merge($errorsToDisplay, $_SESSION['conf_messages']); |
| 133 |
unset($_SESSION['conf_messages']); |
| 134 |
} |
| 135 |
|
| 136 |
// check if button was pressed and if we have to save the settings or go to another tab |
| 137 |
if (isset($_POST['saveSettings']) || isset($_POST['editmodules']) |
| 138 |
|| isset($_POST['edittypes']) || isset($_POST['generalSettingsButton']) |
| 139 |
|| isset($_POST['moduleSettings']) || isset($_POST['jobs'])) { |
| 140 |
$errorsToDisplay = checkInput(); |
| 141 |
if (count($errorsToDisplay) === 0) { |
| 142 |
// go to final page |
| 143 |
if (isset($_POST['saveSettings'])) { |
| 144 |
metaRefresh("confsave.php"); |
| 145 |
exit; |
| 146 |
} |
| 147 |
// go to modules page |
| 148 |
elseif (isset($_POST['editmodules'])) { |
| 149 |
metaRefresh("confmodules.php"); |
| 150 |
exit; |
| 151 |
} |
| 152 |
// go to types page |
| 153 |
elseif (isset($_POST['edittypes'])) { |
| 154 |
metaRefresh("conftypes.php"); |
| 155 |
exit; |
| 156 |
} |
| 157 |
// go to module settings page |
| 158 |
elseif (isset($_POST['moduleSettings'])) { |
| 159 |
metaRefresh("moduleSettings.php"); |
| 160 |
exit; |
| 161 |
} |
| 162 |
// go to jobs page |
| 163 |
elseif (isset($_POST['jobs'])) { |
| 164 |
metaRefresh("jobs.php"); |
| 165 |
exit; |
| 166 |
} |
| 167 |
} |
| 168 |
} |
| 169 |
|
| 170 |
|
| 171 |
echo $_SESSION['header']; |
| 172 |
printHeaderContents(_("LDAP Account Manager Configuration"), '../..'); |
| 173 |
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../templates/lib/extra/jodit/jodit.css\">\n"; |
| 174 |
echo "<body>\n"; |
| 175 |
// include all JavaScript files |
| 176 |
printJsIncludes('../..'); |
| 177 |
printConfigurationPageHeaderBar($conf); |
| 178 |
|
| 179 |
if (!$serverProfilePersistenceManager->isWritable($_SESSION['conf_config']->getName())) { |
| 180 |
StatusMessage('WARN', _('The config file is not writable.'), _('Your changes cannot be saved until you make the file writable for the webserver user.')); |
| 181 |
echo "<br>"; |
| 182 |
} |
| 183 |
|
| 184 |
// display error messages |
| 185 |
if ($errorsToDisplay !== []) { |
| 186 |
foreach ($errorsToDisplay as $errorToDisplay) { |
| 187 |
call_user_func_array(StatusMessage(...), $errorToDisplay); |
| 188 |
} |
| 189 |
echo "<br>"; |
| 190 |
} |
| 191 |
|
| 192 |
$cfgMain = new LAMCfgMain(); |
| 193 |
|
| 194 |
// display formular |
| 195 |
echo "<form enctype=\"multipart/form-data\" action=\"confmain.php\" method=\"post\" autocomplete=\"off\" novalidate=\"novalidate\">\n"; |
| 196 |
|
| 197 |
printConfigurationPageTabs(ConfigurationPageTab::GENERAL); |
| 198 |
|
| 199 |
?> |
| 200 |
<input type="text" name="hiddenPreventAutocomplete" autocomplete="false" class="hidden" value=""> |
| 201 |
<input type="password" name="hiddenPreventAutocompletePwd1" autocomplete="false" class="hidden" value="123"> |
| 202 |
<input type="password" name="hiddenPreventAutocompletePwd2" autocomplete="false" class="hidden" value="321"> |
| 203 |
<?php |
| 204 |
|
| 205 |
$row = new htmlResponsiveRow(); |
| 206 |
|
| 207 |
$serverSettings = new htmlSubTitle(_("Server settings"), '../../graphics/world.svg', null, true); |
| 208 |
$row->add($serverSettings); |
| 209 |
// server URL |
| 210 |
$urlInput = new htmlResponsiveInputField(_("Server address"), 'serverurl', $conf->get_ServerURL(), '201'); |
| 211 |
$urlInput->setRequired(true); |
| 212 |
$row->add($urlInput); |
| 213 |
// use TLS |
| 214 |
$tlsOptions = [_("yes") => 'yes', _("no") => 'no']; |
| 215 |
$tlsSelect = new htmlResponsiveSelect('useTLS', $tlsOptions, [$conf->getUseTLS()], _("Activate TLS"), '201'); |
| 216 |
$tlsSelect->setHasDescriptiveElements(true); |
| 217 |
$row->add($tlsSelect); |
| 218 |
// LDAP search limit |
| 219 |
$searchLimitOptions = [ |
| 220 |
'-' => '0', |
| 221 |
'100' => '100', |
| 222 |
'500' => '500', |
| 223 |
'1000' => '1000', |
| 224 |
'5000' => '5000', |
| 225 |
'10000' => '10000', |
| 226 |
'50000' => '50000', |
| 227 |
'100000' => '100000' |
| 228 |
]; |
| 229 |
$limitSelect = new htmlResponsiveSelect('searchLimit', $searchLimitOptions, [$conf->get_searchLimit()], _("LDAP search limit"), '222'); |
| 230 |
$limitSelect->setHasDescriptiveElements(true); |
| 231 |
$row->add($limitSelect); |
| 232 |
// DN part to hide |
| 233 |
$urlInput = new htmlResponsiveInputField(_("DN part to hide"), 'hideDnPart', $conf->getHideDnPart(), '292'); |
| 234 |
$row->add($urlInput); |
| 235 |
|
| 236 |
// access level is only visible in Pro version |
| 237 |
if (isLAMProVersion()) { |
| 238 |
$accessOptions = [ |
| 239 |
_('Write access') => LAMConfig::ACCESS_ALL, |
| 240 |
_('Change passwords') => LAMConfig::ACCESS_PASSWORD_CHANGE, |
| 241 |
_('Read-only') => LAMConfig::ACCESS_READ_ONLY |
| 242 |
]; |
| 243 |
$accessSelect = new htmlResponsiveSelect('accessLevel', $accessOptions, [$conf->getAccessLevel()], _("Access level"), '215'); |
| 244 |
$accessSelect->setHasDescriptiveElements(true); |
| 245 |
$row->add($accessSelect); |
| 246 |
} |
| 247 |
|
| 248 |
$row->addVerticalSpacer('1rem'); |
| 249 |
// login method |
| 250 |
$loginOptions = [ |
| 251 |
_('Fixed list') => LAMConfig::LOGIN_LIST, |
| 252 |
_('LDAP search') => LAMConfig::LOGIN_SEARCH |
| 253 |
]; |
| 254 |
$loginSelect = new htmlResponsiveSelect('loginMethod', $loginOptions, [$conf->getLoginMethod()], _("Login method"), '220'); |
| 255 |
$loginSelect->setHasDescriptiveElements(true); |
| 256 |
$loginSelect->setTableRowsToHide([ |
| 257 |
LAMConfig::LOGIN_LIST => ['loginSearchSuffix', 'loginSearchFilter', 'loginSearchDN', 'loginSearchPassword', 'httpAuthentication'], |
| 258 |
LAMConfig::LOGIN_SEARCH => ['admins'] |
| 259 |
]); |
| 260 |
$loginSelect->setTableRowsToShow([ |
| 261 |
LAMConfig::LOGIN_LIST => ['admins'], |
| 262 |
LAMConfig::LOGIN_SEARCH => ['loginSearchSuffix', 'loginSearchFilter', 'loginSearchDN', 'loginSearchPassword', 'httpAuthentication'] |
| 263 |
]); |
| 264 |
$row->add($loginSelect); |
| 265 |
// admin list |
| 266 |
$adminText = implode("\n", explode(";", $conf->get_Adminstring())); |
| 267 |
$adminTextInput = new htmlResponsiveInputTextarea('admins', $adminText, 50, 3, _("List of valid users"), '207'); |
| 268 |
$adminTextInput->setRequired(true); |
| 269 |
$row->add($adminTextInput); |
| 270 |
// search suffix |
| 271 |
$searchSuffixInput = new htmlResponsiveInputField(_("LDAP suffix"), 'loginSearchSuffix', $conf->getLoginSearchSuffix(), '221'); |
| 272 |
$searchSuffixInput->setRequired(true); |
| 273 |
$row->add($searchSuffixInput); |
| 274 |
// login search filter |
| 275 |
$searchFilterInput = new htmlResponsiveInputField(_("LDAP filter"), 'loginSearchFilter', $conf->getLoginSearchFilter(), '221'); |
| 276 |
$searchFilterInput->setRequired(true); |
| 277 |
$row->add($searchFilterInput); |
| 278 |
// login search bind user |
| 279 |
$row->add(new htmlResponsiveInputField(_("Bind user"), 'loginSearchDN', $conf->getLoginSearchDN(), '224')); |
| 280 |
// login search bind password |
| 281 |
$searchPasswordInput = new htmlResponsiveInputField(_("Bind password"), 'loginSearchPassword', $conf->getLoginSearchPassword(), '224'); |
| 282 |
$searchPasswordInput->setIsPassword(true); |
| 283 |
$row->add($searchPasswordInput); |
| 284 |
// HTTP authentication |
| 285 |
$row->add(new htmlResponsiveInputCheckbox('httpAuthentication', ($conf->getHttpAuthentication() == 'true'), _('HTTP authentication'), '223')); |
| 286 |
$row->addVerticalSpacer('1rem'); |
| 287 |
|
| 288 |
// advanced options |
| 289 |
$advancedOptionsContent = new htmlResponsiveRow(); |
| 290 |
// display name |
| 291 |
$advancedOptionsContent->add(new htmlResponsiveInputField(_('Display name'), 'serverDisplayName', $conf->getServerDisplayName(), '268')); |
| 292 |
// referrals |
| 293 |
$followReferrals = ($conf->getFollowReferrals() === 'true'); |
| 294 |
$advancedOptionsContent->add(new htmlResponsiveInputCheckbox('followReferrals', $followReferrals, _('Follow referrals'), '205')); |
| 295 |
// paged results |
| 296 |
$pagedResults = ($conf->getPagedResults() === 'true'); |
| 297 |
$advancedOptionsContent->add(new htmlResponsiveInputCheckbox('pagedResults', $pagedResults, _('Paged results'), '266')); |
| 298 |
// show deleted entries |
| 299 |
$adShowDeleted = ($conf->getAdShowDeleted() === 'true'); |
| 300 |
$advancedOptionsContent->add(new htmlResponsiveInputCheckbox('adShowDeleted', $adShowDeleted, _('Show deleted entries'), '295')); |
| 301 |
// referential integrity overlay |
| 302 |
$referentialIntegrity = ($conf->isReferentialIntegrityOverlayActive()); |
| 303 |
$advancedOptionsContent->add(new htmlResponsiveInputCheckbox('referentialIntegrityOverlay', $referentialIntegrity, _('Referential integrity overlay'), '269')); |
| 304 |
// hide password prompt for expired passwords |
| 305 |
$hidePasswordPromptForExpiredPasswords = ($conf->isHidePasswordPromptForExpiredPasswords()); |
| 306 |
$advancedOptionsContent->add(new htmlResponsiveInputCheckbox('hidePasswordPromptForExpiredPasswords', $hidePasswordPromptForExpiredPasswords, _('Hide password prompt for expired password'), '291')); |
| 307 |
|
| 308 |
// build advanced options box |
| 309 |
$advancedOptions = new htmlAccordion('advancedOptions_server', [_('Advanced options') => $advancedOptionsContent], false); |
| 310 |
$advancedOptions->colspan = 15; |
| 311 |
$row->add($advancedOptions); |
| 312 |
|
| 313 |
$row->addVerticalSpacer('2rem'); |
| 314 |
|
| 315 |
// language |
| 316 |
$row->add(new htmlSubTitle(_("Language settings"), '../../graphics/language.svg', null, true)); |
| 317 |
// read available languages |
| 318 |
$possibleLanguages = getLanguages(); |
| 319 |
$defaultLanguage = ['en_GB.utf8']; |
| 320 |
if (!empty($possibleLanguages)) { |
| 321 |
$languages = []; |
| 322 |
foreach ($possibleLanguages as $lang) { |
| 323 |
$languages[$lang->description] = $lang->code; |
| 324 |
if (str_starts_with($conf->get_defaultLanguage(), $lang->code)) { |
| 325 |
$defaultLanguage = [$lang->code]; |
| 326 |
} |
| 327 |
} |
| 328 |
$languageSelect = new htmlResponsiveSelect('lang', $languages, $defaultLanguage, _("Default language"), '209'); |
| 329 |
$languageSelect->setHasDescriptiveElements(true); |
| 330 |
$row->add($languageSelect); |
| 331 |
} |
| 332 |
else { |
| 333 |
$row->add(new htmlStatusMessage('ERROR', "Unable to load available languages. Setting English as default language.")); |
| 334 |
} |
| 335 |
$timezones = []; |
| 336 |
$timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::AFRICA)); |
| 337 |
$timezones = [...$timezones, ...DateTimeZone::listIdentifiers(DateTimeZone::AMERICA)]; |
| 338 |
$timezones = [...$timezones, ...DateTimeZone::listIdentifiers(DateTimeZone::ANTARCTICA)]; |
| 339 |
$timezones = [...$timezones, ...DateTimeZone::listIdentifiers(DateTimeZone::ARCTIC)]; |
| 340 |
$timezones = [...$timezones, ...DateTimeZone::listIdentifiers(DateTimeZone::ASIA)]; |
| 341 |
$timezones = [...$timezones, ...DateTimeZone::listIdentifiers(DateTimeZone::ATLANTIC)]; |
| 342 |
$timezones = [...$timezones, ...DateTimeZone::listIdentifiers(DateTimeZone::AUSTRALIA)]; |
| 343 |
$timezones = [...$timezones, ...DateTimeZone::listIdentifiers(DateTimeZone::EUROPE)]; |
| 344 |
$timezones = [...$timezones, ...DateTimeZone::listIdentifiers(DateTimeZone::INDIAN)]; |
| 345 |
$timezones = [...$timezones, ...DateTimeZone::listIdentifiers(DateTimeZone::PACIFIC)]; |
| 346 |
$timezones = [...$timezones, ...DateTimeZone::listIdentifiers(DateTimeZone::UTC)]; |
| 347 |
$row->add(new htmlResponsiveSelect('timeZone', $timezones, [$conf->getTimeZone()], _('Time zone'), '213')); |
| 348 |
|
| 349 |
$row->addVerticalSpacer('2rem'); |
| 350 |
|
| 351 |
// tool settings |
| 352 |
$row->add(new htmlSubTitle(_("Tool settings"), '../../graphics/configure.svg', null, true)); |
| 353 |
$toolSettings = $conf->getToolSettings(); |
| 354 |
$tools = getTools(); |
| 355 |
$row->add(new htmlOutputText(_('Hidden tools'))); |
| 356 |
$row->addVerticalSpacer('0.5rem'); |
| 357 |
$hideableTools = 0; |
| 358 |
foreach ($tools as $tool) { |
| 359 |
if (!$tool->isHideable()) { |
| 360 |
continue; |
| 361 |
} |
| 362 |
$hideableTools++; |
| 363 |
$toolClass = $tool::class; |
| 364 |
$toolName = substr($toolClass, strrpos($toolClass, '\\') + 1); |
| 365 |
$selected = false; |
| 366 |
if (isset($toolSettings['tool_hide_' . $toolName]) && ($toolSettings['tool_hide_' . $toolName] === 'true')) { |
| 367 |
$selected = true; |
| 368 |
} |
| 369 |
$row->add(new htmlResponsiveInputCheckbox('tool_hide_' . $toolName, $selected, $tool->getName(), null, true), 12, 4); |
| 370 |
} |
| 371 |
for ($i = $hideableTools % 3; $i < 3; $i++) { |
| 372 |
$row->add(new htmlOutputText(''), 0, 4); |
| 373 |
} |
| 374 |
$toolConfigOptionTypes = []; |
| 375 |
foreach ($tools as $tool) { |
| 376 |
$toolConfigContent = $tool->getConfigOptions($toolSettings); |
| 377 |
if ($toolConfigContent !== null) { |
| 378 |
ob_start(); |
| 379 |
$optionTypes = parseHtml(null, $tool->getConfigOptions($toolSettings), [], true, 'user'); |
| 380 |
ob_end_clean(); |
| 381 |
$toolConfigOptionTypes = array_merge($toolConfigOptionTypes, $optionTypes); |
| 382 |
$row->addVerticalSpacer('1rem'); |
| 383 |
$row->add($toolConfigContent); |
| 384 |
} |
| 385 |
} |
| 386 |
$_SESSION['confmain_toolTypes'] = $toolConfigOptionTypes; |
| 387 |
|
| 388 |
$row->addVerticalSpacer('2rem'); |
| 389 |
|
| 390 |
// LAM Pro settings |
| 391 |
if (isLAMProVersion()) { |
| 392 |
// password reset page |
| 393 |
$row->add(new htmlSubTitle(_("Password reset page settings"), '../../graphics/key.svg', null, true)); |
| 394 |
|
| 395 |
$pwdResetAllowSpecific = true; |
| 396 |
if ($conf->getPwdResetAllowSpecificPassword() == 'false') { |
| 397 |
$pwdResetAllowSpecific = false; |
| 398 |
} |
| 399 |
$row->add(new htmlResponsiveInputCheckbox('pwdResetAllowSpecificPassword', $pwdResetAllowSpecific, _('Allow setting specific passwords'), '280')); |
| 400 |
|
| 401 |
$pwdResetAllowScreenPassword = true; |
| 402 |
if ($conf->getPwdResetAllowScreenPassword() == 'false') { |
| 403 |
$pwdResetAllowScreenPassword = false; |
| 404 |
} |
| 405 |
$row->add(new htmlResponsiveInputCheckbox('pwdResetAllowScreenPassword', $pwdResetAllowScreenPassword, _('Allow to display password on screen'), '281')); |
| 406 |
|
| 407 |
$pwdResetForcePasswordChange = true; |
| 408 |
if ($conf->getPwdResetForcePasswordChange() == 'false') { |
| 409 |
$pwdResetForcePasswordChange = false; |
| 410 |
} |
| 411 |
$row->add(new htmlResponsiveInputCheckbox('pwdResetForcePasswordChange', $pwdResetForcePasswordChange, _('Force password change by default'), '283')); |
| 412 |
|
| 413 |
$pwdResetDefaultPasswordOutputOptions = [ |
| 414 |
_('Display on screen') => LAMConfig::PWDRESET_DEFAULT_SCREEN, |
| 415 |
_('Send via mail') => LAMConfig::PWDRESET_DEFAULT_MAIL, |
| 416 |
_('All') => LAMConfig::PWDRESET_DEFAULT_ALL |
| 417 |
]; |
| 418 |
if (!empty($cfgMain->smsProvider)) { |
| 419 |
$pwdResetDefaultPasswordOutputOptions[_('Send via SMS')] = LAMConfig::PWDRESET_DEFAULT_SMS; |
| 420 |
} |
| 421 |
$pwdResetDefaultPasswordOutputSelect = new htmlResponsiveSelect('pwdResetDefaultPasswordOutput', $pwdResetDefaultPasswordOutputOptions, [$conf->getPwdResetDefaultPasswordOutput()], _("Default password output"), '282'); |
| 422 |
$pwdResetDefaultPasswordOutputSelect->setHasDescriptiveElements(true); |
| 423 |
$row->add($pwdResetDefaultPasswordOutputSelect); |
| 424 |
|
| 425 |
$row->addVerticalSpacer('2rem'); |
| 426 |
|
| 427 |
// mail settings |
| 428 |
$row->add(new htmlSubTitle(_("Password mail settings"), '../../graphics/mail.svg', null, true)); |
| 429 |
|
| 430 |
$pwdMailFrom = new htmlResponsiveInputField(_('From address'), 'pwdResetMail_from', $conf->getLamProMailFrom(), '550', true); |
| 431 |
$row->add($pwdMailFrom); |
| 432 |
|
| 433 |
$pwdMailReplyTo = new htmlResponsiveInputField(_('Reply-to address'), 'pwdResetMail_replyTo', $conf->getLamProMailReplyTo(), '554'); |
| 434 |
$row->add($pwdMailReplyTo); |
| 435 |
|
| 436 |
$pwdMailSubject = new htmlResponsiveInputField(_('Subject'), 'pwdResetMail_subject', $conf->getLamProMailSubject(), '551'); |
| 437 |
$row->add($pwdMailSubject); |
| 438 |
|
| 439 |
$pwdMailIsHTML = false; |
| 440 |
if ($conf->getLamProMailIsHTML() == 'true') { |
| 441 |
$pwdMailIsHTML = true; |
| 442 |
} |
| 443 |
$row->add(new htmlResponsiveInputCheckbox('pwdResetMail_isHTML', $pwdMailIsHTML, _('HTML format'), '553')); |
| 444 |
|
| 445 |
$pwdMailAllowAlternate = true; |
| 446 |
if ($conf->getLamProMailAllowAlternateAddress() == 'false') { |
| 447 |
$pwdMailAllowAlternate = false; |
| 448 |
} |
| 449 |
$row->add(new htmlResponsiveInputCheckbox('pwdResetMail_allowAlternate', $pwdMailAllowAlternate, _('Allow alternate address'), '555')); |
| 450 |
|
| 451 |
$pwdMailBody = new htmlResponsiveInputTextarea('pwdResetMail_body', $conf->getLamProMailText(), 50, 4, _('Text'), '552'); |
| 452 |
$row->add($pwdMailBody); |
| 453 |
|
| 454 |
$row->addVerticalSpacer('2rem'); |
| 455 |
} |
| 456 |
|
| 457 |
// lamdaemon settings |
| 458 |
$row->add(new htmlSubTitle(_("Lamdaemon settings"), '../../graphics/script.svg', null, true)); |
| 459 |
$row->add(new htmlResponsiveInputField(_("Server list"), 'scriptservers', $conf->get_scriptServers(), '218')); |
| 460 |
$row->add(new htmlResponsiveInputField(_("Path to external script"), 'scriptpath', $conf->get_scriptPath(), '210')); |
| 461 |
|
| 462 |
$row->add(new htmlResponsiveInputField(_('User name'), 'scriptuser', $conf->getScriptUserName(), '284')); |
| 463 |
$row->add(new htmlResponsiveInputField(_('SSH key file'), 'scriptkey', $conf->getScriptSSHKey(), '285')); |
| 464 |
$sshKeyPassword = new htmlResponsiveInputField(_('SSH key password'), 'scriptkeypassword', $conf->getScriptSSHKeyPassword(), '286'); |
| 465 |
$sshKeyPassword->setIsPassword(true); |
| 466 |
$row->add($sshKeyPassword); |
| 467 |
|
| 468 |
$row->addVerticalSpacer('0.5rem'); |
| 469 |
$lamdaemonRightsLabel = new htmlGroup(); |
| 470 |
$lamdaemonRightsLabel->addElement(new htmlOutputText(_("Rights for the home directory"))); |
| 471 |
$lamdaemonRightsLabel->addElement(new htmlSpacer('0.2rem', null)); |
| 472 |
$lamdaemonRightsLabel->addElement(new htmlHelpLink('219')); |
| 473 |
$row->addLabel($lamdaemonRightsLabel); |
| 474 |
$chmod = $conf->get_scriptRights(); |
| 475 |
$rightsTable = new htmlTable(); |
| 476 |
$rightsTable->setCSSClasses(['padding5']); |
| 477 |
$rightsTable->addElement(new htmlOutputText('')); |
| 478 |
$rightsTable->addElement(new htmlOutputText(_("Read"))); |
| 479 |
$rightsTable->addElement(new htmlOutputText(_("Write"))); |
| 480 |
$rightsTable->addElement(new htmlOutputText(_("Execute")), true); |
| 481 |
$rightsTable->addElement(new htmlOutputText(_("Owner"))); |
| 482 |
$rightsTable->addElement(new htmlInputCheckbox('chmod_owr', checkChmod("read", "owner", $chmod))); |
| 483 |
$rightsTable->addElement(new htmlInputCheckbox('chmod_oww', checkChmod("write", "owner", $chmod))); |
| 484 |
$rightsTable->addElement(new htmlInputCheckbox('chmod_owe', checkChmod("execute", "owner", $chmod)), true); |
| 485 |
$rightsTable->addElement(new htmlOutputText(_("Group"))); |
| 486 |
$rightsTable->addElement(new htmlInputCheckbox('chmod_grr', checkChmod("read", "group", $chmod))); |
| 487 |
$rightsTable->addElement(new htmlInputCheckbox('chmod_grw', checkChmod("write", "group", $chmod))); |
| 488 |
$rightsTable->addElement(new htmlInputCheckbox('chmod_gre', checkChmod("execute", "group", $chmod)), true); |
| 489 |
$rightsTable->addElement(new htmlOutputText(_("Other"))); |
| 490 |
$rightsTable->addElement(new htmlInputCheckbox('chmod_otr', checkChmod("read", "other", $chmod))); |
| 491 |
$rightsTable->addElement(new htmlInputCheckbox('chmod_otw', checkChmod("write", "other", $chmod))); |
| 492 |
$rightsTable->addElement(new htmlInputCheckbox('chmod_ote', checkChmod("execute", "other", $chmod)), true); |
| 493 |
$row->addField($rightsTable); |
| 494 |
|
| 495 |
$row->addVerticalSpacer('2rem'); |
| 496 |
|
| 497 |
// security settings |
| 498 |
$row->add(new htmlSubTitle(_("Security settings"), '../../graphics/locked.svg', null, true)); |
| 499 |
// password policy override |
| 500 |
$row->add(new htmlSubTitle(_("Global password policy override"), '../../graphics/locked.svg')); |
| 501 |
$optionsPwdLength = ['']; |
| 502 |
for ($i = 1; $i <= 50; $i++) { |
| 503 |
$optionsPwdLength[] = $i; |
| 504 |
} |
| 505 |
$row->add(new htmlResponsiveSelect('pwdPolicyMinLength', $optionsPwdLength, [$conf->getPwdPolicyMinLength()], _('Minimum password length'), '242')); |
| 506 |
$row->add(new htmlResponsiveSelect('pwdPolicyMinLowercase', $optionsPwdLength, [$conf->getpwdPolicyMinLowercase()], _('Minimum lowercase characters'), '242')); |
| 507 |
$row->add(new htmlResponsiveSelect('pwdPolicyMinUppercase', $optionsPwdLength, [$conf->getPwdPolicyMinUppercase()], _('Minimum uppercase characters'), '242')); |
| 508 |
$row->add(new htmlResponsiveSelect('pwdPolicyMinNumeric', $optionsPwdLength, [$conf->getPwdPolicyMinNumeric()], _('Minimum numeric characters'), '242')); |
| 509 |
$row->add(new htmlResponsiveSelect('pwdPolicyMinSymbolic', $optionsPwdLength, [$conf->getPwdPolicyMinSymbolic()], _('Minimum symbolic characters'), '242')); |
| 510 |
|
| 511 |
// 2factor authentication |
| 512 |
if (extension_loaded('curl')) { |
| 513 |
$row->add(new htmlSubTitle(_("2-factor authentication"), '../../graphics/locked.svg')); |
| 514 |
$twoFactorOptions = [ |
| 515 |
_('None') => TwoFactorProviderService::TWO_FACTOR_NONE, |
| 516 |
'privacyIDEA' => TwoFactorProviderService::TWO_FACTOR_PRIVACYIDEA, |
| 517 |
'YubiKey' => TwoFactorProviderService::TWO_FACTOR_YUBICO, |
| 518 |
'Duo' => TwoFactorProviderService::TWO_FACTOR_DUO, |
| 519 |
'Okta' => TwoFactorProviderService::TWO_FACTOR_OKTA, |
| 520 |
'OpenId' => TwoFactorProviderService::TWO_FACTOR_OPENID, |
| 521 |
'WebAuthn' => TwoFactorProviderService::TWO_FACTOR_WEBAUTHN |
| 522 |
]; |
| 523 |
$twoFactorSelect = new htmlResponsiveSelect('twoFactor', $twoFactorOptions, [$conf->getTwoFactorAuthentication()], _('Provider'), '514'); |
| 524 |
$twoFactorSelect->setHasDescriptiveElements(true); |
| 525 |
$twoFactorSelect->setTableRowsToHide([ |
| 526 |
TwoFactorProviderService::TWO_FACTOR_NONE => ['twoFactorURL', 'twoFactorURLs', 'twoFactorInsecure', 'twoFactorLabel', |
| 527 |
'twoFactorOptional', 'twoFactorCaption', 'twoFactorClientId', 'twoFactorSecretKey', 'twoFactorAttribute', |
| 528 |
'twoFactorDomain', 'twoFactorAllowToRememberDeviceOptions'], |
| 529 |
TwoFactorProviderService::TWO_FACTOR_PRIVACYIDEA => ['twoFactorURLs', 'twoFactorClientId', 'twoFactorSecretKey', 'twoFactorDomain'], |
| 530 |
TwoFactorProviderService::TWO_FACTOR_YUBICO => ['twoFactorURL', 'twoFactorAttribute', 'twoFactorDomain'], |
| 531 |
TwoFactorProviderService::TWO_FACTOR_DUO => ['twoFactorURLs', 'twoFactorOptional', 'twoFactorInsecure', 'twoFactorLabel', |
| 532 |
'twoFactorDomain', 'twoFactorAllowToRememberDeviceOptions'], |
| 533 |
TwoFactorProviderService::TWO_FACTOR_OKTA => ['twoFactorURLs', 'twoFactorOptional', 'twoFactorInsecure', 'twoFactorLabel', |
| 534 |
'twoFactorDomain', 'twoFactorAllowToRememberDeviceOptions'], |
| 535 |
TwoFactorProviderService::TWO_FACTOR_OPENID => ['twoFactorURLs', 'twoFactorOptional', 'twoFactorInsecure', 'twoFactorLabel', |
| 536 |
'twoFactorDomain', 'twoFactorAllowToRememberDeviceOptions'], |
| 537 |
TwoFactorProviderService::TWO_FACTOR_WEBAUTHN => ['twoFactorURL', 'twoFactorURLs', 'twoFactorInsecure', 'twoFactorLabel', |
| 538 |
'twoFactorCaption', 'twoFactorClientId', 'twoFactorSecretKey', 'twoFactorAttribute'] |
| 539 |
]); |
| 540 |
$twoFactorSelect->setTableRowsToShow([ |
| 541 |
TwoFactorProviderService::TWO_FACTOR_PRIVACYIDEA => ['twoFactorURL', 'twoFactorInsecure', 'twoFactorLabel', |
| 542 |
'twoFactorOptional', 'twoFactorCaption', 'twoFactorAttribute', 'twoFactorAllowToRememberDeviceOptions'], |
| 543 |
TwoFactorProviderService::TWO_FACTOR_YUBICO => ['twoFactorURLs', 'twoFactorInsecure', 'twoFactorLabel', |
| 544 |
'twoFactorOptional', 'twoFactorCaption', 'twoFactorClientId', 'twoFactorSecretKey', 'twoFactorAllowToRememberDeviceOptions'], |
| 545 |
TwoFactorProviderService::TWO_FACTOR_DUO => ['twoFactorURL', 'twoFactorLabel', 'twoFactorCaption', |
| 546 |
'twoFactorClientId', 'twoFactorSecretKey', 'twoFactorAttribute'], |
| 547 |
TwoFactorProviderService::TWO_FACTOR_OKTA => ['twoFactorURL', 'twoFactorCaption', 'twoFactorClientId', |
| 548 |
'twoFactorSecretKey', 'twoFactorAttribute'], |
| 549 |
TwoFactorProviderService::TWO_FACTOR_OPENID => ['twoFactorURL', 'twoFactorCaption', 'twoFactorClientId', |
| 550 |
'twoFactorSecretKey', 'twoFactorAttribute'], |
| 551 |
TwoFactorProviderService::TWO_FACTOR_WEBAUTHN => ['twoFactorDomain', 'twoFactorOptional', |
| 552 |
'twoFactorAllowToRememberDeviceOptions'] |
| 553 |
]); |
| 554 |
$row->add($twoFactorSelect); |
| 555 |
$twoFactorAttribute = new htmlResponsiveInputField(_("User name attribute"), 'twoFactorAttribute', $conf->getTwoFactorAuthenticationAttribute(), '528'); |
| 556 |
$row->add($twoFactorAttribute); |
| 557 |
$twoFactorUrl = new htmlResponsiveInputField(_("Base URL"), 'twoFactorURL', $conf->getTwoFactorAuthenticationURL(), '515'); |
| 558 |
$twoFactorUrl->setRequired(true); |
| 559 |
$row->add($twoFactorUrl); |
| 560 |
$twoFactorUrl = new htmlResponsiveInputTextarea('twoFactorURLs', $conf->getTwoFactorAuthenticationURL(), 80, 4, _("Base URLs"), '515a'); |
| 561 |
$twoFactorUrl->setRequired(true); |
| 562 |
$row->add($twoFactorUrl); |
| 563 |
$twoFactorClientId = new htmlResponsiveInputField(_("Client id"), 'twoFactorClientId', $conf->getTwoFactorAuthenticationClientId(), '524'); |
| 564 |
$row->add($twoFactorClientId); |
| 565 |
$twoFactorSecretKey = new htmlResponsiveInputField(_("Secret key"), 'twoFactorSecretKey', $conf->getTwoFactorAuthenticationSecretKey(), '528'); |
| 566 |
$row->add($twoFactorSecretKey); |
| 567 |
$twoFactorDomain = new htmlResponsiveInputField(_("Domain"), 'twoFactorDomain', $conf->getTwoFactorAuthenticationDomain(), '529'); |
| 568 |
$row->add($twoFactorDomain); |
| 569 |
$twoFactorLabel = new htmlResponsiveInputField(_("Label"), 'twoFactorLabel', $conf->getTwoFactorAuthenticationLabel(), '517'); |
| 570 |
$row->add($twoFactorLabel); |
| 571 |
$row->add(new htmlResponsiveInputCheckbox('twoFactorOptional', $conf->getTwoFactorAuthenticationOptional(), _('Optional'), '519')); |
| 572 |
$row->add(new htmlResponsiveInputCheckbox('twoFactorInsecure', $conf->getTwoFactorAuthenticationInsecure(), _('Disable certificate check'), '516')); |
| 573 |
$twoFactorCaption = new htmlResponsiveInputTextarea('twoFactorCaption', $conf->getTwoFactorAuthenticationCaption(), 80, 4, _("Caption")); |
| 574 |
$twoFactorCaption->setIsRichEdit(true); |
| 575 |
$row->add($twoFactorCaption); |
| 576 |
$row->addVerticalSpacer('0.5rem'); |
| 577 |
$rememberDeviceRow = new htmlResponsiveRow(); |
| 578 |
$rememberDeviceRow->setId('twoFactorAllowToRememberDeviceOptions'); |
| 579 |
$twoFactorAllowToRememberDeviceChecked = ($conf->getTwoFactorAllowToRememberDevice() === 'true'); |
| 580 |
$twoFactorAllowToRememberDevice = new htmlResponsiveInputCheckbox('twoFactorAllowToRememberDevice', $twoFactorAllowToRememberDeviceChecked, _('Allow remembering device'), '530'); |
| 581 |
$twoFactorAllowToRememberDevice->setTableRowsToShow(['twoFactorAllowToRememberDeviceExtraOptions']); |
| 582 |
$rememberDeviceRow->add($twoFactorAllowToRememberDevice); |
| 583 |
$rememberDeviceExtraRow = new htmlResponsiveRow(); |
| 584 |
$rememberDeviceExtraRow->setId('twoFactorAllowToRememberDeviceExtraOptions'); |
| 585 |
$twoFactorRememberDeviceDuration = new htmlResponsiveInputField(_("Remember device period"), 'twoFactorRememberDeviceDuration', formatSecondsToShortFormat($conf->getTwoFactorRememberDeviceDuration()), '531'); |
| 586 |
$rememberDeviceExtraRow->add($twoFactorRememberDeviceDuration); |
| 587 |
$twoFactorRememberDevicePassword = new htmlResponsiveInputField(_("Password to remember devices"), 'twoFactorRememberDevicePassword', $conf->getTwoFactorRememberDevicePassword(), '532'); |
| 588 |
$twoFactorRememberDevicePassword->setIsPassword(true); |
| 589 |
$rememberDeviceExtraRow->add($twoFactorRememberDevicePassword); |
| 590 |
$rememberDeviceRow->add($rememberDeviceExtraRow); |
| 591 |
$row->add($rememberDeviceRow); |
| 592 |
} |
| 593 |
|
| 594 |
// new password |
| 595 |
$row->add(new htmlSubTitle(_("Profile password"), '../../graphics/key.svg', null, true)); |
| 596 |
$password1 = new htmlResponsiveInputField(_("New password"), 'passwd1', null, '212'); |
| 597 |
$password1->setIsPassword(true, false, true); |
| 598 |
$password2 = new htmlResponsiveInputField(_("Reenter password"), 'passwd2'); |
| 599 |
$password2->setIsPassword(true, false, true); |
| 600 |
$password2->setSameValueFieldID('passwd1'); |
| 601 |
$row->add($password1); |
| 602 |
$row->add($password2); |
| 603 |
|
| 604 |
$row->addVerticalSpacer('2rem'); |
| 605 |
|
| 606 |
parseHtml(null, $row, [], false, 'user'); |
| 607 |
|
| 608 |
echo "</div></div>"; |
| 609 |
|
| 610 |
$buttonContainer = new htmlTable(); |
| 611 |
$buttonContainer->addElement(new htmlSpacer(null, '10px'), true); |
| 612 |
$saveButton = new htmlButton('saveSettings', _('Save')); |
| 613 |
$saveButton->setCSSClasses(['lam-primary']); |
| 614 |
$buttonContainer->addElement($saveButton); |
| 615 |
$cancelButton = new htmlButton('cancelSettings', _('Cancel')); |
| 616 |
$buttonContainer->addElement($cancelButton, true); |
| 617 |
$buttonContainer->addElement(new htmlSpacer(null, '10px'), true); |
| 618 |
parseHtml(null, $buttonContainer, [], false, 'user'); |
| 619 |
|
| 620 |
?> |
| 621 |
</form> |
| 622 |
<script type="text/javascript" src="../lib/extra/jodit/jodit.js"></script> |
| 623 |
</body> |
| 624 |
</html> |
| 625 |
<?php |
| 626 |
|
| 627 |
/** |
| 628 |
* Checks user input and saves the entered settings. |
| 629 |
* |
| 630 |
* @return array<int, string[]> list of errors |
| 631 |
*/ |
| 632 |
function checkInput(): array { |
| 633 |
$conf = &$_SESSION['conf_config']; |
| 634 |
|
| 635 |
// check new preferences |
| 636 |
$errors = []; |
| 637 |
if (!$conf->set_ServerURL($_POST['serverurl'])) { |
| 638 |
$errors[] = ["ERROR", _("Server address is invalid!")]; |
| 639 |
} |
| 640 |
$conf->setServerDisplayName($_POST['serverDisplayName']); |
| 641 |
$conf->setUseTLS($_POST['useTLS']); |
| 642 |
if ((str_contains($_POST['serverurl'], 'ldaps://')) && ($_POST['useTLS'] == 'yes')) { |
| 643 |
$errors[] = ["ERROR", _('You cannot use SSL and TLS encryption at the same time. Please use either "ldaps://" or TLS.')]; |
| 644 |
} |
| 645 |
if (isset($_POST['followReferrals']) && ($_POST['followReferrals'] == 'on')) { |
| 646 |
$conf->setFollowReferrals('true'); |
| 647 |
} |
| 648 |
else { |
| 649 |
$conf->setFollowReferrals('false'); |
| 650 |
} |
| 651 |
if (isset($_POST['pagedResults']) && ($_POST['pagedResults'] == 'on')) { |
| 652 |
$conf->setPagedResults('true'); |
| 653 |
} |
| 654 |
else { |
| 655 |
$conf->setPagedResults('false'); |
| 656 |
} |
| 657 |
if (isset($_POST['adShowDeleted']) && ($_POST['adShowDeleted'] == 'on')) { |
| 658 |
$conf->setAdShowDeleted('true'); |
| 659 |
} |
| 660 |
else { |
| 661 |
$conf->setAdShowDeleted('false'); |
| 662 |
} |
| 663 |
if (isset($_POST['referentialIntegrityOverlay']) && ($_POST['referentialIntegrityOverlay'] == 'on')) { |
| 664 |
$conf->setReferentialIntegrityOverlay('true'); |
| 665 |
} |
| 666 |
else { |
| 667 |
$conf->setReferentialIntegrityOverlay('false'); |
| 668 |
} |
| 669 |
if (isset($_POST['hidePasswordPromptForExpiredPasswords']) && ($_POST['hidePasswordPromptForExpiredPasswords'] == 'on')) { |
| 670 |
$conf->setHidePasswordPromptForExpiredPasswords('true'); |
| 671 |
} |
| 672 |
else { |
| 673 |
$conf->setHidePasswordPromptForExpiredPasswords('false'); |
| 674 |
} |
| 675 |
$conf->set_searchLimit((int) $_POST['searchLimit']); |
| 676 |
$conf->setHideDnPart($_POST['hideDnPart']); |
| 677 |
if (isLAMProVersion()) { |
| 678 |
$conf->setAccessLevel($_POST['accessLevel']); |
| 679 |
if (isset($_POST['pwdResetAllowSpecificPassword']) && ($_POST['pwdResetAllowSpecificPassword'] == 'on')) { |
| 680 |
$conf->setPwdResetAllowSpecificPassword('true'); |
| 681 |
} |
| 682 |
else { |
| 683 |
$conf->setPwdResetAllowSpecificPassword('false'); |
| 684 |
} |
| 685 |
if (isset($_POST['pwdResetAllowScreenPassword']) && ($_POST['pwdResetAllowScreenPassword'] == 'on')) { |
| 686 |
$conf->setPwdResetAllowScreenPassword('true'); |
| 687 |
} |
| 688 |
else { |
| 689 |
$conf->setPwdResetAllowScreenPassword('false'); |
| 690 |
} |
| 691 |
if (isset($_POST['pwdResetForcePasswordChange']) && ($_POST['pwdResetForcePasswordChange'] == 'on')) { |
| 692 |
$conf->setPwdResetForcePasswordChange('true'); |
| 693 |
} |
| 694 |
else { |
| 695 |
$conf->setPwdResetForcePasswordChange('false'); |
| 696 |
} |
| 697 |
$conf->setPwdResetDefaultPasswordOutput($_POST['pwdResetDefaultPasswordOutput']); |
| 698 |
if (!$conf->setLamProMailFrom($_POST['pwdResetMail_from'])) { |
| 699 |
$errors[] = ["ERROR", _("From address for password mails is invalid."), htmlspecialchars($_POST['pwdResetMail_from'])]; |
| 700 |
} |
| 701 |
if (!empty($_POST['pwdResetMail_subject']) && empty($_POST['pwdResetMail_from'])) { |
| 702 |
$errors[] = ["ERROR", _("From address for password mails is invalid."), htmlspecialchars($_POST['pwdResetMail_from'])]; |
| 703 |
} |
| 704 |
if (!$conf->setLamProMailReplyTo($_POST['pwdResetMail_replyTo'])) { |
| 705 |
$errors[] = ["ERROR", _("Reply-to address for password mails is invalid."), htmlspecialchars($_POST['pwdResetMail_replyTo'])]; |
| 706 |
} |
| 707 |
$conf->setLamProMailSubject($_POST['pwdResetMail_subject']); |
| 708 |
if (isset($_POST['pwdResetMail_isHTML']) && ($_POST['pwdResetMail_isHTML'] == 'on')) { |
| 709 |
$conf->setLamProMailIsHTML('true'); |
| 710 |
} |
| 711 |
else { |
| 712 |
$conf->setLamProMailIsHTML('false'); |
| 713 |
} |
| 714 |
if (isset($_POST['pwdResetMail_allowAlternate']) && ($_POST['pwdResetMail_allowAlternate'] == 'on')) { |
| 715 |
$conf->setLamProMailAllowAlternateAddress('true'); |
| 716 |
} |
| 717 |
else { |
| 718 |
$conf->setLamProMailAllowAlternateAddress('false'); |
| 719 |
} |
| 720 |
$conf->setLamProMailText($_POST['pwdResetMail_body']); |
| 721 |
} |
| 722 |
$adminText = $_POST['admins']; |
| 723 |
$adminText = explode("\n", $adminText); |
| 724 |
$adminTextNew = []; |
| 725 |
foreach ($adminText as $adminLine) { |
| 726 |
$adminLine = trim($adminLine); |
| 727 |
if ($adminLine === '') { |
| 728 |
continue; |
| 729 |
} |
| 730 |
$adminTextNew[] = $adminLine; |
| 731 |
} |
| 732 |
$conf->setLoginMethod($_POST['loginMethod']); |
| 733 |
$conf->setLoginSearchFilter($_POST['loginSearchFilter']); |
| 734 |
$conf->setLoginSearchSuffix($_POST['loginSearchSuffix']); |
| 735 |
$conf->setLoginSearchPassword($_POST['loginSearchPassword']); |
| 736 |
$conf->setLoginSearchDN($_POST['loginSearchDN']); |
| 737 |
// check only if search method |
| 738 |
if (($_POST['loginMethod'] == LAMConfig::LOGIN_SEARCH) |
| 739 |
&& !$conf->setLoginSearchDN($_POST['loginSearchDN'])) { |
| 740 |
$errors[] = ["ERROR", _("Please enter a valid bind user.")]; |
| 741 |
} |
| 742 |
if (isset($_POST['httpAuthentication']) && ($_POST['httpAuthentication'] == 'on')) { |
| 743 |
$conf->setHttpAuthentication('true'); |
| 744 |
} |
| 745 |
else { |
| 746 |
$conf->setHttpAuthentication('false'); |
| 747 |
} |
| 748 |
if (!$conf->set_Adminstring(implode(";", $adminTextNew))) { |
| 749 |
$errors[] = ["ERROR", _("List of admin users is empty or invalid!")]; |
| 750 |
} |
| 751 |
if (!$conf->set_defaultLanguage($_POST['lang'])) { |
| 752 |
$errors[] = ["ERROR", _("Language is not defined!")]; |
| 753 |
} |
| 754 |
$conf->setTimeZone($_POST['timeZone']); |
| 755 |
if (!$conf->set_scriptpath($_POST['scriptpath'])) { |
| 756 |
$errors[] = ["ERROR", _("Script path is invalid!")]; |
| 757 |
} |
| 758 |
if (!$conf->set_scriptservers($_POST['scriptservers'])) { |
| 759 |
$errors[] = ["ERROR", _("Script server is invalid!")]; |
| 760 |
} |
| 761 |
$chmodOwner = 0; |
| 762 |
$chmodGroup = 0; |
| 763 |
$chmodOther = 0; |
| 764 |
if (isset($_POST['chmod_owr']) && ($_POST['chmod_owr'] == 'on')) { |
| 765 |
$chmodOwner += 4; |
| 766 |
} |
| 767 |
if (isset($_POST['chmod_oww']) && ($_POST['chmod_oww'] == 'on')) { |
| 768 |
$chmodOwner += 2; |
| 769 |
} |
| 770 |
if (isset($_POST['chmod_owe']) && ($_POST['chmod_owe'] == 'on')) { |
| 771 |
$chmodOwner += 1; |
| 772 |
} |
| 773 |
if (isset($_POST['chmod_grr']) && ($_POST['chmod_grr'] == 'on')) { |
| 774 |
$chmodGroup += 4; |
| 775 |
} |
| 776 |
if (isset($_POST['chmod_grw']) && ($_POST['chmod_grw'] == 'on')) { |
| 777 |
$chmodGroup += 2; |
| 778 |
} |
| 779 |
if (isset($_POST['chmod_gre']) && ($_POST['chmod_gre'] == 'on')) { |
| 780 |
$chmodGroup += 1; |
| 781 |
} |
| 782 |
if (isset($_POST['chmod_otr']) && ($_POST['chmod_otr'] == 'on')) { |
| 783 |
$chmodOther += 4; |
| 784 |
} |
| 785 |
if (isset($_POST['chmod_otw']) && ($_POST['chmod_otw'] == 'on')) { |
| 786 |
$chmodOther += 2; |
| 787 |
} |
| 788 |
if (isset($_POST['chmod_ote']) && ($_POST['chmod_ote'] == 'on')) { |
| 789 |
$chmodOther += 1; |
| 790 |
} |
| 791 |
$chmod = $chmodOwner . $chmodGroup . $chmodOther; |
| 792 |
if (!$conf->set_scriptrights($chmod)) { |
| 793 |
$errors[] = ["ERROR", _("Script rights are invalid!")]; |
| 794 |
} |
| 795 |
$conf->setScriptUserName($_POST['scriptuser']); |
| 796 |
$conf->setScriptSSHKey($_POST['scriptkey']); |
| 797 |
$conf->setScriptSSHKeyPassword($_POST['scriptkeypassword']); |
| 798 |
if (!empty($_POST['scriptkey'])) { |
| 799 |
include_once __DIR__ . '/../../lib/remote.inc'; |
| 800 |
$remote = new Remote(); |
| 801 |
try { |
| 802 |
$remote->loadKey($conf->getScriptSSHKey(), $conf->getScriptSSHKeyPassword()); |
| 803 |
} |
| 804 |
catch (LAMException $e) { |
| 805 |
$errors[] = ['ERROR', _('SSH key file'), $e->getTitle()]; |
| 806 |
} |
| 807 |
} |
| 808 |
// tool settings |
| 809 |
$tools = getTools(); |
| 810 |
$toolSettings = extractConfigOptionsFromPOST($_SESSION['confmain_toolTypes']); |
| 811 |
foreach ($toolSettings as $key => $value) { |
| 812 |
$toolSettings[$key] = implode(LAMConfig::LINE_SEPARATOR, $value); |
| 813 |
} |
| 814 |
foreach ($tools as $tool) { |
| 815 |
$toolClass = $tool::class; |
| 816 |
$toolName = substr($toolClass, strrpos($toolClass, '\\') + 1); |
| 817 |
$toolConfigID = 'tool_hide_' . $toolName; |
| 818 |
$toolSettings[$toolConfigID] = (isset($_POST[$toolConfigID])) && ($_POST[$toolConfigID] == 'on') ? 'true' : 'false'; |
| 819 |
$toolErrors = $tool->checkConfigurationOptions($toolSettings); |
| 820 |
if (!empty($toolErrors)) { |
| 821 |
$errors = array_merge($errors, $toolErrors); |
| 822 |
} |
| 823 |
} |
| 824 |
|
| 825 |
$conf->setToolSettings($toolSettings); |
| 826 |
// password policy override |
| 827 |
$conf->setPwdPolicyMinLength($_POST['pwdPolicyMinLength']); |
| 828 |
$conf->setPwdPolicyMinLowercase($_POST['pwdPolicyMinLowercase']); |
| 829 |
$conf->setPwdPolicyMinUppercase($_POST['pwdPolicyMinUppercase']); |
| 830 |
$conf->setPwdPolicyMinNumeric($_POST['pwdPolicyMinNumeric']); |
| 831 |
$conf->setPwdPolicyMinSymbolic($_POST['pwdPolicyMinSymbolic']); |
| 832 |
// 2-factor |
| 833 |
if (extension_loaded('curl')) { |
| 834 |
$conf->setTwoFactorAuthentication($_POST['twoFactor']); |
| 835 |
if ($_POST['twoFactor'] === TwoFactorProviderService::TWO_FACTOR_YUBICO) { |
| 836 |
$conf->setTwoFactorAuthenticationURL($_POST['twoFactorURLs']); |
| 837 |
} |
| 838 |
else { |
| 839 |
$conf->setTwoFactorAuthenticationURL($_POST['twoFactorURL']); |
| 840 |
} |
| 841 |
$conf->setTwoFactorAuthenticationAttribute($_POST['twoFactorAttribute']); |
| 842 |
$conf->setTwoFactorAuthenticationClientId($_POST['twoFactorClientId']); |
| 843 |
$conf->setTwoFactorAuthenticationSecretKey($_POST['twoFactorSecretKey']); |
| 844 |
$conf->setTwoFactorAuthenticationDomain($_POST['twoFactorDomain']); |
| 845 |
$conf->setTwoFactorAuthenticationInsecure(isset($_POST['twoFactorInsecure']) && ($_POST['twoFactorInsecure'] === 'on')); |
| 846 |
$conf->setTwoFactorAuthenticationLabel($_POST['twoFactorLabel']); |
| 847 |
$conf->setTwoFactorAuthenticationOptional(isset($_POST['twoFactorOptional']) && ($_POST['twoFactorOptional'] === 'on')); |
| 848 |
$conf->setTwoFactorAuthenticationCaption(str_replace(["\r", "\n"], ['', ''], $_POST['twoFactorCaption'])); |
| 849 |
$twoFactorAllowToRememberDevice = (isset($_POST['twoFactorAllowToRememberDevice']) && ($_POST['twoFactorAllowToRememberDevice'] === 'on')) ? 'true' : 'false'; |
| 850 |
$conf->setTwoFactorAllowToRememberDevice($twoFactorAllowToRememberDevice); |
| 851 |
$conf->setTwoFactorRememberDeviceDuration(unformatShortFormatToSeconds($_POST['twoFactorRememberDeviceDuration'])); |
| 852 |
$conf->setTwoFactorRememberDevicePassword($_POST['twoFactorRememberDevicePassword']); |
| 853 |
} |
| 854 |
// check if password was changed |
| 855 |
if (!empty($_POST['passwd1'])) { |
| 856 |
if ($_POST['passwd1'] !== $_POST['passwd2']) { |
| 857 |
$errors[] = ["ERROR", _("Passwords are different!")]; |
| 858 |
} |
| 859 |
elseif (!isValidConfigurationPassword($_POST['passwd1'])) { |
| 860 |
$errors[] = ["ERROR", _('Profile password'), _('Please enter at least 8 characters including letters, a number and a symbol.')]; |
| 861 |
} |
| 862 |
else { |
| 863 |
// set new password |
| 864 |
$conf->set_Passwd($_POST['passwd1']); |
| 865 |
} |
| 866 |
} |
| 867 |
|
| 868 |
return $errors; |
| 869 |
} |