PageRenderTime 22ms CodeModel.GetById 15ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-admin/upgrade.php

https://gitlab.com/geyson/geyson
PHP | 126 lines | 88 code | 18 blank | 20 comment | 13 complexity | e001a00156b43340927fb6c293cdae08 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( dirname( dirname( __FILE__ ) ) . '/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/**
 39 * @global string $wp_version
 40 * @global string $required_php_version
 41 * @global string $required_mysql_version
 42 * @global wpdb   $wpdb
 43 */
 44global $wp_version, $required_php_version, $required_mysql_version;
 45
 46$step = (int) $step;
 47
 48$php_version    = phpversion();
 49$mysql_version  = $wpdb->db_version();
 50$php_compat     = version_compare( $php_version, $required_php_version, '>=' );
 51if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
 52	$mysql_compat = true;
 53else
 54	$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' );
 55
 56@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
 57?>
 58<!DOCTYPE html>
 59<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
 60<head>
 61	<meta name="viewport" content="width=device-width" />
 62	<meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php echo get_option( 'blog_charset' ); ?>" />
 63	<title><?php _e( 'WordPress &rsaquo; Update' ); ?></title>
 64	<?php
 65	wp_admin_css( 'install', true );
 66	wp_admin_css( 'ie', true );
 67	?>
 68</head>
 69<body class="wp-core-ui">
 70<h1 id="logo"><a href="<?php echo esc_url( __( 'https://wordpress.org/' ) ); ?>" tabindex="-1"><?php _e( 'WordPress' ); ?></a></h1>
 71
 72<?php if ( get_option( 'db_version' ) == $wp_db_version || !is_blog_installed() ) : ?>
 73
 74<h2><?php _e( 'No Update Required' ); ?></h2>
 75<p><?php _e( 'Your WordPress database is already up-to-date!' ); ?></p>
 76<p class="step"><a class="button button-large" href="<?php echo get_option( 'home' ); ?>/"><?php _e( 'Continue' ); ?></a></p>
 77
 78<?php elseif ( !$php_compat || !$mysql_compat ) :
 79	if ( !$mysql_compat && !$php_compat )
 80		printf( __('You cannot update because <a href="https://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 );
 81	elseif ( !$php_compat )
 82		printf( __('You cannot update because <a href="https://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 );
 83	elseif ( !$mysql_compat )
 84		printf( __('You cannot update because <a href="https://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 );
 85?>
 86<?php else :
 87switch ( $step ) :
 88	case 0:
 89		$goback = wp_get_referer();
 90		if ( $goback ) {
 91			$goback = esc_url_raw( $goback );
 92			$goback = urlencode( $goback );
 93		}
 94?>
 95<h2><?php _e( 'Database Update Required' ); ?></h2>
 96<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>
 97<p><?php _e( 'The update process may take a little while, so please be patient.' ); ?></p>
 98<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>
 99<?php
100		break;
101	case 1:
102		wp_upgrade();
103
104			$backto = !empty($_GET['backto']) ? wp_unslash( urldecode( $_GET['backto'] ) ) : __get_option( 'home' ) . '/';
105			$backto = esc_url( $backto );
106			$backto = wp_validate_redirect($backto, __get_option( 'home' ) . '/');
107?>
108<h2><?php _e( 'Update Complete' ); ?></h2>
109	<p><?php _e( 'Your WordPress database has been successfully updated!' ); ?></p>
110	<p class="step"><a class="button button-large" href="<?php echo $backto; ?>"><?php _e( 'Continue' ); ?></a></p>
111
112<!--
113<pre>
114<?php printf( __( '%s queries' ), $wpdb->num_queries ); ?>
115
116<?php printf( __( '%s seconds' ), timer_stop( 0 ) ); ?>
117</pre>
118-->
119
120<?php
121		break;
122endswitch;
123endif;
124?>
125</body>
126</html>