Eliminate use of DOCUMENT_ROOT. Look for .htaccess in 'home'.

git-svn-id: https://develop.svn.wordpress.org/trunk@1567 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2004-08-27 05:20:59 +00:00
parent 44e22a498a
commit 0db135005b
2 changed files with 21 additions and 6 deletions

View File

@ -20,6 +20,16 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
}
}
$home = get_settings('home');
if ($home != '' && $home != get_settings('siteurl')) {
$home_path = parse_url($home);
$home_path = $home_root['path'];
$root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["PATH_TRANSLATED"]);
$home_path = $root . $home_path . "/";
} else {
$home_path = ABSPATH;
}
require_once('./optionhandler.php');
if (isset($_POST['submit'])) {
@ -47,7 +57,7 @@ if (isset($_POST['submit'])) {
<?php if(isset($_POST['rules'])) {
$rules = explode("\n", $_POST['rules']);
if(insert_with_markers(ABSPATH.'.htaccess', 'WordPress', $rules)) {
if(insert_with_markers($home_path.'.htaccess', 'WordPress', $rules)) {
?>
<div class="updated" id="htupdate"><p><?php _e('mod_rewrite rules written to .htaccess.'); ?></p></div>
<?php
@ -136,7 +146,8 @@ if (isset($_POST['submit'])) {
</textarea>
</p>
<?php
if ((! file_exists(ABSPATH.'.htaccess') && is_writable(ABSPATH)) || is_writable(ABSPATH.'.htaccess')) {
if ((! file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess')) {
?>
<p class="submit">
<input type="submit" name="writerules" value="<?php _e('Write mod_rewrite rules to .htaccess &raquo;') ?>">

View File

@ -97,10 +97,14 @@ update_option('recently_edited', array(1, 2, 3) );
}
$home = get_settings('home');
if ($home != '' && ('index.php' == $file || get_settings('blogfilename') == $file)) {
$home_root = str_replace('http://', '', $home);
$home_root = preg_replace('|([^/]*)(.*)|i', '$2', $home_root);
$real_file = $_SERVER['DOCUMENT_ROOT'] . $home_root . '/' . $file;
if (($home != '' && $home != get_settings('siteurl')) &&
('index.php' == $file || get_settings('blogfilename') == $file ||
'.htaccess' == $file)) {
$home_root = parse_url($home);
$home_root = $home_root['path'];
$root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["PATH_TRANSLATED"]);
$home_root = $root . $home_root;
$real_file = $home_root . '/' . $file;
} else {
$file = validate_file($file);
$real_file = '../' . $file;