2005-11-03 19:00:17 +01:00
< ? php
2016-02-22 18:45:00 +01:00
/* Copyright ( C ) 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2004 Benoit Mortier < benoit . mortier @ opensides . be >
* Copyright ( C ) 2004 Sebastien DiCintio < sdicintio @ ressource - toi . org >
* Copyright ( C ) 2007 - 2012 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2012 Marcos GarcÃa < marcosgdf @ gmail . com >
* Copyright ( C ) 2016 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
2021-02-22 13:12:06 +01:00
* Copyright ( C ) 2021 Charlene Benke < charlene @ patas - monkey . com >
2023-02-18 14:06:58 +01:00
* Copyright ( C ) 2023 Alexandre Janniaux < alexandre . janniaux @ gmail . com >
2025-02-03 14:28:54 +01:00
* Copyright ( C ) 2024 - 2025 MDW < mdeweerd @ users . noreply . github . com >
2021-02-22 13:12:06 +01:00
*
2005-11-03 19:00:17 +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
2005-11-03 19:00:17 +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 />.
2005-11-03 19:00:17 +01:00
*/
2005-11-04 02:28:28 +01:00
2012-01-29 20:57:40 +01:00
/**
* \file htdocs / install / inc . php
* \ingroup core
* \brief File that define environment for support pages
2009-11-04 23:23:48 +01:00
*/
2005-11-04 02:28:28 +01:00
2012-04-28 16:37:58 +02:00
// Just to define version DOL_VERSION
2021-02-22 14:41:20 +01:00
if ( ! defined ( 'DOL_INC_FOR_VERSION_ERROR' )) {
define ( 'DOL_INC_FOR_VERSION_ERROR' , '1' );
}
2012-08-22 23:11:24 +02:00
require_once '../filefunc.inc.php' ;
2008-04-19 23:52:14 +02:00
2012-10-07 20:04:07 +02:00
2012-12-05 00:45:10 +01:00
2022-10-22 01:54:50 +02:00
// Define DOL_DOCUMENT_ROOT used for install/upgrade process
2021-02-22 14:41:20 +01:00
if ( ! defined ( 'DOL_DOCUMENT_ROOT' )) {
define ( 'DOL_DOCUMENT_ROOT' , '..' );
}
2011-09-07 15:27:50 +02:00
2021-02-22 13:12:06 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/conf.class.php' ;
2023-04-29 15:46:44 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/translate.class.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2007-10-29 13:47:43 +01:00
2025-02-03 14:28:54 +01:00
'
@ phan - var - force ? string $dolibarr_main_url_root_alt
@ phan - var - force ? string $dolibarr_main_db_prefix
' ;
2021-02-22 14:41:20 +01:00
$conf = new Conf ();
2012-03-21 02:12:44 +01:00
2012-04-28 16:37:58 +02:00
// Force $_REQUEST["logtohtml"]
2020-04-10 10:59:32 +02:00
$_REQUEST [ " logtohtml " ] = 1 ;
2008-12-15 02:04:32 +01:00
2007-03-06 19:30:16 +01:00
// Correction PHP_SELF (ex pour apache via caudium) car PHP_SELF doit valoir URL relative
// et non path absolu.
2021-02-22 14:41:20 +01:00
if ( isset ( $_SERVER [ " DOCUMENT_URI " ]) && $_SERVER [ " DOCUMENT_URI " ]) {
2020-10-31 14:32:18 +01:00
$_SERVER [ " PHP_SELF " ] = $_SERVER [ " DOCUMENT_URI " ];
2007-03-06 19:30:16 +01:00
}
2007-12-17 19:33:34 +01:00
2020-04-10 10:59:32 +02:00
$includeconferror = '' ;
2011-07-30 12:23:24 +02:00
2011-09-20 12:30:56 +02:00
// Define vars
2011-07-30 12:23:24 +02:00
$conffiletoshowshort = " conf.php " ;
2011-09-20 12:30:56 +02:00
// Define localization of conf file
2006-06-17 20:12:46 +02:00
$conffile = " ../conf/conf.php " ;
2011-07-30 12:23:24 +02:00
$conffiletoshow = " htdocs/conf/conf.php " ;
2011-09-20 12:30:56 +02:00
// For debian/redhat like systems
//$conffile = "/etc/dolibarr/conf.php";
//$conffiletoshow = "/etc/dolibarr/conf.php";
2011-08-04 14:07:29 +02:00
2023-02-18 14:06:58 +01:00
$short_options = " c:h " ;
$long_options = array (
" config: " ,
" help " ,
);
/**
* Print the usage when executing scripts from install /.
*
* Print the help text exposing the available options when executing
* update or install script ( ie . from htdocs / install / ) from CLI with
* the `php` executable . This function does not `exit` the program and
* the caller should then call `exit` themselves since they should
* determine whether it was an error or not .
*
* @ param string $program the script that was originally run
* @ param string $header the message to signal to the user
* @ return void
*/
2025-02-18 16:08:09 +01:00
function install_usage ( $program , $header )
2023-02-18 14:06:58 +01:00
{
echo $header . " \n " ;
2023-04-27 13:35:34 +02:00
echo " php " . $program . " [options] [script options] \n " ;
echo " \n " ;
echo " Script syntax when using step2.php: \n " ;
echo " php " . $program . " [options] [action] [selectlang] \n " ;
echo " \n " ;
echo " action: \n " ;
echo " Specify the action to execute for the file among the following ones. \n " ;
echo " - set: Create tables, keys, functions and data for the instance. \n " ;
2023-02-18 14:06:58 +01:00
echo " \n " ;
2023-04-27 13:35:34 +02:00
echo " selectlang: \n " ;
echo " Setup the default lang to use, default to 'auto'. \n " ;
echo " \n " ;
echo " Script syntax when using upgrade.php: \n " ;
echo " php " . $program . " [options] previous_version new_version [script options] \n " ;
2023-02-18 14:06:58 +01:00
echo " \n " ;
echo " dirmodule: \n " ;
echo " Specify dirmodule to provide a path for an external module \n " ;
echo " so the migration is done using a script from a module. \n " ;
echo " \n " ;
echo " ignoredbversion: \n " ;
echo " Allow to run migration even if database version does \n " ;
echo " not match start version of migration. \n " ;
echo " \n " ;
2023-04-27 13:35:34 +02:00
echo " Script syntax when using upgrade2.php: \n " ;
echo " php " . $program . " [options] previous_version new_version [module list] \n " ;
2023-02-18 14:06:58 +01:00
echo " \n " ;
2023-04-27 13:35:34 +02:00
echo " MAIN_MODULE_NAME1,MAIN_MODULE_NAME2: \n " ;
echo " Specify a list of module-name to enable, in upper case, with MAIN_MODULE_ prefix, joined by comma. \n " ;
2023-02-18 14:06:58 +01:00
echo " \n " ;
echo " Options: \n " ;
echo " -c, --config <filename>: \n " ;
echo " Provide a different conf.php file to use. \n " ;
echo " \n " ;
echo " -h, --help: \n " ;
echo " Display this help message. \n " ;
}
2023-10-25 16:41:46 +02:00
if ( php_sapi_name () === " cli " && ( float ) PHP_VERSION > 7.0 ) {
2023-02-18 14:06:58 +01:00
$rest_index = 0 ;
$opts = getopt ( $short_options , $long_options , $rest_index );
2023-12-04 12:36:19 +01:00
foreach ( $opts as $opt => $arg ) {
switch ( $opt ) {
case 'c' :
case 'config' :
$conffile = $arg ;
$conffiletoshow = $arg ;
2024-03-14 21:59:15 +01:00
break ;
2023-12-04 12:36:19 +01:00
case 'h' :
case 'help' :
2025-02-18 16:08:09 +01:00
install_usage ( $argv [ 0 ], " Usage: " );
2024-03-14 21:59:15 +01:00
exit ( 0 );
2023-12-04 12:36:19 +01:00
}
2023-02-18 14:06:58 +01:00
}
2023-04-27 14:09:55 +02:00
// Parse the arguments to find the options.
2024-03-14 21:59:15 +01:00
$args_options = array_filter (
array_slice ( $argv , 0 , $rest_index ),
/**
* @ param string $arg
* @ return bool
*/
static function ( $arg ) {
return strlen ( $arg ) >= 2 && $arg [ 0 ] == '-' ;
2023-12-04 12:36:19 +01:00
}
2024-03-14 21:59:15 +01:00
);
$parsed_options = array_map (
/**
* Previx option with '-' for single characters and -- for more than single characters
* @ param string $arg
2024-03-15 04:10:57 +01:00
* @ return string
2024-03-14 21:59:15 +01:00
*/
static function ( $arg ) {
if ( strlen ( $arg ) > 1 ) {
return " -- " . $arg ;
}
return " - " . $arg ;
},
array_keys ( $opts )
);
2023-04-27 14:09:55 +02:00
// Find options (dash-prefixed) that were not parsed.
$unknown_options = array_diff ( $args_options , $parsed_options );
2023-02-18 14:06:58 +01:00
// In the following test, only dash-prefixed arguments will trigger an
// error, given that scripts options can allow a variable number of
// additional non-prefixed argument and we mostly want to check for
// typo right now.
2023-04-27 14:09:55 +02:00
if ( count ( $unknown_options ) > 0 ) {
echo " Unknown option: " . array_values ( $unknown_options )[ 0 ] . " \n " ;
2025-02-18 16:08:09 +01:00
install_usage ( $argv [ 0 ], " Usage: " );
2023-02-18 14:06:58 +01:00
exit ( 1 );
}
// Tricky argument list hack, should be removed someday.
// Reset argv to remove the argument that were parsed. This is needed
// currently because some install code, like in upgrade.php, are using
// $argv[] directly with fixed index to fetch some arguments.
$argv = array_merge ( array ( $argv [ 0 ]), array_slice ( $argv , $rest_index ));
$argc = count ( $argv );
}
2009-08-26 20:59:13 +02:00
2016-02-06 17:19:57 +01:00
// Load conf file if it is already defined
2021-02-22 14:41:20 +01:00
if ( ! defined ( 'DONOTLOADCONF' ) && file_exists ( $conffile ) && filesize ( $conffile ) > 8 ) { // Test on filesize is to ensure that conf file is more that an empty template with just <?php in first line
2020-10-31 14:32:18 +01:00
$result = include_once $conffile ; // Load conf file
2021-02-22 14:41:20 +01:00
if ( $result ) {
if ( empty ( $dolibarr_main_db_type )) {
$dolibarr_main_db_type = 'mysqli' ; // For backward compatibility
}
2016-04-17 15:39:46 +02:00
2020-10-31 14:32:18 +01:00
//Mysql driver support has been removed in favor of mysqli
if ( $dolibarr_main_db_type == 'mysql' ) {
$dolibarr_main_db_type = 'mysqli' ;
}
2016-04-17 15:39:46 +02:00
2024-03-24 15:34:19 +01:00
if ( ! isset ( $dolibarr_main_db_port ) && ( $dolibarr_main_db_type == 'mysqli' )) {
2021-02-22 14:41:20 +01:00
$dolibarr_main_db_port = '3306' ; // For backward compatibility
}
2012-10-07 20:04:07 +02:00
2012-07-02 19:30:37 +02:00
// Clean parameters
2023-12-04 12:36:19 +01:00
$dolibarr_main_data_root = isset ( $dolibarr_main_data_root ) ? trim ( $dolibarr_main_data_root ) : DOL_DOCUMENT_ROOT . '/../documents' ;
$dolibarr_main_url_root = isset ( $dolibarr_main_url_root ) ? trim ( $dolibarr_main_url_root ) : '' ;
$dolibarr_main_url_root_alt = isset ( $dolibarr_main_url_root_alt ) ? trim ( $dolibarr_main_url_root_alt ) : '' ;
$dolibarr_main_document_root = isset ( $dolibarr_main_document_root ) ? trim ( $dolibarr_main_document_root ) : '' ;
$dolibarr_main_document_root_alt = isset ( $dolibarr_main_document_root_alt ) ? trim ( $dolibarr_main_document_root_alt ) : '' ;
2020-10-31 14:32:18 +01:00
// Remove last / or \ on directories or url value
2021-02-22 14:41:20 +01:00
if ( ! empty ( $dolibarr_main_document_root ) && ! preg_match ( '/^[\\/]+$/' , $dolibarr_main_document_root )) {
$dolibarr_main_document_root = preg_replace ( '/[\\/]+$/' , '' , $dolibarr_main_document_root );
}
if ( ! empty ( $dolibarr_main_url_root ) && ! preg_match ( '/^[\\/]+$/' , $dolibarr_main_url_root )) {
$dolibarr_main_url_root = preg_replace ( '/[\\/]+$/' , '' , $dolibarr_main_url_root );
}
if ( ! empty ( $dolibarr_main_data_root ) && ! preg_match ( '/^[\\/]+$/' , $dolibarr_main_data_root )) {
$dolibarr_main_data_root = preg_replace ( '/[\\/]+$/' , '' , $dolibarr_main_data_root );
}
if ( ! empty ( $dolibarr_main_document_root_alt ) && ! preg_match ( '/^[\\/]+$/' , $dolibarr_main_document_root_alt )) {
$dolibarr_main_document_root_alt = preg_replace ( '/[\\/]+$/' , '' , $dolibarr_main_document_root_alt );
}
if ( ! empty ( $dolibarr_main_url_root_alt ) && ! preg_match ( '/^[\\/]+$/' , $dolibarr_main_url_root_alt )) {
$dolibarr_main_url_root_alt = preg_replace ( '/[\\/]+$/' , '' , $dolibarr_main_url_root_alt );
}
2020-10-31 14:32:18 +01:00
// Create conf object
2021-02-22 14:41:20 +01:00
if ( ! empty ( $dolibarr_main_document_root )) {
2020-10-31 14:32:18 +01:00
$result = conf ( $dolibarr_main_document_root );
}
// Load database driver
2024-11-20 13:29:07 +01:00
if ( $result > 0 ) {
2021-02-22 14:41:20 +01:00
if ( ! empty ( $dolibarr_main_document_root ) && ! empty ( $dolibarr_main_db_type )) {
2020-10-31 14:32:18 +01:00
$result = include_once $dolibarr_main_document_root . " /core/db/ " . $dolibarr_main_db_type . '.class.php' ;
2021-02-22 14:41:20 +01:00
if ( ! $result ) {
2020-10-31 14:32:18 +01:00
$includeconferror = 'ErrorBadValueForDolibarrMainDBType' ;
}
}
} else {
$includeconferror = 'ErrorBadValueForDolibarrMainDocumentRoot' ;
}
} else {
$includeconferror = 'ErrorBadFormatForConfFile' ;
}
2006-10-20 23:42:57 +02:00
}
2024-06-12 13:57:56 +02:00
2016-03-10 18:36:09 +01:00
$conf -> global -> MAIN_ENABLE_LOG_TO_HTML = 1 ;
2008-06-17 03:18:48 +02:00
2008-12-08 01:04:11 +01:00
// Define prefix
2021-02-22 14:41:20 +01:00
if ( ! isset ( $dolibarr_main_db_prefix ) || ! $dolibarr_main_db_prefix ) {
$dolibarr_main_db_prefix = 'llx_' ;
}
2020-04-10 10:59:32 +02:00
define ( 'MAIN_DB_PREFIX' , ( isset ( $dolibarr_main_db_prefix ) ? $dolibarr_main_db_prefix : '' ));
2008-12-08 01:04:11 +01:00
2024-01-13 19:48:41 +01:00
define ( 'DOL_CLASS_PATH' , 'class/' ); // Filesystem path to class dir
2020-04-10 10:59:32 +02:00
define ( 'DOL_DATA_ROOT' , ( isset ( $dolibarr_main_data_root ) ? $dolibarr_main_data_root : DOL_DOCUMENT_ROOT . '/../documents' ));
define ( 'DOL_MAIN_URL_ROOT' , ( isset ( $dolibarr_main_url_root ) ? $dolibarr_main_url_root : '' )); // URL relative root
$uri = preg_replace ( '/^http(s?):\/\//i' , '' , constant ( 'DOL_MAIN_URL_ROOT' )); // $uri contains url without http*
$suburi = strstr ( $uri , '/' ); // $suburi contains url without domain
2021-02-22 14:41:20 +01:00
if ( $suburi == '/' ) {
$suburi = '' ; // If $suburi is /, it is now ''
}
2020-04-10 10:59:32 +02:00
define ( 'DOL_URL_ROOT' , $suburi ); // URL relative root ('', '/dolibarr', ...)
2010-10-03 02:12:54 +02:00
2021-02-22 14:41:20 +01:00
if ( empty ( $conf -> file -> character_set_client )) {
$conf -> file -> character_set_client = " utf-8 " ;
}
if ( empty ( $conf -> db -> character_set )) {
$conf -> db -> character_set = 'utf8' ;
}
if ( empty ( $conf -> db -> dolibarr_main_db_collation )) {
$conf -> db -> dolibarr_main_db_collation = 'utf8_unicode_ci' ;
}
if ( empty ( $conf -> db -> dolibarr_main_db_encryption )) {
$conf -> db -> dolibarr_main_db_encryption = 0 ;
}
if ( empty ( $conf -> db -> dolibarr_main_db_cryptkey )) {
$conf -> db -> dolibarr_main_db_cryptkey = '' ;
}
if ( empty ( $conf -> db -> user )) {
$conf -> db -> user = '' ;
}
2008-04-04 02:30:57 +02:00
2024-06-30 21:02:50 +02:00
// Define an array of document root directories
2020-04-10 10:59:32 +02:00
$conf -> file -> dol_document_root = array ( DOL_DOCUMENT_ROOT );
2021-02-22 14:41:20 +01:00
if ( ! empty ( $dolibarr_main_document_root_alt )) {
2020-10-31 14:32:18 +01:00
// dolibarr_main_document_root_alt contains several directories
$values = preg_split ( '/[;,]/' , $dolibarr_main_document_root_alt );
2021-02-22 14:41:20 +01:00
foreach ( $values as $value ) {
2020-10-31 14:32:18 +01:00
$conf -> file -> dol_document_root [] = $value ;
}
2010-10-03 02:12:54 +02:00
}
2009-01-20 00:32:18 +01:00
2023-02-02 12:58:12 +01:00
// Check install.lock (for both install and upgrade)
2022-07-14 14:59:28 +02:00
2023-02-02 12:58:12 +01:00
$lockfile = DOL_DATA_ROOT . '/install.lock' ; // To lock all /install pages
$lockfile2 = DOL_DOCUMENT_ROOT . '/install.lock' ; // To lock all /install pages (recommended)
$upgradeunlockfile = DOL_DATA_ROOT . '/upgrade.unlock' ; // To unlock upgrade process
$upgradeunlockfile2 = DOL_DOCUMENT_ROOT . '/upgrade.unlock' ; // To unlock upgrade process
2016-01-14 11:17:47 +01:00
if ( constant ( 'DOL_DATA_ROOT' ) === null ) {
2016-01-08 11:57:18 +01:00
// We don't have a configuration file yet
// Try to detect any lockfile in the default documents path
$lockfile = '../../documents/install.lock' ;
2023-02-02 12:58:12 +01:00
$upgradeunlockfile = '../../documents/upgrade.unlock' ;
}
2024-03-14 21:59:15 +01:00
$islocked = false ;
2023-02-02 12:58:12 +01:00
if ( @ file_exists ( $lockfile ) || @ file_exists ( $lockfile2 )) {
if ( ! defined ( 'ALLOWED_IF_UPGRADE_UNLOCK_FOUND' ) || ( ! @ file_exists ( $upgradeunlockfile ) && ! @ file_exists ( $upgradeunlockfile2 ))) {
// If this is a dangerous install page (ALLOWED_IF_UPGRADE_UNLOCK_FOUND not defined) or
// if there is no upgrade unlock files, we lock the pages.
$islocked = true ;
}
2016-01-08 11:57:18 +01:00
}
2023-02-02 12:58:12 +01:00
if ( $islocked ) { // Pages are locked
2021-02-22 14:41:20 +01:00
if ( ! isset ( $langs ) || ! is_object ( $langs )) {
2018-06-30 01:59:54 +02:00
$langs = new Translate ( '..' , $conf );
2018-06-27 01:53:36 +02:00
$langs -> setDefaultLang ( 'auto' );
}
$langs -> load ( " install " );
2022-07-14 14:59:28 +02:00
header ( " X-Content-Type-Options: nosniff " );
header ( " X-Frame-Options: SAMEORIGIN " ); // Frames allowed only if on same domain (stop some XSS attacks)
2023-02-02 12:58:12 +01:00
if ( GETPOST ( 'action' ) != 'upgrade' ) {
print $langs -> trans ( " YouTryInstallDisabledByFileLock " ) . '<br>' ;
} else {
print $langs -> trans ( " YouTryUpgradeDisabledByMissingFileUnLock " ) . '<br>' ;
}
2021-02-22 14:41:20 +01:00
if ( ! empty ( $dolibarr_main_url_root )) {
2023-11-28 14:00:15 +01:00
if ( GETPOST ( 'action' ) != 'upgrade' && ( ! file_exists ( $conffile ) || ! isset ( $dolibarr_main_url_root ))) {
2023-02-02 12:58:12 +01:00
print $langs -> trans ( " ClickOnLinkOrRemoveManualy " ) . '<br>' ;
} else {
print $langs -> trans ( " ClickOnLinkOrCreateUnlockFileManualy " ) . '<br>' ;
}
2020-11-30 14:47:07 +01:00
print '<a href="' . $dolibarr_main_url_root . '/admin/index.php?mainmenu=home&leftmenu=setup' . ( GETPOSTISSET ( " login " ) ? '&username=' . urlencode ( GETPOST ( " login " )) : '' ) . '">' ;
2020-10-31 14:32:18 +01:00
print $langs -> trans ( " ClickHereToGoToApp " );
print '</a>' ;
} else {
2023-02-02 12:58:12 +01:00
print 'If you always reach this page, you must remove the install.lock file manually.<br>' ;
2020-10-31 14:32:18 +01:00
}
exit ;
2008-04-04 02:30:57 +02:00
}
2011-10-03 17:19:39 +02:00
// Force usage of log file for install and upgrades
2023-04-15 01:52:35 +02:00
$conf -> modules [ 'syslog' ] = 'syslog' ;
2020-04-10 10:59:32 +02:00
$conf -> global -> SYSLOG_LEVEL = constant ( 'LOG_DEBUG' );
2021-02-22 14:41:20 +01:00
if ( ! defined ( 'SYSLOG_HANDLERS' )) {
define ( 'SYSLOG_HANDLERS' , '["mod_syslog_file"]' );
}
if ( ! defined ( 'SYSLOG_FILE' )) { // To avoid warning on systems with constant already defined
if ( @ is_writable ( '/tmp' )) {
define ( 'SYSLOG_FILE' , '/tmp/dolibarr_install.log' );
} elseif ( ! empty ( $_ENV [ " TMP " ]) && @ is_writable ( $_ENV [ " TMP " ])) {
define ( 'SYSLOG_FILE' , $_ENV [ " TMP " ] . '/dolibarr_install.log' );
} elseif ( ! empty ( $_ENV [ " TEMP " ]) && @ is_writable ( $_ENV [ " TEMP " ])) {
define ( 'SYSLOG_FILE' , $_ENV [ " TEMP " ] . '/dolibarr_install.log' );
} elseif ( @ is_writable ( '../../../../' ) && @ file_exists ( '../../../../startdoliwamp.bat' )) {
define ( 'SYSLOG_FILE' , '../../../../dolibarr_install.log' ); // For DoliWamp
} elseif ( @ is_writable ( '../../' )) {
define ( 'SYSLOG_FILE' , '../../dolibarr_install.log' ); // For others
}
2013-01-10 08:27:12 +01:00
//print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
}
2021-02-22 14:41:20 +01:00
if ( defined ( 'SYSLOG_FILE' )) {
$conf -> global -> SYSLOG_FILE = constant ( 'SYSLOG_FILE' );
}
if ( ! defined ( 'SYSLOG_FILE_NO_ERROR' )) {
define ( 'SYSLOG_FILE_NO_ERROR' , 1 );
}
2013-01-10 08:27:12 +01:00
// We init log handler for install
$handlers = array ( 'mod_syslog_file' );
2021-02-22 14:41:20 +01:00
foreach ( $handlers as $handler ) {
2013-01-10 08:27:12 +01:00
$file = DOL_DOCUMENT_ROOT . '/core/modules/syslog/' . $handler . '.php' ;
2021-02-22 14:41:20 +01:00
if ( ! file_exists ( $file )) {
2013-01-10 08:27:12 +01:00
throw new Exception ( 'Missing log handler file ' . $handler . '.php' );
}
require_once $file ;
$loghandlerinstance = new $handler ();
2024-04-25 11:13:34 +02:00
if ( ! $loghandlerinstance instanceof LogHandler ) {
throw new Exception ( 'Log handler does not extend LogHandler' );
2013-01-10 08:27:12 +01:00
}
2021-02-22 14:41:20 +01:00
if ( empty ( $conf -> loghandlers [ $handler ])) {
$conf -> loghandlers [ $handler ] = $loghandlerinstance ;
}
2013-01-10 08:27:12 +01:00
}
2012-12-27 15:22:40 +01:00
2019-06-22 18:29:24 +02:00
// Define object $langs
2019-01-27 11:55:16 +01:00
$langs = new Translate ( '..' , $conf );
2021-02-22 14:41:20 +01:00
if ( GETPOST ( 'lang' , 'aZ09' )) {
$langs -> setDefaultLang ( GETPOST ( 'lang' , 'aZ09' ));
} else {
$langs -> setDefaultLang ( 'auto' );
}
2005-11-04 02:28:28 +01:00
2006-06-17 20:12:46 +02:00
2010-01-20 18:54:44 +01:00
/**
2011-09-29 22:21:57 +02:00
* Load conf file ( file must exists )
*
* @ param string $dolibarr_main_document_root Root directory of Dolibarr bin files
2023-12-01 19:51:32 +01:00
* @ return int Return integer < 0 if KO , > 0 if OK
2010-01-20 18:54:44 +01:00
*/
2007-10-04 19:07:15 +02:00
function conf ( $dolibarr_main_document_root )
{
2020-10-31 14:32:18 +01:00
global $conf ;
global $dolibarr_main_db_type ;
global $dolibarr_main_db_host ;
global $dolibarr_main_db_port ;
global $dolibarr_main_db_name ;
global $dolibarr_main_db_user ;
global $dolibarr_main_db_pass ;
2024-02-12 02:05:52 +01:00
global $dolibarr_main_db_collation ;
global $dolibarr_main_db_character_set ;
2020-10-31 14:32:18 +01:00
global $character_set_client ;
2023-05-03 12:29:11 +02:00
global $dolibarr_main_instance_unique_id ;
global $dolibarr_main_cookie_cryptkey ;
2020-10-31 14:32:18 +01:00
2024-11-20 13:29:07 +01:00
$return = @ include_once $dolibarr_main_document_root . '/core/class/conf.class.php' ;
2021-02-22 14:41:20 +01:00
if ( ! $return ) {
return - 1 ;
}
2020-10-31 14:32:18 +01:00
$conf = new Conf ();
$conf -> db -> type = trim ( $dolibarr_main_db_type );
$conf -> db -> host = trim ( $dolibarr_main_db_host );
$conf -> db -> port = trim ( $dolibarr_main_db_port );
$conf -> db -> name = trim ( $dolibarr_main_db_name );
$conf -> db -> user = trim ( $dolibarr_main_db_user );
2022-09-21 03:16:18 +02:00
$conf -> db -> pass = ( empty ( $dolibarr_main_db_pass ) ? '' : trim ( $dolibarr_main_db_pass ));
2020-10-31 14:32:18 +01:00
// Mysql driver support has been removed in favor of mysqli
2021-02-22 14:41:20 +01:00
if ( $conf -> db -> type == 'mysql' ) {
$conf -> db -> type = 'mysqli' ;
}
if ( empty ( $character_set_client )) {
$character_set_client = " UTF-8 " ;
}
2020-10-31 14:32:18 +01:00
$conf -> file -> character_set_client = strtoupper ( $character_set_client );
2023-05-03 12:29:11 +02:00
// Unique id of instance
$conf -> file -> instance_unique_id = empty ( $dolibarr_main_instance_unique_id ) ? ( empty ( $dolibarr_main_cookie_cryptkey ) ? '' : $dolibarr_main_cookie_cryptkey ) : $dolibarr_main_instance_unique_id ;
2021-02-22 14:41:20 +01:00
if ( empty ( $dolibarr_main_db_character_set )) {
$dolibarr_main_db_character_set = ( $conf -> db -> type == 'mysqli' ? 'utf8' : '' );
}
2020-10-31 14:32:18 +01:00
$conf -> db -> character_set = $dolibarr_main_db_character_set ;
2021-02-22 14:41:20 +01:00
if ( empty ( $dolibarr_main_db_collation )) {
$dolibarr_main_db_collation = ( $conf -> db -> type == 'mysqli' ? 'utf8_unicode_ci' : '' );
}
2020-10-31 14:32:18 +01:00
$conf -> db -> dolibarr_main_db_collation = $dolibarr_main_db_collation ;
2021-02-22 14:41:20 +01:00
if ( empty ( $dolibarr_main_db_encryption )) {
$dolibarr_main_db_encryption = 0 ;
}
2020-10-31 14:32:18 +01:00
$conf -> db -> dolibarr_main_db_encryption = $dolibarr_main_db_encryption ;
2021-02-22 14:41:20 +01:00
if ( empty ( $dolibarr_main_db_cryptkey )) {
$dolibarr_main_db_cryptkey = '' ;
}
2020-10-31 14:32:18 +01:00
$conf -> db -> dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey ;
// Force usage of log file for install and upgrades
2023-04-15 01:52:35 +02:00
$conf -> modules [ 'syslog' ] = 'syslog' ;
2020-10-31 14:32:18 +01:00
$conf -> global -> SYSLOG_LEVEL = constant ( 'LOG_DEBUG' );
2021-02-22 14:41:20 +01:00
if ( ! defined ( 'SYSLOG_HANDLERS' )) {
define ( 'SYSLOG_HANDLERS' , '["mod_syslog_file"]' );
}
if ( ! defined ( 'SYSLOG_FILE' )) { // To avoid warning on systems with constant already defined
if ( @ is_writable ( '/tmp' )) {
define ( 'SYSLOG_FILE' , '/tmp/dolibarr_install.log' );
} elseif ( ! empty ( $_ENV [ " TMP " ]) && @ is_writable ( $_ENV [ " TMP " ])) {
define ( 'SYSLOG_FILE' , $_ENV [ " TMP " ] . '/dolibarr_install.log' );
} elseif ( ! empty ( $_ENV [ " TEMP " ]) && @ is_writable ( $_ENV [ " TEMP " ])) {
define ( 'SYSLOG_FILE' , $_ENV [ " TEMP " ] . '/dolibarr_install.log' );
} elseif ( @ is_writable ( '../../../../' ) && @ file_exists ( '../../../../startdoliwamp.bat' )) {
define ( 'SYSLOG_FILE' , '../../../../dolibarr_install.log' ); // For DoliWamp
} elseif ( @ is_writable ( '../../' )) {
define ( 'SYSLOG_FILE' , '../../dolibarr_install.log' ); // For others
}
2020-10-31 14:32:18 +01:00
//print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
}
2021-02-22 14:41:20 +01:00
if ( defined ( 'SYSLOG_FILE' )) {
$conf -> global -> SYSLOG_FILE = constant ( 'SYSLOG_FILE' );
}
if ( ! defined ( 'SYSLOG_FILE_NO_ERROR' )) {
define ( 'SYSLOG_FILE_NO_ERROR' , 1 );
}
2020-10-31 14:32:18 +01:00
// We init log handler for install
$handlers = array ( 'mod_syslog_file' );
2021-02-22 14:41:20 +01:00
foreach ( $handlers as $handler ) {
2020-10-31 14:32:18 +01:00
$file = DOL_DOCUMENT_ROOT . '/core/modules/syslog/' . $handler . '.php' ;
2021-02-22 14:41:20 +01:00
if ( ! file_exists ( $file )) {
2020-10-31 14:32:18 +01:00
throw new Exception ( 'Missing log handler file ' . $handler . '.php' );
}
require_once $file ;
$loghandlerinstance = new $handler ();
2024-04-25 11:13:34 +02:00
if ( ! $loghandlerinstance instanceof LogHandler ) {
throw new Exception ( 'Log handler does not extend LogHandler' );
2020-10-31 14:32:18 +01:00
}
2013-03-30 14:27:13 +01:00
2021-02-22 14:41:20 +01:00
if ( empty ( $conf -> loghandlers [ $handler ])) {
$conf -> loghandlers [ $handler ] = $loghandlerinstance ;
}
2020-10-31 14:32:18 +01:00
}
2013-07-07 03:26:51 +02:00
2020-10-31 14:32:18 +01:00
return 1 ;
2007-07-19 21:30:32 +02:00
}
2007-11-09 00:06:00 +01:00
2010-01-20 18:54:44 +01:00
/**
2012-04-28 16:37:58 +02:00
* Show HTML header of install pages
2010-01-20 18:54:44 +01:00
*
2012-10-08 02:45:58 +02:00
* @ param string $subtitle Title
2012-10-07 20:04:07 +02:00
* @ param string $next Next
* @ param string $action Action code ( 'set' or 'upgrade' )
* @ param string $param Param
* @ param string $forcejqueryurl Set jquery relative URL ( must end with / if defined )
2016-12-23 00:28:16 +01:00
* @ param string $csstable Css for table
2011-09-29 22:21:57 +02:00
* @ return void
2010-01-20 18:54:44 +01:00
*/
2019-01-27 15:20:16 +01:00
function pHeader ( $subtitle , $next , $action = 'set' , $param = '' , $forcejqueryurl = '' , $csstable = 'main-inside' )
2005-11-03 19:00:17 +01:00
{
2020-10-31 14:32:18 +01:00
global $conf ;
global $langs ;
$langs -> load ( " main " );
$langs -> load ( " admin " );
2018-06-24 15:44:13 +02:00
$langs -> load ( " install " );
2011-09-29 22:21:57 +02:00
2020-10-31 14:32:18 +01:00
$jquerytheme = 'base' ;
2021-02-22 14:41:20 +01:00
if ( $forcejqueryurl ) {
2020-10-31 14:32:18 +01:00
$jQueryCustomPath = $forcejqueryurl ;
$jQueryUiCustomPath = $forcejqueryurl ;
} else {
$jQueryCustomPath = ( defined ( 'JS_JQUERY' ) && constant ( 'JS_JQUERY' )) ? JS_JQUERY : false ;
$jQueryUiCustomPath = ( defined ( 'JS_JQUERY_UI' ) && constant ( 'JS_JQUERY_UI' )) ? JS_JQUERY_UI : false ;
}
// We force the content charset
header ( " Content-type: text/html; charset= " . $conf -> file -> character_set_client );
header ( " X-Content-Type-Options: nosniff " );
2022-07-14 11:53:31 +02:00
header ( " X-Frame-Options: SAMEORIGIN " ); // Frames allowed only if on same domain (stop some XSS attacks)
2020-10-31 14:32:18 +01:00
print '<!DOCTYPE HTML>' . " \n " ;
print '<html>' . " \n " ;
print '<head>' . " \n " ;
print '<meta charset="' . $conf -> file -> character_set_client . '">' . " \n " ;
print '<meta name="viewport" content="width=device-width, initial-scale=1.0">' . " \n " ;
print '<meta name="generator" content="Dolibarr installer">' . " \n " ;
print '<link rel="stylesheet" type="text/css" href="default.css">' . " \n " ;
print '<!-- Includes CSS for JQuery -->' . " \n " ;
2021-02-22 14:41:20 +01:00
if ( $jQueryUiCustomPath ) {
print '<link rel="stylesheet" type="text/css" href="' . $jQueryUiCustomPath . 'css/' . $jquerytheme . '/jquery-ui.min.css" />' . " \n " ; // JQuery
} else {
print '<link rel="stylesheet" type="text/css" href="../includes/jquery/css/' . $jquerytheme . '/jquery-ui.min.css" />' . " \n " ; // JQuery
}
2020-10-31 14:32:18 +01:00
print '<!-- Includes JS for JQuery -->' . " \n " ;
2021-02-22 14:41:20 +01:00
if ( $jQueryCustomPath ) {
print '<script type="text/javascript" src="' . $jQueryCustomPath . 'jquery.min.js"></script>' . " \n " ;
} else {
print '<script type="text/javascript" src="../includes/jquery/js/jquery.min.js"></script>' . " \n " ;
}
if ( $jQueryUiCustomPath ) {
print '<script type="text/javascript" src="' . $jQueryUiCustomPath . 'jquery-ui.min.js"></script>' . " \n " ;
} else {
print '<script type="text/javascript" src="../includes/jquery/js/jquery-ui.min.js"></script>' . " \n " ;
}
2020-10-31 14:32:18 +01:00
print '<title>' . $langs -> trans ( " DolibarrSetup " ) . '</title>' . " \n " ;
print '</head>' . " \n " ;
print '<body>' . " \n " ;
print '<div class="divlogoinstall" style="text-align:center">' ;
print '<img class="imglogoinstall" src="../theme/dolibarr_logo.svg" alt="Dolibarr logo" width="300px"><br>' ;
print DOL_VERSION ;
print '</div><br>' ;
2024-09-05 11:49:33 +02:00
print '<span class="titre">' ;
2020-10-31 14:32:18 +01:00
if ( $subtitle ) {
2024-09-05 11:49:33 +02:00
print $subtitle ;
} else {
print $langs -> trans ( " DolibarrSetup " );
2020-10-31 14:32:18 +01:00
}
print '</span>' . " \n " ;
2024-06-19 17:58:15 +02:00
print '<form name="forminstall" id="forminstall" class="centpercent" action="' . $next . '.php' . ( $param ? '?' . $param : '' ) . '" method="POST"' ;
2021-02-22 14:41:20 +01:00
if ( $next == 'step5' ) {
print ' autocomplete="off"' ;
}
2020-10-31 14:32:18 +01:00
print '>' . " \n " ;
print '<input type="hidden" name="testpost" value="ok">' . " \n " ;
print '<input type="hidden" name="action" value="' . $action . '">' . " \n " ;
2024-06-19 17:58:15 +02:00
print '<div id="divinstall">' ;
2020-10-31 14:32:18 +01:00
2024-06-19 17:58:15 +02:00
print '<table class="main centpercent"><tr><td>' . " \n " ;
print '<table class="' . $csstable . ' centpercent"><tr><td>' . " \n " ;
2005-11-03 19:00:17 +01:00
}
2005-11-04 02:28:28 +01:00
2010-01-20 18:54:44 +01:00
/**
2012-04-28 16:37:58 +02:00
* Print HTML footer of install pages
2010-01-20 18:54:44 +01:00
*
2016-05-09 11:06:18 +02:00
* @ param integer $nonext 1 = No button " Next step " , 2 = Show button but disabled with a link to enable
2012-04-28 16:37:58 +02:00
* @ param string $setuplang Language code
2011-09-29 22:21:57 +02:00
* @ param string $jscheckfunction Add a javascript check function
2015-03-17 00:21:17 +01:00
* @ param integer $withpleasewait Add also please wait tags
2021-02-27 12:45:07 +01:00
* @ param string $morehtml Add more HTML content
2011-09-29 22:21:57 +02:00
* @ return void
2010-01-20 18:54:44 +01:00
*/
2021-02-27 12:45:07 +01:00
function pFooter ( $nonext = 0 , $setuplang = '' , $jscheckfunction = '' , $withpleasewait = 0 , $morehtml = '' )
2005-11-03 19:00:17 +01:00
{
2020-10-31 14:32:18 +01:00
global $conf , $langs ;
2011-09-29 22:21:57 +02:00
2020-11-26 11:09:35 +01:00
$langs -> loadLangs ( array ( " main " , " other " , " admin " ));
2011-09-29 22:21:57 +02:00
2020-10-31 14:32:18 +01:00
print '</td></tr></table>' . " \n " ;
print '</td></tr></table>' . " \n " ;
2011-09-29 22:21:57 +02:00
2021-02-27 12:45:07 +01:00
print '<!-- pFooter -->' . " \n " ;
print $morehtml ;
2024-06-19 17:58:15 +02:00
print '</div>' ;
2021-02-22 14:41:20 +01:00
if ( ! $nonext || ( $nonext == '2' )) {
2020-10-31 14:32:18 +01:00
print '<div class="nextbutton" id="nextbutton">' ;
2021-02-22 14:41:20 +01:00
if ( $nonext == '2' ) {
2020-11-26 11:09:35 +01:00
print '<span class="warning">' ;
print $langs -> trans ( " ErrorFoundDuringMigration " , isset ( $_SERVER [ " REQUEST_URI " ]) ? $_SERVER [ " REQUEST_URI " ] . '&ignoreerrors=1' : '' );
print '</span>' ;
print '<br><br>' ;
2016-05-09 11:06:18 +02:00
}
2017-06-10 21:37:27 +02:00
2020-10-31 14:32:18 +01:00
print '<input type="submit" ' . ( $nonext == '2' ? 'disabled="disabled" ' : '' ) . 'value="' . $langs -> trans ( " NextStep " ) . ' ->"' ;
2021-02-22 14:41:20 +01:00
if ( $jscheckfunction ) {
print ' onClick="return ' . $jscheckfunction . '();"' ;
}
2024-06-19 17:58:15 +02:00
print '>' ;
print '</div>' ;
2021-02-22 14:41:20 +01:00
if ( $withpleasewait ) {
print '<div style="visibility: hidden;" class="pleasewait" id="pleasewait"><br>' . $langs -> trans ( " NextStepMightLastALongTime " ) . '<br><br><div class="blinkwait">' . $langs -> trans ( " PleaseBePatient " ) . '</div></div>' ;
}
2020-10-31 14:32:18 +01:00
}
2021-02-22 14:41:20 +01:00
if ( $setuplang ) {
2021-03-22 19:19:18 +01:00
print '<input type="hidden" name="selectlang" value="' . dol_escape_htmltag ( $setuplang ) . '">' ;
2020-10-31 14:32:18 +01:00
}
2022-09-11 23:47:32 +02:00
print '</form><br>' . " \n " ;
2020-10-31 14:32:18 +01:00
// If there is some logs in buffer to show
2021-02-22 14:41:20 +01:00
if ( isset ( $conf -> logbuffer ) && count ( $conf -> logbuffer )) {
2020-10-31 14:32:18 +01:00
print " \n " ;
print " <!-- Start of log output \n " ;
//print '<div class="hidden">'."\n";
2021-02-22 14:41:20 +01:00
foreach ( $conf -> logbuffer as $logline ) {
2020-10-31 14:32:18 +01:00
print $logline . " <br> \n " ;
}
//print '</div>'."\n";
print " End of log output --> \n " ;
print " \n " ;
}
print '</body>' . " \n " ;
print '</html>' . " \n " ;
2005-11-03 19:00:17 +01:00
}
2005-11-04 02:28:28 +01:00
2010-01-20 18:54:44 +01:00
/**
* Log function for install pages
*
2011-09-29 22:21:57 +02:00
* @ param string $message Message
* @ param int $level Level of log
* @ return void
2010-01-20 18:54:44 +01:00
*/
2019-01-27 15:20:16 +01:00
function dolibarr_install_syslog ( $message , $level = LOG_DEBUG )
2005-11-03 19:00:17 +01:00
{
2021-02-22 14:41:20 +01:00
if ( ! defined ( 'LOG_DEBUG' )) {
define ( 'LOG_DEBUG' , 6 );
}
2020-10-31 14:32:18 +01:00
dol_syslog ( $message , $level );
2006-06-17 02:58:51 +02:00
}
2016-02-22 18:45:00 +01:00
/**
* Automatically detect Dolibarr ' s main document root
*
* @ return string
*/
function detect_dolibarr_main_document_root ()
{
// If PHP is in CGI mode, SCRIPT_FILENAME is PHP's path.
// Since that's not what we want, we suggest $_SERVER["DOCUMENT_ROOT"]
2021-02-22 14:41:20 +01:00
if ( $_SERVER [ " SCRIPT_FILENAME " ] == 'php' || preg_match ( '/[\\/]php$/i' , $_SERVER [ " SCRIPT_FILENAME " ]) || preg_match ( '/php\.exe$/i' , $_SERVER [ " SCRIPT_FILENAME " ])) {
2016-02-22 18:45:00 +01:00
$dolibarr_main_document_root = $_SERVER [ " DOCUMENT_ROOT " ];
if ( ! preg_match ( '/[\\/]dolibarr[\\/]htdocs$/i' , $dolibarr_main_document_root )) {
$dolibarr_main_document_root .= " /dolibarr/htdocs " ;
}
} else {
// We assume /install to be under /htdocs, so we get the parent directory of the current directory
$dolibarr_main_document_root = dirname ( dirname ( $_SERVER [ " SCRIPT_FILENAME " ]));
}
return $dolibarr_main_document_root ;
}
/**
* Automatically detect Dolibarr ' s main data root
*
* @ param string $dolibarr_main_document_root Current main document root
* @ return string
*/
function detect_dolibarr_main_data_root ( $dolibarr_main_document_root )
{
2024-07-02 01:59:20 +02:00
$dolibarr_main_data_root = preg_replace ( " / \ /[^ \ /]+ $ / " , " /documents " , $dolibarr_main_document_root );
2016-02-22 18:45:00 +01:00
return $dolibarr_main_data_root ;
}
/**
* Automatically detect Dolibarr ' s main URL root
*
* @ return string
*/
function detect_dolibarr_main_url_root ()
{
// If defined (Ie: Apache with Linux)
if ( isset ( $_SERVER [ " SCRIPT_URI " ])) {
$dolibarr_main_url_root = $_SERVER [ " SCRIPT_URI " ];
2021-02-22 14:41:20 +01:00
} elseif ( isset ( $_SERVER [ " SERVER_URL " ]) && isset ( $_SERVER [ " DOCUMENT_URI " ])) {
// If defined (Ie: Apache with Caudium)
2020-04-10 10:59:32 +02:00
$dolibarr_main_url_root = $_SERVER [ " SERVER_URL " ] . $_SERVER [ " DOCUMENT_URI " ];
2021-02-22 14:41:20 +01:00
} else {
// If SCRIPT_URI, SERVER_URL, DOCUMENT_URI not defined (Ie: Apache 2.0.44 for Windows)
2020-04-10 10:59:32 +02:00
$proto = (( ! empty ( $_SERVER [ " HTTPS " ]) && $_SERVER [ " HTTPS " ] == 'on' ) || ( ! empty ( $_SERVER [ 'SERVER_PORT' ]) && $_SERVER [ 'SERVER_PORT' ] == 443 )) ? 'https' : 'http' ;
2016-02-22 18:45:00 +01:00
if ( ! empty ( $_SERVER [ " HTTP_HOST " ])) {
$serverport = $_SERVER [ " HTTP_HOST " ];
2020-05-21 15:05:19 +02:00
} elseif ( ! empty ( $_SERVER [ " SERVER_NAME " ])) {
2016-02-22 18:45:00 +01:00
$serverport = $_SERVER [ " SERVER_NAME " ];
2020-05-21 15:05:19 +02:00
} else {
2019-09-30 21:51:42 +02:00
$serverport = 'localhost' ;
}
2020-04-10 10:59:32 +02:00
$dolibarr_main_url_root = $proto . " :// " . $serverport . $_SERVER [ " SCRIPT_NAME " ];
2016-02-22 18:45:00 +01:00
}
// Clean proposed URL
// We assume /install to be under /htdocs, so we get the parent path of the current URL
$dolibarr_main_url_root = dirname ( dirname ( $dolibarr_main_url_root ));
return $dolibarr_main_url_root ;
}
/**
* Replaces automatic database login by actual value
*
* @ param string $force_install_databaserootlogin Login
* @ return string
*/
function parse_database_login ( $force_install_databaserootlogin )
{
return preg_replace ( '/__SUPERUSERLOGIN__/' , 'root' , $force_install_databaserootlogin );
}
/**
* Replaces automatic database password by actual value
*
* @ param string $force_install_databaserootpass Password
* @ return string
*/
function parse_database_pass ( $force_install_databaserootpass )
{
return preg_replace ( '/__SUPERUSERPASSWORD__/' , '' , $force_install_databaserootpass );
}