本文整理汇总了PHP中BackWPup_Job类的典型用法代码示例。如果您正苦于以下问题:PHP BackWPup_Job类的具体用法?PHP BackWPup_Job怎么用?PHP BackWPup_Job使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BackWPup_Job类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: job_run
public function job_run(BackWPup_Job $job_object)
{
global $wpdb;
$job_object->substeps_todo = 1;
$job_object->log(sprintf(__('%d. Trying to generate a file with installed widget names …', 'backwpup'), $job_object->steps_data[$job_object->step_working]['STEP_TRY']));
//build filename
if (empty($job_object->temp['widgetlistfile'])) {
$job_object->temp['widgetlistfile'] = $job_object->generate_filename($job_object->job['widgetlistfile'], 'sql') . $job_object->job['widgetlistfilecompression'];
}
$handle = fopen($job_object->temp['widgetlistfile'], 'w');
if ($handle) {
$query = "SELECT * FROM {$wpdb->options} WHERE option_name LIKE 'widget_%'";
$rows = $wpdb->get_results($query);
$header = '';
foreach ($rows as $row) {
$header .= "INSERT INTO {$wpdb->options} (option_name, option_value, autoload) VALUES" . "('" . esc_sql($row->option_name) . "', '" . esc_sql($row->option_value) . "', '" . esc_sql($row->autoload) . "')" . "ON DUPLICATE KEY UPDATE option_value = '" . esc_sql($row->option_value) . "';\n";
}
$query = "SELECT * FROM {$wpdb->options} WHERE option_name = 'sidebars_widgets'";
$rows = $wpdb->get_results($query);
foreach ($rows as $row) {
$header .= "INSERT INTO {$wpdb->options} (option_name, option_value, autoload) VALUES" . "('" . esc_sql($row->option_name) . "', '" . esc_sql($row->option_value) . "', '" . esc_sql($row->autoload) . "')" . "ON DUPLICATE KEY UPDATE option_value = '" . esc_sql($row->option_value) . "';\n";
}
fwrite($handle, $header);
fclose($handle);
} else {
$job_object->log(__('Can not open target file for writing.', 'backwpup'), E_USER_ERROR);
return FALSE;
}
if ($job_object->temp['widgetlistfile']) {
$job_object->additional_files_to_backup[] = $job_object->temp['widgetlistfile'];
$job_object->log(sprintf(__('Added widget list file "%1$s" with %2$s to backup file list.', 'backwpup'), $job_object->temp['widgetlistfile'], size_format($job_object->temp['widgetlistfile']), 2));
}
$job_object->substeps_done = 1;
return TRUE;
}
开发者ID:rufas-hajdu,项目名称:backwpup-widget,代码行数:35,代码来源:class-jobtype-wpwidget.php
示例2: update
public static function update($backwpup_jobid)
{
$params = array('id' => NULL, 'email_me' => 0, 'log_output_length' => 0, 'testfirst' => 0);
if (empty($backwpup_jobid)) {
$params['id'] = get_site_option('backwpup_cfg_easycronjobid');
$params['cron_job_name'] = sprintf('WordPress on %s', home_url());
$params['cron_expression'] = '*/5 * * * *';
$url = BackWPup_Job::get_jobrun_url('runext', 0);
$url = remove_query_arg('_nonce', $url['url']);
$url = remove_query_arg('doing_wp_cron', $url);
$url = remove_query_arg('backwpup_run', $url);
$url = add_query_arg(array('doing_wp_cron' => ''), $url);
$cookies = get_site_transient('backwpup_cookies');
$params['url'] = $url;
if (!empty($cookies)) {
$params['cookies'] = http_build_query($cookies);
}
} else {
$params['id'] = BackWPup_Option::get($backwpup_jobid, 'easycronjobid');
if (empty($params['id'])) {
$params['id'] = NULL;
}
$params['cron_job_name'] = sprintf('BackWPup %s on %s', BackWPup_Option::get($backwpup_jobid, 'name'), home_url());
$params['cron_expression'] = BackWPup_Option::get($backwpup_jobid, 'cron');
$url = BackWPup_Job::get_jobrun_url('runext', $backwpup_jobid);
$cookies = get_site_transient('backwpup_cookies');
$params['url'] = $url['url'];
if (!empty($cookies)) {
$params['cookies'] = http_build_query($cookies);
}
}
if (empty($params['id'])) {
$message = self::query_api('add', $params);
} else {
$message = self::query_api('edit', $params);
}
delete_site_transient('backwpup_easycron_' . $params['id']);
if ($message['status'] == 'success' && !empty($message['cron_job_id'])) {
if (empty($backwpup_jobid)) {
update_site_option('backwpup_cfg_easycronjobid', $message['cron_job_id']);
} else {
BackWPup_Option::update($backwpup_jobid, 'easycronjobid', $message['cron_job_id']);
}
return TRUE;
} else {
if ($message['error']['code'] == 25) {
if (empty($backwpup_jobid)) {
delete_site_option('backwpup_cfg_easycronjobid');
} else {
BackWPup_Option::delete($backwpup_jobid, 'easycronjobid');
}
}
}
return FALSE;
}
开发者ID:yszar,项目名称:linuxwp,代码行数:55,代码来源:class-easycron.php
示例3: working
/**
* See Status of a working job
*
* @param $args
* @param $assoc_args
*/
public function working($args, $assoc_args)
{
$job_object = BackWPup_Job::get_working_data();
if (!is_object($job_object)) {
WP_CLI::error(__('No job running', 'backwpup'));
}
$formatter_args = array('format' => 'table', 'fields' => array('JobID', 'Name', 'Warnings', 'Errors', 'On Step', 'Done'), 'field' => NULL);
$formatter = new WP_CLI\Formatter($formatter_args);
$items = array();
$items[] = array('JobID' => $job_object->job['jobid'], 'Name' => $job_object->job['name'], 'Warnings' => $job_object->warnings, 'Errors' => $job_object->errors, 'On Step' => $job_object->steps_data[$job_object->step_working]['NAME'], 'Done' => $job_object->step_percent . ' / ' . $job_object->substep_percent, 'Last message' => str_replace('…', '...', strip_tags($job_object->lastmsg)));
$formatter->display_items($items);
WP_CLI::log('Last Message: ' . str_replace('…', '...', strip_tags($job_object->lastmsg)));
}
开发者ID:leotaillard,项目名称:btws2016,代码行数:19,代码来源:class-wp-cli.php
示例4: working
/**
* See Status of a working job
*
* @param $args
* @param $assoc_args
* @synopsis working
*/
public function working($args, $assoc_args)
{
$job_object = BackWPup_Job::get_working_data();
if (is_object($job_object)) {
WP_CLI::error(__('No job running', 'backwpup'));
}
WP_CLI::line(__('Running job', 'backwpup'));
WP_CLI::line('----------------------------------------------------------------------');
WP_CLI::line(sprintf(__('ID: %1$d Name: %2$s', 'backwpup'), $job_object->job['jobid'], $job_object->job['name']));
WP_CLI::line(sprintf(__('Warnings: %1$d Errors: %2$d', 'backwpup'), $job_object->warnings, $job_object->errors));
WP_CLI::line(sprintf(__('Steps in percent: %1$d percent of step: %2$d', 'backwpup'), $job_object->step_percent, $job_object->substep_percent));
WP_CLI::line(sprintf(__('On step: %s', 'backwpup'), $job_object->steps_data[$job_object->step_working]['NAME']));
WP_CLI::line(sprintf(__('Last message: %s', 'backwpup'), str_replace('…', '...', strip_tags($job_object->lastmsg))));
}
开发者ID:isrealconsulting,项目名称:site,代码行数:21,代码来源:class-wp-cli.php
示例5: prepare_items
/**
*
*/
function prepare_items()
{
$this->job_types = BackWPup::get_job_types();
$per_page = $this->get_items_per_page('backwpuplogs_per_page');
if (empty($per_page) || $per_page < 1) {
$per_page = 20;
}
//load logs
$logfiles = array();
if (is_readable($this->log_folder) && ($dir = opendir($this->log_folder))) {
while (($file = readdir($dir)) !== FALSE) {
$log_file = $this->log_folder . '/' . $file;
if (is_file($log_file) && is_readable($log_file) && FALSE !== strpos($file, 'backwpup_log_') && FALSE !== strpos($file, '.html')) {
$logfiles[] = $file;
}
}
closedir($dir);
}
//ordering
$order = isset($_GET['order']) ? $_GET['order'] : 'desc';
$orderby = isset($_GET['orderby']) ? $_GET['orderby'] : 'time';
if ($orderby == 'time') {
if ($order == 'asc') {
sort($logfiles);
} else {
rsort($logfiles);
}
}
//by page
$start = intval(($this->get_pagenum() - 1) * $per_page);
$end = $start + $per_page;
if ($end > count($logfiles)) {
$end = count($logfiles);
}
$this->items = array();
$i = -1;
foreach ($logfiles as $mtime => $logfile) {
$i++;
if ($i < $start) {
continue;
}
if ($i >= $end) {
break;
}
$this->items[$mtime] = BackWPup_Job::read_logheader($this->log_folder . '/' . $logfile);
$this->items[$mtime]['file'] = $logfile;
}
$this->set_pagination_args(array('total_items' => count($logfiles), 'per_page' => $per_page, 'orderby' => $orderby, 'order' => $order));
}
开发者ID:leotaillard,项目名称:btws2016,代码行数:52,代码来源:class-page-logs.php
示例6: __construct
/**
* Set needed filters and actions and load
*/
private function __construct()
{
// Nothing else matters if we're not on the main site
if (!is_main_site()) {
return;
}
//auto loader
spl_autoload_register(array($this, 'autoloader'));
//start upgrade if needed
if (get_site_option('backwpup_version') != self::get_plugin_data('Version')) {
BackWPup_Install::activate();
}
//load pro features
if (class_exists('BackWPup_Pro')) {
BackWPup_Pro::get_instance();
}
//WP-Cron
if (defined('DOING_CRON') && DOING_CRON) {
if (!empty($_GET['backwpup_run']) && class_exists('BackWPup_Job')) {
//early disable caches
BackWPup_Job::disable_caches();
//add action for running jobs in wp-cron.php
add_action('wp_loaded', array('BackWPup_Cron', 'cron_active'), PHP_INT_MAX);
} else {
//add cron actions
add_action('backwpup_cron', array('BackWPup_Cron', 'run'));
add_action('backwpup_check_cleanup', array('BackWPup_Cron', 'check_cleanup'));
}
//if in cron the rest is not needed
return;
}
//deactivation hook
register_deactivation_hook(__FILE__, array('BackWPup_Install', 'deactivate'));
//Admin bar
if (get_site_option('backwpup_cfg_showadminbar', FALSE)) {
add_action('init', array('BackWPup_Adminbar', 'get_instance'));
}
//only in backend
if (is_admin() && class_exists('BackWPup_Admin')) {
BackWPup_Admin::get_instance();
}
//work with wp-cli
if (defined('WP_CLI') && WP_CLI && method_exists('WP_CLI', 'add_command')) {
WP_CLI::add_command('backwpup', 'BackWPup_WP_CLI');
}
}
开发者ID:aim-web-projects,项目名称:kobe-chuoh,代码行数:49,代码来源:backwpup.php
示例7: __construct
/**
* Set needed filters and actions and load
*/
private function __construct()
{
// Nothing else matters if we're not on the main site
if (!is_main_site()) {
return;
}
//auto loader
spl_autoload_register(array($this, 'autoloader'));
//Options
new BackWPup_Option();
//start upgrade if needed
if (get_site_option('backwpup_version') != self::get_plugin_data('Version')) {
BackWPup_Install::activate();
}
//load pro features
if (class_exists('BackWPup_Pro')) {
BackWPup_Pro::get_instance();
}
//WP-Cron
if (defined('DOING_CRON') && DOING_CRON) {
//early disable caches
if (!empty($_GET['backwpup_run']) && class_exists('BackWPup_Job')) {
BackWPup_Job::disable_caches();
}
// add normal cron actions
add_action('backwpup_cron', array('BackWPup_Cron', 'run'));
add_action('backwpup_check_cleanup', array('BackWPup_Cron', 'check_cleanup'));
// add action for doing thinks if cron active
// must done in int before wp-cron control
add_action('init', array('BackWPup_Cron', 'cron_active'), 1);
// if in cron the rest must not needed
return;
}
//deactivation hook
register_deactivation_hook(__FILE__, array('BackWPup_Install', 'deactivate'));
//Things that must do in plugin init
add_action('init', array($this, 'plugin_init'));
//only in backend
if (is_admin() && class_exists('BackWPup_Admin')) {
BackWPup_Admin::get_instance();
}
//work with wp-cli
if (defined('WP_CLI') && WP_CLI && class_exists('WP_CLI') && class_exists('BackWPup_WP_CLI')) {
WP_CLI::addCommand('backwpup', 'BackWPup_WP_CLI');
}
}
开发者ID:congtrieu112,项目名称:anime,代码行数:49,代码来源:backwpup.php
示例8: 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']));
}
}
}
开发者ID:leotaillard,项目名称:btws2016,代码行数:45,代码来源:class-adminbar.php
示例9: job_run
/**
* @param $job_object
* @return bool
*/
public function job_run(BackWPup_Job $job_object)
{
global $wpdb, $post, $wp_query;
$wxr_version = '1.2';
if ($job_object->steps_data[$job_object->step_working]['SAVE_STEP_TRY'] != $job_object->steps_data[$job_object->step_working]['STEP_TRY']) {
$job_object->log(sprintf(__('%d. Trying to create a WordPress export to XML file …', 'backwpup'), $job_object->steps_data[$job_object->step_working]['STEP_TRY']));
$job_object->steps_data[$job_object->step_working]['wpexportfile'] = BackWPup::get_plugin_data('TEMP') . $job_object->generate_filename($job_object->job['wpexportfile'], 'xml', TRUE);
$job_object->steps_data[$job_object->step_working]['substep'] = 'header';
$job_object->steps_data[$job_object->step_working]['post_ids'] = array();
$job_object->substeps_todo = 10;
$job_object->substeps_done = 0;
}
add_filter('wxr_export_skip_postmeta', array($this, 'wxr_filter_postmeta'), 10, 2);
if ($job_object->steps_data[$job_object->step_working]['substep'] == 'header') {
if ('all' != $job_object->job['wpexportcontent'] && post_type_exists($job_object->job['wpexportcontent'])) {
$ptype = get_post_type_object($job_object->job['wpexportcontent']);
if (!$ptype->can_export) {
$job_object->log(sprintf(__('WP Export: Post type “%s” does not allow export.', 'backwpup'), $job_object->job['wpexportcontent']), E_USER_ERROR);
return FALSE;
}
$where = $wpdb->prepare("{$wpdb->posts}.post_type = %s", $job_object->job['wpexportcontent']);
} else {
$post_types = get_post_types(array('can_export' => true));
$esses = array_fill(0, count($post_types), '%s');
$where = $wpdb->prepare("{$wpdb->posts}.post_type IN (" . implode(',', $esses) . ')', $post_types);
$job_object->job['wpexportcontent'] = 'all';
}
$where .= " AND {$wpdb->posts}.post_status != 'auto-draft'";
// grab a snapshot of post IDs, just in case it changes during the export
$job_object->steps_data[$job_object->step_working]['post_ids'] = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE {$where}");
$job_object->substeps_todo = $job_object->substeps_todo + count($job_object->steps_data[$job_object->step_working]['post_ids']);
$header = '<?xml version="1.0" encoding="' . get_bloginfo('charset') . "\" ?>\n";
$header .= "<!-- This is a WordPress eXtended RSS file generated by the WordPress plugin BackWPup as an export of your site. -->\n";
$header .= "<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->\n";
$header .= "<!-- You may use this file to transfer that content from one site to another. -->\n";
$header .= "<!-- This file is not intended to serve as a complete backup of your site. -->\n\n";
$header .= "<!-- To import this information into a WordPress site follow these steps: -->\n";
$header .= "<!-- 1. Log in to that site as an administrator. -->\n";
$header .= "<!-- 2. Go to Tools: Import in the WordPress admin panel. -->\n";
$header .= "<!-- 3. Install the \"WordPress\" importer from the list. -->\n";
$header .= "<!-- 4. Activate & Run Importer. -->\n";
$header .= "<!-- 5. Upload this file using the form provided on that page. -->\n";
$header .= "<!-- 6. You will first be asked to map the authors in this export file to users -->\n";
$header .= "<!-- on the site. For each author, you may choose to map to an -->\n";
$header .= "<!-- existing user on the site or to create a new user. -->\n";
$header .= "<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->\n";
$header .= "<!-- contained in this file into your site. -->\n\n";
$header .= "<!-- generator=\"WordPress/" . get_bloginfo_rss('version') . "\" created=\"" . date('Y-m-d H:i') . "\" -->\n";
$header .= "<rss version=\"2.0\" xmlns:excerpt=\"http://wordpress.org/export/{$wxr_version}/excerpt/\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\" xmlns:wfw=\"http://wellformedweb.org/CommentAPI/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:wp=\"http://wordpress.org/export/{$wxr_version}/\">\n";
$header .= "<channel>\n";
$header .= "\t<title>" . get_bloginfo_rss('name') . "</title>\n";
$header .= "\t<link>" . get_bloginfo_rss('url') . "</link>\n";
$header .= "\t<description>" . get_bloginfo_rss('description') . "</description>\n";
$header .= "\t<pubDate>" . date('D, d M Y H:i:s +0000') . "</pubDate>\n";
$header .= "\t<language>" . get_bloginfo_rss('language') . "</language>\n";
$header .= "\t<wp:wxr_version>" . $wxr_version . "</wp:wxr_version>\n";
$header .= "\t<wp:base_site_url>" . $this->wxr_site_url() . "</wp:base_site_url>\n";
$header .= "\t<wp:base_blog_url>" . get_bloginfo_rss('url') . "</wp:base_blog_url>\n";
$written = file_put_contents($job_object->steps_data[$job_object->step_working]['wpexportfile'], $header, FILE_APPEND);
if ($written === FALSE) {
$job_object->log(__('WP Export file could not written.', 'backwpup'), E_USER_ERROR);
return FALSE;
}
unset($header);
$job_object->steps_data[$job_object->step_working]['substep'] = 'authors';
$job_object->substeps_done++;
$job_object->update_working_data();
$job_object->do_restart_time();
}
if ($job_object->steps_data[$job_object->step_working]['substep'] == 'authors') {
$written = file_put_contents($job_object->steps_data[$job_object->step_working]['wpexportfile'], $this->wxr_authors_list(), FILE_APPEND);
if ($written === FALSE) {
$job_object->log(__('WP Export file could not written.', 'backwpup'), E_USER_ERROR);
return FALSE;
}
$job_object->steps_data[$job_object->step_working]['substep'] = 'cats';
$job_object->substeps_done++;
$job_object->update_working_data();
$job_object->do_restart_time();
}
if ($job_object->steps_data[$job_object->step_working]['substep'] == 'cats') {
if ('all' == $job_object->job['wpexportcontent']) {
$cats = array();
$categories = (array) get_categories(array('get' => 'all'));
// put categories in order with no child going before its parent
while ($cat = array_shift($categories)) {
if ($cat->parent == 0 || isset($cats[$cat->parent])) {
$cats[$cat->term_id] = $cat;
} else {
$categories[] = $cat;
}
}
$cats_xml = '';
foreach ($cats as $c) {
$parent_slug = $c->parent ? $cats[$c->parent]->slug : '';
$cats_xml .= "\t<wp:category><wp:term_id>" . $c->term_id . "</wp:term_id><wp:category_nicename>" . $c->slug . "</wp:category_nicename><wp:category_parent>" . $parent_slug . "</wp:category_parent>" . $this->wxr_cat_name($c) . $this->wxr_category_description($c) . "</wp:category>\n";
//.........这里部分代码省略.........
开发者ID:demochko-ol,项目名称:hezy,代码行数:101,代码来源:class-jobtype-wpexp.php
示例10: job_run_archive
/**
* @param $job_object
* @return bool
*/
public function job_run_archive(BackWPup_Job $job_object)
{
$job_object->substeps_todo = 2 + $job_object->backup_filesize;
if ($job_object->steps_data[$job_object->step_working]['SAVE_STEP_TRY'] != $job_object->steps_data[$job_object->step_working]['STEP_TRY']) {
$job_object->log(sprintf(__('%d. Try to send backup file to an FTP server …', 'backwpup'), $job_object->steps_data[$job_object->step_working]['STEP_TRY']), E_USER_NOTICE);
}
if (!empty($job_object->job['ftpssl'])) {
//make SSL FTP connection
if (function_exists('ftp_ssl_connect')) {
$ftp_conn_id = ftp_ssl_connect($job_object->job['ftphost'], $job_object->job['ftphostport'], $job_object->job['ftptimeout']);
if ($ftp_conn_id) {
$job_object->log(sprintf(__('Connected via explicit SSL-FTP to server: %s', 'backwpup'), $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport']), E_USER_NOTICE);
} else {
$job_object->log(sprintf(__('Cannot connect via explicit SSL-FTP to server: %s', 'backwpup'), $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport']), E_USER_ERROR);
return FALSE;
}
} else {
$job_object->log(__('PHP function to connect with explicit SSL-FTP to server does not exist!', 'backwpup'), E_USER_ERROR);
return TRUE;
}
} else {
//make normal FTP connection if SSL not work
$ftp_conn_id = ftp_connect($job_object->job['ftphost'], $job_object->job['ftphostport'], $job_object->job['ftptimeout']);
if ($ftp_conn_id) {
$job_object->log(sprintf(__('Connected to FTP server: %s', 'backwpup'), $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport']), E_USER_NOTICE);
} else {
$job_object->log(sprintf(__('Cannot connect to FTP server: %s', 'backwpup'), $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport']), E_USER_ERROR);
return FALSE;
}
}
//FTP Login
$job_object->log(sprintf(__('FTP client command: %s', 'backwpup'), 'USER ' . $job_object->job['ftpuser']), E_USER_NOTICE);
if ($loginok = @ftp_login($ftp_conn_id, $job_object->job['ftpuser'], BackWPup_Encryption::decrypt($job_object->job['ftppass']))) {
$job_object->log(sprintf(__('FTP server response: %s', 'backwpup'), 'User ' . $job_object->job['ftpuser'] . ' logged in.'), E_USER_NOTICE);
} else {
//if PHP ftp login don't work use raw login
$return = ftp_raw($ftp_conn_id, 'USER ' . $job_object->job['ftpuser']);
$job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), $return[0]), E_USER_NOTICE);
if (substr(trim($return[0]), 0, 3) <= 400) {
$job_object->log(sprintf(__('FTP client command: %s', 'backwpup'), 'PASS *******'), E_USER_NOTICE);
$return = ftp_raw($ftp_conn_id, 'PASS ' . BackWPup_Encryption::decrypt($job_object->job['ftppass']));
if (substr(trim($return[0]), 0, 3) <= 400) {
$job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), $return[0]), E_USER_NOTICE);
$loginok = TRUE;
} else {
$job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), $return[0]), E_USER_ERROR);
}
}
}
if (!$loginok) {
return FALSE;
}
//SYSTYPE
$job_object->log(sprintf(__('FTP client command: %s', 'backwpup'), 'SYST'), E_USER_NOTICE);
$systype = ftp_systype($ftp_conn_id);
if ($systype) {
$job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), $systype), E_USER_NOTICE);
} else {
$job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), __('Error getting SYSTYPE', 'backwpup')), E_USER_ERROR);
}
//set actual ftp dir to ftp dir
if (empty($job_object->job['ftpdir'])) {
$job_object->job['ftpdir'] = trailingslashit(ftp_pwd($ftp_conn_id));
}
// prepend actual ftp dir if relative dir
if (substr($job_object->job['ftpdir'], 0, 1) != '/') {
$job_object->job['ftpdir'] = trailingslashit(ftp_pwd($ftp_conn_id)) . $job_object->job['ftpdir'];
}
//test ftp dir and create it if not exists
if ($job_object->job['ftpdir'] != '/') {
@ftp_chdir($ftp_conn_id, '/');
//go to root
$ftpdirs = explode('/', trim($job_object->job['ftpdir'], '/'));
foreach ($ftpdirs as $ftpdir) {
if (empty($ftpdir)) {
continue;
}
if (!@ftp_chdir($ftp_conn_id, $ftpdir)) {
if (@ftp_mkdir($ftp_conn_id, $ftpdir)) {
$job_object->log(sprintf(__('FTP Folder "%s" created!', 'backwpup'), $ftpdir), E_USER_NOTICE);
ftp_chdir($ftp_conn_id, $ftpdir);
} else {
$job_object->log(sprintf(__('FTP Folder "%s" cannot be created!', 'backwpup'), $ftpdir), E_USER_ERROR);
return FALSE;
}
}
}
}
// Get the current working directory
$current_ftp_dir = trailingslashit(ftp_pwd($ftp_conn_id));
if ($job_object->substeps_done == 0) {
$job_object->log(sprintf(__('FTP current folder is: %s', 'backwpup'), $current_ftp_dir), E_USER_NOTICE);
}
//get file size to resume upload
@clearstatcache();
$job_object->substeps_done = @ftp_size($ftp_conn_id, $job_object->job['ftpdir'] . $job_object->backup_file);
//.........这里部分代码省略.........
开发者ID:skinnard,项目名称:FTL-2,代码行数:101,代码来源:class-destination-ftp.php
示例11: page
//.........这里部分代码省略.........
</div>
<div class="table ui-tabs-hide" id="backwpup-tab-information">
<br />
<?php
echo '<table class="wp-list-table widefat fixed" cellspacing="0" style="width:85%;margin-left:auto;margin-right:auto;">';
echo '<thead><tr><th width="35%">' . __('Setting', 'backwpup') . '</th><th>' . __('Value', 'backwpup') . '</th></tr></thead>';
echo '<tfoot><tr><th>' . __('Setting', 'backwpup') . '</th><th>' . __('Value', 'backwpup') . '</th></tr></tfoot>';
echo '<tr title=">=3.2"><td>' . __('WordPress version', 'backwpup') . '</td><td>' . esc_html(BackWPup::get_plugin_data('wp_version')) . '</td></tr>';
if (!class_exists('BackWPup_Pro', FALSE)) {
echo '<tr title=""><td>' . __('BackWPup version', 'backwpup') . '</td><td>' . esc_html(BackWPup::get_plugin_data('Version')) . ' <a href="' . __('http://backwpup.com', 'backwpup') . '">' . __('Get pro.', 'backwpup') . '</a></td></tr>';
} else {
echo '<tr title=""><td>' . __('BackWPup Pro version', 'backwpup') . '</td><td>' . esc_html(BackWPup::get_plugin_data('Version')) . '</td></tr>';
}
$bit = '';
if (PHP_INT_SIZE === 4) {
$bit = ' (32bit)';
}
if (PHP_INT_SIZE === 8) {
$bit = ' (64bit)';
}
echo '<tr title=">=5.3.3"><td>' . __('PHP version', 'backwpup') . '</td><td>' . esc_html(PHP_VERSION . ' ' . $bit) . '</td></tr>';
echo '<tr title=">=5.0.7"><td>' . __('MySQL version', 'backwpup') . '</td><td>' . esc_html($wpdb->get_var("SELECT VERSION() AS version")) . '</td></tr>';
if (function_exists('curl_version')) {
$curlversion = curl_version();
echo '<tr title=""><td>' . __('cURL version', 'backwpup') . '</td><td>' . esc_html($curlversion['version']) . '</td></tr>';
echo '<tr title=""><td>' . __('cURL SSL version', 'backwpup') . '</td><td>' . esc_html($curlversion['ssl_version']) . '</td></tr>';
} else {
echo '<tr title=""><td>' . __('cURL version', 'backwpup') . '</td><td>' . __('unavailable', 'backwpup') . '</td></tr>';
}
echo '<tr title=""><td>' . __('WP-Cron url:', 'backwpup') . '</td><td>' . site_url('wp-cron.php') . '</td></tr>';
//response test
echo '<tr><td>' . __('Server self connect:', 'backwpup') . '</td><td>';
$raw_response = BackWPup_Job::get_jobrun_url('test');
$response_code = wp_remote_retrieve_response_code($raw_response);
$response_body = wp_remote_retrieve_body($raw_response);
if (strstr($response_body, 'BackWPup test request') === false) {
$test_result = __('<strong>Not expected HTTP response:</strong><br>', 'backwpup');
if (!$response_code) {
$test_result .= sprintf(__('WP Http Error: <code>%s</code>', 'backwpup'), esc_html($raw_response->get_error_message())) . '<br>';
} else {
$test_result .= sprintf(__('Status-Code: <code>%d</code>', 'backwpup'), esc_html($response_code)) . '<br>';
}
$response_headers = wp_remote_retrieve_headers($raw_response);
foreach ($response_headers as $key => $value) {
$test_result .= esc_html(ucfirst($key)) . ': <code>' . esc_html($value) . '</code><br>';
}
$content = esc_html(wp_remote_retrieve_body($raw_response));
if ($content) {
$test_result .= sprintf(__('Content: <code>%s</code>', 'backwpup'), $content);
}
echo $test_result;
} else {
_e('Response Test O.K.', 'backwpup');
}
echo '</td></tr>';
//folder test
echo '<tr><td>' . __('Temp folder:', 'backwpup') . '</td><td>';
if (!is_dir(BackWPup::get_plugin_data('TEMP'))) {
echo sprintf(__('Temp folder %s doesn\'t exist.', 'backwpup'), esc_html(BackWPup::get_plugin_data('TEMP')));
} elseif (!is_writable(BackWPup::get_plugin_data('TEMP'))) {
echo sprintf(__('Temporary folder %s is not writable.', 'backwpup'), esc_html(BackWPup::get_plugin_data('TEMP')));
} else {
echo esc_html(BackWPup::get_plugin_data('TEMP'));
}
echo '</td></tr>';
开发者ID:pedro-mendonca,项目名称:backwpup,代码行数:67,代码来源:class-page-settings.php
示例12: ajax_working
/**
*
* Function to generate json data
*
*/
public static function ajax_working()
{
check_ajax_referer('backwpupworking_ajax_nonce');
$logfile = isset($_GET['logfile']) ? get_site_option('backwpup_cfg_logfolder') . trim($_GET['logfile']) : NULL;
$logpos = isset($_GET['logpos']) ? (int) $_GET['logpos'] : 0;
//check if logfile renamed
if (file_exists($logfile . '.gz')) {
$logfile .= '.gz';
}
if (!is_readable($logfile)) {
die('0');
}
$job_object = BackWPup_Job::get_working_data();
$done = 0;
if (is_object($job_object)) {
$warnings = $job_object->warnings;
$errors = $job_object->errors;
$step_percent = $job_object->step_percent;
$substep_percent = $job_object->substep_percent;
$runtime = current_time('timestamp') - $job_object->start_time;
$onstep = $job_object->steps_data[$job_object->step_working]['NAME'];
$lastmsg = $job_object->lastmsg;
$lasterrormsg = $job_object->lasterrormsg;
} else {
$logheader = BackWPup_Job::read_logheader($logfile);
$warnings = $logheader['warnings'];
$runtime = $logheader['runtime'];
$errors = $logheader['errors'];
$step_percent = 100;
$substep_percent = 100;
$onstep = '<div class="backwpup-message backwpup-info"><p>' . __('Job completed', 'backwpup') . '</p></div>';
if ($errors > 0) {
$lastmsg = '<div class="error"><p>' . __('ERROR:', 'backwpup') . ' ' . sprintf(__('Job has ended with errors in %s seconds. You must resolve the errors for correct execution.', 'backwpup'), $logheader['runtime']) . '</p></div>';
} elseif ($warnings > 0) {
$lastmsg = '<div class="backwpup-message backwpup-warning"><p>' . __('WARNING:', 'backwpup') . ' ' . sprintf(__('Job has done with warnings in %s seconds. Please resolve them for correct execution.', 'backwpup'), $logheader['runtime']) . '</p></div>';
} else {
$lastmsg = '<div class="updated"><p>' . sprintf(__('Job done in %s seconds.', 'backwpup'), $logheader['runtime']) . '</p></div>';
}
$lasterrormsg = '';
$done = 1;
}
if ('.gz' == substr($logfile, -3)) {
$logfiledata = file_get_contents('compress.zlib://' . $logfile, FALSE, NULL, $logpos);
} else {
$logfiledata = file_get_contents($logfile, FALSE, NULL, $logpos);
}
preg_match('/<body[^>]*>/si', $logfiledata, $match);
if (!empty($match[0])) {
$startpos = strpos($logfiledata, $match[0]) + strlen($match[0]);
} else {
$startpos = 0;
}
$endpos = stripos($logfiledata, '</body>');
if (FALSE === $endpos) {
$endpos = strlen($logfiledata);
}
$length = strlen($logfiledata) - (strlen($logfiledata) - $endpos) - $startpos;
wp_send_json(array('log_pos' => strlen($logfiledata) + $logpos, 'log_text' => substr($logfiledata, $startpos, $length), 'warning_count' => $warnings, 'error_count' => $errors, 'running_time' => $runtime, 'step_percent' => $step_percent, 'on_step' => $onstep, 'last_msg' => $lastmsg, 'last_error_msg' => $lasterrormsg, 'sub_step_percent' => $substep_percent, 'job_done' => $done));
}
开发者ID:kirkov,项目名称:backwpup,代码行数:64,代码来源:class-page-jobs.php
示例13: ajax_working
/**
*
* Function to generate json data
*
*/
public static function ajax_working()
{
check_ajax_referer('backwpupworking_ajax_nonce');
if (!current_user_can('backwpup_jobs_start')) {
die('-1');
}
$log_folder = get_site_option('backwpup_cfg_logfolder');
$log_folder = BackWPup_File::get_absolute_path($log_folder);
$logfile = isset($_GET['logfile']) ? $log_folder . basename(trim($_GET['logfile'])) : NULL;
$logpos = isset($_GET['logpos']) ? absint($_GET['logpos']) : 0;
$restart_url = '';
//check if logfile renamed
if (file_exists($logfile . '.gz')) {
$logfile .= '.gz';
}
if (!is_readable($logfile) || strstr($_GET['logfile'], 'backwpup_log_') === false) {
die('0');
}
$job_object = BackWPup_Job::get_working_data();
$done = 0;
if (is_object($job_object)) {
$warnings = $job_object->warnings;
$errors = $job_object->errors;
$step_percent = $job_object->step_percent;
$substep_percent = $job_object->substep_percent;
$runtime = current_time('timestamp') - $job_object->start_time;
$onstep = $job_object->steps_data[$job_object->step_working]['NAME'];
$lastmsg = $job_object->lastmsg;
$lasterrormsg = $job_object->lasterrormsg;
} else {
$logheader = BackWPup_Job::read_logheader($logfile);
$warnings = $logheader['warnings'];
$runtime = $logheader['runtime'];
$errors = $logheader['errors'];
$step_percent = 100;
$substep_percent = 100;
$onstep = '<div class="backwpup-message backwpup-info"><p>' . esc_html__('Job completed', 'backwpup') . '</p></div>';
if ($errors > 0) {
$lastmsg = '<div class="error"><p>' . esc_html__('ERROR:', 'backwpup') . ' ' . sprintf(esc_html__('Job has ended with errors in %s seconds. You must resolve the errors for correct execution.', 'backwpup'), $logheader['runtime']) . '</p></div>';
} elseif ($warnings > 0) {
$lastmsg = '<div class="backwpup-message backwpup-warning"><p>' . esc_html__('WARNING:', 'backwpup') . ' ' . sprintf(esc_html__('Job has done with warnings in %s seconds. Please resolve them for correct execution.', 'backwpup'), $logheader['runtime']) . '</p></div>';
} else {
$lastmsg = '<div class="updated"><p>' . sprintf(esc_html__('Job done in %s seconds.', 'backwpup'), $logheader['runtime']) . '</p></div>';
}
$lasterrormsg = '';
$done = 1;
}
if ('.gz' == substr($logfile, -3)) {
$logfiledata = file_get_contents('compress.zlib://' . $logfile, FALSE, NULL, $logpos);
} else {
$logfiledata = file_get_contents($logfile, FALSE, NULL, $logpos);
}
preg_match('/<body[^>]*>/si', $logfiledata, $match);
if (!empty($match[0])) {
$startpos = strpos($logfiledata, $match[0]) + strlen($match[0]);
} else {
$startpos = 0;
}
$endpos = stripos($logfiledata, '</body>');
if (FALSE === $endpos) {
$endpos = strlen($logfiledata);
}
$length = strlen($logfiledata) - (strlen($logfiledata) - $endpos) - $startpos;
//check if restart must done on ALTERNATE_WP_CRON
if (is_object($job_object) && defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
$restart = BackWPup_Job::get_jobrun_url('restartalt');
if ($job_object->pid === 0 && $job_object->uniqid === '') {
$restart_url = $restart['url'];
}
$last_update = microtime(TRUE) - $job_object->timestamp_last_update;
if (empty($job_object->pid) && $last_update > 10) {
$restart_url = $restart['url'];
}
}
wp_send_json(array('log_pos' => strlen($logfiledata) + $logpos, 'log_text' => substr($logfiledata, $startpos, $length), 'warning_count' => $warnings, 'error_count' => $errors, 'running_time' => $runtime, 'step_percent' => $step_percent, 'on_step' => $onstep, 'last_msg' => $lastmsg, 'last_error_msg' => $lasterrormsg, 'sub_step_percent' => $substep_percent, 'restart_url' => $restart_url, 'job_done' => $done));
}
开发者ID:skinnard,项目名称:FTL-2,代码行数:81,代码来源:class-page-jobs.php
示例14: 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'],
|
请发表评论