dolibarr 25.0.0-alpha
security.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2022 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
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
25// Load Dolibarr environment
26require '../../main.inc.php';
48require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
49require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
50require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
51require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
52require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
53require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
54require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
55require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
56
57// Load translation files required by the page
58$langs->loadLangs(array("install", "other", "admin", "website"));
59
60if (!$user->admin) {
62}
63
64if (GETPOST('action', 'aZ09') == 'donothing') {
65 exit;
66}
67
68$execmethod = getDolGlobalInt('MAIN_EXEC_USE_POPEN', 1);
69
70
71/*
72 * View
73 */
74
75$form = new Form($db);
76
77llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-system_security');
78
79print load_fiche_titre($langs->trans("Security"), '', 'title_setup');
80
81print '<div class="info">';
82print '<span class="">'.$langs->trans("YouMayFindSecurityAdviceHere", 'hhttps://wiki.dolibarr.org/index.php/Security_information').'</span>';
83print ' &nbsp; &nbsp; ';
84print '<a href="'.$_SERVER["PHP_SELF"].'">';
85print img_picto($langs->trans("Reload"), 'refresh').' ';
86print $langs->trans("Reload");
87print '</a>';
88print '</div>';
89
90
91print '<br>';
92
93
94print load_fiche_titre($langs->trans("PHPSetup"), '', 'folder');
95
96
97print '<div class="divsection wordbreak">';
98
99// Get version of PHP
100$phpversion = version_php();
101print "<strong>PHP</strong>: ".$langs->trans("Version").": ".$phpversion;
102if (function_exists('php_ini_loaded_file')) {
103 $inipath = php_ini_loaded_file();
104 print " - <strong>INI</strong>: ".$inipath;
105}
106print "<br>\n";
107
108// Get version of web server
109print "<br><strong>Web server - ".$langs->trans("Version")."</strong>: ".$_SERVER["SERVER_SOFTWARE"]."<br>\n";
110print '<strong>'.$langs->trans("DataRootServer")."</strong>: ".DOL_DATA_ROOT."<br>\n";
111// Web user group by default
112$labeluser = dol_getwebuser('user');
113$labelgroup = dol_getwebuser('group');
114if ($labeluser && $labelgroup) {
115 print '<strong>'.$langs->trans("WebUserGroup")." (env vars)</strong> : ".$labeluser.':'.$labelgroup;
116 if (function_exists('posix_geteuid') && function_exists('posix_getpwuid')) {
117 $arrayofinfoofuser = posix_getpwuid(posix_geteuid());
118 print ' <span class="opacitymedium">(POSIX '.$arrayofinfoofuser['name'].':'.$arrayofinfoofuser['gecos'].':'.$arrayofinfoofuser['dir'].':'.$arrayofinfoofuser['shell'].')</span><br>'."\n";
119 }
120}
121// Web user group real (detected by 'id' external command)
122if (function_exists('exec')) {
123 $arrayout = array();
124 $varout = 0;
125 exec('id', $arrayout, $varout);
126 if (empty($varout)) { // Test command is ok. Work only on Linux OS.
127 print '<strong>'.$langs->trans("WebUserGroup")." (real, 'id' command)</strong> : ".implode(',', $arrayout)."<br>\n";
128 }
129}
130print '<br>';
131
132print (ini_get('session.use_strict_mode') ? img_picto('', 'tick', 'class="pictofixedwidth"') : img_warning('', '', 'pictofixedwidth nopaddingleft'))."<strong>PHP session.use_strict_mode</strong> = ".(ini_get('session.use_strict_mode') ? ini_get('session.use_strict_mode') : yn(0)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", '1').")</span><br>\n";
133print (ini_get('session.use_only_cookies') ? img_picto('', 'tick', 'class="pictofixedwidth"') : img_warning('', '', 'pictofixedwidth nopaddingleft'))."<strong>PHP session.use_only_cookies</strong> = ".(ini_get('session.use_only_cookies') ? ini_get('session.use_only_cookies') : yn(0)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", '1').")</span><br>\n";
134print (ini_get('session.cookie_httponly') ? img_picto('', 'tick', 'class="pictofixedwidth"') : img_warning('', '', 'pictofixedwidth nopaddingleft'))."<strong>PHP session.cookie_httponly</strong> = ".(ini_get('session.cookie_httponly') ? ini_get('session.cookie_httponly') : '').' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", '1').")</span><br>\n";
135print (ini_get('session.cookie_samesite') ? img_picto('', 'tick', 'class="pictofixedwidth"') : img_warning('', '', 'pictofixedwidth nopaddingleft'))."<strong>PHP session.cookie_samesite</strong> = ".(ini_get('session.cookie_samesite') ? ini_get('session.cookie_samesite') : 'None');
136if (!ini_get('session.cookie_samesite') || ini_get('session.cookie_samesite') == 'Lax') {
137 print ' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'Lax').")</span>";
138} elseif (ini_get('session.cookie_samesite') == 'Strict') {
139 $langs->load('errors');
140 print ' &nbsp; '.img_warning().' <span class="opacitymedium">'.$langs->trans("WarningPaypalPaymentNotCompatibleWithStrict")."</span>";
141}
142print "<br>\n";
143
144print (ini_get('open_basedir') ? img_picto('', 'tick', 'class="pictofixedwidth"') : img_warning('', '', 'pictofixedwidth nopaddingleft'))."<strong>PHP open_basedir</strong> = ".(ini_get('open_basedir') ? ini_get('open_basedir') : yn(0).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("ARestrictedPath").', '.$langs->transnoentitiesnoconv("Example").': '.$_SERVER["DOCUMENT_ROOT"].','.DOL_DATA_ROOT).')</span>')."<br>\n";
145
146print ((empty(ini_get('short_open_tag')) || ini_get('short_open_tag') == 'Off') ? img_picto('', 'tick', 'class="pictofixedwidth"') : img_warning('', '', 'pictofixedwidth nopaddingleft'))."<strong>PHP short_open_tag</strong> = ".((empty(ini_get('short_open_tag')) || ini_get('short_open_tag') == 'Off') ? yn(0) : yn(1)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).')</span>'."<br>\n";
147
148print (ini_get('allow_url_fopen') ? img_picto($langs->trans("YouShouldSetThisToOff"), 'warning', 'class="pictofixedwidth nopaddingleft"') : img_picto('', 'tick', 'class="pictofixedwidth"'))."<strong>PHP allow_url_fopen</strong> = ".(ini_get('allow_url_fopen') ? ini_get('allow_url_fopen') : yn(0)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).", except if Yes is required by some external modules)</span><br>\n";
149
150print (ini_get('allow_url_include') ? img_picto($langs->trans("YouShouldSetThisToOff"), 'warning', 'class="pictofixedwidth nopaddingleft"') : img_picto('', 'tick', 'class="pictofixedwidth"')). "<strong>PHP allow_url_include</strong> = ".(ini_get('allow_url_include') ? ini_get('allow_url_include') : yn(0)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).")</span><br>\n";
151//print "<strong>PHP safe_mode</strong> = ".(ini_get('safe_mode') ? ini_get('safe_mode') : yn(0)).' &nbsp; <span class="opacitymedium">'.$langs->trans("Deprecated")." (removed in PHP 5.4)</span><br>\n";
152
153if (getDolGlobalString('MAIN_SECURITY_SHOW_MORE_INFO')) {
154 print "<strong>PHP auto_prepend_file</strong> = ".(ini_get('auto_prepend_file') ? ini_get('auto_prepend_file') : '')."</span><br>\n";
155
156 print "<strong>PHP sendmail_path</strong> = ".(ini_get('sendmail_path') ? ini_get('sendmail_path') : '')."</span><br>\n";
157}
158
159print '<br>';
160print "<strong>PHP disable_functions</strong>: ";
161// The original value is...
162$disablefunctionorign = '';
163$phparray = phpinfo_array();
164foreach ($phparray as $key => $value) {
165 foreach ($value as $keyparam => $keyvalue) {
166 if ($keyparam == 'disable_functions') {
167 if (!empty($keyvalue['master'])) {
168 $disablefunctionorign = $keyvalue['master'];
169 break;
170 }
171 }
172 }
173}
174/*
175if (empty($disablefunctionorign)) {
176 $disablefunctionorign = ini_get('disable_functions'); // Not always the real value
177}
178*/
179$arrayoffunctionsdisabled = explode(',', $disablefunctionorign);
180
181$arrayoffunctionstodisable = explode(',', 'dl,apache_note,apache_setenv,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,show_source,virtual');
182//$arrayoffunctionstodisable[] = 'stream_wrapper_restore';
183//$arrayoffunctionstodisable[] = 'stream_wrapper_register';
184if ($execmethod == 1) {
185 $arrayoffunctionstodisable2 = explode(',', 'passthru,shell_exec,system,proc_open,popen');
186 $functiontokeep = 'exec';
187} else {
188 $arrayoffunctionstodisable2 = explode(',', 'exec,passthru,shell_exec,system,proc_open');
189 $functiontokeep = 'popen';
190}
191$i = 0;
192foreach ($arrayoffunctionsdisabled as $functionkey) {
193 if ($i > 0) {
194 print ', ';
195 }
196 print '<span class="opacitymedium">'.$functionkey.'</span>';
197 $i++;
198}
199print "<br>\n";
200$todisabletext = '';
201$i = 0;
202foreach ($arrayoffunctionstodisable as $functiontodisable) {
203 if (\function_exists($functiontodisable)) {
204 if ($i > 0) {
205 $todisabletext .= ', ';
206 }
207 $todisabletext .= ' <span class="opacitymedium">'.$functiontodisable.'</span>';
208 $i++;
209 }
210}
211if ($todisabletext) {
212 print img_picto('', 'warning', 'class="pictofixedwidth nopaddingleft"').$langs->trans("YouShouldDisablePHPFunctions").': '.$todisabletext;
213 print '<br>';
214}
215$todisabletext = '';
216$i = 0;
217foreach ($arrayoffunctionstodisable2 as $functiontodisable) {
218 if (\function_exists($functiontodisable)) {
219 if ($i > 0) {
220 $todisabletext .= ', ';
221 }
222 $todisabletext .= ' <span class="opacitymedium">'.$functiontodisable.'</span>';
223 $i++;
224 }
225}
226if ($todisabletext) {
227 print img_picto('', 'warning', 'class="pictofixedwidth nopaddingleft"').$langs->trans("IfCLINotRequiredYouShouldDisablePHPFunctions").': '.$todisabletext;
228 print '<br>';
229}
230if (!function_exists($functiontokeep)) {
231 print img_picto($langs->trans("PHPFunctionsRequiredForCLI"), 'warning', 'class="pictofixedwidth"');
232} else {
233 print img_picto('', 'tick', 'class="pictofixedwidth"');
234}
235print $langs->trans("PHPFunctionsRequiredForCLI").': ';
236print '<span class="opacitymedium" title="exec or popen can be used depending on MAIN_EXEC_USE_POPEN option, currently to '.getDolGlobalInt('MAIN_EXEC_USE_POPEN').'">'.$functiontokeep.'</span>';
237print '<br>';
238
239print '<br>';
240
241// JSON
242$loadedExtensions = array_map('strtolower', get_loaded_extensions(false));
243$test = !in_array('json', $loadedExtensions);
244if ($test || function_exists('dol_json_decode')) {
245 print img_picto('', 'error', 'class="pictofixedwidth nopaddingleft"');
246} else {
247 print img_picto('', 'tick', 'class="pictofixedwidth"');
248}
249print '<strong>JSON</strong>: ';
250if ($test || function_exists('dol_json_decode')) {
251 print $langs->trans("NotInstalled").' - '.$langs->trans("VulnerableToRCEAttack");
252} else {
253 print $langs->trans("Available").' <span class="opacitymedium">(PHP native so not emulated, safe)</span>';
254}
255print '<br>';
256
257// XDebug
258$test = !function_exists('xdebug_is_enabled') && !extension_loaded('xdebug');
259if ($test) {
260 print img_picto('', 'tick', 'class="pictofixedwidth"');
261} else {
262 print img_picto('', 'warning', 'class="pictofixedwidth nopaddingleft"');
263}
264print '<strong>XDebug</strong>: ';
265if ($test) {
266 print $langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis");
267} else {
268 print $langs->trans("ModuleActivatedMayExposeInformation", $langs->transnoentities("XDebug"));
269 print ' - '.$langs->trans("MoreInformation").' <a href="'.DOL_URL_ROOT.'/admin/system/xdebug.php">XDebug admin page</a>';
270}
271
272print '</div>';
273
274print '<br>';
275
276
277// OS Setup - Permissions on files
278
279print '<br>';
280print load_fiche_titre($langs->trans("OSSetup").' - '.$langs->trans("PermissionsOnFiles"), '', 'folder');
281
282print '<div class="divsection wordbreak">';
283
284print '<strong>'.$langs->trans("PermissionsOnFilesInWebRoot").'</strong>: ';
285$arrayoffilesinroot = dol_dir_list(DOL_DOCUMENT_ROOT, 'all', 1, '', array('\/custom'), 'name', SORT_ASC, 4, 1, '', 1);
286$fileswithwritepermission = array();
287foreach ($arrayoffilesinroot as $fileinroot) {
288 // Test if there is at least one write permission file. If yes, add the entry into array $fileswithwritepermission
289 if (isset($fileinroot['perm']) && ($fileinroot['perm'] & 0222)) {
290 $fileswithwritepermission[] = $fileinroot['relativename'];
291 }
292}
293if (empty($fileswithwritepermission)) {
294 print img_picto('', 'tick').' '.$langs->trans("NoWritableFilesFoundIntoRootDir");
295} else {
296 print img_warning().' '.$langs->trans("SomeFilesOrDirInRootAreWritable");
297 print ' &nbsp; - &nbsp; <span class="classlink cursorpointer" onclick="javascript: console.log(\'Toggle examples\'); jQuery(\'#examplewritablefiles\').toggle();">'.$langs->trans("Examples").'</span>';
298 print '<span id="examplewritablefiles" class="hideobject"><br>'.$langs->trans("Example").': ';
299 $i = 0;
300 foreach ($fileswithwritepermission as $filewithwritepermission) {
301 if ($i > 0) {
302 print ', ';
303 }
304 print '<span class="opacitymedium">'.$filewithwritepermission.'</span>';
305 if ($i > 20) {
306 print ' ...';
307 break;
308 }
309 $i++;
310 }
311 print '</span>';
312}
313print '<br>';
314print '<br>';
315
316print '<strong>'.$langs->trans("PermissionsOnFile", $conffile).'</strong>: '; // $conffile is defined into filefunc.inc.php
317$perms = fileperms($dolibarr_main_document_root.'/'.$conffile);
318if ($perms) {
319 if (($perms & 0x0004) || ($perms & 0x0002)) {
320 print img_warning().' '.$langs->trans("ConfFileIsReadableOrWritableByAnyUsers");
321 // Web user group by default
322 $labeluser = dol_getwebuser('user');
323 $labelgroup = dol_getwebuser('group');
324 print ' '.$langs->trans("User").': '.$labeluser.':'.$labelgroup;
325 if (function_exists('posix_geteuid') && function_exists('posix_getpwuid')) {
326 $arrayofinfoofuser = posix_getpwuid(posix_geteuid());
327 print ' <span class="opacitymedium">(POSIX '.$arrayofinfoofuser['name'].':'.$arrayofinfoofuser['gecos'].':'.$arrayofinfoofuser['dir'].':'.$arrayofinfoofuser['shell'].')</span>';
328 }
329 } else {
330 print img_picto('', 'tick');
331 }
332} else {
333 print img_warning().' '.$langs->trans("FailedToReadFile", $conffile);
334}
335print '<br>';
336print '<br>';
337
338$installlock = DOL_DATA_ROOT.'/install.lock';
339$upgradeunlock = DOL_DATA_ROOT.'/upgrade.unlock';
340$installmoduleslock = DOL_DATA_ROOT.'/installmodules.lock';
341
342// Is install (upgrade) locked
343$test = file_exists($installlock);
344print '<strong>'.$langs->trans("DolibarrSetup").'</strong>: ';
345if ($test) {
346 if (file_exists($upgradeunlock)) {
347 print img_picto('', 'tick').' '.$langs->trans("InstallLockedBy", $installlock);
348 } else {
349 print img_picto('', 'tick').' '.$langs->trans("InstallAndUpgradeLockedBy", $installlock);
350 }
351} else {
352 $langs->load('errors');
353 print img_warning().' '.$langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT);
354}
355
356print '<br>';
357print '<br>';
358
359// Is upgrade unlocked
360if (file_exists($installlock)) { // If install not locked, no need to show this.
361 if (file_exists($upgradeunlock)) {
362 print '<strong>'.$langs->trans("DolibarrUpgrade").'</strong>: ';
363 $langs->load('errors');
364 print img_warning().' '.$langs->trans("WarningUpgradeHasBeenUnlocked", $upgradeunlock);
365 print '<br>';
366 print '<br>';
367 }
368}
369
370// Is addon install locked ?
371$test = file_exists($installmoduleslock);
372print '<strong>'.$langs->trans("DolibarrAddonInstall").'</strong>: ';
373if ($test) {
374 print img_picto('', 'tick').' '.$langs->trans("InstallAndUpgradeLockedBy", $installmoduleslock);
375} else {
376 print $langs->trans("InstallOfAddonIsNotBlocked", DOL_DATA_ROOT);
377}
378
379print '</div>';
380
381
382
383// File conf.php
384
385print '<br>';
386print '<br>';
387print load_fiche_titre($langs->trans("ConfigurationFile").' ('.$conffile.')', '', 'folder');
388
389print '<div class="divsection wordbreak">';
390print '<strong>$dolibarr_main_prod</strong>: '.($dolibarr_main_prod ? $dolibarr_main_prod : '0');
391if (empty($dolibarr_main_prod)) {
392 print ' &nbsp; &nbsp; '.img_picto('', 'warning').' '.$langs->trans("IfYouAreOnAProductionSetThis", 1);
393}
394print '<br>';
395
396if (!empty($dolibarr_nocsrfcheck)) {
397 print '<strong>$dolibarr_nocsrfcheck</strong>: '.(empty($dolibarr_nocsrfcheck) ? '0' : $dolibarr_nocsrfcheck);
398 print ' &nbsp; &nbsp;'.img_picto('', 'error').' '.$langs->trans("IfYouAreOnAProductionSetThis", 0);
399 print '<br>';
400}
401
402print '<strong>$dolibarr_main_restrict_ip</strong>: ';
403if (empty($dolibarr_main_restrict_ip)) {
404 print $langs->trans("None");
405 print ' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("StaticIPsOfUsers")).')</span>';
406} else {
407 print $dolibarr_main_restrict_ip;
408}
409print '<br>';
410
411
412print '<strong>$dolibarr_main_restrict_os_commands</strong>: ';
413if (empty($dolibarr_main_restrict_os_commands)) {
414 print $langs->trans("None");
415} else {
416 print $dolibarr_main_restrict_os_commands;
417}
418print ' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'mariadb-dump, mariadb, mysqldump, mysql, pg_dump, pg_restore, clamdscan, ls').')</span>';
419print '<br>';
420
421
422print '<strong>$dolibarr_main_restrict_eval_methods</strong>: ';
423if (empty($dolibarr_main_restrict_eval_methods)) {
424 print $langs->trans("None");
425} else {
426 print $dolibarr_main_restrict_eval_methods;
427}
428print ' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'getDolGlobalString, getDolGlobalInt, getDolCurrency, getDolEntity, getDolDBType, fetchNoCompute, hasRight, isAdmin, isExternalUser, isModEnabled, isStringVarMatching, abs, min, max, round, dol_now, dol_concat, preg_match').')</span>';
429print '<br>';
430
431
432print '<strong>$dolibarr_website_allow_custom_php</strong>: ';
433if (!empty($dolibarr_website_allow_custom_php) && $dolibarr_website_allow_custom_php == 2) {
434 print img_picto('', 'warning').' ';
435}
436if (empty($dolibarr_website_allow_custom_php)) {
437 print '0';
438} else {
439 print $dolibarr_website_allow_custom_php;
440}
441print ' &nbsp; &nbsp; <span class="opacitymedium">(';
442if (isModEnabled('website')) {
443 print $langs->trans("RecommendedValueIs", '0 if you don\'t include PHP in your websites, else 1');
444} else {
445 print $langs->trans("RecommendedValueIs", '0');
446}
447print ')</span>';
448print '<br>';
449
450
451if (!getDolGlobalString('SECURITY_DISABLE_TEST_ON_OBFUSCATED_CONF')) {
452 print '<strong>$dolibarr_main_db_pass</strong>: ';
453 if (!empty($dolibarr_main_db_pass) && empty($dolibarr_main_db_encrypted_pass)) {
454 print img_picto('', 'warning').' '.$langs->trans("DatabasePasswordNotObfuscated").' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': '.$langs->trans("SetOptionTo", $langs->transnoentitiesnoconv("MainDbPasswordFileConfEncrypted"), yn(1)).')</span>';
455 //print ' <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("IPsOfUsers")).')</span>';
456 } else {
457 print img_picto('', 'tick').' '.$langs->trans("DatabasePasswordObfuscated");
458 }
459
460 print '<br>';
461}
462
463print '<strong>$dolibarr_main_stream_to_disable</strong>: ';
464// $arrayofstreamtodisable is defined into filefunc.inc.php
465'@phan-var-force string[] $arrayofstreamtodisable';
466if (empty($dolibarr_main_stream_to_disable)) {
467 print '<span class="opacitymedium">'.$langs->trans("Undefined").' = '.implode(', ', $arrayofstreamtodisable).'</span>';
468} else {
469 print implode(', ', $dolibarr_main_stream_to_disable);
470}
471print '<span class="bold"> &nbsp; -> Current PHP streams allowed = </span>';
472$arrayofstreams = stream_get_wrappers();
473if (!empty($arrayofstreams)) {
474 sort($arrayofstreams);
475 print '<span class="wordbreak">'.implode(',', $arrayofstreams).'</span>';
476 print ' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': '.$langs->trans("TryToKeepOnly", 'file,http,https,php,zip').')</span>'."\n";
477}
478print '</div>';
479
480
481/*
482if (!empty($dolibarr_main_stream_do_not_disable)) {
483 print '<strong>$dolibarr_main_stream_do_not_disable</strong>: ';
484 if (empty($dolibarr_main_stream_do_not_disable)) {
485 print '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>';
486 } else {
487 print join(', ', $dolibarr_main_stream_do_not_disable);
488 }
489 print ' -> PHP stream allowed = ';
490 $arrayofstreams = stream_get_wrappers();
491 if (!empty($arrayofstreams)) {
492 sort($arrayofstreams);
493 print (join(',', $arrayofstreams)).' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'Undefined').')</span>'."\n";
494 }
495
496 print '<br>';
497}
498*/
499
500
501// Menu Home - Setup - Security
502
503print '<br>';
504print '<br>';
505
506print load_fiche_titre($langs->trans("Menu").' '.$langs->trans("SecuritySetup"), '', 'folder');
507
508print '<div class="divsection wordbreak">';
509
510print '<strong>'.$langs->trans("UseCaptchaCode").' - Login</strong>: ';
511print !getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA') ? '' : img_picto('', 'tick').' ';
512print yn(!getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA') ? 0 : 1);
513print '<br>';
514print '<br>';
515
516print '<strong>'.$langs->trans("UseCaptchaCode").' - Ticket</strong>: ';
517print !getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_TICKET') ? '' : img_picto('', 'tick').' ';
518print yn(!getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_TICKET') ? 0 : 1);
519print '<br>';
520print '<br>';
521
522print '<strong>'.$langs->trans("UseCaptchaCode").' - Thirdparty public contact form</strong>: ';
523print !getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_THIRPARTY') ? '' : img_picto('', 'tick').' ';
524print yn(!getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_THIRPARTY') ? 0 : 1);
525print '<br>';
526print '<br>';
527
528print '<strong>'.$langs->trans("UseCaptchaCode").' - Membership subscription</strong>: ';
529print !getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_MEMBER') ? '' : img_picto('', 'tick').' ';
530print yn(!getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_MEMBER') ? 0 : 1);
531print '<br>';
532print '<br>';
533
534$sessiontimeout = ini_get("session.gc_maxlifetime");
535if (!getDolGlobalString('MAIN_SESSION_TIMEOUT')) {
536 $conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout;
537}
538print '<strong>'.$langs->trans("SessionTimeOut").'</strong>';
539if (!ini_get("session.gc_probability")) {
540 print $form->textwithpicto('', $langs->trans("SessionsPurgedByExternalSystem", ini_get("session.gc_maxlifetime")));
541} else {
542 print $form->textwithpicto('', $langs->trans("SessionExplanation", ini_get("session.gc_probability"), ini_get("session.gc_divisor"), ini_get("session.gc_maxlifetime")));
543}
544print ': '.getDolGlobalInt('MAIN_SESSION_TIMEOUT').' '.strtolower($langs->trans("Seconds"));
545print '<br><br>';
546
547print '<strong>'.$langs->trans("MaxNumberOfImagesInGetPost").'</strong>: ';
548print(getDolGlobalInt('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT') ? img_picto('', 'tick').' ' : '').getDolGlobalInt('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT').' '.strtolower($langs->trans("Images"));
549print '<br><br>';
550
551print '<strong>'.$langs->trans("MaxNumberOfPostOnPublicPagesByIP").'</strong>: ';
552print(getDolGlobalInt('MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS', 200) ? img_picto('', 'tick').' ' : '').getDolGlobalInt('MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS', 200).' '.strtolower($langs->trans("Posts"));
553print '<br><br>';
554
555print '<strong>'.$langs->trans("MaxNumberOfAttachementOnForms").'</strong>: ';
556print(getDolGlobalInt('MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS', 10) ? img_picto('', 'tick').' ' : '').getDolGlobalInt("MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", 10).' '.strtolower($langs->trans("Files"));
557print '<br><br>';
558
559
560// Clear password ?
561
562print '<strong>'.$langs->trans("DoNotStoreClearPassword").'</strong>: ';
563print !getDolGlobalString('DATABASE_PWD_ENCRYPTED') ? '' : img_picto('', 'tick').' ';
564print yn(!getDolGlobalString('DATABASE_PWD_ENCRYPTED') ? 0 : 1);
565if (!getDolGlobalString('DATABASE_PWD_ENCRYPTED')) {
566 print ' <span class="opacitymedium">('.$langs->trans("Recommended").' '.yn(1).')</span>';
567}
568print '<br>';
569print '<br>';
570
571
572// Mask by default in upload
573$umask = getDolGlobalString('MAIN_UMASK');
574
575print '<strong>'.$langs->trans("UMask").'</strong>: ';
576if (! in_array($umask, array('600', '660', '0600', '0660'))) {
577 print img_warning().' ';
578}
579print $umask;
580if (! in_array($umask, array('600', '660', '0600', '0660'))) {
581 print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 0600 | 0660)</span>';
582}
583print '<br>';
584print '<br>';
585
586
587/* Already into section conf file */
588/*
589$usepassinconfencrypted = 0;
590global $dolibarr_main_db_pass, $dolibarr_main_db_encrypted_pass;
591if (preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
592 $usepassinconfencrypted = 1;
593}
594print '<strong>'.$langs->trans("MainDbPasswordFileConfEncrypted").'</strong>: ';
595print $usepassinconfencrypted ? img_picto('', 'tick').' ' : img_warning().' ';
596print yn($usepassinconfencrypted);
597if (empty($usepassinconfencrypted)) {
598 print ' <span class="opacitymedium">('.$langs->trans("Recommended").' '.yn(1).')</span>';
599}
600print '<br>';
601print '<br>';
602*/
603
604/* Password length
605
606// Stored into $tabconf[0] if module generator is "Perso" or specific to the module generator.
607$tabConf = explode(";", getDolGlobalString('USER_PASSWORD_PATTERN'));
608
609print '<strong>'.$langs->trans("PasswordLength").'</strong>: ';
610print empty($conf->global->DATABASE_PWD_ENCRYPTED) ? '' : img_picto('', 'tick').' ';
611print yn(empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1);
612if (empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
613 print ' <span class="opacitymedium">('.$langs->trans("Recommended").' '.yn(1).')</span>';
614}
615print '<br>';
616print '<br>';
617*/
618
619print '<strong>'.$langs->trans("AntivirusEnabledOnUpload").'</strong>: ';
620print getDolGlobalString('MAIN_ANTIVIRUS_UPLOAD_ON') ? img_picto('', 'tick').' ' : img_warning().' ';
621print yn(!getDolGlobalString('MAIN_ANTIVIRUS_UPLOAD_ON') ? 0 : 1);
622if (!getDolGlobalString('MAIN_ANTIVIRUS_UPLOAD_ON') || !getDolGlobalString('MAIN_ANTIVIRUS_COMMAND')) {
623 print ' - <span class="opacitymedium">'.$langs->trans("Recommended").': '.$langs->trans("DefinedAPathForAntivirusCommandIntoSetup", $langs->transnoentitiesnoconv("Home")." - ".$langs->transnoentitiesnoconv("Setup")." - ".$langs->transnoentitiesnoconv("Security")).'</span>';
624} else {
625 print ' &nbsp; - ' . getDolGlobalString('MAIN_ANTIVIRUS_COMMAND');
626 if (defined('MAIN_ANTIVIRUS_COMMAND') && !defined('MAIN_ANTIVIRUS_BYPASS_COMMAND_AND_PARAM')) {
627 print ' - <span class="opacitymedium">'.$langs->trans("ValueIsForcedBySystem").'</span>';
628 }
629}
630print '<br>';
631print '<br>';
632
633// File extension locked in upload by default
634
635print '<strong>'.$langs->trans("UploadExtensionRestriction").'</strong>: ';
636print implode(', ', explode(',', getDolGlobalString('MAIN_FILE_EXTENSION_UPLOAD_RESTRICTION', implode(',', getExecutableContent()))));
637print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': '.implode(', ', getExecutableContent()).')</span>';
638print '<br>';
639print '<br>';
640
641
642print '<strong>'.$langs->trans("MAIN_SECURITY_MAXFILESIZE_DOWNLOADED").'</strong> = '.getDolGlobalString('MAIN_SECURITY_MAXFILESIZE_DOWNLOADED', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': < 100000)</span>')."<br>";
643print '<br>';
644
645
646
647$securityevent = new Events($db);
648$eventstolog = $securityevent->eventstolog;
649
650print '<strong>'.$langs->trans("AuditedSecurityEvents").'</strong>: ';
651$out = '';
652if (!empty($eventstolog) && is_array($eventstolog)) {
653 // Loop on each event type
654 $i = 0;
655 foreach ($eventstolog as $key => $arr) {
656 if ($arr['id']) {
657 $key = 'MAIN_LOGEVENTS_'.$arr['id'];
658 $value = getDolGlobalString($key);
659 if ($value) {
660 if ($i > 0) {
661 $out .= ', ';
662 }
663 $out .= '<span class="opacitymedium">'.$key.'</span>';
664 $i++;
665 }
666 }
667 }
668 print $out;
669}
670
671if (empty($out)) {
672 print img_warning().' '.$langs->trans("NoSecurityEventsAreAduited", $langs->transnoentities("Home").' - '.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Security").' - '.$langs->transnoentities("Audit")).'<br>';
673} else {
674 $s = $langs->trans("SeeSetupPage", ' {s1}'.$langs->transnoentities("Home").' - '.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Security").' - '.$langs->transnoentities("Audit").'{s2}');
675 print ' - '.str_replace('{s2}', '</a>', str_replace('{s1}', '<a href="'.DOL_URL_ROOT.'/admin/events.php" target="_blank">'.img_picto('', 'url', 'class="pictofixedwidth"'), $s));
676}
677
678print '<br>';
679
680print '<br>';
681
682print '<strong>MAIN_SECURITY_FORCERP</strong> = '.getDolGlobalString('MAIN_SECURITY_FORCERP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"strict-origin-when-cross-origin\" or \"same-origin\" so browser doesn't send any referrer when going into another web site domain)</span><br>";
683print '<br>';
684
685print '<strong>MAIN_SECURITY_FORCESTS</strong> = '.getDolGlobalString('MAIN_SECURITY_FORCESTS', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").": max-age=31536000; includeSubDomains)</span><br>";
686print '<br>';
687
688print '<strong>MAIN_SECURITY_FORCEPP</strong> = '.getDolGlobalString('MAIN_SECURITY_FORCEPP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").": camera=*, microphone=(), geolocation=*)</span><br>";
689print '<br>';
690
691if (getDolGlobalString('MAIN_SECURITY_FORCECSPRO')) {
692 $examplecsprule = "frame-ancestors 'self'; img-src * data:; font-src *; default-src 'self' 'unsafe-inline' 'unsafe-eval' *.paypal.com *.stripe.com *.google.com *.googleapis.com *.google-analytics.com *.googletagmanager.com *.dolistore.com *.githubusercontent.com";
693 print '<strong>MAIN_SECURITY_FORCECSPRO</strong> = '.getDolGlobalString('MAIN_SECURITY_FORCECSPRO', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").': "'.$examplecsprule.'")</span><br>';
694 print '<br>';
695}
696
697$examplecsprule = "frame-ancestors 'self'; img-src * data:; font-src *; default-src 'self' 'unsafe-inline' 'unsafe-eval' *.paypal.com *.stripe.com *.google.com *.googleapis.com *.google-analytics.com *.googletagmanager.com *.dolistore.com *.githubusercontent.com";
698print '<strong>MAIN_SECURITY_FORCECSP</strong> = '.getDolGlobalString('MAIN_SECURITY_FORCECSP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").': "'.$examplecsprule.'")</span><br>';
699print '<br>';
700
701$tmpurl = constant('DOL_MAIN_URL_ROOT');
702$tmpurl = preg_replace('/^(https?:\/\/[^\/]+)\/.*$/', '\1', $tmpurl);
703print '<strong>MAIN_SECURITY_FORCE_ACCESS_CONTROL_ALLOW_ORIGIN</strong> = '.getDolGlobalString('MAIN_SECURITY_FORCE_ACCESS_CONTROL_ALLOW_ORIGIN', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").": 1 so browsers will accept answers of a page only if page was requested from the domain ".$tmpurl.". Note: it is not possible to limit to several domains)</span><br>";
704
705print '</div>';
706
707print '<br>';
708
709
710
711// Modules/Applications
712
713print '<br>';
714print '<br>';
715print load_fiche_titre($langs->trans("Modules"), '', 'folder');
716
717print '<div class="divsection wordbreak">';
718
719// Module log
720print '<strong>'.$langs->trans("Syslog").'</strong>: ';
721$test = isModEnabled('syslog');
722if (!$test) {
723 print img_picto('', 'tick').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis");
724} else {
725 if (getDolGlobalInt('SYSLOG_LEVEL') > LOG_NOTICE) {
726 print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedWithTooHighLogLevel", $langs->transnoentities("Syslog"));
727 } else {
728 print img_picto('', 'tick').' '.$langs->trans("ModuleSyslogActivatedButLevelNotTooVerbose", $langs->transnoentities("Syslog"), getDolGlobalInt('SYSLOG_LEVEL'));
729 }
730 //print ' '.$langs->trans("MoreInformation").' <a href="'.DOL_URL_ROOT.'/admin/system/xdebug.php'.'">XDebug admin page</a>';
731}
732print '<br>';
733
734print '<br>';
735
736// Module debugbar
737print '<strong>'.$langs->trans("DebugBar").'</strong>: ';
738$test = isModEnabled('debugbar');
739if (!$test) {
740 print img_picto('', 'tick').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis");
741} else {
742 print img_picto('', 'error').' '.$langs->trans("ModuleActivatedDoNotUseInProduction", $langs->transnoentities("DebugBar"));
743 //print ' '.$langs->trans("MoreInformation").' <a href="'.DOL_URL_ROOT.'/admin/system/xdebug.php'.'">XDebug admin page</a>';
744}
745print '<br>';
746
747// Modules for Payments
748/*
749$test = isModEnabled('stripe');
750if ($test) {
751 print '<br>';
752
753 print '<strong>'.$langs->trans("Stripe").'</strong>: ';
754 if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) {
755 print img_picto('', 'error').' '.$langs->trans("OptionXShouldBeEnabledInModuleY", $langs->transnoentities("SecurityTokenIsUnique"), $langs->transnoentities("Stripe"));
756 } else {
757 print img_picto('', 'tick').' '.$langs->trans("OptionXIsCorrectlyEnabledInModuleY", $langs->transnoentities("SecurityTokenIsUnique"), $langs->transnoentities("Stripe"));
758 }
759 print '<br>';
760} else {
761 $test = isModEnabled('paypal');
762 if ($test) {
763 print '<br>';
764
765 print '<strong>'.$langs->trans("Paypal").'</strong>: ';
766 if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) {
767 print img_picto('', 'error').' '.$langs->trans("OptionXShouldBeEnabledInModuleY", $langs->transnoentities("SecurityTokenIsUnique"), $langs->transnoentities("Paypal"));
768 } else {
769 print img_picto('', 'tick').' '.$langs->trans("OptionXIsCorrectlyEnabledInModuleY", $langs->transnoentities("SecurityTokenIsUnique"), $langs->transnoentities("Paypal"));
770 }
771 print '<br>';
772 }
773}
774*/
775
776print '</div>';
777
778
779// APIs
780
781print '<br>';
782print '<br>';
783print load_fiche_titre($langs->trans("API"), '', 'folder');
784
785print '<div class="divsection wordbreak">';
786
787if (!isModEnabled('api') && !isModEnabled('webservices')) {
788 print $langs->trans("APIsAreNotEnabled");
789} else {
790 if (isModEnabled('webservices')) {
791 print img_picto('', 'warning').' '.$langs->trans('YouEnableDeprecatedWSAPIsUseRESTAPIsInstead')."<br>\n";
792 print '<br>';
793 }
794 if (isModEnabled('api')) {
795 print '<strong>API_ENDPOINT_RULES</strong> = '.getDolGlobalString('API_ENDPOINT_RULES', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Example").': login:0,users:0,setup:1,status:1,tickets:1,...)</span>')."<br>\n";
796
797 print '<br>';
798
799 print '<strong>API_ENABLE_LOGIN_API</strong> = '.getDolGlobalString('API_ENABLE_LOGIN_API', '0').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 0)</span><br>';
800 }
801}
802
803
804print '</div>';
805
806
807print '<br>';
808print '<br>';
809
810
811// Other setup
812
813print load_fiche_titre($langs->trans("OtherSetup"), '', 'folder');
814
815print '<div class="divsection wordbreak">';
816
817print '<strong>MAIN_ALLOW_SVG_FILES_AS_IMAGES</strong> = '.getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_IMAGES', '0').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 0)</span><br>';
818print '<br>';
819
820print '<strong>MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE</strong> = '.getDolGlobalString('MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 1)</span><br>';
821print '<br>';
822
823print '<strong>MAIN_SECURITY_ANTI_SSRF_SERVER_IP</strong> = '.getDolGlobalString('MAIN_SECURITY_ANTI_SSRF_SERVER_IP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span> &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': List of static IPs of server separated with coma - '.$langs->trans("Note").': common loopback ip like 127.*.*.*, [::1] are already added)</span>')."<br>";
824print '<br>';
825
826print '<strong>MAIN_SECURITY_CSRF_WITH_TOKEN</strong> = '.getDolGlobalString('MAIN_SECURITY_CSRF_WITH_TOKEN', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 2)</span>'."<br>";
827
828print '</div>';
829
830print '<br>';
831print '<br>';
832
833
834
835// Database encryption
836
837print load_fiche_titre($langs->trans("DatabaseEncryption"), '', 'folder');
838
839print '<div class="divsection wordbreak">';
840
841//print '<strong>'.$langs->trans("PasswordEncryption").'</strong>: ';
842print '<strong>'.$langs->trans("AlgorithmFor", $langs->transnoentitiesnoconv("Passwords"));
843print $form->textwithpicto('', 'non reversible encryption, defined into MAIN_SECURITY_HASH_ALGO');
844print '</strong> = '.getDolGlobalString('MAIN_SECURITY_HASH_ALGO', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>')." &nbsp; ";
845if (!getDolGlobalString('MAIN_SECURITY_HASH_ALGO')) {
846 print '<span class="opacitymedium"> &nbsp; &nbsp; (If unset: \'md5\')</span>';
847}
848if (getDolGlobalString('MAIN_SECURITY_HASH_ALGO') != 'password_hash') {
849 print '<br><strong>MAIN_SECURITY_SALT</strong> = '.getDolGlobalString('MAIN_SECURITY_SALT', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').'<br>';
850} else {
851 print '<span class="opacitymedium">('.$langs->trans("Recommended").': password_hash)</span>';
852 print '<br>';
853}
854if (getDolGlobalString('MAIN_SECURITY_HASH_ALGO') != 'password_hash') {
855 print '<div class="info">The recommended value for MAIN_SECURITY_HASH_ALGO is now \'password_hash\' but setting it now will make ALL existing passwords of all users not valid, so update is not possible.<br>';
856 print 'If you really want to switch, you must:<br>';
857 print '- Go on home - setup - other and add constant MAIN_SECURITY_HASH_ALGO to value \'password_hash\'<br>';
858 print '- In same session, WITHOUT LOGGING OUT, go into your admin user record and set a new password<br>';
859 print '- You can now logout and login with this new password. You must now reset password of all other users.<br>';
860 print '</div>';
861}
862print '<br>';
863
864$action = GETPOST('action');
865$exampletodecrypt = GETPOST('exampletodecrypt', 'password');
866
867print '<strong>'.$langs->trans("AlgorithmFor", $langs->transnoentitiesnoconv("SensitiveData"));
868print $form->textwithpicto('', 'reversible encryption done with dolEncrypt/dolDecrypt');
869print '</strong> = '.constant('MAIN_SECURITY_REVERSIBLE_ALGO').' with a random seed + a crypt key defined into the conf.php file (in $dolibarr_main_instance_unique_id or $dolibarr_main_dolcrypt_key)<br>';
870print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'" spellcheck="false">';
871print '<input type="hidden" name="action" value="doldecrypt">';
872print '<input type="hidden" name="token" value="'.newToken().'">';
873print '<input type="hidden" name="page_y" value="">';
874print $langs->trans("ToolToDecryptAString").': ';
875print '<input type="text" class="minwidth500 valignmiddle" name="exampletodecrypt" placeholder="dolcrypt:ALGOXXXX:ABCDFEF1234" value="'.$exampletodecrypt.'" spellcheck="false">';
876print '<input type="submit" class="reposition button small smallpaddingimp valignmiddle" name="submit" value="'.$langs->transnoentitiesnoconv("Decrypt").'">';
877if ($action == 'doldecrypt' && $user->admin && $exampletodecrypt) {
878 usleep(200);
879 $decryptedstring = $exampletodecrypt;
880 if (preg_match('/^dolobfuscationv1/', $exampletodecrypt)) {
881 // Clear cache
882 unset($_SESSION['obfuscationkey_'.((int) $conf->entity)]);
883 unset($conf->cache['obfuscationkey_'.((int) $conf->entity)]);
884 // Reload obfuscationkey
885 require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
886 $b = new BlockedLog($db);
887 $obfuscationkey = $b->getObfuscationKey();
888
889 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
890 $registrationnumber = getHashUniqueIdOfRegistration();
891 print '<!-- registrationnumber '.$registrationnumber.' -->'."\n";
892 print '<!-- mysoc->idprof1 = '.$mysoc->idprof1.' -->'."\n";
893 print '<!-- session '.$_SESSION['obfuscationkey_'.((int) $conf->entity)].' -->'."\n";
894 print '<!-- conf->cache = '. (string) $conf->cache['obfuscationkey_'.((int) $conf->entity)].' -->'."\n";
895 print '<!-- obfuscationkey => '.$obfuscationkey.' -->'."\n"; // For debug only
896
897 $decryptedstring = dolDecrypt($exampletodecrypt, $obfuscationkey);
898 } elseif (preg_match('/^dolcrypt/', $exampletodecrypt)) {
899 $decryptedstring = dolDecrypt($exampletodecrypt);
900 }
901 if (ascii_check($decryptedstring)) {
902 print '<br> => <textarea rows="'.ROWS_1.'" class="valignmiddle quatrevingtpercent">'.dolPrintHTMLForTextArea($decryptedstring).'</textarea>';
903 } else {
904 print '<br><span class="error"> => Failed to decrypt. The crypting key saved into the conf.php file seems to not be the one used to encrypt the provided encrypted string</span>';
905 }
906}
907print '</form>';
908
909print '</div>';
910
911
912print '<br>';
913print '<br>';
914
915
916// Websites
917
918if (isModEnabled('website')) {
919 print load_fiche_titre($langs->trans("Website"), '', 'website');
920 print '<div class="divsection wordbreak">';
921
922 $sql = "SELECT w.rowid as id, w.ref";
923 $sql .= " FROM ".MAIN_DB_PREFIX."website as w";
924 $sql .= " WHERE w.entity = ".((int) $conf->entity);
925 $sql .= " AND w.status = 1";
926
927 $resql = $db->query($sql);
928 if ($resql) {
929 $num_rows = $db->num_rows($resql);
930 if ($num_rows > 0) {
931 $i = 0;
932 while ($obj = $db->fetch_object($resql)) {
933 print "<strong>".$langs->trans("WebsiteSecurityOptions").": ".$obj->ref."</strong>";
934 print'<br><br>';
935
936 print '<strong>WEBSITE_'.$obj->id.'_SECURITY_FORCERP</strong> = '.getDolGlobalString('WEBSITE_'.$obj->id.'_SECURITY_FORCERP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': '.$langs->trans("Undefined").'="strict-origin-when-cross-origin" '.$langs->trans("or").' "same-origin"=more secured)</span><br>';
937
938 print '<strong>WEBSITE_'.$obj->id.'_SECURITY_FORCESTS</strong> = '.getDolGlobalString('WEBSITE_'.$obj->id.'_SECURITY_FORCESTS', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").": \"max-age=31536000; includeSubDomains\")</span><br>";
939
940 print '<strong>WEBSITE_'.$obj->id.'_SECURITY_FORCEPP</strong> = '.getDolGlobalString('WEBSITE_'.$obj->id.'_SECURITY_FORCEPP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").": \"camera=(), microphone=(), geolocation=*\")</span><br>";
941
942 if (getDolGlobalString('WEBSITE_'.$obj->id.'_SECURITY_FORCECSPPRO')) {
943 print '<strong>WEBSITE_'.$obj->id.'_SECURITY_FORCECSPPRO</strong> = '.getDolGlobalString('WEBSITE_'.$obj->id.'_SECURITY_FORCECSPPRO', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
944 print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").': "';
945 $examplecsprule = "default-src 'self' 'unsafe-inline' matomo.".getDomainFromURL($_SERVER["SERVER_NAME"], 1)." *.transifex.net *.transifex.com *.cloudflare.com *.cloudflareinsights.com *.google-analytics.com *.googletagmanager.com *.google.com *.gstatic.com *.googleapis.com *.googleadservices.com *.ads-twitter.com *.doubleclick.net; frame-ancestors 'self'; object-src *.youtube.com; frame-src 'self' *.twitter.com *.facebook.com *.youtube.com; img-src * data:;";
946 print $examplecsprule;
947 print '")</span><br>';
948 }
949
950 print '<strong>WEBSITE_'.$obj->id.'_SECURITY_FORCECSP</strong> = '.getDolGlobalString('WEBSITE_'.$obj->id.'_SECURITY_FORCECSP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
951 print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").': "';
952 $examplecsprule = "default-src 'self' 'unsafe-inline' matomo.".getDomainFromURL($_SERVER["SERVER_NAME"], 1)." *.transifex.net *.transifex.com *.cloudflare.com *.cloudflareinsights.com *.google-analytics.com *.googletagmanager.com *.google.com *.gstatic.com *.googleapis.com *.googleadservices.com *.ads-twitter.com *.doubleclick.net; frame-ancestors 'self'; object-src *.youtube.com; frame-src 'self' *.twitter.com *.facebook.com *.youtube.com; img-src * data:;";
953 print $examplecsprule;
954 print '")</span><br>';
955
956 $i++;
957 if ($i != $num_rows) {
958 print '<br>';
959 }
960 }
961 } else {
962 print '<span class="opacity">'.$langs->trans("NoWebsite").'</span>';
963 }
964 } else {
965 dol_print_error($db);
966 }
967 print '</div>';
968
969
970 print '<br>';
971}
972
973
974// Other - experimental
975
976print load_fiche_titre($langs->trans("OtherSetup").' ('.$langs->trans("Experimental").')', '', 'folder');
977
978print '<div class="divsection wordbreak">';
979print '<strong>MAIN_EXEC_USE_POPEN</strong> = ';
980if (!getDolGlobalString('MAIN_EXEC_USE_POPEN')) {
981 print '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>';
982} else {
983 print getDolGlobalString('MAIN_EXEC_USE_POPEN');
984}
985if ($execmethod == 1) {
986 print '<span class="opacitymedium"> &nbsp; &nbsp; "exec" PHP method will be used for shell commands';
987 print ' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 1)';
988 print '</span>';
989}
990if ($execmethod == 2) {
991 print '<span class="opacitymedium"> &nbsp; &nbsp; "popen" PHP method will be used for shell commands';
992 print ' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 1)';
993 print '</span>';
994}
995print '<br>';
996print '<br>';
997
998print '<strong>MAIN_RESTRICTHTML_ONLY_VALID_HTML</strong> = '.(getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML') ? '1' : '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
999print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").": 1 - does not work on HTML5 with some old libxml libs)</span>";
1000
1001// Test compatibility of MAIN_RESTRICTHTML_ONLY_VALID_HTML
1002$savMAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = getDolGlobalString('MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES');
1003$savMAIN_RESTRICTHTML_ONLY_VALID_HTML = getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML');
1004$savMAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY');
1005$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0;
1006$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1;
1007$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 0;
1008$result = dol_htmlwithnojs('<img onerror<=alert(document.domain)> src=>0xbeefed');
1009$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = $savMAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES;
1010$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = $savMAIN_RESTRICTHTML_ONLY_VALID_HTML;
1011$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = $savMAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY;
1012
1013if ($result == 'InvalidHTMLStringCantBeCleaned') {
1014 print ' &nbsp; - &nbsp; '.img_warning().' Your libxml seems to old to work correctly with this option. Disable it !';
1015} else {
1016 print ' &nbsp; - &nbsp; Test of compatibility with this option seems ok';
1017}
1018print '<br>';
1019
1020print '<br>';
1021
1022print '<strong>MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY</strong> = '.(getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY') ? '1' : '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
1023print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 1)</span> &nbsp; - &nbsp; Module "php-tidy" must be enabled (currently: '.((extension_loaded('tidy') && class_exists("tidy")) ? 'Enabled' : img_picto('', 'warning').' Not available').")";
1024if (extension_loaded('tidy') && class_exists("tidy")) {
1025 // Test compatibility of MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY
1026 $savMAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = getDolGlobalString('MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES');
1027 $savMAIN_RESTRICTHTML_ONLY_VALID_HTML = getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML');
1028 $savMAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY');
1029 $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0;
1030 $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0;
1031 $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1;
1032 $result = dol_htmlwithnojs('<img onerror<=alert(document.domain)> src=>0xbeefed');
1033 $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = $savMAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES;
1034 $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = $savMAIN_RESTRICTHTML_ONLY_VALID_HTML;
1035 $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = $savMAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY;
1036
1037 if ($result == 'InvalidHTMLStringCantBeCleaned') {
1038 print ' &nbsp; - &nbsp; '.img_warning().' Your libxml seems to old to work correctly with this option. Disable it !';
1039 } else {
1040 print ' &nbsp; - &nbsp; Test of compatibility with this option seems ok';
1041 }
1042}
1043print '<br>';
1044
1045print '<br>';
1046
1047print '<strong>MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES</strong> = '.(getDolGlobalString('MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES') ? '1' : '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
1048print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").": 1 - does not work on HTML5 with some old libxml libs)</span><br>";
1049print '<br>';
1050
1051// MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1, disallow url links except if on the local wrapper document.php or viewimage.php
1052// MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 2, disallow all urls link
1053print '<strong>MAIN_DISALLOW_URL_INTO_DESCRIPTIONS</strong> = '.getDolGlobalString('MAIN_DISALLOW_URL_INTO_DESCRIPTIONS', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': 1=only local links allowed (to wrapper document.php or image.php) or 2=no links at all)</span>')."<br>";
1054print '<br>';
1055
1056print '<strong>MAIN_ALLOW_SVG_FILES_AS_EXTERNAL_LINKS</strong> = '.getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_EXTERNAL_LINKS', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)</span>')."<br>";
1057print '<br>';
1058
1059print '<strong>MAIN_ALLOW_LINK_STARTING_WITH_FILE</strong> = '.getDolGlobalString('MAIN_ALLOW_LINK_STARTING_WITH_FILE', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)</span>')."<br>";
1060print '<br>';
1061
1062print '<strong>MAIN_ALLOW_OBFUSCATION_METHODS_IN_DOL_EVAL</strong> = '.getDolGlobalString('MAIN_ALLOW_OBFUSCATION_METHODS_IN_DOL_EVAL', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
1063print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").": ".$langs->trans("Undefined").' '.$langs->trans("or")." 0 - The value 1 allows the use of concatenation functions like . or dol_concat into extra fields conditions or formula but is not secured)</span><br>";
1064print '<br>';
1065
1066// MAIN_ALLOW_LOCAL_LINKS_AS_EXTERNAL_LINKS
1067
1068print '<strong>MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL</strong> = '.getDolGlobalString('MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)</span>')."<br>";
1069print '<br>';
1070
1071print '<strong>MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED</strong> = '.getDolGlobalString('MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)</span>')."<br>";
1072
1073
1074
1075/*
1076 * If we call URL with param security.php/test/test and security.php/test%2Ftest, we can get information if
1077 * AllowEncodedSlashes is enabled or not.
1078 * Note: When there is a string after the page.php/... and before the ? or #, it is available into the $_SERVER["PATH_INFO"].
1079 * Note about $_SERVER:
1080 * REQUEST_URI: /test/before_rewrite/script.php/path/info?q=helloword
1081 * PHP_SELF: /test/after_rewrite/script.php/path/info
1082 * QUERY_STRING: q=helloword
1083 * SCRIPT_NAME: /test/after_rewrite/script.php
1084 * PATH_INFO: /path/info (usually not defined because there is no text between page.php/... and before the ? or #)
1085 * SCRIPT_FILENAME: /var/www/test/php/script.php
1086 * __FILE__ : /var/www/test/php/script_included.php
1087 */
1088$request = $_SERVER['REQUEST_URI'];
1089if (strpos($request, '%2F') !== false) { // It seems than even when AllowEncodedSlashes=NoDecode, behaviour is forced to On on some servers.
1090 echo '<br><strong>AllowEncodedSlashes probably enabled (NoDecode)</strong>';
1091} elseif (strpos($request, '/test/test') !== false) {
1092 echo '<br><strong>AllowEncodedSlashes enabled with decoding On</strong>';
1093} else {
1094 //echo 'Cannot determine';
1095}
1096
1097
1098
1099print '</div>';
1100
1101
1102print '<br>';
1103print '<br>';
1104
1105
1106print load_fiche_titre($langs->trans("LimitsAndMitigation"), '', 'folder');
1107
1108print '<div class="divsection wordbreak">';
1109
1110print '<span class="opacitymedium">';
1111print $langs->trans("RecommendMitigationOnURL").'<br>';
1112print '</span>';
1113
1114print '<br>';
1115$urlexamplebase = 'https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/fail2ban/filter.d/';
1116print '<span class="fas fa-shield-alt"></span> Login or API authentication (see <a target="_blank" rel="noopener" href="'.$urlexamplebase.'web-dolibarr-rulesbruteforce.conf">fail2ban example on GitHub</a>)<br>';
1117print '<span class="fas fa-shield-alt"></span> '.DOL_URL_ROOT.'/passwordforgotten.php (see <a target="_blank" rel="noopener" href="'.$urlexamplebase.'web-dolibarr-rulespassforgotten.conf">fail2ban example on GitHub</a>)<br>';
1118print '<span class="fas fa-shield-alt"></span> '.DOL_URL_ROOT.'/public/* (see <a target="_blank" rel="noopener" href="'.$urlexamplebase.'web-dolibarr-limitpublic.conf">fail2ban example on GitHub</a>)<br>';
1119print '<br>';
1120$urlexamplebase = 'https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/apache/';
1121print '<span class="fas fa-shield-alt"></span> You can also protect the application using a HTTP Basic authentication layer (see <a target="_blank" rel="noopener" href="'.$urlexamplebase.'virtualhost">apache2 virtualhost example on GitHub</a>)<br>';
1122
1123print '</div>';
1124
1125// End of page
1126llxFooter();
1127$db->close();
phpinfo_array()
Return the php_info into an array.
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
getHashUniqueIdOfRegistration($algo='sha256')
Return a hash unique identifier of the registration (used to identify the registration of instance wi...
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 Blocked Log.
Events class.
Class to manage generation of HTML components Only common components must be here.
$conffile
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:66
version_php()
Return PHP version.
getExecutableContent()
Return array of extension for executable files of text files that can contains executable code.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
ascii_check($str)
Check if a string is in ASCII.
dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox=0, $check='restricthtml')
Sanitize a HTML to remove js, dangerous content and external links.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_getwebuser($mode)
Return user/group account of web server.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
dolDecrypt($chain, $key='', $patterntotest='')
Decode a string with a symmetric encryption.