39require_once
'filefunc.inc.php';
69@phan-var-force ?string $dolibarr_main_db_prefix
70@phan-var-force ?string $dolibarr_main_db_collation
71@phan-var-force ?string $dolibarr_main_db_encryption
72@phan-var-force ?string $dolibarr_main_db_cryptkey
73@phan-var-force ?string $dolibarr_main_limit_users
74@phan-var-force ?string $dolibarr_main_url_root_alt
76require_once DOL_DOCUMENT_ROOT.
'/core/class/conf.class.php';
77require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
80if (!function_exists(
'is_countable')) {
87 function is_countable(
$c)
89 return is_array(
$c) ||
$c instanceof Countable;
98if (!defined(
'EURO')) {
99 define(
'EURO', chr(128));
103if (!defined(
'LOG_DEBUG')) {
104 if (!function_exists(
"syslog")) {
106 define(
'LOG_EMERG', 0);
107 define(
'LOG_ALERT', 1);
108 define(
'LOG_CRIT', 2);
109 define(
'LOG_ERR', 3);
110 define(
'LOG_WARNING', 4);
111 define(
'LOG_NOTICE', 5);
112 define(
'LOG_INFO', 6);
113 define(
'LOG_DEBUG', 7);
117if (!defined(
'SUBTOTALS_SPECIAL_CODE')) {
118 define(
'SUBTOTALS_SPECIAL_CODE', 81);
125$listofwrappers = stream_get_wrappers();
129$arrayofstreamtodisable = array(
'compress.zlib',
'compress.bzip2',
'ftp',
'ftps',
'glob',
'data',
'expect',
'ogg',
'rar',
'zlib');
130if (!empty($dolibarr_main_stream_to_disable) && is_array($dolibarr_main_stream_to_disable)) {
131 $arrayofstreamtodisable = $dolibarr_main_stream_to_disable;
133foreach ($arrayofstreamtodisable as $streamtodisable) {
134 if (!empty($listofwrappers) && in_array($streamtodisable, $listofwrappers)) {
138 stream_wrapper_unregister($streamtodisable);
150$conf->db->host = empty($dolibarr_main_db_host) ?
'' : $dolibarr_main_db_host;
151$conf->db->port = empty($dolibarr_main_db_port) ?
'' : $dolibarr_main_db_port;
152$conf->db->name = empty($dolibarr_main_db_name) ?
'' : $dolibarr_main_db_name;
153$conf->db->user = empty($dolibarr_main_db_user) ?
'' : $dolibarr_main_db_user;
154$conf->db->pass = empty($dolibarr_main_db_pass) ?
'' : $dolibarr_main_db_pass;
155$conf->db->type = empty($dolibarr_main_db_type) ?
'' : $dolibarr_main_db_type;
156$conf->db->prefix = $dolibarr_main_db_prefix;
157$conf->db->character_set = $dolibarr_main_db_character_set;
158$conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation;
159$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
160$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
161if (defined(
'TEST_DB_FORCE_TYPE')) {
162 $conf->db->type = constant(
'TEST_DB_FORCE_TYPE');
166$conf->file->main_limit_users = $dolibarr_main_limit_users;
167$conf->file->mailing_limit_sendbyweb = empty($dolibarr_mailing_limit_sendbyweb) ? 0 : $dolibarr_mailing_limit_sendbyweb;
168$conf->file->mailing_limit_sendbycli = empty($dolibarr_mailing_limit_sendbycli) ? 0 : $dolibarr_mailing_limit_sendbycli;
169$conf->file->mailing_limit_sendbyday = empty($dolibarr_mailing_limit_sendbyday) ? 0 : $dolibarr_mailing_limit_sendbyday;
170$conf->file->main_authentication = empty($dolibarr_main_authentication) ?
'dolibarr' : $dolibarr_main_authentication;
171$conf->file->main_force_https = empty($dolibarr_main_force_https) ?
'' : $dolibarr_main_force_https;
172$conf->file->strict_mode = empty($dolibarr_strict_mode) ?
'' : $dolibarr_strict_mode;
173$conf->file->instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ?
'' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id;
175$conf->file->dol_document_root = array(
'main' => (
string) DOL_DOCUMENT_ROOT);
176$conf->file->dol_url_root = array(
'main' => (
string) DOL_URL_ROOT);
177if (!empty($dolibarr_main_document_root_alt)) {
179 $values = preg_split(
'/[;,]/', $dolibarr_main_document_root_alt);
181 foreach ($values as $value) {
182 $conf->file->dol_document_root[
'alt'.($i++)] = (
string) $value;
184 $values = preg_split(
'/[;,]/', (
string) $dolibarr_main_url_root_alt);
186 foreach ($values as $value) {
187 if (preg_match(
'/^http(s)?:/', $value)) {
190 print
'<b>Error:</b><br>'.
"\n";
191 print
'Wrong <b>$dolibarr_main_url_root_alt</b> value in <b>conf.php</b> file.<br>'.
"\n";
192 print
'We now use a relative path to $dolibarr_main_url_root to build alternate URLs.<br>'.
"\n";
193 print
'Value found: '.$value.
'<br>'.
"\n";
194 print
'Should be replaced by: '.$correct_value.
'<br>'.
"\n";
195 print
"Or something like following examples:<br>\n";
196 print
"\"/extensions\"<br>\n";
197 print
"\"/extensions1,/extensions2,...\"<br>\n";
198 print
"\"/../extensions\"<br>\n";
199 print
"\"/custom\"<br>\n";
202 $conf->file->dol_url_root[
'alt'.($i++)] = (
string) $value;
207if (!defined(
'NOREQUIREUSER')) {
208 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
210if (!defined(
'NOREQUIRETRAN')) {
211 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
213if (!defined(
'NOREQUIRESOC')) {
214 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
222if (!defined(
'NOREQUIRETRAN')) {
231if (!defined(
'NOREQUIREDB')) {
238 if (is_object($langs)) {
239 $langs->setDefaultLang(
'auto');
242 if (!defined(
'USEDOLIBARREDITOR') && !defined(
'USEDOLIBARRSERVER') && !empty($_SERVER[
'SCRIPT_FILENAME']) && (strpos($_SERVER[
'SCRIPT_FILENAME'], DOL_DATA_ROOT.
'/website') === 0)) {
243 $sapi_type = php_sapi_name();
244 if (substr($sapi_type, 0, 3) !=
'cgi') {
245 http_response_code(503);
247 print
'<div class="center" style="text-align: center; margin: 100px;">';
248 if (is_object($langs)) {
249 $langs->load(
"website");
250 print $langs->trans(
"SorryWebsiteIsCurrentlyOffLine");
252 print
"SorryWebsiteIsCurrentlyOffLine";
264unset(
$conf->db->pass);
270if (!defined(
'NOREQUIREUSER')) {
271 $user =
new User($db);
277if (!defined(
'NOHOOKMANAGER')) {
284 require_once DOL_DOCUMENT_ROOT .
'/core/class/extrafields.class.php';
294if (session_id() && !empty($_SESSION[
"dol_entity"])) {
296 $conf->entity = $_SESSION[
"dol_entity"];
297} elseif (!empty($_ENV[
"dol_entity"])) {
299 $conf->entity = $_ENV[
"dol_entity"];
300} elseif (GETPOSTISSET(
"loginfunction") && (
GETPOSTINT(
"entity") ||
GETPOSTINT(
"switchentity"))) {
303} elseif (defined(
'DOLENTITY') && is_numeric(constant(
'DOLENTITY'))) {
305 $conf->entity = constant(
'DOLENTITY');
308if (!is_numeric(
$conf->entity)) {
314 $conf->setValues($db);
319if (!defined(
'NOREQUIRETRAN')) {
321 if (defined(
'MAIN_LANG_DEFAULT')) {
322 $langcode = constant(
'MAIN_LANG_DEFAULT');
324 $langs->setDefaultLang($langcode);
329if (!defined(
'NOREQUIREDB') && !defined(
'NOREQUIRESOC') && $db !=
null) {
330 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
337 if (
$mysoc->country_code ==
'DE' && !isset(
$conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
339 $conf->global->MAIN_INVERT_SENDER_RECIPIENT = 1;
341 if (
$mysoc->country_code ==
'FR' && !isset(
$conf->global->INVOICE_CATEGORY_OF_OPERATION)) {
343 $conf->global->INVOICE_CATEGORY_OF_OPERATION = 1;
345 if (
$mysoc->country_code ==
'FR' && !isset(
$conf->global->INVOICE_DISABLE_REPLACEMENT)) {
349 $conf->global->INVOICE_DISABLE_REPLACEMENT = 1;
351 if (
$mysoc->country_code ==
'GR' && !isset(
$conf->global->INVOICE_DISABLE_REPLACEMENT)) {
353 $conf->global->INVOICE_DISABLE_REPLACEMENT = 1;
355 if (
$mysoc->country_code ==
'GR' && !isset(
$conf->global->INVOICE_DISABLE_DEPOSIT)) {
357 $conf->global->INVOICE_DISABLE_DEPOSIT = 1;
359 if (
$mysoc->country_code ==
'GR' && !isset(
$conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) {
361 $conf->global->INVOICE_CREDIT_NOTE_STANDALONE = 1;
363 if (
$mysoc->country_code ==
'GR' && !isset(
$conf->global->INVOICE_SUBTYPE_ENABLED)) {
365 $conf->global->INVOICE_SUBTYPE_ENABLED = 1;
368 if ((
$mysoc->localtax1_assuj ||
$mysoc->localtax2_assuj) && !isset(
$conf->global->MAIN_NO_INPUT_PRICE_WITH_TAX)) {
371 $conf->global->MAIN_NO_INPUT_PRICE_WITH_TAX = 1;
global $dolibarr_main_url_root
Class to stock current configuration.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).