PageRenderTime 70ms CodeModel.GetById 41ms app.highlight 7ms RepoModel.GetById 13ms app.codeStats 0ms

/wp-admin/upgrade.php

http://officialwp.codeplex.com
PHP | 115 lines | 84 code | 17 blank | 14 comment | 12 complexity | ec93ec193f8afefe352dd0975f248c65 MD5 | raw file
  1<?php
  2/**
  3 * Upgrade WordPress Page.
  4 *
  5 * @package WordPress
  6 * @subpackage Administration
  7 */
  8
  9/**
 10 * We are upgrading WordPress.
 11 *
 12 * @since 1.5.1
 13 * @var bool
 14 */
 15define( 'WP_INSTALLING', true );
 16
 17/** Load WordPress Bootstrap */
 18require( '../wp-load.php' );
 19
 20nocache_headers();
 21
 22timer_start();
 23require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
 24
 25delete_site_transient('update_core');
 26
 27if ( isset( $_GET['step'] ) )
 28	$step = $_GET['step'];
 29else
 30	$step = 0;
 31
 32// Do it. No output.
 33if ( 'upgrade_db' === $step ) {
 34	wp_upgrade();
 35	die( '0' );
 36}
 37
 38$step = (int) $step;
 39
 40$php_version    = phpversion();
 41$mysql_version  = $wpdb->db_version();
 42$php_compat     = version_compare( $php_version, $required_php_version, '>=' );
 43if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
 44	$mysql_compat = true;
 45else
 46	$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' );
 47
 48@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
 49?>
 50<!DOCTYPE html>
 51<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
 52<head>
 53	<meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php echo get_option( 'blog_charset' ); ?>" />
 54	<title><?php _e( 'WordPress &rsaquo; Update' ); ?></title>
 55	<?php
 56	wp_admin_css( 'install', true );
 57	wp_admin_css( 'ie', true );
 58	?>
 59</head>
 60<body class="wp-core-ui">
 61<h1 id="logo"><a href="<?php esc_attr_e( 'http://wordpress.org/' ); ?>"><?php _e( 'WordPress' ); ?></a></h1>
 62
 63<?php if ( get_option( 'db_version' ) == $wp_db_version || !is_blog_installed() ) : ?>
 64
 65<h2><?php _e( 'No Update Required' ); ?></h2>
 66<p><?php _e( 'Your WordPress database is already up-to-date!' ); ?></p>
 67<p class="step"><a class="button button-large" href="<?php echo get_option( 'home' ); ?>/"><?php _e( 'Continue' ); ?></a></p>
 68
 69<?php elseif ( !$php_compat || !$mysql_compat ) :
 70	if ( !$mysql_compat && !$php_compat )
 71		printf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version );
 72	elseif ( !$php_compat )
 73		printf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.'), $wp_version, $required_php_version, $php_version );
 74	elseif ( !$mysql_compat )
 75		printf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.'), $wp_version, $required_mysql_version, $mysql_version );
 76?>
 77<?php else :
 78switch ( $step ) :
 79	case 0:
 80		$goback = stripslashes( wp_get_referer() );
 81		$goback = esc_url_raw( $goback );
 82		$goback = urlencode( $goback );
 83?>
 84<h2><?php _e( 'Database Update Required' ); ?></h2>
 85<p><?php _e( 'WordPress has been updated! Before we send you on your way, we have to update your database to the newest version.' ); ?></p>
 86<p><?php _e( 'The update process may take a little while, so please be patient.' ); ?></p>
 87<p class="step"><a class="button button-large" href="upgrade.php?step=1&amp;backto=<?php echo $goback; ?>"><?php _e( 'Update WordPress Database' ); ?></a></p>
 88<?php
 89		break;
 90	case 1:
 91		wp_upgrade();
 92
 93			$backto = !empty($_GET['backto']) ? stripslashes( urldecode( $_GET['backto'] ) ) : __get_option( 'home' ) . '/';
 94			$backto = esc_url( $backto );
 95			$backto = wp_validate_redirect($backto, __get_option( 'home' ) . '/');
 96?>
 97<h2><?php _e( 'Update Complete' ); ?></h2>
 98	<p><?php _e( 'Your WordPress database has been successfully updated!' ); ?></p>
 99	<p class="step"><a class="button button-large" href="<?php echo $backto; ?>"><?php _e( 'Continue' ); ?></a></p>
100
101<!--
102<pre>
103<?php printf( __( '%s queries' ), $wpdb->num_queries ); ?>
104
105<?php printf( __( '%s seconds' ), timer_stop( 0 ) ); ?>
106</pre>
107-->
108
109<?php
110		break;
111endswitch;
112endif;
113?>
114</body>
115</html>