예제 #1
0
파일: core.php 프로젝트: verbazend/AWFA
 public function get_site_size()
 {
     $exclusions = pb_backupbuddy_core::get_directory_exclusions();
     $dir_array = array();
     $result = pb_backupbuddy::$filesystem->dir_size_map(ABSPATH, ABSPATH, $exclusions, $dir_array);
     unset($dir_array);
     // Free this large chunk of memory.
     $total_size = pb_backupbuddy::$options['stats']['site_size'] = $result[0];
     $total_size_excluded = pb_backupbuddy::$options['stats']['site_size_excluded'] = $result[1];
     pb_backupbuddy::$options['stats']['site_size_updated'] = time();
     pb_backupbuddy::save();
     return array($total_size, $total_size_excluded);
 }
예제 #2
0
파일: ajax.php 프로젝트: brettex/pspark
    public function site_size_listing()
    {
        $exclusions = pb_backupbuddy_core::get_directory_exclusions();
        $result = pb_backupbuddy::$filesystem->dir_size_map(ABSPATH, ABSPATH, $exclusions, $dir_array);
        $total_size = pb_backupbuddy::$options['stats']['site_size'] = $result[0];
        $total_size_excluded = pb_backupbuddy::$options['stats']['site_size_excluded'] = $result[1];
        pb_backupbuddy::$options['stats']['site_size_updated'] = time();
        pb_backupbuddy::save();
        arsort($dir_array);
        ?>
		<table class="widefat">
			<thead>
				<tr class="thead">
					<?php 
        echo '<th>', __('Directory', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Size with Children', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Size with Exclusions', 'it-l10n-backupbuddy'), '</th>';
        ?>
				</tr>
			</thead>
			<tfoot>
				<tr class="thead">
					<?php 
        echo '<th>', __('Directory', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Size with Children', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Size with Exclusions', 'it-l10n-backupbuddy'), '</th>';
        ?>
				</tr>
			</tfoot>
			<tbody>
		<?php 
        echo '<tr><td align="right"><b>' . __('TOTALS', 'it-l10n-backupbuddy') . ':</b></td><td><b>' . pb_backupbuddy::$format->file_size($total_size) . '</b></td><td><b>' . pb_backupbuddy::$format->file_size($total_size_excluded) . '</b></td></tr>';
        $item_count = 0;
        foreach ($dir_array as $id => $item) {
            // Each $item is in format array( TOTAL_SIZE, TOTAL_SIZE_TAKING_EXCLUSIONS_INTO_ACCOUNT );
            $item_count++;
            if ($item_count > 100) {
                flush();
                $item_count = 0;
            }
            if ($item[1] === false) {
                $excluded_size = '<i>Excluded</i>';
                echo '<tr style="background: #F9B6B6;">';
            } else {
                $excluded_size = pb_backupbuddy::$format->file_size($item[1]);
                echo '<tr>';
            }
            echo '<td>' . $id . '</td><td>' . pb_backupbuddy::$format->file_size($item[0]) . '</td><td>' . $excluded_size . '</td></tr>';
        }
        echo '<tr><td align="right"><b>' . __('TOTALS', 'it-l10n-backupbuddy') . ':</b></td><td><b>' . pb_backupbuddy::$format->file_size($total_size) . '</b></td><td><b>' . pb_backupbuddy::$format->file_size($total_size_excluded) . '</b></td></tr>';
        echo '</tbody>';
        echo '</table>';
        echo '<br>';
        echo 'Exclusions';
        pb_backupbuddy::tip('List of directories that will be excluded in an actual backup. This includes user-defined directories and BackupBuddy directories such as the archive directory and temporary directories.');
        echo '<div id="pb_backupbuddy_serverinfo_exclusions" style="background-color: #EEEEEE; padding: 4px; float: right; white-space: nowrap; height: 90px; width: 70%; min-width: 400px; overflow: auto;"><i>' . implode("<br>", $exclusions) . '</i></div>';
        echo '<br style="clear: both;">';
        die;
    }
예제 #3
0
    public function site_size_listing()
    {
        $profile_id = 0;
        if (is_numeric(pb_backupbuddy::_GET('profile'))) {
            if (isset(pb_backupbuddy::$options['profiles'][pb_backupbuddy::_GET('profile')])) {
                $profile_id = pb_backupbuddy::_GET('profile');
                pb_backupbuddy::$options['profiles'][pb_backupbuddy::_GET('profile')] = array_merge(pb_backupbuddy::settings('profile_defaults'), pb_backupbuddy::$options['profiles'][pb_backupbuddy::_GET('profile')]);
                // Set defaults if not set.
            } else {
                pb_backupbuddy::alert('Error #45849458b: Invalid profile ID number `' . htmlentities(pb_backupbuddy::_GET('profile')) . '`. Displaying with default profile.', true);
            }
        }
        echo '<!-- profile: ' . $profile_id . ' -->';
        $exclusions = pb_backupbuddy_core::get_directory_exclusions(pb_backupbuddy::$options['profiles'][$profile_id]);
        $result = pb_backupbuddy::$filesystem->dir_size_map(ABSPATH, ABSPATH, $exclusions, $dir_array);
        if (0 == $result) {
            pb_backupbuddy::alert('Error #5656653. Unable to access directory map listing for directory `' . ABSPATH . '`.');
            die;
        }
        $total_size = pb_backupbuddy::$options['stats']['site_size'] = $result[0];
        $total_size_excluded = pb_backupbuddy::$options['stats']['site_size_excluded'] = $result[1];
        pb_backupbuddy::$options['stats']['site_size_updated'] = time();
        pb_backupbuddy::save();
        arsort($dir_array);
        if (pb_backupbuddy::_GET('text') == 'true') {
            pb_backupbuddy::$ui->ajax_header();
            echo '<h3>' . __('Site Size Listing & Exclusions', 'it-l10n-backupbuddy') . '</h3>';
            echo '<textarea style="width:100%; height: 300px; font-family: monospace;" wrap="off">';
            echo __('Size + Children', 'it-l10n-backupbuddy') . "\t";
            echo __('- Exclusions', 'it-l10n-backupbuddy') . "\t";
            echo __('Directory', 'it-l10n-backupbuddy') . "\n";
        } else {
            ?>
			<table class="widefat">
				<thead>
					<tr class="thead">
						<?php 
            echo '<th>', __('Directory', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Size with Children', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Size with Exclusions', 'it-l10n-backupbuddy'), '<br><span class="description">Global defaults profile</span></th>';
            ?>
					</tr>
				</thead>
				<tfoot>
					<tr class="thead">
						<?php 
            echo '<th>', __('Directory', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Size with Children', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Size with Exclusions', 'it-l10n-backupbuddy'), '<br><span class="description">Global defaults profile</span></th>';
            ?>
					</tr>
				</tfoot>
				<tbody>
			<?php 
        }
        if (pb_backupbuddy::_GET('text') == 'true') {
            echo str_pad(pb_backupbuddy::$format->file_size($total_size), 10, ' ', STR_PAD_RIGHT) . "\t" . str_pad(pb_backupbuddy::$format->file_size($total_size_excluded), 10, ' ', STR_PAD_RIGHT) . "\t" . __('TOTALS', 'it-l10n-backupbuddy') . "\n";
        } else {
            echo '<tr><td align="right"><b>' . __('TOTALS', 'it-l10n-backupbuddy') . ':</b></td><td><b>' . pb_backupbuddy::$format->file_size($total_size) . '</b></td><td><b>' . pb_backupbuddy::$format->file_size($total_size_excluded) . '</b></td></tr>';
        }
        $item_count = 0;
        foreach ($dir_array as $id => $item) {
            // Each $item is in format array( TOTAL_SIZE, TOTAL_SIZE_TAKING_EXCLUSIONS_INTO_ACCOUNT );
            $item_count++;
            if ($item_count > 100) {
                flush();
                $item_count = 0;
            }
            if ($item[1] === false) {
                if (pb_backupbuddy::_GET('text') == 'true') {
                    $excluded_size = 'EXCLUDED';
                    echo '**';
                } else {
                    $excluded_size = '<span class="pb_label pb_label-important">Excluded</span>';
                    echo '<tr style="background: #fcc9c9;">';
                }
            } else {
                $excluded_size = pb_backupbuddy::$format->file_size($item[1]);
                if (pb_backupbuddy::_GET('text') != 'true') {
                    echo '<tr>';
                }
            }
            if (pb_backupbuddy::_GET('text') == 'true') {
                echo str_pad(pb_backupbuddy::$format->file_size($item[0]), 10, ' ', STR_PAD_RIGHT) . "\t" . str_pad($excluded_size, 10, ' ', STR_PAD_RIGHT) . "\t" . $id . "\n";
            } else {
                echo '<td>' . $id . '</td><td>' . pb_backupbuddy::$format->file_size($item[0]) . '</td><td>' . $excluded_size . '</td></tr>';
            }
        }
        if (pb_backupbuddy::_GET('text') == 'true') {
            echo str_pad(pb_backupbuddy::$format->file_size($total_size), 10, ' ', STR_PAD_RIGHT) . "\t" . str_pad(pb_backupbuddy::$format->file_size($total_size_excluded), 10, ' ', STR_PAD_RIGHT) . "\t" . __('TOTALS', 'it-l10n-backupbuddy') . "\n";
        } else {
            echo '<tr><td align="right"><b>' . __('TOTALS', 'it-l10n-backupbuddy') . ':</b></td><td><b>' . pb_backupbuddy::$format->file_size($total_size) . '</b></td><td><b>' . pb_backupbuddy::$format->file_size($total_size_excluded) . '</b></td></tr>';
        }
        if (pb_backupbuddy::_GET('text') == 'true') {
            echo "\n\nEXCLUSIONS (" . count($exclusions) . "):" . "\n" . implode("\n", $exclusions);
            echo '</textarea>';
            pb_backupbuddy::$ui->ajax_footer();
        } else {
            echo '</tbody>';
            echo '</table>';
            echo '<br>';
            echo 'Exclusions (' . count($exclusions) . ')';
            pb_backupbuddy::tip('List of directories that will be excluded in an actual backup. This includes user-defined directories and BackupBuddy directories such as the archive directory and temporary directories.');
            echo '<div id="pb_backupbuddy_serverinfo_exclusions" style="background-color: #EEEEEE; padding: 4px; float: right; white-space: nowrap; height: 90px; width: 70%; min-width: 400px; overflow: auto;"><i>' . implode("<br>", $exclusions) . '</i></div>';
            echo '<br style="clear: both;">';
            echo '<br><center>';
            echo '<a href="' . pb_backupbuddy::ajax_url('site_size_listing') . '&text=true&#038;TB_iframe=1&#038;width=640&#038;height=600" class="thickbox button secondary-button">' . __('Display Results in Text Format', 'it-l10n-backupbuddy') . '</a>';
            echo '</center>';
        }
        die;
    }
예제 #4
0


<?php 
$dir_array = array();
$icicle_array = array();
$time_start = microtime(true);
//echo '<pre>' . $this->build_icicle( ABSPATH, ABSPATH, '' ) . '</pre>';
echo '<br>';
echo '<div class="pb_htitle">' . __('Directory Size Listing', 'it-l10n-backupbuddy') . '</div><br>';
echo '<a name="pb_backupbuddy_dir_size_listing">&nbsp;</a>';
if (empty($_GET['site_size'])) {
    echo __('This option displays a comprehensive listing of directories and the corresponding size of all contents within, including subdirectories.  This is useful for finding where space is being used. Note that this is a CPU intensive process and may take a while to load and even time out on some servers.', 'it-l10n-backupbuddy');
    echo '<br /><br /><a href="' . pb_backupbuddy::page_url() . '&site_size=true#pb_backupbuddy_dir_size_listing" class="button secondary-button" style="margin-top: 3px;">', __('Display Directory Size Listing', 'it-l10n-backupbuddy'), '</a>';
} else {
    $exclusions = pb_backupbuddy_core::get_directory_exclusions();
    $result = pb_backupbuddy::$filesystem->dir_size_map(ABSPATH, ABSPATH, $exclusions, $dir_array);
    $total_size = pb_backupbuddy::$options['stats']['site_size'] = $result[0];
    $total_size_excluded = pb_backupbuddy::$options['stats']['site_size_excluded'] = $result[1];
    pb_backupbuddy::$options['stats']['site_size_updated'] = time();
    pb_backupbuddy::save();
    arsort($dir_array);
    ?>
	<table class="widefat">
		<thead>
			<tr class="thead">
				<?php 
    echo '<th>', __('Directory', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Size with Children', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Size with Exclusions', 'it-l10n-backupbuddy'), '</th>';
    ?>
			</tr>
		</thead>
예제 #5
0
파일: backup.php 프로젝트: verbazend/AWFA
 function backup_zip_files()
 {
     pb_backupbuddy::status('action', 'start_files');
     if (!isset(pb_backupbuddy::$classes['core'])) {
         require_once pb_backupbuddy::plugin_path() . '/classes/core.php';
         pb_backupbuddy::$classes['core'] = new pb_backupbuddy_core();
     }
     // Calculate user-defined directory exclusions AND additional internal BB exclusions such as backup archive directory and temp directory.
     $exclusions = pb_backupbuddy_core::get_directory_exclusions();
     // Use compression?
     if (pb_backupbuddy::$options['compression'] == '1') {
         $compression = true;
     } else {
         $compression = false;
     }
     pb_backupbuddy::status('details', 'Backup root: `' . $this->_backup['backup_root'] . '`.');
     // Additional logging?
     if (pb_backupbuddy::$options['log_level'] == 3) {
         // Also shows debugging consolse.
         $quiet_response = false;
     } else {
         $quiet_response = true;
     }
     // MAKE THE ZIP!
     if (pb_backupbuddy::$classes['zipbuddy']->add_directory_to_zip($this->_backup['archive_file'], $this->_backup['backup_root'], $compression, $exclusions, $this->_backup['temporary_zip_directory'], $this->_backup['force_compatibility'], $quiet_response) === true) {
         pb_backupbuddy::status('message', __('Backup ZIP file successfully created.', 'it-l10n-backupbuddy'));
         if (chmod($this->_backup['archive_file'], 0644)) {
             pb_backupbuddy::status('details', __('Chmod of ZIP file to 0644 succeeded.', 'it-l10n-backupbuddy'));
         } else {
             pb_backupbuddy::status('details', __('Chmod of ZIP file to 0644 failed.', 'it-l10n-backupbuddy'));
         }
     } else {
         pb_backupbuddy::status('error', __('Backup FAILED. Unable to successfully generate ZIP archive. Error #3382.', 'it-l10n-backupbuddy'));
         pb_backupbuddy::status('error', __('Error #3382 help: http://ithemes.com/codex/page/BackupBuddy:_Error_Codes#3382', 'it-l10n-backupbuddy'));
         pb_backupbuddy::status('action', 'halt_script');
         // Halt JS on page.
         return false;
     }
     // Need to make sure the database connection is active. Sometimes it goes away during long bouts doing other things -- sigh.
     // This is not essential so use include and not require (suppress any warning)
     @(include_once pb_backupbuddy::plugin_path() . '/lib/wpdbutils/wpdbutils.php');
     if (class_exists('pluginbuddy_wpdbutils')) {
         // This is the database object we want to use
         global $wpdb;
         // Get our helper object and let it use us to output status messages
         $dbhelper = new pluginbuddy_wpdbutils($wpdb);
         // If we cannot kick the database into life then signal the error and return false which will stop the backup
         // Otherwise all is ok and we can just fall through and let the function return true
         if (!$dbhelper->kick()) {
             pb_backupbuddy::status('error', __('Backup FAILED. Backup file produced but Database Server has gone away, unable to schedule next backup step', 'it-l10n-backupbuddy'));
             return false;
         }
     } else {
         // Utils not available so cannot verify database connection status - just notify
         pb_backupbuddy::status('details', __('Database Server connection status unverified.', 'it-l10n-backupbuddy'));
     }
     return true;
 }