30 if (!defined(
'DOL_INC_FOR_VERSION_ERROR')) define(
'DOL_INC_FOR_VERSION_ERROR',
'1');
31 require_once
'../filefunc.inc.php';
36 if (!defined(
'DOL_DOCUMENT_ROOT')) define(
'DOL_DOCUMENT_ROOT',
'..');
37 if (!defined(
'ADODB_PATH'))
39 $foundpath = DOL_DOCUMENT_ROOT.
'/includes/adodbtime/';
40 if (!is_dir($foundpath)) $foundpath =
'/usr/share/php/adodb/';
41 define(
'ADODB_PATH', $foundpath);
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.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';
48 require_once ADODB_PATH.
'adodb-time.inc.php';
51 $conf =
new stdClass();
52 $conf->global =
new stdClass();
53 $conf->file =
new stdClass();
54 $conf->db =
new stdClass();
55 $conf->syslog =
new stdClass();
58 $_REQUEST[
"logtohtml"] = 1;
68 $includeconferror =
'';
72 $conffiletoshowshort =
"conf.php";
74 $conffile =
"../conf/conf.php";
75 $conffiletoshow =
"htdocs/conf/conf.php";
82 if (!defined(
'DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) > 8)
84 $result = include_once $conffile;
87 if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type =
'mysqli';
90 if ($dolibarr_main_db_type ==
'mysql') {
91 $dolibarr_main_db_type =
'mysqli';
94 if (empty($dolibarr_main_db_port) && ($dolibarr_main_db_type ==
'mysqli')) $dolibarr_main_db_port =
'3306';
97 $dolibarr_main_data_root = isset($dolibarr_main_data_root) ?trim($dolibarr_main_data_root) : DOL_DOCUMENT_ROOT.
'/../documents';
98 $dolibarr_main_url_root = isset($dolibarr_main_url_root) ?trim($dolibarr_main_url_root) :
'';
99 $dolibarr_main_url_root_alt = isset($dolibarr_main_url_root_alt) ?trim($dolibarr_main_url_root_alt) :
'';
100 $dolibarr_main_document_root = isset($dolibarr_main_document_root) ?trim($dolibarr_main_document_root) :
'';
101 $dolibarr_main_document_root_alt = isset($dolibarr_main_document_root_alt) ?trim($dolibarr_main_document_root_alt) :
'';
104 if (!empty($dolibarr_main_document_root) && !preg_match(
'/^[\\/]+$/', $dolibarr_main_document_root)) $dolibarr_main_document_root = preg_replace(
'/[\\/]+$/',
'', $dolibarr_main_document_root);
105 if (!empty($dolibarr_main_url_root) && !preg_match(
'/^[\\/]+$/', $dolibarr_main_url_root)) $dolibarr_main_url_root = preg_replace(
'/[\\/]+$/',
'', $dolibarr_main_url_root);
106 if (!empty($dolibarr_main_data_root) && !preg_match(
'/^[\\/]+$/', $dolibarr_main_data_root)) $dolibarr_main_data_root = preg_replace(
'/[\\/]+$/',
'', $dolibarr_main_data_root);
107 if (!empty($dolibarr_main_document_root_alt) && !preg_match(
'/^[\\/]+$/', $dolibarr_main_document_root_alt)) $dolibarr_main_document_root_alt = preg_replace(
'/[\\/]+$/',
'', $dolibarr_main_document_root_alt);
108 if (!empty($dolibarr_main_url_root_alt) && !preg_match(
'/^[\\/]+$/', $dolibarr_main_url_root_alt)) $dolibarr_main_url_root_alt = preg_replace(
'/[\\/]+$/',
'', $dolibarr_main_url_root_alt);
111 if (!empty($dolibarr_main_document_root))
113 $result =
conf($dolibarr_main_document_root);
118 if (!empty($dolibarr_main_document_root) && !empty($dolibarr_main_db_type))
120 $result = include_once $dolibarr_main_document_root.
"/core/db/".$dolibarr_main_db_type.
'.class.php';
123 $includeconferror =
'ErrorBadValueForDolibarrMainDBType';
127 $includeconferror =
'ErrorBadValueForDolibarrMainDocumentRoot';
130 $includeconferror =
'ErrorBadFormatForConfFile';
133 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
136 if (!isset($dolibarr_main_db_prefix) || !$dolibarr_main_db_prefix) $dolibarr_main_db_prefix =
'llx_';
137 define(
'MAIN_DB_PREFIX', (isset($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix :
''));
139 define(
'DOL_CLASS_PATH',
'class/');
140 define(
'DOL_DATA_ROOT', (isset($dolibarr_main_data_root) ? $dolibarr_main_data_root : DOL_DOCUMENT_ROOT.
'/../documents'));
141 define(
'DOL_MAIN_URL_ROOT', (isset($dolibarr_main_url_root) ? $dolibarr_main_url_root :
''));
142 $uri = preg_replace(
'/^http(s?):\/\//i',
'', constant(
'DOL_MAIN_URL_ROOT'));
143 $suburi = strstr($uri,
'/');
144 if ($suburi ==
'/') $suburi =
'';
145 define(
'DOL_URL_ROOT', $suburi);
148 if (empty($conf->file->character_set_client)) $conf->file->character_set_client =
"utf-8";
149 if (empty($conf->db->character_set)) $conf->db->character_set =
'utf8';
150 if (empty($conf->db->dolibarr_main_db_collation)) $conf->db->dolibarr_main_db_collation =
'utf8_unicode_ci';
151 if (empty($conf->db->dolibarr_main_db_encryption)) $conf->db->dolibarr_main_db_encryption = 0;
152 if (empty($conf->db->dolibarr_main_db_cryptkey)) $conf->db->dolibarr_main_db_cryptkey =
'';
153 if (empty($conf->db->user)) $conf->db->user =
'';
156 $conf->file->dol_document_root = array(DOL_DOCUMENT_ROOT);
157 if (!empty($dolibarr_main_document_root_alt))
160 $values = preg_split(
'/[;,]/', $dolibarr_main_document_root_alt);
161 foreach ($values as $value)
163 $conf->file->dol_document_root[] = $value;
169 if (preg_match(
'/install\.lock/i',
$_SERVER[
"SCRIPT_FILENAME"]))
171 if (!is_object($langs))
174 $langs->setDefaultLang(
'auto');
176 $langs->load(
"install");
177 print $langs->trans(
"YouTryInstallDisabledByDirLock");
178 if (!empty($dolibarr_main_url_root))
180 print 'Click on following link, <a href="'.$dolibarr_main_url_root.
'/admin/index.php?mainmenu=home&leftmenu=setup'.(
GETPOSTISSET(
"login") ?
'&username='.urlencode(
GETPOST(
"login")) :
'').
'">';
181 print $langs->trans(
"ClickHereToGoToApp");
187 $lockfile = DOL_DATA_ROOT.
'/install.lock';
188 if (constant(
'DOL_DATA_ROOT') === null) {
191 $lockfile =
'../../documents/install.lock';
193 if (@file_exists($lockfile))
195 if (!isset($langs) || !is_object($langs))
198 $langs->setDefaultLang(
'auto');
200 $langs->load(
"install");
201 print $langs->trans(
"YouTryInstallDisabledByFileLock");
202 if (!empty($dolibarr_main_url_root))
204 print $langs->trans(
"ClickOnLinkOrRemoveManualy").
'<br>';
205 print '<a href="'.$dolibarr_main_url_root.
'/admin/index.php?mainmenu=home&leftmenu=setup'.(
GETPOSTISSET(
"login") ?
'&username='.urlencode(
GETPOST(
"login")) :
'').
'">';
206 print $langs->trans(
"ClickHereToGoToApp");
209 print 'If you always reach this page, you must remove install.lock file manually.<br>';
216 $conf->syslog->enabled = 1;
217 $conf->global->SYSLOG_LEVEL = constant(
'LOG_DEBUG');
218 if (!defined(
'SYSLOG_HANDLERS')) define(
'SYSLOG_HANDLERS',
'["mod_syslog_file"]');
219 if (!defined(
'SYSLOG_FILE'))
221 if (@is_writable(
'/tmp')) define(
'SYSLOG_FILE',
'/tmp/dolibarr_install.log');
222 elseif (!empty($_ENV[
"TMP"]) && @is_writable($_ENV[
"TMP"])) define('SYSLOG_FILE', $_ENV["TMP"].'/dolibarr_install.log');
223 elseif (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) define('SYSLOG_FILE', $_ENV["TEMP"].'/dolibarr_install.log');
224 elseif (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) define('SYSLOG_FILE', '../../../../dolibarr_install.log');
225 elseif (@is_writable('../../')) define('SYSLOG_FILE', '../../dolibarr_install.log');
228 if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
229 if (!defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR', 1);
232 foreach ($handlers as $handler)
234 $file = DOL_DOCUMENT_ROOT.
'/core/modules/syslog/'.$handler.
'.php';
235 if (!file_exists($file))
237 throw new Exception(
'Missing log handler file '.$handler.
'.php');
241 $loghandlerinstance =
new $handler();
244 throw new Exception(
'Log handler does not extend LogHandlerInterface');
247 if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler] = $loghandlerinstance;
252 if (
GETPOST(
'lang',
'aZ09')) $langs->setDefaultLang(
GETPOST(
'lang',
'aZ09'));
253 else $langs->setDefaultLang(
'auto');
262 function conf($dolibarr_main_document_root)
265 global $dolibarr_main_db_type;
266 global $dolibarr_main_db_host;
267 global $dolibarr_main_db_port;
268 global $dolibarr_main_db_name;
269 global $dolibarr_main_db_user;
270 global $dolibarr_main_db_pass;
271 global $character_set_client;
273 $return = include_once $dolibarr_main_document_root.
'/core/class/conf.class.php';
274 if (!$return)
return -1;
277 $conf->db->type = trim($dolibarr_main_db_type);
278 $conf->db->host = trim($dolibarr_main_db_host);
279 $conf->db->port = trim($dolibarr_main_db_port);
280 $conf->db->name = trim($dolibarr_main_db_name);
281 $conf->db->user = trim($dolibarr_main_db_user);
282 $conf->db->pass = trim($dolibarr_main_db_pass);
285 if ($conf->db->type ==
'mysql') $conf->db->type =
'mysqli';
286 if (empty($character_set_client)) $character_set_client =
"UTF-8";
287 $conf->file->character_set_client = strtoupper($character_set_client);
288 if (empty($dolibarr_main_db_character_set)) $dolibarr_main_db_character_set = ($conf->db->type ==
'mysqli' ?
'utf8' :
'');
289 $conf->db->character_set = $dolibarr_main_db_character_set;
290 if (empty($dolibarr_main_db_collation)) $dolibarr_main_db_collation = ($conf->db->type ==
'mysqli' ?
'utf8_unicode_ci' :
'');
291 $conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation;
292 if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0;
293 $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
294 if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey =
'';
295 $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
298 $conf->syslog->enabled = 1;
299 $conf->global->SYSLOG_LEVEL = constant(
'LOG_DEBUG');
300 if (!defined(
'SYSLOG_HANDLERS')) define(
'SYSLOG_HANDLERS',
'["mod_syslog_file"]');
301 if (!defined(
'SYSLOG_FILE'))
303 if (@is_writable(
'/tmp')) define(
'SYSLOG_FILE',
'/tmp/dolibarr_install.log');
304 elseif (!empty($_ENV[
"TMP"]) && @is_writable($_ENV[
"TMP"])) define(
'SYSLOG_FILE', $_ENV[
"TMP"].
'/dolibarr_install.log');
305 elseif (!empty($_ENV[
"TEMP"]) && @is_writable($_ENV[
"TEMP"])) define(
'SYSLOG_FILE', $_ENV[
"TEMP"].
'/dolibarr_install.log');
306 elseif (@is_writable(
'../../../../') && @file_exists(
'../../../../startdoliwamp.bat')) define(
'SYSLOG_FILE',
'../../../../dolibarr_install.log');
307 elseif (@is_writable(
'../../')) define(
'SYSLOG_FILE',
'../../dolibarr_install.log');
310 if (defined(
'SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
311 if (!defined(
'SYSLOG_FILE_NO_ERROR')) define(
'SYSLOG_FILE_NO_ERROR', 1);
313 $handlers = array(
'mod_syslog_file');
314 foreach ($handlers as $handler)
316 $file = DOL_DOCUMENT_ROOT.
'/core/modules/syslog/'.$handler.
'.php';
317 if (!file_exists($file))
319 throw new Exception(
'Missing log handler file '.$handler.
'.php');
323 $loghandlerinstance =
new $handler();
324 if (!$loghandlerinstance instanceof LogHandlerInterface)
326 throw new Exception(
'Log handler does not extend LogHandlerInterface');
329 if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler] = $loghandlerinstance;
347 function pHeader($subtitle, $next, $action =
'set', $param =
'', $forcejqueryurl =
'', $csstable =
'main-inside')
351 $langs->load(
"main");
352 $langs->load(
"admin");
353 $langs->load(
"install");
355 $jquerytheme =
'base';
359 $jQueryCustomPath = $forcejqueryurl;
360 $jQueryUiCustomPath = $forcejqueryurl;
362 $jQueryCustomPath = (defined(
'JS_JQUERY') && constant(
'JS_JQUERY')) ? JS_JQUERY :
false;
363 $jQueryUiCustomPath = (defined(
'JS_JQUERY_UI') && constant(
'JS_JQUERY_UI')) ? JS_JQUERY_UI :
false;
367 header(
"Content-type: text/html; charset=".$conf->file->character_set_client);
368 header(
"X-Content-Type-Options: nosniff");
370 print '<!DOCTYPE HTML>'.
"\n";
373 print '<meta charset="'.$conf->file->character_set_client.
'">'.
"\n";
374 print '<meta name="viewport" content="width=device-width, initial-scale=1.0">'.
"\n";
375 print '<meta name="generator" content="Dolibarr installer">'.
"\n";
376 print '<link rel="stylesheet" type="text/css" href="default.css">'.
"\n";
378 print '<!-- Includes CSS for JQuery -->'.
"\n";
379 if ($jQueryUiCustomPath)
print '<link rel="stylesheet" type="text/css" href="'.$jQueryUiCustomPath.
'css/'.$jquerytheme.
'/jquery-ui.min.css" />'.
"\n";
380 else print '<link rel="stylesheet" type="text/css" href="../includes/jquery/css/'.$jquerytheme.
'/jquery-ui.min.css" />'.
"\n";
382 print '<!-- Includes JS for JQuery -->'.
"\n";
383 if ($jQueryCustomPath)
print '<script type="text/javascript" src="'.$jQueryCustomPath.
'jquery.min.js"></script>'.
"\n";
384 else print '<script type="text/javascript" src="../includes/jquery/js/jquery.min.js"></script>'.
"\n";
385 if ($jQueryUiCustomPath)
print '<script type="text/javascript" src="'.$jQueryUiCustomPath.
'jquery-ui.min.js"></script>'.
"\n";
386 else print '<script type="text/javascript" src="../includes/jquery/js/jquery-ui.min.js"></script>'.
"\n";
388 print '<title>'.$langs->trans(
"DolibarrSetup").
'</title>'.
"\n";
389 print '</head>'.
"\n";
393 print '<div class="divlogoinstall" style="text-align:center">';
394 print '<img class="imglogoinstall" src="../theme/dolibarr_logo.svg" alt="Dolibarr logo" width="300px"><br>';
398 print '<span class="titre">'.$langs->trans(
"DolibarrSetup");
400 print ' - '.$subtitle;
402 print '</span>'.
"\n";
404 print '<form name="forminstall" style="width: 100%" action="'.$next.
'.php'.($param ?
'?'.$param :
'').
'" method="POST"';
405 if ($next ==
'step5')
print ' autocomplete="off"';
407 print '<input type="hidden" name="testpost" value="ok">'.
"\n";
408 print '<input type="hidden" name="action" value="'.$action.
'">'.
"\n";
410 print '<table class="main" width="100%"><tr><td>'.
"\n";
412 print '<table class="'.$csstable.
'" width="100%"><tr><td>'.
"\n";
424 function pFooter($nonext = 0, $setuplang =
'', $jscheckfunction =
'', $withpleasewait = 0)
426 global $conf, $langs;
428 $langs->loadLangs(array(
"main",
"other",
"admin"));
430 print '</td></tr></table>'.
"\n";
431 print '</td></tr></table>'.
"\n";
433 if (!$nonext || ($nonext ==
'2'))
435 print '<div class="nextbutton" id="nextbutton">';
438 print '<span class="warning">';
439 print $langs->trans(
"ErrorFoundDuringMigration", isset(
$_SERVER[
"REQUEST_URI"]) ?
$_SERVER[
"REQUEST_URI"].
'&ignoreerrors=1' :
'');
444 print '<input type="submit" '.($nonext ==
'2' ?
'disabled="disabled" ' :
'').
'value="'.$langs->trans(
"NextStep").
' ->"';
445 if ($jscheckfunction)
print ' onClick="return '.$jscheckfunction.
'();"';
447 if ($withpleasewait)
print '<div style="visibility: hidden;" class="pleasewait" id="pleasewait"><br>'.$langs->trans(
"NextStepMightLastALongTime").
'<br><br><div class="blinkwait">'.$langs->trans(
"PleaseBePatient").
'</div></div>';
451 print '<input type="hidden" name="selectlang" value="'.$setuplang.
'">';
454 print '</form>'.
"\n";
457 if (isset($conf->logbuffer) && count($conf->logbuffer))
460 print "<!-- Start of log output\n";
462 foreach ($conf->logbuffer as $logline)
464 print $logline.
"<br>\n";
467 print "End of log output -->\n";
471 print '</body>'.
"\n";
472 print '</html>'.
"\n";
484 if (!defined(
'LOG_DEBUG')) define(
'LOG_DEBUG', 6);
497 if (
$_SERVER[
"SCRIPT_FILENAME"] ==
'php' || preg_match(
'/[\\/]php$/i',
$_SERVER[
"SCRIPT_FILENAME"]) || preg_match(
'/php\.exe$/i',
$_SERVER[
"SCRIPT_FILENAME"]))
499 $dolibarr_main_document_root =
$_SERVER[
"DOCUMENT_ROOT"];
501 if (!preg_match(
'/[\\/]dolibarr[\\/]htdocs$/i', $dolibarr_main_document_root)) {
502 $dolibarr_main_document_root .=
"/dolibarr/htdocs";
506 $dolibarr_main_document_root = dirname(dirname(
$_SERVER[
"SCRIPT_FILENAME"]));
509 return $dolibarr_main_document_root;
520 $dolibarr_main_data_root = preg_replace(
"/\/htdocs$/",
"", $dolibarr_main_document_root);
521 $dolibarr_main_data_root .=
"/documents";
522 return $dolibarr_main_data_root;
533 if (isset(
$_SERVER[
"SCRIPT_URI"])) {
534 $dolibarr_main_url_root =
$_SERVER[
"SCRIPT_URI"];
537 $dolibarr_main_url_root =
$_SERVER[
"SERVER_URL"].$_SERVER[
"DOCUMENT_URI"];
540 $proto = ((!empty(
$_SERVER[
"HTTPS"]) &&
$_SERVER[
"HTTPS"] ==
'on') || (!empty(
$_SERVER[
'SERVER_PORT']) &&
$_SERVER[
'SERVER_PORT'] == 443)) ?
'https' :
'http';
541 if (!empty(
$_SERVER[
"HTTP_HOST"])) {
542 $serverport =
$_SERVER[
"HTTP_HOST"];
543 } elseif (!empty(
$_SERVER[
"SERVER_NAME"])) {
544 $serverport =
$_SERVER[
"SERVER_NAME"];
546 $serverport =
'localhost';
548 $dolibarr_main_url_root = $proto.
"://".$serverport.$_SERVER[
"SCRIPT_NAME"];
552 $dolibarr_main_url_root = dirname(dirname($dolibarr_main_url_root));
554 return $dolibarr_main_url_root;
565 return preg_replace(
'/__SUPERUSERLOGIN__/',
'root', $force_install_databaserootlogin);
576 return preg_replace(
'/__SUPERUSERPASSWORD__/',
'', $force_install_databaserootpass);
detect_dolibarr_main_document_root()
Automatically detect Dolibarr's main document root.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
pHeader($subtitle, $next, $action= 'set', $param= '', $forcejqueryurl= '', $csstable= 'main-inside')
Show HTML header of install pages.
Class to stock current configuration.
conf($dolibarr_main_document_root)
Load conf file (file must exists)
parse_database_login($force_install_databaserootlogin)
Replaces automatic database login by actual value.
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage logging to a file.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
parse_database_pass($force_install_databaserootpass)
Replaces automatic database password by actual value.
detect_dolibarr_main_url_root()
Automatically detect Dolibarr's main URL root.
Class to manage translations.
print $_SERVER["PHP_SELF"]
Edit parameters.
detect_dolibarr_main_data_root($dolibarr_main_document_root)
Automatically detect Dolibarr's main data root.
pFooter($nonext=0, $setuplang= '', $jscheckfunction= '', $withpleasewait=0)
Print HTML footer of install pages.
print
Draft customers invoices.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.