dolibarr 22.0.5
filefunc.inc.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
4 * Copyright (C) 2004-2025 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
6 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
7 * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
8 * Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
9 * Copyright (C) 2006 Andre Cianfarani <andre.cianfarani@acdeveloppement.net>
10 * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
11 * Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
12 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
13 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <https://www.gnu.org/licenses/>.
27 */
28
48'
49@phan-var-force ?string $dolibarr_font_DOL_DEFAULT_TTF
50@phan-var-force ?string $dolibarr_font_DOL_DEFAULT_TTF_BOLD
51@phan-var-force ?string $dolibarr_js_CKEDITOR
52@phan-var-force ?string $dolibarr_js_JQUERY
53@phan-var-force ?string $dolibarr_js_JQUERY_UI
54@phan-var-force ?string $dolibarr_lib_NUSOAP_PATH
55@phan-var-force ?string $dolibarr_lib_ODTPHP_PATH
56@phan-var-force ?string $dolibarr_lib_ODTPHP_PATHTOPCLZIP
57@phan-var-force ?string $dolibarr_lib_PHPEXCELNEW_PATH
58@phan-var-force ?string $dolibarr_lib_TCPDF_PATH
59@phan-var-force ?string $dolibarr_lib_TCPDI_PATH
60';
61
62if (!defined('DOL_APPLICATION_TITLE')) {
63 define('DOL_APPLICATION_TITLE', 'Dolibarr');
64}
65if (!defined('DOL_VERSION')) {
66 define('DOL_VERSION', '22.0.5'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
67}
68
69if (!defined('EURO')) {
70 define('EURO', chr(128));
71}
72
73// Define syslog constants
74if (!defined('LOG_DEBUG')) {
75 if (!function_exists("syslog")) {
76 // For PHP versions without syslog (like running on Windows OS)
77 define('LOG_EMERG', 0);
78 define('LOG_ALERT', 1);
79 define('LOG_CRIT', 2);
80 define('LOG_ERR', 3);
81 define('LOG_WARNING', 4);
82 define('LOG_NOTICE', 5);
83 define('LOG_INFO', 6);
84 define('LOG_DEBUG', 7);
85 }
86}
87
88// End of common declaration part
89if (defined('DOL_INC_FOR_VERSION_ERROR')) {
90 return;
91}
92
93
100{
101 session_start();
102}
103
110{
111 return session_regenerate_id();
112}
113
121function dol_session_rotate($sessionname = '')
122{
123 $oldsessionid = session_id();
124
125 // Backup the current session
126 $session_backup = $_SESSION;
127
128 // Set current session to expire in 1 minute
129 $_SESSION['OBSOLETE'] = true;
130 $_SESSION['EXPIRES'] = time() + 60;
131
132 // Close the current session
133 session_write_close();
134
135 // Set a new session id and start the session
136 session_name($sessionname);
138
139 // Restore the previous session backup
140 $_SESSION = $session_backup;
141
142 // Clean up
143 unset($session_backup);
144 unset($_SESSION['OBSOLETE']);
145 unset($_SESSION['EXPIRES']);
146
147 $newsessionid = session_id();
148 //var_dump("oldsessionid=".$oldsessionid." - newsessionid=".$newsessionid);
149}
150
151
152
153// Define localization of conf file
154// --- Start of part replaced by Dolibarr packager makepack-dolibarr
155$conffile = "conf/conf.php";
156$conffiletoshow = "htdocs/conf/conf.php";
157// For debian/redhat like systems
158//$conffile = "/etc/dolibarr/conf.php";
159//$conffiletoshow = "/etc/dolibarr/conf.php";
160
161
162// Include configuration
163// --- End of part replaced by Dolibarr packager makepack-dolibarr
164
165// Include configuration
166// @phpstan-ignore-next-line
167$result = @include_once $conffile; // Keep @ because with some error reporting mode, this breaks the redirect done when file is not found
168
186// Disable some not used PHP stream
187$listofwrappers = stream_get_wrappers();
188// We need '.phar' for geoip2. TODO Replace phar in geoip with exploded files so we can disable phar by default.
189// phar stream does not auto unserialize content (possible code execution) since PHP 8.1
190// zip stream is necessary by excel import module
191$arrayofstreamtodisable = array('compress.zlib', 'compress.bzip2', 'ftp', 'ftps', 'glob', 'data', 'expect', 'ogg', 'rar', 'zlib');
192if (!empty($dolibarr_main_stream_to_disable) && is_array($dolibarr_main_stream_to_disable)) {
193 $arrayofstreamtodisable = $dolibarr_main_stream_to_disable;
194}
195foreach ($arrayofstreamtodisable as $streamtodisable) {
196 if (!empty($listofwrappers) && in_array($streamtodisable, $listofwrappers)) {
197 /*if (!empty($dolibarr_main_stream_do_not_disable) && is_array($dolibarr_main_stream_do_not_disable) && in_array($streamtodisable, $dolibarr_main_stream_do_not_disable)) {
198 continue; // We do not disable this stream
199 }*/
200 stream_wrapper_unregister($streamtodisable);
201 }
202}
203
204if (!$result && !empty($_SERVER["GATEWAY_INTERFACE"])) { // If install not done and we are in a web session
205 if (!empty($_SERVER["CONTEXT_PREFIX"])) { // CONTEXT_PREFIX and CONTEXT_DOCUMENT_ROOT are not defined on all apache versions
206 $path = $_SERVER["CONTEXT_PREFIX"]; // example '/dolibarr/' when using an apache alias.
207 if (!preg_match('/\/$/', $path)) {
208 $path .= '/';
209 }
210 } elseif (preg_match('/index\.php/', $_SERVER['PHP_SELF'])) {
211 // When we ask index.php, we MUST BE SURE that $path is '' at the end. This is required to make install process
212 // when using apache alias like '/dolibarr/' that point to htdocs.
213 // Note: If calling page was an index.php not into htdocs (ie comm/index.php, ...), then this redirect will fails,
214 // but we don't want to change this because when URL is correct, we must be sure the redirect to install/index.php will be correct.
215 $path = '';
216 } else {
217 // If what we look is not index.php, we can try to guess location of root. May not work all the time.
218 // There is no real solution, because the only way to know the apache url relative path is to have it into conf file.
219 // If it fails to find correct $path, then only solution is to ask user to enter the correct URL to index.php or install/index.php
220 $TDir = explode('/', $_SERVER['PHP_SELF']);
221 $path = '';
222 $i = count($TDir);
223 while ($i--) {
224 if (empty($TDir[$i]) || $TDir[$i] == 'htdocs') {
225 break;
226 }
227 if ($TDir[$i] == 'dolibarr') {
228 break;
229 }
230 if (substr($TDir[$i], -4, 4) == '.php') {
231 continue;
232 }
233
234 $path .= '../';
235 }
236 }
237
238 header("Location: ".$path."install/index.php");
239
240 /*
241 print '<br><center>';
242 print 'The conf/conf.php file was not found or is not readable by the web server. If this is your first access, <a href="'.$path.'install/index.php">click here to start the Dolibarr installation process</a> to create it...';
243 print '</center><br>';
244 */
245
246 exit;
247}
248
249// Force PHP error_reporting setup (Dolibarr may report warning without this)
250if (version_compare(phpversion(), '8.4', '<')) {
251 if (!empty($dolibarr_strict_mode)) {
252 error_reporting(E_ALL | E_STRICT);
253 } else {
254 error_reporting(E_ALL & ~(E_STRICT | E_NOTICE | E_DEPRECATED));
255 }
256} else {
257 // E_STRICT is deprecated since PHP 8.4
258 if (!empty($dolibarr_strict_mode)) {
259 error_reporting(E_ALL);
260 } else {
261 error_reporting(E_ALL & ~(E_NOTICE | E_DEPRECATED));
262 }
263}
264
265// Disable php display errors
266if (!empty($dolibarr_main_prod)) {
267 ini_set('display_errors', 'Off');
268}
269
270// Clean parameters
271$dolibarr_main_data_root = (empty($dolibarr_main_data_root) ? '' : trim($dolibarr_main_data_root));
272$dolibarr_main_url_root = trim(preg_replace('/\/+$/', '', empty($dolibarr_main_url_root) ? '' : $dolibarr_main_url_root));
274$dolibarr_main_document_root = (empty($dolibarr_main_document_root) ? '' : trim($dolibarr_main_document_root));
275$dolibarr_main_document_root_alt = (empty($dolibarr_main_document_root_alt) ? '' : trim($dolibarr_main_document_root_alt));
276
277if (!isset($dolibarr_main_db_port)) {
278 $dolibarr_main_db_port = 3306; // For compatibility with old configs, if not defined, we take 'mysql' type
279}
280if (empty($dolibarr_main_db_type)) {
281 $dolibarr_main_db_type = 'mysqli'; // For compatibility with old configs, if not defined, we take 'mysql' type
282}
283
284// Mysql driver support has been removed in favor of mysqli
285if ($dolibarr_main_db_type == 'mysql') {
286 $dolibarr_main_db_type = 'mysqli';
287}
288if (empty($dolibarr_main_db_prefix)) {
289 $dolibarr_main_db_prefix = 'llx_';
290}
291if (empty($dolibarr_main_db_character_set)) {
292 $dolibarr_main_db_character_set = ($dolibarr_main_db_type == 'mysqli' ? 'utf8' : ''); // Old installation
293}
294if (empty($dolibarr_main_db_collation)) {
295 $dolibarr_main_db_collation = ($dolibarr_main_db_type == 'mysqli' ? 'utf8_unicode_ci' : ''); // Old installation
296}
297if (empty($dolibarr_main_db_encryption)) {
298 $dolibarr_main_db_encryption = 0;
299}
300if (empty($dolibarr_main_db_cryptkey)) {
301 $dolibarr_main_db_cryptkey = '';
302}
303if (empty($dolibarr_main_limit_users)) {
304 $dolibarr_main_limit_users = 0;
305}
306if (empty($dolibarr_mailing_limit_sendbyweb)) {
307 $dolibarr_mailing_limit_sendbyweb = 0;
308}
309if (empty($dolibarr_mailing_limit_sendbycli)) {
310 $dolibarr_mailing_limit_sendbycli = 0;
311}
312if (empty($dolibarr_mailing_limit_sendbyday)) {
313 $dolibarr_mailing_limit_sendbyday = 0;
314}
315if (empty($dolibarr_strict_mode)) {
316 $dolibarr_strict_mode = 0; // For debug in php strict mode
317}
318
319define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root); // Filesystem core php (htdocs)
320
321if (!file_exists(DOL_DOCUMENT_ROOT."/core/lib/functions.lib.php")) {
322 print "Error: Dolibarr config file content seems to be not correctly defined (file ".DOL_DOCUMENT_ROOT."/core/lib/functions.lib.php not found).<br>\n";
323 print "Please run dolibarr setup by calling page <b>/install</b>.<br>\n";
324 exit(1);
325}
326
327
328// Included by default (must be before the CSRF check so wa can use the dol_syslog)
329include_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
330include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
331//print memory_get_usage();
332
333
334// Security: CSRF protection
335// This test check if referrer ($_SERVER['HTTP_REFERER']) is same web site than Dolibarr ($_SERVER['HTTP_HOST'])
336// when we post forms (we allow GET and HEAD to accept direct link from a particular page).
337// Note about $_SERVER[HTTP_HOST/SERVER_NAME]: http://shiflett.org/blog/2006/mar/server-name-versus-http-host
338// See also CSRF protections done into main.inc.php
339if (!defined('NOCSRFCHECK') && isset($dolibarr_nocsrfcheck) && $dolibarr_nocsrfcheck == 1) { // If $dolibarr_nocsrfcheck is 0, there is a strict CSRF test with token in main
340 if (!empty($_SERVER['REQUEST_METHOD']) && !in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) && !empty($_SERVER['HTTP_HOST'])) {
341 $csrfattack = false;
342 if (empty($_SERVER['HTTP_REFERER'])) {
343 $csrfattack = true; // An evil browser was used
344 } else {
345 $tmpa = parse_url($_SERVER['HTTP_HOST']);
346 $tmpb = parse_url($_SERVER['HTTP_REFERER']);
347 if ((empty($tmpa['host']) ? $tmpa['path'] : $tmpa['host']) != (empty($tmpb['host']) ? $tmpb['path'] : $tmpb['host'])) {
348 $csrfattack = true;
349 }
350 }
351 if ($csrfattack) {
352 //print 'NOCSRFCHECK='.defined('NOCSRFCHECK').' REQUEST_METHOD='.$_SERVER['REQUEST_METHOD'].' HTTP_HOST='.$_SERVER['HTTP_HOST'].' HTTP_REFERER='.$_SERVER['HTTP_REFERER'];
353 // Note: We can't use dol_escape_htmltag here to escape output because lib functions.lib.ph is not yet loaded.
354 dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (Bad referrer).", LOG_WARNING);
355 print "Access refused by CSRF protection in main.inc.php. Referrer of form (".htmlentities(empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'], ENT_COMPAT, 'UTF-8').") is outside the server that serve this page (with method = ".htmlentities($_SERVER['REQUEST_METHOD'], ENT_COMPAT, 'UTF-8').").\n";
356 print "If you access your server behind a proxy using url rewriting, you might check that all HTTP headers are propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file to remove this security check).\n";
357 die;
358 }
359 }
360 // Another test is done later on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on.
361}
362if (empty($dolibarr_main_db_host) && !defined('NOREQUIREDB')) {
363 print '<div class="center">Dolibarr setup is not yet complete.<br><br>'."\n";
364 print '<a href="install/index.php">Click here to finish Dolibarr install process</a> ...</div>'."\n";
365 die;
366}
367if (empty($dolibarr_main_url_root) && !defined('NOREQUIREVIRTUALURL')) {
368 print 'Value for parameter \'dolibarr_main_url_root\' is not defined in your \'htdocs\conf\conf.php\' file.<br>'."\n";
369 print 'You must add this parameter with your full Dolibarr root Url (Example: http://myvirtualdomain/ or http://mydomain/mydolibarrurl/)'."\n";
370 die;
371}
372
373if (empty($dolibarr_main_document_root_alt)) {
374 $dolibarr_main_document_root_alt = $dolibarr_main_document_root.'/custom';
375}
376
377if (empty($dolibarr_main_data_root)) {
378 // If directory not defined, we use the default hardcoded value
379 $dolibarr_main_data_root = str_replace("/htdocs", "", $dolibarr_main_document_root);
380 $dolibarr_main_data_root .= "/documents";
381}
382
383// Define some constants
384define('DOL_CLASS_PATH', 'class/'); // Filesystem path to class dir (defined only for some code that want to be compatible with old versions without this parameter)
385define('DOL_DATA_ROOT', $dolibarr_main_data_root); // Filesystem data (documents)
386// Try to autodetect DOL_MAIN_URL_ROOT and DOL_URL_ROOT when root is not directly the main domain.
387// Note: autodetect works only in case 1, 2, 3 and 4 of phpunit test CoreTest.php. For case 5, 6, only setting value into conf.php will works.
388$tmp = '';
389$found = 0;
390$real_dolibarr_main_document_root = str_replace('\\', '/', realpath($dolibarr_main_document_root)); // A) Value found into config file, to say where are store htdocs files. Ex: C:/xxx/dolibarr, C:/xxx/dolibarr/htdocs
391if (!empty($_SERVER["DOCUMENT_ROOT"])) {
392 $pathroot = $_SERVER["DOCUMENT_ROOT"]; // B) Value reported by web server setup (not defined on CLI mode), to say where is root of web server instance. Ex: C:/xxx/dolibarr, C:/xxx/dolibarr/htdocs
393} else {
394 $pathroot = 'NOTDEFINED';
395}
396$paths = explode('/', str_replace('\\', '/', $_SERVER["SCRIPT_NAME"])); // C) Value reported by web server, to say full path on filesystem of a file. Ex: /dolibarr/htdocs/admin/system/phpinfo.php
397// Try to detect if $_SERVER["DOCUMENT_ROOT"]+start of $_SERVER["SCRIPT_NAME"] is $dolibarr_main_document_root. If yes, relative url to add before dol files is this start part.
398$concatpath = '';
399$tmp3 = '';
400foreach ($paths as $tmppath) { // We check to find (B+start of C)=A
401 if (empty($tmppath)) {
402 continue;
403 }
404 $concatpath .= '/'.$tmppath;
405 //if ($tmppath) $concatpath.='/'.$tmppath;
406 //print $_SERVER["SCRIPT_NAME"].'-'.$pathroot.'-'.$concatpath.'-'.$real_dolibarr_main_document_root.'-'.realpath($pathroot.$concatpath).'<br>';
407 if ($real_dolibarr_main_document_root == @realpath($pathroot.$concatpath)) { // @ avoid warning when safe_mode is on.
408 //print "Found relative url = ".$concatpath;
409 $tmp3 = $concatpath;
410 $found = 1;
411 break;
412 }
413 //else print "Not found yet for concatpath=".$concatpath."<br>\n";
414}
415//print "found=".$found." dolibarr_main_url_root=".$dolibarr_main_url_root."\n";
416if (!$found) {
417 // There is no subdir that compose the main url root or autodetect fails (Ie: when using apache alias that point outside default DOCUMENT_ROOT).
419} else {
420 $tmp = 'http'.((!isHTTPS() && (empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] != 443)) ? '' : 's').'://'.$_SERVER["SERVER_NAME"].((empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] == 80 || $_SERVER["SERVER_PORT"] == 443) ? '' : ':'.$_SERVER["SERVER_PORT"]).($tmp3 ? (preg_match('/^\//', $tmp3) ? '' : '/').$tmp3 : '');
421}
422
423//print "tmp1=".$tmp1." tmp2=".$tmp2." tmp3=".$tmp3." tmp=".$tmp."\n";
424if (!empty($dolibarr_main_force_https)) {
425 $tmp = preg_replace('/^http:/i', 'https:', $tmp);
426}
427define('DOL_MAIN_URL_ROOT', $tmp); // URL absolute root (https://sss/dolibarr, ...)
428$uri = preg_replace('/^http(s?):\/\//i', '', constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*
429$suburi = strstr($uri, '/'); // $suburi contains url without domain:port
430if (empty($suburi) || $suburi === '/') {
431 $suburi = ''; // If $suburi is null or /, it is now ''
432}
433if (!defined('DOL_URL_ROOT')) {
434 define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...)
435}
436//print DOL_MAIN_URL_ROOT.'-'.DOL_URL_ROOT."\n";
437
438// Define prefix MAIN_DB_PREFIX
439define('MAIN_DB_PREFIX', $dolibarr_main_db_prefix);
440
441
442/*
443 * Define PATH to external libraries
444 * To use other version than embedded libraries, define here constant to path. Use '' to use include class path autodetect.
445 */
446// Path to root libraries
447if (!defined('TCPDF_PATH')) {
448 define('TCPDF_PATH', (empty($dolibarr_lib_TCPDF_PATH)) ? DOL_DOCUMENT_ROOT.'/includes/tecnickcom/tcpdf/' : $dolibarr_lib_TCPDF_PATH.'/');
449}
450if (!defined('TCPDI_PATH')) {
451 define('TCPDI_PATH', (empty($dolibarr_lib_TCPDI_PATH)) ? DOL_DOCUMENT_ROOT.'/includes/tcpdi/' : $dolibarr_lib_TCPDI_PATH.'/');
452}
453if (!defined('NUSOAP_PATH')) {
454 define('NUSOAP_PATH', (!isset($dolibarr_lib_NUSOAP_PATH)) ? DOL_DOCUMENT_ROOT.'/includes/nusoap/lib/' : (empty($dolibarr_lib_NUSOAP_PATH) ? '' : $dolibarr_lib_NUSOAP_PATH.'/'));
455}
456if (!defined('PHPEXCELNEW_PATH')) {
457 define('PHPEXCELNEW_PATH', (!isset($dolibarr_lib_PHPEXCELNEW_PATH)) ? DOL_DOCUMENT_ROOT.'/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/' : (empty($dolibarr_lib_PHPEXCELNEW_PATH) ? '' : $dolibarr_lib_PHPEXCELNEW_PATH.'/'));
458}
459if (!defined('ODTPHP_PATH')) {
460 define('ODTPHP_PATH', (!isset($dolibarr_lib_ODTPHP_PATH)) ? DOL_DOCUMENT_ROOT.'/includes/odtphp/' : (empty($dolibarr_lib_ODTPHP_PATH) ? '' : $dolibarr_lib_ODTPHP_PATH.'/'));
461}
462if (!defined('ODTPHP_PATHTOPCLZIP')) {
463 define('ODTPHP_PATHTOPCLZIP', (!isset($dolibarr_lib_ODTPHP_PATHTOPCLZIP)) ? DOL_DOCUMENT_ROOT.'/includes/odtphp/zip/pclzip/' : (empty($dolibarr_lib_ODTPHP_PATHTOPCLZIP) ? '' : $dolibarr_lib_ODTPHP_PATHTOPCLZIP.'/'));
464}
465if (!defined('JS_CKEDITOR')) {
466 define('JS_CKEDITOR', (!isset($dolibarr_js_CKEDITOR)) ? '' : (empty($dolibarr_js_CKEDITOR) ? '' : $dolibarr_js_CKEDITOR.'/'));
467}
468if (!defined('JS_JQUERY')) {
469 define('JS_JQUERY', (!isset($dolibarr_js_JQUERY)) ? '' : (empty($dolibarr_js_JQUERY) ? '' : $dolibarr_js_JQUERY.'/'));
470}
471if (!defined('JS_JQUERY_UI')) {
472 define('JS_JQUERY_UI', (!isset($dolibarr_js_JQUERY_UI)) ? '' : (empty($dolibarr_js_JQUERY_UI) ? '' : $dolibarr_js_JQUERY_UI.'/'));
473}
474// Other required path
475if (!defined('DOL_DEFAULT_TTF')) {
476 define('DOL_DEFAULT_TTF', (!isset($dolibarr_font_DOL_DEFAULT_TTF)) ? DOL_DOCUMENT_ROOT.'/includes/fonts/Aerial.ttf' : (empty($dolibarr_font_DOL_DEFAULT_TTF) ? '' : $dolibarr_font_DOL_DEFAULT_TTF));
477}
478if (!defined('DOL_DEFAULT_TTF_BOLD')) {
479 define('DOL_DEFAULT_TTF_BOLD', (!isset($dolibarr_font_DOL_DEFAULT_TTF_BOLD)) ? DOL_DOCUMENT_ROOT.'/includes/fonts/AerialBd.ttf' : (empty($dolibarr_font_DOL_DEFAULT_TTF_BOLD) ? '' : $dolibarr_font_DOL_DEFAULT_TTF_BOLD));
480}
481
482
483/*
484 * Include functions
485 */
486
487// If password is encoded, we decode it. Note: When page is called for install, $dolibarr_main_db_pass may not be defined yet.
488if ((!empty($dolibarr_main_db_pass) && preg_match('/(dolcrypt|crypted):/i', $dolibarr_main_db_pass)) || !empty($dolibarr_main_db_encrypted_pass)) {
489 if (!empty($dolibarr_main_db_pass) && preg_match('/crypted:/i', $dolibarr_main_db_pass)) {
490 $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
491 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this so we can use it later to know the password was initially encrypted
492 $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
493 } elseif (!empty($dolibarr_main_db_pass) && preg_match('/dolcrypt:/i', $dolibarr_main_db_pass)) {
494 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this so we can use it later to know the password was initially encrypted
495 $dolibarr_main_db_pass = dolDecrypt($dolibarr_main_db_pass, (empty($dolibarr_main_dolcrypt_key) ? (empty($dolibarr_main_instance_unique_id) ? '' : $dolibarr_main_instance_unique_id) : $dolibarr_main_dolcrypt_key));
496 } else {
497 $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
498 }
499}
global $dolibarr_main_url_root
$dolibarr_main_url_root_alt
dol_session_regenerate_id()
Replace session_regenerate_id()
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()
dol_session_rotate($sessionname='')
Destroy and recreate a new session without losing content.
isHTTPS()
Return if we are using a HTTPS connection Check HTTPS (no way to be modified by user but may be empty...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_decode($chain, $key='1')
Decode a base 64 encoded + specific delta change.
dolDecrypt($chain, $key='')
Decode a string with a symmetric encryption.