Ejemplo n.º 1
0
        /**
         *
         */
        public static function render_destination_edit_panel()
        {
            ?>
			<div id="snapshot-metaboxes-destination_add" class="wrap snapshot-wrap">
					<?php 
            $item = 0;
            if (isset($_REQUEST['snapshot-action'])) {
                if (sanitize_text_field($_REQUEST['snapshot-action']) == "edit") {
                    ?>
					<h2><?php 
                    _ex("Edit Snapshot Destination", "Snapshot Plugin Page Title", SNAPSHOT_I18N_DOMAIN);
                    ?>
</h2>
					<p><?php 
                    _ex("", 'Snapshot page description', SNAPSHOT_I18N_DOMAIN);
                    ?>
</p>
					<?php 
                    if (isset($_REQUEST['item'])) {
                        $item_key = sanitize_text_field($_REQUEST['item']);
                        if (isset(WPMUDEVSnapshot::instance()->config_data['destinations'][$item_key])) {
                            $item = WPMUDEVSnapshot::instance()->config_data['destinations'][$item_key];
                        }
                    }
                } else {
                    if (sanitize_text_field($_REQUEST['snapshot-action']) == "add") {
                        ?>
					<h2><?php 
                        _ex("Add Snapshot Destination", "Snapshot Plugin Page Title", SNAPSHOT_I18N_DOMAIN);
                        ?>
</h2>
					<p><?php 
                        _ex("", 'Snapshot page description', SNAPSHOT_I18N_DOMAIN);
                        ?>
</p>
					<?php 
                        unset($item);
                        $item = array();
                        if (isset($_REQUEST['type'])) {
                            $item['type'] = sanitize_text_field($_REQUEST['type']);
                        }
                    } else {
                        if (sanitize_text_field($_REQUEST['snapshot-action']) == "update") {
                            ?>
					<h2><?php 
                            _ex("Edit Snapshot Destination", "Snapshot Plugin Page Title", SNAPSHOT_I18N_DOMAIN);
                            ?>
</h2>
					<p><?php 
                            _ex("", 'Snapshot page description', SNAPSHOT_I18N_DOMAIN);
                            ?>
</p>
					<?php 
                            if (isset($_POST['snapshot-destination'])) {
                                $item = $_POST['snapshot-destination'];
                            }
                        }
                    }
                }
            }
            if ($item) {
                Snapshot_Helper_UI::form_ajax_panels();
                ?>
						<form action="<?php 
                echo WPMUDEVSnapshot::instance()->get_setting('SNAPSHOT_MENU_URL');
                ?>
snapshots_destinations_panel&amp;snapshot-action=<?php 
                echo urlencode(sanitize_text_field($_GET['snapshot-action']));
                ?>
&amp;type=<?php 
                echo urlencode($item['type']);
                ?>
" method="post">
							<?php 
                if (sanitize_text_field($_GET['snapshot-action']) == "edit" || sanitize_text_field($_GET['snapshot-action']) == "update") {
                    ?>
					<input type="hidden" name="snapshot-action" value="update"/>
					<input type="hidden" name="item" value="<?php 
                    echo sanitize_text_field($_GET['item']);
                    ?>
"/>
					<?php 
                    wp_nonce_field('snapshot-update-destination', 'snapshot-noonce-field');
                    ?>
				<?php 
                } else {
                    if (sanitize_text_field($_GET['snapshot-action']) == "add") {
                        ?>
					<input type="hidden" name="snapshot-action" value="add"/>
					<?php 
                        wp_nonce_field('snapshot-add-destination', 'snapshot-noonce-field');
                        ?>
				<?php 
                    }
                }
                $item_object = Snapshot_Model_Destination::get_object_from_type($item['type']);
                if ($item_object && is_object($item_object)) {
                    $item_object->display_details_form($item);
                }
                ?>
								<input class="button-primary" type="submit" value="<?php 
                _e('Save Destination', SNAPSHOT_I18N_DOMAIN);
                ?>
" />
								<a class="button-secondary" href="<?php 
                echo WPMUDEVSnapshot::instance()->get_setting('SNAPSHOT_MENU_URL');
                ?>
snapshots_destinations_panel"><?php 
                _e('Cancel', SNAPSHOT_I18N_DOMAIN);
                ?>
</a>

							</div>
						</form>
						<?php 
            }
            ?>
			</div>
			<?php 
        }
Ejemplo n.º 2
0
        function extra_tablenav($which)
        {
            if ($which == "top") {
                $HAS_FILTERS = false;
                $filters = $this->check_table_filters();
                ?>
				<div class="alignleft actions"><?php 
                /*
                				if (is_multisite()) {
                					$blog_counts = array();
                					if ((isset(WPMUDEVSnapshot::instance()->config_data['items'])) && (count(WPMUDEVSnapshot::instance()->config_data['items']))) {
                
                						foreach(WPMUDEVSnapshot::instance()->config_data['items'] as $idx => $item) {
                
                							if (!isset($blog_counts[$item['blog-id']]))
                								$blog_counts[$item['blog-id']] = 1;
                							else
                								$blog_counts[$item['blog-id']] += 1;
                						}
                					}
                
                					// We need to display a column showing the blog for a snapshot.
                					// Simply gets all blogs then builds a local array using the blog_id as the key to the blog url.
                					$blogs = Snapshot_Helper_Utility::get_blogs();
                					if ($blogs) {
                						$tmp_blogs = array();
                						foreach($blogs as $blog) {
                							// Does this blog_id exist in our count array?
                							if (isset($blog_counts[$blog->blog_id]))
                								$tmp_blogs[$blog->blog_id] = $blog->blogname ."<br /> (". $blog->domain .") (". $blog_counts[$blog->blog_id] .")";
                						}
                						$blogs = $tmp_blogs;
                					}
                
                					if (($blogs) && (count($blogs))) {
                						$HAS_FILTERS = true;
                
                						?>
                						<select
                							name="snapshot-filter-blog-id" id="snapshot-filter-blog-id">
                							<option value="">Show All Blogs</option>
                							<?php
                								foreach($blogs as $blog_id => $blog_domain) {
                									?><option <?php if ($blog_id == $filters['blog-id']) { echo ' selected="selected" '; } ?>
                										value="<?php echo $blog_id ?>"><?php echo $blog_domain; ?></option><?php
                								}
                							?>
                						</select>
                						<?php
                					}
                				}
                */
                if (isset(WPMUDEVSnapshot::instance()->config_data['destinations']) && count(WPMUDEVSnapshot::instance()->config_data['destinations'])) {
                    $HAS_FILTERS = true;
                    ?>
					<select
						name="snapshot-filter-destination" id="snapshot-filter-destination">
						<option value=""><?php 
                    _e('Show All Destinations', SNAPSHOT_I18N_DOMAIN);
                    ?>
</option>

						<?php 
                    Snapshot_Helper_UI::destination_select_options_groups(WPMUDEVSnapshot::instance()->config_data['destinations'], $filters['destination'], WPMUDEVSnapshot::instance()->get_setting('destinationClasses'));
                    ?>
					</select>
				<?php 
                }
                if ($HAS_FILTERS) {
                    ?>
<input id="post-query-submit" class="button-secondary" type="submit" value="Filter"
					         name="snapshot-filter"><?php 
                }
                ?>
</div><?php 
            }
        }
Ejemplo n.º 3
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 
            }
        }
Ejemplo n.º 4
0
        /**
         * Metabox to show the backup destination options
         *
         * @since 1.0.2
         *
         * @param string $title - Title to be displayed in header of metabox
         * @param array $item - The current viewed item
         *
         * @return none
         */
        function snapshot_metabox_show_destination_options($title, $item, $display_only = false)
        {
            if (!isset($item['destination'])) {
                $item['destination'] = "local";
            }
            ?>
			<div class="postbox">
				<h3 class="hndle"><span><?php 
            echo $title;
            ?>
</span></h3>

				<div class="inside">
					<table class="form-table snapshot-backup-destinations">
						<tr class="form-field">
							<th scope="row">
								<label
									for="snapshot-destination"><?php 
            _e('Backup Destination', SNAPSHOT_I18N_DOMAIN);
            ?>
</label><br/>
								<a href="admin.php?page=snapshots_destinations_panel"><?php 
            _e('Add more Destinations', SNAPSHOT_I18N_DOMAIN);
            ?>
</a>
							</th>
							<td>
								<select name="snapshot-destination" id="snapshot-destination">
									<?php 
            // This global is set within the next calling function. Helps determine which set of descriptions to show.
            global $snapshot_destination_selected_type;
            Snapshot_Helper_UI::destination_select_options_groups(WPMUDEVSnapshot::instance()->config_data['destinations'], $item['destination'], WPMUDEVSnapshot::instance()->get_setting('destinationClasses'));
            ?>
								</select><br/>

								<p class="description"><?php 
            _e("If you select a remote destination and the 'Interval' is set as Immediate, the snapshot backup file will not be sent during the normal backup step. Instead the transfer of the backup file will be scheduled at a later time. This is to prevent the screen from locking while the backup file is sent to the remote destination.", SNAPSHOT_I18N_DOMAIN);
            ?>
</p>

							</td>
						</tr>
						<tr class="form-field">
							<th scope="row">
								<label
									for="snapshot-destination-directory"><?php 
            _e('Directory (optional)', SNAPSHOT_I18N_DOMAIN);
            ?>
</label>
							</th>
							<td>
								<input type="text" name="snapshot-destination-directory"
								       id="snapshot-destination-directory"
								       value="<?php 
            if (isset($item['destination-directory'])) {
                echo stripslashes($item['destination-directory']);
            }
            ?>
"/>


								<?php 
            //echo "snapshot_destination_selected_type[". $snapshot_destination_selected_type ."]<br />";
            ?>
								<div id="snapshot-destination-directory-description" <?php 
            if ($snapshot_destination_selected_type == 'google-drive') {
                echo ' style="display:none" ';
            }
            ?>
>

									<p class="description"><?php 
            _e("The optional Directory can be used to override or supplement the selected destination directory value. If 'local server' is selected and if the directory does not start with a forward slash '/' the directory will be relative to the site root.", SNAPSHOT_I18N_DOMAIN);
            ?>
</p>

									<p class="description"><?php 
            _e("This field support tokens you can use to create dynamic values. You can use any combination of the following tokens. Use the forward slash '/' to separate directory elements.", SNAPSHOT_I18N_DOMAIN);
            ?>
</p>
									<ul class="description">
										<li>
											<strong>[DEST_PATH]</strong> &ndash; <?php 
            _e("This represents the Directory/Bucket used by the selected Backup Destination or if local, the Settings Folder Location. This can be used to supplement a value entered into this Snapshot. If [DEST_PATH] is not used the Directory value here will override the complete value from the selected Destination.");
            ?>
										</li>
										<li>
											<strong>[SITE_DOMAIN]</strong> &ndash; <?php 
            _e('This represents the full domain of the selected site per this snapshot');
            ?>
											: <?php 
            if (isset($item['blog-id'])) {
                if (is_multisite()) {
                    $blog_info = get_blog_details($item['blog-id']);
                    if ($blog_info->domain) {
                        $domain = $blog_info->domain;
                    }
                } else {
                    $siteurl = get_option('siteurl');
                    if ($siteurl) {
                        $domain = parse_url($siteurl, PHP_URL_HOST);
                    }
                }
                if (isset($domain) && strlen($domain)) {
                    echo "<strong>" . $domain . "</strong>";
                }
            }
            ?>
</li>
										<li>
											<strong>[SNAPSHOT_ID]</strong> &ndash; <?php 
            _e('This is the unique ID assigned to this Snapshot set');
            ?>
											:
											<?php 
            if (isset($item['timestamp'])) {
                echo "<strong>" . $item['timestamp'] . "</strong>";
            }
            ?>
</li>
									</ul>
								</div>
								<div
									id="snapshot-destination-directory-description-google-drive" <?php 
            if ($snapshot_destination_selected_type != 'google-drive') {
                echo ' style="display:none" ';
            }
            ?>
>
									<p><?php 
            echo sprintf(__('For Google Drive destinations this is not a normal directory path. Instead you must provide the Directory ID. Go to your %s. Navigate to or create a new directory where you want to upload the Snapshot archives. Make sure you are viewing the destination directory. The URL for the directory will be something similar to <em>https://drive.google.com/#folders/0B6GD66ctHXXCOWZKNDRIRGJJXS3</em>. The Directory ID would be the last part after /#folders/ <strong><em>0B6GD66ctHXXCOWZKNDRIRGJJXS3</em></strong>.', SNAPSHOT_I18N_DOMAIN), '<a href="https://drive.google.com/#my-drive">' . __('Drive account', SNAPSHOT_I18N_DOMAIN) . '</a>');
            ?>
</p>
								</div>
							</td>
						</tr>

					</table>
				</div>
				<!-- end inside -->
			</div><!-- end postbox -->
		<?php 
        }