X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/449d082fcc4873c1f7d363a0d9f7409be7f6e77d..cd3609994b39a094ff7528b93f55631bb213fd7f:/wp-admin/includes/class-wp-filesystem-base.php diff --git a/wp-admin/includes/class-wp-filesystem-base.php b/wp-admin/includes/class-wp-filesystem-base.php index eefdd1c2..1f22f241 100644 --- a/wp-admin/includes/class-wp-filesystem-base.php +++ b/wp-admin/includes/class-wp-filesystem-base.php @@ -13,7 +13,7 @@ */ class WP_Filesystem_Base { /** - * Whether to display debug data for the connection or not. + * Whether to display debug data for the connection. * * @since 2.5 * @access public @@ -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 @@ -46,8 +46,6 @@ class WP_Filesystem_Base { * @return string The location of the remote path. */ function abspath() { - if ( defined('FTP_BASE') && strpos($this->method, 'ftp') !== false ) - return FTP_BASE; $folder = $this->find_folder(ABSPATH); //Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare. if ( ! $folder && $this->is_dir('/wp-includes') ) @@ -62,8 +60,6 @@ class WP_Filesystem_Base { * @return string The location of the remote path. */ function wp_content_dir() { - if ( defined('FTP_CONTENT_DIR') && strpos($this->method, 'ftp') !== false ) - return FTP_CONTENT_DIR; return $this->find_folder(WP_CONTENT_DIR); } /** @@ -75,8 +71,6 @@ class WP_Filesystem_Base { * @return string The location of the remote path. */ function wp_plugins_dir() { - if ( defined('FTP_PLUGIN_DIR') && strpos($this->method, 'ftp') !== false ) - return FTP_PLUGIN_DIR; return $this->find_folder(WP_PLUGIN_DIR); } /** @@ -88,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); } /** @@ -142,17 +147,28 @@ class WP_Filesystem_Base { */ function find_folder($folder) { - $folder = preg_replace('|^([a-z]{1}):|i', '', $folder); //Strip out windows driveletter if its there. - $folder = str_replace('\\', '/', $folder); //Windows path sanitiation + if ( strpos($this->method, 'ftp') !== false ) { + $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 sanitisation + return trailingslashit($folder); + } + + $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 ]; if ( $this->exists($folder) ) { //Folder exists at that absolute path. + $folder = trailingslashit($folder); $this->cache[ $folder ] = $folder; return $folder; } - if( $return = $this->search_for_folder($folder) ) + if ( $return = $this->search_for_folder($folder) ) $this->cache[ $folder ] = $return; return $return; } @@ -189,25 +205,25 @@ class WP_Filesystem_Base { // If its found, change into it and follow through looking for it. // If it cant find WordPress down that route, it'll continue onto the next folder level, and see if that matches, and so on. // If it reaches the end, and still cant find it, it'll return false for the entire function. - if( isset($files[ $key ]) ){ + if ( isset($files[ $key ]) ){ //Lets try that folder: $newdir = trailingslashit(path_join($base, $key)); - if( $this->verbose ) + if ( $this->verbose ) printf( __('Changing to %s') . '
', $newdir ); - if( $ret = $this->search_for_folder( $folder, $newdir, $loop) ) + if ( $ret = $this->search_for_folder( $folder, $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. - if(isset( $files[ $last_path ] ) ) { - if( $this->verbose ) + //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 $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. + if ( $loop ) + 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); } @@ -238,7 +254,7 @@ class WP_Filesystem_Base { $info = 'd'; elseif (($perms & 0x2000) == 0x2000) // Character special $info = 'c'; - elseif (($perms & 0x1000) == 0x1000)// FIFO pipe + elseif (($perms & 0x1000) == 0x1000) // FIFO pipe $info = 'p'; else // Unknown $info = 'u'; @@ -284,8 +300,8 @@ class WP_Filesystem_Base { $legal = array('', 'w', 'r', 'x', '-'); $attarray = preg_split('//', $mode); - for($i=0; $i < count($attarray); $i++) - if($key = array_search($attarray[$i], $legal)) + for ($i=0; $i < count($attarray); $i++) + if ($key = array_search($attarray[$i], $legal)) $realmode .= $legal[$key]; $mode = str_pad($realmode, 9, '-'); @@ -312,5 +328,3 @@ class WP_Filesystem_Base { return (bool) preg_match('|[^\x20-\x7E]|', $text); //chr(32)..chr(127) } } - -?>