Changeset 9117 for trunk/wp-admin/includes/class-wp-filesystem-base.php
- Timestamp:
- 10/10/2008 10:02:46 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-filesystem-base.php
r8990 r9117 13 13 */ 14 14 class WP_Filesystem_Base { 15 /** 16 * Whether to display debug data for the connection or not. 17 * 18 * @since 2.5 19 * @access public 20 * @var bool 21 */ 15 22 var $verbose = false; 23 /** 24 * Cached list of local filepaths to maped remote filepaths. 25 * 26 * @since 2.7 27 * @access private 28 * @var array 29 */ 16 30 var $cache = array(); 17 31 32 /** 33 * The Access method of the current connection, Set automatically. 34 * 35 * @since 2.5 36 * @access public 37 * @var string 38 */ 18 39 var $method = ''; 19 40 41 /** 42 * Returns the path on the remote filesystem of ABSPATH 43 * 44 * @since 2.7 45 * @access public 46 * @return string The location of the remote path. 47 */ 20 48 function abspath() { 21 49 if ( defined('FTP_BASE') && strpos($this->method, 'ftp') !== false ) … … 23 51 return $this->find_folder(ABSPATH); 24 52 } 53 /** 54 * Returns the path on the remote filesystem of WP_CONTENT_DIR 55 * 56 * @since 2.7 57 * @access public 58 * @return string The location of the remote path. 59 */ 25 60 function wp_content_dir() { 26 61 if ( defined('FTP_CONTENT_DIR') && strpos($this->method, 'ftp') !== false ) … … 28 63 return $this->find_folder(WP_CONTENT_DIR); 29 64 } 65 /** 66 * Returns the path on the remote filesystem of WP_PLUGIN_DIR 67 * 68 * @since 2.7 69 * @access public 70 * 71 * @return string The location of the remote path. 72 */ 30 73 function wp_plugins_dir() { 31 74 if ( defined('FTP_PLUGIN_DIR') && strpos($this->method, 'ftp') !== false ) … … 33 76 return $this->find_folder(WP_PLUGIN_DIR); 34 77 } 78 /** 79 * Returns the path on the remote filesystem of the Themes Directory 80 * 81 * @since 2.7 82 * @access public 83 * 84 * @return string The location of the remote path. 85 */ 35 86 function wp_themes_dir() { 36 87 return $this->wp_content_dir() . '/themes'; 37 88 } 38 //Back compat: use abspath() or wp_*_dir 89 90 /** 91 * Locates a folder on the remote filesystem. 92 * 93 * Deprecated; use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead. 94 * 95 * @since 2.5 96 * @deprecated 2.7 97 * @access public 98 * 99 * @param string $base The folder to start searching from 100 * @param bool $echo True to display debug information 101 * @return string The location of the remote path. 102 */ 39 103 function find_base_dir($base = '.', $echo = false) { 104 _deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' ); 40 105 $this->verbose = $echo; 41 106 return $this->abspath(); 42 107 } 43 //Back compat: use ::abspath() or ::wp_*_dir 108 /** 109 * Locates a folder on the remote filesystem. 110 * 111 * Deprecated; use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead. 112 * 113 * @since 2.5 114 * @deprecated 2.7 115 * @access public 116 * 117 * @param string $base The folder to start searching from 118 * @param bool $echo True to display debug information 119 * @return string The location of the remote path. 120 */ 44 121 function get_base_dir($base = '.', $echo = false) { 122 _deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' ); 45 123 $this->verbose = $echo; 46 124 return $this->abspath(); 47 125 } 48 126 127 /** 128 * Locates a folder on the remote filesystem. 129 * 130 * Assumes that on Windows systems, Stripping off the Drive letter is OK 131 * Sanitizes \\ to / in windows filepaths. 132 * 133 * @since 2.7 134 * @access public 135 * 136 * @param string $folder the folder to locate 137 * @return string The location of the remote path. 138 */ 49 139 function find_folder($folder) { 50 $folder = str_replace('\\', '/', $folder); //Windows Sanitiation 140 141 $folder = preg_replace('|^([a-z]{1}):|i', '', $folder); //Strip out windows driveletter if its there. 142 $folder = str_replace('\\', '/', $folder); //Windows path sanitiation 143 51 144 if ( isset($this->cache[ $folder ] ) ) 52 145 return $this->cache[ $folder ]; … … 61 154 } 62 155 63 // Assumes $folder is windows sanitized; 64 // Assumes that the drive letter is safe to be stripped off, Should not be a problem for windows servers. 156 /** 157 * Locates a folder on the remote filesystem. 158 * 159 * Expects Windows sanitized path 160 * 161 * @since 2.7 162 * @access private 163 * 164 * @param string $folder the folder to locate 165 * @param string $base the folder to start searching from 166 * @param bool $loop if the function has recursed, Internal use only 167 * @return string The location of the remote path. 168 */ 65 169 function search_for_folder($folder, $base = '.', $loop = false ) { 66 170 if ( empty( $base ) || '.' == $base ) 67 171 $base = trailingslashit($this->cwd()); 68 172 69 $folder = preg_replace('|^([a-z]{1}):|i', '', $folder); //Strip out windows driveletter if its there.173 $folder = untrailingslashit($folder); 70 174 71 175 $folder_parts = explode('/', $folder); … … 105 209 } 106 210 107 //Common Helper functions. 211 /** 212 * Returns the *nix style file permissions for a file 213 * 214 * From the PHP documentation page for fileperms() 215 * 216 * @link http://docs.php.net/fileperms 217 * @since 2.5 218 * @access public 219 * 220 * @param string $file string filename 221 * @return int octal representation of permissions 222 */ 108 223 function gethchmod($file){ 109 //From the PHP.net page for ...?110 224 $perms = $this->getchmod($file); 111 225 if (($perms & 0xC000) == 0xC000) // Socket … … 148 262 return $info; 149 263 } 264 265 /** 266 * Converts *nix style file permissions to a octal number. 267 * 268 * Converts '-rw-r--r--' to 0644 269 * From "info at rvgate dot nl"'s comment on the PHP documentation for chmod() 270 * 271 * @link http://docs.php.net/manual/en/function.chmod.php#49614 272 * @since 2.5 273 * @access public 274 * 275 * @param string $mode string *nix style file permission 276 * @return int octal representation 277 */ 150 278 function getnumchmodfromh($mode) { 151 $realmode = "";152 $legal = array( "", "w", "r", "x", "-");153 $attarray = preg_split( "//", $mode);279 $realmode = ''; 280 $legal = array('', 'w', 'r', 'x', '-'); 281 $attarray = preg_split('//', $mode); 154 282 155 283 for($i=0; $i < count($attarray); $i++) … … 169 297 170 298 /** 171 * Determines if the string provided contains binary characters. 172 * 173 * @since 2.7 174 * @package WordPress 175 * @subpackage WP_Filesystem 176 * 177 * @param string $text String to test against 178 * 179 */ 299 * Determines if the string provided contains binary characters. 300 * 301 * @since 2.7 302 * @access private 303 * 304 * @param string $text String to test against 305 * @return bool true if string is binary, false otherwise 306 */ 180 307 function is_binary( $text ) { 181 308 return (bool) preg_match('|[^\x20-\x7E]|', $text); //chr(32)..chr(127)
Note: See TracChangeset
for help on using the changeset viewer.