dolibarr 25.0.0-alpha
security_other.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
39
40// Load translation files required by the page
41$langs->loadLangs(array("users", "admin", "other"));
42
43if (!$user->admin) {
45}
46
47$action = GETPOST('action', 'aZ09');
48
49
50/*
51 * Actions
52 */
53
54$reg = array();
55if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
56 $code = $reg[1];
57 $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
58 if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
59 header("Location: ".$_SERVER["PHP_SELF"]);
60 exit;
61 } else {
62 dol_print_error($db);
63 }
64} elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
65 $code = $reg[1];
66 if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
67 header("Location: ".$_SERVER["PHP_SELF"]);
68 exit;
69 } else {
70 dol_print_error($db);
71 }
72} elseif ($action == 'updateform') {
73 $res1 = 1;
74 $res2 = 1;
75 $res3 = 1;
76 $res4 = 1;
77 $res5 = 1;
78 $res6 = 1;
79 if (GETPOSTISSET('MAIN_SESSION_TIMEOUT')) {
80 $res2 = dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", max(120, min(3600 * 24, GETPOSTINT("MAIN_SESSION_TIMEOUT"))), 'chaine', 0, '', $conf->entity); // Between 120 and 86400
81 }
82 if (GETPOSTISSET('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT')) {
83 $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);
84 }
85 if (GETPOSTISSET('MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS')) {
86 $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);
87 }
88 if (GETPOSTISSET('MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS')) {
89 $res5 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", GETPOST("MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", 'alphanohtml'), 'int', 0, '', $conf->entity);
90 }
91 if (GETPOSTISSET('MAIN_SECURITY_MAX_NUMBER_FAILED_AUTH')) {
92 $res6 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_NUMBER_FAILED_AUTH", GETPOST("MAIN_SECURITY_MAX_NUMBER_FAILED_AUTH", 'alphanohtml'), 'int', 0, '', $conf->entity);
93 }
94 if ($res1 && $res2 && $res3 && $res4 && $res5 && $res6) {
95 setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
96 }
97}
98
99
100
101/*
102 * View
103 */
104
105$form = new Form($db);
106
107$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
108llxHeader('', $langs->trans("Miscellaneous"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-security_other');
109
110print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
111
112print '<div class="info">'.$langs->trans("MiscellaneousDesc")."</div>\n";
113
114
115
116print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" spellcheck="false">';
117print '<input type="hidden" name="token" value="'.newToken().'">';
118print '<input type="hidden" name="action" value="updateform">';
119
120$head = security_prepare_head();
121
122print dol_get_fiche_head($head, 'misc', '', -1);
123
124print '<br>';
125
126// Other Options
127print '<table class="noborder centpercent">';
128print '<tr class="liste_titre">';
129print '<td colspan="3">'.$langs->trans("Parameters").'</td>';
130print '<td class="right" width="100">'.$langs->trans("Status").'</td>';
131print '</tr>';
132
133// Enable advanced perms
134print '<tr class="oddeven">';
135print '<td colspan="3">'.$langs->trans("UseAdvancedPerms").'</td>';
136print '<td class="right">';
137if (!empty($conf->use_javascript_ajax)) {
138 print ajax_constantonoff('MAIN_USE_ADVANCED_PERMS');
139} else {
140 if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
141 print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_USE_ADVANCED_PERMS&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
142 } else {
143 print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_USE_ADVANCED_PERMS&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
144 }
145}
146print "</td></tr>";
147
148print '</table>';
149
150
151print '<br>';
152
153
154// Timeout
155print '<table width="100%" class="noborder">';
156print '<tr class="liste_titre">';
157print '<td colspan="2">'.$langs->trans("Parameters").'</td>';
158print '<td></td>';
159print "</tr>\n";
160
161
162$sessiontimeout = ini_get("session.gc_maxlifetime");
163if (!getDolGlobalString('MAIN_SESSION_TIMEOUT')) {
164 $conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout;
165}
166print '<tr class="oddeven">';
167print '<td>'.$langs->trans("SessionTimeOut").'</td><td class="right">';
168if (ini_get("session.gc_probability") == 0) {
169 // 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.
170 print $form->textwithpicto('', $langs->trans("SessionsPurgedByExternalSystem", get_cfg_var("session.gc_maxlifetime")));
171} else {
172 print $form->textwithpicto('', $langs->trans("SessionExplanation", ini_get("session.gc_probability"), ini_get("session.gc_divisor"), ini_get("session.gc_maxlifetime")));
173}
174print '</td>';
175print '<td class="nowrap">';
176print '<input class="flat right width75" name="MAIN_SESSION_TIMEOUT" type="text" value="'.getDolGlobalInt('MAIN_SESSION_TIMEOUT').'"> '.strtolower($langs->trans("Seconds"));
177print '</td>';
178print '</tr>';
179
180print '<tr class="oddeven">';
181print '<td>'.$langs->trans("MaxNumberOfImagesInGetPost").'</td><td class="right">';
182print '</td>';
183print '<td class="nowrap">';
184print '<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"));
185print '</td>';
186print '</tr>';
187
188print '<tr class="oddeven">';
189print '<td>'.$langs->trans("MaxNumberOfPostOnPublicPagesByIP").'</td><td class="right">';
190print '</td>';
191print '<td class="nowrap">';
192print '<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"));
193print '</td>';
194print '</tr>';
195
196print '<tr class="oddeven">';
197print '<td>'.$langs->trans("MaxNumberOfAttachementOnForms").'</td><td class="right">';
198print '</td>';
199print '<td class="nowrap">';
200print '<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"));
201print '</td>';
202print '</tr>';
203
204print '<tr class="oddeven">';
205print '<td>'.$form->textwithpicto($langs->trans("MaxNumberOfFailedAuth"), $langs->trans("MaxNumberOfFailedAuthHelp", 'USER_LOGIN_FAILED', $langs->transnoentitiesnoconv("Audit"))).'</td><td class="right">';
206print '</td>';
207print '<td class="nowrap">';
208print '<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");
209print '</td>';
210print '</tr>';
211
212print '</table>';
213
214print $form->buttonsSaveCancel("Modify", '');
215
216print dol_get_fiche_end();
217
218print '</form>';
219
220// End of page
221llxFooter();
222$db->close();
security_prepare_head()
Prepare array with list of tabs.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage generation of HTML components Only common components must be here.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:542
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:740
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.