Changeset 25305
- Timestamp:
- 09/09/2013 02:54:50 AM (13 years ago)
- Location:
- trunk/src/wp-admin/includes
- Files:
-
- 4 edited
-
class-wp-filesystem-base.php (modified) (10 diffs)
-
class-wp-filesystem-direct.php (modified) (18 diffs)
-
class-wp-filesystem-ftpext.php (modified) (12 diffs)
-
class-wp-filesystem-ftpsockets.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-filesystem-base.php
r25082 r25305 21 21 */ 22 22 var $verbose = false; 23 23 24 /** 24 25 * Cached list of local filepaths to mapped remote filepaths. … … 48 49 function abspath() { 49 50 $folder = $this->find_folder(ABSPATH); 50 // Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare.51 // Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare. 51 52 if ( ! $folder && $this->is_dir('/wp-includes') ) 52 53 $folder = '/'; 53 54 return $folder; 54 55 } 56 55 57 /** 56 58 * Returns the path on the remote filesystem of WP_CONTENT_DIR … … 63 65 return $this->find_folder(WP_CONTENT_DIR); 64 66 } 67 65 68 /** 66 69 * Returns the path on the remote filesystem of WP_PLUGIN_DIR … … 74 77 return $this->find_folder(WP_PLUGIN_DIR); 75 78 } 79 76 80 /** 77 81 * Returns the path on the remote filesystem of the Themes Directory … … 92 96 return $this->find_folder( $theme_root ); 93 97 } 98 94 99 /** 95 100 * Returns the path on the remote filesystem of WP_LANG_DIR … … 122 127 return $this->abspath(); 123 128 } 129 124 130 /** 125 131 * Locates a folder on the remote filesystem. … … 189 195 } 190 196 } elseif ( 'direct' == $this->method ) { 191 $folder = str_replace('\\', '/', $folder); // Windows path sanitisation197 $folder = str_replace('\\', '/', $folder); // Windows path sanitisation 192 198 return trailingslashit($folder); 193 199 } 194 200 195 $folder = preg_replace('|^([a-z]{1}):|i', '', $folder); // Strip out windows drive letter if it's there.196 $folder = str_replace('\\', '/', $folder); // Windows path sanitisation201 $folder = preg_replace('|^([a-z]{1}):|i', '', $folder); // Strip out windows drive letter if it's there. 202 $folder = str_replace('\\', '/', $folder); // Windows path sanitisation 197 203 198 204 if ( isset($this->cache[ $folder ] ) ) 199 205 return $this->cache[ $folder ]; 200 206 201 if ( $this->exists($folder) ) { // Folder exists at that absolute path.207 if ( $this->exists($folder) ) { // Folder exists at that absolute path. 202 208 $folder = trailingslashit($folder); 203 209 $this->cache[ $folder ] = $folder; … … 240 246 foreach ( $folder_parts as $index => $key ) { 241 247 if ( $index == $last_index ) 242 continue; // We want this to be caught by the next code block.243 244 // Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder,248 continue; // We want this to be caught by the next code block. 249 250 // Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder, 245 251 // If it's found, change into it and follow through looking for it. 246 252 // If it cant find WordPress down that route, it'll continue onto the next folder level, and see if that matches, and so on. 247 253 // If it reaches the end, and still cant find it, it'll return false for the entire function. 248 254 if ( isset($files[ $key ]) ){ 249 // Lets try that folder:255 // Lets try that folder: 250 256 $newdir = trailingslashit(path_join($base, $key)); 251 257 if ( $this->verbose ) … … 258 264 } 259 265 260 // 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.266 // 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. 261 267 if (isset( $files[ $last_path ] ) ) { 262 268 if ( $this->verbose ) … … 373 379 */ 374 380 function is_binary( $text ) { 375 return (bool) preg_match( '|[^\x20-\x7E]|', $text); //chr(32)..chr(127)381 return (bool) preg_match( '|[^\x20-\x7E]|', $text ); // chr(32)..chr(127) 376 382 } 377 383 } -
trunk/src/wp-admin/includes/class-wp-filesystem-direct.php
r25304 r25305 26 26 $this->errors = new WP_Error(); 27 27 } 28 28 29 /** 29 30 * connect filesystem. … … 34 35 return true; 35 36 } 37 36 38 /** 37 39 * Reads entire file into a string … … 43 45 return @file_get_contents($file); 44 46 } 47 45 48 /** 46 49 * Reads entire file into an array … … 52 55 return @file($file); 53 56 } 57 54 58 /** 55 59 * Write a string to a file … … 76 80 return true; 77 81 } 82 78 83 /** 79 84 * Gets the current working directory … … 84 89 return @getcwd(); 85 90 } 91 86 92 /** 87 93 * Change directory … … 93 99 return @chdir($dir); 94 100 } 101 95 102 /** 96 103 * Changes file group … … 108 115 if ( ! $this->is_dir($file) ) 109 116 return @chgrp($file, $group); 110 // Is a directory, and we want recursive117 // Is a directory, and we want recursive 111 118 $file = trailingslashit($file); 112 119 $filelist = $this->dirlist($file); … … 116 123 return true; 117 124 } 125 118 126 /** 119 127 * Changes filesystem permissions … … 136 144 if ( ! $recursive || ! $this->is_dir($file) ) 137 145 return @chmod($file, $mode); 138 // Is a directory, and we want recursive146 // Is a directory, and we want recursive 139 147 $file = trailingslashit($file); 140 148 $filelist = $this->dirlist($file); … … 144 152 return true; 145 153 } 154 146 155 /** 147 156 * Changes file owner … … 159 168 if ( ! $this->is_dir($file) ) 160 169 return @chown($file, $owner); 161 // Is a directory, and we want recursive170 // Is a directory, and we want recursive 162 171 $filelist = $this->dirlist($file); 163 172 foreach ($filelist as $filename) { … … 166 175 return true; 167 176 } 177 168 178 /** 169 179 * Gets file owner … … 181 191 return $ownerarray['name']; 182 192 } 193 183 194 /** 184 195 * Gets file permissions … … 192 203 return substr(decoct(@fileperms($file)),3); 193 204 } 205 194 206 function group($file) { 195 207 $gid = @filegroup($file); … … 229 241 230 242 function delete($file, $recursive = false, $type = false) { 231 if ( empty( $file) ) //Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.232 return false; 233 $file = str_replace( '\\', '/', $file); //for win32, occasional problems deleting files otherwise243 if ( empty( $file ) ) // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem. 244 return false; 245 $file = str_replace( '\\', '/', $file ); // for win32, occasional problems deleting files otherwise 234 246 235 247 if ( 'f' == $type || $this->is_file($file) ) … … 238 250 return @rmdir($file); 239 251 240 // At this point it's a folder, and we're in recursive mode252 // At this point it's a folder, and we're in recursive mode 241 253 $file = trailingslashit($file); 242 254 $filelist = $this->dirlist($file, true); 243 255 244 256 $retval = true; 245 if ( is_array( $filelist) ) //false if no files, So check first.246 foreach ( $filelist as $filename => $fileinfo)257 if ( is_array( $filelist ) ) { 258 foreach ( $filelist as $filename => $fileinfo ) { 247 259 if ( ! $this->delete($file . $filename, $recursive, $fileinfo['type']) ) 248 260 $retval = false; 261 } 262 } 249 263 250 264 if ( file_exists($file) && ! @rmdir($file) ) 251 265 $retval = false; 266 252 267 return $retval; 253 268 } … … 280 295 return @filemtime($file); 281 296 } 297 282 298 function size($file) { 283 299 return @filesize($file); -
trunk/src/wp-admin/includes/class-wp-filesystem-ftpext.php
r25304 r25305 24 24 $this->errors = new WP_Error(); 25 25 26 // Check if possible to use ftp functions.26 // Check if possible to use ftp functions. 27 27 if ( ! extension_loaded('ftp') ) { 28 28 $this->errors->add('no_ftp_ext', __('The ftp PHP extension is not available')); … … 30 30 } 31 31 32 // Set defaults: 33 //This Class uses the timeout on a per-connection basis, Others use it on a per-action basis. 32 // This Class uses the timeout on a per-connection basis, Others use it on a per-action basis. 34 33 35 34 if ( ! defined('FS_TIMEOUT') ) … … 81 80 } 82 81 83 // Set the Connection to use Passive FTP82 // Set the Connection to use Passive FTP 84 83 @ftp_pasv( $this->link, true ); 85 84 if ( @ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT ) … … 99 98 return false; 100 99 101 fseek( $temp, 0); //Skip back to the start of the file being written to100 fseek( $temp, 0 ); // Skip back to the start of the file being written to 102 101 $contents = ''; 103 102 … … 109 108 return $contents; 110 109 } 110 111 111 function get_contents_array($file) { 112 112 return explode("\n", $this->get_contents($file)); … … 137 137 return $ret; 138 138 } 139 139 140 function cwd() { 140 141 $cwd = @ftp_pwd($this->link); … … 143 144 return $cwd; 144 145 } 146 145 147 function chdir($dir) { 146 148 return @ftp_chdir($this->link, $dir); 147 149 } 150 148 151 function chgrp($file, $group, $recursive = false ) { 149 152 return false; 150 153 } 154 151 155 function chmod($file, $mode = false, $recursive = false) { 152 156 if ( ! $mode ) { … … 171 175 return (bool)@ftp_chmod($this->link, $mode, $file); 172 176 } 177 173 178 function chown($file, $owner, $recursive = false ) { 174 179 return false; 175 180 } 181 176 182 function owner($file) { 177 183 $dir = $this->dirlist($file); 178 184 return $dir[$file]['owner']; 179 185 } 186 180 187 function getchmod($file) { 181 188 $dir = $this->dirlist($file); 182 189 return $dir[$file]['permsn']; 183 190 } 191 184 192 function group($file) { 185 193 $dir = $this->dirlist($file); 186 194 return $dir[$file]['group']; 187 195 } 196 188 197 function copy($source, $destination, $overwrite = false, $mode = false) { 189 198 if ( ! $overwrite && $this->exists($destination) ) … … 194 203 return $this->put_contents($destination, $content, $mode); 195 204 } 205 196 206 function move($source, $destination, $overwrite = false) { 197 207 return ftp_rename($this->link, $source, $destination); … … 217 227 return !empty($list); //empty list = no file, so invert. 218 228 } 229 219 230 function is_file($file) { 220 231 return $this->exists($file) && !$this->is_dir($file); 221 232 } 233 222 234 function is_dir($path) { 223 235 $cwd = $this->cwd(); … … 229 241 return false; 230 242 } 243 231 244 function is_readable($file) { 232 //Get dir list, Check if the file is readable by the current user??233 245 return true; 234 246 } 247 235 248 function is_writable($file) { 236 //Get dir list, Check if the file is writable by the current user??237 249 return true; 238 250 } 251 239 252 function atime($file) { 240 253 return false; 241 254 } 255 242 256 function mtime($file) { 243 257 return ftp_mdtm($this->link, $file); 244 258 } 259 245 260 function size($file) { 246 261 return ftp_size($this->link, $file); 247 262 } 263 248 264 function touch($file, $time = 0, $atime = 0) { 249 265 return false; 250 266 } 267 251 268 function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { 252 269 $path = untrailingslashit($path); … … 263 280 return true; 264 281 } 282 265 283 function rmdir($path, $recursive = false) { 266 284 return $this->delete($path, $recursive); -
trunk/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php
r25304 r25305 24 24 $this->errors = new WP_Error(); 25 25 26 // Check if possible to use ftp functions.26 // Check if possible to use ftp functions. 27 27 if ( ! @include_once ABSPATH . 'wp-admin/includes/class-ftp.php' ) 28 28 return false; 29 29 $this->ftp = new ftp(); 30 30 31 //Set defaults:32 31 if ( empty($opt['port']) ) 33 32 $this->options['port'] = 21; … … 94 93 fclose($temphandle); 95 94 unlink($temp); 96 return ''; // Blank document, File does exist, It's just blank.97 } 98 99 fseek( $temphandle, 0); //Skip back to the start of the file being written to95 return ''; // Blank document, File does exist, It's just blank. 96 } 97 98 fseek( $temphandle, 0 ); // Skip back to the start of the file being written to 100 99 $contents = ''; 101 100 … … 243 242 244 243 function is_readable($file) { 245 //Get dir list, Check if the file is writable by the current user??246 244 return true; 247 245 } 248 246 249 247 function is_writable($file) { 250 //Get dir list, Check if the file is writable by the current user??251 248 return true; 252 249 }
Note: See TracChangeset
for help on using the changeset viewer.