WordPress.org

Make WordPress Core

Ticket #10107: manual_config_text.10107.diff

File manual_config_text.10107.diff, 3.0 KB (added by filosofo, 9 years ago)
  • wp-admin/setup-config.php

     
    3535
    3636$configFile = file(ABSPATH . 'wp-config-sample.php');
    3737
    38 if ( !is_writable(ABSPATH))
    39         wp_die("Sorry, I can't write to the directory. You'll have to either change the permissions on your WordPress directory or create your wp-config.php manually.");
    40 
    4138// Check if wp-config.php has been created
    4239if (file_exists(ABSPATH . 'wp-config.php'))
    4340        wp_die("<p>The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p>");
     
    155152        if ( !empty($wpdb->error) )
    156153                wp_die($wpdb->error->get_error_message());
    157154
    158         $handle = fopen(ABSPATH . 'wp-config.php', 'w');
    159 
    160155        foreach ($configFile as $line_num => $line) {
    161156                switch (substr($line,0,16)) {
    162157                        case "define('DB_NAME'":
    163                                 fwrite($handle, str_replace("putyourdbnamehere", $dbname, $line));
     158                                $configFile[$line_num] = str_replace("putyourdbnamehere", $dbname, $line);
    164159                                break;
    165160                        case "define('DB_USER'":
    166                                 fwrite($handle, str_replace("'usernamehere'", "'$uname'", $line));
     161                                $configFile[$line_num] = str_replace("'usernamehere'", "'$uname'", $line);
    167162                                break;
    168163                        case "define('DB_PASSW":
    169                                 fwrite($handle, str_replace("'yourpasswordhere'", "'$passwrd'", $line));
     164                                $configFile[$line_num] = str_replace("'yourpasswordhere'", "'$passwrd'", $line);
    170165                                break;
    171166                        case "define('DB_HOST'":
    172                                 fwrite($handle, str_replace("localhost", $dbhost, $line));
     167                                $configFile[$line_num] = str_replace("localhost", $dbhost, $line);
    173168                                break;
    174169                        case '$table_prefix  =':
    175                                 fwrite($handle, str_replace('wp_', $prefix, $line));
     170                                $configFile[$line_num] = str_replace('wp_', $prefix, $line);
    176171                                break;
    177                         default:
    178                                 fwrite($handle, $line);
    179172                }
    180173        }
    181         fclose($handle);
    182         chmod(ABSPATH . 'wp-config.php', 0666);
    183 
    184         display_header();
     174        if ( ! is_writable(ABSPATH) ) :
     175                display_header();
    185176?>
     177<p>Sorry, but I can't write a <code>wp-config.php</code> file.  You can create the <code>wp-config.php</code> manually and paste in the following text.</p>
     178<p>After you've done that, click "Run the install."</p>
     179<textarea cols="90" rows="15"><?php
     180                foreach( $configFile as $line ) {
     181                        echo htmlentities($line);
     182                }
     183?></textarea>
     184<p class="step"><a href="install.php" class="button">Run the install</a></p>
     185<?php
     186        else :
     187                $handle = fopen(ABSPATH . 'wp-config.php', 'w');
     188                foreach( $configFile as $line ) {
     189                        fwrite($handle, $line);
     190                }
     191                fclose($handle);
     192                chmod(ABSPATH . 'wp-config.php', 0666);
     193                display_header();
     194?>
    186195<p>All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to&hellip;</p>
    187196
    188197<p class="step"><a href="install.php" class="button">Run the install</a></p>
    189198<?php
     199        endif;
    190200        break;
    191201}
    192202?>