33if (!defined(
'DOL_APPLICATION_TITLE')) {
34 define(
'DOL_APPLICATION_TITLE',
'Dolibarr');
36if (!defined(
'DOL_VERSION')) {
37 define(
'DOL_VERSION',
'18.0.6');
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')) {
66$conffiletoshowshort =
"conf.php";
69$conffile =
"conf/conf.php";
70$conffiletoshow =
"htdocs/conf/conf.php";
81$result = @include_once $conffile;
83if (!$result && !empty($_SERVER[
"GATEWAY_INTERFACE"])) {
84 if (!empty($_SERVER[
"CONTEXT_PREFIX"])) {
85 $path = $_SERVER[
"CONTEXT_PREFIX"];
86 if (!preg_match(
'/\/$/', $path)) {
89 } elseif (preg_match(
'/index\.php/', $_SERVER[
'PHP_SELF'])) {
99 $TDir = explode(
'/', $_SERVER[
'PHP_SELF']);
103 if (empty($TDir[$i]) || $TDir[$i] ==
'htdocs') {
106 if ($TDir[$i] ==
'dolibarr') {
109 if (substr($TDir[$i], -4, 4) ==
'.php') {
117 header(
"Location: ".$path.
"install/index.php");
129if (!empty($dolibarr_strict_mode)) {
130 error_reporting(E_ALL | E_STRICT);
132 error_reporting(E_ALL & ~(E_STRICT | E_NOTICE | E_DEPRECATED));
136if (!empty($dolibarr_main_prod)) {
137 ini_set(
'display_errors',
'Off');
141$dolibarr_main_data_root = (empty($dolibarr_main_data_root) ?
'' : trim($dolibarr_main_data_root));
142$dolibarr_main_url_root = trim(preg_replace(
'/\/+$/',
'', empty($dolibarr_main_url_root) ?
'' : $dolibarr_main_url_root));
143$dolibarr_main_url_root_alt = (empty($dolibarr_main_url_root_alt) ?
'' : trim($dolibarr_main_url_root_alt));
144$dolibarr_main_document_root = (empty($dolibarr_main_document_root) ?
'' : trim($dolibarr_main_document_root));
145$dolibarr_main_document_root_alt = (empty($dolibarr_main_document_root_alt) ?
'' : trim($dolibarr_main_document_root_alt));
147if (empty($dolibarr_main_db_port)) {
148 $dolibarr_main_db_port = 3306;
150if (empty($dolibarr_main_db_type)) {
151 $dolibarr_main_db_type =
'mysqli';
155if ($dolibarr_main_db_type ==
'mysql') {
156 $dolibarr_main_db_type =
'mysqli';
158if (empty($dolibarr_main_db_prefix)) {
159 $dolibarr_main_db_prefix =
'llx_';
161if (empty($dolibarr_main_db_character_set)) {
162 $dolibarr_main_db_character_set = ($dolibarr_main_db_type ==
'mysqli' ?
'utf8' :
'');
164if (empty($dolibarr_main_db_collation)) {
165 $dolibarr_main_db_collation = ($dolibarr_main_db_type ==
'mysqli' ?
'utf8_unicode_ci' :
'');
167if (empty($dolibarr_main_db_encryption)) {
168 $dolibarr_main_db_encryption = 0;
170if (empty($dolibarr_main_db_cryptkey)) {
171 $dolibarr_main_db_cryptkey =
'';
173if (empty($dolibarr_main_limit_users)) {
174 $dolibarr_main_limit_users = 0;
176if (empty($dolibarr_mailing_limit_sendbyweb)) {
177 $dolibarr_mailing_limit_sendbyweb = 0;
179if (empty($dolibarr_mailing_limit_sendbycli)) {
180 $dolibarr_mailing_limit_sendbycli = 0;
182if (empty($dolibarr_mailing_limit_sendbyday)) {
183 $dolibarr_mailing_limit_sendbyday = 0;
185if (empty($dolibarr_strict_mode)) {
186 $dolibarr_strict_mode = 0;
189define(
'DOL_DOCUMENT_ROOT', $dolibarr_main_document_root);
191if (!file_exists(DOL_DOCUMENT_ROOT.
"/core/lib/functions.lib.php")) {
192 print
"Error: Dolibarr config file content seems to be not correctly defined.<br>\n";
193 print
"Please run dolibarr setup by calling page <b>/install</b>.<br>\n";
199include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
200include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
209if (!defined(
'NOCSRFCHECK') && isset($dolibarr_nocsrfcheck) && $dolibarr_nocsrfcheck == 1) {
210 if (!empty($_SERVER[
'REQUEST_METHOD']) && !in_array($_SERVER[
'REQUEST_METHOD'], array(
'GET',
'HEAD')) && !empty($_SERVER[
'HTTP_HOST'])) {
212 if (empty($_SERVER[
'HTTP_REFERER'])) {
215 $tmpa = parse_url($_SERVER[
'HTTP_HOST']);
216 $tmpb = parse_url($_SERVER[
'HTTP_REFERER']);
217 if ((empty($tmpa[
'host']) ? $tmpa[
'path'] : $tmpa[
'host']) != (empty($tmpb[
'host']) ? $tmpb[
'path'] : $tmpb[
'host'])) {
224 dol_syslog(
"--- Access to ".(empty($_SERVER[
"REQUEST_METHOD"])?
'':$_SERVER[
"REQUEST_METHOD"].
' ').$_SERVER[
"PHP_SELF"].
" refused by CSRF protection (Bad referer).", LOG_WARNING);
225 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";
226 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";
232if (empty($dolibarr_main_db_host) && !defined(
'NOREQUIREDB')) {
233 print
'<div class="center">Dolibarr setup is not yet complete.<br><br>'.
"\n";
234 print
'<a href="install/index.php">Click here to finish Dolibarr install process</a> ...</div>'.
"\n";
237if (empty($dolibarr_main_url_root) && !defined(
'NOREQUIREVIRTUALURL')) {
238 print
'Value for parameter \'dolibarr_main_url_root\' is not defined in your \'htdocs\conf\conf.php\' file.<br>'.
"\n";
239 print
'You must add this parameter with your full Dolibarr root Url (Example: http://myvirtualdomain/ or http://mydomain/mydolibarrurl/)'.
"\n";
243if (empty($dolibarr_main_document_root_alt)) {
244 $dolibarr_main_document_root_alt = $dolibarr_main_document_root.
'/custom';
247if (empty($dolibarr_main_data_root)) {
249 $dolibarr_main_data_root = str_replace(
"/htdocs",
"", $dolibarr_main_document_root);
250 $dolibarr_main_data_root .=
"/documents";
254define(
'DOL_CLASS_PATH',
'class/');
255define(
'DOL_DATA_ROOT', $dolibarr_main_data_root);
260$real_dolibarr_main_document_root = str_replace(
'\\',
'/', realpath($dolibarr_main_document_root));
261if (!empty($_SERVER[
"DOCUMENT_ROOT"])) {
262 $pathroot = $_SERVER[
"DOCUMENT_ROOT"];
264 $pathroot =
'NOTDEFINED';
266$paths = explode(
'/', str_replace(
'\\',
'/', $_SERVER[
"SCRIPT_NAME"]));
269foreach ($paths as $tmppath) {
270 if (empty($tmppath)) {
273 $concatpath .=
'/'.$tmppath;
276 if ($real_dolibarr_main_document_root == @realpath($pathroot.$concatpath)) {
287 $tmp = $dolibarr_main_url_root;
289 $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 :
'');
292if (!empty($dolibarr_main_force_https)) {
293 $tmp = preg_replace(
'/^http:/i',
'https:', $tmp);
295define(
'DOL_MAIN_URL_ROOT', $tmp);
296$uri = preg_replace(
'/^http(s?):\/\//i',
'', constant(
'DOL_MAIN_URL_ROOT'));
297$suburi = strstr($uri,
'/');
298if (empty($suburi) || $suburi ===
'/') {
301if (!defined(
'DOL_URL_ROOT')) {
302 define(
'DOL_URL_ROOT', $suburi);
307define(
'MAIN_DB_PREFIX', $dolibarr_main_db_prefix);
315if (!defined(
'TCPDF_PATH')) {
316 define(
'TCPDF_PATH', (empty($dolibarr_lib_TCPDF_PATH)) ?DOL_DOCUMENT_ROOT.
'/includes/tecnickcom/tcpdf/' : $dolibarr_lib_TCPDF_PATH.
'/');
318if (!defined(
'TCPDI_PATH')) {
319 define(
'TCPDI_PATH', (empty($dolibarr_lib_TCPDI_PATH)) ?DOL_DOCUMENT_ROOT.
'/includes/tcpdi/' : $dolibarr_lib_TCPDI_PATH.
'/');
321if (!defined(
'NUSOAP_PATH')) {
322 define(
'NUSOAP_PATH', (!isset($dolibarr_lib_NUSOAP_PATH)) ?DOL_DOCUMENT_ROOT.
'/includes/nusoap/lib/' : (empty($dolibarr_lib_NUSOAP_PATH) ?
'' : $dolibarr_lib_NUSOAP_PATH.
'/'));
324if (!defined(
'PHPEXCELNEW_PATH')) {
325 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.
'/'));
327if (!defined(
'ODTPHP_PATH')) {
328 define(
'ODTPHP_PATH', (!isset($dolibarr_lib_ODTPHP_PATH)) ?DOL_DOCUMENT_ROOT.
'/includes/odtphp/' : (empty($dolibarr_lib_ODTPHP_PATH) ?
'' : $dolibarr_lib_ODTPHP_PATH.
'/'));
330if (!defined(
'ODTPHP_PATHTOPCLZIP')) {
331 define(
'ODTPHP_PATHTOPCLZIP', (!isset($dolibarr_lib_ODTPHP_PATHTOPCLZIP)) ?DOL_DOCUMENT_ROOT.
'/includes/odtphp/zip/pclzip/' : (empty($dolibarr_lib_ODTPHP_PATHTOPCLZIP) ?
'' : $dolibarr_lib_ODTPHP_PATHTOPCLZIP.
'/'));
333if (!defined(
'JS_CKEDITOR')) {
334 define(
'JS_CKEDITOR', (!isset($dolibarr_js_CKEDITOR)) ?
'' : (empty($dolibarr_js_CKEDITOR) ?
'' : $dolibarr_js_CKEDITOR.
'/'));
336if (!defined(
'JS_JQUERY')) {
337 define(
'JS_JQUERY', (!isset($dolibarr_js_JQUERY)) ?
'' : (empty($dolibarr_js_JQUERY) ?
'' : $dolibarr_js_JQUERY.
'/'));
339if (!defined(
'JS_JQUERY_UI')) {
340 define(
'JS_JQUERY_UI', (!isset($dolibarr_js_JQUERY_UI)) ?
'' : (empty($dolibarr_js_JQUERY_UI) ?
'' : $dolibarr_js_JQUERY_UI.
'/'));
343if (!defined(
'DOL_DEFAULT_TTF')) {
344 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));
346if (!defined(
'DOL_DEFAULT_TTF_BOLD')) {
347 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));
356if ((!empty($dolibarr_main_db_pass) && preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) || !empty($dolibarr_main_db_encrypted_pass)) {
357 if (!empty($dolibarr_main_db_pass) && preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) {
358 $dolibarr_main_db_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
359 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_pass);
360 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass;
362 $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.