@ -1,5 +1,6 @@
< ? php
namespace LAM\CONFIG ;
use \LAMCfgMain ;
use \htmlTable ;
use \htmlTitle ;
@ -22,10 +23,11 @@ use \htmlResponsiveInputCheckbox;
use \htmlResponsiveInputField ;
use \htmlDiv ;
use \htmlHiddenInput ;
/*
This code is part of LDAP Account Manager ( http :// www . ldap - account - manager . org / )
Copyright ( C ) 2003 - 2019 Roland Gruber
Copyright ( C ) 2003 - 2020 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
@ -45,11 +47,11 @@ use \htmlHiddenInput;
/**
* Manages the main configuration options .
*
* @ package configuration
* @ author Roland Gruber
*/
* Manages the main configuration options .
*
* @ package configuration
* @ author Roland Gruber
*/
/** Access to config functions */
@ -95,8 +97,7 @@ if (isset($_POST['submitFormData'])) {
$cfg -> setPassword ( $_POST [ 'masterpassword' ]);
$msg = _ ( " New master password set successfully. " );
unset ( $_SESSION [ " mainconf_password " ]);
}
else {
} else {
$errors [] = _ ( " Master passwords are different or empty! " );
}
}
@ -126,8 +127,7 @@ if (isset($_POST['submitFormData'])) {
}
}
$allowedHosts = implode ( " , " , $allowedHostsList );
}
else {
} else {
$allowedHosts = " " ;
}
$cfg -> allowedHosts = $allowedHosts ;
@ -150,8 +150,7 @@ if (isset($_POST['submitFormData'])) {
}
}
$allowedHostsSelfService = implode ( " , " , $allowedHostsSelfServiceList );
}
else {
} else {
$allowedHostsSelfService = " " ;
}
$cfg -> allowedHostsSelfService = $allowedHostsSelfService ;
@ -169,22 +168,18 @@ if (isset($_POST['submitFormData'])) {
// set log destination
if ( $_POST [ 'logDestination' ] == " none " ) {
$cfg -> logDestination = " NONE " ;
}
elseif ( $_POST [ 'logDestination' ] == " syslog " ) {
} elseif ( $_POST [ 'logDestination' ] == " syslog " ) {
$cfg -> logDestination = " SYSLOG " ;
}
elseif ( $_POST [ 'logDestination' ] == " remote " ) {
} elseif ( $_POST [ 'logDestination' ] == " remote " ) {
$cfg -> logDestination = " REMOTE: " . $_POST [ 'logRemote' ];
$remoteParts = explode ( ':' , $_POST [ 'logRemote' ]);
if (( sizeof ( $remoteParts ) !== 2 ) || ! get_preg ( $remoteParts [ 0 ], 'DNSname' ) || ! get_preg ( $remoteParts [ 1 ], 'digit' )) {
$errors [] = _ ( " Please enter a valid remote server in format \" server:port \" . " );
}
}
else {
} else {
if ( isset ( $_POST [ 'logFile' ]) && ( $_POST [ 'logFile' ] != " " ) && preg_match ( " /^[a-z0-9 \\ / \\ \\ : \\ ._-]+ $ /i " , $_POST [ 'logFile' ])) {
$cfg -> logDestination = $_POST [ 'logFile' ];
}
else {
} else {
$errors [] = _ ( " The log file is empty or contains invalid characters! Valid characters are: a-z, A-Z, 0-9, /, \\ , ., :, _ and -. " );
}
}
@ -207,16 +202,14 @@ if (isset($_POST['submitFormData'])) {
if ( isset ( $_POST [ 'sslCaCertUpload' ])) {
if ( ! isset ( $_FILES [ 'sslCaCert' ]) || ( $_FILES [ 'sslCaCert' ][ 'size' ] == 0 )) {
$errors [] = _ ( 'No file selected.' );
}
else {
} else {
$handle = fopen ( $_FILES [ 'sslCaCert' ][ 'tmp_name' ], " r " );
$data = fread ( $handle , 10000000 );
fclose ( $handle );
$sslReturn = $cfg -> uploadSSLCaCert ( $data );
if ( $sslReturn !== true ) {
$errors [] = $sslReturn ;
}
else {
} else {
$messages [] = _ ( 'You might need to restart your webserver for changes to take effect.' );
}
}
@ -237,12 +230,10 @@ if (isset($_POST['submitFormData'])) {
$messages [] = _ ( 'Imported certificate from server.' );
$messages [] = _ ( 'You might need to restart your webserver for changes to take effect.' );
$cfg -> uploadSSLCaCert ( $pemResult );
}
else {
} else {
$errors [] = _ ( 'Unable to import server certificate. Please use the upload function.' );
}
}
else {
} else {
$errors [] = _ ( 'Invalid server name. Please enter "server" or "server:port".' );
}
}
@ -270,264 +261,279 @@ if (isset($_POST['submitFormData'])) {
echo $_SESSION [ 'header' ];
printHeaderContents ( _ ( " Edit general settings " ), '../..' );
?>
</ head >
< body class = " admin " >
< table border = 0 width = " 100% " class = " lamHeader ui-corner-all " >
< tr >
< td align = " left " height = " 30 " >
< a class = " lamLogo " href = " http://www.ldap-account-manager.org/ " target = " new_window " >
< ? php echo getLAMVersionText (); ?>
</ a >
</ td >
</ tr >
</ table >
< br >
<!-- form for adding / renaming / deleting profiles -->
< form enctype = " multipart/form-data " action = " mainmanage.php " method = " post " >
< ? php
// include all JavaScript files
printJsIncludes ( '../..' );
$tabindex = 1 ;
$row = new htmlResponsiveRow ();
$row -> add ( new htmlTitle ( _ ( 'General settings' )), 12 );
// print messages
for ( $i = 0 ; $i < sizeof ( $errors ); $i ++ ) {
$row -> add ( new htmlStatusMessage ( " ERROR " , $errors [ $i ]), 12 );
}
for ( $i = 0 ; $i < sizeof ( $messages ); $i ++ ) {
$row -> add ( new htmlStatusMessage ( " INFO " , $messages [ $i ]), 12 );
}
</ head >
< body class = " admin " >
< table border = 0 width = " 100% " class = " lamHeader ui-corner-all " >
< tr >
< td align = " left " height = " 30 " >
< a class = " lamLogo " href = " http://www.ldap-account-manager.org/ " target = " new_window " >
< ? php echo getLAMVersionText (); ?>
</ a >
</ td >
</ tr >
</ table >
< br >
<!-- form for adding / renaming / deleting profiles -->
< form enctype = " multipart/form-data " action = " mainmanage.php " method = " post " >
< ? php
// include all JavaScript files
printJsIncludes ( '../..' );
$tabindex = 1 ;
$row = new htmlResponsiveRow ();
$row -> add ( new htmlTitle ( _ ( 'General settings' )), 12 );
// print messages
for ( $i = 0 ; $i < sizeof ( $errors ); $i ++ ) {
$row -> add ( new htmlStatusMessage ( " ERROR " , $errors [ $i ]), 12 );
}
for ( $i = 0 ; $i < sizeof ( $messages ); $i ++ ) {
$row -> add ( new htmlStatusMessage ( " INFO " , $messages [ $i ]), 12 );
}
// check if config file is writable
if ( ! $cfg -> isWritable ()) {
$row -> add ( new htmlStatusMessage ( 'WARN' , 'The config file is not writable.' , 'Your changes cannot be saved until you make the file writable for the webserver user.' ), 12 );
}
// check if config file is writable
if ( ! $cfg -> isWritable ()) {
$row -> add ( new htmlStatusMessage ( 'WARN' , 'The config file is not writable.' , 'Your changes cannot be saved until you make the file writable for the webserver user.' ), 12 );
}
// license
if ( isLAMProVersion ()) {
$row -> add ( new htmlSubTitle ( _ ( 'Licence' )), 12 );
$row -> add ( new htmlResponsiveInputTextarea ( 'license' , implode ( " \n " , $cfg -> getLicenseLines ()), null , 10 , _ ( 'Licence' ), '287' ), 12 );
// license
if ( isLAMProVersion ()) {
$row -> add ( new htmlSubTitle ( _ ( 'Licence' )), 12 );
$row -> add ( new htmlResponsiveInputTextarea ( 'license' , implode ( " \n " , $cfg -> getLicenseLines ()), null , 10 , _ ( 'Licence' ), '287' ), 12 );
$row -> add ( new htmlSpacer ( null , '1rem' ), true );
}
$row -> add ( new htmlSpacer ( null , '1rem' ), true );
}
// security settings
$row -> add ( new htmlSubTitle ( _ ( " Security settings " )), 12 );
$options = array ( 5 , 10 , 20 , 30 , 60 , 90 , 120 , 240 );
$row -> add ( new htmlResponsiveSelect ( 'sessionTimeout' , $options , array ( $cfg -> sessionTimeout ), _ ( " Session timeout " ), '238' ), 12 );
$row -> add ( new htmlResponsiveInputTextarea ( 'allowedHosts' , implode ( " \n " , explode ( " , " , $cfg -> allowedHosts )), null , '7' , _ ( " Allowed hosts " ), '241' ), 12 );
if ( isLAMProVersion ()) {
$row -> add ( new htmlResponsiveInputTextarea ( 'allowedHostsSelfService' , implode ( " \n " , explode ( " , " , $cfg -> allowedHostsSelfService )), null , '7' , _ ( " Allowed hosts (self service) " ), '241' ), 12 );
}
$encryptSession = ( $cfg -> encryptSession === 'true' );
$encryptSessionBox = new htmlResponsiveInputCheckbox ( 'encryptSession' , $encryptSession , _ ( 'Encrypt session' ), '245' );
$encryptSessionBox -> setIsEnabled ( function_exists ( 'openssl_random_pseudo_bytes' ));
$row -> add ( $encryptSessionBox , 12 );
// SSL certificate
$row -> addVerticalSpacer ( '1rem' );
$row -> addLabel ( new htmlOutputText ( _ ( 'SSL certificates' )));
$sslMethod = _ ( 'use system certificates' );
$sslFileName = $cfg -> getSSLCaCertTempFileName ();
if ( $sslFileName != null ) {
$sslMethod = _ ( 'use custom CA certificates' );
}
$sslDelSaveGroup = new htmlGroup ();
$sslDelSaveGroup -> addElement ( new htmlOutputText ( $sslMethod ));
$sslDelSaveGroup -> addElement ( new htmlSpacer ( '5px' , null ));
// delete+download button
if ( $sslFileName != null ) {
$sslDownloadBtn = new htmlLink ( '' , '../../tmp/' . $sslFileName , '../../graphics/save.png' );
$sslDownloadBtn -> setTargetWindow ( '_blank' );
$sslDownloadBtn -> setTitle ( _ ( 'Download CA certificates' ));
$sslDelSaveGroup -> addElement ( $sslDownloadBtn );
$sslDeleteBtn = new htmlButton ( 'sslCaCertDelete' , 'delete.png' , true );
$sslDeleteBtn -> setTitle ( _ ( 'Delete all CA certificates' ));
$sslDelSaveGroup -> addElement ( $sslDeleteBtn );
}
$sslDelSaveGroup -> addElement ( new htmlHelpLink ( '204' ));
$row -> addField ( $sslDelSaveGroup );
$row -> addLabel ( new htmlInputFileUpload ( 'sslCaCert' ));
$sslUploadBtn = new htmlButton ( 'sslCaCertUpload' , _ ( 'Upload' ));
$sslUploadBtn -> setIconClass ( 'upButton' );
$sslUploadBtn -> setTitle ( _ ( 'Upload CA certificate in DER/PEM format.' ));
$row -> addField ( $sslUploadBtn );
if ( function_exists ( 'stream_socket_client' ) && function_exists ( 'stream_context_get_params' )) {
$sslImportServerUrl = ! empty ( $_POST [ 'serverurl' ]) ? $_POST [ 'serverurl' ] : 'ldaps://' ;
$serverUrlUpload = new htmlInputField ( 'serverurl' , $sslImportServerUrl );
$row -> addLabel ( $serverUrlUpload );
$sslImportBtn = new htmlButton ( 'sslCaCertImport' , _ ( 'Import from server' ));
$sslImportBtn -> setIconClass ( 'downButton' );
$sslImportBtn -> setTitle ( _ ( 'Imports the certificate directly from your LDAP server.' ));
$row -> addField ( $sslImportBtn );
}
// security settings
$row -> add ( new htmlSubTitle ( _ ( " Security settings " )), 12 );
$options = array ( 5 , 10 , 20 , 30 , 60 , 90 , 120 , 240 );
$row -> add ( new htmlResponsiveSelect ( 'sessionTimeout' , $options , array ( $cfg -> sessionTimeout ), _ ( " Session timeout " ), '238' ), 12 );
$row -> add ( new htmlResponsiveInputTextarea ( 'allowedHosts' , implode ( " \n " , explode ( " , " , $cfg -> allowedHosts )), null , '7' , _ ( " Allowed hosts " ), '241' ), 12 );
if ( isLAMProVersion ()) {
$row -> add ( new htmlResponsiveInputTextarea ( 'allowedHostsSelfService' , implode ( " \n " , explode ( " , " , $cfg -> allowedHostsSelfService )), null , '7' , _ ( " Allowed hosts (self service) " ), '241' ), 12 );
}
$encryptSession = ( $cfg -> encryptSession === 'true' );
$encryptSessionBox = new htmlResponsiveInputCheckbox ( 'encryptSession' , $encryptSession , _ ( 'Encrypt session' ), '245' );
$encryptSessionBox -> setIsEnabled ( function_exists ( 'openssl_random_pseudo_bytes' ));
$row -> add ( $encryptSessionBox , 12 );
// SSL certificate
$row -> addVerticalSpacer ( '1rem' );
$row -> addLabel ( new htmlOutputText ( _ ( 'SSL certificates' )));
$sslMethod = _ ( 'use system certificates' );
$sslFileName = $cfg -> getSSLCaCertTempFileName ();
if ( $sslFileName != null ) {
$sslMethod = _ ( 'use custom CA certificates' );
}
$sslDelSaveGroup = new htmlGroup ();
$sslDelSaveGroup -> addElement ( new htmlOutputText ( $sslMethod ));
$sslDelSaveGroup -> addElement ( new htmlSpacer ( '5px' , null ));
// delete+download button
if ( $sslFileName != null ) {
$sslDownloadBtn = new htmlLink ( '' , '../../tmp/' . $sslFileName , '../../graphics/save.png' );
$sslDownloadBtn -> setTargetWindow ( '_blank' );
$sslDownloadBtn -> setTitle ( _ ( 'Download CA certificates' ));
$sslDelSaveGroup -> addElement ( $sslDownloadBtn );
$sslDeleteBtn = new htmlButton ( 'sslCaCertDelete' , 'delete.png' , true );
$sslDeleteBtn -> setTitle ( _ ( 'Delete all CA certificates' ));
$sslDelSaveGroup -> addElement ( $sslDeleteBtn );
}
$sslDelSaveGroup -> addElement ( new htmlHelpLink ( '204' ));
$row -> addField ( $sslDelSaveGroup );
$row -> addLabel ( new htmlInputFileUpload ( 'sslCaCert' ));
$sslUploadBtn = new htmlButton ( 'sslCaCertUpload' , _ ( 'Upload' ));
$sslUploadBtn -> setIconClass ( 'upButton' );
$sslUploadBtn -> setTitle ( _ ( 'Upload CA certificate in DER/PEM format.' ));
$row -> addField ( $sslUploadBtn );
if ( function_exists ( 'stream_socket_client' ) && function_exists ( 'stream_context_get_params' )) {
$sslImportServerUrl = ! empty ( $_POST [ 'serverurl' ]) ? $_POST [ 'serverurl' ] : 'ldaps://' ;
$serverUrlUpload = new htmlInputField ( 'serverurl' , $sslImportServerUrl );
$row -> addLabel ( $serverUrlUpload );
$sslImportBtn = new htmlButton ( 'sslCaCertImport' , _ ( 'Import from server' ));
$sslImportBtn -> setIconClass ( 'downButton' );
$sslImportBtn -> setTitle ( _ ( 'Imports the certificate directly from your LDAP server.' ));
$row -> addField ( $sslImportBtn );
}
$sslCerts = $cfg -> getSSLCaCertificates ();
if ( sizeof ( $sslCerts ) > 0 ) {
$certsTitles = array ( _ ( 'Common name' ), _ ( 'Valid to' ), _ ( 'Serial number' ), _ ( 'Delete' ));
$certsData = array ();
for ( $i = 0 ; $i < sizeof ( $sslCerts ); $i ++ ) {
$serial = isset ( $sslCerts [ $i ][ 'serialNumber' ]) ? $sslCerts [ $i ][ 'serialNumber' ] : '' ;
$validTo = isset ( $sslCerts [ $i ][ 'validTo_time_t' ]) ? $sslCerts [ $i ][ 'validTo_time_t' ] : '' ;
$cn = isset ( $sslCerts [ $i ][ 'subject' ][ 'CN' ]) ? $sslCerts [ $i ][ 'subject' ][ 'CN' ] : '' ;
$delBtn = new htmlButton ( 'deleteCert_' . $i , 'delete.png' , true );
$certsData [] = array (
new htmlOutputText ( $cn ),
new htmlOutputText ( $validTo ),
new htmlOutputText ( $serial ),
$delBtn
);
$sslCerts = $cfg -> getSSLCaCertificates ();
if ( sizeof ( $sslCerts ) > 0 ) {
$certsTitles = array ( _ ( 'Common name' ), _ ( 'Valid to' ), _ ( 'Serial number' ), _ ( 'Delete' ));
$certsData = array ();
for ( $i = 0 ; $i < sizeof ( $sslCerts ); $i ++ ) {
$serial = isset ( $sslCerts [ $i ][ 'serialNumber' ]) ? $sslCerts [ $i ][ 'serialNumber' ] : '' ;
$validTo = isset ( $sslCerts [ $i ][ 'validTo_time_t' ]) ? $sslCerts [ $i ][ 'validTo_time_t' ] : '' ;
$cn = isset ( $sslCerts [ $i ][ 'subject' ][ 'CN' ]) ? $sslCerts [ $i ][ 'subject' ][ 'CN' ] : '' ;
$delBtn = new htmlButton ( 'deleteCert_' . $i , 'delete.png' , true );
$certsData [] = array (
new htmlOutputText ( $cn ),
new htmlOutputText ( $validTo ),
new htmlOutputText ( $serial ),
$delBtn
);
}
$certsTable = new \htmlResponsiveTable ( $certsTitles , $certsData );
$row -> add ( $certsTable , 12 );
}
$certsTable = new \htmlResponsiveTable ( $certsTitles , $certsData );
$row -> add ( $certsTable , 12 );
}
// password policy
$row -> add ( new htmlSubTitle ( _ ( " Password policy " )), 12 );
$options20 = array ( 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 );
$options4 = array ( 0 , 1 , 2 , 3 , 4 );
$row -> add ( new htmlResponsiveSelect ( 'passwordMinLength' , $options20 , array ( $cfg -> passwordMinLength ), _ ( 'Minimum password length' ), '242' ), 12 );
$row -> addVerticalSpacer ( '1rem' );
$row -> add ( new htmlResponsiveSelect ( 'passwordMinLower' , $options20 , array ( $cfg -> passwordMinLower ), _ ( 'Minimum lowercase characters' ), '242' ), 12 );
$row -> add ( new htmlResponsiveSelect ( 'passwordMinUpper' , $options20 , array ( $cfg -> passwordMinUpper ), _ ( 'Minimum uppercase characters' ), '242' ), 12 );
$row -> add ( new htmlResponsiveSelect ( 'passwordMinNumeric' , $options20 , array ( $cfg -> passwordMinNumeric ), _ ( 'Minimum numeric characters' ), '242' ), 12 );
$row -> add ( new htmlResponsiveSelect ( 'passwordMinSymbol' , $options20 , array ( $cfg -> passwordMinSymbol ), _ ( 'Minimum symbolic characters' ), '242' ), 12 );
$row -> add ( new htmlResponsiveSelect ( 'passwordMinClasses' , $options4 , array ( $cfg -> passwordMinClasses ), _ ( 'Minimum character classes' ), '242' ), 12 );
$row -> addVerticalSpacer ( '1rem' );
$rulesCountOptions = array ( _ ( 'all' ) => '-1' , '3' => '3' , '4' => '4' );
$rulesCountSelect = new htmlResponsiveSelect ( 'passwordRulesCount' , $rulesCountOptions , array ( $cfg -> checkedRulesCount ), _ ( 'Number of rules that must match' ), '246' );
$rulesCountSelect -> setHasDescriptiveElements ( true );
$row -> add ( $rulesCountSelect , 12 );
$passwordMustNotContainUser = ( $cfg -> passwordMustNotContainUser === 'true' );
$row -> add ( new htmlResponsiveInputCheckbox ( 'passwordMustNotContainUser' , $passwordMustNotContainUser , _ ( 'Password must not contain user name' ), '247' ), 12 );
$passwordMustNotContain3Chars = ( $cfg -> passwordMustNotContain3Chars === 'true' );
$row -> add ( new htmlResponsiveInputCheckbox ( 'passwordMustNotContain3Chars' , $passwordMustNotContain3Chars , _ ( 'Password must not contain part of user/first/last name' ), '248' ), 12 );
if ( function_exists ( 'curl_init' )) {
// password policy
$row -> add ( new htmlSubTitle ( _ ( " Password policy " )), 12 );
$options20 = array ( 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 );
$options4 = array ( 0 , 1 , 2 , 3 , 4 );
$row -> add ( new htmlResponsiveSelect ( 'passwordMinLength' , $options20 , array ( $cfg -> passwordMinLength ), _ ( 'Minimum password length' ), '242' ), 12 );
$row -> addVerticalSpacer ( '1rem' );
$row -> add ( new htmlResponsiveInputField ( _ ( 'External password check' ), 'externalPwdCheckUrl' , $cfg -> externalPwdCheckUrl , '249' ), 12 );
}
$row -> add ( new htmlResponsiveSelect ( 'passwordMinLower' , $options20 , array ( $cfg -> passwordMinLower ), _ ( 'Minimum lowercase characters' ), '242' ), 12 );
$row -> add ( new htmlResponsiveSelect ( 'passwordMinUpper' , $options20 , array ( $cfg -> passwordMinUpper ), _ ( 'Minimum uppercase characters' ), '242' ), 12 );
$row -> add ( new htmlResponsiveSelect ( 'passwordMinNumeric' , $options20 , array ( $cfg -> passwordMinNumeric ), _ ( 'Minimum numeric characters' ), '242' ), 12 );
$row -> add ( new htmlResponsiveSelect ( 'passwordMinSymbol' , $options20 , array ( $cfg -> passwordMinSymbol ), _ ( 'Minimum symbolic characters' ), '242' ), 12 );
$row -> add ( new htmlResponsiveSelect ( 'passwordMinClasses' , $options4 , array ( $cfg -> passwordMinClasses ), _ ( 'Minimum character classes' ), '242' ), 12 );
$row -> addVerticalSpacer ( '1rem' );
$rulesCountOptions = array ( _ ( 'all' ) => '-1' , '3' => '3' , '4' => '4' );
$rulesCountSelect = new htmlResponsiveSelect ( 'passwordRulesCount' , $rulesCountOptions , array ( $cfg -> checkedRulesCount ), _ ( 'Number of rules that must match' ), '246' );
$rulesCountSelect -> setHasDescriptiveElements ( true );
$row -> add ( $rulesCountSelect , 12 );
$passwordMustNotContainUser = ( $cfg -> passwordMustNotContainUser === 'true' );
$row -> add ( new htmlResponsiveInputCheckbox ( 'passwordMustNotContainUser' , $passwordMustNotContainUser , _ ( 'Password must not contain user name' ), '247' ), 12 );
$passwordMustNotContain3Chars = ( $cfg -> passwordMustNotContain3Chars === 'true' );
$row -> add ( new htmlResponsiveInputCheckbox ( 'passwordMustNotContain3Chars' , $passwordMustNotContain3Chars , _ ( 'Password must not contain part of user/first/last name' ), '248' ), 12 );
if ( function_exists ( 'curl_init' )) {
$row -> addVerticalSpacer ( '1rem' );
$row -> add ( new htmlResponsiveInputField ( _ ( 'External password check' ), 'externalPwdCheckUrl' , $cfg -> externalPwdCheckUrl , '249' ), 12 );
}
// logging
$row -> add ( new htmlSubTitle ( _ ( " Logging " )), 12 );
$levelOptions = array ( _ ( " Debug " ) => LOG_DEBUG , _ ( " Notice " ) => LOG_NOTICE , _ ( " Warning " ) => LOG_WARNING , _ ( " Error " ) => LOG_ERR );
$levelSelect = new htmlResponsiveSelect ( 'logLevel' , $levelOptions , array ( $cfg -> logLevel ), _ ( " Log level " ), '239' );
$levelSelect -> setHasDescriptiveElements ( true );
$row -> add ( $levelSelect , 12 );
$destinationOptions = array (
_ ( " No logging " ) => " none " ,
_ ( " System logging " ) => " syslog " ,
_ ( " File " ) => 'file' ,
_ ( " Remote " ) => 'remote' ,
);
$destinationSelected = 'file' ;
$destinationPath = $cfg -> logDestination ;
$destinationRemote = '' ;
if ( $cfg -> logDestination == 'NONE' ) {
$destinationSelected = 'none' ;
$destinationPath = '' ;
}
elseif ( $cfg -> logDestination == 'SYSLOG' ) {
$destinationSelected = 'syslog' ;
$destinationPath = '' ;
}
elseif ( strpos ( $cfg -> logDestination , 'REMOTE' ) === 0 ) {
$destinationSelected = 'remote' ;
$remoteParts = explode ( ':' , $cfg -> logDestination , 2 );
$destinationRemote = empty ( $remoteParts [ 1 ]) ? '' : $remoteParts [ 1 ];
$destinationPath = '' ;
}
$logDestinationSelect = new htmlResponsiveSelect ( 'logDestination' , $destinationOptions , array ( $destinationSelected ), _ ( " Log destination " ), '240' );
$logDestinationSelect -> setTableRowsToHide ( array (
'none' => array ( 'logFile' , 'logRemote' ),
'syslog' => array ( 'logFile' , 'logRemote' ),
'remote' => array ( 'logFile' ),
'file' => array ( 'logRemote' ),
));
$logDestinationSelect -> setTableRowsToShow ( array (
'file' => array ( 'logFile' ),
'remote' => array ( 'logRemote' ),
));
$logDestinationSelect -> setHasDescriptiveElements ( true );
$row -> add ( $logDestinationSelect , 12 );
$row -> add ( new htmlResponsiveInputField ( _ ( 'File' ), 'logFile' , $destinationPath ), 12 );
$row -> add ( new htmlResponsiveInputField ( _ ( 'Remote server' ), 'logRemote' , $destinationRemote , '251' ), 12 );
$errorLogOptions = array (
_ ( 'PHP system setting' ) => LAMCfgMain :: ERROR_REPORTING_SYSTEM ,
_ ( 'default' ) => LAMCfgMain :: ERROR_REPORTING_DEFAULT ,
_ ( 'all' ) => LAMCfgMain :: ERROR_REPORTING_ALL
);
$errorLogSelect = new htmlResponsiveSelect ( 'errorReporting' , $errorLogOptions , array ( $cfg -> errorReporting ), _ ( 'PHP error reporting' ), '244' );
$errorLogSelect -> setHasDescriptiveElements ( true );
$row -> add ( $errorLogSelect , 12 );
// additional options
if ( isLAMProVersion ()) {
$row -> add ( new htmlSubTitle ( _ ( 'Additional options' )), 12 );
$mailEOLOptions = array (
_ ( 'Default (\r\n)' ) => 'default' ,
_ ( 'Non-standard (\n)' ) => 'unix'
// logging
$row -> add ( new htmlSubTitle ( _ ( " Logging " )), 12 );
$levelOptions = array ( _ ( " Debug " ) => LOG_DEBUG , _ ( " Notice " ) => LOG_NOTICE , _ ( " Warning " ) => LOG_WARNING , _ ( " Error " ) => LOG_ERR );
$levelSelect = new htmlResponsiveSelect ( 'logLevel' , $levelOptions , array ( $cfg -> logLevel ), _ ( " Log level " ), '239' );
$levelSelect -> setHasDescriptiveElements ( true );
$row -> add ( $levelSelect , 12 );
$destinationOptions = array (
_ ( " No logging " ) => " none " ,
_ ( " System logging " ) => " syslog " ,
_ ( " File " ) => 'file' ,
_ ( " Remote " ) => 'remote' ,
);
$mailEOLSelect = new htmlResponsiveSelect ( 'mailEOL' , $mailEOLOptions , array ( $cfg -> mailEOL ), _ ( 'Email format' ), '243' );
$mailEOLSelect -> setHasDescriptiveElements ( true );
$row -> add ( $mailEOLSelect , 12 );
}
$row -> addVerticalSpacer ( '3rem' );
// change master password
$row -> add ( new htmlSubTitle ( _ ( " Change master password " )), 12 );
$pwd1 = new htmlResponsiveInputField ( _ ( " New master password " ), 'masterpassword' , '' , '235' );
$pwd1 -> setIsPassword ( true , false , true );
$row -> add ( $pwd1 , 12 );
$pwd2 = new htmlResponsiveInputField ( _ ( " Reenter password " ), 'masterpassword2' , '' );
$pwd2 -> setIsPassword ( true , false , true );
$pwd2 -> setSameValueFieldID ( 'masterpassword' );
$row -> add ( $pwd2 , 12 );
$row -> addVerticalSpacer ( '3rem' );
// buttons
if ( $cfg -> isWritable ()) {
$buttonTable = new htmlTable ();
$buttonTable -> addElement ( new htmlButton ( 'submit' , _ ( " Ok " )));
$buttonTable -> addElement ( new htmlSpacer ( '1rem' , null ));
$buttonTable -> addElement ( new htmlButton ( 'cancel' , _ ( " Cancel " )));
$row -> add ( $buttonTable , 12 );
$row -> add ( new htmlHiddenInput ( 'submitFormData' , '1' ), 12 );
}
$destinationSelected = 'file' ;
$destinationPath = $cfg -> logDestination ;
$destinationRemote = '' ;
if ( $cfg -> logDestination == 'NONE' ) {
$destinationSelected = 'none' ;
$destinationPath = '' ;
} elseif ( $cfg -> logDestination == 'SYSLOG' ) {
$destinationSelected = 'syslog' ;
$destinationPath = '' ;
} elseif ( strpos ( $cfg -> logDestination , 'REMOTE' ) === 0 ) {
$destinationSelected = 'remote' ;
$remoteParts = explode ( ':' , $cfg -> logDestination , 2 );
$destinationRemote = empty ( $remoteParts [ 1 ]) ? '' : $remoteParts [ 1 ];
$destinationPath = '' ;
}
$logDestinationSelect = new htmlResponsiveSelect ( 'logDestination' , $destinationOptions , array ( $destinationSelected ), _ ( " Log destination " ), '240' );
$logDestinationSelect -> setTableRowsToHide ( array (
'none' => array ( 'logFile' , 'logRemote' ),
'syslog' => array ( 'logFile' , 'logRemote' ),
'remote' => array ( 'logFile' ),
'file' => array ( 'logRemote' ),
));
$logDestinationSelect -> setTableRowsToShow ( array (
'file' => array ( 'logFile' ),
'remote' => array ( 'logRemote' ),
));
$logDestinationSelect -> setHasDescriptiveElements ( true );
$row -> add ( $logDestinationSelect , 12 );
$row -> add ( new htmlResponsiveInputField ( _ ( 'File' ), 'logFile' , $destinationPath ), 12 );
$row -> add ( new htmlResponsiveInputField ( _ ( 'Remote server' ), 'logRemote' , $destinationRemote , '251' ), 12 );
$errorLogOptions = array (
_ ( 'PHP system setting' ) => LAMCfgMain :: ERROR_REPORTING_SYSTEM ,
_ ( 'default' ) => LAMCfgMain :: ERROR_REPORTING_DEFAULT ,
_ ( 'all' ) => LAMCfgMain :: ERROR_REPORTING_ALL
);
$errorLogSelect = new htmlResponsiveSelect ( 'errorReporting' , $errorLogOptions , array ( $cfg -> errorReporting ), _ ( 'PHP error reporting' ), '244' );
$errorLogSelect -> setHasDescriptiveElements ( true );
$row -> add ( $errorLogSelect , 12 );
$box = new htmlDiv ( null , $row );
$box -> setCSSClasses ( array ( 'ui-corner-all' , 'roundedShadowBox' ));
parseHtml ( null , $box , array (), false , $tabindex , 'user' );
// additional options
if ( isLAMProVersion ()) {
$row -> add ( new htmlSubTitle ( _ ( 'Additional options' )), 12 );
$mailEOLOptions = array (
_ ( 'Default (\r\n)' ) => 'default' ,
_ ( 'Non-standard (\n)' ) => 'unix'
);
$mailEOLSelect = new htmlResponsiveSelect ( 'mailEOL' , $mailEOLOptions , array ( $cfg -> mailEOL ), _ ( 'Email format' ), '243' );
$mailEOLSelect -> setHasDescriptiveElements ( true );
$row -> add ( $mailEOLSelect , 12 );
}
$row -> addVerticalSpacer ( '3rem' );
// webauthn management
if (( version_compare ( phpversion (), '7.2.0' ) >= 0 )
&& extension_loaded ( 'PDO' )
&& in_array ( 'sqlite' , \PDO :: getAvailableDrivers ())) {
include_once __DIR__ . '/../../lib/webauthn.inc' ;
$database = new \LAM\LOGIN\WEBAUTHN\PublicKeyCredentialSourceRepositorySQLite ();
if ( $database -> hasRegisteredCredentials ()) {
$row -> add ( new htmlSubTitle ( _ ( 'Webauthn devices' )), 12 );
$row -> add ( new htmlResponsiveInputField ( _ ( 'User DN' ), 'webauthn_userDN' , null , '252' ), 12 );
$row -> addVerticalSpacer ( '0.5rem' );
$row -> add ( new htmlButton ( 'webauthn_search' , _ ( 'Search' )), 12 , 12 , 12 , 'text-center' );
$resultDiv = new htmlDiv ( 'webauthn_results' , new htmlOutputText ( '' ), array ( 'lam-webauthn-results' ));
addSecurityTokenToSession ( false );
$resultDiv -> addDataAttribute ( 'sec_token_value' , getSecurityTokenValue ());
$row -> add ( $resultDiv , 12 );
}
}
// change master password
$row -> add ( new htmlSubTitle ( _ ( " Change master password " )), 12 );
$pwd1 = new htmlResponsiveInputField ( _ ( " New master password " ), 'masterpassword' , '' , '235' );
$pwd1 -> setIsPassword ( true , false , true );
$row -> add ( $pwd1 , 12 );
$pwd2 = new htmlResponsiveInputField ( _ ( " Reenter password " ), 'masterpassword2' , '' );
$pwd2 -> setIsPassword ( true , false , true );
$pwd2 -> setSameValueFieldID ( 'masterpassword' );
$row -> add ( $pwd2 , 12 );
$row -> addVerticalSpacer ( '3rem' );
// buttons
if ( $cfg -> isWritable ()) {
$buttonTable = new htmlTable ();
$buttonTable -> addElement ( new htmlButton ( 'submit' , _ ( " Ok " )));
$buttonTable -> addElement ( new htmlSpacer ( '1rem' , null ));
$buttonTable -> addElement ( new htmlButton ( 'cancel' , _ ( " Cancel " )));
$row -> add ( $buttonTable , 12 );
$row -> add ( new htmlHiddenInput ( 'submitFormData' , '1' ), 12 );
}
/**
* Formats an LDAP time string ( e . g . from createTimestamp ) .
*
* @ param String $time LDAP time value
* @ return String formated time
*/
function formatSSLTimestamp ( $time ) {
if ( ! empty ( $time )) {
$timeZone = 'UTC' ;
$sysTimeZone = @ date_default_timezone_get ();
if ( ! empty ( $sysTimeZone )) {
$timeZone = $sysTimeZone ;
$box = new htmlDiv ( null , $row );
$box -> setCSSClasses ( array ( 'ui-corner-all' , 'roundedShadowBox' ));
parseHtml ( null , $box , array (), false , $tabindex , 'user' );
/**
* Formats an LDAP time string ( e . g . from createTimestamp ) .
*
* @ param String $time LDAP time value
* @ return String formated time
*/
function formatSSLTimestamp ( $time ) {
if ( ! empty ( $time )) {
$timeZone = 'UTC' ;
$sysTimeZone = @ date_default_timezone_get ();
if ( ! empty ( $sysTimeZone )) {
$timeZone = $sysTimeZone ;
}
$date = new DateTime ( '@' . $time , new DateTimeZone ( $timeZone ));
return $date -> format ( 'd.m.Y' );
}
$date = new DateTime ( '@' . $time , new DateTimeZone ( $timeZone ));
return $date -> format ( 'd.m.Y' );
return '' ;
}
return '' ;
}
?>
?>
</ form >
< p >< br ></ p >
</ form >
< p >< br ></ p >
</ body >
</ body >
</ html >