Changeset 8852 for trunk/wp-admin/includes/file.php
- Timestamp:
- 09/09/2008 03:24:05 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/file.php
r8811 r8852 387 387 return new WP_Error('empty_archive', __('Empty archive')); 388 388 389 $path = explode('/', $to); 390 for ( $i = count($path); $i > 0; $i-- ) { //>0 = first element is empty allways for paths starting with '/' 391 $tmppath = implode('/', array_slice($path, 0, $i) ); 392 if ( $fs->is_dir($tmppath) ) { //Found the highest folder that exists, Create from here(ie +1) 393 for ( $i = $i + 1; $i <= count($path); $i++ ) { 394 $tmppath = implode('/', array_slice($path, 0, $i) ); 395 if ( ! $fs->mkdir($tmppath, 0755) ) 396 return new WP_Error('mkdir_failed', __('Could not create directory'), $tmppath); 397 } 398 break; //Exit main for loop 399 } 400 } 401 389 402 $to = trailingslashit($to); 390 $path = explode('/', $to);391 $tmppath = '';392 for ( $j = 0; $j < count($path) - 1; $j++ ) {393 $tmppath .= $path[$j] . '/';394 if ( ! $fs->is_dir($tmppath) )395 $fs->mkdir($tmppath, 0755);396 }397 398 403 foreach ($archive_files as $file) { 399 404 $path = explode('/', $file['filename']); 400 $tmppath = ''; 401 402 // Loop through each of the items and check that the folder exists. 403 for ( $j = 0; $j < count($path) - 1; $j++ ) { 404 $tmppath .= $path[$j] . '/'; 405 if ( ! $fs->is_dir($to . $tmppath) ) 406 if ( !$fs->mkdir($to . $tmppath, 0755) ) 407 return new WP_Error('mkdir_failed', __('Could not create directory'), $to . $tmppath); 405 for ( $i = count($path) - 1; $i >= 0; $i-- ) { //>=0 as the first element contains data, count()-1, as we do not want the file component 406 $tmppath = $to . implode('/', array_slice($path, 0, $i) ); 407 if ( $fs->is_dir($tmppath) ) {//Found the highest folder that exists, Create from here 408 for ( $i = $i + 1; $i < count($path); $i++ ) { //< count() no file component please. 409 $tmppath = $to . implode('/', array_slice($path, 0, $i) ); 410 if ( ! $fs->mkdir($tmppath, 0755) ) 411 return new WP_Error('mkdir_failed', __('Could not create directory'), $tmppath); 412 } 413 break; //Exit main for loop 414 } 408 415 } 409 416 … … 415 422 } 416 423 } 417 418 424 return true; 419 425 } … … 454 460 return false; 455 461 456 $abstraction_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' .$method.'.php', $method);462 $abstraction_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method); 457 463 if( ! file_exists($abstraction_file) ) 458 464 return; … … 481 487 } 482 488 483 if ( isset($args['connection_type']) && 'ssh' == $args['connection_type'] ) { 484 $method = 'SSH2'; 485 return apply_filters('filesystem_method', $method); 486 } 487 489 if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') ) $method = 'ssh2'; 488 490 if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext'; 489 491 if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread … … 508 510 $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? $_POST['username'] : $credentials['username']); 509 511 $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? $_POST['password'] : $credentials['password']); 510 if ( defined('FTP_SSH') || 'ssh' == $_POST['connection_type'] ) 512 513 if ( strpos($credentials['hostname'], ':') ) 514 list( $credentials['hostname'], $credentials['port'] ) = explode(':', $credentials['hostname'], 2); 515 516 if ( defined('FTP_SSH') || (isset($_POST['connection_type']) && 'ssh' == $_POST['connection_type']) ) 511 517 $credentials['connection_type'] = 'ssh'; 512 else if ( defined('FTP_SSL') || 'ftps' == $_POST['connection_type'])518 else if ( defined('FTP_SSL') || (isset($_POST['connection_type']) && 'ftps' == $_POST['connection_type']) ) 513 519 $credentials['connection_type'] = 'ftps'; 514 520 else … … 524 530 $username = ''; 525 531 $password = ''; 526 $ ssl= '';532 $connection_type = ''; 527 533 if ( !empty($credentials) ) 528 534 extract($credentials, EXTR_OVERWRITE); … … 541 547 <tr valign="top"> 542 548 <th scope="row"><label for="hostname"><?php _e('Hostname') ?></label></th> 543 <td><input name="hostname" type="text" id="hostname" value="<?php echo attribute_escape($hostname) ?>"<?php if( defined('FTP_HOST') ) echo ' disabled="disabled"' ?> size="40" /></td>549 <td><input name="hostname" type="text" id="hostname" value="<?php echo attribute_escape($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php if( defined('FTP_HOST') ) echo ' disabled="disabled"' ?> size="40" /></td> 544 550 </tr> 545 551 <tr valign="top"> … … 557 563 <p><label><input name="connection_type" type="radio" value="ftp" <?php checked('ftp', $connection_type); ?> /> <?php _e('FTP') ?></label><br /> 558 564 <label><input name="connection_type" type="radio" value="ftps" <?php checked('ftps', $connection_type); ?> /> <?php _e('FTPS (SSL)') ?></label><br /> 559 < label><input name="connection_type" type="radio" value="ssh" <?php checked('ssh', $connection_type); ?> /> <?php _e('SSH') ?></label></p>565 <?php if ( extension_loaded('ssh2') ) { ?><label><input name="connection_type" type="radio" value="ssh" <?php checked('ssh', $connection_type); ?> /> <?php _e('SSH') ?></label><?php } ?></p> 560 566 </fieldset> 561 567 </td>
Note: See TracChangeset
for help on using the changeset viewer.