32include_once
'inc.php';
38$setuplang =
GETPOST(
"selectlang",
'alpha', 3) ?
GETPOST(
"selectlang",
'alpha', 3) : (
GETPOST(
'lang',
'alpha', 1) ?
GETPOST(
'lang',
'alpha', 1) :
'auto');
39$langs->setDefaultLang($setuplang);
41$langs->loadLangs(array(
"install",
"errors"));
49if (!isset($force_install_noedit)) {
50 $force_install_noedit =
'';
52if (!isset($force_install_type)) {
53 $force_install_type =
'';
55if (!isset($force_install_dbserver)) {
56 $force_install_dbserver =
'';
58if (!isset($force_install_port)) {
59 $force_install_port =
'';
61if (!isset($force_install_database)) {
62 $force_install_database =
'';
64if (!isset($force_install_prefix)) {
65 $force_install_prefix =
'';
67if (!isset($force_install_createdatabase)) {
68 $force_install_createdatabase =
'';
70if (!isset($force_install_databaselogin)) {
71 $force_install_databaselogin =
'';
73if (!isset($force_install_databasepass)) {
74 $force_install_databasepass =
'';
76if (!isset($force_install_databaserootlogin)) {
77 $force_install_databaserootlogin =
'';
79if (!isset($force_install_databaserootpass)) {
80 $force_install_databaserootpass =
'';
83$useforcedwizard =
false;
84$forcedfile =
"./install.forced.php";
85if ($conffile ==
"/etc/dolibarr/conf.php") {
86 $forcedfile =
"/etc/dolibarr/install.forced.php";
88if (@file_exists($forcedfile)) {
89 $useforcedwizard =
true;
90 include_once $forcedfile;
101pHeader($langs->trans(
"DolibarrSetup").
' - '.$langs->trans(
"ConfigurationFile"),
"step1",
"set",
"", (empty($force_dolibarr_js_JQUERY) ?
'' : $force_dolibarr_js_JQUERY.
'/'),
'main-inside-bis');
104if (!is_writable($conffile)) {
105 print $langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
108 pFooter(1, $setuplang,
'jscheckparam');
112if (!empty($force_install_message)) {
113 print
'<div><br>'.$langs->trans($force_install_message).
'</div>';
133<
table class=
"nobordernopadding<?php if ($force_install_noedit) {
134 print ' hidewhennoedit';
138 <td colspan=
"3" class=
"label">
139 <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>
143 <!--
Documents root $dolibarr_main_document_root -->
145 <td
class=
"label"><label
for=
"main_dir"><b><?php print $langs->trans(
"WebPagesDirectory"); ?></b></label></td>
147if (empty($dolibarr_main_document_root)) {
156 value=
"<?php print $dolibarr_main_document_root ?>"
158if (!empty($force_install_noedit)) {
164 <td
class=
"comment"><?php
165 print
'<span class="opacitymedium">'.$langs->trans(
"WithNoSlashAtTheEnd").
"</span><br>";
166 print $langs->trans(
"Examples").
":<br>";
169 <li>/var/www/dolibarr/htdocs</li>
170 <li>C:/wwwroot/dolibarr/htdocs</li>
175 <!--
Documents URL $dolibarr_main_data_root -->
177 <td
class=
"label"><label
for=
"main_data_dir"><b><?php print $langs->trans(
"DocumentsDirectory"); ?></b></label></td>
179 if (!empty($force_install_main_data_root)) {
180 $dolibarr_main_data_root = @$force_install_main_data_root;
182 if (empty($dolibarr_main_data_root)) {
191 value=
"<?php print $dolibarr_main_data_root ?>"
192<?php
if (!empty($force_install_noedit)) {
197 <td
class=
"comment"><?php
198 print
'<span class="opacitymedium">'.$langs->trans(
"WithNoSlashAtTheEnd").
"</span><br>";
199 print $langs->trans(
"DirectoryRecommendation").
"<br>";
200 print $langs->trans(
"Examples").
":<br>";
203 <li>/var/lib/dolibarr/documents</li>
204 <li>C:/My
Documents/dolibarr/documents</li>
209 <!-- Root URL $dolibarr_main_url_root -->
211 if (empty($dolibarr_main_url_root)) {
216 <td
class=
"label"><label
for=
"main_url"><b><?php echo $langs->trans(
"URLRoot"); ?></b></label>
223 value=
"<?php print $dolibarr_main_url_root; ?> "
224<?php
if (!empty($force_install_noedit) && $force_install_noedit != 3) {
230 <td
class=
"comment"><?php print $langs->trans(
"Examples").
":<br>"; ?>
240 if (!empty($_SERVER[
"HTTPS"]) && $_SERVER[
"HTTPS"] ==
'on') {
243 <td
class=
"label"><label
for=
"main_force_https"><?php echo $langs->trans(
"ForceHttps"); ?></label></td>
245 <input
type=
"checkbox"
246 id=
"main_force_https"
247 name=
"main_force_https"
248 <?php
if (!empty($force_install_mainforcehttps)) {
251 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_mainforcehttps !==
null) {
256 <td
class=
"comment"><?php echo $langs->trans(
"CheckToForceHttps"); ?>
264 <!-- Dolibarr database -->
267 <td colspan=
"3" class=
"label"><br>
268 <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>
273 <td
class=
"label"><label
for=
"db_name"><b><?php echo $langs->trans(
"DatabaseName"); ?></b></label></td>
278 value=
"<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>"
279 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_database !==
null) {
284 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseName"); ?></td>
289 if (!isset($dolibarr_main_db_host)) {
290 $dolibarr_main_db_host =
"localhost";
295 <td
class=
"label"><label
for=
"db_type"><b><?php echo $langs->trans(
"DriverType"); ?></b></label></td>
300 $defaultype = !empty($dolibarr_main_db_type) ? $dolibarr_main_db_type : (empty($force_install_type) ?
'mysqli' : $force_install_type);
307 $dir = DOL_DOCUMENT_ROOT.
'/core/db';
308 $handle = opendir($dir);
309 if (is_resource($handle)) {
310 while (($file = readdir($handle)) !==
false) {
311 if (is_readable($dir.
"/".$file) && preg_match(
'/^(.*)\.class\.php$/i', $file, $reg)) {
313 if ($type ===
'DoliDB') {
316 $class =
'DoliDB'.ucfirst($type);
317 include_once $dir.
"/".$file;
319 if ($type ==
'sqlite') {
322 if ($type ==
'sqlite3') {
327 $note =
'('.$class::LABEL.
' >= '.$class::VERSIONMIN.
')';
330 if ($defaultype ==
'mysqli' && !function_exists(
'mysqli_connect')) {
331 $defaultype =
'mysql';
335 if ($type ==
'mysql') {
336 $testfunction =
'mysql_connect';
339 if ($type ==
'mysqli') {
340 $testfunction =
'mysqli_connect';
343 if ($type ==
'pgsql') {
344 $testfunction =
'pg_connect';
347 if ($type ==
'mssql') {
348 $testfunction =
'mssql_connect';
351 if ($type ==
'sqlite') {
355 if ($type ==
'sqlite3') {
357 $testclass =
'SQLite3';
359 $option .=
'<option value="'.$type.
'"'.($defaultype == $type ?
' selected' :
'');
360 if ($testfunction && !function_exists($testfunction)) {
361 $option .=
' disabled';
363 if ($testclass && !class_exists($testclass)) {
364 $option .=
' disabled';
367 $option .= $type.
' ';
369 $option .=
' '.$note;
372 if ($type ==
'mysql') {
373 $option .=
' '.$langs->trans(
"Deprecated");
374 } elseif ($type ==
'mssql') {
375 $option .=
' '.$langs->trans(
"VersionExperimental");
376 } elseif ($type ==
'sqlite') {
377 $option .=
' '.$langs->trans(
"VersionExperimental");
378 } elseif ($type ==
'sqlite3') {
379 $option .=
' '.$langs->trans(
"VersionExperimental");
380 } elseif ($testfunction ===
null || !function_exists($testfunction)) {
382 $option .=
' - '.$langs->trans(
"FunctionNotAvailableInThisPHP");
384 $option .=
'</option>';
391 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_type !==
null) {
395 <?php print $option; ?>
399 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseType"); ?></td>
403 <tr
class=
"hidesqlite">
404 <td
class=
"label"><label
for=
"db_host"><b><?php echo $langs->trans(
"DatabaseServer"); ?></b></label></td>
409 value=
"<?php print(!empty($force_install_dbserver) ? $force_install_dbserver : (!empty($dolibarr_main_db_host) ? $dolibarr_main_db_host : 'localhost')); ?>"
410 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_dbserver !==
null) {
415 <td
class=
"comment"><?php echo $langs->trans(
"ServerAddressDescription"); ?>
420 <tr
class=
"hidesqlite">
421 <td
class=
"label"><label
for=
"db_port"><?php echo $langs->trans(
"Port"); ?></label></td>
426 value=
"<?php print (!empty($force_install_port)) ? $force_install_port : $dolibarr_main_db_port; ?>"
427 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_port !==
null) {
432 <td
class=
"comment"><?php echo $langs->trans(
"ServerPortDescription"); ?>
437 <tr
class=
"hidesqlite">
438 <td
class=
"label"><label
for=
"db_prefix"><?php echo $langs->trans(
"DatabasePrefix"); ?></label></td>
443 value=
"<?php echo(!empty($force_install_prefix) ? $force_install_prefix : (!empty($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : 'llx_')); ?>"
444 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_prefix !==
null) {
449 <td
class=
"comment"><?php echo $langs->trans(
"DatabasePrefixDescription"); ?></td>
452 <tr
class=
"hidesqlite">
453 <td
class=
"label"><label
for=
"db_create_database"><?php echo $langs->trans(
"CreateDatabase"); ?></label></td>
455 <input
type=
"checkbox"
456 id=
"db_create_database"
457 name=
"db_create_database"
461 if ($force_install_createdatabase) {
465 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_createdatabase !==
null) {
471 <?php echo $langs->trans(
"CheckToCreateDatabase"); ?>
475 <tr
class=
"hidesqlite">
476 <td
class=
"label"><label
for=
"db_user"><b><?php echo $langs->trans(
"Login"); ?></b></label></td>
481 value=
"<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>"
482 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_databaselogin !==
null) {
487 <td
class=
"comment"><?php echo $langs->trans(
"AdminLogin"); ?></td>
490 <tr
class=
"hidesqlite">
491 <td
class=
"label"><label
for=
"db_pass"><b><?php echo $langs->trans(
"Password"); ?></b></label></td>
493 <input
type=
"password" class=
"text-security"
494 id=
"db_pass" autocomplete=
"off"
497 // 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.
498 // @phan-suppress-next-line PhanParamSuspiciousOrder
499 $autofill = ((!empty($_SESSION['dol_save_pass'])) ? $_SESSION['dol_save_pass'] : str_pad('', strlen($force_install_databasepass), '*'));
500 if (!empty($dolibarr_main_prod) && empty($_SESSION['dol_save_pass'])) { // So value can't be found if install page still accessible
503 print dol_escape_htmltag($autofill);
505 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_databasepass !==
null) {
510 <td
class=
"comment"><?php echo $langs->trans(
"AdminPassword"); ?></td>
513 <tr
class=
"hidesqlite">
514 <td
class=
"label"><label
for=
"db_create_user"><?php echo $langs->trans(
"CreateUser"); ?></label></td>
516 <input
type=
"checkbox"
518 name=
"db_create_user"
522 if (!empty($force_install_createuser)) {
526 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_createuser !==
null) {
532 <?php echo $langs->trans(
"CheckToCreateUser"); ?>
537 <!-- Super access -->
542 <tr
class=
"hidesqlite hideroot">
543 <td colspan=
"3" class=
"label"><br>
544 <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>
548 <tr
class=
"hidesqlite hideroot">
549 <td
class=
"label"><label
for=
"db_user_root"><b><?php echo $langs->trans(
"Login"); ?></b></label></td>
555 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 : '')); ?>"
556 <?php
if ($force_install_noedit > 0 && !empty($force_install_databaserootlogin)) {
561 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseRootLoginDescription"); ?>
563 <?php echo
'<br>'.$langs->trans(
"Examples").
':<br>' ?>
565 <li>root (Mysql)</li>
566 <li>postgres (PostgreSql)</li>
572 <tr
class=
"hidesqlite hideroot">
573 <td
class=
"label"><label
for=
"db_pass_root"><b><?php echo $langs->trans(
"Password"); ?></b></label></td>
575 <input
type=
"password"
579 class=
"needroot text-security"
581 // 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.
582 // @phan-suppress-next-line PhanParamSuspiciousOrder
583 $autofill = ((!empty($force_install_databaserootpass)) ? str_pad('', strlen($force_install_databaserootpass), '*') : (isset($db_pass_root) ? $db_pass_root : ''));
584 if (!empty($dolibarr_main_prod)) {
587 // Do not autofill password if instance is a production instance
588 if (!empty($_SERVER["SERVER_NAME
"]) && !in_array(
589 $_SERVER["SERVER_NAME
"],
590 array('127.0.0.1', 'localhost', 'localhostgit')
594 } // Do not autofill password for remote access
595 print dol_escape_htmltag($autofill);
597 <?php
if ($force_install_noedit > 0 && !empty($force_install_databaserootpass)) {
602 <td
class=
"comment"><?php echo $langs->trans(
"KeepEmptyIfNoPassword"); ?>
610<script
type=
"text/javascript">
611function init_needroot()
613 console.log(
"init_needroot force_install_noedit=<?php echo $force_install_noedit?>");
614 console.log(jQuery(
"#db_create_database").is(
":checked"));
615 console.log(jQuery(
"#db_create_user").is(
":checked"));
617 if (jQuery(
"#db_create_database").is(
":checked") || jQuery(
"#db_create_user").is(
":checked"))
619 console.log(
"init_needroot show root section");
620 jQuery(
".hideroot").show();
622 if (empty($force_install_noedit)) { ?>
623 jQuery(
".needroot").removeAttr(
'disabled');
628 console.log(
"init_needroot hide root section");
629 jQuery(
".hideroot").hide();
630 jQuery(
".needroot").prop(
'disabled',
true);
634function checkDatabaseName(databasename) {
635 if (databasename.match(/[;\.]/)) {
return false; }
639function jscheckparam()
641 console.log(
"Click on jscheckparam");
645 if (document.forminstall.main_dir.value ==
'')
648 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("WebPagesDirectory"))); ?>');
650 else if (document.forminstall.main_data_dir.value ==
'')
653 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DocumentsDirectory"))); ?>');
655 else if (document.forminstall.main_url.value ==
'')
658 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("URLRoot"))); ?>');
660 else if (document.forminstall.db_host.value ==
'')
663 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Server"))); ?>');
665 else if (document.forminstall.db_name.value ==
'')
668 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatabaseName"))); ?>');
670 else if (! checkDatabaseName(document.forminstall.db_name.value))
673 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentitiesnoconv("DatabaseName"))); ?>');
676 else if (document.forminstall.db_create_database.checked ==
true && (document.forminstall.db_user_root.value ==
''))
679 alert(
'<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>');
683 else if (document.forminstall.db_create_user.checked ==
true && (document.forminstall.db_user_root.value ==
''))
686 alert(
'<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>');
694jQuery(document).ready(
function() {
696 var dbtype = jQuery(
"#db_type");
698 dbtype.change(
function () {
699 if (dbtype.val() ==
'sqlite' || dbtype.val() ==
'sqlite3') {
700 jQuery(
".hidesqlite").hide();
702 jQuery(
".hidesqlite").show();
706 if (dbtype.val() ==
'mysql' || dbtype.val() ==
'mysqli') {
707 jQuery(
"#db_port").val(3306);
708 jQuery(
"#db_user_root").val(
'root');
709 }
else if (dbtype.val() ==
'pgsql') {
710 jQuery(
"#db_port").val(5432);
711 jQuery(
"#db_user_root").val(
'postgres');
712 }
else if (dbtype.val() ==
'mssql') {
713 jQuery(
"#db_port").val(1433);
714 jQuery(
"#db_user_root").val(
'sa');
719 jQuery(
"#db_create_database").click(
function() {
720 console.log(
"click on db_create_database");
723 jQuery(
"#db_create_user").click(
function() {
724 console.log(
"click on db_create_user");
727 <?php
if (($force_install_noedit == 2 || $force_install_noedit == 3) && empty($force_install_databasepass)) { ?>
728 jQuery(
"#db_pass").focus();
742pFooter($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.