protected function tables() { if (!isset($_POST['settings']['type'])) { return array('error' => __('Missing type.', $this->plugin_translate)); } if (!isset($_POST['settings']['website_id'])) { return array('error' => __('Missing website id.', $this->plugin_translate)); } $type = $_POST['settings']['type']; $website_id = $_POST['settings']['website_id']; $this->wp_list_table_dependency(); $array = array(); switch ($type) { case 'logs': if (!is_dir(get_site_option('backwpup_cfg_logfolder'))) { return array('success' => 1, 'response' => $array); } update_user_option(get_current_user_id(), 'backwpuplogs_per_page', 99999999); $output = new BackWPup_Page_Logs(); $output->prepare_items(); break; case 'backups': update_user_option(get_current_user_id(), 'backwpupbackups_per_page', 99999999); $output = new BackWPup_Page_Backups(); $output->items = array(); $jobids = BackWPup_Option::get_job_ids(); if (!empty($jobids)) { foreach ($jobids as $jobid) { if (BackWPup_Option::get($jobid, 'backuptype') == 'sync') { continue; } $dests = BackWPup_Option::get($jobid, 'destinations'); foreach ($dests as $dest) { $dest_class = BackWPup::get_destination($dest); $items = $dest_class->file_get_list($jobid . '_' . $dest); if (!empty($items)) { foreach ($items as $item) { $temp_single_item = $item; $temp_single_item['dest'] = $jobid . '_' . $dest; $output->items[] = $temp_single_item; } } } } } break; case 'jobs': $output = new BackWPup_Page_Jobs(); $output->prepare_items(); break; } if (is_array($output->items)) { if ($type == 'jobs') { foreach ($output->items as $key => $val) { $temp_array = array(); $temp_array['id'] = $val; $temp_array['name'] = BackWPup_Option::get($val, 'name'); $temp_array['type'] = BackWPup_Option::get($val, 'type'); $temp_array['destinations'] = BackWPup_Option::get($val, 'destinations'); if ($this->is_backwpup_pro) { $temp_array['export'] = str_replace('&', '&', wp_nonce_url(network_admin_url('admin.php') . '?page=backwpupjobs&action=export&jobs[]=' . $val, 'bulk-jobs')); } if (BackWPup_Option::get($val, 'activetype') == 'wpcron') { if ($nextrun = wp_next_scheduled('backwpup_cron', array('id' => $val)) + get_option('gmt_offset') * 3600) { $temp_array['nextrun'] = sprintf(__('%1$s at %2$s by WP-Cron', 'backwpup'), date_i18n(get_option('date_format'), $nextrun, true), date_i18n(get_option('time_format'), $nextrun, true)); } else { $temp_array['nextrun'] = __('Not scheduled!', 'backwpup'); } } else { $temp_array['nextrun'] = __('Inactive', 'backwpup'); } if (BackWPup_Option::get($val, 'lastrun')) { $lastrun = BackWPup_Option::get($val, 'lastrun'); $temp_array['lastrun'] = sprintf(__('%1$s at %2$s', 'backwpup'), date_i18n(get_option('date_format'), $lastrun, true), date_i18n(get_option('time_format'), $lastrun, true)); if (BackWPup_Option::get($val, 'lastruntime')) { $temp_array['lastrun'] .= ' ' . sprintf(__('Runtime: %d seconds', 'backwpup'), BackWPup_Option::get($val, 'lastruntime')); } } else { $temp_array['lastrun'] = __('not yet', 'backwpup'); } $temp_array['website_id'] = $website_id; $array[] = $temp_array; } } else { if ($type == 'backups') { $without_dupes = array(); foreach ($output->items as $key) { $temp_array = $key; $temp_array['downloadurl'] = str_replace(array('&', network_admin_url('admin.php') . '?page=backwpupbackups&action='), array('&', admin_url('admin-ajax.php') . '?action=mainwp_backwpup_download_backup&type='), $temp_array['downloadurl'] . '&_wpnonce=' . $this->create_nonce_without_session('mainwp_download_backup')); $temp_array['website_id'] = $website_id; if (!isset($without_dupes[$temp_array['file']])) { $array[] = $temp_array; $without_dupes[$temp_array['file']] = 1; } } } else { foreach ($output->items as $key => $val) { $array[] = $val; } } } } return array('success' => 1, 'response' => $array); }
/** * */ public static function load() { //Create Table self::$listtable = new BackWPup_Page_Logs(); switch (self::$listtable->current_action()) { case 'delete': if (!current_user_can('backwpup_logs_delete')) { break; } if (is_array($_GET['logfiles'])) { check_admin_referer('bulk-logs'); $num = 0; foreach ($_GET['logfiles'] as $logfile) { if (is_writeable(get_site_option('backwpup_cfg_logfolder') . $logfile) && !is_dir(get_site_option('backwpup_cfg_logfolder') . $logfile) && !is_link(get_site_option('backwpup_cfg_logfolder') . $logfile)) { unlink(get_site_option('backwpup_cfg_logfolder') . $logfile); } $num++; } } break; case 'download': //Download Log if (!current_user_can('backwpup_logs')) { break; } check_admin_referer('download-backup_' . $_GET['file']); if (is_readable(get_site_option('backwpup_cfg_logfolder') . $_GET['file']) && !is_dir(get_site_option('backwpup_cfg_logfolder') . $_GET['file']) && !is_link(get_site_option('backwpup_cfg_logfolder') . $_GET['file'])) { header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=" . get_site_option('backwpup_cfg_logfolder') . $_GET['file'] . ";"); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . filesize(get_site_option('backwpup_cfg_logfolder') . $_GET['file'])); @readfile(get_site_option('backwpup_cfg_logfolder') . $_GET['file']); die; } else { header('HTTP/1.0 404 Not Found'); die; } break; } //Save per page if (isset($_POST['screen-options-apply']) && isset($_POST['wp_screen_options']['option']) && isset($_POST['wp_screen_options']['value']) && $_POST['wp_screen_options']['option'] == 'backwpuplogs_per_page') { check_admin_referer('screen-options-nonce', 'screenoptionnonce'); global $current_user; if ($_POST['wp_screen_options']['value'] > 0 && $_POST['wp_screen_options']['value'] < 1000) { update_user_option($current_user->ID, 'backwpuplogs_per_page', (int) $_POST['wp_screen_options']['value']); wp_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer())); exit; } } add_screen_option('per_page', array('label' => __('Logs', 'backwpup'), 'default' => 20, 'option' => 'backwpuplogs_per_page')); self::$listtable->prepare_items(); }
/** * */ public static function load() { //Create Table self::$listtable = new BackWPup_Page_Logs(); switch (self::$listtable->current_action()) { case 'delete': if (!current_user_can('backwpup_logs_delete')) { break; } if (is_array($_GET['logfiles'])) { check_admin_referer('bulk-logs'); foreach ($_GET['logfiles'] as $logfile) { $logfile = basename($logfile); if (is_writeable(self::$listtable->log_folder . '/' . $logfile) && !is_dir(self::$listtable->log_folder . '/' . $logfile) && !is_link(self::$listtable->log_folder . '/' . $logfile)) { unlink(self::$listtable->log_folder . '/' . $logfile); } } } break; case 'download': //Download Log if (!current_user_can('backwpup_logs')) { break; } check_admin_referer('download-log_' . trim($_GET['file'])); $log_file = trailingslashit(self::$listtable->log_folder) . basename(trim($_GET['file'])); $log_file = realpath($log_file); if ($log_file && is_readable($log_file) && !is_dir($log_file) && !is_link($log_file)) { if ($level = ob_get_level()) { for ($i = 0; $i < $level; $i++) { ob_end_clean(); } } @set_time_limit(300); nocache_headers(); header('Content-Description: File Transfer'); header('Content-Type: ' . BackWPup_Job::get_mime_type($log_file)); header('Content-Disposition: attachment; filename="' . basename($log_file) . '"'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($log_file)); @readfile($log_file); die; } else { header('HTTP/1.0 404 Not Found'); die; } break; } //Save per page if (isset($_POST['screen-options-apply']) && isset($_POST['wp_screen_options']['option']) && isset($_POST['wp_screen_options']['value']) && $_POST['wp_screen_options']['option'] == 'backwpuplogs_per_page') { check_admin_referer('screen-options-nonce', 'screenoptionnonce'); global $current_user; if ($_POST['wp_screen_options']['value'] > 0 && $_POST['wp_screen_options']['value'] < 1000) { update_user_option($current_user->ID, 'backwpuplogs_per_page', (int) $_POST['wp_screen_options']['value']); wp_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer())); exit; } } add_screen_option('per_page', array('label' => __('Logs', 'backwpup'), 'default' => 20, 'option' => 'backwpuplogs_per_page')); self::$listtable->prepare_items(); }