function column_archives($item) { $_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_Helper_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 = WPMUDEVSnapshot::instance()->snapshot_get_item_destination_path($item, $data_item); if (empty($current_backupFolder)) { $current_backupFolder = WPMUDEVSnapshot::instance()->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 = WPMUDEVSnapshot::instance()->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&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_Helper_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 = WPMUDEVSnapshot::instance()->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&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_Helper_Utility::size_format($data_item['file_size']); $output .= " (" . $file_kb . ")"; } if (strlen($output)) { $output .= "<br />"; } } } if ($data_item['destination-sync'] == "mirror") { $output .= Snapshot_Helper_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&snapshot-action=item-archives&item=' . $item['timestamp'] . '">' . __('view', SNAPSHOT_I18N_DOMAIN) . '</a> (' . count($item['data']) . ')'; $backupLogFileFull = trailingslashit(WPMUDEVSnapshot::instance()->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&snapshot-item=' . $item['timestamp'] . '&snapshot-data-item=' . $data_item['timestamp'] . '">' . __('view', SNAPSHOT_I18N_DOMAIN) . '</a> <a href="?page=snapshots_edit_panel&snapshot-action=download-log&snapshot-item=' . $item['timestamp'] . '&snapshot-data-item=' . $data_item['timestamp'] . '&live=0">' . __('download', SNAPSHOT_I18N_DOMAIN) . '</a>'; } //if (strlen($output)) $output .= "<br />"; } else { if (isset($item['timestamp'])) { //$output .= "Last: ". Snapshot_Helper_Utility::show_date_time($item['timestamp']); //if (WPMUDEVSnapshot::instance()->config_data['config']['absoluteFolder'] != true) { $backupLogFileFull = trailingslashit(WPMUDEVSnapshot::instance()->get_setting('backupLogFolderFull')) . $item['timestamp'] . "_backup.log"; if (file_exists($backupLogFileFull)) { if (strlen($output)) { $output .= " "; } $output .= '<a href="?page=snapshots_edit_panel&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 " "; } } $this->column_status($item); }
function column_file($data_item) { $_HAS_FILE_RESTORE = false; $this->file_kb = ' '; //echo "data_item<pre>"; print_r($data_item); echo "</pre>"; //echo "item<pre>"; print_r($this->item); echo "</pre>"; if (empty($data_item['destination']) || $data_item['destination'] == "local") { if (isset($data_item['filename'])) { $current_backupFolder = WPMUDEVSnapshot::instance()->snapshot_get_item_destination_path($this->item, $data_item); if (empty($current_backupFolder)) { $current_backupFolder = WPMUDEVSnapshot::instance()->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 = WPMUDEVSnapshot::instance()->get_setting('backupBaseFolderFull'); $backupFile = trailingslashit(trim($current_backupFolder)) . $data_item['filename']; } } if (file_exists($backupFile)) { $_HAS_FILE_RESTORE = true; if (isset($_GET['snapshot-action-sub']) && sanitize_text_field($_GET['snapshot-action-sub']) == "restore" && Snapshot_Helper_Utility::current_user_can('manage_snapshots_items')) { echo '<a href="?page=snapshots_edit_panel&snapshot-action=restore-panel&item=' . $this->item['timestamp'] . '&snapshot-data-item=' . $data_item['timestamp'] . '">' . $data_item['filename'] . '</a>'; } else { echo '<a href="?page=snapshots_edit_panel&snapshot-item=' . $this->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 = WPMUDEVSnapshot::instance()->get_setting('backupBaseFolderFull'); $backupFile = trailingslashit(trim($current_backupFolder)) . $data_item['filename']; if (file_exists($backupFile)) { $_HAS_FILE_RESTORE = true; ?> <a href="?page=snapshots_edit_panel&snapshot-item=<?php echo $this->item['timestamp']; ?> &snapshot-data-item=<?php echo $data_item['timestamp']; ?> &snapshot-action=download-archive"><?php echo $data_item['filename']; ?> </a><?php } else { echo $data_item['filename']; } } if ($data_item['destination-sync'] == "mirror") { if ($_HAS_FILE_RESTORE == true) { echo "<br />"; } echo Snapshot_Helper_Utility::data_item_file_processed_count($data_item) . " " . __('files synced to destination', SNAPSHOT_I18N_DOMAIN) . "<br />"; } } ?> <div class="row-actions" style="margin:0; padding:0;"> <span class="restore"> <?php $row_actions = ''; if (isset($_GET['snapshot-action-sub']) && sanitize_text_field($_GET['snapshot-action-sub']) == "restore") { if ($_HAS_FILE_RESTORE == true) { if (Snapshot_Helper_Utility::current_user_can('manage_snapshots_items')) { if (strlen($row_actions)) { $row_actions .= ' | '; } $row_actions .= '<a href="?page=snapshots_edit_panel&snapshot-action=restore-panel&item=' . $this->item['timestamp'] . '&snapshot-data-item=' . $data_item['timestamp'] . '">' . __('restore', SNAPSHOT_I18N_DOMAIN) . '</a></span>'; } } if ($data_item['destination-sync'] == "mirror") { echo '<span style="color:#FF0000">' . __("File sync has no restore at this time", SNAPSHOT_I18N_DOMAIN) . '</span>'; } } else { if ($_HAS_FILE_RESTORE == true) { $row_actions .= '<a href="?page=snapshots_edit_panel&snapshot-item=' . $this->item['timestamp'] . '&snapshot-data-item=' . $data_item['timestamp'] . '&snapshot-action=download-archive">' . __('download', SNAPSHOT_I18N_DOMAIN) . '</a>'; } if ($_HAS_FILE_RESTORE == true) { if (Snapshot_Helper_Utility::current_user_can('manage_snapshots_items')) { if (strlen($row_actions)) { $row_actions .= ' | '; } $row_actions .= '<a href="?page=snapshots_edit_panel&snapshot-action=restore-panel&item=' . $this->item['timestamp'] . '&snapshot-data-item=' . $data_item['timestamp'] . '">' . __('restore', SNAPSHOT_I18N_DOMAIN) . '</a></span>'; } } if (Snapshot_Helper_Utility::current_user_can('manage_snapshots_items')) { if (strlen($row_actions)) { $row_actions .= ' | '; } $row_actions .= '<span class="delete"><a href="?page=snapshots_edit_panel&snapshot-action=item-archives&item=' . $this->item['timestamp'] . '&action=delete&data-item=' . $data_item['timestamp'] . '&snapshot-noonce-field=' . wp_create_nonce('snapshot-delete-item') . '">' . __('delete', SNAPSHOT_I18N_DOMAIN) . '</a></span>'; } if (isset($this->item['destination']) && !empty($this->item['destination']) && $this->item['destination'] !== "local") { if (strlen($row_actions)) { $row_actions .= ' | '; } $row_actions .= '<span class="resend"><a href="?page=snapshots_edit_panel&snapshot-action=item-archives&item=' . $this->item['timestamp'] . '&action=resend&data-item=' . $data_item['timestamp'] . '&snapshot-noonce-field=' . wp_create_nonce('snapshot-delete-item') . '">' . __('resend', SNAPSHOT_I18N_DOMAIN) . '</a></span>'; } } if (!empty($row_actions)) { echo $row_actions; } ?> </div> <?php }