Ejemplo n.º 1
0
function end_backup($err = null, $success = null)
{
    global $WPBackitup, $wp_backup, $logger, $backup_job;
    $logger->log_info(__METHOD__, "Begin");
    $logger->log('Zip up all the logs.');
    //Zip up all the logs in the log folder
    $logs_path = WPBACKITUP__PLUGIN_PATH . 'logs';
    $zip_file_path = $wp_backup->backup_project_path . 'logs_' . $backup_job->backup_id . '.zip';
    //copy/replace WP debug file
    $wpdebug_file_path = WPBACKITUP__CONTENT_PATH . '/debug.log';
    $logger->log_info(__METHOD__, "Copy WP Debug: " . $wpdebug_file_path);
    if (file_exists($wpdebug_file_path)) {
        copy($wpdebug_file_path, $logs_path . '/wpdebug.log');
    }
    $zip = new WPBackItUp_Zip($logger, $zip_file_path);
    $zip->zip_files_in_folder($logs_path, $backup_job->backup_id, '*.log');
    $zip->close();
    WPBackItUp_Backup::end();
    //Release the lock
    $current_datetime = current_time('timestamp');
    $WPBackitup->set_backup_lastrun_date($current_datetime);
    $util = new WPBackItUp_Utility($logger);
    $seconds = $util->timestamp_diff_seconds($backup_job->get_job_start_time(), $backup_job->get_job_end_time());
    $processing_minutes = round($seconds / 60);
    $processing_seconds = $seconds % 60;
    $logger->log('Script Processing Time:' . $processing_minutes . ' Minutes ' . $processing_seconds . ' Seconds');
    if (true === $success) {
        $logger->log("Backup completed: SUCCESS");
    }
    if (false === $success) {
        $logger->log("Backup completed: ERROR");
    }
    $logger->log("*** END BACKUP ***");
    //Send Notification email
    $logger->log('Send Email notification');
    $logs_attachment = array($zip_file_path);
    send_backup_notification_email($err, $success, $logs_attachment);
    $logFileName = $logger->logFileName;
    $logFilePath = $logger->logFilePath;
    $logger->close_file();
    //COPY the log if it exists
    $newlogFilePath = $wp_backup->backup_project_path . $logFileName;
    if (null != $success && file_exists($logFilePath)) {
        copy($logFilePath, $newlogFilePath);
    }
    echo 'Backup has completed';
    exit(0);
}
Ejemplo n.º 2
0
 public function zip_logs()
 {
     $this->logger->log_info(__METHOD__, 'Begin');
     //Zip up all the logs in the log folder
     $logs_path = WPBACKITUP__PLUGIN_PATH . 'logs';
     $zip_file_path = $logs_path . '/Restore_Logs_' . $this->backup_id . '.zip';
     //copy/replace WP debug file
     $wpdebug_file_path = WPBACKITUP__CONTENT_PATH . '/debug.log';
     $this->logger->log_info(__METHOD__, "Copy WP Debug: " . $wpdebug_file_path);
     if (file_exists($wpdebug_file_path)) {
         copy($wpdebug_file_path, $logs_path . '/wpdebug.log');
     }
     $zip = new WPBackItUp_Zip($this->logger, $zip_file_path);
     $zip->zip_files_in_folder($logs_path, $this->backup_id, '*.log');
     $zip->close();
     $this->logger->log_info(__METHOD__, 'End');
     return $zip_file_path;
 }
 /**
  * Send support request Schedule
  *
  */
 public function _admin_send_support_request()
 {
     // Verify submission for processing using wp_nonce
     $url = str_replace('&s=1', '', $_REQUEST['_wp_http_referer']);
     $logger = new WPBackItUp_Logger(true, null, 'debug_support');
     $logger->log_sysinfo();
     $logger->log_info(__METHOD__, 'Send Support Request');
     $error = false;
     if (wp_verify_nonce($_REQUEST['_wpnonce'], "{$this->namespace}-support-form")) {
         $logger->log_info(__METHOD__, "Send support request");
         $logger->log_info(__METHOD__, $_POST);
         //save the email in place of transient
         $this->set_support_email($_POST['support_email']);
         // save the transients in case of error
         foreach ($_POST as $key => $val) {
             set_transient($key, __($val, $this->namespace), 60);
         }
         //validate form fields
         if (empty($_POST['support_email']) || !is_email($_POST['support_email'])) {
             $error = true;
             set_transient('error-support-email', __('Please enter a valid email', $this->namespace), 60);
         }
         if (empty($_POST['support_ticket_id'])) {
             $error = true;
             set_transient('error-support-ticket', __('Please enter your support ticket id', $this->namespace), 60);
         } else {
             if (!is_numeric($_POST['support_ticket_id'])) {
                 $error = true;
                 set_transient('error-support-ticket', __('Please only enter numbers in this field', $this->namespace), 60);
             }
         }
         //			if(empty($_POST['support_subject']))
         //			{
         //				$error=true;
         //				set_transient('error-support-subject', __('Please enter a short description of your problem', $this->namespace), 60);
         //			}
         //			if(empty($_POST['support_body']))
         //			{
         //				$error=true;
         //				set_transient('error-support-body', __('Please enter your problem description', $this->namespace), 60);
         //			}
         $include_logs = true;
         //always send logs
         //			if(!empty($_POST['support_include_logs']))
         //			{
         //				$include_logs=true;
         //			}
         //Send if no errors
         if (!$error) {
             if (!class_exists('WPBackItUp_Zip')) {
                 include_once 'class-zip.php';
             }
             if (!class_exists('WPBackItUp_Utility')) {
                 include_once 'class-utility.php';
             }
             $support_request_id = time();
             $logs_attachment = array();
             //default to no logs
             if ($include_logs) {
                 $logs_path = WPBACKITUP__PLUGIN_PATH . 'logs';
                 //copy/replace WP debug file
                 $wpdebug_file_path = WPBACKITUP__CONTENT_PATH . '/debug.log';
                 $logger->log_info(__METHOD__, "Copy WP Debug: " . $wpdebug_file_path);
                 if (file_exists($wpdebug_file_path)) {
                     copy($wpdebug_file_path, $logs_path . '/wpdebug.log');
                 }
                 $zip_file_path = $logs_path . '/logs_' . $support_request_id . '.zip';
                 $zip = new WPBackItUp_Zip($logger, $zip_file_path);
                 $zip->zip_files_in_folder($logs_path, $support_request_id, '*.log');
                 $zip->close();
                 $logs_attachment = array($zip_file_path);
             }
             //Get registration name
             $utility = new WPBackItUp_Utility($logger);
             $support_to_address = WPBACKITUP__SUPPORT_EMAIL;
             //If we force registration then this will always be here.
             $from_name = $this->license_customer_name();
             $support_from_email = $_POST['support_email'];
             $support_subject = '[#' . trim($_POST['support_ticket_id']) . ']';
             $site_info = 'WordPress Site: <a href="' . home_url() . '" target="_blank">' . home_url() . '</a><br/>';
             $site_info .= "WordPress Version: " . get_bloginfo('version') . ' <br />';
             $site_info .= "WP BackItUp License Type: " . $this->license_type_description() . ' <br />';
             $site_info .= "WP BackItUp Version: " . $this->version . ' <br />';
             $support_body = $site_info . '<br/><br/><b>Customer Comments:</b><br/><br/>' . $_POST['support_body'];
             $utility->send_email_v2($support_to_address, $support_subject, $support_body, $logs_attachment, $from_name, $support_from_email, $support_from_email);
             // get rid of the transients
             foreach ($_POST as $key => $val) {
                 delete_transient($key);
             }
             wp_safe_redirect($url . '&s=1');
             exit;
         }
     }
     wp_safe_redirect($url);
     exit;
 }