本文整理汇总了PHP中BackWPup_Option::get_job_ids方法的典型用法代码示例。如果您正苦于以下问题:PHP BackWPup_Option::get_job_ids方法的具体用法?PHP BackWPup_Option::get_job_ids怎么用?PHP BackWPup_Option::get_job_ids使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BackWPup_Option
的用法示例。
在下文中一共展示了BackWPup_Option::get_job_ids方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: jobs
/**
* Display a List of Jobs
*
* @synopsis jobs
*/
public function jobs($args, $assoc_args)
{
$jobids = BackWPup_Option::get_job_ids();
WP_CLI::line(__('List of jobs', 'backwpup'));
WP_CLI::line('----------------------------------------------------------------------');
foreach ($jobids as $jobid) {
WP_CLI::line(sprintf(__('ID: %1$d Name: %2$s', 'backwpup'), $jobid, BackWPup_Option::get($jobid, 'name')));
}
}
示例2: jobs
/**
* Display a List of Jobs
*
*/
public function jobs($args, $assoc_args)
{
$formatter_args = array('format' => 'table', 'fields' => array('Job ID', 'Name'), 'field' => NULL);
$items = array();
$formatter = new WP_CLI\Formatter($formatter_args);
$jobids = BackWPup_Option::get_job_ids();
foreach ($jobids as $jobid) {
$items[] = array('Job ID' => $jobid, 'Name' => BackWPup_Option::get($jobid, 'name'));
}
$formatter->display_items($items);
}
示例3: deactivate
/**
*
* Cleanup on Plugin deactivation
*
* @return void
*/
public static function deactivate()
{
wp_clear_scheduled_hook('backwpup_cron');
$activejobs = BackWPup_Option::get_job_ids('activetype', 'wpcron');
if (!empty($activejobs)) {
foreach ($activejobs as $id) {
wp_clear_scheduled_hook('backwpup_cron', array('id' => $id));
}
}
wp_clear_scheduled_hook('backwpup_check_cleanup');
//to reschedule on activation and so on
update_site_option('backwpup_version', BackWPup::get_plugin_data('version') . '-inactive');
}
示例4: adminbar
/**
* @global $wp_admin_bar WP_Admin_Bar
*/
public function adminbar()
{
global $wp_admin_bar;
/* @var WP_Admin_Bar $wp_admin_bar */
$menu_title = '<span class="ab-icon"></span><span class="ab-label">' . BackWPup::get_plugin_data('name') . '</span>';
$menu_herf = network_admin_url('admin.php') . '?page=backwpup';
if (file_exists(BackWPup::get_plugin_data('running_file')) && current_user_can('backwpup_jobs_start')) {
$menu_title = '<span class="ab-icon"></span><span class="ab-label">' . BackWPup::get_plugin_data('name') . ' <span id="backwpup-adminbar-running">' . __('running', 'backwpup') . '</span></span>';
$menu_herf = network_admin_url('admin.php') . '?page=backwpupjobs';
}
if (current_user_can('backwpup')) {
$wp_admin_bar->add_menu(array('id' => 'backwpup', 'title' => $menu_title, 'href' => $menu_herf, 'meta' => array('title' => BackWPup::get_plugin_data('name'))));
}
if (file_exists(BackWPup::get_plugin_data('running_file')) && current_user_can('backwpup_jobs_start')) {
$wp_admin_bar->add_menu(array('id' => 'backwpup_working', 'parent' => 'backwpup_jobs', 'title' => __('Now Running', 'backwpup'), 'href' => network_admin_url('admin.php') . '?page=backwpupjobs'));
$wp_admin_bar->add_menu(array('id' => 'backwpup_working_abort', 'parent' => 'backwpup_working', 'title' => __('Abort!', 'backwpup'), 'href' => wp_nonce_url(network_admin_url('admin.php') . '?page=backwpup&action=abort', 'abort-job')));
}
if (current_user_can('backwpup_jobs')) {
$wp_admin_bar->add_menu(array('id' => 'backwpup_jobs', 'parent' => 'backwpup', 'title' => __('Jobs', 'backwpup'), 'href' => network_admin_url('admin.php') . '?page=backwpupjobs'));
}
if (current_user_can('backwpup_jobs_edit')) {
$wp_admin_bar->add_menu(array('id' => 'backwpup_jobs_new', 'parent' => 'backwpup_jobs', 'title' => __('Add new', 'backwpup'), 'href' => network_admin_url('admin.php') . '?page=backwpupeditjob&tab=job'));
}
if (current_user_can('backwpup_logs')) {
$wp_admin_bar->add_menu(array('id' => 'backwpup_logs', 'parent' => 'backwpup', 'title' => __('Logs', 'backwpup'), 'href' => network_admin_url('admin.php') . '?page=backwpuplogs'));
}
if (current_user_can('backwpup_backups')) {
$wp_admin_bar->add_menu(array('id' => 'backwpup_backups', 'parent' => 'backwpup', 'title' => __('Backups', 'backwpup'), 'href' => network_admin_url('admin.php') . '?page=backwpupbackups'));
}
//add jobs
$jobs = (array) BackWPup_Option::get_job_ids();
foreach ($jobs as $jobid) {
if (current_user_can('backwpup_jobs_edit')) {
$name = BackWPup_Option::get($jobid, 'name');
$wp_admin_bar->add_menu(array('id' => 'backwpup_jobs_' . $jobid, 'parent' => 'backwpup_jobs', 'title' => $name, 'href' => wp_nonce_url(network_admin_url('admin.php') . '?page=backwpupeditjob&tab=job&jobid=' . $jobid, 'edit-job')));
}
if (current_user_can('backwpup_jobs_start')) {
$url = BackWPup_Job::get_jobrun_url('runnowlink', $jobid);
$wp_admin_bar->add_menu(array('id' => 'backwpup_jobs_runnow_' . $jobid, 'parent' => 'backwpup_jobs_' . $jobid, 'title' => __('Run Now', 'backwpup'), 'href' => $url['url']));
}
}
}
示例5: mb_next_jobs
/**
* Displaying next jobs
*/
private static function mb_next_jobs()
{
if (!current_user_can('backwpup_jobs')) {
return;
}
?>
<table class="wp-list-table widefat" cellspacing="0">
<caption><?php
_e('Next scheduled jobs', 'backwpup');
?>
</caption>
<thead>
<tr>
<th style="width: 30%"><?php
_e('Time', 'backwpup');
?>
</th>
<th style="width: 70%"><?php
_e('Job', 'backwpup');
?>
</th>
</tr>
</thead>
<?php
//get next jobs
$mainsactive = BackWPup_Option::get_job_ids('activetype', 'wpcron');
sort($mainsactive);
$alternate = TRUE;
// add working job if it not in active jobs
$job_object = BackWPup_Job::get_working_data();
if (!empty($job_object) && !empty($job_object->job['jobid']) && !in_array($job_object->job['jobid'], $mainsactive)) {
$mainsactive[] = $job_object->job['jobid'];
}
foreach ($mainsactive as $jobid) {
$name = BackWPup_Option::get($jobid, 'name');
if (!empty($job_object) && $job_object->job['jobid'] == $jobid) {
$runtime = current_time('timestamp') - $job_object->job['lastrun'];
if (!$alternate) {
echo '<tr>';
$alternate = TRUE;
} else {
echo '<tr class="alternate">';
$alternate = FALSE;
}
echo '<td>' . sprintf('<span style="color:#e66f00;">' . __('working since %d seconds', 'backwpup') . '</span>', $runtime) . '</td>';
echo '<td><span style="font-weight:bold;">' . esc_html($job_object->job['name']) . '</span><br />';
echo "<a style=\"color:red;\" href=\"" . wp_nonce_url(network_admin_url('admin.php') . '?page=backwpupjobs&action=abort', 'abort-job') . "\">" . __('Abort', 'backwpup') . "</a>";
echo "</td></tr>";
} else {
if (!$alternate) {
echo '<tr>';
$alternate = TRUE;
} else {
echo '<tr class="alternate">';
$alternate = FALSE;
}
if ($nextrun = wp_next_scheduled('backwpup_cron', array('id' => $jobid)) + get_option('gmt_offset') * 3600) {
echo '<td>' . sprintf(__('%1$s at %2$s', 'backwpup'), date_i18n(get_option('date_format'), $nextrun, TRUE), date_i18n(get_option('time_format'), $nextrun, TRUE)) . '</td>';
} else {
echo '<td><em>' . __('Not scheduled!', 'backwpup') . '</em></td>';
}
echo '<td><a href="' . wp_nonce_url(network_admin_url('admin.php') . '?page=backwpupeditjob&jobid=' . $jobid, 'edit-job') . '" title="' . esc_attr(__('Edit Job', 'backwpup')) . '">' . $name . '</a></td></tr>';
}
}
if (empty($mainsactive) and !empty($job_object)) {
echo '<tr><td colspan="2"><i>' . __('none', 'backwpup') . '</i></td></tr>';
}
?>
</table>
<?php
}
示例6: load
/**
*
*/
public static function load()
{
//Create Table
self::$listtable = new self();
switch (self::$listtable->current_action()) {
case 'delete':
//Delete Job
if (!current_user_can('backwpup_jobs_edit')) {
break;
}
if (is_array($_GET['jobs'])) {
check_admin_referer('bulk-jobs');
foreach ($_GET['jobs'] as $jobid) {
wp_clear_scheduled_hook('backwpup_cron', array('id' => absint($jobid)));
BackWPup_Option::delete_job(absint($jobid));
}
}
break;
case 'copy':
//Copy Job
if (!current_user_can('backwpup_jobs_edit')) {
break;
}
$old_job_id = absint($_GET['jobid']);
check_admin_referer('copy-job_' . $old_job_id);
//create new
$newjobid = BackWPup_Option::get_job_ids();
sort($newjobid);
$newjobid = end($newjobid) + 1;
$old_options = BackWPup_Option::get_job($old_job_id);
foreach ($old_options as $key => $option) {
if ($key === "jobid") {
$option = $newjobid;
}
if ($key === "name") {
$option = __('Copy of', 'backwpup') . ' ' . $option;
}
if ($key === "activetype") {
$option = '';
}
if ($key === "archivename") {
$option = str_replace($old_job_id, $newjobid, $option);
}
if ($key === "logfile" || $key === "lastbackupdownloadurl" || $key === "lastruntime" || $key === "lastrun") {
continue;
}
BackWPup_Option::update($newjobid, $key, $option);
}
break;
case 'runnow':
$jobid = absint($_GET['jobid']);
if ($jobid) {
if (!current_user_can('backwpup_jobs_start')) {
wp_die(__('Sorry, you don\'t have permissions to do that.', 'backwpup'));
}
check_admin_referer('backwpup_job_run-runnowlink');
//check temp folder
$temp_folder_message = BackWPup_File::check_folder(BackWPup::get_plugin_data('TEMP'), TRUE);
BackWPup_Admin::message($temp_folder_message, TRUE);
//check log folder
$log_folder = get_site_option('backwpup_cfg_logfolder');
$log_folder = BackWPup_File::get_absolute_path($log_folder);
$log_folder_message = BackWPup_File::check_folder($log_folder);
BackWPup_Admin::message($log_folder_message, TRUE);
//check backup destinations
$job_types = BackWPup::get_job_types();
$job_conf_types = BackWPup_Option::get($jobid, 'type');
$creates_file = FALSE;
foreach ($job_types as $id => $job_type_class) {
if (in_array($id, $job_conf_types, true) && $job_type_class->creates_file()) {
$creates_file = TRUE;
break;
}
}
if ($creates_file) {
$job_conf_dests = BackWPup_Option::get($jobid, 'destinations');
$destinations = 0;
/* @var BackWPup_Destinations $dest_class */
foreach (BackWPup::get_registered_destinations() as $id => $dest) {
if (!in_array($id, $job_conf_dests, true) || empty($dest['class'])) {
continue;
}
$dest_class = BackWPup::get_destination($id);
$job_settings = BackWPup_Option::get_job($jobid);
if (!$dest_class->can_run($job_settings)) {
BackWPup_Admin::message(sprintf(__('The job "%s" destination "%s" is not configured properly', 'backwpup'), esc_attr(BackWPup_Option::get($jobid, 'name')), $id), TRUE);
}
$destinations++;
}
if ($destinations < 1) {
BackWPup_Admin::message(sprintf(__('The job "%s" needs properly configured destinations to run!', 'backwpup'), esc_attr(BackWPup_Option::get($jobid, 'name'))), TRUE);
}
}
//only start job if messages empty
$log_messages = BackWPup_Admin::get_messages();
if (empty($log_messages)) {
$old_log_file = BackWPup_Option::get($jobid, 'logfile');
//.........这里部分代码省略.........
示例7: cron_active
/**
* 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;
}
示例8: deactivate
/**
*
* Cleanup on Plugin deactivation
*
* @return void
*/
public static function deactivate()
{
wp_clear_scheduled_hook('backwpup_cron');
$activejobs = BackWPup_Option::get_job_ids('activetype', 'wpcron');
if (!empty($activejobs)) {
foreach ($activejobs as $id) {
wp_clear_scheduled_hook('backwpup_cron', array('id' => $id));
}
}
wp_clear_scheduled_hook('backwpup_check_cleanup');
$activejobs = BackWPup_Option::get_job_ids('activetype', 'easycron');
if (!empty($activejobs)) {
foreach ($activejobs as $id) {
BackWPup_EasyCron::delete($id);
}
}
//remove roles
remove_role('backwpup_admin');
remove_role('backwpup_helper');
remove_role('backwpup_check');
//remove capabilities to administrator role
$role = get_role('administrator');
if (is_object($role) && method_exists($role, 'remove_cap')) {
$role->remove_cap('backwpup');
$role->remove_cap('backwpup_jobs');
$role->remove_cap('backwpup_jobs_edit');
$role->remove_cap('backwpup_jobs_start');
$role->remove_cap('backwpup_backups');
$role->remove_cap('backwpup_backups_download');
$role->remove_cap('backwpup_backups_delete');
$role->remove_cap('backwpup_logs');
$role->remove_cap('backwpup_logs_delete');
$role->remove_cap('backwpup_settings');
}
//to reschedule on activation and so on
update_site_option('backwpup_version', get_site_option('backwpup_version') . '-inactive');
}
示例9: insert_or_update_jobs
protected function insert_or_update_jobs()
{
$settings = $_POST['settings'];
if (!is_array($settings) || !isset($settings['value'])) {
return array('error' => __('Missing array settings', $this->plugin_translate));
}
if (!isset($settings['tab'])) {
return array('error' => __('Missing tab', $this->plugin_translate));
}
if (!isset($settings['job_id'])) {
return array('error' => __('Missing job id', $this->plugin_translate));
}
if (!class_exists('BackWPup')) {
return array('error' => __('Install BackWPup on child website', $this->plugin_translate));
}
if ($settings['job_id'] > 0) {
$job_id = intval($settings['job_id']);
} else {
//generate jobid if not exists
$newjobid = BackWPup_Option::get_job_ids();
sort($newjobid);
$job_id = end($newjobid) + 1;
}
update_site_option('backwpup_messages', array());
foreach ($settings['value'] as $key => $val) {
$_POST[$key] = $val;
}
BackWPup_Page_Editjob::save_post_form($settings['tab'], $job_id);
$return = $this->check_backwpup_messages();
if (isset($return['error'])) {
return array('success' => 1, 'error_message' => __('Cannot save jobs: ' . $return['error'], $this->plugin_translate));
}
if (isset($settings['value']['sugarrefreshtoken'])) {
BackWPup_Option::update($job_id, 'sugarrefreshtoken', $settings['value']['sugarrefreshtoken']);
}
if (isset($settings['value']['gdriverefreshtoken'])) {
BackWPup_Option::update($job_id, 'gdriverefreshtoken', $settings['value']['gdriverefreshtoken']);
}
if (isset($settings['value']['dbdumpspecialsetalltables']) && $settings['value']['dbdumpspecialsetalltables']) {
BackWPup_Option::update($job_id, 'dbdumpexclude', array());
}
if (isset($settings['value']['dropboxtoken']) && isset($settings['value']['dropboxroot'])) {
BackWPup_Option::update($job_id, 'dropboxtoken', $settings['value']['dropboxtoken']);
BackWPup_Option::update($job_id, 'dropboxroot', $settings['value']['dropboxroot']);
}
$changes_array = array();
foreach ($settings['value'] as $key => $val) {
$temp_value = BackWPup_Option::get($job_id, $key);
if (is_string($temp_value)) {
if (isset($this->exclusions[$settings['tab']])) {
if (!in_array($key, $this->exclusions[$settings['tab']]) && strcmp($temp_value, $val) != 0) {
$changes_array[$key] = $temp_value;
}
} else {
if (strcmp($temp_value, $val) != 0) {
$changes_array[$key] = $temp_value;
}
}
}
}
return array('success' => 1, 'job_id' => $job_id, 'changes' => $changes_array, 'message' => $return['message']);
}
示例10: cron_active
/**
* 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']);
}
示例11: get_destinations_list
/**
* @return array
*/
function get_destinations_list()
{
$jobdest = array();
$jobids = BackWPup_Option::get_job_ids();
if (!empty($jobids)) {
foreach ($jobids as $jobid) {
if (BackWPup_Option::get($jobid, 'backuptype') == 'sync') {
// jump over sync
continue;
}
$dests = BackWPup_Option::get($jobid, 'destinations');
foreach ($dests as $dest) {
if (empty($this->destinations[$dest]['class'])) {
continue;
}
$dest_class = BackWPup::get_destination($dest);
$can_do_dest = $dest_class->file_get_list($jobid . '_' . $dest);
if (!empty($can_do_dest)) {
$jobdest[] = $jobid . '_' . $dest;
}
}
}
}
return $jobdest;
}
示例12: load
/**
*
*/
public static function load()
{
//Create Table
self::$listtable = new self();
switch (self::$listtable->current_action()) {
case 'delete':
//Delete Job
if (!current_user_can('backwpup_jobs_edit')) {
break;
}
if (is_array($_GET['jobs'])) {
check_admin_referer('bulk-jobs');
foreach ($_GET['jobs'] as $jobid) {
wp_clear_scheduled_hook('backwpup_cron', array('id' => $jobid));
BackWPup_Option::delete_job($jobid);
}
}
break;
case 'copy':
//Copy Job
if (!current_user_can('backwpup_jobs_edit')) {
break;
}
$old_job_id = (int) $_GET['jobid'];
check_admin_referer('copy-job_' . $_GET['jobid']);
//create new
$newjobid = BackWPup_Option::get_job_ids();
sort($newjobid);
$newjobid = end($newjobid) + 1;
$old_options = BackWPup_Option::get_job($old_job_id);
foreach ($old_options as $key => $option) {
if ($key == "jobid") {
$option = $newjobid;
}
if ($key == "name") {
$option = __('Copy of', 'backwpup') . ' ' . $option;
}
if ($key == "activetype") {
$option = '';
}
if ($key == "archivename") {
$option = str_replace($_GET['jobid'], $newjobid, $option);
}
if ($key == "logfile" || $key == "lastbackupdownloadurl" || $key == "lastruntime" || $key == "lastrun") {
continue;
}
BackWPup_Option::update($newjobid, $key, $option);
}
break;
case 'start_cli':
//Get cmd start file
if (!current_user_can('backwpup_jobs_start')) {
break;
}
check_admin_referer('start_cli');
if (empty($_GET['jobid'])) {
break;
}
if (FALSE === strpos(PHP_OS, "WIN")) {
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=BackWPup_cmd_start_job_" . $_GET['jobid'] . ".sh;");
if (defined('PHP_BINDIR')) {
echo "#!/bin/sh" . PHP_EOL;
}
echo "@\$1php -c \"" . php_ini_loaded_file() . "\" -r \"\$_SERVER[ 'SERVER_ADDR' ] = '" . $_SERVER['SERVER_ADDR'] . "'; \$_SERVER[ 'REMOTE_ADDR' ] = '" . $_SERVER['REMOTE_ADDR'] . "'; \$_SERVER[ 'HTTP_HOST' ] = '" . $_SERVER['HTTP_HOST'] . "'; \$_SERVER[ 'HTTP_USER_AGENT' ] = '" . BackWPup::get_plugin_data('name') . "'; define( 'DOING_CRON', TRUE ); require '" . ABSPATH . "wp-load.php'; if( class_exists( 'BackWPup_Job' ) ) BackWPup_Job::start_cli( " . $_GET['jobid'] . " );\"";
die;
} else {
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=BackWPup_cmd_start_job_" . $_GET['jobid'] . ".cmd;");
echo "@%1php.exe -c \"" . php_ini_loaded_file() . "\" -r \"\$_SERVER[ 'SERVER_ADDR' ] = '" . $_SERVER['SERVER_ADDR'] . "'; \$_SERVER[ 'REMOTE_ADDR' ] = '" . $_SERVER['REMOTE_ADDR'] . "'; \$_SERVER[ 'HTTP_HOST' ] = '" . $_SERVER['HTTP_HOST'] . "'; \$_SERVER[ 'HTTP_USER_AGENT' ] = '" . BackWPup::get_plugin_data('name') . "'; define( 'DOING_CRON', TRUE ); require '" . ABSPATH . "wp-load.php'; if( class_exists( 'BackWPup_Job' ) ) BackWPup_Job::start_cli( " . $_GET['jobid'] . " );\"";
die;
}
break;
case 'runnow':
if (!empty($_GET['jobid'])) {
if (!current_user_can('backwpup_jobs_start')) {
wp_die(__('Sorry, you don\'t have permissions to do that.', 'backwpup'));
}
check_admin_referer('backwpup_job_run-runnowlink');
//check temp folder
BackWPup_Job::check_folder(BackWPup::get_plugin_data('TEMP'), TRUE);
//check log folder
BackWPup_Job::check_folder(get_site_option('backwpup_cfg_logfolder'));
//check server callback
$raw_response = BackWPup_Job::get_jobrun_url('test');
$test_result = '';
if (is_wp_error($raw_response)) {
$test_result .= sprintf(__('The HTTP response test get an error "%s"', 'backwpup'), $raw_response->get_error_message());
} elseif (200 != wp_remote_retrieve_response_code($raw_response) && 204 != wp_remote_retrieve_response_code($raw_response)) {
$test_result .= sprintf(__('The HTTP response test get a false http status (%s)', 'backwpup'), wp_remote_retrieve_response_code($raw_response));
}
//.........这里部分代码省略.........
示例13: get_exclude_dirs
/**
*
* Get folder to exclude from a given folder for file backups
*
* @param $folder string folder to check for excludes
*
* @return array of folder to exclude
*/
private function get_exclude_dirs($folder)
{
$folder = trailingslashit(str_replace('\\', '/', realpath($folder)));
$excludedir = array();
$excludedir[] = trailingslashit(str_replace('\\', '/', realpath(BackWPup::get_plugin_data('TEMP'))));
//exclude temp
$excludedir[] = trailingslashit(str_replace('\\', '/', realpath(get_site_option('backwpup_cfg_logfolder'))));
//exclude log folder
if (FALSE !== strpos(trailingslashit(str_replace('\\', '/', realpath(ABSPATH))), $folder) && trailingslashit(str_replace('\\', '/', realpath(ABSPATH))) != $folder) {
$excludedir[] = trailingslashit(str_replace('\\', '/', realpath(ABSPATH)));
}
if (FALSE !== strpos(trailingslashit(str_replace('\\', '/', realpath(WP_CONTENT_DIR))), $folder) && trailingslashit(str_replace('\\', '/', realpath(WP_CONTENT_DIR))) != $folder) {
$excludedir[] = trailingslashit(str_replace('\\', '/', realpath(WP_CONTENT_DIR)));
}
if (FALSE !== strpos(trailingslashit(str_replace('\\', '/', realpath(WP_PLUGIN_DIR))), $folder) && trailingslashit(str_replace('\\', '/', realpath(WP_PLUGIN_DIR))) != $folder) {
$excludedir[] = trailingslashit(str_replace('\\', '/', realpath(WP_PLUGIN_DIR)));
}
if (FALSE !== strpos(trailingslashit(str_replace('\\', '/', realpath(get_theme_root()))), $folder) && trailingslashit(str_replace('\\', '/', realpath(get_theme_root()))) != $folder) {
$excludedir[] = trailingslashit(str_replace('\\', '/', realpath(get_theme_root())));
}
if (FALSE !== strpos(trailingslashit(realpath(BackWPup_File::get_upload_dir())), $folder) && trailingslashit(realpath(BackWPup_File::get_upload_dir())) != $folder) {
$excludedir[] = trailingslashit(realpath(BackWPup_File::get_upload_dir()));
}
//Exclude Backup dirs
$jobids = BackWPup_Option::get_job_ids();
foreach ($jobids as $id) {
$backupdir = realpath(BackWPup_Option::get($id, 'backupdir'));
if (!empty($backupdir) && $backupdir != '/') {
$excludedir[] = trailingslashit(str_replace('\\', '/', $backupdir));
}
}
return array_unique($excludedir);
}
示例14: start_cli
/**
* @param $jobid
*/
public static function start_cli($jobid)
{
if (php_sapi_name() != 'cli') {
return;
}
//define DOING_CRON to prevent caching
if (!defined('DOING_CRON')) {
define('DOING_CRON', true);
}
//load text domain
$log_level = get_site_option('backwpup_cfg_loglevel', 'normal_translated');
if (strstr($log_level, 'translated')) {
BackWPup::load_text_domain();
} else {
add_filter('override_load_textdomain', '__return_true');
$GLOBALS['l10n'] = array();
}
$jobid = absint($jobid);
//Logs Folder
$log_folder = get_site_option('backwpup_cfg_logfolder');
$log_folder = BackWPup_File::get_absolute_path($log_folder);
//check job id exists
$jobids = BackWPup_Option::get_job_ids();
if (!in_array($jobid, $jobids, true)) {
die(__('Wrong BackWPup JobID', 'backwpup'));
}
//check folders
$log_folder_message = BackWPup_File::check_folder($log_folder);
if (!empty($log_folder_message)) {
die($log_folder_message);
}
$log_folder_message = BackWPup_File::check_folder(BackWPup::get_plugin_data('TEMP'), true);
if (!empty($log_folder_message)) {
die($log_folder_message);
}
//check running job
if (file_exists(BackWPup::get_plugin_data('running_file'))) {
die(__('A BackWPup job is already running', 'backwpup'));
}
//start class
$backwpup_job_object = new self();
$backwpup_job_object->create('runcli', (int) $jobid);
$backwpup_job_object->run();
}
示例15: load
/**
*
*/
public static function load()
{
//Create Table
self::$listtable = new self();
switch (self::$listtable->current_action()) {
case 'delete':
//Delete Job
if (!current_user_can('backwpup_jobs_edit')) {
break;
}
if (is_array($_GET['jobs'])) {
check_admin_referer('bulk-jobs');
foreach ($_GET['jobs'] as $jobid) {
wp_clear_scheduled_hook('backwpup_cron', array('id' => $jobid));
BackWPup_Option::delete_job($jobid);
}
}
break;
case 'copy':
//Copy Job
if (!current_user_can('backwpup_jobs_edit')) {
break;
}
$old_job_id = (int) $_GET['jobid'];
check_admin_referer('copy-job_' . $_GET['jobid']);
//create new
$newjobid = BackWPup_Option::get_job_ids();
sort($newjobid);
$newjobid = end($newjobid) + 1;
$old_options = BackWPup_Option::get_job($old_job_id);
foreach ($old_options as $key => $option) {
if ($key == "jobid") {
$option = $newjobid;
}
if ($key == "name") {
$option = __('Copy of', 'backwpup') . ' ' . $option;
}
if ($key == "activetype") {
$option = '';
}
if ($key == "archivename") {
$option = str_replace($_GET['jobid'], $newjobid, $option);
}
if ($key == "logfile" || $key == "lastbackupdownloadurl" || $key == "lastruntime" || $key == "lastrun") {
continue;
}
BackWPup_Option::update($newjobid, $key, $option);
}
break;
case 'runnow':
$_GET['jobid'] = (int) $_GET['jobid'];
if (!empty($_GET['jobid'])) {
if (!current_user_can('backwpup_jobs_start')) {
wp_die(__('Sorry, you don\'t have permissions to do that.', 'backwpup'));
}
check_admin_referer('backwpup_job_run-runnowlink');
//check temp folder
$temp_folder_message = BackWPup_File::check_folder(BackWPup::get_plugin_data('TEMP'), TRUE);
BackWPup_Admin::message($temp_folder_message, TRUE);
//check log folder
$log_folder = get_site_option('backwpup_cfg_logfolder');
$log_folder = BackWPup_File::get_absolute_path($log_folder);
$log_folder_message = BackWPup_File::check_folder($log_folder);
BackWPup_Admin::message($log_folder_message, TRUE);
//check backup destinations
$job_types = BackWPup::get_job_types();
$job_conf_types = BackWPup_Option::get($_GET['jobid'], 'type');
$creates_file = FALSE;
foreach ($job_types as $id => $job_type_class) {
if (in_array($id, $job_conf_types) && $job_type_class->creates_file()) {
$creates_file = TRUE;
break;
}
}
if ($creates_file) {
$job_conf_dests = BackWPup_Option::get($_GET['jobid'], 'destinations');
$destinations = 0;
/* @var BackWPup_Destinations $dest_class */
foreach (BackWPup::get_registered_destinations() as $id => $dest) {
if (!in_array($id, $job_conf_dests) || empty($dest['class'])) {
continue;
}
$dest_class = BackWPup::get_destination($id);
$job_settings = BackWPup_Option::get_job($_GET['jobid']);
if (!$dest_class->can_run($job_settings)) {
BackWPup_Admin::message(sprintf(__('The job "%s" destination "%s" is not configured properly', 'backwpup'), esc_attr(BackWPup_Option::get($_GET['jobid'], 'name')), $id), TRUE);
}
$destinations++;
}
if ($destinations < 1) {
BackWPup_Admin::message(sprintf(__('The job "%s" needs properly configured destinations to run!', 'backwpup'), esc_attr(BackWPup_Option::get($_GET['jobid'], 'name'))), TRUE);
}
}
//check server callback
$raw_response = BackWPup_Job::get_jobrun_url('test');
$test_result = '';
if (is_wp_error($raw_response)) {
//.........这里部分代码省略.........