public function accept() { $logger = new WPBackItUp_Logger(false); $accept = !in_array($this->current()->getFilename(), $this->filters, true); $logger->log('(WPBackItUp_RecursiveFilter_Iterator) accept:' . $this->current()->getFilename() . ":" . $accept); return $accept; }
/** * WP BackItUp - Download handler * * @package WP BackItUp * @author Chris Simmons <*****@*****.**> * @link http://www.wpbackitup.com * */ //Turn off output buffering if it was on. while (@ob_end_clean()) { } // required for IE, otherwise Content-disposition is ignored //@apache_setenv('no-gzip', 1); //Causes failure on siteground...research @ini_set('zlib.output_compression', 'Off'); global $logger; $logger = new WPBackItUp_Logger(true, null, 'debug_download'); $logger->log_info(__METHOD__, $_REQUEST); if (isset($_REQUEST['_wpnonce']) && !empty($_REQUEST['_wpnonce']) && isset($_REQUEST['backup_file']) && !empty($_REQUEST['backup_file'])) { if (wp_verify_nonce($_REQUEST['_wpnonce'], WPBACKITUP__NAMESPACE . '-download_backup')) { $logger->log_info(__METHOD__, 'nonce verified'); //strip off the suffix IF one exists $folder_name = rtrim($_REQUEST['backup_file'], '.zip'); if (($str_pos = strpos($folder_name, '-main-')) !== false) { $suffix = substr($folder_name, $str_pos); $folder_name = str_replace($suffix, '', $folder_name); } if (($str_pos = strpos($folder_name, '-others-')) !== false) { $suffix = substr($folder_name, $str_pos); $folder_name = str_replace($suffix, '', $folder_name); } if (($str_pos = strpos($folder_name, '-plugins-')) !== false) {
* WP BackItUp - Backup View * * @package WP BackItUp * @author Chris Simmons <*****@*****.**> * @link http://www.wpbackitup.com * */ require_once WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-filesystem.php'; //Check the license do_action('wpbackitup_check_license'); $page_title = $this->friendly_name . ' Dashboard'; $namespace = $this->namespace; //Path Variables $backup_folder_root = WPBACKITUP__BACKUP_PATH; $logs_folder_root = WPBACKITUP__PLUGIN_PATH . '/logs'; $logger = new WPBackItUp_Logger(false, null, 'debug_backup_view'); //Get license info - trim off build version if 0 $version = rtrim($this->version, '.0'); $license_key = $this->license_key(); $license_active = $this->license_active(); $license_type = $this->license_type(); $license_type_description = $this->license_type_description(); if (!empty($license_type_description)) { $license_type_description = ucfirst($license_type_description); } $license_status = $this->license_status(); $license_status_message = $this->license_status_message(); $license_Expires = $this->license_expires(); $formatted_expired_date = date('F j, Y', strtotime($license_Expires)); // get retention number set $number_retained_archives = $this->backup_retained_number();
/** * Create all the tasks for a job * * @param $job_id * * @param $tasks * * @return bool */ private static function create_tasks($job_id, $tasks) { $logger = new WPBackItUp_Logger(false, null, 'debug_job'); $logger->log_info(__METHOD__, 'Begin'); //Create the job tasks $last_updated_time = time(); foreach ($tasks as $key => $value) { $task_name = $value; $task_data = array('task_id' => $task_name, 'task_status' => self::QUEUED, 'task_allocated_id' => '', 'task_last_updated' => $last_updated_time); $task_created = update_post_meta($job_id, $task_name, $task_data); if (false === $task_created) { $logger->log_error(__METHOD__, 'Tasks NOT created'); return false; } $logger->log_info(__METHOD__, 'task created:' . $task_created . ':' . $task_name); } $logger->log_info(__METHOD__, 'End'); return true; }
} else { $logger_tasks->log_info(__METHOD__ . '(' . $backup_process_id . ')', 'No backup job available.'); wp_clear_scheduled_hook('wpbackitup_run_backup_tasks'); WPBackItUp_Backup::end(); //release lock return; } //Should only get here when there is a task to run $logger_tasks->log_info(__METHOD__ . '(' . $backup_process_id . ')', 'Run Backup task:' . $current_task); //*************************// //*** MAIN BACKUP CODE ***// //*************************// //Get the backup ID $backup_name = get_backup_name($backup_job->backup_id); global $logger; $logger = new WPBackItUp_Logger(false, null, $backup_name); global $wp_backup; $wp_backup = new WPBackItUp_Backup($logger, $backup_name, $WPBackitup->backup_type); //*************************// //*** BACKUP TASKS ***// //*************************// //An error has occurred on the previous tasks if ($backup_error) { $error_task = substr($current_task, 6); $logger->log('Fatal error on previous task:' . $error_task); //Check for error type switch ($error_task) { case "task_preparing": set_status('preparing', $active, true); write_fatal_error_status('2101'); end_backup(2101, false);
} else { $logger_tasks->log_info(__METHOD__ . '(' . $backup_process_id . ')', 'No backup job available.'); wp_clear_scheduled_hook('wpbackitup_run_cleanup_tasks'); WPBackItUp_Backup::end(); //release lock return; } //Should only get here when there is a task to run $logger_tasks->log_info(__METHOD__ . '(' . $backup_process_id . ')', 'Run Backup task:' . $current_task); //*************************// //*** MAIN BACKUP CODE ***// //*************************// //Get the backup ID $job_name = get_job_name($cleanup_job->backup_id); global $logger; $logger = new WPBackItUp_Logger(false, null, $job_name); global $wp_backup; $wp_backup = new WPBackItUp_Backup($logger, $job_name, $WPBackitup->backup_type); //*** SCHEDULED TASKS ***// //Run cleanup task if ('task_scheduled_cleanup' == $current_task) { //Init $logger->log('***BEGIN JOB***'); $logger->log_sysinfo(); $logger->log('Check License'); do_action('wpbackitup_check_license'); $logger->log('Scheduled Cleanup requested'); $logger->log('**CLEAN UNFINISHED BACKUPS**'); //cleanup any folders that have the TMP_ prefix $wp_backup->cleanup_backups_by_prefix('TMP_'); $logger->log('**END CLEAN UNFINISHED BACKUPS**');
/** * Update statistics */ private function update_stats($license) { $logger = new WPBackItUp_Logger(true); $logger->log('Update Stats:' . $license); $license = trim($license); //Get stats here //Setup API call $api_params = array('wpb_action' => 'update_stats', 'license' => $license); $url = WPBACKITUP__SECURESITE_URL . '/stats-update-test'; $response = wp_remote_get(add_query_arg($api_params, $url), array('timeout' => 25, 'sslverify' => true)); $logger->log('Stats Response:'); $logger->log($response); if (is_wp_error($response)) { return false; } //Exit and don't update //$license_data = json_decode( wp_remote_retrieve_body( $response ) ); return true; }
} } else { $logger_tasks->log_info(__METHOD__ . '(' . $process_id . ')', 'No job available.'); //wp_clear_scheduled_hook( 'wpbackitup_run_restore_tasks'); //WPBackItUp_Backup::end(); //release lock return; } //Should only get here when there is a task to run $logger_tasks->log_info(__METHOD__ . '(' . $process_id . ')', 'Run Restore task:' . $current_task->getId()); //*****************// //*** MAIN CODE ***// //*****************// //Get the job name $job_log_name = get_job_log_name($restore_job->get_job_id()); global $logger; $logger = new WPBackItUp_Logger(false, null, $job_log_name, true); $backup_name = $restore_job->get_job_meta('backup_name'); if (empty($backup_name)) { $logger->log_error(__METHOD__, 'Backup name not found in job meta.'); write_fatal_error_status('error201'); end_restore(); } //Get user ID $user_id = $restore_job->get_job_meta('user_id'); if (empty($user_id)) { $logger->log_error(__METHOD__, 'User Id not found in job meta.'); write_fatal_error_status('error201'); end_restore(); } global $wp_restore; //Eventually everything will be migrated to this class
if (!defined('ABSPATH')) { die('No direct access allowed (upload)'); } /** * WP BackItUp - Upload Handler * * @package WP BackItUp * @author Chris Simmons <*****@*****.**> * @link http://www.wpbackitup.com * */ /*** Includes ***/ /*** Globals ***/ global $logger; $logger = new WPBackItUp_Logger(false, null, 'debug_upload'); $backup_folder_root = WPBACKITUP__BACKUP_PATH . '/'; //*****************// //*** MAIN CODE ***// //*****************// $logger->log('***BEGIN UPLOAD***'); $logger->log($_POST); //verify nonce if (!wp_verify_nonce($_REQUEST['_wpnonce'], WPBACKITUP__NAMESPACE . '-upload')) { $logger->log_error(__METHOD__, 'Invalid Nonce'); echo json_encode(array('error' => sprintf(__('Invalid Nonce', WPBACKITUP__NAMESPACE)))); exit; } //Check upload folder $upload_path = WPBACKITUP__UPLOAD_PATH; if (!is_dir($upload_path)) {