dolibarr 20.0.4
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 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Load Dolibarr environment
27require '../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
31
32// Load translation files required by the page
33$langs->loadLangs(array("users", "admin", "other"));
34
35if (!$user->admin) {
37}
38
39$action = GETPOST('action', 'aZ09');
40
41
42
43/*
44 * Actions
45 */
46
47if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
48 $code = $reg[1];
49 $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
50 if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
51 header("Location: ".$_SERVER["PHP_SELF"]);
52 exit;
53 } else {
54 dol_print_error($db);
55 }
56} elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
57 $code = $reg[1];
58 if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
59 header("Location: ".$_SERVER["PHP_SELF"]);
60 exit;
61 } else {
62 dol_print_error($db);
63 }
64} elseif ($action == 'updateform') {
65 $res1 = 1;
66 $res2 = 1;
67 $res3 = 1;
68 $res4 = 1;
69 $res5 = 1;
70 $res6 = 1;
71 if (GETPOSTISSET('MAIN_APPLICATION_TITLE')) {
72 $res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
73 }
74 if (GETPOSTISSET('MAIN_SESSION_TIMEOUT')) {
75 $res2 = dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", GETPOST("MAIN_SESSION_TIMEOUT", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
76 }
77 if (GETPOSTISSET('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT')) {
78 $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);
79 }
80 if (GETPOSTISSET('MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS')) {
81 $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);
82 }
83 if (GETPOSTISSET('MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS')) {
84 $res5 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", GETPOST("MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", 'alphanohtml'), 'int', 0, '', $conf->entity);
85 }
86 if (GETPOSTISSET('MAIN_SECURITY_MAX_NUMBER_FAILED_AUTH')) {
87 $res6 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_NUMBER_FAILED_AUTH", GETPOST("MAIN_SECURITY_MAX_NUMBER_FAILED_AUTH", 'alphanohtml'), 'int', 0, '', $conf->entity);
88 }
89 if ($res1 && $res2 && $res3 && $res4 && $res5 && $res6) {
90 setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
91 }
92}
93
94
95
96/*
97 * View
98 */
99
100$form = new Form($db);
101
102$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
103llxHeader('', $langs->trans("Miscellaneous"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-security_other');
104
105print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
106
107print '<span class="opacitymedium">'.$langs->trans("MiscellaneousDesc")."</span><br>\n";
108print "<br>\n";
109
110
111
112print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
113print '<input type="hidden" name="token" value="'.newToken().'">';
114print '<input type="hidden" name="action" value="updateform">';
115
116$head = security_prepare_head();
117
118print dol_get_fiche_head($head, 'misc', '', -1);
119
120print '<br>';
121
122// Other Options
123print '<table class="noborder centpercent">';
124print '<tr class="liste_titre">';
125print '<td colspan="3">'.$langs->trans("Parameters").'</td>';
126print '<td class="right" width="100">'.$langs->trans("Status").'</td>';
127print '</tr>';
128
129// Enable Captcha code
130print '<tr class="oddeven">';
131print '<td colspan="3">'.$langs->trans("UseCaptchaCode").'</td>';
132print '<td class="right">';
133if (function_exists("imagecreatefrompng")) {
134 if (!empty($conf->use_javascript_ajax)) {
135 print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA');
136 } else {
137 if (!getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA')) {
138 print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_SECURITY_ENABLECAPTCHA&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
139 } else {
140 print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_SECURITY_ENABLECAPTCHA&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
141 }
142 }
143} else {
144 $desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning');
145 print $desc;
146}
147print '</td></tr>';
148
149// Enable advanced perms
150print '<tr class="oddeven">';
151print '<td colspan="3">'.$langs->trans("UseAdvancedPerms").'</td>';
152print '<td class="right">';
153if (!empty($conf->use_javascript_ajax)) {
154 print ajax_constantonoff('MAIN_USE_ADVANCED_PERMS');
155} else {
156 if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
157 print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_USE_ADVANCED_PERMS&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
158 } else {
159 print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_USE_ADVANCED_PERMS&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
160 }
161}
162print "</td></tr>";
163
164print '</table>';
165
166
167print '<br>';
168
169
170// Timeout
171print '<table width="100%" class="noborder">';
172print '<tr class="liste_titre">';
173print '<td colspan="2">'.$langs->trans("Parameters").'</td>';
174print '<td>'.$langs->trans("Value").'</td>';
175print "</tr>\n";
176
177
178$sessiontimeout = ini_get("session.gc_maxlifetime");
179if (!getDolGlobalString('MAIN_SESSION_TIMEOUT')) {
180 $conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout;
181}
182print '<tr class="oddeven">';
183print '<td>'.$langs->trans("SessionTimeOut").'</td><td class="right">';
184if (ini_get("session.gc_probability") == 0) {
185 print $form->textwithpicto('', $langs->trans("SessionsPurgedByExternalSystem", ini_get("session.gc_maxlifetime")));
186} else {
187 print $form->textwithpicto('', $langs->trans("SessionExplanation", ini_get("session.gc_probability"), ini_get("session.gc_divisor"), ini_get("session.gc_maxlifetime")));
188}
189print '</td>';
190print '<td class="nowrap">';
191print '<input class="flat right width50" name="MAIN_SESSION_TIMEOUT" type="text" value="'.getDolGlobalInt('MAIN_SESSION_TIMEOUT').'"> '.strtolower($langs->trans("Seconds"));
192print '</td>';
193print '</tr>';
194
195print '<tr class="oddeven">';
196print '<td>'.$langs->trans("MaxNumberOfImagesInGetPost").'</td><td class="right">';
197print '</td>';
198print '<td class="nowrap">';
199print '<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"));
200print '</td>';
201print '</tr>';
202
203print '<tr class="oddeven">';
204print '<td>'.$langs->trans("MaxNumberOfPostOnPublicPagesByIP").'</td><td class="right">';
205print '</td>';
206print '<td class="nowrap">';
207print '<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"));
208print '</td>';
209print '</tr>';
210
211print '<tr class="oddeven">';
212print '<td>'.$langs->trans("MaxNumberOfAttachementOnForms").'</td><td class="right">';
213print '</td>';
214print '<td class="nowrap">';
215print '<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"));
216print '</td>';
217print '</tr>';
218
219print '<tr class="oddeven">';
220print '<td>'.$langs->trans("MaxNumberOfFailedAuth").'</td><td class="right">';
221print '</td>';
222print '<td class="nowrap">';
223print '<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");
224print '</td>';
225print '</tr>';
226
227/*
228if (empty($conf->global->MAIN_APPLICATION_TITLE)) {
229 $conf->global->MAIN_APPLICATION_TITLE = "";
230}
231print '<tr class="oddeven">';
232print '<td>'.$langs->trans("MAIN_APPLICATION_TITLE").'</td><td class="right">';
233print '</td>';
234print '<td class="nowrap">';
235print '<input class="flat" name="MAIN_APPLICATION_TITLE" type="text" size="20" value="'.dol_escape_htmltag($conf->global->MAIN_APPLICATION_TITLE).'"> ';
236print '</td>';
237print '</tr>';
238*/
239
240print '</table>';
241
242print $form->buttonsSaveCancel("Modify", '');
243
244print dol_get_fiche_end();
245
246print '</form>';
247
248// End of page
249llxFooter();
250$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()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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.