Changeset 7238
- Timestamp:
- 03/11/2008 04:37:44 PM (17 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-filesystem-direct.php
r7155 r7238 272 272 if ( '/' == substr($filename,-1,1) ) 273 273 $this->rmdir($path.'/'.$filename,$recursive); 274 @rmdir($ entry);274 @rmdir($filename); 275 275 } 276 276 return @rmdir($path); -
trunk/wp-admin/includes/class-wp-filesystem-ftpext.php
r7164 r7238 133 133 function get_contents($file,$type='',$resumepos=0){ 134 134 if( empty($type) ){ 135 $extension = substr(strrchr($file name, "."), 1);135 $extension = substr(strrchr($file, "."), 1); 136 136 $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII; 137 137 } … … 349 349 function rmdir($path,$recursive=false){ 350 350 if( ! $recursive ) 351 return @ftp_rmdir($this->link, $ file);351 return @ftp_rmdir($this->link, $path); 352 352 353 353 //TODO: Recursive Directory delete, Have to delete files from the folder first. -
trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php
r7171 r7238 140 140 141 141 if( empty($type) ){ 142 $extension = substr(strrchr($file name, "."), 1);142 $extension = substr(strrchr($file, "."), 1); 143 143 $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_AUTOASCII; 144 144 } … … 377 377 function rmdir($path,$recursive=false){ 378 378 if( ! $recursive ) 379 return $this->ftp->rmdir($ file);379 return $this->ftp->rmdir($path); 380 380 381 381 return $this->ftp->mdel($path); -
trunk/wp-admin/includes/file.php
r7172 r7238 232 232 // Is the archive valid? 233 233 if ( false == ($archive_files = $archive->extract(PCLZIP_OPT_EXTRACT_AS_STRING)) ) 234 return new WP_Error('incompatible_archive', __('Incompatible archive'), $archive->error _string);234 return new WP_Error('incompatible_archive', __('Incompatible archive'), $archive->errorInfo(true)); 235 235 236 236 if ( 0 == count($archive_files) ) … … 241 241 $tmppath = ''; 242 242 for ( $j = 0; $j < count($path) - 1; $j++ ) { 243 $prevpath = $tmppath;244 243 $tmppath .= $path[$j] . '/'; 245 if ( ! $fs->is_dir($tmppath) ) { 246 //$fs->setDefaultPermissions( $fs->getchmod($tmppath) ); 244 if ( ! $fs->is_dir($tmppath) ) 247 245 $fs->mkdir($tmppath, 0755); 248 }249 246 } 250 247 -
trunk/wp-admin/includes/update.php
r7237 r7238 128 128 129 129 echo "<tr><td colspan='5' class='plugin-update'>"; 130 printf( __('There is a new version of %1$s available. <a href="%2$s">Download version %3$s here</a> or <a href="%4$s">upgrade automatically</a>.'), $plugin_data['Name'], $r->url, $r->new_version, "update.php?action=upgrade-plugin&plugin=$file");130 printf( __('There is a new version of %1$s available. <a href="%2$s">Download version %3$s here</a> or <a href="%4$s">upgrade automatically</a>.'), $plugin_data['Name'], $r->url, $r->new_version, wp_nonce_url("update.php?action=upgrade-plugin&plugin=$file", 'upgrade-plugin_' . $file) ); 131 131 echo "</td></tr>"; 132 132 } … … 168 168 // Download the package 169 169 $package = $r->package; 170 apply_filters('update_feedback', sprintf(__( "Downloading update from %s"), $package));170 apply_filters('update_feedback', sprintf(__('Downloading update from %s'), $package)); 171 171 $file = download_url($package); 172 172 … … 174 174 return new WP_Error('download_failed', __('Download failed.')); 175 175 176 $name = basename($plugin, '.php'); 177 $working_dir = $base . 'wp-content/upgrade/' . $name; 176 $working_dir = $base . 'wp-content/upgrade/' . basename($plugin, '.php'); 178 177 179 178 // Clean up working directory 180 if ( is_dir($working_dir) )179 if ( $wp_filesystem->is_dir($working_dir) ) 181 180 $wp_filesystem->delete($working_dir, true); 182 181 183 apply_filters('update_feedback', __( "Unpacking the update"));182 apply_filters('update_feedback', __('Unpacking the update')); 184 183 // Unzip package to working directory 185 184 $result = unzip_file($file, $working_dir); … … 194 193 195 194 // Remove the existing plugin. 196 apply_filters('update_feedback', __( "Removing the old version of the plugin"));195 apply_filters('update_feedback', __('Removing the old version of the plugin')); 197 196 $plugin_dir = dirname($base . PLUGINDIR . "/$plugin"); 198 197 $plugin_dir = trailingslashit($plugin_dir); 198 199 199 // If plugin is in its own directory, recursively delete the directory. 200 if( ! in_array( $plugin_dir, array('.', trailingslashit($base . PLUGINDIR) ) ))200 if( strpos($plugin, '/') && $plugin_dir != $base . PLUGINDIR . '/' ) 201 201 $deleted = $wp_filesystem->delete($plugin_dir, true); 202 202 else 203 203 $deleted = $wp_filesystem->delete($base . PLUGINDIR . "/$plugin"); 204 204 205 if ( !$deleted ) { 205 206 $wp_filesystem->delete($working_dir, true); … … 207 208 } 208 209 209 apply_filters('update_feedback', __( "Installing the latest version"));210 apply_filters('update_feedback', __('Installing the latest version')); 210 211 // Copy new version of plugin into place. 211 212 if ( !copy_dir($working_dir, $base . PLUGINDIR) ) { 212 //$wp_filesystem->delete($working_dir, true); 213 //$wp_filesystem->delete($working_dir, true); //TODO: Uncomment? This DOES mean that the new files are available in the upgrade folder if it fails. 213 214 return new WP_Error('install_failed', __('Installation failed')); 214 215 } -
trunk/wp-admin/update.php
r7206 r7238 6 6 wp_die('<p>'.__('You do not have sufficient permissions to update plugins for this blog.').'</p>'); 7 7 8 function request_filesystem_credentials($form_post, $type = '' ) {8 function request_filesystem_credentials($form_post, $type = '', $error = false) { 9 9 if ( empty($type) ) 10 10 $type = get_filesystem_method(); … … 13 13 return array(); 14 14 15 if ( ! empty($_POST['password']) && !empty($_POST['username']) && !empty($_POST['hostname']) ) {15 if ( ! $error && !empty($_POST['password']) && !empty($_POST['username']) && !empty($_POST['hostname']) ) { 16 16 $credentials = array('hostname' => $_POST['hostname'], 'username' => $_POST['username'], 17 17 'password' => $_POST['password'], 'ssl' => $_POST['ssl']); … … 27 27 if ( $credentials = get_option('ftp_credentials') ) 28 28 extract($credentials, EXTR_OVERWRITE); 29 if( $error ){ 30 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>'; 31 } 29 32 ?> 30 33 <form action="<?php echo $form_post ?>" method="post"> … … 43 46 <tr valign="top"> 44 47 <th scope="row"><?php _e('Password:') ?></th> 45 <td><input name="password" type=" text" id="password" value="<?php echo attribute_escape($password) ?>" size="40" /></td>48 <td><input name="password" type="password" id="password" value="<?php echo attribute_escape($password) ?>" size="40" /></td> 46 49 </tr> 47 50 <tr valign="top"> … … 81 84 global $wp_filesystem; 82 85 83 $ credentials = request_filesystem_credentials("update.php?action=upgrade-plugin&plugin=$plugin");84 if ( false === $credentials)86 $url = wp_nonce_url("update.php?action=upgrade-plugin&plugin=$plugin", "upgrade-plugin_$plugin"); 87 if ( false === ($credentials = request_filesystem_credentials($url)) ) 85 88 return; 89 90 if( ! WP_Filesystem($credentials) ){ 91 request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again 92 return; 93 } 94 86 95 echo '<div class="wrap">'; 87 96 echo '<h2>' . __('Upgrade Plugin') . '</h2>'; 88 WP_Filesystem($credentials);89 // TODO: look for auth and connect error codes and direct back to credentials form.90 97 if ( $wp_filesystem->errors->get_error_code() ) { 91 98 foreach ( $wp_filesystem->errors->get_error_messages() as $message ) … … 109 116 110 117 if ( 'upgrade-plugin' == $_GET['action'] ) { 111 //check-admin_referer('upgrade-plugin_' . $plugin);118 check_admin_referer('upgrade-plugin_' . $plugin); 112 119 $title = __('Upgrade Plugin'); 113 120 $parent_file = 'plugins.php'; … … 116 123 include('admin-footer.php'); 117 124 } 118 119 125 } 120 126
Note: See TracChangeset
for help on using the changeset viewer.