Exemple #1
0
function plugin_information($plugin_slug, $data)
{
    $plugin_path = $data['path'];
    ?>
	
	<textarea readonly="readonly" rows="7" cols="65" wrap="off" style="width: 100%;"><?php 
    //echo "Version History:\n\n";
    readfile($plugin_path . '/history.txt');
    ?>
</textarea>
	<script type="text/javascript">
		jQuery(document).ready(function() {
			jQuery("#pluginbuddy_<?php 
    echo $plugin_slug;
    ?>
_debugtoggle").click(function() {
				jQuery("#pluginbuddy_<?php 
    echo $plugin_slug;
    ?>
_debugtoggle_div").slideToggle();
			});
		});
	</script>
	<?php 
    if (pb_backupbuddy::_POST('reset_defaults') == $plugin_slug) {
        if (call_user_func('pb_' . $plugin_slug . '::reset_options', true) === true) {
            pb_backupbuddy::alert('Plugin settings have been reset to defaults for plugin `' . $data['name'] . '`.');
        } else {
            pb_backupbuddy::alert('Unable to reset plugin settings. Verify you are running the latest version.');
        }
    }
    ?>
	
	<?php 
}
Exemple #2
0
function finalActions($restore)
{
    // Rename .htaccess.bb_temp back to .htaccess.
    $restore->renameHtaccessTempBack();
    // Remove any temporary .maintenance file created by ImportBuddy.
    $restore->maintenanceOff($onlyOurCreatedFile = true);
    // Remove any temporary index.htm file created by ImportBuddy.
    $restore->scrubIndexFiles();
    // TODO: Make these thnings be able to output stuff into the cleanupSettings.ejs template. Add functions?
    // Update wpconfig if needed.
    $wpconfig_result = $restore->migrateWpConfig();
    if ($wpconfig_result !== true) {
        pb_backupbuddy::alert('Error: Unable to update wp-config.php file. Verify write permissions for the wp-config.php file then refresh this page. You may manually update your wp-config.php file by changing it to the following:<textarea readonly="readonly" style="width: 80%;">' . $wpconfig_result . '</textarea>');
    }
    // Scan for 'trouble' such as a remaining .maintenance file, index.htm, index.html, missing wp-config.php, missing .htaccess, etc etc.
    $problems = $restore->troubleScan();
    if (count($problems) > 0) {
        $restore->_state['potentialProblems'] = $problems;
        $trouble_text = '';
        foreach ($problems as $problem) {
            $trouble_text .= '<li>' . $problem . '</li>';
        }
        $trouble_text = '<ul>' . $trouble_text . '</ul>';
        pb_backupbuddy::status('warning', 'One or more potential issues detected that may require your attention: ' . $trouble_text);
    }
    pb_backupbuddy::status('details', 'Finished final actions function.');
}
Exemple #3
0
 public function start($sourceInfo)
 {
     $this->_before(__FUNCTION__);
     $pingTimePre = microtime(true);
     if (false === ($this->_state['remoteInfo'] = backupbuddy_remote_api::remoteCall($this->_state['destination'], 'getPreDeployInfo', array(), $timeout = 10))) {
         pb_backupbuddy::alert(implode(', ', backupbuddy_remote_api::getErrors()));
         return false;
     }
     $this->_state['remoteInfo'] = $this->_state['remoteInfo']['data'];
     $pingTimePost = microtime(true);
     $this->_state['remoteInfo']['pingTime'] = $pingTimePost - $pingTimePre;
     // Calculate plugins that do not match.
     $this->_state['pushPluginFiles'] = $this->calculatePluginDiff($sourceInfo['activePlugins'], $this->_state['remoteInfo']['activePlugins']);
     $this->_state['pullPluginFiles'] = $this->calculatePluginDiff($this->_state['remoteInfo']['activePlugins'], $sourceInfo['activePlugins']);
     if ($sourceInfo['activeTheme'] == $this->_state['remoteInfo']['activeTheme']) {
         // Calculate themes that do not match.
         $this->_state['pushThemeFiles'] = $this->calculateFileDiff($sourceInfo['themeSignatures'], $this->_state['remoteInfo']['themeSignatures']);
         $this->_state['pullThemeFiles'] = $this->calculateFileDiff($this->_state['remoteInfo']['themeSignatures'], $sourceInfo['themeSignatures']);
     } else {
         $this->_state['sendTheme'] = false;
         pb_backupbuddy::status('details', 'Different themes. No theme data will be sent.');
     }
     // Calculate media files that do not match.
     $this->_state['pushMediaFiles'] = $this->calculateFileDiff($sourceInfo['mediaSignatures'], $this->_state['remoteInfo']['mediaSignatures']);
     // was calculateMediaDiff().
     $this->_state['pullMediaFiles'] = $this->calculateFileDiff($this->_state['remoteInfo']['mediaSignatures'], $sourceInfo['mediaSignatures']);
     // was calculateMediaDiff().
     unset($this->_state['remoteInfo']['mediaSignatures']);
     unset($this->_state['remoteInfo']['themeSignatures']);
     return true;
 }
 public static function get_info($destination_type)
 {
     // Initialize destination.
     if (false === ($destination = self::_init_destination(array('type' => $destination_type)))) {
         pb_backupbuddy::alert('Unable to load destination files. Your BackupBuddy installation may be incomplete or your server may no longer support a destination you previously configured. Some destination may require PHP 5.3 or newer to function.');
         return false;
     }
     return $destination['info'];
 }
Exemple #5
0
 private static function _connect($accessToken)
 {
     try {
         self::$_dbxClient = new dbx\Client($accessToken, 'BackupBuddy v' . pb_backupbuddy::settings('version'));
     } catch (\Exception $e) {
         pb_backupbuddy::alert('Dropbox Error: ' . $e->getMessage() . '<br><br>' . pb_backupbuddy::$ui->button(pb_backupbuddy::page_url(), '&larr; go back & retry'), true);
         return false;
     }
     pb_backupbuddy::status('details', 'Connected to Dropbox.');
     return true;
 }
Exemple #6
0
/**
 *	upload()
 *
 *	Processes uploaded backup file.
 *
 *	@return		array		True on upload success; false otherwise.
 */
function upload()
{
    if (isset($_POST['upload']) && $_POST['upload'] == 'local') {
        if (pb_backupbuddy::$options['password'] != '#PASSWORD#') {
            $path_parts = pathinfo($_FILES['file']['name']);
            if (strtolower(substr($_FILES['file']['name'], 0, 6)) == 'backup' && strtolower($path_parts['extension']) == 'zip') {
                if (move_uploaded_file($_FILES['file']['tmp_name'], basename($_FILES['file']['name']))) {
                    pb_backupbuddy::alert('File Uploaded. Your backup was successfully uploaded.');
                    return true;
                } else {
                    pb_backupbuddy::alert('Sorry, there was a problem uploading your file.', true);
                    return false;
                }
            } else {
                pb_backupbuddy::alert('Only properly named BackupBuddy zip archives with a zip extension may be uploaded.', true);
                return false;
            }
        } else {
            pb_backupbuddy::alert('Upload Access Denied. To prevent unauthorized file uploads an importbuddy password must be configured and properly entered to use this feature.');
            return false;
        }
    }
    // DOWNLOAD FILE FROM STASH TO LOCAL.
    if (pb_backupbuddy::_POST('upload') == 'stash') {
        pb_backupbuddy::set_greedy_script_limits(true);
        /*
        echo '<pre>';
        print_r( $_POST );
        echo '</pre>';
        */
        $requestcore_file = dirname(dirname(dirname(__FILE__))) . '/lib/requestcore/requestcore.class.php';
        require_once $requestcore_file;
        $link = pb_backupbuddy::_POST('link');
        $destination_file = dirname(dirname(dirname(dirname(__FILE__)))) . '/' . basename(pb_backupbuddy::_POST('link'));
        $destination_file = substr($destination_file, 0, stripos($destination_file, '.zip') + 4);
        $_GET['file'] = basename($destination_file);
        $request = new RequestCore($link);
        $request->set_write_file($destination_file);
        echo '<div id="pb_importbuddy_working" style="padding: 20px;">Downloading backup from Stash to `' . $destination_file . '`...<br><br><img src="' . pb_backupbuddy::plugin_url() . '/images/loading_large.gif" title="Working... Please wait as this may take a moment..."><br><br></div>';
        flush();
        $response = $request->send_request(false);
        if ($response !== true) {
            pb_backupbuddy::alert('Error #8548459598. Unable to download file from Stash. You may manually download it and upload to the server via FTP.');
        } else {
            // No error.
            if (!file_exists($destination_file)) {
                pb_backupbuddy::alert('Error #34845745878. Stash returned a success but the backup file was not found locally. Check this server\'s directory write permissions. You may manually download it and upload to the server via FTP.');
            }
        }
        echo '<script type="text/javascript">jQuery("#pb_importbuddy_working").hide();</script>';
    }
}
Exemple #7
0
 public static function get_info($destination_type)
 {
     // Initialize destination.
     $destination_class = self::_init_destination($destination_type);
     if (!class_exists($destination_class)) {
         pb_backupbuddy::alert('Unable to load class `' . $destination_class . '` for destination type `' . $destination_type . '`.');
         return self::$_destination_info_defaults;
     }
     // Get default dest info from class. Was using a variable class name but had to change this for PHP 5.2 compat.
     $vars = get_class_vars($destination_class);
     $default_info = $vars['destination_info'];
     unset($vars);
     $destination_info = array_merge(self::$_destination_info_defaults, $default_info);
     // Merge in defaults from destination over defaults for BB destinations.
     return $destination_info;
 }
Exemple #8
0
/**
 *	upload()
 *
 *	Processes uploaded backup file.
 *
 *	@return		array		True on upload success; false otherwise.
 */
function upload() {
	if ( isset( $_POST['upload'] ) && ( $_POST['upload'] == 'local' ) ) {
		if ( pb_backupbuddy::$options['password'] != '#PASSWORD#' ) {
			$path_parts = pathinfo( $_FILES['file']['name'] );
			if ( ( strtolower( substr( $_FILES['file']['name'], 0, 6 ) ) == 'backup' ) && ( strtolower( $path_parts['extension'] ) == 'zip' ) ) {
				if ( move_uploaded_file( $_FILES['file']['tmp_name'], basename( $_FILES['file']['name'] ) ) ) {
					pb_backupbuddy::alert( 'File Uploaded. Your backup was successfully uploaded.' );
					return true;
				} else {
					pb_backupbuddy::alert( 'Sorry, there was a problem uploading your file.', true );
					return false;
				}
			} else {
				pb_backupbuddy::alert( 'Only properly named BackupBuddy zip archives with a zip extension may be uploaded.', true );
				return false;
			}
		} else {
			pb_backupbuddy::alert( 'Upload Access Denied. To prevent unauthorized file uploads an importbuddy password must be configured and properly entered to use this feature.' );
			return false;
		}
	}
}
 public static function get_manage_data($settings)
 {
     $itxapi_username = $settings['itxapi_username'];
     $itxapi_password = $settings['itxapi_password'];
     require_once dirname(__FILE__) . '/lib/class.itx_helper.php';
     require_once dirname(dirname(__FILE__)) . '/_s3lib/aws-sdk/sdk.class.php';
     $stash = new ITXAPI_Helper(pb_backupbuddy_destination_stash::ITXAPI_KEY, pb_backupbuddy_destination_stash::ITXAPI_URL, $itxapi_username, $itxapi_password);
     //  get the url to use to request management credentials
     //  url looks something like this - http://api.ithemes.com/stash/upload?apikey=sb31kesem0c879m0&expires=1347439653&subscriber=jwooley&signature=VFMbmXb5OorWwqE0iedOCsDtSgs%3D
     $manage_url = $stash->get_manage_url();
     //  create a new RequestCore to get the credentials
     //  NOTE: RequestCore is part of the AWS SDK, it's a generic http request class.
     //        You can use any available function to make the api request, the wordpress http class for example,
     //        or even just the basic file_get_contents()
     $request = new RequestCore($manage_url);
     //  send the api request
     $response = $request->send_request(true);
     //  see if the request was successful
     if (!$response->isOK()) {
         //throw new Exception('Request for management credentials failed.');
         $error = 'Request for management credentials failed.';
         pb_backupbuddy::status('error', $error);
         pb_backupbuddy::alert($error);
         return false;
     }
     //  see if we got a json response
     if (!($manage_data = json_decode($response->body, true))) {
         $error = 'Did not get valid JSON response.';
         pb_backupbuddy::status('error', $error);
         pb_backupbuddy::alert($error);
         return false;
     }
     //  finally see if the API returned an error
     if (isset($manage_data['error'])) {
         $error = 'Error: ' . implode(' - ', $manage_data['error']);
         pb_backupbuddy::status('error', $error);
         pb_backupbuddy::alert($error);
         return false;
     }
     return $manage_data;
 }
Exemple #10
0
		pb_backupbuddy::alert( sprintf( __('Unable to create backup storage directory (%s)', 'it-l10n-backupbuddy' ) , pb_backupbuddy::$options['backup_directory'] ), true, '9002' );
	}
}

// Keep temp directory up to date.
if ( pb_backupbuddy::$options['temp_directory'] != ( ABSPATH . 'wp-content/uploads/backupbuddy_temp/' ) ) {
	pb_backupbuddy::status( 'details', 'Temporary directory has changed. Updating from `' . pb_backupbuddy::$options['temp_directory'] . '` to `' . ABSPATH . 'wp-content/uploads/backupbuddy_temp/' . '`.' );
	pb_backupbuddy::$options['temp_directory'] = ABSPATH . 'wp-content/uploads/backupbuddy_temp/';
	pb_backupbuddy::save();
}
// Make backup directory if it does not exist yet.
if ( !file_exists( pb_backupbuddy::$options['temp_directory'] ) ) {
	pb_backupbuddy::status( 'details', 'Temporary directory does not exist. Attempting to create.' );
	if ( pb_backupbuddy::$filesystem->mkdir( pb_backupbuddy::$options['temp_directory'] ) === false ) {
		pb_backupbuddy::status( 'error', sprintf( __('Unable to create temporary storage directory (%s)', 'it-l10n-backupbuddy' ) , pb_backupbuddy::$options['temp_directory'] ) );
		pb_backupbuddy::alert( sprintf( __('Unable to create temporary storage directory (%s)', 'it-l10n-backupbuddy' ) , pb_backupbuddy::$options['temp_directory'] ), true, '9002' );
	}
}
/********** End directory checking. **********/


// The below is no longer needed? - Dustin May 12, 2012:
// ZipBuddy handles all zipping, testing available zip methods, etc. Only runs on backupbuddy pages here.
// TODO: Make sure zipbuddy testing is cached.
/*
//todo: add this back in. temp disabled just for some testing jan 25, 11am.
if ( strstr( pb_backupbuddy::_GET( 'page' ), 'backupbuddy' ) && !isset( pb_backupbuddy::$classes['zipbuddy'] ) ) { // Only run if zipbuddy object not already loaded.
	require_once( pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php' );
	pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy( pb_backupbuddy::$options['backup_directory'] );
}
*/
Exemple #11
0
 /**
  *	migrateHtaccess()
  *
  *	Migrates .htaccess.bb_temp file if it exists.
  *
  *	@return		boolean		False only if file is unwritable. True if write success; true if file does not even exist.
  *
  */
 function migrateHtaccess()
 {
     $htaccessFile = ABSPATH . '.htaccess.bb_temp';
     // If no .htaccess.bb_temp file exists then create a basic default one then migrate that as needed. @since 2.2.32.
     if (!file_exists($htaccessFile)) {
         pb_backupbuddy::status('message', 'No `' . basename($htaccessFile) . '` file found. Creating basic default .htaccess.bb_temp file (to be later renamed to .htaccess).');
         // Default .htaccess file.
         $htaccess_contents = "# BEGIN WordPress\n\n\t\t\t\t<IfModule mod_rewrite.c>\n\n\t\t\t\tRewriteEngine On\n\n\t\t\t\tRewriteBase /\n\n\t\t\t\tRewriteRule ^index\\.php\$ - [L]\n\n\t\t\t\tRewriteCond %{REQUEST_FILENAME} !-f\n\n\t\t\t\tRewriteCond %{REQUEST_FILENAME} !-d\n\n\t\t\t\tRewriteRule . /index.php [L]\n\n\t\t\t\t</IfModule>\n\n\t\t\t\t# END WordPress\n";
         file_put_contents($htaccessFile, $htaccess_contents);
         unset($htaccess_contents);
     }
     pb_backupbuddy::status('message', 'Migrating `' . basename($htaccessFile) . '` file...');
     $oldurl = strtolower($this->_state['dat']['siteurl']);
     $oldurl = str_replace('/', '\\', $oldurl);
     $oldurl = str_replace('http:\\', '', $oldurl);
     $oldurl = trim($oldurl, '\\');
     $oldurl = explode('\\', $oldurl);
     $oldurl[0] = '';
     $old_path = implode('/', $oldurl);
     $newurl = strtolower($this->_state['siteurl']);
     $newurl = str_replace('/', '\\', $newurl);
     $newurl = str_replace('http:\\', '', $newurl);
     $newurl = trim($newurl, '\\');
     $newurl = explode('\\', $newurl);
     $newurl[0] = '';
     pb_backupbuddy::status('message', 'Checking `' . basename($htaccessFile) . '` file.');
     if ($newurl !== $oldurl) {
         pb_backupbuddy::status('message', 'URL directory has changed. Updating from `' . implode('/', $oldurl) . '` to `' . implode('/', $newurl) . '`.');
     }
     $rewrite_lines = array();
     $got_rewrite = false;
     $rewrite_path = implode('/', $newurl);
     $file_array = file($htaccessFile);
     $htaccessNeedsUpdating = false;
     // Loop through .htaccess lines, updating as needed.
     foreach ((array) $file_array as $line_number => $line) {
         if ($got_rewrite == true) {
             // In a WordPress section.
             if (strstr($line, 'END WordPress')) {
                 // End of a WordPress block so stop replacing.
                 $got_rewrite = false;
                 $rewrite_lines[] = $line;
                 // Captures end of WordPress block.
             } else {
                 if ($newurl !== $oldurl) {
                     if (strstr($line, 'RewriteBase')) {
                         // RewriteBase
                         $rewrite_lines[] = 'RewriteBase ' . $rewrite_path . '/' . "\n";
                         $htaccessNeedsUpdating = true;
                     } elseif (strstr($line, 'RewriteRule')) {
                         // RewriteRule
                         if (strstr($line, '^index\\.php$')) {
                             // Handle new strange rewriterule. Leave as is.
                             $rewrite_lines[] = $line;
                             pb_backupbuddy::status('details', '.htaccess ^index\\.php$ detected. Leaving as is.');
                         } elseif (!strstr($line, 'RewriteRule . ')) {
                             // Handle what is probably a user generated rule - better detection needed.
                             $new_line = str_replace($old_path, $rewrite_path, $line);
                             $rewrite_lines[] = $new_line;
                             $htaccessNeedsUpdating = true;
                             if ($new_line != $line) {
                                 pb_backupbuddy::status('message', '.htaccess line changed from `' . trim($line) . '` to `' . trim($new_line) . '`.');
                             }
                         } else {
                             // Normal spot.
                             $rewrite_lines[] = 'RewriteRule . ' . $rewrite_path . '/index.php' . "\n";
                             $htaccessNeedsUpdating = true;
                         }
                     } else {
                         // User custom rewriterule we did not update.
                         $rewrite_lines[] = $line;
                         // Captures everything inside WordPress block we arent modifying.
                         if (false !== strstr($line, 'RewriteRule . ')) {
                             // RewriteRule, warn user potentially if path may need changed.
                             if ($old_path !== $rewrite_path) {
                                 pb_backupbuddy::status('warning', 'User-defined RewriteRule found and WordPress path has changed so this rule MAY need manually updated by you to function properly.  Line: "' . $line . '".');
                             }
                         }
                     }
                 }
             }
         } else {
             // Outside a WordPress section.
             if (strstr($line, 'BEGIN WordPress')) {
                 $got_rewrite = true;
                 // Beginning of a WordPress block so start replacing.
             }
             if (strstr($line, 'AddHandler')) {
                 // Has AddHandler. Skip keeping this line -- if importbuddy is running now then we do not need this most likely.
                 $message = 'An AddHandler directive has been found in your .htaccess file. This could result in WordPress and PHP not running properly if configured improperly, especially when migrating to a new server. If you encounter problems such as an Internal Server Error or Error 500, try removing this line from your .htaccess file.  Line: "' . $line . '".';
                 pb_backupbuddy::status('warning', $message);
                 pb_backupbuddy::alert($message);
             } else {
                 $rewrite_lines[] = $line;
                 // Captures everything outside of WordPress block (except addhandler stuff).
             }
         }
     }
     // end foreach.
     // If the URL (domain and/or URL subdirectory ) has changed, then need to update .htaccess.bb_temp file.
     if (true === $htaccessNeedsUpdating) {
         // Check that we can write to this file (if it already exists).
         if (file_exists($htaccessFile) && !is_writable($htaccessFile)) {
             pb_backupbuddy::status('warning', 'Warning #28573: Temp `' . basename($htaccessFile) . '` file shows to be unwritable. Attempting to override permissions temporarily.');
             $oldPerms = fileperms($htaccessFile) & 0777;
             @chmod($htaccessFile, 0644);
             // Try to make writable.
             // Check if still not writable...
             if (!is_writable($htaccessFile)) {
                 pb_backupbuddy::status('error', 'Error #9020: Unable to write to `' . basename($htaccessFile) . '` file. Verify permissions.');
                 pb_backupbuddy::alert('Warning: Unable to write to temporary .htaccess file. Verify this file has proper write permissions. You may receive 404 Not Found errors on your site if this is not corrected. To fix after migration completes: Log in to your WordPress admin and select Settings: Permalinks from the left menu then save. To manually update, copy/paste the following into your .htaccess file: <textarea>' . implode($rewrite_lines) . '</textarea>', '9020');
                 return false;
             }
         }
         $handling = fopen($htaccessFile, 'w');
         fwrite($handling, implode($rewrite_lines));
         fclose($handling);
         unset($handling);
         // Restore prior permissions if applicable.
         if (isset($oldPerms)) {
             @chmod($htaccessFile, $oldPerms);
         }
         pb_backupbuddy::status('message', 'Migrated `' . basename($htaccessFile) . '` file. It will be renamed back to `.htaccess` on the final step.');
     } else {
         pb_backupbuddy::status('message', 'No changes needed for `' . basename($htaccessFile) . '` file.');
     }
     return true;
 }
Exemple #12
0
 function dir_size_map($dir, $base, $exclusions, &$dir_array)
 {
     $dir = rtrim($dir, '/\\');
     // Force no trailing slash.
     if (!is_dir($dir)) {
         return 0;
     }
     $ret = 0;
     $ret_with_exclusions = 0;
     $ret_objects = 0;
     $ret_objects_with_exclusions = 0;
     $exclusions_result = $exclusions;
     $sub = @opendir($dir);
     if (false === $sub) {
         // Cannot access.
         pb_backupbuddy::alert('Error #568385: Unable to access directory: `' . $dir . '`. Verify proper permissions.', true);
         return 0;
     } else {
         while ($file = readdir($sub)) {
             $exclusions_result = $exclusions;
             $dir_path = '/' . str_replace($base, '', $dir . '/' . $file);
             //str_replace( $base, '', $dir . $file . '/' );
             if ($file == '.' || $file == '..') {
                 // Do nothing.
             } elseif (is_dir($dir . '/' . $file)) {
                 // DIRECTORY.
                 if ($exclusions === true || self::in_array_substr($exclusions, $dir_path, '/')) {
                     $exclusions_result = true;
                 }
                 $result = $this->dir_size_map($dir . '/' . $file . '/', $base, $exclusions, $dir_array);
                 $this_size = $result[0];
                 $this_objects = $result[2];
                 if ($exclusions_result === true) {
                     // If excluding then wipe excluded value.
                     $this_size_with_exclusions = false;
                     $this_objects_with_exclusions = 0;
                 } else {
                     $this_size_with_exclusions = $result[1];
                     // / 1048576 );
                     $this_objects_with_exclusions = $result[3];
                     // / 1048576 );
                 }
                 $dir_array[$dir_path] = array($this_size, $this_size_with_exclusions, $this_objects, $this_objects_with_exclusions);
                 // $dir_array[ DIRECTORY_PATH ] = DIRECTORY_SIZE;
                 $ret += $this_size;
                 $ret_objects += $this_objects;
                 $ret_with_exclusions += $this_size_with_exclusions;
                 $ret_objects_with_exclusions += $this_objects_with_exclusions;
                 unset($file);
             } else {
                 // FILE.
                 $stats = stat($dir . '/' . $file);
                 $ret += $stats['size'];
                 $ret_objects++;
                 if ($exclusions !== true && !in_array($dir_path, $exclusions)) {
                     // Not excluding.
                     $ret_with_exclusions += $stats['size'];
                     $ret_objects_with_exclusions++;
                 }
                 unset($file);
             }
         }
         closedir($sub);
         unset($sub);
         return array($ret, $ret_with_exclusions, $ret_objects, $ret_objects_with_exclusions);
     }
 }
Exemple #13
0
<?php

$page_title = 'Unzipping Backup File';
require_once '_header.php';
echo '<div class="wrap">';
echo pb_backupbuddy::$classes['import']->status_box('Extracting backup ZIP file with ImportBuddy v' . pb_backupbuddy::$options['bb_version'] . '... Powered by BackupBuddy.');
echo '<div id="pb_importbuddy_working"><img src="' . pb_backupbuddy::plugin_url() . '/images/loading_large.gif" title="Working... Please wait as this may take a moment..."></div>';
flush();
$results = extract_files();
echo '<script type="text/javascript">jQuery("#pb_importbuddy_working").hide();</script>';
if (true === $results) {
    // Move on to next step.
    echo '<br><br><p style="text-align: center;">Files successfully extracted.</p>';
    echo '<form action="?step=3" method=post>';
    echo '<input type="hidden" name="options" value="' . htmlspecialchars(serialize(pb_backupbuddy::$options)) . '" />';
    echo '</div><!-- /wrap -->';
    echo '<div class="main_box_foot"><input type="submit" name="submit" value="Next Step &rarr;" class="button" /></div>';
    echo '</form>';
} else {
    pb_backupbuddy::alert('File extraction process did not complete successfully. Unable to continue to next step. Manually extract the backup ZIP file and choose to "Skip File Extraction" from the advanced options on Step 1.', true, '9005');
    echo '<p style="text-align: center;"><a href="http://pluginbuddy.com/tutorials/unzip-backup-zip-file-in-cpanel/">Click here for instructions on manual ZIP extraction as a work-around.</a></p>';
    echo '</div><!-- /wrap -->';
}
rename_htaccess_temp();
// Rename .htaccess to .htaccess.bb_temp until end of migration.
get_dat_from_backup();
require_once '_footer.php';
        echo '</form>';
    }
    // end authorication code submitted.
} elseif ('edit' == $mode) {
    // EDIT mode.
    $accessToken = $destination_settings['access_token'];
    try {
        $dropboxClient = new \Dropbox\Client($accessToken, 'BackupBuddy v' . pb_backupbuddy::settings('version'));
    } catch (\Exception $e) {
        pb_backupbuddy::alert('Dropbox Error #143838: ' . $e->getMessage() . '<br><br>' . pb_backupbuddy::$ui->button(pb_backupbuddy::page_url(), '&larr; go back & retry'), true);
        return false;
    }
    try {
        $accountInfo = $dropboxClient->getAccountInfo();
    } catch (\Exception $e) {
        pb_backupbuddy::alert('Dropbox Error #132852: ' . $e->getMessage() . '<br><br>' . pb_backupbuddy::$ui->button(pb_backupbuddy::page_url(), '&larr; go back & retry'), true);
        return false;
    }
    $show_config_form = true;
    // Enable showing configuration form below.
} elseif ('save' == $mode) {
    $show_config_form = true;
} else {
    // UNKNOWN mode.
    die('Error #3283489434: Unknown destination form mode.');
}
// End checking mode.
// Display configuration form.
if (true === $show_config_form) {
    if ('save' != $mode) {
        // Account info.
    echo '<br>';
    pb_backupbuddy::status('details', 'Scheduling Cron for creating Dropbox copy.');
    backupbuddy_core::schedule_single_event(time(), pb_backupbuddy::cron_tag('process_destination_copy'), array($destination, pb_backupbuddy::_GET('cpy')));
    spawn_cron(time() + 150);
    // Adds > 60 seconds to get around once per minute cron running limit.
    update_option('_transient_doing_cron', 0);
    // Prevent cron-blocking for next item.
}
// Delete selected dropbox backup(s) from form submission.
if ('delete_backup' == pb_backupbuddy::_POST('bulk_action')) {
    pb_backupbuddy::verify_nonce();
    if (is_array(pb_backupbuddy::_POST('items'))) {
        if (true === ($result = pb_backupbuddy_destinations::delete($destination, pb_backupbuddy::_POST('items')))) {
            pb_backupbuddy::alert(__('Selected file(s) deleted.', 'it-l10n-backupbuddy'));
        } else {
            pb_backupbuddy::alert(__('Unable to delete one or more files. Details: ', 'it-l10n-backupbuddy') . $result);
        }
        echo '<br>';
    }
}
$files_result = pb_backupbuddy_destinations::listFiles($destination);
$backup_files = array();
foreach ((array) $files_result['contents'] as $file) {
    // Loop through files looking for backups.
    if ($file['is_dir'] == '1') {
        // Do NOT display subdirectories.
        continue;
    }
    $filename = str_ireplace($files_result['path'] . '/', '', $file['path']);
    // Remove path from filename.
    if (isset($file['client_mtime'])) {
}
// Handle copying files to local
if (pb_backupbuddy::_GET('cpy_file') != '') {
    pb_backupbuddy::alert('The remote file is now being copied to your local backups. If the backup gets marked as bad during copying, please wait a bit then click the `Refresh` icon to rescan after the transfer is complete.');
    echo '<br>';
    pb_backupbuddy::status('details', 'Scheduling Cron for creating Stash copy.');
    backupbuddy_core::schedule_single_event(time(), 'process_remote_copy', array('stash', pb_backupbuddy::_GET('cpy_file'), $settings));
    spawn_cron(time() + 150);
    // Adds > 60 seconds to get around once per minute cron running limit.
    update_option('_transient_doing_cron', 0);
    // Prevent cron-blocking for next item.
}
// Handle download link
if (pb_backupbuddy::_GET('downloadlink_file') != '') {
    $link = $s3->get_object($manage_data['bucket'], $manage_data['subkey'] . $remote_path . pb_backupbuddy::_GET('downloadlink_file'), array('preauth' => time() + 3600));
    pb_backupbuddy::alert('You may download this backup (' . pb_backupbuddy::_GET('downloadlink_file') . ') with <a href="' . $link . '">this link</a>. The link is valid for one hour.');
    echo '<br>';
}
// QUOTA INFORMATION.
$account_info = pb_backupbuddy_destination_stash::get_quota(array('itxapi_username' => $itxapi_username, 'itxapi_password' => $itxapi_password), false);
/*
echo '<pre>';
print_r( $account_info );
echo '</pre>';
*/
echo pb_backupbuddy_destination_stash::get_quota_bar($account_info);
echo '<div style="text-align: center;">';
echo '
<b>Upgrade to get more Stash space:</b> &nbsp;
<a href="https://ithemes.com/member/cart.php?action=add&id=290" target="_blank" style="text-decoration: none; font-weight: 300;">+ 5GB</a>, &nbsp;
<a href="https://ithemes.com/member/cart.php?action=add&id=291" target="_blank" style="text-decoration: none; font-weight: 600; font-size: 1.1em;">+ 10GB</a>, &nbsp;
Exemple #17
0
 function periodic_cleanup($backup_age_limit = 43200, $die_on_fail = true)
 {
     if (!isset(pb_backupbuddy::$options)) {
         $this->load();
     }
     // TODO: Check for orphaned .gz files in root from PCLZip.
     // TODO: Cleanup any orphaned temp ZIP creation directories under the backups directory. wp-content/uploads/backupbuddy_backups/temp_zip_XXSERIALXX/
     // Cleanup backup itegrity portion of array.
     $this->trim_backups_integrity_stats();
     // Cleanup logs in pb_backupbuddy dirctory.
     $log_directory = WP_CONTENT_DIR . '/uploads/pb_' . pb_backupbuddy::settings('slug') . '/';
     $files = glob($log_directory . '*.txt');
     if (is_array($files) && !empty($files)) {
         // For robustness. Without open_basedir the glob() function returns an empty array for no match. With open_basedir in effect the glob() function returns a boolean false for no match.
         foreach ($files as $file) {
             $file_stats = stat($file);
             if (time() - $file_stats['mtime'] > $backup_age_limit) {
                 // If older than 12 hours, delete the log.
                 @unlink($file);
             }
         }
     }
     // Cleanup excess backup stats.
     if (count(pb_backupbuddy::$options['backups']) > 3) {
         // Keep a minimum number of backups in array for stats.
         $number_backups = count(pb_backupbuddy::$options['backups']);
         $kept_loop_count = 0;
         $needs_save = false;
         foreach (pb_backupbuddy::$options['backups'] as $backup_serial => $backup) {
             if ($number_backups - $kept_loop_count > 3) {
                 if (isset($backup['archive_file']) && !file_exists($backup['archive_file'])) {
                     unset(pb_backupbuddy::$options['backups'][$backup_serial]);
                     $needs_save = true;
                 } else {
                     $kept_loop_count++;
                 }
             }
         }
         if ($needs_save === true) {
             //echo 'saved';
             pb_backupbuddy::save();
         }
     }
     // Cleanup any temporary local destinations.
     foreach (pb_backupbuddy::$options['remote_destinations'] as $destination_id => $destination) {
         if ($destination['type'] == 'local' && $destination['temporary'] === true) {
             // If local and temporary.
             if (time() - $destination['created'] > $backup_age_limit) {
                 // Older than 12 hours; clear out!
                 pb_backupbuddy::status('details', 'Cleaned up stale local destination `' . $destination_id . '`.');
                 unset(pb_backupbuddy::$options['remote_destinations'][$destination_id]);
                 pb_backupbuddy::save();
             }
         }
     }
     // Cleanup excess remote sending stats.
     $this->trim_remote_send_stats();
     // Check for orphaned backups in the data structure that havent been updates in 12+ hours & cleanup after them.
     foreach ((array) pb_backupbuddy::$options['backups'] as $backup_serial => $backup) {
         if (isset($backup['updated_time'])) {
             if (time() - $backup['updated_time'] > $backup_age_limit) {
                 // If more than 12 hours has passed...
                 pb_backupbuddy::status('details', 'Cleaned up stale backup `' . $backup_serial . '`.');
                 $this->final_cleanup($backup_serial);
             }
         }
     }
     // Verify existance of anti-directory browsing files in backup directory.
     pb_backupbuddy::anti_directory_browsing(pb_backupbuddy::$options['backup_directory'], $die_on_fail);
     // Verify existance of anti-directory browsing files in status log directory.
     $status_directory = WP_CONTENT_DIR . '/uploads/pb_' . pb_backupbuddy::settings('slug') . '/';
     pb_backupbuddy::anti_directory_browsing($status_directory, $die_on_fail);
     // Handle high security mode archives directory .htaccess system. If high security backup directory mode: Make sure backup archives are NOT downloadable by default publicly. This is only lifted for ~8 seconds during a backup download for security. Overwrites any existing .htaccess in this location.
     if (pb_backupbuddy::$options['lock_archives_directory'] == '0') {
         // Normal security mode. Put normal .htaccess.
         pb_backupbuddy::status('details', 'Removing .htaccess high security mode for backups directory. Normal mode .htaccess to be added next.');
         // Remove high security .htaccess.
         if (file_exists(pb_backupbuddy::$options['backup_directory'] . '.htaccess')) {
             $unlink_status = @unlink(pb_backupbuddy::$options['backup_directory'] . '.htaccess');
             if ($unlink_status === false) {
                 pb_backupbuddy::alert('Error #844594. Unable to temporarily remove .htaccess security protection on archives directory to allow downloading. Please verify permissions of the BackupBuddy archives directory or manually download via FTP.');
             }
         }
         // Place normal .htaccess.
         pb_backupbuddy::anti_directory_browsing(pb_backupbuddy::$options['backup_directory'], $die_on_fail);
     } else {
         // High security mode. Make sure high security .htaccess in place.
         pb_backupbuddy::status('details', 'Adding .htaccess high security mode for backups directory.');
         $htaccess_creation_status = @file_put_contents(pb_backupbuddy::$options['backup_directory'] . '.htaccess', 'deny from all');
         if ($htaccess_creation_status === false) {
             pb_backupbuddy::alert('Error #344894545. Security Warning! Unable to create security file (.htaccess) in backups archive directory. This file prevents unauthorized downloading of backups should someone be able to guess the backup location and filenames. This is unlikely but for best security should be in place. Please verify permissions on the backups directory.');
         }
     }
     // Verify existance of anti-directory browsing files in temporary directory.
     pb_backupbuddy::anti_directory_browsing(pb_backupbuddy::$options['temp_directory'], $die_on_fail);
     // Remove any copy of importbuddy.php in root.
     if (file_exists(ABSPATH . 'importbuddy.php')) {
         pb_backupbuddy::status('details', 'Unlinked importbuddy.php in root of site.');
         unlink(ABSPATH . 'importbuddy.php');
     }
     // Remove any copy of importbuddy directory in root.
     if (file_exists(ABSPATH . 'importbuddy/')) {
         pb_backupbuddy::status('details', 'Unlinked importbuddy directory recursively in root of site.');
         pb_backupbuddy::$filesystem->unlink_recursive(ABSPATH . 'importbuddy/');
     }
 }
Exemple #18
0
    echo '<input type="hidden" name="file" value="' . pb_backupbuddy::_GET('file') . '">';
} else {
    ?>
	
	<div class="backup_select_buttons">
		<button href="#pb_upload_modal" class="button button-secondary leanModal createdb_modal_link" style="font-size: 14px;">Upload a Backup</button>
		<button href="#pb_stash_modal" class="button button-secondary leanModal createdb_modal_link" style="font-size: 14px;">Restore from Stash</button>
	</div>
	
	<?php 
    $backup_archives = get_archives_list();
    if (0 == count($backup_archives)) {
        // No backups found.
        // Look for manually unzipped
        pb_backupbuddy::alert('<b>No BackupBuddy Zip backup found in this directory `' . ABSPATH . '`</b> - 
			You must upload a backup file by FTP (into the same directory as this importbuddy.php file), the upload tab, or import from Stash via the Stash tab above to continue.
			<b>Do not rename the backup file from its original filename.</b> If you manually extracted/unzipped, upload the backup file,
			select it, then select <i>Advanced Troubleshooting Options</i> & click <i>Skip Zip Extraction</i>. Refresh this page once you have uploaded the backup.');
    } else {
        // Found one or more backups.
        ?>
			<form action="?ajax=2" method="post" target="miniFrame">
				<input type="hidden" name="pass_hash" value="<?php 
        echo PB_PASSWORD;
        ?>
">
				<input type="hidden" name="options" value="<?php 
        echo htmlspecialchars(serialize(pb_backupbuddy::$options));
        ?>
'" />
		<?php 
        echo '<div class="backup_select_text">Backups in <span>' . ABSPATH . '</span></div>';
Exemple #19
0
    if (file_exists($log_file)) {
        @unlink($log_file);
    }
    if (file_exists($log_file)) {
        // Didnt unlink.
        pb_backupbuddy::alert('Unable to clear log file. Please verify permissions on file `' . $log_file . '`.');
    } else {
        // Unlinked.
        pb_backupbuddy::alert('Cleared log file.');
    }
}
// Reset disalerts.
if (pb_backupbuddy::_GET('reset_disalerts') != '') {
    pb_backupbuddy::$options['disalerts'] = array();
    pb_backupbuddy::save();
    pb_backupbuddy::alert('Dismissed alerts have been reset. They may now be visible again.');
}
echo '<textarea readonly="readonly" style="width: 100%;" wrap="off" cols="65" rows="7">';
if (file_exists($log_file)) {
    readfile($log_file);
} else {
    echo __('Nothing has been logged.', 'it-l10n-backupbuddy');
}
echo '</textarea>';
echo '<a href="' . pb_backupbuddy::page_url() . '&reset_log=true" class="button secondary-button">' . __('Clear Log', 'it-l10n-backupbuddy') . '</a>';
pb_backupbuddy::$ui->end_metabox();
plugin_information(pb_backupbuddy::settings('slug'), array('name' => pb_backupbuddy::settings('name'), 'path' => pb_backupbuddy::plugin_path()));
?>
		
		
		<br style="clear: both;">
 function multisite_network_warning()
 {
     $message = 'BackupBuddy Multisite support is experimental beta software and is not officially supported in a Multisite setting.';
     if (!backupbuddy_core::is_network_activated()) {
         $message .= ' You must <a href="' . esc_url(admin_url('network/plugins.php')) . '">Network Activate</a> BackupBuddy to use it with Multisite (not activate within subsites nor the main site).';
     }
     if (!defined('PB_BACKUPBUDDY_MULTISITE_EXPERIMENT') || PB_BACKUPBUDDY_MULTISITE_EXPERIMENT != TRUE) {
         $message .= ' You must add the following line to your wp-config.php to activate Multisite experimental functionality: <b>define( \'PB_BACKUPBUDDY_MULTISITE_EXPERIMENT\', true );</b>';
     }
     pb_backupbuddy::alert($message, true);
 }
    pb_backupbuddy::status('details', 'Removing .htaccess high security mode for backups directory. Normal mode .htaccess to be added next.');
    // Remove high security .htaccess.
    if (file_exists(backupbuddy_core::getBackupDirectory() . '.htaccess')) {
        $unlink_status = @unlink(backupbuddy_core::getBackupDirectory() . '.htaccess');
        if ($unlink_status === false) {
            pb_backupbuddy::alert('Error #844594. Unable to temporarily remove .htaccess security protection on archives directory to allow downloading. Please verify permissions of the BackupBuddy archives directory or manually download via FTP.');
        }
    }
    // Place normal .htaccess.
    pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getBackupDirectory(), $die_on_fail);
} else {
    // High security mode. Make sure high security .htaccess in place.
    pb_backupbuddy::status('details', 'Adding .htaccess high security mode for backups directory.');
    $htaccess_creation_status = @file_put_contents(backupbuddy_core::getBackupDirectory() . '.htaccess', 'deny from all');
    if ($htaccess_creation_status === false) {
        pb_backupbuddy::alert('Error #344894545. Security Warning! Unable to create security file (.htaccess) in backups archive directory. This file prevents unauthorized downloading of backups should someone be able to guess the backup location and filenames. This is unlikely but for best security should be in place. Please verify permissions on the backups directory.');
    }
}
$temp_dir = get_temp_dir();
// Remove any copy of importbuddy.php in root.
pb_backupbuddy::status('details', 'Cleaning up any importbuddy scripts in site root if it exists & is not very recent.');
$importbuddyFiles = glob($temp_dir . 'importbuddy*.php');
if (!is_array($importbuddyFiles)) {
    $importbuddyFiles = array();
}
foreach ($importbuddyFiles as $importbuddyFile) {
    $modified = filemtime($importbuddyFile);
    if (FALSE === $modified || time() > $modified + backupbuddy_constants::CLEANUP_MAX_IMPORTBUDDY_AGE) {
        // If time modified unknown OR was modified long enough ago.
        pb_backupbuddy::status('details', 'Unlinked `' . basename($importbuddyFile) . '` in root of site.');
        unlink($importbuddyFile);
Exemple #22
0
$post_backup_steps = array();
if (pb_backupbuddy::_GET('after_destination') != '' && is_numeric(pb_backupbuddy::_GET('after_destination'))) {
    $destination_id = (int) pb_backupbuddy::_GET('after_destination');
    if (pb_backupbuddy::_GET('delete_after') == 'true') {
        $delete_after = true;
    } else {
        $delete_after = false;
    }
    $post_backup_steps = array(array('function' => 'send_remote_destination', 'args' => array($destination_id, $delete_after), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0));
    pb_backupbuddy::status('details', 'Manual backup set to send to remote destination `' . $destination_id . '`.  Delete after: `' . $delete_after . '`. Added to post backup function steps.');
}
// Run the backup!
pb_backupbuddy::flush();
// Flush any buffer to screen just before the backup begins.
if (pb_backupbuddy::$classes['backup']->start_backup_process($profile_array, 'manual', array(), $post_backup_steps, '', $serial_override, $export_plugins) !== true) {
    pb_backupbuddy::alert(__('Fatal Error #4344443: Backup failure', 'it-l10n-backupbuddy'), true);
}
?>


	<?php 
pb_backupbuddy::$ui->end_tab();
?>

</div>




<div style="width: 793px;">
	<div id="backupbuddy_errors_notice"><span id="backupbuddy_errors_notice_count"></span> or more errors encountered. See the Status Log for details.<br><span id="backupbuddy_errors_notice_subtext"><b>Not all errors are fatal.</b> Look up error codes & troubleshooting details in the <a href="http://ithemes.com/codex/page/BackupBuddy#Troubleshooting" target="_new"><b>Knowledge Base</b></a>.<br><b><i>Provide a copy of the Status Log if seeking support.</i></b></span></div>
Exemple #23
0
                    global $pb_hide_save;
                    global $pb_hide_test;
                    $pb_hide_save = true;
                    $pb_hide_test = true;
                    echo '<br><b>Adding a Dropbox destination</b><ol>';
                    echo '<li>Click the <b>' . __('Connect to Dropbox & Authorize', 'it-l10n-backupbuddy') . '</b> button below.</li>';
                    echo '<li>In the new window that opens, login to Dropbox.com if prompted and click <b>Allow</b>.</li>';
                    echo '<li>Return to this window and click the <b>' . __("Yes, I've Authorized BackupBuddy with Dropbox", 'it-l10n-backupbuddy') . '</b> button below.</li>';
                    echo '<li>Configure the destination and click the <b>+' . __('Add Destination', 'it-l10n-backupbuddy') . '</b> button.</li>';
                    echo '</ol>';
                    echo '<a href="' . $dropbuddy->get_authorize_url() . '" class="button-primary pb_dropbox_authorize" target="_new">' . __('Connect to Dropbox & Authorize (opens new window)', 'it-l10n-backupbuddy') . '</a>';
                } else {
                    pb_backupbuddy::$options['dropboxtemptoken'] = '';
                    // Clear temp token.
                    pb_backupbuddy::save();
                    pb_backupbuddy::alert('Error #6557565: Dropbox authentication failed; BackupBuddy access to your account is no longer valid. You should delete this destination and re-add it.', true);
                }
            }
        }
    }
    // Yes, I've Authorized BackupBuddy with Dropbox BUTTON.
    echo '<a href="';
    echo pb_backupbuddy::ajax_url('destination_picker') . '&add=dropbox&callback_data=' . pb_backupbuddy::_GET('callback_data') . '&t=' . time() . '&dropbox_auth=true';
    echo '" id="pb_dropbox_authorize" style="display: none;" class="button-primary">' . __("Yes, I've Authorized BackupBuddy with Dropbox", 'it-l10n-backupbuddy') . '</a>';
    //echo '<br>';
} else {
    // end add & edit mode.
    $hide_add = false;
}
// ACCOUNT INFO ONCE ACCEPTED.
if ($hide_add !== true) {
Exemple #24
0
 function process_remote_copy($destination_type, $file, $settings)
 {
     pb_backupbuddy::status('details', 'Copying remote `' . $destination_type . '` file `' . $file . '` down to local.');
     pb_backupbuddy::set_greedy_script_limits();
     if (!class_exists('backupbuddy_core')) {
         require_once pb_backupbuddy::plugin_path() . '/classes/core.php';
     }
     // Determine destination filename.
     $destination_file = backupbuddy_core::getBackupDirectory() . basename($file);
     if (file_exists($destination_file)) {
         $destination_file = str_replace('backup-', 'backup_copy_' . pb_backupbuddy::random_string(5) . '-', $destination_file);
     }
     pb_backupbuddy::status('details', 'Filename of resulting local copy: `' . $destination_file . '`.');
     if ($destination_type == 'stash2') {
         require_once ABSPATH . 'wp-admin/includes/file.php';
         pb_backupbuddy::status('details', 'About to begin downloading from URL.');
         $download = download_url($url);
         pb_backupbuddy::status('details', 'Download process complete.');
         if (is_wp_error($download)) {
             $error = 'Error #832989323: Unable to download file `' . $file . '` from URL: `' . $url . '`. Details: `' . $download->get_error_message() . '`.';
             pb_backupbuddy::status('error', $error);
             pb_backupbuddy::alert($error);
             return false;
         } else {
             if (false === copy($download, $destination_file)) {
                 $error = 'Error #3329383: Unable to copy file from `' . $download . '` to `' . $destination_file . '`.';
                 pb_backupbuddy::status('error', $error);
                 pb_backupbuddy::alert($error);
                 @unlink($download);
                 return false;
             } else {
                 pb_backupbuddy::status('details', 'File saved to `' . $destination_file . '`.');
                 @unlink($download);
                 return true;
             }
         }
     }
     // end stash2.
     if ($destination_type == 'stash') {
         $itxapi_username = $settings['itxapi_username'];
         $itxapi_password = $settings['itxapi_password'];
         // Load required files.
         pb_backupbuddy::status('details', 'Load Stash files.');
         require_once pb_backupbuddy::plugin_path() . '/destinations/stash/init.php';
         require_once dirname(dirname(__FILE__)) . '/destinations/_s3lib/aws-sdk/sdk.class.php';
         require_once pb_backupbuddy::plugin_path() . '/destinations/stash/lib/class.itx_helper.php';
         // Talk with the Stash API to get access to do things.
         pb_backupbuddy::status('details', 'Authenticating Stash for remote copy to local.');
         $stash = new ITXAPI_Helper(pb_backupbuddy_destination_stash::ITXAPI_KEY, pb_backupbuddy_destination_stash::ITXAPI_URL, $itxapi_username, $itxapi_password);
         $manage_url = $stash->get_manage_url();
         $request = new RequestCore($manage_url);
         $response = $request->send_request(true);
         // Validate response.
         if (!$response->isOK()) {
             $error = 'Request for management credentials failed.';
             pb_backupbuddy::status('error', $error);
             pb_backupbuddy::alert($error);
             return false;
         }
         if (!($manage_data = json_decode($response->body, true))) {
             $error = 'Did not get valid JSON response.';
             pb_backupbuddy::status('error', $error);
             pb_backupbuddy::alert($error);
             return false;
         }
         if (isset($manage_data['error'])) {
             $error = 'Error: ' . implode(' - ', $manage_data['error']);
             pb_backupbuddy::status('error', $error);
             pb_backupbuddy::alert($error);
             return false;
         }
         // Connect to S3.
         pb_backupbuddy::status('details', 'Instantiating S3 object.');
         $s3 = new AmazonS3($manage_data['credentials']);
         pb_backupbuddy::status('details', 'About to get Stash object `' . $file . '`...');
         try {
             $response = $s3->get_object($manage_data['bucket'], $manage_data['subkey'] . pb_backupbuddy_destination_stash::get_remote_path() . $file, array('fileDownload' => $destination_file));
         } catch (Exception $e) {
             pb_backupbuddy::status('error', 'Error #5443984: ' . $e->getMessage());
             error_log('err:' . $e->getMessage());
             return false;
         }
         if ($response->isOK()) {
             pb_backupbuddy::status('details', 'Stash copy to local success.');
             return true;
         } else {
             pb_backupbuddy::status('error', 'Error #894597845. Stash copy to local FAILURE. Details: `' . print_r($response, true) . '`.');
             return false;
         }
     } elseif ($destination_type == 'gdrive') {
         die('Not implemented here.');
         require_once pb_backupbuddy::plugin_path() . '/destinations/gdrive/init.php';
         $settings = array_merge(pb_backupbuddy_destination_gdrive::$default_settings, $settings);
         if (true === pb_backupbuddy_destination_gdrive::getFile($settings, $file, $destination_file)) {
             // success
             pb_backupbuddy::status('details', 'Google Drive copy to local success.');
             return true;
         } else {
             // fail
             pb_backupbuddy::status('details', 'Error #2332903. Google Drive copy to local FAILURE.');
             return false;
         }
     } elseif ($destination_type == 's3') {
         require_once pb_backupbuddy::plugin_path() . '/destinations/s3/init.php';
         if (true === pb_backupbuddy_destination_s3::download_file($settings, $file, $destination_file)) {
             // success
             pb_backupbuddy::status('details', 'S3 copy to local success.');
             return true;
         } else {
             // fail
             pb_backupbuddy::status('details', 'Error #85448774. S3 copy to local FAILURE.');
             return false;
         }
     } else {
         pb_backupbuddy::status('error', 'Error #859485. Unknown destination type for remote copy `' . $destination_type . '`.');
         return false;
     }
 }
Exemple #25
0
        }
        $account_details .= '.';
        if ($mode == 'add') {
            $default_name = 'My Stash';
            echo $account_details;
            //echo '<br>';
            echo ' ' . __('To jump right in using the defaults just hit "Add Destination" below.', 'it-l10n-backupbuddy');
        } else {
            echo '<div style="text-align: center;">' . $account_details . '</div>';
        }
        if ($mode == 'add') {
            // Check to see if user already has a Stash with this username set up for this site. No need for multiple same account Stashes.
            foreach ((array) pb_backupbuddy::$options['remote_destinations'] as $destination) {
                if (isset($destination['itxapi_username']) && strtolower($destination['itxapi_username']) == strtolower($itxapi_username)) {
                    echo '<br><br>';
                    pb_backupbuddy::alert('Note: You already have a Stash destination set up under the provided iThemes account username.  It is unnecessary to create multiple Stash destinations that go to the same user account as they are effectively the same destination and a duplicate.');
                    break;
                }
            }
        }
        echo '<br><br>';
        echo pb_backupbuddy_destination_stash::get_quota_bar($account_info);
        echo '<div style="text-align: center;">';
        echo '
		<b>Upgrade to more space:</b> &nbsp;
		<a href="http://ithemes.com/member/cart.php?action=add&id=290" target="_blank" style="text-decoration: none; font-weight: 300;">+ 5GB</a>, &nbsp;
		<a href="http://ithemes.com/member/cart.php?action=add&id=290" target="_blank" style="text-decoration: none; font-weight: 600; font-size: 1.1em;">+ 10GB</a>, &nbsp;
		<a href="http://ithemes.com/member/cart.php?action=add&id=290" target="_blank" style="text-decoration: none; font-weight: 800; font-size: 1.2em;">+ 25GB</a>
		&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
		<a href="http://ithemes.com/member/panel/stash.php" target="_blank" style="text-decoration: none;"><b>Manage Files & Account</b></a>
		';
Exemple #26
0
 public function importexport_settings()
 {
     pb_backupbuddy::load();
     pb_backupbuddy::$ui->ajax_header();
     if (pb_backupbuddy::_POST('import_settings') != '') {
         $import = trim(stripslashes(pb_backupbuddy::_POST('import_data')));
         $import = base64_decode($import);
         if ($import === false) {
             // decode failed.
             pb_backupbuddy::alert('Unable to decode settings data. Import aborted. Insure that you fully copied the settings and did not change any of the text.');
         } else {
             // decode success.
             if (($import = maybe_unserialize($import)) === false) {
                 // unserialize fail.
                 pb_backupbuddy::alert('Unable to unserialize settings data. Import aborted. Insure that you fully copied the settings and did not change any of the text.');
             } else {
                 // unserialize success.
                 if (!isset($import['data_version'])) {
                     // missing expected content.
                     pb_backupbuddy::alert('Unserialized settings data but it did not contain expected data. Import aborted. Insure that you fully copied the settings and did not change any of the text.');
                 } else {
                     // contains expected content.
                     pb_backupbuddy::$options = $import;
                     require_once pb_backupbuddy::plugin_path() . '/controllers/activation.php';
                     // Run data migration to upgrade if needed.
                     pb_backupbuddy::save();
                     pb_backupbuddy::alert('Provided settings successfully imported. Prior settings overwritten.');
                 }
             }
         }
     }
     echo '<h2>Export BackupBuddy Settings</h2>';
     echo 'Copy the encoded plugin settings below and paste it into the destination BackupBuddy Settings Import page.<br><br>';
     echo '<textarea style="width: 100%; height: 100px;" wrap="on">';
     echo base64_encode(serialize(pb_backupbuddy::$options));
     echo '</textarea>';
     echo '<br><br><br>';
     echo '<h2>Import BackupBuddy Settings</h2>';
     echo 'Paste encoded plugin settings below to import & replace current settings.  If importing settings from an older version and errors are encountered please deactivate and reactivate the plugin.<br><br>';
     echo '<form method="post" action="' . pb_backupbuddy::ajax_url('importexport_settings') . '">';
     echo '<textarea style="width: 100%; height: 100px;" wrap="on" name="import_data"></textarea>';
     echo '<br><br><input type="submit" name="import_settings" value="Import Settings" class="button button-primary">';
     echo '</form>';
     pb_backupbuddy::$ui->ajax_footer();
     die;
 }
Exemple #27
0
<?php

pb_backupbuddy::$ui->title(__('Deploy Database', 'it-l10n-backupbuddy') . ' &nbsp;&nbsp; <a style="font-size: 0.6em;" href="#" onClick="jQuery(\'#pb_backupbuddy_status_wrap\').toggle();">Display Status Log</a>');
if (!defined('BACKUPBUDDY_API_ENABLE') || TRUE != BACKUPBUDDY_API_ENABLE) {
    pb_backupbuddy::alert("Make sure the following is in your wp-config.php file on this server:<br><textarea style='width: 100%;' disabled='disabled'>define( 'BACKUPBUDDY_API_ENABLE', true ); // Requires API key to access.</textarea>");
    return false;
}
/*
if ( ! defined( 'BACKUPBUDDY_API_SALT' ) || ( 'CHANGEME' == BACKUPBUDDY_API_SALT ) || ( strlen( BACKUPBUDDY_API_SALT ) < 5 ) ) {
	pb_backupbuddy::alert( "Make sure the following is in your wp-config.php file on this server:<br><textarea style='width: 100%;' disabled='disabled'>define( 'BACKUPBUDDY_API_SALT', 'CHANGEME' ); // !!! IMPORTANT !!! Change CHANGEME to the left to a unique password/phrase for generating API keys. 5+ characters.</textarea>" );
	return false;
}
*/
if ('1' == pb_backupbuddy::_POST('regenerate_api_key')) {
    pb_backupbuddy::verify_nonce();
    // Security check.
    pb_backupbuddy::$options['api_key'] = backupbuddy_core::generate_api_key();
    pb_backupbuddy::save();
}
?>

<b>Note:</b> wp-config.php files as well as BackupBuddy settings will NOT be transferred in either direction. Your current BackupBuddy settings, destinations, API keys etc. will remain as they are on both sites.<br><br>

<form method="post">
	<?php 
pb_backupbuddy::nonce();
?>
	<input type="hidden" name="regenerate_api_key" value="1">
	<button class="button secondary-button" onClick="jQuery('.backupbuddy_api_key-hide').toggle(); return false;">Show API Key</button><span class="backupbuddy_api_key-hide" style="display: none;">&nbsp;&nbsp;<input type="submit" name="submit" value="Generate New API Key" class="button button-primary"></span>
	<br>
	<br>
<?php

// Incoming vars: $backupFile, $step
if (!current_user_can(pb_backupbuddy::$options['role_access'])) {
    die('Error #473623. Access Denied.');
}
//pb_backupbuddy::verify_nonce();
$restoreData = unserialize(base64_decode(pb_backupbuddy::_POST('restoreData')));
require_once pb_backupbuddy::plugin_path() . '/classes/restore.php';
$rollback = new backupbuddy_restore('rollback', $restoreData);
$status = $rollback->swapDatabases();
if (false === $status) {
    $errors = $rollback->getErrors();
    if (count($errors) > 0) {
        pb_backupbuddy::alert('Errors were encountered: ' . implode(', ', $errors) . ' If seeking support please click to Show Advanced Details above and provide a copy of the log.');
    }
    return;
}
$restoreData = $rollback->getState();
?>


<h3>Test your site then select <i>Accept</i> to lock in changes or <i>Cancel</i> to undo.</h3>
<a href="<?php 
echo site_url();
?>
" target="_new"><b>Click here to test your site</b></a> before proceeding.
<br><br>
If your site functions as expected you may proceed to making these changes permanent by selecting the button below to
accept the changes. If anything appears wrong or you have not made a backup of your original site you should select to cancel
the rollback to revert your site to its prior condition.
            // Run cron.
            $cron_array = $cron[$timestamp][$cron_hook][$cron_key];
            // Get cron array based on passed values.
            /*
            if ( count( $cron_array['args'] ) == 1 ) {
            	$args = $cron_array['args'][0];
            } else {
            	$args = $cron_array['args'];
            }
            */
            do_action_ref_array($cron_hook, $cron_array['args']);
            // Run the cron job!
            pb_backupbuddy::alert('Ran CRON event `' . $cron_hook . ' / ' . $cron_key . '`. Its schedule was not modified.');
        } else {
            // Cron not found, error.
            pb_backupbuddy::alert('Invalid CRON job. Not found.', true);
        }
    }
}
// Loop through each cron time to create $crons array for displaying later.
$crons = array();
foreach ((array) $cron as $time => $cron_item) {
    if (is_numeric($time)) {
        // Loop through each schedule for this time
        foreach ((array) $cron_item as $hook_name => $event) {
            foreach ((array) $event as $item_name => $item) {
                // Determine period.
                if (!empty($item['schedule'])) {
                    // Recurring schedule.
                    $period = $item['schedule'];
                } else {
Exemple #30
0
<span id="backupbuddy_gdrive_loading"><h3><img src="<?php 
echo pb_backupbuddy::plugin_url();
?>
/images/loading.gif" alt="' . __('Loading...', 'it-l10n-backupbuddy' ) . '" title="' . __('Loading...', 'it-l10n-backupbuddy' ) . '" width="16" height="16" style="vertical-align: -3px;"> <?php 
_e('Loading...', 'it-l10n-backupbuddy');
?>
</h3></span>


<?php 
pb_backupbuddy::flush();
$info = pb_backupbuddy_destination_gdrive::getDriveInfo($settings);
$folderMeta = pb_backupbuddy_destination_gdrive::getFileMeta($settings, $folderID);
if (false === $folderMeta) {
    pb_backupbuddy::alert('Error connecting to Google Drive.');
    ?>
	<script>jQuery( '#backupbuddy_gdrive_loading' ).hide();</script>
	<?php 
    return false;
}
//echo '<h3>Files in folder "<a href="' . $folderMeta->alternateLink . '" target="_new">' . $folderMeta->title . '</a>" <span style="font-size: 0.6em;">(Used ' . pb_backupbuddy::$format->file_size( $info['quotaUsed'] ) . ' of ' . pb_backupbuddy::$format->file_size( $info['quotaTotal'] ) . ' available space)</span></h3>';
$usagePercent = ceil($info['quotaUsed'] / $info['quotaTotal'] * 100);
echo '<center><b>Usage</b>:&nbsp; ' . pb_backupbuddy::$format->file_size($info['quotaUsed']) . ' &nbsp;of&nbsp; ' . pb_backupbuddy::$format->file_size($info['quotaTotal']) . ' &nbsp;( ' . $usagePercent . ' % )</center>';
$files = pb_backupbuddy_destination_gdrive::listFiles($settings, "title contains 'backup-' AND '" . $folderID . "' IN parents AND trashed=false");
//"title contains 'backup' and trashed=false" );
if (false === $files) {
    die('Error #834843: Error attempting to list files.');
}
?>
<script>jQuery( '#backupbuddy_gdrive_loading' ).hide();</script>