32include_once
'inc.php';
48$setuplang =
GETPOST(
"selectlang",
'alpha', 3) ?
GETPOST(
"selectlang",
'alpha', 3) : (
GETPOST(
'lang',
'alpha', 1) ?
GETPOST(
'lang',
'alpha', 1) :
'auto');
49$langs->setDefaultLang($setuplang);
51$langs->loadLangs(array(
"install",
"errors"));
59if (!isset($force_install_noedit)) {
60 $force_install_noedit =
'';
62if (!isset($force_install_type)) {
63 $force_install_type =
'';
65if (!isset($force_install_dbserver)) {
66 $force_install_dbserver =
'';
68if (!isset($force_install_port)) {
69 $force_install_port =
'';
71if (!isset($force_install_database)) {
72 $force_install_database =
'';
74if (!isset($force_install_prefix)) {
75 $force_install_prefix =
'';
77if (!isset($force_install_createdatabase)) {
78 $force_install_createdatabase =
'';
80if (!isset($force_install_databaselogin)) {
81 $force_install_databaselogin =
'';
83if (!isset($force_install_databasepass)) {
84 $force_install_databasepass =
'';
86if (!isset($force_install_databaserootlogin)) {
87 $force_install_databaserootlogin =
'';
89if (!isset($force_install_databaserootpass)) {
90 $force_install_databaserootpass =
'';
93$useforcedwizard =
false;
94$forcedfile =
"./install.forced.php";
95if ($conffile ==
"/etc/dolibarr/conf.php") {
96 $forcedfile =
"/etc/dolibarr/install.forced.php";
98if (@file_exists($forcedfile)) {
99 $useforcedwizard =
true;
100 include_once $forcedfile;
111pHeader($langs->trans(
"DolibarrSetup").
' - '.$langs->trans(
"ConfigurationFile"),
"step1",
"set",
"", (empty($force_dolibarr_js_JQUERY) ?
'' : $force_dolibarr_js_JQUERY.
'/'),
'main-inside-bis');
114if (!is_writable($conffile)) {
115 print $langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
118 pFooter(1, $setuplang,
'jscheckparam');
122if (!empty($force_install_message)) {
123 print
'<div><br>'.$langs->trans($force_install_message).
'</div>';
143<
table class=
"nobordernopadding<?php if ($force_install_noedit) {
144 print ' hidewhennoedit';
148 <td colspan=
"3" class=
"label">
149 <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>
153 <!--
Documents root $dolibarr_main_document_root -->
155 <td
class=
"label"><label
for=
"main_dir"><b><?php print $langs->trans(
"WebPagesDirectory"); ?></b></label></td>
157if (empty($dolibarr_main_document_root)) {
162 <input
type=
"text" class=
"minwidth300" id=
"main_dir"
164 value=
"<?php print $dolibarr_main_document_root ?>"
166if (!empty($force_install_noedit)) {
172 <td
class=
"comment"><?php
173 print
'<span class="opacitymedium">'.$langs->trans(
"WithNoSlashAtTheEnd").
"</span><br>";
174 print $langs->trans(
"Examples").
":<br>";
177 <li>/var/www/dolibarr/htdocs</li>
178 <li>C:/wwwroot/dolibarr/htdocs</li>
183 <!--
Documents URL $dolibarr_main_data_root -->
185 <td
class=
"label"><label
for=
"main_data_dir"><b><?php print $langs->trans(
"DocumentsDirectory"); ?></b></label></td>
187 if (!empty($force_install_main_data_root)) {
188 $dolibarr_main_data_root = @$force_install_main_data_root;
190 if (empty($dolibarr_main_data_root)) {
199 value=
"<?php print $dolibarr_main_data_root ?>"
200<?php
if (!empty($force_install_noedit)) {
205 <td
class=
"comment"><?php
206 print
'<span class="opacitymedium">'.$langs->trans(
"WithNoSlashAtTheEnd").
"</span><br>";
207 print $langs->trans(
"DirectoryRecommendation").
"<br>";
208 print $langs->trans(
"Examples").
":<br>";
211 <li>/var/lib/dolibarr/documents</li>
212 <li>C:/My
Documents/dolibarr/documents</li>
217 <!-- Root URL $dolibarr_main_url_root -->
219 if (empty($dolibarr_main_url_root)) {
224 <td
class=
"label"><label
for=
"main_url"><b><?php echo $langs->trans(
"URLRoot"); ?></b></label>
231 value=
"<?php print $dolibarr_main_url_root; ?> "
232<?php
if (!empty($force_install_noedit) && $force_install_noedit != 3) {
238 <td
class=
"comment"><?php print $langs->trans(
"Examples").
":<br>"; ?>
248 if (!empty($_SERVER[
"HTTPS"]) && $_SERVER[
"HTTPS"] ==
'on') {
251 <td
class=
"label"><label
for=
"main_force_https"><?php echo $langs->trans(
"ForceHttps"); ?></label></td>
253 <input
type=
"checkbox"
254 id=
"main_force_https"
255 name=
"main_force_https"
256 <?php
if (!empty($force_install_mainforcehttps)) {
259 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_mainforcehttps !==
null) {
264 <td
class=
"comment"><?php echo $langs->trans(
"CheckToForceHttps"); ?>
272 <!-- Dolibarr database -->
275 <td colspan=
"3" class=
"label"><br>
276 <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>
281 <td
class=
"label"><label
for=
"db_name"><b><?php echo $langs->trans(
"DatabaseName"); ?></b></label></td>
286 value=
"<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>"
287 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_database !==
null) {
292 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseName"); ?></td>
297 if (!isset($dolibarr_main_db_host)) {
298 $dolibarr_main_db_host =
"localhost";
303 <td
class=
"label"><label
for=
"db_type"><b><?php echo $langs->trans(
"DriverType"); ?></b></label></td>
308 $defaultype = !empty($dolibarr_main_db_type) ? $dolibarr_main_db_type : (empty($force_install_type) ?
'mysqli' : $force_install_type);
315 $dir = DOL_DOCUMENT_ROOT.
'/core/db';
316 $handle = opendir($dir);
317 if (is_resource($handle)) {
318 while (($file = readdir($handle)) !==
false) {
319 if (is_readable($dir.
"/".$file) && preg_match(
'/^(.*)\.class\.php$/i', $file, $reg)) {
321 if ($type ===
'DoliDB') {
324 $class =
'DoliDB'.ucfirst($type);
325 include_once $dir.
"/".$file;
327 if ($type ==
'sqlite') {
330 if ($type ==
'sqlite3') {
335 $note =
'('.$class::LABEL.
' >= '.$class::VERSIONMIN.
')';
338 if ($defaultype ==
'mysqli' && !function_exists(
'mysqli_connect')) {
339 $defaultype =
'mysql';
343 if ($type ==
'mysql') {
344 $testfunction =
'mysql_connect';
347 if ($type ==
'mysqli') {
348 $testfunction =
'mysqli_connect';
351 if ($type ==
'pgsql') {
352 $testfunction =
'pg_connect';
355 if ($type ==
'mssql') {
356 $testfunction =
'mssql_connect';
359 if ($type ==
'sqlite') {
363 if ($type ==
'sqlite3') {
365 $testclass =
'SQLite3';
367 $option .=
'<option value="'.$type.
'"'.($defaultype == $type ?
' selected' :
'');
368 if ($testfunction && !function_exists($testfunction)) {
369 $option .=
' disabled';
371 if ($testclass && !class_exists($testclass)) {
372 $option .=
' disabled';
375 $option .= $type.
' ';
377 $option .=
' '.$note;
380 if ($type ==
'mysql') {
381 $option .=
' '.$langs->trans(
"Deprecated");
382 } elseif ($type ==
'mssql') {
383 $option .=
' '.$langs->trans(
"VersionExperimental");
384 } elseif ($type ==
'sqlite') {
385 $option .=
' '.$langs->trans(
"VersionExperimental");
386 } elseif ($type ==
'sqlite3') {
387 $option .=
' '.$langs->trans(
"VersionExperimental");
388 } elseif ($testfunction ===
null || !function_exists($testfunction)) {
390 $option .=
' - '.$langs->trans(
"FunctionNotAvailableInThisPHP");
392 $option .=
'</option>';
399 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_type !==
null) {
403 <?php print $option; ?>
407 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseType"); ?></td>
411 <tr
class=
"hidesqlite">
412 <td
class=
"label"><label
for=
"db_host"><b><?php echo $langs->trans(
"DatabaseServer"); ?></b></label></td>
417 value=
"<?php print(!empty($force_install_dbserver) ? $force_install_dbserver : (!empty($dolibarr_main_db_host) ? $dolibarr_main_db_host : 'localhost')); ?>"
418 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_dbserver !==
null) {
423 <td
class=
"comment"><?php echo $langs->trans(
"ServerAddressDescription"); ?>
428 <tr
class=
"hidesqlite">
429 <td
class=
"label"><label
for=
"db_port"><?php echo $langs->trans(
"Port"); ?></label></td>
434 value=
"<?php print (!empty($force_install_port)) ? $force_install_port : $dolibarr_main_db_port; ?>"
435 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_port !==
null) {
440 <td
class=
"comment"><?php echo $langs->trans(
"ServerPortDescription"); ?>
445 <tr
class=
"hidesqlite">
446 <td
class=
"label"><label
for=
"db_prefix"><?php echo $langs->trans(
"DatabasePrefix"); ?></label></td>
451 value=
"<?php echo(!empty($force_install_prefix) ? $force_install_prefix : (!empty($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : 'llx_')); ?>"
452 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_prefix !==
null) {
457 <td
class=
"comment"><?php echo $langs->trans(
"DatabasePrefixDescription"); ?></td>
460 <tr
class=
"hidesqlite">
461 <td
class=
"label"><label
for=
"db_create_database"><?php echo $langs->trans(
"CreateDatabase"); ?></label></td>
463 <input
type=
"checkbox"
464 id=
"db_create_database"
465 name=
"db_create_database"
469 if ($force_install_createdatabase) {
473 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_createdatabase !==
null) {
479 <?php echo $langs->trans(
"CheckToCreateDatabase"); ?>
483 <tr
class=
"hidesqlite">
484 <td
class=
"label"><label
for=
"db_user"><b><?php echo $langs->trans(
"Login"); ?></b></label></td>
489 value=
"<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>"
490 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_databaselogin !==
null) {
495 <td
class=
"comment"><?php echo $langs->trans(
"AdminLogin"); ?></td>
498 <tr
class=
"hidesqlite">
499 <td
class=
"label"><label
for=
"db_pass"><b><?php echo $langs->trans(
"Password"); ?></b></label></td>
501 <input
type=
"password" class=
"text-security"
502 id=
"db_pass" autocomplete=
"off"
505 // 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.
506 // @phan-suppress-next-line PhanParamSuspiciousOrder
507 $autofill = ((!empty($_SESSION['dol_save_pass'])) ? $_SESSION['dol_save_pass'] : str_pad('', strlen($force_install_databasepass), '*'));
508 if (!empty($dolibarr_main_prod) && empty($_SESSION['dol_save_pass'])) { // So value can't be found if install page still accessible
511 print dol_escape_htmltag($autofill);
513 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_databasepass !==
null) {
518 <td
class=
"comment"><?php echo $langs->trans(
"AdminPassword"); ?></td>
521 <tr
class=
"hidesqlite">
522 <td
class=
"label"><label
for=
"db_create_user"><?php echo $langs->trans(
"CreateUser"); ?></label></td>
524 <input
type=
"checkbox"
526 name=
"db_create_user"
530 if (!empty($force_install_createuser)) {
534 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_createuser !==
null) {
540 <?php echo $langs->trans(
"CheckToCreateUser"); ?>
545 <!-- Super access -->
550 <tr
class=
"hidesqlite hideroot">
551 <td colspan=
"3" class=
"label"><br>
552 <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>
556 <tr
class=
"hidesqlite hideroot">
557 <td
class=
"label"><label
for=
"db_user_root"><b><?php echo $langs->trans(
"Login"); ?></b></label></td>
563 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 : '')); ?>"
564 <?php
if ($force_install_noedit > 0 && !empty($force_install_databaserootlogin)) {
569 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseRootLoginDescription"); ?>
571 <?php echo
'<br>'.$langs->trans(
"Examples").
':<br>' ?>
573 <li>root (Mysql)</li>
574 <li>postgres (PostgreSql)</li>
580 <tr
class=
"hidesqlite hideroot">
581 <td
class=
"label"><label
for=
"db_pass_root"><b><?php echo $langs->trans(
"Password"); ?></b></label></td>
583 <input
type=
"password"
587 class=
"needroot text-security"
589 // 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.
590 // @phan-suppress-next-line PhanParamSuspiciousOrder
591 $autofill = ((!empty($force_install_databaserootpass)) ? str_pad('', strlen($force_install_databaserootpass), '*') : (isset($db_pass_root) ? $db_pass_root : ''));
592 if (!empty($dolibarr_main_prod)) {
595 // Do not autofill password if instance is a production instance
596 if (!empty($_SERVER["SERVER_NAME
"]) && !in_array(
597 $_SERVER["SERVER_NAME
"],
598 array('127.0.0.1', 'localhost', 'localhostgit')
602 } // Do not autofill password for remote access
603 print dol_escape_htmltag($autofill);
605 <?php
if ($force_install_noedit > 0 && !empty($force_install_databaserootpass)) {
610 <td
class=
"comment"><?php echo $langs->trans(
"KeepEmptyIfNoPassword"); ?>
618<script
type=
"text/javascript">
619function init_needroot()
621 console.log(
"init_needroot force_install_noedit=<?php echo $force_install_noedit?>");
622 console.log(jQuery(
"#db_create_database").is(
":checked"));
623 console.log(jQuery(
"#db_create_user").is(
":checked"));
625 if (jQuery(
"#db_create_database").is(
":checked") || jQuery(
"#db_create_user").is(
":checked"))
627 console.log(
"init_needroot show root section");
628 jQuery(
".hideroot").show();
630 if (empty($force_install_noedit)) { ?>
631 jQuery(
".needroot").removeAttr(
'disabled');
636 console.log(
"init_needroot hide root section");
637 jQuery(
".hideroot").hide();
638 jQuery(
".needroot").prop(
'disabled',
true);
642function checkDatabaseName(databasename) {
643 if (databasename.match(/[;\.]/)) {
return false; }
647function jscheckparam()
649 console.log(
"Click on jscheckparam");
653 if (document.forminstall.main_dir.value ==
'')
656 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("WebPagesDirectory"))); ?>');
658 else if (document.forminstall.main_data_dir.value ==
'')
661 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DocumentsDirectory"))); ?>');
663 else if (document.forminstall.main_url.value ==
'')
666 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("URLRoot"))); ?>');
668 else if (document.forminstall.db_host.value ==
'')
671 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Server"))); ?>');
673 else if (document.forminstall.db_name.value ==
'')
676 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatabaseName"))); ?>');
678 else if (! checkDatabaseName(document.forminstall.db_name.value))
681 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentitiesnoconv("DatabaseName"))); ?>');
684 else if (document.forminstall.db_create_database.checked ==
true && (document.forminstall.db_user_root.value ==
''))
687 alert(
'<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>');
691 else if (document.forminstall.db_create_user.checked ==
true && (document.forminstall.db_user_root.value ==
''))
694 alert(
'<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>');
702jQuery(document).ready(
function() {
704 var dbtype = jQuery(
"#db_type");
706 dbtype.change(
function () {
707 if (dbtype.val() ==
'sqlite' || dbtype.val() ==
'sqlite3') {
708 jQuery(
".hidesqlite").hide();
710 jQuery(
".hidesqlite").show();
714 if (dbtype.val() ==
'mysql' || dbtype.val() ==
'mysqli') {
715 jQuery(
"#db_port").val(3306);
716 jQuery(
"#db_user_root").val(
'root');
717 }
else if (dbtype.val() ==
'pgsql') {
718 jQuery(
"#db_port").val(5432);
719 jQuery(
"#db_user_root").val(
'postgres');
720 }
else if (dbtype.val() ==
'mssql') {
721 jQuery(
"#db_port").val(1433);
722 jQuery(
"#db_user_root").val(
'sa');
727 jQuery(
"#db_create_database").click(
function() {
728 console.log(
"click on db_create_database");
731 jQuery(
"#db_create_user").click(
function() {
732 console.log(
"click on db_create_user");
735 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && empty($force_install_databasepass)) { ?>
736 jQuery(
"#db_pass").focus();
750pFooter($err, $setuplang,
'jscheckparam');
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:/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.