Ejemplo n.º 1
0
 /**
  * @return array
  */
 public function option_defaults()
 {
     $upload_dir = wp_upload_dir();
     $backups_dir = trailingslashit(str_replace('\\', '/', $upload_dir['basedir'])) . 'backwpup-' . BackWPup::get_plugin_data('hash') . '-backups/';
     $content_path = trailingslashit(str_replace('\\', '/', WP_CONTENT_DIR));
     $backups_dir = str_replace($content_path, '', $backups_dir);
     return array('maxbackups' => 15, 'backupdir' => $backups_dir, 'backupsyncnodelete' => TRUE);
 }
Ejemplo n.º 2
0
 /**
  *
  */
 public function admin_print_scripts()
 {
     if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) {
         wp_enqueue_script('backwpupjobtypefile', BackWPup::get_plugin_data('URL') . '/assets/js/page_edit_jobtype_file.js', array('jquery'), time(), TRUE);
     } else {
         wp_enqueue_script('backwpupjobtypefile', BackWPup::get_plugin_data('URL') . '/assets/js/page_edit_jobtype_file.min.js', array('jquery'), BackWPup::get_plugin_data('Version'), TRUE);
     }
 }
Ejemplo n.º 3
0
 /**
  *  Abort a working BackWPup Job
  *
  *  @synopsis abort
  */
 public function abort($args, $assoc_args)
 {
     if (file_exists(BackWPup::get_plugin_data('running_file'))) {
         WP_CLI::error(__('Nothing to abort!', 'backwpup'));
     }
     //abort
     BackWPup_Job::user_abort();
     WP_CLI::success(__('Job will be terminated.', 'backwpup'));
 }
Ejemplo n.º 4
0
 /**
  * Check Jobs worked and Cleanup logs and so on
  */
 public static function check_cleanup()
 {
     $job_object = BackWPup_Job::get_working_data();
     $log_folder = get_site_option('backwpup_cfg_logfolder');
     $log_folder = BackWPup_File::get_absolute_path($log_folder);
     // check aborted jobs for longer than a tow hours, abort them courtly and send mail
     if (is_object($job_object) && !empty($job_object->logfile)) {
         $not_worked_time = microtime(TRUE) - $job_object->timestamp_last_update;
         if ($not_worked_time > 3600) {
             $job_object->log(E_USER_ERROR, __('Aborted, because no progress for one hour!', 'backwpup'), __FILE__, __LINE__);
             unlink(BackWPup::get_plugin_data('running_file'));
             $job_object->update_working_data();
         }
     }
     //Compress not compressed logs
     if (is_readable($log_folder) && function_exists('gzopen') && get_site_option('backwpup_cfg_gzlogs') && !is_object($job_object)) {
         //Compress old not compressed logs
         if ($dir = opendir($log_folder)) {
             $jobids = BackWPup_Option::get_job_ids();
             while (FALSE !== ($file = readdir($dir))) {
                 if (is_writeable($log_folder . $file) && '.html' == substr($file, -5)) {
                     $compress = new BackWPup_Create_Archive($log_folder . $file . '.gz');
                     if ($compress->add_file($log_folder . $file)) {
                         unlink($log_folder . $file);
                         //change last logfile in jobs
                         foreach ($jobids as $jobid) {
                             $job_logfile = BackWPup_Option::get($jobid, 'logfile');
                             if (!empty($job_logfile) && $job_logfile === $log_folder . $file) {
                                 BackWPup_Option::update($jobid, 'logfile', $log_folder . $file . '.gz');
                             }
                         }
                     }
                     unset($compress);
                 }
             }
             closedir($dir);
         }
     }
     //Jobs cleanings
     if (!$job_object) {
         //remove restart cron
         wp_clear_scheduled_hook('backwpup_cron', array('id' => 'restart'));
         //temp cleanup
         BackWPup_Job::clean_temp_folder();
     }
     //check scheduling jobs that not found will removed because there are single scheduled
     $activejobs = BackWPup_Option::get_job_ids('activetype', 'wpcron');
     foreach ($activejobs as $jobid) {
         $cron_next = wp_next_scheduled('backwpup_cron', array('id' => $jobid));
         if (!$cron_next || $cron_next < time()) {
             wp_unschedule_event($cron_next, 'backwpup_cron', array('id' => $jobid));
             $cron_next = BackWPup_Cron::cron_next(BackWPup_Option::get($jobid, 'cron'));
             wp_schedule_single_event($cron_next, 'backwpup_cron', array('id' => $jobid));
         }
     }
 }
Ejemplo n.º 5
0
 /**
  *
  */
 public function __construct()
 {
     $this->info['ID'] = 'DBCHECK';
     $this->info['name'] = __('DB Check', 'backwpup');
     $this->info['description'] = __('Check database tables', 'backwpup');
     $this->info['URI'] = __('http://backwpup.com', 'backwpup');
     $this->info['author'] = 'Inpsyde GmbH';
     $this->info['authorURI'] = __('http://inpsyde.com', 'backwpup');
     $this->info['version'] = BackWPup::get_plugin_data('Version');
 }
 /**
  *
  */
 public function __construct()
 {
     $this->info['ID'] = 'DBCHECK';
     $this->info['name'] = __('DB Check', 'backwpup');
     $this->info['description'] = __('Check database tables', 'backwpup');
     $this->info['URI'] = translate(BackWPup::get_plugin_data('PluginURI'), 'backwpup');
     $this->info['author'] = BackWPup::get_plugin_data('Author');
     $this->info['authorURI'] = translate(BackWPup::get_plugin_data('AuthorURI'), 'backwpup');
     $this->info['version'] = BackWPup::get_plugin_data('Version');
 }
 public function __construct()
 {
     $this->info['ID'] = 'WPWIDGET';
     $this->info['name'] = __('Widget', 'backwpup-widget');
     $this->info['description'] = __('Widget list', 'backwpup-widget');
     $this->info['URI'] = translate(BackWPup::get_plugin_data('WidgetURI'), 'backwpup-widget');
     $this->info['author'] = BackWPup::get_plugin_data('Author');
     $this->info['authorURI'] = translate(BackWPup::get_plugin_data('AuthorURI'), 'backwpup-widget');
     $this->info['version'] = BackWPup::get_plugin_data('Version');
 }
Ejemplo n.º 8
0
 /**
  *
  */
 public static function help()
 {
     if (method_exists(get_current_screen(), 'add_help_tab')) {
         get_current_screen()->add_help_tab(array('id' => 'plugininfo', 'title' => __('Plugin Info', 'backwpup'), 'content' => '<p> ' . str_replace('\\"', '"', sprintf(_x('%1$s version %2$s. A project by <a href="http://inpsyde.com">Inpsyde GmbH</a>.', 'Plugin name and link; Plugin Version', 'backwpup'), '<a href="' . esc_attr__('http://backwpup.com', 'backwpup') . '">' . BackWPup::get_plugin_data('Name') . '</a>', BackWPup::get_plugin_data('Version'))) . '</p>' . '<p>' . esc_html__('BackWPup comes with ABSOLUTELY NO WARRANTY. This is a free software, and you are welcome to redistribute it under certain conditions.', 'backwpup') . '</p>'));
         $text_help_sidebar = '<p><strong>' . __('For more information:', 'backwpup') . '</strong></p>';
         $text_help_sidebar .= '<p><a href="' . esc_attr__('http://backwpup.com', 'backwpup') . '">' . BackWPup::get_plugin_data('Name') . '</a></p>';
         $text_help_sidebar .= '<p><a href="http://wordpress.org/extend/plugins/backwpup/">' . esc_html__('Plugin on wordpress.org', 'backwpup') . '</a></p>';
         $text_help_sidebar .= '<p><a href="' . esc_attr__('http://docs.backwpup.com', 'backwpup') . '">' . esc_html__('Manual', 'backwpup') . '</a></p>';
         get_current_screen()->set_help_sidebar($text_help_sidebar);
     }
 }
Ejemplo n.º 9
0
 /**
  *
  */
 public static function help()
 {
     if (method_exists(get_current_screen(), 'add_help_tab')) {
         get_current_screen()->add_help_tab(array('id' => 'plugininfo', 'title' => __('Plugin Info', 'backwpup'), 'content' => '<p> ' . str_replace('\\"', '"', sprintf(_x('%1$s version %2$s. A project by <a href="http://inpsyde.com">Inpsyde GmbH</a>.', 'Plugin name and link; Plugin Version', 'backwpup'), '<a href="' . translate(BackWPup::get_plugin_data('PluginURI'), 'backwpup') . '">' . BackWPup::get_plugin_data('Name') . '</a>', BackWPup::get_plugin_data('Version'))) . '</p>' . '<p>' . __('BackWPup comes with ABSOLUTELY NO WARRANTY. This is a free software, and you are welcome to redistribute it under certain conditions.', 'backwpup') . '</p>'));
         $text_help_sidebar = '<p><strong>' . __('For more information:', 'backwpup') . '</strong></p>';
         $text_help_sidebar .= '<p><a href="' . translate(BackWPup::get_plugin_data('PluginURI'), 'backwpup') . '">' . BackWPup::get_plugin_data('Name') . '</a></p>';
         $text_help_sidebar .= '<p><a href="http://wordpress.org/extend/plugins/backwpup/">' . __('Plugin on wordpress.org', 'backwpup') . '</a></p>';
         $text_help_sidebar .= '<p><a href="' . __('https://marketpress.com/news/', 'backwpup') . '">' . __('News', 'backwpup') . '</a></p>';
         if (class_exists('BackWPup_Pro', FALSE)) {
             $text_help_sidebar .= '<p><a href="' . __('https://marketpress.com/support/forum/plugins/backwpup-pro/', 'backwpup') . '">' . __('Pro Support', 'backwpup') . '</a></p>';
         } else {
             $text_help_sidebar .= '<p><a href="' . __('http://wordpress.org/support/plugin/backwpup/', 'backwpup') . '">' . __('Support', 'backwpup') . '</a></p>';
         }
         $text_help_sidebar .= '<p><a href="' . __('https://marketpress.com/documentation/backwpup-pro/', 'backwpup') . '">' . __('Manual', 'backwpup') . '</a></p>';
         get_current_screen()->set_help_sidebar($text_help_sidebar);
     }
 }
Ejemplo n.º 10
0
 /**
  * @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']));
         }
     }
 }
 /**
  * @param        $url
  * @param array  $args
  * @param string $method
  * @param string $data
  * @param bool   $echo
  *
  * @throws BackWPup_Destination_Dropbox_API_Exception
  * @internal param null $file
  * @return array|mixed|string
  */
 private function request($url, $args = array(), $method = 'GET', $data = '', $echo = FALSE)
 {
     /* Header*/
     $headers[] = 'Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="' . $this->oauth_app_key . '", oauth_token="' . $this->oauth_token . '", oauth_signature="' . $this->oauth_app_secret . '&' . $this->oauth_token_secret . '"';
     $headers[] = 'Expect:';
     /* Build cURL Request */
     $ch = curl_init();
     if ($method == 'POST') {
         curl_setopt($ch, CURLOPT_POST, TRUE);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
         curl_setopt($ch, CURLOPT_URL, $url);
     } elseif ($method == 'PUT') {
         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
         curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
         $headers[] = 'Content-Type: application/octet-stream';
         $args = is_array($args) ? '?' . http_build_query($args, '', '&') : $args;
         curl_setopt($ch, CURLOPT_URL, $url . $args);
     } else {
         curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE);
         $args = is_array($args) ? '?' . http_build_query($args, '', '&') : $args;
         curl_setopt($ch, CURLOPT_URL, $url . $args);
     }
     curl_setopt($ch, CURLOPT_USERAGENT, BackWPup::get_plugin_data('User-Agent'));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
     if (BackWPup::get_plugin_data('cacert')) {
         curl_setopt($ch, CURLOPT_SSLVERSION, 3);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
         curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'ECDHE-RSA-AES256-GCM-SHA384:' . 'ECDHE-RSA-AES128-GCM-SHA256:' . 'ECDHE-RSA-AES256-SHA384:' . 'ECDHE-RSA-AES128-SHA256:' . 'ECDHE-RSA-AES256-SHA:' . 'ECDHE-RSA-AES128-SHA:' . 'ECDHE-RSA-RC4-SHA:' . 'DHE-RSA-AES256-GCM-SHA384:' . 'DHE-RSA-AES128-GCM-SHA256:' . 'DHE-RSA-AES256-SHA256:' . 'DHE-RSA-AES128-SHA256:' . 'DHE-RSA-AES256-SHA:' . 'DHE-RSA-AES128-SHA:' . 'AES256-GCM-SHA384:' . 'AES128-GCM-SHA256:' . 'AES256-SHA256:' . 'AES128-SHA256:' . 'AES256-SHA:' . 'AES128-SHA');
         if (defined('CURLOPT_PROTOCOLS')) {
             curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
         }
         if (defined('CURLOPT_REDIR_PROTOCOLS')) {
             curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS);
         }
         curl_setopt($ch, CURLOPT_CAINFO, BackWPup::get_plugin_data('cacert'));
         curl_setopt($ch, CURLOPT_CAPATH, dirname(BackWPup::get_plugin_data('cacert')));
     } else {
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     }
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     $output = '';
     if ($echo) {
         echo curl_exec($ch);
     } else {
         curl_setopt($ch, CURLOPT_HEADER, TRUE);
         if (0 == curl_errno($ch)) {
             $responce = explode("\r\n\r\n", curl_exec($ch), 2);
             if (!empty($responce[1])) {
                 $output = json_decode($responce[1], TRUE);
             }
         }
     }
     $status = curl_getinfo($ch);
     if (isset($datafilefd) && is_resource($datafilefd)) {
         fclose($datafilefd);
     }
     if ($status['http_code'] == 503) {
         $wait = 0;
         if (preg_match("/retry-after:(.*?)\r/i", $responce[0], $matches)) {
             $wait = trim($matches[1]);
         }
         //only wait if we get a retry-after header.
         if (!empty($wait)) {
             trigger_error(sprintf('(503) Your app is making too many requests and is being rate limited. Error 503 can be triggered on a per-app or per-user basis. Wait for %d seconds.', $wait), E_USER_WARNING);
             sleep($wait);
         } else {
             trigger_error('(503) Service unavailable. Retrying.', E_USER_WARNING);
         }
         //redo request
         return $this->request($url, $args, $method, $data, $echo);
     } elseif ($status['http_code'] == 400 && $method == 'PUT') {
         //correct offset on chunk uploads
         trigger_error('(' . $status['http_code'] . ') False offset will corrected', E_USER_NOTICE);
         return $output;
     } elseif ($status['http_code'] == 404 && !empty($output['error'])) {
         trigger_error('(' . $status['http_code'] . ') ' . $output['error'], E_USER_WARNING);
         return FALSE;
     } elseif (isset($output['error']) || $status['http_code'] >= 300 || $status['http_code'] < 200 || curl_errno($ch) > 0) {
         if (isset($output['error']) && is_string($output['error'])) {
             $message = '(' . $status['http_code'] . ') ' . $output['error'];
         } elseif (isset($output['error']['hash']) && $output['error']['hash'] != '') {
             $message = (string) '(' . $status['http_code'] . ') ' . $output['error']['hash'];
         } elseif (0 != curl_errno($ch)) {
             $message = '(' . curl_errno($ch) . ') ' . curl_error($ch);
         } elseif ($status['http_code'] == 304) {
             $message = '(304) Folder contents have not changed (relies on hash parameter).';
         } elseif ($status['http_code'] == 400) {
             $message = '(400) Bad input parameter: ' . strip_tags($responce[1]);
         } elseif ($status['http_code'] == 401) {
             $message = '(401) Bad or expired token. Please re-authenticate the user.';
         } elseif ($status['http_code'] == 403) {
             $message = '(403) Bad OAuth request (wrong consumer key, bad nonce, expired timestamp,&hellip;)';
         } elseif ($status['http_code'] == 404) {
             $message = '(404) File could not be found at the specified path or rev.';
         } elseif ($status['http_code'] == 405) {
             $message = '(405) Request method not expected (generally should be GET,PUT or POST).';
         } elseif ($status['http_code'] == 406) {
             $message = '(406) There are too many file entries to return.';
         } elseif ($status['http_code'] == 411) {
             $message = '(411) Chunked encoding was attempted for this upload, but is not supported by Dropbox.';
         } elseif ($status['http_code'] == 415) {
             $message = '(415) The image is invalid and cannot be thumbnailed.';
         } elseif ($status['http_code'] == 503) {
             $message = '(503) Service unavailable.';
         } elseif ($status['http_code'] == 507) {
             $message = '(507) User exceeding Dropbox storage quota.';
         } else {
             $message = '(' . $status['http_code'] . ') Invalid response.';
         }
         throw new BackWPup_Destination_Dropbox_API_Exception($message);
     } else {
         curl_close($ch);
         if (!is_array($output)) {
             return $responce[1];
         } else {
             return $output;
         }
     }
 }
    /**
     *
     */
    public static function page()
    {
        if (!empty($_GET['jobid'])) {
            $jobid = (int) $_GET['jobid'];
        } else {
            //generate jobid if not exists
            $newjobid = BackWPup_Option::get_job_ids();
            sort($newjobid);
            $jobid = end($newjobid) + 1;
        }
        $destinations = BackWPup::get_registered_destinations();
        $job_types = BackWPup::get_job_types();
        ?>
    <div class="wrap" id="backwpup-page">
		<?php 
        echo '<h2><span id="backwpup-page-icon">&nbsp;</span>' . sprintf(__('%1$s Job: %2$s', 'backwpup'), BackWPup::get_plugin_data('name'), '<span id="h2jobtitle">' . esc_html(BackWPup_Option::get($jobid, 'name')) . '</span>') . '</h2>';
        //default tabs
        $tabs = array('job' => array('name' => __('General', 'backwpup'), 'display' => TRUE), 'cron' => array('name' => __('Schedule', 'backwpup'), 'display' => TRUE));
        //add jobtypes to tabs
        $job_job_types = BackWPup_Option::get($jobid, 'type');
        foreach ($job_types as $typeid => $typeclass) {
            $tabid = 'jobtype-' . strtolower($typeid);
            $tabs[$tabid]['name'] = $typeclass->info['name'];
            $tabs[$tabid]['display'] = TRUE;
            if (!in_array($typeid, $job_job_types)) {
                $tabs[$tabid]['display'] = FALSE;
            }
        }
        //add destinations to tabs
        $jobdests = BackWPup_Option::get($jobid, 'destinations');
        foreach ($destinations as $destid => $dest) {
            $tabid = 'dest-' . strtolower($destid);
            $tabs[$tabid]['name'] = sprintf(__('To: %s', 'backwpup'), $dest['info']['name']);
            $tabs[$tabid]['display'] = TRUE;
            if (!in_array($destid, $jobdests)) {
                $tabs[$tabid]['display'] = FALSE;
            }
        }
        //display tabs
        echo '<h2 class="nav-tab-wrapper">';
        foreach ($tabs as $id => $tab) {
            $addclass = '';
            if ($id == $_GET['tab']) {
                $addclass = ' nav-tab-active';
            }
            $display = '';
            if (!$tab['display']) {
                $display = ' style="display:none;"';
            }
            echo '<a href="' . wp_nonce_url(network_admin_url('admin.php') . '?page=backwpupeditjob&tab=' . $id . '&jobid=' . $jobid, 'edit-job') . '" class="nav-tab' . $addclass . '" id="tab-' . $id . '" data-nexttab="' . $id . '" ' . $display . '>' . $tab['name'] . '</a>';
        }
        echo '</h2>';
        //display messages
        BackWPup_Admin::display_messages();
        echo '<form name="editjob" id="editjob" method="post" action="' . admin_url('admin-post.php') . '">';
        echo '<input type="hidden" id="jobid" name="jobid" value="' . $jobid . '" />';
        echo '<input type="hidden" name="tab" value="' . $_GET['tab'] . '" />';
        echo '<input type="hidden" name="nexttab" value="' . $_GET['tab'] . '" />';
        echo '<input type="hidden" name="page" value="backwpupeditjob" />';
        echo '<input type="hidden" name="action" value="backwpup" />';
        echo '<input type="hidden" name="anchor" value="" />';
        wp_nonce_field('backwpupeditjob_page');
        wp_nonce_field('backwpup_ajax_nonce', 'backwpupajaxnonce', FALSE);
        switch ($_GET['tab']) {
            case 'job':
                echo '<div class="table" id="info-tab-job">';
                ?>
				<h3 class="title"><?php 
                _e('Job Name', 'backwpup');
                ?>
</h3>
				<p></p>
				<table class="form-table">
					<tr>
						<th scope="row"><label for="name"><?php 
                _e('Please name this job.', 'backwpup');
                ?>
</label></th>
						<td>
							<input name="name" type="text" id="name" data-empty="<?php 
                _e('New Job', 'backwpup');
                ?>
"
								   value="<?php 
                echo BackWPup_Option::get($jobid, 'name');
                ?>
" class="regular-text" />
						</td>
					</tr>
				</table>

				<h3 class="title"><?php 
                _e('Job Tasks', 'backwpup');
                ?>
</h3>
				<p></p>
				<table class="form-table">
					<tr>
						<th scope="row"><?php 
                _e('This job is a&#160;&hellip;', 'backwpup');
                ?>
</th>
						<td>
							<fieldset>
								<legend class="screen-reader-text"><span><?php 
                _e('Job tasks', 'backwpup');
                ?>
</span>
								</legend><?php 
                foreach ($job_types as $id => $typeclass) {
                    $addclass = '';
                    if ($typeclass->creates_file()) {
                        $addclass .= ' filetype';
                    }
                    $title = '';
                    if (!empty($typeclass->info['help'])) {
                        $title = ' title="' . esc_attr($typeclass->info['help']) . '"';
                        $addclass .= ' help-tip';
                    }
                    echo '<label for="jobtype-select-' . strtolower($id) . '"><input class="jobtype-select checkbox' . $addclass . '"' . $title . '  id="jobtype-select-' . strtolower($id) . '" type="checkbox" ' . checked(TRUE, in_array($id, BackWPup_Option::get($jobid, 'type')), FALSE) . ' name="type[]" value="' . $id . '" /> ' . $typeclass->info['description'] . '</label><br />';
                }
                ?>
</fieldset>
						</td>
					</tr>
				</table>

				<h3 class="title hasdests"><?php 
                _e('Backup File Creation', 'backwpup');
                ?>
</h3>
				<p class="hasdests"></p>
				<table class="form-table hasdests">
					<?php 
                if (class_exists('BackWPup_Pro', FALSE)) {
                    ?>
					<tr>
						<th scope="row"><?php 
                    _e('Backup type', 'backwpup');
                    ?>
</th>
						<td>
							<fieldset>
								<legend class="screen-reader-text">	<span><?php 
                    _e('Backup type', 'backwpup');
                    ?>
</span></legend>
								<label for="idbackuptype-sync"><input class="radio"
									   type="radio"<?php 
                    checked('sync', BackWPup_Option::get($jobid, 'backuptype'), TRUE);
                    ?>
									   name="backuptype" id="idbackuptype-sync"
									   value="sync"/> <?php 
                    _e('Synchronize file by file to destination', 'backwpup');
                    ?>
</label><br/>
                                <label for="idbackuptype-archive"><input class="radio"
									   type="radio"<?php 
                    checked('archive', BackWPup_Option::get($jobid, 'backuptype'), TRUE);
                    ?>
									   name="backuptype" id="idbackuptype-archive"
									   value="archive"/> <?php 
                    _e('Create a backup archive', 'backwpup');
                    ?>
</label><br/>
							</fieldset>
						</td>
					</tr>
					<?php 
                }
                ?>
					<tr class="nosync">
						<th scope="row"><label for="archivename"><?php 
                _e('Archive name', 'backwpup');
                ?>
</label></th>
						<td>
							<input name="archivename" type="text" id="archivename"
								value="<?php 
                echo BackWPup_Option::get($jobid, 'archivename');
                ?>
"
								class="regular-text code help-tip" title="<?php 
                echo "<strong>" . esc_attr__('Replacement patterns:', 'backwpup') . "</strong><br />";
                echo esc_attr__('%d = Two digit day of the month, with leading zeros', 'backwpup') . '<br />';
                echo esc_attr__('%j = Day of the month, without leading zeros', 'backwpup') . '<br />';
                echo esc_attr__('%m = Day of the month, with leading zeros', 'backwpup') . '<br />';
                echo esc_attr__('%n = Representation of the month (without leading zeros)', 'backwpup') . '<br />';
                echo esc_attr__('%Y = Four digit representation for the year', 'backwpup') . '<br />';
                echo esc_attr__('%y = Two digit representation of the year', 'backwpup') . '<br />';
                echo esc_attr__('%a = Lowercase ante meridiem (am) and post meridiem (pm)', 'backwpup') . '<br />';
                echo esc_attr__('%A = Uppercase ante meridiem (AM) and post meridiem (PM)', 'backwpup') . '<br />';
                echo esc_attr__('%B = Swatch Internet Time', 'backwpup') . '<br />';
                echo esc_attr__('%g = Hour in 12-hour format, without leading zeros', 'backwpup') . '<br />';
                echo esc_attr__('%G = Hour in 24-hour format, without leading zeros', 'backwpup') . '<br />';
                echo esc_attr__('%h = Hour in 12-hour format, with leading zeros', 'backwpup') . '<br />';
                echo esc_attr__('%H = Hour in 24-hour format, with leading zeros', 'backwpup') . '<br />';
                echo esc_attr__('%i = Two digit representation of the minute', 'backwpup') . '<br />';
                echo esc_attr__('%s = Two digit representation of the second', 'backwpup') . '<br />';
                ?>
" />
							<?php 
                $current_time = current_time('timestamp');
                $datevars = array('%d', '%j', '%m', '%n', '%Y', '%y', '%a', '%A', '%B', '%g', '%G', '%h', '%H', '%i', '%s');
                $datevalues = array(date('d', $current_time), date('j', $current_time), date('m', $current_time), date('n', $current_time), date('Y', $current_time), date('y', $current_time), date('a', $current_time), date('A', $current_time), date('B', $current_time), date('g', $current_time), date('G', $current_time), date('h', $current_time), date('H', $current_time), date('i', $current_time), date('s', $current_time));
                $archivename = str_replace($datevars, $datevalues, BackWPup_Job::sanitize_file_name(BackWPup_Option::get($jobid, 'archivename')));
                echo '<p>Preview: <code><span id="archivefilename">' . $archivename . '</span><span id="archiveformat">' . BackWPup_Option::get($jobid, 'archiveformat') . '</span></code></p>';
                ?>
						</td>
					</tr>
					<tr class="nosync">
						<th scope="row"><?php 
                _e('Archive Format', 'backwpup');
                ?>
</th>
						<td>
							<fieldset>
								<legend class="screen-reader-text"><span><?php 
                _e('Archive Format', 'backwpup');
                ?>
</span></legend>
								<?php 
                if (function_exists('gzopen') || class_exists('ZipArchive')) {
                    echo '<label for="idarchiveformat-zip"><input class="radio help-tip" title="' . __('PHP Zip functions will be used if available (needs less memory). Otherwise the PCLZip class will be used.', 'backwpup') . '" type="radio"' . checked('.zip', BackWPup_Option::get($jobid, 'archiveformat'), FALSE) . ' name="archiveformat" id="idarchiveformat-zip" value=".zip" /> ' . __('Zip', 'backwpup') . '</label><br />';
                } else {
                    echo '<label for="idarchiveformat-zip"><input class="radio help-tip" title="' . __('Disabled due to missing PHP function.', 'backwpup') . '" type="radio"' . checked('.zip', BackWPup_Option::get($jobid, 'archiveformat'), FALSE) . ' name="archiveformat" id="idarchiveformat-zip" value=".zip" disabled="disabled" /> ' . __('Zip', 'backwpup') . '</label><br />';
                }
                echo '<label for="idarchiveformat-tar"><input class="radio help-tip" title="' . __('A tarballed, not compressed archive (fast and less memory)', 'backwpup') . '" type="radio"' . checked('.tar', BackWPup_Option::get($jobid, 'archiveformat'), FALSE) . ' name="archiveformat" id="idarchiveformat-tar" value=".tar" /> ' . __('Tar', 'backwpup') . '</label><br />';
                if (function_exists('gzopen')) {
                    echo '<label for="idarchiveformat-targz"><input class="radio help-tip" title="' . __('A tarballed, GZipped archive (fast and less memory)', 'backwpup') . '" type="radio"' . checked('.tar.gz', BackWPup_Option::get($jobid, 'archiveformat'), FALSE) . ' name="archiveformat" id="idarchiveformat-targz" value=".tar.gz" /> ' . __('Tar GZip', 'backwpup') . '</label><br />';
                } else {
                    echo '<label for="idarchiveformat-targz"><input class="radio help-tip" title="' . __('Disabled due to missing PHP function.', 'backwpup') . '" type="radio"' . checked('.tar.gz', BackWPup_Option::get($jobid, 'archiveformat'), FALSE) . ' name="archiveformat" id="idarchiveformat-targz" value=".tar.gz" disabled="disabled" /> ' . __('Tar GZip', 'backwpup') . '</label><br />';
                }
                if (function_exists('bzopen')) {
                    echo '<label for="idarchiveformat-tarbz2"><input class="radio help-tip" title="' . __('A tarballed, BZipped archive (fast and less memory)', 'backwpup') . '" type="radio"' . checked('.tar.bz2', BackWPup_Option::get($jobid, 'archiveformat'), FALSE) . ' name="archiveformat" id="idarchiveformat-tarbz2" value=".tar.bz2" /> ' . __('Tar BZip2', 'backwpup') . '</label><br />';
                } else {
                    echo '<label for="idarchiveformat-tarbz2"><input class="radio help-tip" title="' . __('Disabled due to missing PHP function.', 'backwpup') . '" type="radio"' . checked('.tar.bz2', BackWPup_Option::get($jobid, 'archiveformat'), FALSE) . ' name="archiveformat" id="idarchiveformat-tarbz2" value=".tar.bz2" disabled="disabled" /> ' . __('Tar BZip2', 'backwpup') . '</label><br />';
                }
                ?>
</fieldset>
						</td>
					</tr>
				</table>

				<h3 class="title hasdests"><?php 
                _e('Job Destination', 'backwpup');
                ?>
</h3>
				<p class="hasdests"></p>
				<table class="form-table hasdests">
					<tr>
						<th scope="row"><?php 
                _e('Where should your backup file be stored?', 'backwpup');
                ?>
</th>
						<td>
							<fieldset>
								<legend class="screen-reader-text"><span><?php 
                _e('Where should your backup file be stored?', 'backwpup');
                ?>
</span>
								</legend><?php 
                foreach ($destinations as $id => $dest) {
                    $syncclass = '';
                    if (!$dest['can_sync']) {
                        $syncclass = 'nosync';
                    }
                    $title = '';
                    $helpclass = '';
                    if (!empty($dest['info']['help'])) {
                        $title = ' title="' . esc_attr($dest['info']['help']) . '"';
                        $helpclass = ' help-tip';
                    }
                    echo '<span class="' . $syncclass . '"><label for="dest-select-' . strtolower($id) . '"><input class="checkbox' . $helpclass . '"' . $title . ' id="dest-select-' . strtolower($id) . '" type="checkbox" ' . checked(TRUE, in_array($id, BackWPup_Option::get($jobid, 'destinations')), FALSE) . ' name="destinations[]" value="' . $id . '" ' . disabled(!empty($dest['error']), TRUE, FALSE) . ' /> ' . $dest['info']['description'];
                    if (!empty($dest['error'])) {
                        echo '<br /><span class="description">' . $dest['error'] . '</span>';
                    }
                    echo '</label><br /></span>';
                }
                ?>
</fieldset>
						</td>
					</tr>
				</table>

				<h3 class="title"><?php 
                _e('Log Files', 'backwpup');
                ?>
</h3>
				<p></p>
				<table class="form-table">
					<tr>
						<th scope="row"><label for="mailaddresslog"><?php 
                _e('Send log to email address', 'backwpup');
                ?>
</label></th>
						<td>
							<input name="mailaddresslog" type="text" id="mailaddresslog"
								   value="<?php 
                echo BackWPup_Option::get($jobid, 'mailaddresslog');
                ?>
"
								   class="regular-text help-tip" title="<?php 
                esc_attr_e('Leave empty to not have log sent. Or separate with , for more than one receiver.', 'backwpup');
                ?>
" />
						</td>
					</tr>
					<tr>
						<th scope="row"><label for="mailaddresssenderlog"><?php 
                _e('Email FROM field', 'backwpup');
                ?>
</label></th>
						<td>
							<input name="mailaddresssenderlog" type="text" id="mailaddresssenderlog"
								   value="<?php 
                echo BackWPup_Option::get($jobid, 'mailaddresssenderlog');
                ?>
"
								   class="regular-text help-tip" title="<?php 
                esc_attr_e('Email "From" field (Name &lt;&#160;you@your-email-address.tld&#160;&gt;)', 'backwpup');
                ?>
" />
						</td>
					</tr>
					<tr>
						<th scope="row"><?php 
                _e('Errors only', 'backwpup');
                ?>
</th>
						<td>
                            <label for="idmailerroronly">
							<input class="checkbox" value="1" id="idmailerroronly"
								   type="checkbox" <?php 
                checked(BackWPup_Option::get($jobid, 'mailerroronly'), TRUE);
                ?>
								   name="mailerroronly" /> <?php 
                _e('Send email with log only when errors occur during job execution.', 'backwpup');
                ?>
							</label>
						</td>
					</tr>
				</table>
				<?php 
                echo '</div>';
                break;
            case 'cron':
                echo '<div class="table" id="info-tab-cron">';
                ?>
				<h3 class="title"><?php 
                _e('Job Schedule', 'backwpup');
                ?>
</h3>
				<p></p>
				<table class="form-table">
					<tr>
                        <th scope="row"><?php 
                _e('Start job', 'backwpup');
                ?>
</th>
                        <td>
                            <fieldset>
                                <legend class="screen-reader-text"><span><?php 
                _e('Start job', 'backwpup');
                ?>
</span></legend>
                                <label for="idactivetype"><input class="radio"
                                       type="radio"<?php 
                checked('', BackWPup_Option::get($jobid, 'activetype'), TRUE);
                ?>
                                       name="activetype" id="idactivetype"
                                       value="" /> <?php 
                _e('manually only', 'backwpup');
                ?>
</label><br/>
                                <label for="idactivetype-wpcron"><input class="radio"
                                       type="radio"<?php 
                checked('wpcron', BackWPup_Option::get($jobid, 'activetype'), TRUE);
                ?>
                                       name="activetype" id="idactivetype-wpcron"
                                       value="wpcron" /> <?php 
                _e('with WordPress cron', 'backwpup');
                ?>
</label><br/>
	                            <?php 
                $disabled = '';
                $easycron_api = get_site_option('backwpup_cfg_easycronapikey');
                if (empty($easycron_api)) {
                    $disabled = ' disabled="disabled"';
                }
                ?>
	                            <label for="idactivetype-easycron"><input class="radio help-tip"
			                            type="radio"<?php 
                checked('easycron', BackWPup_Option::get($jobid, 'activetype'), TRUE);
                ?>
			                            name="activetype" id="idactivetype-easycron"<?php 
                echo $disabled;
                ?>
			                            value="easycron" title="<?php 
                _e('Use EasyCron.com Cron jobs.');
                ?>
" /> <?php 
                _e('with <a href="https://www.easycron.com?ref=36673" class="help-tip" title="Affiliate Link!">EasyCron.com</a>', 'backwpup');
                ?>
	                            <?php 
                if (empty($easycron_api)) {
                    echo ' <strong>' . sprintf(__('Setup <a href="https://www.easycron.com?ref=36673" class="help-tip" title="Affiliate Link!">Account</a> / <a href="%s">API Key</a> first.', 'backwpup'), network_admin_url('admin.php') . '?page=backwpupsettings#backwpup-tab-apikey') . '</strong>';
                }
                ?>
	                            </label><br/>
	                            <?php 
                $url = BackWPup_Job::get_jobrun_url('runext', BackWPup_Option::get($jobid, 'jobid'));
                ?>
                                <label for="idactivetype-link"><input class="radio help-tip"
									   type="radio"<?php 
                checked('link', BackWPup_Option::get($jobid, 'activetype'), TRUE);
                ?>
									   name="activetype" id="idactivetype-link"
									   value="link" title="<?php 
                esc_attr_e('Copy the link for an external start. This option has to be activated to make the link work.', 'backwpup');
                ?>
" /> <?php 
                _e('with a link', 'backwpup');
                ?>
 <code><a href="<?php 
                echo $url['url'];
                ?>
" target="_blank"><?php 
                echo $url['url'];
                ?>
</a></code></label>
								<br />
                            </fieldset>
                        </td>
                    </tr>
                    <tr>
						<th scope="row"><?php 
                _e('Start job with CLI', 'backwpup');
                ?>
</th>
						<td class="help-tip" title="<?php 
                esc_attr_e('Use WP-CLI commands to let the job start with the server’s cron on command line interface.', 'backwpup');
                ?>
">
							<?php 
                _e('Use <a href="http://wp-cli.org/">WP-CLI</a> to run jobs from commandline.', 'backwpup');
                ?>
						</td>
                    </tr>
				</table>
				<h3 class="title wpcron"><?php 
                _e('Schedule execution time', 'backwpup');
                ?>
</h3>
				<?php 
                BackWPup_Page_Editjob::ajax_cron_text(array('cronstamp' => BackWPup_Option::get($jobid, 'cron'), 'crontype' => BackWPup_Option::get($jobid, 'cronselect')));
                ?>
				<table class="form-table wpcron">
					<tr>
						<th scope="row"><?php 
                _e('Scheduler type', 'backwpup');
                ?>
</th>
						<td>
							<fieldset>
								<legend class="screen-reader-text"><span><?php 
                _e('Scheduler type', 'backwpup');
                ?>
</span></legend>
                                <label for="idcronselect-basic"><input class="radio"
									   type="radio"<?php 
                checked('basic', BackWPup_Option::get($jobid, 'cronselect'), TRUE);
                ?>
									   name="cronselect" id="idcronselect-basic"
									   value="basic" /> <?php 
                _e('basic', 'backwpup');
                ?>
</label><br/>
                                <label for="idcronselect-advanced"><input class="radio"
									   type="radio"<?php 
                checked('advanced', BackWPup_Option::get($jobid, 'cronselect'), TRUE);
                ?>
									   name="cronselect" id="idcronselect-advanced"
									   value="advanced" /> <?php 
                _e('advanced', 'backwpup');
                ?>
</label><br/>
							</fieldset>
						</td>
					</tr>
					<?php 
                list($cronstr['minutes'], $cronstr['hours'], $cronstr['mday'], $cronstr['mon'], $cronstr['wday']) = explode(' ', BackWPup_Option::get($jobid, 'cron'), 5);
                if (strstr($cronstr['minutes'], '*/')) {
                    $minutes = explode('/', $cronstr['minutes']);
                } else {
                    $minutes = explode(',', $cronstr['minutes']);
                }
                if (strstr($cronstr['hours'], '*/')) {
                    $hours = explode('/', $cronstr['hours']);
                } else {
                    $hours = explode(',', $cronstr['hours']);
                }
                if (strstr($cronstr['mday'], '*/')) {
                    $mday = explode('/', $cronstr['mday']);
                } else {
                    $mday = explode(',', $cronstr['mday']);
                }
                if (strstr($cronstr['mon'], '*/')) {
                    $mon = explode('/', $cronstr['mon']);
                } else {
                    $mon = explode(',', $cronstr['mon']);
                }
                if (strstr($cronstr['wday'], '*/')) {
                    $wday = explode('/', $cronstr['wday']);
                } else {
                    $wday = explode(',', $cronstr['wday']);
                }
                ?>
                    <tr class="wpcronbasic"<?php 
                if (BackWPup_Option::get($jobid, 'cronselect') != 'basic') {
                    echo ' style="display:none;"';
                }
                ?>
>
                        <th scope="row"><?php 
                _e('Scheduler', 'backwpup');
                ?>
</th>
                        <td>
                            <table id="wpcronbasic">
                                <tr>
                                    <th>
										<?php 
                _e('Type', 'backwpup');
                ?>
                                    </th>
                                    <th>
                                    </th>
                                    <th>
										<?php 
                _e('Hour', 'backwpup');
                ?>
                                    </th>
                                    <th>
										<?php 
                _e('Minute', 'backwpup');
                ?>
                                    </th>
                                </tr>
                                <tr>
                                    <td><label for="idcronbtype-mon"><?php 
                echo '<input class="radio" type="radio"' . checked(TRUE, is_numeric($mday[0]), FALSE) . ' name="cronbtype" id="idcronbtype-mon" value="mon" /> ' . __('monthly', 'backwpup');
                ?>
</label></td>
                                    <td><select name="moncronmday"><?php 
                for ($i = 1; $i <= 31; $i++) {
                    echo '<option ' . selected(in_array("{$i}", $mday, TRUE), TRUE, FALSE) . '  value="' . $i . '" />' . __('on', 'backwpup') . ' ' . $i . '</option>';
                }
                ?>
</select></td>
                                    <td><select name="moncronhours"><?php 
                for ($i = 0; $i < 24; $i++) {
                    echo '<option ' . selected(in_array("{$i}", $hours, TRUE), TRUE, FALSE) . '  value="' . $i . '" />' . $i . '</option>';
                }
                ?>
</select></td>
                                    <td><select name="moncronminutes"><?php 
                for ($i = 0; $i < 60; $i = $i + 5) {
                    echo '<option ' . selected(in_array("{$i}", $minutes, TRUE), TRUE, FALSE) . '  value="' . $i . '" />' . $i . '</option>';
                }
                ?>
</select></td>
                                </tr>
                                <tr>
                                    <td><label for="idcronbtype-week"><?php 
                echo '<input class="radio" type="radio"' . checked(TRUE, is_numeric($wday[0]), FALSE) . ' name="cronbtype" id="idcronbtype-week" value="week" /> ' . __('weekly', 'backwpup');
                ?>
</label></td>
                                    <td><select name="weekcronwday">
										<?php 
                echo '<option ' . selected(in_array("0", $wday, TRUE), TRUE, FALSE) . '  value="0" />' . __('Sunday', 'backwpup') . '</option>';
                echo '<option ' . selected(in_array("1", $wday, TRUE), TRUE, FALSE) . '  value="1" />' . __('Monday', 'backwpup') . '</option>';
                echo '<option ' . selected(in_array("2", $wday, TRUE), TRUE, FALSE) . '  value="2" />' . __('Tuesday', 'backwpup') . '</option>';
                echo '<option ' . selected(in_array("3", $wday, TRUE), TRUE, FALSE) . '  value="3" />' . __('Wednesday', 'backwpup') . '</option>';
                echo '<option ' . selected(in_array("4", $wday, TRUE), TRUE, FALSE) . '  value="4" />' . __('Thursday', 'backwpup') . '</option>';
                echo '<option ' . selected(in_array("5", $wday, TRUE), TRUE, FALSE) . '  value="5" />' . __('Friday', 'backwpup') . '</option>';
                echo '<option ' . selected(in_array("6", $wday, TRUE), TRUE, FALSE) . '  value="6" />' . __('Saturday', 'backwpup') . '</option>';
                ?>
                                    </select></td>
                                    <td><select name="weekcronhours"><?php 
                for ($i = 0; $i < 24; $i++) {
                    echo '<option ' . selected(in_array("{$i}", $hours, TRUE), TRUE, FALSE) . '  value="' . $i . '" />' . $i . '</option>';
                }
                ?>
</select></td>
                                    <td><select name="weekcronminutes"><?php 
                for ($i = 0; $i < 60; $i = $i + 5) {
                    echo '<option ' . selected(in_array("{$i}", $minutes, TRUE), TRUE, FALSE) . '  value="' . $i . '" />' . $i . '</option>';
                }
                ?>
</select></td>
                                </tr>
                                <tr>
                                    <td><label for="idcronbtype-day"><?php 
                echo '<input class="radio" type="radio"' . checked("**", $mday[0] . $wday[0], FALSE) . ' name="cronbtype" id="idcronbtype-day" value="day" /> ' . __('daily', 'backwpup');
                ?>
</label></td>
                                    <td></td>
                                    <td><select name="daycronhours"><?php 
                for ($i = 0; $i < 24; $i++) {
                    echo '<option ' . selected(in_array("{$i}", $hours, TRUE), TRUE, FALSE) . '  value="' . $i . '" />' . $i . '</option>';
                }
                ?>
</select></td>
                                    <td><select name="daycronminutes"><?php 
                for ($i = 0; $i < 60; $i = $i + 5) {
                    echo '<option ' . selected(in_array("{$i}", $minutes, TRUE), TRUE, FALSE) . '  value="' . $i . '" />' . $i . '</option>';
                }
                ?>
</select></td>
                                </tr>
                                <tr>
                                    <td><label for="idcronbtype-hour"><?php 
                echo '<input class="radio" type="radio"' . checked("*", $hours[0], FALSE, FALSE) . ' name="cronbtype" id="idcronbtype-hour" value="hour" /> ' . __('hourly', 'backwpup');
                ?>
</label></td>
                                    <td></td>
                                    <td></td>
                                    <td><select name="hourcronminutes"><?php 
                for ($i = 0; $i < 60; $i = $i + 5) {
                    echo '<option ' . selected(in_array("{$i}", $minutes, TRUE), TRUE, FALSE) . '  value="' . $i . '" />' . $i . '</option>';
                }
                ?>
</select></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
					<tr class="wpcronadvanced"<?php 
                if (BackWPup_Option::get($jobid, 'cronselect') != 'advanced') {
                    echo ' style="display:none;"';
                }
                ?>
>
						<th scope="row"><?php 
                _e('Scheduler', 'backwpup');
                ?>
</th>
						<td>
                            <div id="cron-min-box">
                                <b><?php 
                _e('Minutes:', 'backwpup');
                ?>
</b><br/>
								<?php 
                echo '<label for="idcronminutes"><input class="checkbox" type="checkbox"' . checked(in_array("*", $minutes, TRUE), TRUE, FALSE) . ' name="cronminutes[]" id="idcronminutes" value="*" /> ' . __('Any (*)', 'backwpup') . '</label><br />';
                ?>
                                <div id="cron-min"><?php 
                for ($i = 0; $i < 60; $i = $i + 5) {
                    echo '<label for="idcronminutes-' . $i . '"><input class="checkbox" type="checkbox"' . checked(in_array("{$i}", $minutes, TRUE), TRUE, FALSE) . ' name="cronminutes[]" id="idcronminutes-' . $i . '" value="' . $i . '" /> ' . $i . '</label><br />';
                }
                ?>
                                </div>
                            </div>
                            <div id="cron-hour-box">
                                <b><?php 
                _e('Hours:', 'backwpup');
                ?>
</b><br/>
								<?php 
                echo '<label for="idcronhours"><input class="checkbox" type="checkbox"' . checked(in_array("*", $hours, TRUE), TRUE, FALSE) . ' name="cronhours[]" for="idcronhours" value="*" /> ' . __('Any (*)', 'backwpup') . '</label><br />';
                ?>
                                <div id="cron-hour"><?php 
                for ($i = 0; $i < 24; $i++) {
                    echo '<label for="idcronhours-' . $i . '"><input class="checkbox" type="checkbox"' . checked(in_array("{$i}", $hours, TRUE), TRUE, FALSE) . ' name="cronhours[]" id="idcronhours-' . $i . '" value="' . $i . '" /> ' . $i . '</label><br />';
                }
                ?>
                                </div>
                            </div>
                            <div id="cron-day-box">
                                <b><?php 
                _e('Day of Month:', 'backwpup');
                ?>
</b><br/>
                                <label for="idcronmday"><input class="checkbox" type="checkbox"<?php 
                checked(in_array("*", $mday, TRUE), TRUE, TRUE);
                ?>
                                       name="cronmday[]" id="idcronmday" value="*"/> <?php 
                _e('Any (*)', 'backwpup');
                ?>
</label>
                                <br/>

                                <div id="cron-day">
									<?php 
                for ($i = 1; $i <= 31; $i++) {
                    echo '<label for="idcronmday-' . $i . '"><input class="checkbox" type="checkbox"' . checked(in_array("{$i}", $mday, TRUE), TRUE, FALSE) . ' name="cronmday[]" id="idcronmday-' . $i . '" value="' . $i . '" /> ' . $i . '</label><br />';
                }
                ?>
                                </div>
                            </div>
                            <div id="cron-month-box">
                                <b><?php 
                _e('Month:', 'backwpup');
                ?>
</b><br/>
								<?php 
                echo '<label for="idcronmon"><input class="checkbox" type="checkbox"' . checked(in_array("*", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon" value="*" /> ' . __('Any (*)', 'backwpup') . '</label><br />';
                ?>
                                <div id="cron-month">
									<?php 
                echo '<label for="idcronmon-1"><input class="checkbox" type="checkbox"' . checked(in_array("1", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-1" value="1" /> ' . __('January', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-2"><input class="checkbox" type="checkbox"' . checked(in_array("2", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-2" value="2" /> ' . __('February', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-3"><input class="checkbox" type="checkbox"' . checked(in_array("3", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-3" value="3" /> ' . __('March', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-4"><input class="checkbox" type="checkbox"' . checked(in_array("4", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-4" value="4" /> ' . __('April', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-5"><input class="checkbox" type="checkbox"' . checked(in_array("5", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-5" value="5" /> ' . __('May', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-6"><input class="checkbox" type="checkbox"' . checked(in_array("6", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-6" value="6" /> ' . __('June', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-7"><input class="checkbox" type="checkbox"' . checked(in_array("7", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-7" value="7" /> ' . __('July', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-8"><input class="checkbox" type="checkbox"' . checked(in_array("8", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-8" value="8" /> ' . __('August', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-9"><input class="checkbox" type="checkbox"' . checked(in_array("9", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-9" value="9" /> ' . __('September', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-10"><input class="checkbox" type="checkbox"' . checked(in_array("10", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-10" value="10" /> ' . __('October', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-11"><input class="checkbox" type="checkbox"' . checked(in_array("11", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-11" value="11" /> ' . __('November', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-12"><input class="checkbox" type="checkbox"' . checked(in_array("12", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-12" value="12" /> ' . __('December', 'backwpup') . '</label><br />';
                ?>
                                </div>
                            </div>
                            <div id="cron-weekday-box">
                                <b><?php 
                _e('Day of Week:', 'backwpup');
                ?>
</b><br/>
								<?php 
                echo '<label for="idcronwday"><input class="checkbox" type="checkbox"' . checked(in_array("*", $wday, TRUE), TRUE, FALSE) . ' name="cronwday[]" id="idcronwday" value="*" /> ' . __('Any (*)', 'backwpup') . '</label><br />';
                ?>
                                <div id="cron-weekday">
									<?php 
                echo '<label for="idcronwday-0"><input class="checkbox" type="checkbox"' . checked(in_array("0", $wday, TRUE), TRUE, FALSE) . ' name="cronwday[]" id="idcronwday-0" value="0" /> ' . __('Sunday', 'backwpup') . '</label><br />';
                echo '<label for="idcronwday-1"><input class="checkbox" type="checkbox"' . checked(in_array("1", $wday, TRUE), TRUE, FALSE) . ' name="cronwday[]" id="idcronwday-1" value="1" /> ' . __('Monday', 'backwpup') . '</label><br />';
                echo '<label for="idcronwday-2"><input class="checkbox" type="checkbox"' . checked(in_array("2", $wday, TRUE), TRUE, FALSE) . ' name="cronwday[]" id="idcronwday-2" value="2" /> ' . __('Tuesday', 'backwpup') . '</label><br />';
                echo '<label for="idcronwday-3"><input class="checkbox" type="checkbox"' . checked(in_array("3", $wday, TRUE), TRUE, FALSE) . ' name="cronwday[]" id="idcronwday-3" value="3" /> ' . __('Wednesday', 'backwpup') . '</label><br />';
                echo '<label for="idcronwday-4"><input class="checkbox" type="checkbox"' . checked(in_array("4", $wday, TRUE), TRUE, FALSE) . ' name="cronwday[]" id="idcronwday-4" value="4" /> ' . __('Thursday', 'backwpup') . '</label><br />';
                echo '<label for="idcronwday-5"><input class="checkbox" type="checkbox"' . checked(in_array("5", $wday, TRUE), TRUE, FALSE) . ' name="cronwday[]" id="idcronwday-5" value="5" /> ' . __('Friday', 'backwpup') . '</label><br />';
                echo '<label for="idcronwday-6"><input class="checkbox" type="checkbox"' . checked(in_array("6", $wday, TRUE), TRUE, FALSE) . ' name="cronwday[]" id="idcronwday-6" value="6" /> ' . __('Saturday', 'backwpup') . '</label><br />';
                ?>
                                </div>
                            </div>
                            <br class="clear"/>
						</td>
					</tr>
				</table>
				<?php 
                echo '</div>';
                break;
            default:
                echo '<div class="table" id="info-tab-' . $_GET['tab'] . '">';
                if (strstr($_GET['tab'], 'dest-')) {
                    $dest_object = BackWPup::get_destination(str_replace('dest-', '', $_GET['tab']));
                    $dest_object->edit_tab($jobid);
                }
                if (strstr($_GET['tab'], 'jobtype-')) {
                    $id = strtoupper(str_replace('jobtype-', '', $_GET['tab']));
                    $job_types[$id]->edit_tab($jobid);
                }
                echo '</div>';
        }
        echo '<p class="submit">';
        submit_button(__('Save changes', 'backwpup'), 'primary', 'save', FALSE, array('tabindex' => '2', 'accesskey' => 'p'));
        echo '</p></form>';
        ?>
    </div>

    <script type="text/javascript">
    //<![CDATA[
    jQuery(document).ready(function ($) {
        // auto post if things changed
        var changed = false;
        $( '#editjob' ).change( function () {
            changed = true;
        });
		$( '.nav-tab' ).click( function () {
			if ( changed ) {
				$( 'input[name="nexttab"]' ).val( $(this).data( "nexttab" ) );
				$( '#editjob' ).submit();
				return false;
            }
		});
		<?php 
        //add inline js
        if (strstr($_GET['tab'], 'dest-')) {
            $dest_object = BackWPup::get_destination(str_replace('dest-', '', $_GET['tab']));
            $dest_object->edit_inline_js();
        }
        if (strstr($_GET['tab'], 'jobtype-')) {
            $id = strtoupper(str_replace('jobtype-', '', $_GET['tab']));
            $job_types[$id]->edit_inline_js();
        }
        ?>
    });
    //]]>
    </script>
	<?php 
    }
Ejemplo n.º 13
0
 /**
  * @param        $url
  * @param array $args
  * @param string $method
  * @param string $data
  * @param bool $echo
  *
  * @throws BackWPup_Destination_Dropbox_API_Exception
  * @internal param null $file
  * @return array|mixed|string
  */
 private function request($url, $args = array(), $method = 'GET', $data = '', $echo = false)
 {
     /* Header*/
     // oAuth 2
     if (!empty($this->oauth_token['access_token']) && !empty($this->oauth_token['token_type']) && strtolower($this->oauth_token['token_type']) == 'bearer') {
         $headers[] = 'Authorization: Bearer ' . $this->oauth_token['access_token'];
     } elseif (!empty($this->oauth_token['access_token']) && !empty($this->oauth_token['oauth_token_secret'])) {
         $headers[] = 'Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="' . $this->oauth_app_key . '", oauth_token="' . $this->oauth_token['access_token'] . '", oauth_signature="' . $this->oauth_app_secret . '&' . $this->oauth_token['oauth_token_secret'] . '"';
     }
     $headers[] = 'Expect:';
     /* Build cURL Request */
     $ch = curl_init();
     if ($method == 'POST') {
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
         curl_setopt($ch, CURLOPT_URL, $url);
     } elseif ($method == 'PUT') {
         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
         curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
         $headers[] = 'Content-Type: application/octet-stream';
         $args = is_array($args) ? '?' . http_build_query($args, '', '&') : $args;
         curl_setopt($ch, CURLOPT_URL, $url . $args);
     } else {
         curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
         $args = is_array($args) ? '?' . http_build_query($args, '', '&') : $args;
         curl_setopt($ch, CURLOPT_URL, $url . $args);
     }
     curl_setopt($ch, CURLOPT_USERAGENT, BackWPup::get_plugin_data('User-Agent'));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     if (BackWPup::get_plugin_data('cacert')) {
         curl_setopt($ch, CURLOPT_SSLVERSION, 1);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
         $curl_version = curl_version();
         if (strstr($curl_version['ssl_version'], 'NSS/') === false) {
             curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'ECDHE-RSA-AES256-GCM-SHA384:' . 'ECDHE-RSA-AES128-GCM-SHA256:' . 'ECDHE-RSA-AES256-SHA384:' . 'ECDHE-RSA-AES128-SHA256:' . 'ECDHE-RSA-AES256-SHA:' . 'ECDHE-RSA-AES128-SHA:' . 'ECDHE-RSA-RC4-SHA:' . 'DHE-RSA-AES256-GCM-SHA384:' . 'DHE-RSA-AES128-GCM-SHA256:' . 'DHE-RSA-AES256-SHA256:' . 'DHE-RSA-AES128-SHA256:' . 'DHE-RSA-AES256-SHA:' . 'DHE-RSA-AES128-SHA:' . 'AES256-GCM-SHA384:' . 'AES128-GCM-SHA256:' . 'AES256-SHA256:' . 'AES128-SHA256:' . 'AES256-SHA:' . 'AES128-SHA');
         }
         if (defined('CURLOPT_PROTOCOLS')) {
             curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
         }
         if (defined('CURLOPT_REDIR_PROTOCOLS')) {
             curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS);
         }
         curl_setopt($ch, CURLOPT_CAINFO, BackWPup::get_plugin_data('cacert'));
         curl_setopt($ch, CURLOPT_CAPATH, dirname(BackWPup::get_plugin_data('cacert')));
     } else {
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     }
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     $output = '';
     if ($echo) {
         echo curl_exec($ch);
     } else {
         curl_setopt($ch, CURLOPT_HEADER, true);
         if (0 == curl_errno($ch)) {
             $responce = explode("\r\n\r\n", curl_exec($ch), 2);
             if (!empty($responce[1])) {
                 $output = json_decode($responce[1], true);
             }
         }
     }
     $status = curl_getinfo($ch);
     if ($status['http_code'] == 503) {
         $wait = 0;
         if (preg_match("/retry-after:(.*?)\r/i", $responce[0], $matches)) {
             $wait = trim($matches[1]);
         }
         //only wait if we get a retry-after header.
         if (!empty($wait)) {
             trigger_error(sprintf('(503) Your app is making too many requests and is being rate limited. Error 503 can be triggered on a per-app or per-user basis. Wait for %d seconds.', $wait), E_USER_WARNING);
             sleep($wait);
         } else {
             throw new BackWPup_Destination_Dropbox_API_Exception('(503) This indicates a transient server error.');
         }
         //redo request
         return $this->request($url, $args, $method, $data, $echo);
     } elseif ($status['http_code'] === 400 && $method === 'PUT' && strstr($url, '/chunked_upload')) {
         //correct offset on chunk uploads
         trigger_error('(' . $status['http_code'] . ') False offset will corrected', E_USER_NOTICE);
         return $output;
     } elseif ($status['http_code'] === 404 && !empty($output['error'])) {
         trigger_error('(' . $status['http_code'] . ') ' . $output['error'], E_USER_WARNING);
         return false;
     } elseif (isset($output['error']) || $status['http_code'] >= 300 || $status['http_code'] < 200 || curl_errno($ch) > 0) {
         if (isset($output['error']) && is_string($output['error'])) {
             $args = is_array($args) ? '?' . http_build_query($args, '', '&') : $args;
             $message = '(' . $status['http_code'] . ') ' . $output['error'] . ' ' . $url . $args;
         } elseif (isset($output['error']['hash']) && $output['error']['hash'] != '') {
             $message = (string) '(' . $status['http_code'] . ') ' . $output['error']['hash'] . ' ' . $url . $args;
         } elseif (0 != curl_errno($ch)) {
             $message = '(' . curl_errno($ch) . ') ' . curl_error($ch);
         } elseif ($status['http_code'] == 304) {
             $message = '(304) Folder contents have not changed (relies on hash parameter).';
         } elseif ($status['http_code'] == 400) {
             $message = '(400) Bad input parameter: ' . strip_tags($responce[1]);
         } elseif ($status['http_code'] == 401) {
             $message = '(401) Bad or expired token. This can happen if the user or Dropbox revoked or expired an access token. To fix, you should re-authenticate the user.';
         } elseif ($status['http_code'] == 403) {
             $message = '(403) Bad OAuth request (wrong consumer key, bad nonce, expired timestamp...). Unfortunately, re-authenticating the user won\'t help here.';
         } elseif ($status['http_code'] == 404) {
             $message = '(404) File or folder not found at the specified path.';
         } elseif ($status['http_code'] == 405) {
             $message = '(405) Request method not expected (generally should be GET or POST).';
         } elseif ($status['http_code'] == 406) {
             $message = '(406) There are too many file entries to return.';
         } elseif ($status['http_code'] == 411) {
             $message = '(411) Missing Content-Length header (this endpoint doesn\'t support HTTP chunked transfer encoding).';
         } elseif ($status['http_code'] == 415) {
             $message = '(415) The image is invalid and cannot be converted to a thumbnail.';
         } elseif ($status['http_code'] == 429) {
             $message = '(429) Your app is making too many requests and is being rate limited. 429s can trigger on a per-app or per-user basis.';
         } elseif ($status['http_code'] == 507) {
             $message = '(507) User is over Dropbox storage quota.';
         } else {
             $message = '(' . $status['http_code'] . ') Invalid response.';
         }
         throw new BackWPup_Destination_Dropbox_API_Exception($message);
     } else {
         curl_close($ch);
         if (!is_array($output)) {
             return $responce[1];
         } else {
             return $output;
         }
     }
 }
 /**
  * @param $email
  * @param $password
  * @throws BackWPup_Destination_SugarSync_API_Exception
  */
 public function create_account($email, $password)
 {
     $auth = '<?xml version="1.0" encoding="UTF-8" ?>';
     $auth .= '<user>';
     $auth .= '<email>' . mb_convert_encoding($email, 'UTF-8', $this->encoding) . '</email>';
     $auth .= '<password>' . mb_convert_encoding($password, 'UTF-8', $this->encoding) . '</password>';
     $auth .= '<accessKeyId>' . get_site_option('backwpup_cfg_sugarsynckey', base64_decode("TlRBek1EY3lOakV6TkRrMk1URXhNemM0TWpJ")) . '</accessKeyId>';
     $auth .= '<privateAccessKey>' . BackWPup_Encryption::decrypt(get_site_option('backwpup_cfg_sugarsyncsecret', base64_decode("TkRFd01UazRNVEpqTW1Ga05EaG1NR0k1TVRFNFpqa3lPR1V6WlRVMk1tTQ=="))) . '</privateAccessKey>';
     $auth .= '</user>';
     // init
     $curl = curl_init();
     //set options
     curl_setopt($curl, CURLOPT_URL, 'https://provisioning-api.sugarsync.com/users');
     curl_setopt($curl, CURLOPT_USERAGENT, BackWPup::get_plugin_data('User-Agent'));
     if (ini_get('open_basedir') == '') {
         curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
     }
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
     if (BackWPup::get_plugin_data('cacert')) {
         curl_setopt($curl, CURLOPT_SSLVERSION, 1);
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, TRUE);
         curl_setopt($curl, CURLOPT_CAINFO, BackWPup::get_plugin_data('cacert'));
         curl_setopt($curl, CURLOPT_CAPATH, dirname(BackWPup::get_plugin_data('cacert')));
     } else {
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
     }
     curl_setopt($curl, CURLOPT_HEADER, TRUE);
     curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/xml; charset=UTF-8', 'Content-Length: ' . strlen($auth)));
     curl_setopt($curl, CURLOPT_POSTFIELDS, $auth);
     curl_setopt($curl, CURLOPT_POST, TRUE);
     // execute
     $response = curl_exec($curl);
     $curlgetinfo = curl_getinfo($curl);
     // fetch curl errors
     if (curl_errno($curl) != 0) {
         throw new BackWPup_Destination_SugarSync_API_Exception('cUrl Error: ' . curl_error($curl));
     }
     curl_close($curl);
     if ($curlgetinfo['http_code'] == 201) {
         throw new BackWPup_Destination_SugarSync_API_Exception('Account created.');
     } else {
         if ($curlgetinfo['http_code'] == 400) {
             throw new BackWPup_Destination_SugarSync_API_Exception('Http Error: ' . $curlgetinfo['http_code'] . ' ' . substr($response, $curlgetinfo['header_size']));
         } elseif ($curlgetinfo['http_code'] == 401) {
             throw new BackWPup_Destination_SugarSync_API_Exception('Http Error: ' . $curlgetinfo['http_code'] . ' Developer credentials cannot be verified. Either a developer with the specified accessKeyId does not exist or the privateKeyID does not match an assigned accessKeyId.');
         } elseif ($curlgetinfo['http_code'] == 403) {
             throw new BackWPup_Destination_SugarSync_API_Exception('Http Error: ' . $curlgetinfo['http_code'] . ' ' . substr($response, $curlgetinfo['header_size']));
         } elseif ($curlgetinfo['http_code'] == 503) {
             throw new BackWPup_Destination_SugarSync_API_Exception('Http Error: ' . $curlgetinfo['http_code'] . ' ' . substr($response, $curlgetinfo['header_size']));
         } else {
             throw new BackWPup_Destination_SugarSync_API_Exception('Http Error: ' . $curlgetinfo['http_code']);
         }
     }
 }
Ejemplo n.º 15
0
 /**
  * Gets a array of instances from Wizards
  *
  * @return array BackWPup_Pro_Wizards
  */
 public static function get_wizards()
 {
     if (!empty(self::$wizards)) {
         return self::$wizards;
     }
     self::$wizards = apply_filters('backwpup_pro_wizards', self::$wizards);
     //remove wizards can't load
     foreach (self::$wizards as $key => $wizard) {
         if (empty($wizard) || !is_object($wizard)) {
             unset(self::$wizards[$key]);
         }
     }
     return self::$wizards;
 }
Ejemplo n.º 16
0
 /**
  * @param $job_object
  * @return bool
  */
 public function job_run(&$job_object)
 {
     $job_object->substeps_todo = 1;
     $job_object->log(sprintf(__('%d. Trying to generate a file with installed plugin names&#160;&hellip;', 'backwpup'), $job_object->steps_data[$job_object->step_working]['STEP_TRY']));
     //build filename
     if (empty($job_object->temp['pluginlistfile'])) {
         $job_object->temp['pluginlistfile'] = $job_object->generate_filename($job_object->job['pluginlistfile'], 'txt') . $job_object->job['pluginlistfilecompression'];
     }
     if ($job_object->job['pluginlistfilecompression'] == '.gz') {
         $handle = fopen('compress.zlib://' . BackWPup::get_plugin_data('TEMP') . $job_object->temp['pluginlistfile'], 'w');
     } elseif ($job_object->job['pluginlistfilecompression'] == '.bz2') {
         $handle = fopen('compress.bzip2://' . BackWPup::get_plugin_data('TEMP') . $job_object->temp['pluginlistfile'], 'w');
     } else {
         $handle = fopen(BackWPup::get_plugin_data('TEMP') . $job_object->temp['pluginlistfile'], 'w');
     }
     //open file
     $header = "------------------------------------------------------------" . PHP_EOL;
     $header .= "  Plugin list generated with BackWPup version: " . BackWPup::get_plugin_data('Version') . PHP_EOL;
     $header .= "  " . translate(BackWPup::get_plugin_data('pluginuri'), 'backwpup') . PHP_EOL;
     $header .= "  Blog Name: " . get_bloginfo('name') . PHP_EOL;
     $header .= "  Blog URL: " . get_bloginfo('url') . PHP_EOL;
     $header .= "  Generated on: " . date_i18n('Y-m-d H:i.s') . PHP_EOL;
     $header .= "------------------------------------------------------------" . PHP_EOL . PHP_EOL;
     fwrite($handle, $header);
     //get Plugins
     if (!function_exists('get_plugins')) {
         require_once ABSPATH . 'wp-admin/includes/plugin.php';
     }
     $plugins = get_plugins();
     $plugins_active = get_option('active_plugins');
     //write it to file
     fwrite($handle, PHP_EOL . __('All plugin information:', 'backwpup') . PHP_EOL . '------------------------------' . PHP_EOL);
     foreach ($plugins as $plugin) {
         fwrite($handle, $plugin['Name'] . ' (v.' . $plugin['Version'] . ') ' . html_entity_decode(sprintf(__('from %s', 'backwpup'), $plugin['Author']), ENT_QUOTES) . PHP_EOL . "\t" . $plugin['PluginURI'] . PHP_EOL);
     }
     fwrite($handle, PHP_EOL . __('Active plugins:', 'backwpup') . PHP_EOL . '------------------------------' . PHP_EOL);
     foreach ($plugins as $key => $plugin) {
         if (in_array($key, $plugins_active)) {
             fwrite($handle, $plugin['Name'] . PHP_EOL);
         }
     }
     fwrite($handle, PHP_EOL . __('Inactive plugins:', 'backwpup') . PHP_EOL . '------------------------------' . PHP_EOL);
     foreach ($plugins as $key => $plugin) {
         if (!in_array($key, $plugins_active)) {
             fwrite($handle, $plugin['Name'] . PHP_EOL);
         }
     }
     fclose($handle);
     //add file to backup files
     if (is_readable(BackWPup::get_plugin_data('TEMP') . $job_object->temp['pluginlistfile'])) {
         $job_object->additional_files_to_backup[] = BackWPup::get_plugin_data('TEMP') . $job_object->temp['pluginlistfile'];
         $job_object->count_files++;
         $job_object->count_filesize = $job_object->count_filesize + filesize(BackWPup::get_plugin_data('TEMP') . $job_object->temp['pluginlistfile']);
         $job_object->log(sprintf(__('Added plugin list file "%1$s" with %2$s to backup file list.', 'backwpup'), $job_object->temp['pluginlistfile'], size_format(filesize(BackWPup::get_plugin_data('TEMP') . $job_object->temp['pluginlistfile']), 2)));
     }
     $job_object->substeps_done = 1;
     return TRUE;
 }
Ejemplo n.º 17
0
 /**
  * @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&#160;&hellip;', '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";
             }
             $written = file_put_contents($job_object->steps_data[$job_object->step_working]['wpexportfile'], $cats_xml, FILE_APPEND);
             if ($written === FALSE) {
                 $job_object->log(__('WP Export file could not written.', 'backwpup'), E_USER_ERROR);
                 return FALSE;
             }
             unset($cats_xml);
         }
         $job_object->steps_data[$job_object->step_working]['substep'] = 'tags';
         $job_object->substeps_done++;
         $job_object->update_working_data();
         $job_object->do_restart_time();
     }
     if ($job_object->steps_data[$job_object->step_working]['substep'] == 'tags') {
         if ('all' == $job_object->job['wpexportcontent']) {
             $tags = (array) get_tags(array('get' => 'all'));
             $tags_xml = '';
             foreach ($tags as $t) {
                 $tags_xml .= "\t<wp:tag><wp:term_id>" . $t->term_id . "</wp:term_id><wp:tag_slug>" . $t->slug . "</wp:tag_slug>" . $this->wxr_tag_name($t) . $this->wxr_tag_description($t) . "</wp:tag>\n";
             }
             $written = file_put_contents($job_object->steps_data[$job_object->step_working]['wpexportfile'], $tags_xml, FILE_APPEND);
             if ($written === FALSE) {
                 $job_object->log(__('WP Export file could not written.', 'backwpup'), E_USER_ERROR);
                 return FALSE;
             }
             unset($tags_xml);
         }
         $job_object->steps_data[$job_object->step_working]['substep'] = 'terms';
         $job_object->substeps_done++;
         $job_object->update_working_data();
         $job_object->do_restart_time();
     }
     if ($job_object->steps_data[$job_object->step_working]['substep'] == 'terms') {
         if ('all' == $job_object->job['wpexportcontent']) {
             $terms = array();
             $custom_taxonomies = get_taxonomies(array('_builtin' => false));
             $custom_terms = (array) get_terms($custom_taxonomies, array('get' => 'all'));
             // put terms in order with no child going before its parent
             while ($t = array_shift($custom_terms)) {
                 if ($t->parent == 0 || isset($terms[$t->parent])) {
                     $terms[$t->term_id] = $t;
                 } else {
                     $custom_terms[] = $t;
                 }
             }
             $terms_xml = '';
             foreach ($terms as $t) {
                 $parent_slug = $t->parent ? $terms[$t->parent]->slug : '';
                 $terms_xml .= "\t<wp:term><wp:term_id>" . $t->term_id . "</wp:term_id><wp:term_taxonomy>" . $t->taxonomy . "</wp:term_taxonomy><wp:term_slug>" . $t->slug . "</wp:term_slug><wp:term_parent>" . $parent_slug . "</wp:term_parent>" . $this->wxr_term_name($t) . $this->wxr_term_description($t) . "</wp:term>\n";
             }
             $written = file_put_contents($job_object->steps_data[$job_object->step_working]['wpexportfile'], $terms_xml, FILE_APPEND);
             if ($written === FALSE) {
                 $job_object->log(__('WP Export file could not written.', 'backwpup'), E_USER_ERROR);
                 return FALSE;
             }
             unset($terms_xml);
         }
         $job_object->steps_data[$job_object->step_working]['substep'] = 'menus';
         $job_object->substeps_done++;
         $job_object->update_working_data();
         $job_object->do_restart_time();
     }
     if ($job_object->steps_data[$job_object->step_working]['substep'] == 'menus') {
         $menu_xml = '';
         if ('all' == $job_object->job['wpexportcontent']) {
             $menu_xml .= $this->wxr_nav_menu_terms();
         }
         $menu_xml .= "\t<generator>http://wordpress.org/?v=" . get_bloginfo_rss('version') . "</generator>\n";
         $written = file_put_contents($job_object->steps_data[$job_object->step_working]['wpexportfile'], $menu_xml, FILE_APPEND);
         if ($written === FALSE) {
             $job_object->log(__('WP Export file could not written.', 'backwpup'), E_USER_ERROR);
             return FALSE;
         }
         unset($menu_xml);
         $job_object->steps_data[$job_object->step_working]['substep'] = 'posts';
         $job_object->substeps_done++;
         $job_object->update_working_data();
         $job_object->do_restart_time();
     }
     if ($job_object->steps_data[$job_object->step_working]['substep'] == 'posts') {
         if (!empty($job_object->steps_data[$job_object->step_working]['post_ids'])) {
             $wp_query->in_the_loop = true;
             // Fake being in the loop.
             // fetch 20 posts at a time rather than loading the entire table into memory
             while ($next_posts = array_splice($job_object->steps_data[$job_object->step_working]['post_ids'], 0, 20)) {
                 $where = 'WHERE ID IN (' . join(',', $next_posts) . ')';
                 $posts = $wpdb->get_results("SELECT * FROM {$wpdb->posts} {$where}");
                 $wxr_post = '';
                 // Begin Loop
                 foreach ($posts as $post) {
                     /* @var WP_Post $post */
                     $is_sticky = is_sticky($post->ID) ? 1 : 0;
                     $wxr_post .= "\t<item>\n";
                     $wxr_post .= "\t\t<title>" . apply_filters('the_title_rss', $post->post_title) . "</title>\n";
                     $wxr_post .= "\t\t<link>" . esc_url(apply_filters('the_permalink_rss', get_permalink($post))) . "</link>\n";
                     $wxr_post .= "\t\t<pubDate>" . mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true, $post), false) . "</pubDate>\n";
                     $wxr_post .= "\t\t<dc:creator>" . $this->wxr_cdata(get_the_author_meta('login', $post->post_author)) . "</dc:creator>\n";
                     $wxr_post .= "\t\t<guid isPermaLink=\"false\">" . esc_url(get_the_guid($post->ID)) . "</guid>\n";
                     $wxr_post .= "\t\t<description></description>\n";
                     $wxr_post .= "\t\t<content:encoded>" . $this->wxr_cdata(apply_filters('the_content_export', $post->post_content)) . "</content:encoded>\n";
                     $wxr_post .= "\t\t<excerpt:encoded>" . $this->wxr_cdata(apply_filters('the_excerpt_export', $post->post_excerpt)) . "</excerpt:encoded>\n";
                     $wxr_post .= "\t\t<wp:post_id>" . $post->ID . "</wp:post_id>\n";
                     $wxr_post .= "\t\t<wp:post_date>" . $post->post_date . "</wp:post_date>\n";
                     $wxr_post .= "\t\t<wp:post_date_gmt>" . $post->post_date_gmt . "</wp:post_date_gmt>\n";
                     $wxr_post .= "\t\t<wp:comment_status>" . $post->comment_status . "</wp:comment_status>\n";
                     $wxr_post .= "\t\t<wp:ping_status>" . $post->ping_status . "</wp:ping_status>\n";
                     $wxr_post .= "\t\t<wp:post_name>" . $post->post_name . "</wp:post_name>\n";
                     $wxr_post .= "\t\t<wp:status>" . $post->post_status . "</wp:status>\n";
                     $wxr_post .= "\t\t<wp:post_parent>" . $post->post_parent . "</wp:post_parent>\n";
                     $wxr_post .= "\t\t<wp:menu_order>" . $post->menu_order . "</wp:menu_order>\n";
                     $wxr_post .= "\t\t<wp:post_type>" . $post->post_type . "</wp:post_type>\n";
                     $wxr_post .= "\t\t<wp:post_password>" . $post->post_password . "</wp:post_password>\n";
                     $wxr_post .= "\t\t<wp:is_sticky>" . $is_sticky . "</wp:is_sticky>\n";
                     if ($post->post_type == 'attachment') {
                         $wxr_post .= "\t\t<wp:attachment_url>" . wp_get_attachment_url($post->ID) . "</wp:attachment_url>\n";
                     }
                     $wxr_post .= $this->wxr_post_taxonomy();
                     $postmeta = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE post_id = %d", $post->ID));
                     foreach ($postmeta as $meta) {
                         if (apply_filters('wxr_export_skip_postmeta', false, $meta->meta_key, $meta)) {
                             continue;
                         }
                         $wxr_post .= "\t\t<wp:postmeta>\n\t\t\t<wp:meta_key>" . $meta->meta_key . "</wp:meta_key>\n\t\t\t<wp:meta_value>" . $this->wxr_cdata($meta->meta_value) . "</wp:meta_value>\n\t\t</wp:postmeta>\n";
                     }
                     $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID));
                     foreach ($comments as $c) {
                         $wxr_post .= "\t\t<wp:comment>\n";
                         $wxr_post .= "\t\t\t<wp:comment_id>" . $c->comment_ID . "</wp:comment_id>\n";
                         $wxr_post .= "\t\t\t<wp:comment_author>" . $this->wxr_cdata($c->comment_author) . "</wp:comment_author>\n";
                         $wxr_post .= "\t\t\t<wp:comment_author_email>" . $c->comment_author_email . "</wp:comment_author_email>\n";
                         $wxr_post .= "\t\t\t<wp:comment_author_url>" . esc_url_raw($c->comment_author_url) . "</wp:comment_author_url>\n";
                         $wxr_post .= "\t\t\t<wp:comment_author_IP>" . $c->comment_author_IP . "</wp:comment_author_IP>\n";
                         $wxr_post .= "\t\t\t<wp:comment_date>" . $c->comment_date . "</wp:comment_date>\n";
                         $wxr_post .= "\t\t\t<wp:comment_date_gmt>" . $c->comment_date_gmt . "</wp:comment_date_gmt>\n";
                         $wxr_post .= "\t\t\t<wp:comment_content>" . $this->wxr_cdata($c->comment_content) . "</wp:comment_content>\n";
                         $wxr_post .= "\t\t\t<wp:comment_approved>" . $c->comment_approved . "</wp:comment_approved>\n";
                         $wxr_post .= "\t\t\t<wp:comment_type>" . $c->comment_type . "</wp:comment_type>\n";
                         $wxr_post .= "\t\t\t<wp:comment_parent>" . $c->comment_parent . "</wp:comment_parent>\n";
                         $wxr_post .= "\t\t\t<wp:comment_user_id>" . $c->user_id . "</wp:comment_user_id>\n";
                         $c_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->commentmeta} WHERE comment_id = %d", $c->comment_ID));
                         foreach ($c_meta as $meta) {
                             $wxr_post .= "\t\t\t<wp:commentmeta>\n\t\t\t\t<wp:meta_key>" . $meta->meta_key . "</wp:meta_key>\n\t\t\t\t<wp:meta_value>" . $this->wxr_cdata($meta->meta_value) . "</wp:meta_value>\n\t\t\t</wp:commentmeta>\n";
                         }
                         $wxr_post .= "\t\t</wp:comment>\n";
                     }
                     $wxr_post .= "\t</item>\n";
                     $job_object->substeps_done++;
                 }
                 $written = file_put_contents($job_object->steps_data[$job_object->step_working]['wpexportfile'], $wxr_post, FILE_APPEND);
                 if ($written === FALSE) {
                     $job_object->log(__('WP Export file could not written.', 'backwpup'), E_USER_ERROR);
                     return FALSE;
                 }
                 $job_object->do_restart_time();
             }
         }
         $written = file_put_contents($job_object->steps_data[$job_object->step_working]['wpexportfile'], "</channel>\n</rss>", 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'] = 'check';
         $job_object->substeps_done++;
         $job_object->update_working_data();
         $job_object->do_restart_time();
     }
     remove_filter('wxr_export_skip_postmeta', array($this, 'wxr_filter_postmeta'), 10);
     if ($job_object->steps_data[$job_object->step_working]['substep'] == 'check') {
         if (extension_loaded('simplexml') && class_exists('DOMDocument')) {
             $job_object->log(__('Check WP Export file&#160;&hellip;', 'backwpup'));
             $job_object->need_free_memory(filesize($job_object->steps_data[$job_object->step_working]['wpexportfile']) * 2);
             $valid = TRUE;
             $internal_errors = libxml_use_internal_errors(TRUE);
             $dom = new DOMDocument();
             $old_value = NULL;
             if (function_exists('libxml_disable_entity_loader')) {
                 $old_value = libxml_disable_entity_loader(TRUE);
             }
             $success = $dom->loadXML(file_get_contents($job_object->steps_data[$job_object->step_working]['wpexportfile']));
             if (!is_null($old_value)) {
                 libxml_disable_entity_loader($old_value);
             }
             if (!$success || isset($dom->doctype)) {
                 $errors = libxml_get_errors();
                 $valid = FALSE;
                 foreach ($errors as $error) {
                     switch ($error->level) {
                         case LIBXML_ERR_WARNING:
                             $job_object->log(E_USER_WARNING, sprintf(__('XML WARNING (%s): %s', 'backwpup'), $error->code, trim($error->message)), $job_object->steps_data[$job_object->step_working]['wpexportfile'], $error->line);
                             break;
                         case LIBXML_ERR_ERROR:
                             $job_object->log(E_USER_WARNING, sprintf(__('XML RECOVERABLE (%s): %s', 'backwpup'), $error->code, trim($error->message)), $job_object->steps_data[$job_object->step_working]['wpexportfile'], $error->line);
                             break;
                         case LIBXML_ERR_FATAL:
                             $job_object->log(E_USER_WARNING, sprintf(__('XML ERROR (%s): %s', 'backwpup'), $error->code, trim($error->message)), $job_object->steps_data[$job_object->step_working]['wpexportfile'], $error->line);
                             break;
                     }
                 }
             } else {
                 $xml = simplexml_import_dom($dom);
                 unset($dom);
                 // halt if loading produces an error
                 if (!$xml) {
                     $job_object->log(__('There was an error when reading this WXR file', 'backwpup'), E_USER_ERROR);
                     $valid = FALSE;
                 } else {
                     $wxr_version = $xml->xpath('/rss/channel/wp:wxr_version');
                     if (!$wxr_version) {
                         $job_object->log(__('This does not appear to be a WXR file, missing/invalid WXR version number', 'backwpup'), E_USER_ERROR);
                         $valid = FALSE;
                     }
                     $wxr_version = (string) trim($wxr_version[0]);
                     // confirm that we are dealing with the correct file format
                     if (!preg_match('/^\\d+\\.\\d+$/', $wxr_version)) {
                         $job_object->log(__('This does not appear to be a WXR file, missing/invalid WXR version number', 'backwpup'), E_USER_ERROR);
                         $valid = FALSE;
                     }
                 }
             }
             libxml_use_internal_errors($internal_errors);
             if ($valid) {
                 $job_object->log(__('WP Export file is a valid WXR file.', 'backwpup'));
             }
         } else {
             $job_object->log(__('WP Export file can not be checked, because no XML extension is loaded, to ensure the file verification.', 'backwpup'));
         }
         $job_object->steps_data[$job_object->step_working]['substep'] = 'compress';
         $job_object->substeps_done++;
         $job_object->update_working_data();
         $job_object->do_restart_time();
     }
     //Compress file
     if ($job_object->steps_data[$job_object->step_working]['substep'] == 'compress') {
         if (!empty($job_object->job['wpexportfilecompression'])) {
             $job_object->log(__('Compressing file&#160;&hellip;', 'backwpup'));
             try {
                 $compress = new BackWPup_Create_Archive($job_object->steps_data[$job_object->step_working]['wpexportfile'] . $job_object->job['wpexportfilecompression']);
                 if ($compress->add_file($job_object->steps_data[$job_object->step_working]['wpexportfile'])) {
                     unset($compress);
                     unlink($job_object->steps_data[$job_object->step_working]['wpexportfile']);
                     $job_object->steps_data[$job_object->step_working]['wpexportfile'] .= $job_object->job['wpexportfilecompression'];
                     $job_object->log(__('Compressing done.', 'backwpup'));
                 }
             } catch (Exception $e) {
                 $job_object->log($e->getMessage(), E_USER_ERROR, $e->getFile(), $e->getLine());
                 unset($compress);
                 return FALSE;
             }
         }
         $job_object->steps_data[$job_object->step_working]['substep'] = 'addfile';
         $job_object->substeps_done++;
         $job_object->update_working_data();
         $job_object->do_restart_time();
     }
     if ($job_object->steps_data[$job_object->step_working]['substep'] == 'addfile') {
         //add XML file to backup files
         if (is_readable($job_object->steps_data[$job_object->step_working]['wpexportfile'])) {
             $job_object->additional_files_to_backup[] = $job_object->steps_data[$job_object->step_working]['wpexportfile'];
             $filesize = filesize($job_object->steps_data[$job_object->step_working]['wpexportfile']);
             $job_object->log(sprintf(__('Added XML export "%1$s" with %2$s to backup file list.', 'backwpup'), basename($job_object->steps_data[$job_object->step_working]['wpexportfile']), size_format($filesize, 2)));
         }
         $job_object->substeps_done++;
         $job_object->update_working_data();
     }
     return TRUE;
 }
Ejemplo n.º 18
0
 /**
  * @param string $args
  */
 public function edit_ajax($args = '')
 {
     $error = '';
     $buckets_list = array();
     if (is_array($args)) {
         $ajax = FALSE;
     } else {
         if (!current_user_can('backwpup_jobs_edit')) {
             wp_die(-1);
         }
         check_ajax_referer('backwpup_ajax_nonce');
         $args['s3accesskey'] = sanitize_text_field($_POST['s3accesskey']);
         $args['s3secretkey'] = sanitize_text_field($_POST['s3secretkey']);
         $args['s3bucketselected'] = sanitize_text_field($_POST['s3bucketselected']);
         $args['s3base_url'] = esc_url_raw($_POST['s3base_url']);
         $args['s3region'] = sanitize_text_field($_POST['s3region']);
         $ajax = TRUE;
     }
     echo '<span id="s3bucketerror" style="color:red;">';
     if (!empty($args['s3accesskey']) && !empty($args['s3secretkey'])) {
         try {
             $s3 = Aws\S3\S3Client::factory(array('key' => $args['s3accesskey'], 'secret' => BackWPup_Encryption::decrypt($args['s3secretkey']), 'region' => $args['s3region'], 'base_url' => $this->get_s3_base_url($args['s3region'], $args['s3base_url']), 'scheme' => 'https', 'ssl.certificate_authority' => BackWPup::get_plugin_data('cacert')));
             $buckets = $s3->listBuckets();
             if (!empty($buckets['Buckets'])) {
                 $buckets_list = $buckets['Buckets'];
             }
             while (!empty($vaults['Marker'])) {
                 $buckets = $s3->listBuckets(array('marker' => $buckets['Marker']));
                 if (!empty($buckets['Buckets'])) {
                     $buckets_list = array_merge($buckets_list, $buckets['Buckets']);
                 }
             }
         } catch (Exception $e) {
             $error = $e->getMessage();
         }
     }
     if (empty($args['s3accesskey'])) {
         _e('Missing access key!', 'backwpup');
     } elseif (empty($args['s3secretkey'])) {
         _e('Missing secret access key!', 'backwpup');
     } elseif (!empty($error) && $error == 'Access Denied') {
         echo '<input type="text" name="s3bucket" id="s3bucket" value="' . esc_attr($args['s3bucketselected']) . '" >';
     } elseif (!empty($error)) {
         echo esc_html($error);
     } elseif (!isset($buckets) || count($buckets['Buckets']) < 1) {
         _e('No bucket found!', 'backwpup');
     }
     echo '</span>';
     if (!empty($buckets_list)) {
         echo '<select name="s3bucket" id="s3bucket">';
         foreach ($buckets_list as $bucket) {
             echo "<option " . selected($args['s3bucketselected'], esc_attr($bucket['Name']), FALSE) . ">" . esc_attr($bucket['Name']) . "</option>";
         }
         echo '</select>';
     }
     if ($ajax) {
         die;
     }
 }
Ejemplo n.º 19
0
 /**
  * Creates DB und updates settings
  */
 public static function activate()
 {
     //convert inactive version to active
     if ($incative_version = get_site_option('backwpup_version')) {
         update_site_option('backwpup_version', str_replace('-inactive', '', $incative_version));
     }
     //changes for version before 3.0.0
     if (!get_site_option('backwpup_version') && get_option('backwpup') && get_option('backwpup_jobs')) {
         self::upgrade_from_version_two();
     }
     //changes for version before 3.0.14
     if (version_compare('3.0.13', get_site_option('backwpup_version'), '>') && version_compare('3.0', get_site_option('backwpup_version'), '<')) {
         $upload_dir = wp_upload_dir();
         $logfolder = get_site_option('backwpup_cfg_logfolder');
         if (empty($logfolder)) {
             $old_log_folder = trailingslashit(str_replace('\\', '/', $upload_dir['basedir'])) . 'backwpup-' . substr(md5(md5(SECURE_AUTH_KEY)), 9, 5) . '-logs/';
             update_site_option('backwpup_cfg_logfolder', $old_log_folder);
         }
     }
     //changes for 3.2
     $no_translation = get_site_option('backwpup_cfg_jobnotranslate');
     if ($no_translation) {
         update_site_option('backwpup_cfg_loglevel', 'normal');
         delete_site_option('backwpup_cfg_jobnotranslate');
     }
     //create new options
     if (is_multisite()) {
         add_site_option('backwpup_jobs', array());
     } else {
         add_option('backwpup_jobs', array(), NULL, 'no');
     }
     //remove old schedule
     wp_clear_scheduled_hook('backwpup_cron');
     //make new schedule
     $activejobs = BackWPup_Option::get_job_ids('activetype', 'wpcron');
     if (!empty($activejobs)) {
         foreach ($activejobs as $id) {
             $cron_next = BackWPup_Cron::cron_next(BackWPup_Option::get($id, 'cron'));
             wp_schedule_single_event($cron_next, 'backwpup_cron', array('id' => $id));
         }
     }
     $activejobs = BackWPup_Option::get_job_ids('activetype', 'easycron');
     if (!empty($activejobs)) {
         foreach ($activejobs as $id) {
             BackWPup_EasyCron::update($id);
         }
     }
     //add check Cleanup schedule
     wp_clear_scheduled_hook('backwpup_check_cleanup');
     wp_schedule_event(time(), 'twicedaily', 'backwpup_check_cleanup');
     //add capabilities to administrator role
     $role = get_role('administrator');
     if (is_object($role) && method_exists($role, 'add_cap')) {
         $role->add_cap('backwpup');
         $role->add_cap('backwpup_jobs');
         $role->add_cap('backwpup_jobs_edit');
         $role->add_cap('backwpup_jobs_start');
         $role->add_cap('backwpup_backups');
         $role->add_cap('backwpup_backups_download');
         $role->add_cap('backwpup_backups_delete');
         $role->add_cap('backwpup_logs');
         $role->add_cap('backwpup_logs_delete');
         $role->add_cap('backwpup_settings');
     }
     //add/overwrite roles
     add_role('backwpup_admin', __('BackWPup Admin', 'backwpup'), array('read' => TRUE, 'backwpup' => TRUE, 'backwpup_jobs' => TRUE, 'backwpup_jobs_edit' => TRUE, 'backwpup_jobs_start' => TRUE, 'backwpup_backups' => TRUE, 'backwpup_backups_download' => TRUE, 'backwpup_backups_delete' => TRUE, 'backwpup_logs' => TRUE, 'backwpup_logs_delete' => TRUE, 'backwpup_settings' => TRUE));
     add_role('backwpup_check', __('BackWPup jobs checker', 'backwpup'), array('read' => TRUE, 'backwpup' => TRUE, 'backwpup_jobs' => TRUE, 'backwpup_jobs_edit' => FALSE, 'backwpup_jobs_start' => FALSE, 'backwpup_backups' => TRUE, 'backwpup_backups_download' => FALSE, 'backwpup_backups_delete' => FALSE, 'backwpup_logs' => TRUE, 'backwpup_logs_delete' => FALSE, 'backwpup_settings' => FALSE));
     add_role('backwpup_helper', __('BackWPup jobs helper', 'backwpup'), array('read' => TRUE, 'backwpup' => TRUE, 'backwpup_jobs' => TRUE, 'backwpup_jobs_edit' => FALSE, 'backwpup_jobs_start' => TRUE, 'backwpup_backups' => TRUE, 'backwpup_backups_download' => TRUE, 'backwpup_backups_delete' => TRUE, 'backwpup_logs' => TRUE, 'backwpup_logs_delete' => TRUE, 'backwpup_settings' => FALSE));
     //add default options
     BackWPup_Option::default_site_options();
     //update version
     update_site_option('backwpup_version', BackWPup::get_plugin_data('Version'));
 }
Ejemplo n.º 20
0
    /**
     * Page Output
     */
    public static function page()
    {
        global $wpdb;
        ?>
    <div class="wrap" id="backwpup-page">
		<h2><span id="backwpup-page-icon">&nbsp;</span><?php 
        echo sprintf(__('%s Settings', 'backwpup'), BackWPup::get_plugin_data('name'));
        ?>
</h2>
		<?php 
        $tabs = array('general' => __('General', 'backwpup'), 'job' => __('Jobs', 'backwpup'), 'log' => __('Logs', 'backwpup'), 'net' => __('Network', 'backwpup'), 'apikey' => __('API Keys', 'backwpup'), 'information' => __('Information', 'backwpup'));
        $tabs = apply_filters('backwpup_page_settings_tab', $tabs);
        echo '<h2 class="nav-tab-wrapper">';
        foreach ($tabs as $id => $name) {
            echo '<a href="#backwpup-tab-' . $id . '" class="nav-tab">' . $name . '</a>';
        }
        echo '</h2>';
        BackWPup_Admin::display_messages();
        ?>

    <form id="settingsform" action="<?php 
        echo admin_url('admin-post.php?action=backwpup');
        ?>
" method="post">
		<?php 
        wp_nonce_field('backwpupsettings_page');
        ?>
        <input type="hidden" name="page" value="backwpupsettings" />
    	<input type="hidden" name="anchor" value="#backwpup-tab-general" />

		<div class="table ui-tabs-hide" id="backwpup-tab-general">

			<h3 class="title"><?php 
        _e('Display Settings', 'backwpup');
        ?>
</h3>
            <p><?php 
        _e('Do you want to see BackWPup in the WordPress admin bar?', 'backwpup');
        ?>
</p>
            <table class="form-table">
                <tr>
                    <th scope="row"><?php 
        _e('Admin bar', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Admin Bar', 'backwpup');
        ?>
</span>
                            </legend>
                            <label for="showadminbar">
                                <input name="showadminbar" type="checkbox" id="showadminbar"
                                       value="1" <?php 
        checked(get_site_option('backwpup_cfg_showadminbar'), TRUE);
        ?>
 />
								<?php 
        _e('Show BackWPup links in admin bar.', 'backwpup');
        ?>
</label>
                        </fieldset>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Folder sizes', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Folder sizes', 'backwpup');
        ?>
</span>
                            </legend>
                            <label for="showfoldersize">
                                <input name="showfoldersize" type="checkbox" id="showfoldersize"
                                       value="1" <?php 
        checked(get_site_option('backwpup_cfg_showfoldersize'), TRUE);
        ?>
 />
								<?php 
        _e('Display folder sizes in the files tab when editing a job. (Might increase loading time of files tab.)', 'backwpup');
        ?>
</label>
                        </fieldset>
                    </td>
                </tr>
            </table>
			<h3 class="title"><?php 
        _e('Security', 'backwpup');
        ?>
</h3>
			<p><?php 
        _e('Security option for BackWPup', 'backwpup');
        ?>
</p>
            <table class="form-table">
                <tr>
                    <th scope="row"><?php 
        _e('Protect folders', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Protect folders', 'backwpup');
        ?>
</span>
                            </legend>
                            <label for="protectfolders">
                                <input name="protectfolders" type="checkbox" id="protectfolders"
                                       value="1" <?php 
        checked(get_site_option('backwpup_cfg_protectfolders'), TRUE);
        ?>
 />
								<?php 
        _e('Protect BackWPup folders ( Temp, Log and Backups ) with <code>.htaccess</code> and <code>index.php</code>', 'backwpup');
        ?>
                            </label>
                        </fieldset>
                    </td>
                </tr>
            </table>

			<?php 
        do_action('backwpup_page_settings_tab_generel');
        ?>

		</div>

        <div class="table ui-tabs-hide" id="backwpup-tab-log">

            <p><?php 
        _e('Every time BackWPup runs a backup job, a log file is being generated. Choose where to store your log files and how many of them.', 'backwpup');
        ?>
</p>
            <table class="form-table">
                <tr>
                    <th scope="row"><label for="logfolder"><?php 
        _e('Log file folder', 'backwpup');
        ?>
</label></th>
                    <td>
                        <input name="logfolder" type="text" id="logfolder"
                               value="<?php 
        echo get_site_option('backwpup_cfg_logfolder');
        ?>
"
                               class="regular-text code"/>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><label for="maxlogs"><?php 
        _e('Maximum number of log files in folder', 'backwpup');
        ?>
</label>
                    </th>
                    <td>
                        <input name="maxlogs" type="text" id="maxlogs" title="<?php 
        esc_attr_e('Oldest files will be deleted first.', 'backwpup');
        ?>
"
                               value="<?php 
        echo get_site_option('backwpup_cfg_maxlogs');
        ?>
" class="small-text code help-tip"/>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Compression', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Compression', 'backwpup');
        ?>
</span>
                            </legend>
                            <label for="gzlogs">
                                <input name="gzlogs" type="checkbox" id="gzlogs"
                                       value="1" <?php 
        checked(get_site_option('backwpup_cfg_gzlogs'), TRUE);
        if (!function_exists('gzopen')) {
            echo " disabled=\"disabled\"";
        }
        ?>
 />
								<?php 
        _e('Compress log files with GZip.', 'backwpup');
        ?>
</label>
                        </fieldset>
                    </td>
                </tr>
            </table>

        </div>
        <div class="table ui-tabs-hide" id="backwpup-tab-job">

            <p><?php 
        _e('There are a couple of general options for backup jobs. Set them here.', 'backwpup');
        ?>
</p>
            <table class="form-table">
                <tr>
                    <th scope="row">
                        <label for="jobstepretry"><?php 
        _e("Maximum number of retries for job steps", 'backwpup');
        ?>
</label></th>
                    <td>
                        <input name="jobstepretry" type="text" id="jobstepretry"
                               value="<?php 
        echo get_site_option('backwpup_cfg_jobstepretry');
        ?>
"
                               class="small-text code" />
                    </td>
                </tr>
				<tr>
                    <th scope="row"><?php 
        _e('Maximum script execution time', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Maximum PHP Script execution time', 'backwpup');
        ?>
</span>
                            </legend>
                            <label for="jobmaxexecutiontime">
                                <input name="jobmaxexecutiontime" type="text" id="jobmaxexecutiontime" size="3" title="<?php 
        esc_attr_e('Job will restart before hitting maximum execution time. It will not work with CLI and not on every step during execution. If <code>ALTERNATE_WP_CRON</code> has been defined, WordPress Cron will be used.', 'backwpup');
        ?>
"
                                       value="<?php 
        echo get_site_option('backwpup_cfg_jobmaxexecutiontime');
        ?>
" class="help-tip" />
								<?php 
        _e('seconds. 0 = disabled.', 'backwpup');
        ?>
							</label>
                        </fieldset>
                    </td>
                </tr>
				<tr>
                    <th scope="row"><?php 
        _e('Method for creating ZIP-file archives', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Method for creating ZIP-file archives', 'backwpup');
        ?>
</span>
                            </legend>
                            <label for="jobziparchivemethod">
								<select name="jobziparchivemethod" size="1" class="help-tip" title="<?php 
        esc_attr_e('Auto = Uses PHP class ZipArchive if available; otherwise uses PclZip.<br />ZipArchive = Uses less memory, but many open files at a time.<br />PclZip = Uses more memory, but only 2 open files at a time.', 'backwpup');
        ?>
">
									<option value="" <?php 
        selected(get_site_option('backwpup_cfg_jobziparchivemethod'), '');
        ?>
><?php 
        _e('Auto', 'backwpup');
        ?>
</option>
                                    <option value="ZipArchive" <?php 
        selected(get_site_option('backwpup_cfg_jobziparchivemethod'), 'ZipArchive');
        disabled(function_exists('ZipArchive'), TRUE);
        ?>
><?php 
        _e('ZipArchive', 'backwpup');
        ?>
</option>
                                    <option value="PclZip" <?php 
        selected(get_site_option('backwpup_cfg_jobziparchivemethod'), 'PclZip');
        ?>
><?php 
        _e('PclZip', 'backwpup');
        ?>
</option>
                                </select>
                            </label>
                        </fieldset>
                    </td>
                </tr>
                <tr>
                    <th scope="row">
                        <label for="jobrunauthkey"><?php 
        _e('Key to start jobs externally with an URL', 'backwpup');
        ?>
</label>
                    </th>
                    <td>
                        <input name="jobrunauthkey" type="text" id="jobrunauthkey" title="<?php 
        esc_attr_e('empty = deactivated. Will be used to protect job starts from unauthorized person.', 'backwpup');
        ?>
"
                               value="<?php 
        echo get_site_option('backwpup_cfg_jobrunauthkey');
        ?>
" class="text code help-tip"/>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('No translation', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('No Translation', 'backwpup');
        ?>
</span>
                            </legend>
                            <label for="jobnotranslate">
                                <input name="jobnotranslate" type="checkbox" id="jobnotranslate"
                                       value="1" <?php 
        checked(get_site_option('backwpup_cfg_jobnotranslate'), TRUE);
        ?>
 />
								<?php 
        _e('No translation for the job, the log will be written in English', 'backwpup');
        ?>
                            </label>
                        </fieldset>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Reduce server load', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Reduce server load', 'backwpup');
        ?>
</span>
                            </legend>
                            <label for="jobwaittimems">
								<select name="jobwaittimems" size="1" class="help-tip" title="<?php 
        esc_attr_e('This adds short pauses to the process. Can be used to reduce the CPU load.<br /> Disabled = off<br /> minimum = shortest sleep<br /> medium = middle between minimum and maximum<br /> maximum = longest sleep<br />', 'backwpup');
        ?>
">
									<option value="0" <?php 
        selected(get_site_option('backwpup_cfg_jobwaittimems'), 0);
        ?>
><?php 
        _e('disabled', 'backwpup');
        ?>
</option>
                                    <option value="10000" <?php 
        selected(get_site_option('backwpup_cfg_jobwaittimems'), 10000);
        ?>
><?php 
        _e('minimum', 'backwpup');
        ?>
</option>
                                    <option value="30000" <?php 
        selected(get_site_option('backwpup_cfg_jobwaittimems'), 30000);
        ?>
><?php 
        _e('medium', 'backwpup');
        ?>
</option>
                                    <option value="90000" <?php 
        selected(get_site_option('backwpup_cfg_jobwaittimems'), 90000);
        ?>
><?php 
        _e('maximum', 'backwpup');
        ?>
</option>
                                </select>
                            </label>
                        </fieldset>
                    </td>
                </tr>
            </table>

        </div>

        <div class="table ui-tabs-hide" id="backwpup-tab-net">

			<h3 class="title"><?php 
        _e('Authentication', 'backwpup');
        ?>
</h3>
            <p><?php 
        _e('Is your blog protected with HTTP basic authentication (.htaccess)? If yes, please set the username and password for authentication here.', 'backwpup');
        ?>
</p>
            <table class="form-table">
                <tr>
                    <th scope="row"><label for="httpauthuser"><?php 
        _e('Username:'******'backwpup');
        ?>
</label></th>
                    <td>
                        <input name="httpauthuser" type="text" id="httpauthuser"
                               value="<?php 
        echo get_site_option('backwpup_cfg_httpauthuser');
        ?>
"
                               class="regular-text" autocomplete="off" />
                    </td>
                </tr>
                <tr>
                    <th scope="row"><label for="httpauthpassword"><?php 
        _e('Password:'******'backwpup');
        ?>
</label></th>
                    <td>
                        <input name="httpauthpassword" type="password" id="httpauthpassword"
                               value="<?php 
        echo BackWPup_Encryption::decrypt(get_site_option('backwpup_cfg_httpauthpassword'));
        ?>
"
                               class="regular-text" autocomplete="off" />
                </tr>
            </table>

        </div>

        <div class="table ui-tabs-hide" id="backwpup-tab-apikey">

			<?php 
        do_action('backwpup_page_settings_tab_apikey');
        ?>

        </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="&gt;=3.2"><td>' . __('WordPress version', 'backwpup') . '</td><td>' . BackWPup::get_plugin_data('wp_version') . '</td></tr>';
        if (!class_exists('BackWPup_Pro', FALSE)) {
            echo '<tr title=""><td>' . __('BackWPup version', 'backwpup') . '</td><td>' . BackWPup::get_plugin_data('Version') . ' <a href="' . translate(BackWPup::get_plugin_data('pluginuri'), 'backwpup') . '">' . __('Get pro.', 'backwpup') . '</a></td></tr>';
        } else {
            echo '<tr title=""><td>' . __('BackWPup Pro version', 'backwpup') . '</td><td>' . BackWPup::get_plugin_data('Version') . '</td></tr>';
        }
        echo '<tr title="&gt;=5.3.3"><td>' . __('PHP version', 'backwpup') . '</td><td>' . PHP_VERSION . '</td></tr>';
        echo '<tr title="&gt;=5.0.7"><td>' . __('MySQL version', 'backwpup') . '</td><td>' . $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>' . $curlversion['version'] . '</td></tr>';
            echo '<tr title=""><td>' . __('cURL SSL version', 'backwpup') . '</td><td>' . $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');
        $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));
        }
        $headers = wp_remote_retrieve_headers($raw_response);
        if (isset($headers['x-backwpup-ver']) && $headers['x-backwpup-ver'] != BackWPup::get_plugin_data('version')) {
            $test_result .= sprintf(__('The BackWPup HTTP response header returns a false value: "%s"', 'backwpup'), $headers['x-backwpup-ver']);
        }
        if (empty($test_result)) {
            _e('Response Test O.K.', 'backwpup');
        } else {
            echo $test_result;
        }
        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'), BackWPup::get_plugin_data('TEMP'));
        } elseif (!is_writable(BackWPup::get_plugin_data('TEMP'))) {
            echo sprintf(__('Temporary folder %s is not writable.', 'backwpup'), BackWPup::get_plugin_data('TEMP'));
        } else {
            echo BackWPup::get_plugin_data('TEMP');
        }
        echo '</td></tr>';
        echo '<tr><td>' . __('Log folder:', 'backwpup') . '</td><td>';
        if (!is_dir(get_site_option('backwpup_cfg_logfolder'))) {
            echo sprintf(__('Logs folder %s not exist.', 'backwpup'), get_site_option('backwpup_cfg_logfolder'));
        } elseif (!is_writable(get_site_option('backwpup_cfg_logfolder'))) {
            echo sprintf(__('Log folder %s is not writable.', 'backwpup'), get_site_option('backwpup_cfg_logfolder'));
        } else {
            echo get_site_option('backwpup_cfg_logfolder');
        }
        echo '</td></tr>';
        echo '<tr title=""><td>' . __('Server', 'backwpup') . '</td><td>' . $_SERVER['SERVER_SOFTWARE'] . '</td></tr>';
        echo '<tr title=""><td>' . __('Operating System', 'backwpup') . '</td><td>' . PHP_OS . '</td></tr>';
        echo '<tr title=""><td>' . __('PHP SAPI', 'backwpup') . '</td><td>' . PHP_SAPI . '</td></tr>';
        echo '<tr title=""><td>' . __('Current PHP user', 'backwpup') . '</td><td>' . get_current_user() . '</td></tr>';
        $text = (bool) ini_get('safe_mode') ? __('On', 'backwpup') : __('Off', 'backwpup');
        echo '<tr title=""><td>' . __('Safe Mode', 'backwpup') . '</td><td>' . $text . '</td></tr>';
        echo '<tr title="&gt;=30"><td>' . __('Maximum execution time', 'backwpup') . '</td><td>' . ini_get('max_execution_time') . ' ' . __('seconds', 'backwpup') . '</td></tr>';
        if (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
            echo '<tr title="ALTERNATE_WP_CRON"><td>' . __('Alternative WP Cron', 'backwpup') . '</td><td>' . __('On', 'backwpup') . '</td></tr>';
        } else {
            echo '<tr title="ALTERNATE_WP_CRON"><td>' . __('Alternative WP Cron', 'backwpup') . '</td><td>' . __('Off', 'backwpup') . '</td></tr>';
        }
        if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON) {
            echo '<tr title="DISABLE_WP_CRON"><td>' . __('Disabled WP Cron', 'backwpup') . '</td><td>' . __('On', 'backwpup') . '</td></tr>';
        } else {
            echo '<tr title="DISABLE_WP_CRON"><td>' . __('Disabled WP Cron', 'backwpup') . '</td><td>' . __('Off', 'backwpup') . '</td></tr>';
        }
        if (defined('FS_CHMOD_DIR')) {
            echo '<tr title="FS_CHMOD_DIR"><td>' . __('CHMOD Dir', 'backwpup') . '</td><td>' . FS_CHMOD_DIR . '</td></tr>';
        } else {
            echo '<tr title="FS_CHMOD_DIR"><td>' . __('CHMOD Dir', 'backwpup') . '</td><td>0755</td></tr>';
        }
        $now = localtime(time(), TRUE);
        echo '<tr title=""><td>' . __('Server Time', 'backwpup') . '</td><td>' . $now['tm_hour'] . ':' . $now['tm_min'] . '</td></tr>';
        echo '<tr title=""><td>' . __('Blog Time', 'backwpup') . '</td><td>' . date_i18n('H:i') . '</td></tr>';
        echo '<tr title=""><td>' . __('Blog Timezone', 'backwpup') . '</td><td>' . get_option('timezone_string') . '</td></tr>';
        echo '<tr title=""><td>' . __('Blog Time offset', 'backwpup') . '</td><td>' . sprintf(__('%s hours', 'backwpup'), get_option('gmt_offset')) . '</td></tr>';
        echo '<tr title="WPLANG"><td>' . __('Blog language', 'backwpup') . '</td><td>' . get_bloginfo('language') . '</td></tr>';
        echo '<tr title="utf8"><td>' . __('MySQL Client encoding', 'backwpup') . '</td><td>';
        echo defined('DB_CHARSET') ? DB_CHARSET : '';
        echo '</td></tr>';
        echo '<tr title="URF-8"><td>' . __('Blog charset', 'backwpup') . '</td><td>' . get_bloginfo('charset') . '</td></tr>';
        echo '<tr title="&gt;=128M"><td>' . __('PHP Memory limit', 'backwpup') . '</td><td>' . ini_get('memory_limit') . '</td></tr>';
        echo '<tr title="WP_MEMORY_LIMIT"><td>' . __('WP memory limit', 'backwpup') . '</td><td>' . WP_MEMORY_LIMIT . '</td></tr>';
        echo '<tr title="WP_MAX_MEMORY_LIMIT"><td>' . __('WP maximum memory limit', 'backwpup') . '</td><td>' . WP_MAX_MEMORY_LIMIT . '</td></tr>';
        echo '<tr title=""><td>' . __('Memory in use', 'backwpup') . '</td><td>' . size_format(@memory_get_usage(TRUE), 2) . '</td></tr>';
        //disabled PHP functions
        $disabled = ini_get('disable_functions');
        if (!empty($disabled)) {
            $disabledarry = explode(',', $disabled);
            echo '<tr title=""><td>' . __('Disabled PHP Functions:', 'backwpup') . '</td><td>';
            echo implode(', ', $disabledarry);
            echo '</td></tr>';
        }
        //Loaded PHP Extensions
        echo '<tr title=""><td>' . __('Loaded PHP Extensions:', 'backwpup') . '</td><td>';
        $extensions = get_loaded_extensions();
        sort($extensions);
        echo implode(', ', $extensions);
        echo '</td></tr>';
        echo '</table>';
        ?>
        </div>

		<?php 
        do_action('backwpup_page_settings_tab_content');
        ?>

        <p class="submit">
            <input type="submit" name="submit" id="submit" class="button-primary" value="<?php 
        _e('Save Changes', 'backwpup');
        ?>
" />
			&nbsp;
			<input type="submit" name="default_settings" id="default_settings" class="button-secondary" value="<?php 
        _e('Reset all settings to default', 'backwpup');
        ?>
" />
        </p>
    </form>
    </div>
	<?php 
    }
Ejemplo n.º 21
0
    /**
     * Display the page content
     */
    public static function page()
    {
        ?>
		<div class="wrap" id="backwpup-page">
			<h2><span id="backwpup-page-icon">&nbsp;</span><?php 
        echo esc_html(sprintf(__('%s Logs', 'backwpup'), BackWPup::get_plugin_data('name')));
        ?>
</h2>
			<?php 
        BackWPup_Admin::display_messages();
        ?>
			<form id="posts-filter" action="" method="get">
				<input type="hidden" name="page" value="backwpuplogs" />
				<?php 
        self::$listtable->display();
        ?>
				<div id="ajax-response"></div>
			</form>
		</div>
		<?php 
    }
Ejemplo n.º 22
0
 /**
  * Set archive Parameter
  *
  * @param $file string File with full path of the archive
  * @throws BackWPup_Create_Archive_Exception
  */
 public function __construct($file)
 {
     //check param
     if (empty($file)) {
         throw new BackWPup_Create_Archive_Exception(__('The file name of an archive cannot be empty.', 'backwpup'));
     }
     //set file
     $this->file = trim($file);
     //check folder can used
     if (!is_dir(dirname($this->file)) || !is_writable(dirname($this->file))) {
         throw new BackWPup_Create_Archive_Exception(sprintf(_x('Folder %s for archive not found', '%s = Folder name', 'backwpup'), dirname($this->file)));
     }
     //set and check method and get open handle
     if (strtolower(substr($this->file, -7)) == '.tar.gz') {
         if (!function_exists('gzencode')) {
             throw new BackWPup_Create_Archive_Exception(__('Functions for gz compression not available', 'backwpup'));
         }
         $this->method = 'TarGz';
         $this->filehandel = fopen($this->file, 'ab');
     } elseif (strtolower(substr($this->file, -8)) == '.tar.bz2') {
         if (!function_exists('bzcompress')) {
             throw new BackWPup_Create_Archive_Exception(__('Functions for bz2 compression not available', 'backwpup'));
         }
         $this->method = 'TarBz2';
         $this->filehandel = fopen($this->file, 'ab');
     } elseif (strtolower(substr($this->file, -4)) == '.tar') {
         $this->method = 'Tar';
         $this->filehandel = fopen($this->file, 'ab');
     } elseif (strtolower(substr($this->file, -4)) == '.zip') {
         $this->method = 'ZipArchive';
         //check and set method
         if (!class_exists('ZipArchive')) {
             $this->method = 'PclZip';
         }
         //open classes
         if ($this->get_method() == 'ZipArchive') {
             $this->ziparchive = new ZipArchive();
             $ziparchive_open = $this->ziparchive->open($this->file, ZipArchive::CREATE);
             if ($ziparchive_open !== TRUE) {
                 $this->ziparchive_status();
                 throw new BackWPup_Create_Archive_Exception(sprintf(_x('Cannot create zip archive: %d', 'ZipArchive open() result', 'backwpup'), $ziparchive_open));
             }
         }
         if ($this->get_method() == 'PclZip' && !function_exists('gzencode')) {
             throw new BackWPup_Create_Archive_Exception(__('Functions for gz compression not available', 'backwpup'));
         }
         if ($this->get_method() == 'PclZip') {
             $this->method = 'PclZip';
             if (!defined('PCLZIP_TEMPORARY_DIR')) {
                 define('PCLZIP_TEMPORARY_DIR', BackWPup::get_plugin_data('TEMP'));
             }
             require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
             $this->pclzip = new PclZip($this->file);
         }
     } elseif (strtolower(substr($this->file, -3)) == '.gz') {
         if (!function_exists('gzencode')) {
             throw new BackWPup_Create_Archive_Exception(__('Functions for gz compression not available', 'backwpup'));
         }
         $this->method = 'gz';
         $this->filehandel = fopen('compress.zlib://' . $this->file, 'wb');
     } elseif (strtolower(substr($this->file, -4)) == '.bz2') {
         if (!function_exists('bzcompress')) {
             throw new BackWPup_Create_Archive_Exception(__('Functions for bz2 compression not available', 'backwpup'));
         }
         $this->method = 'bz2';
         $this->filehandel = fopen('compress.bzip2://' . $this->file, 'w');
     } else {
         throw new BackWPup_Create_Archive_Exception(sprintf(_x('Method to archive file %s not detected', '%s = file name', 'backwpup'), basename($this->file)));
     }
     //check file handle
     if (isset($this->filehandel) && !$this->filehandel) {
         throw new BackWPup_Create_Archive_Exception(__('Cannot open archive file', 'backwpup'));
     }
 }
Ejemplo n.º 23
0
 /**
  * Set Feed Options
  *
  * @param $feed
  */
 public static function wp_feed_options($feed)
 {
     if (is_object($feed)) {
         $feed->set_useragent(BackWPup::get_plugin_data('user-agent'));
     }
 }
 /**
  * @param $job_object
  * @return bool
  */
 public function job_run_archive(&$job_object)
 {
     $job_object->substeps_todo = 1;
     $job_object->log(sprintf(__('%d. Try to send backup with email&#160;&hellip;', 'backwpup'), $job_object->steps_data[$job_object->step_working]['STEP_TRY']), E_USER_NOTICE);
     //check file Size
     if (!empty($job_object->job['emailefilesize'])) {
         if ($job_object->backup_filesize > $job_object->job['emailefilesize'] * 1024 * 1024) {
             $job_object->log(__('Backup archive too big to be sent by email!', 'backwpup'), E_USER_ERROR);
             $job_object->substeps_done = 1;
             return TRUE;
         }
     }
     $job_object->log(sprintf(__('Sending email to %s&hellip;', 'backwpup'), $job_object->job['emailaddress']), E_USER_NOTICE);
     //get mail settings
     $emailmethod = 'mail';
     $emailsendmail = '';
     $emailhost = '';
     $emailhostport = '';
     $emailsecure = '';
     $emailuser = '';
     $emailpass = '';
     if (empty($job_object->job['emailmethod'])) {
         //do so if i'm the wp_mail to get the settings
         global $phpmailer;
         // (Re)create it, if it's gone missing
         if (!is_object($phpmailer) || !$phpmailer instanceof PHPMailer) {
             require_once ABSPATH . WPINC . '/class-phpmailer.php';
             require_once ABSPATH . WPINC . '/class-smtp.php';
             $phpmailer = new PHPMailer(true);
         }
         //only if PHPMailer really used
         if (is_object($phpmailer)) {
             do_action_ref_array('phpmailer_init', array(&$phpmailer));
             //get settings from PHPMailer
             $emailmethod = $phpmailer->Mailer;
             $emailsendmail = $phpmailer->Sendmail;
             $emailhost = $phpmailer->Host;
             $emailhostport = $phpmailer->Port;
             $emailsecure = $phpmailer->SMTPSecure;
             $emailuser = $phpmailer->Username;
             $emailpass = $phpmailer->Password;
         }
     } else {
         $emailmethod = $job_object->job['emailmethod'];
         $emailsendmail = $job_object->job['emailsendmail'];
         $emailhost = $job_object->job['emailhost'];
         $emailhostport = $job_object->job['emailhostport'];
         $emailsecure = $job_object->job['emailsecure'];
         $emailuser = $job_object->job['emailuser'];
         $emailpass = BackWPup_Encryption::decrypt($job_object->job['emailpass']);
     }
     //Generate mail with Swift Mailer
     if (function_exists('mb_internal_encoding') && (int) ini_get('mbstring.func_overload') & 2) {
         $mbEncoding = mb_internal_encoding();
         mb_internal_encoding('ASCII');
     }
     try {
         //Set Temp dir for mailing
         Swift_Preferences::getInstance()->setTempDir(untrailingslashit(BackWPup::get_plugin_data('TEMP')))->setCacheType('disk');
         // Create the Transport
         if ($emailmethod == 'smtp') {
             $transport = Swift_SmtpTransport::newInstance($emailhost, $emailhostport);
             $transport->setUsername($emailuser);
             $transport->setPassword($emailpass);
             if ($emailsecure == 'ssl') {
                 $transport->setEncryption('ssl');
             }
             if ($emailsecure == 'tls') {
                 $transport->setEncryption('tls');
             }
         } elseif ($emailmethod == 'sendmail') {
             $transport = Swift_SendmailTransport::newInstance($emailsendmail);
         } else {
             $job_object->need_free_memory($job_object->backup_filesize * 8);
             $transport = Swift_MailTransport::newInstance();
         }
         // Create the Mailer using your created Transport
         $emailer = Swift_Mailer::newInstance($transport);
         // Create a message
         $message = Swift_Message::newInstance(sprintf(__('BackWPup archive from %1$s: %2$s', 'backwpup'), date_i18n('d-M-Y H:i', $job_object->start_time, TRUE), esc_attr($job_object->job['name'])));
         $message->setFrom(array($job_object->job['emailsndemail'] => $job_object->job['emailsndemailname']));
         $message->setTo(array($job_object->job['emailaddress']));
         $message->setBody(sprintf(__('Backup archive: %s', 'backwpup'), $job_object->backup_file), 'text/plain', strtolower(get_bloginfo('charset')));
         $message->attach(Swift_Attachment::fromPath($job_object->backup_folder . $job_object->backup_file, $job_object->get_mime_type($job_object->backup_folder . $job_object->backup_file)));
         // Send the message
         $result = $emailer->send($message);
     } catch (Exception $e) {
         $job_object->log('Swift Mailer: ' . $e->getMessage(), E_USER_ERROR);
     }
     if (isset($mbEncoding)) {
         mb_internal_encoding($mbEncoding);
     }
     if (isset($result) && !$result) {
         $job_object->log(__('Error while sending email!', 'backwpup'), E_USER_ERROR);
         return FALSE;
     } else {
         $job_object->substeps_done = 1;
         $job_object->log(__('Email sent.', 'backwpup'), E_USER_NOTICE);
         return TRUE;
     }
 }
Ejemplo n.º 25
0
 /**
  * Cleanup Temp Folder
  */
 public static function clean_temp_folder()
 {
     $temp_dir = BackWPup::get_plugin_data('TEMP');
     $do_not_delete_files = array('.htaccess', 'nginx.conf', 'index.php', '.', '..', '.donotbackup');
     if (is_writable($temp_dir) && ($dir = opendir($temp_dir))) {
         while (false !== ($file = readdir($dir))) {
             if (in_array($file, $do_not_delete_files, true) || is_dir($temp_dir . $file) || is_link($temp_dir . $file)) {
                 continue;
             }
             if (is_writeable($temp_dir . $file)) {
                 unlink($temp_dir . $file);
             }
         }
         closedir($dir);
     }
 }
Ejemplo n.º 26
0
 /**
  * Write Dump Header
  *
  * @param bool $wp_info Dump WordPress info in dump head
  */
 public function dump_head($wp_info = FALSE)
 {
     // get sql timezone
     $res = $this->mysqli->query("SELECT @@time_zone");
     $GLOBALS['wpdb']->num_queries++;
     $mysqltimezone = $res->fetch_row();
     $mysqltimezone = $mysqltimezone[0];
     $res->close();
     //For SQL always use \n as MySQL wants this on all platforms.
     $dbdumpheader = "-- ---------------------------------------------------------\n";
     $dbdumpheader .= "-- Backup with BackWPup ver.: " . BackWPup::get_plugin_data('Version') . "\n";
     $dbdumpheader .= "-- https://marketpress.de/product/backwpup-pro/\n";
     if ($wp_info) {
         $dbdumpheader .= "-- Blog Name: " . get_bloginfo('name') . "\n";
         $dbdumpheader .= "-- Blog URL: " . trailingslashit(get_bloginfo('url')) . "\n";
         $dbdumpheader .= "-- Blog ABSPATH: " . trailingslashit(str_replace('\\', '/', ABSPATH)) . "\n";
         $dbdumpheader .= "-- Blog Charset: " . get_bloginfo('charset') . "\n";
         $dbdumpheader .= "-- Table Prefix: " . $GLOBALS['wpdb']->prefix . "\n";
     }
     $dbdumpheader .= "-- Database Name: " . $this->dbname . "\n";
     $dbdumpheader .= "-- Backup on: " . date_i18n('Y-m-d H:i.s') . "\n";
     $dbdumpheader .= "-- ---------------------------------------------------------\n\n";
     //for better import with mysql client
     $dbdumpheader .= "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n";
     $dbdumpheader .= "/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\n";
     $dbdumpheader .= "/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\n";
     $dbdumpheader .= "/*!40101 SET NAMES " . $this->mysqli->character_set_name() . " */;\n";
     $dbdumpheader .= "/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;\n";
     $dbdumpheader .= "/*!40103 SET TIME_ZONE='" . $mysqltimezone . "' */;\n";
     $dbdumpheader .= "/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;\n";
     $dbdumpheader .= "/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;\n";
     $dbdumpheader .= "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;\n";
     $dbdumpheader .= "/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;\n\n";
     $this->write($dbdumpheader);
 }
 /**
  * @param string $args
  */
 public function edit_ajax($args = '')
 {
     $error = '';
     if (is_array($args)) {
         $ajax = FALSE;
     } else {
         if (!current_user_can('backwpup_jobs_edit')) {
             wp_die(-1);
         }
         check_ajax_referer('backwpup_ajax_nonce');
         $args['msazureaccname'] = $_POST['msazureaccname'];
         $args['msazurekey'] = $_POST['msazurekey'];
         $args['msazureselected'] = $_POST['msazureselected'];
         $ajax = TRUE;
     }
     echo '<span id="msazurecontainererror" style="color:red;">';
     if (!empty($args['msazureaccname']) && !empty($args['msazurekey'])) {
         try {
             set_include_path(get_include_path() . PATH_SEPARATOR . BackWPup::get_plugin_data('plugindir') . '/vendor/PEAR/');
             $blobRestProxy = WindowsAzure\Common\ServicesBuilder::getInstance()->createBlobService('DefaultEndpointsProtocol=https;AccountName=' . $args['msazureaccname'] . ';AccountKey=' . BackWPup_Encryption::decrypt($args['msazurekey']));
             $containers = $blobRestProxy->listContainers()->getContainers();
         } catch (Exception $e) {
             $error = $e->getMessage();
         }
     }
     if (empty($args['msazureaccname'])) {
         _e('Missing account name!', 'backwpup');
     } elseif (empty($args['msazurekey'])) {
         _e('Missing access key!', 'backwpup');
     } elseif (!empty($error)) {
         echo esc_html($error);
     } elseif (empty($containers)) {
         _e('No container found!', 'backwpup');
     }
     echo '</span>';
     if (!empty($containers)) {
         echo '<select name="msazurecontainer" id="msazurecontainer">';
         foreach ($containers as $container) {
             echo "<option " . selected(strtolower($args['msazureselected']), strtolower($container->getName()), FALSE) . ">" . $container->getName() . "</option>";
         }
         echo '</select>';
     }
     if ($ajax) {
         die;
     } else {
         return;
     }
 }
Ejemplo n.º 28
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;
 }
Ejemplo n.º 29
0
 /**
  *
  * Get default option for BackWPup option
  *
  * @param string $key Option key
  *
  * @internal param int $id The job id
  *
  * @return bool|mixed
  */
 public static function defaults_job($key = '')
 {
     $key = sanitize_key(trim($key));
     //set defaults
     $default['type'] = array('DBDUMP', 'FILE', 'WPPLUGIN');
     $default['destinations'] = array();
     $default['name'] = __('New Job', 'backwpup');
     $default['activetype'] = '';
     $default['logfile'] = '';
     $default['lastbackupdownloadurl'] = '';
     $default['cronselect'] = 'basic';
     $default['cron'] = '0 3 * * *';
     $default['mailaddresslog'] = sanitize_email(get_bloginfo('admin_email'));
     $default['mailaddresssenderlog'] = 'BackWPup ' . get_bloginfo('name') . ' <' . sanitize_email(get_bloginfo('admin_email')) . '>';
     $default['mailerroronly'] = true;
     $default['backuptype'] = 'archive';
     $default['archiveformat'] = '.tar.gz';
     $default['archivename'] = 'backwpup_' . BackWPup::get_plugin_data('hash') . '_%Y-%m-%d_%H-%i-%s';
     //defaults vor destinations
     foreach (BackWPup::get_registered_destinations() as $dest_key => $dest) {
         if (!empty($dest['class'])) {
             $dest_object = BackWPup::get_destination($dest_key);
             $default = array_merge($default, $dest_object->option_defaults());
         }
     }
     //defaults vor job types
     foreach (BackWPup::get_job_types() as $job_type) {
         $default = array_merge($default, $job_type->option_defaults());
     }
     //return all
     if (empty($key)) {
         return $default;
     }
     //return one default setting
     if (isset($default[$key])) {
         return $default[$key];
     } else {
         return false;
     }
 }
Ejemplo n.º 30
0
    /**
     *
     */
    public static function page()
    {
        echo '<div class="wrap" id="backwpup-page">';
        echo '<h1>' . esc_html(sprintf(__('%s &rsaquo; Jobs', 'backwpup'), BackWPup::get_plugin_data('name'))) . '&nbsp;<a href="' . wp_nonce_url(network_admin_url('admin.php') . '?page=backwpupeditjob', 'edit-job') . '" class="add-new-h2">' . esc_html__('Add new', 'backwpup') . '</a></h1>';
        BackWPup_Admin::display_messages();
        $job_object = BackWPup_Job::get_working_data();
        if (current_user_can('backwpup_jobs_start') && is_object($job_object)) {
            //read existing logfile
            $logfiledata = file_get_contents($job_object->logfile);
            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 (empty($endpos)) {
                $endpos = strlen($logfiledata);
            }
            $length = strlen($logfiledata) - (strlen($logfiledata) - $endpos) - $startpos;
            ?>
			<div id="runningjob">
				<div id="runniginfos">
					<h2 id="runningtitle"><?php 
            esc_html(sprintf(__('Job currently running: %s', 'backwpup'), $job_object->job['name']));
            ?>
</h2>
					<span id="warningsid"><?php 
            esc_html_e('Warnings:', 'backwpup');
            ?>
 <span id="warnings"><?php 
            echo $job_object->warnings;
            ?>
</span></span>
					<span id="errorid"><?php 
            esc_html_e('Errors:', 'backwpup');
            ?>
 <span id="errors"><?php 
            echo $job_object->errors;
            ?>
</span></span>
					<div class="infobuttons"><a href="#TB_inline?height=440&width=630&inlineId=tb-showworking" id="showworkingbutton" class="thickbox button button-primary button-primary-bwp" title="<?php 
            esc_attr_e('Log of running job', 'backwpup');
            ?>
"><?php 
            esc_html_e('Display working log', 'backwpup');
            ?>
</a>
					<a href="<?php 
            echo wp_nonce_url(network_admin_url('admin.php') . '?page=backwpupjobs&action=abort', 'abort-job');
            ?>
" id="abortbutton" class="backwpup-fancybox button button-bwp"><?php 
            esc_html_e('Abort', 'backwpup');
            ?>
</a>
					<a href="#" id="showworkingclose" title="<?php 
            esc_html_e('Close working screen', 'backwpup');
            ?>
" class="button button-bwp" style="display:none" ><?php 
            esc_html_e('Close', 'backwpup');
            ?>
</a></div>
				</div>
				<input type="hidden" name="logpos" id="logpos" value="<?php 
            echo strlen($logfiledata);
            ?>
">
				<div id="lasterrormsg"></div>
				<div class="progressbar"><div id="progressstep" class="bwpu-progress" style="width:<?php 
            echo $job_object->step_percent;
            ?>
%;"><?php 
            echo esc_html($job_object->step_percent);
            ?>
%</div></div>
				<div id="onstep"><?php 
            echo esc_html($job_object->steps_data[$job_object->step_working]['NAME']);
            ?>
</div>
				<div class="progressbar"><div id="progresssteps" class="bwpu-progress" style="width:<?php 
            echo $job_object->substep_percent;
            ?>
%;"><?php 
            echo esc_html($job_object->substep_percent);
            ?>
%</div></div>
				<div id="lastmsg"><?php 
            echo esc_html($job_object->lastmsg);
            ?>
</div>
				<div id="tb-showworking" style="display:none;">
					<div id="showworking"><?php 
            echo substr($logfiledata, $startpos, $length);
            ?>
</div>
				</div>
			</div>
		<?php 
        }
        //display jos Table
        ?>
		<form id="posts-filter" action="" method="get">
		<input type="hidden" name="page" value="backwpupjobs" />
		<?php 
        echo wp_nonce_field('backwpup_ajax_nonce', 'backwpupajaxnonce', FALSE);
        self::$listtable->display();
        ?>
		<div id="ajax-response"></div>
		</form>
		</div>
		<?php 
        if (!empty($job_object->logfile)) {
            ?>
        <script type="text/javascript">
            //<![CDATA[
            jQuery(document).ready(function ($) {
                backwpup_show_working = function () {
	                var save_log_pos = 0;
                    $.ajax({
                        type: 'GET',
                        url: ajaxurl,
                        cache: false,
                        data:{
                            action: 'backwpup_working',
                            logpos: $('#logpos').val(),
							logfile: '<?php 
            echo basename($job_object->logfile);
            ?>
',
                            _ajax_nonce: '<?php 
            echo wp_create_nonce('backwpupworking_ajax_nonce');
            ?>
'
                        },
                        dataType: 'json',
                        success:function (rundata) {
							if ( rundata == 0 ) {
								$("#abortbutton").remove();
								$("#backwpup-adminbar-running").remove();
								$(".job-run").hide();
								$("#message").hide();
								$(".job-normal").show();
								$('#showworkingclose').show();
							}
							if (0 < rundata.log_pos) {
								$('#logpos').val(rundata.log_pos);
							}
                            if ('' != rundata.log_text) {
                                $('#showworking').append(rundata.log_text);
								$('#TB_ajaxContent').scrollTop(rundata.log_pos * 15);
                            }
                            if (0 < rundata.error_count) {
                                $('#errors').replaceWith('<span id="errors">' + rundata.error_count + '</span>');
                            }
                            if (0 < rundata.warning_count) {
                                $('#warnings').replaceWith('<span id="warnings">' + rundata.warning_count + '</span>');
                            }
                            if (0 < rundata.step_percent) {
                                $('#progressstep').replaceWith('<div id="progressstep" class="bwpu-progress">' + rundata.step_percent + '%</div>');
                                $('#progressstep').css('width', parseFloat(rundata.step_percent) + '%');
                            }
                            if (0 < rundata.sub_step_percent) {
                                $('#progresssteps').replaceWith('<div id="progresssteps" class="bwpu-progress">' + rundata.sub_step_percent + '%</div>');
                                $('#progresssteps').css('width', parseFloat(rundata.sub_step_percent) + '%');
                            }
                            if (0 < rundata.running_time) {
                                $('#runtime').replaceWith('<span id="runtime">' + rundata.running_time + '</span>');
                            }
                            if ( '' != rundata.onstep ) {
                                $('#onstep').replaceWith('<div id="onstep">' + rundata.on_step + '</div>');
                            }
                            if ( '' != rundata.last_msg ) {
                                $('#lastmsg').replaceWith('<div id="lastmsg">' + rundata.last_msg + '</div>');
                            }
							if ( '' != rundata.last_error_msg ) {
							    $('#lasterrormsg').replaceWith('<div id="lasterrormsg">' + rundata.last_error_msg + '</div>');
						    }
                            if ( rundata.job_done == 1 ) {
                                $("#abortbutton").remove();
                                $("#backwpup-adminbar-running").remove();
								$(".job-run").hide();
                                $("#message").hide();
                                $(".job-normal").show();
                                $('#showworkingclose').show();
                            } else {
								if ( rundata.restart_url !== '' ) {
	                                backwpup_trigger_cron( rundata.restart_url );
								}
                            	setTimeout('backwpup_show_working()', 750);
                            }
                        },
						error:function( ) {
							setTimeout('backwpup_show_working()', 750);
						}
                    });
                };
	            backwpup_trigger_cron = function ( cron_url ) {
		            $.ajax({
			            type: 'POST',
			            url: cron_url,
			            dataType: 'text',
			            cache: false,
			            processData: false,
			            timeout: 1
		            });
	            };
                backwpup_show_working();
                $('#showworkingclose').click( function() {
                    $("#runningjob").hide( 'slow' );
                    return false;
                });
            });
            //]]>
        </script>
		<?php 
        }
    }