@ -28,10 +28,13 @@ $opts = rcube_utils::get_opt(array('v' => 'version', 'y' => 'accept:bool'));
// ask user if no version is specified
if ( !$opts [ 'version' ] ) {
echo "What version are you upgrading from? Type '?' if you don't know.\n" ;
if ( ( $input = trim( fgets( STDIN) ) ) && preg_match( '/^[0-9.]+[a-z-]*$/' , $input ) )
if ( ( $input = trim( fgets( STDIN) ) ) && preg_match( '/^[0-9.]+[a-z-]*$/' , $input ) ) {
$opts [ 'version' ] = $input ;
else
}
else {
$opts [ 'version' ] = RCMAIL_VERSION;
}
}
$RCI = rcmail_install::get_instance( ) ;
@ -53,24 +56,28 @@ if ($RCI->configured) {
echo "- '" . $msg [ 'prop' ] . "' was replaced by '" . $msg [ 'replacement' ] . "'\n" ;
$err ++;
}
echo "\n" ;
}
// list obsolete config options ( just a notice)
if ( is_array( $messages [ 'obsolete' ] ) ) {
echo "NOTICE: Obsolete config options:\n" ;
echo "(You still have some obsolete or inexistent properties set. This isn't a problem but should be noticed)\n" ;
echo "(You still have some obsolete or inexistent properties set."
. " This isn't a problem but should be noticed)\n" ;
foreach ( $messages [ 'obsolete' ] as $msg ) {
echo "- '" . $msg [ 'prop' ] . ( $msg [ 'name' ] ? "': " . $msg [ 'name' ] : "'" ) . "\n" ;
$err ++;
}
echo "\n" ;
}
if ( !$err && $RCI ->legacy_config) {
echo "WARNING: Your configuration needs to be migrated!\n" ;
echo "We changed the configuration files structure and your two config files main.inc.php and db.inc.php have to be merged into one single file.\n" ;
echo "We changed the configuration files structure and your two config files "
. "main.inc.php and db.inc.php have to be merged into one single file.\n" ;
$err ++;
}
@ -81,11 +88,10 @@ if ($RCI->configured) {
$input = trim( fgets( STDIN) ) ;
}
// positive: let' s merge the local config with the defaults
// positive: merge the local config with the defaults
if ( $opts [ 'accept' ] || strtolower( $input ) = = 'y' ) {
$error = $written = false;
// backup current config
echo ". backing up the current config file(s)...\n" ;
foreach ( array( 'config' , 'main' , 'db' ) as $file ) {
@ -109,9 +115,10 @@ if ($RCI->configured) {
if ( $messages [ 'missing' ] ) {
echo "But you still need to add the following missing options:\n" ;
foreach ( $messages [ 'missing' ] as $msg )
foreach ( $messages [ 'missing' ] as $msg ) {
echo "- '" . $msg [ 'prop' ] . ( $msg [ 'name' ] ? "': " . $msg [ 'name' ] : "'" ) . "\n" ;
}
}
if ( $RCI ->legacy_config) {
foreach ( array( 'main' , 'db' ) as $file ) {
@ -121,7 +128,8 @@ if ($RCI->configured) {
}
else {
echo "Failed to write config file(s)!\n" ;
echo "Grant write privileges to the current user or update the files manually according to the above messages.\n" ;
echo "Grant write privileges to the current user or update the files manually "
. "according to the above messages.\n" ;
}
}
else {
@ -132,11 +140,13 @@ if ($RCI->configured) {
// check dependencies based on the current configuration
if ( is_array( $messages [ 'dependencies' ] ) ) {
echo "WARNING: Dependency check failed!\n" ;
echo "(Some of your configuration settings require other options to be configured or additional PHP modules to be installed)\n" ;
echo "(Some of your configuration settings require other options to be configured "
. "or additional PHP modules to be installed)\n" ;
foreach ( $messages [ 'dependencies' ] as $msg ) {
echo "- " . $msg [ 'prop' ] . ': ' . $msg [ 'explain' ] . "\n" ;
}
echo "Please fix your config files and run this script again!\n" ;
echo "See ya.\n" ;
}
@ -182,6 +192,7 @@ if ($RCI->configured) {
'roundcube/net_sieve' ,
'endroid/qrcode' ,
) ;
foreach ( $old_packages as $pkg ) {
if ( array_key_exists( $pkg , $composer_data [ 'require' ] ) ) {
unset( $composer_data [ 'require' ] [ $pkg ] ) ;
@ -198,22 +209,26 @@ if ($RCI->configured) {
foreach ( $composer_template [ 'repositories' ] as $repo ) {
$rkey = $repo [ 'type' ] . preg_replace( '/^https?:/' , '' , $repo [ 'url' ] ) . $repo [ 'package' ] [ 'name' ] ;
$existing = false;
foreach ( $composer_data [ 'repositories' ] as $k = > $_repo ) {
if ( $rkey = = $_repo [ 'type' ] . preg_replace( '/^https?:/' , '' , $_repo [ 'url' ] ) . $_repo [ 'package' ] [ 'name' ] ) {
// switch to https://
if ( isset( $_repo [ 'url' ] ) && strpos( $_repo [ 'url' ] , 'http://' ) = = = 0)
if ( isset( $_repo [ 'url' ] ) && strpos( $_repo [ 'url' ] , 'http://' ) = = = 0) {
$composer_data [ 'repositories' ] [ $k ] [ 'url' ] = 'https:' . substr( $_repo [ 'url' ] , 5) ;
}
$existing = true;
break;
}
// remove old repos
else if ( strpos( $_repo [ 'url' ] , 'git://git.kolab.org' ) = = = 0) {
if ( strpos( $_repo [ 'url' ] , 'git://git.kolab.org' ) = = = 0) {
unset( $composer_data [ 'repositories' ] [ $k ] ) ;
}
else if ( $_repo [ 'type' ] = = 'package' && $_repo [ 'package' ] [ 'name' ] = = 'Net_SMTP' ) {
unset( $composer_data [ 'repositories' ] [ $k ] ) ;
}
}
if ( !$existing ) {
$composer_data [ 'repositories' ] [ ] = $repo ;
}