- Timestamp:
- 02/11/2008 08:46:11 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php
r6779 r6785 24 24 ); 25 25 26 function WP_Filesystem_ftpsockets($opt='') {26 function WP_Filesystem_ftpsockets($opt='') { 27 27 //Check if possible to use ftp functions. 28 28 if( ! @include_once ABSPATH . 'wp-admin/includes/class-ftp.php' ) 29 29 return false; 30 30 $this->ftp = new FTP(); 31 31 32 //Set defaults: 32 if ( ! isset($opt['port']) ||empty($opt['port']) )33 if ( empty($opt['port']) ) 33 34 $this->options['port'] = 21; 34 35 else 35 36 $this->options['port'] = $opt['port']; 36 37 37 if ( ! isset($opt['hostname']) ||empty($opt['hostname']) )38 $this->errors ['require']['hostname'] = __('Hostname');38 if ( empty($opt['hostname']) ) 39 $this->errors->add('empty_hostname', __('FTP hostname is required')); 39 40 else 40 41 $this->options['hostname'] = $opt['hostname']; 41 42 42 if ( isset($opt['base']) && ! empty($opt['base']) )43 if ( isset($opt['base']) && ! empty($opt['base']) ) 43 44 $this->wp_base = $opt['base']; 44 45 45 // Check if the options provided are OK.46 if ( ! isset($opt['username']) ||empty ($opt['username']) )47 $this->errors ['require']['username'] = __('Username');46 // Check if the options provided are OK. 47 if ( empty ($opt['username']) ) 48 $this->errors->add('empty_username', __('FTP username is required')); 48 49 else 49 50 $this->options['username'] = $opt['username']; 50 51 51 if ( ! isset($opt['password']) ||empty ($opt['password']) )52 $this->errors ['require']['password'] = __('Password');52 if ( empty ($opt['password']) ) 53 $this->errors->add('empty_password', __('FTP password is required')); 53 54 else 54 55 $this->options['password'] = $opt['password']; 55 56 } 56 function connect(){ 57 if( ! $this->ftp ) 57 58 function connect() { 59 if ( ! $this->ftp ) 58 60 return false; 59 61 60 if( ! $this->ftp->connect($this->options['hostname'], $this->options['port'], $this->timeout) ){ 61 $this->errors['server'] = __('Failed to connect to FTP Server') . ' ' . $this->options['hostname'] . ':' . $this->options['port']; 62 return false; 63 } 64 if( ! $this->ftp->login($this->options['username'], $this->options['password']) ){ 65 $this->errors['auth'] = __('Username/Password incorrect') . ' ' . 66 $this->options['username'] . ':********@' .$this->options['hostname'] . ':' . $this->options['port']; 67 return false; 68 } 69 return true; 70 } 71 function setDefaultPermissions($perm){ 62 if ( ! $this->ftp->connect($this->options['hostname'], $this->options['port'], $this->timeout) ) { 63 $this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port'])); 64 return false; 65 } 66 67 if ( ! $this->ftp->login($this->options['username'], $this->options['password']) ) { 68 $this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username'])); 69 return false; 70 } 71 72 return true; 73 } 74 75 function setDefaultPermissions($perm) { 72 76 $this->permission = $perm; 73 77 } 74 function find_base_dir($base = '.',$echo = false){ 78 79 function find_base_dir($base = '.',$echo = false) { 75 80 if( empty( $base ) || '.' == $base ) $base = $this->cwd(); 76 81 if( empty( $base ) ) $base = '/'; … … 254 259 return $this->ftp->rename($source,$destination); 255 260 } 256 function delete($file,$recursive=false){ 257 if( $this->is_file($file) ) 261 262 function delete($file,$recursive=false) { 263 if ( $this->is_file($file) ) 258 264 return $this->ftp->delete($file); 259 if ( !$recursive )265 if ( !$recursive ) 260 266 return $this->ftp->rmdir($file); 261 267 $filelist = $this->dirlist($file); 262 foreach ($filelist as $filename){268 foreach ($filelist as $filename) { 263 269 $this->delete($file.'/'.$filename,$recursive); 264 270 } 265 } 271 return $this->ftp->rmdir($file); 272 } 273 266 274 function exists($file){ 267 275 return $this->ftp->is_exists($file);
Note: See TracChangeset
for help on using the changeset viewer.