コード例 #1
0
function backwpup_cron()
{
    if (is_file(backwpup_get_temp() . '.running')) {
        $cfg = get_option('backwpup');
        $revtime = time() - 600;
        //10 min no progress.
        $infile = backwpup_get_working_file();
        $httpauthheader = '';
        if (!empty($cfg['httpauthuser']) and !empty($cfg['httpauthpassword'])) {
            $httpauthheader = array('Authorization' => 'Basic ' . base64_encode($cfg['httpauthuser'] . ':' . base64_decode($cfg['httpauthpassword'])));
        }
        if (!empty($infile['timestamp']) and $infile['timestamp'] < $revtime) {
            wp_remote_post(BACKWPUP_PLUGIN_BASEURL . '/job/job_run.php', array('timeout' => 3, 'blocking' => false, 'sslverify' => false, 'headers' => $httpauthheader, 'body' => array('BackWPupJobTemp' => backwpup_get_temp(), 'nonce' => $infile['WORKING']['NONCE'], 'type' => 'restarttime'), 'user-agent' => 'BackWPup'));
        }
    } else {
        $jobs = get_option('backwpup_jobs');
        if (!empty($jobs)) {
            foreach ($jobs as $jobid => $jobvalue) {
                if (!isset($jobvalue['activated']) or !$jobvalue['activated']) {
                    continue;
                }
                if ($jobvalue['cronnextrun'] <= current_time('timestamp')) {
                    require_once dirname(__FILE__) . '/job/job_start.php';
                    backwpup_jobstart($jobid, true);
                }
            }
        }
    }
}
コード例 #2
0
<?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'));