コード例 #1
0
		/**
		 * Metabox to show the backup archived files
		 *
		 * @since 1.0.2
		 *
		 * @param string $title - Title to be displayed in header of metabox
		 * @param array  $item 	- The current viewed item
		 * @param bool  $restore_option - If shown on the restore panel.
		 * @return none
		 */

		function snapshot_metabox_show_archive_files($title, $item, $restore_option=false) {
			global $wpmudev_snapshot;

			//echo "item<pre>"; print_r($item); echo "</pre>";
			?>
			<div class="postbox">
				<h3 class="hndle"><span><?php echo $title; ?></span></h3>
				<div class="inside">
				<?php
					if ($restore_option == true) {
						/* ?><p><?php _e('Select which archive to restore', SNAPSHOT_I18N_DOMAIN); ?></p><?php */
					} else {
						?>
						<p><?php _e('Below is a listing of your archives showing at most the most recent 6 entries. If the archive is local you can click on the filename to download it. You can also view or download the load file the archive.', SNAPSHOT_I18N_DOMAIN); ?> <a href="?page=snapshots_edit_panel&amp;snapshot-action=item-archives&amp;item=<?php echo $item['timestamp'] ?>"><?php
							_e('View all archives', SNAPSHOT_I18N_DOMAIN); ?></a></p>
						<?php
					}

					if ((isset($item['data'])) && (count($item['data']))) {

						$data_items = $item['data'];
						krsort($data_items);
						if (isset($_GET['snapshot-data-item'])) {
							$data_item_key = intval($_GET['snapshot-data-item']);
							if (isset($data_items[$data_item_key])) {
								$data_item = $data_items[$data_item_key];
								$data_items = array();
								$data_items[$data_item_key] = $data_item;
							}
						} else {
							if (count($data_items) > 6) {
								$data_items = array_slice($data_items, 0, 6, true);
							}
						}


						?>
						<table class="widefat">
						<thead>
							<tr class="form-field">
								<?php if ($restore_option == true) { ?><th class="snapshot-col-restore"><?php
									_e('Select', SNAPSHOT_I18N_DOMAIN); ?></th><?php } ?>
								<th class="snapshot-col-date"><?php _e('Date', SNAPSHOT_I18N_DOMAIN); ?></th>
								<th class="snapshot-col-file"><?php _e('File', SNAPSHOT_I18N_DOMAIN); ?></th>
								<th class="snapshot-col-notes"><?php _e('Notes', SNAPSHOT_I18N_DOMAIN); ?></th>
								<th class="snapshot-col-size"><?php _e('Size', SNAPSHOT_I18N_DOMAIN); ?></th>
								<?php
									if ($restore_option != true) {
										if ($wpmudev_snapshot->config_data['config']['absoluteFolder'] != true) {
											?><th class="snapshot-col-logs"><?php _e('Logs', SNAPSHOT_I18N_DOMAIN); ?></th><?php
										}
									}
								?>
							</tr>
						</thead>
						<tbody style="overflow: auto; max-height: 100px;">
						<?php
							$selected_item = "";
							foreach($data_items as $data_key => $data_item) {
								//echo "data_item<pre>"; print_r($data_item); echo "</pre>";

								if (!isset($row_class)) { $row_class = ""; }
								$row_class = ( $row_class == '' ? 'alternate' : '' );

								$backupLogFileFull = trailingslashit($wpmudev_snapshot->snapshot_get_setting('backupLogFolderFull'))
									. $item['timestamp'] ."_". $data_item['timestamp'] .".log";

								?><tr class="form-field <?php echo $row_class; ?>"><?php

									if ($restore_option == true) {
										?><td><input type="radio" name="snapshot-restore-file" class="snapshot-restore-file"
											id="snapshot-restore-<?php echo $data_item['timestamp']; ?>"
											value="<?php echo $data_item['timestamp']; ?>" <?php
											if ((isset($_GET['snapshot-data-item'])) && (intval($_GET['snapshot-data-item']) == $data_item['timestamp'])) {
												echo ' checked="checked" ';
											} ?>/></td><?php
									}

									?><td><?php echo snapshot_utility_show_date_time($data_item['timestamp']); ?></td><?php

									?><td><?php
									if ((empty($data_item['destination'])) || ($data_item['destination'] == "local")) {
										if (isset($data_item['filename'])) {
											$current_backupFolder = $wpmudev_snapshot->snapshot_get_item_destination_path($item, $data_item);
											if (empty($current_backupFolder)) {
												$current_backupFolder = $wpmudev_snapshot->snapshot_get_setting('backupBaseFolderFull');
											}
											$backupFile = trailingslashit(trim($current_backupFolder)) . $data_item['filename'];
											// If we don't find file is the alternate directory then try the default
											if (!file_exists($backupFile)) {
												if ( (isset($data_item['destination-directory'])) || (!empty($data_item['destination-directory'])) ){
													$current_backupFolder = $wpmudev_snapshot->snapshot_get_setting('backupBaseFolderFull');
													$backupFile = trailingslashit(trim($current_backupFolder)) . $data_item['filename'];
												}
											}

											if (file_exists($backupFile)) {

												echo '<a href="?page=snapshots_edit_panel&amp;snapshot-item='. $item['timestamp']
													.'&snapshot-data-item='. $data_item['timestamp']
													.'&snapshot-action=download-archive">'. $data_item['filename'] .'</a>';

											} else {
												echo  $data_item['filename'];
											}
										}
									} else {
										if (isset($data_item['filename'])) {

											$current_backupFolder = $wpmudev_snapshot->snapshot_get_setting('backupBaseFolderFull');
											$backupFile = trailingslashit(trim($current_backupFolder)) . $data_item['filename'];

											if (file_exists($backupFile)) {

												echo '<a href="?page=snapshots_edit_panel&amp;snapshot-item='. $item['timestamp']
													.'&snapshot-data-item='. $data_item['timestamp']
													.'&snapshot-action=download-archive">'. $data_item['filename'] .'</a>';

											} else {
												echo  $data_item['filename'];
											}
										}
									}
									?></td><?php

									?><td><?php

										$tables_sections_out 	= snapshot_utility_get_tables_sections_display($data_item);
										$files_sections_out 	= snapshot_utility_get_files_sections_display($data_item);

										if ((strlen($tables_sections_out['click'])) || (strlen($files_str))) {
											?><p><?php
											echo $tables_sections_out['click'];
											if (strlen($tables_sections_out['click'])) echo "</br />";
											echo $files_sections_out['click'];
											?></p><?php
											echo $tables_sections_out['hidden'];

										}

									?></td><?php

									?><td><?php
										if (isset($data_item['file_size'])) {
											$file_kb = snapshot_utility_size_format($data_item['file_size']);
											echo $file_kb;
										} else {
											echo "&nbsp;";
										}
									?></td><?php

									if ($restore_option != true) {
										?><td><?php
										if (file_exists($backupLogFileFull)) {

											echo '<a class="thickbox"
												href="'. admin_url()
												.'admin-ajax.php?action=snapshot_view_log_ajax&amp;width=800&amp;height=600&amp;snapshot-item='
												. $item['timestamp']
												.'&amp;snapshot-data-item='. $data_item['timestamp'] .'">'. __('view', SNAPSHOT_I18N_DOMAIN) .'</a>';
											echo " ";
											echo '<a href="?page=snapshots_edit_panel&amp;snapshot-action=download-log&amp;snapshot-item=' . $item['timestamp']
												.'&amp;snapshot-data-item='. $data_item['timestamp'] .'">'
												. __('download', SNAPSHOT_I18N_DOMAIN) .'</a>';



										} else {
											echo "&nbsp;";
										}

										?></td><?php
									}
								?></tr><?php
							}

						?></tbody></table><?php

					} else {
						_e('No Archives', SNAPSHOT_I18N_DOMAIN);
					}
				?>
				</div>
			</div>
			<?php
		}
コード例 #2
0
		function snapshot_admin_show_import_panel() {
			global $wpmudev_snapshot;
			require( $wpmudev_snapshot->snapshot_get_setting('SNAPSHOT_PLUGIN_BASE_DIR'). '/lib/snapshot_admin_metaboxes.php' );
			$_snapshot_metaboxes = new wpmudev_snapshot_admin_metaboxes( );

			?>
			<div id="snapshot-settings-metaboxes-general" class="wrap snapshot-wrap">
				<?php screen_icon('snapshot'); ?>
				<h2><?php _ex("Snapshots Scan / Import", "Snapshot Plugin Page Title", SNAPSHOT_I18N_DOMAIN); ?></h2>
				<div id="poststuff" class="metabox-holder">
					<div id="post-body" class="">
						<div id="post-body-content" class="snapshot-metabox-holder-main">
							<p><?php _e('The Snapshot import form below is used to import snapshot archives from outside of this environment into view of the snapshot plugin. If you are attempting to restore an archive from a remote server for example you first need to import the archive here. This will then show the archive in the All Snapshots listing. From that page you can then perform the needed restore.', SNAPSHOT_I18N_DOMAIN); ?></p>
							<form  action="<?php echo $wpmudev_snapshot->snapshot_get_setting('SNAPSHOT_MENU_URL'); ?>snapshots_import_panel" method="post">
								<input type="hidden" value="archives-import" name="snapshot-action">
								<?php wp_nonce_field('snapshot-import', 'snapshot-noonce-field'); ?>

								<?php $_snapshot_metaboxes->snapshot_metaboxes_show_import(
									__('Import Options', SNAPSHOT_I18N_DOMAIN) ); ?>

								<input id="snapshot-add-button" class="button-primary" type="submit"
									value="<?php _e('Scan / Import Snapshots', SNAPSHOT_I18N_DOMAIN); ?>" />
							</form>
						</div>
					</div>
					<?php
						//echo "_POST<pre>"; print_r($_POST); echo "</pre>";
						//echo "_GET<pre>"; print_r($_GET); echo "</pre>";

						if ((isset($_REQUEST['snapshot-action'])) && (esc_attr($_REQUEST['snapshot-action']) == "archives-import")) {
							if ( wp_verify_nonce($_POST['snapshot-noonce-field'],'snapshot-import') ) {

								if ((isset($_POST['snapshot-import-archive-remote-url'])) && (!empty($_POST['snapshot-import-archive-remote-url']))) {
									//echo "remote url[". $_POST['snapshot-import-archive-remote-url'] ."]<br />";
									if (substr($_POST['snapshot-import-archive-remote-url'], 0, 4) == 'http') {

										if (function_exists('curl_version')) {

											$remoteFile = esc_url($_POST['snapshot-import-archive-remote-url']);

											@set_time_limit(900); // 15 minutes Technically, server to server should be quick for large files.

											?><p><?php _e("PHP max_execution_time", SNAPSHOT_I18N_DOMAIN); ?>: <?php echo ini_get('max_execution_time'); ?>s</p><?php

											?><p><?php _e("Attempting to download remote file", SNAPSHOT_I18N_DOMAIN); ?>: <?php echo $remoteFile; ?></p><?php
											flush();

											$restoreFile = trailingslashit($wpmudev_snapshot->snapshot_get_setting('backupBaseFolderFull')) . basename($remoteFile);
											//echo "remoteFile=[". $remoteFile ."]<br />";
											//echo "restoreFile=[". $restoreFile ."]<br />";

											snapshot_utility_remote_url_to_local_file($remoteFile, $restoreFile);
											if (file_exists($restoreFile)) {

												$restoreFolder = trailingslashit($wpmudev_snapshot->snapshot_get_setting('backupRestoreFolderFull')) ."_imports";

												echo "<ol>";
												echo "<li><strong>". __('Processing archive', SNAPSHOT_I18N_DOMAIN). ": ", basename($restoreFile) ."</strong> (".
												 snapshot_utility_size_format(filesize($restoreFile)) .")<ul><li>";
												flush();
												$error_status = snapshot_utility_archives_import_proc($restoreFile, $restoreFolder);
												//echo "error_status<pre>"; print_r($error_status); echo "</pre>";
												if ( (isset($error_status['errorStatus'])) && ($error_status['errorStatus'] === true) ) {
													if ((isset($error_status['errorText'])) && (strlen($error_status['errorText']))) {
														echo  '<span class="snapshot-error">Error: '. $error_status['errorText'] .'</span></br />';
													}
												} else if ((isset($error_status['errorStatus'])) && ($error_status['errorStatus'] === false)) {
													if ((isset($error_status['responseText'])) && (strlen($error_status['responseText']))) {
														echo '<span class="snapshot-success">Success: '. $error_status['responseText'] .'</span></br />';
													} else {

													}
												}
												echo "</li></ul></li>";
												echo "</ol>";
											} else {
												echo '<p>' .__('Error: Your server does not have lib_curl installed. So the import process cannot retrieve remote file.', SNAPSHOT_I18N_DOMAIN) .'</p>';
											}
										} else {
											echo "<p>". __('local import file not found. This could mean either the entered URL was not valid or the file was not publicly accessible.', SNAPSHOT_I18N_DOMAIN) ."</p>";
										}
									} else {
										// Then a local directory

										// Are we dealing with a absolote path...
										if (substr($_POST['snapshot-import-archive-remote-url'], 0, 1) == "/") {
											$dir = trailingslashit(esc_attr($_POST['snapshot-import-archive-remote-url']));
										} else {
											$dir = trailingslashit(trailingslashit($wpmudev_snapshot->snapshot_get_setting('backupBaseFolderFull')) . esc_attr($_POST['snapshot-import-archive-remote-url']));
										}
										//echo "dir[". $dir ."]<br />";
										if (is_dir($dir)) {
											echo "<p>". __('Importing archives from', SNAPSHOT_I18N_DOMAIN). ": ". $dir ."</p>";

											if ($dh = opendir($dir)) {
												$restoreFolder = trailingslashit($wpmudev_snapshot->snapshot_get_setting('backupRestoreFolderFull')) ."_imports";

												echo "<ol>";
												while (($file = readdir($dh)) !== false) {

													if (($file == '.') || ($file == '..') || ($file == 'index.php') || ($file[0] == '.'))
														continue;

													if (pathinfo($file, PATHINFO_EXTENSION) != "zip")
														continue;

													$restoreFile = $dir . $file;
													if (is_dir($restoreFile))
														continue;

													echo "<li><strong>". __('Processing archive', SNAPSHOT_I18N_DOMAIN). ": ", basename($restoreFile) ."</strong> (".
														snapshot_utility_size_format(filesize($restoreFile)) .")<ul><li>";
													flush();
													$error_status = snapshot_utility_archives_import_proc($restoreFile, $restoreFolder);
													//echo "error_status<pre>"; print_r($error_status); echo "</pre>";
													if ( (isset($error_status['errorStatus'])) && ($error_status['errorStatus'] === true) ) {
														if ((isset($error_status['errorText'])) && (strlen($error_status['errorText']))) {
															echo  '<span class="snapshot-error">Error: '. $error_status['errorText'] .'</span></br />';
														}
													} else if ((isset($error_status['errorStatus'])) && ($error_status['errorStatus'] === false)) {
														if ((isset($error_status['responseText'])) && (strlen($error_status['responseText']))) {
															echo '<span class="snapshot-success">Success: '. $error_status['responseText'] .'</span></br />';
														} else {

														}
													}
													echo "</li></ul></li>";
												}
												echo "</ol>";

												closedir($dh);

											}
										} else {
											echo "<p>". sprintf(__('local import file not found %s. This could mean either the entered path was not valid or accessible.', SNAPSHOT_I18N_DOMAIN), $dir) ."</p>";

										}
									}

								} else {

									$dir = trailingslashit($wpmudev_snapshot->snapshot_get_setting('backupBaseFolderFull'));
									echo "<p>". __('Importing archives from', SNAPSHOT_I18N_DOMAIN). ": ". $dir ."</p>";

									if ($dh = opendir($dir)) {
										$restoreFolder = trailingslashit($wpmudev_snapshot->snapshot_get_setting('backupRestoreFolderFull')) ."_imports";

										echo "<ol>";
										while (($file = readdir($dh)) !== false) {

											if (($file == '.') || ($file == '..') || ($file == 'index.php') || ($file[0] == '.'))
												continue;

											if (pathinfo($file, PATHINFO_EXTENSION) != "zip")
												continue;

											$restoreFile = $dir . $file;
											if (is_dir($restoreFile))
												continue;

											echo "<li><strong>". __('Processing archive', SNAPSHOT_I18N_DOMAIN). ": ", basename($restoreFile) ."</strong> (".
												snapshot_utility_size_format(filesize($restoreFile)) .")<ul><li>";
											flush();
											$error_status = snapshot_utility_archives_import_proc($restoreFile, $restoreFolder);
											//echo "error_status<pre>"; print_r($error_status); echo "</pre>";
											if ( (isset($error_status['errorStatus'])) && ($error_status['errorStatus'] === true) ) {
												if ((isset($error_status['errorText'])) && (strlen($error_status['errorText']))) {
													echo  '<span class="snapshot-error">Error: '. $error_status['errorText'] .'</span></br />';
												}
											} else if ((isset($error_status['errorStatus'])) && ($error_status['errorStatus'] === false)) {
												if ((isset($error_status['responseText'])) && (strlen($error_status['responseText']))) {
													echo '<span class="snapshot-success">Success: '. $error_status['responseText'] .'</span></br />';
												} else {

												}
											}
											echo "</li></ul></li>";
										}
										echo "</ol>";

										closedir($dh);

									}
								}
							}
							echo "<p>". __('Snapshot import complete', SNAPSHOT_I18N_DOMAIN) ."</p>";
						}
					?>
				</div>
			</div>
			<?php
		}
コード例 #3
0
 function process_item_send_archive($item, $data_item, $snapshot_locker)
 {
     $item_key = $item['timestamp'];
     $data_item_key = $data_item['timestamp'];
     // Create a logged for each item/data_item combination because that is how the log files are setup
     if (isset($snapshot_logger)) {
         unset($snapshot_logger);
     }
     $snapshot_logger = new SnapshotLogger($this->_settings['backupLogFolderFull'], $item_key, $data_item_key);
     // If the file has already been transmitted the move to the next one.
     if (isset($data_item['destination-status']) && count($data_item['destination-status'])) {
         $destination_status = snapshot_utility_latest_data_item($data_item['destination-status']);
         //$snapshot_logger->log_message("destination_status<pre>: ". print_r($destination_status, true) ."</pre>");
         //echo "destination_status<pre>"; print_r($destination_status); echo "</pre>";
         //die();
         // If we have a positive 'sendFileStatus' continue on
         if (isset($destination_status['sendFileStatus']) && $destination_status['sendFileStatus'] == true) {
             //echo "finished item[". $item_key ."] data_item_key[". $data_item_key ."] file[". $data_item['filename'] ."]<br />";
             return;
         }
         /*
         				else if ( (isset($destination_status['responseArray'])) && (count($destination_status['responseArray']))
         					     && (isset($destination_status['errorStatus'])) && ($destination_status['errorStatus'] != true) ) {
         					return;
         				} */
     }
     //echo "DEBUG: processing item[". $item_key ."] data_item[". $data_item_key ."] file[". $data_item['filename'] ."]<br />";
     //return
     // Get the archive folder
     $current_backupFolder = $this->snapshot_get_item_destination_path($item, $data_item);
     if (empty($current_backupFolder)) {
         $current_backupFolder = $this->snapshot_get_setting('backupBaseFolderFull');
     }
     //echo "DEBUG: current_backupFolder=[". $current_backupFolder ."]<br />";
     // If the data_item destination is not empty...
     if (isset($data_item['destination']) && !empty($data_item['destination'])) {
         // We make sure to check it against the item master. If they don't match it means
         // the data_item archive was sent to the data_item destination. We probably don't
         // have the archive file to resent.
         //				echo "destination data_item[". $data_item['destination']."] item[". $item['destination'] ."]<br />";
         //				if ($data_item['destination'] !== $item['destination']) {
         //					return;
         //				}
     }
     $destination_key = $item['destination'];
     if (!isset($this->config_data['destinations'][$destination_key])) {
         return;
     }
     $destination = $this->config_data['destinations'][$destination_key];
     if (!isset($destination['type'])) {
         return;
     }
     if (!isset($this->_settings['destinationClasses'][$destination['type']])) {
         return;
     }
     $destination_object = $this->_settings['destinationClasses'][$destination['type']];
     $new_backupFolder = $this->snapshot_get_item_destination_path($item);
     if ($new_backupFolder && strlen($new_backupFolder)) {
         $destination['directory'] = $new_backupFolder;
     }
     if (!isset($data_item['destination-sync'])) {
         $data_item['destination-sync'] = "archive";
     }
     $files_sync = array();
     if ($data_item['destination-sync'] == "archive") {
         // If the data item is there but no final archive filename (probably stopped in an error). Abort
         if (!isset($data_item['filename']) || empty($data_item['filename'])) {
             return;
         }
         // See if we still have the archive file.
         // First check where we originally placed it.
         $backupFile = trailingslashit($current_backupFolder) . $data_item['filename'];
         if (!file_exists($backupFile)) {
             // Then check is the detail Snapshot archive folder
             $current_backupFolder = $this->_settings['backupBaseFolderFull'];
             $backupFile = trailingslashit($current_backupFolder) . $data_item['filename'];
             if (!file_exists($backupFile)) {
                 return;
             }
         }
         $snapshot_logger->log_message("Sending Archive: " . basename($backupFile) . " " . snapshot_utility_size_format(filesize($backupFile)));
         $snapshot_logger->log_message("Destination: " . $destination['type'] . ": " . stripslashes($destination['name']));
         $locker_info = $snapshot_locker->get_locker_info();
         $locker_info['file_name'] = $backupFile;
         $locker_info['file_size'] = filesize($backupFile);
         $snapshot_locker->set_locker_info($locker_info);
         $destination_object->snapshot_logger = $snapshot_logger;
         $destination_object->snapshot_locker = $snapshot_locker;
         $error_array = $destination_object->sendfile_to_remote($destination, $backupFile);
         //echo "error_array<pre>"; print_r($error_array); echo "</pre>";
         //$snapshot_logger->log_message("DEBUG: error_array<pre>". print_r($error_array, true)."</pre>");
         if (isset($error_array['responseArray']) && count($error_array['responseArray'])) {
             foreach ($error_array['responseArray'] as $message) {
                 $snapshot_logger->log_message($message);
             }
         }
         if (isset($error_array['errorStatus']) && $error_array['errorStatus'] == true) {
             if (isset($error_array['errorArray']) && count($error_array['errorArray'])) {
                 foreach ($error_array['errorArray'] as $message) {
                     $snapshot_logger->log_message("ERROR: " . $message);
                 }
             }
         }
         if (!isset($data_item['destination-status'])) {
             $data_item['destination-status'] = array();
         }
         $data_item['destination-status'][time()] = $error_array;
         //echo "destination-status<pre>"; print_r($data_item['destination-status']); echo "</pre>";
         //die();
         krsort($data_item['destination-status']);
         if (count($data_item['destination-status']) > 5) {
             $data_item['destination-status'] = array_slice($data_item['destination-status'], 0, 5, true);
         }
         $data_item['destination'] = $item['destination'];
         $data_item['destination-directory'] = $item['destination-directory'];
         //				echo "data_item<pre>"; print_r($data_item); echo "</pre>";
         //				die();
     } else {
         // We create an option to store the list of files we are sending. This is better than adding to the config data
         // for snapshot. Less loading of the master array. The list of files is a reference we pass to the sender function
         // of the destination. As files are sent they are removed from the array and the option is updated. So if something
         // happens we don't start from the first of the list. Could probably use a local file...
         $snapshot_sync_files_option = 'wpmudev_snapshot_sync_files_' . $item_key;
         $snapshot_sync_files = get_option($snapshot_sync_files_option);
         if (!$snapshot_sync_files) {
             $snapshot_sync_files = array();
         }
         $last_sync_timestamp = time();
         //$snapshot_logger->log_message("DEBUG: going to snapshot_gather_item_files");
         //$snapshot_logger->log_message("DEBUG: data_item<pre>". print_r($data_item, true), "</pre>");
         if (!isset($data_item['blog-id'])) {
             $data_item['blog-id'] = $item['blog-id'];
         }
         $gather_files_sync = $this->snapshot_gather_item_files($data_item);
         foreach ($data_item['files-sections'] as $file_section) {
             if ($file_section == "config" || $file_section == "config") {
                 $file_section = "files";
             }
             if (isset($gather_files_sync['included'][$file_section])) {
                 if (!isset($snapshot_sync_files['last-sync'][$file_section])) {
                     $snapshot_sync_files['last-sync'][$file_section] = 0;
                 }
                 foreach ($gather_files_sync['included'][$file_section] as $_file_idx => $_file) {
                     if (filemtime($_file) < $snapshot_sync_files['last-sync'][$file_section]) {
                         unset($gather_files_sync['included'][$file_section][$_file_idx]);
                     }
                 }
                 if (!isset($snapshot_sync_files['included'][$file_section])) {
                     $snapshot_sync_files['included'][$file_section] = array();
                 }
                 if (count($gather_files_sync['included'][$file_section])) {
                     $snapshot_sync_files['included'][$file_section] = array_merge($snapshot_sync_files['included'][$file_section], $gather_files_sync['included'][$file_section]);
                     $snapshot_sync_files['included'][$file_section] = array_unique($snapshot_sync_files['included'][$file_section]);
                     $snapshot_sync_files['included'][$file_section] = array_values($snapshot_sync_files['included'][$file_section]);
                 }
                 $snapshot_sync_files['last-sync'][$file_section] = $last_sync_timestamp;
             }
         }
         $destination_object->snapshot_logger = $snapshot_logger;
         $destination_object->snapshot_locker = $snapshot_locker;
         update_option($snapshot_sync_files_option, $snapshot_sync_files);
         $error_array = $destination_object->syncfiles_to_remote($destination, $snapshot_sync_files, $snapshot_sync_files_option);
         if (isset($error_array['errorStatus']) && $error_array['errorStatus'] == true) {
             if (isset($error_array['errorArray']) && count($error_array['errorArray'])) {
                 foreach ($error_array['errorArray'] as $message) {
                     $snapshot_logger->log_message("ERROR: " . $message);
                 }
             }
         }
         if (!isset($data_item['destination-status'])) {
             $data_item['destination-status'] = array();
         }
         $data_item['destination-status'][time()] = $error_array;
         krsort($data_item['destination-status']);
         if (count($data_item['destination-status']) > 5) {
             $data_item['destination-status'] = array_slice($data_item['destination-status'], 0, 5);
         }
         $data_item['destination'] = $item['destination'];
         $data_item['destination-directory'] = $item['destination-directory'];
         // See if we still have the archive file.
         // First check where we originally placed it.
         if (strlen($data_item['filename'])) {
             $backupFile = trailingslashit($current_backupFolder) . $data_item['filename'];
             if (!file_exists($backupFile)) {
                 // Then check is the detail Snapshot archive folder
                 $current_backupFolder = $this->_settings['backupBaseFolderFull'];
                 $backupFile = trailingslashit($current_backupFolder) . $data_item['filename'];
                 if (!file_exists($backupFile)) {
                     return $data_item;
                 }
             }
             //echo "backupFile=[". $backupFile ."]<br />";
             $snapshot_logger->log_message("Sending Archive: " . basename($backupFile));
             $snapshot_logger->log_message("Destination: " . $destination['type'] . ": " . stripslashes($destination['name']));
             $error_array = $destination_object->sendfile_to_remote($destination, $backupFile);
             //$snapshot_logger->log_message("DEBUG: error_array<pre>". print_r($error_array, true)."</pre>");
             if (isset($error_array['responseArray']) && count($error_array['responseArray'])) {
                 foreach ($error_array['responseArray'] as $message) {
                     $snapshot_logger->log_message($message);
                 }
             }
             if (isset($error_array['errorStatus']) && $error_array['errorStatus'] == true) {
                 if (isset($error_array['errorArray']) && count($error_array['errorArray'])) {
                     foreach ($error_array['errorArray'] as $message) {
                         $snapshot_logger->log_message("ERROR: " . $message);
                     }
                 }
             }
             if (!isset($data_item['destination-status'])) {
                 $data_item['destination-status'] = array();
             }
             $data_item['destination-status'][time()] = $error_array;
             krsort($data_item['destination-status']);
             if (count($data_item['destination-status']) > 5) {
                 $data_item['destination-status'] = array_slice($data_item['destination-status'], 0, 5);
             }
             $data_item['destination'] = $item['destination'];
             $data_item['destination-directory'] = $item['destination-directory'];
         }
     }
     return $data_item;
 }
コード例 #4
0
		function column_archives($item) {
			global $wpmudev_snapshot;

			$_HAS_FILE_RESTORE = false;

			if (!isset($data_item['destination-sync']))
				$data_item['destination-sync'] = "archive";

			if (!isset($data_item['files-count']))
				$data_item['files-count'] = 0;

			$output = "";

			if ((isset($item['data'])) && (count($item['data']))) {

				$data_item = snapshot_utility_latest_data_item($item['data']);
				if (!isset($data_item['timestamp'])) return;

				//echo "data_item<pre>"; print_r($data_item); echo "</pre>";
				if (isset($data_item)) {
					if ((empty($data_item['destination'])) || ($data_item['destination'] == "local")) {

						if (isset($data_item['filename'])) {

							$current_backupFolder = $wpmudev_snapshot->snapshot_get_item_destination_path($item, $data_item);
							if (empty($current_backupFolder)) {
								$current_backupFolder = $wpmudev_snapshot->snapshot_get_setting('backupBaseFolderFull');
							}

							$backupFile = trailingslashit(trim($current_backupFolder)) . $data_item['filename'];
							//echo "backupFile=[". $backupFile ."]<br />";

							// If we don't find file is the alternate directory then try the default
							if (!file_exists($backupFile)) {
								if ( (isset($data_item['destination-directory'])) || (!empty($data_item['destination-directory'])) ){
									$current_backupFolder = $wpmudev_snapshot->snapshot_get_setting('backupBaseFolderFull');
									$backupFile = trailingslashit(trim($current_backupFolder)) . $data_item['filename'];
								}
							}

							if (file_exists($backupFile)) {
								$_HAS_FILE_RESTORE = true;

								$output .= '<a href="?page=snapshots_edit_panel&amp;snapshot-item='. $item['timestamp']
									.'&snapshot-data-item='. $data_item['timestamp']
									.'&snapshot-action=download-archive">'. $data_item['filename'] .'</a>';

							} else {

								$output .=  $data_item['filename'];
							}

							if (isset($data_item['file_size'])) {
								$file_kb = snapshot_utility_size_format($data_item['file_size']);
								$output .= " (". $file_kb .")";
							}

							if (strlen($output)) $output .= "<br />";
						}
					} else {

						if (isset($data_item['filename'])) {

							if ( (isset($data_item['destination-directory'])) || (!empty($data_item['destination-directory'])) ){
								$current_backupFolder = $wpmudev_snapshot->snapshot_get_setting('backupBaseFolderFull');
								$backupFile = trailingslashit(trim($current_backupFolder)) . $data_item['filename'];

								if (file_exists($backupFile)) {
									$_HAS_FILE_RESTORE = true;

									echo '<a href="?page=snapshots_edit_panel&amp;snapshot-item='. $item['timestamp']
										.'&snapshot-data-item='. $data_item['timestamp']
										.'&snapshot-action=download-archive">'. $data_item['filename'] .'</a>';

								} else {
									echo  $data_item['filename'];
								}

								if (isset($data_item['file_size'])) {
									$file_kb = snapshot_utility_size_format($data_item['file_size']);
									$output .= " (". $file_kb .")";
								}

								if (strlen($output)) $output .= "<br />";
							}
						}

						if ($data_item['destination-sync'] == "mirror") {
							$output .= snapshot_utility_data_item_file_processed_count($data_item) ." ".
								__('files synced to destination', SNAPSHOT_I18N_DOMAIN)."<br />";
						}
					}

					$output .= __('Archives', SNAPSHOT_I18N_DOMAIN) .': '. '<a href="?page=snapshots_edit_panel&amp;snapshot-action=item-archives&amp;item='
						. $item['timestamp']
						.'">'. __('view', SNAPSHOT_I18N_DOMAIN) .'</a> ('. count($item['data']) .')';

					$backupLogFileFull = trailingslashit($wpmudev_snapshot->snapshot_get_setting('backupLogFolderFull'))
						. $item['timestamp'] ."_". $data_item['timestamp'] .".log";

					if (file_exists($backupLogFileFull)) {
						if (strlen($output)) $output .= " ";

						$output .= __('Latest Log:', SNAPSHOT_I18N_DOMAIN) .' '. '<a class="snapshot-thickbox"
							href="'. admin_url()
							.'admin-ajax.php?action=snapshot_view_log_ajax&amp;snapshot-item='. $item['timestamp'] .
							'&amp;snapshot-data-item='. $data_item['timestamp'] .'">'. __('view', SNAPSHOT_I18N_DOMAIN) .'</a>
							<a href="?page=snapshots_edit_panel&amp;snapshot-action=download-log&amp;snapshot-item=' . $item['timestamp']
								.'&amp;snapshot-data-item='. $data_item['timestamp'] .'&amp;live=0">'
								. __('download', SNAPSHOT_I18N_DOMAIN) .'</a>';

					}

					//if (strlen($output)) $output .= "<br />";


				} else {
					if (isset($item['timestamp'])) {
						//$output .= "Last: ". snapshot_utility_show_date_time($item['timestamp']);

						//if ($wpmudev_snapshot->config_data['config']['absoluteFolder'] != true) {

							$backupLogFileFull = trailingslashit($wpmudev_snapshot->snapshot_get_setting('backupLogFolderFull'))
								. $item['timestamp'] ."_backup.log";
							if (file_exists($backupLogFileFull)) {
								if (strlen($output)) $output .= " ";
								$output .= '<a href="?page=snapshots_edit_panel&amp;snapshot-item='. $item['timestamp']
									.'&snapshot-data-item='. $data_item['timestamp']
									.'&snapshot-action=download-log">'. __('view log', SNAPSHOT_I18N_DOMAIN) .'</a>';
							}
						//}
					}

					if (strlen($output)) $output .= "<br />";

					$output .= __('No Snapshot file found', SNAPSHOT_I18N_DOMAIN);
				}

				if (strlen($output))
					echo $output;
				else
					echo "&nbsp;";
			}
			$this->column_status($item);
		}
コード例 #5
0
		function column_size($data_item) {
			//echo $this->file_kb;
			if (isset($data_item['file_size'])) {
				$file_kb = snapshot_utility_size_format($data_item['file_size']);
				echo $file_kb;
			} else {
				echo "&nbsp;";
			}

		}