Changeset 11005 for trunk/wp-admin/includes/class-wp-filesystem-ftpext.php
- Timestamp:
- 04/19/2009 07:36:28 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-filesystem-ftpext.php
r10930 r11005 18 18 var $link; 19 19 var $timeout = 5; 20 var $errors = array();20 var $errors = null; 21 21 var $options = array(); 22 22 … … 66 66 67 67 function connect() { 68 if ( $this->options['ssl'] && function_exists('ftp_ssl_connect') )68 if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') ) 69 69 $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'],$this->timeout); 70 70 else … … 188 188 } 189 189 190 function delete($file,$recursive=false) { 190 function delete($file, $recursive = false ) { 191 if ( empty($file) ) 192 return false; 191 193 if ( $this->is_file($file) ) 192 194 return @ftp_delete($this->link, $file); 193 195 if ( !$recursive ) 194 196 return @ftp_rmdir($this->link, $file); 195 $filelist = $this->dirlist($file); 196 foreach ((array) $filelist as $filename => $fileinfo) { 197 $this->delete($file . '/' . $filename, $recursive); 198 } 197 198 $filelist = $this->dirlist( trailingslashit($file) ); 199 if ( !empty($filelist) ) 200 foreach ( $filelist as $delete_file ) 201 $this->delete( trailingslashit($file) . $delete_file['name'], $recursive); 199 202 return @ftp_rmdir($this->link, $file); 200 203 } 201 204 202 205 function exists($file) { 203 $list = ftp_rawlist($this->link, $file, false); 204 if( ! $list ) 205 return false; 206 return count($list) == 1 ? true : false; 206 $list = @ftp_rawlist($this->link, $file, false); 207 return !empty($list); //empty list = no file, so invert. 207 208 } 208 209 function is_file($file) { 209 return $this-> is_dir($file) ? false : true;210 return $this->exists($file) && !$this->is_dir($file); 210 211 } 211 212 function is_dir($path) { 212 213 $cwd = $this->cwd(); 213 $result = @ftp_chdir($this->link, $path);214 $result = @ftp_chdir($this->link, trailingslashit($path) ); 214 215 if( $result && $path == $this->cwd() || $this->cwd() != $cwd ) { 215 216 @ftp_chdir($this->link, $cwd); … … 219 220 } 220 221 function is_readable($file) { 221 //Get dir list, Check if the file is writable by the current user??222 //Get dir list, Check if the file is readable by the current user?? 222 223 return true; 223 224 } … … 239 240 } 240 241 function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { 241 if( ! @ftp_mkdir($this->link, $path) )242 if( !ftp_mkdir($this->link, $path) ) 242 243 return false; 243 244 if( $chmod ) … … 250 251 } 251 252 function rmdir($path, $recursive = false) { 252 if( ! $recursive ) 253 return @ftp_rmdir($this->link, $path); 254 255 //TODO: Recursive Directory delete, Have to delete files from the folder first. 256 //$dir = $this->dirlist($path); 257 //foreach($dir as $file) 258 253 return $this->delete($path, $recursive); 259 254 } 260 255 261 256 function parselisting($line) { 262 $is_windows = ($this->OS_remote == FTP_OS_Windows); 257 static $is_windows; 258 if ( is_null($is_windows) ) 259 $is_windows = strpos( strtolower(ftp_systype($this->link)), 'win') !== false; 260 263 261 if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/", $line, $lucifer)) { 264 262 $b = array();
Note: See TracChangeset
for help on using the changeset viewer.