dolibarr 21.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';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
32
41// Load translation files required by the page
42$langs->loadLangs(array("users", "admin", "other"));
43
44if (!$user->admin) {
46}
47
48$action = GETPOST('action', 'aZ09');
49
50
51
52/*
53 * Actions
54 */
55
56if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
57 $code = $reg[1];
58 $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
59 if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
60 header("Location: ".$_SERVER["PHP_SELF"]);
61 exit;
62 } else {
63 dol_print_error($db);
64 }
65} elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
66 $code = $reg[1];
67 if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
68 header("Location: ".$_SERVER["PHP_SELF"]);
69 exit;
70 } else {
71 dol_print_error($db);
72 }
73} elseif ($action == 'updateform') {
74 $res1 = 1;
75 $res2 = 1;
76 $res3 = 1;
77 $res4 = 1;
78 $res5 = 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", GETPOST("MAIN_SESSION_TIMEOUT", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
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 ($res1 && $res2 && $res3 && $res4 && $res5) {
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 '<span class="opacitymedium">'.$langs->trans("MiscellaneousDesc")."</span><br>\n";
113print "<br>\n";
114
115
116
117print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
118print '<input type="hidden" name="token" value="'.newToken().'">';
119print '<input type="hidden" name="action" value="updateform">';
120
121$head = security_prepare_head();
122
123print dol_get_fiche_head($head, 'misc', '', -1);
124
125print '<br>';
126
127// Other Options
128print '<table class="noborder centpercent">';
129print '<tr class="liste_titre">';
130print '<td colspan="3">'.$langs->trans("Parameters").'</td>';
131print '<td class="right" width="100">'.$langs->trans("Status").'</td>';
132print '</tr>';
133
134// Enable advanced perms
135print '<tr class="oddeven">';
136print '<td colspan="3">'.$langs->trans("UseAdvancedPerms").'</td>';
137print '<td class="right">';
138if (!empty($conf->use_javascript_ajax)) {
139 print ajax_constantonoff('MAIN_USE_ADVANCED_PERMS');
140} else {
141 if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
142 print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_USE_ADVANCED_PERMS&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
143 } else {
144 print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_USE_ADVANCED_PERMS&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
145 }
146}
147print "</td></tr>";
148
149print '</table>';
150
151
152print '<br>';
153
154
155// Timeout
156print '<table width="100%" class="noborder">';
157print '<tr class="liste_titre">';
158print '<td colspan="2">'.$langs->trans("Parameters").'</td>';
159print '<td></td>';
160print "</tr>\n";
161
162
163$sessiontimeout = ini_get("session.gc_maxlifetime");
164if (!getDolGlobalString('MAIN_SESSION_TIMEOUT')) {
165 $conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout;
166}
167print '<tr class="oddeven">';
168print '<td>'.$langs->trans("SessionTimeOut").'</td><td class="right">';
169if (ini_get("session.gc_probability") == 0) {
170 // 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.
171 print $form->textwithpicto('', $langs->trans("SessionsPurgedByExternalSystem", get_cfg_var("session.gc_maxlifetime")));
172} else {
173 print $form->textwithpicto('', $langs->trans("SessionExplanation", ini_get("session.gc_probability"), ini_get("session.gc_divisor"), ini_get("session.gc_maxlifetime")));
174}
175print '</td>';
176print '<td class="nowrap">';
177print '<input class="flat right width50" name="MAIN_SESSION_TIMEOUT" type="text" value="'.getDolGlobalInt('MAIN_SESSION_TIMEOUT').'"> '.strtolower($langs->trans("Seconds"));
178print '</td>';
179print '</tr>';
180
181print '<tr class="oddeven">';
182print '<td>'.$langs->trans("MaxNumberOfImagesInGetPost").'</td><td class="right">';
183print '</td>';
184print '<td class="nowrap">';
185print '<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"));
186print '</td>';
187print '</tr>';
188
189print '<tr class="oddeven">';
190print '<td>'.$langs->trans("MaxNumberOfPostOnPublicPagesByIP").'</td><td class="right">';
191print '</td>';
192print '<td class="nowrap">';
193print '<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"));
194print '</td>';
195print '</tr>';
196
197print '<tr class="oddeven">';
198print '<td>'.$langs->trans("MaxNumberOfAttachementOnForms").'</td><td class="right">';
199print '</td>';
200print '<td class="nowrap">';
201print '<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"));
202print '</td>';
203print '</tr>';
204
205print '<tr class="oddeven">';
206print '<td>'.$langs->trans("MaxNumberOfFailedAuth").'</td><td class="right">';
207print '</td>';
208print '<td class="nowrap">';
209print '<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");
210print '</td>';
211print '</tr>';
212
213/*
214if (empty($conf->global->MAIN_APPLICATION_TITLE)) {
215 $conf->global->MAIN_APPLICATION_TITLE = "";
216}
217print '<tr class="oddeven">';
218print '<td>'.$langs->trans("MAIN_APPLICATION_TITLE").'</td><td class="right">';
219print '</td>';
220print '<td class="nowrap">';
221print '<input class="flat" name="MAIN_APPLICATION_TITLE" type="text" size="20" value="'.dol_escape_htmltag($conf->global->MAIN_APPLICATION_TITLE).'"> ';
222print '</td>';
223print '</tr>';
224*/
225
226print '</table>';
227
228print $form->buttonsSaveCancel("Modify", '');
229
230print dol_get_fiche_end();
231
232print '</form>';
233
234// End of page
235llxFooter();
236$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.
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:71
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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)
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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)
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...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.