Ticket #5586: 5586.4.diff
File 5586.4.diff, 5.1 KB (added by , 13 years ago) |
---|
-
wp-admin/includes/class-wp-filesystem-ftpext.php
85 85 } 86 86 87 87 function find_base_dir($base = '.',$echo = false){ 88 $abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths.. 89 if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter 90 if( preg_match("|.{1}\:(.+)|i", $abspath, $mat) ) 91 $abspath = $mat[1]; 92 } 93 88 94 if( empty( $base ) || '.' == $base ) $base = $this->cwd(); 89 95 if( empty( $base ) ) $base = '/'; 90 96 if( '/' != substr($base, -1) ) $base .= '/'; 91 97 92 if($echo) echo sprintf(__('Changing to %s'), $base).'<br>';93 if( false === ftp_chdir($this->link,$base) )98 if($echo) echo __('Changing to ') . $base .'<br>'; 99 if( false === $this->chdir($base) ) 94 100 return false; 95 101 96 102 if( $this->exists($base . 'wp-settings.php') ){ 97 if($echo) echo sprintf(__('Found %s'), $base . 'wp-settings.php') . '<br>';103 if($echo) echo __('Found ') . $base . 'wp-settings.php<br>'; 98 104 $this->wp_base = $base; 99 105 return $this->wp_base; 100 106 } 101 107 102 if( strpos( ABSPATH, $base) > 0)103 $arrPath = split('/',substr( ABSPATH,strpos(ABSPATH, $base)));108 if( strpos($abspath, $base) > 0) 109 $arrPath = split('/',substr($abspath,strpos($abspath, $base))); 104 110 else 105 $arrPath = split('/', ABSPATH);111 $arrPath = split('/',$abspath); 106 112 107 113 for($i = 0; $i <= count($arrPath); $i++) 108 114 if( $arrPath[ $i ] == '' ) unset( $arrPath[ $i ] ); 109 115 110 116 foreach($arrPath as $key=>$folder){ 111 117 if( $this->is_dir($base . $folder) ){ 112 if($echo) echo sprintf(__('Found %s'), $folder) . ' ' . sprintf(__('Changing to %s'), $base . $folder . '/') . '<br>';118 if($echo) echo __('Found ') . $folder . ' ' . __('Changing to') . ' ' . $base . $folder . '/<br>'; 113 119 return $this->find_base_dir($base . $folder . '/',$echo); 114 120 } 115 121 } … … 158 164 function cwd(){ 159 165 return ftp_pwd($this->link); 160 166 } 167 function chdir($dir){ 168 return @ftp_chdir($dir); 169 } 161 170 function chgrp($file,$group,$recursive=false){ 162 171 return false; 163 172 } … … 170 179 return false; 171 180 if ( ! $recursive || ! $this->is_dir($file) ){ 172 181 if (!function_exists('ftp_chmod')) 173 return ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));174 return ftp_chmod($this->link,$mode,$file);182 return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); 183 return @ftp_chmod($this->link,$mode,$file); 175 184 } 176 185 //Is a directory, and we want recursive 177 186 $filelist = $this->dirlist($file); … … 267 276 function copy($source,$destination,$overwrite=false){ 268 277 if( ! $overwrite && $this->exists($destination) ) 269 278 return false; 270 if ( !$content = $this->get_contents($source) ) 279 $content = $this->get_contents($source); 280 if( false === $content) 271 281 return false; 272 282 return $this->put_contents($destination,$content); 273 283 } -
wp-admin/includes/class-wp-filesystem-ftpsockets.php
87 87 } 88 88 89 89 function find_base_dir($base = '.',$echo = false) { 90 $abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths.. 91 if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter 92 if( preg_match("|.{1}\:(.+)|i", $abspath, $mat) ) 93 $abspath = $mat[1]; 94 } 95 90 96 if( empty( $base ) || '.' == $base ) $base = $this->cwd(); 91 97 if( empty( $base ) ) $base = '/'; 92 98 if( '/' != substr($base, -1) ) $base .= '/'; 93 99 94 100 if($echo) echo __('Changing to ') . $base .'<br>'; 95 if( false === $this-> ftp->chdir($base) )101 if( false === $this->chdir($base) ) 96 102 return false; 97 103 98 104 if( $this->exists($base . 'wp-settings.php') ){ … … 101 107 return $this->wp_base; 102 108 } 103 109 104 if( strpos( ABSPATH, $base) > 0)105 $arrPath = split('/',substr( ABSPATH,strpos(ABSPATH, $base)));110 if( strpos($abspath, $base) > 0) 111 $arrPath = split('/',substr($abspath,strpos($abspath, $base))); 106 112 else 107 $arrPath = split('/', ABSPATH);113 $arrPath = split('/',$abspath); 108 114 109 115 for($i = 0; $i <= count($arrPath); $i++) 110 116 if( $arrPath[ $i ] == '' ) unset( $arrPath[ $i ] ); … … 129 135 } 130 136 131 137 function get_contents($file,$type='',$resumepos=0){ 138 if( ! $this->exists($file) ) 139 return false; 140 132 141 if( empty($type) ){ 133 142 $extension = substr(strrchr($filename, "."), 1); 134 143 $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_AUTOASCII; … … 137 146 $temp = tmpfile(); 138 147 if ( ! $this->ftp->fget($temp, $file) ) { 139 148 fclose($temp); 140 return false;149 return ''; //Blank document, File does exist, Its just blank. 141 150 } 142 151 fseek($temp, 0); //Skip back to the start of the file being written to 143 152 $contents = ''; … … 287 296 return false; 288 297 289 298 $content = $this->get_contents($source); 290 if ( !$content )299 if ( false === $content ) 291 300 return false; 292 301 293 302 return $this->put_contents($destination,$content);