hasPasswordSet()) { logNewMessage(LOG_ERR, 'Invalid attempt to set initial config password'); die(); } setlanguage(); if (!empty($_POST)) { validateSecurityToken(); } $message = null; // check if user already pressed button if (isset($_POST['changePassword'])) { // check new password $password1 = $_POST['password1']; $password2 = $_POST['password2']; if ($password1 == '') { $message = new htmlStatusMessage('ERROR', _('No password was entered!')); printContent($message); exit(); } // check if passwords match if ($password1 != $password2) { $message = new htmlStatusMessage('ERROR', _('Passwords are different!')); printContent($message); exit(); } // check password strength $pwdPolicyResult = isValidConfigurationPassword($password1); if (!$pwdPolicyResult) { $message = new htmlStatusMessage('ERROR', _('Please enter at least 8 characters including letters, a number and a symbol.')); printContent($message); exit(); } // set new password $cfgMain->setPassword($password1); try { $cfgMain->save(); metaRefresh('config/mainlogin.php'); exit(); } catch (LAMException $e) { $message = new htmlStatusMessage('ERROR', $e->getTitle(), $e->getMessage()); } } printContent($message); /** * Displays the content area * * @param htmlStatusMessage|null $message status message * @param bool $showPasswordInputs show password input fields */ function printContent(?htmlStatusMessage $message = null, bool $showPasswordInputs = true): void { echo '
'; printHeaderContents('LDAP Account Manager', '..'); echo ' '; printJsIncludes('..'); echo '