b2evolution PHP Cross Reference Blogging Systems

Source: /inc/maintenance/backup.ctrl.php - 127 lines - 3657 bytes - Text - Print

Description: Backup - 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   * Backup - 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: backup.ctrl.php 6136 2014-03-08 07:59:48Z manuel $
  26   */
  27  
  28  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  29  
  30  /**
  31   * @var instance of User class
  32   */
  33  global $current_User;
  34  
  35  // Check minimum permission:
  36  $current_User->check_perm( 'perm_maintenance', 'backup', true );
  37  
  38  // Load Backup class (PHP4):
  39  load_class( 'maintenance/model/_backup.class.php', 'Backup' );
  40  
  41  // Set options path:
  42  $AdminUI->set_path( 'options', 'misc', 'backup' );
  43  
  44  // Get action parameter from request:
  45  param_action( 'start' );
  46  
  47  // Create instance of Backup class
  48  $current_Backup = new Backup();
  49  
  50  // Load backup settings from request
  51  if( $action == 'backup' && !$current_Backup->load_from_Request() )
  52  {
  53      $action = 'new';
  54  }
  55  
  56  
  57  $AdminUI->breadcrumbpath_init( false );  // fp> I'm playing with the idea of keeping the current blog in the path here...
  58  $AdminUI->breadcrumbpath_add( T_('System'), '?ctrl=system' );
  59  $AdminUI->breadcrumbpath_add( T_('Maintenance'), '?ctrl=tools' );
  60  $AdminUI->breadcrumbpath_add( T_('Backup'), '?ctrl=backup' );
  61  
  62  
  63  // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
  64  $AdminUI->disp_html_head();
  65  
  66  // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
  67  $AdminUI->disp_body_top();
  68  
  69  $AdminUI->disp_payload_begin();
  70  
  71  /**
  72   * Display payload:
  73   */
  74  switch( $action )
  75  {
  76      case 'start':
  77          // Display backup settings form
  78          $AdminUI->disp_view( 'maintenance/views/_backup.form.php' );
  79          break;
  80  
  81      case 'backup':
  82          if( $demo_mode )
  83          {
  84              echo('This feature is disabled on the demo server.');
  85              break;
  86          }
  87  
  88          // Check that this action request is not a CSRF hacked request:
  89          $Session->assert_received_crumb( 'backup' );
  90  
  91          $Form = new Form( NULL, 'backup_progress', 'post' );
  92  
  93          // Interactive / flush() backup should start here
  94          $Form->begin_form( 'fform', T_('System backup is in progress...') );
  95  
  96          evo_flush();
  97  
  98          $success = true;
  99          if( $maintenance_mode = param( 'bk_maintenance_mode', 'boolean' ) )
 100          {    // Enable maintenance mode
 101              $success = switch_maintenance_mode( true, 'all', T_( 'System backup is in progress. Please reload this page in a few minutes.' ) );
 102  
 103              // Make sure we exit the maintenance mode if PHP dies
 104              register_shutdown_function( 'switch_maintenance_mode', false, '', true );
 105          }
 106  
 107          if( $success )
 108          {    // We can start backup
 109              set_max_execution_time( 1800 ); // 30 minutes
 110              $current_Backup->start_backup();
 111          }
 112  
 113          if( $maintenance_mode )
 114          {    // Disable maintenance mode
 115              switch_maintenance_mode( false, 'all' );
 116          }
 117  
 118          $Form->end_form();
 119          break;
 120  }
 121  
 122  $AdminUI->disp_payload_end();
 123  
 124  // Display body bottom, debug info and close </html>:
 125  $AdminUI->disp_global_footer();
 126  
 127  ?>

title

Description

title

Description

title

Description

title

title

Body