WordPress.org

Make WordPress Core

Changeset 11705


Ignore:
Timestamp:
07/09/09 21:35:47 (6 years ago)
Author:
westi
Message:

Provide a pre-filled wp-config.php file in a textarea if setup-config can't write to the server. Fixes #10107 props filosofo.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/setup-config.php

    r11301 r11705  
    3535 
    3636$configFile = file(ABSPATH . 'wp-config-sample.php'); 
    37  
    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."); 
    4037 
    4138// Check if wp-config.php has been created 
     
    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)); 
    176                 break; 
    177             default: 
    178                 fwrite($handle, $line); 
     170                $configFile[$line_num] = str_replace('wp_', $prefix, $line); 
     171                break; 
    179172        } 
    180173    } 
    181     fclose($handle); 
    182     chmod(ABSPATH . 'wp-config.php', 0666); 
    183  
    184     display_header(); 
     174    if ( ! is_writable(ABSPATH) ) : 
     175        display_header(); 
     176?> 
     177<p>Sorry, but I can't write the <code>wp-config.php</code> file.</p> 
     178<p>You can create the <code>wp-config.php</code> manually and paste the following text into it.</p> 
     179<textarea cols="90" rows="15"><?php 
     180        foreach( $configFile as $line ) { 
     181            echo htmlentities($line); 
     182        } 
     183?></textarea> 
     184<p>After you've done that, click "Run the install."</p> 
     185<p class="step"><a href="install.php" class="button">Run the install</a></p> 
     186<?php 
     187    else : 
     188        $handle = fopen(ABSPATH . 'wp-config.php', 'w'); 
     189        foreach( $configFile as $line ) { 
     190            fwrite($handle, $line); 
     191        } 
     192        fclose($handle); 
     193        chmod(ABSPATH . 'wp-config.php', 0666); 
     194        display_header(); 
    185195?> 
    186196<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> 
     
    188198<p class="step"><a href="install.php" class="button">Run the install</a></p> 
    189199<?php 
     200    endif; 
    190201    break; 
    191202} 
Note: See TracChangeset for help on using the changeset viewer.