X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/4f9d63e13cd8c6e275797c75b401b074b82937bc..5964d2279dc52bdfe105f9bfa17e04337d47a3fa:/wp-admin/includes/class-wp-filesystem-base.php?ds=inline
diff --git a/wp-admin/includes/class-wp-filesystem-base.php b/wp-admin/includes/class-wp-filesystem-base.php
index 0aaadeba..75808df8 100644
--- a/wp-admin/includes/class-wp-filesystem-base.php
+++ b/wp-admin/includes/class-wp-filesystem-base.php
@@ -21,7 +21,7 @@ class WP_Filesystem_Base {
*/
var $verbose = false;
/**
- * Cached list of local filepaths to maped remote filepaths.
+ * Cached list of local filepaths to mapped remote filepaths.
*
* @since 2.7
* @access private
@@ -82,7 +82,18 @@ class WP_Filesystem_Base {
* @return string The location of the remote path.
*/
function wp_themes_dir() {
- return $this->wp_content_dir() . '/themes';
+ return $this->wp_content_dir() . 'themes/';
+ }
+ /**
+ * Returns the path on the remote filesystem of WP_LANG_DIR
+ *
+ * @since 3.2.0
+ * @access public
+ *
+ * @return string The location of the remote path.
+ */
+ function wp_lang_dir() {
+ return $this->find_folder(WP_LANG_DIR);
}
/**
@@ -137,17 +148,17 @@ class WP_Filesystem_Base {
function find_folder($folder) {
if ( strpos($this->method, 'ftp') !== false ) {
- $constant_overrides = array( 'FTP_BASE' => ABSPATH, 'FTP_CONTENT_DIR' => WP_CONTENT_DIR, 'FTP_PLUGIN_DIR' => WP_PLUGIN_DIR );
+ $constant_overrides = array( 'FTP_BASE' => ABSPATH, 'FTP_CONTENT_DIR' => WP_CONTENT_DIR, 'FTP_PLUGIN_DIR' => WP_PLUGIN_DIR, 'FTP_LANG_DIR' => WP_LANG_DIR );
foreach ( $constant_overrides as $constant => $dir )
if ( defined($constant) && $folder === $dir )
return trailingslashit(constant($constant));
} elseif ( 'direct' == $this->method ) {
- $folder = str_replace('\\', '/', $folder); //Windows path sanitiation
+ $folder = str_replace('\\', '/', $folder); //Windows path sanitisation
return trailingslashit($folder);
}
- $folder = preg_replace('|^([a-z]{1}):|i', '', $folder); //Strip out windows driveletter if its there.
- $folder = str_replace('\\', '/', $folder); //Windows path sanitiation
+ $folder = preg_replace('|^([a-z]{1}):|i', '', $folder); //Strip out windows drive letter if it's there.
+ $folder = str_replace('\\', '/', $folder); //Windows path sanitisation
if ( isset($this->cache[ $folder ] ) )
return $this->cache[ $folder ];
@@ -182,12 +193,13 @@ class WP_Filesystem_Base {
$folder = untrailingslashit($folder);
$folder_parts = explode('/', $folder);
- $last_path = $folder_parts[ count($folder_parts) - 1 ];
+ $last_index = array_pop( array_keys( $folder_parts ) );
+ $last_path = $folder_parts[ $last_index ];
$files = $this->dirlist( $base );
- foreach ( $folder_parts as $key ) {
- if ( $key == $last_path )
+ foreach ( $folder_parts as $index => $key ) {
+ if ( $index == $last_index )
continue; //We want this to be caught by the next code block.
//Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder,
@@ -199,20 +211,22 @@ class WP_Filesystem_Base {
$newdir = trailingslashit(path_join($base, $key));
if ( $this->verbose )
printf( __('Changing to %s') . '
', $newdir );
- if ( $ret = $this->search_for_folder( $folder, $newdir, $loop) )
+ // only search for the remaining path tokens in the directory, not the full path again
+ $newfolder = implode( '/', array_slice( $folder_parts, $index + 1 ) );
+ if ( $ret = $this->search_for_folder( $newfolder, $newdir, $loop) )
return $ret;
}
}
- //Only check this as a last resort, to prevent locating the incorrect install. All above proceeedures will fail quickly if this is the right branch to take.
+ //Only check this as a last resort, to prevent locating the incorrect install. All above procedures will fail quickly if this is the right branch to take.
if (isset( $files[ $last_path ] ) ) {
if ( $this->verbose )
printf( __('Found %s') . '
', $base . $last_path );
return trailingslashit($base . $last_path);
}
if ( $loop )
- return false; //Prevent tihs function looping again.
- //As an extra last resort, Change back to / if the folder wasnt found. This comes into effect when the CWD is /home/user/ but WP is at /var/www/.... mainly dedicated setups.
+ return false; //Prevent this function from looping again.
+ //As an extra last resort, Change back to / if the folder wasn't found. This comes into effect when the CWD is /home/user/ but WP is at /var/www/.... mainly dedicated setups.
return $this->search_for_folder($folder, '/', true);
}
@@ -293,14 +307,14 @@ class WP_Filesystem_Base {
if ($key = array_search($attarray[$i], $legal))
$realmode .= $legal[$key];
- $mode = str_pad($realmode, 9, '-');
+ $mode = str_pad($realmode, 10, '-', STR_PAD_LEFT);
$trans = array('-'=>'0', 'r'=>'4', 'w'=>'2', 'x'=>'1');
$mode = strtr($mode,$trans);
- $newmode = '';
- $newmode .= $mode[0] + $mode[1] + $mode[2];
- $newmode .= $mode[3] + $mode[4] + $mode[5];
- $newmode .= $mode[6] + $mode[7] + $mode[8];
+ $newmode = $mode[0];
+ $newmode .= $mode[1] + $mode[2] + $mode[3];
+ $newmode .= $mode[4] + $mode[5] + $mode[6];
+ $newmode .= $mode[7] + $mode[8] + $mode[9];
return $newmode;
}
@@ -317,5 +331,3 @@ class WP_Filesystem_Base {
return (bool) preg_match('|[^\x20-\x7E]|', $text); //chr(32)..chr(127)
}
}
-
-?>