当前位置: 首页>>代码示例>>PHP>>正文


PHP pb_backupbuddy::anti_directory_browsing方法代码示例

本文整理汇总了PHP中pb_backupbuddy::anti_directory_browsing方法的典型用法代码示例。如果您正苦于以下问题:PHP pb_backupbuddy::anti_directory_browsing方法的具体用法?PHP pb_backupbuddy::anti_directory_browsing怎么用?PHP pb_backupbuddy::anti_directory_browsing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pb_backupbuddy的用法示例。


在下文中一共展示了pb_backupbuddy::anti_directory_browsing方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test

 public static function test($settings)
 {
     $email = $settings['address'];
     pb_backupbuddy::status('details', 'Testing email destination. Sending ImportBuddy.php.');
     pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
     $importbuddy_temp = backupbuddy_core::getTempDirectory() . 'importbuddy_' . pb_backupbuddy::random_string(10) . '.php.tmp';
     // Full path & filename to temporary importbuddy
     backupbuddy_core::importbuddy($importbuddy_temp);
     // Create temporary importbuddy.
     $files = array($importbuddy_temp);
     if (pb_backupbuddy::$options['email_return'] != '') {
         $email_return = pb_backupbuddy::$options['email_return'];
     } else {
         $email_return = get_option('admin_email');
     }
     $headers = 'From: BackupBuddy <' . $email_return . '>' . "\r\n";
     $wp_mail_result = wp_mail($email, 'BackupBuddy Test', 'BackupBuddy destination test for ' . site_url(), $headers, $files);
     pb_backupbuddy::status('details', 'Sent test email.');
     @unlink($importbuddy_temp);
     if ($wp_mail_result === true) {
         // WP sent. Hopefully it makes it!
         return true;
     } else {
         // WP couldn't try to send.
         echo 'WordPress was unable to attempt to send email. Check your WordPress & server settings.';
         return false;
     }
 }
开发者ID:Coop920,项目名称:Sterling-Wellness,代码行数:28,代码来源:init.php

示例2: __construct

 function __construct($file, $read_only = false, $ignore_lock = false, $create_file = false)
 {
     $this->_file = $file;
     $this->_read_only = $read_only;
     // If read-only then ignore locks is forced.
     if ($read_only === true) {
         $ignore_lock = true;
     }
     if (!file_exists(dirname($file))) {
         // Directory exist?
         pb_backupbuddy::anti_directory_browsing(dirname($file), $die_on_fail = false, $deny_all = true);
     }
     /*
     if ( ! file_exists( $file ) ) { // File exist?
     	//$this->save();
     }
     */
     $this->load($ignore_lock, $create_file);
 }
开发者ID:FelixNong1990,项目名称:andy,代码行数:19,代码来源:fileoptions.php

示例3: destination_send

 public function destination_send($destination_settings, $files, $send_id = '', $delete_after = false, $identifier = '', $isRetry = false)
 {
     pb_backupbuddy::status('details', 'Beginning cron destination_send. Unique ID: `' . $identifier . '`.');
     if ('' != $identifier) {
         $lockFile = backupbuddy_core::getLogDirectory() . 'cronSend-' . $identifier . '.lock';
         pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
         if (@file_exists($lockFile)) {
             // Lock exists already. Duplicate run?
             $attempts = @file_get_contents($lockFile);
             $attempts++;
             pb_backupbuddy::status('warning', 'Lock file exists and now shows ' . $attempts . ' attempts.');
             $attempts = @file_get_contents($lockFile, $attempts);
             return;
         } else {
             // No lock yet.
             if (false === @file_put_contents($lockFile, '1')) {
                 pb_backupbuddy::status('warning', 'Unable to create destination send lock file `' . $lockFile . '`.');
             } else {
                 pb_backupbuddy::status('details', 'Create destination send lock file `' . $lockFile . '`.');
             }
         }
     }
     pb_backupbuddy::status('details', 'Launching destination send via cron.');
     if (!class_exists('backupbuddy_core')) {
         require_once pb_backupbuddy::plugin_path() . '/classes/core.php';
     }
     if (true === backupbuddy_core::destination_send($destination_settings, $files, $send_id, $delete_after, $isRetry)) {
         // completely finished, go ahead and clean up lock file.
         /* DO not delete here as we need to keep this locked down a little longer...
         			if ( '' != $identifier ) {
         				if ( true === @unlink( $lockFile ) ) {
         					pb_backupbuddy::status( 'details', 'Removed destination lock file.' );
         				} else {
         					pb_backupbuddy::status( 'warning', 'Unable to remove destination lock file `' . $lockFile . '`.' );
         				}
         			}
         			*/
     }
 }
开发者ID:elephantcode,项目名称:elephantcode,代码行数:39,代码来源:cron.php

示例4: get_temp_dir

// Calculate temp directory & lock it down.
$temp_dir = get_temp_dir();
$destination = $temp_dir . 'backupbuddy-' . $serial;
if (!file_exists($destination) && false === mkdir($destination)) {
    $error = 'Error #458485945b: Unable to create temporary location.';
    pb_backupbuddy::status('error', $error);
    die($error);
}
// If temp directory is within webroot then lock it down.
$temp_dir = str_replace('\\', '/', $temp_dir);
// Normalize for Windows.
$temp_dir = rtrim($temp_dir, '/\\') . '/';
// Enforce single trailing slash.
if (FALSE !== stristr($temp_dir, ABSPATH)) {
    // Temp dir is within webroot.
    pb_backupbuddy::anti_directory_browsing($destination);
}
unset($temp_dir);
$message = 'Extracting "' . $file . '" from archive "' . $archive_file . '" into temporary file "' . $destination . '". ';
echo '<!-- ';
pb_backupbuddy::status('details', $message);
echo $message;
$extractions = array($file => $temp_file);
$extract_result = $zipbuddy->extract(backupbuddy_core::getBackupDirectory() . $archive_file, $destination, $extractions);
if (false === $extract_result) {
    // failed.
    echo ' -->';
    $error = 'Error #584984458. Unable to extract.';
    pb_backupbuddy::status('error', $error);
    die($error);
} else {
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:31,代码来源:restore_file_view.php

示例5: restore

 public static function restore($archive_file, $files, $finalPath, &$zipbuddy = null)
 {
     if (!current_user_can(pb_backupbuddy::$options['role_access'])) {
         die('Error #473623. Access Denied.');
     }
     $serial = backupbuddy_core::get_serial_from_file($archive_file);
     // serial of archive.
     $success = false;
     foreach ($files as $file) {
         $file = str_replace('*', '', $file);
         // Remove any wildcard.
         if (file_exists($finalPath . $file) && is_dir($finalPath . $file)) {
             if (($file_count = @scandir($finalPath . $file)) && count($file_count) > 2) {
                 pb_backupbuddy::status('error', __('Error #9036. The destination directory being restored already exists and is NOT empty. The directory will not be restored to prevent inadvertently losing files within the existing directory. Delete existing directory first if you wish to proceed or restore individual files.', 'it-l10n-backupbuddy') . ' Existing directory: `' . $finalPath . $file . '`.');
                 return false;
             }
         }
     }
     if (null === $zipbuddy) {
         require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
         $zipbuddy = new pluginbuddy_zipbuddy(backupbuddy_core::getBackupDirectory());
     }
     // Calculate temp directory & lock it down.
     $temp_dir = get_temp_dir();
     $destination = $temp_dir . 'backupbuddy-' . $serial;
     if (!file_exists($destination) && false === mkdir($destination, 0777, true)) {
         $error = 'Error #458485945: Unable to create temporary location.';
         pb_backupbuddy::status('error', $error);
         return false;
     }
     // If temp directory is within webroot then lock it down.
     $temp_dir = str_replace('\\', '/', $temp_dir);
     // Normalize for Windows.
     $temp_dir = rtrim($temp_dir, '/\\') . '/';
     // Enforce single trailing slash.
     if (FALSE !== stristr($temp_dir, ABSPATH)) {
         // Temp dir is within webroot.
         pb_backupbuddy::anti_directory_browsing($destination);
     }
     unset($temp_dir);
     pb_backupbuddy::status('details', 'Extracting into temporary directory "' . $destination . '".');
     $prettyFilesList = array();
     foreach ($files as $fileSource => $fileDestination) {
         $prettyFilesList[] = $fileSource . ' => ' . $fileDestination;
     }
     pb_backupbuddy::status('details', 'Files to extract: `' . htmlentities(implode(', ', $prettyFilesList)) . '`.');
     unset($prettyFilesList);
     pb_backupbuddy::flush();
     // Do the actual extraction.
     $extract_success = true;
     if (false === $zipbuddy->extract($archive_file, $destination, $files)) {
         pb_backupbuddy::status('error', 'Error #584984458b. Unable to extract.');
         $extract_success = false;
     }
     if (true === $extract_success) {
         // Verify all files/directories to be extracted exist in temp destination directory. If any missing then delete everything and bail out.
         foreach ($files as &$file) {
             $file = str_replace('*', '', $file);
             // Remove any wildcard.
             if (!file_exists($destination . '/' . $file)) {
                 // Cleanup.
                 foreach ($files as $file) {
                     @trigger_error('');
                     // Clear out last error.
                     @unlink($destination . '/' . $file);
                     $last_error = error_get_last();
                     if (is_array($last_error)) {
                         pb_backupbuddy::status('error', $last_error['message'] . ' File: `' . $last_error['file'] . '`. Line: `' . $last_error['line'] . '`.');
                     }
                 }
                 pb_backupbuddy::status('error', 'Error #854783474. One or more expected files / directories missing.');
                 $extract_success = false;
                 break;
             }
         }
         unset($file);
         // Made it this far so files all exist. Move them all.
         foreach ($files as $file) {
             @trigger_error('');
             // Clear out last error.
             if (false === @rename($destination . '/' . $file, $finalPath . $file)) {
                 $last_error = error_get_last();
                 if (is_array($last_error)) {
                     //print_r( $last_error );
                     pb_backupbuddy::status('error', $last_error['message'] . ' File: `' . $last_error['file'] . '`. Line: `' . $last_error['line'] . '`.');
                 }
                 $error = 'Error #9035. Unable to move restored file `' . $destination . '/' . $file . '` to `' . $finalPath . $file . '`. Verify permissions on destination location & that the destination directory/file does not already exist.';
                 pb_backupbuddy::status('error', $error);
             } else {
                 $details = 'Moved `' . $destination . '/' . $file . '` to `' . $finalPath . $file . '`.<br>';
                 pb_backupbuddy::status('details', $details);
                 $success = true;
             }
         }
     }
     // end extract success.
     // Try to cleanup.
     if (file_exists($destination)) {
         if (false === pb_backupbuddy::$filesystem->unlink_recursive($destination)) {
             pb_backupbuddy::status('details', 'Unable to delete temporary holding directory `' . $destination . '`.');
//.........这里部分代码省略.........
开发者ID:FelixNong1990,项目名称:andy,代码行数:101,代码来源:_restoreFiles.php

示例6: verify_directories

 public static function verify_directories($skipTempGeneration = false)
 {
     $success = true;
     // Update backup directory if unable to write to the defined one.
     if (!@is_writable(backupbuddy_core::getBackupDirectory())) {
         pb_backupbuddy::status('details', 'Backup directory invalid. Updating from `' . backupbuddy_core::getBackupDirectory() . '` to default.');
         pb_backupbuddy::$options['backup_directory'] = '';
         // Reset to default (blank).
         pb_backupbuddy::save();
     }
     $response = pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getBackupDirectory(), $die = false);
     if (false === $response) {
         $success = false;
     }
     // Update log directory if unable to write to the defined one.
     if (!@is_writable(backupbuddy_core::getLogDirectory())) {
         pb_backupbuddy::status('details', 'Log directory invalid. Updating from `' . backupbuddy_core::getLogDirectory() . '` to default.');
         pb_backupbuddy::$options['log_directory'] = '';
         // Reset to default (blank).
         pb_backupbuddy::save();
     }
     pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getLogDirectory(), $die = false);
     if (false === $response) {
         $success = false;
     }
     // Update temp directory if unable to write to the defined one.
     if (true !== $skipTempGeneration) {
         if (!@is_writable(backupbuddy_core::getTempDirectory())) {
             pb_backupbuddy::status('details', 'Temporary directory invalid. Updating from `' . backupbuddy_core::getTempDirectory() . '` to default.');
             pb_backupbuddy::$options['temp_directory'] = '';
             pb_backupbuddy::save();
         }
         pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
         if (false === $response) {
             $success = false;
         }
     }
     global $pb_backupbuddy_directory_verification;
     $pb_backupbuddy_directory_verification = $success;
     return $success;
 }
开发者ID:bunnywong,项目名称:freshlinker,代码行数:41,代码来源:core.php

示例7: str_replace

/* BEGIN VERIFYING BACKUP DIRECTORY */
if (pb_backupbuddy::_POST('pb_backupbuddy_backup_directory') != '') {
    $backup_directory = pb_backupbuddy::_POST('pb_backupbuddy_backup_directory');
    $backup_directory = str_replace('\\', '/', $backup_directory);
    $backup_directory = rtrim($backup_directory, '/\\') . '/';
    // Enforce single trailing slash.
    if (!is_dir($backup_directory)) {
        if (false === @mkdir($backup_directory, 0755)) {
            pb_backupbuddy::alert('Error #4838594589: Selected backup directory does not exist and it could not be created. Verify the path is correct or manually create the directory and set proper permissions. Reset to default path.');
            $_POST['pb_backupbuddy_backup_directory'] = pb_backupbuddy::$options['backup_directory'];
            // Set back to previous value (aka unchanged).
        }
    }
    if (pb_backupbuddy::$options['backup_directory'] != $backup_directory) {
        // Directory differs. Needs updated in post var. Give messages here as this value is going to end up being saved.
        pb_backupbuddy::anti_directory_browsing($backup_directory);
        $old_backup_dir = pb_backupbuddy::$options['backup_directory'];
        $new_backup_dir = $backup_directory;
        // Move all files from old backup to new.
        $old_backups_moved = 0;
        $old_backups = glob($old_backup_dir . 'backup*.zip');
        if (!is_array($old_backups) || empty($old_backups)) {
            // On failure glob() returns false or an empty array depending on server settings so normalize here.
            $old_backups = array();
        }
        foreach ($old_backups as $old_backup) {
            if (false === rename($old_backup, $new_backup_dir . basename($old_backup))) {
                pb_backupbuddy::alert('ERROR: Unable to move backup "' . basename($old_backup) . '" to new storage directory. Manually move it or delete it for security and to prevent it from being backed up within backups.');
            } else {
                // rename success.
                $old_backups_moved++;
开发者ID:mariakhair,项目名称:bootstrap,代码行数:31,代码来源:settings.php

示例8: parse_options

    pb_backupbuddy::alert($errorMsg);
    return;
}
$restore->_state['defaultURL'] = $restore->getDefaultUrl();
$restore->_state['defaultDomain'] = $restore->getDefaultDomain();
if ('true' != pb_backupbuddy::_GET('deploy')) {
    // deployment mode pre-loads state data in a file instead of passing via post.
    $restore->_state = parse_options($restore->_state);
}
$restore->_state['skipUnzip'] = $skipUnzip;
// Set up state variables.
if ('db' == $restore->_state['dat']['backup_type'] || false == $restore->_state['restoreFiles']) {
    pb_backupbuddy::status('details', 'Database backup OR not restoring files.');
    $restore->_state['tempPath'] = ABSPATH . 'importbuddy/temp_' . pb_backupbuddy::random_string(12) . '/';
    $restore->_state['restoreFileRoot'] = $restore->_state['tempPath'];
    pb_backupbuddy::anti_directory_browsing($restore->_state['restoreFileRoot'], $die = false);
} else {
    pb_backupbuddy::status('details', 'Restoring files.');
    $restore->_state['restoreFileRoot'] = ABSPATH;
    // Restore files into current root.
}
// Parse submitted options for saving to state.
function parse_options($restoreData)
{
    if ('1' == pb_backupbuddy::_POST('restoreFiles')) {
        $restoreData['restoreFiles'] = true;
    } else {
        $restoreData['restoreFiles'] = false;
    }
    if ('1' == pb_backupbuddy::_POST('restoreDatabase')) {
        $restoreData['restoreDatabase'] = true;
开发者ID:Offirmo,项目名称:base-wordpress,代码行数:31,代码来源:2.php

示例9: periodic_cleanup

 function periodic_cleanup($backup_age_limit = 43200, $die_on_fail = true)
 {
     $max_importbuddy_age = 60 * 60 * 1;
     // 1hr - Max age, in seconds, importbuddy files can be there before cleaning up (delay useful if just imported and testing out site).
     pb_backupbuddy::status('message', 'Starting cleanup procedure for BackupBuddy v' . pb_backupbuddy::settings('version') . '.');
     if (!isset(pb_backupbuddy::$options)) {
         $this->load();
     }
     // TODO: Check for orphaned .gz files in root from PCLZip.
     // Cleanup backup itegrity portion of array.
     // (status logging info inside function)
     $this->trim_backups_integrity_stats();
     // Cleanup logs in pb_backupbuddy dirctory.
     pb_backupbuddy::status('details', 'Cleaning up old logs.');
     $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.
     pb_backupbuddy::status('details', 'Cleaning up 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.
     pb_backupbuddy::status('details', 'Cleaning up any temporary local destinations.');
     foreach (pb_backupbuddy::$options['remote_destinations'] as $destination_id => $destination) {
         if ($destination['type'] == 'local' && (isset($destination['temporary']) && $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.
     pb_backupbuddy::status('details', 'Cleaning up remote send stats.');
     $this->trim_remote_send_stats();
     // Check for orphaned backups in the data structure that havent been updates in 12+ hours & cleanup after them.
     pb_backupbuddy::status('details', 'Cleaning up data structure.');
     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::status('details', 'Verifying anti-directory browsing security on 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.
     pb_backupbuddy::status('details', 'Verifying anti-directory browsing security on 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) {
//.........这里部分代码省略.........
开发者ID:brettex,项目名称:pspark,代码行数:101,代码来源:core.php

示例10:

		return false;
	});
});
</script>
<?php 
// END TOUR.
// Check if performing an actual migration now. If so then load file and skip the rest of this page.
if (pb_backupbuddy::_GET('callback_data') != '' && pb_backupbuddy::_GET('callback_data') != 'importbuddy.php') {
    require_once '_migrate.php';
    return;
}
// Handle remote sending ImportBuddy.
if (pb_backupbuddy::_GET('callback_data') == 'importbuddy.php') {
    pb_backupbuddy::alert('<span id="pb_backupbuddy_ib_sent">Sending ImportBuddy file. This may take several seconds. Please wait ...</span>');
    pb_backupbuddy::flush();
    pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
    $importbuddy_file = backupbuddy_core::getTempDirectory() . 'importbuddy.php';
    // Render ImportBuddy to temp location.
    backupbuddy_core::importbuddy($importbuddy_file);
    if (file_exists($importbuddy_file)) {
        $response = backupbuddy_core::send_remote_destination($_GET['destination'], $importbuddy_file, $trigger = 'manual');
    } else {
        pb_backupbuddy::alert('Error #4589: Local importbuddy.php file not found for sending. Check directory permissions and / or manually migrating by downloading importbuddy.php.');
        $response = false;
    }
    if (file_exists($importbuddy_file)) {
        if (false === unlink($importbuddy_file)) {
            // Delete temporary ImportBuddy file.
            pb_backupbuddy::alert('Unable to delete file. For security please manually delete it: `' . $importbuddy_file . '`.');
        }
    }
开发者ID:Coop920,项目名称:Sterling-Wellness,代码行数:31,代码来源:migrate_restore.php

示例11: test

 public static function test($settings)
 {
     $settings = self::_normalizeSettings($settings);
     if (false === ($settings = self::_connect($settings))) {
         $error = 'Unable to connect with Google Drive. See log for details.';
         echo $error;
         pb_backupbuddy::status('error', $error);
         return false;
     }
     pb_backupbuddy::status('details', 'Testing Google Drive destination. Sending ImportBuddy.php.');
     pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
     $importbuddy_temp = backupbuddy_core::getTempDirectory() . 'importbuddy_' . pb_backupbuddy::random_string(10) . '.php.tmp';
     // Full path & filename to temporary importbuddy
     backupbuddy_core::importbuddy($importbuddy_temp);
     // Create temporary importbuddy.
     $files = array($importbuddy_temp);
     $results = self::send($settings, $files, '', $delete_remote_after = true);
     @unlink($importbuddy_temp);
     if (true === $results) {
         echo 'Success sending test file to Google Drive. ';
         return true;
     } else {
         global $pb_backupbuddy_destination_errors;
         echo 'Failure sending test file to Google Drive. Details: `' . implode(', ', $pb_backupbuddy_destination_errors) . '`.';
         return false;
     }
 }
开发者ID:jcwproductions,项目名称:jcwproductions-blog,代码行数:27,代码来源:init.php

示例12: load_backup_dat

 function load_backup_dat()
 {
     pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
     $dat_file = $this->import_options['extract_to'] . '/' . str_replace(ABSPATH, '', backupbuddy_core::getTempDirectory()) . $this->import_options['zip_id'] . '/backupbuddy_dat.php';
     $this->_backupdata = $this->get_backup_dat($dat_file);
 }
开发者ID:AgilData,项目名称:WordPress-Skeleton,代码行数:6,代码来源:multisite_import.php

示例13: pre_backup


//.........这里部分代码省略.........
         $this->_backup['steps'][] = array('function' => 'ms_copy_media', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
         $this->_backup['steps'][] = array('function' => 'ms_copy_users_table', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
     }
     if (pb_backupbuddy::$options['skip_database_dump'] != '1') {
         // Backup database if not skipping.
         global $wpdb;
         // Default tables to backup.
         if (pb_backupbuddy::$options['backup_nonwp_tables'] == '1') {
             // Backup all tables.
             $base_dump_mode = 'all';
         } else {
             // Only backup matching prefix.
             $base_dump_mode = 'prefix';
         }
         // Calculate tables to dump based on the provided information. $tables will be an array of tables.
         $tables = $this->_calculate_tables($base_dump_mode, $this->_backup['additional_table_includes'], $this->_backup['additional_table_excludes']);
         // Tables we will try to break out into standalone steps if possible.
         $breakout_tables_defaults = array($wpdb->prefix . 'posts', $wpdb->prefix . 'postmeta');
         // Step through tables we want to break out and figure out which ones were indeed set to be backed up and break them out.
         $breakout_tables_calculated = array();
         // Calculated next.
         if (pb_backupbuddy::$options['breakout_tables'] == '0') {
             // Breaking out DISABLED.
             pb_backupbuddy::status('details', 'Breaking out tables DISABLED based on settings.');
         } else {
             // Breaking out ENABLED.
             pb_backupbuddy::status('details', 'Breaking out tables ENABLED based on settings. Tables to be broken out into individual steps: `' . implode(', ', $breakout_tables_defaults) . '`.');
             foreach ((array) $breakout_tables_defaults as $breakout_tables_default) {
                 if (in_array($breakout_tables_default, $tables)) {
                     $breakout_tables_calculated[] = $breakout_tables_default;
                     $tables = array_diff($tables, array($breakout_tables_default));
                     // Remove from main table backup list.
                 }
             }
         }
         unset($breakout_tables_defaults);
         // No longer needed.
         $this->_backup['steps'][] = array('function' => 'backup_create_database_dump', 'args' => array($tables), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
         // Set up backup steps for additional broken out tables.
         foreach ($breakout_tables_calculated as $breakout_table) {
             $this->_backup['steps'][] = array('function' => 'backup_create_database_dump', 'args' => array(array($breakout_table)), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
         }
     } else {
         pb_backupbuddy::status('message', __('Skipping database dump based on advanced options.', 'it-l10n-backupbuddy'));
     }
     $this->_backup['steps'][] = array('function' => 'backup_zip_files', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
     if ($type == 'export') {
         $this->_backup['steps'][] = array('function' => 'ms_cleanup', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
     }
     $this->_backup['steps'][] = array('function' => 'post_backup', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
     // Prepend and append pre backup and post backup steps.
     $this->_backup['steps'] = array_merge($pre_backup, $this->_backup['steps'], $post_backup);
     /********* End setting up steps array. *********/
     /********* Begin directory creation and security. *********/
     pb_backupbuddy::anti_directory_browsing($this->_backup['backup_directory']);
     // Prepare temporary directory for holding SQL and data file.
     if (!file_exists($this->_backup['temp_directory'])) {
         if (pb_backupbuddy::$filesystem->mkdir($this->_backup['temp_directory']) === false) {
             pb_backupbuddy::status('error', 'Error #9002. Unable to create temporary storage directory (' . $this->_backup['temp_directory'] . ')');
             return false;
         }
     }
     if (!is_writable($this->_backup['temp_directory'])) {
         pb_backupbuddy::status('error', 'Error #9015. Temp data directory is not writable. Check your permissions. (' . $this->_backup['temp_directory'] . ')');
         return false;
     }
     pb_backupbuddy::anti_directory_browsing(ABSPATH . 'wp-content/uploads/backupbuddy_temp/');
     // Prepare temporary directory for holding ZIP file while it is being generated.
     $this->_backup['temporary_zip_directory'] = pb_backupbuddy::$options['backup_directory'] . 'temp_zip_' . $this->_backup['serial'] . '/';
     if (!file_exists($this->_backup['temporary_zip_directory'])) {
         if (pb_backupbuddy::$filesystem->mkdir($this->_backup['temporary_zip_directory']) === false) {
             pb_backupbuddy::status('details', 'Error #9002. Unable to create temporary ZIP storage directory (' . $this->_backup['temporary_zip_directory'] . ')');
             return false;
         }
     }
     if (!is_writable($this->_backup['temporary_zip_directory'])) {
         pb_backupbuddy::status('error', 'Error #9015. Temp data directory is not writable. Check your permissions. (' . $this->_backup['temporary_zip_directory'] . ')');
         return false;
     }
     /********* End directory creation and security *********/
     //$this->echo();
     // Schedule cleanup of temporary files and such for XX hours in the future just in case everything goes wrong we dont leave junk too long.
     wp_schedule_single_event(time() + 48 * 60 * 60, pb_backupbuddy::cron_tag('final_cleanup'), array($serial));
     // Generate backup DAT (data) file containing details about the backup.
     if ($this->backup_create_dat_file($trigger) !== true) {
         pb_backupbuddy::status('details', __('Problem creating DAT file.', 'it-l10n-backupbuddy'));
         return false;
     }
     // Generating ImportBuddy file to include in the backup for FULL BACKUPS ONLY currently. Cannot put in DB because it would be in root and be excluded or conflict on extraction.
     if ($type == 'full') {
         pb_backupbuddy::status('details', 'Generating ImportBuddy tool to include in backup archive: `' . $this->_backup['temp_directory'] . 'importbuddy.php`.');
         pb_backupbuddy::$classes['core']->importbuddy($this->_backup['temp_directory'] . 'importbuddy.php');
         pb_backupbuddy::status('details', 'ImportBuddy generation complete.');
     }
     // Save all of this.
     pb_backupbuddy::save();
     pb_backupbuddy::status('details', __('Finished pre-backup procedures.', 'it-l10n-backupbuddy'));
     pb_backupbuddy::status('action', 'finish_settings');
     return true;
 }
开发者ID:CherylMuniz,项目名称:fashion,代码行数:101,代码来源:backup.php

示例14: check_high_security_mode

 public static function check_high_security_mode($die_on_fail = false)
 {
     // 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(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.');
         }
     }
 }
开发者ID:arobbins,项目名称:spellestate,代码行数:24,代码来源:housekeeping.php

示例15: verify_directories

 public function verify_directories()
 {
     $success = true;
     // Keep backup directory up to date.
     if (pb_backupbuddy::$options['backup_directory'] == '' || !@is_writable(pb_backupbuddy::$options['backup_directory'])) {
         $default_backup_dir = ABSPATH . 'wp-content/uploads/backupbuddy_backups/';
         pb_backupbuddy::status('details', 'Backup directory invalid. Updating from `' . pb_backupbuddy::$options['backup_directory'] . '` to the default `' . $default_backup_dir . '`.');
         pb_backupbuddy::$options['backup_directory'] = $default_backup_dir;
         pb_backupbuddy::save();
     }
     $response = pb_backupbuddy::anti_directory_browsing(pb_backupbuddy::$options['backup_directory'], $die = false);
     if (false === $response) {
         $success = false;
     }
     // Keep log directory up to date.
     if (pb_backupbuddy::$options['log_directory'] == '' || !@is_writable(pb_backupbuddy::$options['log_directory'])) {
         $default_log_dir = ABSPATH . 'wp-content/uploads/pb_backupbuddy/';
         pb_backupbuddy::status('details', 'Log directory invalid. Updating from `' . pb_backupbuddy::$options['log_directory'] . '` to the default `' . $default_log_dir . '`.');
         pb_backupbuddy::$options['log_directory'] = $default_log_dir;
         pb_backupbuddy::save();
     }
     pb_backupbuddy::anti_directory_browsing(pb_backupbuddy::$options['log_directory'], $die = false);
     if (false === $response) {
         $success = false;
     }
     // 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();
     }
     pb_backupbuddy::anti_directory_browsing(pb_backupbuddy::$options['temp_directory'], $die = false);
     if (false === $response) {
         $success = false;
     }
     global $pb_backupbuddy_directory_verification;
     $pb_backupbuddy_directory_verification = $success;
     return $success;
 }
开发者ID:mariakhair,项目名称:bootstrap,代码行数:39,代码来源:core.php


注:本文中的pb_backupbuddy::anti_directory_browsing方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。