b2evolution PHP Cross Reference Blogging Systems

Source: /inc/maintenance/upgrade.ctrl.php - 673 lines - 21795 bytes - Text - Print

Description: Upgrade - This is a LINEAR controller This file is part of b2evolution - {@link http://b2evolution.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * Upgrade - This is a LINEAR controller
   4   *
   5   * This file is part of b2evolution - {@link http://b2evolution.net/}
   6   * See also {@link http://sourceforge.net/projects/evocms/}.
   7   *
   8   * @copyright (c)2009-2014 by Francois PLANQUE - {@link http://fplanque.net/}
   9   * Parts of this file are copyright (c)2009 by The Evo Factory - {@link http://www.evofactory.com/}.
  10   *
  11   * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
  12   *
  13   * {@internal Open Source relicensing agreement:
  14   * The Evo Factory grants Francois PLANQUE the right to license
  15   * The Evo Factory's contributions to this file and the b2evolution project
  16   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  17   * }}
  18   *
  19   * @package maintenance
  20   *
  21   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  22   * @author efy-maxim: Evo Factory / Maxim.
  23   * @author fplanque: Francois Planque.
  24   *
  25   * @version $Id: upgrade.ctrl.php 6180 2014-03-13 10:53:17Z yura $
  26   */
  27  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  28  
  29  /**
  30   * @var instance of User class
  31   */
  32  global $current_User;
  33  
  34  /**
  35   * @vars string paths
  36   */
  37  global $basepath, $upgrade_path, $install_path;
  38  
  39  // Check minimum permission:
  40  $current_User->check_perm( 'perm_maintenance', 'upgrade', true );
  41  
  42  // Used in the upgrade process
  43  $script_start_time = $servertimenow;
  44  
  45  $tab = param( 'tab', 'string', '', true );
  46  
  47  // Set options path:
  48  $AdminUI->set_path( 'options', 'misc', 'upgrade'.$tab );
  49  
  50  // Get action parameter from request:
  51  param_action();
  52  
  53  // Display message if the upgrade config file doesn't exist
  54  check_upgrade_config( true );
  55  
  56  $AdminUI->breadcrumbpath_init( false );  // fp> I'm playing with the idea of keeping the current blog in the path here...
  57  $AdminUI->breadcrumbpath_add( T_('System'), '?ctrl=system' );
  58  $AdminUI->breadcrumbpath_add( T_('Maintenance'), '?ctrl=tools' );
  59  if( $tab == 'svn' )
  60  {
  61      $AdminUI->breadcrumbpath_add( T_('Upgrade from SVN'), '?ctrl=upgrade&amp;tab='.$tab );
  62  }
  63  else
  64  {
  65      $AdminUI->breadcrumbpath_add( T_('Auto Upgrade'), '?ctrl=upgrade' );
  66  }
  67  
  68  
  69  // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
  70  $AdminUI->disp_html_head();
  71  
  72  // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
  73  $AdminUI->disp_body_top();
  74  
  75  $AdminUI->disp_payload_begin();
  76  
  77  echo '<h2 class="red">WARNING: EXPERIMENTAL FEATURE!</h2>';
  78  
  79  echo '<h3>Use for testing only at this point!</h3>';
  80  evo_flush();
  81  
  82  /**
  83   * Display payload:
  84   */
  85  switch( $action )
  86  {
  87      case 'start':
  88      default:
  89          // STEP 1: Check for updates.
  90          if( $tab == '' )
  91          {
  92              autoupgrade_display_steps( 1 );
  93  
  94              $block_item_Widget = new Widget( 'block_item' );
  95              $block_item_Widget->title = T_('Updates from b2evolution.net').get_manual_link( 'auto-upgrade' );
  96              $block_item_Widget->disp_template_replaced( 'block_start' );
  97  
  98              // Note: hopefully, the update will have been downloaded in the shutdown function of a previous page (including the login screen)
  99              // However if we have outdated info, we will load updates here.
 100              load_funcs( 'dashboard/model/_dashboard.funcs.php' );
 101              // Let's clear any remaining messages that should already have been displayed before...
 102              $Messages->clear();
 103              b2evonet_get_updates( true );
 104  
 105              // Display info & error messages
 106              echo $Messages->display( NULL, NULL, false, 'action_messages' );
 107  
 108              /**
 109               * @var AbstractSettings
 110               */
 111              global $global_Cache;
 112  
 113              // Display the current version info for now. We may remove this in the future.
 114              $version_status_msg = $global_Cache->get( 'version_status_msg' );
 115              if( !empty($version_status_msg) )
 116              {    // We have managed to get updates (right now or in the past):
 117                  echo '<p>'.$version_status_msg.'</p>';
 118                  $extra_msg = $global_Cache->get( 'extra_msg' );
 119                  if( !empty($extra_msg) )
 120                  {
 121                      echo '<p>'.$extra_msg.'</p>';
 122                  }
 123              }
 124  
 125              // Extract available updates:
 126              $updates = $global_Cache->get( 'updates' );
 127          }
 128          elseif( $tab == 'svn' )
 129          {
 130              svnupgrade_display_steps( 1 );
 131          }
 132  
 133          // DEBUG:
 134          // $updates[0]['url'] = 'http://xxx/b2evolution-1.0.0.zip'; // TODO: temporary URL
 135  
 136          $action = 'start';
 137  
 138          break;
 139  
 140      case 'download':
 141      case 'force_download':
 142          // STEP 2: DOWNLOAD.
 143  
 144          if( $demo_mode )
 145          {
 146              echo('This feature is disabled on the demo server.');
 147              break;
 148          }
 149  
 150          $action_success = true;
 151          $download_success = true;
 152  
 153          autoupgrade_display_steps( 2 );
 154  
 155          $block_item_Widget = new Widget( 'block_item' );
 156          $block_item_Widget->title = T_('Downloading package...');
 157          $block_item_Widget->disp_template_replaced( 'block_start' );
 158  
 159          $download_url = param( 'upd_url', 'string', '', true );
 160  
 161          $upgrade_name = pathinfo( $download_url );
 162          $upgrade_name = $upgrade_name['filename'];
 163          $upgrade_file = $upgrade_path.$upgrade_name.'.zip';
 164  
 165          if( file_exists( $upgrade_file ) )
 166          { // The downloading file already exists
 167              if( $action == 'force_download' )
 168              { // Try to delete previous package if the downloading is forced
 169                  if( ! @unlink( $upgrade_file ) )
 170                  {
 171                      echo '<p class="red">'.sprintf( T_('Unable to delete previous downloaded package %s before forcing the download.'), '<b>'.$upgrade_file.'</b>' ).'</p>';
 172                      $action_success = false;
 173                  }
 174              }
 175              else
 176              {
 177                  echo '<div class="action_messages"><div class="log_error" style="text-align:center;font-weight:bold">'
 178                      .sprintf( T_( 'The package %s is already downloaded.' ), $upgrade_name.'.zip' ).'</div></div>';
 179                  $action_success = false;
 180              }
 181              evo_flush();
 182          }
 183  
 184          if( $action_success && ( $download_success = prepare_maintenance_dir( $upgrade_path, true ) ) )
 185          {
 186              // Set maximum execution time
 187              set_max_execution_time( 1800 ); // 30 minutes
 188  
 189              echo '<p>'.sprintf( T_( 'Downloading package to &laquo;<strong>%s</strong>&raquo;...' ), $upgrade_file );
 190              evo_flush();
 191  
 192              // Downloading
 193              $file_contents = fetch_remote_page( $download_url, $info, 1800 );
 194  
 195              if( $info['status'] != 200 || empty( $file_contents ) )
 196              { // Impossible to download
 197                  $download_success = false;
 198                  echo '</p><p style="color:red">'.sprintf( T_( 'Unable to download package from &laquo;%s&raquo;' ), $download_url ).'</p>';
 199              }
 200              elseif( ! save_to_file( $file_contents, $upgrade_file, 'w' ) )
 201              { // Impossible to save file...
 202                  $download_success = false;
 203                  echo '</p><p style="color:red">'.sprintf( T_( 'Unable to create file: &laquo;%s&raquo;' ), $upgrade_file ).'</p>';
 204  
 205                  if( file_exists( $upgrade_file ) )
 206                  { // Remove file from disk
 207                      if( ! @unlink( $upgrade_file ) )
 208                      {
 209                          echo '<p style="color:red">'.sprintf( T_( 'Unable to remove file: &laquo;%s&raquo;' ), $upgrade_file ).'</p>';
 210                      }
 211                  }
 212              }
 213              else
 214              { // The package is downloaded successfully
 215                  echo ' OK '.bytesreadable( filesize( $upgrade_file ), false, false ).'.</p>';
 216              }
 217              evo_flush();
 218          }
 219  
 220          if( $action_success && $download_success )
 221          { // Init a button to unzip
 222              $upgrade_buttons = array( 'unzip' => T_( 'Unzip package' ) );
 223          }
 224          elseif( $download_success )
 225          { // Init the buttons to select next action
 226              $upgrade_buttons = array(
 227                      'unzip'          => T_( 'Skip Download' ),
 228                      'force_download' => T_( 'Force New Download' ),
 229                  );
 230          }
 231          else
 232          { // Init a button to back step
 233              $upgrade_buttons = array( 'start' => T_( 'Back to select package' ) );
 234          }
 235  
 236          // Pause a process before next step
 237          $AdminUI->disp_view( 'maintenance/views/_upgrade_continue.form.php' );
 238          unset( $block_item_Widget );
 239          break;
 240  
 241      case 'unzip':
 242      case 'force_unzip':
 243          // STEP 3: UNZIP.
 244  
 245          if( $demo_mode )
 246          {
 247              echo('This feature is disabled on the demo server.');
 248              break;
 249          }
 250  
 251          $action_success = true;
 252          $unzip_success = true;
 253  
 254          autoupgrade_display_steps( 3 );
 255  
 256          $block_item_Widget = new Widget( 'block_item' );
 257          $block_item_Widget->title = T_('Unzipping package...');
 258          $block_item_Widget->disp_template_replaced( 'block_start' );
 259          evo_flush();
 260  
 261          $download_url = param( 'upd_url', 'string', '', true );
 262  
 263          $upgrade_name = pathinfo( $download_url );
 264          $upgrade_name = $upgrade_name['filename'];
 265          $upgrade_dir = $upgrade_path.$upgrade_name;
 266          $upgrade_file = $upgrade_dir.'.zip';
 267  
 268          if( file_exists( $upgrade_dir ) )
 269          { // The downloading file already exists
 270              if( $action == 'force_unzip' )
 271              { // Try to delete previous package if the downloading is forced
 272                  if( ! rmdir_r( $upgrade_dir ) )
 273                  {
 274                      echo '<p class="red">'.sprintf( T_('Unable to delete previous unzipped package %s before forcing the unzip.'), '<b>'.$upgrade_dir.'</b>' ).'</p>';
 275                      $action_success = false;
 276                  }
 277              }
 278              else
 279              {
 280                  echo '<div class="action_messages"><div class="log_error" style="text-align:center;font-weight:bold">'
 281                      .sprintf( T_( 'The package %s is already unzipped.' ), $upgrade_name.'.zip' ).'</div></div>';
 282                  $action_success = false;
 283              }
 284              evo_flush();
 285          }
 286  
 287          if( $action_success )
 288          {
 289              // Set maximum execution time
 290              set_max_execution_time( 1800 ); // 30 minutes
 291  
 292              echo '<p>'.sprintf( T_( 'Unpacking package to &laquo;<strong>%s</strong>&raquo;...' ), $upgrade_dir );
 293              evo_flush();
 294  
 295              // Unpack package
 296              if( $unzip_success = unpack_archive( $upgrade_file, $upgrade_dir, true ) )
 297              {
 298                  echo ' OK.</p>';
 299                  evo_flush();
 300              }
 301              else
 302              {
 303                  echo '</p>';
 304                  // Additional check
 305                  @rmdir_r( $upgrade_dir );
 306              }
 307          }
 308  
 309          if( $action_success && $unzip_success )
 310          { // Init a button to next step
 311              $upgrade_buttons = array( 'ready' => T_( 'Continue' ) );
 312          }
 313          elseif( $unzip_success )
 314          { // Init the buttons to select next action
 315              $upgrade_buttons = array( 'ready' => T_( 'Skip Unzip' ) );
 316              if( file_exists( $upgrade_file ) )
 317              {
 318                  $upgrade_buttons['force_unzip'] = T_( 'Force New Unzip' );
 319              }
 320          }
 321          else
 322          { // Init a button to back step
 323              $upgrade_buttons = array( 'download' => T_( 'Back to download package' ) );
 324          }
 325  
 326          // Pause a process before next step
 327          $AdminUI->disp_view( 'maintenance/views/_upgrade_continue.form.php' );
 328          unset( $block_item_Widget );
 329          break;
 330  
 331      case 'ready':
 332          // STEP 4: READY TO UPGRADE.
 333      case 'ready_svn':
 334          // SVN STEP 3: READY TO UPGRADE.
 335  
 336          if( $action == 'ready_svn' )
 337          { // SVN upgrade
 338              svnupgrade_display_steps( 3 );
 339  
 340              $upgrade_name = param( 'upd_name', 'string', NULL, true );
 341          }
 342          else
 343          { // Auto upgrade
 344              autoupgrade_display_steps( 4 );
 345  
 346              $download_url = param( 'upd_url', 'string', '', true );
 347  
 348              $upgrade_name = pathinfo( $download_url );
 349              $upgrade_name = $upgrade_name['filename'];
 350              $upgrade_dir = $upgrade_path.$upgrade_name;
 351              $upgrade_file = $upgrade_dir.'.zip';
 352          }
 353  
 354          $block_item_Widget = new Widget( 'block_item' );
 355          $block_item_Widget->title = T_('Ready to upgrade...');
 356          $block_item_Widget->disp_template_replaced( 'block_start' );
 357          evo_flush();
 358  
 359          $new_version_status = check_version( $upgrade_name );
 360          $action_backup_value = ( $action == 'ready_svn' ) ? 'backup_and_overwrite_svn' : 'backup_and_overwrite';
 361          if( empty( $new_version_status ) )
 362          { // New version
 363              echo '<p><b>'.T_( 'The new files are ready to be installed.' ).'</b></p>';
 364              $upgrade_buttons = array( $action_backup_value => T_( 'Backup & Upgrade' ) );
 365          }
 366          else
 367          { // Old/Same version
 368              echo '<div class="action_messages"><div class="log_error" style="text-align:center;font-weight:bold">'.$new_version_status.'</div></div>';
 369              $upgrade_buttons = array( $action_backup_value => T_( 'Force Backup & Upgrade' ) );
 370          }
 371  
 372          echo '<p>'
 373              .T_( 'If you continue, the following sequence will be carried out automatically (trying to minimize "maintenance time" for the site):' )
 374              .'<ul><li>'.T_( 'The site will switch to maintenance mode' ).'</li>'
 375                  .'<li>'.T_( 'A backup will be performed' ).'</li>'
 376                  .'<li>'.T_( 'The upgrade will be applied' ).'</li>'
 377                  .'<li>'.T_( 'The install script of the new version will be called' ).'</li>'
 378                  .'<li>'.sprintf( T_( 'The cleanup rules from %s will be applied' ), '<b>upgrade_policy.conf</b>' ).'</li>'
 379                  .'<li>'.T_( 'The site will switch to normal mode again at the end of the install script.' ).'</li>'
 380              .'</ul></p>';
 381  
 382          // Pause a process before next step
 383          $AdminUI->disp_view( 'maintenance/views/_upgrade_continue.form.php' );
 384          unset( $block_item_Widget );
 385          break;
 386  
 387      case 'backup_and_overwrite':
 388          // STEP 5: BACKUP & UPGRADE.
 389      case 'backup_and_overwrite_svn':
 390          // SVN STEP 2: BACKUP AND OVERWRITE.
 391  
 392          if( $demo_mode )
 393          {
 394              echo('This feature is disabled on the demo server.');
 395              break;
 396          }
 397  
 398          if( !isset( $block_item_Widget ) )
 399          {
 400              if( $action == 'backup_and_overwrite_svn' )
 401              { // SVN upgrade
 402                  svnupgrade_display_steps( 4 );
 403              }
 404              else
 405              { // Auto upgrade
 406                  autoupgrade_display_steps( 5 );
 407              }
 408  
 409              $block_item_Widget = new Widget( 'block_item' );
 410              $block_item_Widget->title = $action == 'backup_and_overwrite_svn'
 411                  ? T_('Installing package from SVN...')
 412                  : T_('Installing package...');
 413              $block_item_Widget->disp_template_replaced( 'block_start' );
 414  
 415              $upgrade_name = param( 'upd_name', 'string', NULL, true );
 416              if( $upgrade_name === NULL )
 417              { // Get an upgrade name from url (Used for auto-upgrade, not svn)
 418                  $download_url = param( 'upd_url', 'string', '', true );
 419                  $upgrade_name = pathinfo( $download_url );
 420                  $upgrade_name = $upgrade_name['filename'];
 421              }
 422  
 423              $success = true;
 424          }
 425  
 426          // Enable maintenance mode
 427          $success = ( $success && switch_maintenance_mode( true, 'upgrade', T_( 'System upgrade is in progress. Please reload this page in a few minutes.' ) ) );
 428  
 429          if( $success )
 430          {
 431              // Set maximum execution time
 432              set_max_execution_time( 1800 ); // 30 minutes
 433  
 434              // Verify that all destination files can be overwritten
 435              echo '<h4>'.T_( 'Verifying that all destination files can be overwritten...' ).'</h4>';
 436              evo_flush();
 437  
 438              $read_only_list = array();
 439  
 440              // Get a folder path where we should get the files
 441              $upgrade_folder_path = get_upgrade_folder_path( $upgrade_name );
 442  
 443              $success = verify_overwrite( $upgrade_folder_path, no_trailing_slash( $basepath ), 'Verifying', false, $read_only_list );
 444  
 445              if( $success && empty( $read_only_list ) )
 446              { // We can backup files and database
 447  
 448                  // Load Backup class (PHP4) and backup all of the folders and files
 449                  load_class( 'maintenance/model/_backup.class.php', 'Backup' );
 450                  $Backup = new Backup();
 451                  $Backup->load_from_Request();
 452  
 453                  if( ! function_exists( 'gzopen' ) )
 454                  {
 455                      $Backup->pack_backup_files = false;
 456                  }
 457  
 458                  // Start backup
 459                  if( $success = $Backup->start_backup() )
 460                  { // We can upgrade files and database
 461  
 462                      // Copying new folders and files
 463                      echo '<h4>'.T_( 'Copying new folders and files...' ).'</h4>';
 464                      evo_flush();
 465  
 466                      $success = verify_overwrite( $upgrade_folder_path, no_trailing_slash( $basepath ), 'Copying', true, $read_only_list );
 467                      if( ( ! $success ) || ( ! empty( $read_only_list ) ) )
 468                      { // In case if something was changed before the previous verify_overwrite check
 469                          echo '<p style="color:red"><strong>'.T_( 'The files and database backup was created successfully but all folders and files could not be overwritten' );
 470                          if( empty( $read_only_list ) )
 471                          { // There was some error in the verify_overwrite() function, but the corresponding error message was already displayed.
 472                              echo '.</strong></p>';
 473                          }
 474                          else
 475                          { // Some file/folder could not be overwritten, display it
 476                              echo ':</strong></p>';
 477                              foreach( $read_only_list as $read_only_file )
 478                              {
 479                                  echo $read_only_file.'<br/>';
 480                              }
 481                          }
 482                          echo '<p style="color:red"><strong>'.sprintf( T_('Please restore the backup files from the &laquo;%s&raquo; package. The database was not changed.'), $backup_path ).'</strong></p>';
 483                          evo_flush();
 484                      }
 485                  }
 486              }
 487              else
 488              {
 489                  echo '<p style="color:red">'.T_( '<strong>The following folders and files can\'t be overwritten:</strong>' ).'</p>';
 490                  evo_flush();
 491                  foreach( $read_only_list as $read_only_file )
 492                  {
 493                      echo $read_only_file.'<br/>';
 494                  }
 495                  $success = false;
 496              }
 497          }
 498  
 499          if( $success )
 500          { // Pause a process before upgrading, and display a link to the normal upgrade action
 501              $block_item_Widget->disp_template_replaced( 'block_end' );
 502              $Form = new Form();
 503              $Form->begin_form( 'fform' );
 504              $Form->begin_fieldset( T_( 'Actions' ) );
 505              echo '<p><b>'.T_('All new b2evolution files are in place. You will now be redirected to the installer to perform a DB upgrade.').'</b> '.T_('Note: the User Interface will look different.').'</p>';
 506              $continue_onclick = 'location.href="'.$baseurl.'install/index.php?action='.( ( $action == 'backup_and_overwrite_svn' ) ? 'svn_upgrade' : 'auto_upgrade' ).'&locale='.$current_locale.'"';
 507              $Form->end_form( array( array( 'button', 'continue', T_('Continue to installer'), '', $continue_onclick ) ) );
 508              unset( $block_item_Widget );
 509          }
 510          else
 511          { // Disable maintenance mode
 512              switch_maintenance_mode( false, 'upgrade' );
 513              echo '<h4 style="color:red">'.T_( 'Upgrade failed!' ).'</h4>';
 514          }
 515          break;
 516  
 517      /****** UPGRADE FROM SVN *****/
 518      case 'export_svn':
 519      case 'force_export_svn':
 520          // SVN STEP 2: EXPORT.
 521  
 522          if( $demo_mode )
 523          {
 524              echo('This feature is disabled on the demo server.');
 525              break;
 526          }
 527  
 528          svnupgrade_display_steps( 2 );
 529  
 530          $block_item_Widget = new Widget( 'block_item' );
 531          $block_item_Widget->title = T_('Exporting package from SVN...');
 532          $block_item_Widget->disp_template_replaced( 'block_start' );
 533  
 534          $svn_url = param( 'svn_url', 'string', '', true );
 535          $svn_folder = param( 'svn_folder', 'string', '/', true );
 536          $svn_user = param( 'svn_user', 'string', false, true );
 537          $svn_password = param( 'svn_password', 'string', false, true );
 538          $svn_revision = param( 'svn_revision', 'integer', 0, true );
 539  
 540          $UserSettings->set( 'svn_upgrade_url', $svn_url );
 541          $UserSettings->set( 'svn_upgrade_folder', $svn_folder );
 542          $UserSettings->set( 'svn_upgrade_user', $svn_user );
 543          $UserSettings->set( 'svn_upgrade_revision', $svn_revision );
 544          $UserSettings->dbupdate();
 545  
 546          $success = param_check_not_empty( 'svn_url', T_('Please enter the URL of repository') );
 547          //$success = $success && param_check_regexp( 'svn_folder', '#/blogs/$#', T_('A correct SVN folder path must ends with "/blogs/"') );
 548  
 549          if( ! $success )
 550          {
 551              $action = 'start';
 552              break;
 553          }
 554  
 555          $success = prepare_maintenance_dir( $upgrade_path, true );
 556  
 557          if( $success )
 558          {
 559              // Set maximum execution time
 560              set_max_execution_time( 2400 ); // 60 minutes
 561  
 562              load_class('_ext/phpsvnclient/phpsvnclient.php', 'phpsvnclient' );
 563  
 564              $phpsvnclient = new phpsvnclient( $svn_url, $svn_user, $svn_password );
 565  
 566              // Get an error if it was during connecting to svn server
 567              $svn_error = $phpsvnclient->getError();
 568  
 569              if( ! empty( $svn_error ) || $phpsvnclient->getVersion() < 1 )
 570              { // Some errors or Incorrect version
 571                  echo '<p class="red">'.T_( 'Unable to get a repository version, probably URL of repository is incorrect.' ).'</p>';
 572                  evo_flush();
 573                  $action = 'start';
 574                  break; // Stop an upgrade from SVN
 575              }
 576  
 577              if( $svn_revision > 0 )
 578              { // Set revision from request
 579                  if( $phpsvnclient->getVersion() < $svn_revision )
 580                  { // Incorrect revision number
 581                      echo '<p class="red">'.sprintf( T_( 'Please select a correct revision number. The latest revision is %s.' ), $phpsvnclient->getVersion() ).'</p>';
 582                      evo_flush();
 583                      $action = 'start';
 584                      break; // Stop an upgrade from SVN
 585                  }
 586                  else
 587                  { // Use only correct revision
 588                      $phpsvnclient->setVersion( $svn_revision );
 589                  }
 590              }
 591  
 592              $repository_version = $phpsvnclient->getVersion();
 593  
 594              $upgrade_name = 'export_svn_'.$repository_version;
 595              memorize_param( 'upd_name', 'string', '', $upgrade_name );
 596              $upgrade_folder = $upgrade_path.$upgrade_name;
 597  
 598              if( $action == 'force_export_svn' && file_exists( $upgrade_folder ) )
 599              { // The exported folder already exists
 600                  // Try to delete previous package
 601                  if( ! rmdir_r( $upgrade_folder ) )
 602                  {
 603                      echo '<p class="red">'.sprintf( T_('Unable to delete previous exported package %s before forcing the export.'), '<b>'.$upgrade_folder.'</b>' ).'</p>';
 604                  }
 605                  evo_flush();
 606              }
 607  
 608              if( file_exists( $upgrade_folder ) )
 609              { // Current version already is downloaded
 610                  echo '<p class="green">'.sprintf( T_('Revision %s has already been downloaded. Using: %s'), $repository_version, $upgrade_folder );
 611                  $revision_is_exported = true;
 612              }
 613              else
 614              { // Download files
 615                  echo '<p>'.sprintf( T_( 'Downloading package to &laquo;<strong>%s</strong>&raquo;...' ), $upgrade_folder );
 616                  evo_flush();
 617  
 618                  // Export all files in temp folder for following coping
 619                  $svn_result = $phpsvnclient->checkOut( $svn_folder, $upgrade_folder, false, true );
 620  
 621                  echo '</p>';
 622  
 623                  if( $svn_result === false )
 624                  { // Checkout is failed
 625                      echo '<p style="color:red">'.sprintf( T_( 'Unable to download package from &laquo;%s&raquo;' ), $svn_url ).'</p>';
 626                      evo_flush();
 627                      $action = 'start';
 628                      break;
 629                  }
 630              }
 631          }
 632  
 633          if( $success )
 634          { // Pause a process before upgrading
 635              if( empty( $revision_is_exported ) )
 636              { // Init the buttons to continue
 637                  $upgrade_buttons = array( 'ready_svn' => T_( 'Continue' ) );
 638              }
 639              else
 640              { // Init the buttons to select next action
 641                  $upgrade_buttons = array(
 642                          'ready_svn'        => T_( 'Skip Export' ),
 643                          'force_export_svn' => T_( 'Force New Export' ),
 644                      );
 645              }
 646              $AdminUI->disp_view( 'maintenance/views/_upgrade_continue.form.php' );
 647              unset( $block_item_Widget );
 648          }
 649          break;
 650  }
 651  
 652  if( isset( $block_item_Widget ) )
 653  {
 654      $block_item_Widget->disp_template_replaced( 'block_end' );
 655  }
 656  
 657  switch( $tab )
 658  {
 659      case 'svn':
 660          $AdminUI->disp_view( 'maintenance/views/_upgrade_svn.form.php' );
 661          break;
 662  
 663      default:
 664          $AdminUI->disp_view( 'maintenance/views/_upgrade.form.php' );
 665          break;
 666  }
 667  
 668  $AdminUI->disp_payload_end();
 669  
 670  // Display body bottom, debug info and close </html>:
 671  $AdminUI->disp_global_footer();
 672  
 673  ?>

title

Description

title

Description

title

Description

title

title

Body