WordPress.org

Make WordPress Core

Ticket #6933: allow-config-file-outside-of-webroot.patch

File allow-config-file-outside-of-webroot.patch, 15.4 KB (added by sambauers, 10 years ago)
  • wp-pass.php

     
    11<?php
    2 require( dirname(__FILE__) . '/wp-config.php');
     2require( dirname(__FILE__) . '/wp-load.php');
    33
    44if ( get_magic_quotes_gpc() )
    55        $_POST['post_password'] = stripslashes($_POST['post_password']);
  • wp-rss.php

     
    11<?php
    22
    33if (empty($wp)) {
    4         require_once('./wp-config.php');
     4        require_once('./wp-load.php');
    55        wp('feed=rss');
    66}
    77
  • wp-comments-post.php

     
    55        header('Content-Type: text/plain');
    66        exit;
    77}
    8 require( dirname(__FILE__) . '/wp-config.php' );
     8require( dirname(__FILE__) . '/wp-load.php' );
    99
    1010nocache_headers();
    1111
  • wp-login.php

     
    11<?php
    2 require( dirname(__FILE__) . '/wp-config.php' );
     2require( dirname(__FILE__) . '/wp-load.php' );
    33
    44// Rather than duplicating this HTML all over the place, we'll stick it in function
    55function login_header($title = 'Login', $message = '', $wp_error = '') {
  • wp-blog-header.php

     
    11<?php
    22
    3 if (! isset($wp_did_header)):
    4 if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) {
    5         if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = '';
    6         else $path = 'wp-admin/';
     3if ( !isset($wp_did_header) ) {
    74
    8         require_once( dirname(__FILE__) . '/wp-includes/classes.php');
    9         require_once( dirname(__FILE__) . '/wp-includes/functions.php');
    10         require_once( dirname(__FILE__) . '/wp-includes/plugin.php');
    11         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");
    12 }
     5        $wp_did_header = true;
    136
    14 $wp_did_header = true;
     7        require_once( dirname(__FILE__) . '/wp-load.php' );
    158
    16 require_once( dirname(__FILE__) . '/wp-config.php');
     9        wp();
    1710
    18 wp();
     11        require_once( ABSPATH . WPINC . '/template-loader.php' );
    1912
    20 require_once(ABSPATH . WPINC . '/template-loader.php');
     13}
    2114
    22 endif;
    23 
    2415?>
  • wp-rdf.php

     
    11<?php /* RDF 1.0 generator, original version by garym@teledyn.com */
    22
    33if (empty($wp)) {
    4         require_once('./wp-config.php');
     4        require_once('./wp-load.php');
    55        wp('feed=rdf');
    66}
    77
  • wp-load.php

     
     1<?php
     2
     3// Define ABSPATH as this files directory
     4define( 'ABSPATH', dirname(__FILE__) . '/' );
     5
     6if ( file_exists( ABSPATH . 'wp-config.php') ) {
     7
     8        // The config file resides in ABSPATH
     9        require_once( ABSPATH . 'wp-config.php' );
     10
     11} elseif ( file_exists( dirname(ABSPATH) . '/wp-config.php' ) ) {
     12
     13        // The config file resides one level below ABSPATH
     14        require_once( dirname(ABSPATH) . '/wp-config.php' );
     15
     16} else {
     17
     18        // A config file doesn't exist
     19
     20        // Set a path for the link to the installer
     21        if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = '';
     22        else $path = 'wp-admin/';
     23
     24        // Die with an error message
     25        require_once( ABSPATH . '/wp-includes/classes.php' );
     26        require_once( ABSPATH . '/wp-includes/functions.php' );
     27        require_once( ABSPATH . '/wp-includes/plugin.php' );
     28        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");
     29
     30}
     31
     32?>
  • wp-app.php

     
    99
    1010define('APP_REQUEST', true);
    1111
    12 require_once('./wp-config.php');
     12require_once('./wp-load.php');
    1313require_once(ABSPATH . WPINC . '/post-template.php');
    1414require_once(ABSPATH . WPINC . '/atomlib.php');
    1515require_once(ABSPATH . WPINC . '/feed.php');
  • wp-includes/js/tinymce/tiny_mce_config.php

     
    44 * $Id: tiny_mce_gzip.php 315 2007-10-25 14:03:43Z spocke $
    55 *
    66 * @author Moxiecode
    7  * @copyright Copyright © 2005-2006, Moxiecode Systems AB, All rights reserved.
     7 * @copyright Copyright © 2005-2006, Moxiecode Systems AB, All rights reserved.
    88 *
    99 * This file compresses the TinyMCE JavaScript using GZip.
    1010 **/
     
    1212// Discard any buffers
    1313while ( @ob_end_clean() );
    1414
    15 @ require('../../../wp-config.php');
     15@ require('../../../wp-load.php');
    1616
    1717function getFileContents($path) {
    1818
  • wp-includes/js/tinymce/wp-mce-help.php

     
    1 <?php require_once('../../../wp-config.php');
     1<?php require_once('../../../wp-load.php');
    22header('Content-Type: text/html; charset=' . get_bloginfo('charset'));
    33?>
    44<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  • xmlrpc.php

     
    1515if ( isset($HTTP_RAW_POST_DATA) )
    1616        $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);
    1717
    18 include('./wp-config.php');
     18include('./wp-load.php');
    1919
    2020if ( isset( $_GET['rsd'] ) ) { // http://archipelago.phrasewise.com/rsd
    2121header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
  • wp-mail.php

     
    11<?php
    2 require(dirname(__FILE__) . '/wp-config.php');
     2require(dirname(__FILE__) . '/wp-load.php');
    33
    44require_once(ABSPATH.WPINC.'/class-pop3.php');
    55
  • wp-register.php

     
    33# This file is deprecated, but you shouldn't have been linking to it directly anyway :P
    44# Use wp_register() to create a registration link instead, it's much better ;)
    55
    6 require('./wp-config.php');
     6require('./wp-load.php');
    77wp_redirect('wp-login.php?action=register');
    88
    99?>
     10 No newline at end of file
  • wp-config-sample.php

     
    2323
    2424/* That's all, stop editing! Happy blogging. */
    2525
    26 define('ABSPATH', dirname(__FILE__).'/');
    27 require_once(ABSPATH.'wp-settings.php');
     26if ( !defined('ABSPATH') )
     27        define('ABSPATH', dirname(__FILE__) . '/');
     28require_once(ABSPATH . 'wp-settings.php');
    2829?>
  • wp-links-opml.php

     
    11<?php
    22
    33if (empty($wp)) {
    4         require_once('./wp-config.php');
     4        require_once('./wp-load.php');
    55        wp();
    66}
    77
  • wp-trackback.php

     
    11<?php
    22
    33if (empty($wp)) {
    4         require_once('./wp-config.php');
     4        require_once('./wp-load.php');
    55        wp('tb=1');
    66}
    77
  • wp-rss2.php

     
    11<?php
    22
    33if (empty($wp)) {
    4         require_once('./wp-config.php');
     4        require_once('./wp-load.php');
    55        wp('feed=rss2');
    66}
    77
  • wp-commentsrss2.php

     
    11<?php
    22
    33if (empty($wp)) {
    4         require_once('./wp-config.php');
     4        require_once('./wp-load.php');
    55        wp('feed=rss2&withcomments=1');
    66}
    77
  • wp-atom.php

     
    11<?php
    22
    33if (empty($wp)) {
    4         require_once('./wp-config.php');
     4        require_once('./wp-load.php');
    55        wp('feed=atom');
    66}
    77
  • wp-cron.php

     
    11<?php
    22ignore_user_abort(true);
    33define('DOING_CRON', TRUE);
    4 require_once('./wp-config.php');
     4require_once('./wp-load.php');
    55
    66if ( $_GET['check'] != wp_hash('187425') )
    77        exit;
  • wp-admin/update-links.php

     
    11<?php
    2 require_once('../wp-config.php');
     2require_once('../wp-load.php');
    33require_once( ABSPATH . 'wp-includes/class-snoopy.php');
    44
    55if ( !get_option('use_linksupdate') )
  • wp-admin/admin-ajax.php

     
    11<?php
    22define('DOING_AJAX', true);
    33
    4 require_once('../wp-config.php');
     4require_once('../wp-load.php');
    55require_once('includes/admin.php');
    66
    77if ( !is_user_logged_in() )
  • wp-admin/install-helper.php

     
    11<?php
    2 require_once(dirname(dirname(__FILE__)).'/wp-config.php');
     2$wp_only_load_config = true;
     3require_once(dirname(dirname(__FILE__)).'/wp-load.php');
    34$debug = 0;
    45
    56/**
  • wp-admin/admin.php

     
    22define('WP_ADMIN', TRUE);
    33
    44if ( defined('ABSPATH') )
    5         require_once( ABSPATH . 'wp-config.php');
     5        require_once(ABSPATH . 'wp-load.php');
    66else
    7     require_once('../wp-config.php');
     7        require_once('../wp-load.php');
    88
    99if ( get_option('db_version') != $wp_db_version ) {
    1010        wp_redirect(get_option('siteurl') . '/wp-admin/upgrade.php?_wp_http_referer=' . urlencode(stripslashes($_SERVER['REQUEST_URI'])));
  • wp-admin/async-upload.php

     
    55*/
    66
    77if ( defined('ABSPATH') )
    8         require_once( ABSPATH . 'wp-config.php');
     8        require_once(ABSPATH . 'wp-load.php');
    99else
    10     require_once('../wp-config.php');
     10        require_once('../wp-load.php');
    1111
    1212// Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead
    1313if ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
  • wp-admin/moderation.php

     
    11<?php
    2 require_once('../wp-config.php');
     2require_once('../wp-load.php');
    33wp_redirect('edit-comments.php?comment_status=moderated');
    44?>
  • wp-admin/upgrade.php

     
    11<?php
    22define('WP_INSTALLING', true);
    3 if (!file_exists('../wp-config.php'))
    4         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>");
    53
    6 require('../wp-config.php');
     4require('../wp-load.php');
    75timer_start();
    86require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    97
  • wp-admin/setup-config.php

     
    2020if (file_exists('../wp-config.php'))
    2121        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>");
    2222
     23// Check if wp-config.php exists above the root directory
     24if (file_exists('../../wp-config.php'))
     25        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>");
     26
    2327if (isset($_GET['step']))
    2428        $step = $_GET['step'];
    2529else
  • wp-admin/install.php

     
    11<?php
    22define('WP_INSTALLING', true);
    3 if (!file_exists('../wp-config.php')) {
    4   require_once('../wp-includes/compat.php');
    5   require_once('../wp-includes/functions.php');
    6   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");
    7 }
    83
    9 require_once('../wp-config.php');
     4require_once('../wp-load.php');
    105require_once('./includes/upgrade.php');
    116
    127if (isset($_GET['step']))
  • wp-admin/link-parse-opml.php

     
    11<?php
    2 require_once('../wp-config.php');
     2require_once('../wp-load.php');
    33
    44// columns we wish to find are:  link_url, link_name, link_target, link_description
    55// we need to map XML attribute names to our columns