33if (!defined(
'DOL_APPLICATION_TITLE')) {
34 define(
'DOL_APPLICATION_TITLE',
'Dolibarr');
36if (!defined(
'DOL_VERSION')) {
37 define(
'DOL_VERSION',
'19.0.3');
40if (!defined(
'EURO')) {
41 define(
'EURO', chr(128));
45if (!defined(
'LOG_DEBUG')) {
46 if (!function_exists(
"syslog")) {
48 define(
'LOG_EMERG', 0);
49 define(
'LOG_ALERT', 1);
50 define(
'LOG_CRIT', 2);
52 define(
'LOG_WARNING', 4);
53 define(
'LOG_NOTICE', 5);
54 define(
'LOG_INFO', 6);
55 define(
'LOG_DEBUG', 7);
60if (defined(
'DOL_INC_FOR_VERSION_ERROR')) {
65$conffiletoshowshort =
"conf.php";
68$conffile =
"conf/conf.php";
69$conffiletoshow =
"htdocs/conf/conf.php";
79$result = @include_once $conffile;
82$listofwrappers = stream_get_wrappers();
86$arrayofstreamtodisable = array(
'compress.zlib',
'compress.bzip2',
'ftp',
'ftps',
'glob',
'data',
'expect',
'ogg',
'rar',
'zlib');
87if (!empty($dolibarr_main_stream_to_disable) && is_array($dolibarr_main_stream_to_disable)) {
88 $arrayofstreamtodisable = $dolibarr_main_stream_to_disable;
90foreach ($arrayofstreamtodisable as $streamtodisable) {
91 if (!empty($listofwrappers) && in_array($streamtodisable, $listofwrappers)) {
95 stream_wrapper_unregister($streamtodisable);
99if (!$result && !empty($_SERVER[
"GATEWAY_INTERFACE"])) {
100 if (!empty($_SERVER[
"CONTEXT_PREFIX"])) {
101 $path = $_SERVER[
"CONTEXT_PREFIX"];
102 if (!preg_match(
'/\/$/', $path)) {
105 } elseif (preg_match(
'/index\.php/', $_SERVER[
'PHP_SELF'])) {
115 $TDir = explode(
'/', $_SERVER[
'PHP_SELF']);
119 if (empty($TDir[$i]) || $TDir[$i] ==
'htdocs') {
122 if ($TDir[$i] ==
'dolibarr') {
125 if (substr($TDir[$i], -4, 4) ==
'.php') {
133 header(
"Location: ".$path.
"install/index.php");
145if (!empty($dolibarr_strict_mode)) {
146 error_reporting(E_ALL | E_STRICT);
148 error_reporting(E_ALL & ~(E_STRICT | E_NOTICE | E_DEPRECATED));
152if (!empty($dolibarr_main_prod)) {
153 ini_set(
'display_errors',
'Off');
157$dolibarr_main_data_root = (empty($dolibarr_main_data_root) ?
'' : trim($dolibarr_main_data_root));
158$dolibarr_main_url_root = trim(preg_replace(
'/\/+$/',
'', empty($dolibarr_main_url_root) ?
'' : $dolibarr_main_url_root));
159$dolibarr_main_url_root_alt = (empty($dolibarr_main_url_root_alt) ?
'' : trim($dolibarr_main_url_root_alt));
160$dolibarr_main_document_root = (empty($dolibarr_main_document_root) ?
'' : trim($dolibarr_main_document_root));
161$dolibarr_main_document_root_alt = (empty($dolibarr_main_document_root_alt) ?
'' : trim($dolibarr_main_document_root_alt));
163if (empty($dolibarr_main_db_port)) {
164 $dolibarr_main_db_port = 3306;
166if (empty($dolibarr_main_db_type)) {
167 $dolibarr_main_db_type =
'mysqli';
171if ($dolibarr_main_db_type ==
'mysql') {
172 $dolibarr_main_db_type =
'mysqli';
174if (empty($dolibarr_main_db_prefix)) {
175 $dolibarr_main_db_prefix =
'llx_';
177if (empty($dolibarr_main_db_character_set)) {
178 $dolibarr_main_db_character_set = ($dolibarr_main_db_type ==
'mysqli' ?
'utf8' :
'');
180if (empty($dolibarr_main_db_collation)) {
181 $dolibarr_main_db_collation = ($dolibarr_main_db_type ==
'mysqli' ?
'utf8_unicode_ci' :
'');
183if (empty($dolibarr_main_db_encryption)) {
184 $dolibarr_main_db_encryption = 0;
186if (empty($dolibarr_main_db_cryptkey)) {
187 $dolibarr_main_db_cryptkey =
'';
189if (empty($dolibarr_main_limit_users)) {
190 $dolibarr_main_limit_users = 0;
192if (empty($dolibarr_mailing_limit_sendbyweb)) {
193 $dolibarr_mailing_limit_sendbyweb = 0;
195if (empty($dolibarr_mailing_limit_sendbycli)) {
196 $dolibarr_mailing_limit_sendbycli = 0;
198if (empty($dolibarr_mailing_limit_sendbyday)) {
199 $dolibarr_mailing_limit_sendbyday = 0;
201if (empty($dolibarr_strict_mode)) {
202 $dolibarr_strict_mode = 0;
205define(
'DOL_DOCUMENT_ROOT', $dolibarr_main_document_root);
207if (!file_exists(DOL_DOCUMENT_ROOT.
"/core/lib/functions.lib.php")) {
208 print
"Error: Dolibarr config file content seems to be not correctly defined.<br>\n";
209 print
"Please run dolibarr setup by calling page <b>/install</b>.<br>\n";
215include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
216include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
225if (!defined(
'NOCSRFCHECK') && isset($dolibarr_nocsrfcheck) && $dolibarr_nocsrfcheck == 1) {
226 if (!empty($_SERVER[
'REQUEST_METHOD']) && !in_array($_SERVER[
'REQUEST_METHOD'], array(
'GET',
'HEAD')) && !empty($_SERVER[
'HTTP_HOST'])) {
228 if (empty($_SERVER[
'HTTP_REFERER'])) {
231 $tmpa = parse_url($_SERVER[
'HTTP_HOST']);
232 $tmpb = parse_url($_SERVER[
'HTTP_REFERER']);
233 if ((empty($tmpa[
'host']) ? $tmpa[
'path'] : $tmpa[
'host']) != (empty($tmpb[
'host']) ? $tmpb[
'path'] : $tmpb[
'host'])) {
240 dol_syslog(
"--- Access to ".(empty($_SERVER[
"REQUEST_METHOD"])?
'':$_SERVER[
"REQUEST_METHOD"].
' ').$_SERVER[
"PHP_SELF"].
" refused by CSRF protection (Bad referer).", LOG_WARNING);
241 print
"Access refused by CSRF protection in main.inc.php. Referer of form (".htmlentities($_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";
242 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";
248if (empty($dolibarr_main_db_host) && !defined(
'NOREQUIREDB')) {
249 print
'<div class="center">Dolibarr setup is not yet complete.<br><br>'.
"\n";
250 print
'<a href="install/index.php">Click here to finish Dolibarr install process</a> ...</div>'.
"\n";
253if (empty($dolibarr_main_url_root) && !defined(
'NOREQUIREVIRTUALURL')) {
254 print
'Value for parameter \'dolibarr_main_url_root\' is not defined in your \'htdocs\conf\conf.php\' file.<br>'.
"\n";
255 print
'You must add this parameter with your full Dolibarr root Url (Example: http://myvirtualdomain/ or http://mydomain/mydolibarrurl/)'.
"\n";
259if (empty($dolibarr_main_document_root_alt)) {
260 $dolibarr_main_document_root_alt = $dolibarr_main_document_root.
'/custom';
263if (empty($dolibarr_main_data_root)) {
265 $dolibarr_main_data_root = str_replace(
"/htdocs",
"", $dolibarr_main_document_root);
266 $dolibarr_main_data_root .=
"/documents";
270define(
'DOL_CLASS_PATH',
'class/');
271define(
'DOL_DATA_ROOT', $dolibarr_main_data_root);
276$real_dolibarr_main_document_root = str_replace(
'\\',
'/', realpath($dolibarr_main_document_root));
277if (!empty($_SERVER[
"DOCUMENT_ROOT"])) {
278 $pathroot = $_SERVER[
"DOCUMENT_ROOT"];
280 $pathroot =
'NOTDEFINED';
282$paths = explode(
'/', str_replace(
'\\',
'/', $_SERVER[
"SCRIPT_NAME"]));
285foreach ($paths as $tmppath) {
286 if (empty($tmppath)) {
289 $concatpath .=
'/'.$tmppath;
292 if ($real_dolibarr_main_document_root == @realpath($pathroot.$concatpath)) {
303 $tmp = $dolibarr_main_url_root;
305 $tmp =
'http'.(((empty($_SERVER[
"HTTPS"]) || $_SERVER[
"HTTPS"] !=
'on') && (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 :
'');
308if (!empty($dolibarr_main_force_https)) {
309 $tmp = preg_replace(
'/^http:/i',
'https:', $tmp);
311define(
'DOL_MAIN_URL_ROOT', $tmp);
312$uri = preg_replace(
'/^http(s?):\/\//i',
'', constant(
'DOL_MAIN_URL_ROOT'));
313$suburi = strstr($uri,
'/');
314if (empty($suburi) || $suburi ===
'/') {
317if (!defined(
'DOL_URL_ROOT')) {
318 define(
'DOL_URL_ROOT', $suburi);
323define(
'MAIN_DB_PREFIX', $dolibarr_main_db_prefix);
331if (!defined(
'TCPDF_PATH')) {
332 define(
'TCPDF_PATH', (empty($dolibarr_lib_TCPDF_PATH)) ?DOL_DOCUMENT_ROOT.
'/includes/tecnickcom/tcpdf/' : $dolibarr_lib_TCPDF_PATH.
'/');
334if (!defined(
'TCPDI_PATH')) {
335 define(
'TCPDI_PATH', (empty($dolibarr_lib_TCPDI_PATH)) ?DOL_DOCUMENT_ROOT.
'/includes/tcpdi/' : $dolibarr_lib_TCPDI_PATH.
'/');
337if (!defined(
'NUSOAP_PATH')) {
338 define(
'NUSOAP_PATH', (!isset($dolibarr_lib_NUSOAP_PATH)) ?DOL_DOCUMENT_ROOT.
'/includes/nusoap/lib/' : (empty($dolibarr_lib_NUSOAP_PATH) ?
'' : $dolibarr_lib_NUSOAP_PATH.
'/'));
340if (!defined(
'PHPEXCELNEW_PATH')) {
341 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.
'/'));
343if (!defined(
'ODTPHP_PATH')) {
344 define(
'ODTPHP_PATH', (!isset($dolibarr_lib_ODTPHP_PATH)) ?DOL_DOCUMENT_ROOT.
'/includes/odtphp/' : (empty($dolibarr_lib_ODTPHP_PATH) ?
'' : $dolibarr_lib_ODTPHP_PATH.
'/'));
346if (!defined(
'ODTPHP_PATHTOPCLZIP')) {
347 define(
'ODTPHP_PATHTOPCLZIP', (!isset($dolibarr_lib_ODTPHP_PATHTOPCLZIP)) ?DOL_DOCUMENT_ROOT.
'/includes/odtphp/zip/pclzip/' : (empty($dolibarr_lib_ODTPHP_PATHTOPCLZIP) ?
'' : $dolibarr_lib_ODTPHP_PATHTOPCLZIP.
'/'));
349if (!defined(
'JS_CKEDITOR')) {
350 define(
'JS_CKEDITOR', (!isset($dolibarr_js_CKEDITOR)) ?
'' : (empty($dolibarr_js_CKEDITOR) ?
'' : $dolibarr_js_CKEDITOR.
'/'));
352if (!defined(
'JS_JQUERY')) {
353 define(
'JS_JQUERY', (!isset($dolibarr_js_JQUERY)) ?
'' : (empty($dolibarr_js_JQUERY) ?
'' : $dolibarr_js_JQUERY.
'/'));
355if (!defined(
'JS_JQUERY_UI')) {
356 define(
'JS_JQUERY_UI', (!isset($dolibarr_js_JQUERY_UI)) ?
'' : (empty($dolibarr_js_JQUERY_UI) ?
'' : $dolibarr_js_JQUERY_UI.
'/'));
359if (!defined(
'DOL_DEFAULT_TTF')) {
360 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));
362if (!defined(
'DOL_DEFAULT_TTF_BOLD')) {
363 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));
372if ((!empty($dolibarr_main_db_pass) && preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) || !empty($dolibarr_main_db_encrypted_pass)) {
373 if (!empty($dolibarr_main_db_pass) && preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) {
374 $dolibarr_main_db_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
375 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_pass);
376 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass;
378 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
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.