30include_once
'inc.php';
36$setuplang =
GETPOST(
"selectlang",
'alpha', 3) ?
GETPOST(
"selectlang",
'alpha', 3) : (
GETPOST(
'lang',
'alpha', 1) ?
GETPOST(
'lang',
'alpha', 1) :
'auto');
37$langs->setDefaultLang($setuplang);
39$langs->loadLangs(array(
"install",
"errors"));
47if (!isset($force_install_noedit)) {
48 $force_install_noedit =
'';
50if (!isset($force_install_type)) {
51 $force_install_type =
'';
53if (!isset($force_install_dbserver)) {
54 $force_install_dbserver =
'';
56if (!isset($force_install_port)) {
57 $force_install_port =
'';
59if (!isset($force_install_database)) {
60 $force_install_database =
'';
62if (!isset($force_install_prefix)) {
63 $force_install_prefix =
'';
65if (!isset($force_install_createdatabase)) {
66 $force_install_createdatabase =
'';
68if (!isset($force_install_databaselogin)) {
69 $force_install_databaselogin =
'';
71if (!isset($force_install_databasepass)) {
72 $force_install_databasepass =
'';
74if (!isset($force_install_databaserootlogin)) {
75 $force_install_databaserootlogin =
'';
77if (!isset($force_install_databaserootpass)) {
78 $force_install_databaserootpass =
'';
81$useforcedwizard =
false;
82$forcedfile =
"./install.forced.php";
83if ($conffile ==
"/etc/dolibarr/conf.php") {
84 $forcedfile =
"/etc/dolibarr/install.forced.php";
86if (@file_exists($forcedfile)) {
87 $useforcedwizard =
true;
88 include_once $forcedfile;
99pHeader($langs->trans(
"ConfigurationFile"),
"step1",
"set",
"", (empty($force_dolibarr_js_JQUERY) ?
'' : $force_dolibarr_js_JQUERY.
'/'),
'main-inside-bis');
102if (!is_writable($conffile)) {
103 print $langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
106 pFooter(1, $setuplang,
'jscheckparam');
110if (!empty($force_install_message)) {
111 print
'<div><br>'.$langs->trans($force_install_message).
'</div>';
131<table
class=
"nobordernopadding<?php if ($force_install_noedit) {
132 print ' hidewhennoedit';
136 <td colspan=
"3" class=
"label">
137 <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>
141 <!--
Documents root $dolibarr_main_document_root -->
143 <td
class=
"label"><label
for=
"main_dir"><b><?php print $langs->trans(
"WebPagesDirectory"); ?></b></label></td>
145if (empty($dolibarr_main_document_root)) {
154 value=
"<?php print $dolibarr_main_document_root ?>"
156if (!empty($force_install_noedit)) {
162 <td
class=
"comment"><?php
163 print
'<span class="opacitymedium">'.$langs->trans(
"WithNoSlashAtTheEnd").
"</span><br>";
164 print $langs->trans(
"Examples").
":<br>";
167 <li>/var/www/dolibarr/htdocs</li>
168 <li>C:/wwwroot/dolibarr/htdocs</li>
173 <!--
Documents URL $dolibarr_main_data_root -->
175 <td
class=
"label"><label
for=
"main_data_dir"><b><?php print $langs->trans(
"DocumentsDirectory"); ?></b></label></td>
177 if (!empty($force_install_main_data_root)) {
178 $dolibarr_main_data_root = @$force_install_main_data_root;
180 if (empty($dolibarr_main_data_root)) {
189 value=
"<?php print $dolibarr_main_data_root ?>"
190<?php
if (!empty($force_install_noedit)) {
195 <td
class=
"comment"><?php
196 print
'<span class="opacitymedium">'.$langs->trans(
"WithNoSlashAtTheEnd").
"</span><br>";
197 print $langs->trans(
"DirectoryRecommendation").
"<br>";
198 print $langs->trans(
"Examples").
":<br>";
201 <li>/var/lib/dolibarr/documents</li>
202 <li>C:/My
Documents/dolibarr/documents</li>
207 <!-- Root URL $dolibarr_main_url_root -->
209 if (empty($dolibarr_main_url_root)) {
214 <td
class=
"label"><label
for=
"main_url"><b><?php echo $langs->trans(
"URLRoot"); ?></b></label>
221 value=
"<?php print $dolibarr_main_url_root; ?> "
222<?php
if (!empty($force_install_noedit)) {
228 <td
class=
"comment"><?php print $langs->trans(
"Examples").
":<br>"; ?>
238 if (!empty($_SERVER[
"HTTPS"]) && $_SERVER[
"HTTPS"] ==
'on') {
241 <td
class=
"label"><label
for=
"main_force_https"><?php echo $langs->trans(
"ForceHttps"); ?></label></td>
243 <input
type=
"checkbox"
244 id=
"main_force_https"
245 name=
"main_force_https"
246 <?php
if (!empty($force_install_mainforcehttps)) {
249 <?php
if ($force_install_noedit == 2 && $force_install_mainforcehttps !==
null) {
254 <td
class=
"comment"><?php echo $langs->trans(
"CheckToForceHttps"); ?>
262 <!-- Dolibarr database -->
265 <td colspan=
"3" class=
"label"><br>
266 <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>
271 <td
class=
"label"><label
for=
"db_name"><b><?php echo $langs->trans(
"DatabaseName"); ?></b></label></td>
276 value=
"<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>"
277 <?php
if ($force_install_noedit == 2 && $force_install_database !==
null) {
282 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseName"); ?></td>
287 if (!isset($dolibarr_main_db_host)) {
288 $dolibarr_main_db_host =
"localhost";
293 <td
class=
"label"><label
for=
"db_type"><b><?php echo $langs->trans(
"DriverType"); ?></b></label></td>
298 $defaultype = !empty($dolibarr_main_db_type) ? $dolibarr_main_db_type : (empty($force_install_type) ?
'mysqli' : $force_install_type);
305 $dir = DOL_DOCUMENT_ROOT.
'/core/db';
306 $handle = opendir($dir);
307 if (is_resource($handle)) {
308 while (($file = readdir($handle)) !==
false) {
309 if (is_readable($dir.
"/".$file) && preg_match(
'/^(.*)\.class\.php$/i', $file, $reg)) {
311 if ($type ===
'DoliDB') {
314 $class =
'DoliDB'.ucfirst($type);
315 include_once $dir.
"/".$file;
317 if ($type ==
'sqlite') {
320 if ($type ==
'sqlite3') {
325 $versionbasemin = explode(
'.', $class::VERSIONMIN);
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'; $testclass =
'';
337 if ($type ==
'mysqli') {
338 $testfunction =
'mysqli_connect'; $testclass =
'';
340 if ($type ==
'pgsql') {
341 $testfunction =
'pg_connect'; $testclass =
'';
343 if ($type ==
'mssql') {
344 $testfunction =
'mssql_connect'; $testclass =
'';
346 if ($type ==
'sqlite') {
347 $testfunction =
''; $testclass =
'PDO';
349 if ($type ==
'sqlite3') {
350 $testfunction =
''; $testclass =
'SQLite3';
352 $option .=
'<option value="'.$type.
'"'.($defaultype == $type ?
' selected' :
'');
353 if ($testfunction && !function_exists($testfunction)) {
354 $option .=
' disabled';
356 if ($testclass && !class_exists($testclass)) {
357 $option .=
' disabled';
360 $option .= $type.
' ';
362 $option .=
' '.$note;
365 if ($type ==
'mysql') {
366 $option .=
' '.$langs->trans(
"Deprecated");
367 } elseif ($type ==
'mssql') {
368 $option .=
' '.$langs->trans(
"VersionExperimental");
369 } elseif ($type ==
'sqlite') {
370 $option .=
' '.$langs->trans(
"VersionExperimental");
371 } elseif ($type ==
'sqlite3') {
372 $option .=
' '.$langs->trans(
"VersionExperimental");
373 } elseif (!function_exists($testfunction)) {
375 $option .=
' - '.$langs->trans(
"FunctionNotAvailableInThisPHP");
377 $option .=
'</option>';
384 <?php
if ($force_install_noedit == 2 && $force_install_type !==
null) {
388 <?php print $option; ?>
392 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseType"); ?></td>
396 <tr
class=
"hidesqlite">
397 <td
class=
"label"><label
for=
"db_host"><b><?php echo $langs->trans(
"DatabaseServer"); ?></b></label></td>
402 value=
"<?php print (!empty($force_install_dbserver) ? $force_install_dbserver : (!empty($dolibarr_main_db_host) ? $dolibarr_main_db_host : 'localhost')); ?>"
403 <?php
if ($force_install_noedit == 2 && $force_install_dbserver !==
null) {
408 <td
class=
"comment"><?php echo $langs->trans(
"ServerAddressDescription"); ?>
413 <tr
class=
"hidesqlite">
414 <td
class=
"label"><label
for=
"db_port"><?php echo $langs->trans(
"Port"); ?></label></td>
419 value=
"<?php print (!empty($force_install_port)) ? $force_install_port : $dolibarr_main_db_port; ?>"
420 <?php
if ($force_install_noedit == 2 && $force_install_port !==
null) {
425 <td
class=
"comment"><?php echo $langs->trans(
"ServerPortDescription"); ?>
430 <tr
class=
"hidesqlite">
431 <td
class=
"label"><label
for=
"db_prefix"><?php echo $langs->trans(
"DatabasePrefix"); ?></label></td>
436 value=
"<?php echo(!empty($force_install_prefix) ? $force_install_prefix : (!empty($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : 'llx_')); ?>"
437 <?php
if ($force_install_noedit == 2 && $force_install_prefix !==
null) {
442 <td
class=
"comment"><?php echo $langs->trans(
"DatabasePrefixDescription"); ?></td>
445 <tr
class=
"hidesqlite">
446 <td
class=
"label"><label
for=
"db_create_database"><?php echo $langs->trans(
"CreateDatabase"); ?></label></td>
448 <input
type=
"checkbox"
449 id=
"db_create_database"
450 name=
"db_create_database"
454 if ($force_install_createdatabase) {
458 <?php
if ($force_install_noedit == 2 && $force_install_createdatabase !==
null) {
464 <?php echo $langs->trans(
"CheckToCreateDatabase"); ?>
468 <tr
class=
"hidesqlite">
469 <td
class=
"label"><label
for=
"db_user"><b><?php echo $langs->trans(
"Login"); ?></b></label></td>
474 value=
"<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>"
475 <?php
if ($force_install_noedit == 2 && $force_install_databaselogin !==
null) {
480 <td
class=
"comment"><?php echo $langs->trans(
"AdminLogin"); ?></td>
483 <tr
class=
"hidesqlite">
484 <td
class=
"label"><label
for=
"db_pass"><b><?php echo $langs->trans(
"Password"); ?></b></label></td>
486 <input
type=
"password" class=
"text-security";
487 id=
"db_pass" autocomplete=
"off"
490 // 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.
491 $autofill = ((!empty($_SESSION['dol_save_pass'])) ? $_SESSION['dol_save_pass'] : str_pad('', strlen($force_install_databasepass), '*'));
492 if (!empty($dolibarr_main_prod) && empty($_SESSION['dol_save_pass'])) { // So value can't be found if install page still accessible
495 print dol_escape_htmltag($autofill);
497 <?php
if ($force_install_noedit == 2 && $force_install_databasepass !==
null) {
502 <td
class=
"comment"><?php echo $langs->trans(
"AdminPassword"); ?></td>
505 <tr
class=
"hidesqlite">
506 <td
class=
"label"><label
for=
"db_create_user"><?php echo $langs->trans(
"CreateUser"); ?></label></td>
508 <input
type=
"checkbox"
510 name=
"db_create_user"
514 if (!empty($force_install_createuser)) {
518 <?php
if ($force_install_noedit == 2 && $force_install_createuser !==
null) {
524 <?php echo $langs->trans(
"CheckToCreateUser"); ?>
529 <!-- Super access -->
534 <tr
class=
"hidesqlite hideroot">
535 <td colspan=
"3" class=
"label"><br>
536 <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>
540 <tr
class=
"hidesqlite hideroot">
541 <td
class=
"label"><label
for=
"db_user_root"><b><?php echo $langs->trans(
"Login"); ?></b></label></td>
547 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 : '')); ?>"
548 <?php
if ($force_install_noedit > 0 && !empty($force_install_databaserootlogin)) {
553 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseRootLoginDescription"); ?>
555 <?php echo
'<br>'.$langs->trans(
"Examples").
':<br>' ?>
557 <li>root (Mysql)</li>
558 <li>postgres (PostgreSql)</li>
564 <tr
class=
"hidesqlite hideroot">
565 <td
class=
"label"><label
for=
"db_pass_root"><b><?php echo $langs->trans(
"Password"); ?></b></label></td>
567 <input
type=
"password"
571 class=
"needroot text-security"
573 // 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.
574 $autofill = ((!empty($force_install_databaserootpass)) ? str_pad('', strlen($force_install_databaserootpass), '*') : (isset($db_pass_root) ? $db_pass_root : ''));
575 if (!empty($dolibarr_main_prod)) {
578 // Do not autofill password if instance is a production instance
579 if (!empty($_SERVER["SERVER_NAME
"]) && !in_array(
580 $_SERVER["SERVER_NAME
"],
581 array('127.0.0.1', 'localhost', 'localhostgit')
585 } // Do not autofill password for remote access
586 print dol_escape_htmltag($autofill);
588 <?php
if ($force_install_noedit > 0 && !empty($force_install_databaserootpass)) {
593 <td
class=
"comment"><?php echo $langs->trans(
"KeepEmptyIfNoPassword"); ?>
600<script
type=
"text/javascript">
601function init_needroot()
603 console.log(
"init_needroot force_install_noedit=<?php echo $force_install_noedit?>");
604 console.log(jQuery(
"#db_create_database").is(
":checked"));
605 console.log(jQuery(
"#db_create_user").is(
":checked"));
607 if (jQuery(
"#db_create_database").is(
":checked") || jQuery(
"#db_create_user").is(
":checked"))
609 console.log(
"init_needroot show root section");
610 jQuery(
".hideroot").show();
612 if (empty($force_install_noedit)) { ?>
613 jQuery(
".needroot").removeAttr(
'disabled');
618 console.log(
"init_needroot hide root section");
619 jQuery(
".hideroot").hide();
620 jQuery(
".needroot").prop(
'disabled',
true);
624function checkDatabaseName(databasename) {
625 if (databasename.match(/[;\.]/)) {
return false; }
629function jscheckparam()
631 console.log(
"Click on jscheckparam");
635 if (document.forminstall.main_dir.value ==
'')
638 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("WebPagesDirectory"))); ?>');
640 else if (document.forminstall.main_data_dir.value ==
'')
643 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DocumentsDirectory"))); ?>');
645 else if (document.forminstall.main_url.value ==
'')
648 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("URLRoot"))); ?>');
650 else if (document.forminstall.db_host.value ==
'')
653 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Server"))); ?>');
655 else if (document.forminstall.db_name.value ==
'')
658 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatabaseName"))); ?>');
660 else if (! checkDatabaseName(document.forminstall.db_name.value))
663 alert(
'<?php echo dol_escape_js($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentitiesnoconv("DatabaseName"))); ?>');
666 else if (document.forminstall.db_create_database.checked ==
true && (document.forminstall.db_user_root.value ==
''))
669 alert(
'<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>');
673 else if (document.forminstall.db_create_user.checked ==
true && (document.forminstall.db_user_root.value ==
''))
676 alert(
'<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>');
684jQuery(document).ready(
function() {
686 var dbtype = jQuery(
"#db_type");
688 dbtype.change(
function () {
689 if (dbtype.val() ==
'sqlite' || dbtype.val() ==
'sqlite3') {
690 jQuery(
".hidesqlite").hide();
692 jQuery(
".hidesqlite").show();
696 if (dbtype.val() ==
'mysql' || dbtype.val() ==
'mysqli') {
697 jQuery(
"#db_port").val(3306);
698 jQuery(
"#db_user_root").val(
'root');
699 }
else if (dbtype.val() ==
'pgsql') {
700 jQuery(
"#db_port").val(5432);
701 jQuery(
"#db_user_root").val(
'postgres');
702 }
else if (dbtype.val() ==
'mssql') {
703 jQuery(
"#db_port").val(1433);
704 jQuery(
"#db_user_root").val(
'sa');
709 jQuery(
"#db_create_database").click(
function() {
710 console.log(
"click on db_create_database");
713 jQuery(
"#db_create_user").click(
function() {
714 console.log(
"click on db_create_user");
717 <?php
if ($force_install_noedit == 2 && empty($force_install_databasepass)) { ?>
718 jQuery(
"#db_pass").focus();
731pFooter($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.
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.