30 include_once
'inc.php';
36 $setuplang =
GETPOST(
"selectlang",
'', 3) ?
GETPOST(
"selectlang",
'', 3) : (isset($_GET[
"lang"]) ? $_GET[
"lang"] :
'auto');
37 $langs->setDefaultLang($setuplang);
39 $langs->loadLangs(array(
"install",
"errors"));
47 if (!isset($force_install_noedit)) {
48 $force_install_noedit =
'';
50 if (!isset($force_install_type)) {
51 $force_install_type =
'';
53 if (!isset($force_install_dbserver)) {
54 $force_install_dbserver =
'';
56 if (!isset($force_install_port)) {
57 $force_install_port =
'';
59 if (!isset($force_install_database)) {
60 $force_install_database =
'';
62 if (!isset($force_install_prefix)) {
63 $force_install_prefix =
'';
65 if (!isset($force_install_createdatabase)) {
66 $force_install_createdatabase =
'';
68 if (!isset($force_install_databaselogin)) {
69 $force_install_databaselogin =
'';
71 if (!isset($force_install_databasepass)) {
72 $force_install_databasepass =
'';
74 if (!isset($force_install_databaserootlogin)) {
75 $force_install_databaserootlogin =
'';
77 if (!isset($force_install_databaserootpass)) {
78 $force_install_databaserootpass =
'';
81 $useforcedwizard =
false;
82 $forcedfile =
"./install.forced.php";
83 if ($conffile ==
"/etc/dolibarr/conf.php") {
84 $forcedfile =
"/etc/dolibarr/install.forced.php";
86 if (@file_exists($forcedfile)) {
87 $useforcedwizard =
true;
88 include_once $forcedfile;
99 pHeader($langs->trans(
"ConfigurationFile"),
"step1",
"set",
"", (empty($force_dolibarr_js_JQUERY) ?
'' : $force_dolibarr_js_JQUERY.
'/'),
'main-inside-bis');
102 if (!is_writable($conffile)) {
103 print $langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
106 pFooter(1, $setuplang,
'jscheckparam');
110 if (!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=
"valigntextbottom" 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>
145 if (empty($dolibarr_main_url_root)) {
154 value=
"<?php print $dolibarr_main_document_root ?>"
156 if (!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 $dolibarr_main_data_root = @$force_install_main_data_root;
178 if (empty($dolibarr_main_data_root)) {
187 value=
"<?php print $dolibarr_main_data_root ?>"
188 <?php
if (!empty($force_install_noedit)) {
193 <td
class=
"comment"><?php
194 print '<span class="opacitymedium">'.$langs->trans(
"WithNoSlashAtTheEnd").
"</span><br>";
195 print $langs->trans(
"DirectoryRecommendation").
"<br>";
196 print $langs->trans(
"Examples").
":<br>";
199 <li>/var/lib/dolibarr/documents</li>
200 <li>C:/My
Documents/dolibarr/documents</li>
205 <!-- Root URL $dolibarr_main_url_root -->
207 if (empty($dolibarr_main_url_root)) {
212 <td
class=
"label"><label
for=
"main_url"><b><?php echo $langs->trans(
"URLRoot"); ?></b></label>
219 value=
"<?php print $dolibarr_main_url_root; ?> "
220 <?php
if (!empty($force_install_noedit)) {
226 <td
class=
"comment"><?php
print $langs->trans(
"Examples").
":<br>"; ?>
239 <td
class=
"label"><label
for=
"main_force_https"><?php echo $langs->trans(
"ForceHttps"); ?></label></td>
241 <input type=
"checkbox"
242 id=
"main_force_https"
243 name=
"main_force_https"
244 <?php
if (!empty($force_install_mainforcehttps)) {
247 <?php
if ($force_install_noedit == 2 && $force_install_mainforcehttps !== null) {
252 <td
class=
"comment"><?php echo $langs->trans(
"CheckToForceHttps"); ?>
260 <!-- Dolibarr database -->
263 <td colspan=
"3" class=
"label"><br>
264 <h3><img
class=
"valigntextbottom" src=
"../theme/common/octicons/build/svg/database.svg" width=
"20" alt=
"webserver"> <?php echo $langs->trans(
"DolibarrDatabase"); ?></h3>
269 <td
class=
"label"><label
for=
"db_name"><b><?php echo $langs->trans(
"DatabaseName"); ?></b></label></td>
274 value=
"<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>"
275 <?php
if ($force_install_noedit == 2 && $force_install_database !== null) {
280 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseName"); ?></td>
285 if (!isset($dolibarr_main_db_host)) {
286 $dolibarr_main_db_host =
"localhost";
291 <td
class=
"label"><label
for=
"db_type"><b><?php echo $langs->trans(
"DriverType"); ?></b></label></td>
296 $defaultype = !empty($dolibarr_main_db_type) ? $dolibarr_main_db_type : ($force_install_type ? $force_install_type :
'mysqli');
303 $dir = DOL_DOCUMENT_ROOT.
'/core/db';
304 $handle = opendir($dir);
305 if (is_resource($handle)) {
306 while (($file = readdir($handle)) !==
false) {
307 if (is_readable($dir.
"/".$file) && preg_match(
'/^(.*)\.class\.php$/i', $file, $reg)) {
309 if ($type ===
'DoliDB') {
312 $class =
'DoliDB'.ucfirst($type);
313 include_once $dir.
"/".$file;
315 if ($type ==
'sqlite') {
318 if ($type ==
'sqlite3') {
323 $versionbasemin = explode(
'.', $class::VERSIONMIN);
324 $note =
'('.$class::LABEL.
' >= '.$class::VERSIONMIN.
')';
327 if ($defaultype ==
'mysqli' && !function_exists(
'mysqli_connect')) {
328 $defaultype =
'mysql';
332 if ($type ==
'mysql') {
333 $testfunction =
'mysql_connect'; $testclass =
'';
335 if ($type ==
'mysqli') {
336 $testfunction =
'mysqli_connect'; $testclass =
'';
338 if ($type ==
'pgsql') {
339 $testfunction =
'pg_connect'; $testclass =
'';
341 if ($type ==
'mssql') {
342 $testfunction =
'mssql_connect'; $testclass =
'';
344 if ($type ==
'sqlite') {
345 $testfunction =
''; $testclass =
'PDO';
347 if ($type ==
'sqlite3') {
348 $testfunction =
''; $testclass =
'SQLite3';
350 $option .=
'<option value="'.$type.
'"'.($defaultype == $type ?
' selected' :
'');
351 if ($testfunction && !function_exists($testfunction)) {
352 $option .=
' disabled';
354 if ($testclass && !class_exists($testclass)) {
355 $option .=
' disabled';
358 $option .= $type.
' ';
360 $option .=
' '.$note;
363 if ($type ==
'mysql') {
364 $option .=
' '.$langs->trans(
"Deprecated");
365 } elseif ($type ==
'mssql') {
366 $option .=
' '.$langs->trans(
"VersionExperimental");
367 } elseif ($type ==
'sqlite') {
368 $option .=
' '.$langs->trans(
"VersionExperimental");
369 } elseif ($type ==
'sqlite3') {
370 $option .=
' '.$langs->trans(
"VersionExperimental");
371 } elseif (!function_exists($testfunction)) {
373 $option .=
' - '.$langs->trans(
"FunctionNotAvailableInThisPHP");
375 $option .=
'</option>';
382 <?php
if ($force_install_noedit == 2 && $force_install_type !== null) {
386 <?php
print $option; ?>
390 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseType"); ?></td>
394 <tr
class=
"hidesqlite">
395 <td
class=
"label"><label
for=
"db_host"><b><?php echo $langs->trans(
"DatabaseServer"); ?></b></label></td>
400 value=
"<?php print (!empty($force_install_dbserver) ? $force_install_dbserver : (!empty($dolibarr_main_db_host) ? $dolibarr_main_db_host : 'localhost')); ?>"
401 <?php
if ($force_install_noedit == 2 && $force_install_dbserver !== null) {
406 <td
class=
"comment"><?php echo $langs->trans(
"ServerAddressDescription"); ?>
411 <tr
class=
"hidesqlite">
412 <td
class=
"label"><label
for=
"db_port"><?php echo $langs->trans(
"Port"); ?></label></td>
417 value=
"<?php print (!empty($force_install_port)) ? $force_install_port : $dolibarr_main_db_port; ?>"
418 <?php
if ($force_install_noedit == 2 && $force_install_port !== null) {
423 <td
class=
"comment"><?php echo $langs->trans(
"ServerPortDescription"); ?>
428 <tr
class=
"hidesqlite">
429 <td
class=
"label"><label
for=
"db_prefix"><?php echo $langs->trans(
"DatabasePrefix"); ?></label></td>
434 value=
"<?php echo(!empty($force_install_prefix) ? $force_install_prefix : (!empty($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : 'llx_')); ?>"
435 <?php
if ($force_install_noedit == 2 && $force_install_prefix !== null) {
440 <td
class=
"comment"><?php echo $langs->trans(
"DatabasePrefixDescription"); ?></td>
443 <tr
class=
"hidesqlite">
444 <td
class=
"label"><label
for=
"db_create_database"><?php echo $langs->trans(
"CreateDatabase"); ?></label></td>
446 <input type=
"checkbox"
447 id=
"db_create_database"
448 name=
"db_create_database"
449 <?php
if ($force_install_createdatabase) {
452 <?php
if ($force_install_noedit == 2 && $force_install_createdatabase !== null) {
457 <td
class=
"comment"><?php echo $langs->trans(
"CheckToCreateDatabase"); ?>
461 <tr
class=
"hidesqlite">
462 <td
class=
"label"><label
for=
"db_user"><b><?php echo $langs->trans(
"Login"); ?></b></label></td>
467 value=
"<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>"
468 <?php
if ($force_install_noedit == 2 && $force_install_databaselogin !== null) {
473 <td
class=
"comment"><?php echo $langs->trans(
"AdminLogin"); ?></td>
476 <tr
class=
"hidesqlite">
477 <td
class=
"label"><label
for=
"db_pass"><b><?php echo $langs->trans(
"Password"); ?></b></label></td>
479 <input type=
"password"
480 id=
"db_pass" autocomplete=
"off"
483 // 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.
484 $autofill = ((!empty($_SESSION['dol_save_pass'])) ? $_SESSION['dol_save_pass'] : str_pad('', strlen($force_install_databasepass), '*'));
485 if (!empty($dolibarr_main_prod)) {
488 print dol_escape_htmltag($autofill);
490 <?php
if ($force_install_noedit == 2 && $force_install_databasepass !== null) {
495 <td
class=
"comment"><?php echo $langs->trans(
"AdminPassword"); ?></td>
498 <tr
class=
"hidesqlite">
499 <td
class=
"label"><label
for=
"db_create_user"><?php echo $langs->trans(
"CreateUser"); ?></label></td>
501 <input type=
"checkbox"
503 name=
"db_create_user"
504 <?php
if (!empty($force_install_createuser)) {
507 <?php
if ($force_install_noedit == 2 && $force_install_createuser !== null) {
512 <td
class=
"comment"><?php echo $langs->trans(
"CheckToCreateUser"); ?>
517 <!-- Super access -->
522 <tr
class=
"hidesqlite hideroot">
523 <td colspan=
"3" class=
"label"><br>
524 <h3><img
class=
"valigntextbottom" src=
"../theme/common/octicons/build/svg/shield.svg" width=
"20" alt=
"webserver"> <?php echo $langs->trans(
"DatabaseSuperUserAccess"); ?></h3>
528 <tr
class=
"hidesqlite hideroot">
529 <td
class=
"label"><label
for=
"db_user_root"><b><?php echo $langs->trans(
"Login"); ?></b></label></td>
535 value=
"<?php print (!empty($force_install_databaserootlogin)) ? $force_install_databaserootlogin : @$db_user_root; ?>"
536 <?php
if ($force_install_noedit > 0 && !empty($force_install_databaserootlogin)) {
541 <td
class=
"comment"><?php echo $langs->trans(
"DatabaseRootLoginDescription"); ?>
543 <?php echo
'<br>'.$langs->trans(
"Examples").
':<br>' ?>
545 <li>root (Mysql)</li>
546 <li>postgres (PostgreSql)</li>
552 <tr
class=
"hidesqlite hideroot">
553 <td
class=
"label"><label
for=
"db_pass_root"><b><?php echo $langs->trans(
"Password"); ?></b></label></td>
555 <input type=
"password"
561 // 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.
562 $autofill = ((!empty($force_install_databaserootpass)) ? str_pad('', strlen($force_install_databaserootpass), '*') : @$db_pass_root);
563 if (!empty($dolibarr_main_prod)) {
566 // Do not autofill password if instance is a production instance
567 if (!empty($_SERVER["SERVER_NAME
"]) && !in_array(
568 $_SERVER["SERVER_NAME
"],
569 array('127.0.0.1', 'localhost', 'localhostgit')
573 } // Do not autofill password for remote access
574 print dol_escape_htmltag($autofill);
576 <?php
if ($force_install_noedit > 0 && !empty($force_install_databaserootpass)) {
581 <td
class=
"comment"><?php echo $langs->trans(
"KeepEmptyIfNoPassword"); ?>
588 <script type=
"text/javascript">
589 jQuery(document).ready(
function() {
591 var dbtype = jQuery(
"#db_type");
593 dbtype.change(
function () {
594 if (dbtype.val() ==
'sqlite' || dbtype.val() ==
'sqlite3') {
595 jQuery(
".hidesqlite").hide();
597 jQuery(
".hidesqlite").show();
601 if (dbtype.val() ==
'mysql' || dbtype.val() ==
'mysqli') {
602 jQuery(
"#db_port").val(3306);
603 jQuery(
"#db_user_root").val(
'root');
604 }
else if (dbtype.val() ==
'pgsql') {
605 jQuery(
"#db_port").val(5432);
606 jQuery(
"#db_user_root").val(
'postgres');
607 }
else if (dbtype.val() ==
'mssql') {
608 jQuery(
"#db_port").val(1433);
609 jQuery(
"#db_user_root").val(
'sa');
614 function init_needroot()
617 if (jQuery(
"#db_create_database").is(
":checked") || jQuery(
"#db_create_user").is(
":checked"))
619 jQuery(
".hideroot").show();
621 if ($force_install_noedit == 0) { ?>
622 jQuery(
".needroot").removeAttr(
'disabled');
627 jQuery(
".hideroot").hide();
628 jQuery(
".needroot").prop(
'disabled',
true);
633 jQuery(
"#db_create_database").click(
function() {
636 jQuery(
"#db_create_user").click(
function() {
639 <?php
if ($force_install_noedit == 2 && empty($force_install_databasepass)) { ?>
640 jQuery(
"#db_pass").focus();
644 function checkDatabaseName(databasename) {
645 if (databasename.match(/[;\.]/)) {
return false; }
649 function 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("ErrorSpecialCharNotAllowedForField", $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")); ?>');
690 else if (document.forminstall.db_create_user.checked ==
true && (document.forminstall.db_user_root.value ==
''))
693 alert(
'<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>');
706 pFooter($err, $setuplang,
'jscheckparam');
detect_dolibarr_main_document_root()
Automatically detect Dolibarr's main document root.
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.
API class for receive files.
parse_database_login($force_install_databaserootlogin)
Replaces automatic database login by actual value.
$conf db name
Only used if Module[ID]Name translation string is not found.
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
parse_database_pass($force_install_databaserootpass)
Replaces automatic database password by actual value.
detect_dolibarr_main_url_root()
Automatically detect Dolibarr's main URL root.
print $_SERVER["PHP_SELF"]
Edit parameters.
detect_dolibarr_main_data_root($dolibarr_main_document_root)
Automatically detect Dolibarr's main data root.
pFooter($nonext=0, $setuplang= '', $jscheckfunction= '', $withpleasewait=0)
Print HTML footer of install pages.
print
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type