265 if (is_array($var)) {
266 foreach ($var as $key => $value) {
268 if ($type === 0 && defined(
'NOSCANPOSTFORINJECTION') && is_array(constant(
'NOSCANPOSTFORINJECTION')) && in_array($key, constant(
'NOSCANPOSTFORINJECTION'))) {
275 http_response_code(403);
278 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'unknown' : $_SERVER[
'REMOTE_ADDR']);
281 $errormessage =
'Access refused to '.htmlentities($ip, ENT_COMPAT,
'UTF-8').
' by SQL or Script injection protection in main.inc.php:analyseVarsForSqlAndScriptsInjection type='.htmlentities((
string) $type, ENT_COMPAT,
'UTF-8');
284 $errormessage2 =
'page='.htmlentities((empty($_SERVER[
"REQUEST_URI"]) ?
'' : $_SERVER[
"REQUEST_URI"]), ENT_COMPAT,
'UTF-8');
285 $errormessage2 .=
' paramtype='.htmlentities((
string) $type, ENT_COMPAT,
'UTF-8');
286 $errormessage2 .=
' paramkey='.htmlentities($key, ENT_COMPAT,
'UTF-8');
287 $errormessage2 .=
' paramvalue='.htmlentities($value, ENT_COMPAT,
'UTF-8');
291 print
'Try to go back, fix data of your form and resubmit it. You can contact also your technical support.';
293 print
"\n".
'<!--'.
"\n";
294 print $errormessage2;
298 if (function_exists(
'error_log')) {
299 error_log($errormessage.
' '.substr($errormessage2, 2000));
306 if (class_exists(
'PHPUnit\Framework\TestSuite')) {
307 $message = $errormessage.
' '.substr($errormessage2, 2000);
308 throw new Exception(
"Security injection exception: $message");
328if ((defined(
'NOREQUIREDB') || defined(
'NOREQUIRETRAN')) && !defined(
'NOREQUIREMENU')) {
329 print
'If define NOREQUIREDB or NOREQUIRETRAN are set, you must also set NOREQUIREMENU or not set them.';
332if (defined(
'NOREQUIREUSER') && !defined(
'NOREQUIREMENU')) {
333 print
'If define NOREQUIREUSER is set, you must also set NOREQUIREMENU or not set it.';
338if (!defined(
'NOSCANPHPSELFFORINJECTION') && !empty($_SERVER[
"PHP_SELF"])) {
339 $morevaltochecklikepost = array($_SERVER[
"PHP_SELF"]);
343if (!defined(
'NOSCANGETFORINJECTION') && !empty($_SERVER[
"QUERY_STRING"])) {
347 $morevaltochecklikeget = array(urldecode($_SERVER[
"QUERY_STRING"]));
351if (!defined(
'NOSCANPOSTFORINJECTION') || is_array(constant(
'NOSCANPOSTFORINJECTION'))) {
356if (!empty($_SERVER[
'DOCUMENT_ROOT']) && substr($_SERVER[
'DOCUMENT_ROOT'], -6) !==
'htdocs') {
357 set_include_path($_SERVER[
'DOCUMENT_ROOT'].
'/htdocs');
361require_once
'filefunc.inc.php';
366if (
GETPOST(
"DOL_AUTOSET_COOKIE")) {
367 $tmpautoset = explode(
':',
GETPOST(
"DOL_AUTOSET_COOKIE"), 2);
368 $tmplist = explode(
',', $tmpautoset[1]);
369 $cookiearrayvalue = array();
370 foreach ($tmplist as $tmpkey) {
371 $postkey = $tmpautoset[0].
'_'.$tmpkey;
374 $cookiearrayvalue[$tmpkey] =
GETPOST($postkey);
377 $cookiename = $tmpautoset[0];
378 $cookievalue = json_encode($cookiearrayvalue);
380 if (PHP_VERSION_ID < 70300) {
381 setcookie($cookiename, empty($cookievalue) ?
'' : $cookievalue, empty($cookievalue) ? 0 : (time() + (86400 * 354)),
'/',
'', !(empty($dolibarr_main_force_https) &&
isHTTPS() === false), true);
384 $cookieparams = array(
385 'expires' => empty($cookievalue) ? 0 : (time() + (86400 * 354)),
388 'secure' => !(empty($dolibarr_main_force_https) &&
isHTTPS() === false),
392 setcookie($cookiename, empty($cookievalue) ?
'' : $cookievalue, $cookieparams);
394 if (empty($cookievalue)) {
395 unset($_COOKIE[$cookiename]);
401if (!empty($php_session_save_handler) && $php_session_save_handler ==
'db') {
402 require_once
'core/lib/phpsessionin'.$php_session_save_handler.
'.lib.php';
408$prefix = dol_getprefix(
'');
409$sessionname =
'DOLSESSID_'.$prefix;
410$sessiontimeout =
'DOLSESSTIMEOUT_'.$prefix;
411if (!empty($_COOKIE[$sessiontimeout])) {
412 ini_set(
'session.gc_maxlifetime', $_COOKIE[$sessiontimeout]);
417if (!defined(
'NOSESSION')) {
418 if (PHP_VERSION_ID < 70300) {
419 session_set_cookie_params(0,
'/',
null, !(empty($dolibarr_main_force_https) &&
isHTTPS() ===
false),
true);
422 $sessioncookieparams = array(
426 'secure' => !(empty($dolibarr_main_force_https) &&
isHTTPS() ===
false),
430 session_set_cookie_params($sessioncookieparams);
432 session_name($sessionname);
439require_once
'master.inc.php';
447 if ((!session_id() || !isset($_SESSION[
"dol_login"])) && !isset($_POST[
"username"]) && !empty($_SERVER[
"GATEWAY_INTERFACE"])) {
449 } elseif (isset($_POST[
"username"]) && in_array($_POST[
"username"], explode(
';',
getDolGlobalString(
'MAIN_ONLY_LOGIN_ALLOWED')))) {
451 } elseif (defined(
'NOREQUIREDB')) {
453 } elseif (defined(
'EVEN_IF_ONLY_LOGIN_ALLOWED')) {
455 } elseif (session_id() && isset($_SESSION[
"dol_login"]) && in_array($_SESSION[
"dol_login"], explode(
';',
getDolGlobalString(
'MAIN_ONLY_LOGIN_ALLOWED')))) {
459 if (session_id() && isset($_SESSION[
"dol_login"]) && !in_array($_SESSION[
"dol_login"], explode(
';',
getDolGlobalString(
'MAIN_ONLY_LOGIN_ALLOWED')))) {
460 print
'Sorry, your application is offline.'.
"\n";
461 print
'You are logged with user "'.$_SESSION[
"dol_login"].
'" and only administrator users (' . str_replace(
';',
', ',
getDolGlobalString(
'MAIN_ONLY_LOGIN_ALLOWED')).
') is allowed to connect for the moment.'.
"\n";
462 $nexturl = DOL_URL_ROOT.
'/user/logout.php?token='.
newToken();
463 print
'Please try later or <a href="'.$nexturl.
'">click here to disconnect and change login user</a>...'.
"\n";
465 print
'Sorry, your application is offline. Only administrator users (' . str_replace(
';',
', ',
getDolGlobalString(
'MAIN_ONLY_LOGIN_ALLOWED')).
') is allowed to connect for the moment.'.
"\n";
466 $nexturl = DOL_URL_ROOT.
'/';
467 print
'Please try later or <a href="'.$nexturl.
'">click here to change login user</a>...'.
"\n";
475register_shutdown_function(
'dol_shutdown');
478if (isModEnabled(
'debugbar') && !
GETPOST(
'dol_use_jmobile') && empty($_SESSION[
'dol_use_jmobile'])) {
480 include_once DOL_DOCUMENT_ROOT.
'/debugbar/class/DebugBar.php';
482 $renderer = $debugbar->getJavascriptRenderer();
484 $conf->global->MAIN_HTML_HEADER =
'';
486 $conf->global->MAIN_HTML_HEADER .= $renderer->renderHead();
488 '@phan-var-force array{time:DebugBar\DataCollector\TimeDataCollector} $debugbar';
489 $debugbar[
'time']->startMeasure(
'pageaftermaster',
'Page generation (after environment init)');
493if (isset($_SERVER[
"HTTP_USER_AGENT"])) {
495 $conf->browser->name = $tmp[
'browsername'];
496 $conf->browser->os = $tmp[
'browseros'];
497 $conf->browser->version = $tmp[
'browserversion'];
498 $conf->browser->ua = $tmp[
'browserua'];
499 $conf->browser->layout = $tmp[
'layout'];
502 if ($conf->browser->layout ==
'phone') {
503 $conf->dol_no_mouse_hover = 1;
509 $conf->theme =
GETPOST(
'theme',
'aZ09');
510 $conf->css =
"/theme/".$conf->theme.
"/style.css.php";
514if (
GETPOSTINT(
'textbrowser') || (!empty($conf->browser->name) && $conf->browser->name ==
'textbrowser')) {
515 $conf->global->MAIN_OPTIMIZEFORTEXTBROWSER = 2;
520if (!empty($conf->file->main_force_https) && !
isHTTPS() && !defined(
'NOHTTPSREDIRECT')) {
522 if (is_numeric($conf->file->main_force_https)) {
523 if ($conf->file->main_force_https ==
'1' && !empty($_SERVER[
"SCRIPT_URI"])) {
524 if (preg_match(
'/^http:/i', $_SERVER[
"SCRIPT_URI"]) && !preg_match(
'/^https:/i', $_SERVER[
"SCRIPT_URI"])) {
525 $newurl = preg_replace(
'/^http:/i',
'https:', $_SERVER[
"SCRIPT_URI"]);
530 $newurl = preg_replace(
'/^http:/i',
'https:', DOL_MAIN_URL_ROOT).$_SERVER[
"REQUEST_URI"];
534 $newurl = $conf->file->main_force_https.$_SERVER[
"REQUEST_URI"];
539 dol_syslog(
"main.inc: dolibarr_main_force_https is on, we make a redirect to ".$newurl);
540 header(
"Location: ".$newurl);
543 dol_syslog(
"main.inc: dolibarr_main_force_https is on but we failed to forge new https url so no redirect is done", LOG_WARNING);
547if (!defined(
'NOLOGIN') && !defined(
'NOIPCHECK') && !empty($dolibarr_main_restrict_ip)) {
548 $listofip = explode(
',', $dolibarr_main_restrict_ip);
550 foreach ($listofip as $ip) {
552 if ($ip == $_SERVER[
'REMOTE_ADDR']) {
558 print
'Access refused by IP protection. Your detected IP is '.$_SERVER[
'REMOTE_ADDR'];
564if (!defined(
'NOREQUIREHTML')) {
565 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
567if (!defined(
'NOREQUIREAJAX')) {
568 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
573 dol_syslog(
"main.inc: A previous install or upgrade was not complete. Redirect to install page.", LOG_WARNING);
574 header(
"Location: ".DOL_URL_ROOT.
"/install/index.php");
578$checkifupgraderequired =
false;
580 $checkifupgraderequired =
true;
583 $checkifupgraderequired =
true;
585if ($checkifupgraderequired) {
587 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
588 $dolibarrversionlastupgrade = preg_split(
'/[.-]/', $versiontocompare);
589 $dolibarrversionprogram = preg_split(
'/[.-]/', DOL_VERSION);
590 $rescomp =
versioncompare($dolibarrversionprogram, $dolibarrversionlastupgrade);
592 if (!
getDolGlobalString(
'MAIN_NO_UPGRADE_REDIRECT_ON_LEVEL_3_CHANGE') || $rescomp < 3) {
594 dol_syslog(
"main.inc: database version ".$versiontocompare.
" is lower than programs version ".DOL_VERSION.
". Redirect to install/upgrade page.", LOG_WARNING);
595 if (php_sapi_name() ===
"cli") {
596 print
"main.inc: database version ".$versiontocompare.
" is lower than programs version ".DOL_VERSION.
". Try to run upgrade process.\n";
598 header(
"Location: ".DOL_URL_ROOT.
"/install/index.php");
606if (!defined(
'NOTOKENRENEWAL') && !defined(
'NOSESSION')) {
608 if (!preg_match(
'/\.(css|js|json)\.php$/', $_SERVER[
"PHP_SELF"])) {
610 if (isset($_SESSION[
'newtoken'])) {
611 $_SESSION[
'token'] = $_SESSION[
'newtoken'];
614 if (!isset($_SESSION[
'newtoken']) ||
getDolGlobalInt(
'MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL')) {
618 $token =
dol_hash(uniqid((
string) mt_rand(),
false),
'md5');
619 $_SESSION[
'newtoken'] = $token;
620 dol_syslog(
"NEW TOKEN generated by : ".$_SERVER[
'PHP_SELF'], LOG_DEBUG);
628if ((!defined(
'NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) &&
getDolGlobalInt(
'MAIN_SECURITY_CSRF_WITH_TOKEN')) || defined(
'CSRFCHECK_WITH_TOKEN')) {
630 $sensitiveget =
false;
631 if ((GETPOSTISSET(
'massaction') ||
GETPOST(
'action',
'aZ09')) &&
getDolGlobalInt(
'MAIN_SECURITY_CSRF_WITH_TOKEN') >= 3) {
633 if (GETPOSTISSET(
'massaction') || !in_array(
GETPOST(
'action',
'aZ09'), array(
'create',
'create2',
'createsite',
'createcard',
'edit',
'editcontract',
'editvalidator',
'file_manager',
'presend',
'presend_addmessage',
'preview',
'reconcile',
'specimen'))) {
634 $sensitiveget =
true;
638 $arrayofactiontoforcetokencheck = array(
640 'doprev',
'donext',
'dvprev',
'dvnext',
641 'freezone',
'install',
644 if (in_array(
GETPOST(
'action',
'aZ09'), $arrayofactiontoforcetokencheck)) {
645 $sensitiveget =
true;
648 if (preg_match(
'/^(confirm_)?(add|classify|close|confirm|copy|del|disable|enable|remove|set|unset|update|save)/',
GETPOST(
'action',
'aZ09'))) {
649 $sensitiveget =
true;
656 (!empty($_SERVER[
'REQUEST_METHOD']) && $_SERVER[
'REQUEST_METHOD'] ==
'POST') ||
658 GETPOSTISSET(
'massaction') ||
659 ((GETPOSTISSET(
'actionlogin') || GETPOSTISSET(
'action')) && defined(
'CSRFCHECK_WITH_TOKEN'))
662 if (!
GETPOST(
'token',
'alpha') ||
GETPOST(
'token',
'alpha') ==
'notrequired') {
665 dol_syslog(
"--- Access to ".(empty($_SERVER[
"REQUEST_METHOD"]) ?
'' : $_SERVER[
"REQUEST_METHOD"].
' ').$_SERVER[
"PHP_SELF"].
" refused. File size too large or not provided.");
666 $langs->loadLangs(array(
"errors",
"install"));
667 print $langs->trans(
"ErrorFileSizeTooLarge").
' ';
668 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
670 http_response_code(403);
671 if (defined(
'CSRFCHECK_WITH_TOKEN')) {
672 dol_syslog(
"--- Access to ".(empty($_SERVER[
"REQUEST_METHOD"]) ?
'' : $_SERVER[
"REQUEST_METHOD"].
' ').$_SERVER[
"PHP_SELF"].
" refused by CSRF protection (CSRFCHECK_WITH_TOKEN protection) in main.inc.php. Token not provided.", LOG_WARNING);
673 print
"Access to a page that needs a token (constant CSRFCHECK_WITH_TOKEN is defined) is refused by CSRF protection in main.inc.php. Token not provided.\n";
675 dol_syslog(
"--- Access to ".(empty($_SERVER[
"REQUEST_METHOD"]) ?
'' : $_SERVER[
"REQUEST_METHOD"].
' ').$_SERVER[
"PHP_SELF"].
" refused by CSRF protection (POST method or GET with a sensible value for 'action' parameter) in main.inc.php. Token not provided.", LOG_WARNING);
676 print
"Access to this page this way (POST method or GET with a sensible value for 'action' parameter) is refused by CSRF protection in main.inc.php. Token not provided.\n";
677 print
"If you access your server behind a proxy using url rewriting and the parameter is provided by caller, you might check that all HTTP header are propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file or MAIN_SECURITY_CSRF_WITH_TOKEN to 0";
681 print
" into setup).\n";
688 $sessiontokenforthisurl = (empty($_SESSION[
'token']) ?
'' : $_SESSION[
'token']);
690 if (GETPOSTISSET(
'token') &&
GETPOST(
'token') !=
'notrequired' &&
GETPOST(
'token',
'alpha') != $sessiontokenforthisurl) {
691 dol_syslog(
"--- Access to ".(empty($_SERVER[
"REQUEST_METHOD"]) ?
'' : $_SERVER[
"REQUEST_METHOD"].
' ').$_SERVER[
"PHP_SELF"].
" refused by CSRF protection (invalid token), so we disable POST and some GET parameters - referrer=".(empty($_SERVER[
'HTTP_REFERER']) ?
'' : $_SERVER[
'HTTP_REFERER']).
", action=".
GETPOST(
'action',
'aZ09').
", _GET|POST['token']=".
GETPOST(
'token',
'alpha'), LOG_WARNING);
694 if (!defined(
'NOTOKENRENEWAL')) {
696 setEventMessages(
'SecurityTokenHasExpiredSoActionHasBeenCanceledPleaseRetry',
null,
'warnings',
'', 1);
699 if (isset($_POST[
'id'])) {
700 $savid = ((int) $_POST[
'id']);
703 unset($_GET[
'confirm']);
704 unset($_GET[
'action']);
705 unset($_GET[
'confirmmassaction']);
706 unset($_GET[
'massaction']);
707 unset($_GET[
'token']);
709 $_POST[
'id'] = ((int) $savid);
712 $_GET[
'errorcode'] =
'InvalidToken';
719if (GETPOSTISSET(
'disablemodules')) {
720 $_SESSION[
"disablemodules"] =
GETPOST(
'disablemodules',
'alpha');
722if (!empty($_SESSION[
"disablemodules"])) {
723 $modulepartkeys = array(
'css',
'js',
'tabs',
'triggers',
'login',
'substitutions',
'menus',
'theme',
'sms',
'tpl',
'barcode',
'models',
'societe',
'hooks',
'dir',
'syslog',
'tpllinkable',
'contactelement',
'moduleforexternal',
'websitetemplates');
725 $disabled_modules = explode(
',', $_SESSION[
"disablemodules"]);
726 foreach ($disabled_modules as $module) {
728 if (empty($conf->$module)) {
731 $conf->$module->enabled =
false;
732 foreach ($modulepartkeys as $modulepartkey) {
733 unset($conf->modules_parts[$modulepartkey][$module]);
735 if ($module ==
'fournisseur') {
736 $conf->supplier_order->enabled = 0;
737 $conf->supplier_invoice->enabled = 0;
744$modulepart = explode(
"/", $_SERVER[
"PHP_SELF"]);
745if (is_array($modulepart) && count($modulepart) > 0) {
746 foreach ($conf->modules as $module) {
747 if (in_array($module, $modulepart)) {
748 $modulepart = $module;
753if (is_array($modulepart)) {
764if (!defined(
'NOLOGIN')) {
768 if (defined(
'MAIN_AUTHENTICATION_MODE')) {
769 $dolibarr_main_authentication = constant(
'MAIN_AUTHENTICATION_MODE');
772 if (empty($dolibarr_main_authentication)) {
773 $dolibarr_main_authentication =
'dolibarr';
776 if ($dolibarr_main_authentication ==
'forceuser' && empty($dolibarr_auto_user)) {
777 $dolibarr_auto_user =
'auto';
781 $authmode = explode(
',', $dolibarr_main_authentication);
784 if (!count($authmode)) {
785 $langs->load(
'main');
786 dol_print_error(
null, $langs->trans(
"ErrorConfigParameterNotDefined",
'dolibarr_main_authentication'));
793 $resultFetchUser =
'';
795 $dol_authmode =
null;
797 if (!isset($_SESSION[
"dol_login"])) {
799 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
801 $dol_dst_observed =
GETPOSTINT(
"dst_observed", 3);
803 $dol_dst_second =
GETPOSTINT(
"dst_second", 3);
804 $dol_screenwidth =
GETPOSTINT(
"screenwidth", 3);
805 $dol_screenheight =
GETPOSTINT(
"screenheight", 3);
806 $dol_hide_topmenu =
GETPOSTINT(
'dol_hide_topmenu', 3);
807 $dol_hide_leftmenu =
GETPOSTINT(
'dol_hide_leftmenu', 3);
808 $dol_optimize_smallscreen =
GETPOSTINT(
'dol_optimize_smallscreen', 3);
809 $dol_no_mouse_hover =
GETPOSTINT(
'dol_no_mouse_hover', 3);
810 $dol_use_jmobile =
GETPOSTINT(
'dol_use_jmobile', 3);
813 if (!empty($dolibarr_main_demo) && $_SERVER[
'PHP_SELF'] == DOL_URL_ROOT.
'/index.php') {
814 if (empty($_SERVER[
'HTTP_REFERER']) || !preg_match(
'/public/', $_SERVER[
'HTTP_REFERER'])) {
815 dol_syslog(
"Call index page from another url than demo page (call is done from page ".(empty($_SERVER[
'HTTP_REFERER']) ?
'' : $_SERVER[
'HTTP_REFER']).
")");
817 $url .= ($url ?
'&' :
'').($dol_hide_topmenu ?
'dol_hide_topmenu='.$dol_hide_topmenu :
'');
818 $url .= ($url ?
'&' :
'').($dol_hide_leftmenu ?
'dol_hide_leftmenu='.$dol_hide_leftmenu :
'');
819 $url .= ($url ?
'&' :
'').($dol_optimize_smallscreen ?
'dol_optimize_smallscreen='.$dol_optimize_smallscreen :
'');
820 $url .= ($url ?
'&' :
'').($dol_no_mouse_hover ?
'dol_no_mouse_hover='.$dol_no_mouse_hover :
'');
821 $url .= ($url ?
'&' :
'').($dol_use_jmobile ?
'dol_use_jmobile='.$dol_use_jmobile :
'');
822 $url = DOL_URL_ROOT.
'/public/demo/index.php'.($url ?
'?'.$url :
'');
823 header(
"Location: ".$url);
830 $hookmanager->initHooks(array(
'login'));
831 $parameters = array();
832 $reshook = $hookmanager->executeHooks(
'beforeLoginAuthentication', $parameters, $user, $action);
839 if ($test &&
GETPOST(
"username",
"alpha", 2) &&
getDolGlobalString(
'MAIN_SECURITY_ENABLECAPTCHA') && !isset($_SESSION[
'dol_bypass_antispam'])) {
840 $sessionkey =
'dol_antispam_value';
841 $ok = (array_key_exists($sessionkey, $_SESSION) && (strtolower($_SESSION[$sessionkey]) === strtolower(
GETPOST(
'code',
'restricthtml'))));
845 dol_syslog(
'Bad value for code, connection refused', LOG_NOTICE);
847 $langs->loadLangs(array(
'main',
'errors'));
849 $_SESSION[
"dol_loginmesg"] = $langs->transnoentitiesnoconv(
"ErrorBadValueForCode");
853 $user->context[
'audit'] =
'ErrorBadValueForCode - login='.GETPOST(
"username",
"alpha", 2);
856 $result = $user->call_trigger(
'USER_LOGIN_FAILED', $user);
864 $hookmanager->initHooks(array(
'login'));
865 $parameters = array(
'dol_authmode' => $authmode,
'dol_loginmesg' => $_SESSION[
"dol_loginmesg"]);
866 $reshook = $hookmanager->executeHooks(
'afterLoginFailed', $parameters, $user, $action);
875 $allowedmethodtopostusername = 3;
876 if (defined(
'MAIN_AUTHENTICATION_POST_METHOD')) {
877 $allowedmethodtopostusername = constant(
'MAIN_AUTHENTICATION_POST_METHOD');
880 $usertotest = (!empty($_COOKIE[
'login_dolibarr']) ? preg_replace(
'/[^a-zA-Z0-9_@\-\.]/',
'', $_COOKIE[
'login_dolibarr']) :
GETPOST(
"username",
"alpha", $allowedmethodtopostusername));
881 $passwordtotest =
GETPOST(
'password',
'password', $allowedmethodtopostusername);
882 $entitytotest = (
GETPOSTINT(
'entity') ?
GETPOSTINT(
'entity') : (!empty($conf->entity) ? $conf->entity : 1));
885 $goontestloop =
false;
886 if (isset($_SERVER[
"REMOTE_USER"]) && in_array(
'http', $authmode)) {
887 $goontestloop =
true;
889 if ($dolibarr_main_authentication ==
'forceuser' && !empty($dolibarr_auto_user)) {
890 $goontestloop =
true;
892 if (
GETPOST(
"username",
"alpha", $allowedmethodtopostusername)) {
893 $goontestloop =
true;
895 if (
GETPOST(
'openid_mode',
'alpha')) {
896 $goontestloop =
true;
898 if (
GETPOST(
'beforeoauthloginredirect') ||
GETPOST(
'afteroauthloginreturn')) {
899 $goontestloop =
true;
901 if (!empty($_COOKIE[
'login_dolibarr'])) {
902 $goontestloop =
true;
905 if (!is_object($langs)) {
906 include_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
909 if (defined(
'MAIN_LANG_DEFAULT')) {
910 $langcode = constant(
'MAIN_LANG_DEFAULT');
912 $langs->setDefaultLang($langcode);
918 if ($test && $goontestloop && (
GETPOST(
'actionlogin',
'aZ09') ==
'login' || $dolibarr_main_authentication !=
'dolibarr')) {
921 $oauthmodetotestarray = array(
'google');
922 foreach ($oauthmodetotestarray as $oauthmodetotest) {
923 if (in_array($oauthmodetotest.
'oauth', $authmode)) {
925 if (
GETPOST(
'beforeoauthloginredirect') == $oauthmodetotest ||
GETPOST(
'afteroauthloginreturn')) {
929 dol_syslog(
"User did not click on link for OAuth or is not on the OAuth return, so we disable check using ".$oauthmodetotest);
930 foreach ($authmode as $tmpkey => $tmpval) {
931 if ($tmpval == $oauthmodetotest.
'oauth') {
932 unset($authmode[$tmpkey]);
941 if ($login ===
'--bad-login-validity--') {
946 $dol_authmode = $conf->authmode;
947 $dol_tz = empty($_POST[
"tz"]) ? (empty($_SESSION[
"tz"]) ?
'' : $_SESSION[
"tz"]) : $_POST[
"tz"];
948 $dol_tz_string = empty($_POST[
"tz_string"]) ? (empty($_SESSION[
"tz_string"]) ?
'' : $_SESSION[
"tz_string"]) : $_POST[
"tz_string"];
949 $dol_tz_string = preg_replace(
'/\s*\(.+\)$/',
'', $dol_tz_string);
950 $dol_tz_string = preg_replace(
'/,/',
'/', $dol_tz_string);
951 $dol_tz_string = preg_replace(
'/\s/',
'_', $dol_tz_string);
954 $dol_dst_first = empty($_POST[
"dst_first"]) ? (empty($_SESSION[
"dst_first"]) ?
'' : $_SESSION[
"dst_first"]) : $_POST[
"dst_first"];
955 $dol_dst_second = empty($_POST[
"dst_second"]) ? (empty($_SESSION[
"dst_second"]) ?
'' : $_SESSION[
"dst_second"]) : $_POST[
"dst_second"];
956 if ($dol_dst_first && $dol_dst_second) {
957 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
961 if ($datenow >= $datefirst && $datenow < $datesecond) {
965 $dol_screenheight = empty($_POST[
"screenheight"]) ? (empty($_SESSION[
"dol_screenheight"]) ?
'' : $_SESSION[
"dol_screenheight"]) : $_POST[
"screenheight"];
966 $dol_screenwidth = empty($_POST[
"screenwidth"]) ? (empty($_SESSION[
"dol_screenwidth"]) ?
'' : $_SESSION[
"dol_screenwidth"]) : $_POST[
"screenwidth"];
971 dol_syslog(
'Bad password, connection refused (see a previous notice message for more info)', LOG_NOTICE);
973 $langs->loadLangs(array(
'main',
'errors'));
977 if (empty($_SESSION[
"dol_loginmesg"])) {
978 $_SESSION[
"dol_loginmesg"] = $langs->transnoentitiesnoconv(
"ErrorBadLoginPassword");
982 $user->context[
'audit'] = $langs->trans(
"ErrorBadLoginPassword").
' - login='.
GETPOST(
"username",
"alpha", 2);
985 $result = $user->call_trigger(
'USER_LOGIN_FAILED', $user);
993 $hookmanager->initHooks(array(
'login'));
994 $parameters = array(
'dol_authmode' => $dol_authmode,
'dol_loginmesg' => $_SESSION[
"dol_loginmesg"]);
995 $reshook = $hookmanager->executeHooks(
'afterLoginFailed', $parameters, $user, $action);
1005 if (!$login || (in_array(
'ldap', $authmode) && empty($passwordtotest))) {
1007 dol_syslog(
"--- Access to ".(empty($_SERVER[
"REQUEST_METHOD"]) ?
'' : $_SERVER[
"REQUEST_METHOD"].
' ').$_SERVER[
"PHP_SELF"].
" - action=".
GETPOST(
'action',
'aZ09').
" - actionlogin=".
GETPOST(
'actionlogin',
'aZ09').
" - showing the login form and exit", LOG_NOTICE);
1008 if (defined(
'NOREDIRECTBYMAINTOLOGIN')) {
1013 return 'ERROR_NOT_LOGGED';
1015 if (!empty($_SERVER[
"HTTP_USER_AGENT"]) && $_SERVER[
"HTTP_USER_AGENT"] ==
'securitytest') {
1016 http_response_code(401);
1018 dol_loginfunction($langs, $conf, (!empty($mysoc) ? $mysoc :
''));
1023 $resultFetchUser = $user->fetch(0, $login,
'', 1, ($entitytotest > 0 ? $entitytotest : -1));
1024 if ($resultFetchUser <= 0 || $user->isNotIntoValidityDateRange()) {
1025 dol_syslog(
'User not found or not valid, connection refused');
1027 session_set_cookie_params(0,
'/',
null, !empty($dolibarr_main_force_https),
true);
1028 session_name($sessionname);
1031 if ($resultFetchUser == 0) {
1033 $langs->loadLangs(array(
'main',
'errors'));
1035 $_SESSION[
"dol_loginmesg"] = $langs->transnoentitiesnoconv(
"ErrorCantLoadUserFromDolibarrDatabase", $login);
1037 $user->context[
'audit'] =
'ErrorCantLoadUserFromDolibarrDatabase - login='.$login;
1038 } elseif ($resultFetchUser < 0) {
1039 $_SESSION[
"dol_loginmesg"] = $user->error;
1041 $user->context[
'audit'] = $user->error;
1044 $langs->loadLangs(array(
'main',
'errors'));
1046 $_SESSION[
"dol_loginmesg"] = $langs->transnoentitiesnoconv(
"ErrorLoginDateValidity");
1048 $user->context[
'audit'] = $langs->trans(
"ErrorLoginDateValidity").
' - login='.$login;
1052 $result = $user->call_trigger(
'USER_LOGIN_FAILED', $user);
1061 $hookmanager->initHooks(array(
'login'));
1062 $parameters = array(
'dol_authmode' => $dol_authmode,
'dol_loginmesg' => $_SESSION[
"dol_loginmesg"]);
1063 $reshook = $hookmanager->executeHooks(
'afterLoginFailed', $parameters, $user, $action);
1068 $paramsurl = array();
1070 $paramsurl[] =
'textbrowser='.GETPOSTINT(
'textbrowser');
1073 $paramsurl[] =
'nojs='.GETPOSTINT(
'nojs');
1075 if (
GETPOST(
'lang',
'aZ09')) {
1076 $paramsurl[] =
'lang='.GETPOST(
'lang',
'aZ09');
1078 header(
'Location: '.DOL_URL_ROOT.
'/index.php'.(count($paramsurl) ?
'?'.implode(
'&', $paramsurl) :
''));
1082 if (!empty($user->conf->MAIN_LANG_DEFAULT)) {
1083 $langs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT);
1088 $login = $_SESSION[
"dol_login"];
1089 $entity = isset($_SESSION[
"dol_entity"]) ? $_SESSION[
"dol_entity"] : 0;
1090 dol_syslog(
"- This is an already logged session. _SESSION['dol_login']=".$login.
" _SESSION['dol_entity']=".$entity, LOG_DEBUG);
1092 $resultFetchUser = $user->fetch(0, $login,
'', 1, ($entity > 0 ? $entity : -1));
1096 if ($resultFetchUser <= 0
1097 || ($user->flagdelsessionsbefore && !empty($_SESSION[
"dol_logindate"]) && $user->flagdelsessionsbefore > $_SESSION[
"dol_logindate"])
1098 || ($user->status != $user::STATUS_ENABLED)
1099 || ($user->isNotIntoValidityDateRange())) {
1100 if ($resultFetchUser <= 0) {
1102 dol_syslog(
"Can't load user even if session logged. _SESSION['dol_login']=".$login, LOG_WARNING);
1103 } elseif ($user->flagdelsessionsbefore && !empty($_SESSION[
"dol_logindate"]) && $user->flagdelsessionsbefore > $_SESSION[
"dol_logindate"]) {
1105 dol_syslog(
"The user has a date for session invalidation = ".$user->flagdelsessionsbefore.
" and a session date = ".$_SESSION[
"dol_logindate"].
". We must invalidate its sessions.");
1106 } elseif ($user->status != $user::STATUS_ENABLED) {
1111 dol_syslog(
"The user login has a validity between [".$user->datestartvalidity.
" and ".$user->dateendvalidity.
"], current date is ".
dol_now());
1114 session_set_cookie_params(0,
'/',
null, !empty($dolibarr_main_force_https),
true);
1115 session_name($sessionname);
1118 if ($resultFetchUser == 0) {
1119 $langs->loadLangs(array(
'main',
'errors'));
1121 $_SESSION[
"dol_loginmesg"] = $langs->transnoentitiesnoconv(
"ErrorCantLoadUserFromDolibarrDatabase", $login);
1123 $user->context[
'audit'] =
'ErrorCantLoadUserFromDolibarrDatabase - login='.$login;
1124 } elseif ($resultFetchUser < 0) {
1125 $_SESSION[
"dol_loginmesg"] = $user->error;
1127 $user->context[
'audit'] = $user->error;
1129 $langs->loadLangs(array(
'main',
'errors'));
1131 $_SESSION[
"dol_loginmesg"] = $langs->transnoentitiesnoconv(
"ErrorSessionInvalidatedAfterPasswordChange");
1133 $user->context[
'audit'] =
'ErrorUserSessionWasInvalidated - login='.$login;
1137 $result = $user->call_trigger(
'USER_LOGIN_FAILED', $user);
1145 $hookmanager->initHooks(array(
'login'));
1146 $parameters = array(
'dol_authmode' => (
string) $dol_authmode,
'dol_loginmesg' => $_SESSION[
"dol_loginmesg"]);
1147 $reshook = $hookmanager->executeHooks(
'afterLoginFailed', $parameters, $user, $action);
1152 $paramsurl = array();
1154 $paramsurl[] =
'textbrowser='.GETPOSTINT(
'textbrowser');
1157 $paramsurl[] =
'nojs='.GETPOSTINT(
'nojs');
1159 if (
GETPOST(
'lang',
'aZ09')) {
1160 $paramsurl[] =
'lang='.GETPOST(
'lang',
'aZ09');
1163 header(
'Location: '.DOL_URL_ROOT.
'/index.php'.(count($paramsurl) ?
'?'.implode(
'&', $paramsurl) :
''));
1167 $hookmanager->initHooks(array(
'main'));
1170 if (!empty($_GET[
'save_lastsearch_values']) && !empty($_SERVER[
"HTTP_REFERER"])) {
1171 $relativepathstring = preg_replace(
'/\?.*$/',
'', $_SERVER[
"HTTP_REFERER"]);
1172 $relativepathstring = preg_replace(
'/^https?:\/\/[^\/]*/',
'', $relativepathstring);
1174 if (constant(
'DOL_URL_ROOT')) {
1175 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
1177 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
1178 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
1182 if (!empty($_SESSION[
'lastsearch_values_tmp_'.$relativepathstring])) {
1183 $_SESSION[
'lastsearch_values_'.$relativepathstring] = $_SESSION[
'lastsearch_values_tmp_'.$relativepathstring];
1184 unset($_SESSION[
'lastsearch_values_tmp_'.$relativepathstring]);
1186 if (!empty($_SESSION[
'lastsearch_contextpage_tmp_'.$relativepathstring])) {
1187 $_SESSION[
'lastsearch_contextpage_'.$relativepathstring] = $_SESSION[
'lastsearch_contextpage_tmp_'.$relativepathstring];
1188 unset($_SESSION[
'lastsearch_contextpage_tmp_'.$relativepathstring]);
1190 if (!empty($_SESSION[
'lastsearch_limit_tmp_'.$relativepathstring]) && $_SESSION[
'lastsearch_limit_tmp_'.$relativepathstring] != $conf->liste_limit) {
1191 $_SESSION[
'lastsearch_limit_'.$relativepathstring] = $_SESSION[
'lastsearch_limit_tmp_'.$relativepathstring];
1192 unset($_SESSION[
'lastsearch_limit_tmp_'.$relativepathstring]);
1194 if (!empty($_SESSION[
'lastsearch_page_tmp_'.$relativepathstring]) && $_SESSION[
'lastsearch_page_tmp_'.$relativepathstring] > 0) {
1195 $_SESSION[
'lastsearch_page_'.$relativepathstring] = $_SESSION[
'lastsearch_page_tmp_'.$relativepathstring];
1196 unset($_SESSION[
'lastsearch_page_tmp_'.$relativepathstring]);
1198 if (!empty($_SESSION[
'lastsearch_mode_tmp_'.$relativepathstring])) {
1199 $_SESSION[
'lastsearch_mode_'.$relativepathstring] = $_SESSION[
'lastsearch_mode_tmp_'.$relativepathstring];
1200 unset($_SESSION[
'lastsearch_mode_tmp_'.$relativepathstring]);
1203 if (!empty($_GET[
'save_pageforbacktolist']) && !empty($_SERVER[
"HTTP_REFERER"])) {
1204 if (empty($_SESSION[
'pageforbacktolist'])) {
1205 $pageforbacktolistarray = array();
1207 $pageforbacktolistarray = $_SESSION[
'pageforbacktolist'];
1209 $tmparray = explode(
':', $_GET[
'save_pageforbacktolist'], 2);
1210 if (!empty($tmparray[0]) && !empty($tmparray[1])) {
1211 $pageforbacktolistarray[$tmparray[0]] = $tmparray[1];
1212 $_SESSION[
'pageforbacktolist'] = $pageforbacktolistarray;
1217 $parameters = array();
1218 $reshook = $hookmanager->executeHooks(
'updateSession', $parameters, $user, $action);
1227 if (!isset($_SESSION[
"dol_login"])) {
1232 $_SESSION[
"dol_login"] = $user->login;
1233 $_SESSION[
"dol_logindate"] =
dol_now(
'gmt');
1234 $_SESSION[
"dol_authmode"] = isset($dol_authmode) ? $dol_authmode :
'';
1235 $_SESSION[
"dol_tz"] = isset($dol_tz) ? $dol_tz :
'';
1236 $_SESSION[
"dol_tz_string"] = isset($dol_tz_string) ? $dol_tz_string :
'';
1237 $_SESSION[
"dol_dst"] = isset($dol_dst) ? $dol_dst :
'';
1238 $_SESSION[
"dol_dst_observed"] = isset($dol_dst_observed) ? $dol_dst_observed :
'';
1239 $_SESSION[
"dol_dst_first"] = isset($dol_dst_first) ? $dol_dst_first :
'';
1240 $_SESSION[
"dol_dst_second"] = isset($dol_dst_second) ? $dol_dst_second :
'';
1241 $_SESSION[
"dol_screenwidth"] = isset($dol_screenwidth) ? $dol_screenwidth :
'';
1242 $_SESSION[
"dol_screenheight"] = isset($dol_screenheight) ? $dol_screenheight :
'';
1244 $_SESSION[
"dol_entity"] = $conf->entity;
1246 if (!empty($dol_hide_topmenu)) {
1247 $_SESSION[
'dol_hide_topmenu'] = $dol_hide_topmenu;
1249 if (!empty($dol_hide_leftmenu)) {
1250 $_SESSION[
'dol_hide_leftmenu'] = $dol_hide_leftmenu;
1252 if (!empty($dol_optimize_smallscreen)) {
1253 $_SESSION[
'dol_optimize_smallscreen'] = $dol_optimize_smallscreen;
1255 if (!empty($dol_no_mouse_hover)) {
1256 $_SESSION[
'dol_no_mouse_hover'] = $dol_no_mouse_hover;
1258 if (!empty($dol_use_jmobile)) {
1259 $_SESSION[
'dol_use_jmobile'] = $dol_use_jmobile;
1262 dol_syslog(
"This is a new started user session. _SESSION['dol_login']=".$_SESSION[
"dol_login"].
" Session id=".session_id());
1266 $user->update_last_login_date();
1268 $loginfo =
'TZ='.$_SESSION[
"dol_tz"].
';TZString='.$_SESSION[
"dol_tz_string"].
';Screen='.$_SESSION[
"dol_screenwidth"].
'x'.$_SESSION[
"dol_screenheight"];
1269 $loginfo .=
' - authmode='.$dol_authmode.
' - entity='.$conf->entity;
1272 $user->context[
'audit'] = $loginfo;
1273 $user->context[
'authentication_method'] = $dol_authmode;
1276 $result = $user->call_trigger(
'USER_LOGIN', $user);
1284 $hookmanager->initHooks(array(
'login'));
1285 $parameters = array(
'dol_authmode' => $dol_authmode,
'dol_loginfo' => $loginfo);
1286 $reshook = $hookmanager->executeHooks(
'afterLogin', $parameters, $user, $action);
1294 dol_print_error($db,
'Error in some triggers USER_LOGIN or in some hooks afterLogin');
1301 $landingpage = (empty($user->conf->MAIN_LANDING_PAGE) ? (!
getDolGlobalString(
'MAIN_LANDING_PAGE') ?
'' : $conf->global->MAIN_LANDING_PAGE) : $user->
conf->MAIN_LANDING_PAGE);
1302 if (!empty($landingpage)) {
1304 if ($_SERVER[
"PHP_SELF"] != $newpath) {
1305 header(
'Location: '.$newpath);
1314 $user->rights->user->user->lire = 1;
1315 $user->rights->user->user->creer = 1;
1316 $user->rights->user->user->password = 1;
1317 $user->rights->user->user->supprimer = 1;
1318 $user->rights->user->self->creer = 1;
1319 $user->rights->user->self->password = 1;
1323 if (!$user->hasRight(
'user',
'user_advance')) {
1324 $user->rights->user->user_advance =
new stdClass();
1326 if (!$user->hasRight(
'user',
'self_advance')) {
1327 $user->rights->user->self_advance =
new stdClass();
1329 if (!$user->hasRight(
'user',
'group_advance')) {
1330 $user->rights->user->group_advance =
new stdClass();
1333 $user->rights->user->user_advance->readperms = 1;
1334 $user->rights->user->user_advance->write = 1;
1335 $user->rights->user->self_advance->readperms = 1;
1336 $user->rights->user->self_advance->writeperms = 1;
1337 $user->rights->user->group_advance->read = 1;
1338 $user->rights->user->group_advance->readperms = 1;
1339 $user->rights->user->group_advance->write = 1;
1340 $user->rights->user->group_advance->delete = 1;
1349 if (isset($user->conf->MAIN_SIZE_LISTE_LIMIT)) {
1350 $conf->liste_limit =
getDolUserInt(
'MAIN_SIZE_LISTE_LIMIT');
1352 if ((
int) $conf->liste_limit <= 0) {
1354 $conf->liste_limit = 15;
1355 if (!empty($_SESSION[
'dol_screenheight']) && $_SESSION[
'dol_screenheight'] < 910) {
1356 $conf->liste_limit = 10;
1357 } elseif (!empty($_SESSION[
'dol_screenheight']) && $_SESSION[
'dol_screenheight'] > 1130) {
1358 $conf->liste_limit = 20;
1362 if (isset($user->conf->MAIN_CHECKBOX_LEFT_COLUMN)) {
1363 $conf->main_checkbox_left_column =
getDolUserInt(
'MAIN_CHECKBOX_LEFT_COLUMN');
1369 $conf->css =
"/theme/".$conf->theme.
"/style.css.php";
1373 if (!empty($user) && method_exists($user,
'loadDefaultValues') && !defined(
'NODEFAULTVALUES')) {
1374 $user->loadDefaultValues();
1380if (
GETPOST(
'theme',
'aZ09')) {
1381 $conf->theme =
GETPOST(
'theme',
'aZ09', 1);
1382 $conf->css =
"/theme/".$conf->theme.
"/style.css.php";
1387 $conf->use_javascript_ajax = 0;
1396 $conf->global->MAIN_OPTIMIZEFORTEXTBROWSER =
getDolUserString(
'MAIN_OPTIMIZEFORTEXTBROWSER');
1398 $conf->global->THEME_TOPMENU_DISABLE_IMAGE = 1;
1405$conf->global->MAIN_OPTIMIZEFORCOLORBLIND =
getDolUserString(
'MAIN_OPTIMIZEFORCOLORBLIND');
1408if (
GETPOSTINT(
'dol_hide_leftmenu') || !empty($_SESSION[
'dol_hide_leftmenu'])) {
1409 $conf->dol_hide_leftmenu = 1;
1411if (
GETPOSTINT(
'dol_hide_topmenu') || !empty($_SESSION[
'dol_hide_topmenu'])) {
1412 $conf->dol_hide_topmenu = 1;
1414if (
GETPOSTINT(
'dol_optimize_smallscreen') || !empty($_SESSION[
'dol_optimize_smallscreen'])) {
1415 $conf->dol_optimize_smallscreen = 1;
1417if (
GETPOSTINT(
'dol_no_mouse_hover') || !empty($_SESSION[
'dol_no_mouse_hover'])) {
1418 $conf->dol_no_mouse_hover = 1;
1420if (
GETPOSTINT(
'dol_use_jmobile') || !empty($_SESSION[
'dol_use_jmobile'])) {
1421 $conf->dol_use_jmobile = 1;
1424if (!empty($conf->browser->layout) && $conf->browser->layout !=
'classic') {
1425 $conf->dol_no_mouse_hover = 1;
1429if ((!empty($conf->browser->layout) && $conf->browser->layout ==
'phone')
1430 || (!empty($_SESSION[
'dol_screenwidth']) && $_SESSION[
'dol_screenwidth'] < 400)
1431 || (!empty($_SESSION[
'dol_screenheight']) && $_SESSION[
'dol_screenheight'] < 400
1434 $conf->dol_optimize_smallscreen = 1;
1437 $conf->global->PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE = 0;
1441if (!empty($conf->dol_use_jmobile) && in_array($conf->theme, array(
'bureau2crea',
'cameleo',
'amarok'))) {
1442 $conf->theme =
'eldy';
1443 $conf->css =
"/theme/".$conf->theme.
"/style.css.php";
1446if (!defined(
'NOREQUIRETRAN')) {
1447 if (!
GETPOST(
'lang',
'aZ09')) {
1449 if (!empty($user->conf->MAIN_LANG_DEFAULT)) {
1452 if ($langs->getDefaultLang() != $user->conf->MAIN_LANG_DEFAULT) {
1453 $langs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT);
1459if (!defined(
'NOLOGIN')) {
1462 if (!$user->login) {
1467 if ($user->statut < 1) {
1469 $langs->loadLangs(array(
"errors",
"other"));
1470 dol_syslog(
"Authentication KO as login is disabled", LOG_NOTICE);
1475 $user->loadRights();
1478dol_syslog(
"--- Access to ".(empty($_SERVER[
"REQUEST_METHOD"]) ?
'' : $_SERVER[
"REQUEST_METHOD"].
' ').$_SERVER[
"PHP_SELF"].
' - action='.
GETPOST(
'action',
'aZ09').
', massaction='.
GETPOST(
'massaction',
'aZ09').(defined(
'NOTOKENRENEWAL') ?
' NOTOKENRENEWAL='.constant(
'NOTOKENRENEWAL') :
''), LOG_NOTICE);
1483if (!defined(
'NOREQUIRETRAN')) {
1485 $langs->loadLangs(array(
'main',
'dict'));
1489$bc = array(0 =>
'class="impair"', 1 =>
'class="pair"');
1490$bcdd = array(0 =>
'class="drag drop oddeven"', 1 =>
'class="drag drop oddeven"');
1491$bcnd = array(0 =>
'class="nodrag nodrop nohover"', 1 =>
'class="nodrag nodrop nohoverpair"');
1492$bctag = array(0 =>
'class="impair tagtr"', 1 =>
'class="pair tagtr"');
1504if (empty($conf->browser->firefox)) {
1505 define(
'ROWS_1', 1);
1506 define(
'ROWS_2', 2);
1507 define(
'ROWS_3', 3);
1508 define(
'ROWS_4', 4);
1509 define(
'ROWS_5', 5);
1510 define(
'ROWS_6', 6);
1511 define(
'ROWS_7', 7);
1512 define(
'ROWS_8', 8);
1513 define(
'ROWS_9', 9);
1515 define(
'ROWS_1', 0);
1516 define(
'ROWS_2', 1);
1517 define(
'ROWS_3', 2);
1518 define(
'ROWS_4', 3);
1519 define(
'ROWS_5', 4);
1520 define(
'ROWS_6', 5);
1521 define(
'ROWS_7', 6);
1522 define(
'ROWS_8', 7);
1523 define(
'ROWS_9', 8);
1526$heightforframes = 50;
1529if (!defined(
'NOREQUIREMENU')) {
1530 if (empty($user->socid)) {
1538 $file_menu = $conf->standard_menu;
1539 if (
GETPOST(
'menu',
'alpha')) {
1540 $file_menu =
GETPOST(
'menu',
'alpha');
1543 if (!class_exists(
'MenuManager')) {
1545 $dirmenus = array_merge(array(
"/core/menus/"), (array) $conf->modules_parts[
'menus']);
1546 foreach ($dirmenus as $dirmenu) {
1548 if (class_exists(
'MenuManager')) {
1552 if (!class_exists(
'MenuManager')) {
1553 dol_syslog(
"You define a menu manager '".$file_menu.
"' that can not be loaded.", LOG_WARNING);
1554 $file_menu =
'eldy_menu.php';
1555 include_once DOL_DOCUMENT_ROOT.
"/core/menus/standard/".$file_menu;
1559 $menumanager =
new MenuManager($db, empty($user->socid) ? 0 : 1);
1564if (!empty(
GETPOST(
'seteventmessages',
'alpha'))) {
1565 $message =
GETPOST(
'seteventmessages',
'alpha');
1566 $messages = explode(
',', $message);
1567 foreach ($messages as $key => $msg) {
1568 $tmp = explode(
':', $msg);
1575if (!function_exists(
"llxHeader")) {
1597 function llxHeader($head =
'', $title =
'', $help_url =
'', $target =
'', $disablejs = 0, $disablehead = 0, $arrayofjs =
'', $arrayofcss =
'', $morequerystring =
'', $morecssonbody =
'', $replacemainareaby =
'', $disablenofollow = 0, $disablenoindex = 0)
1599 global $conf, $hookmanager;
1601 $parameters = array(
1603 'title' => & $title,
1604 'help_url' => & $help_url,
1605 'target' => & $target,
1606 'disablejs' => & $disablejs,
1607 'disablehead' => & $disablehead,
1608 'arrayofjs' => & $arrayofjs,
1609 'arrayofcss' => & $arrayofcss,
1610 'morequerystring' => & $morequerystring,
1611 'morecssonbody' => & $morecssonbody,
1612 'replacemainareaby' => & $replacemainareaby,
1613 'disablenofollow' => & $disablenofollow,
1614 'disablenoindex' => & $disablenoindex
1617 $reshook = $hookmanager->executeHooks(
'llxHeader', $parameters);
1619 print $hookmanager->resPrint;
1624 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss, 0, $disablenofollow, $disablenoindex);
1626 $tmpcsstouse =
'sidebar-collapse'.($morecssonbody ?
' '.$morecssonbody :
'');
1628 if ($conf->theme ==
'md' && !in_array($conf->browser->layout, array(
'phone',
'tablet')) && !
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER')) {
1630 if ($mainmenu !=
'website') {
1631 $tmpcsstouse = $morecssonbody;
1636 $tmpcsstouse .=
' colorblind-'.strip_tags(
getDolGlobalString(
'MAIN_OPTIMIZEFORCOLORBLIND'));
1639 print
'<body id="mainbody" class="'.$tmpcsstouse.
'">'.
"\n";
1642 if ((empty($conf->dol_hide_topmenu) ||
GETPOSTINT(
'dol_invisible_topmenu')) && !
GETPOST(
'dol_openinpopup',
'aZ09')) {
1643 top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring, $help_url);
1646 if (empty($conf->dol_hide_leftmenu) && !
GETPOST(
'dol_openinpopup',
'aZ09')) {
1647 left_menu(
'', $help_url,
'', array(), 1, $title, 1);
1651 if ($replacemainareaby) {
1652 print $replacemainareaby;
1807function top_htmlhead($head, $title =
'', $disablejs = 0, $disablehead = 0, $arrayofjs = array(), $arrayofcss = array(), $disableforlogin = 0, $disablenofollow = 0, $disablenoindex = 0)
1809 global $db, $conf, $langs, $user, $mysoc, $hookmanager;
1813 if (empty($conf->css)) {
1814 $conf->css =
'/theme/eldy/style.css.php';
1817 print
'<!doctype html>'.
"\n";
1819 print
'<html lang="'.substr($langs->defaultlang, 0, 2).
'">'.
"\n";
1822 if (empty($disablehead)) {
1823 if (!is_object($hookmanager)) {
1824 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
1827 $hookmanager->initHooks(array(
"main"));
1829 $ext =
'layout='.(empty($conf->browser->layout) ?
'' : $conf->browser->layout).
'&version='.urlencode(DOL_VERSION);
1833 if (
GETPOST(
'dol_basehref',
'alpha')) {
1834 print
'<base href="'.dol_escape_htmltag(
GETPOST(
'dol_basehref',
'alpha')).
'">'.
"\n";
1838 print
'<meta charset="utf-8">'.
"\n";
1839 print
'<meta name="robots" content="'.($disablenoindex ?
'index' :
'noindex').($disablenofollow ?
',follow' :
',nofollow').
'">'.
"\n";
1840 print
'<meta name="viewport" content="width=device-width, initial-scale=1.0">'.
"\n";
1841 print
'<meta name="author" content="Dolibarr Development Team">'.
"\n";
1842 print
'<meta name="anti-csrf-newtoken" content="'.newToken().
'">'.
"\n";
1843 print
'<meta name="anti-csrf-currenttoken" content="'.currentToken().
'">'.
"\n";
1845 print
'<meta name="MAIN_FEATURES_LEVEL" content="'.getDolGlobalInt(
'MAIN_FEATURES_LEVEL').
'">'.
"\n";
1848 $favicon = DOL_URL_ROOT.
'/theme/dolibarr_256x256_color.png';
1849 $appletouchicon = DOL_URL_ROOT.
'/theme/apple-touch-icon.png';
1850 if (!empty($mysoc->logo_squarred_mini)) {
1851 $favicon = DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/thumbs/'.$mysoc->logo_squarred_mini);
1856 if (empty($conf->dol_use_jmobile)) {
1857 print
'<link rel="shortcut icon" type="image/x-icon" href="'.$favicon.
'"/>'.
"\n";
1858 print
'<link rel="apple-touch-icon" href="'.$appletouchicon.
'"/>'.
"\n";
1862 $manifest = DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/manifest.json.php';
1863 $parameters = array(
'manifest' => $manifest);
1864 $resHook = $hookmanager->executeHooks(
'hookSetManifest', $parameters);
1866 $manifest = $hookmanager->resPrint;
1868 $manifest .= $hookmanager->resPrint;
1870 if (!empty($manifest)) {
1871 print
'<link rel="manifest" href="'.$manifest.
'" />'.
"\n";
1876 print
'<meta name="theme-color" content="rgb(' .
getDolGlobalString(
'THEME_ELDY_TOPMENU_BACK1').
')">'.
"\n";
1881 print
'<meta http-equiv="refresh" content="'.GETPOSTINT(
'autorefresh').
'">';
1885 $appli = constant(
'DOL_APPLICATION_TITLE');
1900 $parameters = array(
'title' => $titletoshow);
1901 $result = $hookmanager->executeHooks(
'setHtmlTitle', $parameters);
1903 $titletoshow = $hookmanager->resPrint;
1905 $titletoshow .= $hookmanager->resPrint;
1914 $ext =
'version='.GETPOSTINT(
'version');
1917 if (
GETPOST(
'dol_resetcache')) {
1918 include_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
1922 $themeparam =
'?lang='.$langs->defaultlang.
'&theme='.$conf->theme.(GETPOST(
'optioncss',
'aZ09') ?
'&optioncss='.GETPOST(
'optioncss',
'aZ09', 1) :
'').(empty($user->id) ?
'' : (
'&userid='.$user->id)).
'&entity='.$conf->entity;
1924 $themeparam .= ($ext ?
'&'.$ext :
'').
'&revision='.
getDolGlobalInt(
"MAIN_IHM_PARAMS_REV");
1925 if (GETPOSTISSET(
'dol_hide_topmenu')) {
1926 $themeparam .=
'&dol_hide_topmenu='.GETPOSTINT(
'dol_hide_topmenu');
1928 if (GETPOSTISSET(
'dol_hide_leftmenu')) {
1929 $themeparam .=
'&dol_hide_leftmenu='.GETPOSTINT(
'dol_hide_leftmenu');
1931 if (GETPOSTISSET(
'dol_openinpopup')) {
1932 $themeparam .=
'&dol_openinpopup='.GETPOST(
'dol_openinpopup',
'aZ09');
1934 if (GETPOSTISSET(
'dol_optimize_smallscreen')) {
1935 $themeparam .=
'&dol_optimize_smallscreen='.GETPOSTINT(
'dol_optimize_smallscreen');
1937 if (GETPOSTISSET(
'dol_no_mouse_hover')) {
1938 $themeparam .=
'&dol_no_mouse_hover='.GETPOSTINT(
'dol_no_mouse_hover');
1940 if (GETPOSTISSET(
'dol_use_jmobile')) {
1941 $themeparam .=
'&dol_use_jmobile='.GETPOSTINT(
'dol_use_jmobile');
1942 $conf->dol_use_jmobile =
GETPOSTINT(
'dol_use_jmobile');
1944 if (GETPOSTISSET(
'THEME_DARKMODEENABLED')) {
1945 $themeparam .=
'&THEME_DARKMODEENABLED='.GETPOSTINT(
'THEME_DARKMODEENABLED');
1947 if (GETPOSTISSET(
'THEME_SATURATE_RATIO')) {
1948 $themeparam .=
'&THEME_SATURATE_RATIO='.GETPOSTINT(
'THEME_SATURATE_RATIO');
1952 print
'<link rel="preconnect" href="https://fonts.gstatic.com">'.
"\n";
1953 print
'<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@200;300;400;500;600&display=swap" rel="stylesheet">'.
"\n";
1956 if (!defined(
'DISABLE_JQUERY') && !$disablejs && $conf->use_javascript_ajax) {
1957 print
'<!-- Includes CSS for JQuery (Ajax library) -->'.
"\n";
1958 $jquerytheme =
'base';
1962 if (constant(
'JS_JQUERY_UI')) {
1963 print
'<link rel="stylesheet" type="text/css" href="'.JS_JQUERY_UI.
'css/'.$jquerytheme.
'/jquery-ui.min.css'.($ext ?
'?'.$ext :
'').
'">'.
"\n";
1965 print
'<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.
'/includes/jquery/css/'.$jquerytheme.
'/jquery-ui.css'.($ext ?
'?'.$ext :
'').
'">'.
"\n";
1967 if (!defined(
'DISABLE_JQUERY_JNOTIFY')) {
1968 print
'<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jnotify/jquery.jnotify-alt.min.css'.($ext ?
'?'.$ext :
'').
'">'.
"\n";
1970 if (!defined(
'DISABLE_SELECT2') && (
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') || defined(
'REQUIRE_JQUERY_MULTISELECT'))) {
1971 $tmpplugin = !
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') ? constant(
'REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
1972 print
'<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.
'/includes/jquery/plugins/'.$tmpplugin.
'/dist/css/'.$tmpplugin.
'.css'.($ext ?
'?'.$ext :
'').
'">'.
"\n";
1976 if (!defined(
'DISABLE_FONT_AWSOME')) {
1977 print
'<!-- Includes CSS for font awesome -->'.
"\n";
1978 $fontawesome_directory =
getDolGlobalString(
'MAIN_FONTAWESOME_DIRECTORY',
'/theme/common/fontawesome-5');
1979 print
'<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.$fontawesome_directory.
'/css/all.min.css'.($ext ?
'?'.$ext :
'').
'">'.
"\n";
1982 print
'<!-- Includes CSS for Dolibarr theme -->'.
"\n";
1986 if (!empty($conf->modules_parts[
'theme'])) {
1987 foreach ($conf->modules_parts[
'theme'] as $reldir) {
1990 $themesubdir = $reldir;
1997 print
'<link rel="stylesheet" type="text/css" href="'.$themepath.$themeparam.
'">'.
"\n";
1999 print
'<!-- Includes CSS that does not exists as a workaround of flash bug of chrome -->'.
"\n".
'<link rel="stylesheet" type="text/css" href="filethatdoesnotexiststosolvechromeflashbug">'.
"\n";
2004 print
'<link rel="stylesheet" href="'.DOL_URL_ROOT.
'/includes/leaflet/leaflet.css'.($ext ?
'?'.$ext :
'').
"\">\n";
2005 print
'<link rel="stylesheet" href="'.DOL_URL_ROOT.
'/includes/leaflet/leaflet-geoman.css'.($ext ?
'?'.$ext :
'').
"\">\n";
2009 if (!empty($conf->modules_parts[
'css'])) {
2010 $arraycss = (array) $conf->modules_parts[
'css'];
2011 foreach ($arraycss as $modcss => $filescss) {
2012 $filescss = (array) $filescss;
2013 foreach ($filescss as $cssfile) {
2014 if (empty($cssfile)) {
2015 dol_syslog(
"Warning: module ".$modcss.
" declared a css path file into its descriptor that is empty.", LOG_WARNING);
2019 if ($urlforcss && $urlforcss !=
'/') {
2020 print
'<!-- Includes CSS added by module '.$modcss.
' -->'.
"\n".
'<link rel="stylesheet" type="text/css" href="'.$urlforcss;
2022 if (!preg_match(
'/\.css$/i', $cssfile)) {
2027 dol_syslog(
"Warning: module ".$modcss.
" declared a css path file for a file we can't find.", LOG_WARNING);
2033 if (is_array($arrayofcss)) {
2034 foreach ($arrayofcss as $cssfile) {
2035 if (preg_match(
'/^(http|\/\/)/i', $cssfile)) {
2036 $urltofile = $cssfile;
2040 print
'<!-- Includes CSS added by page -->'.
"\n".
'<link rel="stylesheet" type="text/css" title="default" href="'.$urltofile;
2042 if (!preg_match(
'/\.css$/i', $cssfile)) {
2052 print
'<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.
'/theme/custom.css.php'.($ext ?
'?'.$ext :
'').
'&revision='.
getDolGlobalInt(
"MAIN_IHM_PARAMS_REV").
'">'.
"\n";
2056 if (!defined(
'DISABLE_JQUERY') && !$disablejs && !empty($conf->use_javascript_ajax)) {
2058 print
'<!-- Includes JS for JQuery -->'.
"\n";
2059 if (defined(
'JS_JQUERY') && constant(
'JS_JQUERY')) {
2060 print
'<script nonce="'.getNonce().
'" src="'.JS_JQUERY.
'jquery.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2062 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/js/jquery.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2064 if (defined(
'JS_JQUERY_UI') && constant(
'JS_JQUERY_UI')) {
2065 print
'<script nonce="'.getNonce().
'" src="'.JS_JQUERY_UI.
'jquery-ui.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2067 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/js/jquery-ui.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2070 if (!
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') && !defined(
'DISABLE_JQUERY_JNOTIFY')) {
2071 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jnotify/jquery.jnotify.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2074 if (empty($disableforlogin) && !defined(
'DISABLE_JQUERY_TABLEDND')) {
2075 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/tablednd/jquery.tablednd.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2079 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/nnnick/chartjs/dist/chart.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2083 if (
getDolGlobalString(
'MAIN_USE_JQUERY_JEDITABLE') && !defined(
'DISABLE_JQUERY_JEDITABLE')) {
2084 print
'<!-- JS to manage editInPlace feature -->'.
"\n";
2085 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jeditable/jquery.jeditable.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2086 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jeditable/jquery.jeditable.ui-datepicker.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2087 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jeditable/jquery.jeditable.ui-autocomplete.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2088 print
'<script>'.
"\n";
2089 print
'var urlSaveInPlace = \''.DOL_URL_ROOT.
'/core/ajax/saveinplace.php\';'.
"\n";
2090 print
'var urlLoadInPlace = \''.DOL_URL_ROOT.
'/core/ajax/loadinplace.php\';'.
"\n";
2091 print
'var tooltipInPlace = \''.$langs->transnoentities(
'ClickToEdit').
'\';
'."\n"; // Added in title attribute of span
2092 print 'var placeholderInPlace = \
' \';'.
"\n";
2093 print
'var cancelInPlace = \''.$langs->trans(
"Cancel").
'\';
'."\n";
2094 print 'var submitInPlace = \
''.$langs->trans(
'Ok').
'\';
'."\n";
2095 print 'var indicatorInPlace = \
'<img src="'.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'">\';'.
"\n";
2096 print
'var withInPlace = 300;';
2097 print
'</script>'.
"\n";
2098 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/core/js/editinplace.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2099 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jeditable/jquery.jeditable.ckeditor.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2102 if (
getDolGlobalString(
'MAIN_USE_JQUERY_TIMEPICKER') || defined(
'REQUIRE_JQUERY_TIMEPICKER')) {
2103 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2104 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/core/js/timepicker.js.php?lang='.$langs->defaultlang.($ext ?
'&'.$ext :
'').
'"></script>'.
"\n";
2106 if (!defined(
'DISABLE_SELECT2') && (
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') || defined(
'REQUIRE_JQUERY_MULTISELECT'))) {
2108 $tmpplugin = !
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') ? constant(
'REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
2109 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/'.$tmpplugin.
'/dist/js/'.$tmpplugin.
'.full.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2111 if (!defined(
'DISABLE_MULTISELECT')) {
2112 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/multiselect/jquery.multi-select.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2116 if (!$disablejs && !empty($conf->use_javascript_ajax)) {
2118 if (empty($disableforlogin) && (isModEnabled(
'fckeditor') && (!
getDolGlobalString(
'FCKEDITOR_EDITORNAME') ||
getDolGlobalString(
'FCKEDITOR_EDITORNAME') ==
'ckeditor') && !defined(
'DISABLE_CKEDITOR')) || defined(
'FORCE_CKEDITOR')) {
2119 print
'<!-- Includes JS for CKEditor -->'.
"\n";
2120 $pathckeditor = DOL_URL_ROOT.
'/includes/ckeditor/ckeditor/';
2121 $jsckeditor =
'ckeditor.js';
2122 if (constant(
'JS_CKEDITOR')) {
2124 $pathckeditor = constant(
'JS_CKEDITOR');
2126 print
'<script nonce="'.getNonce().
'">';
2127 print
'/* enable ckeditor by main.inc.php */';
2128 print
'var CKEDITOR_BASEPATH = \''.dol_escape_js($pathckeditor).
'\';
'."\n";
2129 print 'var ckeditorConfig = \
''.dol_escape_js(
dol_buildpath($themesubdir.
'/theme/'.$conf->theme.
'/ckeditor/config.js'.($ext ?
'?'.$ext :
''), 1)).
'\';
'."\n"; // $themesubdir='' in standard usage
2130 print 'var ckeditorFilebrowserBrowseUrl = \
''.DOL_URL_ROOT.
'/core/filemanagerdol/browser/default/browser.php?Connector='.DOL_URL_ROOT.
'/core/filemanagerdol/connectors/php/connector.php\';'.
"\n";
2131 print
'var ckeditorFilebrowserImageBrowseUrl = \''.DOL_URL_ROOT.
'/core/filemanagerdol/browser/default/browser.php?Type=Image&Connector='.DOL_URL_ROOT.
'/core/filemanagerdol/connectors/php/connector.php\';'.
"\n";
2132 print
'</script>'.
"\n";
2133 print
'<script src="'.$pathckeditor.$jsckeditor.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2135 if (
GETPOST(
'mode',
'aZ09') ==
'Full_inline') {
2136 print
'CKEDITOR.disableAutoInline = false;'.
"\n";
2138 print
'CKEDITOR.disableAutoInline = true;'.
"\n";
2140 print
'</script>'.
"\n";
2144 if (!defined(
'NOBROWSERNOTIF') && !defined(
'NOREQUIREMENU') && !defined(
'NOLOGIN')) {
2145 $enablebrowsernotif =
false;
2147 $enablebrowsernotif =
true;
2149 if ($conf->browser->layout ==
'phone') {
2150 $enablebrowsernotif =
false;
2152 if ($enablebrowsernotif) {
2153 print
'<!-- Includes JS of Dolibarr (browser layout = '.$conf->browser->layout.
')-->'.
"\n";
2154 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/core/js/lib_notification.js.php?lang='.$langs->defaultlang.($ext ?
'&'.$ext :
'').
'"></script>'.
"\n";
2159 print
'<!-- Includes JS of Dolibarr -->'.
"\n";
2160 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/core/js/lib_head.js.php?lang='.$langs->defaultlang.($ext ?
'&'.$ext :
'').
'"></script>'.
"\n";
2164 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/leaflet/leaflet.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2165 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/leaflet/leaflet-geoman.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2169 if (!empty($conf->modules_parts[
'js'])) {
2170 $arrayjs = (array) $conf->modules_parts[
'js'];
2171 foreach ($arrayjs as $modjs => $filesjs) {
2172 $filesjs = (array) $filesjs;
2173 foreach ($filesjs as $jsfile) {
2176 if ($urlforjs && $urlforjs !=
'/') {
2177 print
'<!-- Include JS added by module '.$modjs.
'-->'.
"\n";
2178 print
'<script nonce="'.getNonce().
'" src="'.$urlforjs.((strpos($jsfile,
'?') ===
false) ?
'?' :
'&').
'lang='.$langs->defaultlang.
'"></script>'.
"\n";
2180 dol_syslog(
"Warning: module ".$modjs.
" declared a js path file for a file we can't find.", LOG_WARNING);
2186 if (is_array($arrayofjs)) {
2187 print
'<!-- Includes JS added by page -->'.
"\n";
2188 foreach ($arrayofjs as $jsfile) {
2189 if (preg_match(
'/^(http|\/\/)/i', $jsfile)) {
2190 print
'<script nonce="'.getNonce().
'" src="'.$jsfile.((strpos($jsfile,
'?') ===
false) ?
'?' :
'&').
'lang='.$langs->defaultlang.
'"></script>'.
"\n";
2192 print
'<script nonce="'.getNonce().
'" src="'.
dol_buildpath($jsfile, 1).((strpos($jsfile,
'?') ===
false) ?
'?' :
'&').
'lang='.$langs->defaultlang.
'"></script>'.
"\n";
2200 $theme_js =
dol_buildpath(
'/theme/'.$conf->theme.
'/'.$conf->theme.
'.js', 0);
2201 if (file_exists($theme_js)) {
2202 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/'.$conf->theme.
'.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2206 if (!empty($head)) {
2213 $parameters = array();
2214 $result = $hookmanager->executeHooks(
'addHtmlHeader', $parameters);
2215 print $hookmanager->resPrint;
2217 print
"</head>\n\n";
2220 $conf->headerdone = 1;
3387function left_menu($menu_array_before, $helppagename =
'', $notused =
'', $menu_array_after = array(), $leftmenuwithoutmainarea = 0, $title =
'', $acceptdelayedhtml = 0)
3389 global $user, $conf, $langs, $db, $form;
3390 global $hookmanager, $menumanager;
3394 if (!empty($menu_array_before)) {
3395 dol_syslog(
"Deprecated parameter menu_array_before was used when calling main::left_menu function. Menu entries of module should now be defined into module descriptor and not provided when calling left_menu.", LOG_WARNING);
3398 if (empty($conf->dol_hide_leftmenu) && (!defined(
'NOREQUIREMENU') || !constant(
'NOREQUIREMENU'))) {
3400 $hookmanager->initHooks(array(
'leftblock'));
3402 print
"\n".
'<!-- Begin side-nav id-left -->'.
"\n".
'<div class="side-nav"><div id="id-left">'.
"\n";
3405 if (!is_object($form)) {
3406 $form =
new Form($db);
3411 if ($conf->browser->layout ==
'phone') {
3412 $conf->global->MAIN_USE_OLD_SEARCH_FORM = 1;
3416 $arrayresult = array();
3417 include DOL_DOCUMENT_ROOT.
'/core/ajax/selectsearchbox.php';
3422 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
3423 if ($conf->browser->name ==
'chrome') {
3424 $stringforfirstkey .=
' ALT +';
3425 } elseif ($conf->browser->name ==
'firefox') {
3426 $stringforfirstkey .=
' ALT + SHIFT +';
3428 $stringforfirstkey .=
' CTL +';
3432 $textsearch =
'<span class="fa fa-search paddingright pictofixedwidth"></span>'.$langs->trans(
"Search");
3433 $searchform .= $form->selectArrayFilter(
'searchselectcombo', $arrayresult, $selected,
'accesskey="s"', 1, 0, (
getDolGlobalString(
'MAIN_SEARCHBOX_CONTENT_LOADED_BEFORE_KEY') ? 0 : 1),
'vmenusearchselectcombo', 1, $textsearch, 1, $stringforfirstkey.
' s');
3435 if (is_array($arrayresult)) {
3437 foreach ($arrayresult as $key => $val) {
3438 $searchform .=
printSearchForm($val[
'url'], $val[
'url'], $val[
'label'],
'maxwidth125',
'search_all', (empty($val[
'shortcut']) ?
'' : $val[
'shortcut']),
'searchleft'.$key, $val[
'img']);
3444 $parameters = array(
'searchform' => $searchform);
3445 $reshook = $hookmanager->executeHooks(
'printSearchForm', $parameters);
3446 if (empty($reshook)) {
3447 $searchform .= $hookmanager->resPrint;
3449 $searchform = $hookmanager->resPrint;
3453 if (
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') || empty($conf->use_javascript_ajax)) {
3454 $urltosearch = DOL_URL_ROOT.
'/core/search_page.php?showtitlebefore=1';
3455 $searchform =
'<div class="blockvmenuimpair blockvmenusearchphone"><div id="divsearchforms1"><a href="'.$urltosearch.
'" accesskey="s" alt="'.
dol_escape_htmltag($langs->trans(
"ShowSearchFields")).
'">'.$langs->trans(
"Search").
'...</a></div></div>';
3456 } elseif ($conf->use_javascript_ajax &&
getDolGlobalString(
'MAIN_USE_OLD_SEARCH_FORM')) {
3457 $searchform =
'<div class="blockvmenuimpair blockvmenusearchphone"><div id="divsearchforms1"><a href="#" alt="'.dol_escape_htmltag($langs->trans(
"ShowSearchFields")).
'">'.$langs->trans(
"Search").
'...</a></div><div id="divsearchforms2" style="display: none">'.$searchform.
'</div>';
3458 $searchform .=
'<script>
3459 jQuery(document).ready(function () {
3460 jQuery("#divsearchforms1").click(function(){
3461 jQuery("#divsearchforms2").toggle();
3465 $searchform .=
'</div>';
3469 $searchform .=
'<script>
3470 jQuery(document).keydown(function(e){
3471 if( e.which === 70 && e.ctrlKey && e.shiftKey ){
3472 console.log(\'control + shift + f : trigger open global-search dropdown\');
3473 openGlobalSearchDropDown();
3475 if( (e.which === 83 || e.which === 115) && e.altKey ){
3476 console.log(\'alt + s : trigger open global-search dropdown\');
3477 openGlobalSearchDropDown();
3481 var openGlobalSearchDropDown = function() {
3482 jQuery("#searchselectcombo").select2(\'open\');
3488 print
'<!-- Begin left menu -->'.
"\n";
3490 print
'<div class="vmenu"'.(getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
' alt="Left menu"' :
'').
'>'.
"\n\n";
3494 $menumanager->menu_array = $menu_array_before;
3496 $menumanager->menu_array_after = $menu_array_after;
3499 $menumanager->showmenu(
'leftdropdown', array(
'searchform' => $searchform));
3502 $menumanager->showmenu(
'left', array(
'searchform' => $searchform));
3507 print
"<!-- Begin Help Block-->\n";
3508 print
'<div id="blockvmenuhelp" class="blockvmenuhelp">'.
"\n";
3512 $doliurl =
'https://www.dolibarr.org';
3514 if (preg_match(
'/fr/i', $langs->defaultlang)) {
3515 $doliurl =
'https://www.dolibarr.fr';
3517 if (preg_match(
'/es/i', $langs->defaultlang)) {
3518 $doliurl =
'https://www.dolibarr.es';
3520 if (preg_match(
'/de/i', $langs->defaultlang)) {
3521 $doliurl =
'https://www.dolibarr.de';
3523 if (preg_match(
'/it/i', $langs->defaultlang)) {
3524 $doliurl =
'https://www.dolibarr.it';
3526 if (preg_match(
'/gr/i', $langs->defaultlang)) {
3527 $doliurl =
'https://www.dolibarr.gr';
3530 $appli = constant(
'DOL_APPLICATION_TITLE');
3534 if (preg_match(
'/\d\.\d/', $appli)) {
3535 if (!preg_match(
'/'.preg_quote(DOL_VERSION).
'/', $appli)) {
3536 $appli .=
" (".DOL_VERSION.
")";
3539 $appli .=
" ".DOL_VERSION;
3542 $appli .=
" ".DOL_VERSION;
3544 print
'<div id="blockvmenuhelpapp" class="blockvmenuhelp">';
3546 print
'<a class="help" target="_blank" rel="noopener noreferrer" href="'.$doliurl.
'">';
3548 print
'<span class="help">';
3556 print
'</div>'.
"\n";
3561 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
3564 $bugbaseurl =
'https://github.com/Dolibarr/dolibarr/issues/new?labels=Bug';
3565 $bugbaseurl .=
'&title=';
3566 $bugbaseurl .= urlencode(
"Bug: ");
3567 $bugbaseurl .=
'&body=';
3568 $bugbaseurl .= urlencode(
"# Instructions\n");
3569 $bugbaseurl .= urlencode(
"*This is a template to help you report good issues. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.*\n");
3570 $bugbaseurl .= urlencode(
"*Please:*\n");
3571 $bugbaseurl .= urlencode(
"- *replace the bracket enclosed texts with meaningful information*\n");
3572 $bugbaseurl .= urlencode(
"- *remove any unused sub-section*\n");
3573 $bugbaseurl .= urlencode(
"\n");
3574 $bugbaseurl .= urlencode(
"\n");
3575 $bugbaseurl .= urlencode(
"# Bug\n");
3576 $bugbaseurl .= urlencode(
"[*Short description*]\n");
3577 $bugbaseurl .= urlencode(
"\n");
3578 $bugbaseurl .= urlencode(
"## Environment\n");
3579 $bugbaseurl .= urlencode(
"- **Version**: ".DOL_VERSION.
"\n");
3580 $bugbaseurl .= urlencode(
"- **OS**: ".php_uname(
's').
"\n");
3581 $bugbaseurl .= urlencode(
"- **Web server**: ".$_SERVER[
"SERVER_SOFTWARE"].
"\n");
3582 $bugbaseurl .= urlencode(
"- **PHP**: ".php_sapi_name().
' '.phpversion().
"\n");
3583 $bugbaseurl .= urlencode(
"- **Database**: ".$db::LABEL.
' '.$db->getVersion().
"\n");
3584 $bugbaseurl .= urlencode(
"- **URL(s)**: ".$_SERVER[
"REQUEST_URI"].
"\n");
3585 $bugbaseurl .= urlencode(
"\n");
3586 $bugbaseurl .= urlencode(
"## Expected and actual behavior\n");
3587 $bugbaseurl .= urlencode(
"[*Verbose description*]\n");
3588 $bugbaseurl .= urlencode(
"\n");
3589 $bugbaseurl .= urlencode(
"## Steps to reproduce the behavior\n");
3590 $bugbaseurl .= urlencode(
"[*Verbose description*]\n");
3591 $bugbaseurl .= urlencode(
"\n");
3592 $bugbaseurl .= urlencode(
"## [Attached files](https://help.github.com/articles/issue-attachments) (Screenshots, screencasts, dolibarr.log, debugging information…)\n");
3593 $bugbaseurl .= urlencode(
"[*Files*]\n");
3594 $bugbaseurl .= urlencode(
"\n");
3596 $bugbaseurl .= urlencode(
"\n");
3597 $bugbaseurl .= urlencode(
"## Report\n");
3605 $parameters = array(
'bugbaseurl' => $bugbaseurl);
3606 $reshook = $hookmanager->executeHooks(
'printBugtrackInfo', $parameters);
3607 if (empty($reshook)) {
3608 $bugbaseurl .= $hookmanager->resPrint;
3610 $bugbaseurl = $hookmanager->resPrint;
3613 print
'<div id="blockvmenuhelpbugreport" class="blockvmenuhelp">';
3614 print
'<a class="help" target="_blank" rel="noopener noreferrer" href="'.$bugbaseurl.
'"><i class="fas fa-bug"></i> '.$langs->trans(
"FindBug").
'</a>';
3619 print
"<!-- End Help Block-->\n";
3623 print
"<!-- End left menu -->\n";
3627 $parameters = array();
3628 $reshook = $hookmanager->executeHooks(
'printLeftBlock', $parameters);
3629 print $hookmanager->resPrint;
3631 print
'</div></div> <!-- End side-nav id-left -->';
3635 print
'<!-- Begin right area -->'.
"\n";
3637 if (empty($leftmenuwithoutmainarea)) {