public function init() { $this->config = WP_Backup_Registry::config(); if (!extension_loaded('curl')) { throw new Exception(sprintf(__('The cURL extension is not loaded. %sPlease ensure its installed and activated.%s', 'wpbtd'), '<a href="http://php.net/manual/en/curl.installation.php">', '</a>')); } $this->oauth = new OAuth_Consumer_Curl(self::CONSUMER_KEY, self::CONSUMER_SECRET); $this->oauth_state = $this->config->get_option('oauth_state'); $this->request_token = $this->get_token('request'); $this->access_token = $this->get_token('access'); if ($this->oauth_state == 'request') { //If we have not got an access token then we need to grab one try { $this->oauth->setToken($this->request_token); $this->access_token = $this->oauth->getAccessToken(); $this->oauth_state = 'access'; $this->oauth->setToken($this->access_token); $this->save_tokens(); //Supress the error because unlink, then init should be called } catch (Exception $e) { } } else { if ($this->oauth_state == 'access') { $this->oauth->setToken($this->access_token); } else { //If we don't have an acess token then lets setup a new request $this->request_token = $this->oauth->getRequestToken(); $this->oauth->setToken($this->request_token); $this->oauth_state = 'request'; $this->save_tokens(); } } $this->dropbox = new API($this->oauth); $this->dropbox->setTracker(new WP_Backup_Upload_Tracker()); }
public function __construct() { $this->db = WP_Backup_Registry::db(); $ret = $this->db->get_results("SELECT * FROM {$this->db->prefix}wpb2d_processed_files"); if (is_array($ret)) { $this->processed_files = $ret; } }
public function __construct() { $this->db = WP_Backup_Registry::db(); $result = $this->db->get_results("SELECT * FROM {$this->db->prefix}wpb2d_excluded_files WHERE isdir = 0"); foreach ($result as $value) { $this->excluded_files[] = $value->file; } $result = $this->db->get_results("SELECT * FROM {$this->db->prefix}wpb2d_excluded_files WHERE isdir = 1"); foreach ($result as $value) { $this->excluded_dirs[] = $value->file; } }
public function get_log_file() { if (!$this->logFile) { WP_Backup::create_dump_dir(); $path = WP_Backup_Registry::config()->get_backup_dir() . DIRECTORY_SEPARATOR . self::LOGFILE; $files = glob($path . '.*'); if (isset($files[0])) { $this->logFile = $files[0]; } else { $this->logFile = $path . '.' . WP_Backup_Registry::get_secret($file); } } return $this->logFile; }
* @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. */ WP_Backup_Registry::config()->set_time_limit(); WP_Backup_Registry::config()->set_memory_limit(); try { $file_list = new File_List(); if (isset($_POST['dir'])) { //Convert to the os' directiry separator $_POST['dir'] = str_replace('/', DIRECTORY_SEPARATOR, urldecode($_POST['dir'])); if (file_exists($_POST['dir']) && is_readable($_POST['dir'])) { $files = scandir($_POST['dir']); natcasesort($files); if (count($files) > 2) { /* The 2 accounts for . and .. */ echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">"; // All dirs foreach ($files as $file) { if ($file != '.' && $file != '..' && file_exists($_POST['dir'] . $file) && is_dir($_POST['dir'] . $file)) { if (!is_readable($_POST['dir']) || $_POST['dir'] == dirname(get_sanitized_home_path()) && !strstr($file, basename(get_sanitized_home_path()))) {
public static function create_dump_dir() { $dump_dir = WP_Backup_Registry::config()->get_backup_dir(); $error_message = sprintf(__("WordPress Backup to Dropbox requires write access to '%s', please ensure it exists and has write permissions.", 'wpbtd'), $dump_dir); if (!file_exists($dump_dir)) { //It really pains me to use the error suppressor here but PHP error handling sucks :-( if (!@mkdir($dump_dir)) { throw new Exception($error_message); } } else { if (!is_writable($dump_dir)) { throw new Exception($error_message); } } self::create_silence_file(); }
public static function setDatabase($db) { self::$db = $db; }
public function track_upload($file, $upload_id, $offset) { WP_Backup_Registry::config()->die_if_stopped(); $this->processed_files->update_file($file, $upload_id, $offset); WP_Backup_Registry::logger()->log(sprintf(__("Uploaded %sMB of %sMB", 'wpbtd'), round($offset / 1048576, 1), round(filesize($file) / 1048576, 1))); }
* (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. */ $config = WP_Backup_Registry::config(); if (!$config->get_option('in_progress')) { spawn_cron(); } $log = WP_Backup_Registry::logger()->get_log(); if (empty($log)) { ?> <p><?php _e('You have not run a backup yet. When you do you will see a log of it here.'); ?> </p> <?php } else { ?> <ul> <?php foreach (array_reverse($log) as $log_item) { ?> <li> <?php
* @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. */ $config = WP_Backup_Registry::config(); $backup = new WP_Backup(); if (array_key_exists('stop_backup', $_POST)) { check_admin_referer('backup_to_dropbox_monitor_stop'); $backup->stop(); } else { if (array_key_exists('start_backup', $_POST)) { check_admin_referer('backup_to_dropbox_monitor_stop'); $backup->backup_now(); $started = true; } } ?> <script type="text/javascript" language="javascript"> function reload() { jQuery('.files').hide();
public function die_if_stopped() { $in_progress = $this->db->get_var("SELECT value FROM {$this->db->prefix}wpb2d_options WHERE name = 'in_progress'"); if (!$in_progress) { $msg = __('Backup stopped by user.', 'wpbtd'); WP_Backup_Registry::logger()->log($msg); die($msg); } }
* @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_Registry::extension_manager(); $error = $title = null; if (isset($_REQUEST['error'])) { $error = sprintf(__('There was an error with your payment, please contact %s to resolve.', 'wpbtd'), '<a href="mailto:michael.dewildt@gmail.com">Mikey</a>'); } if (isset($_REQUEST['title'])) { $success = sprintf(__('You have succesfully purchased %s.', 'wpbtd'), "<strong>{$_REQUEST['title']}</strong>"); } if (isset($_POST['name'])) { try { $ext = $manager->install($_POST['name']); $slug = $manager->get_menu_slug($ext); $title = $ext->get_menu(); ?> <script type='text/javascript'> jQuery(document).ready(function ($) {
public function __construct() { $this->dropbox = WP_Backup_Registry::dropbox(); $this->config = WP_Backup_Registry::config(); }
protected function write_db_dump_header() { $this->handle = fopen($this->get_file(), 'w+'); if (!$this->handle) { throw new Exception(__('Error creating sql dump file.', 'wpbtd')); } $dump_location = $this->config->get_backup_dir(); if (!is_writable($dump_location)) { $msg = sprintf(__("A database backup cannot be created because WordPress does not have write access to '%s', please ensure this directory has write access.", 'wpbtd'), $dump_location); WP_Backup_Registry::logger()->log($msg); return false; } $blog_time = strtotime(current_time('mysql')); $this->write_to_file("-- WordPress Backup to Dropbox SQL Dump\n"); $this->write_to_file("-- Version " . BACKUP_TO_DROPBOX_VERSION . "\n"); $this->write_to_file("-- http://wpb2d.com\n"); $this->write_to_file("-- Generation Time: " . date("F j, Y", $blog_time) . " at " . date("H:i", $blog_time) . "\n\n"); $this->write_to_file('SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";' . "\n\n"); //I got this out of the phpMyAdmin database dump to make sure charset is correct $this->write_to_file("/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n"); $this->write_to_file("/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\n"); $this->write_to_file("/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\n"); $this->write_to_file("/*!40101 SET NAMES utf8 */;\n\n"); $this->write_to_file("--\n-- Create and use the backed up database\n--\n\n"); $this->write_to_file("CREATE DATABASE IF NOT EXISTS " . DB_NAME . ";\n"); $this->write_to_file("USE " . DB_NAME . ";\n\n"); }