Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow wp-config.php to exist one level up from WordPress root directo…
…ry. Props sambauers. fixes #6933

git-svn-id: http://core.svn.wordpress.org/trunk@7971 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
ryan committed May 21, 2008
1 parent 5376678 commit 94ca99e
Show file tree
Hide file tree
Showing 30 changed files with 75 additions and 53 deletions.
2 changes: 1 addition & 1 deletion wp-admin/admin-ajax.php
@@ -1,7 +1,7 @@
<?php
define('DOING_AJAX', true);

require_once('../wp-config.php');
require_once('../wp-load.php');
require_once('includes/admin.php');

if ( !is_user_logged_in() )
Expand Down
4 changes: 2 additions & 2 deletions wp-admin/admin.php
Expand Up @@ -2,9 +2,9 @@
define('WP_ADMIN', TRUE);

if ( defined('ABSPATH') )
require_once( ABSPATH . 'wp-config.php');
require_once(ABSPATH . 'wp-load.php');
else
require_once('../wp-config.php');
require_once('../wp-load.php');

if ( get_option('db_version') != $wp_db_version ) {
wp_redirect(get_option('siteurl') . '/wp-admin/upgrade.php?_wp_http_referer=' . urlencode(stripslashes($_SERVER['REQUEST_URI'])));
Expand Down
4 changes: 2 additions & 2 deletions wp-admin/async-upload.php
Expand Up @@ -5,9 +5,9 @@
*/

if ( defined('ABSPATH') )
require_once( ABSPATH . 'wp-config.php');
require_once(ABSPATH . 'wp-load.php');
else
require_once('../wp-config.php');
require_once('../wp-load.php');

// Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead
if ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
Expand Down
3 changes: 2 additions & 1 deletion wp-admin/install-helper.php
@@ -1,5 +1,6 @@
<?php
require_once(dirname(dirname(__FILE__)).'/wp-config.php');
$wp_only_load_config = true;
require_once(dirname(dirname(__FILE__)).'/wp-load.php');
$debug = 0;

/**
Expand Down
7 changes: 1 addition & 6 deletions wp-admin/install.php
@@ -1,12 +1,7 @@
<?php
define('WP_INSTALLING', true);
if (!file_exists('../wp-config.php')) {
require_once('../wp-includes/compat.php');
require_once('../wp-includes/functions.php');
wp_die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>. You can create a <code>wp-config.php</code> file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.</p><p><a href='setup-config.php' class='button'>Create a Configuration File</a>", "WordPress &rsaquo; Error");
}

require_once('../wp-config.php');
require_once('../wp-load.php');
require_once('./includes/upgrade.php');

if (isset($_GET['step']))
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/link-parse-opml.php
@@ -1,5 +1,5 @@
<?php
require_once('../wp-config.php');
require_once('../wp-load.php');

// columns we wish to find are: link_url, link_name, link_target, link_description
// we need to map XML attribute names to our columns
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/moderation.php
@@ -1,4 +1,4 @@
<?php
require_once('../wp-config.php');
require_once('../wp-load.php');
wp_redirect('edit-comments.php?comment_status=moderated');
?>
4 changes: 4 additions & 0 deletions wp-admin/setup-config.php
Expand Up @@ -20,6 +20,10 @@
if (file_exists('../wp-config.php'))
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>");

// Check if wp-config.php exists above the root directory
if (file_exists('../../wp-config.php'))
wp_die("<p>The file 'wp-config.php' already exists one level above your WordPress installation. 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>");

if (isset($_GET['step']))
$step = $_GET['step'];
else
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/update-links.php
@@ -1,5 +1,5 @@
<?php
require_once('../wp-config.php');
require_once('../wp-load.php');
require_once( ABSPATH . 'wp-includes/class-snoopy.php');

if ( !get_option('use_linksupdate') )
Expand Down
4 changes: 1 addition & 3 deletions wp-admin/upgrade.php
@@ -1,9 +1,7 @@
<?php
define('WP_INSTALLING', true);
if (!file_exists('../wp-config.php'))
die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://codex.wordpress.org/Installing_WordPress#Step_3:_Set_up_wp-config.php'>We got it</a>. You can create a <code>wp-config.php</code> file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.</p><p><a href='setup-config.php' class='button'>Create a Configuration File</a>");

require('../wp-config.php');
require('../wp-load.php');
timer_start();
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');

Expand Down
2 changes: 1 addition & 1 deletion wp-app.php
Expand Up @@ -9,7 +9,7 @@

define('APP_REQUEST', true);

require_once('./wp-config.php');
require_once('./wp-load.php');
require_once(ABSPATH . WPINC . '/post-template.php');
require_once(ABSPATH . WPINC . '/atomlib.php');
require_once(ABSPATH . WPINC . '/feed.php');
Expand Down
2 changes: 1 addition & 1 deletion wp-atom.php
@@ -1,7 +1,7 @@
<?php

if (empty($wp)) {
require_once('./wp-config.php');
require_once('./wp-load.php');
wp('feed=atom');
}

Expand Down
21 changes: 6 additions & 15 deletions wp-blog-header.php
@@ -1,24 +1,15 @@
<?php

if (! isset($wp_did_header)):
if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) {
if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = '';
else $path = 'wp-admin/';
if ( !isset($wp_did_header) ) {

require_once( dirname(__FILE__) . '/wp-includes/classes.php');
require_once( dirname(__FILE__) . '/wp-includes/functions.php');
require_once( dirname(__FILE__) . '/wp-includes/plugin.php');
wp_die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>. You can create a <code>wp-config.php</code> file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.</p><p><a href='{$path}setup-config.php' class='button'>Create a Configuration File</a>", "WordPress &rsaquo; Error");
}

$wp_did_header = true;
$wp_did_header = true;

require_once( dirname(__FILE__) . '/wp-config.php');
require_once( dirname(__FILE__) . '/wp-load.php' );

wp();
wp();

require_once(ABSPATH . WPINC . '/template-loader.php');
require_once( ABSPATH . WPINC . '/template-loader.php' );

endif;
}

?>
2 changes: 1 addition & 1 deletion wp-comments-post.php
Expand Up @@ -5,7 +5,7 @@
header('Content-Type: text/plain');
exit;
}
require( dirname(__FILE__) . '/wp-config.php' );
require( dirname(__FILE__) . '/wp-load.php' );

nocache_headers();

Expand Down
2 changes: 1 addition & 1 deletion wp-commentsrss2.php
@@ -1,7 +1,7 @@
<?php

if (empty($wp)) {
require_once('./wp-config.php');
require_once('./wp-load.php');
wp('feed=rss2&withcomments=1');
}

Expand Down
5 changes: 3 additions & 2 deletions wp-config-sample.php
Expand Up @@ -23,6 +23,7 @@

/* That's all, stop editing! Happy blogging. */

define('ABSPATH', dirname(__FILE__).'/');
require_once(ABSPATH.'wp-settings.php');
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
require_once(ABSPATH . 'wp-settings.php');
?>
2 changes: 1 addition & 1 deletion wp-cron.php
@@ -1,7 +1,7 @@
<?php
ignore_user_abort(true);
define('DOING_CRON', TRUE);
require_once('./wp-config.php');
require_once('./wp-load.php');

if ( $_GET['check'] != wp_hash('187425') )
exit;
Expand Down
4 changes: 2 additions & 2 deletions wp-includes/js/tinymce/tiny_mce_config.php
Expand Up @@ -4,15 +4,15 @@
* $Id: tiny_mce_gzip.php 315 2007-10-25 14:03:43Z spocke $
*
* @author Moxiecode
* @copyright Copyright © 2005-2006, Moxiecode Systems AB, All rights reserved.
* @copyright Copyright © 2005-2006, Moxiecode Systems AB, All rights reserved.
*
* This file compresses the TinyMCE JavaScript using GZip.
**/

// Discard any buffers
while ( @ob_end_clean() );

@ require('../../../wp-config.php');
@ require('../../../wp-load.php');

function getFileContents($path) {

Expand Down
2 changes: 1 addition & 1 deletion wp-includes/js/tinymce/wp-mce-help.php
@@ -1,4 +1,4 @@
<?php require_once('../../../wp-config.php');
<?php require_once('../../../wp-load.php');
header('Content-Type: text/html; charset=' . get_bloginfo('charset'));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Expand Down
2 changes: 1 addition & 1 deletion wp-links-opml.php
@@ -1,7 +1,7 @@
<?php

if (empty($wp)) {
require_once('./wp-config.php');
require_once('./wp-load.php');
wp();
}

Expand Down
32 changes: 32 additions & 0 deletions wp-load.php
@@ -0,0 +1,32 @@
<?php

// Define ABSPATH as this files directory
define( 'ABSPATH', dirname(__FILE__) . '/' );

if ( file_exists( ABSPATH . 'wp-config.php') ) {

// The config file resides in ABSPATH
require_once( ABSPATH . 'wp-config.php' );

} elseif ( file_exists( dirname(ABSPATH) . '/wp-config.php' ) ) {

// The config file resides one level below ABSPATH
require_once( dirname(ABSPATH) . '/wp-config.php' );

} else {

// A config file doesn't exist

// Set a path for the link to the installer
if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = '';
else $path = 'wp-admin/';

// Die with an error message
require_once( ABSPATH . '/wp-includes/classes.php' );
require_once( ABSPATH . '/wp-includes/functions.php' );
require_once( ABSPATH . '/wp-includes/plugin.php' );
wp_die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>. You can create a <code>wp-config.php</code> file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.</p><p><a href='{$path}setup-config.php' class='button'>Create a Configuration File</a>", "WordPress &rsaquo; Error");

}

?>
2 changes: 1 addition & 1 deletion wp-login.php
@@ -1,5 +1,5 @@
<?php
require( dirname(__FILE__) . '/wp-config.php' );
require( dirname(__FILE__) . '/wp-load.php' );

// Rather than duplicating this HTML all over the place, we'll stick it in function
function login_header($title = 'Login', $message = '', $wp_error = '') {
Expand Down
2 changes: 1 addition & 1 deletion wp-mail.php
@@ -1,5 +1,5 @@
<?php
require(dirname(__FILE__) . '/wp-config.php');
require(dirname(__FILE__) . '/wp-load.php');

require_once(ABSPATH.WPINC.'/class-pop3.php');

Expand Down
2 changes: 1 addition & 1 deletion wp-pass.php
@@ -1,5 +1,5 @@
<?php
require( dirname(__FILE__) . '/wp-config.php');
require( dirname(__FILE__) . '/wp-load.php');

if ( get_magic_quotes_gpc() )
$_POST['post_password'] = stripslashes($_POST['post_password']);
Expand Down
2 changes: 1 addition & 1 deletion wp-rdf.php
@@ -1,7 +1,7 @@
<?php /* RDF 1.0 generator, original version by garym@teledyn.com */

if (empty($wp)) {
require_once('./wp-config.php');
require_once('./wp-load.php');
wp('feed=rdf');
}

Expand Down
2 changes: 1 addition & 1 deletion wp-register.php
Expand Up @@ -3,7 +3,7 @@
# This file is deprecated, but you shouldn't have been linking to it directly anyway :P
# Use wp_register() to create a registration link instead, it's much better ;)

require('./wp-config.php');
require('./wp-load.php');
wp_redirect('wp-login.php?action=register');

?>
2 changes: 1 addition & 1 deletion wp-rss.php
@@ -1,7 +1,7 @@
<?php

if (empty($wp)) {
require_once('./wp-config.php');
require_once('./wp-load.php');
wp('feed=rss');
}

Expand Down
2 changes: 1 addition & 1 deletion wp-rss2.php
@@ -1,7 +1,7 @@
<?php

if (empty($wp)) {
require_once('./wp-config.php');
require_once('./wp-load.php');
wp('feed=rss2');
}

Expand Down
2 changes: 1 addition & 1 deletion wp-trackback.php
@@ -1,7 +1,7 @@
<?php

if (empty($wp)) {
require_once('./wp-config.php');
require_once('./wp-load.php');
wp('tb=1');
}

Expand Down
2 changes: 1 addition & 1 deletion xmlrpc.php
Expand Up @@ -15,7 +15,7 @@
if ( isset($HTTP_RAW_POST_DATA) )
$HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);

include('./wp-config.php');
include('./wp-load.php');

if ( isset( $_GET['rsd'] ) ) { // http://archipelago.phrasewise.com/rsd
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
Expand Down

0 comments on commit 94ca99e

Please sign in to comment.