39require_once
'filefunc.inc.php';
70@phan-var-force ?string $dolibarr_main_db_prefix
71@phan-var-force ?string $dolibarr_main_db_collation
72@phan-var-force ?string $dolibarr_main_db_encryption
73@phan-var-force ?string $dolibarr_main_db_cryptkey
74@phan-var-force ?string $dolibarr_main_limit_users
75@phan-var-force ?string $dolibarr_main_limit_sessions_per_user
76@phan-var-force ?string $dolibarr_main_url_root_alt
78require_once DOL_DOCUMENT_ROOT.
'/core/class/conf.class.php';
79require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
82if (!function_exists(
'is_countable')) {
89 function is_countable(
$c)
91 return is_array(
$c) ||
$c instanceof Countable;
100if (!defined(
'EURO')) {
101 define(
'EURO', chr(128));
105if (!defined(
'LOG_DEBUG')) {
106 if (!function_exists(
"syslog")) {
108 define(
'LOG_EMERG', 0);
109 define(
'LOG_ALERT', 1);
110 define(
'LOG_CRIT', 2);
111 define(
'LOG_ERR', 3);
112 define(
'LOG_WARNING', 4);
113 define(
'LOG_NOTICE', 5);
114 define(
'LOG_INFO', 6);
115 define(
'LOG_DEBUG', 7);
119if (!defined(
'SUBTOTALS_SPECIAL_CODE')) {
120 define(
'SUBTOTALS_SPECIAL_CODE', 81);
127$listofwrappers = stream_get_wrappers();
131$arrayofstreamtodisable = array(
'compress.zlib',
'compress.bzip2',
'ftp',
'ftps',
'glob',
'data',
'expect',
'ogg',
'rar',
'zlib');
132if (!empty($dolibarr_main_stream_to_disable) && is_array($dolibarr_main_stream_to_disable)) {
133 $arrayofstreamtodisable = $dolibarr_main_stream_to_disable;
135foreach ($arrayofstreamtodisable as $streamtodisable) {
136 if (!empty($listofwrappers) && in_array($streamtodisable, $listofwrappers)) {
140 stream_wrapper_unregister($streamtodisable);
152$conf->db->host = empty($dolibarr_main_db_host) ?
'' : $dolibarr_main_db_host;
153$conf->db->port = empty($dolibarr_main_db_port) ?
'' : $dolibarr_main_db_port;
154$conf->db->name = empty($dolibarr_main_db_name) ?
'' : $dolibarr_main_db_name;
155$conf->db->user = empty($dolibarr_main_db_user) ?
'' : $dolibarr_main_db_user;
156$conf->db->pass = empty($dolibarr_main_db_pass) ?
'' : $dolibarr_main_db_pass;
157$conf->db->type = empty($dolibarr_main_db_type) ?
'' : $dolibarr_main_db_type;
158$conf->db->prefix = $dolibarr_main_db_prefix;
159$conf->db->character_set = $dolibarr_main_db_character_set;
160$conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation;
161$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
162$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
163if (defined(
'TEST_DB_FORCE_TYPE')) {
164 $conf->db->type = constant(
'TEST_DB_FORCE_TYPE');
168$conf->file->main_limit_users = $dolibarr_main_limit_users;
169$conf->file->main_limit_sessions_per_user = empty($dolibarr_main_limit_sessions_per_user) ? 0 : $dolibarr_main_limit_sessions_per_user;
170$conf->file->mailing_limit_sendbyweb = empty($dolibarr_mailing_limit_sendbyweb) ? 0 : $dolibarr_mailing_limit_sendbyweb;
171$conf->file->mailing_limit_sendbycli = empty($dolibarr_mailing_limit_sendbycli) ? 0 : $dolibarr_mailing_limit_sendbycli;
172$conf->file->mailing_limit_sendbyday = empty($dolibarr_mailing_limit_sendbyday) ? 0 : $dolibarr_mailing_limit_sendbyday;
173$conf->file->main_authentication = empty($dolibarr_main_authentication) ?
'dolibarr' : $dolibarr_main_authentication;
174$conf->file->main_force_https = empty($dolibarr_main_force_https) ?
'' : $dolibarr_main_force_https;
175$conf->file->strict_mode = empty($dolibarr_strict_mode) ?
'' : $dolibarr_strict_mode;
176$conf->file->restrict_password_generation_none = empty($dolibarr_main_restrict_password_generation_none) ? 0 : $dolibarr_main_restrict_password_generation_none;
177$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;
179$conf->file->dol_document_root = array(
'main' => (
string) DOL_DOCUMENT_ROOT);
180$conf->file->dol_url_root = array(
'main' => (
string) DOL_URL_ROOT);
181if (!empty($dolibarr_main_document_root_alt)) {
183 $values = preg_split(
'/[;,]/', $dolibarr_main_document_root_alt);
185 foreach ($values as $value) {
186 $conf->file->dol_document_root[
'alt'.($i++)] = (
string) $value;
188 $values = preg_split(
'/[;,]/', (
string) $dolibarr_main_url_root_alt);
190 foreach ($values as $value) {
191 if (preg_match(
'/^http(s)?:/', $value)) {
194 print
'<b>Error:</b><br>'.
"\n";
195 print
'Wrong <b>$dolibarr_main_url_root_alt</b> value in <b>conf.php</b> file.<br>'.
"\n";
196 print
'We now use a relative path to $dolibarr_main_url_root to build alternate URLs.<br>'.
"\n";
197 print
'Value found: '.$value.
'<br>'.
"\n";
198 print
'Should be replaced by: '.$correct_value.
'<br>'.
"\n";
199 print
"Or something like following examples:<br>\n";
200 print
"\"/extensions\"<br>\n";
201 print
"\"/extensions1,/extensions2,...\"<br>\n";
202 print
"\"/../extensions\"<br>\n";
203 print
"\"/custom\"<br>\n";
206 $conf->file->dol_url_root[
'alt'.($i++)] = (
string) $value;
211if (!defined(
'NOREQUIREUSER')) {
212 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
214if (!defined(
'NOREQUIRETRAN')) {
215 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
217if (!defined(
'NOREQUIRESOC')) {
218 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
226if (!defined(
'NOREQUIRETRAN')) {
235if (!defined(
'NOREQUIREDB')) {
242 if (is_object($langs)) {
243 $langs->setDefaultLang(
'auto');
246 if (!defined(
'USEDOLIBARREDITOR') && !defined(
'USEDOLIBARRSERVER') && !empty($_SERVER[
'SCRIPT_FILENAME']) && (strpos($_SERVER[
'SCRIPT_FILENAME'], DOL_DATA_ROOT.
'/website') === 0)) {
247 $sapi_type = php_sapi_name();
248 if (substr($sapi_type, 0, 3) !=
'cgi') {
249 http_response_code(503);
251 print
'<div class="center" style="text-align: center; margin: 100px;">';
252 if (is_object($langs)) {
253 $langs->load(
"website");
254 print $langs->trans(
"SorryWebsiteIsCurrentlyOffLine");
256 print
"SorryWebsiteIsCurrentlyOffLine";
261 dol_print_error($db,
"host=".
$conf->db->host.
", port=".
$conf->db->port.
", user=".
$conf->db->user.
", databasename=".
$conf->db->name.
", ".$db->error);
268unset(
$conf->db->pass);
274if (!defined(
'NOREQUIREUSER')) {
275 $user =
new User($db);
281if (!defined(
'NOHOOKMANAGER')) {
288 require_once DOL_DOCUMENT_ROOT .
'/core/class/extrafields.class.php';
298if (session_id() && !empty($_SESSION[
"dol_entity"])) {
300 $conf->entity = $_SESSION[
"dol_entity"];
301} elseif (!empty($_ENV[
"dol_entity"])) {
303 $conf->entity = $_ENV[
"dol_entity"];
307} elseif (defined(
'DOLENTITY') && is_numeric(constant(
'DOLENTITY'))) {
309 $conf->entity = constant(
'DOLENTITY');
312if (!is_numeric(
$conf->entity)) {
318 $conf->setValues($db);
323if (!defined(
'NOREQUIRETRAN')) {
325 $langcode = (
GETPOST(
'lang',
'aZ09') ?
GETPOST(
'lang',
'aZ09', 1) : ((defined(
'NOLOGIN') && !empty($_SERVER[
'HTTP_ACCEPT_LANGUAGE'])) ?
'auto' :
getDolGlobalString(
'MAIN_LANG_DEFAULT',
'auto')));
326 if (defined(
'MAIN_LANG_DEFAULT')) {
327 $langcode = constant(
'MAIN_LANG_DEFAULT');
329 $langs->setDefaultLang($langcode);
334if (!defined(
'NOREQUIREDB') && !defined(
'NOREQUIRESOC') && $db !=
null) {
335 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
342 if (
$mysoc->country_code ==
'DE' && !isset(
$conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
344 $conf->global->MAIN_INVERT_SENDER_RECIPIENT = 1;
346 if (
$mysoc->country_code ==
'FR' && !isset(
$conf->global->INVOICE_CATEGORY_OF_OPERATION)) {
348 $conf->global->INVOICE_CATEGORY_OF_OPERATION = 1;
350 if (
$mysoc->country_code ==
'FR' && !isset(
$conf->global->INVOICE_DISABLE_REPLACEMENT)) {
354 $conf->global->INVOICE_DISABLE_REPLACEMENT = 1;
356 if (
$mysoc->country_code ==
'GR' && !isset(
$conf->global->INVOICE_DISABLE_REPLACEMENT)) {
358 $conf->global->INVOICE_DISABLE_REPLACEMENT = 1;
360 if (
$mysoc->country_code ==
'GR' && !isset(
$conf->global->INVOICE_DISABLE_DEPOSIT)) {
362 $conf->global->INVOICE_DISABLE_DEPOSIT = 1;
364 if (
$mysoc->country_code ==
'GR' && !isset(
$conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) {
366 $conf->global->INVOICE_CREDIT_NOTE_STANDALONE = 1;
368 if (
$mysoc->country_code ==
'GR' && !isset(
$conf->global->INVOICE_SUBTYPE_ENABLED)) {
370 $conf->global->INVOICE_SUBTYPE_ENABLED = 1;
373 if ((
$mysoc->localtax1_assuj ||
$mysoc->localtax2_assuj) && !isset(
$conf->global->MAIN_NO_INPUT_PRICE_WITH_TAX)) {
376 $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.
getDoliDBInstance($type, $host, $user, $pass, $name, $port, $forcenew=false)
Return a DoliDB instance (database handler).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.