chakalos /wp-content/plugins/backupbuddy/controllers/pages/server_info/database.php

Language PHP Lines 169
MD5 Hash 563c06df9d1f6b8797072e08b8f2e9be Estimated Cost $2,611 (why?)
Repository https://bitbucket.org/betaimages/chakalos.git View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<br><?php
if ( !isset( $parent_class ) ) {
	$parent_class = $this;
}
if ( defined( 'pluginbuddy_importbuddy' ) ) {
	//$parent_class->admin_scripts();
}












//$table_list = array();
?>

<table class="widefat">
	<thead>
		<tr class="thead">
			<?php
				echo '<th>', __('Database Table', 'it-l10n-backupbuddy' ),'</th>',
					 '<th>', __('Status', 'it-l10n-backupbuddy' ), '</th>',
					 '<th>', __('Settings', 'it-l10n-backupbuddy' ), '</th>',
					 '<th>', __('Updated / Checked', 'it-l10n-backupbuddy' ),'</th>',
					 '<th>', __('Rows', 'it-l10n-backupbuddy' ), '</th>',
					 '<th>', __('Size', 'it-l10n-backupbuddy' ), '</th>',
					 '<th>', __('Excluded Size', 'it-l10n-backupbuddy' ), '</th>';
			?>
		</tr>
	</thead>
	<tfoot>
		<tr class="thead">
			<?php
				echo '<th>', __('Database Table', 'it-l10n-backupbuddy' ),'</th>',
					 '<th>', __('Status', 'it-l10n-backupbuddy' ), '</th>',
					 '<th>', __('Settings', 'it-l10n-backupbuddy' ), '</th>',
					 '<th>', __('Updated / Checked', 'it-l10n-backupbuddy' ),'</th>',
					 '<th>', __('Rows', 'it-l10n-backupbuddy' ), '</th>',
					 '<th>', __('Size', 'it-l10n-backupbuddy' ), '</th>',
					 '<th>', __('Excluded Size', 'it-l10n-backupbuddy' ), '</th>';
			?>
		</tr>
	</tfoot>
	<tbody>
		<?php
		global $wpdb;
		$prefix = $wpdb->prefix;
		$prefix_length = strlen( $wpdb->prefix );
		
		$additional_includes = explode( "\n", pb_backupbuddy::$options['mysqldump_additional_includes'] );
		array_walk( $additional_includes, create_function('&$val', '$val = trim($val);')); 
		$additional_excludes = explode( "\n", pb_backupbuddy::$options['mysqldump_additional_excludes'] );
		array_walk( $additional_excludes, create_function('&$val', '$val = trim($val);')); 

		
		$total_size = 0;
		$total_size_with_exclusions = 0;
		$total_rows = 0;
		$result = mysql_query("SHOW TABLE STATUS");
		while( $rs = mysql_fetch_array( $result ) ) {
			$excluded = true; // Default.
			
			// TABLE STATUS.
			$resultb = mysql_query("CHECK TABLE `{$rs['Name']}`");
			while( $rsb = mysql_fetch_array( $resultb ) ) {
				if ( $rsb['Msg_type'] == 'status' ) {
					$status = $rsb['Msg_text'];
				}
			}
			mysql_free_result( $resultb );
			
			// TABLE SIZE.
			$size = ( $rs['Data_length'] + $rs['Index_length'] );
			$total_size += $size;
			
			
			// HANDLE EXCLUSIONS.
			if ( pb_backupbuddy::$options['backup_nonwp_tables'] == 0 ) { // Only matching prefix.
				if ( ( substr( $rs['Name'], 0, $prefix_length ) == $prefix ) OR ( in_array( $rs['Name'], $additional_includes ) ) ) {
					if ( !in_array( $rs['Name'], $additional_excludes ) ) {
						$total_size_with_exclusions += $size;
						$excluded = false;
					}
				}
			} else { // All tables.
				if ( !in_array( $rs['Name'], $additional_excludes ) ) {
					$total_size_with_exclusions += $size;
					$excluded = false;
				}
			}
			
			
			
			
			
			// OUTPUT TABLE ROW.
			echo '<tr class="entry-row alternate"';
			if ( $excluded === true ) {
				echo ' style="background: #F9B6B6;"';
			}
			echo '>';
			echo '	<td>' . $rs['Name'];
			echo '	<div class="row-actions">
						<a href="' . pb_backupbuddy::ajax_url( 'db_check' ) . '&table=' . base64_encode( $rs['Name'] ) . '&#038;TB_iframe=1&#038;width=640&#038;height=600" class="thickbox" title="Check database table for any errors or corruption.">Check</a>
						|
						<a href="' . pb_backupbuddy::ajax_url( 'db_repair' ) . '&table=' . base64_encode( $rs['Name'] ) . '&#038;TB_iframe=1&#038;width=640&#038;height=600" class="thickbox" title="Repair table that has been corrupted. Only needed if the status or check response indicated damage.">Repair</a>
					</div>
				';
			echo '</td>';
			echo '	<td>' . $status . '</td>';
			echo '	<td>Engine: ' . $rs['Engine'] . '<br>Collation: ' . $rs['Collation'] . '</td>';
			
			echo '	<td>Updated: ';
			if ( $rs['Update_time'] == '' ) {
				_e( 'Unavailable', 'it-l10n-backupbuddy' );
			} else {
				echo $rs['Update_time'];
			}
			echo '<br>Checked: ';
			if ( $rs['Check_time'] == '' ) {
				_e( 'Unavailable', 'it-l10n-backupbuddy' );
			} else {
				echo $rs['Check_time'];
			}
			echo '</td>';
			
			echo '	<td>' . $rs['Rows'] . '</td>';
			echo '	<td>' . pb_backupbuddy::$format->file_size( $size ) . '</td>';
			if ( $excluded === true ) {
				echo '	<td><i>Excluded</i></td>';
			} else {
				echo '	<td>' . pb_backupbuddy::$format->file_size( $size ) . '</td>';
			}
			
			
			
						
			
			
			$total_rows += $rs['Rows'];
			echo '</tr>';
		}
		echo '<tr class="entry-row alternate">';
		echo '	<td>&nbsp;</td>';
		echo '	<td>&nbsp;</td>';
		echo '	<td>&nbsp;</td>';
		echo '<td><b>',__('TOTALS','it-l10n-backupbuddy' ),':</b></td>';
		echo '<td><b>' . $total_rows . '</b></td>';
		echo '<td><b>' . pb_backupbuddy::$format->file_size( $total_size ) . '</b></td>';
		echo '<td><b>' . pb_backupbuddy::$format->file_size( $total_size_with_exclusions ) . '</b></td>';
		echo '</tr>';
		
		pb_backupbuddy::$options['stats']['db_size'] = $total_size;
		pb_backupbuddy::$options['stats']['db_size_excluded'] = $total_size_with_exclusions;
		pb_backupbuddy::$options['stats']['db_size_updated'] = time();
		pb_backupbuddy::save();
		
		unset( $total_size );
		unset( $total_rows );
		mysql_free_result( $result );
		?>
	</tbody>
</table><br>
Back to Top