public static function construct()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
/**
 * A wrapper function that includes the backup to Dropbox monitor page
 * @return void
 */
function backup_to_dropbox_monitor()
{
    if (!Dropbox_Facade::construct()->is_authorized()) {
        backup_to_dropbox_admin_menu_contents();
    } else {
        $uri = rtrim(WP_PLUGIN_URL, '/') . '/wordpress-backup-to-dropbox';
        include 'Views/wp-backup-to-dropbox-monitor.php';
    }
}
 public function __construct($dropbox = false, $config = false)
 {
     $this->dropbox = $dropbox ? $dropbox : Dropbox_Facade::construct();
     $this->config = $config ? $config : WP_Backup_Config::construct();
     $this->last_backup_time = $this->config->get_option('last_backup_time');
     $this->dropbox_location = null;
     if ($this->config->get_option('store_in_subfolder')) {
         $this->dropbox_location = $this->config->get_option('dropbox_location');
     }
     $this->max_file_size = $this->config->get_max_file_size();
 }
Ejemplo n.º 4
0
 public function backup_path($path, $dropbox_path = null, $always_include = array())
 {
     if (!$this->config->get_option('in_progress')) {
         return;
     }
     if (!$dropbox_path) {
         $dropbox_path = get_sanitized_home_path();
     }
     $file_list = new File_List();
     $current_processed_files = $uploaded_files = array();
     $next_check = time() + 5;
     $total_files = $this->config->get_option('total_file_count');
     if ($total_files < 1800) {
         //I doub't very much a wp installation can get smaller then this
         $total_files = 1800;
     }
     $processed_files = new WP_Backup_Processed_Files();
     $processed_file_count = $processed_files->get_file_count();
     if (file_exists($path)) {
         $source = realpath($path);
         $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD);
         foreach ($files as $file_info) {
             $file = $file_info->getPathname();
             if (time() > $next_check) {
                 $this->config->die_if_stopped();
                 $percent_done = round($processed_file_count / $total_files * 100, 0);
                 if ($percent_done > 99) {
                     $percent_done = 99;
                 }
                 if ($percent_done < 1) {
                     $percent_done = 1;
                 }
                 $processed_files->add_files($current_processed_files);
                 WP_Backup_Registry::logger()->log(sprintf(__('Approximately %s%% complete.', 'wpbtd'), $percent_done), $uploaded_files);
                 $next_check = time() + 5;
                 $uploaded_files = $current_processed_files = array();
             }
             if (!in_array($file, $always_include) && $file_list->is_excluded($file)) {
                 continue;
             }
             if ($file_list->in_ignore_list($file)) {
                 continue;
             }
             if (is_file($file)) {
                 $processed_file = $processed_files->get_file($file);
                 if ($processed_file && $processed_file->offset == 0) {
                     continue;
                 }
                 if (dirname($file) == $this->config->get_backup_dir() && !in_array($file, $always_include)) {
                     continue;
                 }
                 if ($this->output->out($dropbox_path, $file, $processed_file)) {
                     $uploaded_files[] = array('file' => str_replace($dropbox_path . DIRECTORY_SEPARATOR, '', Dropbox_Facade::remove_secret($file)), 'mtime' => filemtime($file));
                     if ($processed_file && $processed_file->offset > 0) {
                         $processed_files->file_complete($file);
                     }
                 }
                 $current_processed_files[] = $file;
                 $processed_file_count++;
             }
         }
         return $processed_file_count;
     }
 }
 *          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.
 */
try {
    $v = phpversion();
    if ($v < 5) {
        throw new Exception(sprintf(__('Your PHP version (%s) is too old for this plugin to function correctly please update to PHP 5.2 or higher.'), $v));
    }
    global $wpdb;
    $validation_errors = null;
    $dropbox = Dropbox_Facade::construct();
    $config = WP_Backup_Config::construct();
    $backup = new WP_Backup();
    $disable_backup_now = $config->in_progress();
    //We have a form submit so update the schedule and options
    if (array_key_exists('save_changes', $_POST)) {
        check_admin_referer('backup_to_dropbox_options_save');
        $config->set_schedule($_POST['day'], $_POST['time'], $_POST['frequency']);
        $options = array('store_in_subfolder' => $_POST['store_in_subfolder'] == "on", 'dump_location' => $_POST['dump_location'], 'dropbox_location' => $_POST['dropbox_location']);
        $validation_errors = $config->set_options($options);
    } else {
        if (array_key_exists('unlink', $_POST)) {
            check_admin_referer('backup_to_dropbox_options_save');
            $dropbox->unlink_account();
        } else {
            if (array_key_exists('clear_history', $_POST)) {
 public function __construct($dropbox = null, $output = null)
 {
     $this->dropbox = $dropbox ? $dropbox : Dropbox_Facade::construct();
     $this->output = $output ? $output : WP_Backup_Extension_Manager::construct()->get_output();
     $this->config = WP_Backup_Config::construct();
 }