2006-04-16 12:49:12 +00:00
< ? php
2017-03-06 18:12:02 +00:00
namespace LAM\CONFIG ;
use \LAMCfgMain ;
use \htmlTable ;
use \htmlTitle ;
use \htmlStatusMessage ;
use \htmlSubTitle ;
use \htmlSpacer ;
use \htmlOutputText ;
use \htmlLink ;
use \htmlGroup ;
use \htmlButton ;
use \htmlHelpLink ;
use \htmlInputField ;
use \htmlInputFileUpload ;
use \DateTime ;
use \DateTimeZone ;
2017-11-03 17:53:10 +00:00
use \htmlResponsiveRow ;
use \htmlResponsiveInputTextarea ;
use \htmlResponsiveSelect ;
use \htmlResponsiveInputCheckbox ;
use \htmlResponsiveInputField ;
use \htmlDiv ;
2018-02-02 17:58:23 +00:00
use \htmlHiddenInput ;
2006-04-16 12:49:12 +00:00
/*
2009-10-27 18:47:12 +00:00
This code is part of LDAP Account Manager ( http :// www . ldap - account - manager . org / )
2019-02-23 18:44:10 +00:00
Copyright ( C ) 2003 - 2019 Roland Gruber
2006-04-16 12:49:12 +00:00
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
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*/
2006-09-24 14:19:50 +00:00
2006-04-16 12:49:12 +00:00
/**
* Manages the main configuration options .
*
* @ package configuration
* @ author Roland Gruber
*/
/** Access to config functions */
include_once ( '../../lib/config.inc' );
/** Used to print status messages */
include_once ( '../../lib/status.inc' );
2016-08-21 09:16:44 +00:00
/** LAM Pro */
include_once ( '../../lib/selfService.inc' );
2006-04-16 12:49:12 +00:00
// start session
2009-07-08 18:03:28 +00:00
if ( strtolower ( session_module_name ()) == 'files' ) {
session_save_path ( " ../../sess " );
}
2018-03-10 17:48:11 +00:00
lam_start_session ();
2006-04-16 12:49:12 +00:00
setlanguage ();
2013-08-10 12:43:01 +00:00
if ( ! isset ( $_SESSION [ 'cfgMain' ])) {
$cfg = new LAMCfgMain ();
$_SESSION [ 'cfgMain' ] = $cfg ;
}
$cfg = & $_SESSION [ 'cfgMain' ];
2006-04-16 12:49:12 +00:00
// check if user is logged in
2007-11-07 21:02:13 +00:00
if ( ! isset ( $_SESSION [ " mainconf_password " ]) || ( ! $cfg -> checkPassword ( $_SESSION [ " mainconf_password " ]))) {
2006-04-16 12:49:12 +00:00
require ( 'mainlogin.php' );
exit ();
}
2010-05-28 08:48:57 +00:00
if ( isset ( $_POST [ 'cancel' ])) {
// back to login
metaRefresh ( '../login.php' );
exit ();
2010-01-01 17:39:38 +00:00
}
2006-04-16 12:49:12 +00:00
2010-05-28 08:48:57 +00:00
$errors = array ();
2013-08-10 12:43:01 +00:00
$messages = array ();
2006-04-16 12:49:12 +00:00
// check if submit button was pressed
2018-02-02 17:58:23 +00:00
if ( isset ( $_POST [ 'submitFormData' ])) {
2006-04-16 12:49:12 +00:00
// set master password
if ( isset ( $_POST [ 'masterpassword' ]) && ( $_POST [ 'masterpassword' ] != " " )) {
if ( $_POST [ 'masterpassword' ] && $_POST [ 'masterpassword2' ] && ( $_POST [ 'masterpassword' ] == $_POST [ 'masterpassword2' ])) {
2007-11-07 21:02:13 +00:00
$cfg -> setPassword ( $_POST [ 'masterpassword' ]);
2006-04-16 12:49:12 +00:00
$msg = _ ( " New master password set successfully. " );
unset ( $_SESSION [ " mainconf_password " ]);
}
2019-02-23 18:44:10 +00:00
else {
$errors [] = _ ( " Master passwords are different or empty! " );
}
2006-04-16 12:49:12 +00:00
}
2016-08-21 09:16:44 +00:00
// set license
if ( isLAMProVersion ()) {
$licenseLines = explode ( " \n " , $_POST [ 'license' ]);
$licenseLines = array_map ( 'trim' , $licenseLines );
$cfg -> setLicenseLines ( $licenseLines );
}
2006-04-18 10:57:16 +00:00
// set session timeout
$cfg -> sessionTimeout = $_POST [ 'sessionTimeout' ];
2006-04-25 11:25:07 +00:00
// set allowed hosts
if ( isset ( $_POST [ 'allowedHosts' ])) {
$allowedHosts = $_POST [ 'allowedHosts' ];
$allowedHostsList = explode ( " \n " , $allowedHosts );
for ( $i = 0 ; $i < sizeof ( $allowedHostsList ); $i ++ ) {
$allowedHostsList [ $i ] = trim ( $allowedHostsList [ $i ]);
// ignore empty lines
if ( $allowedHostsList [ $i ] == " " ) {
unset ( $allowedHostsList [ $i ]);
continue ;
}
// check each line
2012-03-13 21:02:37 +00:00
$ipRegex = '/^[0-9a-f\\.:\\*]+$/i' ;
2009-08-14 18:06:15 +00:00
if ( ! preg_match ( $ipRegex , $allowedHostsList [ $i ]) || ( strlen ( $allowedHostsList [ $i ]) > 15 )) {
2012-03-13 21:02:37 +00:00
$errors [] = sprintf ( _ ( " The IP address %s is invalid! " ), htmlspecialchars ( str_replace ( '%' , '%%' , $allowedHostsList [ $i ])));
2006-04-25 11:25:07 +00:00
}
}
$allowedHosts = implode ( " , " , $allowedHostsList );
}
2019-02-23 18:44:10 +00:00
else {
$allowedHosts = " " ;
}
2006-04-25 11:25:07 +00:00
$cfg -> allowedHosts = $allowedHosts ;
2014-01-12 19:58:15 +00:00
// set allowed hosts for self service
if ( isLAMProVersion ()) {
if ( isset ( $_POST [ 'allowedHostsSelfService' ])) {
$allowedHostsSelfService = $_POST [ 'allowedHostsSelfService' ];
$allowedHostsSelfServiceList = explode ( " \n " , $allowedHostsSelfService );
for ( $i = 0 ; $i < sizeof ( $allowedHostsSelfServiceList ); $i ++ ) {
$allowedHostsSelfServiceList [ $i ] = trim ( $allowedHostsSelfServiceList [ $i ]);
// ignore empty lines
if ( $allowedHostsSelfServiceList [ $i ] == " " ) {
unset ( $allowedHostsSelfServiceList [ $i ]);
continue ;
}
// check each line
$ipRegex = '/^[0-9a-f\\.:\\*]+$/i' ;
if ( ! preg_match ( $ipRegex , $allowedHostsSelfServiceList [ $i ]) || ( strlen ( $allowedHostsSelfServiceList [ $i ]) > 15 )) {
$errors [] = sprintf ( _ ( " The IP address %s is invalid! " ), htmlspecialchars ( str_replace ( '%' , '%%' , $allowedHostsSelfServiceList [ $i ])));
}
}
$allowedHostsSelfService = implode ( " , " , $allowedHostsSelfServiceList );
}
2019-02-23 18:44:10 +00:00
else {
$allowedHostsSelfService = " " ;
}
2014-01-12 19:58:15 +00:00
$cfg -> allowedHostsSelfService = $allowedHostsSelfService ;
}
2014-01-12 11:08:43 +00:00
// set session encryption
2017-04-02 17:37:06 +00:00
if ( function_exists ( 'openssl_random_pseudo_bytes' )) {
2014-01-12 11:08:43 +00:00
$encryptSession = 'false' ;
if ( isset ( $_POST [ 'encryptSession' ]) && ( $_POST [ 'encryptSession' ] == 'on' )) {
$encryptSession = 'true' ;
}
$cfg -> encryptSession = $encryptSession ;
}
2006-04-23 16:33:25 +00:00
// set log level
$cfg -> logLevel = $_POST [ 'logLevel' ];
// set log destination
2019-02-23 18:44:10 +00:00
if ( $_POST [ 'logDestination' ] == " none " ) {
$cfg -> logDestination = " NONE " ;
}
elseif ( $_POST [ 'logDestination' ] == " syslog " ) {
$cfg -> logDestination = " SYSLOG " ;
}
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 \" . " );
}
}
2006-04-23 16:33:25 +00:00
else {
2009-10-28 16:05:25 +00:00
if ( isset ( $_POST [ 'logFile' ]) && ( $_POST [ 'logFile' ] != " " ) && preg_match ( " /^[a-z0-9 \\ / \\ \\ : \\ ._-]+ $ /i " , $_POST [ 'logFile' ])) {
2006-04-23 16:33:25 +00:00
$cfg -> logDestination = $_POST [ 'logFile' ];
}
2019-02-23 18:44:10 +00:00
else {
$errors [] = _ ( " The log file is empty or contains invalid characters! Valid characters are: a-z, A-Z, 0-9, /, \\ , ., :, _ and -. " );
}
2006-04-23 16:33:25 +00:00
}
2008-02-10 13:19:05 +00:00
// password policies
$cfg -> passwordMinLength = $_POST [ 'passwordMinLength' ];
$cfg -> passwordMinLower = $_POST [ 'passwordMinLower' ];
$cfg -> passwordMinUpper = $_POST [ 'passwordMinUpper' ];
$cfg -> passwordMinNumeric = $_POST [ 'passwordMinNumeric' ];
$cfg -> passwordMinSymbol = $_POST [ 'passwordMinSymbol' ];
$cfg -> passwordMinClasses = $_POST [ 'passwordMinClasses' ];
2014-04-05 18:42:46 +00:00
$cfg -> checkedRulesCount = $_POST [ 'passwordRulesCount' ];
$cfg -> passwordMustNotContain3Chars = isset ( $_POST [ 'passwordMustNotContain3Chars' ]) && ( $_POST [ 'passwordMustNotContain3Chars' ] == 'on' ) ? 'true' : 'false' ;
$cfg -> passwordMustNotContainUser = isset ( $_POST [ 'passwordMustNotContainUser' ]) && ( $_POST [ 'passwordMustNotContainUser' ] == 'on' ) ? 'true' : 'false' ;
2018-04-10 19:32:26 +00:00
if ( function_exists ( 'curl_init' )) {
$cfg -> externalPwdCheckUrl = $_POST [ 'externalPwdCheckUrl' ];
if ( ! empty ( $cfg -> externalPwdCheckUrl ) && ( strpos ( $cfg -> externalPwdCheckUrl , '{SHA1PREFIX}' ) === false )) {
$errors [] = _ ( 'The URL for the external password check is invalid.' );
}
}
2013-08-10 12:43:01 +00:00
if ( isset ( $_POST [ 'sslCaCertUpload' ])) {
if ( ! isset ( $_FILES [ 'sslCaCert' ]) || ( $_FILES [ 'sslCaCert' ][ 'size' ] == 0 )) {
$errors [] = _ ( 'No file selected.' );
}
else {
$handle = fopen ( $_FILES [ 'sslCaCert' ][ 'tmp_name' ], " r " );
$data = fread ( $handle , 10000000 );
fclose ( $handle );
$sslReturn = $cfg -> uploadSSLCaCert ( $data );
if ( $sslReturn !== true ) {
$errors [] = $sslReturn ;
}
else {
$messages [] = _ ( 'You might need to restart your webserver for changes to take effect.' );
}
}
}
if ( isset ( $_POST [ 'sslCaCertDelete' ])) {
$cfg -> deleteSSLCaCert ();
$messages [] = _ ( 'You might need to restart your webserver for changes to take effect.' );
}
if ( isset ( $_POST [ 'sslCaCertImport' ])) {
$matches = array ();
2017-11-03 17:53:10 +00:00
if ( preg_match ( '/^ldaps:\\/\\/([a-zA-Z0-9_\\.-]+)(:([0-9]+))?$/' , $_POST [ 'serverurl' ], $matches )) {
2013-08-10 12:43:01 +00:00
$port = '636' ;
if ( isset ( $matches [ 3 ]) && ! empty ( $matches [ 3 ])) {
$port = $matches [ 3 ];
}
$pemResult = getLDAPSSLCertificate ( $matches [ 1 ], $port );
if ( $pemResult !== false ) {
$messages [] = _ ( 'Imported certificate from server.' );
$messages [] = _ ( 'You might need to restart your webserver for changes to take effect.' );
$cfg -> uploadSSLCaCert ( $pemResult );
}
else {
$errors [] = _ ( 'Unable to import server certificate. Please use the upload function.' );
}
}
else {
$errors [] = _ ( 'Invalid server name. Please enter "server" or "server:port".' );
}
}
foreach ( $_POST as $key => $value ) {
if ( strpos ( $key , 'deleteCert_' ) === 0 ) {
$index = substr ( $key , strlen ( 'deleteCert_' ));
$cfg -> deleteSSLCaCert ( $index );
}
}
2013-10-16 16:48:59 +00:00
// mail EOL
if ( isLAMProVersion ()) {
$cfg -> mailEOL = $_POST [ 'mailEOL' ];
}
2013-10-18 17:43:09 +00:00
$cfg -> errorReporting = $_POST [ 'errorReporting' ];
2006-04-18 10:57:16 +00:00
// save settings
2013-08-10 12:43:01 +00:00
if ( isset ( $_POST [ 'submit' ])) {
$cfg -> save ();
if ( sizeof ( $errors ) == 0 ) {
metaRefresh ( '../login.php?confMainSavedOk=1' );
exit ();
}
2006-04-16 12:49:12 +00:00
}
}
2009-11-06 19:15:56 +00:00
2010-05-28 08:48:57 +00:00
echo $_SESSION [ 'header' ];
2017-11-04 10:29:38 +00:00
printHeaderContents ( _ ( " Edit general settings " ), '../..' );
2010-05-28 08:48:57 +00:00
?>
</ head >
2017-11-03 17:53:10 +00:00
< body class = " admin " >
2010-08-31 18:05:17 +00:00
< table border = 0 width = " 100% " class = " lamHeader ui-corner-all " >
2010-07-30 16:08:20 +00:00
< tr >
< td align = " left " height = " 30 " >
2019-05-12 07:50:23 +00:00
< a class = " lamLogo " href = " http://www.ldap-account-manager.org/ " target = " new_window " >
< ? php echo getLAMVersionText (); ?>
</ a >
2010-07-30 16:08:20 +00:00
</ td >
</ tr >
</ table >
< br >
2010-11-18 19:29:44 +00:00
<!-- form for adding / renaming / deleting profiles -->
2013-08-10 12:43:01 +00:00
< form enctype = " multipart/form-data " action = " mainmanage.php " method = " post " >
2010-05-28 08:48:57 +00:00
< ? php
// include all JavaScript files
2017-11-04 10:29:38 +00:00
printJsIncludes ( '../..' );
2010-05-28 08:48:57 +00:00
2017-11-03 17:53:10 +00:00
$tabindex = 1 ;
$row = new htmlResponsiveRow ();
$row -> add ( new htmlTitle ( _ ( 'General settings' )), 12 );
2010-11-18 19:29:44 +00:00
2010-05-28 08:48:57 +00:00
// print messages
for ( $i = 0 ; $i < sizeof ( $errors ); $i ++ ) {
2017-11-03 17:53:10 +00:00
$row -> add ( new htmlStatusMessage ( " ERROR " , $errors [ $i ]), 12 );
2010-05-28 08:48:57 +00:00
}
2013-08-10 12:43:01 +00:00
for ( $i = 0 ; $i < sizeof ( $messages ); $i ++ ) {
2017-11-03 17:53:10 +00:00
$row -> add ( new htmlStatusMessage ( " INFO " , $messages [ $i ]), 12 );
2013-08-10 12:43:01 +00:00
}
2010-05-28 08:48:57 +00:00
2009-11-06 19:15:56 +00:00
// check if config file is writable
if ( ! $cfg -> isWritable ()) {
2017-11-03 17:53:10 +00:00
$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 );
2009-11-06 19:15:56 +00:00
}
2006-04-16 12:49:12 +00:00
2016-08-21 09:16:44 +00:00
// license
if ( isLAMProVersion ()) {
2017-11-03 17:53:10 +00:00
$row -> add ( new htmlSubTitle ( _ ( 'Licence' )), 12 );
$row -> add ( new htmlResponsiveInputTextarea ( 'license' , implode ( " \n " , $cfg -> getLicenseLines ()), null , 10 , _ ( 'Licence' ), '287' ), 12 );
2016-08-21 09:16:44 +00:00
2017-11-03 17:53:10 +00:00
$row -> add ( new htmlSpacer ( null , '1rem' ), true );
2016-08-21 09:16:44 +00:00
}
2010-11-18 19:29:44 +00:00
// security settings
2017-11-03 17:53:10 +00:00
$row -> add ( new htmlSubTitle ( _ ( " Security settings " )), 12 );
2013-02-28 17:42:09 +00:00
$options = array ( 5 , 10 , 20 , 30 , 60 , 90 , 120 , 240 );
2017-11-03 17:53:10 +00:00
$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 );
2014-01-12 19:58:15 +00:00
if ( isLAMProVersion ()) {
2017-11-03 17:53:10 +00:00
$row -> add ( new htmlResponsiveInputTextarea ( 'allowedHostsSelfService' , implode ( " \n " , explode ( " , " , $cfg -> allowedHostsSelfService )), null , '7' , _ ( " Allowed hosts (self service) " ), '241' ), 12 );
2014-01-12 19:58:15 +00:00
}
2014-01-12 11:08:43 +00:00
$encryptSession = ( $cfg -> encryptSession === 'true' );
2017-11-03 17:53:10 +00:00
$encryptSessionBox = new htmlResponsiveInputCheckbox ( 'encryptSession' , $encryptSession , _ ( 'Encrypt session' ), '245' );
2017-04-02 17:37:06 +00:00
$encryptSessionBox -> setIsEnabled ( function_exists ( 'openssl_random_pseudo_bytes' ));
2017-11-03 17:53:10 +00:00
$row -> add ( $encryptSessionBox , 12 );
2013-08-10 12:43:01 +00:00
// SSL certificate
2017-11-03 17:53:10 +00:00
$row -> addVerticalSpacer ( '1rem' );
$row -> addLabel ( new htmlOutputText ( _ ( 'SSL certificates' )));
2013-08-10 12:43:01 +00:00
$sslMethod = _ ( 'use system certificates' );
$sslFileName = $cfg -> getSSLCaCertTempFileName ();
if ( $sslFileName != null ) {
2013-08-10 13:25:09 +00:00
$sslMethod = _ ( 'use custom CA certificates' );
2013-08-10 12:43:01 +00:00
}
$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 );
}
2017-11-03 17:53:10 +00:00
$sslDelSaveGroup -> addElement ( new htmlHelpLink ( '204' ));
$row -> addField ( $sslDelSaveGroup );
$row -> addLabel ( new htmlInputFileUpload ( 'sslCaCert' ));
2013-08-10 12:43:01 +00:00
$sslUploadBtn = new htmlButton ( 'sslCaCertUpload' , _ ( 'Upload' ));
$sslUploadBtn -> setIconClass ( 'upButton' );
2013-08-10 13:25:09 +00:00
$sslUploadBtn -> setTitle ( _ ( 'Upload CA certificate in DER/PEM format.' ));
2017-11-03 17:53:10 +00:00
$row -> addField ( $sslUploadBtn );
2013-08-15 15:30:19 +00:00
if ( function_exists ( 'stream_socket_client' ) && function_exists ( 'stream_context_get_params' )) {
2017-11-03 17:53:10 +00:00
$sslImportServerUrl = ! empty ( $_POST [ 'serverurl' ]) ? $_POST [ 'serverurl' ] : 'ldaps://' ;
$serverUrlUpload = new htmlInputField ( 'serverurl' , $sslImportServerUrl );
$row -> addLabel ( $serverUrlUpload );
2013-08-10 12:43:01 +00:00
$sslImportBtn = new htmlButton ( 'sslCaCertImport' , _ ( 'Import from server' ));
$sslImportBtn -> setIconClass ( 'downButton' );
$sslImportBtn -> setTitle ( _ ( 'Imports the certificate directly from your LDAP server.' ));
2017-11-03 17:53:10 +00:00
$row -> addField ( $sslImportBtn );
2013-08-10 12:43:01 +00:00
}
2017-11-03 17:53:10 +00:00
2013-08-10 12:43:01 +00:00
$sslCerts = $cfg -> getSSLCaCertificates ();
if ( sizeof ( $sslCerts ) > 0 ) {
2017-11-03 17:53:10 +00:00
$certsTitles = array ( _ ( 'Common name' ), _ ( 'Valid to' ), _ ( 'Serial number' ), _ ( 'Delete' ));
$certsData = array ();
2013-08-10 12:43:01 +00:00
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' ] : '' ;
2017-11-03 17:53:10 +00:00
$delBtn = new htmlButton ( 'deleteCert_' . $i , 'delete.png' , true );
$certsData [] = array (
new htmlOutputText ( $cn ),
new htmlOutputText ( $validTo ),
new htmlOutputText ( $serial ),
$delBtn
);
2013-08-10 12:43:01 +00:00
}
2017-11-03 17:53:10 +00:00
$certsTable = new \htmlResponsiveTable ( $certsTitles , $certsData );
$row -> add ( $certsTable , 12 );
2013-08-10 12:43:01 +00:00
}
2006-04-16 12:49:12 +00:00
2010-11-18 19:29:44 +00:00
// password policy
2017-11-03 17:53:10 +00:00
$row -> add ( new htmlSubTitle ( _ ( " Password policy " )), 12 );
2010-11-18 19:29:44 +00:00
$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 );
2017-11-03 17:53:10 +00:00
$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' );
2014-04-05 18:42:46 +00:00
$rulesCountOptions = array ( _ ( 'all' ) => '-1' , '3' => '3' , '4' => '4' );
2017-11-03 17:53:10 +00:00
$rulesCountSelect = new htmlResponsiveSelect ( 'passwordRulesCount' , $rulesCountOptions , array ( $cfg -> checkedRulesCount ), _ ( 'Number of rules that must match' ), '246' );
2014-04-05 18:42:46 +00:00
$rulesCountSelect -> setHasDescriptiveElements ( true );
2017-11-03 17:53:10 +00:00
$row -> add ( $rulesCountSelect , 12 );
2019-02-23 18:44:10 +00:00
$passwordMustNotContainUser = ( $cfg -> passwordMustNotContainUser === 'true' );
2017-11-03 17:53:10 +00:00
$row -> add ( new htmlResponsiveInputCheckbox ( 'passwordMustNotContainUser' , $passwordMustNotContainUser , _ ( 'Password must not contain user name' ), '247' ), 12 );
2019-02-23 18:44:10 +00:00
$passwordMustNotContain3Chars = ( $cfg -> passwordMustNotContain3Chars === 'true' );
2017-11-03 17:53:10 +00:00
$row -> add ( new htmlResponsiveInputCheckbox ( 'passwordMustNotContain3Chars' , $passwordMustNotContain3Chars , _ ( 'Password must not contain part of user/first/last name' ), '248' ), 12 );
2018-04-10 19:32:26 +00:00
if ( function_exists ( 'curl_init' )) {
$row -> addVerticalSpacer ( '1rem' );
$row -> add ( new htmlResponsiveInputField ( _ ( 'External password check' ), 'externalPwdCheckUrl' , $cfg -> externalPwdCheckUrl , '249' ), 12 );
}
2010-11-18 19:29:44 +00:00
// logging
2017-11-03 17:53:10 +00:00
$row -> add ( new htmlSubTitle ( _ ( " Logging " )), 12 );
2010-11-18 19:29:44 +00:00
$levelOptions = array ( _ ( " Debug " ) => LOG_DEBUG , _ ( " Notice " ) => LOG_NOTICE , _ ( " Warning " ) => LOG_WARNING , _ ( " Error " ) => LOG_ERR );
2017-11-03 17:53:10 +00:00
$levelSelect = new htmlResponsiveSelect ( 'logLevel' , $levelOptions , array ( $cfg -> logLevel ), _ ( " Log level " ), '239' );
2010-11-18 19:29:44 +00:00
$levelSelect -> setHasDescriptiveElements ( true );
2017-11-03 17:53:10 +00:00
$row -> add ( $levelSelect , 12 );
2019-02-23 18:44:10 +00:00
$destinationOptions = array (
_ ( " No logging " ) => " none " ,
_ ( " System logging " ) => " syslog " ,
_ ( " File " ) => 'file' ,
_ ( " Remote " ) => 'remote' ,
);
2010-11-18 19:29:44 +00:00
$destinationSelected = 'file' ;
$destinationPath = $cfg -> logDestination ;
2019-02-23 18:44:10 +00:00
$destinationRemote = '' ;
2010-11-18 19:29:44 +00:00
if ( $cfg -> logDestination == 'NONE' ) {
$destinationSelected = 'none' ;
$destinationPath = '' ;
}
elseif ( $cfg -> logDestination == 'SYSLOG' ) {
$destinationSelected = 'syslog' ;
$destinationPath = '' ;
}
2019-02-23 18:44:10 +00:00
elseif ( strpos ( $cfg -> logDestination , 'REMOTE' ) === 0 ) {
$destinationSelected = 'remote' ;
$remoteParts = explode ( ':' , $cfg -> logDestination , 2 );
$destinationRemote = empty ( $remoteParts [ 1 ]) ? '' : $remoteParts [ 1 ];
$destinationPath = '' ;
}
2017-11-03 17:53:10 +00:00
$logDestinationSelect = new htmlResponsiveSelect ( 'logDestination' , $destinationOptions , array ( $destinationSelected ), _ ( " Log destination " ), '240' );
$logDestinationSelect -> setTableRowsToHide ( array (
2019-02-23 18:44:10 +00:00
'none' => array ( 'logFile' , 'logRemote' ),
'syslog' => array ( 'logFile' , 'logRemote' ),
'remote' => array ( 'logFile' ),
'file' => array ( 'logRemote' ),
2017-11-03 17:53:10 +00:00
));
$logDestinationSelect -> setTableRowsToShow ( array (
'file' => array ( 'logFile' ),
2019-02-23 18:44:10 +00:00
'remote' => array ( 'logRemote' ),
2017-11-03 17:53:10 +00:00
));
$logDestinationSelect -> setHasDescriptiveElements ( true );
$row -> add ( $logDestinationSelect , 12 );
$row -> add ( new htmlResponsiveInputField ( _ ( 'File' ), 'logFile' , $destinationPath ), 12 );
2019-02-23 18:44:10 +00:00
$row -> add ( new htmlResponsiveInputField ( _ ( 'Remote server' ), 'logRemote' , $destinationRemote , '251' ), 12 );
2013-10-18 17:43:09 +00:00
$errorLogOptions = array (
_ ( 'PHP system setting' ) => LAMCfgMain :: ERROR_REPORTING_SYSTEM ,
2014-04-21 10:52:46 +00:00
_ ( 'default' ) => LAMCfgMain :: ERROR_REPORTING_DEFAULT ,
_ ( 'all' ) => LAMCfgMain :: ERROR_REPORTING_ALL
2013-10-18 17:43:09 +00:00
);
2017-11-03 17:53:10 +00:00
$errorLogSelect = new htmlResponsiveSelect ( 'errorReporting' , $errorLogOptions , array ( $cfg -> errorReporting ), _ ( 'PHP error reporting' ), '244' );
2013-10-18 17:43:09 +00:00
$errorLogSelect -> setHasDescriptiveElements ( true );
2017-11-03 17:53:10 +00:00
$row -> add ( $errorLogSelect , 12 );
2010-11-18 19:29:44 +00:00
2013-10-16 16:48:59 +00:00
// additional options
if ( isLAMProVersion ()) {
2017-11-03 17:53:10 +00:00
$row -> add ( new htmlSubTitle ( _ ( 'Additional options' )), 12 );
2013-10-16 16:48:59 +00:00
$mailEOLOptions = array (
_ ( 'Default (\r\n)' ) => 'default' ,
_ ( 'Non-standard (\n)' ) => 'unix'
);
2017-11-03 17:53:10 +00:00
$mailEOLSelect = new htmlResponsiveSelect ( 'mailEOL' , $mailEOLOptions , array ( $cfg -> mailEOL ), _ ( 'Email format' ), '243' );
2013-10-16 16:48:59 +00:00
$mailEOLSelect -> setHasDescriptiveElements ( true );
2017-11-03 17:53:10 +00:00
$row -> add ( $mailEOLSelect , 12 );
2013-10-16 16:48:59 +00:00
}
2017-11-03 17:53:10 +00:00
$row -> addVerticalSpacer ( '3rem' );
2013-10-16 16:48:59 +00:00
2010-11-18 19:29:44 +00:00
// change master password
2017-11-03 17:53:10 +00:00
$row -> add ( new htmlSubTitle ( _ ( " Change master password " )), 12 );
$pwd1 = new htmlResponsiveInputField ( _ ( " New master password " ), 'masterpassword' , '' , '235' );
2019-10-10 18:45:40 +00:00
$pwd1 -> setIsPassword ( true , false , true );
2017-11-03 17:53:10 +00:00
$row -> add ( $pwd1 , 12 );
$pwd2 = new htmlResponsiveInputField ( _ ( " Reenter password " ), 'masterpassword2' , '' );
2019-10-10 18:45:40 +00:00
$pwd2 -> setIsPassword ( true , false , true );
2014-05-25 14:37:05 +00:00
$pwd2 -> setSameValueFieldID ( 'masterpassword' );
2017-11-03 17:53:10 +00:00
$row -> add ( $pwd2 , 12 );
$row -> addVerticalSpacer ( '3rem' );
2010-11-18 19:29:44 +00:00
// buttons
if ( $cfg -> isWritable ()) {
$buttonTable = new htmlTable ();
$buttonTable -> addElement ( new htmlButton ( 'submit' , _ ( " Ok " )));
2017-11-03 17:53:10 +00:00
$buttonTable -> addElement ( new htmlSpacer ( '1rem' , null ));
2010-11-18 19:29:44 +00:00
$buttonTable -> addElement ( new htmlButton ( 'cancel' , _ ( " Cancel " )));
2017-11-03 17:53:10 +00:00
$row -> add ( $buttonTable , 12 );
2018-02-02 17:58:23 +00:00
$row -> add ( new htmlHiddenInput ( 'submitFormData' , '1' ), 12 );
2010-11-18 19:29:44 +00:00
}
2017-11-03 17:53:10 +00:00
$box = new htmlDiv ( null , $row );
$box -> setCSSClasses ( array ( 'ui-corner-all' , 'roundedShadowBox' ));
parseHtml ( null , $box , array (), false , $tabindex , 'user' );
2013-08-10 12:43:01 +00:00
/**
* Formats an LDAP time string ( e . g . from createTimestamp ) .
2015-08-23 17:56:27 +00:00
*
2013-08-10 12:43:01 +00:00
* @ param String $time LDAP time value
* @ return String formated time
*/
function formatSSLTimestamp ( $time ) {
if ( ! empty ( $time )) {
2015-08-23 17:56:27 +00:00
$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' );
2013-08-10 12:43:01 +00:00
}
return '' ;
}
2010-11-18 19:29:44 +00:00
?>
2006-09-24 14:19:50 +00:00
2006-04-16 12:49:12 +00:00
</ form >
< p >< br ></ p >
</ body >
</ html >