38require_once
'filefunc.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/conf.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
43if (!function_exists(
'is_countable')) {
50 function is_countable($c)
52 return is_array($c) || $c instanceof Countable;
63$conf->db->host = empty($dolibarr_main_db_host) ?
'' : $dolibarr_main_db_host;
64$conf->db->port = empty($dolibarr_main_db_port) ?
'' : $dolibarr_main_db_port;
65$conf->db->name = empty($dolibarr_main_db_name) ?
'' : $dolibarr_main_db_name;
66$conf->db->user = empty($dolibarr_main_db_user) ?
'' : $dolibarr_main_db_user;
67$conf->db->pass = empty($dolibarr_main_db_pass) ?
'' : $dolibarr_main_db_pass;
68$conf->db->type = $dolibarr_main_db_type;
69$conf->db->prefix = $dolibarr_main_db_prefix;
70$conf->db->character_set = $dolibarr_main_db_character_set;
71$conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation;
72$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
73$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
74if (defined(
'TEST_DB_FORCE_TYPE')) {
75 $conf->db->type = constant(
'TEST_DB_FORCE_TYPE');
79$conf->file->main_limit_users = $dolibarr_main_limit_users;
80$conf->file->mailing_limit_sendbyweb = empty($dolibarr_mailing_limit_sendbyweb) ? 0 : $dolibarr_mailing_limit_sendbyweb;
81$conf->file->mailing_limit_sendbycli = empty($dolibarr_mailing_limit_sendbycli) ? 0 : $dolibarr_mailing_limit_sendbycli;
82$conf->file->mailing_limit_sendbyday = empty($dolibarr_mailing_limit_sendbyday) ? 0 : $dolibarr_mailing_limit_sendbyday;
83$conf->file->main_authentication = empty($dolibarr_main_authentication) ?
'dolibarr' : $dolibarr_main_authentication;
84$conf->file->main_force_https = empty($dolibarr_main_force_https) ?
'' : $dolibarr_main_force_https;
85$conf->file->strict_mode = empty($dolibarr_strict_mode) ?
'' : $dolibarr_strict_mode;
86$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;
87$conf->file->dol_main_url_root = $dolibarr_main_url_root;
88$conf->file->dol_document_root = array(
'main' => (
string) DOL_DOCUMENT_ROOT);
89$conf->file->dol_url_root = array(
'main' => (
string) DOL_URL_ROOT);
90if (!empty($dolibarr_main_document_root_alt)) {
92 $values = preg_split(
'/[;,]/', $dolibarr_main_document_root_alt);
94 foreach ($values as $value) {
95 $conf->file->dol_document_root[
'alt'.($i++)] = (
string) $value;
97 $values = preg_split(
'/[;,]/', $dolibarr_main_url_root_alt);
99 foreach ($values as $value) {
100 if (preg_match(
'/^http(s)?:/', $value)) {
102 $correct_value = str_replace($dolibarr_main_url_root,
'', $value);
103 print
'<b>Error:</b><br>'.
"\n";
104 print
'Wrong <b>$dolibarr_main_url_root_alt</b> value in <b>conf.php</b> file.<br>'.
"\n";
105 print
'We now use a relative path to $dolibarr_main_url_root to build alternate URLs.<br>'.
"\n";
106 print
'Value found: '.$value.
'<br>'.
"\n";
107 print
'Should be replaced by: '.$correct_value.
'<br>'.
"\n";
108 print
"Or something like following examples:<br>\n";
109 print
"\"/extensions\"<br>\n";
110 print
"\"/extensions1,/extensions2,...\"<br>\n";
111 print
"\"/../extensions\"<br>\n";
112 print
"\"/custom\"<br>\n";
115 $conf->file->dol_url_root[
'alt'.($i++)] = (
string) $value;
120if (!defined(
'NOREQUIREUSER')) {
121 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
123if (!defined(
'NOREQUIRETRAN')) {
124 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
126if (!defined(
'NOREQUIRESOC')) {
127 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
134if (!defined(
'NOREQUIRETRAN')) {
142if (!defined(
'NOREQUIREDB')) {
143 $db =
getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, (
int) $conf->db->port);
147 if (!defined(
'USEDOLIBARREDITOR') && !defined(
'USEDOLIBARRSERVER') && !empty($_SERVER[
'SCRIPT_FILENAME']) && (strpos($_SERVER[
'SCRIPT_FILENAME'], DOL_DATA_ROOT.
'/website') === 0)) {
148 $sapi_type = php_sapi_name();
149 if (substr($sapi_type, 0, 3) !=
'cgi') {
150 http_response_code(503);
152 print
'<div class="center" style="text-align: center; margin: 100px;">';
153 if (is_object($langs)) {
154 $langs->setDefaultLang(
'auto');
155 $langs->load(
"website");
156 print $langs->trans(
"SorryWebsiteIsCurrentlyOffLine");
158 print
"SorryWebsiteIsCurrentlyOffLine";
163 dol_print_error($db,
"host=".$conf->db->host.
", port=".$conf->db->port.
", user=".$conf->db->user.
", databasename=".$conf->db->name.
", ".$db->error);
170unset($conf->db->pass);
176if (!defined(
'NOREQUIREUSER')) {
177 $user =
new User($db);
191if (session_id() && !empty($_SESSION[
"dol_entity"])) {
193 $conf->entity = $_SESSION[
"dol_entity"];
194} elseif (!empty($_ENV[
"dol_entity"])) {
196 $conf->entity = $_ENV[
"dol_entity"];
197} elseif (GETPOSTISSET(
"loginfunction") && (
GETPOSTINT(
"entity") ||
GETPOSTINT(
"switchentity"))) {
200} elseif (defined(
'DOLENTITY') && is_numeric(constant(
'DOLENTITY'))) {
202 $conf->entity = constant(
'DOLENTITY');
205if (!is_numeric($conf->entity)) {
210$conf->setValues($db);
213if (!defined(
'NOREQUIREDB') && !defined(
'NOREQUIRESOC')) {
214 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
217 $mysoc->setMysoc($conf);
221 if ($mysoc->country_code ==
'DE' && !isset($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
223 $conf->global->MAIN_INVERT_SENDER_RECIPIENT = 1;
225 if ($mysoc->country_code ==
'FR' && !isset($conf->global->INVOICE_CATEGORY_OF_OPERATION)) {
227 $conf->global->INVOICE_CATEGORY_OF_OPERATION = 1;
229 if ($mysoc->country_code ==
'FR' && !isset($conf->global->INVOICE_DISABLE_REPLACEMENT)) {
233 $conf->global->INVOICE_DISABLE_REPLACEMENT = 1;
235 if ($mysoc->country_code ==
'GR' && !isset($conf->global->INVOICE_DISABLE_REPLACEMENT)) {
237 $conf->global->INVOICE_DISABLE_REPLACEMENT = 1;
239 if ($mysoc->country_code ==
'GR' && !isset($conf->global->INVOICE_DISABLE_DEPOSIT)) {
241 $conf->global->INVOICE_DISABLE_DEPOSIT = 1;
243 if ($mysoc->country_code ==
'GR' && !isset($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) {
245 $conf->global->INVOICE_CREDIT_NOTE_STANDALONE = 1;
247 if ($mysoc->country_code ==
'GR' && !isset($conf->global->INVOICE_SUBTYPE_ENABLED)) {
249 $conf->global->INVOICE_SUBTYPE_ENABLED = 1;
252 if (($mysoc->localtax1_assuj || $mysoc->localtax2_assuj) && !isset($conf->global->MAIN_NO_INPUT_PRICE_WITH_TAX)) {
255 $conf->global->MAIN_NO_INPUT_PRICE_WITH_TAX = 1;
261if (!defined(
'NOREQUIRETRAN')) {
263 if (defined(
'MAIN_LANG_DEFAULT')) {
264 $langcode = constant(
'MAIN_LANG_DEFAULT');
266 $langs->setDefaultLang($langcode);
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).