From 0b79658085205ca94d15e40d268a3e07e9ed7ab5 Mon Sep 17 00:00:00 2001 From: rboren Date: Thu, 23 Dec 2004 00:53:56 +0000 Subject: [PATCH] Use SCRIPT_FILENAME instead of PATH_TRANSLATED since PATH_TRANSLATED is not always set. Consolidate home path logic into get_home_path(). git-svn-id: http://svn.automattic.com/wordpress/trunk@1995 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-functions.php | 37 +++++++++++++++++----------------- wp-admin/options-permalink.php | 10 +-------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 0bc772020..926cfb6ec 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -495,15 +495,7 @@ function extract_from_markers($filename, $marker) { function save_mod_rewrite_rules() { global $is_apache, $wp_rewrite; - $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; - } + $home_path = get_home_path(); if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') ) $writable = true; @@ -787,17 +779,24 @@ function validate_file_to_edit($file, $allowed_files = '') { return $file; } -function get_real_file_to_edit($file) { +function get_home_path() { $home = get_settings('home'); - 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; + if ( $home != '' && $home != get_settings('siteurl') ) { + $home_path = parse_url($home); + $home_path = $home_root['path']; + $root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["SCRIPT_FILENAME"]); + $home_path = $root . $home_path . "/"; + } else { + $home_path = ABSPATH; + } + + return $home_path; +} + +function get_real_file_to_edit($file) { + if ('index.php' == $file || get_settings('blogfilename') == $file || + '.htaccess' == $file) { + $real_file = get_home_path() . $file; } else { $real_file = ABSPATH . $file; } diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php index 335ca7a47..70e8fe93b 100644 --- a/wp-admin/options-permalink.php +++ b/wp-admin/options-permalink.php @@ -6,15 +6,7 @@ $parent_file = 'options-general.php'; include('admin-header.php'); -$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; -} +$home_path = get_home_path(); if ( isset($_POST) ) { if ( isset($_POST['permalink_structure']) ) {