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;
 }
 /**
  * Gets a job by id
  *
  * @param $id
  *
  * @return bool|WPBackItUp_Job
  */
 public static function get_job_by_id($id)
 {
     $logger = new WPBackItUp_Logger(false, null, 'debug_job');
     $logger->log_info(__METHOD__, 'Begin');
     $job = get_post($id, 'OBJECT');
     $logger->log($job);
     if (null != $job) {
         $logger->log_info(__METHOD__, 'Job found:' . $id);
         return new WPBackItUp_Job_v2($job);
     }
     $logger->log_info(__METHOD__, 'No job found with id.' . $id);
     $logger->log_info(__METHOD__, 'End');
     return false;
 }
//*************************//
//*** 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);
            break;
        case "task_backup_db":
            set_status('backupdb', $active, true);
            write_fatal_error_status('2104');
            end_backup(2104, false);
            break;
        case "task_backup_siteinfo":
            set_status('infofile', $active, true);
            write_fatal_error_status('2105');
//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**');
    $logger->log('**CLEAN DELETED BACKUPS**');
    //cleanup any folders that have the DLT_ prefix
    $wp_backup->cleanup_backups_by_prefix('DLT_');
    $logger->log('**END CLEAN DELETED BACKUPS**');
    $logger->log('**CLEAN OLD BACKUPS**');
    //Cleanup any folders that exceed retention limit
    $wp_backup->cleanup_old_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;
 }
            fatal_error('stage_wpcontent', '2005', 'Task ended in error:' . $current_task->getId());
            break;
        case "task_restore_wpcontent":
            fatal_error('restore_wpcontent', '2006', 'Task ended in error:' . $current_task->getId());
            break;
        case "task_restore_database":
            fatal_error('restore_database', '2007', 'Task ended in error:' . $current_task->getId());
            break;
        default:
            fatal_error('unknown', '2999', 'Task ended in error:' . $current_task->getId());
            break;
    }
}
//Cleanup Task
if ('task_preparing' == $current_task->getId()) {
    $logger->log('***BEGIN RESTORE***');
    $logger->log_sysinfo();
    $task = 'preparing';
    start_status($task);
    $logger->log('**PREPARING FOR RESTORE**');
    //ONLY check license here and prevent restore from starting. If
    //IF license check fails in later steps could be because DB was restored and no license on backup
    //which is a valid condition.
    if (!$this->license_active()) {
        fatal_error($task, '225', 'Restore is not available because license is not active.');
    }
    //PREPARE TASK
    if (!class_exists('ZipArchive')) {
        fatal_error($task, '235', 'Zip Archive Class is not available.');
    }
    $logger->log('*DELETE RESTORE FOLDER*');
 * 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)) {
    if (!mkdir($upload_path, 0755)) {
        $logger->log_error(__METHOD__, 'Upload directory is not writable, or does not exist.');
        echo json_encode(array('error' => sprintf(__("Upload directory is not writable, or does not exist.", WPBACKITUP__NAMESPACE))));
        exit;
    }