示例#1
0
/**
 * Send the download file to the browser and then redirect back to the backups page
 */
function hmbkp_request_download_backup()
{
    check_admin_referer('hmbkp_download_backup', 'hmbkp_download_backup_nonce');
    if (!file_exists(sanitize_text_field(base64_decode($_GET['hmbkp_backup_archive'])))) {
        return;
    }
    $url = str_replace(HM\BackUpWordPress\Backup::conform_dir(HM\BackUpWordPress\Backup::get_home_path()), home_url(), trailingslashit(dirname(sanitize_text_field(base64_decode($_GET['hmbkp_backup_archive']))))) . urlencode(pathinfo(sanitize_text_field(base64_decode($_GET['hmbkp_backup_archive'])), PATHINFO_BASENAME));
    global $is_apache;
    if ($is_apache) {
        HM\BackUpWordPress\Path::get_instance()->protect_path('reset');
        $url = add_query_arg('key', HMBKP_SECURE_KEY, $url);
    }
    wp_safe_redirect($url, 303);
    die;
}
示例#2
0
			<td>

				<?php 
if (defined('HMBKP_ROOT')) {
    ?>
					<p><?php 
    printf(__('You\'ve set it to: %s', 'backupwordpress'), '<code>' . esc_html(HMBKP_ROOT) . '</code>');
    ?>
</p>
				<?php 
}
?>

				<p><?php 
printf(__('The root directory that is backed up. Defaults to %s.', 'backupwordpress'), '<code>' . HM\BackUpWordPress\Backup::get_home_path() . '</code>');
?>
 <?php 
_e('e.g.', 'backupwordpress');
?>
 <code>define( 'HMBKP_ROOT', ABSPATH . 'wp/' );</code></p>

			</td>

		</tr>

		<tr<?php 
if (defined('HMBKP_SCHEDULE_TIME') && HMBKP_SCHEDULE_TIME !== '11pm') {
    ?>
 class="hmbkp_active"<?php 
}
 function reload_backups()
 {
     $scheduleIds = isset($_POST['schedule_ids']) ? $_POST['schedule_ids'] : array();
     HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
     $all_schedules_ids = array();
     $schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
     foreach ($schedules as $sch) {
         $all_schedules_ids[] = $sch->get_id();
     }
     if (empty($all_schedules_ids)) {
         return array('error' => __("Not found schedules.", 'mainwp-child'));
     }
     foreach ($all_schedules_ids as $schedule_id) {
         if (!HM\BackUpWordPress\Schedules::get_instance()->get_schedule($schedule_id)) {
             continue;
         }
         $schedule = new HM\BackUpWordPress\Scheduled_Backup(sanitize_text_field(urldecode($schedule_id)));
         $out = array('b' => $this->get_backupslist_html($schedule), 'count' => count($schedule->get_backups()), 'file_size_text' => $this->hmbkp_get_site_size_text($schedule), 'scheduleStatus' => $schedule->get_status(), 'started_ago' => human_time_diff($schedule->get_schedule_running_start_time()));
         $information['backups'][$schedule_id] = $out;
     }
     $send_back_schedules = array();
     $schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
     foreach ($schedules as $schedule) {
         $sch_id = $schedule->get_id();
         if (!in_array($sch_id, $scheduleIds)) {
             $current_option = get_option('hmbkp_schedule_' . $sch_id);
             if (is_array($current_option)) {
                 unset($current_option['excludes']);
                 // not send this value
                 $send_back_schedules[$sch_id] = array('options' => $current_option, 'b' => $this->get_backupslist_html($schedule), 'count' => count($schedule->get_backups()), 'file_size_text' => $this->hmbkp_get_site_size_text($schedule), 'scheduleStatus' => $schedule->get_status(), 'started_ago' => human_time_diff($schedule->get_schedule_running_start_time()));
             }
         }
     }
     $information['backups_path'] = str_replace(HM\BackUpWordPress\Backup::get_home_path(), '', hmbkp_path());
     $information['send_back_schedules'] = $send_back_schedules;
     $information['result'] = 'SUCCESS';
     return $information;
 }
示例#4
0
function hmbkp_is_path_accessible($dir)
{
    // Path is inaccessible
    if (strpos($dir, HM\BackUpWordPress\Backup::get_home_path()) === false) {
        return false;
    }
    return true;
}
        break;
    case 'hmbkp_fortnightly':
        $reoccurrence = sprintf(__('biweekly on %1$s at %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . $day . '</span>', '<span>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>');
        break;
    case 'hmbkp_monthly':
        $reoccurrence = sprintf(__('on the %1$s of each month at %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . esc_html(date_i18n('jS', $schedule->get_next_occurrence(false))) . '</span>', '<span>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>');
        break;
    case 'manually':
        $reoccurrence = __('manually', 'backupwordpress');
        break;
    default:
        $reoccurrence = __('manually', 'backupwordpress');
        $schedule->set_reoccurrence('manually');
}
$server = '<span title="' . esc_attr(hmbkp_path()) . '">' . __('this server', 'backupwordpress') . '</span>';
$server = '<code>' . esc_attr(str_replace(HM\BackUpWordPress\Backup::get_home_path(), '', hmbkp_path())) . '</code>';
// Backup to keep
switch ($schedule->get_max_backups()) {
    case 1:
        $backup_to_keep = sprintf(__('store the most recent backup in %s', 'backupwordpress'), $server);
        break;
    case 0:
        $backup_to_keep = sprintf(__('don\'t store any backups in on this server', 'backupwordpress'), hmbkp_path());
        break;
    default:
        $backup_to_keep = sprintf(__('store the last %1$s backups in %2$s', 'backupwordpress'), esc_html($schedule->get_max_backups()), $server);
}
$email_msg = $services = '';
foreach (HM\BackUpWordPress\Services::get_services($schedule) as $file => $service) {
    if ('Email' === $service->name) {
        $email_msg = wp_kses_post($service->display());