2004-10-20 00:24:10 +02:00
< ? php
2016-02-22 18:45:00 +01:00
/* Copyright ( C ) 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2004 Eric Seigne < eric . seigne @ ryxeo . com >
* Copyright ( C ) 2004 - 2012 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2004 Benoit Mortier < benoit . mortier @ opensides . be >
* Copyright ( C ) 2004 Sebastien DiCintio < sdicintio @ ressource - toi . org >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2011 Regis Houssin < regis . houssin @ inodbox . com >
2016-02-22 18:45:00 +01:00
* Copyright ( C ) 2016 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
2025-02-03 14:28:54 +01:00
* Copyright ( C ) 2024 - 2025 MDW < mdeweerd @ users . noreply . github . com >
2025-01-03 19:00:05 +01:00
* Copyright ( C ) 2024 - 2025 Frédéric France < frederic . france @ free . fr >
2004-02-11 19:08:59 +01:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2004-02-11 19:08:59 +01:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2004-02-11 19:08:59 +01:00
*/
2004-12-04 16:30:14 +01:00
2005-03-24 00:27:50 +01:00
/**
2008-12-05 00:25:48 +01:00
* \file htdocs / install / fileconf . php
* \ingroup install
2018-07-07 23:50:41 +02:00
* \brief Ask all information required to build Dolibarr htdocs / conf / conf . php file ( will be written to disk on next page step1 )
2008-12-05 00:25:48 +01:00
*/
2008-02-01 02:01:56 +01:00
2012-10-07 20:04:07 +02:00
include_once 'inc.php' ;
2025-01-03 19:00:05 +01:00
/**
* @ var Translate $langs
*
* @ var string $dolibarr_main_db_host
* @ var string $dolibarr_main_db_port
* @ var string $dolibarr_main_db_name
* @ var string $dolibarr_main_db_user
* @ var string $dolibarr_main_db_pass
* @ var string $dolibarr_main_db_encrypted_pass
* @ var string $conffile
* @ var string $conffiletoshow
*/
2025-02-03 14:28:54 +01:00
'
@ phan - var - force string $dolibarr_main_db_host
@ phan - var - force string $dolibarr_main_db_port
@ phan - var - force string $dolibarr_main_db_name
@ phan - var - force string $dolibarr_main_db_user
@ phan - var - force string $dolibarr_main_db_pass
@ phan - var - force string $dolibarr_main_db_encrypted_pass
@ phan - var - force string $conffile
@ phan - var - force string $conffiletoshow
@ phan - var - force ? bool $force_install_
@ phan - var - force ? string $force_install_packager
@ phan - var - force ? string $force_install_message
@ phan - var - force ? string $force_install_main_data_root
@ phan - var - force ? int < 0 , 2 > $force_install_noedit
@ phan - var - force ? string $force_install_type
@ phan - var - force ? string $force_install_dbserver
@ phan - var - force ? string $force_install_port
@ phan - var - force ? string $force_install_database
@ phan - var - force ? string $force_install_prefix
@ phan - var - force ? string $force_install_createdatabase
@ phan - var - force ? string $force_install_databaselogin
@ phan - var - force ? string $force_install_databasepass
@ phan - var - force ? string $force_install_databaserootlogin
@ phan - var - force ? string $force_install_databaserootpass
@ phan - var - force ? string $force_install_dolibarrlogin
@ phan - var - force ? string $force_install_nophpinfo
@ phan - var - force ? string $force_install_lockinstall
@ phan - var - force ? string $force_install_distrib
@ phan - var - force ? string $db_user_root
@ phan - var - force ? string $db_pass_root
' ;
2016-02-22 18:45:00 +01:00
2020-04-10 10:59:32 +02:00
$err = 0 ;
2005-04-02 22:56:18 +02:00
2021-05-12 18:38:22 +02:00
$setuplang = GETPOST ( " selectlang " , 'alpha' , 3 ) ? GETPOST ( " selectlang " , 'alpha' , 3 ) : ( GETPOST ( 'lang' , 'alpha' , 1 ) ? GETPOST ( 'lang' , 'alpha' , 1 ) : 'auto' );
2005-10-30 02:07:00 +01:00
$langs -> setDefaultLang ( $setuplang );
2018-10-01 08:22:23 +02:00
$langs -> loadLangs ( array ( " install " , " errors " ));
2004-02-11 19:08:59 +01:00
2018-07-07 23:50:41 +02:00
dolibarr_install_syslog ( " - fileconf: entering fileconf.php page " );
2008-04-21 09:21:13 +02:00
2012-12-05 11:18:45 +01:00
// You can force preselected values of the config step of Dolibarr by adding a file
// install.forced.php into directory htdocs/install (This is the case with some wizard
// installer like DoliWamp, DoliMamp or DoliBuntu).
// We first init "forced values" to nothing.
2020-12-20 10:28:06 +01:00
if ( ! isset ( $force_install_noedit )) {
2024-06-19 19:27:04 +02:00
$force_install_noedit = '' ; // 1=To block vars specific to distrib, 2 to block all technical parameters, 3 to block all technical parameters excepted main_url
2020-12-20 10:28:06 +01:00
}
if ( ! isset ( $force_install_type )) {
$force_install_type = '' ;
}
if ( ! isset ( $force_install_dbserver )) {
$force_install_dbserver = '' ;
}
if ( ! isset ( $force_install_port )) {
$force_install_port = '' ;
}
if ( ! isset ( $force_install_database )) {
$force_install_database = '' ;
}
if ( ! isset ( $force_install_prefix )) {
$force_install_prefix = '' ;
}
if ( ! isset ( $force_install_createdatabase )) {
$force_install_createdatabase = '' ;
}
if ( ! isset ( $force_install_databaselogin )) {
$force_install_databaselogin = '' ;
}
if ( ! isset ( $force_install_databasepass )) {
$force_install_databasepass = '' ;
}
if ( ! isset ( $force_install_databaserootlogin )) {
$force_install_databaserootlogin = '' ;
}
if ( ! isset ( $force_install_databaserootpass )) {
$force_install_databaserootpass = '' ;
}
2018-07-07 23:50:41 +02:00
// Now we load forced values from install.forced.php file.
2020-04-10 10:59:32 +02:00
$useforcedwizard = false ;
$forcedfile = " ./install.forced.php " ;
2020-12-20 10:28:06 +01:00
if ( $conffile == " /etc/dolibarr/conf.php " ) {
$forcedfile = " /etc/dolibarr/install.forced.php " ; // Must be after inc.php
}
2012-12-05 11:18:45 +01:00
if ( @ file_exists ( $forcedfile )) {
2020-10-31 14:32:18 +01:00
$useforcedwizard = true ;
include_once $forcedfile ;
2012-10-07 20:04:07 +02:00
}
2010-09-29 10:09:17 +02:00
2017-06-24 21:36:51 +02:00
2008-04-21 09:21:13 +02:00
/*
2010-09-29 10:09:17 +02:00
* View
*/
2005-10-30 02:07:00 +01:00
2024-01-13 19:48:41 +01:00
session_start (); // To be able to keep info into session (used for not losing pass during navigation. pass must not transit through parameters)
2012-11-20 11:22:57 +01:00
2024-09-05 11:49:33 +02:00
pHeader ( $langs -> trans ( " DolibarrSetup " ) . ' - ' . $langs -> trans ( " ConfigurationFile " ), " step1 " , " set " , " " , ( empty ( $force_dolibarr_js_JQUERY ) ? '' : $force_dolibarr_js_JQUERY . '/' ), 'main-inside-bis' );
2004-02-11 19:08:59 +01:00
2010-09-29 10:09:17 +02:00
// Test if we can run a first install process
2020-12-20 10:28:06 +01:00
if ( ! is_writable ( $conffile )) {
2020-10-31 14:32:18 +01:00
print $langs -> trans ( " ConfFileIsNotWritable " , $conffiletoshow );
dolibarr_install_syslog ( " fileconf: config file is not writable " , LOG_WARNING );
dolibarr_install_syslog ( " - fileconf: end " );
pFooter ( 1 , $setuplang , 'jscheckparam' );
exit ;
2010-09-29 10:09:17 +02:00
}
2020-12-20 10:28:06 +01:00
if ( ! empty ( $force_install_message )) {
2020-10-31 14:32:18 +01:00
print '<div><br>' . $langs -> trans ( $force_install_message ) . '</div>' ;
2012-10-07 20:04:07 +02:00
2020-10-31 14:32:18 +01:00
/* print '<script type="text/javascript">' ;
2020-12-20 10:28:06 +01:00
print ' jQuery ( document ) . ready ( function () {
2012-10-07 20:04:07 +02:00
jQuery ( " #linktoshowtechnicalparam " ) . click ( function () {
jQuery ( " .hidewhenedit " ) . hide ();
jQuery ( " .hidewhennoedit " ) . show ();
}); ' ;
2020-12-20 10:28:06 +01:00
if ( $force_install_noedit ) print 'jQuery(".hidewhennoedit").hide();' ;
2012-10-07 20:04:07 +02:00
print '});' ;
2020-12-20 10:28:06 +01:00
print '</script>' ;
2012-10-07 20:04:07 +02:00
2020-12-20 10:28:06 +01:00
print '<br><a href="#" id="linktoshowtechnicalparam" class="hidewhenedit">' . $langs -> trans ( " ShowEditTechnicalParameters " ) . '</a><br>' ;
*/
2008-05-17 16:56:06 +02:00
}
2007-05-26 18:45:00 +02:00
?>
2012-10-07 20:04:07 +02:00
< div >
2020-12-20 10:28:06 +01:00
< table class = " nobordernopadding<?php if ( $force_install_noedit ) {
print ' hidewhennoedit' ;
2023-12-13 12:46:23 +01:00
} ?> ">
2008-12-05 00:25:48 +01:00
2010-09-29 10:09:17 +02:00
< tr >
2017-05-26 00:02:41 +02:00
< td colspan = " 3 " class = " label " >
2021-04-30 15:34:02 +02:00
< 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>
2010-09-29 10:09:17 +02:00
</ td >
</ tr >
2007-05-26 18:45:00 +02:00
2011-09-29 22:21:57 +02:00
<!-- Documents root $dolibarr_main_document_root -->
2010-09-29 10:09:17 +02:00
< tr >
2020-12-20 10:28:06 +01:00
< td class = " label " >< label for = " main_dir " >< b >< ? php print $langs -> trans ( " WebPagesDirectory " ); ?> </b></label></td>
2018-07-07 23:50:41 +02:00
< ? php
2022-03-31 15:51:48 +02:00
if ( empty ( $dolibarr_main_document_root )) {
2022-05-18 11:23:21 +02:00
$dolibarr_main_document_root = GETPOSTISSET ( 'main_dir' ) ? GETPOST ( 'main_dir' ) : detect_dolibarr_main_document_root ();
2019-10-27 09:51:15 +01:00
}
?>
2018-07-07 23:50:41 +02:00
< td class = " label " >
2025-01-03 19:01:38 +01:00
< input type = " text " class = " minwidth300 " id = " main_dir "
2020-12-20 10:28:06 +01:00
name = " main_dir "
value = " <?php print $dolibarr_main_document_root ?> "
2019-10-27 09:51:15 +01:00
< ? php
if ( ! empty ( $force_install_noedit )) {
print ' disabled' ;
}
?>
2016-02-22 18:45:00 +01:00
>
</ td >
2010-09-29 10:09:17 +02:00
< td class = " comment " >< ? php
2020-01-30 12:24:04 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " WithNoSlashAtTheEnd " ) . " </span><br> " ;
2010-09-29 10:09:17 +02:00
print $langs -> trans ( " Examples " ) . " :<br> " ;
?>
< ul >
< li >/ var / www / dolibarr / htdocs </ li >
< li > C :/ wwwroot / dolibarr / htdocs </ li >
</ ul >
</ td >
</ tr >
2011-09-29 22:21:57 +02:00
<!-- Documents URL $dolibarr_main_data_root -->
2010-09-29 10:09:17 +02:00
< tr >
2018-07-07 23:50:41 +02:00
< td class = " label " >< label for = " main_data_dir " >< b >< ? php print $langs -> trans ( " DocumentsDirectory " ); ?> </b></label></td>
2010-09-29 10:09:17 +02:00
< ? php
2022-03-31 16:23:36 +02:00
if ( ! empty ( $force_install_main_data_root )) {
$dolibarr_main_data_root = @ $force_install_main_data_root ;
}
2016-02-22 18:45:00 +01:00
if ( empty ( $dolibarr_main_data_root )) {
2022-05-18 11:23:21 +02:00
$dolibarr_main_data_root = GETPOSTISSET ( 'main_data_dir' ) ? GETPOST ( 'main_data_dir' ) : detect_dolibarr_main_data_root ( $dolibarr_main_document_root );
2010-09-29 10:09:17 +02:00
}
?>
2018-07-07 23:50:41 +02:00
< td class = " label " >
2016-02-22 18:45:00 +01:00
< input type = " text "
2020-12-20 10:28:06 +01:00
class = " minwidth300 "
id = " main_data_dir "
name = " main_data_dir "
value = " <?php print $dolibarr_main_data_root ?> "
2019-10-27 09:51:15 +01:00
< ? php if ( ! empty ( $force_install_noedit )) {
2024-02-28 15:36:29 +01:00
print ' disabled' ;
2023-12-13 12:46:23 +01:00
} ?>
2016-02-22 18:45:00 +01:00
>
</ td >
2010-09-29 10:09:17 +02:00
< td class = " comment " >< ? php
2020-01-30 12:24:04 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " WithNoSlashAtTheEnd " ) . " </span><br> " ;
2010-09-29 10:09:17 +02:00
print $langs -> trans ( " DirectoryRecommendation " ) . " <br> " ;
print $langs -> trans ( " Examples " ) . " :<br> " ;
?>
< ul >
2011-07-30 16:56:11 +02:00
< li >/ var / lib / dolibarr / documents </ li >
2018-08-19 00:09:34 +02:00
< li > C :/ My Documents / dolibarr / documents </ li >
2010-09-29 10:09:17 +02:00
</ ul >
</ td >
</ tr >
2011-09-29 22:21:57 +02:00
<!-- Root URL $dolibarr_main_url_root -->
< ? php
2016-02-22 18:45:00 +01:00
if ( empty ( $dolibarr_main_url_root )) {
2022-05-18 11:23:21 +02:00
$dolibarr_main_url_root = GETPOSTISSET ( 'main_url' ) ? GETPOST ( 'main_url' ) : detect_dolibarr_main_url_root ();
2011-09-29 22:21:57 +02:00
}
?>
2011-01-09 23:47:02 +01:00
< tr >
2020-12-20 10:28:06 +01:00
< td class = " label " >< label for = " main_url " >< b >< ? php echo $langs -> trans ( " URLRoot " ); ?> </b></label>
2011-01-09 23:47:02 +01:00
</ td >
2018-07-07 23:50:41 +02:00
< td class = " label " >
2016-02-22 18:45:00 +01:00
< input type = " text "
2020-12-20 10:28:06 +01:00
class = " minwidth300 "
id = " main_url "
name = " main_url "
value = " <?php print $dolibarr_main_url_root ; ?> "
2024-06-19 19:27:04 +02:00
< ? php if ( ! empty ( $force_install_noedit ) && $force_install_noedit != 3 ) {
2024-02-28 15:36:29 +01:00
print ' disabled' ;
2023-12-13 12:46:23 +01:00
}
2019-10-27 09:51:15 +01:00
?>
2016-02-22 18:45:00 +01:00
>
</ td >
2011-01-09 23:47:02 +01:00
< td class = " comment " >< ? php print $langs -> trans ( " Examples " ) . " :<br> " ; ?>
2010-09-29 10:09:17 +02:00
< ul >
< li > http :// localhost /</ li >
2018-08-29 21:46:39 +02:00
< li > http :// www . myserver . com : 8180 / dolibarr </ li >
< li > https :// www . myvirtualfordolibarr . com /</ li >
2010-09-29 10:09:17 +02:00
</ ul >
2011-08-12 20:48:35 +02:00
</ td >
2010-09-29 10:09:17 +02:00
</ tr >
2011-09-29 22:21:57 +02:00
< ? php
2020-04-10 10:59:32 +02:00
if ( ! empty ( $_SERVER [ " HTTPS " ]) && $_SERVER [ " HTTPS " ] == 'on' ) { // Enabled if the installation process is "https://"
2020-10-31 14:32:18 +01:00
?>
2010-09-29 10:09:17 +02:00
< tr >
2020-12-20 10:28:06 +01:00
< td class = " label " >< label for = " main_force_https " >< ? php echo $langs -> trans ( " ForceHttps " ); ?> </label></td>
< td class = " label " >
< input type = " checkbox "
id = " main_force_https "
name = " main_force_https "
< ? php if ( ! empty ( $force_install_mainforcehttps )) {
2023-12-13 12:46:23 +01:00
print ' checked' ;
} ?>
2024-06-19 19:27:04 +02:00
< ? php if (( $force_install_noedit == 2 || $force_install_noedit == 3 ) && $force_install_mainforcehttps !== null ) {
2023-12-13 12:46:23 +01:00
print ' disabled' ;
} ?>
2016-02-22 18:45:00 +01:00
>
</ td >
2010-09-29 10:09:17 +02:00
< td class = " comment " >< ? php echo $langs -> trans ( " CheckToForceHttps " ); ?>
</ td >
</ tr >
2019-10-27 09:51:15 +01:00
< ? php
2011-09-29 22:21:57 +02:00
}
?>
2010-09-29 10:09:17 +02:00
<!-- Dolibarr database -->
< tr >
2017-05-26 00:02:41 +02:00
< td colspan = " 3 " class = " label " >< br >
2021-04-30 15:34:02 +02:00
< 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>
2010-09-29 10:09:17 +02:00
</ td >
</ tr >
2011-12-19 23:32:24 +01:00
< tr >
2020-12-20 10:28:06 +01:00
< td class = " label " >< label for = " db_name " >< b >< ? php echo $langs -> trans ( " DatabaseName " ); ?> </b></label></td>
2018-07-07 23:50:41 +02:00
< td class = " label " >
< input type = " text "
2020-12-20 10:28:06 +01:00
id = " db_name "
name = " db_name "
value = " <?php echo (!empty( $dolibarr_main_db_name )) ? $dolibarr_main_db_name : ( $force_install_database ? $force_install_database : 'dolibarr'); ?> "
2024-06-19 19:27:04 +02:00
< ? php if (( $force_install_noedit == 2 || $force_install_noedit == 3 ) && $force_install_database !== null ) {
2023-12-13 12:46:23 +01:00
print ' disabled' ;
} ?>
2016-02-22 18:45:00 +01:00
>
</ td >
< td class = " comment " >< ? php echo $langs -> trans ( " DatabaseName " ); ?> </td>
2011-12-19 23:32:24 +01:00
</ tr >
2010-09-29 10:09:17 +02:00
< ? php
2020-12-20 10:28:06 +01:00
if ( ! isset ( $dolibarr_main_db_host )) {
2020-10-31 14:32:18 +01:00
$dolibarr_main_db_host = " localhost " ;
2010-09-29 10:09:17 +02:00
}
?>
< tr >
2011-01-09 23:47:02 +01:00
<!-- Driver type -->
2018-07-07 23:50:41 +02:00
< td class = " label " >< label for = " db_type " >< b >< ? php echo $langs -> trans ( " DriverType " ); ?> </b></label></td>
2010-09-29 10:09:17 +02:00
2016-02-22 18:45:00 +01:00
< td class = " label " >
< ? php
2010-09-29 10:09:17 +02:00
2022-03-31 16:23:36 +02:00
$defaultype = ! empty ( $dolibarr_main_db_type ) ? $dolibarr_main_db_type : ( empty ( $force_install_type ) ? 'mysqli' : $force_install_type );
2010-09-29 10:09:17 +02:00
2011-09-29 22:21:57 +02:00
$modules = array ();
$nbok = $nbko = 0 ;
2020-04-10 10:59:32 +02:00
$option = '' ;
2010-12-15 19:15:08 +01:00
2011-09-29 22:21:57 +02:00
// Scan les drivers
2020-04-10 10:59:32 +02:00
$dir = DOL_DOCUMENT_ROOT . '/core/db' ;
$handle = opendir ( $dir );
2020-12-20 10:28:06 +01:00
if ( is_resource ( $handle )) {
while (( $file = readdir ( $handle )) !== false ) {
if ( is_readable ( $dir . " / " . $file ) && preg_match ( '/^(.*)\.class\.php$/i' , $file , $reg )) {
2020-10-31 14:32:18 +01:00
$type = $reg [ 1 ];
2020-12-20 10:28:06 +01:00
if ( $type === 'DoliDB' ) {
continue ; // Skip abstract class
}
2020-10-31 14:32:18 +01:00
$class = 'DoliDB' . ucfirst ( $type );
include_once $dir . " / " . $file ;
2020-12-20 10:28:06 +01:00
if ( $type == 'sqlite' ) {
continue ; // We hide sqlite because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported)
}
if ( $type == 'sqlite3' ) {
continue ; // We hide sqlite3 because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported)
}
2020-10-31 14:32:18 +01:00
// Version min of database
$note = '(' . $class :: LABEL . ' >= ' . $class :: VERSIONMIN . ')' ;
// Switch to mysql if mysqli is not present
2020-12-20 10:28:06 +01:00
if ( $defaultype == 'mysqli' && ! function_exists ( 'mysqli_connect' )) {
$defaultype = 'mysql' ;
}
2020-10-31 14:32:18 +01:00
2025-02-03 14:28:54 +01:00
$testclass = '' ;
$testfunction = null ;
2020-10-31 14:32:18 +01:00
// Show line into list
2020-12-20 10:28:06 +01:00
if ( $type == 'mysql' ) {
2023-12-04 12:36:19 +01:00
$testfunction = 'mysql_connect' ;
$testclass = '' ;
2020-12-20 10:28:06 +01:00
}
if ( $type == 'mysqli' ) {
2023-12-04 12:36:19 +01:00
$testfunction = 'mysqli_connect' ;
$testclass = '' ;
2020-12-20 10:28:06 +01:00
}
if ( $type == 'pgsql' ) {
2023-12-04 12:36:19 +01:00
$testfunction = 'pg_connect' ;
$testclass = '' ;
2020-12-20 10:28:06 +01:00
}
if ( $type == 'mssql' ) {
2023-12-04 12:36:19 +01:00
$testfunction = 'mssql_connect' ;
$testclass = '' ;
2020-12-20 10:28:06 +01:00
}
if ( $type == 'sqlite' ) {
2023-12-04 12:36:19 +01:00
$testfunction = '' ;
$testclass = 'PDO' ;
2020-12-20 10:28:06 +01:00
}
if ( $type == 'sqlite3' ) {
2023-12-04 12:36:19 +01:00
$testfunction = '' ;
$testclass = 'SQLite3' ;
2020-12-20 10:28:06 +01:00
}
2020-10-31 14:32:18 +01:00
$option .= '<option value="' . $type . '"' . ( $defaultype == $type ? ' selected' : '' );
2020-12-20 10:28:06 +01:00
if ( $testfunction && ! function_exists ( $testfunction )) {
$option .= ' disabled' ;
}
if ( $testclass && ! class_exists ( $testclass )) {
$option .= ' disabled' ;
}
2020-10-31 14:32:18 +01:00
$option .= '>' ;
$option .= $type . ' ' ;
2020-12-20 10:28:06 +01:00
if ( $note ) {
$option .= ' ' . $note ;
}
2020-10-31 14:32:18 +01:00
// Deprecated and experimental
2020-12-20 10:28:06 +01:00
if ( $type == 'mysql' ) {
$option .= ' ' . $langs -> trans ( " Deprecated " );
} elseif ( $type == 'mssql' ) {
$option .= ' ' . $langs -> trans ( " VersionExperimental " );
} elseif ( $type == 'sqlite' ) {
$option .= ' ' . $langs -> trans ( " VersionExperimental " );
} elseif ( $type == 'sqlite3' ) {
$option .= ' ' . $langs -> trans ( " VersionExperimental " );
2024-10-29 22:44:47 +01:00
} elseif ( $testfunction === null || ! function_exists ( $testfunction )) {
// None available
2020-12-20 10:28:06 +01:00
$option .= ' - ' . $langs -> trans ( " FunctionNotAvailableInThisPHP " );
}
2020-10-31 14:32:18 +01:00
$option .= '</option>' ;
}
}
2011-09-29 22:21:57 +02:00
}
2016-02-22 18:45:00 +01:00
?>
< select id = " db_type "
2020-12-20 10:28:06 +01:00
name = " db_type "
2024-06-19 19:27:04 +02:00
< ? php if (( $force_install_noedit == 2 || $force_install_noedit == 3 ) && $force_install_type !== null ) {
2023-12-13 12:46:23 +01:00
print ' disabled' ;
} ?>
2016-02-22 18:45:00 +01:00
>
< ? php print $option ; ?>
</ select >
2011-09-29 22:21:57 +02:00
2016-02-22 18:45:00 +01:00
</ td >
2010-09-29 10:09:17 +02:00
< td class = " comment " >< ? php echo $langs -> trans ( " DatabaseType " ); ?> </td>
</ tr >
2012-01-02 02:46:12 +01:00
< tr class = " hidesqlite " >
2018-07-07 23:50:41 +02:00
< td class = " label " >< label for = " db_host " >< b >< ? php echo $langs -> trans ( " DatabaseServer " ); ?> </b></label></td>
< td class = " label " >
2016-02-22 18:45:00 +01:00
< input type = " text "
2020-12-20 10:28:06 +01:00
id = " db_host "
name = " db_host "
2023-12-04 12:36:19 +01:00
value = " <?php print(!empty( $force_install_dbserver ) ? $force_install_dbserver : (!empty( $dolibarr_main_db_host ) ? $dolibarr_main_db_host : 'localhost')); ?> "
2024-06-19 19:27:04 +02:00
< ? php if (( $force_install_noedit == 2 || $force_install_noedit == 3 ) && $force_install_dbserver !== null ) {
2023-12-13 12:46:23 +01:00
print ' disabled' ;
} ?>
2016-02-22 18:45:00 +01:00
>
2011-06-12 01:21:59 +02:00
</ td >
2010-09-29 10:09:17 +02:00
< td class = " comment " >< ? php echo $langs -> trans ( " ServerAddressDescription " ); ?>
</ td >
</ tr >
2012-01-02 02:46:12 +01:00
< tr class = " hidesqlite " >
2020-12-20 10:28:06 +01:00
< td class = " label " >< label for = " db_port " >< ? php echo $langs -> trans ( " Port " ); ?> </label></td>
2018-07-07 23:50:41 +02:00
< td class = " label " >
2016-02-22 18:45:00 +01:00
< input type = " text "
2020-12-20 10:28:06 +01:00
name = " db_port "
id = " db_port "
value = " <?php print (!empty( $force_install_port )) ? $force_install_port : $dolibarr_main_db_port ; ?> "
2024-06-19 19:27:04 +02:00
< ? php if (( $force_install_noedit == 2 || $force_install_noedit == 3 ) && $force_install_port !== null ) {
2023-12-13 12:46:23 +01:00
print ' disabled' ;
} ?>
2016-02-22 18:45:00 +01:00
>
2011-06-12 01:21:59 +02:00
</ td >
2010-09-29 10:09:17 +02:00
< td class = " comment " >< ? php echo $langs -> trans ( " ServerPortDescription " ); ?>
</ td >
</ tr >
2012-01-02 02:46:12 +01:00
< tr class = " hidesqlite " >
2020-12-20 10:28:06 +01:00
< td class = " label " >< label for = " db_prefix " >< ? php echo $langs -> trans ( " DatabasePrefix " ); ?> </label></td>
2018-07-07 23:50:41 +02:00
< td class = " label " >
< input type = " text "
2020-12-20 10:28:06 +01:00
id = " db_prefix "
name = " db_prefix "
value = " <?php echo(!empty( $force_install_prefix ) ? $force_install_prefix : (!empty( $dolibarr_main_db_prefix ) ? $dolibarr_main_db_prefix : 'llx_')); ?> "
2024-06-19 19:27:04 +02:00
< ? php if (( $force_install_noedit == 2 || $force_install_noedit == 3 ) && $force_install_prefix !== null ) {
2023-12-13 12:46:23 +01:00
print ' disabled' ;
} ?>
2016-02-22 18:45:00 +01:00
>
</ td >
2018-08-19 00:09:34 +02:00
< td class = " comment " >< ? php echo $langs -> trans ( " DatabasePrefixDescription " ); ?> </td>
2011-11-23 23:09:57 +01:00
</ tr >
2010-09-29 10:09:17 +02:00
2012-01-02 02:46:12 +01:00
< tr class = " hidesqlite " >
2020-12-20 10:28:06 +01:00
< td class = " label " >< label for = " db_create_database " >< ? php echo $langs -> trans ( " CreateDatabase " ); ?> </label></td>
2018-07-07 23:50:41 +02:00
< td class = " label " >
2016-02-22 18:45:00 +01:00
< input type = " checkbox "
2020-12-20 10:28:06 +01:00
id = " db_create_database "
name = " db_create_database "
2022-12-11 13:56:31 +01:00
value = " on "
2022-09-11 23:47:32 +02:00
< ? php
$checked = 0 ;
if ( $force_install_createdatabase ) {
$checked = 1 ;
2020-12-20 10:28:06 +01:00
print ' checked' ;
} ?>
2024-06-19 19:27:04 +02:00
< ? php if (( $force_install_noedit == 2 || $force_install_noedit == 3 ) && $force_install_createdatabase !== null ) {
2020-12-20 10:28:06 +01:00
print ' disabled' ;
} ?>
2016-02-22 18:45:00 +01:00
>
</ td >
2022-09-11 23:47:32 +02:00
< td class = " comment " >
< ? php echo $langs -> trans ( " CheckToCreateDatabase " ); ?>
2010-09-29 10:09:17 +02:00
</ td >
</ tr >
2012-01-02 02:46:12 +01:00
< tr class = " hidesqlite " >
2018-07-07 23:50:41 +02:00
< td class = " label " >< label for = " db_user " >< b >< ? php echo $langs -> trans ( " Login " ); ?> </b></label></td>
< td class = " label " >
< input type = " text "
2020-12-20 10:28:06 +01:00
id = " db_user "
name = " db_user "
value = " <?php print (!empty( $force_install_databaselogin )) ? $force_install_databaselogin : $dolibarr_main_db_user ; ?> "
2024-06-19 19:27:04 +02:00
< ? php if (( $force_install_noedit == 2 || $force_install_noedit == 3 ) && $force_install_databaselogin !== null ) {
2020-12-20 10:28:06 +01:00
print ' disabled' ;
} ?>
2016-02-22 18:45:00 +01:00
>
</ td >
2010-09-29 10:09:17 +02:00
< td class = " comment " >< ? php echo $langs -> trans ( " AdminLogin " ); ?> </td>
</ tr >
2012-01-02 02:46:12 +01:00
< tr class = " hidesqlite " >
2018-07-07 23:50:41 +02:00
< td class = " label " >< label for = " db_pass " >< b >< ? php echo $langs -> trans ( " Password " ); ?> </b></label></td>
< td class = " label " >
2023-10-05 11:08:19 +02:00
< input type = " password " class = " text-security "
2020-12-20 10:28:06 +01:00
id = " db_pass " autocomplete = " off "
name = " db_pass "
value = " <?php
// 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.
2024-02-28 15:36:29 +01:00
// @phan-suppress-next-line PhanParamSuspiciousOrder
2020-12-20 10:28:06 +01:00
$autofill = (( ! empty ( $_SESSION [ 'dol_save_pass' ])) ? $_SESSION [ 'dol_save_pass' ] : str_pad ( '' , strlen ( $force_install_databasepass ), '*' ));
2021-07-20 22:14:11 +02:00
if ( ! empty ( $dolibarr_main_prod ) && empty ( $_SESSION [ 'dol_save_pass' ])) { // So value can't be found if install page still accessible
2020-12-20 10:28:06 +01:00
$autofill = '' ;
}
print dol_escape_htmltag ( $autofill );
?> "
2024-06-19 19:27:04 +02:00
< ? php if (( $force_install_noedit == 2 || $force_install_noedit == 3 ) && $force_install_databasepass !== null ) {
2024-02-28 15:36:29 +01:00
print ' disabled' ;
2023-12-13 12:46:23 +01:00
} ?>
2016-02-22 18:45:00 +01:00
>
</ td >
2010-09-29 10:09:17 +02:00
< td class = " comment " >< ? php echo $langs -> trans ( " AdminPassword " ); ?> </td>
</ tr >
2012-01-02 02:46:12 +01:00
< tr class = " hidesqlite " >
2018-07-07 23:50:41 +02:00
< td class = " label " >< label for = " db_create_user " >< ? php echo $langs -> trans ( " CreateUser " ); ?> </label></td>
< td class = " label " >
2016-02-22 18:45:00 +01:00
< input type = " checkbox "
2020-12-20 10:28:06 +01:00
id = " db_create_user "
name = " db_create_user "
2022-12-11 13:56:31 +01:00
value = " on "
2022-09-11 23:47:32 +02:00
< ? php
$checked = 0 ;
if ( ! empty ( $force_install_createuser )) {
$checked = 1 ;
2020-12-20 10:28:06 +01:00
print ' checked' ;
} ?>
2024-06-19 19:27:04 +02:00
< ? php if (( $force_install_noedit == 2 || $force_install_noedit == 3 ) && $force_install_createuser !== null ) {
2020-12-20 10:28:06 +01:00
print ' disabled' ;
} ?>
2016-02-22 18:45:00 +01:00
>
</ td >
2022-09-11 23:47:32 +02:00
< td class = " comment " >
< ? php echo $langs -> trans ( " CheckToCreateUser " ); ?>
2010-09-29 10:09:17 +02:00
</ td >
</ tr >
<!-- Super access -->
2011-08-07 01:10:00 +02:00
< ? php
2016-02-22 18:45:00 +01:00
$force_install_databaserootlogin = parse_database_login ( $force_install_databaserootlogin );
$force_install_databaserootpass = parse_database_pass ( $force_install_databaserootpass );
2011-08-07 01:10:00 +02:00
?>
2012-07-04 10:23:59 +02:00
< tr class = " hidesqlite hideroot " >
2017-05-26 00:02:41 +02:00
< td colspan = " 3 " class = " label " >< br >
2021-04-30 15:34:02 +02:00
< 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>
2010-09-29 10:09:17 +02:00
</ td >
</ tr >
2012-07-04 10:23:59 +02:00
< tr class = " hidesqlite hideroot " >
2018-07-07 23:50:41 +02:00
< td class = " label " >< label for = " db_user_root " >< b >< ? php echo $langs -> trans ( " Login " ); ?> </b></label></td>
< td class = " label " >
2016-02-22 18:45:00 +01:00
< input type = " text "
2020-12-20 10:28:06 +01:00
id = " db_user_root "
name = " db_user_root "
class = " needroot "
2022-03-31 15:51:48 +02:00
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 : '')); ?> "
2020-12-20 10:28:06 +01:00
< ? php if ( $force_install_noedit > 0 && ! empty ( $force_install_databaserootlogin )) {
2023-12-13 12:46:23 +01:00
print ' disabled' ;
} ?>
2016-02-22 18:45:00 +01:00
>
</ td >
2011-09-29 22:21:57 +02:00
< td class = " comment " >< ? php echo $langs -> trans ( " DatabaseRootLoginDescription " ); ?>
2011-08-12 20:48:35 +02:00
<!--
< ? php echo '<br>' . $langs -> trans ( " Examples " ) . ':<br>' ?>
< ul >
< li > root ( Mysql ) </ li >
< li > postgres ( PostgreSql ) </ li >
</ ul >
2010-09-29 10:09:17 +02:00
</ td >
2011-08-12 20:48:35 +02:00
-->
2011-09-29 22:21:57 +02:00
2010-09-29 10:09:17 +02:00
</ tr >
2012-07-04 10:23:59 +02:00
< tr class = " hidesqlite hideroot " >
2018-07-07 23:50:41 +02:00
< td class = " label " >< label for = " db_pass_root " >< b >< ? php echo $langs -> trans ( " Password " ); ?> </b></label></td>
< td class = " label " >
2016-02-22 18:45:00 +01:00
< input type = " password "
2020-12-20 10:28:06 +01:00
autocomplete = " off "
id = " db_pass_root "
name = " db_pass_root "
2021-07-20 22:14:11 +02:00
class = " needroot text-security "
2020-12-20 10:28:06 +01:00
value = " <?php
2020-10-31 14:32:18 +01:00
// 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.
2024-02-28 15:36:29 +01:00
// @phan-suppress-next-line PhanParamSuspiciousOrder
2021-07-21 00:35:08 +02:00
$autofill = (( ! empty ( $force_install_databaserootpass )) ? str_pad ( '' , strlen ( $force_install_databaserootpass ), '*' ) : ( isset ( $db_pass_root ) ? $db_pass_root : '' ));
2020-10-31 14:32:18 +01:00
if ( ! empty ( $dolibarr_main_prod )) {
$autofill = '' ;
}
// Do not autofill password if instance is a production instance
2020-12-20 10:28:06 +01:00
if ( ! empty ( $_SERVER [ " SERVER_NAME " ]) && ! in_array (
2024-02-28 15:36:29 +01:00
$_SERVER [ " SERVER_NAME " ],
array ( '127.0.0.1' , 'localhost' , 'localhostgit' )
2020-12-20 10:28:06 +01:00
)
2020-10-31 14:32:18 +01:00
) {
$autofill = '' ;
} // Do not autofill password for remote access
print dol_escape_htmltag ( $autofill );
?> "
2020-12-20 10:28:06 +01:00
< ? php if ( $force_install_noedit > 0 && ! empty ( $force_install_databaserootpass )) {
2024-02-28 15:36:29 +01:00
print ' disabled' ; /* May be removed by javascript*/
2023-12-13 12:46:23 +01:00
} ?>
2016-02-22 18:45:00 +01:00
>
</ td >
2011-09-29 22:21:57 +02:00
< td class = " comment " >< ? php echo $langs -> trans ( " KeepEmptyIfNoPassword " ); ?>
2010-09-29 10:09:17 +02:00
</ td >
</ tr >
2004-02-11 19:08:59 +01:00
</ table >
2012-10-07 20:04:07 +02:00
</ div >
2004-12-04 16:30:14 +01:00
2024-06-19 17:58:15 +02:00
2011-11-21 01:34:37 +01:00
< script type = " text/javascript " >
2022-09-11 23:47:32 +02:00
function init_needroot ()
{
console . log ( " init_needroot force_install_noedit=<?php echo $force_install_noedit ?> " );
2022-12-11 13:56:31 +01:00
console . log ( jQuery ( " #db_create_database " ) . is ( " :checked " ));
console . log ( jQuery ( " #db_create_user " ) . is ( " :checked " ));
2022-09-11 23:47:32 +02:00
if ( jQuery ( " #db_create_database " ) . is ( " :checked " ) || jQuery ( " #db_create_user " ) . is ( " :checked " ))
{
console . log ( " init_needroot show root section " );
jQuery ( " .hideroot " ) . show ();
< ? php
if ( empty ( $force_install_noedit )) { ?>
jQuery ( " .needroot " ) . removeAttr ( 'disabled' );
< ? php } ?>
}
else
{
console . log ( " init_needroot hide root section " );
jQuery ( " .hideroot " ) . hide ();
jQuery ( " .needroot " ) . prop ( 'disabled' , true );
}
}
2010-02-04 23:00:51 +01:00
function checkDatabaseName ( databasename ) {
2010-08-20 13:58:29 +02:00
if ( databasename . match ( / [; \ . ] / )) { return false ; }
2010-02-04 23:00:51 +01:00
return true ;
}
2010-01-20 18:54:44 +01:00
function jscheckparam ()
{
2022-09-11 23:47:32 +02:00
console . log ( " Click on jscheckparam " );
2023-05-01 15:09:43 +02:00
var ok = true ;
2010-01-20 18:54:44 +01:00
if ( document . forminstall . main_dir . value == '' )
{
ok = false ;
2019-01-27 11:55:16 +01:00
alert ( '<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("WebPagesDirectory"))); ?>' );
2010-01-20 18:54:44 +01:00
}
else if ( document . forminstall . main_data_dir . value == '' )
{
ok = false ;
2019-01-27 11:55:16 +01:00
alert ( '<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DocumentsDirectory"))); ?>' );
2010-01-20 18:54:44 +01:00
}
else if ( document . forminstall . main_url . value == '' )
{
ok = false ;
2019-01-27 11:55:16 +01:00
alert ( '<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("URLRoot"))); ?>' );
2010-01-20 18:54:44 +01:00
}
else if ( document . forminstall . db_host . value == '' )
{
ok = false ;
2019-01-27 11:55:16 +01:00
alert ( '<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Server"))); ?>' );
2010-01-20 18:54:44 +01:00
}
else if ( document . forminstall . db_name . value == '' )
{
ok = false ;
2019-01-27 11:55:16 +01:00
alert ( '<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatabaseName"))); ?>' );
2010-01-20 18:54:44 +01:00
}
2010-02-04 23:00:51 +01:00
else if ( ! checkDatabaseName ( document . forminstall . db_name . value ))
{
ok = false ;
2022-09-17 12:45:42 +02:00
alert ( '<?php echo dol_escape_js($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentitiesnoconv("DatabaseName"))); ?>' );
2010-02-04 23:00:51 +01:00
}
2010-01-20 18:54:44 +01:00
// If create database asked
2010-02-04 23:00:51 +01:00
else if ( document . forminstall . db_create_database . checked == true && ( document . forminstall . db_user_root . value == '' ))
2010-01-20 18:54:44 +01:00
{
ok = false ;
alert ( '<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>' );
2022-09-11 23:47:32 +02:00
init_needroot ();
2010-01-20 18:54:44 +01:00
}
// If create user asked
2010-02-04 23:00:51 +01:00
else if ( document . forminstall . db_create_user . checked == true && ( document . forminstall . db_user_root . value == '' ))
2010-01-20 18:54:44 +01:00
{
ok = false ;
alert ( '<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>' );
2022-09-11 23:47:32 +02:00
init_needroot ();
2010-01-20 18:54:44 +01:00
}
return ok ;
}
2022-12-11 13:56:31 +01:00
jQuery ( document ) . ready ( function () { // TODO Test $( window ).load(function() to see if the init_needroot work better after a back
var dbtype = jQuery ( " #db_type " );
dbtype . change ( function () {
if ( dbtype . val () == 'sqlite' || dbtype . val () == 'sqlite3' ) {
jQuery ( " .hidesqlite " ) . hide ();
} else {
jQuery ( " .hidesqlite " ) . show ();
}
// Automatically set default database ports and admin user
if ( dbtype . val () == 'mysql' || dbtype . val () == 'mysqli' ) {
jQuery ( " #db_port " ) . val ( 3306 );
jQuery ( " #db_user_root " ) . val ( 'root' );
} else if ( dbtype . val () == 'pgsql' ) {
jQuery ( " #db_port " ) . val ( 5432 );
jQuery ( " #db_user_root " ) . val ( 'postgres' );
} else if ( dbtype . val () == 'mssql' ) {
jQuery ( " #db_port " ) . val ( 1433 );
jQuery ( " #db_user_root " ) . val ( 'sa' );
}
});
jQuery ( " #db_create_database " ) . click ( function () {
console . log ( " click on db_create_database " );
init_needroot ();
});
jQuery ( " #db_create_user " ) . click ( function () {
console . log ( " click on db_create_user " );
init_needroot ();
});
2024-06-19 19:27:04 +02:00
< ? php if (( $force_install_noedit == 2 || $force_install_noedit == 3 ) && empty ( $force_install_databasepass )) { ?>
2022-12-11 13:56:31 +01:00
jQuery ( " #db_pass " ) . focus ();
< ? php } ?>
init_needroot ();
});
2010-01-20 18:54:44 +01:00
</ script >
2004-12-04 16:30:14 +01:00
2012-07-04 10:23:59 +02:00
< ? php
2004-12-04 16:30:14 +01:00
2024-01-13 19:48:41 +01:00
// $db->close(); Not database connection yet
2012-07-04 10:23:59 +02:00
2018-07-07 23:50:41 +02:00
dolibarr_install_syslog ( " - fileconf: end " );
2024-06-19 17:58:15 +02:00
2019-01-27 11:55:16 +01:00
pFooter ( $err , $setuplang , 'jscheckparam' );