Edit File by line
/home/barbar84/public_h.../wp-admin/maint
File: repair.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Database Repair and Optimization Script.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Database
[5] Fix | Delete
*/
[6] Fix | Delete
define( 'WP_REPAIRING', true );
[7] Fix | Delete
[8] Fix | Delete
require_once dirname( dirname( __DIR__ ) ) . '/wp-load.php';
[9] Fix | Delete
[10] Fix | Delete
header( 'Content-Type: text/html; charset=utf-8' );
[11] Fix | Delete
?>
[12] Fix | Delete
<!DOCTYPE html>
[13] Fix | Delete
<html <?php language_attributes(); ?>>
[14] Fix | Delete
<head>
[15] Fix | Delete
<meta name="viewport" content="width=device-width" />
[16] Fix | Delete
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
[17] Fix | Delete
<meta name="robots" content="noindex,nofollow" />
[18] Fix | Delete
<title><?php _e( 'WordPress &rsaquo; Database Repair' ); ?></title>
[19] Fix | Delete
<?php wp_admin_css( 'install', true ); ?>
[20] Fix | Delete
</head>
[21] Fix | Delete
<body class="wp-core-ui">
[22] Fix | Delete
<p id="logo"><a href="<?php echo esc_url( __( 'https://wordpress.org/' ) ); ?>"><?php _e( 'WordPress' ); ?></a></p>
[23] Fix | Delete
[24] Fix | Delete
<?php
[25] Fix | Delete
[26] Fix | Delete
if ( ! defined( 'WP_ALLOW_REPAIR' ) || ! WP_ALLOW_REPAIR ) {
[27] Fix | Delete
[28] Fix | Delete
echo '<h1 class="screen-reader-text">' . __( 'Allow automatic database repair' ) . '</h1>';
[29] Fix | Delete
[30] Fix | Delete
echo '<p>';
[31] Fix | Delete
printf(
[32] Fix | Delete
/* translators: %s: wp-config.php */
[33] Fix | Delete
__( 'To allow use of this page to automatically repair database problems, please add the following line to your %s file. Once this line is added to your config, reload this page.' ),
[34] Fix | Delete
'<code>wp-config.php</code>'
[35] Fix | Delete
);
[36] Fix | Delete
echo "</p><p><code>define('WP_ALLOW_REPAIR', true);</code></p>";
[37] Fix | Delete
[38] Fix | Delete
$default_key = 'put your unique phrase here';
[39] Fix | Delete
$missing_key = false;
[40] Fix | Delete
$duplicated_keys = array();
[41] Fix | Delete
[42] Fix | Delete
foreach ( array( 'AUTH_KEY', 'SECURE_AUTH_KEY', 'LOGGED_IN_KEY', 'NONCE_KEY', 'AUTH_SALT', 'SECURE_AUTH_SALT', 'LOGGED_IN_SALT', 'NONCE_SALT' ) as $key ) {
[43] Fix | Delete
if ( defined( $key ) ) {
[44] Fix | Delete
// Check for unique values of each key.
[45] Fix | Delete
$duplicated_keys[ constant( $key ) ] = isset( $duplicated_keys[ constant( $key ) ] );
[46] Fix | Delete
} else {
[47] Fix | Delete
// If a constant is not defined, it's missing.
[48] Fix | Delete
$missing_key = true;
[49] Fix | Delete
}
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
// If at least one key uses the default value, consider it duplicated.
[53] Fix | Delete
if ( isset( $duplicated_keys[ $default_key ] ) ) {
[54] Fix | Delete
$duplicated_keys[ $default_key ] = true;
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
// Weed out all unique, non-default values.
[58] Fix | Delete
$duplicated_keys = array_filter( $duplicated_keys );
[59] Fix | Delete
[60] Fix | Delete
if ( $duplicated_keys || $missing_key ) {
[61] Fix | Delete
[62] Fix | Delete
echo '<h2 class="screen-reader-text">' . __( 'Check secret keys' ) . '</h2>';
[63] Fix | Delete
[64] Fix | Delete
/* translators: 1: wp-config.php, 2: Secret key service URL. */
[65] Fix | Delete
echo '<p>' . sprintf( __( 'While you are editing your %1$s file, take a moment to make sure you have all 8 keys and that they are unique. You can generate these using the <a href="%2$s">WordPress.org secret key service</a>.' ), '<code>wp-config.php</code>', 'https://api.wordpress.org/secret-key/1.1/salt/' ) . '</p>';
[66] Fix | Delete
}
[67] Fix | Delete
} elseif ( isset( $_GET['repair'] ) ) {
[68] Fix | Delete
[69] Fix | Delete
echo '<h1 class="screen-reader-text">' . __( 'Database repair results' ) . '</h1>';
[70] Fix | Delete
[71] Fix | Delete
$optimize = 2 == $_GET['repair'];
[72] Fix | Delete
$okay = true;
[73] Fix | Delete
$problems = array();
[74] Fix | Delete
[75] Fix | Delete
$tables = $wpdb->tables();
[76] Fix | Delete
[77] Fix | Delete
// Sitecategories may not exist if global terms are disabled.
[78] Fix | Delete
$query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->sitecategories ) );
[79] Fix | Delete
if ( is_multisite() && ! $wpdb->get_var( $query ) ) {
[80] Fix | Delete
unset( $tables['sitecategories'] );
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
/**
[84] Fix | Delete
* Filters additional database tables to repair.
[85] Fix | Delete
*
[86] Fix | Delete
* @since 3.0.0
[87] Fix | Delete
*
[88] Fix | Delete
* @param string[] $tables Array of prefixed table names to be repaired.
[89] Fix | Delete
*/
[90] Fix | Delete
$tables = array_merge( $tables, (array) apply_filters( 'tables_to_repair', array() ) );
[91] Fix | Delete
[92] Fix | Delete
// Loop over the tables, checking and repairing as needed.
[93] Fix | Delete
foreach ( $tables as $table ) {
[94] Fix | Delete
$check = $wpdb->get_row( "CHECK TABLE $table" );
[95] Fix | Delete
[96] Fix | Delete
echo '<p>';
[97] Fix | Delete
if ( 'OK' === $check->Msg_text ) {
[98] Fix | Delete
/* translators: %s: Table name. */
[99] Fix | Delete
printf( __( 'The %s table is okay.' ), "<code>$table</code>" );
[100] Fix | Delete
} else {
[101] Fix | Delete
/* translators: 1: Table name, 2: Error message. */
[102] Fix | Delete
printf( __( 'The %1$s table is not okay. It is reporting the following error: %2$s. WordPress will attempt to repair this table&hellip;' ), "<code>$table</code>", "<code>$check->Msg_text</code>" );
[103] Fix | Delete
[104] Fix | Delete
$repair = $wpdb->get_row( "REPAIR TABLE $table" );
[105] Fix | Delete
[106] Fix | Delete
echo '<br />&nbsp;&nbsp;&nbsp;&nbsp;';
[107] Fix | Delete
if ( 'OK' === $repair->Msg_text ) {
[108] Fix | Delete
/* translators: %s: Table name. */
[109] Fix | Delete
printf( __( 'Successfully repaired the %s table.' ), "<code>$table</code>" );
[110] Fix | Delete
} else {
[111] Fix | Delete
/* translators: 1: Table name, 2: Error message. */
[112] Fix | Delete
printf( __( 'Failed to repair the %1$s table. Error: %2$s' ), "<code>$table</code>", "<code>$repair->Msg_text</code>" ) . '<br />';
[113] Fix | Delete
$problems[ $table ] = $repair->Msg_text;
[114] Fix | Delete
$okay = false;
[115] Fix | Delete
}
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
if ( $okay && $optimize ) {
[119] Fix | Delete
$analyze = $wpdb->get_row( "ANALYZE TABLE $table" );
[120] Fix | Delete
[121] Fix | Delete
echo '<br />&nbsp;&nbsp;&nbsp;&nbsp;';
[122] Fix | Delete
if ( 'Table is already up to date' === $analyze->Msg_text ) {
[123] Fix | Delete
/* translators: %s: Table name. */
[124] Fix | Delete
printf( __( 'The %s table is already optimized.' ), "<code>$table</code>" );
[125] Fix | Delete
} else {
[126] Fix | Delete
$optimize = $wpdb->get_row( "OPTIMIZE TABLE $table" );
[127] Fix | Delete
[128] Fix | Delete
echo '<br />&nbsp;&nbsp;&nbsp;&nbsp;';
[129] Fix | Delete
if ( 'OK' === $optimize->Msg_text || 'Table is already up to date' === $optimize->Msg_text ) {
[130] Fix | Delete
/* translators: %s: Table name. */
[131] Fix | Delete
printf( __( 'Successfully optimized the %s table.' ), "<code>$table</code>" );
[132] Fix | Delete
} else {
[133] Fix | Delete
/* translators: 1: Table name. 2: Error message. */
[134] Fix | Delete
printf( __( 'Failed to optimize the %1$s table. Error: %2$s' ), "<code>$table</code>", "<code>$optimize->Msg_text</code>" );
[135] Fix | Delete
}
[136] Fix | Delete
}
[137] Fix | Delete
}
[138] Fix | Delete
echo '</p>';
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
if ( $problems ) {
[142] Fix | Delete
printf(
[143] Fix | Delete
/* translators: %s: URL to "Fixing WordPress" forum. */
[144] Fix | Delete
'<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>',
[145] Fix | Delete
__( 'https://wordpress.org/support/forum/how-to-and-troubleshooting' )
[146] Fix | Delete
);
[147] Fix | Delete
$problem_output = '';
[148] Fix | Delete
foreach ( $problems as $table => $problem ) {
[149] Fix | Delete
$problem_output .= "$table: $problem\n";
[150] Fix | Delete
}
[151] Fix | Delete
echo '<p><textarea name="errors" id="errors" rows="20" cols="60">' . esc_textarea( $problem_output ) . '</textarea></p>';
[152] Fix | Delete
} else {
[153] Fix | Delete
echo '<p>' . __( 'Repairs complete. Please remove the following line from wp-config.php to prevent this page from being used by unauthorized users.' ) . "</p><p><code>define('WP_ALLOW_REPAIR', true);</code></p>";
[154] Fix | Delete
}
[155] Fix | Delete
} else {
[156] Fix | Delete
[157] Fix | Delete
echo '<h1 class="screen-reader-text">' . __( 'WordPress database repair' ) . '</h1>';
[158] Fix | Delete
[159] Fix | Delete
if ( isset( $_GET['referrer'] ) && 'is_blog_installed' === $_GET['referrer'] ) {
[160] Fix | Delete
echo '<p>' . __( 'One or more database tables are unavailable. To allow WordPress to attempt to repair these tables, press the &#8220;Repair Database&#8221; button. Repairing can take a while, so please be patient.' ) . '</p>';
[161] Fix | Delete
} else {
[162] Fix | Delete
echo '<p>' . __( 'WordPress can automatically look for some common database problems and repair them. Repairing can take a while, so please be patient.' ) . '</p>';
[163] Fix | Delete
}
[164] Fix | Delete
?>
[165] Fix | Delete
<p class="step"><a class="button button-large" href="repair.php?repair=1"><?php _e( 'Repair Database' ); ?></a></p>
[166] Fix | Delete
<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>
[167] Fix | Delete
<p class="step"><a class="button button-large" href="repair.php?repair=2"><?php _e( 'Repair and Optimize Database' ); ?></a></p>
[168] Fix | Delete
<?php
[169] Fix | Delete
}
[170] Fix | Delete
?>
[171] Fix | Delete
</body>
[172] Fix | Delete
</html>
[173] Fix | Delete
[174] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function