2006-11-13 23:31:26 +01:00
< ? php
2013-02-24 18:08:52 +01:00
/* Copyright ( C ) 2004 - 2013 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2013-11-16 13:00:21 +01:00
* Copyright ( C ) 2013 Juanjo Menent < jmenent @ 2 byte . es >
2024-11-04 23:53:20 +01:00
* Copyright ( C ) 2024 Frédéric France < frederic . france @ free . fr >
2006-11-13 23:31:26 +01: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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2006-11-13 23:31:26 +01:00
* ( 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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2006-11-13 23:31:26 +01:00
*/
/**
2008-10-12 13:41:13 +02:00
* \file htdocs / admin / security_other . php
* \ingroup core
2008-10-28 21:46:22 +01:00
* \brief Security options setup
2008-10-12 13:41:13 +02:00
*/
2006-11-13 23:31:26 +01:00
2022-09-07 20:08:59 +02:00
// Load Dolibarr environment
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
2012-09-02 22:15:00 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
2006-11-13 23:31:26 +01:00
2024-11-04 23:53:20 +01:00
/**
* @ var Conf $conf
* @ var DoliDB $db
* @ var HookManager $hookmanager
* @ var Translate $langs
* @ var User $user
*/
2018-05-26 18:52:14 +02:00
// Load translation files required by the page
2020-02-18 23:47:25 +01:00
$langs -> loadLangs ( array ( " users " , " admin " , " other " ));
2006-11-13 23:31:26 +01:00
2021-02-26 22:04:03 +01:00
if ( ! $user -> admin ) {
2012-08-09 16:35:39 +02:00
accessforbidden ();
2021-02-26 22:04:03 +01:00
}
2012-08-09 16:35:39 +02:00
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2006-11-13 23:31:26 +01:00
2010-01-06 00:01:25 +01:00
2006-11-13 23:31:26 +01:00
/*
* Actions
*/
2010-01-06 00:01:25 +01:00
2021-02-26 22:04:03 +01:00
if ( preg_match ( '/set_([a-z0-9_\-]+)/i' , $action , $reg )) {
2020-02-18 23:47:25 +01:00
$code = $reg [ 1 ];
$value = ( GETPOST ( $code , 'alpha' ) ? GETPOST ( $code , 'alpha' ) : 1 );
2021-02-26 22:04:03 +01:00
if ( dolibarr_set_const ( $db , $code , $value , 'chaine' , 0 , '' , $conf -> entity ) > 0 ) {
2024-01-12 20:40:34 +01:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ]);
2012-09-02 22:04:30 +02:00
exit ;
2020-05-21 09:35:30 +02:00
} else {
2012-09-02 22:04:30 +02:00
dol_print_error ( $db );
}
2019-01-27 23:23:38 +01:00
} elseif ( preg_match ( '/del_([a-z0-9_\-]+)/i' , $action , $reg )) {
2020-02-18 23:47:25 +01:00
$code = $reg [ 1 ];
2021-02-26 22:04:03 +01:00
if ( dolibarr_del_const ( $db , $code , $conf -> entity ) > 0 ) {
2024-01-12 20:40:34 +01:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ]);
2012-09-02 22:04:30 +02:00
exit ;
2020-05-21 09:35:30 +02:00
} else {
2012-09-02 22:04:30 +02:00
dol_print_error ( $db );
}
2021-02-26 22:04:03 +01:00
} elseif ( $action == 'updateform' ) {
2023-12-04 11:41:14 +01:00
$res1 = 1 ;
$res2 = 1 ;
$res3 = 1 ;
$res4 = 1 ;
$res5 = 1 ;
2024-12-07 12:50:57 +01:00
$res6 = 1 ;
2022-07-24 18:30:18 +02:00
if ( GETPOSTISSET ( 'MAIN_APPLICATION_TITLE' )) {
$res1 = dolibarr_set_const ( $db , " MAIN_APPLICATION_TITLE " , GETPOST ( " MAIN_APPLICATION_TITLE " , 'alphanohtml' ), 'chaine' , 0 , '' , $conf -> entity );
}
if ( GETPOSTISSET ( 'MAIN_SESSION_TIMEOUT' )) {
$res2 = dolibarr_set_const ( $db , " MAIN_SESSION_TIMEOUT " , GETPOST ( " MAIN_SESSION_TIMEOUT " , 'alphanohtml' ), 'chaine' , 0 , '' , $conf -> entity );
}
2022-08-03 14:24:27 +02:00
if ( GETPOSTISSET ( 'MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT' )) {
$res3 = dolibarr_set_const ( $db , " MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT " , GETPOST ( " MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT " , 'alphanohtml' ), 'int' , 0 , '' , $conf -> entity );
}
2022-08-04 16:53:58 +02:00
if ( GETPOSTISSET ( 'MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS' )) {
$res4 = dolibarr_set_const ( $db , " MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS " , GETPOST ( " MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS " , 'alphanohtml' ), 'int' , 0 , '' , $conf -> entity );
}
2022-11-25 17:20:39 +01:00
if ( GETPOSTISSET ( 'MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS' )) {
$res5 = dolibarr_set_const ( $db , " MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS " , GETPOST ( " MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS " , 'alphanohtml' ), 'int' , 0 , '' , $conf -> entity );
}
2024-12-07 12:50:57 +01:00
if ( GETPOSTISSET ( 'MAIN_SECURITY_MAX_NUMBER_FAILED_AUTH' )) {
$res6 = dolibarr_set_const ( $db , " MAIN_SECURITY_MAX_NUMBER_FAILED_AUTH " , GETPOST ( " MAIN_SECURITY_MAX_NUMBER_FAILED_AUTH " , 'alphanohtml' ), 'int' , 0 , '' , $conf -> entity );
}
if ( $res1 && $res2 && $res3 && $res4 && $res5 && $res6 ) {
2021-02-26 22:04:03 +01:00
setEventMessages ( $langs -> trans ( " RecordModifiedSuccessfully " ), null , 'mesgs' );
}
2014-08-12 12:29:20 +02:00
}
2010-01-07 01:06:21 +01:00
2006-11-13 23:31:26 +01:00
/*
2010-01-07 01:06:21 +01:00
* View
2006-11-13 23:31:26 +01:00
*/
2010-01-06 00:01:25 +01:00
$form = new Form ( $db );
2020-02-18 23:47:25 +01:00
$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad' ;
2024-06-08 17:03:08 +02:00
llxHeader ( '' , $langs -> trans ( " Miscellaneous " ), $wikihelp , '' , 0 , 0 , '' , '' , '' , 'mod-admin page-security_other' );
2006-11-13 23:31:26 +01:00
2019-01-27 11:55:16 +01:00
print load_fiche_titre ( $langs -> trans ( " SecuritySetup " ), '' , 'title_setup' );
2006-11-13 23:31:26 +01:00
2019-10-11 14:42:55 +02:00
print '<span class="opacitymedium">' . $langs -> trans ( " MiscellaneousDesc " ) . " </span><br> \n " ;
2006-11-13 23:31:26 +01:00
print " <br> \n " ;
2014-11-20 10:15:24 +01:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2014-11-20 10:15:24 +01:00
print '<input type="hidden" name="action" value="updateform">' ;
2008-10-12 13:41:13 +02:00
2020-02-18 23:47:25 +01:00
$head = security_prepare_head ();
2006-11-13 23:31:26 +01:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'misc' , '' , - 1 );
2006-11-13 23:31:26 +01:00
2021-10-19 16:26:43 +02:00
print '<br>' ;
2009-08-21 21:09:20 +02:00
// Other Options
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2007-10-02 17:33:13 +02:00
print '<tr class="liste_titre">' ;
print '<td colspan="3">' . $langs -> trans ( " Parameters " ) . '</td>' ;
2019-01-22 11:56:09 +01:00
print '<td class="right" width="100">' . $langs -> trans ( " Status " ) . '</td>' ;
2007-10-02 17:33:13 +02:00
print '</tr>' ;
2010-11-08 12:40:52 +01:00
// Enable advanced perms
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2010-11-08 12:40:52 +01:00
print '<td colspan="3">' . $langs -> trans ( " UseAdvancedPerms " ) . '</td>' ;
2019-01-22 11:56:09 +01:00
print '<td class="right">' ;
2021-02-26 22:04:03 +01:00
if ( ! empty ( $conf -> use_javascript_ajax )) {
2012-09-02 22:04:30 +02:00
print ajax_constantonoff ( 'MAIN_USE_ADVANCED_PERMS' );
2020-05-21 09:35:30 +02:00
} else {
2023-10-24 17:00:13 +02:00
if ( ! getDolGlobalString ( 'MAIN_USE_ADVANCED_PERMS' )) {
2021-09-19 14:41:46 +02:00
print '<a href="' . $_SERVER [ 'PHP_SELF' ] . '?action=set_MAIN_USE_ADVANCED_PERMS&token=' . newToken () . '">' . img_picto ( $langs -> trans ( " Disabled " ), 'off' ) . '</a>' ;
2020-05-21 09:35:30 +02:00
} else {
2021-09-19 14:41:46 +02:00
print '<a href="' . $_SERVER [ 'PHP_SELF' ] . '?action=del_MAIN_USE_ADVANCED_PERMS&token=' . newToken () . '">' . img_picto ( $langs -> trans ( " Enabled " ), 'on' ) . '</a>' ;
2012-09-02 22:04:30 +02:00
}
2010-11-08 12:40:52 +01:00
}
2012-09-02 22:04:30 +02:00
print " </td></tr> " ;
2007-10-02 17:33:13 +02:00
2009-08-21 21:09:20 +02:00
print '</table>' ;
2014-11-20 10:15:24 +01:00
print '<br>' ;
// Timeout
print '<table width="100%" class="noborder">' ;
print '<tr class="liste_titre">' ;
print '<td colspan="2">' . $langs -> trans ( " Parameters " ) . '</td>' ;
2024-09-27 18:55:19 +02:00
print '<td></td>' ;
2014-11-20 10:15:24 +01:00
print " </tr> \n " ;
2017-04-14 11:22:48 +02:00
2020-02-18 23:47:25 +01:00
$sessiontimeout = ini_get ( " session.gc_maxlifetime " );
2023-10-24 17:00:13 +02:00
if ( ! getDolGlobalString ( 'MAIN_SESSION_TIMEOUT' )) {
2021-02-26 22:04:03 +01:00
$conf -> global -> MAIN_SESSION_TIMEOUT = $sessiontimeout ;
}
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2019-01-22 11:56:09 +01:00
print '<td>' . $langs -> trans ( " SessionTimeOut " ) . '</td><td class="right">' ;
2020-05-18 15:26:04 +02:00
if ( ini_get ( " session.gc_probability " ) == 0 ) {
2024-11-26 16:34:17 +01:00
// For external cleaning of session, the delay used may be the one into the ini file, so get_cfg_var("session.gc_maxlifetime"), not the one overloaded in runtime.
print $form -> textwithpicto ( '' , $langs -> trans ( " SessionsPurgedByExternalSystem " , get_cfg_var ( " session.gc_maxlifetime " )));
2020-05-18 15:26:04 +02:00
} else {
print $form -> textwithpicto ( '' , $langs -> trans ( " SessionExplanation " , ini_get ( " session.gc_probability " ), ini_get ( " session.gc_divisor " ), ini_get ( " session.gc_maxlifetime " )));
}
2014-11-20 10:15:24 +01:00
print '</td>' ;
print '<td class="nowrap">' ;
2022-11-29 10:24:21 +01:00
print '<input class="flat right width50" name="MAIN_SESSION_TIMEOUT" type="text" value="' . getDolGlobalInt ( 'MAIN_SESSION_TIMEOUT' ) . '"> ' . strtolower ( $langs -> trans ( " Seconds " ));
2014-11-20 10:15:24 +01:00
print '</td>' ;
print '</tr>' ;
2022-08-03 14:24:27 +02:00
print '<tr class="oddeven">' ;
print '<td>' . $langs -> trans ( " MaxNumberOfImagesInGetPost " ) . '</td><td class="right">' ;
print '</td>' ;
print '<td class="nowrap">' ;
2022-11-29 10:24:21 +01:00
print '<input class="flat right width50" name="MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT" type="text" value="' . getDolGlobalInt ( 'MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT' ) . '"> ' . strtolower ( $langs -> trans ( " Images " ));
2022-08-03 14:24:27 +02:00
print '</td>' ;
print '</tr>' ;
2022-08-04 16:53:58 +02:00
print '<tr class="oddeven">' ;
print '<td>' . $langs -> trans ( " MaxNumberOfPostOnPublicPagesByIP " ) . '</td><td class="right">' ;
print '</td>' ;
print '<td class="nowrap">' ;
2022-11-29 10:24:21 +01:00
print '<input class="flat right width50" name="MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS" type="text" value="' . getDolGlobalInt ( " MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS " , 200 ) . '"> ' . strtolower ( $langs -> trans ( " Posts " ));
2022-08-04 16:53:58 +02:00
print '</td>' ;
print '</tr>' ;
2022-11-25 17:20:39 +01:00
print '<tr class="oddeven">' ;
print '<td>' . $langs -> trans ( " MaxNumberOfAttachementOnForms " ) . '</td><td class="right">' ;
print '</td>' ;
print '<td class="nowrap">' ;
2022-11-28 11:06:36 +01:00
print '<input class="flat right width50" name="MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS" type="text" value="' . getDolGlobalInt ( " MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS " , 10 ) . '"> ' . strtolower ( $langs -> trans ( " Files " ));
2022-11-25 17:20:39 +01:00
print '</td>' ;
print '</tr>' ;
2023-08-01 17:16:50 +02:00
print '<tr class="oddeven">' ;
print '<td>' . $langs -> trans ( " MaxNumberOfFailedAuth " ) . '</td><td class="right">' ;
print '</td>' ;
print '<td class="nowrap">' ;
print '<input class="flat right width50" name="MAIN_SECURITY_MAX_NUMBER_FAILED_AUTH" type="text" value="' . getDolGlobalInt ( " MAIN_SECURITY_MAX_NUMBER_FAILED_AUTH " , 100 ) . '"> ' . $langs -> trans ( " FailedAuth " );
print '</td>' ;
print '</tr>' ;
2022-07-24 18:30:18 +02:00
/*
2021-02-26 22:04:03 +01:00
if ( empty ( $conf -> global -> MAIN_APPLICATION_TITLE )) {
$conf -> global -> MAIN_APPLICATION_TITLE = " " ;
}
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2019-01-22 11:56:09 +01:00
print '<td>' . $langs -> trans ( " MAIN_APPLICATION_TITLE " ) . '</td><td class="right">' ;
2014-11-20 10:15:24 +01:00
print '</td>' ;
print '<td class="nowrap">' ;
2022-07-22 19:25:15 +02:00
print '<input class="flat" name="MAIN_APPLICATION_TITLE" type="text" size="20" value="' . dol_escape_htmltag ( $conf -> global -> MAIN_APPLICATION_TITLE ) . '"> ' ;
2014-11-20 10:15:24 +01:00
print '</td>' ;
print '</tr>' ;
2022-07-24 18:30:18 +02:00
*/
2014-11-20 10:15:24 +01:00
print '</table>' ;
2021-08-24 17:04:17 +02:00
print $form -> buttonsSaveCancel ( " Modify " , '' );
2014-11-20 10:15:24 +01:00
2022-08-25 19:33:04 +02:00
print dol_get_fiche_end ();
2014-11-20 10:15:24 +01:00
print '</form>' ;
2018-07-28 18:03:14 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-01-08 00:52:07 +01:00
$db -> close ();