2005-02-13 16:40:15 +01:00
< ? php
2016-02-22 18:45:00 +01:00
/* Copyright ( C ) 2004 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2004 - 2015 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2005 Marc Barilley / Ocebo < marc @ ocebo . com >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2016-02-22 18:45:00 +01:00
* Copyright ( C ) 2013 - 2014 Juanjo Menent < jmenent @ 2 byte . es >
2014-05-05 12:24:39 +02:00
* Copyright ( C ) 2014 Marcos GarcÃa < marcosgdf @ gmail . com >
2016-02-22 18:45:00 +01:00
* Copyright ( C ) 2015 - 2016 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
2005-02-13 16:40:15 +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-02-13 16:40:15 +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-02-13 16:40:15 +01:00
*/
/**
2008-11-14 11:08:57 +01:00
* \file htdocs / install / check . php
* \ingroup install
2010-11-11 00:54:59 +01:00
* \brief Test if file conf can be modified and if does not exists , test if install process can create it
2008-08-28 23:28:59 +02:00
*/
2012-08-23 02:46:16 +02:00
include_once 'inc.php' ;
2005-10-03 03:14:50 +02:00
2016-02-22 18:45:00 +01:00
global $langs ;
2005-04-02 12:06:57 +02:00
$err = 0 ;
2005-10-03 03:14:50 +02:00
$allowinstall = 0 ;
2015-11-22 11:32:31 +01:00
$allowupgrade = false ;
2006-09-09 02:54:59 +02:00
$checksok = 1 ;
2005-02-13 16:40:15 +01:00
2019-11-13 18:32:11 +01:00
$setuplang = GETPOST ( " selectlang " , 'aZ09' , 3 ) ? GETPOST ( " selectlang " , 'aZ09' , 3 ) : $langs -> getDefaultLang ();
2005-10-30 02:07:00 +01:00
$langs -> setDefaultLang ( $setuplang );
2005-02-13 16:40:15 +01:00
$langs -> load ( " install " );
2018-07-07 23:50:41 +02:00
// Now we load forced/pre-set values from install.forced.php file.
2019-11-13 18:32:11 +01:00
$useforcedwizard = false ;
$forcedfile = " ./install.forced.php " ;
2021-02-22 15:18:01 +01:00
if ( $conffile == " /etc/dolibarr/conf.php " ) {
$forcedfile = " /etc/dolibarr/install.forced.php " ;
}
2016-02-22 18:45:00 +01:00
if ( @ file_exists ( $forcedfile )) {
$useforcedwizard = true ;
include_once $forcedfile ;
}
2008-04-20 14:35:28 +02:00
2018-07-07 23:50:41 +02:00
dolibarr_install_syslog ( " - check: Dolibarr install/upgrade process started " );
2008-04-20 14:35:28 +02:00
2010-11-11 00:54:59 +01:00
2008-04-21 09:21:13 +02:00
/*
2008-08-28 23:28:59 +02:00
* View
*/
2006-06-17 16:13:49 +02:00
2019-11-13 18:32:11 +01:00
pHeader ( '' , '' ); // No next step for navigation buttons. Next step is defined by click on links.
2010-11-11 00:54:59 +01:00
2009-08-08 18:26:06 +02:00
//print "<br>\n";
//print $langs->trans("InstallEasy")."<br><br>\n";
2006-09-09 02:54:59 +02:00
2021-04-30 15:34:02 +02:00
print '<h3><img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Database"> ' ;
2021-02-27 12:45:07 +01:00
print '<span class="inline-block">' . $langs -> trans ( " MiscellaneousChecks " ) . " </span></h3> \n " ;
2006-09-09 02:54:59 +02:00
2012-02-29 19:41:12 +01:00
// Check browser
2019-11-13 18:32:11 +01:00
$useragent = $_SERVER [ 'HTTP_USER_AGENT' ];
2021-02-22 15:18:01 +01:00
if ( ! empty ( $useragent )) {
2020-10-31 14:32:18 +01:00
$tmp = getBrowserInfo ( $_SERVER [ " HTTP_USER_AGENT " ]);
$browserversion = $tmp [ 'browserversion' ];
$browsername = $tmp [ 'browsername' ];
2021-02-22 15:18:01 +01:00
if ( $browsername == 'ie' && $browserversion < 7 ) {
print '<img src="../theme/eldy/img/warning.png" alt="Error"> ' . $langs -> trans ( " WarningBrowserTooOld " ) . " <br> \n " ;
}
2012-02-29 19:41:12 +01:00
}
2007-04-18 19:38:55 +02:00
2006-09-09 02:54:59 +02:00
// Check PHP version
2019-11-13 18:32:11 +01:00
$arrayphpminversionerror = array ( 5 , 5 , 0 );
2021-01-05 18:09:59 +01:00
$arrayphpminversionwarning = array ( 5 , 6 , 0 );
2021-02-22 15:18:01 +01:00
if ( versioncompare ( versionphparray (), $arrayphpminversionerror ) < 0 ) { // Minimum to use (error if lower)
2016-07-27 16:49:00 +02:00
print '<img src="../theme/eldy/img/error.png" alt="Error"> ' . $langs -> trans ( " ErrorPHPVersionTooLow " , versiontostring ( $arrayphpminversionerror ));
2019-11-13 18:32:11 +01:00
$checksok = 0 ; // 0=error, 1=warning
2021-02-22 15:18:01 +01:00
} elseif ( versioncompare ( versionphparray (), $arrayphpminversionwarning ) < 0 ) { // Minimum supported (warning if lower)
2020-10-31 14:32:18 +01:00
print '<img src="../theme/eldy/img/warning.png" alt="Error"> ' . $langs -> trans ( " ErrorPHPVersionTooLow " , versiontostring ( $arrayphpminversionwarning ));
$checksok = 0 ; // 0=error, 1=warning
2020-05-21 15:05:19 +02:00
} else {
2008-08-28 23:28:59 +02:00
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> ' . $langs -> trans ( " PHPVersion " ) . " " . versiontostring ( versionphparray ());
2006-09-09 02:54:59 +02:00
}
2021-02-22 15:18:01 +01:00
if ( empty ( $force_install_nophpinfo )) {
print ' (<a href="phpinfo.php" target="_blank">' . $langs -> trans ( " MoreInformation " ) . '</a>)' ;
}
2007-04-18 19:38:55 +02:00
print " <br> \n " ;
2006-09-09 02:54:59 +02:00
2020-11-30 14:47:07 +01:00
// Check PHP support for $_GET and $_POST
2021-02-22 15:18:01 +01:00
if ( ! isset ( $_GET [ " testget " ]) && ! isset ( $_POST [ " testpost " ])) { // We must keep $_GET and $_POST here
2007-04-10 20:54:34 +02:00
print '<img src="../theme/eldy/img/warning.png" alt="Warning"> ' . $langs -> trans ( " PHPSupportPOSTGETKo " );
print ' (<a href="' . $_SERVER [ " PHP_SELF " ] . '?testget=ok">' . $langs -> trans ( " Recheck " ) . '</a>)' ;
print " <br> \n " ;
2019-11-13 18:32:11 +01:00
$checksok = 0 ;
2020-05-21 15:05:19 +02:00
} else {
2008-08-28 23:28:59 +02:00
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> ' . $langs -> trans ( " PHPSupportPOSTGETOk " ) . " <br> \n " ;
2007-03-06 19:30:16 +01:00
}
2007-04-18 19:38:55 +02:00
2021-01-05 18:09:59 +01:00
// Check if session_id is enabled
2021-02-22 15:18:01 +01:00
if ( ! function_exists ( " session_id " )) {
2008-08-28 23:28:59 +02:00
print '<img src="../theme/eldy/img/error.png" alt="Error"> ' . $langs -> trans ( " ErrorPHPDoesNotSupportSessions " ) . " <br> \n " ;
2019-11-13 18:32:11 +01:00
$checksok = 0 ;
2020-05-21 15:05:19 +02:00
} else {
2008-08-28 23:28:59 +02:00
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> ' . $langs -> trans ( " PHPSupportSessions " ) . " <br> \n " ;
2006-09-09 02:54:59 +02:00
}
2005-02-13 16:40:15 +01:00
2007-09-27 00:23:03 +02:00
2021-01-05 18:09:59 +01:00
// Check if GD is supported (we need GD for image conversion)
2021-02-22 15:18:01 +01:00
if ( ! function_exists ( " imagecreate " )) {
2008-05-26 23:27:50 +02:00
$langs -> load ( " errors " );
2008-08-28 23:28:59 +02:00
print '<img src="../theme/eldy/img/warning.png" alt="Error"> ' . $langs -> trans ( " ErrorPHPDoesNotSupportGD " ) . " <br> \n " ;
2020-01-16 01:11:39 +01:00
// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
2020-05-21 15:05:19 +02:00
} else {
2021-01-15 11:21:47 +01:00
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> ' . $langs -> trans ( " PHPSupport " , " GD " ) . " <br> \n " ;
2016-08-05 04:45:05 +02:00
}
2016-07-27 16:52:02 +02:00
2021-01-05 18:09:59 +01:00
// Check if Curl is supported
2021-02-22 15:18:01 +01:00
if ( ! function_exists ( " curl_init " )) {
2020-10-31 14:32:18 +01:00
$langs -> load ( " errors " );
print '<img src="../theme/eldy/img/warning.png" alt="Error"> ' . $langs -> trans ( " ErrorPHPDoesNotSupportCurl " ) . " <br> \n " ;
// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
2020-05-21 15:05:19 +02:00
} else {
2021-01-15 11:21:47 +01:00
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> ' . $langs -> trans ( " PHPSupport " , " Curl " ) . " <br> \n " ;
2007-11-07 18:37:54 +01:00
}
2019-09-30 21:14:25 +02:00
// Check if PHP calendar extension is available
2021-02-22 15:18:01 +01:00
if ( ! function_exists ( " easter_date " )) {
2020-10-31 14:32:18 +01:00
print '<img src="../theme/eldy/img/warning.png" alt="Error"> ' . $langs -> trans ( " ErrorPHPDoesNotSupportCalendar " ) . " <br> \n " ;
2020-05-21 15:05:19 +02:00
} else {
2021-01-15 11:21:47 +01:00
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> ' . $langs -> trans ( " PHPSupport " , " Calendar " ) . " <br> \n " ;
2019-09-30 21:14:25 +02:00
}
2007-11-07 18:37:54 +01:00
2021-01-05 18:09:59 +01:00
// Check if UTF8 is supported
2021-02-22 15:18:01 +01:00
if ( ! function_exists ( " utf8_encode " )) {
2008-11-14 11:08:57 +01:00
$langs -> load ( " errors " );
print '<img src="../theme/eldy/img/warning.png" alt="Error"> ' . $langs -> trans ( " ErrorPHPDoesNotSupportUTF8 " ) . " <br> \n " ;
2020-01-16 01:11:39 +01:00
// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
2020-05-21 15:05:19 +02:00
} else {
2021-01-15 11:21:47 +01:00
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> ' . $langs -> trans ( " PHPSupport " , " UTF8 " ) . " <br> \n " ;
2008-11-14 11:08:57 +01:00
}
2012-05-28 22:39:04 +02:00
2019-06-30 23:52:28 +02:00
// Check if intl methods are supported
2021-02-22 15:18:01 +01:00
if ( empty ( $_SERVER [ " SERVER_ADMIN " ]) || $_SERVER [ " SERVER_ADMIN " ] != 'doliwamp@localhost' ) {
if ( ! function_exists ( " locale_get_primary_language " ) || ! function_exists ( " locale_get_region " )) {
2020-10-31 14:32:18 +01:00
$langs -> load ( " errors " );
print '<img src="../theme/eldy/img/warning.png" alt="Error"> ' . $langs -> trans ( " ErrorPHPDoesNotSupportIntl " ) . " <br> \n " ;
// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
2020-05-21 15:05:19 +02:00
} else {
2021-01-15 11:21:47 +01:00
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> ' . $langs -> trans ( " PHPSupport " , " Intl " ) . " <br> \n " ;
2019-06-30 23:52:28 +02:00
}
2019-04-03 19:37:54 +02:00
}
2021-02-22 15:18:01 +01:00
if ( ! class_exists ( 'ZipArchive' )) {
2020-01-16 01:11:39 +01:00
$langs -> load ( " errors " );
print '<img src="../theme/eldy/img/warning.png" alt="Error"> ' . $langs -> trans ( " ErrorPHPDoesNotSupport " , " ZIP " ) . " <br> \n " ;
// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
2020-05-21 15:05:19 +02:00
} else {
2020-01-16 01:11:39 +01:00
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> ' . $langs -> trans ( " PHPSupport " , " ZIP " ) . " <br> \n " ;
}
2019-04-03 19:37:54 +02:00
2007-09-27 00:23:03 +02:00
// Check memory
2019-11-13 18:32:11 +01:00
$memrequiredorig = '64M' ;
$memrequired = 64 * 1024 * 1024 ;
$memmaxorig = @ ini_get ( " memory_limit " );
$memmax = @ ini_get ( " memory_limit " );
2021-02-22 15:18:01 +01:00
if ( $memmaxorig != '' ) {
2019-01-27 11:55:16 +01:00
preg_match ( '/([0-9]+)([a-zA-Z]*)/i' , $memmax , $reg );
2021-02-22 15:18:01 +01:00
if ( $reg [ 2 ]) {
if ( strtoupper ( $reg [ 2 ]) == 'G' ) {
$memmax = $reg [ 1 ] * 1024 * 1024 * 1024 ;
}
if ( strtoupper ( $reg [ 2 ]) == 'M' ) {
$memmax = $reg [ 1 ] * 1024 * 1024 ;
}
if ( strtoupper ( $reg [ 2 ]) == 'K' ) {
$memmax = $reg [ 1 ] * 1024 ;
}
2007-10-04 01:38:33 +02:00
}
2021-02-22 15:18:01 +01:00
if ( $memmax >= $memrequired || $memmax == - 1 ) {
2019-01-27 11:55:16 +01:00
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> ' . $langs -> trans ( " PHPMemoryOK " , $memmaxorig , $memrequiredorig ) . " <br> \n " ;
2020-05-21 15:05:19 +02:00
} else {
2019-01-27 11:55:16 +01:00
print '<img src="../theme/eldy/img/warning.png" alt="Warning"> ' . $langs -> trans ( " PHPMemoryTooLow " , $memmaxorig , $memrequiredorig ) . " <br> \n " ;
2007-10-04 01:38:33 +02:00
}
2007-09-27 00:23:03 +02:00
}
2007-11-07 18:37:54 +01:00
2021-01-05 18:09:59 +01:00
// If that config file is present and filled
2005-11-03 19:00:17 +01:00
clearstatcache ();
2021-02-22 15:18:01 +01:00
if ( is_readable ( $conffile ) && filesize ( $conffile ) > 8 ) {
2019-11-13 18:32:11 +01:00
dolibarr_install_syslog ( " check: conf file ' " . $conffile . " ' already defined " );
$confexists = 1 ;
2012-08-23 02:04:35 +02:00
include_once $conffile ;
2008-08-28 23:28:59 +02:00
2019-11-13 18:32:11 +01:00
$databaseok = 1 ;
2021-02-22 15:18:01 +01:00
if ( $databaseok ) {
2009-10-06 01:04:05 +02:00
// Already installed for all parts (config and database). We can propose upgrade.
2019-11-13 18:32:11 +01:00
$allowupgrade = true ;
2020-05-21 15:05:19 +02:00
} else {
2019-11-13 18:32:11 +01:00
$allowupgrade = false ;
2009-10-06 01:04:05 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2009-10-06 01:04:05 +02:00
// If not, we create it
2019-11-13 18:32:11 +01:00
dolibarr_install_syslog ( " check: we try to create conf file ' " . $conffile . " ' " );
$confexists = 0 ;
2007-05-10 19:58:57 +02:00
2011-09-20 12:30:56 +02:00
// First we try by copying example
2021-02-22 15:18:01 +01:00
if ( @ copy ( $conffile . " .example " , $conffile )) {
2011-09-20 12:30:56 +02:00
// Success
2019-11-13 18:32:11 +01:00
dolibarr_install_syslog ( " check: successfully copied file " . $conffile . " .example into " . $conffile );
2020-05-21 15:05:19 +02:00
} else {
2011-09-20 12:30:56 +02:00
// If failed, we try to create an empty file
2019-11-13 18:32:11 +01:00
dolibarr_install_syslog ( " check: failed to copy file " . $conffile . " .example into " . $conffile . " . We try to create it. " , LOG_WARNING );
2007-05-10 19:58:57 +02:00
$fp = @ fopen ( $conffile , " w " );
2021-02-22 15:18:01 +01:00
if ( $fp ) {
2007-05-10 19:58:57 +02:00
@ fwrite ( $fp , '<?php' );
2019-01-27 11:55:16 +01:00
@ fputs ( $fp , " \n " );
2007-05-10 19:58:57 +02:00
fclose ( $fp );
2021-02-22 15:18:01 +01:00
} else {
dolibarr_install_syslog ( " check: failed to create a new file " . $conffile . " into current dir " . getcwd () . " . Please check permissions. " , LOG_ERR );
}
2008-08-28 23:28:59 +02:00
}
2007-05-10 19:58:57 +02:00
2018-07-07 23:50:41 +02:00
// First install: no upgrade necessary/required
2019-11-13 18:32:11 +01:00
$allowupgrade = false ;
2005-02-13 16:40:15 +01:00
}
2007-04-18 19:38:55 +02:00
2018-07-07 23:50:41 +02:00
// File is missing and cannot be created
2021-02-22 15:18:01 +01:00
if ( ! file_exists ( $conffile )) {
2019-01-27 11:55:16 +01:00
print '<img src="../theme/eldy/img/error.png" alt="Error"> ' . $langs -> trans ( " ConfFileDoesNotExistsAndCouldNotBeCreated " , $conffiletoshow );
2010-03-16 00:54:37 +01:00
print " <br><br> " ;
2019-01-27 11:55:16 +01:00
print $langs -> trans ( " YouMustCreateWithPermission " , $conffiletoshow );
2010-03-16 00:54:37 +01:00
print " <br><br> " ;
2008-08-28 23:28:59 +02:00
2019-01-27 11:55:16 +01:00
print $langs -> trans ( " CorrectProblemAndReloadPage " , $_SERVER [ 'PHP_SELF' ] . '?testget=ok' );
2008-08-28 23:28:59 +02:00
$err ++ ;
2020-05-21 15:05:19 +02:00
} else {
2021-02-22 15:18:01 +01:00
if ( dol_is_dir ( $conffile )) {
2019-01-27 11:55:16 +01:00
print '<img src="../theme/eldy/img/error.png" alt="Warning"> ' . $langs -> trans ( " ConfFileMustBeAFileNotADir " , $conffiletoshow );
2018-06-05 08:57:04 +02:00
2019-11-13 18:32:11 +01:00
$allowinstall = 0 ;
2021-02-22 15:18:01 +01:00
} elseif ( ! is_writable ( $conffile )) {
// File exists but cannot be modified
if ( $confexists ) {
2019-01-27 11:55:16 +01:00
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> ' . $langs -> trans ( " ConfFileExists " , $conffiletoshow );
2020-05-21 15:05:19 +02:00
} else {
2019-01-27 11:55:16 +01:00
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> ' . $langs -> trans ( " ConfFileCouldBeCreated " , $conffiletoshow );
2008-08-28 23:28:59 +02:00
}
2010-03-16 00:54:37 +01:00
print " <br> " ;
2019-01-27 11:55:16 +01:00
print '<img src="../theme/eldy/img/tick.png" alt="Warning"> ' . $langs -> trans ( " ConfFileIsNotWritable " , $conffiletoshow );
2010-03-16 00:54:37 +01:00
print " <br> \n " ;
2008-08-28 23:28:59 +02:00
2019-11-13 18:32:11 +01:00
$allowinstall = 0 ;
2021-02-22 15:18:01 +01:00
} else {
// File exists and can be modified
if ( $confexists ) {
2019-01-27 11:55:16 +01:00
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> ' . $langs -> trans ( " ConfFileExists " , $conffiletoshow );
2020-05-21 15:05:19 +02:00
} else {
2019-01-27 11:55:16 +01:00
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> ' . $langs -> trans ( " ConfFileCouldBeCreated " , $conffiletoshow );
2008-08-28 23:28:59 +02:00
}
2010-03-16 00:54:37 +01:00
print " <br> " ;
2019-01-27 11:55:16 +01:00
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> ' . $langs -> trans ( " ConfFileIsWritable " , $conffiletoshow );
2010-03-16 00:54:37 +01:00
print " <br> \n " ;
2008-08-28 23:28:59 +02:00
2019-11-13 18:32:11 +01:00
$allowinstall = 1 ;
2008-08-28 23:28:59 +02:00
}
2010-03-16 00:54:37 +01:00
print " <br> \n " ;
2008-08-28 23:28:59 +02:00
2018-07-07 23:50:41 +02:00
// Requirements met/all ok: display the next step button
2021-02-22 15:18:01 +01:00
if ( $checksok ) {
2019-11-13 18:32:11 +01:00
$ok = 0 ;
2009-06-16 02:21:51 +02:00
2014-05-16 14:15:39 +02:00
// Try to create db connection
2021-02-22 15:18:01 +01:00
if ( file_exists ( $conffile )) {
2012-08-23 02:04:35 +02:00
include_once $conffile ;
2021-02-22 15:18:01 +01:00
if ( ! empty ( $dolibarr_main_db_type ) && ! empty ( $dolibarr_main_document_root )) {
if ( ! file_exists ( $dolibarr_main_document_root . " /core/lib/admin.lib.php " )) {
2020-10-31 14:32:18 +01:00
print '<span class="error">A ' . $conffiletoshow . ' file exists with a dolibarr_main_document_root to ' . $dolibarr_main_document_root . ' that seems wrong. Try to fix or remove the ' . $conffiletoshow . ' file.</span><br>' . " \n " ;
dol_syslog ( " A ' " . $conffiletoshow . " ' file exists with a dolibarr_main_document_root to " . $dolibarr_main_document_root . " that seems wrong. Try to fix or remove the ' " . $conffiletoshow . " ' file. " , LOG_WARNING );
2020-05-21 15:05:19 +02:00
} else {
2020-10-31 14:32:18 +01:00
require_once $dolibarr_main_document_root . '/core/lib/admin.lib.php' ;
// If password is encoded, we decode it
2021-02-22 15:18:01 +01:00
if ( preg_match ( '/crypted:/i' , $dolibarr_main_db_pass ) || ! empty ( $dolibarr_main_db_encrypted_pass )) {
2020-10-31 14:32:18 +01:00
require_once $dolibarr_main_document_root . '/core/lib/security.lib.php' ;
2021-02-22 15:18:01 +01:00
if ( preg_match ( '/crypted:/i' , $dolibarr_main_db_pass )) {
2020-10-31 14:32:18 +01:00
$dolibarr_main_db_encrypted_pass = preg_replace ( '/crypted:/i' , '' , $dolibarr_main_db_pass ); // We need to set this as it is used to know the password was initially crypted
$dolibarr_main_db_pass = dol_decode ( $dolibarr_main_db_encrypted_pass );
2021-02-22 15:18:01 +01:00
} else {
$dolibarr_main_db_pass = dol_decode ( $dolibarr_main_db_encrypted_pass );
}
2020-10-31 14:32:18 +01:00
}
// $conf already created in inc.php
$conf -> db -> type = $dolibarr_main_db_type ;
$conf -> db -> host = $dolibarr_main_db_host ;
$conf -> db -> port = $dolibarr_main_db_port ;
$conf -> db -> name = $dolibarr_main_db_name ;
$conf -> db -> user = $dolibarr_main_db_user ;
$conf -> db -> pass = $dolibarr_main_db_pass ;
$db = getDoliDBInstance ( $conf -> db -> type , $conf -> db -> host , $conf -> db -> user , $conf -> db -> pass , $conf -> db -> name , $conf -> db -> port );
2021-02-22 15:18:01 +01:00
if ( $db -> connected && $db -> database_selected ) {
2020-10-31 14:32:18 +01:00
$ok = true ;
}
}
2009-06-16 02:21:51 +02:00
}
}
2018-07-07 23:50:41 +02:00
// If database access is available, we set more variables
2021-02-22 15:18:01 +01:00
if ( $ok ) {
if ( empty ( $dolibarr_main_db_encryption )) {
$dolibarr_main_db_encryption = 0 ;
}
2009-06-30 11:21:29 +02:00
$conf -> db -> dolibarr_main_db_encryption = $dolibarr_main_db_encryption ;
2021-02-22 15:18:01 +01:00
if ( empty ( $dolibarr_main_db_cryptkey )) {
$dolibarr_main_db_cryptkey = '' ;
}
2009-06-30 11:21:29 +02:00
$conf -> db -> dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey ;
2009-07-02 02:19:06 +02:00
2009-06-16 02:21:51 +02:00
$conf -> setValues ( $db );
2018-02-14 14:50:22 +01:00
// Reset forced setup after the setValues
2021-02-22 15:18:01 +01:00
if ( defined ( 'SYSLOG_FILE' )) {
$conf -> global -> SYSLOG_FILE = constant ( 'SYSLOG_FILE' );
}
2018-02-14 14:50:22 +01:00
$conf -> global -> MAIN_ENABLE_LOG_TO_HTML = 1 ;
2009-06-16 02:21:51 +02:00
// Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE
// Version to install is DOL_VERSION
2019-11-13 18:32:11 +01:00
$dolibarrlastupgradeversionarray = preg_split ( '/[\.-]/' , isset ( $conf -> global -> MAIN_VERSION_LAST_UPGRADE ) ? $conf -> global -> MAIN_VERSION_LAST_UPGRADE : ( isset ( $conf -> global -> MAIN_VERSION_LAST_INSTALL ) ? $conf -> global -> MAIN_VERSION_LAST_INSTALL : '' ));
$dolibarrversiontoinstallarray = versiondolibarrarray ();
2009-06-16 02:21:51 +02:00
}
2011-09-20 12:30:56 +02:00
// Show title
2021-02-22 15:18:01 +01:00
if ( ! empty ( $conf -> global -> MAIN_VERSION_LAST_UPGRADE ) || ! empty ( $conf -> global -> MAIN_VERSION_LAST_INSTALL )) {
2020-10-31 14:32:18 +01:00
print $langs -> trans ( " VersionLastUpgrade " ) . ': <b><span class="ok">' . ( empty ( $conf -> global -> MAIN_VERSION_LAST_UPGRADE ) ? $conf -> global -> MAIN_VERSION_LAST_INSTALL : $conf -> global -> MAIN_VERSION_LAST_UPGRADE ) . '</span></b> - ' ;
print $langs -> trans ( " VersionProgram " ) . ': <b><span class="ok">' . DOL_VERSION . '</span></b>' ;
2009-08-04 16:36:29 +02:00
//print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired"));
print '<br>' ;
print '<br>' ;
2021-02-22 15:18:01 +01:00
} else {
print " <br> \n " ;
}
2009-08-04 16:36:29 +02:00
2019-11-02 17:18:34 +01:00
//print $langs->trans("InstallEasy")." ";
2019-11-05 17:20:44 +01:00
print '<h3><span class="soustitre">' . $langs -> trans ( " ChooseYourSetupMode " ) . '</span></h3>' ;
2009-12-04 11:14:51 +01:00
2019-11-13 18:32:11 +01:00
$foundrecommandedchoice = 0 ;
2009-12-04 11:14:51 +01:00
2020-10-31 14:32:18 +01:00
$available_choices = array ();
$notavailable_choices = array ();
2009-08-04 16:36:29 +02:00
2021-02-22 15:18:01 +01:00
if ( empty ( $dolibarr_main_db_host )) { // This means install process was not run
2020-10-31 14:32:18 +01:00
$foundrecommandedchoice = 1 ; // To show only once
}
2020-03-29 23:14:51 +02:00
2020-10-31 14:32:18 +01:00
// Show line of first install choice
$choice = '<tr class="trlineforchoice' . ( $foundrecommandedchoice ? ' choiceselected' : '' ) . '">' . " \n " ;
$choice .= '<td class="nowrap center"><b>' . $langs -> trans ( " FreshInstall " ) . '</b>' ;
2014-05-05 12:08:19 +02:00
$choice .= '</td>' ;
2020-10-31 14:32:18 +01:00
$choice .= '<td class="listofchoicesdesc">' ;
2014-05-05 12:08:19 +02:00
$choice .= $langs -> trans ( " FreshInstallDesc " );
2021-02-22 15:18:01 +01:00
if ( empty ( $dolibarr_main_db_host )) { // This means install process was not run
2020-03-29 23:14:51 +02:00
$choice .= '<br>' ;
2009-10-29 23:28:03 +01:00
//print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
2020-05-25 13:01:32 +02:00
$choice .= '<div class="center"><div class="ok suggestedchoice">' . $langs -> trans ( " InstallChoiceSuggested " ) . '</div></div>' ;
2009-10-29 23:28:03 +01:00
// <img src="../theme/eldy/img/tick.png" alt="Ok"> ';
}
2014-05-05 12:08:19 +02:00
2020-10-31 14:32:18 +01:00
$choice .= '</td>' ;
$choice .= '<td class="center">' ;
2021-02-22 15:18:01 +01:00
if ( $allowinstall ) {
2020-10-31 14:32:18 +01:00
$choice .= '<a class="button" href="fileconf.php?selectlang=' . $setuplang . '">' . $langs -> trans ( " Start " ) . '</a>' ;
2020-05-21 15:05:19 +02:00
} else {
2019-11-02 17:18:34 +01:00
$choice .= ( $foundrecommandedchoice ? '<span class="warning">' : '' ) . $langs -> trans ( " InstallNotAllowed " ) . ( $foundrecommandedchoice ? '</span>' : '' );
2009-08-04 16:36:29 +02:00
}
2020-10-31 14:32:18 +01:00
$choice .= '</td>' . " \n " ;
$choice .= '</tr>' . " \n " ;
2009-08-04 16:36:29 +02:00
2020-10-31 14:32:18 +01:00
$positionkey = ( $foundrecommandedchoice ? 999 : 0 );
if ( $allowinstall ) {
$available_choices [ $positionkey ] = $choice ;
} else {
$notavailable_choices [ $positionkey ] = $choice ;
}
2009-08-04 16:36:29 +02:00
2011-09-20 12:30:56 +02:00
// Show upgrade lines
2019-11-13 18:32:11 +01:00
$allowupgrade = true ;
2021-02-22 15:18:01 +01:00
if ( empty ( $dolibarr_main_db_host )) { // This means install process was not run
$allowupgrade = false ;
}
if ( defined ( " MAIN_NOT_INSTALLED " )) {
2019-11-13 18:32:11 +01:00
$allowupgrade = false ;
2009-10-29 23:28:03 +01:00
}
2021-02-22 15:18:01 +01:00
if ( GETPOST ( 'allowupgrade' )) {
$allowupgrade = true ;
}
2019-11-13 18:32:11 +01:00
$migrationscript = array ( array ( 'from' => '3.0.0' , 'to' => '3.1.0' ),
2012-04-11 16:52:55 +02:00
array ( 'from' => '3.1.0' , 'to' => '3.2.0' ),
2013-01-12 14:34:16 +01:00
array ( 'from' => '3.2.0' , 'to' => '3.3.0' ),
2013-05-04 01:22:09 +02:00
array ( 'from' => '3.3.0' , 'to' => '3.4.0' ),
2013-12-15 00:05:04 +01:00
array ( 'from' => '3.4.0' , 'to' => '3.5.0' ),
2014-07-04 12:27:53 +02:00
array ( 'from' => '3.5.0' , 'to' => '3.6.0' ),
2014-12-03 17:06:44 +01:00
array ( 'from' => '3.6.0' , 'to' => '3.7.0' ),
2015-09-07 13:24:52 +02:00
array ( 'from' => '3.7.0' , 'to' => '3.8.0' ),
2018-01-28 10:57:12 +01:00
array ( 'from' => '3.8.0' , 'to' => '3.9.0' ),
array ( 'from' => '3.9.0' , 'to' => '4.0.0' ),
array ( 'from' => '4.0.0' , 'to' => '5.0.0' ),
array ( 'from' => '5.0.0' , 'to' => '6.0.0' ),
array ( 'from' => '6.0.0' , 'to' => '7.0.0' ),
2018-06-28 18:39:24 +02:00
array ( 'from' => '7.0.0' , 'to' => '8.0.0' ),
2018-12-14 11:13:48 +01:00
array ( 'from' => '8.0.0' , 'to' => '9.0.0' ),
2019-06-20 03:53:33 +02:00
array ( 'from' => '9.0.0' , 'to' => '10.0.0' ),
2019-12-23 14:28:55 +01:00
array ( 'from' => '10.0.0' , 'to' => '11.0.0' ),
2020-05-14 16:45:32 +02:00
array ( 'from' => '11.0.0' , 'to' => '12.0.0' ),
2020-12-27 19:06:56 +01:00
array ( 'from' => '12.0.0' , 'to' => '13.0.0' ),
array ( 'from' => '13.0.0' , 'to' => '14.0.0' )
2013-12-15 00:05:04 +01:00
);
2009-08-04 16:36:29 +02:00
2019-11-13 18:32:11 +01:00
$count = 0 ;
2021-02-22 15:18:01 +01:00
foreach ( $migrationscript as $migarray ) {
2020-10-31 14:32:18 +01:00
$choice = '' ;
2014-05-05 12:08:19 +02:00
2009-08-14 02:30:43 +02:00
$count ++ ;
2020-10-31 14:32:18 +01:00
$recommended_choice = false ;
$version = DOL_VERSION ;
2019-11-13 18:32:11 +01:00
$versionfrom = $migarray [ 'from' ];
2020-10-31 14:32:18 +01:00
$versionto = $migarray [ 'to' ];
$versionarray = preg_split ( '/[\.-]/' , $version );
$dolibarrversionfromarray = preg_split ( '/[\.-]/' , $versionfrom );
$dolibarrversiontoarray = preg_split ( '/[\.-]/' , $versionto );
// Define string newversionxxx that are used for text to show
$newversionfrom = preg_replace ( '/(\.[0-9]+)$/i' , '.*' , $versionfrom );
$newversionto = preg_replace ( '/(\.[0-9]+)$/i' , '.*' , $versionto );
$newversionfrombis = '' ;
2021-02-22 15:18:01 +01:00
if ( versioncompare ( $dolibarrversiontoarray , $versionarray ) < - 2 ) { // From x.y.z -> x.y.z+1
2020-10-31 14:32:18 +01:00
$newversionfrombis = ' ' . $langs -> trans ( " or " ) . ' ' . $versionto ;
}
2021-02-22 15:18:01 +01:00
if ( $ok ) {
if ( count ( $dolibarrlastupgradeversionarray ) >= 2 ) { // If database access is available and last upgrade version is known
2021-02-22 15:18:47 +01:00
// Now we check if this is the first qualified choice
2020-10-31 14:32:18 +01:00
if ( $allowupgrade && empty ( $foundrecommandedchoice ) &&
( versioncompare ( $dolibarrversiontoarray , $dolibarrlastupgradeversionarray ) > 0 || versioncompare ( $dolibarrversiontoarray , $versionarray ) < - 2 )
2021-02-22 15:18:01 +01:00
) {
2020-10-31 14:32:18 +01:00
$foundrecommandedchoice = 1 ; // To show only once
$recommended_choice = true ;
}
} else {
// We cannot recommend a choice.
// A version of install may be known, but we need last upgrade.
}
}
$choice .= " \n " . '<!-- choice ' . $count . ' -->' . " \n " ;
$choice .= '<tr' . ( $recommended_choice ? ' class="choiceselected"' : '' ) . '>' ;
$choice .= '<td class="nowrap center"><b>' . $langs -> trans ( " Upgrade " ) . '<br>' . $newversionfrom . $newversionfrombis . ' -> ' . $newversionto . '</b></td>' ;
$choice .= '<td class="listofchoicesdesc">' ;
$choice .= $langs -> trans ( " UpgradeDesc " );
2021-02-22 15:18:01 +01:00
if ( $recommended_choice ) {
2020-10-31 14:32:18 +01:00
$choice .= '<br>' ;
//print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
$choice .= '<div class="center">' ;
$choice .= '<div class="ok suggestedchoice">' . $langs -> trans ( " InstallChoiceSuggested " ) . '</div>' ;
2021-02-22 15:18:01 +01:00
if ( $count < count ( $migarray )) { // There are other choices after
2020-10-31 14:32:18 +01:00
print $langs -> trans ( " MigrateIsDoneStepByStep " , DOL_VERSION );
}
$choice .= '</div>' ;
}
$choice .= '</td>' ;
$choice .= '<td class="center">' ;
2021-02-22 15:18:01 +01:00
if ( $allowupgrade ) {
2019-11-13 18:32:11 +01:00
$disabled = false ;
2021-02-22 15:18:01 +01:00
if ( $foundrecommandedchoice == 2 ) {
2019-11-13 18:32:11 +01:00
$disabled = true ;
2017-03-20 19:21:26 +01:00
}
2021-02-22 15:18:01 +01:00
if ( $foundrecommandedchoice == 1 ) {
2017-03-20 19:21:26 +01:00
$foundrecommandedchoice = 2 ;
}
2021-02-22 15:18:01 +01:00
if ( $disabled ) {
2020-10-31 14:32:18 +01:00
$choice .= '<span class="opacitymedium">' . $langs -> trans ( " NotYetAvailable " ) . '</span>' ;
} else {
$choice .= '<a class="button runupgrade" href="upgrade.php?action=upgrade' . ( $count < count ( $migrationscript ) ? '_' . $versionto : '' ) . '&selectlang=' . $setuplang . '&versionfrom=' . $versionfrom . '&versionto=' . $versionto . '">' . $langs -> trans ( " Start " ) . '</a>' ;
}
} else {
$choice .= $langs -> trans ( " NotAvailable " );
}
$choice .= '</td>' ;
$choice .= '</tr>' . " \n " ;
if ( $allowupgrade ) {
$available_choices [ $count ] = $choice ;
2020-05-21 15:05:19 +02:00
} else {
2020-10-31 14:32:18 +01:00
$notavailable_choices [ $count ] = $choice ;
2008-08-28 23:28:59 +02:00
}
}
2009-06-16 02:21:51 +02:00
2014-05-29 18:11:14 +02:00
// If there is no choice at all, we show all of them.
2021-02-22 15:18:01 +01:00
if ( empty ( $available_choices )) {
2019-11-13 18:32:11 +01:00
$available_choices = $notavailable_choices ;
$notavailable_choices = array ();
2014-05-29 18:11:14 +02:00
}
2020-10-31 14:32:18 +01:00
// Array of install choices
2019-11-02 17:18:34 +01:00
krsort ( $available_choices , SORT_NATURAL );
2020-10-31 14:32:18 +01:00
print " \n " ;
print '<table width="100%" class="listofchoices">' ;
foreach ( $available_choices as $choice ) {
print $choice ;
}
print '</table>' . " \n " ;
if ( count ( $notavailable_choices )) {
print '<br><div id="AShowChoices" style="opacity: 0.5">' ;
print '> ' . $langs -> trans ( 'ShowNotAvailableOptions' ) . '...' ;
print '</div>' ;
print '<div id="navail_choices" style="display:none">' ;
print " <br> \n " ;
print '<table width="100%" class="listofchoices">' ;
foreach ( $notavailable_choices as $choice ) {
print $choice ;
}
print '</table>' . " \n " ;
print '</div>' ;
}
}
2005-02-13 16:40:15 +01:00
}
2014-05-05 12:08:19 +02:00
print ' < script type = " text/javascript " >
2019-01-21 01:51:28 +01:00
$ ( " div#AShowChoices " ) . click ( function () {
2014-05-05 12:08:19 +02:00
$ ( " div#navail_choices " ) . toggle ();
if ( $ ( " div#navail_choices " ) . css ( " display " ) == " none " ) {
2019-04-22 17:29:02 +02:00
$ ( this ) . text ( " > '. $langs->trans ('ShowNotAvailableOptions').'... " );
2014-05-05 12:08:19 +02:00
} else {
2019-01-21 01:51:28 +01:00
$ ( this ) . text ( " '. $langs->trans ('HideNotAvailableOptions').'... " );
2014-05-05 12:08:19 +02:00
}
});
2005-10-03 03:14:50 +02:00
2015-02-14 12:24:16 +01:00
/*
2015-01-25 22:29:36 +01:00
$ ( " .runupgrade " ) . click ( function () {
return confirm ( " '.dol_escape_js( $langs->transnoentitiesnoconv ( " WarningUpgrade " ), 0, 1).' " );
});
2015-02-14 12:24:16 +01:00
*/
2015-01-25 22:29:36 +01:00
2014-05-05 12:08:19 +02:00
</ script > ' ;
2007-04-18 19:38:55 +02:00
2018-07-07 23:50:41 +02:00
dolibarr_install_syslog ( " - check: end " );
2019-11-13 18:32:11 +01:00
pFooter ( 1 ); // Never display next button