37 require_once
'filefunc.inc.php';
40 if (!function_exists(
'is_countable')) {
46 function is_countable($c)
48 return is_array($c) || $c instanceof Countable;
56 require_once DOL_DOCUMENT_ROOT.
'/core/class/conf.class.php';
61 $conf->db->host = empty($dolibarr_main_db_host) ?
'' : $dolibarr_main_db_host;
62 $conf->db->port = empty($dolibarr_main_db_port) ?
'' : $dolibarr_main_db_port;
63 $conf->db->name = empty($dolibarr_main_db_name) ?
'' : $dolibarr_main_db_name;
64 $conf->db->user = empty($dolibarr_main_db_user) ?
'' : $dolibarr_main_db_user;
65 $conf->db->pass = empty($dolibarr_main_db_pass) ?
'' : $dolibarr_main_db_pass;
66 $conf->db->type = $dolibarr_main_db_type;
67 $conf->db->prefix = $dolibarr_main_db_prefix;
68 $conf->db->character_set = $dolibarr_main_db_character_set;
69 $conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation;
70 $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
71 $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
72 if (defined(
'TEST_DB_FORCE_TYPE')) {
73 $conf->db->type = constant(
'TEST_DB_FORCE_TYPE');
77 $conf->file->main_limit_users = $dolibarr_main_limit_users;
78 $conf->file->mailing_limit_sendbyweb = empty($dolibarr_mailing_limit_sendbyweb) ? 0 : $dolibarr_mailing_limit_sendbyweb;
79 $conf->file->mailing_limit_sendbycli = empty($dolibarr_mailing_limit_sendbycli) ? 0 : $dolibarr_mailing_limit_sendbycli;
80 $conf->file->mailing_limit_sendbyday = empty($dolibarr_mailing_limit_sendbyday) ? 0 : $dolibarr_mailing_limit_sendbyday;
81 $conf->file->main_authentication = empty($dolibarr_main_authentication) ?
'' : $dolibarr_main_authentication;
82 $conf->file->main_force_https = empty($dolibarr_main_force_https) ?
'' : $dolibarr_main_force_https;
83 $conf->file->strict_mode = empty($dolibarr_strict_mode) ?
'' : $dolibarr_strict_mode;
84 $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;
85 $conf->file->dol_document_root = array(
'main' => (
string) DOL_DOCUMENT_ROOT);
86 $conf->file->dol_url_root = array(
'main' => (
string) DOL_URL_ROOT);
87 if (!empty($dolibarr_main_document_root_alt)) {
89 $values = preg_split(
'/[;,]/', $dolibarr_main_document_root_alt);
91 foreach ($values as $value) {
92 $conf->file->dol_document_root[
'alt'.($i++)] = (
string) $value;
94 $values = preg_split(
'/[;,]/', $dolibarr_main_url_root_alt);
96 foreach ($values as $value) {
97 if (preg_match(
'/^http(s)?:/', $value)) {
99 $correct_value = str_replace($dolibarr_main_url_root,
'', $value);
100 print
'<b>Error:</b><br>'.
"\n";
101 print
'Wrong <b>$dolibarr_main_url_root_alt</b> value in <b>conf.php</b> file.<br>'.
"\n";
102 print
'We now use a relative path to $dolibarr_main_url_root to build alternate URLs.<br>'.
"\n";
103 print
'Value found: '.$value.
'<br>'.
"\n";
104 print
'Should be replaced by: '.$correct_value.
'<br>'.
"\n";
105 print
"Or something like following examples:<br>\n";
106 print
"\"/extensions\"<br>\n";
107 print
"\"/extensions1,/extensions2,...\"<br>\n";
108 print
"\"/../extensions\"<br>\n";
109 print
"\"/custom\"<br>\n";
112 $conf->file->dol_url_root[
'alt'.($i++)] = (
string) $value;
117 if (!defined(
'NOREQUIREUSER')) {
118 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
120 if (!defined(
'NOREQUIRETRAN')) {
121 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
123 if (!defined(
'NOREQUIRESOC')) {
124 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
131 if (!defined(
'NOREQUIRETRAN')) {
139 if (!defined(
'NOREQUIREDB')) {
140 $db =
getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
144 if (!defined(
'USEDOLIBARREDITOR') && !defined(
'USEDOLIBARRSERVER') && !empty($_SERVER[
'SCRIPT_FILENAME']) && (strpos($_SERVER[
'SCRIPT_FILENAME'], DOL_DATA_ROOT.
'/website') === 0)) {
145 $sapi_type = php_sapi_name();
146 if (substr($sapi_type, 0, 3) !=
'cgi') {
147 http_response_code(503);
149 print
'<div class="center" style="text-align: center; margin: 100px;">';
150 if (is_object($langs)) {
151 $langs->setDefaultLang(
'auto');
152 $langs->load(
"website");
153 print $langs->trans(
"SorryWebsiteIsCurrentlyOffLine");
155 print
"SorryWebsiteIsCurrentlyOffLine";
160 dol_print_error($db,
"host=".$conf->db->host.
", port=".$conf->db->port.
", user=".$conf->db->user.
", databasename=".$conf->db->name.
", ".$db->error);
167 unset($conf->db->pass);
173 if (!defined(
'NOREQUIREUSER')) {
174 $user =
new User($db);
183 if (session_id() && !empty($_SESSION[
"dol_entity"])) {
185 $conf->entity = $_SESSION[
"dol_entity"];
186 } elseif (!empty($_ENV[
"dol_entity"])) {
188 $conf->entity = $_ENV[
"dol_entity"];
191 $conf->entity =
GETPOST(
"entity",
'int');
192 } elseif (defined(
'DOLENTITY') && is_numeric(constant(
'DOLENTITY'))) {
194 $conf->entity = constant(
'DOLENTITY');
197 if (!is_numeric($conf->entity)) {
202 $conf->setValues($db);
205 if (!defined(
'NOREQUIREDB') && !defined(
'NOREQUIRESOC')) {
206 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
209 $mysoc->setMysoc($conf);
213 if ($mysoc->country_code ==
'DE' && !isset($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
215 $conf->global->MAIN_INVERT_SENDER_RECIPIENT = 1;
217 if ($mysoc->country_code ==
'FR' && !isset($conf->global->MAIN_PROFID1_IN_ADDRESS)) {
219 $conf->global->MAIN_PROFID1_IN_ADDRESS = 1;
221 if ($mysoc->country_code ==
'FR' && !isset($conf->global->INVOICE_CATEGORY_OF_OPERATION)) {
223 $conf->global->INVOICE_CATEGORY_OF_OPERATION = 1;
229 if (!defined(
'NOREQUIRETRAN')) {
230 $langcode = (
GETPOST(
'lang',
'aZ09') ?
GETPOST(
'lang',
'aZ09', 1) : (empty($conf->global->MAIN_LANG_DEFAULT) ?
'auto' : $conf->global->MAIN_LANG_DEFAULT));
231 if (defined(
'MAIN_LANG_DEFAULT')) {
232 $langcode = constant(
'MAIN_LANG_DEFAULT');
234 $langs->setDefaultLang($langcode);
239 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
243 if (!defined(
'MAIN_LABEL_MENTION_NPR')) {
244 define(
'MAIN_LABEL_MENTION_NPR',
'NPR');
Class to stock current configuration.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).