PageRenderTime 47ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/df_home/static/test/portalbkd/wp-admin/install.php

https://gitlab.com/darmawan.fatria/df-skp-2014
PHP | 307 lines | 233 code | 38 blank | 36 comment | 35 complexity | 6a48aee948fe2ea5d3a6b9a325b604f5 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. function display_header( $body_classes = '' ) {
  48. header( 'Content-Type: text/html; charset=utf-8' );
  49. if ( is_rtl() ) {
  50. $body_classes .= 'rtl';
  51. }
  52. if ( $body_classes ) {
  53. $body_classes = ' ' . $body_classes;
  54. }
  55. ?>
  56. <!DOCTYPE html>
  57. <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
  58. <head>
  59. <meta name="viewport" content="width=device-width" />
  60. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  61. <title><?php _e( 'WordPress &rsaquo; Installation' ); ?></title>
  62. <?php
  63. wp_admin_css( 'install', true );
  64. ?>
  65. </head>
  66. <body class="wp-core-ui<?php echo $body_classes ?>">
  67. <h1 id="logo"><a href="<?php echo esc_url( __( 'https://wordpress.org/' ) ); ?>" tabindex="-1"><?php _e( 'WordPress' ); ?></a></h1>
  68. <?php
  69. } // end display_header()
  70. /**
  71. * Display installer setup form.
  72. *
  73. * @since 2.8.0
  74. */
  75. function display_setup_form( $error = null ) {
  76. global $wpdb;
  77. $sql = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->users ) );
  78. $user_table = ( $wpdb->get_var( $sql ) != null );
  79. // Ensure that Blogs appear in search engines by default.
  80. $blog_public = 1;
  81. if ( isset( $_POST['weblog_title'] ) ) {
  82. $blog_public = isset( $_POST['blog_public'] );
  83. }
  84. $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : '';
  85. $user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : '';
  86. $admin_email = isset( $_POST['admin_email'] ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : '';
  87. if ( ! is_null( $error ) ) {
  88. ?>
  89. <p class="message"><?php echo $error; ?></p>
  90. <?php } ?>
  91. <form id="setup" method="post" action="install.php?step=2" novalidate="novalidate">
  92. <table class="form-table">
  93. <tr>
  94. <th scope="row"><label for="weblog_title"><?php _e( 'Site Title' ); ?></label></th>
  95. <td><input name="weblog_title" type="text" id="weblog_title" size="25" value="<?php echo esc_attr( $weblog_title ); ?>" /></td>
  96. </tr>
  97. <tr>
  98. <th scope="row"><label for="user_login"><?php _e('Username'); ?></label></th>
  99. <td>
  100. <?php
  101. if ( $user_table ) {
  102. _e('User(s) already exists.');
  103. echo '<input name="user_name" type="hidden" value="admin" />';
  104. } else {
  105. ?><input name="user_name" type="text" id="user_login" size="25" value="<?php echo esc_attr( sanitize_user( $user_name, true ) ); ?>" />
  106. <p><?php _e( 'Usernames can have only alphanumeric characters, spaces, underscores, hyphens, periods, and the @ symbol.' ); ?></p>
  107. <?php
  108. } ?>
  109. </td>
  110. </tr>
  111. <?php if ( ! $user_table ) : ?>
  112. <tr>
  113. <th scope="row">
  114. <label for="pass1"><?php _e('Password, twice'); ?></label>
  115. <p><?php _e('A password will be automatically generated for you if you leave this blank.'); ?></p>
  116. </th>
  117. <td>
  118. <input name="admin_password" type="password" id="pass1" size="25" value="" />
  119. <p><input name="admin_password2" type="password" id="pass2" size="25" value="" /></p>
  120. <div id="pass-strength-result"><?php _e('Strength indicator'); ?></div>
  121. <p><?php echo wp_get_password_hint(); ?></p>
  122. </td>
  123. </tr>
  124. <?php endif; ?>
  125. <tr>
  126. <th scope="row"><label for="admin_email"><?php _e( 'Your E-mail' ); ?></label></th>
  127. <td><input name="admin_email" type="email" id="admin_email" size="25" value="<?php echo esc_attr( $admin_email ); ?>" />
  128. <p><?php _e( 'Double-check your email address before continuing.' ); ?></p></td>
  129. </tr>
  130. <tr>
  131. <th scope="row"><?php _e( 'Privacy' ); ?></th>
  132. <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>
  133. </tr>
  134. </table>
  135. <p class="step"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Install WordPress' ); ?>" class="button button-large" /></p>
  136. <input type="hidden" name="language" value="<?php echo isset( $_REQUEST['language'] ) ? esc_attr( $_REQUEST['language'] ) : ''; ?>" />
  137. </form>
  138. <?php
  139. } // end display_setup_form()
  140. // Let's check to make sure WP isn't already installed.
  141. if ( is_blog_installed() ) {
  142. display_header();
  143. 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>' );
  144. }
  145. global $wp_version, $required_php_version, $required_mysql_version;
  146. $php_version = phpversion();
  147. $mysql_version = $wpdb->db_version();
  148. $php_compat = version_compare( $php_version, $required_php_version, '>=' );
  149. $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
  150. if ( !$mysql_compat && !$php_compat )
  151. $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 );
  152. elseif ( !$php_compat )
  153. $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 );
  154. elseif ( !$mysql_compat )
  155. $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 );
  156. if ( !$mysql_compat || !$php_compat ) {
  157. display_header();
  158. die( '<h1>' . __( 'Insufficient Requirements' ) . '</h1><p>' . $compat . '</p></body></html>' );
  159. }
  160. if ( ! is_string( $wpdb->base_prefix ) || '' === $wpdb->base_prefix ) {
  161. display_header();
  162. 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>' );
  163. }
  164. $language = '';
  165. if ( ! empty( $_REQUEST['language'] ) ) {
  166. $language = preg_replace( '/[^a-zA-Z_]/', '', $_REQUEST['language'] );
  167. } elseif ( isset( $GLOBALS['wp_local_package'] ) ) {
  168. $language = $GLOBALS['wp_local_package'];
  169. }
  170. switch($step) {
  171. case 0: // Step 0
  172. if ( wp_can_install_language_pack() && empty( $language ) && ( $languages = wp_get_available_translations() ) ) {
  173. display_header( 'language-chooser' );
  174. echo '<form id="setup" method="post" action="?step=1">';
  175. wp_install_language_form( $languages );
  176. echo '</form>';
  177. break;
  178. }
  179. // Deliberately fall through if we can't reach the translations API.
  180. case 1: // Step 1, direct link or from language chooser.
  181. if ( ! empty( $language ) ) {
  182. $loaded_language = wp_download_language_pack( $language );
  183. if ( $loaded_language ) {
  184. load_default_textdomain( $loaded_language );
  185. $GLOBALS['wp_locale'] = new WP_Locale();
  186. }
  187. }
  188. display_header();
  189. ?>
  190. <h1><?php _ex( 'Welcome', 'Howdy' ); ?></h1>
  191. <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>
  192. <h1><?php _e( 'Information needed' ); ?></h1>
  193. <p><?php _e( 'Please provide the following information. Don&#8217;t worry, you can always change these settings later.' ); ?></p>
  194. <?php
  195. display_setup_form();
  196. break;
  197. case 2:
  198. if ( ! empty( $language ) && load_default_textdomain( $language ) ) {
  199. $loaded_language = $language;
  200. $GLOBALS['wp_locale'] = new WP_Locale();
  201. } else {
  202. $loaded_language = 'en_US';
  203. }
  204. if ( ! empty( $wpdb->error ) )
  205. wp_die( $wpdb->error->get_error_message() );
  206. display_header();
  207. // Fill in the data we gathered
  208. $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : '';
  209. $user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : '';
  210. $admin_password = isset($_POST['admin_password']) ? wp_unslash( $_POST['admin_password'] ) : '';
  211. $admin_password_check = isset($_POST['admin_password2']) ? wp_unslash( $_POST['admin_password2'] ) : '';
  212. $admin_email = isset( $_POST['admin_email'] ) ?trim( wp_unslash( $_POST['admin_email'] ) ) : '';
  213. $public = isset( $_POST['blog_public'] ) ? (int) $_POST['blog_public'] : 0;
  214. // Check e-mail address.
  215. $error = false;
  216. if ( empty( $user_name ) ) {
  217. // TODO: poka-yoke
  218. display_setup_form( __( 'Please provide a valid username.' ) );
  219. $error = true;
  220. } elseif ( $user_name != sanitize_user( $user_name, true ) ) {
  221. display_setup_form( __( 'The username you provided has invalid characters.' ) );
  222. $error = true;
  223. } elseif ( $admin_password != $admin_password_check ) {
  224. // TODO: poka-yoke
  225. display_setup_form( __( 'Your passwords do not match. Please try again.' ) );
  226. $error = true;
  227. } elseif ( empty( $admin_email ) ) {
  228. // TODO: poka-yoke
  229. display_setup_form( __( 'You must provide an email address.' ) );
  230. $error = true;
  231. } elseif ( ! is_email( $admin_email ) ) {
  232. // TODO: poka-yoke
  233. display_setup_form( __( 'Sorry, that isn&#8217;t a valid email address. Email addresses look like <code>username@example.com</code>.' ) );
  234. $error = true;
  235. }
  236. if ( $error === false ) {
  237. $wpdb->show_errors();
  238. $result = wp_install( $weblog_title, $user_name, $admin_email, $public, '', wp_slash( $admin_password ), $loaded_language );
  239. ?>
  240. <h1><?php _e( 'Success!' ); ?></h1>
  241. <p><?php _e( 'WordPress has been installed. Were you expecting more steps? Sorry to disappoint.' ); ?></p>
  242. <table class="form-table install-success">
  243. <tr>
  244. <th><?php _e( 'Username' ); ?></th>
  245. <td><?php echo esc_html( sanitize_user( $user_name, true ) ); ?></td>
  246. </tr>
  247. <tr>
  248. <th><?php _e( 'Password' ); ?></th>
  249. <td><?php
  250. if ( ! empty( $result['password'] ) && empty( $admin_password_check ) ): ?>
  251. <code><?php echo esc_html( $result['password'] ) ?></code><br />
  252. <?php endif ?>
  253. <p><?php echo $result['password_message'] ?></p>
  254. </td>
  255. </tr>
  256. </table>
  257. <p class="step"><a href="../wp-login.php" class="button button-large"><?php _e( 'Log In' ); ?></a></p>
  258. <?php
  259. }
  260. break;
  261. }
  262. if ( !wp_is_mobile() ) {
  263. ?>
  264. <script type="text/javascript">var t = document.getElementById('weblog_title'); if (t){ t.focus(); }</script>
  265. <?php } ?>
  266. <?php wp_print_scripts( 'user-profile' ); ?>
  267. <?php wp_print_scripts( 'language-chooser' ); ?>
  268. </body>
  269. </html>