dolibarr 24.0.0-beta
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 {
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 {
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_APPLICATION_TITLE')) {
80 $res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
81 }
82 if (GETPOSTISSET('MAIN_SESSION_TIMEOUT')) {
83 $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
84 }
85 if (GETPOSTISSET('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT')) {
86 $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);
87 }
88 if (GETPOSTISSET('MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS')) {
89 $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);
90 }
91 if (GETPOSTISSET('MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS')) {
92 $res5 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", GETPOST("MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", 'alphanohtml'), 'int', 0, '', $conf->entity);
93 }
94 if (GETPOSTISSET('MAIN_SECURITY_MAX_NUMBER_FAILED_AUTH')) {
95 $res6 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_NUMBER_FAILED_AUTH", GETPOST("MAIN_SECURITY_MAX_NUMBER_FAILED_AUTH", 'alphanohtml'), 'int', 0, '', $conf->entity);
96 }
97 if ($res1 && $res2 && $res3 && $res4 && $res5 && $res6) {
98 setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
99 }
100}
101
102
103
104/*
105 * View
106 */
107
108$form = new Form($db);
109
110$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
111llxHeader('', $langs->trans("Miscellaneous"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-security_other');
112
113print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
114
115print '<span class="opacitymedium">'.$langs->trans("MiscellaneousDesc")."</span><br>\n";
116print "<br>\n";
117
118
119
120print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
121print '<input type="hidden" name="token" value="'.newToken().'">';
122print '<input type="hidden" name="action" value="updateform">';
123
124$head = security_prepare_head();
125
126print dol_get_fiche_head($head, 'misc', '', -1);
127
128print '<br>';
129
130// Other Options
131print '<table class="noborder centpercent">';
132print '<tr class="liste_titre">';
133print '<td colspan="3">'.$langs->trans("Parameters").'</td>';
134print '<td class="right" width="100">'.$langs->trans("Status").'</td>';
135print '</tr>';
136
137// Enable advanced perms
138print '<tr class="oddeven">';
139print '<td colspan="3">'.$langs->trans("UseAdvancedPerms").'</td>';
140print '<td class="right">';
141if (!empty($conf->use_javascript_ajax)) {
142 print ajax_constantonoff('MAIN_USE_ADVANCED_PERMS');
143} else {
144 if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
145 print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_USE_ADVANCED_PERMS&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
146 } else {
147 print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_USE_ADVANCED_PERMS&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
148 }
149}
150print "</td></tr>";
151
152print '</table>';
153
154
155print '<br>';
156
157
158// Timeout
159print '<table width="100%" class="noborder">';
160print '<tr class="liste_titre">';
161print '<td colspan="2">'.$langs->trans("Parameters").'</td>';
162print '<td></td>';
163print "</tr>\n";
164
165
166$sessiontimeout = ini_get("session.gc_maxlifetime");
167if (!getDolGlobalString('MAIN_SESSION_TIMEOUT')) {
168 $conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout;
169}
170print '<tr class="oddeven">';
171print '<td>'.$langs->trans("SessionTimeOut").'</td><td class="right">';
172if (ini_get("session.gc_probability") == 0) {
173 // 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.
174 print $form->textwithpicto('', $langs->trans("SessionsPurgedByExternalSystem", get_cfg_var("session.gc_maxlifetime")));
175} else {
176 print $form->textwithpicto('', $langs->trans("SessionExplanation", ini_get("session.gc_probability"), ini_get("session.gc_divisor"), ini_get("session.gc_maxlifetime")));
177}
178print '</td>';
179print '<td class="nowrap">';
180print '<input class="flat right width75" name="MAIN_SESSION_TIMEOUT" type="text" value="'.getDolGlobalInt('MAIN_SESSION_TIMEOUT').'"> '.strtolower($langs->trans("Seconds"));
181print '</td>';
182print '</tr>';
183
184print '<tr class="oddeven">';
185print '<td>'.$langs->trans("MaxNumberOfImagesInGetPost").'</td><td class="right">';
186print '</td>';
187print '<td class="nowrap">';
188print '<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"));
189print '</td>';
190print '</tr>';
191
192print '<tr class="oddeven">';
193print '<td>'.$langs->trans("MaxNumberOfPostOnPublicPagesByIP").'</td><td class="right">';
194print '</td>';
195print '<td class="nowrap">';
196print '<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"));
197print '</td>';
198print '</tr>';
199
200print '<tr class="oddeven">';
201print '<td>'.$langs->trans("MaxNumberOfAttachementOnForms").'</td><td class="right">';
202print '</td>';
203print '<td class="nowrap">';
204print '<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"));
205print '</td>';
206print '</tr>';
207
208print '<tr class="oddeven">';
209print '<td>'.$langs->trans("MaxNumberOfFailedAuth").'</td><td class="right">';
210print '</td>';
211print '<td class="nowrap">';
212print '<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");
213print '</td>';
214print '</tr>';
215
216print '</table>';
217
218print $form->buttonsSaveCancel("Modify", '');
219
220print dol_get_fiche_end();
221
222print '</form>';
223
224// End of page
225llxFooter();
226$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
Class to manage generation of HTML components Only common components must be here.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.