Browse files

Allow wp-config.php to exist one level up from WordPress root directo…

…ry. Props sambauers. fixes #6933

git-svn-id: http://svn.automattic.com/wordpress/trunk@7971 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
1 parent e9aa24c commit 5b8113578d44a36065d43e37c49190264a842cbb ryan committed May 21, 2008
View
2 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() )
View
4 wp-admin/admin.php
@@ -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'])));
View
4 wp-admin/async-upload.php
@@ -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']) )
View
3 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;
/**
View
7 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']))
View
2 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
View
2 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');
?>
View
4 wp-admin/setup-config.php
@@ -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
View
2 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') )
View
4 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');
View
2 wp-app.php
@@ -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');
View
2 wp-atom.php
@@ -1,7 +1,7 @@
<?php
if (empty($wp)) {
- require_once('./wp-config.php');
+ require_once('./wp-load.php');
wp('feed=atom');
}
View
21 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;
+}
?>
View
2 wp-comments-post.php
@@ -5,7 +5,7 @@
header('Content-Type: text/plain');
exit;
}
-require( dirname(__FILE__) . '/wp-config.php' );
+require( dirname(__FILE__) . '/wp-load.php' );
nocache_headers();
View
2 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');
}
View
5 wp-config-sample.php
@@ -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');
?>
View
2 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;
View
4 wp-includes/js/tinymce/tiny_mce_config.php
@@ -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) {
View
2 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">
View
2 wp-links-opml.php
@@ -1,7 +1,7 @@
<?php
if (empty($wp)) {
- require_once('./wp-config.php');
+ require_once('./wp-load.php');
wp();
}
View
32 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");
+
+}
+
+?>
View
2 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 = '') {
View
2 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');
View
2 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']);
View
2 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');
}
View
2 wp-register.php
@@ -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');
?>
View
2 wp-rss.php
@@ -1,7 +1,7 @@
<?php
if (empty($wp)) {
- require_once('./wp-config.php');
+ require_once('./wp-load.php');
wp('feed=rss');
}
View
2 wp-rss2.php
@@ -1,7 +1,7 @@
<?php
if (empty($wp)) {
- require_once('./wp-config.php');
+ require_once('./wp-load.php');
wp('feed=rss2');
}
View
2 wp-trackback.php
@@ -1,7 +1,7 @@
<?php
if (empty($wp)) {
- require_once('./wp-config.php');
+ require_once('./wp-load.php');
wp('tb=1');
}
View
2 xmlrpc.php
@@ -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);

0 comments on commit 5b81135

Please sign in to comment.