37require_once
'version.inc.php';
41if (!defined(
'LOG_DEBUG')) {
42 if (!function_exists(
"syslog")) {
44 define(
'LOG_EMERG', 0);
45 define(
'LOG_ALERT', 1);
46 define(
'LOG_CRIT', 2);
48 define(
'LOG_WARNING', 4);
49 define(
'LOG_NOTICE', 5);
50 define(
'LOG_INFO', 6);
51 define(
'LOG_DEBUG', 7);
56if (defined(
'DOL_INC_FOR_VERSION_ERROR')) {
78 return session_regenerate_id();
93 $session_backup = $_SESSION;
96 $_SESSION[
'OBSOLETE'] =
true;
97 $_SESSION[
'EXPIRES'] = time() + 60;
100 session_write_close();
103 session_name($sessionname);
107 $_SESSION = $session_backup;
110 unset($session_backup);
111 unset($_SESSION[
'OBSOLETE']);
112 unset($_SESSION[
'EXPIRES']);
123$conffiletoshow =
"htdocs/conf/conf.php";
184if (!$result && !empty($_SERVER[
"GATEWAY_INTERFACE"])) {
185 if (!empty($_SERVER[
"CONTEXT_PREFIX"])) {
186 $path = $_SERVER[
"CONTEXT_PREFIX"];
187 if (!preg_match(
'/\/$/', $path)) {
190 } elseif (preg_match(
'/index\.php/', $_SERVER[
'PHP_SELF'])) {
200 $TDir = explode(
'/', $_SERVER[
'PHP_SELF']);
204 if (empty($TDir[$i]) || $TDir[$i] ==
'htdocs') {
207 if ($TDir[$i] ==
'dolibarr') {
210 if (substr($TDir[$i], -4, 4) ==
'.php') {
218 header(
"Location: ".$path.
"install/index.php");
230if (version_compare(phpversion(),
'8.4',
'<')) {
231 if (!empty($dolibarr_strict_mode)) {
232 error_reporting(E_ALL | E_STRICT);
234 error_reporting(E_ALL & ~(E_STRICT | E_NOTICE | E_DEPRECATED));
238 if (!empty($dolibarr_strict_mode)) {
239 error_reporting(E_ALL);
241 error_reporting(E_ALL & ~(E_NOTICE | E_DEPRECATED));
246if (!empty($dolibarr_main_prod)) {
247 ini_set(
'display_errors',
'Off');
251$dolibarr_main_data_root = (empty($dolibarr_main_data_root) ?
'' : trim($dolibarr_main_data_root));
253$dolibarr_main_url_root_alt = (empty($dolibarr_main_url_root_alt) ?
'' : trim($dolibarr_main_url_root_alt));
254$dolibarr_main_document_root = (empty($dolibarr_main_document_root) ?
'' : trim($dolibarr_main_document_root));
255$dolibarr_main_document_root_alt = (empty($dolibarr_main_document_root_alt) ?
'' : trim($dolibarr_main_document_root_alt));
257if (!isset($dolibarr_main_db_port)) {
258 $dolibarr_main_db_port = 3306;
260if (empty($dolibarr_main_db_type)) {
261 $dolibarr_main_db_type =
'mysqli';
265if ($dolibarr_main_db_type ==
'mysql') {
266 $dolibarr_main_db_type =
'mysqli';
268if (empty($dolibarr_main_db_prefix)) {
269 $dolibarr_main_db_prefix =
'llx_';
271if (empty($dolibarr_main_db_character_set)) {
272 $dolibarr_main_db_character_set = ($dolibarr_main_db_type ==
'mysqli' ?
'utf8' :
'');
274if (empty($dolibarr_main_db_collation)) {
275 $dolibarr_main_db_collation = ($dolibarr_main_db_type ==
'mysqli' ?
'utf8_unicode_ci' :
'');
277if (empty($dolibarr_main_db_encryption)) {
278 $dolibarr_main_db_encryption = 0;
280if (empty($dolibarr_main_db_cryptkey)) {
281 $dolibarr_main_db_cryptkey =
'';
283if (empty($dolibarr_main_limit_users)) {
284 $dolibarr_main_limit_users = 0;
286if (empty($dolibarr_mailing_limit_sendbyweb)) {
287 $dolibarr_mailing_limit_sendbyweb = 0;
289if (empty($dolibarr_mailing_limit_sendbycli)) {
290 $dolibarr_mailing_limit_sendbycli = 0;
292if (empty($dolibarr_mailing_limit_sendbyday)) {
293 $dolibarr_mailing_limit_sendbyday = 0;
295if (empty($dolibarr_strict_mode)) {
296 $dolibarr_strict_mode = 0;
299if (!defined(
'DOL_DOCUMENT_ROOT')) {
300 define(
'DOL_DOCUMENT_ROOT', $dolibarr_main_document_root);
304if (empty(DOL_DOCUMENT_ROOT) || !file_exists(DOL_DOCUMENT_ROOT.
"/core/lib/functions.lib.php")) {
305 print
"Error: Dolibarr config file content seems to be not correctly defined";
306 if (empty($dolibarr_main_document_root)) {
307 print
" (dolibarr_main_document_root can't be unknown).<br>\n";
309 print
" (file ".DOL_DOCUMENT_ROOT.
"/core/lib/functions.lib.php not found).<br>\n";
311 print
"Please run dolibarr setup by calling page <b>/install</b>.<br>\n";
317include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
318include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
319include_once DOL_DOCUMENT_ROOT.
'/blockedlog/lib/securitycore.lib.php';
328if (!defined(
'NOCSRFCHECK') && isset($dolibarr_nocsrfcheck) && $dolibarr_nocsrfcheck == 1) {
329 if (!empty($_SERVER[
'REQUEST_METHOD']) && !in_array($_SERVER[
'REQUEST_METHOD'], array(
'GET',
'HEAD')) && !empty($_SERVER[
'HTTP_HOST'])) {
331 if (empty($_SERVER[
'HTTP_REFERER'])) {
334 $tmpa = parse_url($_SERVER[
'HTTP_HOST']);
335 $tmpb = parse_url($_SERVER[
'HTTP_REFERER']);
336 if ((empty($tmpa[
'host']) ? $tmpa[
'path'] : $tmpa[
'host']) != (empty($tmpb[
'host']) ? $tmpb[
'path'] : $tmpb[
'host'])) {
343 dol_syslog(
"--- Access to ".(empty($_SERVER[
"REQUEST_METHOD"]) ?
'' : $_SERVER[
"REQUEST_METHOD"].
' ').$_SERVER[
"PHP_SELF"].
" refused by CSRF protection (Bad referrer).", LOG_WARNING);
344 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";
345 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";
351if (empty($dolibarr_main_db_host) && !defined(
'NOREQUIREDB')) {
352 print
'<div class="center">Dolibarr setup is not yet complete.<br><br>'.
"\n";
353 print
'<a href="install/index.php">Click here to finish Dolibarr install process</a> ...</div>'.
"\n";
356if (empty($dolibarr_main_url_root) && !defined(
'NOREQUIREVIRTUALURL')) {
357 print
'Value for parameter \'dolibarr_main_url_root\' is not defined in your \'htdocs\conf\conf.php\' file.<br>'.
"\n";
358 print
'You must add this parameter with your full Dolibarr root Url (Example: http://myvirtualdomain/ or http://mydomain/mydolibarrurl/)'.
"\n";
362if (empty($dolibarr_main_document_root_alt)) {
363 $dolibarr_main_document_root_alt = $dolibarr_main_document_root.
'/custom';
366if (empty($dolibarr_main_data_root)) {
368 $dolibarr_main_data_root = str_replace(
"/htdocs",
"", $dolibarr_main_document_root);
369 $dolibarr_main_data_root .=
"/documents";
373define(
'DOL_CLASS_PATH',
'class/');
374define(
'DOL_DATA_ROOT', $dolibarr_main_data_root);
379$real_dolibarr_main_document_root = str_replace(
'\\',
'/', realpath($dolibarr_main_document_root));
380if (!empty($_SERVER[
"DOCUMENT_ROOT"])) {
381 $pathroot = $_SERVER[
"DOCUMENT_ROOT"];
383 $pathroot =
'NOTDEFINED';
385$paths = explode(
'/', str_replace(
'\\',
'/', $_SERVER[
"SCRIPT_NAME"]));
389foreach ($paths as $tmppath) {
390 if (empty($tmppath)) {
393 $concatpath .=
'/'.$tmppath;
396 if ($real_dolibarr_main_document_root == @realpath($pathroot.$concatpath)) {
412 $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 :
'');
416if (!empty($dolibarr_main_force_https)) {
417 $tmp = preg_replace(
'/^http:/i',
'https:', $tmp);
420define(
'DOL_MAIN_URL_ROOT', $tmp);
421$uri = preg_replace(
'/^http(s?):\/\//i',
'', constant(
'DOL_MAIN_URL_ROOT'));
422$suburi = strstr($uri,
'/');
423if (empty($suburi) || $suburi ===
'/') {
426if (!defined(
'DOL_URL_ROOT')) {
427 define(
'DOL_URL_ROOT', $suburi);
432define(
'MAIN_DB_PREFIX', $dolibarr_main_db_prefix);
440if (!defined(
'TCPDF_PATH')) {
441 define(
'TCPDF_PATH', (empty($dolibarr_lib_TCPDF_PATH)) ? DOL_DOCUMENT_ROOT.
'/includes/tecnickcom/tcpdf/' : $dolibarr_lib_TCPDF_PATH.
'/');
443if (!defined(
'TCPDI_PATH')) {
444 define(
'TCPDI_PATH', (empty($dolibarr_lib_TCPDI_PATH)) ? DOL_DOCUMENT_ROOT.
'/includes/tcpdi/' : $dolibarr_lib_TCPDI_PATH.
'/');
446if (!defined(
'NUSOAP_PATH')) {
447 define(
'NUSOAP_PATH', (!isset($dolibarr_lib_NUSOAP_PATH)) ? DOL_DOCUMENT_ROOT.
'/includes/nusoap/lib/' : (empty($dolibarr_lib_NUSOAP_PATH) ?
'' : $dolibarr_lib_NUSOAP_PATH.
'/'));
449if (!defined(
'PHPEXCELNEW_PATH')) {
450 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.
'/'));
452if (!defined(
'ODTPHP_PATH')) {
453 define(
'ODTPHP_PATH', (!isset($dolibarr_lib_ODTPHP_PATH)) ? DOL_DOCUMENT_ROOT.
'/includes/odtphp/' : (empty($dolibarr_lib_ODTPHP_PATH) ?
'' : $dolibarr_lib_ODTPHP_PATH.
'/'));
455if (!defined(
'ODTPHP_PATHTOPCLZIP')) {
456 define(
'ODTPHP_PATHTOPCLZIP', (!isset($dolibarr_lib_ODTPHP_PATHTOPCLZIP)) ? DOL_DOCUMENT_ROOT.
'/includes/odtphp/zip/pclzip/' : (empty($dolibarr_lib_ODTPHP_PATHTOPCLZIP) ?
'' : $dolibarr_lib_ODTPHP_PATHTOPCLZIP.
'/'));
458if (!defined(
'JS_CKEDITOR')) {
459 define(
'JS_CKEDITOR', (!isset($dolibarr_js_CKEDITOR)) ?
'' : (empty($dolibarr_js_CKEDITOR) ?
'' : $dolibarr_js_CKEDITOR.
'/'));
461if (!defined(
'JS_JQUERY')) {
462 define(
'JS_JQUERY', (!isset($dolibarr_js_JQUERY)) ?
'' : (empty($dolibarr_js_JQUERY) ?
'' : $dolibarr_js_JQUERY.
'/'));
464if (!defined(
'JS_JQUERY_UI')) {
465 define(
'JS_JQUERY_UI', (!isset($dolibarr_js_JQUERY_UI)) ?
'' : (empty($dolibarr_js_JQUERY_UI) ?
'' : $dolibarr_js_JQUERY_UI.
'/'));
468if (!defined(
'DOL_DEFAULT_TTF')) {
469 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));
471if (!defined(
'DOL_DEFAULT_TTF_BOLD')) {
472 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));
481if ((!empty($dolibarr_main_db_pass) && preg_match(
'/(dolcrypt|crypted):/i', $dolibarr_main_db_pass)) || !empty($dolibarr_main_db_encrypted_pass)) {
482 if (!empty($dolibarr_main_db_pass) && preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) {
483 $dolibarr_main_db_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
484 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass;
485 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_pass);
486 } elseif (!empty($dolibarr_main_db_pass) && preg_match(
'/dolcrypt:/i', $dolibarr_main_db_pass)) {
487 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass;
488 $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));
490 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
global $dolibarr_main_url_root
if(!defined('LOG_DEBUG')) if(defined( 'DOL_INC_FOR_VERSION_ERROR')) dol_session_start()
Replace session_start()
dol_session_regenerate_id()
Replace session_regenerate_id()
dol_session_rotate($sessionname='')
Destroy and recreate a new session without losing content.
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='', $patterntotest='')
Decode a string with a symmetric encryption.
isHTTPS()
Return if we are using a HTTPS connection Check HTTPS (no way to be modified by user but may be empty...