31include_once
'inc.php';
37$setuplang =
GETPOST(
"selectlang",
'alpha', 3) ?
GETPOST(
"selectlang",
'alpha', 3) : (
GETPOST(
'lang',
'alpha', 1) ?
GETPOST(
'lang',
'alpha', 1) :
'auto');
38$langs->setDefaultLang($setuplang);
40$langs->loadLangs(array(
"install",
"errors"));
48if (!isset($force_install_noedit)) {
49 $force_install_noedit =
'';
51if (!isset($force_install_type)) {
52 $force_install_type =
'';
54if (!isset($force_install_dbserver)) {
55 $force_install_dbserver =
'';
57if (!isset($force_install_port)) {
58 $force_install_port =
'';
60if (!isset($force_install_database)) {
61 $force_install_database =
'';
63if (!isset($force_install_prefix)) {
64 $force_install_prefix =
'';
66if (!isset($force_install_createdatabase)) {
67 $force_install_createdatabase =
'';
69if (!isset($force_install_databaselogin)) {
70 $force_install_databaselogin =
'';
72if (!isset($force_install_databasepass)) {
73 $force_install_databasepass =
'';
75if (!isset($force_install_databaserootlogin)) {
76 $force_install_databaserootlogin =
'';
78if (!isset($force_install_databaserootpass)) {
79 $force_install_databaserootpass =
'';
82$useforcedwizard =
false;
83$forcedfile =
"./install.forced.php";
84if ($conffile ==
"/etc/dolibarr/conf.php") {
85 $forcedfile =
"/etc/dolibarr/install.forced.php";
87if (@file_exists($forcedfile)) {
88 $useforcedwizard =
true;
89 include_once $forcedfile;
100pHeader($langs->trans(
"DolibarrSetup").
' - '.$langs->trans(
"ConfigurationFile"),
"step1",
"set",
"", (empty($force_dolibarr_js_JQUERY) ?
'' : $force_dolibarr_js_JQUERY.
'/'),
'main-inside-bis');
103if (!is_writable($conffile)) {
104 print $langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
107 pFooter(1, $setuplang,
'jscheckparam');
111if (!empty($force_install_message)) {
112 print
'<div><br>'.$langs->trans($force_install_message).
'</div>';
132<
table class=
"nobordernopadding<?php if ($force_install_noedit) {
133 print ' hidewhennoedit';
137 <td colspan=
"3" class=
"label">
138 <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>
142 <!--
Documents root $dolibarr_main_document_root -->
144 <td
class=
"label"><label
for=
"main_dir"><b><?php print $langs->trans(
"WebPagesDirectory"); ?></b></label></td>
146if (empty($dolibarr_main_document_root)) {
155 value=
"<?php print $dolibarr_main_document_root ?>"
157if (!empty($force_install_noedit)) {
163 <td
class=
"comment"><?php
164 print
'<span class="opacitymedium">'.$langs->trans(
"WithNoSlashAtTheEnd").
"</span><br>";
165 print $langs->trans(
"Examples").
":<br>";
168 <li>/var/www/dolibarr/htdocs</li>
169 <li>C:/wwwroot/dolibarr/htdocs</li>
174 <!--
Documents URL $dolibarr_main_data_root -->
176 <td
class=
"label"><label
for=
"main_data_dir"><b><?php print $langs->trans(
"DocumentsDirectory"); ?></b></label></td>
178 if (!empty($force_install_main_data_root)) {
179 $dolibarr_main_data_root = @$force_install_main_data_root;
181 if (empty($dolibarr_main_data_root)) {
190 value=
"<?php print $dolibarr_main_data_root ?>"
191<?php
if (!empty($force_install_noedit)) {
196 <td
class=
"comment"><?php
197 print
'<span class="opacitymedium">'.$langs->trans(
"WithNoSlashAtTheEnd").
"</span><br>";
198 print $langs->trans(
"DirectoryRecommendation").
"<br>";
199 print $langs->trans(
"Examples").
":<br>";
202 <li>/var/lib/dolibarr/documents</li>
203 <li>C:/My
Documents/dolibarr/documents</li>
208 <!-- Root URL $dolibarr_main_url_root -->
210 if (empty($dolibarr_main_url_root)) {
215 <td
class=
"label"><label
for=
"main_url"><b><?php echo $langs->trans(
"URLRoot"); ?></b></label>
222 value=
"<?php print $dolibarr_main_url_root; ?> "
223<?php
if (!empty($force_install_noedit) && $force_install_noedit != 3) {
229 <td
class=
"comment"><?php print $langs->trans(
"Examples").
":<br>"; ?>
239 if (!empty($_SERVER[
"HTTPS"]) && $_SERVER[
"HTTPS"] ==
'on') {
242 <td
class=
"label"><label
for=
"main_force_https"><?php echo $langs->trans(
"ForceHttps"); ?></label></td>
244 <input
type=
"checkbox"
245 id=
"main_force_https"
246 name=
"main_force_https"
247 <?php
if (!empty($force_install_mainforcehttps)) {
250 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_mainforcehttps !==
null) {
255 <td
class=
"comment"><?php echo $langs->trans(
"CheckToForceHttps"); ?>
263 <!-- Dolibarr database -->
266 <td colspan=
"3" class=
"label"><br>
267 <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>
272 <td
class=
"label"><label
for=
"db_name"><b><?php echo $langs->trans(
"DatabaseName"); ?></b></label></td>
277 value=
"<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>"
278 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_database !==
null) {
283 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseName"); ?></td>
288 if (!isset($dolibarr_main_db_host)) {
289 $dolibarr_main_db_host =
"localhost";
294 <td
class=
"label"><label
for=
"db_type"><b><?php echo $langs->trans(
"DriverType"); ?></b></label></td>
299 $defaultype = !empty($dolibarr_main_db_type) ? $dolibarr_main_db_type : (empty($force_install_type) ?
'mysqli' : $force_install_type);
306 $dir = DOL_DOCUMENT_ROOT.
'/core/db';
307 $handle = opendir($dir);
308 if (is_resource($handle)) {
309 while (($file = readdir($handle)) !==
false) {
310 if (is_readable($dir.
"/".$file) && preg_match(
'/^(.*)\.class\.php$/i', $file, $reg)) {
312 if ($type ===
'DoliDB') {
315 $class =
'DoliDB'.ucfirst($type);
316 include_once $dir.
"/".$file;
318 if ($type ==
'sqlite') {
321 if ($type ==
'sqlite3') {
326 $note =
'('.$class::LABEL.
' >= '.$class::VERSIONMIN.
')';
329 if ($defaultype ==
'mysqli' && !function_exists(
'mysqli_connect')) {
330 $defaultype =
'mysql';
334 if ($type ==
'mysql') {
335 $testfunction =
'mysql_connect';
338 if ($type ==
'mysqli') {
339 $testfunction =
'mysqli_connect';
342 if ($type ==
'pgsql') {
343 $testfunction =
'pg_connect';
346 if ($type ==
'mssql') {
347 $testfunction =
'mssql_connect';
350 if ($type ==
'sqlite') {
354 if ($type ==
'sqlite3') {
356 $testclass =
'SQLite3';
358 $option .=
'<option value="'.$type.
'"'.($defaultype == $type ?
' selected' :
'');
359 if ($testfunction && !function_exists($testfunction)) {
360 $option .=
' disabled';
362 if ($testclass && !class_exists($testclass)) {
363 $option .=
' disabled';
366 $option .= $type.
' ';
368 $option .=
' '.$note;
371 if ($type ==
'mysql') {
372 $option .=
' '.$langs->trans(
"Deprecated");
373 } elseif ($type ==
'mssql') {
374 $option .=
' '.$langs->trans(
"VersionExperimental");
375 } elseif ($type ==
'sqlite') {
376 $option .=
' '.$langs->trans(
"VersionExperimental");
377 } elseif ($type ==
'sqlite3') {
378 $option .=
' '.$langs->trans(
"VersionExperimental");
379 } elseif ($testfunction ===
null || !function_exists($testfunction)) {
381 $option .=
' - '.$langs->trans(
"FunctionNotAvailableInThisPHP");
383 $option .=
'</option>';
390 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_type !==
null) {
394 <?php print $option; ?>
398 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseType"); ?></td>
402 <tr
class=
"hidesqlite">
403 <td
class=
"label"><label
for=
"db_host"><b><?php echo $langs->trans(
"DatabaseServer"); ?></b></label></td>
408 value=
"<?php print(!empty($force_install_dbserver) ? $force_install_dbserver : (!empty($dolibarr_main_db_host) ? $dolibarr_main_db_host : 'localhost')); ?>"
409 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_dbserver !==
null) {
414 <td
class=
"comment"><?php echo $langs->trans(
"ServerAddressDescription"); ?>
419 <tr
class=
"hidesqlite">
420 <td
class=
"label"><label
for=
"db_port"><?php echo $langs->trans(
"Port"); ?></label></td>
425 value=
"<?php print (!empty($force_install_port)) ? $force_install_port : $dolibarr_main_db_port; ?>"
426 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_port !==
null) {
431 <td
class=
"comment"><?php echo $langs->trans(
"ServerPortDescription"); ?>
436 <tr
class=
"hidesqlite">
437 <td
class=
"label"><label
for=
"db_prefix"><?php echo $langs->trans(
"DatabasePrefix"); ?></label></td>
442 value=
"<?php echo(!empty($force_install_prefix) ? $force_install_prefix : (!empty($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : 'llx_')); ?>"
443 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_prefix !==
null) {
448 <td
class=
"comment"><?php echo $langs->trans(
"DatabasePrefixDescription"); ?></td>
451 <tr
class=
"hidesqlite">
452 <td
class=
"label"><label
for=
"db_create_database"><?php echo $langs->trans(
"CreateDatabase"); ?></label></td>
454 <input
type=
"checkbox"
455 id=
"db_create_database"
456 name=
"db_create_database"
460 if ($force_install_createdatabase) {
464 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_createdatabase !==
null) {
470 <?php echo $langs->trans(
"CheckToCreateDatabase"); ?>
474 <tr
class=
"hidesqlite">
475 <td
class=
"label"><label
for=
"db_user"><b><?php echo $langs->trans(
"Login"); ?></b></label></td>
480 value=
"<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>"
481 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_databaselogin !==
null) {
486 <td
class=
"comment"><?php echo $langs->trans(
"AdminLogin"); ?></td>
489 <tr
class=
"hidesqlite">
490 <td
class=
"label"><label
for=
"db_pass"><b><?php echo $langs->trans(
"Password"); ?></b></label></td>
492 <input
type=
"password" class=
"text-security"
493 id=
"db_pass" autocomplete=
"off"
496 // 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.
497 // @phan-suppress-next-line PhanParamSuspiciousOrder
498 $autofill = ((!empty($_SESSION['dol_save_pass'])) ? $_SESSION['dol_save_pass'] : str_pad('', strlen($force_install_databasepass), '*'));
499 if (!empty($dolibarr_main_prod) && empty($_SESSION['dol_save_pass'])) { // So value can't be found if install page still accessible
502 print dol_escape_htmltag($autofill);
504 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_databasepass !==
null) {
509 <td
class=
"comment"><?php echo $langs->trans(
"AdminPassword"); ?></td>
512 <tr
class=
"hidesqlite">
513 <td
class=
"label"><label
for=
"db_create_user"><?php echo $langs->trans(
"CreateUser"); ?></label></td>
515 <input
type=
"checkbox"
517 name=
"db_create_user"
521 if (!empty($force_install_createuser)) {
525 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_createuser !==
null) {
531 <?php echo $langs->trans(
"CheckToCreateUser"); ?>
536 <!-- Super access -->
541 <tr
class=
"hidesqlite hideroot">
542 <td colspan=
"3" class=
"label"><br>
543 <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>
547 <tr
class=
"hidesqlite hideroot">
548 <td
class=
"label"><label
for=
"db_user_root"><b><?php echo $langs->trans(
"Login"); ?></b></label></td>
554 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 : '')); ?>"
555 <?php
if ($force_install_noedit > 0 && !empty($force_install_databaserootlogin)) {
560 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseRootLoginDescription"); ?>
562 <?php echo
'<br>'.$langs->trans(
"Examples").
':<br>' ?>
564 <li>root (Mysql)</li>
565 <li>postgres (PostgreSql)</li>
571 <tr
class=
"hidesqlite hideroot">
572 <td
class=
"label"><label
for=
"db_pass_root"><b><?php echo $langs->trans(
"Password"); ?></b></label></td>
574 <input
type=
"password"
578 class=
"needroot text-security"
580 // 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.
581 // @phan-suppress-next-line PhanParamSuspiciousOrder
582 $autofill = ((!empty($force_install_databaserootpass)) ? str_pad('', strlen($force_install_databaserootpass), '*') : (isset($db_pass_root) ? $db_pass_root : ''));
583 if (!empty($dolibarr_main_prod)) {
586 // Do not autofill password if instance is a production instance
587 if (!empty($_SERVER["SERVER_NAME
"]) && !in_array(
588 $_SERVER["SERVER_NAME
"],
589 array('127.0.0.1', 'localhost', 'localhostgit')
593 } // Do not autofill password for remote access
594 print dol_escape_htmltag($autofill);
596 <?php
if ($force_install_noedit > 0 && !empty($force_install_databaserootpass)) {
601 <td
class=
"comment"><?php echo $langs->trans(
"KeepEmptyIfNoPassword"); ?>
609<script
type=
"text/javascript">
610function init_needroot()
612 console.log(
"init_needroot force_install_noedit=<?php echo $force_install_noedit?>");
613 console.log(jQuery(
"#db_create_database").is(
":checked"));
614 console.log(jQuery(
"#db_create_user").is(
":checked"));
616 if (jQuery(
"#db_create_database").is(
":checked") || jQuery(
"#db_create_user").is(
":checked"))
618 console.log(
"init_needroot show root section");
619 jQuery(
".hideroot").show();
621 if (empty($force_install_noedit)) { ?>
622 jQuery(
".needroot").removeAttr(
'disabled');
627 console.log(
"init_needroot hide root section");
628 jQuery(
".hideroot").hide();
629 jQuery(
".needroot").prop(
'disabled',
true);
633function checkDatabaseName(databasename) {
634 if (databasename.match(/[;\.]/)) {
return false; }
638function jscheckparam()
640 console.log(
"Click on jscheckparam");
644 if (document.forminstall.main_dir.value ==
'')
647 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("WebPagesDirectory"))); ?>');
649 else if (document.forminstall.main_data_dir.value ==
'')
652 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DocumentsDirectory"))); ?>');
654 else if (document.forminstall.main_url.value ==
'')
657 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("URLRoot"))); ?>');
659 else if (document.forminstall.db_host.value ==
'')
662 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Server"))); ?>');
664 else if (document.forminstall.db_name.value ==
'')
667 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatabaseName"))); ?>');
669 else if (! checkDatabaseName(document.forminstall.db_name.value))
672 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentitiesnoconv("DatabaseName"))); ?>');
675 else if (document.forminstall.db_create_database.checked ==
true && (document.forminstall.db_user_root.value ==
''))
678 alert(
'<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>');
682 else if (document.forminstall.db_create_user.checked ==
true && (document.forminstall.db_user_root.value ==
''))
685 alert(
'<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>');
693jQuery(document).ready(
function() {
695 var dbtype = jQuery(
"#db_type");
697 dbtype.change(
function () {
698 if (dbtype.val() ==
'sqlite' || dbtype.val() ==
'sqlite3') {
699 jQuery(
".hidesqlite").hide();
701 jQuery(
".hidesqlite").show();
705 if (dbtype.val() ==
'mysql' || dbtype.val() ==
'mysqli') {
706 jQuery(
"#db_port").val(3306);
707 jQuery(
"#db_user_root").val(
'root');
708 }
else if (dbtype.val() ==
'pgsql') {
709 jQuery(
"#db_port").val(5432);
710 jQuery(
"#db_user_root").val(
'postgres');
711 }
else if (dbtype.val() ==
'mssql') {
712 jQuery(
"#db_port").val(1433);
713 jQuery(
"#db_user_root").val(
'sa');
718 jQuery(
"#db_create_database").click(
function() {
719 console.log(
"click on db_create_database");
722 jQuery(
"#db_create_user").click(
function() {
723 console.log(
"click on db_create_user");
726 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && empty($force_install_databasepass)) { ?>
727 jQuery(
"#db_pass").focus();
741pFooter($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.