33include_once
'inc.php';
48@phan-var-force string $dolibarr_main_db_host
49@phan-var-force string $dolibarr_main_db_port
50@phan-var-force string $dolibarr_main_db_name
51@phan-var-force string $dolibarr_main_db_user
52@phan-var-force string $dolibarr_main_db_pass
53@phan-var-force string $dolibarr_main_db_encrypted_pass
54@phan-var-force string $conffile
55@phan-var-force string $conffiletoshow
56@phan-var-force ?bool $force_install_
57@phan-var-force ?string $force_install_packager
58@phan-var-force ?string $force_install_message
59@phan-var-force ?string $force_install_main_data_root
60@phan-var-force ?int<0,2> $force_install_noedit
61@phan-var-force ?string $force_install_type
62@phan-var-force ?string $force_install_dbserver
63@phan-var-force ?string $force_install_port
64@phan-var-force ?string $force_install_database
65@phan-var-force ?string $force_install_prefix
66@phan-var-force ?string $force_install_createdatabase
67@phan-var-force ?string $force_install_databaselogin
68@phan-var-force ?string $force_install_databasepass
69@phan-var-force ?string $force_install_databaserootlogin
70@phan-var-force ?string $force_install_databaserootpass
71@phan-var-force ?string $force_install_dolibarrlogin
72@phan-var-force ?string $force_install_nophpinfo
73@phan-var-force ?string $force_install_lockinstall
74@phan-var-force ?string $force_install_distrib
75@phan-var-force ?string $db_user_root
76@phan-var-force ?string $db_pass_root
81$setuplang =
GETPOST(
"selectlang",
'alpha', 3) ?
GETPOST(
"selectlang",
'alpha', 3) : (
GETPOST(
'lang',
'alpha', 1) ?
GETPOST(
'lang',
'alpha', 1) :
'auto');
82$langs->setDefaultLang($setuplang);
84$langs->loadLangs(array(
"install",
"errors",
"admin"));
92if (!isset($force_install_distrib)) {
93 $force_install_distrib =
'undefined';
95if (!isset($force_install_noedit)) {
96 $force_install_noedit =
'';
98if (!isset($force_install_type)) {
99 $force_install_type =
'';
101if (!isset($force_install_dbserver)) {
102 $force_install_dbserver =
'';
104if (!isset($force_install_port)) {
105 $force_install_port =
'';
107if (!isset($force_install_database)) {
108 $force_install_database =
'';
110if (!isset($force_install_prefix)) {
111 $force_install_prefix =
'';
113if (!isset($force_install_createdatabase)) {
114 $force_install_createdatabase =
'';
116if (!isset($force_install_databaselogin)) {
117 $force_install_databaselogin =
'';
119if (!isset($force_install_databasepass)) {
120 $force_install_databasepass =
'';
122if (!isset($force_install_databaserootlogin)) {
123 $force_install_databaserootlogin =
'';
125if (!isset($force_install_databaserootpass)) {
126 $force_install_databaserootpass =
'';
129$useforcedwizard =
false;
130$forcedfile =
"./install.forced.php";
131if (
$conffile ==
"/etc/dolibarr/conf.php") {
132 $forcedfile =
"/etc/dolibarr/install.forced.php";
134if (@file_exists($forcedfile)) {
135 $useforcedwizard =
true;
136 include_once $forcedfile;
147pHeader($langs->trans(
"DolibarrSetup").
' - '.$langs->trans(
"ConfigurationFile"),
"step1",
"set",
"", (empty($force_dolibarr_js_JQUERY) ?
'' : $force_dolibarr_js_JQUERY.
'/'),
'main-inside-bis');
151 print $langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
154 pFooter(1, $setuplang,
'jscheckparam');
158if (!empty($force_install_distrib)) {
159 print
'<!-- $force_install_distrib = '.dol_escape_htmltag($force_install_distrib).
' -->';
162if (!empty($force_install_message)) {
163 print
'<div><br>'.$langs->trans($force_install_message).
'</div>';
183<
table class=
"nobordernopadding<?php if ($force_install_noedit) {
184 print ' hidewhennoedit';
188 <td colspan=
"3" class=
"label">
189 <h3><img
class=
"valignmiddle inline-block paddingright" src=
"../public/theme/common/globe.svg" width=
"20" alt=
"webserver"> <?php echo $langs->trans(
"WebServer"); ?></h3>
193 <!--
Documents root $dolibarr_main_document_root -->
195 <td
class=
"label"><label
for=
"main_dir"><b><?php print $langs->trans(
"WebPagesDirectory"); ?></b></label></td>
197if (empty($dolibarr_main_document_root)) {
202 <input
type=
"text" class=
"minwidth300" id=
"main_dir"
204 value=
"<?php print $dolibarr_main_document_root ?>"
206if (!empty($force_install_noedit)) {
212 <td
class=
"comment"><?php
213 print
'<span class="opacitymedium">'.$langs->trans(
"WithNoSlashAtTheEnd").
"</span><br>";
214 print $langs->trans(
"Examples").
":<br>";
217 <li>/var/www/dolibarr/htdocs</li>
218 <li>C:/wwwroot/dolibarr/htdocs</li>
223 <!--
Documents URL $dolibarr_main_data_root -->
225 <td
class=
"label"><label
for=
"main_data_dir"><b><?php print $langs->trans(
"DocumentsDirectory"); ?></b></label></td>
227 if (!empty($force_install_main_data_root)) {
228 $dolibarr_main_data_root = @$force_install_main_data_root;
230 if (empty($dolibarr_main_data_root)) {
239 value=
"<?php print $dolibarr_main_data_root ?>"
240<?php
if (!empty($force_install_noedit)) {
245 <td
class=
"comment"><?php
246 print
'<span class="opacitymedium">'.$langs->trans(
"WithNoSlashAtTheEnd").
"</span><br>";
247 print $langs->trans(
"DirectoryRecommendation").
"<br>";
248 print $langs->trans(
"Examples").
":<br>";
251 <li>/var/lib/dolibarr/documents</li>
252 <li>C:/My
Documents/dolibarr/documents</li>
265 <td
class=
"label"><label
for=
"main_url"><b><?php echo $langs->trans(
"URLRoot"); ?></b></label>
272 value=
"<?php print $dolibarr_main_url_root; ?>"
273<?php
if (!empty($force_install_noedit) && $force_install_noedit != 3) {
279 <td
class=
"comment"><?php print $langs->trans(
"Examples").
":<br>"; ?>
289 if (!empty($_SERVER[
"HTTPS"]) && $_SERVER[
"HTTPS"] ==
'on') {
292 <td
class=
"label"><label
for=
"main_force_https"><?php echo $langs->trans(
"ForceHttps"); ?></label></td>
294 <input
type=
"checkbox"
295 id=
"main_force_https"
296 name=
"main_force_https"
297 <?php
if (!empty($force_install_mainforcehttps)) {
300 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_mainforcehttps !==
null) {
305 <td
class=
"comment"><?php echo $langs->trans(
"CheckToForceHttps"); ?>
313 <!-- Dolibarr database -->
316 <td colspan=
"3" class=
"label"><br>
317 <h3><img
class=
"valignmiddle inline-block paddingright" src=
"../public/theme/common/database.svg" width=
"20" alt=
"webserver"> <?php echo $langs->trans(
"DolibarrDatabase"); ?></h3>
322 <td
class=
"label"><label
for=
"db_name"><b><?php echo $langs->trans(
"DatabaseName"); ?></b></label></td>
327 value=
"<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>"
328 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_database !==
null) {
333 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseName"); ?></td>
338 if (!isset($dolibarr_main_db_host)) {
339 $dolibarr_main_db_host =
"localhost";
341 if (!isset($dolibarr_main_db_port)) {
342 $dolibarr_main_db_port =
"";
344 if (!isset($dolibarr_main_db_user)) {
345 $dolibarr_main_db_user =
"";
351 <td
class=
"label"><label
for=
"db_type"><b><?php echo $langs->trans(
"DriverType"); ?></b></label></td>
356 $defaultype = !empty($dolibarr_main_db_type) ? $dolibarr_main_db_type : (empty($force_install_type) ?
'mysqli' : $force_install_type);
363 $dir = DOL_DOCUMENT_ROOT.
'/core/db';
364 $handle = opendir($dir);
365 if (is_resource($handle)) {
366 while (($file = readdir($handle)) !==
false) {
367 if (is_readable($dir.
"/".$file) && preg_match(
'/^(.*)\.class\.php$/i', $file, $reg)) {
369 if ($type ===
'DoliDB') {
372 $class =
'DoliDB'.ucfirst($type);
373 include_once $dir.
"/".$file;
375 if ($type ==
'sqlite') {
378 if ($type ==
'sqlite3') {
383 $note =
'('.$class::LABEL.
' >= '.$class::VERSIONMIN.
')';
386 if ($defaultype ==
'mysqli' && !function_exists(
'mysqli_connect')) {
387 $defaultype =
'mysql';
391 $testfunction =
null;
393 if ($type ==
'mysql') {
394 $testfunction =
'mysql_connect';
397 if ($type ==
'mysqli') {
398 $testfunction =
'mysqli_connect';
401 if ($type ==
'pgsql') {
402 $testfunction =
'pg_connect';
405 if ($type ==
'mssql') {
406 $testfunction =
'mssql_connect';
409 if ($type ==
'sqlite') {
413 if ($type ==
'sqlite3') {
415 $testclass =
'SQLite3';
417 $option .=
'<option value="'.$type.
'"'.($defaultype == $type ?
' selected' :
'');
418 if ($testfunction && !function_exists($testfunction)) {
419 $option .=
' disabled';
421 if ($testclass && !class_exists($testclass)) {
422 $option .=
' disabled';
425 $option .= $type.
' ';
427 $option .=
' '.$note;
430 if ($type ==
'mysql') {
431 $option .=
' '.$langs->trans(
"Deprecated");
432 } elseif ($type ==
'mssql') {
433 $option .=
' '.$langs->trans(
"VersionExperimental");
434 } elseif ($type ==
'sqlite') {
435 $option .=
' '.$langs->trans(
"VersionExperimental");
436 } elseif ($type ==
'sqlite3') {
437 $option .=
' '.$langs->trans(
"VersionExperimental");
438 } elseif ($testfunction ===
null || !function_exists($testfunction)) {
440 $option .=
' - '.$langs->trans(
"FunctionNotAvailableInThisPHP");
442 $option .=
'</option>';
449 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_type !==
null) {
453 <?php print $option; ?>
457 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseType"); ?></td>
461 <tr
class=
"hidesqlite">
462 <td
class=
"label"><label
for=
"db_host"><b><?php echo $langs->trans(
"DatabaseServer"); ?></b></label></td>
467 value=
"<?php print(!empty($force_install_dbserver) ? $force_install_dbserver : (!empty($dolibarr_main_db_host) ? $dolibarr_main_db_host : 'localhost')); ?>"
468 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_dbserver !==
null) {
473 <td
class=
"comment"><?php echo $langs->trans(
"ServerAddressDescription"); ?>
478 <tr
class=
"hidesqlite">
479 <td
class=
"label"><label
for=
"db_port"><?php echo $langs->trans(
"Port"); ?></label></td>
481 <input
type=
"text" class=
"width75"
484 value=
"<?php print (!empty($force_install_port)) ? $force_install_port : $dolibarr_main_db_port; ?>"
485 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_port !==
null) {
490 <td
class=
"comment"><?php echo $langs->trans(
"ServerPortDescription"); ?>
495 <tr
class=
"hidesqlite">
496 <td
class=
"label"><label
for=
"db_prefix"><?php echo $langs->trans(
"DatabasePrefix"); ?></label></td>
501 value=
"<?php echo(!empty($force_install_prefix) ? $force_install_prefix : (!empty($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : 'llx_')); ?>"
502 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_prefix !==
null) {
507 <td
class=
"comment"><?php echo $langs->trans(
"DatabasePrefixDescription"); ?></td>
510 <tr
class=
"hidesqlite">
511 <td
class=
"label"><label
for=
"db_create_database"><?php echo $langs->trans(
"CreateDatabase"); ?></label></td>
513 <input
type=
"checkbox"
514 id=
"db_create_database"
515 name=
"db_create_database"
519 if ($force_install_createdatabase) {
523 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_createdatabase !==
null) {
529 <?php echo $langs->trans(
"CheckToCreateDatabase"); ?>
533 <tr
class=
"hidesqlite">
534 <td
class=
"label"><label
for=
"db_user"><b><?php echo $langs->trans(
"Login"); ?></b></label></td>
539 value=
"<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>"
540 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_databaselogin !==
null) {
545 <td
class=
"comment"><?php echo $langs->trans(
"AdminLogin"); ?></td>
548 <tr
class=
"hidesqlite">
549 <td
class=
"label"><label
for=
"db_pass"><b><?php echo $langs->trans(
"Password"); ?></b></label></td>
551 <input
type=
"password" class=
"text-security"
552 id=
"db_pass" autocomplete=
"off"
555 // 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.
556 // @phan-suppress-next-line PhanParamSuspiciousOrder
557 $autofill = ((!empty($_SESSION['dol_save_pass'])) ? $_SESSION['dol_save_pass'] : str_pad('', strlen($force_install_databasepass), '*'));
558 if (!empty($dolibarr_main_prod) && empty($_SESSION['dol_save_pass'])) { // So value can't be found if install page still accessible
561 print dol_escape_htmltag($autofill);
563 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_databasepass !==
null) {
568 <td
class=
"comment"><?php echo $langs->trans(
"AdminPassword"); ?></td>
571 <tr
class=
"hidesqlite">
572 <td
class=
"label"><label
for=
"db_create_user"><?php echo $langs->trans(
"CreateUser"); ?></label></td>
574 <input
type=
"checkbox"
576 name=
"db_create_user"
580 if (!empty($force_install_createuser)) {
584 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_createuser !==
null) {
590 <?php echo $langs->trans(
"CheckToCreateUser"); ?>
595 <!-- Super access -->
600 <tr
class=
"hidesqlite hideroot">
601 <td colspan=
"3" class=
"label"><br>
602 <h3><img
class=
"valignmiddle inline-block paddingright" src=
"../public/theme/common/shield.svg" width=
"20" alt=
"webserver"> <?php echo $langs->trans(
"DatabaseSuperUserAccess"); ?></h3>
606 <tr
class=
"hidesqlite hideroot">
607 <td
class=
"label"><label
for=
"db_user_root"><b><?php echo $langs->trans(
"Login"); ?></b></label></td>
613 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 : '')); ?>"
614 <?php
if ($force_install_noedit > 0 && !empty($force_install_databaserootlogin)) {
619 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseRootLoginDescription"); ?>
621 <?php echo
'<br>'.$langs->trans(
"Examples").
':<br>' ?>
623 <li>root (Mysql)</li>
624 <li>postgres (PostgreSql)</li>
630 <tr
class=
"hidesqlite hideroot">
631 <td
class=
"label"><label
for=
"db_pass_root"><b><?php echo $langs->trans(
"Password"); ?></b></label></td>
633 <input
type=
"password"
637 class=
"needroot text-security"
639 // 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.
640 // @phan-suppress-next-line PhanParamSuspiciousOrder
641 $autofill = ((!empty($force_install_databaserootpass)) ? str_pad('', strlen($force_install_databaserootpass), '*') : (isset($db_pass_root) ? $db_pass_root : ''));
642 if (!empty($dolibarr_main_prod)) {
645 // Do not autofill password if instance is a production instance
646 if (!empty($_SERVER["SERVER_NAME
"]) && !in_array(
647 $_SERVER["SERVER_NAME
"],
648 array('127.0.0.1', 'localhost', 'localhostgit')
652 } // Do not autofill password for remote access
653 print dol_escape_htmltag($autofill);
655 <?php
if ($force_install_noedit > 0 && !empty($force_install_databaserootpass)) {
660 <td
class=
"comment"><?php echo $langs->trans(
"KeepEmptyIfNoPassword"); ?>
668<script
type=
"text/javascript">
669function init_needroot()
671 console.log(
"init_needroot force_install_noedit=<?php echo $force_install_noedit?>");
672 console.log(jQuery(
"#db_create_database").is(
":checked"));
673 console.log(jQuery(
"#db_create_user").is(
":checked"));
675 if (jQuery(
"#db_create_database").is(
":checked") || jQuery(
"#db_create_user").is(
":checked"))
677 console.log(
"init_needroot show root section");
678 jQuery(
".hideroot").show();
680 if (empty($force_install_noedit)) { ?>
681 jQuery(
".needroot").removeAttr(
'disabled');
686 console.log(
"init_needroot hide root section");
687 jQuery(
".hideroot").hide();
688 jQuery(
".needroot").prop(
'disabled',
true);
692function checkDatabaseName(databasename) {
693 if (databasename.match(/[;\.]/)) {
return false; }
697function jscheckparam()
699 console.log(
"Click on jscheckparam");
703 if (document.forminstall.main_dir.value ==
'')
706 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("WebPagesDirectory"))); ?>');
708 else if (document.forminstall.main_data_dir.value ==
'')
711 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DocumentsDirectory"))); ?>');
713 else if (document.forminstall.main_url.value ==
'')
716 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("URLRoot"))); ?>');
718 else if (document.forminstall.db_host.value ==
'')
721 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Server"))); ?>');
723 else if (document.forminstall.db_name.value ==
'')
726 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatabaseName"))); ?>');
728 else if (! checkDatabaseName(document.forminstall.db_name.value))
731 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentitiesnoconv("DatabaseName"))); ?>');
734 else if (document.forminstall.db_create_database.checked ==
true && (document.forminstall.db_user_root.value ==
''))
737 alert(
'<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>');
741 else if (document.forminstall.db_create_user.checked ==
true && (document.forminstall.db_user_root.value ==
''))
744 alert(
'<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>');
752jQuery(document).ready(
function() {
754 var dbtype = jQuery(
"#db_type");
756 dbtype.change(
function () {
757 if (dbtype.val() ==
'sqlite' || dbtype.val() ==
'sqlite3') {
758 jQuery(
".hidesqlite").hide();
760 jQuery(
".hidesqlite").show();
764 if (dbtype.val() ==
'mysql' || dbtype.val() ==
'mysqli') {
765 jQuery(
"#db_port").val(3306);
766 jQuery(
"#db_user_root").val(
'root');
767 }
else if (dbtype.val() ==
'pgsql') {
768 jQuery(
"#db_port").val(5432);
769 jQuery(
"#db_user_root").val(
'postgres');
770 }
else if (dbtype.val() ==
'mssql') {
771 jQuery(
"#db_port").val(1433);
772 jQuery(
"#db_user_root").val(
'sa');
777 jQuery(
"#db_create_database").click(
function() {
778 console.log(
"click on db_create_database");
781 jQuery(
"#db_create_user").click(
function() {
782 console.log(
"click on db_create_user");
785 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && empty($force_install_databasepass)) { ?>
786 jQuery(
"#db_pass").focus();
800pFooter($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'))
Abort invoice creation with a given error message.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
$conf db name
Only used if Module[ID]Name translation string is not found.