46if (!empty($_SERVER[
'MAIN_SHOW_TUNING_INFO'])) {
47 list($usec, $sec) = explode(
" ", microtime());
48 $micro_start_time = ((float) $usec + (
float) $sec);
51 if (defined(
'XDEBUGCOVERAGE')) {
52 xdebug_start_code_coverage();
64 $arrayofcommonemoji = array(
65 'misc' => array(
'2600',
'26FF'),
66 'ding' => array(
'2700',
'27BF'),
67 '????' => array(
'9989',
'9989'),
68 'vars' => array(
'FE00',
'FE0F'),
69 'pict' => array(
'1F300',
'1F5FF'),
70 'emot' => array(
'1F600',
'1F64F'),
71 'tran' => array(
'1F680',
'1F6FF'),
72 'flag' => array(
'1F1E0',
'1F1FF'),
73 'supp' => array(
'1F900',
'1F9FF'),
76 return $arrayofcommonemoji;
88 $newstringnumentity = preg_replace(
'/;$/',
'', $matches[1]);
91 if (preg_match(
'/^x/i', $newstringnumentity)) {
92 $newstringnumentity = hexdec(preg_replace(
'/^x/i',
'', $newstringnumentity));
94 $newstringnumentity = (int) $newstringnumentity;
98 if (($newstringnumentity >= 65 && $newstringnumentity <= 90) || ($newstringnumentity >= 97 && $newstringnumentity <= 122)) {
99 return chr((
int) $newstringnumentity);
104 foreach ($arrayofemojis as $valarray) {
105 if ($newstringnumentity >= hexdec($valarray[0]) && $newstringnumentity <= hexdec($valarray[1])) {
107 return html_entity_decode($matches[0], ENT_COMPAT | ENT_HTML5,
'UTF-8');
111 return '&#'.$matches[1];
135 $val = html_entity_decode($val, ENT_QUOTES | ENT_HTML5);
137 $val = preg_replace_callback(
138 '/&#(x?[0-9][0-9a-f]+;?)/i',
143 static function ($m) {
151 $val = preg_replace(
'/<!--[^>]*-->/',
'', $val);
152 $val = preg_replace(
'/[\r\n\t]/',
'', $val);
153 }
while ($oldval != $val);
164 $newval = preg_replace(
'/[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F]/u',
'', $val);
167 if ($newval != $val) {
174 if ($type == 1 || $type == 3) {
176 $inj += preg_match(
'/delete\s*from/i', $val);
177 $inj += preg_match(
'/create\s*table/i', $val);
178 $inj += preg_match(
'/insert\s*into/i', $val);
179 $inj += preg_match(
'/select\s*from/i', $val);
180 $inj += preg_match(
'/into\s*(outfile|dumpfile)/i', $val);
181 $inj += preg_match(
'/user\s*\(/i', $val);
182 $inj += preg_match(
'/information_schema/i', $val);
183 $inj += preg_match(
'/<svg/i', $val);
184 $inj += preg_match(
'/update[^&=\w].*set.+=/i', $val);
185 $inj += preg_match(
'/union.+select/i', $val);
189 $inj += preg_match(
'/select|update|delete|truncate|replace|group\s*by|concat|count|from|union/i', $val);
192 $inj += preg_match(
'/updatexml\(/i', $val);
193 $inj += preg_match(
'/(\.\.%2f)+/i', $val);
194 $inj += preg_match(
'/\s@@/', $val);
197 $inj += preg_match(
'/<\/textarea/i', $val);
203 $inj += preg_match(
'/<audio/i', $val);
204 $inj += preg_match(
'/<embed/i', $val);
205 $inj += preg_match(
'/<iframe/i', $val);
206 $inj += preg_match(
'/<object/i', $val);
207 $inj += preg_match(
'/<script/i', $val);
208 $inj += preg_match(
'/Set\.constructor/i', $val);
209 if (!defined(
'NOSTYLECHECK')) {
210 $inj += preg_match(
'/<style/i', $val);
212 $inj += preg_match(
'/base\s+href/si', $val);
213 $inj += preg_match(
'/=data:/si', $val);
216 $inj += preg_match(
'/on(mouse|drag|key|load|touch|pointer|select|transition)[a-z]*\s*=/i', $val);
217 $inj += preg_match(
'/on(abort|after|animation|auxclick|before|blur|cancel|canplay|canplaythrough|change|click|close|contextmenu|cuechange|copy|cut)[a-z]*\s*=/i', $val);
218 $inj += preg_match(
'/on(dblclick|drop|durationchange|emptied|end|ended|error|focus|focusin|focusout|formdata|gotpointercapture|hashchange|input|invalid)[a-z]*\s*=/i', $val);
219 $inj += preg_match(
'/on(lostpointercapture|offline|online|pagehide|pageshow)[a-z]*\s*=/i', $val);
220 $inj += preg_match(
'/on(paste|pause|play|playing|progress|ratechange|reset|resize|scroll|search|seeked|seeking|show|stalled|start|submit|suspend)[a-z]*\s*=/i', $val);
221 $inj += preg_match(
'/on(timeupdate|toggle|unload|volumechange|waiting|wheel)[a-z]*\s*=/i', $val);
223 $inj += preg_match(
'/on(repeat|begin|finish|beforeinput)[a-z]*\s*=/i', $val);
227 $tmpval = preg_replace(
'/<[^<]*>/',
'', $val);
230 $inj += preg_match(
'/on(mouse|drag|key|load|touch|pointer|select|transition)[a-z]*\s*=/i', $tmpval);
231 $inj += preg_match(
'/on(abort|after|animation|auxclick|before|blur|cancel|canplay|canplaythrough|change|click|close|contextmenu|cuechange|copy|cut)[a-z]*\s*=/i', $tmpval);
232 $inj += preg_match(
'/on(dblclick|drop|durationchange|emptied|end|ended|error|focus|focusin|focusout|formdata|gotpointercapture|hashchange|input|invalid)[a-z]*\s*=/i', $tmpval);
233 $inj += preg_match(
'/on(lostpointercapture|offline|online|pagehide|pageshow)[a-z]*\s*=/i', $tmpval);
234 $inj += preg_match(
'/on(paste|pause|play|playing|progress|ratechange|reset|resize|scroll|search|seeked|seeking|show|stalled|start|submit|suspend)[a-z]*\s*=/i', $tmpval);
235 $inj += preg_match(
'/on(timeupdate|toggle|unload|volumechange|waiting|wheel)[a-z]*\s*=/i', $tmpval);
237 $inj += preg_match(
'/on(repeat|begin|finish|beforeinput)[a-z]*\s*=/i', $tmpval);
240 $inj += preg_match(
'/:|:|:/i', $val);
241 $inj += preg_match(
'/j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t\s*:/i', $val);
242 $inj += preg_match(
'/vbscript\s*:/i', $val);
244 if ($type == 1 || $type == 3) {
245 $val = str_replace(
'enclosure="',
'enclosure=X', $val);
246 $inj += preg_match(
'/"/i', $val);
249 $inj += preg_match(
'/[:;"\'<>\?\(\){}\$%]/', $val);
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';
374if (
GETPOST(
"DOL_AUTOSET_COOKIE")) {
375 $tmpautoset = explode(
':',
GETPOST(
"DOL_AUTOSET_COOKIE"), 2);
376 $tmplist = explode(
',', $tmpautoset[1]);
377 $cookiearrayvalue = array();
378 foreach ($tmplist as $tmpkey) {
379 $postkey = $tmpautoset[0].
'_'.$tmpkey;
382 $cookiearrayvalue[$tmpkey] =
GETPOST($postkey);
385 $cookiename = $tmpautoset[0];
386 $cookievalue = json_encode($cookiearrayvalue);
388 if (PHP_VERSION_ID < 70300) {
389 setcookie($cookiename, empty($cookievalue) ?
'' : $cookievalue, empty($cookievalue) ? 0 : (time() + (86400 * 354)),
'/',
'', !(empty($dolibarr_main_force_https) &&
isHTTPS() === false), true);
392 $cookieparams = array(
393 'expires' => empty($cookievalue) ? 0 : (time() + (86400 * 354)),
396 'secure' => !(empty($dolibarr_main_force_https) &&
isHTTPS() === false),
400 setcookie($cookiename, empty($cookievalue) ?
'' : $cookievalue, $cookieparams);
402 if (empty($cookievalue)) {
403 unset($_COOKIE[$cookiename]);
409if (!empty($php_session_save_handler) && $php_session_save_handler ==
'db') {
410 require_once
'core/lib/phpsessionin'.$php_session_save_handler.
'.lib.php';
416$prefix = dol_getprefix(
'');
417$sessionname =
'DOLSESSID_'.$prefix;
418$sessiontimeout =
'DOLSESSTIMEOUT_'.$prefix;
419if (!empty($_COOKIE[$sessiontimeout])) {
420 ini_set(
'session.gc_maxlifetime', $_COOKIE[$sessiontimeout]);
425if (!defined(
'NOSESSION')) {
426 if (PHP_VERSION_ID < 70300) {
427 session_set_cookie_params(0,
'/',
null, !(empty($dolibarr_main_force_https) &&
isHTTPS() ===
false),
true);
430 $sessioncookieparams = array(
434 'secure' => !(empty($dolibarr_main_force_https) &&
isHTTPS() ===
false),
438 session_set_cookie_params($sessioncookieparams);
440 session_name($sessionname);
447require_once
'master.inc.php';
455 if ((!session_id() || !isset($_SESSION[
"dol_login"])) && !isset($_POST[
"username"]) && !empty($_SERVER[
"GATEWAY_INTERFACE"])) {
457 } elseif (isset($_POST[
"username"]) && in_array($_POST[
"username"], explode(
';',
getDolGlobalString(
'MAIN_ONLY_LOGIN_ALLOWED')))) {
459 } elseif (defined(
'NOREQUIREDB')) {
461 } elseif (defined(
'EVEN_IF_ONLY_LOGIN_ALLOWED')) {
463 } elseif (session_id() && isset($_SESSION[
"dol_login"]) && in_array($_SESSION[
"dol_login"], explode(
';',
getDolGlobalString(
'MAIN_ONLY_LOGIN_ALLOWED')))) {
467 if (session_id() && isset($_SESSION[
"dol_login"]) && !in_array($_SESSION[
"dol_login"], explode(
';',
getDolGlobalString(
'MAIN_ONLY_LOGIN_ALLOWED')))) {
468 print
'Sorry, your application is offline.'.
"\n";
469 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";
470 $nexturl = DOL_URL_ROOT.
'/user/logout.php?token='.
newToken();
471 print
'Please try later or <a href="'.$nexturl.
'">click here to disconnect and change login user</a>...'.
"\n";
473 print
'Sorry, your application is offline. Only administrator users (' . str_replace(
';',
', ',
getDolGlobalString(
'MAIN_ONLY_LOGIN_ALLOWED')).
') is allowed to connect for the moment.'.
"\n";
474 $nexturl = DOL_URL_ROOT.
'/';
475 print
'Please try later or <a href="'.$nexturl.
'">click here to change login user</a>...'.
"\n";
483register_shutdown_function(
'dol_shutdown');
486if (isModEnabled(
'debugbar') && !
GETPOST(
'dol_use_jmobile') && empty($_SESSION[
'dol_use_jmobile'])) {
488 include_once DOL_DOCUMENT_ROOT.
'/debugbar/class/DebugBar.php';
490 $renderer = $debugbar->getJavascriptRenderer();
492 $conf->global->MAIN_HTML_HEADER =
'';
494 $conf->global->MAIN_HTML_HEADER .= $renderer->renderHead();
496 '@phan-var-force array{time:DebugBar\DataCollector\TimeDataCollector} $debugbar';
497 $debugbar[
'time']->startMeasure(
'pageaftermaster',
'Page generation (after environment init)');
501if (isset($_SERVER[
"HTTP_USER_AGENT"])) {
503 $conf->browser->name = $tmp[
'browsername'];
504 $conf->browser->os = $tmp[
'browseros'];
505 $conf->browser->version = $tmp[
'browserversion'];
506 $conf->browser->ua = $tmp[
'browserua'];
507 $conf->browser->layout = $tmp[
'layout'];
510 if (
$conf->browser->layout ==
'phone') {
511 $conf->dol_no_mouse_hover = 1;
518 $conf->css =
"/theme/".$conf->theme.
"/style.css.php";
522if (
GETPOSTINT(
'textbrowser') || (!empty(
$conf->browser->name) &&
$conf->browser->name ==
'textbrowser')) {
523 $conf->global->MAIN_OPTIMIZEFORTEXTBROWSER = 2;
528if (!empty(
$conf->file->main_force_https) && !
isHTTPS() && !defined(
'NOHTTPSREDIRECT')) {
530 if (is_numeric(
$conf->file->main_force_https)) {
531 if (
$conf->file->main_force_https ==
'1' && !empty($_SERVER[
"SCRIPT_URI"])) {
532 if (preg_match(
'/^http:/i', $_SERVER[
"SCRIPT_URI"]) && !preg_match(
'/^https:/i', $_SERVER[
"SCRIPT_URI"])) {
533 $newurl = preg_replace(
'/^http:/i',
'https:', $_SERVER[
"SCRIPT_URI"]);
538 $newurl = preg_replace(
'/^http:/i',
'https:', DOL_MAIN_URL_ROOT).$_SERVER[
"REQUEST_URI"];
542 $newurl =
$conf->file->main_force_https.$_SERVER[
"REQUEST_URI"];
547 dol_syslog(
"main.inc: dolibarr_main_force_https is on, we make a redirect to ".$newurl);
548 header(
"Location: ".$newurl);
551 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);
555if (!defined(
'NOLOGIN') && !defined(
'NOIPCHECK') && !empty($dolibarr_main_restrict_ip)) {
556 $listofip = explode(
',', $dolibarr_main_restrict_ip);
558 foreach ($listofip as $ip) {
560 if ($ip == $_SERVER[
'REMOTE_ADDR']) {
566 print
'Access refused by IP protection. Your detected IP is '.$_SERVER[
'REMOTE_ADDR'];
572if (!defined(
'NOREQUIREHTML')) {
573 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
575if (!defined(
'NOREQUIREAJAX')) {
576 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
581 dol_syslog(
"main.inc: A previous install or upgrade was not complete. Redirect to install page.", LOG_WARNING);
582 header(
"Location: ".DOL_URL_ROOT.
"/install/index.php");
586$checkifupgraderequired =
false;
588 $checkifupgraderequired =
true;
591 $checkifupgraderequired =
true;
593if ($checkifupgraderequired) {
595 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
596 $dolibarrversionlastupgrade = preg_split(
'/[.-]/', $versiontocompare);
597 $dolibarrversionprogram = preg_split(
'/[.-]/', DOL_VERSION);
598 $rescomp =
versioncompare($dolibarrversionprogram, $dolibarrversionlastupgrade);
600 if (!
getDolGlobalString(
'MAIN_NO_UPGRADE_REDIRECT_ON_LEVEL_3_CHANGE') || $rescomp < 3) {
602 dol_syslog(
"main.inc: database version ".$versiontocompare.
" is lower than programs version ".DOL_VERSION.
". Redirect to install/upgrade page.", LOG_WARNING);
603 if (php_sapi_name() ===
"cli") {
604 print
"main.inc: database version ".$versiontocompare.
" is lower than programs version ".DOL_VERSION.
". Try to run upgrade process.\n";
606 header(
"Location: ".DOL_URL_ROOT.
"/install/index.php");
614if (!defined(
'NOTOKENRENEWAL') && !defined(
'NOSESSION')) {
616 if (!preg_match(
'/\.(css|js|json)\.php$/', $_SERVER[
"PHP_SELF"])) {
618 if (isset($_SESSION[
'newtoken'])) {
619 $_SESSION[
'token'] = $_SESSION[
'newtoken'];
622 if (!isset($_SESSION[
'newtoken']) ||
getDolGlobalInt(
'MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL')) {
626 $token =
dol_hash(uniqid((
string) mt_rand(),
false),
'md5');
627 $_SESSION[
'newtoken'] = $token;
628 dol_syslog(
"NEW TOKEN generated by : ".$_SERVER[
'PHP_SELF'], LOG_DEBUG);
636if ((!defined(
'NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) &&
getDolGlobalInt(
'MAIN_SECURITY_CSRF_WITH_TOKEN')) || defined(
'CSRFCHECK_WITH_TOKEN')) {
637 $tmpaction =
GETPOST(
'action',
'aZ09');
639 $sensitiveget =
false;
640 if ((GETPOSTISSET(
'massaction') || $tmpaction) &&
getDolGlobalInt(
'MAIN_SECURITY_CSRF_WITH_TOKEN') >= 3) {
643 if (GETPOSTISSET(
'massaction') || (strpos($tmpaction,
'display') !== 0 && !in_array($tmpaction, array(
'create',
'create2',
'createsite',
'createcard',
'edit',
'editcontract',
'editvalidator',
'file_manager',
'presend',
'presend_addmessage',
'preview',
'reconcile',
'specimen')))) {
644 $sensitiveget =
true;
648 $arrayofactiontoforcetokencheck = array(
650 'doprev',
'donext',
'dvprev',
'dvnext',
651 'freezone',
'install',
654 if (in_array($tmpaction, $arrayofactiontoforcetokencheck)) {
655 $sensitiveget =
true;
658 if (preg_match(
'/^(confirm_)?(add|classify|close|confirm|copy|del|disable|enable|remove|set|unset|update|save)/', $tmpaction)) {
659 $sensitiveget =
true;
666 (!empty($_SERVER[
'REQUEST_METHOD']) && $_SERVER[
'REQUEST_METHOD'] ==
'POST') ||
668 GETPOSTISSET(
'massaction') ||
669 ((GETPOSTISSET(
'actionlogin') || GETPOSTISSET(
'action')) && defined(
'CSRFCHECK_WITH_TOKEN'))
672 if (!
GETPOST(
'token',
'alpha') ||
GETPOST(
'token',
'alpha') ==
'notrequired') {
675 dol_syslog(
"--- Access to ".(empty($_SERVER[
"REQUEST_METHOD"]) ?
'' : $_SERVER[
"REQUEST_METHOD"].
' ').$_SERVER[
"PHP_SELF"].
" refused. File size too large or not provided.");
676 $langs->loadLangs(array(
"errors",
"install"));
677 print $langs->trans(
"ErrorFileSizeTooLarge").
' ';
678 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
680 http_response_code(403);
681 if (defined(
'CSRFCHECK_WITH_TOKEN')) {
682 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);
683 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";
685 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);
686 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";
687 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";
691 print
" into setup).\n";
698 $sessiontokenforthisurl = (empty($_SESSION[
'token']) ?
'' : $_SESSION[
'token']);
700 if (GETPOSTISSET(
'token') &&
GETPOST(
'token') !=
'notrequired' &&
GETPOST(
'token',
'alpha') != $sessiontokenforthisurl) {
701 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);
704 if (!defined(
'NOTOKENRENEWAL')) {
706 setEventMessages(
'SecurityTokenHasExpiredSoActionHasBeenCanceledPleaseRetry',
null,
'warnings',
'', 1);
709 if (isset($_POST[
'id'])) {
710 $savid = ((int) $_POST[
'id']);
713 unset($_GET[
'confirm']);
714 unset($_GET[
'action']);
715 unset($_GET[
'confirmmassaction']);
716 unset($_GET[
'massaction']);
717 unset($_GET[
'token']);
719 $_POST[
'id'] = ((int) $savid);
722 $_GET[
'errorcode'] =
'InvalidToken';
729if (GETPOSTISSET(
'disablemodules')) {
730 $_SESSION[
"disablemodules"] =
GETPOST(
'disablemodules',
'alpha');
732if (!empty($_SESSION[
"disablemodules"])) {
733 $modulepartkeys = array(
'css',
'js',
'tabs',
'triggers',
'login',
'substitutions',
'menus',
'theme',
'sms',
'tpl',
'barcode',
'models',
'societe',
'hooks',
'dir',
'syslog',
'tpllinkable',
'contactelement',
'moduleforexternal',
'websitetemplates');
735 $disabled_modules = explode(
',', $_SESSION[
"disablemodules"]);
736 foreach ($disabled_modules as $module) {
738 if (empty(
$conf->$module)) {
741 $conf->$module->enabled =
false;
742 foreach ($modulepartkeys as $modulepartkey) {
743 unset(
$conf->modules_parts[$modulepartkey][$module]);
745 if ($module ==
'fournisseur') {
746 $conf->supplier_order->enabled = 0;
747 $conf->supplier_invoice->enabled = 0;
754$modulepart = explode(
"/", $_SERVER[
"PHP_SELF"]);
755if (is_array($modulepart) && count($modulepart) > 0) {
756 foreach (
$conf->modules as $module) {
757 if (in_array($module, $modulepart)) {
758 $modulepart = $module;
763if (is_array($modulepart)) {
774if (!defined(
'NOLOGIN')) {
778 if (defined(
'MAIN_AUTHENTICATION_MODE')) {
779 $dolibarr_main_authentication = constant(
'MAIN_AUTHENTICATION_MODE');
782 if (empty($dolibarr_main_authentication)) {
783 $dolibarr_main_authentication =
'dolibarr';
786 if ($dolibarr_main_authentication ==
'forceuser' && empty($dolibarr_auto_user)) {
787 $dolibarr_auto_user =
'auto';
791 $authmode = explode(
',', $dolibarr_main_authentication);
794 if (!count($authmode)) {
795 $langs->load(
'main');
796 dol_print_error(
null, $langs->trans(
"ErrorConfigParameterNotDefined",
'dolibarr_main_authentication'));
803 $resultFetchUser =
'';
805 $dol_authmode =
null;
807 if (!isset($_SESSION[
"dol_login"])) {
809 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
811 $dol_dst_observed =
GETPOSTINT(
"dst_observed", 3);
813 $dol_dst_second =
GETPOSTINT(
"dst_second", 3);
814 $dol_screenwidth =
GETPOSTINT(
"screenwidth", 3);
815 $dol_screenheight =
GETPOSTINT(
"screenheight", 3);
816 $dol_hide_topmenu =
GETPOSTINT(
'dol_hide_topmenu', 3);
817 $dol_hide_leftmenu =
GETPOSTINT(
'dol_hide_leftmenu', 3);
818 $dol_optimize_smallscreen =
GETPOSTINT(
'dol_optimize_smallscreen', 3);
819 $dol_no_mouse_hover =
GETPOSTINT(
'dol_no_mouse_hover', 3);
820 $dol_use_jmobile =
GETPOSTINT(
'dol_use_jmobile', 3);
823 if (!empty($dolibarr_main_demo) && $_SERVER[
'PHP_SELF'] == DOL_URL_ROOT.
'/index.php') {
824 if (empty($_SERVER[
'HTTP_REFERER']) || !preg_match(
'/public/', $_SERVER[
'HTTP_REFERER'])) {
825 dol_syslog(
"Call index page from another url than demo page (call is done from page ".(empty($_SERVER[
'HTTP_REFERER']) ?
'' : $_SERVER[
'HTTP_REFER']).
")");
827 $url .= ($url ?
'&' :
'').($dol_hide_topmenu ?
'dol_hide_topmenu='.$dol_hide_topmenu :
'');
828 $url .= ($url ?
'&' :
'').($dol_hide_leftmenu ?
'dol_hide_leftmenu='.$dol_hide_leftmenu :
'');
829 $url .= ($url ?
'&' :
'').($dol_optimize_smallscreen ?
'dol_optimize_smallscreen='.$dol_optimize_smallscreen :
'');
830 $url .= ($url ?
'&' :
'').($dol_no_mouse_hover ?
'dol_no_mouse_hover='.$dol_no_mouse_hover :
'');
831 $url .= ($url ?
'&' :
'').($dol_use_jmobile ?
'dol_use_jmobile='.$dol_use_jmobile :
'');
832 $url = DOL_URL_ROOT.
'/public/demo/index.php'.($url ?
'?'.$url :
'');
833 header(
"Location: ".$url);
840 $hookmanager->initHooks(array(
'login'));
841 $parameters = array();
842 $reshook = $hookmanager->executeHooks(
'beforeLoginAuthentication', $parameters, $user, $action);
849 if ($test &&
GETPOST(
'actionlogin',
'aZ09') ==
'login' &&
GETPOST(
"username",
"alpha", 2) &&
getDolGlobalString(
'MAIN_SECURITY_ENABLECAPTCHA') && !isset($_SESSION[
'dol_bypass_antispam'])) {
853 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
857 $dirModCaptcha = array_merge(array(
'main' =>
'/core/modules/security/captcha/'), is_array(
$conf->modules_parts[
'captcha']) ?
$conf->modules_parts[
'captcha'] : array());
858 $fullpathclassfile =
'';
859 foreach ($dirModCaptcha as $dir) {
860 $fullpathclassfile =
dol_buildpath($dir.
"modCaptcha".ucfirst($captcha).
'.class.php', 0, 2);
861 if ($fullpathclassfile) {
867 if ($fullpathclassfile) {
868 include_once $fullpathclassfile;
872 $classname =
"modCaptcha".ucfirst($captcha);
873 if (class_exists($classname)) {
875 $captchaobj =
new $classname($db,
$conf, $langs, $user);
876 '@phan-var-force ModeleCaptcha $captchaobj';
878 if (is_object($captchaobj) && method_exists($captchaobj,
'validateCodeAfterLoginSubmit')) {
879 $ok = $captchaobj->validateCodeAfterLoginSubmit();
881 $_SESSION[
"dol_loginmesg"] =
'Error, the captcha handler '.get_class($captchaobj).
' does not have any method validateCodeAfterLoginSubmit()';
886 $_SESSION[
"dol_loginmesg"] =
'Error, the captcha handler class '.$classname.
' was not found after the include';
891 $_SESSION[
"dol_loginmesg"] =
'Error, the captcha handler '.$captcha.
' has no class file found modCaptcha'.ucfirst($captcha);
898 dol_syslog(
'Bad value for code, connection refused', LOG_NOTICE);
900 $langs->loadLangs(array(
'main',
'errors'));
902 $_SESSION[
"dol_loginmesg"] = (empty($_SESSION[
"dol_loginmesg"]) ?
"" : $_SESSION[
"dol_loginmesg"].
"<br>\n").$langs->transnoentitiesnoconv(
"ErrorBadValueForCode");
906 $user->context[
'audit'] =
'ErrorBadValueForCode - login='.GETPOST(
"username",
"alpha", 2);
909 $result = $user->call_trigger(
'USER_LOGIN_FAILED', $user);
917 $hookmanager->initHooks(array(
'login'));
918 $parameters = array(
'dol_authmode' => $authmode,
'dol_loginmesg' => $_SESSION[
"dol_loginmesg"]);
919 $reshook = $hookmanager->executeHooks(
'afterLoginFailed', $parameters, $user, $action);
928 $allowedmethodtopostusername = 3;
929 if (defined(
'MAIN_AUTHENTICATION_POST_METHOD')) {
930 $allowedmethodtopostusername = constant(
'MAIN_AUTHENTICATION_POST_METHOD');
933 $usertotest = (!empty($_COOKIE[
'login_dolibarr']) ? preg_replace(
'/[^a-zA-Z0-9_@\-\.]/',
'', $_COOKIE[
'login_dolibarr']) :
GETPOST(
"username",
"alpha", $allowedmethodtopostusername));
934 $passwordtotest =
GETPOST(
'password',
'password', $allowedmethodtopostusername);
938 $goontestloop =
false;
939 if (isset($_SERVER[
"REMOTE_USER"]) && in_array(
'http', $authmode)) {
940 $goontestloop =
true;
942 if ($dolibarr_main_authentication ==
'forceuser' && !empty($dolibarr_auto_user)) {
943 $goontestloop =
true;
945 if (
GETPOST(
"username",
"alpha", $allowedmethodtopostusername)) {
946 $goontestloop =
true;
948 if (
GETPOST(
'openid_mode',
'alpha')) {
949 $goontestloop =
true;
951 if (
GETPOST(
'beforeoauthloginredirect') ||
GETPOST(
'afteroauthloginreturn')) {
952 $goontestloop =
true;
954 if (!empty($_COOKIE[
'login_dolibarr'])) {
955 $goontestloop =
true;
958 if (!is_object($langs)) {
959 include_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
962 if (defined(
'MAIN_LANG_DEFAULT')) {
963 $langcode = constant(
'MAIN_LANG_DEFAULT');
965 $langs->setDefaultLang($langcode);
971 if ($test && $goontestloop &&
GETPOST(
'actionlogin',
'aZ09') !=
'disabled' && (
GETPOST(
'actionlogin',
'aZ09') ==
'login' || $dolibarr_main_authentication !=
'dolibarr')) {
974 $oauthmodetotestarray = array(
'google');
975 foreach ($oauthmodetotestarray as $oauthmodetotest) {
976 if (in_array($oauthmodetotest.
'oauth', $authmode)) {
979 if (
GETPOST(
'beforeoauthloginredirect') == $oauthmodetotest ||
GETPOST(
'afteroauthloginreturn')) {
982 dol_syslog(
"User did not click on link for OAuth, or is not on the OAuth return, so we disable check using ".$oauthmodetotest);
983 foreach ($authmode as $tmpkey => $tmpval) {
984 if ($tmpval == $oauthmodetotest.
'oauth') {
985 unset($authmode[$tmpkey]);
994 if ($login ===
'--bad-login-validity--') {
999 $dol_authmode =
$conf->authmode;
1000 $dol_tz = empty($_POST[
"tz"]) ? (empty($_SESSION[
"tz"]) ?
'' : $_SESSION[
"tz"]) : $_POST[
"tz"];
1001 $dol_tz_string = empty($_POST[
"tz_string"]) ? (empty($_SESSION[
"tz_string"]) ?
'' : $_SESSION[
"tz_string"]) : $_POST[
"tz_string"];
1002 $dol_tz_string = preg_replace(
'/\s*\(.+\)$/',
'', $dol_tz_string);
1003 $dol_tz_string = preg_replace(
'/,/',
'/', $dol_tz_string);
1004 $dol_tz_string = preg_replace(
'/\s/',
'_', $dol_tz_string);
1007 $dol_dst_first = empty($_POST[
"dst_first"]) ? (empty($_SESSION[
"dst_first"]) ?
'' : $_SESSION[
"dst_first"]) : $_POST[
"dst_first"];
1008 $dol_dst_second = empty($_POST[
"dst_second"]) ? (empty($_SESSION[
"dst_second"]) ?
'' : $_SESSION[
"dst_second"]) : $_POST[
"dst_second"];
1009 if ($dol_dst_first && $dol_dst_second) {
1010 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1014 if ($datenow >= $datefirst && $datenow < $datesecond) {
1018 $dol_screenheight = empty($_POST[
"screenheight"]) ? (empty($_SESSION[
"dol_screenheight"]) ?
'' : $_SESSION[
"dol_screenheight"]) : $_POST[
"screenheight"];
1019 $dol_screenwidth = empty($_POST[
"screenwidth"]) ? (empty($_SESSION[
"dol_screenwidth"]) ?
'' : $_SESSION[
"dol_screenwidth"]) : $_POST[
"screenwidth"];
1024 dol_syslog(
'Bad password, connection refused (see a previous notice message for more info)', LOG_NOTICE);
1026 $langs->loadLangs(array(
'main',
'errors'));
1030 if (empty($_SESSION[
"dol_loginmesg"])) {
1031 $_SESSION[
"dol_loginmesg"] = $langs->transnoentitiesnoconv(
"ErrorBadLoginPassword");
1035 $user->context[
'audit'] = $langs->trans(
"ErrorBadLoginPassword").
' - login='.
GETPOST(
"username",
"alpha", 2);
1038 $result = $user->call_trigger(
'USER_LOGIN_FAILED', $user);
1046 $hookmanager->initHooks(array(
'login'));
1047 $parameters = array(
'dol_authmode' => $dol_authmode,
'dol_loginmesg' => $_SESSION[
"dol_loginmesg"]);
1048 $reshook = $hookmanager->executeHooks(
'afterLoginFailed', $parameters, $user, $action);
1058 if (!$login || (in_array(
'ldap', $authmode) && empty($passwordtotest))) {
1060 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);
1061 if (defined(
'NOREDIRECTBYMAINTOLOGIN')) {
1066 return 'ERROR_NOT_LOGGED';
1068 if (!empty($_SERVER[
"HTTP_USER_AGENT"]) && $_SERVER[
"HTTP_USER_AGENT"] ==
'securitytest') {
1069 http_response_code(401);
1073 dol_loginfunction($langs,
$conf, (!empty($mysoc) ? $mysoc :
''));
1078 $resultFetchUser = $user->fetch(0, $login,
'', 1, ($entitytotest > 0 ? $entitytotest : -1));
1079 if ($resultFetchUser <= 0 || $user->isNotIntoValidityDateRange()) {
1080 dol_syslog(
'User not found or not valid, connection refused');
1082 session_set_cookie_params(0,
'/',
null, !empty($dolibarr_main_force_https),
true);
1083 session_name($sessionname);
1086 if ($resultFetchUser == 0) {
1088 $langs->loadLangs(array(
'main',
'errors'));
1090 $_SESSION[
"dol_loginmesg"] = $langs->transnoentitiesnoconv(
"ErrorCantLoadUserFromDolibarrDatabase", $login);
1092 $user->context[
'audit'] =
'ErrorCantLoadUserFromDolibarrDatabase - login='.$login;
1093 } elseif ($resultFetchUser < 0) {
1094 $_SESSION[
"dol_loginmesg"] = $user->error;
1096 $user->context[
'audit'] = $user->error;
1099 $langs->loadLangs(array(
'main',
'errors'));
1101 $_SESSION[
"dol_loginmesg"] = $langs->transnoentitiesnoconv(
"ErrorLoginDateValidity");
1103 $user->context[
'audit'] = $langs->trans(
"ErrorLoginDateValidity").
' - login='.$login;
1107 $result = $user->call_trigger(
'USER_LOGIN_FAILED', $user);
1116 $hookmanager->initHooks(array(
'login'));
1117 $parameters = array(
'dol_authmode' => $dol_authmode,
'dol_loginmesg' => $_SESSION[
"dol_loginmesg"]);
1118 $reshook = $hookmanager->executeHooks(
'afterLoginFailed', $parameters, $user, $action);
1123 $paramsurl = array();
1125 $paramsurl[] =
'textbrowser='.GETPOSTINT(
'textbrowser');
1128 $paramsurl[] =
'nojs='.GETPOSTINT(
'nojs');
1130 if (
GETPOST(
'lang',
'aZ09')) {
1131 $paramsurl[] =
'lang='.GETPOST(
'lang',
'aZ09');
1133 header(
'Location: '.DOL_URL_ROOT.
'/index.php'.(count($paramsurl) ?
'?'.implode(
'&', $paramsurl) :
''));
1137 if (!empty($user->conf->MAIN_LANG_DEFAULT)) {
1138 $langs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT);
1143 $login = $_SESSION[
"dol_login"];
1144 $entity = isset($_SESSION[
"dol_entity"]) ? $_SESSION[
"dol_entity"] : 0;
1145 dol_syslog(
"- This is an already logged session. _SESSION['dol_login']=".$login.
" _SESSION['dol_entity']=".$entity, LOG_DEBUG);
1147 $resultFetchUser = $user->fetch(0, $login,
'', 1, ($entity > 0 ? $entity : -1));
1151 if ($resultFetchUser <= 0
1152 || ($user->flagdelsessionsbefore && !empty($_SESSION[
"dol_logindate"]) && $user->flagdelsessionsbefore > $_SESSION[
"dol_logindate"])
1153 || ($user->status != $user::STATUS_ENABLED)
1154 || ($user->isNotIntoValidityDateRange())) {
1155 if ($resultFetchUser <= 0) {
1157 dol_syslog(
"Can't load user even if session logged. _SESSION['dol_login']=".$login, LOG_WARNING);
1158 } elseif ($user->flagdelsessionsbefore && !empty($_SESSION[
"dol_logindate"]) && $user->flagdelsessionsbefore > $_SESSION[
"dol_logindate"]) {
1160 dol_syslog(
"The user has a date for session invalidation = ".$user->flagdelsessionsbefore.
" and a session date = ".$_SESSION[
"dol_logindate"].
". We must invalidate its sessions.");
1161 } elseif ($user->status != $user::STATUS_ENABLED) {
1166 dol_syslog(
"The user login has a validity between [".$user->datestartvalidity.
" and ".$user->dateendvalidity.
"], current date is ".
dol_now());
1169 session_set_cookie_params(0,
'/',
null, !empty($dolibarr_main_force_https),
true);
1170 session_name($sessionname);
1173 if ($resultFetchUser == 0) {
1174 $langs->loadLangs(array(
'main',
'errors'));
1176 $_SESSION[
"dol_loginmesg"] = $langs->transnoentitiesnoconv(
"ErrorCantLoadUserFromDolibarrDatabase", $login);
1178 $user->context[
'audit'] =
'ErrorCantLoadUserFromDolibarrDatabase - login='.$login;
1179 } elseif ($resultFetchUser < 0) {
1180 $_SESSION[
"dol_loginmesg"] = $user->error;
1182 $user->context[
'audit'] = $user->error;
1184 $langs->loadLangs(array(
'main',
'errors'));
1186 $_SESSION[
"dol_loginmesg"] = $langs->transnoentitiesnoconv(
"ErrorSessionInvalidatedAfterPasswordChange");
1188 $user->context[
'audit'] =
'ErrorUserSessionWasInvalidated - login='.$login;
1192 $result = $user->call_trigger(
'USER_LOGIN_FAILED', $user);
1200 $hookmanager->initHooks(array(
'login'));
1201 $parameters = array(
'dol_authmode' => (
string) $dol_authmode,
'dol_loginmesg' => $_SESSION[
"dol_loginmesg"]);
1202 $reshook = $hookmanager->executeHooks(
'afterLoginFailed', $parameters, $user, $action);
1207 $paramsurl = array();
1209 $paramsurl[] =
'textbrowser='.GETPOSTINT(
'textbrowser');
1212 $paramsurl[] =
'nojs='.GETPOSTINT(
'nojs');
1214 if (
GETPOST(
'lang',
'aZ09')) {
1215 $paramsurl[] =
'lang='.GETPOST(
'lang',
'aZ09');
1218 header(
'Location: '.DOL_URL_ROOT.
'/index.php'.(count($paramsurl) ?
'?'.implode(
'&', $paramsurl) :
''));
1222 $hookmanager->initHooks(array(
'main'));
1225 if (!empty($_GET[
'save_lastsearch_values']) && !empty($_SERVER[
"HTTP_REFERER"])) {
1226 $relativepathstring = preg_replace(
'/\?.*$/',
'', $_SERVER[
"HTTP_REFERER"]);
1227 $relativepathstring = preg_replace(
'/^https?:\/\/[^\/]*/',
'', $relativepathstring);
1229 if (constant(
'DOL_URL_ROOT')) {
1230 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
1232 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
1233 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
1237 if (!empty($_SESSION[
'lastsearch_values_tmp_'.$relativepathstring])) {
1238 $_SESSION[
'lastsearch_values_'.$relativepathstring] = $_SESSION[
'lastsearch_values_tmp_'.$relativepathstring];
1239 unset($_SESSION[
'lastsearch_values_tmp_'.$relativepathstring]);
1241 if (!empty($_SESSION[
'lastsearch_contextpage_tmp_'.$relativepathstring])) {
1242 $_SESSION[
'lastsearch_contextpage_'.$relativepathstring] = $_SESSION[
'lastsearch_contextpage_tmp_'.$relativepathstring];
1243 unset($_SESSION[
'lastsearch_contextpage_tmp_'.$relativepathstring]);
1245 if (!empty($_SESSION[
'lastsearch_limit_tmp_'.$relativepathstring]) && $_SESSION[
'lastsearch_limit_tmp_'.$relativepathstring] !=
$conf->liste_limit) {
1246 $_SESSION[
'lastsearch_limit_'.$relativepathstring] = $_SESSION[
'lastsearch_limit_tmp_'.$relativepathstring];
1247 unset($_SESSION[
'lastsearch_limit_tmp_'.$relativepathstring]);
1249 if (!empty($_SESSION[
'lastsearch_page_tmp_'.$relativepathstring]) && $_SESSION[
'lastsearch_page_tmp_'.$relativepathstring] > 0) {
1250 $_SESSION[
'lastsearch_page_'.$relativepathstring] = $_SESSION[
'lastsearch_page_tmp_'.$relativepathstring];
1251 unset($_SESSION[
'lastsearch_page_tmp_'.$relativepathstring]);
1253 if (!empty($_SESSION[
'lastsearch_mode_tmp_'.$relativepathstring])) {
1254 $_SESSION[
'lastsearch_mode_'.$relativepathstring] = $_SESSION[
'lastsearch_mode_tmp_'.$relativepathstring];
1255 unset($_SESSION[
'lastsearch_mode_tmp_'.$relativepathstring]);
1258 if (!empty($_GET[
'save_pageforbacktolist']) && !empty($_SERVER[
"HTTP_REFERER"])) {
1259 if (empty($_SESSION[
'pageforbacktolist'])) {
1260 $pageforbacktolistarray = array();
1262 $pageforbacktolistarray = $_SESSION[
'pageforbacktolist'];
1264 $tmparray = explode(
':', $_GET[
'save_pageforbacktolist'], 2);
1265 if (!empty($tmparray[0]) && !empty($tmparray[1])) {
1266 $pageforbacktolistarray[$tmparray[0]] = $tmparray[1];
1267 $_SESSION[
'pageforbacktolist'] = $pageforbacktolistarray;
1272 $parameters = array();
1273 $reshook = $hookmanager->executeHooks(
'updateSession', $parameters, $user, $action);
1282 if (!isset($_SESSION[
"dol_login"])) {
1287 $_SESSION[
"dol_login"] = $user->login;
1288 $_SESSION[
"dol_logindate"] =
dol_now(
'gmt');
1289 $_SESSION[
"dol_authmode"] = isset($dol_authmode) ? $dol_authmode :
'';
1290 $_SESSION[
"dol_tz"] = isset($dol_tz) ? $dol_tz :
'';
1291 $_SESSION[
"dol_tz_string"] = isset($dol_tz_string) ? $dol_tz_string :
'';
1292 $_SESSION[
"dol_dst"] = isset($dol_dst) ? $dol_dst :
'';
1293 $_SESSION[
"dol_dst_observed"] = isset($dol_dst_observed) ? $dol_dst_observed :
'';
1294 $_SESSION[
"dol_dst_first"] = isset($dol_dst_first) ? $dol_dst_first :
'';
1295 $_SESSION[
"dol_dst_second"] = isset($dol_dst_second) ? $dol_dst_second :
'';
1296 $_SESSION[
"dol_screenwidth"] = isset($dol_screenwidth) ? $dol_screenwidth :
'';
1297 $_SESSION[
"dol_screenheight"] = isset($dol_screenheight) ? $dol_screenheight :
'';
1299 $_SESSION[
"dol_entity"] =
$conf->entity;
1301 if (!empty($dol_hide_topmenu)) {
1302 $_SESSION[
'dol_hide_topmenu'] = $dol_hide_topmenu;
1304 if (!empty($dol_hide_leftmenu)) {
1305 $_SESSION[
'dol_hide_leftmenu'] = $dol_hide_leftmenu;
1307 if (!empty($dol_optimize_smallscreen)) {
1308 $_SESSION[
'dol_optimize_smallscreen'] = $dol_optimize_smallscreen;
1310 if (!empty($dol_no_mouse_hover)) {
1311 $_SESSION[
'dol_no_mouse_hover'] = $dol_no_mouse_hover;
1313 if (!empty($dol_use_jmobile)) {
1314 $_SESSION[
'dol_use_jmobile'] = $dol_use_jmobile;
1317 dol_syslog(
"This is a new started user session. _SESSION['dol_login']=".$_SESSION[
"dol_login"].
" Session id=".session_id());
1321 $user->update_last_login_date();
1323 $loginfo =
'TZ='.$_SESSION[
"dol_tz"].
';TZString='.$_SESSION[
"dol_tz_string"].
';Screen='.$_SESSION[
"dol_screenwidth"].
'x'.$_SESSION[
"dol_screenheight"];
1324 $loginfo .=
' - authmode='.$dol_authmode.
' - entity='.
$conf->entity;
1327 $user->context[
'audit'] = $loginfo;
1328 $user->context[
'authentication_method'] = $dol_authmode;
1331 $result = $user->call_trigger(
'USER_LOGIN', $user);
1339 $hookmanager->initHooks(array(
'login'));
1340 $parameters = array(
'dol_authmode' => $dol_authmode,
'dol_loginfo' => $loginfo);
1341 $reshook = $hookmanager->executeHooks(
'afterLogin', $parameters, $user, $action);
1349 dol_print_error($db,
'Error in some triggers USER_LOGIN or in some hooks afterLogin');
1356 $landingpage = (empty($user->conf->MAIN_LANDING_PAGE) ? (!
getDolGlobalString(
'MAIN_LANDING_PAGE') ?
'' :
$conf->global->MAIN_LANDING_PAGE) : $user->
conf->MAIN_LANDING_PAGE);
1357 if (!empty($landingpage)) {
1359 if ($_SERVER[
"PHP_SELF"] != $newpath) {
1360 header(
'Location: '.$newpath);
1369 $user->rights->user->user->lire = 1;
1370 $user->rights->user->user->creer = 1;
1371 $user->rights->user->user->password = 1;
1372 $user->rights->user->user->supprimer = 1;
1373 $user->rights->user->self->creer = 1;
1374 $user->rights->user->self->password = 1;
1378 if (!$user->hasRight(
'user',
'user_advance')) {
1379 $user->rights->user->user_advance =
new stdClass();
1381 if (!$user->hasRight(
'user',
'self_advance')) {
1382 $user->rights->user->self_advance =
new stdClass();
1384 if (!$user->hasRight(
'user',
'group_advance')) {
1385 $user->rights->user->group_advance =
new stdClass();
1388 $user->rights->user->user_advance->readperms = 1;
1389 $user->rights->user->user_advance->write = 1;
1390 $user->rights->user->self_advance->readperms = 1;
1391 $user->rights->user->self_advance->writeperms = 1;
1392 $user->rights->user->group_advance->read = 1;
1393 $user->rights->user->group_advance->readperms = 1;
1394 $user->rights->user->group_advance->write = 1;
1395 $user->rights->user->group_advance->delete = 1;
1404 if (isset($user->conf->MAIN_SIZE_LISTE_LIMIT)) {
1407 if ((
int)
$conf->liste_limit <= 0) {
1409 $conf->liste_limit = 15;
1410 if (!empty($_SESSION[
'dol_screenheight']) && $_SESSION[
'dol_screenheight'] < 700) {
1411 $conf->liste_limit = 8;
1412 } elseif (!empty($_SESSION[
'dol_screenheight']) && $_SESSION[
'dol_screenheight'] < 910) {
1413 $conf->liste_limit = 10;
1414 } elseif (!empty($_SESSION[
'dol_screenheight']) && $_SESSION[
'dol_screenheight'] > 1130) {
1415 $conf->liste_limit = 20;
1419 if (isset($user->conf->MAIN_CHECKBOX_LEFT_COLUMN)) {
1426 $conf->css =
"/theme/".$conf->theme.
"/style.css.php";
1430 if (!empty($user) && method_exists($user,
'loadDefaultValues') && !defined(
'NODEFAULTVALUES')) {
1431 $user->loadDefaultValues();
1437if (
GETPOST(
'theme',
'aZ09')) {
1439 $conf->css =
"/theme/".$conf->theme.
"/style.css.php";
1444 $conf->use_javascript_ajax = 0;
1455 $conf->global->THEME_TOPMENU_DISABLE_IMAGE = 1;
1465if (
GETPOSTINT(
'dol_hide_leftmenu') || !empty($_SESSION[
'dol_hide_leftmenu'])) {
1466 $conf->dol_hide_leftmenu = 1;
1468if (
GETPOSTINT(
'dol_hide_topmenu') || !empty($_SESSION[
'dol_hide_topmenu'])) {
1469 $conf->dol_hide_topmenu = 1;
1471if (
GETPOSTINT(
'dol_optimize_smallscreen') || !empty($_SESSION[
'dol_optimize_smallscreen'])) {
1472 $conf->dol_optimize_smallscreen = 1;
1474if (
GETPOSTINT(
'dol_no_mouse_hover') || !empty($_SESSION[
'dol_no_mouse_hover'])) {
1475 $conf->dol_no_mouse_hover = 1;
1477if (
GETPOSTINT(
'dol_use_jmobile') || !empty($_SESSION[
'dol_use_jmobile'])) {
1478 $conf->dol_use_jmobile = 1;
1481if (!empty(
$conf->browser->layout) &&
$conf->browser->layout !=
'classic') {
1482 $conf->dol_no_mouse_hover = 1;
1486if ((!empty(
$conf->browser->layout) &&
$conf->browser->layout ==
'phone')
1487 || (!empty($_SESSION[
'dol_screenwidth']) && $_SESSION[
'dol_screenwidth'] < 400)
1488 || (!empty($_SESSION[
'dol_screenheight']) && $_SESSION[
'dol_screenheight'] < 400
1491 $conf->dol_optimize_smallscreen = 1;
1494 $conf->global->PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE = 0;
1498if (!empty(
$conf->dol_use_jmobile) && in_array(
$conf->theme, array(
'bureau2crea',
'cameleo',
'amarok'))) {
1499 $conf->theme =
'eldy';
1500 $conf->css =
"/theme/".$conf->theme.
"/style.css.php";
1503if (!defined(
'NOREQUIRETRAN')) {
1504 if (!
GETPOST(
'lang',
'aZ09')) {
1506 if (!empty($user->conf->MAIN_LANG_DEFAULT)) {
1509 if ($langs->getDefaultLang() != $user->conf->MAIN_LANG_DEFAULT) {
1510 $langs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT);
1516if (!defined(
'NOLOGIN')) {
1519 if (!$user->login) {
1524 if ($user->statut < 1) {
1526 $langs->loadLangs(array(
"errors",
"other"));
1527 dol_syslog(
"Authentication KO as login is disabled", LOG_NOTICE);
1532 $user->loadRights();
1535dol_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);
1540if (!defined(
'NOREQUIRETRAN')) {
1542 $langs->loadLangs(array(
'main',
'dict'));
1546$bc = array(0 =>
'class="impair"', 1 =>
'class="pair"');
1547$bcdd = array(0 =>
'class="drag drop oddeven"', 1 =>
'class="drag drop oddeven"');
1548$bcnd = array(0 =>
'class="nodrag nodrop nohover"', 1 =>
'class="nodrag nodrop nohoverpair"');
1549$bctag = array(0 =>
'class="impair tagtr"', 1 =>
'class="pair tagtr"');
1561if (empty(
$conf->browser->firefox)) {
1562 define(
'ROWS_1', 1);
1563 define(
'ROWS_2', 2);
1564 define(
'ROWS_3', 3);
1565 define(
'ROWS_4', 4);
1566 define(
'ROWS_5', 5);
1567 define(
'ROWS_6', 6);
1568 define(
'ROWS_7', 7);
1569 define(
'ROWS_8', 8);
1570 define(
'ROWS_9', 9);
1572 define(
'ROWS_1', 0);
1573 define(
'ROWS_2', 1);
1574 define(
'ROWS_3', 2);
1575 define(
'ROWS_4', 3);
1576 define(
'ROWS_5', 4);
1577 define(
'ROWS_6', 5);
1578 define(
'ROWS_7', 6);
1579 define(
'ROWS_8', 7);
1580 define(
'ROWS_9', 8);
1583$heightforframes = 50;
1586if (!defined(
'NOREQUIREMENU')) {
1587 if (empty($user->socid)) {
1595 $file_menu =
$conf->standard_menu;
1596 if (
GETPOST(
'menu',
'alpha')) {
1597 $file_menu =
GETPOST(
'menu',
'alpha');
1600 if (!class_exists(
'MenuManager')) {
1602 $dirmenus = array_merge(array(
"/core/menus/"), (array)
$conf->modules_parts[
'menus']);
1603 foreach ($dirmenus as $dirmenu) {
1605 if (class_exists(
'MenuManager')) {
1609 if (!class_exists(
'MenuManager')) {
1610 dol_syslog(
"You define a menu manager '".$file_menu.
"' that can not be loaded.", LOG_WARNING);
1611 $file_menu =
'eldy_menu.php';
1612 include_once DOL_DOCUMENT_ROOT.
"/core/menus/standard/".$file_menu;
1616 $menumanager =
new MenuManager($db, empty($user->socid) ? 0 : 1);
1621if (!empty(
GETPOST(
'seteventmessages',
'alpha'))) {
1622 $message =
GETPOST(
'seteventmessages',
'alpha');
1623 $messages = explode(
',', $message);
1624 foreach ($messages as $key => $msg) {
1625 $tmp = explode(
':', $msg);
1632if (!function_exists(
"llxHeader")) {
1654 function llxHeader($head =
'', $title =
'', $help_url =
'', $target =
'', $disablejs = 0, $disablehead = 0, $arrayofjs =
'', $arrayofcss =
'', $morequerystring =
'', $morecssonbody =
'', $replacemainareaby =
'', $disablenofollow = 0, $disablenoindex = 0)
1656 global
$conf, $hookmanager;
1658 $parameters = array(
1660 'title' => & $title,
1661 'help_url' => & $help_url,
1662 'target' => & $target,
1663 'disablejs' => & $disablejs,
1664 'disablehead' => & $disablehead,
1665 'arrayofjs' => & $arrayofjs,
1666 'arrayofcss' => & $arrayofcss,
1667 'morequerystring' => & $morequerystring,
1668 'morecssonbody' => & $morecssonbody,
1669 'replacemainareaby' => & $replacemainareaby,
1670 'disablenofollow' => & $disablenofollow,
1671 'disablenoindex' => & $disablenoindex
1674 $reshook = $hookmanager->executeHooks(
'llxHeader', $parameters);
1676 print $hookmanager->resPrint;
1681 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss, 0, $disablenofollow, $disablenoindex);
1683 $tmpcsstouse =
'sidebar-collapse'.($morecssonbody ?
' '.$morecssonbody :
'');
1685 if (
$conf->theme ==
'md' && !in_array(
$conf->browser->layout, array(
'phone',
'tablet')) && !
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER')) {
1687 if ($mainmenu !=
'website') {
1688 $tmpcsstouse = $morecssonbody;
1693 $tmpcsstouse .=
' colorblind-'.strip_tags(
getDolGlobalString(
'MAIN_OPTIMIZEFORCOLORBLIND'));
1696 print
'<body id="mainbody" class="'.$tmpcsstouse.
'">'.
"\n";
1699 if ((empty(
$conf->dol_hide_topmenu) ||
GETPOSTINT(
'dol_invisible_topmenu')) && !
GETPOST(
'dol_openinpopup',
'aZ09')) {
1700 top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring, $help_url);
1703 if (empty(
$conf->dol_hide_leftmenu) && !
GETPOST(
'dol_openinpopup',
'aZ09')) {
1704 left_menu(
'', $help_url,
'', array(), 1, $title, 1);
1708 if ($replacemainareaby) {
1709 print $replacemainareaby;
1727 global $db,
$conf, $hookmanager;
1729 if ($contenttype ==
'text/html') {
1730 header(
"Content-Type: text/html; charset=".
$conf->file->character_set_client);
1732 header(
"Content-Type: ".$contenttype);
1738 header(
"X-Content-Type-Options: nosniff");
1741 if (!defined(
'XFRAMEOPTIONS_ALLOWALL')) {
1742 header(
"X-Frame-Options: SAMEORIGIN");
1744 header(
"X-Frame-Options: ALLOWALL");
1748 $tmpurl = constant(
'DOL_MAIN_URL_ROOT');
1749 $tmpurl = preg_replace(
'/^(https?:\/\/[^\/]+)\/.*$/',
'\1', $tmpurl);
1750 header(
'Access-Control-Allow-Origin: '.$tmpurl);
1751 header(
'Vary: Origin');
1758 if (!defined(
'MAIN_SECURITY_FORCECSPRO')) {
1773 if (!is_object($hookmanager)) {
1774 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
1777 $hookmanager->initHooks(array(
"main"));
1779 $parameters = array(
'contentsecuritypolicy' => $contentsecuritypolicy,
'mode' =>
'reportonly');
1780 $result = $hookmanager->executeHooks(
'setContentSecurityPolicy', $parameters);
1782 $contentsecuritypolicy = $hookmanager->resPrint;
1784 $contentsecuritypolicy .= $hookmanager->resPrint;
1787 if (!empty($contentsecuritypolicy)) {
1788 header(
"Content-Security-Policy-Report-Only: ".$contentsecuritypolicy);
1791 header(
"Content-Security-Policy: ".constant(
'MAIN_SECURITY_FORCECSPRO'));
1795 if (!defined(
'MAIN_SECURITY_FORCECSP')) {
1810 if (!is_object($hookmanager)) {
1811 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
1814 $hookmanager->initHooks(array(
"main"));
1816 $parameters = array(
'contentsecuritypolicy' => $contentsecuritypolicy,
'mode' =>
'active');
1817 $result = $hookmanager->executeHooks(
'setContentSecurityPolicy', $parameters);
1819 $contentsecuritypolicy = $hookmanager->resPrint;
1821 $contentsecuritypolicy .= $hookmanager->resPrint;
1824 if (!empty($contentsecuritypolicy)) {
1825 header(
"Content-Security-Policy: ".$contentsecuritypolicy);
1828 header(
"Content-Security-Policy: ".constant(
'MAIN_SECURITY_FORCECSP'));
1835 if (!defined(
'MAIN_SECURITY_FORCERP')) {
1838 header(
"Referrer-Policy: ".$referrerpolicy);
1841 if ($forcenocache) {
1842 header(
"Cache-Control: no-cache, no-store, must-revalidate, max-age=0");
1864function top_htmlhead($head, $title =
'', $disablejs = 0, $disablehead = 0, $arrayofjs = array(), $arrayofcss = array(), $disableforlogin = 0, $disablenofollow = 0, $disablenoindex = 0)
1866 global $db,
$conf, $langs, $user, $mysoc, $hookmanager;
1870 if (empty(
$conf->css)) {
1871 $conf->css =
'/theme/eldy/style.css.php';
1874 print
'<!doctype html>'.
"\n";
1876 print
'<html lang="'.substr($langs->defaultlang, 0, 2).
'">'.
"\n";
1879 if (empty($disablehead)) {
1880 if (!is_object($hookmanager)) {
1881 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
1884 $hookmanager->initHooks(array(
"main"));
1886 $ext =
'layout='.(empty(
$conf->browser->layout) ?
'' :
$conf->browser->layout).
'&version='.urlencode(DOL_VERSION);
1890 if (
GETPOST(
'dol_basehref',
'alpha')) {
1891 print
'<base href="'.dol_escape_htmltag(
GETPOST(
'dol_basehref',
'alpha')).
'">'.
"\n";
1895 print
'<meta charset="utf-8">'.
"\n";
1896 print
'<meta name="robots" content="'.($disablenoindex ?
'index' :
'noindex').($disablenofollow ?
',follow' :
',nofollow').
'">'.
"\n";
1897 print
'<meta name="viewport" content="width=device-width, initial-scale=1.0">'.
"\n";
1898 print
'<meta name="author" content="Dolibarr Development Team">'.
"\n";
1899 print
'<meta name="anti-csrf-newtoken" content="'.newToken().
'">'.
"\n";
1900 print
'<meta name="anti-csrf-currenttoken" content="'.currentToken().
'">'.
"\n";
1902 print
'<meta name="MAIN_FEATURES_LEVEL" content="'.getDolGlobalInt(
'MAIN_FEATURES_LEVEL').
'">'.
"\n";
1905 $favicon = DOL_URL_ROOT.
'/theme/dolibarr_256x256_color.png';
1906 $appletouchicon = DOL_URL_ROOT.
'/theme/apple-touch-icon.png';
1907 if (!empty($mysoc->logo_squarred_mini)) {
1908 $favicon = DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/thumbs/'.$mysoc->logo_squarred_mini);
1913 if (empty(
$conf->dol_use_jmobile)) {
1914 print
'<link rel="shortcut icon" type="image/x-icon" href="'.$favicon.
'"/>'.
"\n";
1915 print
'<link rel="apple-touch-icon" href="'.$appletouchicon.
'"/>'.
"\n";
1919 $manifest = DOL_URL_ROOT.
'/theme/'.
$conf->theme.
'/manifest.json.php';
1920 $parameters = array(
'manifest' => $manifest);
1921 $resHook = $hookmanager->executeHooks(
'hookSetManifest', $parameters);
1923 $manifest = $hookmanager->resPrint;
1925 $manifest .= $hookmanager->resPrint;
1927 if (!empty($manifest)) {
1928 print
'<link rel="manifest" href="'.$manifest.
'" />'.
"\n";
1933 print
'<meta name="theme-color" content="rgb(' .
getDolGlobalString(
'THEME_ELDY_TOPMENU_BACK1').
')">'.
"\n";
1938 print
'<meta http-equiv="refresh" content="'.GETPOSTINT(
'autorefresh').
'">';
1942 $appli = constant(
'DOL_APPLICATION_TITLE');
1957 $parameters = array(
'title' => $titletoshow);
1958 $result = $hookmanager->executeHooks(
'setHtmlTitle', $parameters);
1960 $titletoshow = $hookmanager->resPrint;
1962 $titletoshow .= $hookmanager->resPrint;
1971 $ext =
'version='.GETPOSTINT(
'version');
1974 if (
GETPOST(
'dol_resetcache')) {
1975 include_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
1979 $themeparam =
'?lang='.$langs->defaultlang.
'&theme='.
$conf->theme.(GETPOST(
'optioncss',
'aZ09') ?
'&optioncss='.GETPOST(
'optioncss',
'aZ09', 1) :
'').(empty($user->id) ?
'' : (
'&userid='.$user->id)).
'&entity='.
$conf->entity;
1981 $themeparam .= ($ext ?
'&'.$ext :
'').
'&revision='.
getDolGlobalInt(
"MAIN_IHM_PARAMS_REV");
1982 if (GETPOSTISSET(
'dol_hide_topmenu')) {
1983 $themeparam .=
'&dol_hide_topmenu='.GETPOSTINT(
'dol_hide_topmenu');
1985 if (GETPOSTISSET(
'dol_hide_leftmenu')) {
1986 $themeparam .=
'&dol_hide_leftmenu='.GETPOSTINT(
'dol_hide_leftmenu');
1988 if (GETPOSTISSET(
'dol_openinpopup')) {
1989 $themeparam .=
'&dol_openinpopup='.GETPOST(
'dol_openinpopup',
'aZ09');
1991 if (GETPOSTISSET(
'dol_optimize_smallscreen')) {
1992 $themeparam .=
'&dol_optimize_smallscreen='.GETPOSTINT(
'dol_optimize_smallscreen');
1994 if (GETPOSTISSET(
'dol_no_mouse_hover')) {
1995 $themeparam .=
'&dol_no_mouse_hover='.GETPOSTINT(
'dol_no_mouse_hover');
1997 if (GETPOSTISSET(
'dol_use_jmobile')) {
1998 $themeparam .=
'&dol_use_jmobile='.GETPOSTINT(
'dol_use_jmobile');
2001 if (GETPOSTISSET(
'THEME_DARKMODEENABLED')) {
2002 $themeparam .=
'&THEME_DARKMODEENABLED='.GETPOSTINT(
'THEME_DARKMODEENABLED');
2004 if (GETPOSTISSET(
'THEME_SATURATE_RATIO')) {
2005 $themeparam .=
'&THEME_SATURATE_RATIO='.GETPOSTINT(
'THEME_SATURATE_RATIO');
2009 print
'<link rel="preconnect" href="https://fonts.gstatic.com">'.
"\n";
2010 print
'<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@200;300;400;500;600&display=swap" rel="stylesheet">'.
"\n";
2013 if (!defined(
'DISABLE_JQUERY') && !$disablejs &&
$conf->use_javascript_ajax) {
2014 print
'<!-- Includes CSS for JQuery (Ajax library) -->'.
"\n";
2015 $jquerytheme =
'base';
2019 if (constant(
'JS_JQUERY_UI')) {
2020 print
'<link rel="stylesheet" type="text/css" href="'.JS_JQUERY_UI.
'css/'.$jquerytheme.
'/jquery-ui.min.css'.($ext ?
'?'.$ext :
'').
'">'.
"\n";
2022 print
'<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.
'/includes/jquery/css/'.$jquerytheme.
'/jquery-ui.css'.($ext ?
'?'.$ext :
'').
'">'.
"\n";
2024 if (!defined(
'DISABLE_JQUERY_JNOTIFY')) {
2025 print
'<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jnotify/jquery.jnotify-alt.min.css'.($ext ?
'?'.$ext :
'').
'">'.
"\n";
2027 if (!defined(
'DISABLE_SELECT2') && (
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') || defined(
'REQUIRE_JQUERY_MULTISELECT'))) {
2028 $tmpplugin = !
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') ? constant(
'REQUIRE_JQUERY_MULTISELECT') :
$conf->global->MAIN_USE_JQUERY_MULTISELECT;
2029 print
'<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.
'/includes/jquery/plugins/'.$tmpplugin.
'/dist/css/'.$tmpplugin.
'.css'.($ext ?
'?'.$ext :
'').
'">'.
"\n";
2033 if (!defined(
'DISABLE_FONT_AWSOME')) {
2034 print
'<!-- Includes CSS for font awesome -->'.
"\n";
2035 $fontawesome_directory =
getDolGlobalString(
'MAIN_FONTAWESOME_DIRECTORY',
'/theme/common/fontawesome-5');
2036 print
'<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.$fontawesome_directory.
'/css/all.min.css'.($ext ?
'?'.$ext :
'').
'">'.
"\n";
2039 print
'<!-- Includes CSS for Dolibarr theme -->'.
"\n";
2043 if (!empty(
$conf->modules_parts[
'theme'])) {
2044 foreach (
$conf->modules_parts[
'theme'] as $reldir) {
2047 $themesubdir = $reldir;
2054 print
'<link rel="stylesheet" type="text/css" href="'.$themepath.$themeparam.
'">'.
"\n";
2056 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";
2061 print
'<link rel="stylesheet" href="'.DOL_URL_ROOT.
'/includes/leaflet/leaflet.css'.($ext ?
'?'.$ext :
'').
"\">\n";
2062 print
'<link rel="stylesheet" href="'.DOL_URL_ROOT.
'/includes/leaflet/leaflet-geoman.css'.($ext ?
'?'.$ext :
'').
"\">\n";
2066 if (!empty(
$conf->modules_parts[
'css'])) {
2067 $arraycss = (array)
$conf->modules_parts[
'css'];
2068 foreach ($arraycss as $modcss => $filescss) {
2069 $filescss = (array) $filescss;
2070 foreach ($filescss as $cssfile) {
2071 if (empty($cssfile)) {
2072 dol_syslog(
"Warning: module ".$modcss.
" declared a css path file into its descriptor that is empty.", LOG_WARNING);
2076 if ($urlforcss && $urlforcss !=
'/') {
2077 print
'<!-- Includes CSS added by module '.$modcss.
' -->'.
"\n".
'<link rel="stylesheet" type="text/css" href="'.$urlforcss;
2079 if (!preg_match(
'/\.css$/i', $cssfile)) {
2084 dol_syslog(
"Warning: module ".$modcss.
" declared a css path file for a file we can't find.", LOG_WARNING);
2090 if (is_array($arrayofcss)) {
2091 foreach ($arrayofcss as $cssfile) {
2092 if (preg_match(
'/^(http|\/\/)/i', $cssfile)) {
2093 $urltofile = $cssfile;
2097 print
'<!-- Includes CSS added by page -->'.
"\n".
'<link rel="stylesheet" type="text/css" title="default" href="'.$urltofile;
2099 if (!preg_match(
'/\.css$/i', $cssfile)) {
2109 print
'<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.
'/theme/custom.css.php'.($ext ?
'?'.$ext :
'').
'&revision='.
getDolGlobalInt(
"MAIN_IHM_PARAMS_REV").
'">'.
"\n";
2113 if (!defined(
'DISABLE_JQUERY') && !$disablejs && !empty(
$conf->use_javascript_ajax)) {
2115 print
'<!-- Includes JS for JQuery -->'.
"\n";
2116 if (defined(
'JS_JQUERY') && constant(
'JS_JQUERY')) {
2117 print
'<script nonce="'.getNonce().
'" src="'.JS_JQUERY.
'jquery.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2119 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/js/jquery.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2121 if (defined(
'JS_JQUERY_UI') && constant(
'JS_JQUERY_UI')) {
2122 print
'<script nonce="'.getNonce().
'" src="'.JS_JQUERY_UI.
'jquery-ui.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2124 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/js/jquery-ui.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2127 if (!
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') && !defined(
'DISABLE_JQUERY_JNOTIFY')) {
2128 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jnotify/jquery.jnotify.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2131 if (empty($disableforlogin) && !defined(
'DISABLE_JQUERY_TABLEDND')) {
2132 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/tablednd/jquery.tablednd.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2136 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/nnnick/chartjs/dist/chart.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2140 if (
getDolGlobalString(
'MAIN_USE_JQUERY_JEDITABLE') && !defined(
'DISABLE_JQUERY_JEDITABLE')) {
2141 print
'<!-- JS to manage editInPlace feature -->'.
"\n";
2142 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jeditable/jquery.jeditable.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2143 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jeditable/jquery.jeditable.ui-datepicker.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2144 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jeditable/jquery.jeditable.ui-autocomplete.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2145 print
'<script>'.
"\n";
2146 print
'var urlSaveInPlace = \''.DOL_URL_ROOT.
'/core/ajax/saveinplace.php\';'.
"\n";
2147 print
'var urlLoadInPlace = \''.DOL_URL_ROOT.
'/core/ajax/loadinplace.php\';'.
"\n";
2148 print
'var tooltipInPlace = \''.$langs->transnoentities(
'ClickToEdit').
'\';
'."\n"; // Added in title attribute of span
2149 print 'var placeholderInPlace = \
' \';'.
"\n";
2150 print
'var cancelInPlace = \''.$langs->trans(
"Cancel").
'\';
'."\n";
2151 print 'var submitInPlace = \
''.$langs->trans(
'Ok').
'\';
'."\n";
2152 print 'var indicatorInPlace = \
'<img src="'.DOL_URL_ROOT.
"/theme/".
$conf->theme.
"/img/working.gif".
'">\';'.
"\n";
2153 print
'var withInPlace = 300;';
2154 print
'</script>'.
"\n";
2155 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/core/js/editinplace.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2156 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jeditable/jquery.jeditable.ckeditor.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2159 if (
getDolGlobalString(
'MAIN_USE_JQUERY_TIMEPICKER') || defined(
'REQUIRE_JQUERY_TIMEPICKER')) {
2160 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2161 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/core/js/timepicker.js.php?lang='.$langs->defaultlang.($ext ?
'&'.$ext :
'').
'"></script>'.
"\n";
2163 if (!defined(
'DISABLE_SELECT2') && (
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') || defined(
'REQUIRE_JQUERY_MULTISELECT'))) {
2165 $tmpplugin = !
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') ? constant(
'REQUIRE_JQUERY_MULTISELECT') :
$conf->global->MAIN_USE_JQUERY_MULTISELECT;
2166 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/'.$tmpplugin.
'/dist/js/'.$tmpplugin.
'.full.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2168 if (!defined(
'DISABLE_MULTISELECT')) {
2169 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/multiselect/jquery.multi-select.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2173 if (!$disablejs && !empty(
$conf->use_javascript_ajax)) {
2175 if (empty($disableforlogin) && (isModEnabled(
'fckeditor') && (!
getDolGlobalString(
'FCKEDITOR_EDITORNAME') ||
getDolGlobalString(
'FCKEDITOR_EDITORNAME') ==
'ckeditor') && !defined(
'DISABLE_CKEDITOR')) || defined(
'FORCE_CKEDITOR')) {
2176 print
'<!-- Includes JS for CKEditor -->'.
"\n";
2177 $pathckeditor = DOL_URL_ROOT.
'/includes/ckeditor/ckeditor/';
2178 $jsckeditor =
'ckeditor.js';
2179 if (constant(
'JS_CKEDITOR')) {
2181 $pathckeditor = constant(
'JS_CKEDITOR');
2183 print
'<script nonce="'.getNonce().
'">';
2184 print
'/* enable ckeditor by main.inc.php */';
2185 print
'var CKEDITOR_BASEPATH = \''.dol_escape_js($pathckeditor).
'\';
'."\n";
2186 print 'var ckeditorConfig = \
''.dol_escape_js(
dol_buildpath($themesubdir.
'/theme/'.
$conf->theme.
'/ckeditor/config.js'.($ext ?
'?'.$ext :
''), 1)).
'\';
'."\n"; // $themesubdir='' in standard usage
2187 print 'var ckeditorFilebrowserBrowseUrl = \
''.DOL_URL_ROOT.
'/core/filemanagerdol/browser/default/browser.php?Connector='.DOL_URL_ROOT.
'/core/filemanagerdol/connectors/php/connector.php\';'.
"\n";
2188 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";
2189 print
'</script>'.
"\n";
2190 print
'<script src="'.$pathckeditor.$jsckeditor.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2192 if (
GETPOST(
'mode',
'aZ09') ==
'Full_inline') {
2193 print
'CKEDITOR.disableAutoInline = false;'.
"\n";
2195 print
'CKEDITOR.disableAutoInline = true;'.
"\n";
2197 print
'</script>'.
"\n";
2201 if (!defined(
'NOBROWSERNOTIF') && !defined(
'NOREQUIREMENU') && !defined(
'NOLOGIN')) {
2202 $enablebrowsernotif =
false;
2204 $enablebrowsernotif =
true;
2206 if (
$conf->browser->layout ==
'phone') {
2207 $enablebrowsernotif =
false;
2209 if ($enablebrowsernotif) {
2210 print
'<!-- Includes JS of Dolibarr (browser layout = '.$conf->browser->layout.
')-->'.
"\n";
2211 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/core/js/lib_notification.js.php?lang='.$langs->defaultlang.($ext ?
'&'.$ext :
'').
'"></script>'.
"\n";
2216 print
'<!-- Includes JS of Dolibarr -->'.
"\n";
2217 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/core/js/lib_head.js.php?lang='.$langs->defaultlang.($ext ?
'&'.$ext :
'').
'"></script>'.
"\n";
2221 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/leaflet/leaflet.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2222 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/includes/leaflet/leaflet-geoman.min.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2226 if (!empty(
$conf->modules_parts[
'js'])) {
2227 $arrayjs = (array)
$conf->modules_parts[
'js'];
2228 foreach ($arrayjs as $modjs => $filesjs) {
2229 $filesjs = (array) $filesjs;
2230 foreach ($filesjs as $jsfile) {
2233 if ($urlforjs && $urlforjs !=
'/') {
2234 print
'<!-- Include JS added by module '.$modjs.
'-->'.
"\n";
2235 print
'<script nonce="'.getNonce().
'" src="'.$urlforjs.((strpos($jsfile,
'?') ===
false) ?
'?' :
'&').
'lang='.$langs->defaultlang.
'"></script>'.
"\n";
2237 dol_syslog(
"Warning: module ".$modjs.
" declared a js path file for a file we can't find.", LOG_WARNING);
2243 if (is_array($arrayofjs)) {
2244 print
'<!-- Includes JS added by page -->'.
"\n";
2245 foreach ($arrayofjs as $jsfile) {
2246 if (preg_match(
'/^(http|\/\/)/i', $jsfile)) {
2247 print
'<script nonce="'.getNonce().
'" src="'.$jsfile.((strpos($jsfile,
'?') ===
false) ?
'?' :
'&').
'lang='.$langs->defaultlang.
'"></script>'.
"\n";
2249 print
'<script nonce="'.getNonce().
'" src="'.
dol_buildpath($jsfile, 1).((strpos($jsfile,
'?') ===
false) ?
'?' :
'&').
'lang='.$langs->defaultlang.
'"></script>'.
"\n";
2258 if (file_exists($theme_js)) {
2259 print
'<script nonce="'.getNonce().
'" src="'.DOL_URL_ROOT.
'/theme/'.
$conf->theme.
'/'.
$conf->theme.
'.js'.($ext ?
'?'.$ext :
'').
'"></script>'.
"\n";
2263 if (!empty($head)) {
2270 $parameters = array();
2271 $result = $hookmanager->executeHooks(
'addHtmlHeader', $parameters);
2272 print $hookmanager->resPrint;
2274 print
"</head>\n\n";
2277 $conf->headerdone = 1;
2297function top_menu($head, $title =
'', $target =
'', $disablejs = 0, $disablehead = 0, $arrayofjs = array(), $arrayofcss = array(), $morequerystring =
'', $helppagename =
'')
2299 global $user,
$conf, $langs, $db, $form;
2300 global $dolibarr_main_authentication, $dolibarr_main_demo;
2301 global $hookmanager, $menumanager;
2306 $hookmanager->initHooks(array(
'toprightmenu'));
2311 if (empty(
$conf->headerdone)) {
2312 $disablenofollow = 0;
2313 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss, 0, $disablenofollow);
2314 print
'<body id="mainbody">';
2320 if ((empty(
$conf->dol_hide_topmenu) ||
GETPOSTINT(
'dol_invisible_topmenu')) && (!defined(
'NOREQUIREMENU') || !constant(
'NOREQUIREMENU'))) {
2321 if (!isset($form) || !is_object($form)) {
2322 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
2323 $form =
new Form($db);
2326 print
"\n".
'<!-- Start top horizontal -->'.
"\n";
2328 print
'<header id="id-top" class="side-nav-vert'.(GETPOSTINT(
'dol_invisible_topmenu') ?
' hidden' :
'').
'">';
2331 print
'<div id="tmenu_tooltip'.(!
getDolGlobalString(
'MAIN_MENU_INVERT') ?
'' :
'invert').
'" class="tmenu">'.
"\n";
2333 $menumanager->atarget = $target;
2335 $menumanager->showmenu(
'top', array(
'searchform' => $searchform));
2339 $appli = constant(
'DOL_APPLICATION_TITLE');
2342 if (preg_match(
'/\d\.\d/', $appli)) {
2343 if (!preg_match(
'/'.preg_quote(DOL_VERSION).
'/', $appli)) {
2344 $appli .=
" (".DOL_VERSION.
")";
2347 $appli .=
" ".DOL_VERSION;
2350 $appli .=
" ".DOL_VERSION;
2354 $appli .=
"<br>".$langs->trans(
"LevelOfFeature").
': '.
getDolGlobalInt(
'MAIN_FEATURES_LEVEL');
2358 $logouthtmltext =
'';
2361 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
2362 if (
$conf->browser->name ==
'chrome') {
2363 $stringforfirstkey .=
' ALT +';
2364 } elseif (
$conf->browser->name ==
'firefox') {
2365 $stringforfirstkey .=
' ALT + SHIFT +';
2367 $stringforfirstkey .=
' CTL +';
2369 if ($_SESSION[
"dol_authmode"] !=
'forceuser' && $_SESSION[
"dol_authmode"] !=
'http') {
2370 $logouthtmltext .= $langs->trans(
"Logout").
'<br>';
2371 $logouttext .=
'<a accesskey="l" href="'.DOL_URL_ROOT.
'/user/logout.php?token='.
newToken().
'">';
2372 $logouttext .=
img_picto($langs->trans(
'Logout').
' ('.$stringforfirstkey.
' l)',
'sign-out',
'', 0, 0, 0,
'',
'atoplogin valignmiddle');
2373 $logouttext .=
'</a>';
2375 $logouthtmltext .= $langs->trans(
"NoLogoutProcessWithAuthMode", $_SESSION[
"dol_authmode"]);
2376 $logouttext .=
img_picto($langs->trans(
'Logout').
' ('.$stringforfirstkey.
' l)',
'sign-out',
'', 0, 0, 0,
'',
'atoplogin valignmiddle opacitymedium');
2381 print
'<div class="login_block usedropdown">'.
"\n";
2385 $toprightmenu .=
'<div class="login_block_tools valignmiddle">';
2388 $toprightmenu .=
'<div class="inline-block nowrap" style="padding: 0px;">';
2408 $toprightmenu .=
'</div>';
2410 $toprightmenu .=
'</div>'.
"\n";
2414 $toprightmenu .=
'<div class="login_block_other valignmiddle">';
2417 $parameters = array();
2418 $result = $hookmanager->executeHooks(
'printTopRightMenu', $parameters);
2419 if (is_numeric($result)) {
2421 $toprightmenu .= $hookmanager->resPrint;
2423 $toprightmenu = $hookmanager->resPrint;
2426 $toprightmenu .= $result;
2430 if (isModEnabled(
'modulebuilder')) {
2431 $text =
'<a href="'.DOL_URL_ROOT.
'/modulebuilder/index.php?mainmenu=home&leftmenu=admintools" target="modulebuilder">';
2433 $text .=
'<span class="fa fa-bug atoplogin valignmiddle"></span>';
2436 $toprightmenu .= $form->textwithtooltip(
'', $langs->trans(
"ModuleBuilder"), 2, 1, $text,
'login_block_elem', 2);
2443 if (isset($_POST) && is_array($_POST)) {
2444 foreach ($_POST as $key => $value) {
2445 $key = preg_replace(
'/[^a-z0-9_\.\-\[\]]/i',
'', $key);
2446 if (in_array($key, array(
'action',
'massaction',
'password'))) {
2449 if (!is_array($value)) {
2450 if ($value !==
'') {
2451 $qs .=
'&'.urlencode($key).
'='.urlencode($value);
2454 foreach ($value as $value2) {
2455 if (($value2 !==
'') && (!is_array($value2))) {
2456 $qs .=
'&'.urlencode($key).
'[]='.urlencode($value2);
2462 $qs .= (($qs && $morequerystring) ?
'&' :
'').$morequerystring;
2463 $text =
'<a href="'.dol_escape_htmltag($_SERVER[
"PHP_SELF"]).
'?'.$qs.($qs ?
'&' :
'').
'optioncss=print" target="_blank" rel="noopener noreferrer">';
2465 $text .=
'<span class="fa fa-print atoplogin valignmiddle"></span>';
2468 $toprightmenu .= $form->textwithtooltip(
'', $langs->trans(
"PrintContentArea"), 2, 1, $text,
'login_block_elem', 2);
2473 $langs->load(
"help");
2480 if (empty($helppagename)) {
2481 $helppagename =
'EN:User_documentation|FR:Documentation_utilisateur|ES:Documentación_usuarios|DE:Benutzerdokumentation';
2483 $helppresent =
'helppresent';
2488 $helpbaseurl = $arrayres[
'helpbaseurl'];
2489 $helppage = $arrayres[
'helppage'];
2490 $mode = $arrayres[
'mode'];
2493 if ($helpbaseurl && $helppage) {
2495 $title = $langs->trans($mode ==
'wiki' ?
'GoToWikiHelpPage' :
'GoToHelpPage').
', ';
2496 if ($mode ==
'wiki') {
2497 $title .=
'<br>'.img_picto(
'',
'globe',
'class="pictofixedwidth"').$langs->trans(
"PageWiki").
' '.
dol_escape_htmltag(
'"'.strtr($helppage,
'_',
' ').
'"');
2499 $title .=
' <span class="opacitymedium">('.$langs->trans(
"DedicatedPageAvailable").
')</span>';
2501 $title .=
' <span class="opacitymedium">('.$langs->trans(
"HomePage").
')</span>';
2504 $text .=
'<a class="help" target="_blank" rel="noopener noreferrer" href="';
2505 if ($mode ==
'wiki') {
2507 $text .= sprintf($helpbaseurl, urlencode(html_entity_decode($helppage)));
2510 $text .= sprintf($helpbaseurl, $helppage);
2513 $text .=
'<span class="fa fa-question-circle atoplogin valignmiddle'.($helppresent ?
' '.$helppresent :
'').
'"></span>';
2514 $text .=
'<span class="fa fa-long-arrow-alt-up helppresentcircle'.($helppresent ?
'' :
' unvisible').
'"></span>';
2517 $toprightmenu .= $form->textwithtooltip(
'', $title, 2, 1, $text,
'login_block_elem', 2);
2522 $langs->load(
'admin');
2523 $appli .=
'<br>'.$langs->trans(
"Database").
': '.$db->database_name;
2529 $text =
'<span class="aversion"><span class="hideonsmartphone small">'.DOL_VERSION.
'</span></span>';
2531 $toprightmenu .= $form->textwithtooltip(
'', $appli, 2, 1, $text,
'login_block_elem', 2);
2536 $toprightmenu .= $form->textwithtooltip(
'', $logouthtmltext, 2, 1, $logouttext,
'login_block_elem logout-btn', 2);
2539 $toprightmenu .=
'</div>';
2543 $toprightmenu .=
'<div class="login_block_user">';
2546 $toprightmenu .=
'<div class="inline-block login_block_elem login_block_elem_name nowrap centpercent" style="padding: 0px;">';
2551 $toprightmenu .=
'</div>';
2553 $toprightmenu .=
'</div>'.
"\n";
2556 print $toprightmenu;
2563 print
'<div style="clear: both;"></div>';
2564 print
"<!-- End top horizontal menu -->\n\n";
2567 if (empty(
$conf->dol_hide_leftmenu) && empty(
$conf->dol_use_jmobile)) {
2568 print
'<!-- Begin div id-container --><div id="id-container" class="id-container">';
2582 global $langs,
$conf, $db, $hookmanager, $user, $mysoc;
2583 global $dolibarr_main_authentication, $dolibarr_main_demo;
2584 global $menumanager;
2587 if (
$conf->browser->name ==
'textbrowser') {
2591 $langs->load(
'companies');
2593 $userImage = $userDropDownImage =
'';
2594 if (!empty($user->photo)) {
2595 $userImage =
Form::showphoto(
'userphoto', $user, 0, 0, 0,
'photouserphoto userphoto',
'small', 0, 1);
2596 $userDropDownImage =
Form::showphoto(
'userphoto', $user, 0, 0, 0,
'dropdown-user-image',
'small', 0, 1);
2598 $nophoto =
'/public/theme/common/user_anonymous.png';
2599 if ($user->gender ==
'man') {
2600 $nophoto =
'/public/theme/common/user_man.png';
2602 if ($user->gender ==
'woman') {
2603 $nophoto =
'/public/theme/common/user_woman.png';
2606 $userImage =
'<img class="photo photouserphoto userphoto" alt="" src="'.DOL_URL_ROOT.$nophoto.
'" aria-hidden="true">';
2607 $userDropDownImage =
'<img class="photo dropdown-user-image" alt="" src="'.DOL_URL_ROOT.$nophoto.
'">';
2611 $dropdownBody .=
'<span id="topmenulogincompanyinfo-btn"><i class="fa fa-caret-right"></i> '.$langs->trans(
"ShowCompanyInfos").
'</span>';
2612 $dropdownBody .=
'<div id="topmenulogincompanyinfo" >';
2614 $dropdownBody .=
'<br><b>'.$langs->trans(
"Company").
'</b>: <span>'.
dol_escape_htmltag($mysoc->name).
'</span>';
2616 while ($idprofcursor < 10) {
2618 $constkeyforprofid =
'MAIN_INFO_PROFID'.$idprofcursor;
2619 if ($idprofcursor == 1) {
2620 $constkeyforprofid =
'MAIN_INFO_SIREN';
2622 if ($idprofcursor == 2) {
2623 $constkeyforprofid =
'MAIN_INFO_SIRET';
2625 if ($idprofcursor == 3) {
2626 $constkeyforprofid =
'MAIN_INFO_APE';
2628 if ($idprofcursor == 4) {
2629 $constkeyforprofid =
'MAIN_INFO_RCS';
2631 $showprofid = (($idprofcursor <= 6) && $langs->transcountry(
"ProfId".$idprofcursor, $mysoc->country_code) !=
'-');
2636 $dropdownBody .=
'<br><b>'.$langs->transcountry(
"ProfId".$idprofcursor, $mysoc->country_code).
'</b>: <span>'.
dol_print_profids(
getDolGlobalString($constkeyforprofid),
'1').
'</span>';
2640 $dropdownBody .=
'<br><b>'.$langs->trans(
"Country").
'</b>: <span>'.($mysoc->country_code ? $langs->trans(
"Country".$mysoc->country_code) :
'').
'</span>';
2641 if (isModEnabled(
'multicurrency')) {
2642 $dropdownBody .=
'<br><b>'.$langs->trans(
"Currency").
'</b>: <span>'.
$conf->currency.
'</span>';
2644 $dropdownBody .=
'</div>';
2646 $dropdownBody .=
'<br>';
2647 $dropdownBody .=
'<span id="topmenuloginmoreinfo-btn"><i class="fa fa-caret-right"></i> '.$langs->trans(
"ShowMoreInfos").
'</span>';
2648 $dropdownBody .=
'<div id="topmenuloginmoreinfo" >';
2651 if (!empty($user->admin)) {
2652 $dropdownBody .=
'<br><b>'.$langs->trans(
"Administrator").
'</b>: '.
yn($user->admin);
2655 if (!empty($user->socid)) {
2656 $thirdpartystatic =
new Societe($db);
2657 $thirdpartystatic->fetch($user->socid);
2658 $companylink =
' '.$thirdpartystatic->getNomUrl(2);
2659 $company =
' ('.$langs->trans(
"Company").
': '.$thirdpartystatic->name.
')';
2661 $type = ($user->socid ? $langs->trans(
"External").$company : $langs->trans(
"Internal"));
2662 $dropdownBody .=
'<br><b>'.$langs->trans(
"Type").
':</b> '.$type;
2663 $dropdownBody .=
'<br><b>'.$langs->trans(
"Status").
'</b>: '.$user->getLibStatut(0);
2664 $dropdownBody .=
'<br>';
2666 $dropdownBody .=
'<br><u>'.$langs->trans(
"Session").
'</u>';
2667 $dropdownBody .=
'<br><b>'.$langs->trans(
"IPAddress").
'</b>: '.
dol_escape_htmltag($_SERVER[
"REMOTE_ADDR"]);
2669 $dropdownBody .=
'<br><b>'.$langs->trans(
"ConnectedOnMultiCompany").
':</b> '.
$conf->entity.
' (user entity '.$user->entity.
')';
2671 $dropdownBody .=
'<br><b>'.$langs->trans(
"AuthenticationMode").
':</b> '.$_SESSION[
"dol_authmode"].(empty($dolibarr_main_demo) ?
'' :
' (demo)');
2672 $dropdownBody .=
'<br><b>'.$langs->trans(
"ConnectedSince").
':</b> '.
dol_print_date($user->datelastlogin,
"dayhour",
'tzuser');
2673 $dropdownBody .=
'<br><b>'.$langs->trans(
"PreviousConnexion").
':</b> '.
dol_print_date($user->datepreviouslogin,
"dayhour",
'tzuser');
2674 $dropdownBody .=
'<br><b>'.$langs->trans(
"CurrentTheme").
':</b> '.
$conf->theme;
2676 $dropdownBody .=
'<br><b>'.$langs->trans(
"CurrentMenuManager").
':</b> '.(isset($menumanager) ? $menumanager->name :
'unknown');
2678 $dropdownBody .=
'<br><b>'.$langs->trans(
"CurrentUserLanguage").
':</b> '.($langFlag ? $langFlag.
' ' :
'').$langs->getDefaultLang();
2680 $tz = (int) $_SESSION[
'dol_tz'] + (
int) $_SESSION[
'dol_dst'];
2681 $dropdownBody .=
'<br><b>'.$langs->trans(
"ClientTZ").
':</b> '.($tz ? ($tz >= 0 ?
'+' :
'').$tz :
'');
2682 $dropdownBody .=
' ('.$_SESSION[
'dol_tz_string'].
')';
2687 $dropdownBody .=
'<br><b>'.$langs->trans(
"Browser").
':</b> '.
$conf->browser->name.($conf->browser->version ?
' '.$conf->browser->version :
'').
' <small class="opacitymedium">('.
dol_escape_htmltag($_SERVER[
'HTTP_USER_AGENT']).
')</small>';
2688 $dropdownBody .=
'<br><b>'.$langs->trans(
"Layout").
':</b> '.
$conf->browser->layout;
2689 $dropdownBody .=
'<br><b>'.$langs->trans(
"Screen").
':</b> '.$_SESSION[
'dol_screenwidth'].
' x '.$_SESSION[
'dol_screenheight'];
2690 if (
$conf->browser->layout ==
'phone') {
2691 $dropdownBody .=
'<br><b>'.$langs->trans(
"Phone").
':</b> '.$langs->trans(
"Yes");
2693 if (!empty($_SESSION[
"disablemodules"])) {
2694 $dropdownBody .=
'<br><b>'.$langs->trans(
"DisabledModules").
':</b> <br>'.implode(
', ', explode(
',', $_SESSION[
"disablemodules"]));
2696 $dropdownBody .=
'</div>';
2699 $parameters = array(
'user' => $user,
'langs' => $langs);
2700 $result = $hookmanager->executeHooks(
'printTopRightMenuLoginDropdownBody', $parameters);
2701 if (is_numeric($result)) {
2703 $dropdownBody .= $hookmanager->resPrint;
2705 $dropdownBody = $hookmanager->resPrint;
2709 if (empty($urllogout)) {
2710 $urllogout = DOL_URL_ROOT.
'/user/logout.php?token='.
newToken();
2715 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
2716 if (
$conf->browser->name ==
'chrome') {
2717 $stringforfirstkey .=
' ALT +';
2718 } elseif (
$conf->browser->name ==
'firefox') {
2719 $stringforfirstkey .=
' ALT + SHIFT +';
2721 $stringforfirstkey .=
' CTL +';
2725 $profilLink =
'<a accesskey="u" href="'.DOL_URL_ROOT.
'/user/card.php?id='.$user->id.
'" class="button-top-menu-dropdown" title="'.
dol_escape_htmltag($langs->trans(
"YourUserFile").
' ('.$stringforfirstkey.
' u)').
'"><i class="fa fa-user"></i> '.$langs->trans(
"Card").
'</a>';
2726 $urltovirtualcard =
'/user/virtualcard.php?id='.((int) $user->id);
2727 $virtuelcardLink =
dolButtonToOpenUrlInDialogPopup(
'publicvirtualcardmenu', $langs->transnoentitiesnoconv(
"PublicVirtualCardUrl").(is_object($user) ?
' - '.$user->getFullName($langs) :
'').
' ('.$stringforfirstkey.
' v)',
img_picto($langs->trans(
"PublicVirtualCardUrl").
' ('.$stringforfirstkey.
' v)',
'card',
''), $urltovirtualcard,
'',
'button-top-menu-dropdown marginleftonly nohover',
"closeTopMenuLoginDropdown()",
'',
'v');
2728 $logoutLink =
'<a accesskey="l" href="'.$urllogout.
'" class="button-top-menu-dropdown" title="'.
dol_escape_htmltag($langs->trans(
"Logout").
' ('.$stringforfirstkey.
' l)').
'"><i class="fa fa-sign-out-alt pictofixedwidth"></i><span class="hideonsmartphone">'.$langs->trans(
"Logout").
'</span></a>';
2730 $profilName = $user->getFullName($langs).
' ('.$user->login.
')';
2731 if (!empty($user->admin)) {
2732 $profilName =
'<i class="far fa-star classfortooltip" title="'.$langs->trans(
"Administrator").
'" ></i> '.$profilName;
2736 $appli = constant(
'DOL_APPLICATION_TITLE');
2739 if (preg_match(
'/\d\.\d/', $appli)) {
2740 if (!preg_match(
'/'.preg_quote(DOL_VERSION).
'/', $appli)) {
2741 $appli .=
" (".DOL_VERSION.
")";
2744 $appli .=
" ".DOL_VERSION;
2747 $appli .=
" ".DOL_VERSION;
2751 $btnUser =
'<!-- div for user link -->
2752 <div id="topmenu-login-dropdown" class="userimg atoplogin dropdown user user-menu inline-block">
2753 <a href="'.DOL_URL_ROOT.
'/user/card.php?id='.$user->id.
'" class="dropdown-toggle login-dropdown-a valignmiddle" data-toggle="dropdown">
2754 '.$userImage.(empty($user->photo) ?
'<!-- no photo so show also the login --><span class="hidden-xs maxwidth200 atoploginusername hideonsmartphone paddingleft valignmiddle small">'.dol_trunc($user->firstname ? $user->firstname : $user->login, 10).
'</span>' :
'').
'
2756 <div class="dropdown-menu">
2758 <div class="user-header">
2759 '.$userDropDownImage.
'
2761 '.$profilName.
'<br>';
2763 if ($user->datelastlogin) {
2764 $title = $langs->trans(
"ConnectedSince").
' : '.
dol_print_date($user->datelastlogin,
"dayhour",
'tzuser');
2765 if ($user->datepreviouslogin) {
2766 $title .=
'<br>'.$langs->trans(
"PreviousConnexion").
' : '.
dol_print_date($user->datepreviouslogin,
"dayhour",
'tzuser');
2769 $btnUser .=
'<small class="classfortooltip" title="'.dol_escape_htmltag($title).
'" ><i class="fa fa-user-clock"></i> '.
dol_print_date($user->datelastlogin,
"dayhour",
'tzuser').
'</small><br>';
2770 if ($user->datepreviouslogin) {
2771 $btnUser .=
'<small class="classfortooltip" title="'.dol_escape_htmltag($title).
'" ><i class="fa fa-user-clock opacitymedium"></i> '.
dol_print_date($user->datepreviouslogin,
"dayhour",
'tzuser').
'</small><br>';
2779 <!-- Menu Body user-->
2780 <div class="user-body">'.$dropdownBody.
'</div>
2783 <div class="user-footer">
2784 <div class="pull-left">
2787 <div class="pull-left">
2788 '.$virtuelcardLink.
'
2790 <div class="pull-right">
2793 <div class="clearboth"></div>
2799 $btnUser =
'<!-- div for user link text browser -->
2800 <div id="topmenu-login-dropdown" class="userimg atoplogin dropdown user user-menu inline-block">
2801 <a href="'.DOL_URL_ROOT.
'/user/card.php?id='.$user->id.
'" class="valignmiddle" alt="'.$langs->trans(
"MyUserCard").
'">
2802 '.$userImage.(empty($user->photo) ?
'<span class="hidden-xs maxwidth200 atoploginusername hideonsmartphone paddingleft small valignmiddle">'.dol_trunc($user->firstname ? $user->firstname : $user->login, 10).
'</span>' :
'').
'
2807 if (!defined(
'JS_JQUERY_DISABLE_DROPDOWN') && !empty(
$conf->use_javascript_ajax)) {
2809 <!-- Code to show/hide the user drop-down -->
2811 function closeTopMenuLoginDropdown() {
2812 console.log("close login dropdown"); // This is called at each click on page, so we disable the log
2814 jQuery("#topmenu-login-dropdown").removeClass("open");
2816 jQuery(document).ready(function() {
2817 jQuery(document).on("click", function(event) {
2818 if (!$(event.target).closest("#topmenu-login-dropdown").length) {
2819 /* console.log("click close login - we click outside"); */
2820 closeTopMenuLoginDropdown();
2828 jQuery("#topmenu-login-dropdown .dropdown-toggle").on("click", function(event) {
2829 console.log("Click on #topmenu-login-dropdown .dropdown-toggle");
2830 event.preventDefault();
2831 jQuery("#topmenu-login-dropdown").toggleClass("open");
2834 jQuery("#topmenulogincompanyinfo-btn").on("click", function() {
2835 console.log("Click on #topmenulogincompanyinfo-btn");
2836 jQuery("#topmenulogincompanyinfo").slideToggle();
2839 jQuery("#topmenuloginmoreinfo-btn").on("click", function() {
2840 console.log("Click on #topmenuloginmoreinfo-btn");
2841 jQuery("#topmenuloginmoreinfo").slideToggle();
2862 global
$conf, $langs;
2873 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
2874 if (
$conf->browser->os ===
'macintosh') {
2875 $stringforfirstkey .=
' CTL +';
2877 if (
$conf->browser->name ==
'chrome') {
2878 $stringforfirstkey .=
' ALT +';
2879 } elseif (
$conf->browser->name ==
'firefox') {
2880 $stringforfirstkey .=
' ALT + SHIFT +';
2882 $stringforfirstkey .=
' CTL +';
2886 if (!empty(
$conf->use_javascript_ajax)) {
2887 $html .=
'<!-- div for quick add link -->
2888 <div id="topmenu-quickadd-dropdown" class="atoplogin dropdown inline-block">
2889 <a accesskey="a" class="dropdown-toggle login-dropdown-a nofocusvisible" data-toggle="dropdown" href="#" title="'.$langs->trans(
'QuickAdd').
' ('.$stringforfirstkey.
' a)"><i class="fa fa-plus-circle"></i></a>
2892 if (!defined(
'JS_JQUERY_DISABLE_DROPDOWN')) {
2894 <!-- Code to show/hide the user drop-down for the quick add -->
2896 jQuery(document).ready(function() {
2897 jQuery(document).on("click", function(event) {
2898 if (!$(event.target).closest("#topmenu-quickadd-dropdown").length) {
2899 /* console.log("click close quick add - we click outside"); */
2901 $("#topmenu-quickadd-dropdown").removeClass("open");
2904 $("#topmenu-quickadd-dropdown .dropdown-toggle").on("click", function(event) {
2905 console.log("Click on #topmenu-quickadd-dropdown .dropdown-toggle");
2906 openQuickAddDropDown(event);
2910 $(document).keydown(function(event){
2911 var ostype = \''.dol_escape_js(
$conf->browser->os).
'\';
2912 if (ostype ===
"macintosh") {
2913 if ( event.which === 65 && event.ctrlKey ) {
2914 console.log(\
'control + a : trigger open quick add dropdown\');
2915 openQuickAddDropDown(event);
2918 if ( event.which === 65 && event.ctrlKey && event.shiftKey ) {
2919 console.log(\'control + shift + a : trigger open quick add dropdown\');
2920 openQuickAddDropDown(event);
2925 var openQuickAddDropDown = function(event) {
2926 event.preventDefault();
2927 $("#topmenu-quickadd-dropdown").toggleClass("open");
2928 //$("#top-quickadd-search-input").focus();
2948 global
$conf, $langs;
2959 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
2960 if (
$conf->browser->os ===
'macintosh') {
2961 $stringforfirstkey .=
' CTL +';
2963 if (
$conf->browser->name ==
'chrome') {
2964 $stringforfirstkey .=
' ALT +';
2965 } elseif (
$conf->browser->name ==
'firefox') {
2966 $stringforfirstkey .=
' ALT + SHIFT +';
2968 $stringforfirstkey .=
' CTL +';
2973 if (!empty(
$conf->use_javascript_ajax)) {
2974 $urlforuploadpage = DOL_URL_ROOT.
'/core/upload_page.php';
2979 $html .=
'<!-- div for link to upload file -->
2980 <div id="topmenu-uploadfile-dropdown" class="atoplogin dropdown inline-block">
2981 <a accesskey="i" class="dropdown-togglex login-dropdown-a nofocusvisible" data-toggle="dropdown" href="'.$urlforuploadpage.
'" title="'.$langs->trans(
'UploadFile').
' ('.$stringforfirstkey.
' i)"><i class="fa fa-upload"></i></a>
2997 global $user, $langs, $hookmanager;
3002 "url" =>
"/adherents/card.php?action=create&mainmenu=members",
3003 "title" =>
"MenuNewMember@members",
3004 "name" =>
"Adherent@members",
3005 "picto" =>
"object_member",
3006 "activation" => isModEnabled(
'member') && $user->hasRight(
"adherent",
"write"),
3010 "url" =>
"/societe/card.php?action=create&mainmenu=companies",
3011 "title" =>
"MenuNewThirdParty@companies",
3012 "name" =>
"ThirdParty@companies",
3013 "picto" =>
"object_company",
3014 "activation" => isModEnabled(
"societe") && $user->hasRight(
"societe",
"write"),
3018 "url" =>
"/contact/card.php?action=create&mainmenu=companies",
3019 "title" =>
"NewContactAddress@companies",
3020 "name" =>
"Contact@companies",
3021 "picto" =>
"object_contact",
3022 "activation" => isModEnabled(
"societe") && $user->hasRight(
"societe",
"contact",
"write"),
3026 "url" =>
"/comm/propal/card.php?action=create&mainmenu=commercial",
3027 "title" =>
"NewPropal@propal",
3028 "name" =>
"Proposal@propal",
3029 "picto" =>
"object_propal",
3030 "activation" => isModEnabled(
"propal") && $user->hasRight(
"propal",
"write"),
3035 "url" =>
"/commande/card.php?action=create&mainmenu=commercial",
3036 "title" =>
"NewOrder@orders",
3037 "name" =>
"Order@orders",
3038 "picto" =>
"object_order",
3039 "activation" => isModEnabled(
'order') && $user->hasRight(
"commande",
"write"),
3043 "url" =>
"/compta/facture/card.php?action=create&mainmenu=billing",
3044 "title" =>
"NewBill@bills",
3045 "name" =>
"Bill@bills",
3046 "picto" =>
"object_bill",
3047 "activation" => isModEnabled(
'invoice') && $user->hasRight(
"facture",
"write"),
3051 "url" =>
"/contrat/card.php?action=create&mainmenu=commercial",
3052 "title" =>
"NewContractSubscription@contracts",
3053 "name" =>
"Contract@contracts",
3054 "picto" =>
"object_contract",
3055 "activation" => isModEnabled(
'contract') && $user->hasRight(
"contrat",
"write"),
3059 "url" =>
"/supplier_proposal/card.php?action=create&mainmenu=commercial",
3060 "title" =>
"SupplierProposalNew@supplier_proposal",
3061 "name" =>
"SupplierProposal@supplier_proposal",
3062 "picto" =>
"supplier_proposal",
3063 "activation" => isModEnabled(
'supplier_proposal') && $user->hasRight(
"supplier_invoice",
"write"),
3067 "url" =>
"/fourn/commande/card.php?action=create&mainmenu=commercial",
3068 "title" =>
"NewSupplierOrderShort@orders",
3069 "name" =>
"SupplierOrder@orders",
3070 "picto" =>
"supplier_order",
3071 "activation" => (isModEnabled(
"fournisseur") && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight(
"fournisseur",
"commande",
"write")) || (isModEnabled(
"supplier_order") && $user->hasRight(
"supplier_invoice",
"write")),
3075 "url" =>
"/fourn/facture/card.php?action=create&mainmenu=billing",
3076 "title" =>
"NewBill@bills",
3077 "name" =>
"SupplierBill@bills",
3078 "picto" =>
"supplier_invoice",
3079 "activation" => (isModEnabled(
"fournisseur") && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight(
"fournisseur",
"facture",
"write")) || (isModEnabled(
"supplier_invoice") && $user->hasRight(
"supplier_invoice",
"write")),
3083 "url" =>
"/ticket/card.php?action=create&mainmenu=ticket",
3084 "title" =>
"NewTicket@ticket",
3085 "name" =>
"Ticket@ticket",
3086 "picto" =>
"ticket",
3087 "activation" => isModEnabled(
'ticket') && $user->hasRight(
"ticket",
"write"),
3091 "url" =>
"/fichinter/card.php?action=create&mainmenu=commercial",
3092 "title" =>
"NewIntervention@interventions",
3093 "name" =>
"Intervention@interventions",
3094 "picto" =>
"intervention",
3095 "activation" => isModEnabled(
'intervention') && $user->hasRight(
"ficheinter",
"creer"),
3099 "url" =>
"/product/card.php?action=create&type=0&mainmenu=products",
3100 "title" =>
"NewProduct@products",
3101 "name" =>
"Product@products",
3102 "picto" =>
"object_product",
3103 "activation" => isModEnabled(
"product") && $user->hasRight(
"produit",
"write"),
3107 "url" =>
"/product/card.php?action=create&type=1&mainmenu=products",
3108 "title" =>
"NewService@products",
3109 "name" =>
"Service@products",
3110 "picto" =>
"object_service",
3111 "activation" => isModEnabled(
"service") && $user->hasRight(
"service",
"write"),
3115 "url" =>
"/user/card.php?action=create&type=1&mainmenu=home",
3116 "title" =>
"AddUser@users",
3117 "name" =>
"User@users",
3119 "activation" => $user->hasRight(
"user",
"user",
"write"),
3125 $dropDownQuickAddHtml =
'';
3129 $dropDownQuickAddHtml .=
'<div class="quickadd-body dropdown-body">';
3131 $dropDownQuickAddHtml .=
'<div class="dropdown-quickadd-list">';
3134 $parameters = array();
3135 $hook_items = $items;
3136 $reshook = $hookmanager->executeHooks(
'menuDropdownQuickaddItems', $parameters, $hook_items);
3137 if (is_numeric($reshook) && !empty($hookmanager->resArray) && is_array($hookmanager->resArray)) {
3138 if ($reshook == 0) {
3139 $items[
'items'] = array_merge($items[
'items'], $hookmanager->resArray);
3141 $items = $hookmanager->resArray;
3145 $position = array();
3146 foreach ($items[
'items'] as $key => $row) {
3147 $position[$key] = $row[
'position'];
3149 $array1_sort_order = SORT_ASC;
3150 array_multisort($position, $array1_sort_order, $items[
'items']);
3153 foreach ($items[
'items'] as $item) {
3154 if (!$item[
'activation']) {
3157 $langs->load(explode(
'@', $item[
'title'])[1]);
3158 $langs->load(explode(
'@', $item[
'name'])[1]);
3159 $dropDownQuickAddHtml .=
'
3160 <a class="dropdown-item quickadd-item" href="'.DOL_URL_ROOT.$item[
'url'].
'" title="'.$langs->trans(explode(
'@', $item[
'title'])[0]).
'">
3161 '.
img_picto(
'', $item[
'picto'],
'style="width:18px;"') .
' ' . $langs->trans(explode(
'@', $item[
'name'])[0]) .
'</a>
3166 $dropDownQuickAddHtml .=
'</div>';
3168 $dropDownQuickAddHtml .=
'</div>';
3170 return $dropDownQuickAddHtml;
3180 global $langs,
$conf, $user;
3185 if (!isModEnabled(
'bookmark') || !$user->hasRight(
'bookmark',
'lire')) {
3196 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
3197 if (
$conf->browser->os ===
'macintosh') {
3198 $stringforfirstkey .=
' CTL +';
3200 if (
$conf->browser->name ==
'chrome') {
3201 $stringforfirstkey .=
' ALT +';
3202 } elseif (
$conf->browser->name ==
'firefox') {
3203 $stringforfirstkey .=
' ALT + SHIFT +';
3205 $stringforfirstkey .=
' CTL +';
3209 if (!defined(
'JS_JQUERY_DISABLE_DROPDOWN') && !empty(
$conf->use_javascript_ajax)) {
3210 include_once DOL_DOCUMENT_ROOT.
'/bookmarks/bookmarks.lib.php';
3211 $langs->load(
"bookmarks");
3214 $html .=
'<div id="topmenu-bookmark-dropdown" class="dropdown inline-block">';
3218 $html .=
'<!-- div for bookmark link -->
3219 <div id="topmenu-bookmark-dropdown" class="dropdown inline-block">
3220 <a accesskey="b" class="dropdown-toggle login-dropdown-a nofocusvisible" data-toggle="dropdown" href="#" title="'.$langs->trans(
'Bookmarks').
' ('.$stringforfirstkey.
' b)"><i class="fa fa-star"></i></a>
3221 <div class="dropdown-menu">
3227 <!-- Code to show/hide the bookmark drop-down -->
3229 jQuery(document).ready(function() {
3230 jQuery(document).on("click", function(event) {
3231 if (!$(event.target).closest("#topmenu-bookmark-dropdown").length) {
3232 /* console.log("close bookmark dropdown - we click outside"); */
3234 $("#topmenu-bookmark-dropdown").removeClass("open");
3238 jQuery("#topmenu-bookmark-dropdown .dropdown-toggle").on("click", function(event) {
3239 console.log("Click on #topmenu-bookmark-dropdown .dropdown-toggle");
3240 openBookMarkDropDown(event);
3244 jQuery(document).keydown(function(event) {
3245 var ostype = \''.dol_escape_js(
$conf->browser->os).
'\';
3246 if (ostype ===
"macintosh") {
3247 if ( event.which === 66 && event.ctrlKey ) {
3248 console.log(
"Click on control + b : trigger open bookmark dropdown");
3249 openBookMarkDropDown(event);
3252 if ( event.which === 66 && event.ctrlKey && event.shiftKey ) {
3253 console.log(
"Click on control + shift + b : trigger open bookmark dropdown");
3254 openBookMarkDropDown(event);
3259 var openBookMarkDropDown =
function(event) {
3260 event.preventDefault();
3261 jQuery(
"#topmenu-bookmark-dropdown").toggleClass(
"open");
3262 jQuery(
"#top-bookmark-search-input").focus();
3278function top_menu_search()
3280 global $langs, $conf, $db, $user, $hookmanager; // used by htdocs/core/ajax/selectsearchbox.php
3285 $arrayresult = array();
3286 include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php
'; // This sets $arrayresult
3288 // accesskey is for Windows or Linux: ALT + key for chrome, ALT + SHIFT + KEY for firefox
3289 // accesskey is for Mac: CTRL + key for all browsers
3290 $stringforfirstkey = $langs->trans("KeyboardShortcut");
3291 if ($conf->browser->name == 'chrome
') {
3292 $stringforfirstkey .= ' ALT +
';
3293 } elseif ($conf->browser->name == 'firefox
') {
3294 $stringforfirstkey .= ' ALT + SHIFT +
';
3296 $stringforfirstkey .= ' CTL +
';
3299 $searchInput = '<input
type=
"search" name=
"search_all"'.($stringforfirstkey ? ' title=
"'.dol_escape_htmltag($stringforfirstkey.' s').'"' : '').' id=
"top-global-search-input" class=
"dropdown-search-input search_component_input" placeholder=
"'.$langs->trans('Search').'" autocomplete=
"off">
';
3301 $defaultAction = '';
3302 $buttonList = '<div
class=
"dropdown-global-search-button-list" >
';
3303 // Menu with all searchable items
3304 // @phan-suppress-next-line PhanEmptyForeach // array is really empty
3305 foreach ($arrayresult as $keyItem => $item) {
3306 if (empty($defaultAction)) {
3307 $defaultAction = $item['url
'];
3309 $buttonList .= '<
button class=
"dropdown-item global-search-item tdoverflowmax300" data-target=
"'.dol_escape_htmltag($item['url']).'" >
';
3310 $buttonList .= $item['text
'];
3311 $buttonList .= '</
button>
';
3313 $buttonList .= '</div>
';
3315 $dropDownHtml = '<form role=
"search" id=
"top-menu-action-search" name=
"actionsearch" method=
"GET" action=
"'.$defaultAction.'">
';
3318 <!-- search input -->
3319 <div
class=
"dropdown-header search-dropdown-header">
3325 <!--
Menu Body search -->
3326 <div
class=
"dropdown-body search-dropdown-body">
3331 $dropDownHtml .= '</form>
';
3333 // accesskey is for Windows or Linux: ALT + key for chrome, ALT + SHIFT + KEY for firefox
3334 // accesskey is for Mac: CTRL + key for all browsers
3335 $stringforfirstkey = $langs->trans("KeyboardShortcut");
3336 if ($conf->browser->name == 'chrome
') {
3337 $stringforfirstkey .= ' ALT +
';
3338 } elseif ($conf->browser->name == 'firefox
') {
3339 $stringforfirstkey .= ' ALT + SHIFT +
';
3341 $stringforfirstkey .= ' CTL +
';
3344 $html .= '<!-- div
for Global Search -->
3345 <div
id=
"topmenu-global-search-dropdown" class=
"atoplogin dropdown inline-block">
3346 <a accesskey=
"s" class=
"dropdown-toggle login-dropdown-a nofocusvisible" data-toggle=
"dropdown" href=
"#" title=
"'.$langs->trans('Search').' ('.$stringforfirstkey.' s)">
3347 <i
class=
"fa fa-search" aria-hidden=
"true" ></i>
3349 <div
class=
"dropdown-menu dropdown-search">
3355 <!-- Code to show/hide the
user drop-down -->
3357 jQuery(document).ready(
function() {
3360 jQuery(
"#top-global-search-input").keydown(
function (e) {
3361 if (e.keyCode == 13 || e.keyCode == 40) {
3362 var inputs = $(this).parents(
"form").eq(0).find(
":button");
3363 if (inputs[inputs.index(this) + 1] != null) {
3364 inputs[inputs.index(this) + 1].focus();
3365 if (e.keyCode == 13){
3366 inputs[inputs.index(this) + 1].trigger(
"click");
3376 jQuery(document).keydown(
function(e) {
3378 var $focused = $(
":focus");
3379 if($focused.length && $focused.hasClass(
"global-search-item")){
3382 if (e.keyCode == 38) {
3384 $focused.prev().focus();
3388 if (e.keyCode == 40) {
3390 $focused.next().focus();
3397 jQuery(
".dropdown-global-search-button-list .global-search-item").on(
"click",
function(event) {
3398 jQuery(
"#top-menu-action-search").attr(
"action", $(
this).data(
"target"));
3399 jQuery(
"#top-menu-action-search").submit();
3403 jQuery(document).on(
"click",
function(event) {
3404 if (!$(event.target).closest(
"#topmenu-global-search-dropdown").length) {
3405 console.log(
"click close search - we click outside");
3407 jQuery(
"#topmenu-global-search-dropdown").removeClass(
"open");
3412 jQuery(
"#topmenu-global-search-dropdown .dropdown-toggle").on(
"click",
function(event) {
3413 console.log(
"click on toggle #topmenu-global-search-dropdown .dropdown-toggle");
3414 openGlobalSearchDropDown();
3418 jQuery(document).keydown(
function(e){
3419 if ( e.which === 70 && e.ctrlKey && e.shiftKey ) {
3420 console.log(\
'control + shift + f : trigger open global-search dropdown\');
3421 openGlobalSearchDropDown();
3423 if ( e.which === 70 && e.alKey ) {
3424 console.log(\'alt + f : trigger open global-search dropdown\');
3425 openGlobalSearchDropDown();
3429 var openGlobalSearchDropDown = function() {
3430 jQuery("#topmenu-global-search-dropdown").toggleClass("open");
3431 jQuery("#top-global-search-input").focus();
3455function left_menu($menu_array_before, $helppagename =
'', $notused =
'', $menu_array_after = array(), $leftmenuwithoutmainarea = 0, $title =
'', $acceptdelayedhtml = 0)
3457 global $user,
$conf, $langs, $db, $form;
3458 global $hookmanager, $menumanager;
3462 if (!empty($menu_array_before)) {
3463 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);
3466 if (empty(
$conf->dol_hide_leftmenu) && (!defined(
'NOREQUIREMENU') || !constant(
'NOREQUIREMENU'))) {
3468 $hookmanager->initHooks(array(
'leftblock'));
3470 print
"\n".
'<!-- Begin side-nav id-left -->'.
"\n".
'<div class="side-nav"><div id="id-left">'.
"\n";
3473 if (!is_object($form)) {
3474 $form =
new Form($db);
3479 if (
$conf->browser->layout ==
'phone') {
3480 $conf->global->MAIN_USE_OLD_SEARCH_FORM = 1;
3484 $arrayresult = array();
3485 include DOL_DOCUMENT_ROOT.
'/core/ajax/selectsearchbox.php';
3490 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
3491 if (
$conf->browser->name ==
'chrome') {
3492 $stringforfirstkey .=
' ALT +';
3493 } elseif (
$conf->browser->name ==
'firefox') {
3494 $stringforfirstkey .=
' ALT + SHIFT +';
3496 $stringforfirstkey .=
' CTL +';
3500 $textsearch =
'<span class="fa fa-search paddingright pictofixedwidth"></span>'.$langs->trans(
"Search");
3501 $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');
3503 if (is_array($arrayresult)) {
3505 foreach ($arrayresult as $key => $val) {
3506 $searchform .=
printSearchForm($val[
'url'], $val[
'url'], $val[
'label'],
'maxwidth125',
'search_all', (empty($val[
'shortcut']) ?
'' : $val[
'shortcut']),
'searchleft'.$key, $val[
'img']);
3512 $parameters = array(
'searchform' => $searchform);
3513 $reshook = $hookmanager->executeHooks(
'printSearchForm', $parameters);
3514 if (empty($reshook)) {
3515 $searchform .= $hookmanager->resPrint;
3517 $searchform = $hookmanager->resPrint;
3522 $urltosearch = DOL_URL_ROOT.
'/core/search_page.php?showtitlebefore=1';
3523 $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>';
3525 $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>';
3526 $searchform .=
'<script>
3527 jQuery(document).ready(function () {
3528 jQuery("#divsearchforms1").click(function(){
3529 jQuery("#divsearchforms2").toggle();
3533 $searchform .=
'</div>';
3537 $searchform .=
'<script>
3538 jQuery(document).keydown(function(e){
3539 if( e.which === 70 && e.ctrlKey && e.shiftKey ){
3540 console.log(\'control + shift + f : trigger open global-search dropdown\');
3541 openGlobalSearchDropDown();
3543 if( (e.which === 83 || e.which === 115) && e.altKey ){
3544 console.log(\'alt + s : trigger open global-search dropdown\');
3545 openGlobalSearchDropDown();
3549 var openGlobalSearchDropDown = function() {
3550 jQuery("#searchselectcombo").select2(\'open\');
3556 print
'<!-- Begin left menu -->'.
"\n";
3558 print
'<div class="vmenu"'.(getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
' alt="Left menu"' :
'').
'>'.
"\n\n";
3562 $menumanager->menu_array = $menu_array_before;
3564 $menumanager->menu_array_after = $menu_array_after;
3567 $menumanager->showmenu(
'leftdropdown', array(
'searchform' => $searchform));
3570 $menumanager->showmenu(
'left', array(
'searchform' => $searchform));
3575 print
"<!-- Begin Help Block-->\n";
3576 print
'<div id="blockvmenuhelp" class="blockvmenuhelp">'.
"\n";
3580 $doliurl =
'https://www.dolibarr.org';
3582 if (preg_match(
'/fr/i', $langs->defaultlang)) {
3583 $doliurl =
'https://www.dolibarr.fr';
3585 if (preg_match(
'/es/i', $langs->defaultlang)) {
3586 $doliurl =
'https://www.dolibarr.es';
3588 if (preg_match(
'/de/i', $langs->defaultlang)) {
3589 $doliurl =
'https://www.dolibarr.de';
3591 if (preg_match(
'/it/i', $langs->defaultlang)) {
3592 $doliurl =
'https://www.dolibarr.it';
3594 if (preg_match(
'/gr/i', $langs->defaultlang)) {
3595 $doliurl =
'https://www.dolibarr.gr';
3598 $appli = constant(
'DOL_APPLICATION_TITLE');
3602 if (preg_match(
'/\d\.\d/', $appli)) {
3603 if (!preg_match(
'/'.preg_quote(DOL_VERSION).
'/', $appli)) {
3604 $appli .=
" (".DOL_VERSION.
")";
3607 $appli .=
" ".DOL_VERSION;
3610 $appli .=
" ".DOL_VERSION;
3612 print
'<div id="blockvmenuhelpapp" class="blockvmenuhelp">';
3614 print
'<a class="help" target="_blank" rel="noopener noreferrer" href="'.$doliurl.
'">';
3616 print
'<span class="help">';
3624 print
'</div>'.
"\n";
3629 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
3632 $bugbaseurl =
'https://github.com/Dolibarr/dolibarr/issues/new?labels=Bug';
3633 $bugbaseurl .=
'&title=';
3634 $bugbaseurl .= urlencode(
"Bug: ");
3635 $bugbaseurl .=
'&body=';
3636 $bugbaseurl .= urlencode(
"# Instructions\n");
3637 $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");
3638 $bugbaseurl .= urlencode(
"*Please:*\n");
3639 $bugbaseurl .= urlencode(
"- *replace the bracket enclosed texts with meaningful information*\n");
3640 $bugbaseurl .= urlencode(
"- *remove any unused sub-section*\n");
3641 $bugbaseurl .= urlencode(
"\n");
3642 $bugbaseurl .= urlencode(
"\n");
3643 $bugbaseurl .= urlencode(
"# Bug\n");
3644 $bugbaseurl .= urlencode(
"[*Short description*]\n");
3645 $bugbaseurl .= urlencode(
"\n");
3646 $bugbaseurl .= urlencode(
"## Environment\n");
3647 $bugbaseurl .= urlencode(
"- **Version**: ".DOL_VERSION.
"\n");
3648 $bugbaseurl .= urlencode(
"- **OS**: ".php_uname(
's').
"\n");
3649 $bugbaseurl .= urlencode(
"- **Web server**: ".$_SERVER[
"SERVER_SOFTWARE"].
"\n");
3650 $bugbaseurl .= urlencode(
"- **PHP**: ".php_sapi_name().
' '.phpversion().
"\n");
3651 $bugbaseurl .= urlencode(
"- **Database**: ".$db::LABEL.
' '.$db->getVersion().
"\n");
3652 $bugbaseurl .= urlencode(
"- **URL(s)**: ".$_SERVER[
"REQUEST_URI"].
"\n");
3653 $bugbaseurl .= urlencode(
"\n");
3654 $bugbaseurl .= urlencode(
"## Expected and actual behavior\n");
3655 $bugbaseurl .= urlencode(
"[*Verbose description*]\n");
3656 $bugbaseurl .= urlencode(
"\n");
3657 $bugbaseurl .= urlencode(
"## Steps to reproduce the behavior\n");
3658 $bugbaseurl .= urlencode(
"[*Verbose description*]\n");
3659 $bugbaseurl .= urlencode(
"\n");
3660 $bugbaseurl .= urlencode(
"## [Attached files](https://help.github.com/articles/issue-attachments) (Screenshots, screencasts, dolibarr.log, debugging information…)\n");
3661 $bugbaseurl .= urlencode(
"[*Files*]\n");
3662 $bugbaseurl .= urlencode(
"\n");
3664 $bugbaseurl .= urlencode(
"\n");
3665 $bugbaseurl .= urlencode(
"## Report\n");
3673 $parameters = array(
'bugbaseurl' => $bugbaseurl);
3674 $reshook = $hookmanager->executeHooks(
'printBugtrackInfo', $parameters);
3675 if (empty($reshook)) {
3676 $bugbaseurl .= $hookmanager->resPrint;
3678 $bugbaseurl = $hookmanager->resPrint;
3681 print
'<div id="blockvmenuhelpbugreport" class="blockvmenuhelp">';
3682 print
'<a class="help" target="_blank" rel="noopener noreferrer" href="'.$bugbaseurl.
'"><i class="fas fa-bug"></i> '.$langs->trans(
"FindBug").
'</a>';
3687 print
"<!-- End Help Block-->\n";
3691 print
"<!-- End left menu -->\n";
3695 $parameters = array();
3696 $reshook = $hookmanager->executeHooks(
'printLeftBlock', $parameters);
3697 print $hookmanager->resPrint;
3699 print
'</div></div> <!-- End side-nav id-left -->';
3703 print
'<!-- Begin right area -->'.
"\n";
3705 if (empty($leftmenuwithoutmainarea)) {
3719 global
$conf, $langs, $hookmanager;
3721 if (empty(
$conf->dol_hide_leftmenu) && !
GETPOST(
'dol_openinpopup',
'aZ09')) {
3722 print
'<div id="id-right">';
3727 print
'<!-- Begin div class="fiche" -->'.
"\n".
'<div class="fiche">'.
"\n";
3729 $hookmanager->initHooks(array(
'main'));
3730 $parameters = array();
3731 $reshook = $hookmanager->executeHooks(
'printMainArea', $parameters);
3732 print $hookmanager->resPrint;
3735 print
info_admin($langs->trans(
"WarningYouAreInMaintenanceMode",
getDolGlobalString(
'MAIN_ONLY_LOGIN_ALLOWED')), 0, 0,
'1',
'warning maintenancemode');
3740 $parameters = array();
3741 $reshook = $hookmanager->executeHooks(
'showSocinfoOnPrint', $parameters);
3742 if (empty($reshook)) {
3743 print
'<!-- Begin show mysoc info header -->'.
"\n";
3744 print
'<div id="mysoc-info-header">'.
"\n";
3745 print
'<table class="centpercent div-table-responsive">'.
"\n";
3747 print
'<tr><td rowspan="0" class="width20p">';
3749 print
'<img id="mysoc-info-header-logo" style="max-width:100%" alt="" src="'.DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/'.
dol_escape_htmltag(
getDolGlobalString(
'MAIN_INFO_SOCIETE_LOGO'))).
'">';
3751 print
'</td><td rowspan="0" class="width50p"></td></tr>'.
"\n";
3752 print
'<tr><td class="titre bold">'.dol_escape_htmltag(
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM')).
'</td></tr>'.
"\n";
3764 print
'</table>'.
"\n";
3765 print
'</div>'.
"\n";
3766 print
'<!-- End show mysoc info header -->'.
"\n";
3785 if (preg_match(
'/^http/i', $helppagename)) {
3787 $helpbaseurl =
'%s';
3788 $helppage = $helppagename;
3793 if (preg_match(
'/^es/i', $langs->defaultlang)) {
3794 $helpbaseurl =
'http://wiki.dolibarr.org/index.php/%s';
3795 if (preg_match(
'/ES:([^|]+)/i', $helppagename, $reg)) {
3796 $helppage = $reg[1];
3799 if (preg_match(
'/^fr/i', $langs->defaultlang)) {
3800 $helpbaseurl =
'http://wiki.dolibarr.org/index.php/%s';
3801 if (preg_match(
'/FR:([^|]+)/i', $helppagename, $reg)) {
3802 $helppage = $reg[1];
3805 if (preg_match(
'/^de/i', $langs->defaultlang)) {
3806 $helpbaseurl =
'http://wiki.dolibarr.org/index.php/%s';
3807 if (preg_match(
'/DE:([^|]+)/i', $helppagename, $reg)) {
3808 $helppage = $reg[1];
3811 if (empty($helppage)) {
3812 $helpbaseurl =
'http://wiki.dolibarr.org/index.php/%s';
3813 if (preg_match(
'/EN:([^|]+)/i', $helppagename, $reg)) {
3814 $helppage = $reg[1];
3819 return array(
'helpbaseurl' => $helpbaseurl,
'helppage' => $helppage,
'mode' => $mode);
3839function printSearchForm($urlaction, $urlobject, $title, $htmlmorecss, $htmlinputname, $accesskey =
'', $prefhtmlinputname =
'', $img =
'', $showtitlebefore = 0, $autofocus = 0)
3841 global $langs, $user;
3844 $ret .=
'<form action="'.$urlaction.
'" method="post" class="searchform nowraponall tagtr">';
3845 $ret .=
'<input type="hidden" name="token" value="'.newToken().
'">';
3846 $ret .=
'<input type="hidden" name="savelogin" value="'.dol_escape_htmltag($user->login).
'">';
3847 if ($showtitlebefore) {
3848 $ret .=
'<div class="tagtd left">'.$title.
'</div> ';
3850 $ret .=
'<div class="tagtd">';
3851 $ret .=
img_picto(
'', $img,
'', 0, 0, 0,
'',
'paddingright width20');
3852 $ret .=
'<input type="text" class="flat '.$htmlmorecss.
'"';
3853 $ret .=
' style="background-repeat: no-repeat; background-position: 3px;"';
3854 $ret .= ($accesskey ?
' accesskey="'.$accesskey.
'"' :
'');
3855 $ret .=
' placeholder="'.strip_tags($title).
'"';
3856 $ret .= ($autofocus ?
' autofocus' :
'');
3857 $ret .=
' name="'.$htmlinputname.
'" id="'.$prefhtmlinputname.$htmlinputname.
'" />';
3858 $ret .=
'<button type="submit" class="button bordertransp" style="padding-top: 4px; padding-bottom: 4px; padding-left: 6px; padding-right: 6px">';
3859 $ret .=
'<span class="fa fa-search"></span>';
3860 $ret .=
'</button>';
3862 $ret .=
"</form>\n";
3867if (!function_exists(
"llxFooter")) {
3879 function llxFooter($comment =
'', $zone =
'private', $disabledoutputofmessages = 0)
3881 global
$conf, $db, $langs, $user, $mysoc,
$object, $hookmanager, $action;
3882 global $delayedhtmlcontent;
3883 global $contextpage, $page, $limit, $mode;
3884 global $dolibarr_distrib;
3886 $ext =
'layout='.urlencode(
$conf->browser->layout).
'&version='.urlencode(DOL_VERSION);
3890 $parameters = array();
3891 $reshook = $hookmanager->executeHooks(
'llxFooter', $parameters,
$object, $action);
3892 if (empty($reshook)) {
3893 $llxfooter .= $hookmanager->resPrint;
3894 } elseif ($reshook > 0) {
3895 $llxfooter = $hookmanager->resPrint;
3906 if (is_object($user) && !empty($user->lastsearch_values_tmp) && is_array($user->lastsearch_values_tmp)) {
3908 foreach ($user->lastsearch_values_tmp as $key => $val) {
3909 unset($_SESSION[
'lastsearch_values_tmp_'.$key]);
3910 if (count($val) && empty($_POST[
'button_removefilter']) && empty($_POST[
'button_removefilter_x'])) {
3911 if (empty($val[
'sortfield'])) {
3912 unset($val[
'sortfield']);
3914 if (empty($val[
'sortorder'])) {
3915 unset($val[
'sortorder']);
3917 dol_syslog(
'Save lastsearch_values_tmp_'.$key.
'='.json_encode($val, 0).
" (systematic recording of last search criteria)");
3918 $_SESSION[
'lastsearch_values_tmp_'.$key] = json_encode($val);
3919 unset($_SESSION[
'lastsearch_values_'.$key]);
3925 $relativepathstring = $_SERVER[
"PHP_SELF"];
3927 if (constant(
'DOL_URL_ROOT')) {
3928 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
3930 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
3931 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
3932 if (preg_match(
'/list\.php$/', $relativepathstring)) {
3933 unset($_SESSION[
'lastsearch_contextpage_tmp_'.$relativepathstring]);
3934 unset($_SESSION[
'lastsearch_page_tmp_'.$relativepathstring]);
3935 unset($_SESSION[
'lastsearch_limit_tmp_'.$relativepathstring]);
3936 unset($_SESSION[
'lastsearch_mode_tmp_'.$relativepathstring]);
3938 if (!empty($contextpage)) {
3939 $_SESSION[
'lastsearch_contextpage_tmp_'.$relativepathstring] = $contextpage;
3941 if (!empty($page) && $page > 0) {
3942 $_SESSION[
'lastsearch_page_tmp_'.$relativepathstring] = $page;
3944 if (!empty($limit) && $limit !=
$conf->liste_limit) {
3945 $_SESSION[
'lastsearch_limit_tmp_'.$relativepathstring] = $limit;
3947 if (!empty($mode)) {
3948 $_SESSION[
'lastsearch_mode_tmp_'.$relativepathstring] = $mode;
3951 unset($_SESSION[
'lastsearch_contextpage_'.$relativepathstring]);
3952 unset($_SESSION[
'lastsearch_page_'.$relativepathstring]);
3953 unset($_SESSION[
'lastsearch_limit_'.$relativepathstring]);
3954 unset($_SESSION[
'lastsearch_mode_'.$relativepathstring]);
3960 if (
$conf->use_javascript_ajax) {
3961 $title =
img_warning().
' '.$langs->trans(
'CoreErrorTitle');
3962 print
ajax_dialog($title, $langs->trans(
'CoreErrorMessage'));
3965 $msg =
img_warning().
' '.$langs->trans(
'CoreErrorMessage');
3966 print
'<div class="error">'.$msg.
'</div>';
3974 print
'</div> <!-- End div class="fiche" -->'.
"\n";
3976 if (empty(
$conf->dol_hide_leftmenu) && !
GETPOST(
'dol_openinpopup',
'aZ09')) {
3977 print
'</div> <!-- End div id-right -->'.
"\n";
3980 if (empty(
$conf->dol_hide_leftmenu) && empty(
$conf->dol_use_jmobile)) {
3981 print
'</div> <!-- End div id-container -->'.
"\n";
3986 print
'<!-- '.$comment.
' -->'.
"\n";
3991 if (!empty($delayedhtmlcontent)) {
3992 print $delayedhtmlcontent;
3995 if (!empty(
$conf->use_javascript_ajax)) {
3996 print
"\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
3997 print
'<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.($ext ?
'&'.$ext :
'').
'"></script>'.
"\n";
4002 if (in_array(
$object->element, array(
'facture')) &&
$object->statut > 0) {
4003 print
"\n<!-- JS CODE TO ENABLE log when making a download or a preview of a document -->\n";
4006 jQuery(document).ready(
function () {
4007 $(
'a.documentpreview').click(
function() {
4008 console.log(
"Call /blockedlog/ajax/block-add on a.documentpreview");
4009 $.post(
'<?php echo DOL_URL_ROOT."/blockedlog/ajax/block-add.php" ?>'
4012 , element:
'<?php echo dol_escape_js($object->element) ?>'
4013 , action:
'DOC_PREVIEW'
4014 , token:
'<?php echo currentToken(); ?>'
4018 $(
'a.documentdownload').click(
function() {
4019 console.log(
"Call /blockedlog/ajax/block-add a.documentdownload");
4020 $.post(
'<?php echo DOL_URL_ROOT."/blockedlog/ajax/block-add.php" ?>'
4023 , element:
'<?php echo dol_escape_js($object->element) ?>'
4024 , action:
'DOC_DOWNLOAD'
4025 , token:
'<?php echo currentToken(); ?>'
4036 print
"\n<!-- A div to allow dialog popup by jQuery('#dialogforpopup').dialog() -->\n";
4037 print
'<div id="dialogforpopup" style="display: none;"></div>'.
"\n";
4041 $forceping =
GETPOST(
'forceping',
'alpha');
4042 if (($_SERVER[
"PHP_SELF"] == DOL_URL_ROOT.
'/index.php') || $forceping) {
4044 $hash_unique_id =
dol_hash(
'dolibarr'.
$conf->file->instance_unique_id,
'sha256');
4047 || (!empty(
$conf->file->instance_unique_id) && ($hash_unique_id !=
$conf->global->MAIN_FIRST_PING_OK_ID) && (
getDolGlobalString(
'MAIN_FIRST_PING_OK_ID') !=
'disabled'))
4050 if (strpos(
'alpha', DOL_VERSION) > 0 && !$forceping) {
4051 print
"\n<!-- NO JS CODE TO ENABLE the anonymous Ping. It is an alpha version -->\n";
4052 } elseif (empty($_COOKIE[
'DOLINSTALLNOPING_'.$hash_unique_id]) || $forceping) {
4056 print
"\n<!-- NO JS CODE TO ENABLE the anonymous Ping. An error already occurred this month, we will try later. -->\n";
4058 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
4060 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";
4061 print
"\n<!-- JS CODE TO ENABLE the anonymous Ping -->\n";
4062 $url_for_ping =
getDolGlobalString(
'MAIN_URL_FOR_PING',
"https://ping.dolibarr.org/");
4064 $distrib =
'standard';
4065 if ($_SERVER[
"SERVER_ADMIN"] ==
'doliwamp@localhost') {
4066 $distrib =
'doliwamp';
4068 if (!empty($dolibarr_distrib)) {
4069 $distrib = $dolibarr_distrib;
4073 jQuery(document).ready(
function (tmp) {
4074 console.log(
"Try Ping with hash_unique_id is dol_hash('dolibarr'+instance_unique_id, 'sha256')");
4077 url:
"<?php echo $url_for_ping ?>",
4081 hash_algo:
'dol_hash-sha256',
4082 hash_unique_id:
'<?php echo dol_escape_js($hash_unique_id); ?>',
4083 action:
'dolibarrping',
4084 version:
'<?php echo (float) DOL_VERSION; ?>',
4085 entity:
'<?php echo (int) $conf->entity; ?>',
4086 dbtype:
'<?php echo dol_escape_js($db->type); ?>',
4087 country_code:
'<?php echo $mysoc->country_code ? dol_escape_js($mysoc->country_code) : 'unknown
'; ?>',
4088 php_version:
'<?php echo dol_escape_js(phpversion()); ?>',
4089 os_version:
'<?php echo dol_escape_js(version_os('smr
')); ?>',
4090 db_version:
'<?php echo dol_escape_js(version_db()); ?>',
4091 distrib:
'<?php echo $distrib ? dol_escape_js($distrib) : 'unknown
'; ?>',
4092 token:
'notrequired'
4094 success:
function (data,
status, xhr) {
4095 console.log(
"Ping ok");
4098 url:
'<?php echo DOL_URL_ROOT.'/core/ajax/pingresult.php
'; ?>',
4101 data: { hash_algo:
'dol_hash-sha256', hash_unique_id:
'<?php echo dol_escape_js($hash_unique_id); ?>', action:
'firstpingok', token:
'<?php echo currentToken(); ?>' },
4104 error:
function (data,
status,xhr) {
4105 console.log(
"Ping ko: " + data);
4108 url:
'<?php echo DOL_URL_ROOT.'/core/ajax/pingresult.php
'; ?>',
4111 data: { hash_algo:
'dol_hash-sha256', hash_unique_id:
'<?php echo dol_escape_js($hash_unique_id); ?>', action:
'firstpingko', token:
'<?php echo currentToken(); ?>' },
4121 print
"\n<!-- NO JS CODE TO ENABLE the anonymous Ping. It was disabled -->\n";
4122 include_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
4129 $parameters = array();
4130 $reshook = $hookmanager->executeHooks(
'beforeBodyClose', $parameters);
4132 print $hookmanager->resPrint;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
ajax_dialog($title, $message, $w=350, $h=150)
Show an ajax dialog.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
printDropdownBookmarksList()
Add area with bookmarks in top menu.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
if(!defined( 'DOL_APPLICATION_TITLE')) if(!defined('DOL_VERSION')) if(!defined( 'EURO')) if(!defined('LOG_DEBUG')) if(defined( 'DOL_INC_FOR_VERSION_ERROR')) dol_session_start()
Replace session_start()
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
isHTTPS()
Return if we are using a HTTPS connection Check HTTPS (no way to be modified by user but may be empty...
printCommonFooter($zone='private')
Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global-...
getDolUserString($key, $default='', $tmpuser=null)
Return Dolibarr user constant string value.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
getBrowserInfo($user_agent)
Return information about user browser.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
dol_htmloutput_events($disabledoutputofmessages=0)
Print formatted messages to output (Used to show messages on html output).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_profids($profID, $profIDtype, $countrycode='', $addcpButton=1)
Format professional IDs according to their country.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
ui state ui widget content ui state ui widget header ui state a ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
conf($dolibarr_main_document_root)
Load conf file (file must exists)
if(!empty( $_SERVER[ 'MAIN_SHOW_TUNING_INFO'])) getArrayOfEmoji()
Return array of Emojis.
top_menu_importfile()
Build the tooltip on top menu quick add.
top_menu_quickadd()
Build the tooltip on top menu quick add.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
top_menu_user($hideloginname=0, $urllogout='')
Build the tooltip on user login.
testSqlAndScriptInject($val, $type)
Security: WAF layer for SQL Injection and XSS Injection (scripts) protection (Filters on GET,...
left_menu($menu_array_before, $helppagename='', $notused='', $menu_array_after=array(), $leftmenuwithoutmainarea=0, $title='', $acceptdelayedhtml=0)
Show left menu bar.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
main_area($title='')
Begin main area.
realCharForNumericEntities($matches)
Return the real char for a numeric entities.
getHelpParamFor($helppagename, $langs)
Return helpbaseurl, helppage and mode.
printDropdownQuickadd($mode=0)
Generate list of quickadd items.
printSearchForm($urlaction, $urlobject, $title, $htmlmorecss, $htmlinputname, $accesskey='', $prefhtmlinputname='', $img='', $showtitlebefore=0, $autofocus=0)
Show a search area.
top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $morequerystring='', $helppagename='')
Show an HTML header + a BODY + The top menu bar.
top_menu_search()
Build the tooltip on top menu search.
analyseVarsForSqlAndScriptsInjection(&$var, $type, $stopcode=1)
Return true if security check on parameters are OK, false otherwise.
top_menu_bookmark()
Build the tooltip on top menu bookmark.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
$conf db user
Active Directory does not allow anonymous connections.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode, $context='')
Return a login if login/pass was successful.
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.