public static function construct()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
/**
 * A wrapper function that adds an options page to setup Dropbox Backup
 * @return void
 */
function backup_to_dropbox_admin_menu()
{
    $imgUrl = rtrim(WP_PLUGIN_URL, '/') . '/wordpress-backup-to-dropbox/Images/WordPressBackupToDropbox_16.png';
    $text = __('WPB2D', 'wpbtd');
    add_utility_page($text, $text, 'activate_plugins', 'backup-to-dropbox', 'backup_to_dropbox_admin_menu_contents', $imgUrl);
    $text = __('Backup Settings', 'wpbtd');
    add_submenu_page('backup-to-dropbox', $text, $text, 'activate_plugins', 'backup-to-dropbox', 'backup_to_dropbox_admin_menu_contents');
    $text = WP_Backup_Config::construct()->is_scheduled() ? __('Monitor Backup', 'wpbtd') : __('Backup Now', 'wpbtd');
    add_submenu_page('backup-to-dropbox', $text, $text, 'activate_plugins', 'backup-to-dropbox-monitor', 'backup_to_dropbox_monitor');
    WP_Backup_Extension_Manager::construct()->add_menu_items();
    $text = __('Premium Extensions', 'wpbtd');
    add_submenu_page('backup-to-dropbox', $text, $text, 'activate_plugins', 'backup-to-dropbox-premium', 'backup_to_dropbox_premium');
}
 public function execute()
 {
     $manager = WP_Backup_Extension_Manager::construct();
     $this->config->set_in_progress(true);
     try {
         $this->config->set_memory_limit();
         $this->config->set_time_limit();
         if (!$this->dropbox->is_authorized()) {
             $this->config->log(WP_Backup_Config::BACKUP_STATUS_FAILED, __('Your Dropbox account is not authorized yet.', 'wpbtd'));
             return;
         }
         $core = new WP_Backup_Database_Core();
         $core->execute();
         $plugins = new WP_Backup_Database_Plugins();
         $plugins->execute();
         $manager->on_start();
         $this->backup_path(ABSPATH);
         if (dirname(WP_CONTENT_DIR) . '/' != ABSPATH) {
             $this->backup_path(WP_CONTENT_DIR);
         }
         $core->remove_file();
         $plugins->remove_file();
         $manager->on_complete();
         $this->config->log(WP_Backup_Config::BACKUP_STATUS_FINISHED);
     } catch (Exception $e) {
         if ($e->getMessage() == 'Unauthorized') {
             $this->config->log(WP_Backup_Config::BACKUP_STATUS_FAILED, __('The plugin is no longer authorized with Dropbox.', 'wpbtd'));
         } else {
             $this->config->log(WP_Backup_Config::BACKUP_STATUS_FAILED, "Exception - " . $e->getMessage());
         }
         $manager->on_failure();
     }
     $this->config->set_last_backup_time(time());
     $this->config->set_in_progress(false);
     $this->config->clean_up();
 }
Exemplo n.º 4
0
 public function execute()
 {
     $manager = WP_Backup_Extension_Manager::construct();
     $logger = WP_Backup_Registry::logger();
     $this->config->set_time_limit();
     $this->config->set_memory_limit();
     try {
         if (!$this->dropbox->is_authorized()) {
             $logger->log(__('Your Dropbox account is not authorized yet.', 'wpbtd'));
             return;
         }
         if ($this->output->start()) {
             //Create the SQL backups
             if (!$this->db_core->exists() || !$this->db_plugins->exists()) {
                 $logger->log(__('Creating SQL backup.', 'wpbtd'));
                 $this->db_core->execute();
                 $this->db_plugins->execute();
                 $logger->log(__('SQL backup complete. Starting file backup.', 'wpbtd'));
             }
             //Backup the content dir first
             $processed_files = $this->backup_path(WP_CONTENT_DIR, dirname(WP_CONTENT_DIR), array($this->db_core->get_file(), $this->db_plugins->get_file()));
             //Now backup the blog root
             $processed_files += $this->backup_path(get_sanitized_home_path());
             //End any output extensions
             $this->output->end();
             //Record the number of files processed to make the progress meter more accurate
             $this->config->set_option('total_file_count', $processed_files);
         }
         $manager->complete();
         //Update log file with stats
         $logger->log(__('Backup complete.', 'wpbtd'));
         $logger->log(sprintf(__('A total of %s files were processed.', 'wpbtd'), $processed_files));
         $logger->log(sprintf(__('A total of %dMB of memory was used to complete this backup.', 'wpbtd'), memory_get_usage(true) / 1048576));
         $this->output->clean_up();
         //Process the log file using the default backup output
         $root = false;
         if (get_class($this->output) != 'WP_Backup_Output') {
             $this->output = new WP_Backup_Output();
             $root = true;
         }
         $this->output->set_root($root)->out(get_sanitized_home_path(), $logger->get_log_file());
         $this->config->complete()->log_finished_time();
     } catch (Exception $e) {
         if ($e->getMessage() == 'Unauthorized') {
             $logger->log(__('The plugin is no longer authorized with Dropbox.', 'wpbtd'));
         } else {
             $logger->log(__('A fatal error occured: ', 'wpbtd') . $e->getMessage());
         }
         $manager->failure();
         $this->stop();
     }
     $this->clean_up();
 }
 * @author Michael De Wildt (http://www.mikeyd.com.au/)
 * @license This program is free software; you can redistribute it and/or modify
 *          it under the terms of the GNU General Public License as published by
 *          the Free Software Foundation; either version 2 of the License, or
 *          (at your option) any later version.
 *
 *          This program is distributed in the hope that it will be useful,
 *          but WITHOUT ANY WARRANTY; without even the implied warranty of
 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *          GNU General Public License for more details.
 *
 *          You should have received a copy of the GNU General Public License
 *          along with this program; if not, write to the Free Software
 *          Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA.
 */
$manager = WP_Backup_Extension_Manager::construct();
$wpb2d = $manager->get_url();
$key = $manager->get_key();
$installUrl = $manager->get_install_url();
$buyUrl = $manager->get_buy_url();
$error = $title = null;
if (isset($_REQUEST['error'])) {
    $error = sprintf(__('There was an error with your payment, please contact %s to resolve.'), '<a href="mailto:michael.dewildt@gmail.com">Mikey</a>');
}
if (isset($_REQUEST['title'])) {
    $success = sprintf(__('You have succesfully purchased the %s premium extension, please install it below.'), "<strong>{$_REQUEST['title']}</strong>");
}
try {
    if (isset($_POST['name'])) {
        $manager->install($_POST['name'], $_POST['file']);
        echo '<script>window.location.reload(true);</script>';