218 if (is_array($var)) {
219 foreach ($var as $key => $value) {
224 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'unknown' : $_SERVER[
'REMOTE_ADDR']);
225 $errormessage =
'Access refused to '.htmlentities($ip, ENT_COMPAT,
'UTF-8').
' by SQL or Script injection protection in main.inc.php - GETPOST type='.htmlentities($type, ENT_COMPAT,
'UTF-8').
' paramkey='.htmlentities($key, ENT_COMPAT,
'UTF-8').
' paramvalue='.htmlentities($value, ENT_COMPAT,
'UTF-8').
' page='.htmlentities($_SERVER[
"REQUEST_URI"], ENT_COMPAT,
'UTF-8');
228 if (function_exists(
'error_log')) {
229 error_log($errormessage);
247if ((defined(
'NOREQUIREDB') || defined(
'NOREQUIRETRAN')) && !defined(
'NOREQUIREMENU')) {
248 print
'If define NOREQUIREDB or NOREQUIRETRAN are set, you must also set NOREQUIREMENU or not set them.';
251if (defined(
'NOREQUIREUSER') && !defined(
'NOREQUIREMENU')) {
252 print
'If define NOREQUIREUSER is set, you must also set NOREQUIREMENU or not set it.';
257if (!defined(
'NOSCANPHPSELFFORINJECTION') && !empty($_SERVER[
"PHP_SELF"])) {
258 $morevaltochecklikepost = array($_SERVER[
"PHP_SELF"]);
262if (!defined(
'NOSCANGETFORINJECTION') && !empty($_SERVER[
"QUERY_STRING"])) {
266 $morevaltochecklikeget = array(urldecode($_SERVER[
"QUERY_STRING"]));
270if (!defined(
'NOSCANPOSTFORINJECTION')) {
275if (!empty($_SERVER[
'DOCUMENT_ROOT']) && substr($_SERVER[
'DOCUMENT_ROOT'], -6) !==
'htdocs') {
276 set_include_path($_SERVER[
'DOCUMENT_ROOT'].
'/htdocs');
280require_once
'filefunc.inc.php';
285if (!empty($_POST[
"DOL_AUTOSET_COOKIE"])) {
286 $tmpautoset = explode(
':', $_POST[
"DOL_AUTOSET_COOKIE"], 2);
287 $tmplist = explode(
',', $tmpautoset[1]);
288 $cookiearrayvalue = array();
289 foreach ($tmplist as $tmpkey) {
290 $postkey = $tmpautoset[0].
'_'.$tmpkey;
292 if (!empty($_POST[$postkey])) {
293 $cookiearrayvalue[$tmpkey] = $_POST[$postkey];
296 $cookiename = $tmpautoset[0];
297 $cookievalue = json_encode($cookiearrayvalue);
299 if (PHP_VERSION_ID < 70300) {
300 setcookie($cookiename, empty($cookievalue) ?
'' : $cookievalue, empty($cookievalue) ? 0 : (time() + (86400 * 354)),
'/', null, ((empty($dolibarr_main_force_https) &&
isHTTPS() === false) ? false : true), true);
303 $cookieparams = array(
304 'expires' => empty($cookievalue) ? 0 : (time() + (86400 * 354)),
307 'secure' => ((empty($dolibarr_main_force_https) &&
isHTTPS() === false) ? false : true),
311 setcookie($cookiename, empty($cookievalue) ?
'' : $cookievalue, $cookieparams);
313 if (empty($cookievalue)) {
314 unset($_COOKIE[$cookiename]);
320if (!empty($php_session_save_handler) && $php_session_save_handler ==
'db') {
321 require_once
'core/lib/phpsessionin'.$php_session_save_handler.
'.lib.php';
327$prefix = dol_getprefix(
'');
328$sessionname =
'DOLSESSID_'.$prefix;
329$sessiontimeout =
'DOLSESSTIMEOUT_'.$prefix;
330if (!empty($_COOKIE[$sessiontimeout])) {
331 ini_set(
'session.gc_maxlifetime', $_COOKIE[$sessiontimeout]);
336if (!defined(
'NOSESSION')) {
337 if (PHP_VERSION_ID < 70300) {
338 session_set_cookie_params(0,
'/',
null, ((empty($dolibarr_main_force_https) &&
isHTTPS() ===
false) ?
false : true), true);
341 $sessioncookieparams = array(
345 'secure' => ((empty($dolibarr_main_force_https) &&
isHTTPS() ===
false) ?
false : true),
349 session_set_cookie_params($sessioncookieparams);
351 session_name($sessionname);
358require_once
'master.inc.php';
361if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) {
363 if ((!session_id() || !isset($_SESSION[
"dol_login"])) && !isset($_POST[
"username"]) && !empty($_SERVER[
"GATEWAY_INTERFACE"])) {
365 } elseif (isset($_POST[
"username"]) && $_POST[
"username"] == $conf->global->MAIN_ONLY_LOGIN_ALLOWED) {
367 } elseif (defined(
'NOREQUIREDB')) {
369 } elseif (defined(
'EVEN_IF_ONLY_LOGIN_ALLOWED')) {
371 } elseif (session_id() && isset($_SESSION[
"dol_login"]) && $_SESSION[
"dol_login"] == $conf->global->MAIN_ONLY_LOGIN_ALLOWED) {
375 if (session_id() && isset($_SESSION[
"dol_login"]) && $_SESSION[
"dol_login"] != $conf->global->MAIN_ONLY_LOGIN_ALLOWED) {
376 print
'Sorry, your application is offline.'.
"\n";
377 print
'You are logged with user "'.$_SESSION[
"dol_login"].
'" and only administrator user "'.$conf->global->MAIN_ONLY_LOGIN_ALLOWED.
'" is allowed to connect for the moment.'.
"\n";
378 $nexturl = DOL_URL_ROOT.
'/user/logout.php?token='.newToken();
379 print
'Please try later or <a href="'.$nexturl.
'">click here to disconnect and change login user</a>...'.
"\n";
381 print
'Sorry, your application is offline. Only administrator user "'.$conf->global->MAIN_ONLY_LOGIN_ALLOWED.
'" is allowed to connect for the moment.'.
"\n";
382 $nexturl = DOL_URL_ROOT.
'/';
383 print
'Please try later or <a href="'.$nexturl.
'">click here to change login user</a>...'.
"\n";
391register_shutdown_function(
'dol_shutdown');
394if (isModEnabled(
'debugbar') && !
GETPOST(
'dol_use_jmobile') && empty($_SESSION[
'dol_use_jmobile'])) {
396 include_once DOL_DOCUMENT_ROOT.
'/debugbar/class/DebugBar.php';
398 $renderer = $debugbar->getRenderer();
399 if (empty($conf->global->MAIN_HTML_HEADER)) {
400 $conf->global->MAIN_HTML_HEADER =
'';
402 $conf->global->MAIN_HTML_HEADER .= $renderer->renderHead();
404 $debugbar[
'time']->startMeasure(
'pageaftermaster',
'Page generation (after environment init)');
408if (isset($_SERVER[
"HTTP_USER_AGENT"])) {
410 $conf->browser->name = $tmp[
'browsername'];
411 $conf->browser->os = $tmp[
'browseros'];
412 $conf->browser->version = $tmp[
'browserversion'];
413 $conf->browser->ua = $tmp[
'browserua'];
414 $conf->browser->layout = $tmp[
'layout'];
417 if ($conf->browser->layout ==
'phone') {
418 $conf->dol_no_mouse_hover = 1;
424 $conf->theme =
GETPOST(
'theme',
'aZ09');
425 $conf->css =
"/theme/".$conf->theme.
"/style.css.php";
429if (
GETPOST(
'textbrowser',
'int') || (!empty($conf->browser->name) && $conf->browser->name ==
'lynxlinks')) {
430 $conf->global->MAIN_OPTIMIZEFORTEXTBROWSER = 1;
435if (!empty($conf->file->main_force_https) && (empty($_SERVER[
"HTTPS"]) || $_SERVER[
"HTTPS"] !=
'on') && !defined(
'NOHTTPSREDIRECT')) {
437 if (is_numeric($conf->file->main_force_https)) {
438 if ($conf->file->main_force_https ==
'1' && !empty($_SERVER[
"SCRIPT_URI"])) {
439 if (preg_match(
'/^http:/i', $_SERVER[
"SCRIPT_URI"]) && !preg_match(
'/^https:/i', $_SERVER[
"SCRIPT_URI"])) {
440 $newurl = preg_replace(
'/^http:/i',
'https:', $_SERVER[
"SCRIPT_URI"]);
444 $newurl = preg_replace(
'/^http:/i',
'https:', DOL_MAIN_URL_ROOT).$_SERVER[
"REQUEST_URI"];
448 $newurl = $conf->file->main_force_https.$_SERVER[
"REQUEST_URI"];
453 dol_syslog(
"main.inc: dolibarr_main_force_https is on, we make a redirect to ".$newurl);
454 header(
"Location: ".$newurl);
457 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);
461if (!defined(
'NOLOGIN') && !defined(
'NOIPCHECK') && !empty($dolibarr_main_restrict_ip)) {
462 $listofip = explode(
',', $dolibarr_main_restrict_ip);
464 foreach ($listofip as $ip) {
466 if ($ip == $_SERVER[
'REMOTE_ADDR']) {
472 print
'Access refused by IP protection. Your detected IP is '.$_SERVER[
'REMOTE_ADDR'];
478if (!defined(
'NOREQUIREHTML')) {
479 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
481if (!defined(
'NOREQUIREAJAX')) {
482 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
486if (!empty($conf->global->MAIN_NOT_INSTALLED) || !empty($conf->global->MAIN_NOT_UPGRADED)) {
487 dol_syslog(
"main.inc: A previous install or upgrade was not complete. Redirect to install page.", LOG_WARNING);
488 header(
"Location: ".DOL_URL_ROOT.
"/install/index.php");
492if ((!empty($conf->global->MAIN_VERSION_LAST_UPGRADE) && ($conf->global->MAIN_VERSION_LAST_UPGRADE != DOL_VERSION))
493 || (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) && !empty($conf->global->MAIN_VERSION_LAST_INSTALL) && ($conf->global->MAIN_VERSION_LAST_INSTALL != DOL_VERSION))) {
494 $versiontocompare = empty($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_INSTALL : $conf->global->MAIN_VERSION_LAST_UPGRADE;
495 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
496 $dolibarrversionlastupgrade = preg_split(
'/[.-]/', $versiontocompare);
497 $dolibarrversionprogram = preg_split(
'/[.-]/', DOL_VERSION);
498 $rescomp =
versioncompare($dolibarrversionprogram, $dolibarrversionlastupgrade);
500 if (empty($conf->global->MAIN_NO_UPGRADE_REDIRECT_ON_LEVEL_3_CHANGE) || $rescomp < 3) {
502 dol_syslog(
"main.inc: database version ".$versiontocompare.
" is lower than programs version ".DOL_VERSION.
". Redirect to install/upgrade page.", LOG_WARNING);
503 header(
"Location: ".DOL_URL_ROOT.
"/install/index.php");
510if (!defined(
'NOTOKENRENEWAL') && !defined(
'NOSESSION')) {
512 if (!preg_match(
'/\.(css|js|json)\.php$/', $_SERVER[
"PHP_SELF"])) {
514 if (isset($_SESSION[
'newtoken'])) {
515 $_SESSION[
'token'] = $_SESSION[
'newtoken'];
518 if (!isset($_SESSION[
'newtoken']) ||
getDolGlobalInt(
'MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL')) {
522 $token =
dol_hash(uniqid(mt_rand(),
false),
'md5');
523 $_SESSION[
'newtoken'] = $token;
524 dol_syslog(
"NEW TOKEN generated by : ".$_SERVER[
'PHP_SELF'], LOG_DEBUG);
532if ((!defined(
'NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) &&
getDolGlobalInt(
'MAIN_SECURITY_CSRF_WITH_TOKEN')) || defined(
'CSRFCHECK_WITH_TOKEN')) {
534 $sensitiveget =
false;
535 if ((GETPOSTISSET(
'massaction') ||
GETPOST(
'action',
'aZ09')) &&
getDolGlobalInt(
'MAIN_SECURITY_CSRF_WITH_TOKEN') >= 3) {
537 if (GETPOSTISSET(
'massaction') || !in_array(
GETPOST(
'action',
'aZ09'), array(
'create',
'createsite',
'createcard',
'edit',
'editvalidator',
'file_manager',
'presend',
'presend_addmessage',
'preview',
'specimen'))) {
538 $sensitiveget =
true;
542 $arrayofactiontoforcetokencheck = array(
544 'doprev',
'donext',
'dvprev',
'dvnext',
545 'freezone',
'install',
548 if (in_array(
GETPOST(
'action',
'aZ09'), $arrayofactiontoforcetokencheck)) {
549 $sensitiveget =
true;
552 if (preg_match(
'/^(add|classify|close|confirm|copy|del|disable|enable|remove|set|unset|update|save)/',
GETPOST(
'action',
'aZ09'))) {
553 $sensitiveget =
true;
560 $_SERVER[
'REQUEST_METHOD'] ==
'POST' ||
562 GETPOSTISSET(
'massaction') ||
563 ((GETPOSTISSET(
'actionlogin') || GETPOSTISSET(
'action')) && defined(
'CSRFCHECK_WITH_TOKEN'))
566 if (!
GETPOST(
'token',
'alpha') ||
GETPOST(
'token',
'alpha') ==
'notrequired') {
568 if (
GETPOST(
'uploadform',
'int')) {
569 dol_syslog(
"--- Access to ".(empty($_SERVER[
"REQUEST_METHOD"]) ?
'' : $_SERVER[
"REQUEST_METHOD"].
' ').$_SERVER[
"PHP_SELF"].
" refused. File size too large or not provided.");
570 $langs->loadLangs(array(
"errors",
"install"));
571 print $langs->trans(
"ErrorFileSizeTooLarge").
' ';
572 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
574 http_response_code(403);
575 if (defined(
'CSRFCHECK_WITH_TOKEN')) {
576 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);
577 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";
579 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);
580 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";
581 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";
582 if (!empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) {
583 print
" instead of ".$conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN;
585 print
" into setup).\n";
592 $sessiontokenforthisurl = (empty($_SESSION[
'token']) ?
'' : $_SESSION[
'token']);
594 if (GETPOSTISSET(
'token') &&
GETPOST(
'token') !=
'notrequired' &&
GETPOST(
'token',
'alpha') != $sessiontokenforthisurl) {
595 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 - referer=".(empty($_SERVER[
'HTTP_REFERER'])?
'':$_SERVER[
'HTTP_REFERER']).
", action=".
GETPOST(
'action',
'aZ09').
", _GET|POST['token']=".
GETPOST(
'token',
'alpha'), LOG_WARNING);
598 if (!defined(
'NOTOKENRENEWAL')) {
600 setEventMessages(
'SecurityTokenHasExpiredSoActionHasBeenCanceledPleaseRetry',
null,
'warnings',
'', 1);
603 if (isset($_POST[
'id'])) {
604 $savid = ((int) $_POST[
'id']);
607 unset($_GET[
'confirm']);
608 unset($_GET[
'action']);
609 unset($_GET[
'confirmmassaction']);
610 unset($_GET[
'massaction']);
611 unset($_GET[
'token']);
613 $_POST[
'id'] = ((int) $savid);
616 $_GET[
'errorcode'] =
'InvalidToken';
623if (GETPOSTISSET(
'disablemodules')) {
624 $_SESSION[
"disablemodules"] =
GETPOST(
'disablemodules',
'alpha');
626if (!empty($_SESSION[
"disablemodules"])) {
627 $modulepartkeys = array(
'css',
'js',
'tabs',
'triggers',
'login',
'substitutions',
'menus',
'theme',
'sms',
'tpl',
'barcode',
'models',
'societe',
'hooks',
'dir',
'syslog',
'tpllinkable',
'contactelement',
'moduleforexternal');
629 $disabled_modules = explode(
',', $_SESSION[
"disablemodules"]);
630 foreach ($disabled_modules as $module) {
632 if (empty($conf->$module)) {
633 $conf->$module =
new stdClass();
635 $conf->$module->enabled =
false;
636 foreach ($modulepartkeys as $modulepartkey) {
637 unset($conf->modules_parts[$modulepartkey][$module]);
639 if ($module ==
'fournisseur') {
640 $conf->supplier_order->enabled = 0;
641 $conf->supplier_invoice->enabled = 0;
648$modulepart = explode(
"/", $_SERVER[
"PHP_SELF"]);
649if (is_array($modulepart) && count($modulepart) > 0) {
650 foreach ($conf->modules as $module) {
651 if (in_array($module, $modulepart)) {
652 $modulepart = $module;
657if (is_array($modulepart)) {
666if (!defined(
'NOLOGIN')) {
670 if (defined(
'MAIN_AUTHENTICATION_MODE')) {
671 $dolibarr_main_authentication = constant(
'MAIN_AUTHENTICATION_MODE');
674 if (empty($dolibarr_main_authentication)) {
675 $dolibarr_main_authentication =
'dolibarr';
678 if ($dolibarr_main_authentication ==
'forceuser' && empty($dolibarr_auto_user)) {
679 $dolibarr_auto_user =
'auto';
683 $authmode = explode(
',', $dolibarr_main_authentication);
686 if (!count($authmode)) {
687 $langs->load(
'main');
688 dol_print_error(
'', $langs->trans(
"ErrorConfigParameterNotDefined",
'dolibarr_main_authentication'));
695 $resultFetchUser =
'';
697 if (!isset($_SESSION[
"dol_login"])) {
699 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
701 $dol_dst_observed =
GETPOST(
"dst_observed",
'int', 3);
702 $dol_dst_first =
GETPOST(
"dst_first",
'int', 3);
703 $dol_dst_second =
GETPOST(
"dst_second",
'int', 3);
704 $dol_screenwidth =
GETPOST(
"screenwidth",
'int', 3);
705 $dol_screenheight =
GETPOST(
"screenheight",
'int', 3);
706 $dol_hide_topmenu =
GETPOST(
'dol_hide_topmenu',
'int', 3);
707 $dol_hide_leftmenu =
GETPOST(
'dol_hide_leftmenu',
'int', 3);
708 $dol_optimize_smallscreen =
GETPOST(
'dol_optimize_smallscreen',
'int', 3);
709 $dol_no_mouse_hover =
GETPOST(
'dol_no_mouse_hover',
'int', 3);
710 $dol_use_jmobile =
GETPOST(
'dol_use_jmobile',
'int', 3);
714 if (!empty($dolibarr_main_demo) && $_SERVER[
'PHP_SELF'] == DOL_URL_ROOT.
'/index.php') {
715 if (empty($_SERVER[
'HTTP_REFERER']) || !preg_match(
'/public/', $_SERVER[
'HTTP_REFERER'])) {
716 dol_syslog(
"Call index page from another url than demo page (call is done from page ".(empty($_SERVER[
'HTTP_REFERER']) ?
'' : $_SERVER[
'HTTP_REFER']).
")");
718 $url .= ($url ?
'&' :
'').($dol_hide_topmenu ?
'dol_hide_topmenu='.$dol_hide_topmenu :
'');
719 $url .= ($url ?
'&' :
'').($dol_hide_leftmenu ?
'dol_hide_leftmenu='.$dol_hide_leftmenu :
'');
720 $url .= ($url ?
'&' :
'').($dol_optimize_smallscreen ?
'dol_optimize_smallscreen='.$dol_optimize_smallscreen :
'');
721 $url .= ($url ?
'&' :
'').($dol_no_mouse_hover ?
'dol_no_mouse_hover='.$dol_no_mouse_hover :
'');
722 $url .= ($url ?
'&' :
'').($dol_use_jmobile ?
'dol_use_jmobile='.$dol_use_jmobile :
'');
723 $url = DOL_URL_ROOT.
'/public/demo/index.php'.($url ?
'?'.$url :
'');
724 header(
"Location: ".$url);
731 $hookmanager->initHooks(array(
'login'));
732 $parameters = array();
733 $reshook = $hookmanager->executeHooks(
'beforeLoginAuthentication', $parameters, $user, $action);
740 if ($test &&
GETPOST(
"username",
"alpha", 2) && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA) && !isset($_SESSION[
'dol_bypass_antispam'])) {
741 $sessionkey =
'dol_antispam_value';
742 $ok = (array_key_exists($sessionkey, $_SESSION) ===
true && (strtolower($_SESSION[$sessionkey]) === strtolower(
GETPOST(
'code',
'restricthtml'))));
746 dol_syslog(
'Bad value for code, connexion refused');
748 $langs->loadLangs(array(
'main',
'errors'));
750 $_SESSION[
"dol_loginmesg"] = $langs->transnoentitiesnoconv(
"ErrorBadValueForCode");
754 $user->context[
'audit'] =
'ErrorBadValueForCode - login='.GETPOST(
"username",
"alpha", 2);
757 $result = $user->call_trigger(
'USER_LOGIN_FAILED', $user);
765 $hookmanager->initHooks(array(
'login'));
766 $parameters = array(
'dol_authmode'=>$authmode,
'dol_loginmesg'=>$_SESSION[
"dol_loginmesg"]);
767 $reshook = $hookmanager->executeHooks(
'afterLoginFailed', $parameters, $user, $action);
776 $allowedmethodtopostusername = 3;
777 if (defined(
'MAIN_AUTHENTICATION_POST_METHOD')) {
778 $allowedmethodtopostusername = constant(
'MAIN_AUTHENTICATION_POST_METHOD');
781 $usertotest = (!empty($_COOKIE[
'login_dolibarr']) ? preg_replace(
'/[^a-zA-Z0-9_@\-\.]/',
'', $_COOKIE[
'login_dolibarr']) :
GETPOST(
"username",
"alpha", $allowedmethodtopostusername));
782 $passwordtotest =
GETPOST(
'password',
'none', $allowedmethodtopostusername);
783 $entitytotest = (
GETPOST(
'entity',
'int') ?
GETPOST(
'entity',
'int') : (!empty($conf->entity) ? $conf->entity : 1));
786 $goontestloop =
false;
787 if (isset($_SERVER[
"REMOTE_USER"]) && in_array(
'http', $authmode)) {
788 $goontestloop =
true;
790 if ($dolibarr_main_authentication ==
'forceuser' && !empty($dolibarr_auto_user)) {
791 $goontestloop =
true;
793 if (
GETPOST(
"username",
"alpha", $allowedmethodtopostusername)) {
794 $goontestloop =
true;
796 if (
GETPOST(
'openid_mode',
'alpha', 1)) {
797 $goontestloop =
true;
799 if (
GETPOST(
'beforeoauthloginredirect',
'int') ||
GETPOST(
'afteroauthloginreturn')) {
800 $goontestloop =
true;
802 if (!empty($_COOKIE[
'login_dolibarr'])) {
803 $goontestloop =
true;
806 if (!is_object($langs)) {
807 include_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
809 $langcode = (
GETPOST(
'lang',
'aZ09', 1) ?
GETPOST(
'lang',
'aZ09', 1) : (empty($conf->global->MAIN_LANG_DEFAULT) ?
'auto' : $conf->global->MAIN_LANG_DEFAULT));
810 if (defined(
'MAIN_LANG_DEFAULT')) {
811 $langcode = constant(
'MAIN_LANG_DEFAULT');
813 $langs->setDefaultLang($langcode);
820 if ($test && $goontestloop && (
GETPOST(
'actionlogin',
'aZ09') ==
'login' || $dolibarr_main_authentication !=
'dolibarr')) {
822 if ($login ===
'--bad-login-validity--') {
829 $dol_authmode = $conf->authmode;
830 $dol_tz = empty($_POST[
"tz"]) ? (empty($_SESSION[
"tz"]) ?
'' : $_SESSION[
"tz"]) : $_POST[
"tz"];
831 $dol_tz_string = empty($_POST[
"tz_string"]) ? (empty($_SESSION[
"tz_string"]) ?
'' : $_SESSION[
"tz_string"]) : $_POST[
"tz_string"];
832 $dol_tz_string = preg_replace(
'/\s*\(.+\)$/',
'', $dol_tz_string);
833 $dol_tz_string = preg_replace(
'/,/',
'/', $dol_tz_string);
834 $dol_tz_string = preg_replace(
'/\s/',
'_', $dol_tz_string);
837 $dol_dst_first = empty($_POST[
"dst_first"]) ? (empty($_SESSION[
"dst_first"]) ?
'' : $_SESSION[
"dst_first"]) : $_POST[
"dst_first"];
838 $dol_dst_second = empty($_POST[
"dst_second"]) ? (empty($_SESSION[
"dst_second"]) ?
'' : $_SESSION[
"dst_second"]) : $_POST[
"dst_second"];
839 if ($dol_dst_first && $dol_dst_second) {
840 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
844 if ($datenow >= $datefirst && $datenow < $datesecond) {
848 $dol_screenheight = empty($_POST[
"screenheight"]) ? (empty($_SESSION[
"dol_screenheight"]) ?
'' : $_SESSION[
"dol_screenheight"]) : $_POST[
"screenheight"];
849 $dol_screenwidth = empty($_POST[
"screenwidth"]) ? (empty($_SESSION[
"dol_screenwidth"]) ?
'' : $_SESSION[
"dol_screenwidth"]) : $_POST[
"screenwidth"];
854 dol_syslog(
'Bad password, connexion refused', LOG_DEBUG);
856 $langs->loadLangs(array(
'main',
'errors'));
860 if (empty($_SESSION[
"dol_loginmesg"])) {
861 $_SESSION[
"dol_loginmesg"] = $langs->transnoentitiesnoconv(
"ErrorBadLoginPassword");
865 $user->context[
'audit'] = $langs->trans(
"ErrorBadLoginPassword").
' - login='.
GETPOST(
"username",
"alpha", 2);
868 $result = $user->call_trigger(
'USER_LOGIN_FAILED', $user);
876 $hookmanager->initHooks(array(
'login'));
877 $parameters = array(
'dol_authmode'=>$dol_authmode,
'dol_loginmesg'=>$_SESSION[
"dol_loginmesg"]);
878 $reshook = $hookmanager->executeHooks(
'afterLoginFailed', $parameters, $user, $action);
888 if (!$login || (in_array(
'ldap', $authmode) && empty($passwordtotest))) {
890 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);
891 if (defined(
'NOREDIRECTBYMAINTOLOGIN')) {
896 return 'ERROR_NOT_LOGGED';
898 if ($_SERVER[
"HTTP_USER_AGENT"] ==
'securitytest') {
899 http_response_code(401);
901 dol_loginfunction($langs, $conf, (!empty($mysoc) ? $mysoc :
''));
906 $resultFetchUser = $user->fetch(
'', $login,
'', 1, ($entitytotest > 0 ? $entitytotest : -1));
907 if ($resultFetchUser <= 0 || $user->isNotIntoValidityDateRange()) {
908 dol_syslog(
'User not found or not valid, connexion refused');
910 session_set_cookie_params(0,
'/',
null, (empty($dolibarr_main_force_https) ?
false : true), true);
911 session_name($sessionname);
914 if ($resultFetchUser == 0) {
916 $langs->loadLangs(array(
'main',
'errors'));
918 $_SESSION[
"dol_loginmesg"] = $langs->transnoentitiesnoconv(
"ErrorCantLoadUserFromDolibarrDatabase", $login);
920 $user->context[
'audit'] =
'ErrorCantLoadUserFromDolibarrDatabase - login='.$login;
921 } elseif ($resultFetchUser < 0) {
922 $_SESSION[
"dol_loginmesg"] = $user->error;
924 $user->context[
'audit'] = $user->error;
927 $langs->loadLangs(array(
'main',
'errors'));
929 $_SESSION[
"dol_loginmesg"] = $langs->transnoentitiesnoconv(
"ErrorLoginDateValidity");
931 $user->context[
'audit'] = $langs->trans(
"ErrorLoginDateValidity").
' - login='.$login;
935 $result = $user->call_trigger(
'USER_LOGIN_FAILED', $user);
944 $hookmanager->initHooks(array(
'login'));
945 $parameters = array(
'dol_authmode'=>$dol_authmode,
'dol_loginmesg'=>$_SESSION[
"dol_loginmesg"]);
946 $reshook = $hookmanager->executeHooks(
'afterLoginFailed', $parameters, $user, $action);
951 $paramsurl = array();
952 if (
GETPOST(
'textbrowser',
'int')) {
953 $paramsurl[] =
'textbrowser='.GETPOST(
'textbrowser',
'int');
956 $paramsurl[] =
'nojs='.GETPOST(
'nojs',
'int');
959 $paramsurl[] =
'lang='.GETPOST(
'lang',
'aZ09');
961 header(
'Location: '.DOL_URL_ROOT.
'/index.php'.(count($paramsurl) ?
'?'.implode(
'&', $paramsurl) :
''));
965 if (!empty($user->conf->MAIN_LANG_DEFAULT)) {
966 $langs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT);
971 $login = $_SESSION[
"dol_login"];
972 $entity = isset($_SESSION[
"dol_entity"]) ? $_SESSION[
"dol_entity"] : 0;
973 dol_syslog(
"- This is an already logged session. _SESSION['dol_login']=".$login.
" _SESSION['dol_entity']=".$entity, LOG_DEBUG);
975 $resultFetchUser = $user->fetch(
'', $login,
'', 1, ($entity > 0 ? $entity : -1));
979 if ($resultFetchUser <= 0
980 || ($user->flagdelsessionsbefore && !empty($_SESSION[
"dol_logindate"]) && $user->flagdelsessionsbefore > $_SESSION[
"dol_logindate"])
981 || ($user->status != $user::STATUS_ENABLED)
982 || ($user->isNotIntoValidityDateRange())) {
983 if ($resultFetchUser <= 0) {
985 dol_syslog(
"Can't load user even if session logged. _SESSION['dol_login']=".$login, LOG_WARNING);
986 } elseif ($user->flagdelsessionsbefore && !empty($_SESSION[
"dol_logindate"]) && $user->flagdelsessionsbefore > $_SESSION[
"dol_logindate"]) {
988 dol_syslog(
"The user has a date for session invalidation = ".$user->flagdelsessionsbefore.
" and a session date = ".$_SESSION[
"dol_logindate"].
". We must invalidate its sessions.");
989 } elseif ($user->status != $user::STATUS_ENABLED) {
994 dol_syslog(
"The user login has a validity between [".$user->datestartvalidity.
" and ".$user->dateendvalidity.
"], curren date is ".
dol_now());
997 session_set_cookie_params(0,
'/',
null, (empty($dolibarr_main_force_https) ?
false : true), true);
998 session_name($sessionname);
1001 if ($resultFetchUser == 0) {
1002 $langs->loadLangs(array(
'main',
'errors'));
1004 $_SESSION[
"dol_loginmesg"] = $langs->transnoentitiesnoconv(
"ErrorCantLoadUserFromDolibarrDatabase", $login);
1006 $user->context[
'audit'] =
'ErrorCantLoadUserFromDolibarrDatabase - login='.$login;
1007 } elseif ($resultFetchUser < 0) {
1008 $_SESSION[
"dol_loginmesg"] = $user->error;
1010 $user->context[
'audit'] = $user->error;
1012 $langs->loadLangs(array(
'main',
'errors'));
1014 $_SESSION[
"dol_loginmesg"] = $langs->transnoentitiesnoconv(
"ErrorSessionInvalidatedAfterPasswordChange");
1016 $user->context[
'audit'] =
'ErrorUserSessionWasInvalidated - login='.$login;
1020 $result = $user->call_trigger(
'USER_LOGIN_FAILED', $user);
1028 $hookmanager->initHooks(array(
'login'));
1029 $parameters = array(
'dol_authmode' => (isset($dol_authmode) ? $dol_authmode :
''),
'dol_loginmesg' => $_SESSION[
"dol_loginmesg"]);
1030 $reshook = $hookmanager->executeHooks(
'afterLoginFailed', $parameters, $user, $action);
1035 $paramsurl = array();
1036 if (
GETPOST(
'textbrowser',
'int')) {
1037 $paramsurl[] =
'textbrowser='.GETPOST(
'textbrowser',
'int');
1040 $paramsurl[] =
'nojs='.GETPOST(
'nojs',
'int');
1042 if (
GETPOST(
'lang',
'aZ09')) {
1043 $paramsurl[] =
'lang='.GETPOST(
'lang',
'aZ09');
1045 header(
'Location: '.DOL_URL_ROOT.
'/index.php'.(count($paramsurl) ?
'?'.implode(
'&', $paramsurl) :
''));
1049 $hookmanager->initHooks(array(
'main'));
1052 if (!empty($_GET[
'save_lastsearch_values']) && !empty($_SERVER[
"HTTP_REFERER"])) {
1053 $relativepathstring = preg_replace(
'/\?.*$/',
'', $_SERVER[
"HTTP_REFERER"]);
1054 $relativepathstring = preg_replace(
'/^https?:\/\/[^\/]*/',
'', $relativepathstring);
1056 if (constant(
'DOL_URL_ROOT')) {
1057 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
1059 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
1060 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
1064 if (!empty($_SESSION[
'lastsearch_values_tmp_'.$relativepathstring])) {
1065 $_SESSION[
'lastsearch_values_'.$relativepathstring] = $_SESSION[
'lastsearch_values_tmp_'.$relativepathstring];
1066 unset($_SESSION[
'lastsearch_values_tmp_'.$relativepathstring]);
1068 if (!empty($_SESSION[
'lastsearch_contextpage_tmp_'.$relativepathstring])) {
1069 $_SESSION[
'lastsearch_contextpage_'.$relativepathstring] = $_SESSION[
'lastsearch_contextpage_tmp_'.$relativepathstring];
1070 unset($_SESSION[
'lastsearch_contextpage_tmp_'.$relativepathstring]);
1072 if (!empty($_SESSION[
'lastsearch_limit_tmp_'.$relativepathstring]) && $_SESSION[
'lastsearch_limit_tmp_'.$relativepathstring] != $conf->liste_limit) {
1073 $_SESSION[
'lastsearch_limit_'.$relativepathstring] = $_SESSION[
'lastsearch_limit_tmp_'.$relativepathstring];
1074 unset($_SESSION[
'lastsearch_limit_tmp_'.$relativepathstring]);
1076 if (!empty($_SESSION[
'lastsearch_page_tmp_'.$relativepathstring]) && $_SESSION[
'lastsearch_page_tmp_'.$relativepathstring] > 0) {
1077 $_SESSION[
'lastsearch_page_'.$relativepathstring] = $_SESSION[
'lastsearch_page_tmp_'.$relativepathstring];
1078 unset($_SESSION[
'lastsearch_page_tmp_'.$relativepathstring]);
1080 if (!empty($_SESSION[
'lastsearch_mode_tmp_'.$relativepathstring])) {
1081 $_SESSION[
'lastsearch_mode_'.$relativepathstring] = $_SESSION[
'lastsearch_mode_tmp_'.$relativepathstring];
1082 unset($_SESSION[
'lastsearch_mode_tmp_'.$relativepathstring]);
1085 if (!empty($_GET[
'save_pageforbacktolist']) && !empty($_SERVER[
"HTTP_REFERER"])) {
1086 if (empty($_SESSION[
'pageforbacktolist'])) {
1087 $pageforbacktolistarray = array();
1089 $pageforbacktolistarray = $_SESSION[
'pageforbacktolist'];
1091 $tmparray = explode(
':', $_GET[
'save_pageforbacktolist'], 2);
1092 if (!empty($tmparray[0]) && !empty($tmparray[1])) {
1093 $pageforbacktolistarray[$tmparray[0]] = $tmparray[1];
1094 $_SESSION[
'pageforbacktolist'] = $pageforbacktolistarray;
1099 $parameters = array();
1100 $reshook = $hookmanager->executeHooks(
'updateSession', $parameters, $user, $action);
1109 if (!isset($_SESSION[
"dol_login"])) {
1114 $_SESSION[
"dol_login"] = $user->login;
1115 $_SESSION[
"dol_logindate"] =
dol_now(
'gmt');
1116 $_SESSION[
"dol_authmode"] = isset($dol_authmode) ? $dol_authmode :
'';
1117 $_SESSION[
"dol_tz"] = isset($dol_tz) ? $dol_tz :
'';
1118 $_SESSION[
"dol_tz_string"] = isset($dol_tz_string) ? $dol_tz_string :
'';
1119 $_SESSION[
"dol_dst"] = isset($dol_dst) ? $dol_dst :
'';
1120 $_SESSION[
"dol_dst_observed"] = isset($dol_dst_observed) ? $dol_dst_observed :
'';
1121 $_SESSION[
"dol_dst_first"] = isset($dol_dst_first) ? $dol_dst_first :
'';
1122 $_SESSION[
"dol_dst_second"] = isset($dol_dst_second) ? $dol_dst_second :
'';
1123 $_SESSION[
"dol_screenwidth"] = isset($dol_screenwidth) ? $dol_screenwidth :
'';
1124 $_SESSION[
"dol_screenheight"] = isset($dol_screenheight) ? $dol_screenheight :
'';
1126 $_SESSION[
"dol_entity"] = $conf->entity;
1128 if (!empty($dol_hide_topmenu)) {
1129 $_SESSION[
'dol_hide_topmenu'] = $dol_hide_topmenu;
1131 if (!empty($dol_hide_leftmenu)) {
1132 $_SESSION[
'dol_hide_leftmenu'] = $dol_hide_leftmenu;
1134 if (!empty($dol_optimize_smallscreen)) {
1135 $_SESSION[
'dol_optimize_smallscreen'] = $dol_optimize_smallscreen;
1137 if (!empty($dol_no_mouse_hover)) {
1138 $_SESSION[
'dol_no_mouse_hover'] = $dol_no_mouse_hover;
1140 if (!empty($dol_use_jmobile)) {
1141 $_SESSION[
'dol_use_jmobile'] = $dol_use_jmobile;
1144 dol_syslog(
"This is a new started user session. _SESSION['dol_login']=".$_SESSION[
"dol_login"].
" Session id=".session_id());
1148 $user->update_last_login_date();
1150 $loginfo =
'TZ='.$_SESSION[
"dol_tz"].
';TZString='.$_SESSION[
"dol_tz_string"].
';Screen='.$_SESSION[
"dol_screenwidth"].
'x'.$_SESSION[
"dol_screenheight"];
1151 $loginfo .=
' - authmode='.$dol_authmode.
' - entity='.$conf->entity;
1154 $user->context[
'audit'] = $loginfo;
1155 $user->context[
'authentication_method'] = $dol_authmode;
1158 $result = $user->call_trigger(
'USER_LOGIN', $user);
1166 $hookmanager->initHooks(array(
'login'));
1167 $parameters = array(
'dol_authmode'=>$dol_authmode,
'dol_loginfo'=>$loginfo);
1168 $reshook = $hookmanager->executeHooks(
'afterLogin', $parameters, $user, $action);
1176 dol_print_error($db,
'Error in some triggers USER_LOGIN or in some hooks afterLogin');
1183 $landingpage = (empty($user->conf->MAIN_LANDING_PAGE) ? (empty($conf->global->MAIN_LANDING_PAGE) ?
'' : $conf->global->MAIN_LANDING_PAGE) : $user->
conf->MAIN_LANDING_PAGE);
1184 if (!empty($landingpage)) {
1186 if ($_SERVER[
"PHP_SELF"] != $newpath) {
1187 header(
'Location: '.$newpath);
1196 $user->rights->user->user->lire = 1;
1197 $user->rights->user->user->creer = 1;
1198 $user->rights->user->user->password = 1;
1199 $user->rights->user->user->supprimer = 1;
1200 $user->rights->user->self->creer = 1;
1201 $user->rights->user->self->password = 1;
1204 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
1205 if (empty($user->rights->user->user_advance)) {
1206 $user->rights->user->user_advance =
new stdClass();
1208 if (empty($user->rights->user->self_advance)) {
1209 $user->rights->user->self_advance =
new stdClass();
1211 if (empty($user->rights->user->group_advance)) {
1212 $user->rights->user->group_advance =
new stdClass();
1215 $user->rights->user->user_advance->readperms = 1;
1216 $user->rights->user->user_advance->write = 1;
1217 $user->rights->user->self_advance->readperms = 1;
1218 $user->rights->user->self_advance->writeperms = 1;
1219 $user->rights->user->group_advance->read = 1;
1220 $user->rights->user->group_advance->readperms = 1;
1221 $user->rights->user->group_advance->write = 1;
1222 $user->rights->user->group_advance->delete = 1;
1231 if (isset($user->conf->MAIN_SIZE_LISTE_LIMIT)) {
1232 $conf->liste_limit = $user->conf->MAIN_SIZE_LISTE_LIMIT;
1234 if (isset($user->conf->PRODUIT_LIMIT_SIZE)) {
1235 $conf->product->limit_size = $user->conf->PRODUIT_LIMIT_SIZE;
1239 if (empty($conf->global->MAIN_FORCETHEME) && !empty($user->conf->MAIN_THEME)) {
1240 $conf->theme = $user->conf->MAIN_THEME;
1241 $conf->css =
"/theme/".$conf->theme.
"/style.css.php";
1245 if (!empty($user) && method_exists($user,
'loadDefaultValues') && !defined(
'NODEFAULTVALUES')) {
1246 $user->loadDefaultValues();
1252if (
GETPOST(
'theme',
'aZ09')) {
1253 $conf->theme =
GETPOST(
'theme',
'aZ09', 1);
1254 $conf->css =
"/theme/".$conf->theme.
"/style.css.php";
1259 $conf->use_javascript_ajax = 0;
1261 if (!empty($user->conf->MAIN_DISABLE_JAVASCRIPT)) {
1262 $conf->use_javascript_ajax = !$user->conf->MAIN_DISABLE_JAVASCRIPT;
1267if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && !empty($user->conf->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1268 $conf->global->MAIN_OPTIMIZEFORTEXTBROWSER = $user->conf->MAIN_OPTIMIZEFORTEXTBROWSER;
1272$conf->global->MAIN_OPTIMIZEFORCOLORBLIND = empty($user->conf->MAIN_OPTIMIZEFORCOLORBLIND) ?
'' : $user->conf->MAIN_OPTIMIZEFORCOLORBLIND;
1275if (
GETPOST(
'dol_hide_leftmenu',
'int') || !empty($_SESSION[
'dol_hide_leftmenu'])) {
1276 $conf->dol_hide_leftmenu = 1;
1278if (
GETPOST(
'dol_hide_topmenu',
'int') || !empty($_SESSION[
'dol_hide_topmenu'])) {
1279 $conf->dol_hide_topmenu = 1;
1281if (
GETPOST(
'dol_optimize_smallscreen',
'int') || !empty($_SESSION[
'dol_optimize_smallscreen'])) {
1282 $conf->dol_optimize_smallscreen = 1;
1284if (
GETPOST(
'dol_no_mouse_hover',
'int') || !empty($_SESSION[
'dol_no_mouse_hover'])) {
1285 $conf->dol_no_mouse_hover = 1;
1287if (
GETPOST(
'dol_use_jmobile',
'int') || !empty($_SESSION[
'dol_use_jmobile'])) {
1288 $conf->dol_use_jmobile = 1;
1291if (!empty($conf->browser->layout) && $conf->browser->layout !=
'classic') {
1292 $conf->dol_no_mouse_hover = 1;
1296if ((!empty($conf->browser->layout) && $conf->browser->layout ==
'phone')
1297 || (!empty($_SESSION[
'dol_screenwidth']) && $_SESSION[
'dol_screenwidth'] < 400)
1298 || (!empty($_SESSION[
'dol_screenheight']) && $_SESSION[
'dol_screenheight'] < 400
1299 || !empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
1301 $conf->dol_optimize_smallscreen = 1;
1303 if (isset($conf->global->PRODUIT_DESC_IN_FORM) && $conf->global->PRODUIT_DESC_IN_FORM == 1) {
1304 $conf->global->PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE = 0;
1308if (!empty($conf->dol_use_jmobile) && in_array($conf->theme, array(
'bureau2crea',
'cameleo',
'amarok'))) {
1309 $conf->theme =
'eldy';
1310 $conf->css =
"/theme/".$conf->theme.
"/style.css.php";
1313if (!defined(
'NOREQUIRETRAN')) {
1314 if (!
GETPOST(
'lang',
'aZ09')) {
1316 if (!empty($user->conf->MAIN_LANG_DEFAULT)) {
1319 if ($langs->getDefaultLang() != $user->conf->MAIN_LANG_DEFAULT) {
1320 $langs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT);
1326if (!defined(
'NOLOGIN')) {
1329 if (!$user->login) {
1334 if ($user->statut < 1) {
1336 $langs->loadLangs(array(
"errors",
"other"));
1337 dol_syslog(
"Authentication KO as login is disabled", LOG_NOTICE);
1345dol_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);
1350if (!defined(
'NOREQUIRETRAN')) {
1352 $langs->loadLangs(array(
'main',
'dict'));
1356$bc = array(0=>
'class="impair"', 1=>
'class="pair"');
1357$bcdd = array(0=>
'class="drag drop oddeven"', 1=>
'class="drag drop oddeven"');
1358$bcnd = array(0=>
'class="nodrag nodrop nohover"', 1=>
'class="nodrag nodrop nohoverpair"');
1359$bctag = array(0=>
'class="impair tagtr"', 1=>
'class="pair tagtr"');
1362$mesg =
''; $warning =
''; $error = 0;
1364$mesgs = array(); $warnings = array(); $errors = array();
1367if (empty($conf->browser->firefox)) {
1368 define(
'ROWS_1', 1);
1369 define(
'ROWS_2', 2);
1370 define(
'ROWS_3', 3);
1371 define(
'ROWS_4', 4);
1372 define(
'ROWS_5', 5);
1373 define(
'ROWS_6', 6);
1374 define(
'ROWS_7', 7);
1375 define(
'ROWS_8', 8);
1376 define(
'ROWS_9', 9);
1378 define(
'ROWS_1', 0);
1379 define(
'ROWS_2', 1);
1380 define(
'ROWS_3', 2);
1381 define(
'ROWS_4', 3);
1382 define(
'ROWS_5', 4);
1383 define(
'ROWS_6', 5);
1384 define(
'ROWS_7', 6);
1385 define(
'ROWS_8', 7);
1386 define(
'ROWS_9', 8);
1389$heightforframes = 50;
1392if (!defined(
'NOREQUIREMENU')) {
1393 if (empty($user->socid)) {
1394 $conf->standard_menu = (empty($conf->global->MAIN_MENU_STANDARD_FORCED) ? (empty($conf->global->MAIN_MENU_STANDARD) ?
'eldy_menu.php' : $conf->global->MAIN_MENU_STANDARD) : $conf->global->MAIN_MENU_STANDARD_FORCED);
1397 $conf->standard_menu = (empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED) ? (empty($conf->global->MAIN_MENUFRONT_STANDARD) ?
'eldy_menu.php' : $conf->global->MAIN_MENUFRONT_STANDARD) : $conf->global->MAIN_MENUFRONT_STANDARD_FORCED);
1401 $file_menu = $conf->standard_menu;
1402 if (
GETPOST(
'menu',
'alpha')) {
1403 $file_menu =
GETPOST(
'menu',
'alpha');
1405 if (!class_exists(
'MenuManager')) {
1407 $dirmenus = array_merge(array(
"/core/menus/"), (array) $conf->modules_parts[
'menus']);
1408 foreach ($dirmenus as $dirmenu) {
1410 if (class_exists(
'MenuManager')) {
1414 if (!class_exists(
'MenuManager')) {
1415 dol_syslog(
"You define a menu manager '".$file_menu.
"' that can not be loaded.", LOG_WARNING);
1416 $file_menu =
'eldy_menu.php';
1417 include_once DOL_DOCUMENT_ROOT.
"/core/menus/standard/".$file_menu;
1420 $menumanager =
new MenuManager($db, empty($user->socid) ? 0 : 1);
1424if (!empty(
GETPOST(
'seteventmessages',
'alpha'))) {
1425 $message =
GETPOST(
'seteventmessages',
'alpha');
1426 $messages = explode(
',', $message);
1427 foreach ($messages as $key => $msg) {
1428 $tmp = explode(
':', $msg);
1435if (!function_exists(
"llxHeader")) {
1456 function llxHeader($head =
'', $title =
'', $help_url =
'', $target =
'', $disablejs = 0, $disablehead = 0, $arrayofjs =
'', $arrayofcss =
'', $morequerystring =
'', $morecssonbody =
'', $replacemainareaby =
'', $disablenofollow = 0, $disablenoindex = 0)
1458 global $conf, $hookmanager;
1461 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss, 0, $disablenofollow, $disablenoindex);
1463 $tmpcsstouse =
'sidebar-collapse'.($morecssonbody ?
' '.$morecssonbody :
'');
1465 if ($conf->theme ==
'md' && !in_array($conf->browser->layout, array(
'phone',
'tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1467 if ($mainmenu !=
'website') {
1468 $tmpcsstouse = $morecssonbody;
1472 if (!empty($conf->global->MAIN_OPTIMIZEFORCOLORBLIND)) {
1473 $tmpcsstouse .=
' colorblind-'.strip_tags($conf->global->MAIN_OPTIMIZEFORCOLORBLIND);
1476 print
'<body id="mainbody" class="'.$tmpcsstouse.
'">'.
"\n";
1478 $parameters = array(
'help_url' => $help_url);
1479 $reshook = $hookmanager->executeHooks(
'changeHelpURL', $parameters);
1481 $help_url = $hookmanager->resPrint;
1485 if ((empty($conf->dol_hide_topmenu) ||
GETPOST(
'dol_invisible_topmenu',
'int')) && !
GETPOST(
'dol_openinpopup',
'aZ09')) {
1486 top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring, $help_url);
1489 if (empty($conf->dol_hide_leftmenu) && !
GETPOST(
'dol_openinpopup',
'aZ09')) {
1490 left_menu(array(), $help_url,
'',
'', 1, $title, 1);
1494 if ($replacemainareaby) {
1495 print $replacemainareaby;
1641function top_htmlhead($head, $title =
'', $disablejs = 0, $disablehead = 0, $arrayofjs =
'', $arrayofcss =
'', $disableforlogin = 0, $disablenofollow = 0, $disablenoindex = 0)
1643 global $db, $conf, $langs, $user, $mysoc, $hookmanager;
1647 if (empty($conf->css)) {
1648 $conf->css =
'/theme/eldy/style.css.php';
1651 print
'<!doctype html>'.
"\n";
1653 print
'<html lang="'.substr($langs->defaultlang, 0, 2).
'">'.
"\n";
1656 if (empty($disablehead)) {
1657 if (!is_object($hookmanager)) {
1658 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
1661 $hookmanager->initHooks(array(
"main"));
1663 $ext =
'layout='.$conf->browser->layout.
'&version='.urlencode(DOL_VERSION);
1667 if (
GETPOST(
'dol_basehref',
'alpha')) {
1668 print
'<base href="'.dol_escape_htmltag(
GETPOST(
'dol_basehref',
'alpha')).
'">'.
"\n";
1672 print
'<meta charset="utf-8">'.
"\n";
1673 print
'<meta name="robots" content="'.($disablenoindex ?
'index' :
'noindex').($disablenofollow ?
',follow' :
',nofollow').
'">'.
"\n";
1674 print
'<meta name="viewport" content="width=device-width, initial-scale=1.0">'.
"\n";
1675 print
'<meta name="author" content="Dolibarr Development Team">'.
"\n";
1676 print
'<meta name="anti-csrf-newtoken" content="'.newToken().
'">'.
"\n";
1677 print
'<meta name="anti-csrf-currenttoken" content="'.currentToken().
'">'.
"\n";
1679 print
'<meta name="MAIN_FEATURES_LEVEL" content="'.getDolGlobalInt(
'MAIN_FEATURES_LEVEL').
'">'.
"\n";
1682 $favicon = DOL_URL_ROOT.
'/theme/dolibarr_256x256_color.png';
1683 if (!empty($mysoc->logo_squarred_mini)) {
1684 $favicon = DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/thumbs/'.$mysoc->logo_squarred_mini);
1689 if (empty($conf->dol_use_jmobile)) {
1690 print
'<link rel="shortcut icon" type="image/x-icon" href="'.$favicon.
'"/>'.
"\n";
1698 $manifest = DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/manifest.json.php';
1699 if (!empty($manifest)) {
1700 print
'<link rel="manifest" href="'.$manifest.
'" />'.
"\n";
1703 if (!empty($conf->global->THEME_ELDY_TOPMENU_BACK1)) {
1705 print
'<meta name="theme-color" content="rgb('.$conf->global->THEME_ELDY_TOPMENU_BACK1.
')">'.
"\n";
1709 if (
GETPOST(
'autorefresh',
'int') > 0) {
1710 print
'<meta http-equiv="refresh" content="'.GETPOST(
'autorefresh',
'int').
'">';
1714 $appli = constant(
'DOL_APPLICATION_TITLE');
1715 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
1716 $appli = $conf->global->MAIN_APPLICATION_TITLE;
1721 if ($title && !empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/noapp/', $conf->global->MAIN_HTML_TITLE)) {
1729 $parameters = array(
'title'=>$titletoshow);
1730 $result = $hookmanager->executeHooks(
'setHtmlTitle', $parameters);
1732 $titletoshow = $hookmanager->resPrint;
1734 $titletoshow .= $hookmanager->resPrint;
1742 if (
GETPOST(
'version',
'int')) {
1743 $ext =
'version='.GETPOST(
'version',
'int');
1746 if (
GETPOST(
'dol_resetcache')) {
1747 include_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
1751 $themeparam =
'?lang='.$langs->defaultlang.
'&theme='.$conf->theme.(GETPOST(
'optioncss',
'aZ09') ?
'&optioncss='.GETPOST(
'optioncss',
'aZ09', 1) :
'').(empty($user->id) ?
'' : (
'&userid='.$user->id)).
'&entity='.$conf->entity;
1753 $themeparam .= ($ext ?
'&'.$ext :
'').
'&revision='.
getDolGlobalInt(
"MAIN_IHM_PARAMS_REV");
1754 if (GETPOSTISSET(
'dol_hide_topmenu')) {
1755 $themeparam .=
'&dol_hide_topmenu='.GETPOST(
'dol_hide_topmenu',
'int');
1757 if (GETPOSTISSET(
'dol_hide_leftmenu')) {
1758 $themeparam .=
'&dol_hide_leftmenu='.GETPOST(
'dol_hide_leftmenu',
'int');
1760 if (GETPOSTISSET(
'dol_optimize_smallscreen')) {
1761 $themeparam .=
'&dol_optimize_smallscreen='.GETPOST(
'dol_optimize_smallscreen',
'int');
1763 if (GETPOSTISSET(
'dol_no_mouse_hover')) {
1764 $themeparam .=
'&dol_no_mouse_hover='.GETPOST(
'dol_no_mouse_hover',
'int');
1766 if (GETPOSTISSET(
'dol_use_jmobile')) {
1767 $themeparam .=
'&dol_use_jmobile='.GETPOST(
'dol_use_jmobile',
'int'); $conf->dol_use_jmobile =
GETPOST(
'dol_use_jmobile',
'int');
1769 if (GETPOSTISSET(
'THEME_DARKMODEENABLED')) {
1770 $themeparam .=
'&THEME_DARKMODEENABLED='.GETPOST(
'THEME_DARKMODEENABLED',
'int');
1772 if (GETPOSTISSET(
'THEME_SATURATE_RATIO')) {
1773 $themeparam .=
'&THEME_SATURATE_RATIO='.GETPOST(
'THEME_SATURATE_RATIO',
'int');
1776 if (!empty($conf->global->MAIN_ENABLE_FONT_ROBOTO)) {
1777 print
'<link rel="preconnect" href="https://fonts.gstatic.com">'.
"\n";
1778 print
'<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@200;300;400;500;600&display=swap" rel="stylesheet">'.
"\n";
1781 if (!defined(
'DISABLE_JQUERY') && !$disablejs && $conf->use_javascript_ajax) {
1782 print
'<!-- Includes CSS for JQuery (Ajax library) -->'.
"\n";
1783 $jquerytheme =
'base';
1784 if (!empty($conf->global->MAIN_USE_JQUERY_THEME)) {
1785 $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME;
1787 if (constant(
'JS_JQUERY_UI')) {
1788 print
'<link rel="stylesheet" type="text/css" href="'.JS_JQUERY_UI.
'css/'.$jquerytheme.
'/jquery-ui.min.css'.($ext ?
'?'.$ext :
'').
'">'.
"\n";
1790 print
'<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.
'/includes/jquery/css/'.$jquerytheme.
'/jquery-ui.css'.($ext ?
'?'.$ext :
'').
'">'.
"\n";
1792 if (!defined(
'DISABLE_JQUERY_JNOTIFY')) {
1793 print
'<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jnotify/jquery.jnotify-alt.min.css'.($ext ?
'?'.$ext :
'').
'">'.
"\n";
1795 if (!defined(
'DISABLE_SELECT2') && (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined(
'REQUIRE_JQUERY_MULTISELECT'))) {
1796 $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant(
'REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
1797 print
'<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.
'/includes/jquery/plugins/'.$tmpplugin.
'/dist/css/'.$tmpplugin.
'.css'.($ext ?
'?'.$ext :
'').
'">'.
"\n";
1801 if (!defined(
'DISABLE_FONT_AWSOME')) {
1802 print
'<!-- Includes CSS for font awesome -->'.
"\n";
1803 print
'<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.
'/theme/common/fontawesome-5/css/all.min.css'.($ext ?
'?'.$ext :
'').
'">'.
"\n";
1804 print
'<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.
'/theme/common/fontawesome-5/css/v4-shims.min.css'.($ext ?
'?'.$ext :
'').
'">'.
"\n";
1807 print
'<!-- Includes CSS for Dolibarr theme -->'.
"\n";
1811 if (!empty($conf->modules_parts[
'theme'])) {
1812 foreach ($conf->modules_parts[
'theme'] as $reldir) {
1815 $themesubdir = $reldir;
1822 print
'<link rel="stylesheet" type="text/css" href="'.$themepath.$themeparam.
'">'.
"\n";
1823 if (!empty($conf->global->MAIN_FIX_FLASH_ON_CHROME)) {
1824 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";
1828 if (!empty($conf->modules_parts[
'css'])) {
1829 $arraycss = (array) $conf->modules_parts[
'css'];
1830 foreach ($arraycss as $modcss => $filescss) {
1831 $filescss = (array) $filescss;
1832 foreach ($filescss as $cssfile) {
1833 if (empty($cssfile)) {
1834 dol_syslog(
"Warning: module ".$modcss.
" declared a css path file into its descriptor that is empty.", LOG_WARNING);
1838 if ($urlforcss && $urlforcss !=
'/') {
1839 print
'<!-- Includes CSS added by module '.$modcss.
' -->'.
"\n".
'<link rel="stylesheet" type="text/css" href="'.$urlforcss;
1841 if (!preg_match(
'/\.css$/i', $cssfile)) {
1846 dol_syslog(
"Warning: module ".$modcss.
" declared a css path file for a file we can't find.", LOG_WARNING);
1852 if (is_array($arrayofcss)) {
1853 foreach ($arrayofcss as $cssfile) {
1854 if (preg_match(
'/^(http|\/\/)/i', $cssfile)) {
1855 $urltofile = $cssfile;
1859 print
'<!-- Includes CSS added by page -->'.
"\n".
'<link rel="stylesheet" type="text/css" title="default" href="'.$urltofile;
1861 if (!preg_match(
'/\.css$/i', $cssfile)) {
1871 print
'<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.
'/theme/custom.css.php'.($ext ?
'?'.$ext :
'').
'&revision='.
getDolGlobalInt(
"MAIN_IHM_PARAMS_REV").
'">'.
"\n";
1875 if (!defined(
'DISABLE_JQUERY') && !$disablejs && !empty($conf->use_javascript_ajax)) {
1877 print
'<!-- Includes JS for JQuery -->'.
"\n";
1878 if (defined(
'JS_JQUERY') && constant(
'JS_JQUERY')) {
1879 print
'<script nonce="'.getNonce().
'" src="'.JS_JQUERY.
'jquery.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
1881 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/js/jquery.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
1883 if (defined(
'JS_JQUERY_UI') && constant(
'JS_JQUERY_UI')) {
1884 print
'<script nonce="'.getNonce().
'" src="'.JS_JQUERY_UI.
'jquery-ui.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
1886 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/js/jquery-ui.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
1889 if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && !defined(
'DISABLE_JQUERY_JNOTIFY')) {
1890 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jnotify/jquery.jnotify.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
1893 if (empty($disableforlogin) && !defined(
'DISABLE_JQUERY_TABLEDND')) {
1894 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/tablednd/jquery.tablednd.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
1897 if (empty($disableforlogin) && (empty($conf->global->MAIN_JS_GRAPH) || $conf->global->MAIN_JS_GRAPH ==
'chart') && !defined(
'DISABLE_JS_GRAPH')) {
1898 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/nnnick/chartjs/dist/chart.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
1902 if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !defined(
'DISABLE_JQUERY_JEDITABLE')) {
1903 print
'<!-- JS to manage editInPlace feature -->'.
"\n";
1904 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jeditable/jquery.jeditable.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
1905 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jeditable/jquery.jeditable.ui-datepicker.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
1906 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jeditable/jquery.jeditable.ui-autocomplete.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
1907 print
'<script>'.
"\n";
1908 print
'var urlSaveInPlace = \''.DOL_URL_ROOT.
'/core/ajax/saveinplace.php\';'.
"\n";
1909 print
'var urlLoadInPlace = \''.DOL_URL_ROOT.
'/core/ajax/loadinplace.php\';'.
"\n";
1910 print
'var tooltipInPlace = \''.$langs->transnoentities(
'ClickToEdit').
'\';
'."\n"; // Added in title attribute of span
1911 print 'var placeholderInPlace = \
' \';'.
"\n";
1912 print
'var cancelInPlace = \''.$langs->trans(
"Cancel").
'\';
'."\n";
1913 print 'var submitInPlace = \
''.$langs->trans(
'Ok').
'\';
'."\n";
1914 print 'var indicatorInPlace = \
'<img src="'.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'">\';'.
"\n";
1915 print
'var withInPlace = 300;';
1916 print
'</script>'.
"\n";
1917 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/core/js/editinplace.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
1918 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jeditable/jquery.jeditable.ckeditor.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
1921 if (!empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined(
'REQUIRE_JQUERY_TIMEPICKER')) {
1922 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
1923 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/core/js/timepicker.js.php?lang='.$langs->defaultlang.($ext ?
'&'.$ext :
'').
'"></script>'.
"\n";
1925 if (!defined(
'DISABLE_SELECT2') && (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined(
'REQUIRE_JQUERY_MULTISELECT'))) {
1927 $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant(
'REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
1928 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/'.$tmpplugin.
'/dist/js/'.$tmpplugin.
'.full.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
1930 if (!defined(
'DISABLE_MULTISELECT')) {
1931 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/multiselect/jquery.multi-select.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
1935 if (!$disablejs && !empty($conf->use_javascript_ajax)) {
1937 if (empty($disableforlogin) && (isModEnabled(
'fckeditor') && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME ==
'ckeditor') && !defined(
'DISABLE_CKEDITOR')) || defined(
'FORCE_CKEDITOR')) {
1938 print
'<!-- Includes JS for CKEditor -->'.
"\n";
1939 $pathckeditor = DOL_URL_ROOT.
'/includes/ckeditor/ckeditor/';
1940 $jsckeditor =
'ckeditor.js';
1941 if (constant(
'JS_CKEDITOR')) {
1943 $pathckeditor = constant(
'JS_CKEDITOR');
1945 print
'<script nonce="'.getNonce().
'">';
1946 print
'/* enable ckeditor by main.inc.php */';
1947 print
'var CKEDITOR_BASEPATH = \''.dol_escape_js($pathckeditor).
'\';
'."\n";
1948 print 'var ckeditorConfig = \
''.dol_escape_js(
dol_buildpath($themesubdir.
'/theme/'.$conf->theme.
'/ckeditor/config.js'.($ext ?
'?'.$ext :
''), 1)).
'\';
'."\n"; // $themesubdir='' in standard usage
1949 print 'var ckeditorFilebrowserBrowseUrl = \
''.DOL_URL_ROOT.
'/core/filemanagerdol/browser/default/browser.php?Connector='.DOL_URL_ROOT.
'/core/filemanagerdol/connectors/php/connector.php\';'.
"\n";
1950 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";
1951 print
'</script>'.
"\n";
1952 print
'<script src="'.$pathckeditor.$jsckeditor.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
1954 if (
GETPOST(
'mode',
'aZ09') ==
'Full_inline') {
1955 print
'CKEDITOR.disableAutoInline = false;'.
"\n";
1957 print
'CKEDITOR.disableAutoInline = true;'.
"\n";
1959 print
'</script>'.
"\n";
1963 if (!defined(
'NOBROWSERNOTIF') && !defined(
'NOREQUIREMENU') && !defined(
'NOLOGIN')) {
1964 $enablebrowsernotif =
false;
1965 if (isModEnabled(
'agenda') && !empty($conf->global->AGENDA_REMINDER_BROWSER)) {
1966 $enablebrowsernotif =
true;
1968 if ($conf->browser->layout ==
'phone') {
1969 $enablebrowsernotif =
false;
1971 if ($enablebrowsernotif) {
1972 print
'<!-- Includes JS of Dolibarr (browser layout = '.$conf->browser->layout.
')-->'.
"\n";
1973 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/core/js/lib_notification.js.php'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
1978 print
'<!-- Includes JS of Dolibarr -->'.
"\n";
1979 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/core/js/lib_head.js.php?lang='.$langs->defaultlang.($ext ?
'&'.$ext :
'').
'"></script>'.
"\n";
1982 if (!empty($conf->modules_parts[
'js'])) {
1983 $arrayjs = (array) $conf->modules_parts[
'js'];
1984 foreach ($arrayjs as $modjs => $filesjs) {
1985 $filesjs = (array) $filesjs;
1986 foreach ($filesjs as $jsfile) {
1989 if ($urlforjs && $urlforjs !=
'/') {
1990 print
'<!-- Include JS added by module '.$modjs.
'-->'.
"\n";
1991 print
'<script nonce="'.getNonce().
'" src="'.$urlforjs.((strpos($jsfile,
'?') ===
false) ?
'?' :
'&').
'lang='.$langs->defaultlang.
'"></script>'.
"\n";
1993 dol_syslog(
"Warning: module ".$modjs.
" declared a js path file for a file we can't find.", LOG_WARNING);
1999 if (is_array($arrayofjs)) {
2000 print
'<!-- Includes JS added by page -->'.
"\n";
2001 foreach ($arrayofjs as $jsfile) {
2002 if (preg_match(
'/^(http|\/\/)/i', $jsfile)) {
2003 print
'<script nonce="'.getNonce().
'" src="'.$jsfile.((strpos($jsfile,
'?') ===
false) ?
'?' :
'&').
'lang='.$langs->defaultlang.
'"></script>'.
"\n";
2005 print
'<script nonce="'.getNonce().
'" src="'.
dol_buildpath($jsfile, 1).((strpos($jsfile,
'?') ===
false) ?
'?' :
'&').
'lang='.$langs->defaultlang.
'"></script>'.
"\n";
2012 if (!empty($conf->global->ALLOW_THEME_JS)) {
2013 $theme_js =
dol_buildpath(
'/theme/'.$conf->theme.
'/'.$conf->theme.
'.js', 0);
2014 if (file_exists($theme_js)) {
2015 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/'.$conf->theme.
'.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2019 if (!empty($head)) {
2022 if (!empty($conf->global->MAIN_HTML_HEADER)) {
2023 print $conf->global->MAIN_HTML_HEADER.
"\n";
2026 $parameters = array();
2027 $result = $hookmanager->executeHooks(
'addHtmlHeader', $parameters);
2028 print $hookmanager->resPrint;
2030 print
"</head>\n\n";
2033 $conf->headerdone = 1;
3094function left_menu($menu_array_before, $helppagename =
'', $notused =
'', $menu_array_after =
'', $leftmenuwithoutmainarea = 0, $title =
'', $acceptdelayedhtml = 0)
3096 global $user, $conf, $langs, $db, $form;
3097 global $hookmanager, $menumanager;
3101 if (!empty($menu_array_before)) {
3102 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);
3105 if (empty($conf->dol_hide_leftmenu) && (!defined(
'NOREQUIREMENU') || !constant(
'NOREQUIREMENU'))) {
3107 $hookmanager->initHooks(array(
'leftblock'));
3109 print
"\n".
'<!-- Begin side-nav id-left -->'.
"\n".
'<div class="side-nav"><div id="id-left">'.
"\n";
3112 if (!is_object($form)) {
3113 $form =
new Form($db);
3116 if (empty($conf->global->MAIN_USE_TOP_MENU_SEARCH_DROPDOWN)) {
3118 if ($conf->browser->layout ==
'phone') {
3119 $conf->global->MAIN_USE_OLD_SEARCH_FORM = 1;
3123 $arrayresult = array();
3124 include DOL_DOCUMENT_ROOT.
'/core/ajax/selectsearchbox.php';
3126 if ($conf->use_javascript_ajax && empty($conf->global->MAIN_USE_OLD_SEARCH_FORM)) {
3129 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
3130 if ($conf->browser->name ==
'chrome') {
3131 $stringforfirstkey .=
' ALT +';
3132 } elseif ($conf->browser->name ==
'firefox') {
3133 $stringforfirstkey .=
' ALT + SHIFT +';
3135 $stringforfirstkey .=
' CTL +';
3138 $searchform .= $form->selectArrayFilter(
'searchselectcombo', $arrayresult, $selected,
'accesskey="s"', 1, 0, (empty($conf->global->MAIN_SEARCHBOX_CONTENT_LOADED_BEFORE_KEY) ? 1 : 0),
'vmenusearchselectcombo', 1, $langs->trans(
"Search"), 1, $stringforfirstkey.
' s');
3140 if (is_array($arrayresult)) {
3141 foreach ($arrayresult as $key => $val) {
3142 $searchform .=
printSearchForm($val[
'url'], $val[
'url'], $val[
'label'],
'maxwidth125',
'search_all', (empty($val[
'shortcut']) ?
'' : $val[
'shortcut']),
'searchleft'.$key, $val[
'img']);
3148 $parameters = array(
'searchform' => $searchform);
3149 $reshook = $hookmanager->executeHooks(
'printSearchForm', $parameters);
3150 if (empty($reshook)) {
3151 $searchform .= $hookmanager->resPrint;
3153 $searchform = $hookmanager->resPrint;
3157 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) || empty($conf->use_javascript_ajax)) {
3158 $urltosearch = DOL_URL_ROOT.
'/core/search_page.php?showtitlebefore=1';
3159 $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>';
3160 } elseif ($conf->use_javascript_ajax && !empty($conf->global->MAIN_USE_OLD_SEARCH_FORM)) {
3161 $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>';
3162 $searchform .=
'<script>
3163 jQuery(document).ready(function () {
3164 jQuery("#divsearchforms1").click(function(){
3165 jQuery("#divsearchforms2").toggle();
3169 $searchform .=
'</div>';
3173 $searchform .=
'<script>
3174 jQuery(document).keydown(function(e){
3175 if( e.which === 70 && e.ctrlKey && e.shiftKey ){
3176 console.log(\'control + shift + f : trigger open global-search dropdown\');
3177 openGlobalSearchDropDown();
3179 if( (e.which === 83 || e.which === 115) && e.altKey ){
3180 console.log(\'alt + s : trigger open global-search dropdown\');
3181 openGlobalSearchDropDown();
3185 var openGlobalSearchDropDown = function() {
3186 jQuery("#searchselectcombo").select2(\'open\');
3192 print
'<!-- Begin left menu -->'.
"\n";
3194 print
'<div class="vmenu"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ?
'' :
' title="Left menu"').
'>'.
"\n\n";
3197 $menumanager->menu_array = $menu_array_before;
3198 $menumanager->menu_array_after = $menu_array_after;
3199 $menumanager->showmenu(
'left', array(
'searchform'=>$searchform));
3203 print
"<!-- Begin Help Block-->\n";
3204 print
'<div id="blockvmenuhelp" class="blockvmenuhelp">'.
"\n";
3207 if (!empty($conf->global->MAIN_SHOW_VERSION)) {
3208 $doliurl =
'https://www.dolibarr.org';
3210 if (preg_match(
'/fr/i', $langs->defaultlang)) {
3211 $doliurl =
'https://www.dolibarr.fr';
3213 if (preg_match(
'/es/i', $langs->defaultlang)) {
3214 $doliurl =
'https://www.dolibarr.es';
3216 if (preg_match(
'/de/i', $langs->defaultlang)) {
3217 $doliurl =
'https://www.dolibarr.de';
3219 if (preg_match(
'/it/i', $langs->defaultlang)) {
3220 $doliurl =
'https://www.dolibarr.it';
3222 if (preg_match(
'/gr/i', $langs->defaultlang)) {
3223 $doliurl =
'https://www.dolibarr.gr';
3226 $appli = constant(
'DOL_APPLICATION_TITLE');
3227 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
3228 $appli = $conf->global->MAIN_APPLICATION_TITLE; $doliurl =
'';
3229 if (preg_match(
'/\d\.\d/', $appli)) {
3230 if (!preg_match(
'/'.preg_quote(DOL_VERSION).
'/', $appli)) {
3231 $appli .=
" (".DOL_VERSION.
")";
3234 $appli .=
" ".DOL_VERSION;
3237 $appli .=
" ".DOL_VERSION;
3239 print
'<div id="blockvmenuhelpapp" class="blockvmenuhelp">';
3241 print
'<a class="help" target="_blank" rel="noopener noreferrer" href="'.$doliurl.
'">';
3243 print
'<span class="help">';
3251 print
'</div>'.
"\n";
3255 if (!empty($conf->global->MAIN_BUGTRACK_ENABLELINK)) {
3256 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
3258 if ($conf->global->MAIN_BUGTRACK_ENABLELINK ==
'github') {
3259 $bugbaseurl =
'https://github.com/Dolibarr/dolibarr/issues/new?labels=Bug';
3260 $bugbaseurl .=
'&title=';
3261 $bugbaseurl .= urlencode(
"Bug: ");
3262 $bugbaseurl .=
'&body=';
3263 $bugbaseurl .= urlencode(
"# Instructions\n");
3264 $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");
3265 $bugbaseurl .= urlencode(
"*Please:*\n");
3266 $bugbaseurl .= urlencode(
"- *replace the bracket enclosed texts with meaningful information*\n");
3267 $bugbaseurl .= urlencode(
"- *remove any unused sub-section*\n");
3268 $bugbaseurl .= urlencode(
"\n");
3269 $bugbaseurl .= urlencode(
"\n");
3270 $bugbaseurl .= urlencode(
"# Bug\n");
3271 $bugbaseurl .= urlencode(
"[*Short description*]\n");
3272 $bugbaseurl .= urlencode(
"\n");
3273 $bugbaseurl .= urlencode(
"## Environment\n");
3274 $bugbaseurl .= urlencode(
"- **Version**: ".DOL_VERSION.
"\n");
3275 $bugbaseurl .= urlencode(
"- **OS**: ".php_uname(
's').
"\n");
3276 $bugbaseurl .= urlencode(
"- **Web server**: ".$_SERVER[
"SERVER_SOFTWARE"].
"\n");
3277 $bugbaseurl .= urlencode(
"- **PHP**: ".php_sapi_name().
' '.phpversion().
"\n");
3278 $bugbaseurl .= urlencode(
"- **Database**: ".$db::LABEL.
' '.$db->getVersion().
"\n");
3279 $bugbaseurl .= urlencode(
"- **URL(s)**: ".$_SERVER[
"REQUEST_URI"].
"\n");
3280 $bugbaseurl .= urlencode(
"\n");
3281 $bugbaseurl .= urlencode(
"## Expected and actual behavior\n");
3282 $bugbaseurl .= urlencode(
"[*Verbose description*]\n");
3283 $bugbaseurl .= urlencode(
"\n");
3284 $bugbaseurl .= urlencode(
"## Steps to reproduce the behavior\n");
3285 $bugbaseurl .= urlencode(
"[*Verbose description*]\n");
3286 $bugbaseurl .= urlencode(
"\n");
3287 $bugbaseurl .= urlencode(
"## [Attached files](https://help.github.com/articles/issue-attachments) (Screenshots, screencasts, dolibarr.log, debugging informations…)\n");
3288 $bugbaseurl .= urlencode(
"[*Files*]\n");
3289 $bugbaseurl .= urlencode(
"\n");
3291 $bugbaseurl .= urlencode(
"\n");
3292 $bugbaseurl .= urlencode(
"## Report\n");
3293 } elseif (!empty($conf->global->MAIN_BUGTRACK_ENABLELINK)) {
3294 $bugbaseurl = $conf->global->MAIN_BUGTRACK_ENABLELINK;
3300 $parameters = array(
'bugbaseurl' => $bugbaseurl);
3301 $reshook = $hookmanager->executeHooks(
'printBugtrackInfo', $parameters);
3302 if (empty($reshook)) {
3303 $bugbaseurl .= $hookmanager->resPrint;
3305 $bugbaseurl = $hookmanager->resPrint;
3308 print
'<div id="blockvmenuhelpbugreport" class="blockvmenuhelp">';
3309 print
'<a class="help" target="_blank" rel="noopener noreferrer" href="'.$bugbaseurl.
'"><i class="fas fa-bug"></i> '.$langs->trans(
"FindBug").
'</a>';
3314 print
"<!-- End Help Block-->\n";
3318 print
"<!-- End left menu -->\n";
3322 $parameters = array();
3323 $reshook = $hookmanager->executeHooks(
'printLeftBlock', $parameters);
3324 print $hookmanager->resPrint;
3326 print
'</div></div> <!-- End side-nav id-left -->';
3330 print
'<!-- Begin right area -->'.
"\n";
3332 if (empty($leftmenuwithoutmainarea)) {
3466function printSearchForm($urlaction, $urlobject, $title, $htmlmorecss, $htmlinputname, $accesskey =
'', $prefhtmlinputname =
'', $img =
'', $showtitlebefore = 0, $autofocus = 0)
3468 global $langs, $user;
3471 $ret .=
'<form action="'.$urlaction.
'" method="post" class="searchform nowraponall tagtr">';
3472 $ret .=
'<input type="hidden" name="token" value="'.newToken().
'">';
3473 $ret .=
'<input type="hidden" name="savelogin" value="'.dol_escape_htmltag($user->login).
'">';
3474 if ($showtitlebefore) {
3475 $ret .=
'<div class="tagtd left">'.$title.
'</div> ';
3477 $ret .=
'<div class="tagtd">';
3478 $ret .=
img_picto(
'', $img,
'',
false, 0, 0,
'',
'paddingright width20');
3479 $ret .=
'<input type="text" class="flat '.$htmlmorecss.
'"';
3480 $ret .=
' style="background-repeat: no-repeat; background-position: 3px;"';
3481 $ret .= ($accesskey ?
' accesskey="'.$accesskey.
'"' :
'');
3482 $ret .=
' placeholder="'.strip_tags($title).
'"';
3483 $ret .= ($autofocus ?
' autofocus' :
'');
3484 $ret .=
' name="'.$htmlinputname.
'" id="'.$prefhtmlinputname.$htmlinputname.
'" />';
3485 $ret .=
'<button type="submit" class="button bordertransp" style="padding-top: 4px; padding-bottom: 4px; padding-left: 6px; padding-right: 6px">';
3486 $ret .=
'<span class="fa fa-search"></span>';
3487 $ret .=
'</button>';
3489 $ret .=
"</form>\n";
3494if (!function_exists(
"llxFooter")) {
3505 function llxFooter($comment =
'', $zone =
'private', $disabledoutputofmessages = 0)
3507 global $conf, $db, $langs, $user, $mysoc, $object, $hookmanager;
3508 global $delayedhtmlcontent;
3509 global $contextpage, $page, $limit, $mode;
3510 global $dolibarr_distrib;
3512 $ext =
'layout='.urlencode($conf->browser->layout).
'&version='.urlencode(DOL_VERSION);
3516 $parameters = array();
3517 $reshook = $hookmanager->executeHooks(
'llxFooter', $parameters, $object, $action);
3518 if (empty($reshook)) {
3519 $llxfooter .= $hookmanager->resPrint;
3520 } elseif ($reshook > 0) {
3521 $llxfooter = $hookmanager->resPrint;
3532 if (is_object($user) && !empty($user->lastsearch_values_tmp) && is_array($user->lastsearch_values_tmp)) {
3534 foreach ($user->lastsearch_values_tmp as $key => $val) {
3535 unset($_SESSION[
'lastsearch_values_tmp_'.$key]);
3536 if (count($val) && empty($_POST[
'button_removefilter']) && empty($_POST[
'button_removefilter_x'])) {
3537 if (empty($val[
'sortfield'])) {
3538 unset($val[
'sortfield']);
3540 if (empty($val[
'sortorder'])) {
3541 unset($val[
'sortorder']);
3543 dol_syslog(
'Save lastsearch_values_tmp_'.$key.
'='.json_encode($val, 0).
" (systematic recording of last search criterias)");
3544 $_SESSION[
'lastsearch_values_tmp_'.$key] = json_encode($val);
3545 unset($_SESSION[
'lastsearch_values_'.$key]);
3551 $relativepathstring = $_SERVER[
"PHP_SELF"];
3553 if (constant(
'DOL_URL_ROOT')) {
3554 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
3556 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
3557 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
3558 if (preg_match(
'/list\.php$/', $relativepathstring)) {
3559 unset($_SESSION[
'lastsearch_contextpage_tmp_'.$relativepathstring]);
3560 unset($_SESSION[
'lastsearch_page_tmp_'.$relativepathstring]);
3561 unset($_SESSION[
'lastsearch_limit_tmp_'.$relativepathstring]);
3562 unset($_SESSION[
'lastsearch_mode_tmp_'.$relativepathstring]);
3564 if (!empty($contextpage)) {
3565 $_SESSION[
'lastsearch_contextpage_tmp_'.$relativepathstring] = $contextpage;
3567 if (!empty($page) && $page > 0) {
3568 $_SESSION[
'lastsearch_page_tmp_'.$relativepathstring] = $page;
3570 if (!empty($limit) && $limit != $conf->liste_limit) {
3571 $_SESSION[
'lastsearch_limit_tmp_'.$relativepathstring] = $limit;
3573 if (!empty($mode)) {
3574 $_SESSION[
'lastsearch_mode_tmp_'.$relativepathstring] = $mode;
3577 unset($_SESSION[
'lastsearch_contextpage_'.$relativepathstring]);
3578 unset($_SESSION[
'lastsearch_page_'.$relativepathstring]);
3579 unset($_SESSION[
'lastsearch_limit_'.$relativepathstring]);
3580 unset($_SESSION[
'lastsearch_mode_'.$relativepathstring]);
3584 if (!empty($conf->global->MAIN_CORE_ERROR)) {
3586 if ($conf->use_javascript_ajax) {
3587 $title =
img_warning().
' '.$langs->trans(
'CoreErrorTitle');
3588 print
ajax_dialog($title, $langs->trans(
'CoreErrorMessage'));
3591 $msg =
img_warning().
' '.$langs->trans(
'CoreErrorMessage');
3592 print
'<div class="error">'.$msg.
'</div>';
3600 print
'</div> <!-- End div class="fiche" -->'.
"\n";
3602 if (empty($conf->dol_hide_leftmenu) && !
GETPOST(
'dol_openinpopup')) {
3603 print
'</div> <!-- End div id-right -->'.
"\n";
3606 if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) {
3607 print
'</div> <!-- End div id-container -->'.
"\n";
3612 print
'<!-- '.$comment.
' -->'.
"\n";
3617 if (!empty($delayedhtmlcontent)) {
3618 print $delayedhtmlcontent;
3621 if (!empty($conf->use_javascript_ajax)) {
3622 print
"\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
3623 print
'<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.($ext ?
'&'.$ext :
'').
'"></script>'.
"\n";
3627 if (isModEnabled(
'blockedlog') && is_object($object) && !empty($object->id) && $object->id > 0) {
3628 if (in_array($object->element, array(
'facture')) && $object->statut > 0) {
3629 print
"\n<!-- JS CODE TO ENABLE log when making a download or a preview of a document -->\n";
3632 jQuery(document).ready(
function () {
3633 $(
'a.documentpreview').click(
function() {
3634 $.post(
'<?php echo DOL_URL_ROOT."/blockedlog/ajax/block-add.php" ?>'
3636 id:<?php echo $object->id; ?>
3637 , element:
'<?php echo $object->element ?>'
3638 , action:
'DOC_PREVIEW'
3639 , token:
'<?php echo currentToken(); ?>'
3643 $(
'a.documentdownload').click(
function() {
3644 $.post(
'<?php echo DOL_URL_ROOT."/blockedlog/ajax/block-add.php" ?>'
3646 id:<?php echo $object->id; ?>
3647 , element:
'<?php echo $object->element ?>'
3648 , action:
'DOC_DOWNLOAD'
3649 , token:
'<?php echo currentToken(); ?>'
3660 print
"\n<!-- A div to allow dialog popup by jQuery('#dialogforpopup').dialog() -->\n";
3661 print
'<div id="dialogforpopup" style="display: none;"></div>'.
"\n";
3665 $forceping =
GETPOST(
'forceping',
'alpha');
3666 if (($_SERVER[
"PHP_SELF"] == DOL_URL_ROOT.
'/index.php') || $forceping) {
3668 $hash_unique_id = md5(
'dolibarr'.$conf->file->instance_unique_id);
3670 if (empty($conf->global->MAIN_FIRST_PING_OK_DATE)
3671 || (!empty($conf->file->instance_unique_id) && ($hash_unique_id != $conf->global->MAIN_FIRST_PING_OK_ID) && ($conf->global->MAIN_FIRST_PING_OK_ID !=
'disabled'))
3674 if (strpos(
'alpha', DOL_VERSION) > 0 && !$forceping) {
3675 print
"\n<!-- NO JS CODE TO ENABLE the anonymous Ping. It is an alpha version -->\n";
3676 } elseif (empty($_COOKIE[
'DOLINSTALLNOPING_'.$hash_unique_id]) || $forceping) {
3679 if (!empty($conf->global->MAIN_LAST_PING_KO_DATE) && substr($conf->global->MAIN_LAST_PING_KO_DATE, 0, 6) ==
dol_print_date(
dol_now(),
'%Y%m') && !$forceping) {
3680 print
"\n<!-- NO JS CODE TO ENABLE the anonymous Ping. An error already occured this month, we will try later. -->\n";
3682 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
3684 print
"\n".
'<!-- Includes JS for Ping of Dolibarr forceping='.$forceping.
' MAIN_FIRST_PING_OK_DATE='.
getDolGlobalString(
"MAIN_FIRST_PING_OK_DATE").
' MAIN_FIRST_PING_OK_ID='.
getDolGlobalString(
"MAIN_FIRST_PING_OK_ID").
' MAIN_LAST_PING_KO_DATE='.
getDolGlobalString(
"MAIN_LAST_PING_KO_DATE").
' -->'.
"\n";
3685 print
"\n<!-- JS CODE TO ENABLE the anonymous Ping -->\n";
3686 $url_for_ping = (empty($conf->global->MAIN_URL_FOR_PING) ?
"https://ping.dolibarr.org/" : $conf->global->MAIN_URL_FOR_PING);
3688 $distrib =
'standard';
3689 if ($_SERVER[
"SERVER_ADMIN"] ==
'doliwamp@localhost') {
3690 $distrib =
'doliwamp';
3692 if (!empty($dolibarr_distrib)) {
3693 $distrib = $dolibarr_distrib;
3697 jQuery(document).ready(
function (tmp) {
3698 console.log(
"Try Ping with hash_unique_id is md5('dolibarr'+instance_unique_id)");
3701 url:
"<?php echo $url_for_ping ?>",
3706 hash_unique_id:
'<?php echo dol_escape_js($hash_unique_id); ?>',
3707 action:
'dolibarrping',
3708 version:
'<?php echo (float) DOL_VERSION; ?>',
3709 entity:
'<?php echo (int) $conf->entity; ?>',
3710 dbtype:
'<?php echo dol_escape_js($db->type); ?>',
3711 country_code:
'<?php echo $mysoc->country_code ? dol_escape_js($mysoc->country_code) : 'unknown
'; ?>',
3712 php_version:
'<?php echo dol_escape_js(phpversion()); ?>',
3713 os_version:
'<?php echo dol_escape_js(version_os('smr
')); ?>',
3714 distrib:
'<?php echo $distrib ? dol_escape_js($distrib) : 'unknown
'; ?>',
3715 token:
'notrequired'
3717 success:
function (data, status, xhr) {
3718 console.log(
"Ping ok");
3721 url:
'<?php echo DOL_URL_ROOT.'/core/ajax/pingresult.php
'; ?>',
3724 data: { hash_algo:
'md5', hash_unique_id:
'<?php echo dol_escape_js($hash_unique_id); ?>', action:
'firstpingok', token:
'<?php echo currentToken(); ?>' },
3727 error:
function (data,status,xhr) {
3728 console.log(
"Ping ko: " + data);
3731 url:
'<?php echo DOL_URL_ROOT.'/core/ajax/pingresult.php
'; ?>',
3734 data: { hash_algo:
'md5', hash_unique_id:
'<?php echo dol_escape_js($hash_unique_id); ?>', action:
'firstpingko', token:
'<?php echo currentToken(); ?>' },
3744 print
"\n<!-- NO JS CODE TO ENABLE the anonymous Ping. It was disabled -->\n";
3745 include_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
3747 dolibarr_set_const($db,
'MAIN_FIRST_PING_OK_ID',
'disabled',
'chaine', 0,
'', $conf->entity);
3752 $parameters = array();
3753 $reshook = $hookmanager->executeHooks(
'beforeBodyClose', $parameters);
3755 print $hookmanager->resPrint;