Changeset 8540 for trunk/wp-admin/includes/file.php
- Timestamp:
- 08/04/2008 09:01:09 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/file.php
r8192 r8540 459 459 } 460 460 461 function request_filesystem_credentials($form_post, $type = '', $error = false) { 462 $req_cred = apply_filters('request_filesystem_credentials', '', $form_post, $type, $error); 463 if ( '' !== $req_cred ) 464 return $req_cred; 465 466 if ( empty($type) ) 467 $type = get_filesystem_method(); 468 469 if ( 'direct' == $type ) 470 return true; 471 472 if( ! $credentials = get_option('ftp_credentials') ) 473 $credentials = array(); 474 // If defined, set it to that, Else, If POST'd, set it to that, If not, Set it to whatever it previously was(saved details in option) 475 $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? $_POST['hostname'] : $credentials['hostname']); 476 $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? $_POST['username'] : $credentials['username']); 477 $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? $_POST['password'] : $credentials['password']); 478 $credentials['ssl'] = defined('FTP_SSL') ? FTP_SSL : ( isset($_POST['ssl']) ? $_POST['ssl'] : $credentials['ssl']); 479 480 if ( ! $error && !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) { 481 $stored_credentials = $credentials; 482 unset($stored_credentials['password']); 483 update_option('ftp_credentials', $stored_credentials); 484 return $credentials; 485 } 486 $hostname = ''; 487 $username = ''; 488 $password = ''; 489 $ssl = ''; 490 if ( !empty($credentials) ) 491 extract($credentials, EXTR_OVERWRITE); 492 if( $error ) 493 echo '<div id="message" class="error"><p>' . __('<strong>Error:</strong> There was an error connecting to the server, Please verify the settings are correct.') . '</p></div>'; 461 494 ?> 495 <form action="<?php echo $form_post ?>" method="post"> 496 <div class="wrap"> 497 <h2><?php _e('FTP Connection Information') ?></h2> 498 <p><?php _e('To perform the requested action, FTP connection information is required.') ?></p> 499 <table class="form-table"> 500 <tr valign="top"> 501 <th scope="row"><label for="hostname"><?php _e('Hostname:') ?></label></th> 502 <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> 503 </tr> 504 <tr valign="top"> 505 <th scope="row"><label for="username"><?php _e('Username:') ?></label></th> 506 <td><input name="username" type="text" id="username" value="<?php echo attribute_escape($username) ?>"<?php if( defined('FTP_USER') ) echo ' disabled="disabled"' ?> size="40" /></td> 507 </tr> 508 <tr valign="top"> 509 <th scope="row"><label for="password"><?php _e('Password:') ?></label></th> 510 <td><input name="password" type="password" id="password" value=""<?php if( defined('FTP_PASS') ) echo ' disabled="disabled"' ?> size="40" /><?php if( defined('FTP_PASS') && !empty($password) ) echo '<em>'.__('(Password not shown)').'</em>'; ?></td> 511 </tr> 512 <tr valign="top"> 513 <th scope="row"><label for="ssl"><?php _e('Use SSL:') ?></label></th> 514 <td> 515 <select name="ssl" id="ssl"<?php if( defined('FTP_SSL') ) echo ' disabled="disabled"' ?>> 516 <?php 517 foreach ( array(0 => __('No'), 1 => __('Yes')) as $key => $value ) : 518 $selected = ($ssl == $value) ? 'selected="selected"' : ''; 519 echo "\n\t<option value='$key' $selected>" . $value . '</option>'; 520 endforeach; 521 ?> 522 </select> 523 </td> 524 </tr> 525 </table> 526 <p class="submit"> 527 <input type="submit" name="submit" value="<?php _e('Proceed'); ?>" /> 528 </p> 529 </div> 530 </form> 531 <?php 532 return false; 533 } 534 535 ?>
Note: See TracChangeset
for help on using the changeset viewer.