예제 #1
0
 /**
  * Start job if in cron and run query args are set.
  */
 public static function cron_active()
 {
     //only if cron active
     if (!defined('DOING_CRON') || !DOING_CRON) {
         return;
     }
     //only work if backwpup_run as query var ist set and nothing else and the value ist right
     if (empty($_GET['backwpup_run']) || !in_array($_GET['backwpup_run'], array('test', 'restart', 'runnow', 'runnowalt', 'runext', 'cronrun'))) {
         return;
     }
     //special header
     @session_write_close();
     @header('Content-Type: text/html; charset=' . get_bloginfo('charset'), TRUE);
     @header('X-Robots-Tag: noindex, nofollow', TRUE);
     @header('X-BackWPup-Version: ' . BackWPup::get_plugin_data('version'), TRUE);
     nocache_headers();
     //on test die for fast feedback
     if ($_GET['backwpup_run'] == 'test') {
         die('BackWPup Test');
     }
     // generate normal nonce
     $nonce = substr(wp_hash(wp_nonce_tick() . 'backwpup_job_run-' . $_GET['backwpup_run'], 'nonce'), -12, 10);
     //special nonce on external start
     if ($_GET['backwpup_run'] == 'runext') {
         $nonce = get_site_option('backwpup_cfg_jobrunauthkey');
     }
     // check nonce
     if (empty($_GET['_nonce']) || $nonce != $_GET['_nonce']) {
         return;
     }
     //check runext is allowed for job
     if ($_GET['backwpup_run'] == 'runext') {
         $jobids_external = BackWPup_Option::get_job_ids('activetype', 'link');
         if (!isset($_GET['jobid']) || !in_array($_GET['jobid'], $jobids_external)) {
             return;
         }
     }
     //run BackWPup job
     BackWPup_Job::start_http($_GET['backwpup_run']);
     die;
 }
예제 #2
0
 /**
  * Start job if in cron and run query args are set.
  */
 public static function cron_active($args = array())
 {
     //only if cron active
     if (!defined('DOING_CRON') || !DOING_CRON) {
         return;
     }
     if (isset($_GET['backwpup_run'])) {
         $args['run'] = sanitize_text_field($_GET['backwpup_run']);
     }
     if (isset($_GET['_nonce'])) {
         $args['nonce'] = sanitize_text_field($_GET['_nonce']);
     }
     if (isset($_GET['jobid'])) {
         $args['jobid'] = absint($_GET['jobid']);
     }
     $args = array_merge(array('run' => '', 'nonce' => '', 'jobid' => 0), $args);
     if (!in_array($args['run'], array('test', 'restart', 'runnow', 'runnowalt', 'runext', 'cronrun'), true)) {
         return;
     }
     //special header
     @session_write_close();
     @header('Content-Type: text/html; charset=' . get_bloginfo('charset'), true);
     @header('X-Robots-Tag: noindex, nofollow', true);
     nocache_headers();
     //on test die for fast feedback
     if ($args['run'] === 'test') {
         die('BackWPup test request');
     }
     if ($args['run'] === 'restart') {
         $job_object = BackWPup_Job::get_working_data();
         //restart job if not working or a restart wished
         $not_worked_time = microtime(TRUE) - $job_object->timestamp_last_update;
         if (!$job_object->pid || $not_worked_time > 300) {
             BackWPup_Job::start_http('restart');
             return;
         }
     }
     // generate normal nonce
     $nonce = substr(wp_hash(wp_nonce_tick() . 'backwpup_job_run-' . $args['run'], 'nonce'), -12, 10);
     //special nonce on external start
     if ($args['run'] === 'runext') {
         $nonce = get_site_option('backwpup_cfg_jobrunauthkey');
     }
     if ($args['run'] === 'cronrun') {
         $nonce = '';
     }
     // check nonce
     if ($nonce !== $args['nonce']) {
         return;
     }
     //check runext is allowed for job
     if ($args['run'] === 'runext') {
         $jobids_link = BackWPup_Option::get_job_ids('activetype', 'link');
         $jobids_easycron = BackWPup_Option::get_job_ids('activetype', 'easycron');
         $jobids_external = array_merge($jobids_link, $jobids_easycron);
         if (!in_array($args['jobid'], $jobids_external, true)) {
             return;
         }
     }
     //run BackWPup job
     BackWPup_Job::start_http($args['run'], $args['jobid']);
 }