Ticket #8210: 8210.diff
| File 8210.diff, 4.6 KB (added by , 17 years ago) |
|---|
-
wp-admin/includes/class-wp-filesystem-ssh2.php
141 141 142 142 function run_command($link, $command, $returnbool = false) { 143 143 $this->debug("run_command();"); 144 if(!($stream = @ssh2_exec( $link, $command . "; echo \"__COMMAND_FINISHED__\";"))) {144 if(!($stream = @ssh2_exec( $link, $command . '; echo "__COMMAND_FINISHED__";'))) { 145 145 $this->errors->add('command', sprintf(__('Unable to perform command: %s'), $command)); 146 146 } else { 147 147 stream_set_blocking( $stream, true ); 148 148 $time_start = time(); 149 149 $data = null; 150 150 while( true ) { 151 if (strpos($data, "__COMMAND_FINISHED__") !== false){151 if (strpos($data,'__COMMAND_FINISHED__') !== false){ 152 152 break; // the command has finshed! 153 153 } 154 154 if( (time()-$time_start) > $this->timeout ){ … … 189 189 190 190 function get_contents($file, $type = '', $resumepos = 0 ) { 191 191 $this->debug("get_contents();"); 192 193 if ( true ) { 194 $handle = @fopen('ssh2.sftp://' . $this->link . $file, 'rb'); 195 if ( ! $handle ) 196 return false; 197 $content = ''; 198 while ( ! @feof($handle) ) 199 $contents .= fread($handle, 8092); 200 fclose($handle); 201 return $contents; 202 } 203 192 204 $tempfile = wp_tempnam( $file ); 193 205 if ( ! $tempfile ) 194 206 return false; … … 206 218 207 219 function put_contents($file, $contents, $type = '' ) { 208 220 $this->debug("put_contents($file);"); 221 222 if ( true ) { 223 $handle = @fopen('ssh2.sftp://' . $this->link . $file, 'w'); 224 if ( ! $handle || ! @fwrite($handle, $contents) ) 225 return false; 226 fclose($handle); 227 return true; 228 } 229 209 230 $tempfile = wp_tempnam( $file ); 210 231 $temp = fopen($tempfile, 'w'); 211 232 if ( ! $temp ) … … 235 256 if ( ! $this->exists($file) ) 236 257 return false; 237 258 if ( ! $recursive || ! $this->is_dir($file) ) 238 return $this->run_command($this->link, sprintf('chgrp %o %s', $mode, $file), true);239 return $this->run_command($this->link, sprintf('chgrp -R %o %s', $mode, $file), true);259 return $this->run_command($this->link, sprintf('chgrp %o "%s"', $mode, $file), true); 260 return $this->run_command($this->link, sprintf('chgrp -R %o "%s"', $mode, $file), true); 240 261 } 241 262 242 263 function chmod($file, $mode = false, $recursive = false) { … … 248 269 if ( ! $this->exists($file) ) 249 270 return false; 250 271 if ( ! $recursive || ! $this->is_dir($file) ) 251 return $this->run_command($this->link, sprintf('chmod %o %s', $mode, $file), true);252 return $this->run_command($this->link, sprintf('chmod -R %o %s', $mode, $file), true);272 return $this->run_command($this->link, sprintf('chmod %o "%s"', $mode, $file), true); 273 return $this->run_command($this->link, sprintf('chmod -R %o "%s"', $mode, $file), true); 253 274 } 254 275 255 276 function chown($file, $owner, $recursive = false ) { … … 257 278 if ( ! $this->exists($file) ) 258 279 return false; 259 280 if ( ! $recursive || ! $this->is_dir($file) ) 260 return $this->run_command($this->link, sprintf('chown %o %s', $mode, $file), true);261 return $this->run_command($this->link, sprintf('chown -R %o %s', $mode, $file), true);281 return $this->run_command($this->link, sprintf('chown %o "%s"', $mode, $file), true); 282 return $this->run_command($this->link, sprintf('chown -R %o "%s"', $mode, $file), true); 262 283 } 263 284 264 285 function owner($file) { … … 311 332 312 333 function exists($file) { 313 334 $this->debug("exists();"); 314 $list = $this->run_command($this->link, sprintf('ls -lad %s', $file));335 $list = $this->run_command($this->link, sprintf('ls -lad "%s"', $file)); 315 336 return (bool) $list; 316 337 } 317 338 318 339 function is_file($file) { 319 340 $this->debug("is_file();"); 320 341 //DO NOT RELY ON dirlist()! 321 $list = $this->run_command($this->link, sprintf('ls -lad %s', $file));342 $list = $this->run_command($this->link, sprintf('ls -lad "%s"', $file)); 322 343 $list = $this->parselisting($list); 323 344 if ( ! $list ) 324 345 return false; … … 329 350 function is_dir($path) { 330 351 $this->debug("is_dir();"); 331 352 //DO NOT RELY ON dirlist()! 332 $list = $this->parselisting($this->run_command($this->link, sprintf('ls -lad %s', untrailingslashit($path))));353 $list = $this->parselisting($this->run_command($this->link, sprintf('ls -lad "%s"', untrailingslashit($path)))); 333 354 if ( ! $list ) 334 355 return false; 335 356 else … … 449 470 $limitFile = false; 450 471 } 451 472 452 $list = $this->run_command($this->link, sprintf('ls -la %s', $path));473 $list = $this->run_command($this->link, sprintf('ls -la "%s"', $path)); 453 474 454 475 if ( $list === false ) 455 476 return false;