Allow wp-config.php to exist one level up from WordPress root directory. Props sambauers. fixes #6933

git-svn-id: http://svn.automattic.com/wordpress/trunk@7971 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-05-21 05:59:27 +00:00
parent e9aa24cffb
commit 5b8113578d
30 changed files with 78 additions and 56 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
define('DOING_AJAX', true); define('DOING_AJAX', true);
require_once('../wp-config.php'); require_once('../wp-load.php');
require_once('includes/admin.php'); require_once('includes/admin.php');
if ( !is_user_logged_in() ) if ( !is_user_logged_in() )

View File

@ -2,9 +2,9 @@
define('WP_ADMIN', TRUE); define('WP_ADMIN', TRUE);
if ( defined('ABSPATH') ) if ( defined('ABSPATH') )
require_once( ABSPATH . 'wp-config.php'); require_once(ABSPATH . 'wp-load.php');
else else
require_once('../wp-config.php'); require_once('../wp-load.php');
if ( get_option('db_version') != $wp_db_version ) { 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']))); wp_redirect(get_option('siteurl') . '/wp-admin/upgrade.php?_wp_http_referer=' . urlencode(stripslashes($_SERVER['REQUEST_URI'])));

View File

@ -5,9 +5,9 @@
*/ */
if ( defined('ABSPATH') ) if ( defined('ABSPATH') )
require_once( ABSPATH . 'wp-config.php'); require_once(ABSPATH . 'wp-load.php');
else 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 // 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']) ) if ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )

View File

@ -1,5 +1,6 @@
<?php <?php
require_once(dirname(dirname(__FILE__)).'/wp-config.php'); $wp_only_load_config = true;
require_once(dirname(dirname(__FILE__)).'/wp-load.php');
$debug = 0; $debug = 0;
/** /**

View File

@ -1,12 +1,7 @@
<?php <?php
define('WP_INSTALLING', true); 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'); require_once('./includes/upgrade.php');
if (isset($_GET['step'])) if (isset($_GET['step']))

View File

@ -1,5 +1,5 @@
<?php <?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 // columns we wish to find are: link_url, link_name, link_target, link_description
// we need to map XML attribute names to our columns // we need to map XML attribute names to our columns

View File

@ -1,4 +1,4 @@
<?php <?php
require_once('../wp-config.php'); require_once('../wp-load.php');
wp_redirect('edit-comments.php?comment_status=moderated'); wp_redirect('edit-comments.php?comment_status=moderated');
?> ?>

View File

@ -20,6 +20,10 @@ if ( !is_writable('../'))
if (file_exists('../wp-config.php')) 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>"); 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'])) if (isset($_GET['step']))
$step = $_GET['step']; $step = $_GET['step'];
else else

View File

@ -1,5 +1,5 @@
<?php <?php
require_once('../wp-config.php'); require_once('../wp-load.php');
require_once( ABSPATH . 'wp-includes/class-snoopy.php'); require_once( ABSPATH . 'wp-includes/class-snoopy.php');
if ( !get_option('use_linksupdate') ) if ( !get_option('use_linksupdate') )

View File

@ -1,9 +1,7 @@
<?php <?php
define('WP_INSTALLING', true); 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(); timer_start();
require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); require_once(ABSPATH . 'wp-admin/includes/upgrade.php');

View File

@ -9,7 +9,7 @@
define('APP_REQUEST', true); 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 . '/post-template.php');
require_once(ABSPATH . WPINC . '/atomlib.php'); require_once(ABSPATH . WPINC . '/atomlib.php');
require_once(ABSPATH . WPINC . '/feed.php'); require_once(ABSPATH . WPINC . '/feed.php');

View File

@ -1,7 +1,7 @@
<?php <?php
if (empty($wp)) { if (empty($wp)) {
require_once('./wp-config.php'); require_once('./wp-load.php');
wp('feed=atom'); wp('feed=atom');
} }

View File

@ -1,24 +1,15 @@
<?php <?php
if (! isset($wp_did_header)): if ( !isset($wp_did_header) ) {
if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) {
if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = ''; $wp_did_header = true;
else $path = 'wp-admin/';
require_once( dirname(__FILE__) . '/wp-load.php' );
wp();
require_once( ABSPATH . WPINC . '/template-loader.php' );
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;
require_once( dirname(__FILE__) . '/wp-config.php');
wp();
require_once(ABSPATH . WPINC . '/template-loader.php');
endif;
?> ?>

View File

@ -5,7 +5,7 @@ if ( 'POST' != $_SERVER['REQUEST_METHOD'] ) {
header('Content-Type: text/plain'); header('Content-Type: text/plain');
exit; exit;
} }
require( dirname(__FILE__) . '/wp-config.php' ); require( dirname(__FILE__) . '/wp-load.php' );
nocache_headers(); nocache_headers();

View File

@ -1,7 +1,7 @@
<?php <?php
if (empty($wp)) { if (empty($wp)) {
require_once('./wp-config.php'); require_once('./wp-load.php');
wp('feed=rss2&withcomments=1'); wp('feed=rss2&withcomments=1');
} }

View File

@ -23,6 +23,7 @@ define ('WPLANG', '');
/* That's all, stop editing! Happy blogging. */ /* That's all, stop editing! Happy blogging. */
define('ABSPATH', dirname(__FILE__).'/'); if ( !defined('ABSPATH') )
require_once(ABSPATH.'wp-settings.php'); define('ABSPATH', dirname(__FILE__) . '/');
require_once(ABSPATH . 'wp-settings.php');
?> ?>

View File

@ -1,7 +1,7 @@
<?php <?php
ignore_user_abort(true); ignore_user_abort(true);
define('DOING_CRON', TRUE); define('DOING_CRON', TRUE);
require_once('./wp-config.php'); require_once('./wp-load.php');
if ( $_GET['check'] != wp_hash('187425') ) if ( $_GET['check'] != wp_hash('187425') )
exit; exit;

View File

@ -4,7 +4,7 @@
* $Id: tiny_mce_gzip.php 315 2007-10-25 14:03:43Z spocke $ * $Id: tiny_mce_gzip.php 315 2007-10-25 14:03:43Z spocke $
* *
* @author Moxiecode * @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. * This file compresses the TinyMCE JavaScript using GZip.
**/ **/
@ -12,7 +12,7 @@
// Discard any buffers // Discard any buffers
while ( @ob_end_clean() ); while ( @ob_end_clean() );
@ require('../../../wp-config.php'); @ require('../../../wp-load.php');
function getFileContents($path) { function getFileContents($path) {

View File

@ -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')); 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"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

View File

@ -1,7 +1,7 @@
<?php <?php
if (empty($wp)) { if (empty($wp)) {
require_once('./wp-config.php'); require_once('./wp-load.php');
wp(); wp();
} }

32
wp-load.php Normal file
View File

@ -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 File

@ -1,5 +1,5 @@
<?php <?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 // Rather than duplicating this HTML all over the place, we'll stick it in function
function login_header($title = 'Login', $message = '', $wp_error = '') { function login_header($title = 'Login', $message = '', $wp_error = '') {

View File

@ -1,5 +1,5 @@
<?php <?php
require(dirname(__FILE__) . '/wp-config.php'); require(dirname(__FILE__) . '/wp-load.php');
require_once(ABSPATH.WPINC.'/class-pop3.php'); require_once(ABSPATH.WPINC.'/class-pop3.php');

View File

@ -1,5 +1,5 @@
<?php <?php
require( dirname(__FILE__) . '/wp-config.php'); require( dirname(__FILE__) . '/wp-load.php');
if ( get_magic_quotes_gpc() ) if ( get_magic_quotes_gpc() )
$_POST['post_password'] = stripslashes($_POST['post_password']); $_POST['post_password'] = stripslashes($_POST['post_password']);

View File

@ -1,7 +1,7 @@
<?php /* RDF 1.0 generator, original version by garym@teledyn.com */ <?php /* RDF 1.0 generator, original version by garym@teledyn.com */
if (empty($wp)) { if (empty($wp)) {
require_once('./wp-config.php'); require_once('./wp-load.php');
wp('feed=rdf'); wp('feed=rdf');
} }

View File

@ -3,7 +3,7 @@
# This file is deprecated, but you shouldn't have been linking to it directly anyway :P # 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 ;) # 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'); wp_redirect('wp-login.php?action=register');
?> ?>

View File

@ -1,7 +1,7 @@
<?php <?php
if (empty($wp)) { if (empty($wp)) {
require_once('./wp-config.php'); require_once('./wp-load.php');
wp('feed=rss'); wp('feed=rss');
} }

View File

@ -1,7 +1,7 @@
<?php <?php
if (empty($wp)) { if (empty($wp)) {
require_once('./wp-config.php'); require_once('./wp-load.php');
wp('feed=rss2'); wp('feed=rss2');
} }

View File

@ -1,7 +1,7 @@
<?php <?php
if (empty($wp)) { if (empty($wp)) {
require_once('./wp-config.php'); require_once('./wp-load.php');
wp('tb=1'); wp('tb=1');
} }

View File

@ -15,7 +15,7 @@ if ( !isset( $HTTP_RAW_POST_DATA ) ) {
if ( isset($HTTP_RAW_POST_DATA) ) if ( isset($HTTP_RAW_POST_DATA) )
$HTTP_RAW_POST_DATA = trim($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 if ( isset( $_GET['rsd'] ) ) { // http://archipelago.phrasewise.com/rsd
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);