PageRenderTime 51ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-admin/install.php

https://gitlab.com/oxidigitaluser/liguelista
PHP | 362 lines | 272 code | 39 blank | 51 comment | 36 complexity | ac3f2c2ff6dac8ef00046ddaa8421ce4 MD5 | raw file
  1. <?php
  2. /**
  3. * WordPress Installer
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. // Sanity check.
  9. if ( false ) {
  10. ?>
  11. <!DOCTYPE html>
  12. <html xmlns="http://www.w3.org/1999/xhtml">
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  15. <title>Error: PHP is not running</title>
  16. </head>
  17. <body class="wp-core-ui">
  18. <h1 id="logo"><a href="https://wordpress.org/">WordPress</a></h1>
  19. <h2>Error: PHP is not running</h2>
  20. <p>WordPress requires that your web server is running PHP. Your server does not have PHP installed, or PHP is turned off.</p>
  21. </body>
  22. </html>
  23. <?php
  24. }
  25. /**
  26. * We are installing WordPress.
  27. *
  28. * @since 1.5.1
  29. * @var bool
  30. */
  31. define( 'WP_INSTALLING', true );
  32. /** Load WordPress Bootstrap */
  33. require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
  34. /** Load WordPress Administration Upgrade API */
  35. require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
  36. /** Load WordPress Translation Install API */
  37. require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
  38. /** Load wpdb */
  39. require_once( ABSPATH . WPINC . '/wp-db.php' );
  40. nocache_headers();
  41. $step = isset( $_GET['step'] ) ? (int) $_GET['step'] : 0;
  42. /**
  43. * Display install header.
  44. *
  45. * @since 2.5.0
  46. *
  47. * @param string $body_classes
  48. */
  49. function display_header( $body_classes = '' ) {
  50. header( 'Content-Type: text/html; charset=utf-8' );
  51. if ( is_rtl() ) {
  52. $body_classes .= 'rtl';
  53. }
  54. if ( $body_classes ) {
  55. $body_classes = ' ' . $body_classes;
  56. }
  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="text/html; charset=utf-8" />
  63. <title><?php _e( 'WordPress &rsaquo; Installation' ); ?></title>
  64. <?php
  65. wp_admin_css( 'install', true );
  66. wp_admin_css( 'dashicons', true );
  67. ?>
  68. </head>
  69. <body class="wp-core-ui<?php echo $body_classes ?>">
  70. <h1 id="logo"><a href="<?php echo esc_url( __( 'https://wordpress.org/' ) ); ?>" tabindex="-1"><?php _e( 'WordPress' ); ?></a></h1>
  71. <?php
  72. } // end display_header()
  73. /**
  74. * Display installer setup form.
  75. *
  76. * @since 2.8.0
  77. *
  78. * @param string|null $error
  79. */
  80. function display_setup_form( $error = null ) {
  81. global $wpdb;
  82. $sql = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->users ) );
  83. $user_table = ( $wpdb->get_var( $sql ) != null );
  84. // Ensure that Blogs appear in search engines by default.
  85. $blog_public = 1;
  86. if ( isset( $_POST['weblog_title'] ) ) {
  87. $blog_public = isset( $_POST['blog_public'] );
  88. }
  89. $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : '';
  90. $user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : '';
  91. $admin_email = isset( $_POST['admin_email'] ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : '';
  92. if ( ! is_null( $error ) ) {
  93. ?>
  94. <p class="message"><?php echo $error; ?></p>
  95. <?php } ?>
  96. <form id="setup" method="post" action="install.php?step=2" novalidate="novalidate">
  97. <table class="form-table">
  98. <tr>
  99. <th scope="row"><label for="weblog_title"><?php _e( 'Site Title' ); ?></label></th>
  100. <td><input name="weblog_title" type="text" id="weblog_title" size="25" value="<?php echo esc_attr( $weblog_title ); ?>" /></td>
  101. </tr>
  102. <tr>
  103. <th scope="row"><label for="user_login"><?php _e('Username'); ?></label></th>
  104. <td>
  105. <?php
  106. if ( $user_table ) {
  107. _e('User(s) already exists.');
  108. echo '<input name="user_name" type="hidden" value="admin" />';
  109. } else {
  110. ?><input name="user_name" type="text" id="user_login" size="25" value="<?php echo esc_attr( sanitize_user( $user_name, true ) ); ?>" />
  111. <p><?php _e( 'Usernames can have only alphanumeric characters, spaces, underscores, hyphens, periods, and the @ symbol.' ); ?></p>
  112. <?php
  113. } ?>
  114. </td>
  115. </tr>
  116. <?php if ( ! $user_table ) : ?>
  117. <tr class="form-field form-required user-pass1-wrap">
  118. <th scope="row">
  119. <label for="pass1">
  120. <?php _e( 'Password' ); ?>
  121. </label>
  122. </th>
  123. <td>
  124. <div class="">
  125. <?php $initial_password = isset( $_POST['admin_password'] ) ? stripslashes( $_POST['admin_password'] ) : wp_generate_password( 18 ); ?>
  126. <input type="password" name="admin_password" id="pass1" class="regular-text" autocomplete="off" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" />
  127. <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-start-masked="<?php echo (int) isset( $_POST['admin_password'] ); ?>" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
  128. <span class="dashicons dashicons-hidden"></span>
  129. <span class="text"><?php _e( 'Hide' ); ?></span>
  130. </button>
  131. <div id="pass-strength-result" aria-live="polite"></div>
  132. </div>
  133. <p><span class="description important hide-if-no-js">
  134. <strong><?php _e( 'Important:' ); ?></strong>
  135. <?php /* translators: The non-breaking space prevents 1Password from thinking the text "log in" should trigger a password save prompt. */ ?>
  136. <?php _e( 'You will need this password to log&nbsp;in. Please store it in a secure location.' ); ?></span></p>
  137. </td>
  138. </tr>
  139. <tr class="form-field form-required user-pass2-wrap hide-if-js">
  140. <th scope="row">
  141. <label for="pass2"><?php _e( 'Repeat Password' ); ?>
  142. <span class="description"><?php _e( '(required)' ); ?></span>
  143. </label>
  144. </th>
  145. <td>
  146. <input name="admin_password2" type="password" id="pass2" autocomplete="off" />
  147. </td>
  148. </tr>
  149. <tr class="pw-weak">
  150. <th scope="row"><?php _e( 'Confirm Password' ); ?></th>
  151. <td>
  152. <label>
  153. <input type="checkbox" name="pw_weak" class="pw-checkbox" />
  154. <?php _e( 'Confirm use of weak password' ); ?>
  155. </label>
  156. </td>
  157. </tr>
  158. <?php endif; ?>
  159. <tr>
  160. <th scope="row"><label for="admin_email"><?php _e( 'Your E-mail' ); ?></label></th>
  161. <td><input name="admin_email" type="email" id="admin_email" size="25" value="<?php echo esc_attr( $admin_email ); ?>" />
  162. <p><?php _e( 'Double-check your email address before continuing.' ); ?></p></td>
  163. </tr>
  164. <tr>
  165. <th scope="row"><?php _e( 'Privacy' ); ?></th>
  166. <td colspan="2"><label><input type="checkbox" name="blog_public" id="blog_public" value="1" <?php checked( $blog_public ); ?> /> <?php _e( 'Allow search engines to index this site' ); ?></label></td>
  167. </tr>
  168. </table>
  169. <p class="step"><?php submit_button( __( 'Install WordPress' ), 'large', 'Submit', false, array( 'id' => 'submit' ) ); ?></p>
  170. <input type="hidden" name="language" value="<?php echo isset( $_REQUEST['language'] ) ? esc_attr( $_REQUEST['language'] ) : ''; ?>" />
  171. </form>
  172. <?php
  173. } // end display_setup_form()
  174. // Let's check to make sure WP isn't already installed.
  175. if ( is_blog_installed() ) {
  176. display_header();
  177. die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p><p class="step"><a href="../wp-login.php" class="button button-large">' . __( 'Log In' ) . '</a></p></body></html>' );
  178. }
  179. /**
  180. * @global string $wp_version
  181. * @global string $required_php_version
  182. * @global string $required_mysql_version
  183. * @global wpdb $wpdb
  184. */
  185. global $wp_version, $required_php_version, $required_mysql_version;
  186. $php_version = phpversion();
  187. $mysql_version = $wpdb->db_version();
  188. $php_compat = version_compare( $php_version, $required_php_version, '>=' );
  189. $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
  190. if ( !$mysql_compat && !$php_compat )
  191. $compat = sprintf( __( 'You cannot install 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 );
  192. elseif ( !$php_compat )
  193. $compat = sprintf( __( 'You cannot install 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 );
  194. elseif ( !$mysql_compat )
  195. $compat = sprintf( __( 'You cannot install 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 );
  196. if ( !$mysql_compat || !$php_compat ) {
  197. display_header();
  198. die( '<h1>' . __( 'Insufficient Requirements' ) . '</h1><p>' . $compat . '</p></body></html>' );
  199. }
  200. if ( ! is_string( $wpdb->base_prefix ) || '' === $wpdb->base_prefix ) {
  201. display_header();
  202. die( '<h1>' . __( 'Configuration Error' ) . '</h1><p>' . __( 'Your <code>wp-config.php</code> file has an empty database table prefix, which is not supported.' ) . '</p></body></html>' );
  203. }
  204. // Set error message if DO_NOT_UPGRADE_GLOBAL_TABLES isn't set as it will break install.
  205. if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
  206. display_header();
  207. die( '<h1>' . __( 'Configuration Error' ) . '</h1><p>' . __( 'The constant DO_NOT_UPGRADE_GLOBAL_TABLES cannot be defined when installing WordPress.' ) . '</p></body></html>' );
  208. }
  209. /**
  210. * @global string $wp_local_package
  211. * @global WP_Locale $wp_locale
  212. */
  213. $language = '';
  214. if ( ! empty( $_REQUEST['language'] ) ) {
  215. $language = preg_replace( '/[^a-zA-Z_]/', '', $_REQUEST['language'] );
  216. } elseif ( isset( $GLOBALS['wp_local_package'] ) ) {
  217. $language = $GLOBALS['wp_local_package'];
  218. }
  219. switch($step) {
  220. case 0: // Step 0
  221. if ( wp_can_install_language_pack() && empty( $language ) && ( $languages = wp_get_available_translations() ) ) {
  222. display_header( 'language-chooser' );
  223. echo '<form id="setup" method="post" action="?step=1">';
  224. wp_install_language_form( $languages );
  225. echo '</form>';
  226. break;
  227. }
  228. // Deliberately fall through if we can't reach the translations API.
  229. case 1: // Step 1, direct link or from language chooser.
  230. if ( ! empty( $language ) ) {
  231. $loaded_language = wp_download_language_pack( $language );
  232. if ( $loaded_language ) {
  233. load_default_textdomain( $loaded_language );
  234. $GLOBALS['wp_locale'] = new WP_Locale();
  235. }
  236. }
  237. display_header();
  238. ?>
  239. <h1><?php _ex( 'Welcome', 'Howdy' ); ?></h1>
  240. <p><?php _e( 'Welcome to the famous five-minute WordPress installation process! Just fill in the information below and you&#8217;ll be on your way to using the most extendable and powerful personal publishing platform in the world.' ); ?></p>
  241. <h1><?php _e( 'Information needed' ); ?></h1>
  242. <p><?php _e( 'Please provide the following information. Don&#8217;t worry, you can always change these settings later.' ); ?></p>
  243. <?php
  244. display_setup_form();
  245. break;
  246. case 2:
  247. if ( ! empty( $language ) && load_default_textdomain( $language ) ) {
  248. $loaded_language = $language;
  249. $GLOBALS['wp_locale'] = new WP_Locale();
  250. } else {
  251. $loaded_language = 'en_US';
  252. }
  253. if ( ! empty( $wpdb->error ) )
  254. wp_die( $wpdb->error->get_error_message() );
  255. display_header();
  256. // Fill in the data we gathered
  257. $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : '';
  258. $user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : '';
  259. $admin_password = isset($_POST['admin_password']) ? wp_unslash( $_POST['admin_password'] ) : '';
  260. $admin_password_check = isset($_POST['admin_password2']) ? wp_unslash( $_POST['admin_password2'] ) : '';
  261. $admin_email = isset( $_POST['admin_email'] ) ?trim( wp_unslash( $_POST['admin_email'] ) ) : '';
  262. $public = isset( $_POST['blog_public'] ) ? (int) $_POST['blog_public'] : 0;
  263. // Check e-mail address.
  264. $error = false;
  265. if ( empty( $user_name ) ) {
  266. // TODO: poka-yoke
  267. display_setup_form( __( 'Please provide a valid username.' ) );
  268. $error = true;
  269. } elseif ( $user_name != sanitize_user( $user_name, true ) ) {
  270. display_setup_form( __( 'The username you provided has invalid characters.' ) );
  271. $error = true;
  272. } elseif ( $admin_password != $admin_password_check ) {
  273. // TODO: poka-yoke
  274. display_setup_form( __( 'Your passwords do not match. Please try again.' ) );
  275. $error = true;
  276. } elseif ( empty( $admin_email ) ) {
  277. // TODO: poka-yoke
  278. display_setup_form( __( 'You must provide an email address.' ) );
  279. $error = true;
  280. } elseif ( ! is_email( $admin_email ) ) {
  281. // TODO: poka-yoke
  282. display_setup_form( __( 'Sorry, that isn&#8217;t a valid email address. Email addresses look like <code>username@example.com</code>.' ) );
  283. $error = true;
  284. }
  285. if ( $error === false ) {
  286. $wpdb->show_errors();
  287. $result = wp_install( $weblog_title, $user_name, $admin_email, $public, '', wp_slash( $admin_password ), $loaded_language );
  288. ?>
  289. <h1><?php _e( 'Success!' ); ?></h1>
  290. <p><?php _e( 'WordPress has been installed. Were you expecting more steps? Sorry to disappoint.' ); ?></p>
  291. <table class="form-table install-success">
  292. <tr>
  293. <th><?php _e( 'Username' ); ?></th>
  294. <td><?php echo esc_html( sanitize_user( $user_name, true ) ); ?></td>
  295. </tr>
  296. <tr>
  297. <th><?php _e( 'Password' ); ?></th>
  298. <td><?php
  299. if ( ! empty( $result['password'] ) && empty( $admin_password_check ) ): ?>
  300. <code><?php echo esc_html( $result['password'] ) ?></code><br />
  301. <?php endif ?>
  302. <p><?php echo $result['password_message'] ?></p>
  303. </td>
  304. </tr>
  305. </table>
  306. <p class="step"><a href="../wp-login.php" class="button button-large"><?php _e( 'Log In' ); ?></a></p>
  307. <?php
  308. }
  309. break;
  310. }
  311. if ( !wp_is_mobile() ) {
  312. ?>
  313. <script type="text/javascript">var t = document.getElementById('weblog_title'); if (t){ t.focus(); }</script>
  314. <?php } ?>
  315. <?php wp_print_scripts( 'user-profile' ); ?>
  316. <?php wp_print_scripts( 'language-chooser' ); ?>
  317. <script type="text/javascript">
  318. jQuery( function( $ ) {
  319. $( '.hide-if-no-js' ).removeClass( 'hide-if-no-js' );
  320. } );
  321. </script>
  322. </body>
  323. </html>