dolibarr 21.0.0-alpha
security2.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2008-2017 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 * or see https://www.gnu.org/
19 */
20
36function dol_getwebuser($mode)
37{
38 $t = '?';
39 if ($mode == 'user') {
40 $t = getenv('APACHE_RUN_USER'); // $_ENV['APACHE_RUN_USER'] is empty
41 }
42 if ($mode == 'group') {
43 $t = getenv('APACHE_RUN_GROUP');
44 }
45 return $t;
46}
47
58function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode, $context = '')
59{
60 global $conf, $langs;
61
62 // Check parameters
63 if ($entitytotest == '') {
64 $entitytotest = 1;
65 }
66
67 dol_syslog("checkLoginPassEntity usertotest=".$usertotest." entitytotest=".$entitytotest." authmode=".implode(',', $authmode));
68 $login = '';
69
70 // Validation of login/pass/entity with standard modules
71 if (empty($login)) {
72 $test = true;
73 foreach ($authmode as $mode) {
74 if ($test && $mode && !$login) {
75 // Validation of login/pass/entity for mode $mode
76 $mode = trim($mode);
77 $authfile = 'functions_'.$mode.'.php';
78 $fullauthfile = '';
79
80 $dirlogin = array_merge(array("/core/login"), (array) $conf->modules_parts['login']);
81 foreach ($dirlogin as $reldir) {
82 $dir = dol_buildpath($reldir, 0);
83 $newdir = dol_osencode($dir);
84
85 // Check if file found (do not use dol_is_file to avoid loading files.lib.php)
86 $tmpnewauthfile = $newdir.(preg_match('/\/$/', $newdir) ? '' : '/').$authfile;
87 if (is_file($tmpnewauthfile)) {
88 $fullauthfile = $tmpnewauthfile;
89 }
90 }
91
92 $result = false;
93 if ($fullauthfile) {
94 $result = include_once $fullauthfile;
95 }
96 if ($fullauthfile && $result) {
97 // Call function to check user/password
98 $function = 'check_user_password_'.$mode;
99 $login = call_user_func($function, $usertotest, $passwordtotest, $entitytotest, $context);
100 if ($login && $login != '--bad-login-validity--') {
101 // Login is successful with this method
102 $test = false; // To stop once at first login success
103 $conf->authmode = $mode; // This properties is defined only when logged to say what mode was successfully used
104 /*$dol_tz = GETPOST('tz');
105 $dol_dst = GETPOST('dst');
106 $dol_screenwidth = GETPOST('screenwidth');
107 $dol_screenheight = GETPOST('screenheight');*/
108 }
109 } else {
110 dol_syslog("Authentication KO - failed to load file '".$authfile."'", LOG_ERR);
111 sleep(1);
112 // Load translation files required by the page
113 $langs->loadLangs(array('other', 'main', 'errors'));
114
115 $_SESSION["dol_loginmesg"] = (empty($_SESSION["dol_loginmesg"]) ? '' : $_SESSION["dol_loginmesg"].', ').$langs->transnoentitiesnoconv("ErrorFailedToLoadLoginFileForMode", $mode);
116 }
117 }
118 }
119 }
120
121 return $login;
122}
123
124
125if (!function_exists('dol_loginfunction')) {
135 function dol_loginfunction($langs, $conf, $mysoc)
136 {
137 global $dolibarr_main_demo, $dolibarr_main_force_https;
138 global $db, $hookmanager;
139
140 $langs->loadLangs(array("main", "other", "help", "admin"));
141
142 // Instantiate hooks of thirdparty module only if not already define
143 $hookmanager->initHooks(array('mainloginpage'));
144
145 $main_authentication = $conf->file->main_authentication;
146
147 $session_name = session_name(); // Get current session name
148
149 $dol_url_root = DOL_URL_ROOT;
150
151 // Title
152 $appli = constant('DOL_APPLICATION_TITLE');
153 $title = $appli.(getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '' : ' '.constant('DOL_VERSION'));
154 if (getDolGlobalString('MAIN_APPLICATION_TITLE')) {
155 $title = getDolGlobalString('MAIN_APPLICATION_TITLE');
156 }
157 $titletruedolibarrversion = constant('DOL_VERSION'); // $title used by login template after the @ to inform of true Dolibarr version
158
159 // Note: $conf->css looks like '/theme/eldy/style.css.php'
160 /*
161 $conf->css = "/theme/".(GETPOST('theme','aZ09')?GETPOST('theme','aZ09'):$conf->theme)."/style.css.php";
162 $themepath=dol_buildpath($conf->css,1);
163 if (!empty($conf->modules_parts['theme'])) // Using this feature slow down application
164 {
165 foreach($conf->modules_parts['theme'] as $reldir)
166 {
167 if (file_exists(dol_buildpath($reldir.$conf->css, 0)))
168 {
169 $themepath=dol_buildpath($reldir.$conf->css, 1);
170 break;
171 }
172 }
173 }
174 $conf_css = $themepath."?lang=".$langs->defaultlang;
175 */
176
177 // Select templates dir
178 if (!empty($conf->modules_parts['tpl'])) { // Using this feature slow down application
179 $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl/'));
180 foreach ($dirtpls as $reldir) {
181 $tmp = dol_buildpath($reldir.'login.tpl.php');
182 if (file_exists($tmp)) {
183 $template_dir = preg_replace('/login\.tpl\.php$/', '', $tmp);
184 break;
185 }
186 }
187 } else {
188 $template_dir = DOL_DOCUMENT_ROOT."/core/tpl/";
189 }
190
191 // Set cookie for timeout management. We set it as a cookie so we will be able to use it to set timeout on next page before the session start
192 // and the conf file is loaded.
193 $prefix = dol_getprefix('');
194 $sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix;
195
196 if (getDolGlobalString('MAIN_SESSION_TIMEOUT')) {
197 if (session_status() != PHP_SESSION_ACTIVE) {
198 if (PHP_VERSION_ID < 70300) {
199 session_set_cookie_params(0, '/', null, ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? false : true), true); // Add tag secure and httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start.
200 } else {
201 // Only available for php >= 7.3
202 $sessioncookieparams = array(
203 'lifetime' => 0,
204 'path' => '/',
205 //'domain' => '.mywebsite.com', // the dot at the beginning allows compatibility with subdomains
206 'secure' => ((empty($dolibarr_main_force_https) && isHTTPS() === false) ? false : true),
207 'httponly' => true,
208 'samesite' => 'Lax' // None || Lax || Strict
209 );
210 session_set_cookie_params($sessioncookieparams);
211 }
212
213 setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', (empty($dolibarr_main_force_https) ? false : true), true);
214 }
215 }
216
217 if (GETPOST('urlfrom', 'alpha')) {
218 $_SESSION["urlfrom"] = GETPOST('urlfrom', 'alpha');
219 } else {
220 unset($_SESSION["urlfrom"]);
221 }
222
223 if (!GETPOST("username", 'alpha')) {
224 $focus_element = 'username';
225 } else {
226 $focus_element = 'password';
227 }
228
229 $demologin = '';
230 $demopassword = '';
231 if (!empty($dolibarr_main_demo)) {
232 $tab = explode(',', $dolibarr_main_demo);
233 $demologin = $tab[0];
234 $demopassword = $tab[1];
235 }
236
237 // Execute hook getLoginPageOptions (for table)
238 $parameters = array('entity' => GETPOSTINT('entity'), 'switchentity' => GETPOSTINT('switchentity'));
239 $reshook = $hookmanager->executeHooks('getLoginPageOptions', $parameters); // Note that $action and $object may have been modified by some hooks.
240 $morelogincontent = $hookmanager->resPrint;
241
242 // Execute hook getLoginPageExtraOptions (eg for js)
243 $parameters = array('entity' => GETPOSTINT('entity'), 'switchentity' => GETPOSTINT('switchentity'));
244 $reshook = $hookmanager->executeHooks('getLoginPageExtraOptions', $parameters); // Note that $action and $object may have been modified by some hooks.
245 $moreloginextracontent = $hookmanager->resPrint;
246
247 //Redirect after connection
248 $parameters = array('entity' => GETPOSTINT('entity'), 'switchentity' => GETPOSTINT('switchentity'));
249 $reshook = $hookmanager->executeHooks('redirectAfterConnection', $parameters); // Note that $action and $object may have been modified by some hooks.
250 $php_self = $hookmanager->resPrint;
251
252 // Login
253 $login = (!empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username", "alpha") ? GETPOST("username", "alpha") : $demologin));
254 $password = $demopassword;
255
256 // Show logo (search in order: small company logo, large company logo, theme logo, common logo)
257 $width = 0;
258 $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png';
259
260 if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
261 $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
262 } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
263 $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo);
264 $width = 128;
265 } elseif (!empty($mysoc->logo_squarred_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_small)) {
266 $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_small);
267 } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) {
268 $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg';
269 }
270
271 // Security graphical code
272 $captcha = 0;
273 $captcha_refresh = '';
274 if (function_exists("imagecreatefrompng") && getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA')) {
275 $captcha = 1;
276 $captcha_refresh = img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"');
277 }
278
279 // Extra link
280 $forgetpasslink = 0;
281 $helpcenterlink = 0;
282 if (!getDolGlobalString('MAIN_SECURITY_DISABLEFORGETPASSLINK') || !getDolGlobalString('MAIN_HELPCENTER_DISABLELINK')) {
283 if (!getDolGlobalString('MAIN_SECURITY_DISABLEFORGETPASSLINK')) {
284 $forgetpasslink = 1;
285 }
286
287 if (!getDolGlobalString('MAIN_HELPCENTER_DISABLELINK')) {
288 $helpcenterlink = 1;
289 }
290 }
291
292 // Home message
293 $main_home = '';
294 if (getDolGlobalString('MAIN_HOME')) {
295 $substitutionarray = getCommonSubstitutionArray($langs);
296 complete_substitutions_array($substitutionarray, $langs);
297 $texttoshow = make_substitutions(getDolGlobalString('MAIN_HOME'), $substitutionarray, $langs);
298
299 $main_home = dol_htmlcleanlastbr($texttoshow);
300 }
301
302 // Google AD
303 $main_google_ad_client = ((getDolGlobalString('MAIN_GOOGLE_AD_CLIENT') && getDolGlobalString('MAIN_GOOGLE_AD_SLOT')) ? 1 : 0);
304
305 // Set jquery theme
306 $dol_loginmesg = (!empty($_SESSION["dol_loginmesg"]) ? $_SESSION["dol_loginmesg"] : '');
307
308 $favicon = DOL_URL_ROOT.'/theme/dolibarr_256x256_color.png';
309 if (!empty($mysoc->logo_squarred_mini)) {
310 $favicon = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini);
311 }
312 if (getDolGlobalString('MAIN_FAVICON_URL')) {
313 $favicon = getDolGlobalString('MAIN_FAVICON_URL');
314 }
315
316 $jquerytheme = 'base';
317 if (getDolGlobalString('MAIN_USE_JQUERY_THEME')) {
318 $jquerytheme = getDolGlobalString('MAIN_USE_JQUERY_THEME');
319 }
320
321 // Set dol_hide_topmenu, dol_hide_leftmenu, dol_optimize_smallscreen, dol_no_mouse_hover
322 $dol_hide_topmenu = GETPOSTINT('dol_hide_topmenu');
323 $dol_hide_leftmenu = GETPOSTINT('dol_hide_leftmenu');
324 $dol_optimize_smallscreen = GETPOSTINT('dol_optimize_smallscreen');
325 $dol_no_mouse_hover = GETPOSTINT('dol_no_mouse_hover');
326 $dol_use_jmobile = GETPOSTINT('dol_use_jmobile');
327
328 // Include login page template
329 include $template_dir.'login.tpl.php';
330
331 // Global html output events ($mesgs, $errors, $warnings)
333
334 $_SESSION["dol_loginmesg"] = '';
335 }
336}
337
346function makesalt($type = CRYPT_SALT_LENGTH)
347{
348 dol_syslog("makesalt type=".$type);
349 switch ($type) {
350 case 12: // 8 + 4
351 $saltlen = 8;
352 $saltprefix = '$1$';
353 $saltsuffix = '$';
354 break;
355 case 8: // 8 (For compatibility, do not use this)
356 $saltlen = 8;
357 $saltprefix = '$1$';
358 $saltsuffix = '$';
359 break;
360 case 2: // 2
361 default: // by default, fall back on Standard DES (should work everywhere)
362 $saltlen = 2;
363 $saltprefix = '';
364 $saltsuffix = '';
365 break;
366 }
367 $salt = '';
368 while (dol_strlen($salt) < $saltlen) {
369 $salt .= chr(mt_rand(64, 126));
370 }
371
372 $result = $saltprefix.$salt.$saltsuffix;
373 dol_syslog("makesalt return=".$result);
374 return $result;
375}
376
383function encodedecode_dbpassconf($level = 0)
384{
385 dol_syslog("encodedecode_dbpassconf level=".$level, LOG_DEBUG);
386 $config = '';
387 $passwd = '';
388 $passwd_crypted = '';
389
390 if ($fp = fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php', 'r')) {
391 while (!feof($fp)) {
392 $buffer = fgets($fp, 4096);
393
394 $lineofpass = 0;
395
396 $reg = array();
397 if (preg_match('/^[^#]*dolibarr_main_db_encrypted_pass[\s]*=[\s]*(.*)/i', $buffer, $reg)) { // Old way to save encrypted value
398 $val = trim($reg[1]); // This also remove CR/LF
399 $val = preg_replace('/^["\']/', '', $val);
400 $val = preg_replace('/["\'][\s;]*$/', '', $val);
401 if (!empty($val)) {
402 $passwd_crypted = $val;
403 // method dol_encode/dol_decode
404 $val = dol_decode($val);
405 //$val = dolEncrypt($val);
406 $passwd = $val;
407 $lineofpass = 1;
408 }
409 } elseif (preg_match('/^[^#]*dolibarr_main_db_pass[\s]*=[\s]*(.*)/i', $buffer, $reg)) {
410 $val = trim($reg[1]); // This also remove CR/LF
411 $val = preg_replace('/^["\']/', '', $val);
412 $val = preg_replace('/["\'][\s;]*$/', '', $val);
413 if (preg_match('/crypted:/i', $buffer)) {
414 // method dol_encode/dol_decode
415 $mode = 'crypted:';
416 $val = preg_replace('/crypted:/i', '', $val);
417 $passwd_crypted = $val;
418 $val = dol_decode($val);
419 $passwd = $val;
420 } elseif (preg_match('/^dolcrypt:([^:]+):(.*)$/i', $buffer, $reg)) {
421 // method dolEncrypt/dolDecrypt
422 $mode = 'dolcrypt:';
423 $val = preg_replace('/crypted:([^:]+):/i', '', $val);
424 $passwd_crypted = $val;
425 $val = dolDecrypt($buffer);
426 $passwd = $val;
427 } else {
428 $passwd = $val;
429 $mode = 'crypted:';
430 $val = dol_encode($val);
431 $passwd_crypted = $val;
432 // TODO replace with dolEncrypt()
433 // ...
434 }
435 $lineofpass = 1;
436 }
437
438 // Output line
439 if ($lineofpass) {
440 // Add value at end of file
441 if ($level == 0) {
442 $config .= '$dolibarr_main_db_pass=\''.$passwd.'\';'."\n";
443 }
444 if ($level == 1) {
445 $config .= '$dolibarr_main_db_pass=\''.$mode.$passwd_crypted.'\';'."\n";
446 }
447
448 //print 'passwd = '.$passwd.' - passwd_crypted = '.$passwd_crypted;
449 //exit;
450 } else {
451 $config .= $buffer;
452 }
453 }
454 fclose($fp);
455
456 // Write new conf file
457 $file = DOL_DOCUMENT_ROOT.'/conf/conf.php';
458 if ($fp = @fopen($file, 'w')) {
459 fwrite($fp, $config);
460 fflush($fp);
461 fclose($fp);
462 clearstatcache();
463
464 // It's config file, so we set read permission for creator only.
465 // Should set permission to web user and groups for users used by batch
466 //dolChmod($file, '0600');
467
468 return 1;
469 } else {
470 dol_syslog("encodedecode_dbpassconf Failed to open conf.php file for writing", LOG_WARNING);
471 return -1;
472 }
473 } else {
474 dol_syslog("encodedecode_dbpassconf Failed to read conf.php", LOG_ERR);
475 return -2;
476 }
477}
478
488function getRandomPassword($generic = false, $replaceambiguouschars = null, $length = 32)
489{
490 global $db, $conf, $langs, $user;
491
492 $generated_password = '';
493 if ($generic) {
494 $lowercase = "qwertyuiopasdfghjklzxcvbnm";
495 $uppercase = "ASDFGHJKLZXCVBNMQWERTYUIOP";
496 $numbers = "1234567890";
497 $randomCode = "";
498 $nbofchar = round($length / 3);
499 $nbofcharlast = ($length - 2 * $nbofchar);
500 //var_dump($nbofchar.'-'.$nbofcharlast);
501 if (function_exists('random_int')) { // Cryptographic random
502 $max = strlen($lowercase) - 1;
503 for ($x = 0; $x < $nbofchar; $x++) {
504 $tmp = random_int(0, $max);
505 $randomCode .= $lowercase[$tmp];
506 }
507 $max = strlen($uppercase) - 1;
508 for ($x = 0; $x < $nbofchar; $x++) {
509 $tmp = random_int(0, $max);
510 $randomCode .= $uppercase[$tmp];
511 }
512 $max = strlen($numbers) - 1;
513 for ($x = 0; $x < $nbofcharlast; $x++) {
514 $tmp = random_int(0, $max);
515 $randomCode .= $numbers[$tmp];
516 }
517
518 $generated_password = str_shuffle($randomCode);
519 } else {
520 // Old platform, non cryptographic random
521 $max = strlen($lowercase) - 1;
522 for ($x = 0; $x < $nbofchar; $x++) {
523 $tmp = mt_rand(0, $max);
524 $randomCode .= $lowercase[$tmp];
525 }
526 $max = strlen($uppercase) - 1;
527 for ($x = 0; $x < $nbofchar; $x++) {
528 $tmp = mt_rand(0, $max);
529 $randomCode .= $uppercase[$tmp];
530 }
531 $max = strlen($numbers) - 1;
532 for ($x = 0; $x < $nbofcharlast; $x++) {
533 $tmp = mt_rand(0, $max);
534 $randomCode .= $numbers[$tmp];
535 }
536
537 $generated_password = str_shuffle($randomCode);
538 }
539 } elseif (getDolGlobalString('USER_PASSWORD_GENERATED')) {
540 $nomclass = "modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED);
541 $nomfichier = $nomclass.".class.php";
542 //print DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomclass;
543 require_once DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomfichier;
544 $genhandler = new $nomclass($db, $conf, $langs, $user);
545 $generated_password = $genhandler->getNewGeneratedPassword();
546 unset($genhandler);
547 }
548
549 // Do we have to discard some alphabetic characters ?
550 if (is_array($replaceambiguouschars) && count($replaceambiguouschars) > 0) {
551 $numbers = "ABCDEF";
552 $max = strlen($numbers) - 1;
553 if (function_exists('random_int')) { // Cryptographic random
554 $tmp = random_int(0, $max);
555 $generated_password = str_replace($replaceambiguouschars, $numbers[$tmp], $generated_password);
556 } else {
557 $tmp = mt_rand(0, $max);
558 $generated_password = str_replace($replaceambiguouschars, $numbers[$tmp], $generated_password);
559 }
560 }
561
562 return $generated_password;
563}
564
574function dolJSToSetRandomPassword($htmlname, $htmlnameofbutton = 'generate_token', $generic = 1)
575{
576 global $conf;
577
578 $out = '';
579
580 if (!empty($conf->use_javascript_ajax)) {
581 $out .= "\n".'<!-- Js code to suggest a security key -->';
582 $out .= '<script nonce="'.getNonce().'" type="text/javascript">';
583 $out .= 'jQuery(document).ready(function () {
584 jQuery("#'.dol_escape_js($htmlnameofbutton).'").click(function() {
585 var currenttoken = jQuery("meta[name=anti-csrf-currenttoken]").attr("content");
586 console.log("We click on the button '.dol_escape_js($htmlnameofbutton).' to suggest a key. anti-csrf-currentotken is "+currenttoken+". We will fill '.dol_escape_js($htmlname).'");
587 jQuery.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
588 action: \'getrandompassword\',
589 generic: '.($generic ? '1' : '0').',
590 token: currenttoken
591 },
592 function(result) {
593 if (jQuery("input#'.dol_escape_js($htmlname).'").attr("type") == "password") {
594 jQuery("input#'.dol_escape_js($htmlname).'").attr("type", "text");
595 }
596 jQuery("#'.dol_escape_js($htmlname).'").val(result);
597 });
598 });
599 });'."\n";
600 $out .= '</script>';
601 }
602
603 return $out;
604}
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.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
isHTTPS()
Return if we are using a HTTPS connection Check HTTPS (no way to be modified by user but may be empty...
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
dol_htmloutput_events($disabledoutputofmessages=0)
Print formatted messages to output (Used to show messages on html output).
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
conf($dolibarr_main_document_root)
Load conf file (file must exists)
Definition inc.php:420
if(empty($reshook)) $dol_url_root
View.
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Output javascript to autoset a generated password using default module into a HTML element.
dol_getwebuser($mode)
Return user/group account of web server.
encodedecode_dbpassconf($level=0)
Encode or decode database password in config file.
checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode, $context='')
Return a login if login/pass was successful.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
if(!function_exists( 'dol_loginfunction')) makesalt($type=CRYPT_SALT_LENGTH)
Initialise the salt for the crypt function.
dol_encode($chain, $key='1')
Encode a string with base 64 algorithm + specific delta change.
dol_decode($chain, $key='1')
Decode a base 64 encoded + specific delta change.
dolDecrypt($chain, $key='')
Decode a string with a symmetric encryption.