- Timestamp:
- 06/19/2020 10:34:26 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php
r47808 r48089 37 37 return; 38 38 } 39 39 40 $this->ftp = new ftp(); 40 41 … … 88 89 ) 89 90 ); 91 90 92 return false; 91 93 } … … 100 102 ) 101 103 ); 104 102 105 return false; 103 106 } … … 112 115 ) 113 116 ); 117 114 118 return false; 115 119 } … … 118 122 $this->ftp->Passive( true ); 119 123 $this->ftp->setTimeout( FS_TIMEOUT ); 124 120 125 return true; 121 126 } … … 135 140 } 136 141 137 $temp = wp_tempnam( $file );138 139 $temphandle = fopen( $temp, 'w+' ); 142 $tempfile = wp_tempnam( $file ); 143 $temphandle = fopen( $tempfile, 'w+' ); 144 140 145 if ( ! $temphandle ) { 141 unlink( $temp );146 unlink( $tempfile ); 142 147 return false; 143 148 } … … 147 152 if ( ! $this->ftp->fget( $temphandle, $file ) ) { 148 153 fclose( $temphandle ); 149 unlink( $temp );154 unlink( $tempfile ); 150 155 151 156 reset_mbstring_encoding(); … … 164 169 165 170 fclose( $temphandle ); 166 unlink( $temp ); 171 unlink( $tempfile ); 172 167 173 return $contents; 168 174 } … … 192 198 */ 193 199 public function put_contents( $file, $contents, $mode = false ) { 194 $temp = wp_tempnam( $file ); 195 $temphandle = @fopen( $temp, 'w+' ); 200 $tempfile = wp_tempnam( $file ); 201 $temphandle = @fopen( $tempfile, 'w+' ); 202 196 203 if ( ! $temphandle ) { 197 unlink( $temp );204 unlink( $tempfile ); 198 205 return false; 199 206 } … … 203 210 204 211 $bytes_written = fwrite( $temphandle, $contents ); 212 205 213 if ( false === $bytes_written || strlen( $contents ) != $bytes_written ) { 206 214 fclose( $temphandle ); 207 unlink( $temp );215 unlink( $tempfile ); 208 216 209 217 reset_mbstring_encoding(); … … 219 227 220 228 fclose( $temphandle ); 221 unlink( $temp );229 unlink( $tempfile ); 222 230 223 231 $this->chmod( $file, $mode ); … … 235 243 public function cwd() { 236 244 $cwd = $this->ftp->pwd(); 245 237 246 if ( $cwd ) { 238 247 $cwd = trailingslashit( $cwd ); 239 248 } 249 240 250 return $cwd; 241 251 } … … 279 289 if ( $recursive && $this->is_dir( $file ) ) { 280 290 $filelist = $this->dirlist( $file ); 291 281 292 foreach ( (array) $filelist as $filename => $filemeta ) { 282 293 $this->chmod( $file . '/' . $filename, $mode, $recursive ); … … 298 309 public function owner( $file ) { 299 310 $dir = $this->dirlist( $file ); 311 300 312 return $dir[ $file ]['owner']; 301 313 } … … 311 323 public function getchmod( $file ) { 312 324 $dir = $this->dirlist( $file ); 325 313 326 return $dir[ $file ]['permsn']; 314 327 } … … 324 337 public function group( $file ) { 325 338 $dir = $this->dirlist( $file ); 339 326 340 return $dir[ $file ]['group']; 327 341 } … … 346 360 347 361 $content = $this->get_contents( $source ); 362 348 363 if ( false === $content ) { 349 364 return false; … … 384 399 return false; 385 400 } 401 386 402 if ( 'f' === $type || $this->is_file( $file ) ) { 387 403 return $this->ftp->delete( $file ); 388 404 } 405 389 406 if ( ! $recursive ) { 390 407 return $this->ftp->rmdir( $file ); … … 425 442 return false; 426 443 } 444 427 445 if ( $this->exists( $file ) ) { 428 446 return true; 429 447 } 448 430 449 return false; 431 450 } … … 441 460 public function is_dir( $path ) { 442 461 $cwd = $this->cwd(); 462 443 463 if ( $this->chdir( $path ) ) { 444 464 $this->chdir( $cwd ); 445 465 return true; 446 466 } 467 447 468 return false; 448 469 } … … 542 563 public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) { 543 564 $path = untrailingslashit( $path ); 565 544 566 if ( empty( $path ) ) { 545 567 return false; … … 549 571 return false; 550 572 } 573 551 574 if ( ! $chmod ) { 552 575 $chmod = FS_CHMOD_DIR; 553 576 } 577 554 578 $this->chmod( $path, $chmod ); 579 555 580 return true; 556 581 } … … 606 631 607 632 $list = $this->ftp->dirlist( $path ); 633 608 634 if ( empty( $list ) && ! $this->exists( $path ) ) { 609 635 … … 614 640 615 641 $ret = array(); 642 616 643 foreach ( $list as $struc ) { 617 644
Note: See TracChangeset
for help on using the changeset viewer.