Ejemplo n.º 1
0
        /**
         * Panel showing form to restore previous Snapshot.
         *
         * @since 1.0.2
         * @uses metaboxes setup in $this->admin_menu_proc()
         * @uses $_REQUEST['item']
         * @uses $this->config_data['items']
         *
         * @param none
         *
         * @return none
         */
        function snapshot_admin_show_restore_panel($item)
        {
            //			require( WPMUDEVSnapshot::instance()->get_setting( 'SNAPSHOT_PLUGIN_BASE_DIR' ) . '/lib/snapshot_admin_metaboxes.php' );
            $this->_snapshot_metaboxes = new Snapshot_View_Metabox_Admin();
            if (isset($_GET['snapshot-data-item']) && isset($item['data'][intval($_GET['snapshot-data-item'])])) {
                $data_item_key = intval($_GET['snapshot-data-item']);
                ?>
				<div id="snapshot-settings-metaboxes-general" class="wrap snapshot-wrap">
					<h2><?php 
                _ex("Restore Snapshot", "Snapshot Plugin Page Title", SNAPSHOT_I18N_DOMAIN);
                ?>
</h2>

					<p class="snapshot-restore-description"><?php 
                _ex("On this page you can restore a previous snapshot. Using the 'Restore Options' section below you can also opt to turn off all plugins as well as switch to a different theme as part of the restore.", 'Snapshot page description', SNAPSHOT_I18N_DOMAIN);
                ?>
</p>

					<div id='snapshot-ajax-warning' class='updated fade'>
						<p><?php 
                _e('You are about to restore a previous version of your WordPress database. This will remove any new information added since the snapshot backup.', SNAPSHOT_I18N_DOMAIN);
                ?>
</p>
					</div>

					<?php 
                if (!Snapshot_Helper_Utility::check_server_timeout()) {
                    $current_timeout = ini_get('max_execution_time');
                    ?>
						<div class='error snapshot-error'>
						<p><?php 
                    printf(__('Your web server timeout is set very low, %d seconds. Also, it appears this timeout cannot be adjusted via the Snapshot restore process. Attempting a snapshot restore could result in a partial restore of your tables.', SNAPSHOT_I18N_DOMAIN), $current_timeout);
                    ?>
</p>
						</div><?php 
                }
                ?>
					<?php 
                Snapshot_Helper_UI::form_ajax_panels();
                ?>
					<?php 
                if (isset($_GET['snapshot-data-item'])) {
                    $data_item = $item['data'][$_GET['snapshot-data-item']];
                }
                $backupFolder = WPMUDEVSnapshot::instance()->snapshot_get_item_destination_path($item, $data_item);
                if (empty($backupFolder)) {
                    $backupFolder = WPMUDEVSnapshot::instance()->get_setting('backupBaseFolderFull');
                }
                if (isset($data_item['filename']) && strlen($data_item['filename'])) {
                    $manifest_filename = Snapshot_Helper_Utility::extract_archive_manifest(trailingslashit($backupFolder) . $data_item['filename']);
                    if ($manifest_filename) {
                        //echo "manifest_filename=[". $manifest_filename ."]<br />";
                        $manifest_data = Snapshot_Helper_Utility::consume_archive_manifest($manifest_filename);
                        if ($manifest_data) {
                            //echo "manifest_data<pre>"; print_r($manifest_data); echo "</pre>";
                            $item['MANIFEST'] = $manifest_data;
                        }
                    }
                }
                ?>


					<div id="poststuff" class="metabox-holder">

						<form id="snapshot-edit-restore" action="<?php 
                echo WPMUDEVSnapshot::instance()->get_setting('SNAPSHOT_MENU_URL');
                ?>
snapshots_edit_panel"
						      method="post">
							<input type="hidden" name="snapshot-action" value="restore-request"/>
							<input type="hidden" name="item" value="<?php 
                echo $item['timestamp'];
                ?>
"/>
							<?php 
                wp_nonce_field('snapshot-restore', 'snapshot-noonce-field');
                ?>

							<?php 
                $this->_snapshot_metaboxes->snapshot_metaboxes_show_item_header_information(__('Snapshot Information', SNAPSHOT_I18N_DOMAIN), $item, true);
                ?>

							<?php 
                $this->_snapshot_metaboxes->snapshot_metabox_show_archive_files(__('Selected Archive to Restore', SNAPSHOT_I18N_DOMAIN), $item, true);
                ?>
							<?php 
                //if (is_multisite()) {
                $this->_snapshot_metaboxes->snapshot_metabox_restore_blog_options(__('Restore Blog Options', SNAPSHOT_I18N_DOMAIN), $item);
                //}
                ?>
							<?php 
                $this->_snapshot_metaboxes->snapshot_metabox_show_restore_tables_options(__('What Tables to Restore?', SNAPSHOT_I18N_DOMAIN), $item, $data_item_key);
                ?>
							<?php 
                $this->_snapshot_metaboxes->snapshot_metabox_show_restore_files_options(__('What Files to Restore?', SNAPSHOT_I18N_DOMAIN), $item, $data_item_key);
                ?>
							<?php 
                $this->_snapshot_metaboxes->snapshot_metabox_restore_options(__('Restore Theme Options', SNAPSHOT_I18N_DOMAIN), $item);
                ?>
							<input id="snapshot-form-restore-submit" class="button-primary"
								<?php 
                if (!$data_item_key) {
                    ?>
 disabled="disabled" <?php 
                }
                ?>
								   type="submit" value="<?php 
                _e('Restore Snapshot', SNAPSHOT_I18N_DOMAIN);
                ?>
"/>
							<a class="button-secondary"
							   href="<?php 
                echo WPMUDEVSnapshot::instance()->get_setting('SNAPSHOT_MENU_URL');
                ?>
									snapshots_edit_panel"><?php 
                _e('Cancel', SNAPSHOT_I18N_DOMAIN);
                ?>
</a>
						</form>
					</div>
				</div>
			<?php 
            } else {
                ?>
				<div id="snapshot-settings-metaboxes-general" class="wrap snapshot-wrap">
					<h2><?php 
                _ex("Restore Snapshot", "Snapshot Plugin Page Title", SNAPSHOT_I18N_DOMAIN);
                ?>
</h2>

					<p class="snapshot-restore-description"><?php 
                _ex("ERROR: Missing argument. Please return to the main Snapshot panel and select the archive to restore. ", 'Snapshot page description', SNAPSHOT_I18N_DOMAIN);
                ?>
						<a href="?page=snapshots_edit_panel">Snapshot</a>.</p>
				</div>
			<?php 
            }
        }