95 $oldsessionid = session_id();
98 $session_backup = $_SESSION;
101 $_SESSION[
'OBSOLETE'] =
true;
102 $_SESSION[
'EXPIRES'] = time() + 60;
105 session_write_close();
108 session_name($sessionname);
112 $_SESSION = $session_backup;
115 unset($session_backup);
116 unset($_SESSION[
'OBSOLETE']);
117 unset($_SESSION[
'EXPIRES']);
119 $newsessionid = session_id();
126$conffiletoshowshort =
"conf.php";
129$conffile =
"conf/conf.php";
130$conffiletoshow =
"htdocs/conf/conf.php";
140$result = @include_once $conffile;
143$listofwrappers = stream_get_wrappers();
147$arrayofstreamtodisable = array(
'compress.zlib',
'compress.bzip2',
'ftp',
'ftps',
'glob',
'data',
'expect',
'ogg',
'rar',
'zlib');
148if (!empty($dolibarr_main_stream_to_disable) && is_array($dolibarr_main_stream_to_disable)) {
149 $arrayofstreamtodisable = $dolibarr_main_stream_to_disable;
151foreach ($arrayofstreamtodisable as $streamtodisable) {
152 if (!empty($listofwrappers) && in_array($streamtodisable, $listofwrappers)) {
156 stream_wrapper_unregister($streamtodisable);
160if (!$result && !empty($_SERVER[
"GATEWAY_INTERFACE"])) {
161 if (!empty($_SERVER[
"CONTEXT_PREFIX"])) {
162 $path = $_SERVER[
"CONTEXT_PREFIX"];
163 if (!preg_match(
'/\/$/', $path)) {
166 } elseif (preg_match(
'/index\.php/', $_SERVER[
'PHP_SELF'])) {
176 $TDir = explode(
'/', $_SERVER[
'PHP_SELF']);
180 if (empty($TDir[$i]) || $TDir[$i] ==
'htdocs') {
183 if ($TDir[$i] ==
'dolibarr') {
186 if (substr($TDir[$i], -4, 4) ==
'.php') {
194 header(
"Location: ".$path.
"install/index.php");
206if (!empty($dolibarr_strict_mode)) {
207 error_reporting(E_ALL | E_STRICT);
209 error_reporting(E_ALL & ~(E_STRICT | E_NOTICE | E_DEPRECATED));
213if (!empty($dolibarr_main_prod)) {
214 ini_set(
'display_errors',
'Off');
218$dolibarr_main_data_root = (empty($dolibarr_main_data_root) ?
'' : trim($dolibarr_main_data_root));
219$dolibarr_main_url_root = trim(preg_replace(
'/\/+$/',
'', empty($dolibarr_main_url_root) ?
'' : $dolibarr_main_url_root));
220$dolibarr_main_url_root_alt = (empty($dolibarr_main_url_root_alt) ?
'' : trim($dolibarr_main_url_root_alt));
221$dolibarr_main_document_root = (empty($dolibarr_main_document_root) ?
'' : trim($dolibarr_main_document_root));
222$dolibarr_main_document_root_alt = (empty($dolibarr_main_document_root_alt) ?
'' : trim($dolibarr_main_document_root_alt));
224if (!isset($dolibarr_main_db_port)) {
225 $dolibarr_main_db_port = 3306;
227if (empty($dolibarr_main_db_type)) {
228 $dolibarr_main_db_type =
'mysqli';
232if ($dolibarr_main_db_type ==
'mysql') {
233 $dolibarr_main_db_type =
'mysqli';
235if (empty($dolibarr_main_db_prefix)) {
236 $dolibarr_main_db_prefix =
'llx_';
238if (empty($dolibarr_main_db_character_set)) {
239 $dolibarr_main_db_character_set = ($dolibarr_main_db_type ==
'mysqli' ?
'utf8' :
'');
241if (empty($dolibarr_main_db_collation)) {
242 $dolibarr_main_db_collation = ($dolibarr_main_db_type ==
'mysqli' ?
'utf8_unicode_ci' :
'');
244if (empty($dolibarr_main_db_encryption)) {
245 $dolibarr_main_db_encryption = 0;
247if (empty($dolibarr_main_db_cryptkey)) {
248 $dolibarr_main_db_cryptkey =
'';
250if (empty($dolibarr_main_limit_users)) {
251 $dolibarr_main_limit_users = 0;
253if (empty($dolibarr_mailing_limit_sendbyweb)) {
254 $dolibarr_mailing_limit_sendbyweb = 0;
256if (empty($dolibarr_mailing_limit_sendbycli)) {
257 $dolibarr_mailing_limit_sendbycli = 0;
259if (empty($dolibarr_mailing_limit_sendbyday)) {
260 $dolibarr_mailing_limit_sendbyday = 0;
262if (empty($dolibarr_strict_mode)) {
263 $dolibarr_strict_mode = 0;
266define(
'DOL_DOCUMENT_ROOT', $dolibarr_main_document_root);
268if (!file_exists(DOL_DOCUMENT_ROOT.
"/core/lib/functions.lib.php")) {
269 print
"Error: Dolibarr config file content seems to be not correctly defined.<br>\n";
270 print
"Please run dolibarr setup by calling page <b>/install</b>.<br>\n";
276include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
277include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
286if (!defined(
'NOCSRFCHECK') && isset($dolibarr_nocsrfcheck) && $dolibarr_nocsrfcheck == 1) {
287 if (!empty($_SERVER[
'REQUEST_METHOD']) && !in_array($_SERVER[
'REQUEST_METHOD'], array(
'GET',
'HEAD')) && !empty($_SERVER[
'HTTP_HOST'])) {
289 if (empty($_SERVER[
'HTTP_REFERER'])) {
292 $tmpa = parse_url($_SERVER[
'HTTP_HOST']);
293 $tmpb = parse_url($_SERVER[
'HTTP_REFERER']);
294 if ((empty($tmpa[
'host']) ? $tmpa[
'path'] : $tmpa[
'host']) != (empty($tmpb[
'host']) ? $tmpb[
'path'] : $tmpb[
'host'])) {
301 dol_syslog(
"--- Access to ".(empty($_SERVER[
"REQUEST_METHOD"]) ?
'' : $_SERVER[
"REQUEST_METHOD"].
' ').$_SERVER[
"PHP_SELF"].
" refused by CSRF protection (Bad referrer).", LOG_WARNING);
302 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";
303 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";
309if (empty($dolibarr_main_db_host) && !defined(
'NOREQUIREDB')) {
310 print
'<div class="center">Dolibarr setup is not yet complete.<br><br>'.
"\n";
311 print
'<a href="install/index.php">Click here to finish Dolibarr install process</a> ...</div>'.
"\n";
314if (empty($dolibarr_main_url_root) && !defined(
'NOREQUIREVIRTUALURL')) {
315 print
'Value for parameter \'dolibarr_main_url_root\' is not defined in your \'htdocs\conf\conf.php\' file.<br>'.
"\n";
316 print
'You must add this parameter with your full Dolibarr root Url (Example: http://myvirtualdomain/ or http://mydomain/mydolibarrurl/)'.
"\n";
320if (empty($dolibarr_main_document_root_alt)) {
321 $dolibarr_main_document_root_alt = $dolibarr_main_document_root.
'/custom';
324if (empty($dolibarr_main_data_root)) {
326 $dolibarr_main_data_root = str_replace(
"/htdocs",
"", $dolibarr_main_document_root);
327 $dolibarr_main_data_root .=
"/documents";
331define(
'DOL_CLASS_PATH',
'class/');
332define(
'DOL_DATA_ROOT', $dolibarr_main_data_root);
337$real_dolibarr_main_document_root = str_replace(
'\\',
'/', realpath($dolibarr_main_document_root));
338if (!empty($_SERVER[
"DOCUMENT_ROOT"])) {
339 $pathroot = $_SERVER[
"DOCUMENT_ROOT"];
341 $pathroot =
'NOTDEFINED';
343$paths = explode(
'/', str_replace(
'\\',
'/', $_SERVER[
"SCRIPT_NAME"]));
346foreach ($paths as $tmppath) {
347 if (empty($tmppath)) {
350 $concatpath .=
'/'.$tmppath;
353 if ($real_dolibarr_main_document_root == @realpath($pathroot.$concatpath)) {
364 $tmp = $dolibarr_main_url_root;
366 $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 :
'');
370if (!empty($dolibarr_main_force_https)) {
371 $tmp = preg_replace(
'/^http:/i',
'https:', $tmp);
373define(
'DOL_MAIN_URL_ROOT', $tmp);
374$uri = preg_replace(
'/^http(s?):\/\//i',
'', constant(
'DOL_MAIN_URL_ROOT'));
375$suburi = strstr($uri,
'/');
376if (empty($suburi) || $suburi ===
'/') {
379if (!defined(
'DOL_URL_ROOT')) {
380 define(
'DOL_URL_ROOT', $suburi);
385define(
'MAIN_DB_PREFIX', $dolibarr_main_db_prefix);
393if (!defined(
'TCPDF_PATH')) {
394 define(
'TCPDF_PATH', (empty($dolibarr_lib_TCPDF_PATH)) ? DOL_DOCUMENT_ROOT.
'/includes/tecnickcom/tcpdf/' : $dolibarr_lib_TCPDF_PATH.
'/');
396if (!defined(
'TCPDI_PATH')) {
397 define(
'TCPDI_PATH', (empty($dolibarr_lib_TCPDI_PATH)) ? DOL_DOCUMENT_ROOT.
'/includes/tcpdi/' : $dolibarr_lib_TCPDI_PATH.
'/');
399if (!defined(
'NUSOAP_PATH')) {
400 define(
'NUSOAP_PATH', (!isset($dolibarr_lib_NUSOAP_PATH)) ? DOL_DOCUMENT_ROOT.
'/includes/nusoap/lib/' : (empty($dolibarr_lib_NUSOAP_PATH) ?
'' : $dolibarr_lib_NUSOAP_PATH.
'/'));
402if (!defined(
'PHPEXCELNEW_PATH')) {
403 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.
'/'));
405if (!defined(
'ODTPHP_PATH')) {
406 define(
'ODTPHP_PATH', (!isset($dolibarr_lib_ODTPHP_PATH)) ? DOL_DOCUMENT_ROOT.
'/includes/odtphp/' : (empty($dolibarr_lib_ODTPHP_PATH) ?
'' : $dolibarr_lib_ODTPHP_PATH.
'/'));
408if (!defined(
'ODTPHP_PATHTOPCLZIP')) {
409 define(
'ODTPHP_PATHTOPCLZIP', (!isset($dolibarr_lib_ODTPHP_PATHTOPCLZIP)) ? DOL_DOCUMENT_ROOT.
'/includes/odtphp/zip/pclzip/' : (empty($dolibarr_lib_ODTPHP_PATHTOPCLZIP) ?
'' : $dolibarr_lib_ODTPHP_PATHTOPCLZIP.
'/'));
411if (!defined(
'JS_CKEDITOR')) {
412 define(
'JS_CKEDITOR', (!isset($dolibarr_js_CKEDITOR)) ?
'' : (empty($dolibarr_js_CKEDITOR) ?
'' : $dolibarr_js_CKEDITOR.
'/'));
414if (!defined(
'JS_JQUERY')) {
415 define(
'JS_JQUERY', (!isset($dolibarr_js_JQUERY)) ?
'' : (empty($dolibarr_js_JQUERY) ?
'' : $dolibarr_js_JQUERY.
'/'));
417if (!defined(
'JS_JQUERY_UI')) {
418 define(
'JS_JQUERY_UI', (!isset($dolibarr_js_JQUERY_UI)) ?
'' : (empty($dolibarr_js_JQUERY_UI) ?
'' : $dolibarr_js_JQUERY_UI.
'/'));
421if (!defined(
'DOL_DEFAULT_TTF')) {
422 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));
424if (!defined(
'DOL_DEFAULT_TTF_BOLD')) {
425 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));
434if ((!empty($dolibarr_main_db_pass) && preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) || !empty($dolibarr_main_db_encrypted_pass)) {
435 if (!empty($dolibarr_main_db_pass) && preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) {
436 $dolibarr_main_db_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
437 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_pass);
438 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass;
440 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);