33include_once
'inc.php';
47@phan-var-force string $dolibarr_main_db_host
48@phan-var-force string $dolibarr_main_db_port
49@phan-var-force string $dolibarr_main_db_name
50@phan-var-force string $dolibarr_main_db_user
51@phan-var-force string $dolibarr_main_db_pass
52@phan-var-force string $dolibarr_main_db_encrypted_pass
53@phan-var-force string $conffile
54@phan-var-force string $conffiletoshow
55@phan-var-force ?bool $force_install_
56@phan-var-force ?string $force_install_packager
57@phan-var-force ?string $force_install_message
58@phan-var-force ?string $force_install_main_data_root
59@phan-var-force ?int<0,2> $force_install_noedit
60@phan-var-force ?string $force_install_type
61@phan-var-force ?string $force_install_dbserver
62@phan-var-force ?string $force_install_port
63@phan-var-force ?string $force_install_database
64@phan-var-force ?string $force_install_prefix
65@phan-var-force ?string $force_install_createdatabase
66@phan-var-force ?string $force_install_databaselogin
67@phan-var-force ?string $force_install_databasepass
68@phan-var-force ?string $force_install_databaserootlogin
69@phan-var-force ?string $force_install_databaserootpass
70@phan-var-force ?string $force_install_dolibarrlogin
71@phan-var-force ?string $force_install_nophpinfo
72@phan-var-force ?string $force_install_lockinstall
73@phan-var-force ?string $force_install_distrib
74@phan-var-force ?string $db_user_root
75@phan-var-force ?string $db_pass_root
80$setuplang =
GETPOST(
"selectlang",
'alpha', 3) ?
GETPOST(
"selectlang",
'alpha', 3) : (
GETPOST(
'lang',
'alpha', 1) ?
GETPOST(
'lang',
'alpha', 1) :
'auto');
81$langs->setDefaultLang($setuplang);
83$langs->loadLangs(array(
"install",
"errors",
"admin"));
91if (!isset($force_install_noedit)) {
92 $force_install_noedit =
'';
94if (!isset($force_install_type)) {
95 $force_install_type =
'';
97if (!isset($force_install_dbserver)) {
98 $force_install_dbserver =
'';
100if (!isset($force_install_port)) {
101 $force_install_port =
'';
103if (!isset($force_install_database)) {
104 $force_install_database =
'';
106if (!isset($force_install_prefix)) {
107 $force_install_prefix =
'';
109if (!isset($force_install_createdatabase)) {
110 $force_install_createdatabase =
'';
112if (!isset($force_install_databaselogin)) {
113 $force_install_databaselogin =
'';
115if (!isset($force_install_databasepass)) {
116 $force_install_databasepass =
'';
118if (!isset($force_install_databaserootlogin)) {
119 $force_install_databaserootlogin =
'';
121if (!isset($force_install_databaserootpass)) {
122 $force_install_databaserootpass =
'';
125$useforcedwizard =
false;
126$forcedfile =
"./install.forced.php";
127if ($conffile ==
"/etc/dolibarr/conf.php") {
128 $forcedfile =
"/etc/dolibarr/install.forced.php";
130if (@file_exists($forcedfile)) {
131 $useforcedwizard =
true;
132 include_once $forcedfile;
143pHeader($langs->trans(
"DolibarrSetup").
' - '.$langs->trans(
"ConfigurationFile"),
"step1",
"set",
"", (empty($force_dolibarr_js_JQUERY) ?
'' : $force_dolibarr_js_JQUERY.
'/'),
'main-inside-bis');
146if (!is_writable($conffile)) {
147 print $langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
150 pFooter(1, $setuplang,
'jscheckparam');
154if (!empty($force_install_message)) {
155 print
'<div><br>'.$langs->trans($force_install_message).
'</div>';
175<
table class=
"nobordernopadding<?php if ($force_install_noedit) {
176 print ' hidewhennoedit';
180 <td colspan=
"3" class=
"label">
181 <h3><img
class=
"valignmiddle inline-block paddingright" src=
"../theme/common/octicons/build/svg/globe.svg" width=
"20" alt=
"webserver"> <?php echo $langs->trans(
"WebServer"); ?></h3>
185 <!--
Documents root $dolibarr_main_document_root -->
187 <td
class=
"label"><label
for=
"main_dir"><b><?php print $langs->trans(
"WebPagesDirectory"); ?></b></label></td>
189if (empty($dolibarr_main_document_root)) {
194 <input
type=
"text" class=
"minwidth300" id=
"main_dir"
196 value=
"<?php print $dolibarr_main_document_root ?>"
198if (!empty($force_install_noedit)) {
204 <td
class=
"comment"><?php
205 print
'<span class="opacitymedium">'.$langs->trans(
"WithNoSlashAtTheEnd").
"</span><br>";
206 print $langs->trans(
"Examples").
":<br>";
209 <li>/var/www/dolibarr/htdocs</li>
210 <li>C:/wwwroot/dolibarr/htdocs</li>
215 <!--
Documents URL $dolibarr_main_data_root -->
217 <td
class=
"label"><label
for=
"main_data_dir"><b><?php print $langs->trans(
"DocumentsDirectory"); ?></b></label></td>
219 if (!empty($force_install_main_data_root)) {
220 $dolibarr_main_data_root = @$force_install_main_data_root;
222 if (empty($dolibarr_main_data_root)) {
231 value=
"<?php print $dolibarr_main_data_root ?>"
232<?php
if (!empty($force_install_noedit)) {
237 <td
class=
"comment"><?php
238 print
'<span class="opacitymedium">'.$langs->trans(
"WithNoSlashAtTheEnd").
"</span><br>";
239 print $langs->trans(
"DirectoryRecommendation").
"<br>";
240 print $langs->trans(
"Examples").
":<br>";
243 <li>/var/lib/dolibarr/documents</li>
244 <li>C:/My
Documents/dolibarr/documents</li>
256 <td
class=
"label"><label
for=
"main_url"><b><?php echo $langs->trans(
"URLRoot"); ?></b></label>
263 value=
"<?php print $dolibarr_main_url_root; ?> "
264<?php
if (!empty($force_install_noedit) && $force_install_noedit != 3) {
270 <td
class=
"comment"><?php print $langs->trans(
"Examples").
":<br>"; ?>
280 if (!empty($_SERVER[
"HTTPS"]) && $_SERVER[
"HTTPS"] ==
'on') {
283 <td
class=
"label"><label
for=
"main_force_https"><?php echo $langs->trans(
"ForceHttps"); ?></label></td>
285 <input
type=
"checkbox"
286 id=
"main_force_https"
287 name=
"main_force_https"
288 <?php
if (!empty($force_install_mainforcehttps)) {
291 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_mainforcehttps !==
null) {
296 <td
class=
"comment"><?php echo $langs->trans(
"CheckToForceHttps"); ?>
304 <!-- Dolibarr database -->
307 <td colspan=
"3" class=
"label"><br>
308 <h3><img
class=
"valignmiddle inline-block paddingright" src=
"../theme/common/octicons/build/svg/database.svg" width=
"20" alt=
"webserver"> <?php echo $langs->trans(
"DolibarrDatabase"); ?></h3>
313 <td
class=
"label"><label
for=
"db_name"><b><?php echo $langs->trans(
"DatabaseName"); ?></b></label></td>
318 value=
"<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>"
319 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_database !==
null) {
324 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseName"); ?></td>
329 if (!isset($dolibarr_main_db_host)) {
330 $dolibarr_main_db_host =
"localhost";
332 if (!isset($dolibarr_main_db_port)) {
333 $dolibarr_main_db_port =
"";
335 if (!isset($dolibarr_main_db_user)) {
336 $dolibarr_main_db_user =
"";
342 <td
class=
"label"><label
for=
"db_type"><b><?php echo $langs->trans(
"DriverType"); ?></b></label></td>
347 $defaultype = !empty($dolibarr_main_db_type) ? $dolibarr_main_db_type : (empty($force_install_type) ?
'mysqli' : $force_install_type);
354 $dir = DOL_DOCUMENT_ROOT.
'/core/db';
355 $handle = opendir($dir);
356 if (is_resource($handle)) {
357 while (($file = readdir($handle)) !==
false) {
358 if (is_readable($dir.
"/".$file) && preg_match(
'/^(.*)\.class\.php$/i', $file, $reg)) {
360 if ($type ===
'DoliDB') {
363 $class =
'DoliDB'.ucfirst($type);
364 include_once $dir.
"/".$file;
366 if ($type ==
'sqlite') {
369 if ($type ==
'sqlite3') {
374 $note =
'('.$class::LABEL.
' >= '.$class::VERSIONMIN.
')';
377 if ($defaultype ==
'mysqli' && !function_exists(
'mysqli_connect')) {
378 $defaultype =
'mysql';
382 $testfunction =
null;
384 if ($type ==
'mysql') {
385 $testfunction =
'mysql_connect';
388 if ($type ==
'mysqli') {
389 $testfunction =
'mysqli_connect';
392 if ($type ==
'pgsql') {
393 $testfunction =
'pg_connect';
396 if ($type ==
'mssql') {
397 $testfunction =
'mssql_connect';
400 if ($type ==
'sqlite') {
404 if ($type ==
'sqlite3') {
406 $testclass =
'SQLite3';
408 $option .=
'<option value="'.$type.
'"'.($defaultype == $type ?
' selected' :
'');
409 if ($testfunction && !function_exists($testfunction)) {
410 $option .=
' disabled';
412 if ($testclass && !class_exists($testclass)) {
413 $option .=
' disabled';
416 $option .= $type.
' ';
418 $option .=
' '.$note;
421 if ($type ==
'mysql') {
422 $option .=
' '.$langs->trans(
"Deprecated");
423 } elseif ($type ==
'mssql') {
424 $option .=
' '.$langs->trans(
"VersionExperimental");
425 } elseif ($type ==
'sqlite') {
426 $option .=
' '.$langs->trans(
"VersionExperimental");
427 } elseif ($type ==
'sqlite3') {
428 $option .=
' '.$langs->trans(
"VersionExperimental");
429 } elseif ($testfunction ===
null || !function_exists($testfunction)) {
431 $option .=
' - '.$langs->trans(
"FunctionNotAvailableInThisPHP");
433 $option .=
'</option>';
440 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_type !==
null) {
444 <?php print $option; ?>
448 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseType"); ?></td>
452 <tr
class=
"hidesqlite">
453 <td
class=
"label"><label
for=
"db_host"><b><?php echo $langs->trans(
"DatabaseServer"); ?></b></label></td>
458 value=
"<?php print(!empty($force_install_dbserver) ? $force_install_dbserver : (!empty($dolibarr_main_db_host) ? $dolibarr_main_db_host : 'localhost')); ?>"
459 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_dbserver !==
null) {
464 <td
class=
"comment"><?php echo $langs->trans(
"ServerAddressDescription"); ?>
469 <tr
class=
"hidesqlite">
470 <td
class=
"label"><label
for=
"db_port"><?php echo $langs->trans(
"Port"); ?></label></td>
475 value=
"<?php print (!empty($force_install_port)) ? $force_install_port : $dolibarr_main_db_port; ?>"
476 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_port !==
null) {
481 <td
class=
"comment"><?php echo $langs->trans(
"ServerPortDescription"); ?>
486 <tr
class=
"hidesqlite">
487 <td
class=
"label"><label
for=
"db_prefix"><?php echo $langs->trans(
"DatabasePrefix"); ?></label></td>
492 value=
"<?php echo(!empty($force_install_prefix) ? $force_install_prefix : (!empty($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : 'llx_')); ?>"
493 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_prefix !==
null) {
498 <td
class=
"comment"><?php echo $langs->trans(
"DatabasePrefixDescription"); ?></td>
501 <tr
class=
"hidesqlite">
502 <td
class=
"label"><label
for=
"db_create_database"><?php echo $langs->trans(
"CreateDatabase"); ?></label></td>
504 <input
type=
"checkbox"
505 id=
"db_create_database"
506 name=
"db_create_database"
510 if ($force_install_createdatabase) {
514 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_createdatabase !==
null) {
520 <?php echo $langs->trans(
"CheckToCreateDatabase"); ?>
524 <tr
class=
"hidesqlite">
525 <td
class=
"label"><label
for=
"db_user"><b><?php echo $langs->trans(
"Login"); ?></b></label></td>
530 value=
"<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>"
531 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_databaselogin !==
null) {
536 <td
class=
"comment"><?php echo $langs->trans(
"AdminLogin"); ?></td>
539 <tr
class=
"hidesqlite">
540 <td
class=
"label"><label
for=
"db_pass"><b><?php echo $langs->trans(
"Password"); ?></b></label></td>
542 <input
type=
"password" class=
"text-security"
543 id=
"db_pass" autocomplete=
"off"
546 // If $force_install_databasepass is on, we don't want to set password, we just show '***'. Real value will be extracted from the forced install file at step1.
547 // @phan-suppress-next-line PhanParamSuspiciousOrder
548 $autofill = ((!empty($_SESSION['dol_save_pass'])) ? $_SESSION['dol_save_pass'] : str_pad('', strlen($force_install_databasepass), '*'));
549 if (!empty($dolibarr_main_prod) && empty($_SESSION['dol_save_pass'])) { // So value can't be found if install page still accessible
552 print dol_escape_htmltag($autofill);
554 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_databasepass !==
null) {
559 <td
class=
"comment"><?php echo $langs->trans(
"AdminPassword"); ?></td>
562 <tr
class=
"hidesqlite">
563 <td
class=
"label"><label
for=
"db_create_user"><?php echo $langs->trans(
"CreateUser"); ?></label></td>
565 <input
type=
"checkbox"
567 name=
"db_create_user"
571 if (!empty($force_install_createuser)) {
575 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_createuser !==
null) {
581 <?php echo $langs->trans(
"CheckToCreateUser"); ?>
586 <!-- Super access -->
591 <tr
class=
"hidesqlite hideroot">
592 <td colspan=
"3" class=
"label"><br>
593 <h3><img
class=
"valignmiddle inline-block paddingright" src=
"../theme/common/octicons/build/svg/shield.svg" width=
"20" alt=
"webserver"> <?php echo $langs->trans(
"DatabaseSuperUserAccess"); ?></h3>
597 <tr
class=
"hidesqlite hideroot">
598 <td
class=
"label"><label
for=
"db_user_root"><b><?php echo $langs->trans(
"Login"); ?></b></label></td>
604 value=
"<?php print (!empty($force_install_databaserootlogin)) ? $force_install_databaserootlogin : (GETPOSTISSET('db_user_root') ? GETPOST('db_user_root') : (isset($db_user_root) ? $db_user_root : '')); ?>"
605 <?php
if ($force_install_noedit > 0 && !empty($force_install_databaserootlogin)) {
610 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseRootLoginDescription"); ?>
612 <?php echo
'<br>'.$langs->trans(
"Examples").
':<br>' ?>
614 <li>root (Mysql)</li>
615 <li>postgres (PostgreSql)</li>
621 <tr
class=
"hidesqlite hideroot">
622 <td
class=
"label"><label
for=
"db_pass_root"><b><?php echo $langs->trans(
"Password"); ?></b></label></td>
624 <input
type=
"password"
628 class=
"needroot text-security"
630 // If $force_install_databaserootpass is on, we don't want to set password here, we just show '***'. Real value will be extracted from the forced install file at step1.
631 // @phan-suppress-next-line PhanParamSuspiciousOrder
632 $autofill = ((!empty($force_install_databaserootpass)) ? str_pad('', strlen($force_install_databaserootpass), '*') : (isset($db_pass_root) ? $db_pass_root : ''));
633 if (!empty($dolibarr_main_prod)) {
636 // Do not autofill password if instance is a production instance
637 if (!empty($_SERVER["SERVER_NAME
"]) && !in_array(
638 $_SERVER["SERVER_NAME
"],
639 array('127.0.0.1', 'localhost', 'localhostgit')
643 } // Do not autofill password for remote access
644 print dol_escape_htmltag($autofill);
646 <?php
if ($force_install_noedit > 0 && !empty($force_install_databaserootpass)) {
651 <td
class=
"comment"><?php echo $langs->trans(
"KeepEmptyIfNoPassword"); ?>
659<script
type=
"text/javascript">
660function init_needroot()
662 console.log(
"init_needroot force_install_noedit=<?php echo $force_install_noedit?>");
663 console.log(jQuery(
"#db_create_database").is(
":checked"));
664 console.log(jQuery(
"#db_create_user").is(
":checked"));
666 if (jQuery(
"#db_create_database").is(
":checked") || jQuery(
"#db_create_user").is(
":checked"))
668 console.log(
"init_needroot show root section");
669 jQuery(
".hideroot").show();
671 if (empty($force_install_noedit)) { ?>
672 jQuery(
".needroot").removeAttr(
'disabled');
677 console.log(
"init_needroot hide root section");
678 jQuery(
".hideroot").hide();
679 jQuery(
".needroot").prop(
'disabled',
true);
683function checkDatabaseName(databasename) {
684 if (databasename.match(/[;\.]/)) {
return false; }
688function jscheckparam()
690 console.log(
"Click on jscheckparam");
694 if (document.forminstall.main_dir.value ==
'')
697 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("WebPagesDirectory"))); ?>');
699 else if (document.forminstall.main_data_dir.value ==
'')
702 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DocumentsDirectory"))); ?>');
704 else if (document.forminstall.main_url.value ==
'')
707 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("URLRoot"))); ?>');
709 else if (document.forminstall.db_host.value ==
'')
712 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Server"))); ?>');
714 else if (document.forminstall.db_name.value ==
'')
717 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatabaseName"))); ?>');
719 else if (! checkDatabaseName(document.forminstall.db_name.value))
722 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentitiesnoconv("DatabaseName"))); ?>');
725 else if (document.forminstall.db_create_database.checked ==
true && (document.forminstall.db_user_root.value ==
''))
728 alert(
'<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>');
732 else if (document.forminstall.db_create_user.checked ==
true && (document.forminstall.db_user_root.value ==
''))
735 alert(
'<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>');
743jQuery(document).ready(
function() {
745 var dbtype = jQuery(
"#db_type");
747 dbtype.change(
function () {
748 if (dbtype.val() ==
'sqlite' || dbtype.val() ==
'sqlite3') {
749 jQuery(
".hidesqlite").hide();
751 jQuery(
".hidesqlite").show();
755 if (dbtype.val() ==
'mysql' || dbtype.val() ==
'mysqli') {
756 jQuery(
"#db_port").val(3306);
757 jQuery(
"#db_user_root").val(
'root');
758 }
else if (dbtype.val() ==
'pgsql') {
759 jQuery(
"#db_port").val(5432);
760 jQuery(
"#db_user_root").val(
'postgres');
761 }
else if (dbtype.val() ==
'mssql') {
762 jQuery(
"#db_port").val(1433);
763 jQuery(
"#db_user_root").val(
'sa');
768 jQuery(
"#db_create_database").click(
function() {
769 console.log(
"click on db_create_database");
772 jQuery(
"#db_create_user").click(
function() {
773 console.log(
"click on db_create_user");
776 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && empty($force_install_databasepass)) { ?>
777 jQuery(
"#db_pass").focus();
791pFooter($err, $setuplang,
'jscheckparam');
global $dolibarr_main_url_root
API class for receive files.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
treeview li table
No Email.
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.
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.