| [ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Database Repair and Optimization Script. 4 * 5 * @package WordPress 6 * @subpackage Database 7 */ 8 define('WP_REPAIRING', true); 9 10 require_once ('../../wp-load.php'); 11 12 header( 'Content-Type: text/html; charset=utf-8' ); 13 ?> 14 <!DOCTYPE html> 15 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> 16 <head> 17 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 18 <title><?php _e( 'WordPress › Database Repair' ); ?></title> 19 <?php wp_admin_css( 'install', true ); ?> 20 </head> 21 <body> 22 <h1 id="logo"><img alt="WordPress" src="../images/wordpress-logo.png?ver=20120216" /></h1> 23 24 <?php 25 26 if ( ! defined( 'WP_ALLOW_REPAIR' ) ) { 27 echo '<p>' . __( 'To allow use of this page to automatically repair database problems, please add the following line to your <code>wp-config.php</code> file. Once this line is added to your config, reload this page.' ) . "</p><code>define('WP_ALLOW_REPAIR', true);</code>"; 28 } elseif ( isset( $_GET['repair'] ) ) { 29 check_admin_referer( 'repair_db' ); 30 31 $optimize = 2 == $_GET['repair']; 32 $okay = true; 33 $problems = array(); 34 35 $tables = $wpdb->tables(); 36 37 // Sitecategories may not exist if global terms are disabled. 38 if ( is_multisite() && ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->sitecategories'" ) ) 39 unset( $tables['sitecategories'] ); 40 41 $tables = array_merge( $tables, (array) apply_filters( 'tables_to_repair', array() ) ); // Return tables with table prefixes. 42 43 // Loop over the tables, checking and repairing as needed. 44 foreach ( $tables as $table ) { 45 $check = $wpdb->get_row( "CHECK TABLE $table" ); 46 47 echo '<p>'; 48 if ( 'OK' == $check->Msg_text ) { 49 /* translators: %s: table name */ 50 printf( __( 'The %s table is okay.' ), "<code>$table</code>" ); 51 } else { 52 /* translators: 1: table name, 2: error message, */ 53 printf( __( 'The %1$s table is not okay. It is reporting the following error: %2$s. WordPress will attempt to repair this table…' ) , "<code>$table</code>", "<code>$check->Msg_text</code>" ); 54 55 $repair = $wpdb->get_row( "REPAIR TABLE $table" ); 56 57 echo '<br /> '; 58 if ( 'OK' == $check->Msg_text ) { 59 /* translators: %s: table name */ 60 printf( __( 'Successfully repaired the %s table.' ), "<code>$table</code>" ); 61 } else { 62 /* translators: 1: table name, 2: error message, */ 63 echo sprintf( __( 'Failed to repair the %1$s table. Error: %2$s' ), "<code>$table</code>", "<code>$check->Msg_text</code>" ) . '<br />'; 64 $problems[$table] = $check->Msg_text; 65 $okay = false; 66 } 67 } 68 69 if ( $okay && $optimize ) { 70 $check = $wpdb->get_row( "ANALYZE TABLE $table" ); 71 72 echo '<br /> '; 73 if ( 'Table is already up to date' == $check->Msg_text ) { 74 /* translators: %s: table name */ 75 printf( __( 'The %s table is already optimized.' ), "<code>$table</code>" ); 76 } else { 77 $check = $wpdb->get_row( "OPTIMIZE TABLE $table" ); 78 79 echo '<br /> '; 80 if ( 'OK' == $check->Msg_text || 'Table is already up to date' == $check->Msg_text ) { 81 /* translators: %s: table name */ 82 printf( __( 'Successfully optimized the %s table.' ), "<code>$table</code>" ); 83 } else { 84 /* translators: 1: table name, 2: error message, */ 85 printf( __( 'Failed to optimize the %1$s table. Error: %2$s' ), "<code>$table</code>", "<code>$check->Msg_text</code>" ); 86 } 87 } 88 } 89 echo '</p>'; 90 } 91 92 if ( $problems ) { 93 printf( '<p>' . __('Some database problems could not be repaired. Please copy-and-paste the following list of errors to the <a href="%s">WordPress support forums</a> to get additional assistance.') . '</p>', __( 'http://wordpress.org/support/forum/how-to-and-troubleshooting' ) ); 94 $problem_output = ''; 95 foreach ( $problems as $table => $problem ) 96 $problem_output .= "$table: $problem\n"; 97 echo '<p><textarea name="errors" id="errors" rows="20" cols="60">' . esc_textarea( $problem_output ) . '</textarea></p>'; 98 } else { 99 echo '<p>' . __( 'Repairs complete. Please remove the following line from wp-config.php to prevent this page from being used by unauthorized users.' ) . "</p><code>define('WP_ALLOW_REPAIR', true);</code>"; 100 } 101 } else { 102 if ( isset( $_GET['referrer'] ) && 'is_blog_installed' == $_GET['referrer'] ) 103 echo '<p>' . __( 'One or more database tables are unavailable. To allow WordPress to attempt to repair these tables, press the “Repair Database” button. Repairing can take a while, so please be patient.' ) . '</p>'; 104 else 105 echo '<p>' . __( 'WordPress can automatically look for some common database problems and repair them. Repairing can take a while, so please be patient.' ) . '</p>'; 106 ?> 107 <p class="step"><a class="button" href="<?php echo wp_nonce_url( 'repair.php?repair=1', 'repair_db' ); ?>"><?php _e( 'Repair Database' ); ?></a></p> 108 <p><?php _e( 'WordPress can also attempt to optimize the database. This improves performance in some situations. Repairing and optimizing the database can take a long time and the database will be locked while optimizing.' ); ?></p> 109 <p class="step"><a class="button" href="<?php echo wp_nonce_url( 'repair.php?repair=2', 'repair_db' ); ?>"><?php _e( 'Repair and Optimize Database' ); ?></a></p> 110 <?php 111 } 112 ?> 113 </body> 114 </html>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri May 25 03:56:23 2012 | Hosted by follow the white rabbit. |