96 $oldsessionid = session_id();
99 $session_backup = $_SESSION;
102 $_SESSION[
'OBSOLETE'] =
true;
103 $_SESSION[
'EXPIRES'] = time() + 60;
106 session_write_close();
109 session_name($sessionname);
113 $_SESSION = $session_backup;
116 unset($session_backup);
117 unset($_SESSION[
'OBSOLETE']);
118 unset($_SESSION[
'EXPIRES']);
120 $newsessionid = session_id();
127$conffiletoshowshort =
"conf.php";
130$conffile =
"conf/conf.php";
131$conffiletoshow =
"htdocs/conf/conf.php";
142$result = @include_once $conffile;
145$listofwrappers = stream_get_wrappers();
149$arrayofstreamtodisable = array(
'compress.zlib',
'compress.bzip2',
'ftp',
'ftps',
'glob',
'data',
'expect',
'ogg',
'rar',
'zlib');
150if (!empty($dolibarr_main_stream_to_disable) && is_array($dolibarr_main_stream_to_disable)) {
151 $arrayofstreamtodisable = $dolibarr_main_stream_to_disable;
153foreach ($arrayofstreamtodisable as $streamtodisable) {
154 if (!empty($listofwrappers) && in_array($streamtodisable, $listofwrappers)) {
158 stream_wrapper_unregister($streamtodisable);
162if (!$result && !empty($_SERVER[
"GATEWAY_INTERFACE"])) {
163 if (!empty($_SERVER[
"CONTEXT_PREFIX"])) {
164 $path = $_SERVER[
"CONTEXT_PREFIX"];
165 if (!preg_match(
'/\/$/', $path)) {
168 } elseif (preg_match(
'/index\.php/', $_SERVER[
'PHP_SELF'])) {
178 $TDir = explode(
'/', $_SERVER[
'PHP_SELF']);
182 if (empty($TDir[$i]) || $TDir[$i] ==
'htdocs') {
185 if ($TDir[$i] ==
'dolibarr') {
188 if (substr($TDir[$i], -4, 4) ==
'.php') {
196 header(
"Location: ".$path.
"install/index.php");
208if (!empty($dolibarr_strict_mode)) {
209 error_reporting(E_ALL | E_STRICT);
211 error_reporting(E_ALL & ~(E_STRICT | E_NOTICE | E_DEPRECATED));
215if (!empty($dolibarr_main_prod)) {
216 ini_set(
'display_errors',
'Off');
220$dolibarr_main_data_root = (empty($dolibarr_main_data_root) ?
'' : trim($dolibarr_main_data_root));
221$dolibarr_main_url_root = trim(preg_replace(
'/\/+$/',
'', empty($dolibarr_main_url_root) ?
'' : $dolibarr_main_url_root));
222$dolibarr_main_url_root_alt = (empty($dolibarr_main_url_root_alt) ?
'' : trim($dolibarr_main_url_root_alt));
223$dolibarr_main_document_root = (empty($dolibarr_main_document_root) ?
'' : trim($dolibarr_main_document_root));
224$dolibarr_main_document_root_alt = (empty($dolibarr_main_document_root_alt) ?
'' : trim($dolibarr_main_document_root_alt));
226if (!isset($dolibarr_main_db_port)) {
227 $dolibarr_main_db_port = 3306;
229if (empty($dolibarr_main_db_type)) {
230 $dolibarr_main_db_type =
'mysqli';
234if ($dolibarr_main_db_type ==
'mysql') {
235 $dolibarr_main_db_type =
'mysqli';
237if (empty($dolibarr_main_db_prefix)) {
238 $dolibarr_main_db_prefix =
'llx_';
240if (empty($dolibarr_main_db_character_set)) {
241 $dolibarr_main_db_character_set = ($dolibarr_main_db_type ==
'mysqli' ?
'utf8' :
'');
243if (empty($dolibarr_main_db_collation)) {
244 $dolibarr_main_db_collation = ($dolibarr_main_db_type ==
'mysqli' ?
'utf8_unicode_ci' :
'');
246if (empty($dolibarr_main_db_encryption)) {
247 $dolibarr_main_db_encryption = 0;
249if (empty($dolibarr_main_db_cryptkey)) {
250 $dolibarr_main_db_cryptkey =
'';
252if (empty($dolibarr_main_limit_users)) {
253 $dolibarr_main_limit_users = 0;
255if (empty($dolibarr_mailing_limit_sendbyweb)) {
256 $dolibarr_mailing_limit_sendbyweb = 0;
258if (empty($dolibarr_mailing_limit_sendbycli)) {
259 $dolibarr_mailing_limit_sendbycli = 0;
261if (empty($dolibarr_mailing_limit_sendbyday)) {
262 $dolibarr_mailing_limit_sendbyday = 0;
264if (empty($dolibarr_strict_mode)) {
265 $dolibarr_strict_mode = 0;
268define(
'DOL_DOCUMENT_ROOT', $dolibarr_main_document_root);
270if (!file_exists(DOL_DOCUMENT_ROOT.
"/core/lib/functions.lib.php")) {
271 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";
272 print
"Please run dolibarr setup by calling page <b>/install</b>.<br>\n";
278include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
279include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
288if (!defined(
'NOCSRFCHECK') && isset($dolibarr_nocsrfcheck) && $dolibarr_nocsrfcheck == 1) {
289 if (!empty($_SERVER[
'REQUEST_METHOD']) && !in_array($_SERVER[
'REQUEST_METHOD'], array(
'GET',
'HEAD')) && !empty($_SERVER[
'HTTP_HOST'])) {
291 if (empty($_SERVER[
'HTTP_REFERER'])) {
294 $tmpa = parse_url($_SERVER[
'HTTP_HOST']);
295 $tmpb = parse_url($_SERVER[
'HTTP_REFERER']);
296 if ((empty($tmpa[
'host']) ? $tmpa[
'path'] : $tmpa[
'host']) != (empty($tmpb[
'host']) ? $tmpb[
'path'] : $tmpb[
'host'])) {
303 dol_syslog(
"--- Access to ".(empty($_SERVER[
"REQUEST_METHOD"]) ?
'' : $_SERVER[
"REQUEST_METHOD"].
' ').$_SERVER[
"PHP_SELF"].
" refused by CSRF protection (Bad referrer).", LOG_WARNING);
304 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";
305 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";
311if (empty($dolibarr_main_db_host) && !defined(
'NOREQUIREDB')) {
312 print
'<div class="center">Dolibarr setup is not yet complete.<br><br>'.
"\n";
313 print
'<a href="install/index.php">Click here to finish Dolibarr install process</a> ...</div>'.
"\n";
316if (empty($dolibarr_main_url_root) && !defined(
'NOREQUIREVIRTUALURL')) {
317 print
'Value for parameter \'dolibarr_main_url_root\' is not defined in your \'htdocs\conf\conf.php\' file.<br>'.
"\n";
318 print
'You must add this parameter with your full Dolibarr root Url (Example: http://myvirtualdomain/ or http://mydomain/mydolibarrurl/)'.
"\n";
322if (empty($dolibarr_main_document_root_alt)) {
323 $dolibarr_main_document_root_alt = $dolibarr_main_document_root.
'/custom';
326if (empty($dolibarr_main_data_root)) {
328 $dolibarr_main_data_root = str_replace(
"/htdocs",
"", $dolibarr_main_document_root);
329 $dolibarr_main_data_root .=
"/documents";
333define(
'DOL_CLASS_PATH',
'class/');
334define(
'DOL_DATA_ROOT', $dolibarr_main_data_root);
339$real_dolibarr_main_document_root = str_replace(
'\\',
'/', realpath($dolibarr_main_document_root));
340if (!empty($_SERVER[
"DOCUMENT_ROOT"])) {
341 $pathroot = $_SERVER[
"DOCUMENT_ROOT"];
343 $pathroot =
'NOTDEFINED';
345$paths = explode(
'/', str_replace(
'\\',
'/', $_SERVER[
"SCRIPT_NAME"]));
348foreach ($paths as $tmppath) {
349 if (empty($tmppath)) {
352 $concatpath .=
'/'.$tmppath;
355 if ($real_dolibarr_main_document_root == @realpath($pathroot.$concatpath)) {
366 $tmp = $dolibarr_main_url_root;
368 $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 :
'');
372if (!empty($dolibarr_main_force_https)) {
373 $tmp = preg_replace(
'/^http:/i',
'https:', $tmp);
375define(
'DOL_MAIN_URL_ROOT', $tmp);
376$uri = preg_replace(
'/^http(s?):\/\//i',
'', constant(
'DOL_MAIN_URL_ROOT'));
377$suburi = strstr($uri,
'/');
378if (empty($suburi) || $suburi ===
'/') {
381if (!defined(
'DOL_URL_ROOT')) {
382 define(
'DOL_URL_ROOT', $suburi);
387define(
'MAIN_DB_PREFIX', $dolibarr_main_db_prefix);
395if (!defined(
'TCPDF_PATH')) {
396 define(
'TCPDF_PATH', (empty($dolibarr_lib_TCPDF_PATH)) ? DOL_DOCUMENT_ROOT.
'/includes/tecnickcom/tcpdf/' : $dolibarr_lib_TCPDF_PATH.
'/');
398if (!defined(
'TCPDI_PATH')) {
399 define(
'TCPDI_PATH', (empty($dolibarr_lib_TCPDI_PATH)) ? DOL_DOCUMENT_ROOT.
'/includes/tcpdi/' : $dolibarr_lib_TCPDI_PATH.
'/');
401if (!defined(
'NUSOAP_PATH')) {
402 define(
'NUSOAP_PATH', (!isset($dolibarr_lib_NUSOAP_PATH)) ? DOL_DOCUMENT_ROOT.
'/includes/nusoap/lib/' : (empty($dolibarr_lib_NUSOAP_PATH) ?
'' : $dolibarr_lib_NUSOAP_PATH.
'/'));
404if (!defined(
'PHPEXCELNEW_PATH')) {
405 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.
'/'));
407if (!defined(
'ODTPHP_PATH')) {
408 define(
'ODTPHP_PATH', (!isset($dolibarr_lib_ODTPHP_PATH)) ? DOL_DOCUMENT_ROOT.
'/includes/odtphp/' : (empty($dolibarr_lib_ODTPHP_PATH) ?
'' : $dolibarr_lib_ODTPHP_PATH.
'/'));
410if (!defined(
'ODTPHP_PATHTOPCLZIP')) {
411 define(
'ODTPHP_PATHTOPCLZIP', (!isset($dolibarr_lib_ODTPHP_PATHTOPCLZIP)) ? DOL_DOCUMENT_ROOT.
'/includes/odtphp/zip/pclzip/' : (empty($dolibarr_lib_ODTPHP_PATHTOPCLZIP) ?
'' : $dolibarr_lib_ODTPHP_PATHTOPCLZIP.
'/'));
413if (!defined(
'JS_CKEDITOR')) {
414 define(
'JS_CKEDITOR', (!isset($dolibarr_js_CKEDITOR)) ?
'' : (empty($dolibarr_js_CKEDITOR) ?
'' : $dolibarr_js_CKEDITOR.
'/'));
416if (!defined(
'JS_JQUERY')) {
417 define(
'JS_JQUERY', (!isset($dolibarr_js_JQUERY)) ?
'' : (empty($dolibarr_js_JQUERY) ?
'' : $dolibarr_js_JQUERY.
'/'));
419if (!defined(
'JS_JQUERY_UI')) {
420 define(
'JS_JQUERY_UI', (!isset($dolibarr_js_JQUERY_UI)) ?
'' : (empty($dolibarr_js_JQUERY_UI) ?
'' : $dolibarr_js_JQUERY_UI.
'/'));
423if (!defined(
'DOL_DEFAULT_TTF')) {
424 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));
426if (!defined(
'DOL_DEFAULT_TTF_BOLD')) {
427 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));
436if ((!empty($dolibarr_main_db_pass) && preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) || !empty($dolibarr_main_db_encrypted_pass)) {
437 if (!empty($dolibarr_main_db_pass) && preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) {
438 $dolibarr_main_db_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
439 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_pass);
440 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass;
442 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);