}
    if (empty($cfg['jobscriptretry']) or !is_int($cfg['jobscriptretry'])) {
        $cfg['jobscriptretry'] = 5;
    }
    $cfg['maxlogs'] = abs((int) $_POST['maxlogs']);
    $cfg['gzlogs'] = isset($_POST['gzlogs']) ? true : false;
    $cfg['phpzip'] = isset($_POST['phpzip']) ? true : false;
    $cfg['apicronservice'] = isset($_POST['apicronservice']) ? true : false;
    $cfg['httpauthuser'] = $_POST['httpauthuser'];
    $cfg['httpauthpassword'] = base64_encode($_POST['httpauthpassword']);
    $cfg['dirlogs'] = trailingslashit(str_replace('//', '/', str_replace('\\', '/', stripslashes(trim($_POST['dirlogs'])))));
    //set def. folders
    if (!isset($cfg['dirlogs']) or $cfg['dirlogs'] == '/' or empty($cfg['dirlogs'])) {
        $rand = substr(md5(md5(SECURE_AUTH_KEY)), -5);
        $cfg['dirlogs'] = str_replace('\\', '/', trailingslashit(WP_CONTENT_DIR)) . 'backwpup-' . $rand . '-logs/';
    }
    if (substr($cfg['dirlogs'], 0, 1) != '/' and substr($cfg['dirlogs'], 1, 1) != ':') {
        //add abspath if not absolute
        $cfg['dirlogs'] = rtrim(str_replace('\\', '/', ABSPATH), '/') . '/' . $cfg['dirlogs'];
    }
    if (!isset($cfg['mailsendmail']) or empty($cfg['mailsendmail'])) {
        $cfg['mailsendmail'] = substr(ini_get('sendmail_path'), 0, strpos(ini_get('sendmail_path'), ' -'));
    }
    if (update_option('backwpup', $cfg)) {
        $backwpup_message = __('Settings saved', 'backwpup');
    }
    backwpup_api(true);
}
//add Help
backwpup_contextual_help();
                    header("Content-Transfer-Encoding: binary");
                    header("Content-Length: " . $backupfile->content_length);
                    $output = fopen("php://output", "w");
                    $backupfile->stream($output);
                    fclose($output);
                    die;
                } else {
                    header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
                    header("Status: 404 Not Found");
                    die;
                }
            } catch (Exception $e) {
                die($e->getMessage());
            }
            break;
    }
}
//Save per page
if (isset($_POST['screen-options-apply']) and isset($_POST['wp_screen_options']['option']) and isset($_POST['wp_screen_options']['value']) and $_POST['wp_screen_options']['option'] == 'backwpupbackups_per_page') {
    check_admin_referer('screen-options-nonce', 'screenoptionnonce');
    global $current_user;
    if ($_POST['wp_screen_options']['value'] > 0 and $_POST['wp_screen_options']['value'] < 1000) {
        update_user_option($current_user->ID, 'backwpupbackups_per_page', (int) $_POST['wp_screen_options']['value']);
        wp_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
        exit;
    }
}
//add Help
backwpup_contextual_help(__('Here you see a list of backup files. Change the destionation to jobname:destination to become a list of backups from other destinations and jobs. Then you kann delete or download backup files.', 'backwpup'));
add_screen_option('per_page', array('label' => __('Logs', 'backwpup'), 'default' => 20, 'option' => 'backwpupbackups_per_page'));
$backwpup_listtable->prepare_items();
//add several metaboxes now, all metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
add_meta_box('backwpup_jobedit_backupfile', __('Backup File', 'backwpup'), 'backwpup_jobedit_metabox_backupfile', $current_screen->id, 'side', 'default');
add_meta_box('backwpup_jobedit_sendlog', __('Send log', 'backwpup'), 'backwpup_jobedit_metabox_sendlog', $current_screen->id, 'side', 'default');
add_meta_box('backwpup_jobedit_destfolder', __('Backup to Folder', 'backwpup'), 'backwpup_jobedit_metabox_destfolder', $current_screen->id, 'advanced', 'core');
add_meta_box('backwpup_jobedit_destmail', __('Backup to E-Mail', 'backwpup'), 'backwpup_jobedit_metabox_destmail', $current_screen->id, 'advanced', 'core');
if (in_array('FTP', $dests)) {
    add_meta_box('backwpup_jobedit_destftp', __('Backup to FTP Server', 'backwpup'), 'backwpup_jobedit_metabox_destftp', $current_screen->id, 'advanced', 'default');
}
if (in_array('DROPBOX', $dests)) {
    add_meta_box('backwpup_jobedit_destdropbox', __('Backup to Dropbox', 'backwpup'), 'backwpup_jobedit_metabox_destdropbox', $current_screen->id, 'advanced', 'default');
}
if (in_array('SUGARSYNC', $dests)) {
    add_meta_box('backwpup_jobedit_destsugarsync', __('Backup to SugarSync', 'backwpup'), 'backwpup_jobedit_metabox_destsugarsync', $current_screen->id, 'advanced', 'default');
}
if (in_array('S3', $dests)) {
    add_meta_box('backwpup_jobedit_dests3', __('Backup to Amazon S3', 'backwpup'), 'backwpup_jobedit_metabox_dests3', $current_screen->id, 'advanced', 'default');
}
if (in_array('GSTORAGE', $dests)) {
    add_meta_box('backwpup_jobedit_destgstorage', __('Backup to Google storage', 'backwpup'), 'backwpup_jobedit_metabox_destgstorage', $current_screen->id, 'advanced', 'default');
}
if (in_array('MSAZURE', $dests)) {
    add_meta_box('backwpup_jobedit_destazure', __('Backup to Micosoft Azure (Blob)', 'backwpup'), 'backwpup_jobedit_metabox_destazure', $current_screen->id, 'advanced', 'default');
}
if (in_array('RSC', $dests)) {
    add_meta_box('backwpup_jobedit_destrsc', __('Backup to Rackspace Cloud', 'backwpup'), 'backwpup_jobedit_metabox_destrsc', $current_screen->id, 'advanced', 'default');
}
//add clumns
add_screen_option('layout_columns', array('max' => 2, 'default' => 2));
//add Help
backwpup_contextual_help(__('', 'backwpup'));
Example #4
0
                        break;
                    }
                    $filepos = ftell($fd);
                }
                fclose($fd);
            }
            $backwpup_message = __('Job will be terminated.', 'backwpup') . '<br />';
            if (!empty($runningfile['WORKING']['PID']) and function_exists('posix_kill')) {
                if (posix_kill($runningfile['WORKING']['PID'], 9)) {
                    $backwpup_message .= __('Process killed with PID:', 'backwpup') . ' ' . $runningfile['WORKING']['PID'];
                } else {
                    $backwpup_message .= __('Can\'t kill process with PID:', 'backwpup') . ' ' . $runningfile['WORKING']['PID'];
                }
            }
            //update job settings
            if (!empty($runningfile['JOBID'])) {
                $jobs = get_option('backwpup_jobs');
                if (isset($newlogfile) and !empty($newlogfile)) {
                    $jobs[$runningfile['JOBID']]['logfile'] = $newlogfile;
                }
                $jobs[$runningfile['JOBID']]['lastrun'] = $jobs[$runningfile['JOBID']]['starttime'];
                $jobs[$runningfile['JOBID']]['lastruntime'] = $runningfile['timestamp'] - $jobs[$runningfile['JOBID']]['starttime'];
                update_option('backwpup_jobs', $jobs);
                //Save Settings
            }
            break;
    }
}
//add Help
backwpup_contextual_help(__('Here is the job overview with some information. You can see some further information of the jobs, how many can be switched with the view button. Also you can manage the jobs or abbort working jobs. Some links are added to have direct access to the last log or download.', 'backwpup'));
$backwpup_listtable->prepare_items();
<?php

if (!defined('ABSPATH')) {
    die;
}
nocache_headers();
//no chache
if (isset($_GET['action']) and $_GET['action'] == 'runnow' and !empty($_GET['jobid'])) {
    $jobid = (int) $_GET['jobid'];
    check_admin_referer('runnow-job_' . $jobid);
    if ($infile = backwpup_get_working_file()) {
        $backwpup_message = __('A job alredy running!!! Pleace try again if its done.', 'backwpup');
        $_GET['logfile'] = $infile['LOGFILE'];
    } else {
        //include jobstart function
        require_once dirname(__FILE__) . '/../job/job_start.php';
        $_GET['logfile'] = backwpup_jobstart($jobid, false);
    }
} elseif (!empty($_GET['logfile'])) {
    check_admin_referer('view-log_' . basename(trim($_GET['logfile'])));
} elseif ($infile = backwpup_get_working_file()) {
    $backwpup_message = __('A job is running!!!', 'backwpup');
    $_GET['logfile'] = $infile['LOGFILE'];
} elseif (!isset($_GET['action']) and !isset($_GET['logfile']) and empty($backwpup_message)) {
    $backwpup_message = __('Nothing...', 'backwpup');
    $_GET['logfile'] = '';
}
//add Help
backwpup_contextual_help(__('Here you see working jobs or logfiles', 'backwpup'));
                header("Expires: 0");
                header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                header("Content-Type: application/force-download");
                header("Content-Type: application/octet-stream");
                header("Content-Type: application/download");
                header("Content-Disposition: attachment; filename=" . basename(trim($_GET['file'])) . ";");
                header("Content-Transfer-Encoding: binary");
                header("Content-Length: " . filesize(trim($_GET['file'])));
                @readfile(trim($_GET['file']));
                die;
            } else {
                header('HTTP/1.0 404 Not Found');
                die;
            }
            break;
    }
}
//Save per page
if (isset($_POST['screen-options-apply']) and isset($_POST['wp_screen_options']['option']) and isset($_POST['wp_screen_options']['value']) and $_POST['wp_screen_options']['option'] == 'backwpuplogs_per_page') {
    check_admin_referer('screen-options-nonce', 'screenoptionnonce');
    global $current_user;
    if ($_POST['wp_screen_options']['value'] > 0 and $_POST['wp_screen_options']['value'] < 1000) {
        update_user_option($current_user->ID, 'backwpuplogs_per_page', (int) $_POST['wp_screen_options']['value']);
        wp_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
        exit;
    }
}
//add Help
backwpup_contextual_help(__('Here you can manage the log files of the jobs. You can download, view, or delete them.', 'backwpup'));
add_screen_option('per_page', array('label' => __('Logs', 'backwpup'), 'default' => 20, 'option' => 'backwpuplogs_per_page'));
$backwpup_listtable->prepare_items();