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($type)
 {
     $this->type = $type;
     $this->database = WP_Backup_Registry::db();
     $this->config = WP_Backup_Registry::config();
     $this->set_wait_timeout();
 }
 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()))) {
Exemplo n.º 5
0
 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 setConfig($config)
 {
     self::$config = $config;
 }
 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)));
 }
 * @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();
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 
 public function __construct()
 {
     $this->dropbox = WP_Backup_Registry::dropbox();
     $this->config = WP_Backup_Registry::config();
 }