}
 $backup_filename = $_REQUEST['backup_file'];
 $backup_path = WPBACKITUP__BACKUP_PATH . '/' . $folder_name . '/' . $backup_filename;
 $logger->log_info(__METHOD__, 'Backup file path:' . $backup_path);
 if (!empty($backup_filename) && file_exists($backup_path)) {
     $file_name = basename($backup_path);
     $file_size = filesize($backup_path);
     $chunksize = 1024 * 1024;
     // how many bytes per chunk
     $buffer = '';
     $cnt = 0;
     $handle = fopen($backup_path, 'rb');
     if ($handle !== false) {
         //Have the headers already been sent for some reason
         if (headers_sent()) {
             $logger->log_error(__METHOD__, 'Headers already sent.');
         }
         //Output Headers
         header("Pragma: public");
         header("Expires: -1");
         header("Cache-Control: public, must-revalidate, post-check=0, pre-check=0");
         header("Content-Disposition: attachment; filename=\"" . urlencode($file_name) . "\"");
         //              header("Content-Disposition: attachment; filename=\"$file_name\"");
         header("Content-type: application/zip");
         header("Content-Length: " . $file_size);
         while (!feof($handle) && connection_status() == 0) {
             $buffer = fread($handle, $chunksize);
             echo $buffer;
             @ob_flush();
             @flush();
         }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
 //Init
 $logger->log('***BEGIN BACKUP***');
 $logger->log_sysinfo();
 $logger->log('BACKUP TYPE:' . $wp_backup->backup_type);
 $logger->log('BACKUP BATCH SIZE:' . $wp_backup->backup_batch_size);
 $logger->log('BACKUP ID:' . $backup_job->backup_id);
 $WPBackitup->increment_backup_count();
 //End Init
 $logger->log('**BEGIN CLEANUP**');
 //Cleanup & Validate the backup folded is ready
 write_response_processing("preparing for backup");
 set_status('preparing', $active, true);
 write_response_processing("Cleanup before backup");
 //*** Check Dependencies ***
 if (!WPBackItUp_Zip::zip_utility_exists()) {
     $logger->log_error(__METHOD__, 'Zip Util does not exist.');
     $backup_job->set_task_error('125');
     write_fatal_error_status('125');
     end_backup(125, false);
 }
 //*** END Check Dependencies ***
 //Make sure wpbackitup_backups exists
 if (!$wp_backup->backup_root_folder_exists()) {
     $backup_job->set_task_error('101');
     write_fatal_error_status('101');
     end_backup(101, false);
 }
 //Create the root folder for the current backup
 if (!$wp_backup->create_current_backup_folder()) {
     $backup_job->set_task_error('101');
     write_fatal_error_status('101');
 /**
  * Update ALL the license options
  */
 private function update_license_options($license)
 {
     $logger = new WPBackItUp_Logger(false, null, 'debug_activation');
     $logger->log('Update License Options:' . $license);
     $license = trim($license);
     //Load the defaults
     $data['license_key'] = $this->defaults['license_key'];
     $dt = new DateTime('now');
     $data['license_last_check_date'] = $dt->format('Y-m-d H:i:s');
     $data['license_status'] = $this->defaults['license_status'];
     $data['license_status_message'] = $this->defaults['license_status_message'];
     $data['license_expires'] = $this->defaults['license_expires'];
     $data['license_limit'] = $this->defaults['license_limit'];
     $data['license_sitecount'] = $this->defaults['license_sitecount'];
     $data['license_type'] = $this->defaults['license_type'];
     //$data['license_customer_name'] = $this->defaults['license_customer_name'];
     //$data['license_customer_email'] = $this->defaults['license_customer_email'];
     $data['license_customer_name'] = $this->license_customer_name();
     $data['license_customer_email'] = $this->license_customer_email();
     //If no value then default to lite
     if (empty($license) || 'lite' == $license) {
         $data['license_status'] = 'free';
         $data['license_expires'] = $this->defaults['license_expires'];
         $data['license_limit'] = 1;
         $data['license_sitecount'] = 1;
         $data['license_type'] = 0;
     } else {
         //CALL EDD_ACTIVATE_LICENSE to get activation information
         $api_params = array('edd_action' => 'activate_license', 'license' => $license, 'item_name' => urlencode(WPBACKITUP__ITEM_NAME));
         $logger->log('Activate License Request Info:');
         $logger->log($api_params);
         //try 30 secs when connected to web.
         $response = wp_remote_get(add_query_arg($api_params, WPBACKITUP__SECURESITE_URL), array('timeout' => 25, 'sslverify' => false));
         $logger->log('Validation Response:');
         $logger->log($response);
         if (is_wp_error($response)) {
             $logger->log_error(__METHOD__, $response->get_error_message());
             //update license last checked date and
             $this->set_option('license_last_check_date', $data['license_last_check_date']);
             return false;
             //Exit and don't update license
         } else {
             $logger->log_info(__METHOD__, 'No request errors.');
         }
         $license_data = json_decode(wp_remote_retrieve_body($response));
         $logger->log('License Object Info');
         $logger->log($license_data);
         $data['license_key'] = $license;
         $data['license_status'] = $license_data->license;
         if (property_exists($license_data, 'error')) {
             $data['license_status_message'] = $license_data->error;
         }
         $data['license_limit'] = $license_data->license_limit;
         $data['license_sitecount'] = $license_data->site_count;
         $data['license_expires'] = $license_data->expires;
         $data['license_customer_name'] = $license_data->customer_name;
         $data['license_customer_email'] = $license_data->customer_email;
         //This is how we determine the type of license because
         //there is no difference in EDD
         if (is_numeric($license_data->license_limit)) {
             //Personal
             if ($license_data->license_limit < 5) {
                 $data['license_type'] = 1;
             }
             //Business
             if ($license_data->license_limit >= 5 && $license_data->license_limit < 20) {
                 $data['license_type'] = 2;
             }
             //Professional
             if ($license_data->license_limit >= 20) {
                 $data['license_type'] = 3;
             }
         }
         //EDD sends back expired in the error
         if ($license_data->license == 'invalid') {
             $data['license_status_message'] = 'License is invalid.';
             //EDD sends back expired in the error
             if ($license_data->error == 'expired') {
                 $data['license_status'] = 'expired';
                 $data['license_status_message'] = 'License has expired.';
                 $logger->log('Expire License.');
             }
             if ($license_data->error == 'no_activations_left') {
                 $data['license_status_message'] = 'Activation limit has been reached.';
             }
         }
     }
     $logger->log('Updating License Options');
     foreach ($data as $key => $val) {
         $this->set_option($key, $val);
         $logger->log('Updated Option: ' . $key . ':' . $val);
     }
     return true;
 }
예제 #5
0
    //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
$wp_restore = new WPBackItUp_Restore($logger, $backup_name, $restore_job->get_job_id());
//*************************//
//***   RESTORE TASKS   ***//
 * @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;
    }
}
add_filter('upload_dir', array($this, 'upload_dir'));
add_filter('sanitize_file_name', array($this, 'sanitize_file_name'));
$farray = array('test_form' => true, 'action' => WPBACKITUP__NAMESPACE . '_plupload_action');