31 if (!defined(
'DOL_INC_FOR_VERSION_ERROR')) {
32 define(
'DOL_INC_FOR_VERSION_ERROR',
'1');
34 require_once
'../filefunc.inc.php';
39 if (!defined(
'DOL_DOCUMENT_ROOT')) {
40 define(
'DOL_DOCUMENT_ROOT',
'..');
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/conf.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
52 $_REQUEST[
"logtohtml"] = 1;
56 if (isset($_SERVER[
"DOCUMENT_URI"]) && $_SERVER[
"DOCUMENT_URI"]) {
57 $_SERVER[
"PHP_SELF"] = $_SERVER[
"DOCUMENT_URI"];
61 $includeconferror =
'';
65 $conffiletoshowshort =
"conf.php";
67 $conffile =
"../conf/conf.php";
68 $conffiletoshow =
"htdocs/conf/conf.php";
75 if (!defined(
'DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) > 8) {
76 $result = include_once $conffile;
78 if (empty($dolibarr_main_db_type)) {
79 $dolibarr_main_db_type =
'mysqli';
83 if ($dolibarr_main_db_type ==
'mysql') {
84 $dolibarr_main_db_type =
'mysqli';
87 if (empty($dolibarr_main_db_port) && ($dolibarr_main_db_type ==
'mysqli')) {
88 $dolibarr_main_db_port =
'3306';
92 $dolibarr_main_data_root = isset($dolibarr_main_data_root) ?trim($dolibarr_main_data_root) : DOL_DOCUMENT_ROOT.
'/../documents';
93 $dolibarr_main_url_root = isset($dolibarr_main_url_root) ?trim($dolibarr_main_url_root) :
'';
94 $dolibarr_main_url_root_alt = isset($dolibarr_main_url_root_alt) ?trim($dolibarr_main_url_root_alt) :
'';
95 $dolibarr_main_document_root = isset($dolibarr_main_document_root) ?trim($dolibarr_main_document_root) :
'';
96 $dolibarr_main_document_root_alt = isset($dolibarr_main_document_root_alt) ?trim($dolibarr_main_document_root_alt) :
'';
99 if (!empty($dolibarr_main_document_root) && !preg_match(
'/^[\\/]+$/', $dolibarr_main_document_root)) {
100 $dolibarr_main_document_root = preg_replace(
'/[\\/]+$/',
'', $dolibarr_main_document_root);
102 if (!empty($dolibarr_main_url_root) && !preg_match(
'/^[\\/]+$/', $dolibarr_main_url_root)) {
103 $dolibarr_main_url_root = preg_replace(
'/[\\/]+$/',
'', $dolibarr_main_url_root);
105 if (!empty($dolibarr_main_data_root) && !preg_match(
'/^[\\/]+$/', $dolibarr_main_data_root)) {
106 $dolibarr_main_data_root = preg_replace(
'/[\\/]+$/',
'', $dolibarr_main_data_root);
108 if (!empty($dolibarr_main_document_root_alt) && !preg_match(
'/^[\\/]+$/', $dolibarr_main_document_root_alt)) {
109 $dolibarr_main_document_root_alt = preg_replace(
'/[\\/]+$/',
'', $dolibarr_main_document_root_alt);
111 if (!empty($dolibarr_main_url_root_alt) && !preg_match(
'/^[\\/]+$/', $dolibarr_main_url_root_alt)) {
112 $dolibarr_main_url_root_alt = preg_replace(
'/[\\/]+$/',
'', $dolibarr_main_url_root_alt);
116 if (!empty($dolibarr_main_document_root)) {
117 $result =
conf($dolibarr_main_document_root);
121 if (!empty($dolibarr_main_document_root) && !empty($dolibarr_main_db_type)) {
122 $result = include_once $dolibarr_main_document_root.
"/core/db/".$dolibarr_main_db_type.
'.class.php';
124 $includeconferror =
'ErrorBadValueForDolibarrMainDBType';
128 $includeconferror =
'ErrorBadValueForDolibarrMainDocumentRoot';
131 $includeconferror =
'ErrorBadFormatForConfFile';
134 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
137 if (!isset($dolibarr_main_db_prefix) || !$dolibarr_main_db_prefix) {
138 $dolibarr_main_db_prefix =
'llx_';
140 define(
'MAIN_DB_PREFIX', (isset($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix :
''));
142 define(
'DOL_CLASS_PATH',
'class/');
143 define(
'DOL_DATA_ROOT', (isset($dolibarr_main_data_root) ? $dolibarr_main_data_root : DOL_DOCUMENT_ROOT.
'/../documents'));
144 define(
'DOL_MAIN_URL_ROOT', (isset($dolibarr_main_url_root) ? $dolibarr_main_url_root :
''));
145 $uri = preg_replace(
'/^http(s?):\/\//i',
'', constant(
'DOL_MAIN_URL_ROOT'));
146 $suburi = strstr($uri,
'/');
147 if ($suburi ==
'/') {
150 define(
'DOL_URL_ROOT', $suburi);
153 if (empty($conf->file->character_set_client)) {
154 $conf->file->character_set_client =
"utf-8";
156 if (empty($conf->db->character_set)) {
157 $conf->db->character_set =
'utf8';
159 if (empty($conf->db->dolibarr_main_db_collation)) {
160 $conf->db->dolibarr_main_db_collation =
'utf8_unicode_ci';
162 if (empty($conf->db->dolibarr_main_db_encryption)) {
163 $conf->db->dolibarr_main_db_encryption = 0;
165 if (empty($conf->db->dolibarr_main_db_cryptkey)) {
166 $conf->db->dolibarr_main_db_cryptkey =
'';
168 if (empty($conf->db->user)) {
169 $conf->db->user =
'';
173 $conf->file->dol_document_root = array(DOL_DOCUMENT_ROOT);
174 if (!empty($dolibarr_main_document_root_alt)) {
176 $values = preg_split(
'/[;,]/', $dolibarr_main_document_root_alt);
177 foreach ($values as $value) {
178 $conf->file->dol_document_root[] = $value;
184 if (preg_match(
'/install\.lock/i', $_SERVER[
"SCRIPT_FILENAME"])) {
185 if (!is_object($langs)) {
187 $langs->setDefaultLang(
'auto');
189 $langs->load(
"install");
191 header(
"X-Content-Type-Options: nosniff");
192 header(
"X-Frame-Options: SAMEORIGIN");
194 print $langs->trans(
"YouTryInstallDisabledByDirLock");
195 if (!empty($dolibarr_main_url_root)) {
196 print
'Click on following link, <a href="'.$dolibarr_main_url_root.
'/admin/index.php?mainmenu=home&leftmenu=setup'.(
GETPOSTISSET(
"login") ?
'&username='.urlencode(
GETPOST(
"login")) :
'').
'">';
197 print $langs->trans(
"ClickHereToGoToApp");
203 $lockfile = DOL_DATA_ROOT.
'/install.lock';
204 if (constant(
'DOL_DATA_ROOT') ===
null) {
207 $lockfile =
'../../documents/install.lock';
209 if (@file_exists($lockfile)) {
210 if (!isset($langs) || !is_object($langs)) {
212 $langs->setDefaultLang(
'auto');
214 $langs->load(
"install");
216 header(
"X-Content-Type-Options: nosniff");
217 header(
"X-Frame-Options: SAMEORIGIN");
219 print $langs->trans(
"YouTryInstallDisabledByFileLock");
220 if (!empty($dolibarr_main_url_root)) {
221 print $langs->trans(
"ClickOnLinkOrRemoveManualy").
'<br>';
222 print
'<a href="'.$dolibarr_main_url_root.
'/admin/index.php?mainmenu=home&leftmenu=setup'.(
GETPOSTISSET(
"login") ?
'&username='.urlencode(
GETPOST(
"login")) :
'').
'">';
223 print $langs->trans(
"ClickHereToGoToApp");
226 print
'If you always reach this page, you must remove install.lock file manually.<br>';
233 $conf->syslog->enabled = 1;
234 $conf->global->SYSLOG_LEVEL = constant(
'LOG_DEBUG');
235 if (!defined(
'SYSLOG_HANDLERS')) {
236 define(
'SYSLOG_HANDLERS',
'["mod_syslog_file"]');
238 if (!defined(
'SYSLOG_FILE')) {
239 if (@is_writable(
'/tmp')) {
240 define(
'SYSLOG_FILE',
'/tmp/dolibarr_install.log');
241 } elseif (!empty($_ENV[
"TMP"]) && @is_writable($_ENV[
"TMP"])) {
242 define(
'SYSLOG_FILE', $_ENV[
"TMP"].
'/dolibarr_install.log');
243 } elseif (!empty($_ENV[
"TEMP"]) && @is_writable($_ENV[
"TEMP"])) {
244 define(
'SYSLOG_FILE', $_ENV[
"TEMP"].
'/dolibarr_install.log');
245 } elseif (@is_writable(
'../../../../') && @file_exists(
'../../../../startdoliwamp.bat')) {
246 define(
'SYSLOG_FILE',
'../../../../dolibarr_install.log');
247 } elseif (@is_writable(
'../../')) {
248 define(
'SYSLOG_FILE',
'../../dolibarr_install.log');
252 if (defined(
'SYSLOG_FILE')) {
253 $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
255 if (!defined(
'SYSLOG_FILE_NO_ERROR')) {
256 define(
'SYSLOG_FILE_NO_ERROR', 1);
259 $handlers = array(
'mod_syslog_file');
260 foreach ($handlers as $handler) {
261 $file = DOL_DOCUMENT_ROOT.
'/core/modules/syslog/'.$handler.
'.php';
262 if (!file_exists($file)) {
263 throw new Exception(
'Missing log handler file '.$handler.
'.php');
267 $loghandlerinstance =
new $handler();
269 throw new Exception(
'Log handler does not extend LogHandlerInterface');
272 if (empty($conf->loghandlers[$handler])) {
273 $conf->loghandlers[$handler] = $loghandlerinstance;
280 $langs->setDefaultLang(
GETPOST(
'lang',
'aZ09'));
282 $langs->setDefaultLang(
'auto');
292 function conf($dolibarr_main_document_root)
295 global $dolibarr_main_db_type;
296 global $dolibarr_main_db_host;
297 global $dolibarr_main_db_port;
298 global $dolibarr_main_db_name;
299 global $dolibarr_main_db_user;
300 global $dolibarr_main_db_pass;
301 global $character_set_client;
303 $return = include_once $dolibarr_main_document_root.
'/core/class/conf.class.php';
309 $conf->db->type = trim($dolibarr_main_db_type);
310 $conf->db->host = trim($dolibarr_main_db_host);
311 $conf->db->port = trim($dolibarr_main_db_port);
312 $conf->db->name = trim($dolibarr_main_db_name);
313 $conf->db->user = trim($dolibarr_main_db_user);
314 $conf->db->pass = (empty($dolibarr_main_db_pass) ?
'' : trim($dolibarr_main_db_pass));
317 if ($conf->db->type ==
'mysql') {
318 $conf->db->type =
'mysqli';
320 if (empty($character_set_client)) {
321 $character_set_client =
"UTF-8";
323 $conf->file->character_set_client = strtoupper($character_set_client);
324 if (empty($dolibarr_main_db_character_set)) {
325 $dolibarr_main_db_character_set = ($conf->db->type ==
'mysqli' ?
'utf8' :
'');
327 $conf->db->character_set = $dolibarr_main_db_character_set;
328 if (empty($dolibarr_main_db_collation)) {
329 $dolibarr_main_db_collation = ($conf->db->type ==
'mysqli' ?
'utf8_unicode_ci' :
'');
331 $conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation;
332 if (empty($dolibarr_main_db_encryption)) {
333 $dolibarr_main_db_encryption = 0;
335 $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
336 if (empty($dolibarr_main_db_cryptkey)) {
337 $dolibarr_main_db_cryptkey =
'';
339 $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
342 $conf->syslog->enabled = 1;
343 $conf->global->SYSLOG_LEVEL = constant(
'LOG_DEBUG');
344 if (!defined(
'SYSLOG_HANDLERS')) {
345 define(
'SYSLOG_HANDLERS',
'["mod_syslog_file"]');
347 if (!defined(
'SYSLOG_FILE')) {
348 if (@is_writable(
'/tmp')) {
349 define(
'SYSLOG_FILE',
'/tmp/dolibarr_install.log');
350 } elseif (!empty($_ENV[
"TMP"]) && @is_writable($_ENV[
"TMP"])) {
351 define(
'SYSLOG_FILE', $_ENV[
"TMP"].
'/dolibarr_install.log');
352 } elseif (!empty($_ENV[
"TEMP"]) && @is_writable($_ENV[
"TEMP"])) {
353 define(
'SYSLOG_FILE', $_ENV[
"TEMP"].
'/dolibarr_install.log');
354 } elseif (@is_writable(
'../../../../') && @file_exists(
'../../../../startdoliwamp.bat')) {
355 define(
'SYSLOG_FILE',
'../../../../dolibarr_install.log');
356 } elseif (@is_writable(
'../../')) {
357 define(
'SYSLOG_FILE',
'../../dolibarr_install.log');
361 if (defined(
'SYSLOG_FILE')) {
362 $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
364 if (!defined(
'SYSLOG_FILE_NO_ERROR')) {
365 define(
'SYSLOG_FILE_NO_ERROR', 1);
368 $handlers = array(
'mod_syslog_file');
369 foreach ($handlers as $handler) {
370 $file = DOL_DOCUMENT_ROOT.
'/core/modules/syslog/'.$handler.
'.php';
371 if (!file_exists($file)) {
372 throw new Exception(
'Missing log handler file '.$handler.
'.php');
376 $loghandlerinstance =
new $handler();
378 throw new Exception(
'Log handler does not extend LogHandlerInterface');
381 if (empty($conf->loghandlers[$handler])) {
382 $conf->loghandlers[$handler] = $loghandlerinstance;
401 function pHeader($subtitle, $next, $action =
'set', $param =
'', $forcejqueryurl =
'', $csstable =
'main-inside')
405 $langs->load(
"main");
406 $langs->load(
"admin");
407 $langs->load(
"install");
409 $jquerytheme =
'base';
411 if ($forcejqueryurl) {
412 $jQueryCustomPath = $forcejqueryurl;
413 $jQueryUiCustomPath = $forcejqueryurl;
415 $jQueryCustomPath = (defined(
'JS_JQUERY') && constant(
'JS_JQUERY')) ? JS_JQUERY :
false;
416 $jQueryUiCustomPath = (defined(
'JS_JQUERY_UI') && constant(
'JS_JQUERY_UI')) ? JS_JQUERY_UI :
false;
420 header(
"Content-type: text/html; charset=".$conf->file->character_set_client);
421 header(
"X-Content-Type-Options: nosniff");
422 header(
"X-Frame-Options: SAMEORIGIN");
424 print
'<!DOCTYPE HTML>'.
"\n";
427 print
'<meta charset="'.$conf->file->character_set_client.
'">'.
"\n";
428 print
'<meta name="viewport" content="width=device-width, initial-scale=1.0">'.
"\n";
429 print
'<meta name="generator" content="Dolibarr installer">'.
"\n";
430 print
'<link rel="stylesheet" type="text/css" href="default.css">'.
"\n";
432 print
'<!-- Includes CSS for JQuery -->'.
"\n";
433 if ($jQueryUiCustomPath) {
434 print
'<link rel="stylesheet" type="text/css" href="'.$jQueryUiCustomPath.
'css/'.$jquerytheme.
'/jquery-ui.min.css" />'.
"\n";
436 print
'<link rel="stylesheet" type="text/css" href="../includes/jquery/css/'.$jquerytheme.
'/jquery-ui.min.css" />'.
"\n";
439 print
'<!-- Includes JS for JQuery -->'.
"\n";
440 if ($jQueryCustomPath) {
441 print
'<script type="text/javascript" src="'.$jQueryCustomPath.
'jquery.min.js"></script>'.
"\n";
443 print
'<script type="text/javascript" src="../includes/jquery/js/jquery.min.js"></script>'.
"\n";
445 if ($jQueryUiCustomPath) {
446 print
'<script type="text/javascript" src="'.$jQueryUiCustomPath.
'jquery-ui.min.js"></script>'.
"\n";
448 print
'<script type="text/javascript" src="../includes/jquery/js/jquery-ui.min.js"></script>'.
"\n";
451 print
'<title>'.$langs->trans(
"DolibarrSetup").
'</title>'.
"\n";
452 print
'</head>'.
"\n";
456 print
'<div class="divlogoinstall" style="text-align:center">';
457 print
'<img class="imglogoinstall" src="../theme/dolibarr_logo.svg" alt="Dolibarr logo" width="300px"><br>';
461 print
'<span class="titre">'.$langs->trans(
"DolibarrSetup");
463 print
' - '.$subtitle;
465 print
'</span>'.
"\n";
467 print
'<form name="forminstall" style="width: 100%" action="'.$next.
'.php'.($param ?
'?'.$param :
'').
'" method="POST"';
468 if ($next ==
'step5') {
469 print
' autocomplete="off"';
472 print
'<input type="hidden" name="testpost" value="ok">'.
"\n";
473 print
'<input type="hidden" name="action" value="'.$action.
'">'.
"\n";
475 print
'<table class="main" width="100%"><tr><td>'.
"\n";
477 print
'<table class="'.$csstable.
'" width="100%"><tr><td>'.
"\n";
490 function pFooter($nonext = 0, $setuplang =
'', $jscheckfunction =
'', $withpleasewait = 0, $morehtml =
'')
492 global $conf, $langs;
494 $langs->loadLangs(array(
"main",
"other",
"admin"));
496 print
'</td></tr></table>'.
"\n";
497 print
'</td></tr></table>'.
"\n";
499 print
'<!-- pFooter -->'.
"\n";
503 if (!$nonext || ($nonext ==
'2')) {
504 print
'<div class="nextbutton" id="nextbutton">';
505 if ($nonext ==
'2') {
506 print
'<span class="warning">';
507 print $langs->trans(
"ErrorFoundDuringMigration", isset($_SERVER[
"REQUEST_URI"]) ? $_SERVER[
"REQUEST_URI"].
'&ignoreerrors=1' :
'');
512 print
'<input type="submit" '.($nonext ==
'2' ?
'disabled="disabled" ' :
'').
'value="'.$langs->trans(
"NextStep").
' ->"';
513 if ($jscheckfunction) {
514 print
' onClick="return '.$jscheckfunction.
'();"';
517 if ($withpleasewait) {
518 print
'<div style="visibility: hidden;" class="pleasewait" id="pleasewait"><br>'.$langs->trans(
"NextStepMightLastALongTime").
'<br><br><div class="blinkwait">'.$langs->trans(
"PleaseBePatient").
'</div></div>';
522 print
'<input type="hidden" name="selectlang" value="'.dol_escape_htmltag($setuplang).
'">';
525 print
'</form><br>'.
"\n";
528 if (isset($conf->logbuffer) && count($conf->logbuffer)) {
530 print
"<!-- Start of log output\n";
532 foreach ($conf->logbuffer as $logline) {
533 print $logline.
"<br>\n";
536 print
"End of log output -->\n";
540 print
'</body>'.
"\n";
541 print
'</html>'.
"\n";
553 if (!defined(
'LOG_DEBUG')) {
554 define(
'LOG_DEBUG', 6);
568 if ($_SERVER[
"SCRIPT_FILENAME"] ==
'php' || preg_match(
'/[\\/]php$/i', $_SERVER[
"SCRIPT_FILENAME"]) || preg_match(
'/php\.exe$/i', $_SERVER[
"SCRIPT_FILENAME"])) {
569 $dolibarr_main_document_root = $_SERVER[
"DOCUMENT_ROOT"];
571 if (!preg_match(
'/[\\/]dolibarr[\\/]htdocs$/i', $dolibarr_main_document_root)) {
572 $dolibarr_main_document_root .=
"/dolibarr/htdocs";
576 $dolibarr_main_document_root = dirname(dirname($_SERVER[
"SCRIPT_FILENAME"]));
579 return $dolibarr_main_document_root;
590 $dolibarr_main_data_root = preg_replace(
"/\/htdocs$/",
"", $dolibarr_main_document_root);
591 $dolibarr_main_data_root .=
"/documents";
592 return $dolibarr_main_data_root;
603 if (isset($_SERVER[
"SCRIPT_URI"])) {
604 $dolibarr_main_url_root = $_SERVER[
"SCRIPT_URI"];
605 } elseif (isset($_SERVER[
"SERVER_URL"]) && isset($_SERVER[
"DOCUMENT_URI"])) {
607 $dolibarr_main_url_root = $_SERVER[
"SERVER_URL"].$_SERVER[
"DOCUMENT_URI"];
610 $proto = ((!empty($_SERVER[
"HTTPS"]) && $_SERVER[
"HTTPS"] ==
'on') || (!empty($_SERVER[
'SERVER_PORT']) && $_SERVER[
'SERVER_PORT'] == 443)) ?
'https' :
'http';
611 if (!empty($_SERVER[
"HTTP_HOST"])) {
612 $serverport = $_SERVER[
"HTTP_HOST"];
613 } elseif (!empty($_SERVER[
"SERVER_NAME"])) {
614 $serverport = $_SERVER[
"SERVER_NAME"];
616 $serverport =
'localhost';
618 $dolibarr_main_url_root = $proto.
"://".$serverport.$_SERVER[
"SCRIPT_NAME"];
622 $dolibarr_main_url_root = dirname(dirname($dolibarr_main_url_root));
624 return $dolibarr_main_url_root;
635 return preg_replace(
'/__SUPERUSERLOGIN__/',
'root', $force_install_databaserootlogin);
646 return preg_replace(
'/__SUPERUSERPASSWORD__/',
'', $force_install_databaserootpass);
Class to stock current configuration.
Class to manage translations.
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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
conf($dolibarr_main_document_root)
Load conf file (file must exists)
pHeader($subtitle, $next, $action='set', $param='', $forcejqueryurl='', $csstable='main-inside')
Show HTML header of install pages.
detect_dolibarr_main_data_root($dolibarr_main_document_root)
Automatically detect Dolibarr's main data root.
pFooter($nonext=0, $setuplang='', $jscheckfunction='', $withpleasewait=0, $morehtml='')
Print HTML footer of install pages.
parse_database_login($force_install_databaserootlogin)
Replaces automatic database login by actual value.
parse_database_pass($force_install_databaserootpass)
Replaces automatic database password by actual value.
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
detect_dolibarr_main_url_root()
Automatically detect Dolibarr's main URL root.
detect_dolibarr_main_document_root()
Automatically detect Dolibarr's main document root.