@ -48,54 +48,46 @@ $input = trim(fgets(STDIN));
if ( strtolower( $input ) = = 'y' ) {
echo "Copying files to target location..." ;
// Save a copy of original .htaccess file ( #1490623)
if ( file_exists( " $target_dir /.htaccess " ) ) {
$htaccess_copied = copy( " $target_dir /.htaccess " , " $target_dir /.htaccess.orig " ) ;
}
if ( file_exists( " $target_dir /.user.ini " ) ) {
$user_ini_copied = copy( " $target_dir /.user.ini " , " $target_dir /.user.ini.orig " ) ;
}
$dirs = array( 'program' ,'installer' ,'bin' ,'SQL' ,'plugins' ,'skins' ) ;
$dirs = array( 'program' ,'bin' ,'SQL' ,'plugins' ,'skins' ) ;
if ( is_dir( INSTALL_PATH . 'vendor' ) && !is_file( " $target_dir /composer.json " ) ) {
$dirs [ ] = 'vendor' ;
}
if ( file_exists( " $target_dir /installer " ) ) {
$dirs [ ] = 'installer' ;
}
foreach ( $dirs as $dir ) {
// @FIXME: should we use --delete for all directories?
$delete = in_array( $dir , array( 'program' , 'installer' , 'vendor' ) ) ? '--delete ' : '' ;
$delete = in_array( $dir , array( 'program' , ' vendor', 'installe r') ) ? '--delete ' : '' ;
$command = "rsync -aC --out-format=%n " . $delete . INSTALL_PATH . " $dir / $target_dir / $dir / " ;
if ( system( $command , $ret ) = = = false || $ret > 0) {
rcube::raise_error( " Failed to execute command: $command " , false, true ) ;
}
}
foreach ( array( 'index.php' ,' .htaccess','.user.ini' ,' config/defaults.inc.php','composer.json-dist' ,'jsdeps.json' ,'CHANGELOG' ,'README.md' ,'UPGRADING' ,'LICENSE' ,'INSTALL' ) as $file ) {
foreach ( array( 'index.php' ,' config/defaults.inc.php','composer.json-dist' ,'jsdeps.json' ,'CHANGELOG' ,'README.md' ,'UPGRADING' ,'LICENSE' ,'INSTALL' ) as $file ) {
$command = "rsync -a --out-format=%n " . INSTALL_PATH . " $file $target_dir / $file " ;
if ( file_exists( INSTALL_PATH . $file ) && ( system( $command , $ret ) = = = false || $ret > 0) ) {
rcube::raise_error( " Failed to execute command: $command " , false, true ) ;
}
}
foreach ( array( '.htaccess' ,'.user.ini' ) as $file ) {
if ( file_exists( INSTALL_PATH . $file ) ) {
$copied [ $file ] = copy( INSTALL_PATH . $file , " $target_dir / $file .new " ) ;
if ( $copied [ $file ] ) {
echo " $file \n " ;
}
}
}
// remove old ( <1.0) .htaccess file
@unlink( " $target_dir /program/.htaccess " ) ;
echo "done." ;
// Inform the user about .htaccess change
if ( !empty( $htaccess_copied ) ) {
if ( file_get_contents( " $target_dir /.htaccess " ) != file_get_contents( " $target_dir /.htaccess.orig " ) ) {
echo "\n!! Old .htaccess file saved as .htaccess.orig !!" ;
}
else {
@unlink( " $target_dir /.htaccess.orig " ) ;
}
}
// Inform the user about .user.ini change
if ( !empty( $user_ini_copied ) ) {
if ( file_get_contents( " $target_dir /.user.ini " ) != file_get_contents( " $target_dir /.user.ini.orig " ) ) {
echo "\n!! Old .user.ini file saved as .user.ini.orig !!" ;
}
else {
@unlink( " $target_dir /.user.ini.orig " ) ;
// Inform the user about .htaccess or .user.ini change
foreach ( array( '.htaccess' ,'.user.ini' ) as $file ) {
if ( !empty( $copied [ $file ] ) ) {
if ( file_get_contents( " $target_dir / $file .new " ) != file_get_contents( " $target_dir / $file " ) ) {
echo " \n!! New $file file saved as $file .new !! " ;
}
}
}
@ -130,6 +122,10 @@ if (strtolower($input) == 'y') {
echo "Running update script at target...\n" ;
system( " cd $target_dir && php bin/update.sh --version= $oldversion " ) ;
echo "All done.\n" ;
if ( file_exists( " $target_dir /installer " ) ) {
echo "\n!! The directory 'installer' still exists. You should remove it after the upgrade !!\n" ;
}
}
else {
echo "Update cancelled. See ya!\n" ;