Changeset 8852
- Timestamp:
- 09/09/2008 03:24:05 AM (16 years ago)
- Location:
- trunk/wp-admin/includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-filesystem-ssh2.php
r8812 r8852 9 9 /** 10 10 * WordPress Filesystem Class for implementing SSH2. 11 * 12 * To use this class you must follow these steps for PHP 5.2.6+ 13 * 14 * @contrib http://kevin.vanzonneveld.net/techblog/article/make_ssh_connections_with_php/ - Installation Notes 15 * 16 * Complie libssh2 (Note: Only 0.14 is officaly working with PHP 5.2.6+ right now.) 17 * 18 * cd /usr/src 19 * wget http://surfnet.dl.sourceforge.net/sourceforge/libssh2/libssh2-0.14.tar.gz 20 * tar -zxvf libssh2-0.14.tar.gz 21 * cd libssh2-0.14/ 22 * ./configure 23 * make all install 24 * 25 * Note: No not leave the directory yet! 26 * 27 * Enter: pecl install -f ssh2 28 * 29 * Copy the ssh.so file it creates to your PHP Module Directory. 30 * Open up your PHP.INI file and look for where extensions are placed. 31 * Add in your PHP.ini file: extension=ssh2.so 32 * 33 * Restart Apache! 34 * Check phpinfo() streams to confirm that: ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp exist. 35 * 11 36 * 12 37 * @since 2.7 … … 16 41 */ 17 42 class WP_Filesystem_SSH2 extends WP_Filesystem_Base { 18 19 var $debugtest = true; // this is my var that will output the text when debuggin this class 20 21 var $link; 22 var $timeout = 5; 43 44 var $debugtest = false; // this is my var that will output the text when debuggin this class 45 46 var $link = null; 47 var $sftp_link = null; 48 /* 49 * This is the timeout value for ssh results to comeback. 50 * Slower servers might need this incressed, but this number otherwise should not change. 51 * 52 * @parm $timeout int 53 * 54 */ 55 var $timeout = 15; 23 56 var $errors = array(); 24 57 var $options = array(); 25 58 26 var $permission = null; 27 28 var $filetypes = array( 29 'php'=>FTP_ASCII, 30 'css'=>FTP_ASCII, 31 'txt'=>FTP_ASCII, 32 'js'=>FTP_ASCII, 33 'html'=>FTP_ASCII, 34 'htm'=>FTP_ASCII, 35 'xml'=>FTP_ASCII, 36 37 'jpg'=>FTP_BINARY, 38 'png'=>FTP_BINARY, 39 'gif'=>FTP_BINARY, 40 'bmp'=>FTP_BINARY 41 ); 59 var $permission = 0644; 42 60 43 61 function WP_Filesystem_SSH2($opt='') { … … 72 90 73 91 if ( empty ($opt['password']) ) 74 $this->errors->add('empty_password', __('SSH password is required'));92 $this->errors->add('empty_password', __('SSH2 password is required')); 75 93 else 76 94 $this->options['password'] = $opt['password']; 77 78 95 } 79 96 … … 92 109 } 93 110 111 $this->sftp_link = ssh2_sftp($this->link); 112 94 113 return true; 95 114 } 96 115 97 116 function run_command($link, $command, $returnbool = false) { 98 $this->debug("run_command(".$command.");");99 if(!($stream = @ssh2_exec( $link, $command ))) {100 $this->errors->add('command', sprintf(__('Unable to preform command: %s'), $command));101 102 117 //$this->debug("run_command(".$command.",".$returnbool.");"); 118 if(!($stream = @ssh2_exec( $link, $command . "; echo \"__COMMAND_FINISHED__\";"))) { 119 $this->errors->add('command', sprintf(__('Unable to perform command: %s'), $command)); 120 } else { 121 stream_set_blocking( $stream, true ); 103 122 $time_start = time(); 104 $data = "";123 $data = null; 105 124 while( true ) { 106 if( (time()-$time_start) > $this->timeout ){ 107 $this->errors->add('command', sprintf(__('Connection to the server has timeout after %s seconds.'), $this->timeout)); 108 break; 109 } 110 while( $buf = fread( $stream, strlen($stream) ) ){ 111 $data .= $buf; 112 } 125 if (strpos($data,"__COMMAND_FINISHED__") !== false){ 126 break; // the command has finshed! 127 } 128 if( (time()-$time_start) > $this->timeout ){ 129 $this->errors->add('command', sprintf(__('Connection to the server has timeout after %s seconds.'), $this->timeout)); 130 unset($this->link); 131 unset($this->sftp_link); // close connections 132 return false; 133 } 134 while( $buf = fread( $stream, strlen($stream) ) ) 135 $data .= $buf; 113 136 } 114 fclose($stream); 115 if (($returnbool) && ($data)) { 116 $this->debug("Data: " . print_r($data, true) . " Returning: True"); 117 return true; 118 } elseif (($returnbool) && (!$data)) { 119 $this->debug("Data: " . print_r($data, true) . " Returning: False"); 120 return false; 121 } else { 122 $this->debug("Data: " . print_r($data, true)); 123 return $data; 124 } 125 } 137 fclose($stream); 138 $data = str_replace("__COMMAND_FINISHED__", "", $data); 139 //$this->debug("run_command(".$command."); --> \$data = " . $data); 140 if (($returnbool) && ( (int) $data )) { 141 $this->debug("Data. Returning: True"); 142 return true; 143 } elseif (($returnbool) && (! (int) $data )) { 144 $this->debug("Data. Returning: False"); 145 return false; 146 } else { 147 $this->debug("Data Only."); 148 return $data; 149 } 150 } 151 return false; 126 152 } 127 153 … … 130 156 if ($this->debugtest) 131 157 { 132 echo $text . "<br/>";158 echo "<br/>" . $text . "<br/>"; 133 159 } 134 160 } 135 161 136 162 function setDefaultPermissions($perm) { 137 $this->permission = $perm; 138 } 139 140 function get_contents($file, $type = '', $resumepos = 0 ){ 141 if( empty($type) ){ 142 $extension = substr(strrchr($file, "."), 1); 143 $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII; 144 } 145 $temp = tmpfile(); 163 $this->debug("setDefaultPermissions();"); 164 if ( $perm ) 165 $this->permission = $perm; 166 } 167 168 function get_contents($file, $type = '', $resumepos = 0 ) { 169 $tempfile = wp_tempnam( $file ); 170 if ( ! $tempfile ) 171 return false; 172 if( ! ssh2_scp_recv($this->link, $file, $tempfile) ) 173 return false; 174 $contents = file_get_contents($tempfile); 175 unlink($tempfile); 176 return $contents; 177 } 178 179 function get_contents_array($file) { 180 $this->debug("get_contents_array();"); 181 return explode("\n", $this->get_contents($file)); 182 } 183 184 function put_contents($file, $contents, $type = '' ) { 185 $tempfile = wp_tempnam( $file ); 186 $temp = fopen($tempfile, 'w'); 146 187 if ( ! $temp ) 147 188 return false; 148 if( ! @ssh2_scp_recv($this->link, $temp, $file) ) 149 return false; 150 fseek($temp, 0); //Skip back to the start of the file being written to 151 $contents = ''; 152 while (!feof($temp)) { 153 $contents .= fread($temp, 8192); 154 } 189 fwrite($temp, $contents); 155 190 fclose($temp); 156 return $contents; 157 } 158 159 function get_contents_array($file) { 160 return explode("\n", $this->get_contents($file)); 161 } 162 163 function put_contents($file, $contents, $type = '' ) { 164 if( empty($type) ) { 165 $extension = substr(strrchr($file, "."), 1); 166 $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII; 167 } 168 $temp = tmpfile(); 169 if ( ! $temp ) 170 return false; 171 fwrite($temp, $contents); 172 fseek($temp, 0); //Skip back to the start of the file being written to 173 $ret = @ssh2_scp_send($this->link, $file, $temp, $type); 174 fclose($temp); 191 $ret = ssh2_scp_send($this->link, $tempfile, $file, $this->permission); 192 unlink($tempfile); 175 193 return $ret; 176 194 } 177 195 178 196 function cwd() { 179 $cwd = $this->run_command($this->link, "pwd");197 $cwd = $this->run_command($this->link, 'pwd'); 180 198 if( $cwd ) 181 199 $cwd = trailingslashit($cwd); 182 200 return $cwd; 183 201 } 184 202 185 203 function chdir($dir) { 186 if ($this->run_command($this->link, "cd " . $dir, true)) { 187 return true; 188 } 189 return false; 190 } 191 204 return $this->run_command($this->link, 'cd ' . $dir, true); 205 } 206 192 207 function chgrp($file, $group, $recursive = false ) { 193 return false; 194 } 195 208 $this->debug("chgrp();"); 209 if ( ! $this->exists($file) ) 210 return false; 211 if ( ! $recursive || ! $this->is_dir($file) ) 212 return $this->run_command($this->link, sprintf('chgrp %o %s', $mode, $file), true); 213 return $this->run_command($this->link, sprintf('chgrp -R %o %s', $mode, $file), true); 214 } 215 196 216 function chmod($file, $mode = false, $recursive = false) { 217 $this->debug("chmod();"); 197 218 if( ! $mode ) 198 219 $mode = $this->permission; … … 201 222 if ( ! $this->exists($file) ) 202 223 return false; 203 if ( ! $recursive || ! $this->is_dir($file) ) { 204 return $this->run_command($this->link, sprintf('CHMOD %o %s', $mode, $file), true); 205 } 206 //Is a directory, and we want recursive 207 $filelist = $this->dirlist($file); 208 foreach($filelist as $filename){ 209 $this->chmod($file . '/' . $filename, $mode, $recursive); 210 } 211 return true; 212 } 213 224 if ( ! $recursive || ! $this->is_dir($file) ) 225 return $this->run_command($this->link, sprintf('chmod %o %s', $mode, $file), true); 226 return $this->run_command($this->link, sprintf('chmod -R %o %s', $mode, $file), true); 227 } 228 214 229 function chown($file, $owner, $recursive = false ) { 215 return false; 216 } 217 230 $this->debug("chown();"); 231 if ( ! $this->exists($file) ) 232 return false; 233 if ( ! $recursive || ! $this->is_dir($file) ) 234 return $this->run_command($this->link, sprintf('chown %o %s', $mode, $file), true); 235 return $this->run_command($this->link, sprintf('chown -R %o %s', $mode, $file), true); 236 } 237 218 238 function owner($file) { 239 $this->debug("owner();"); 219 240 $dir = $this->dirlist($file); 220 241 return $dir[$file]['owner']; 221 242 } 222 243 223 244 function getchmod($file) { 245 $this->debug("getchmod();"); 224 246 $dir = $this->dirlist($file); 225 247 return $dir[$file]['permsn']; 226 248 } 227 249 228 250 function group($file) { 251 $this->debug("group();"); 229 252 $dir = $this->dirlist($file); 230 253 return $dir[$file]['group']; 231 254 } 232 255 233 256 function copy($source, $destination, $overwrite = false ) { 257 $this->debug("copy();"); 234 258 if( ! $overwrite && $this->exists($destination) ) 235 259 return false; … … 239 263 return $this->put_contents($destination, $content); 240 264 } 241 265 242 266 function move($source, $destination, $overwrite = false) { 267 $this->debug("move();"); 243 268 return @ssh2_sftp_rename($this->link, $source, $destination); 244 269 } 245 270 246 function delete($file, $recursive =false) {271 function delete($file, $recursive = false) { 247 272 if ( $this->is_file($file) ) 248 return @ssh2_sftp_unlink($this->link, $file);249 if ( ! $recursive )250 return @ssh2_sftp_rmdir($this->link, $file);273 return ssh2_sftp_unlink($this->sftp_link, $file); 274 if ( ! $recursive ) 275 return ssh2_sftp_rmdir($this->sftp_link, $file); 251 276 $filelist = $this->dirlist($file); 252 foreach ((array) $filelist as $filename => $fileinfo) { 253 $this->delete($file . '/' . $filename, $recursive); 254 } 255 return @ssh2_sftp_rmdir($this->link, $file); 277 if ( is_array($filelist) ) { 278 foreach ( $filelist as $filename => $fileinfo) { 279 $this->delete($file . '/' . $filename, $recursive); 280 } 281 } 282 return ssh2_sftp_rmdir($this->sftp_link, $file); 256 283 } 257 284 258 285 function exists($file) { 259 $list = $this->run_command($this->link, sprintf('ls -la %s', $file)); 260 if( ! $list ) 261 return false; 262 return count($list) == 1 ? true : false; 263 } 264 286 $list = $this->run_command($this->link, sprintf('ls -lad %s', $file)); 287 return (bool) $list; 288 } 289 265 290 function is_file($file) { 266 return $this->is_dir($file) ? false : true; 267 } 268 291 //DO NOT RELY ON dirlist()! 292 $list = $this->run_command($this->link, sprintf('ls -lad %s', $file)); 293 $list = $this->parselisting($list); 294 if ( ! $list ) 295 return false; 296 else 297 return ( !$list['isdir'] && !$list['islink'] ); //ie. not a file or link, yet exists, must be file. 298 } 299 269 300 function is_dir($path) { 270 $cwd = $this->cwd(); 271 $result = $this->run_command($this->link, sprintf('cd %s', $path), true); 272 if( $result && $path == $this->cwd() || $this->cwd() != $cwd ) { 273 // @todo: use ssh2_exec 274 @ftp_chdir($this->link, $cwd); 275 return true; 276 } 277 return false; 278 } 279 301 //DO NOT RELY ON dirlist()! 302 $list = $this->parselisting($this->run_command($this->link, sprintf('ls -lad %s', rtrim($path, '/')))); 303 if ( ! $list ) 304 return false; 305 else 306 return $list['isdir']; 307 } 308 280 309 function is_readable($file) { 281 //Get dir list, Check if the file is writable by the current user?? 282 return true; 283 } 284 310 //Not implmented. 311 } 312 285 313 function is_writable($file) { 286 //Get dir list, Check if the file is writable by the current user?? 287 return true; 288 } 289 314 //Not implmented. 315 } 316 290 317 function atime($file) { 291 return false;292 } 293 318 //Not implmented. 319 } 320 294 321 function mtime($file) { 295 return; // i have to look up to see if there is a way in SSH2 to look the modifed date 296 // return ftp_mdtm($this->link, $file); 297 } 298 322 //Not implmented. 323 } 324 299 325 function size($file) { 300 return; // i have to look up to see if there is a way in SSH2 to get the file size 301 // return ftp_size($this->link, $file); 302 } 303 326 //Not implmented. 327 } 328 304 329 function touch($file, $time = 0, $atime = 0) { 305 return false; 306 } 307 308 function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { 309 if( !@ssh2_sftp_mkdir($this->link, $path) ) 310 return false; 311 if( $chmod ) 312 $this->chmod($path, $chmod); 330 //Not implmented. 331 } 332 333 function mkdir($path, $chmod = null, $chown = false, $chgrp = false) { 334 if( ! ssh2_sftp_mkdir($this->sftp_link, $path, $chmod, true) ) 335 return false; 313 336 if( $chown ) 314 337 $this->chown($path, $chown); … … 317 340 return true; 318 341 } 319 342 320 343 function rmdir($path, $recursive = false) { 321 if( ! $recursive ) 322 return @ssh2_sftp_rmdir($this->link, $path); 323 324 //TODO: Recursive Directory delete, Have to delete files from the folder first. 325 //$dir = $this->dirlist($path); 326 //foreach($dir as $file) 327 344 return $this->delete($path, $recursive); 328 345 } 329 346 330 347 function parselisting($line) { 348 $this->debug("parselisting();"); 331 349 $is_windows = ($this->OS_remote == FTP_OS_Windows); 332 350 if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/", $line, $lucifer)) { … … 391 409 392 410 function dirlist($path = '.', $incdot = false, $recursive = false) { 411 $this->debug("dirlist();"); 393 412 if( $this->is_file($path) ) { 394 413 $limitFile = basename($path); 395 $path = dirname($path) . '/';414 $path = trailingslashit(dirname($path)); 396 415 } else { 397 416 $limitFile = false; 398 417 } 399 400 $list = $this->run_command($this->link, sprintf('ls - a %s', $path));418 419 $list = $this->run_command($this->link, sprintf('ls -la %s', $path)); 401 420 402 421 if ( $list === false ) 403 422 return false; 404 423 424 $list = explode("\n", $list); 425 405 426 $dirlist = array(); 406 foreach ( $list as $k => $v ) {427 foreach ( (array)$list as $k => $v ) { 407 428 $entry = $this->parselisting($v); 408 429 if ( empty($entry) ) 409 430 continue; 410 431 411 if ( '.' == $entry[ "name"] || '..' == $entry["name"] )432 if ( '.' == $entry['name'] || '..' == $entry['name'] ) 412 433 continue; 413 434 … … 417 438 if ( ! $dirlist ) 418 439 return false; 440 419 441 if ( empty($dirlist) ) 420 442 return array(); … … 433 455 } 434 456 } else { //No dots 435 if ( $recursive)457 if ( $recursive ) 436 458 $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $incdot, $recursive); 437 459 } … … 444 466 445 467 function __destruct(){ 446 if ( $this->link )468 if ( $this->link ) 447 469 unset($this->link); 470 if ( $this->sftp_link ) 471 unset($this->sftp_link); 448 472 } 449 473 } -
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> -
trunk/wp-admin/includes/update.php
r8691 r8852 239 239 240 240 $working_dir = $content_dir . 'upgrade/core'; 241 242 241 // Clean up working directory 243 if ( $wp_filesystem->is_dir($working_dir) ) 244 $wp_filesystem->delete($working_dir, true); 245 246 apply_filters('update_feedback', __('Unpacking the update')); 242 if ( $wp_filesystem->is_dir($working_dir) ) { 243 $wp_filesystem->delete($working_dir, true); 244 } 245 246 apply_filters('update_feedback', __('Unpacking the core update')); 247 247 // Unzip package to working directory 248 248 $result = unzip_file($download_file, $working_dir); 249 250 249 // Once extracted, delete the package 251 250 unlink($download_file); 252 251 253 252 if ( is_wp_error($result) ) { 254 253 $wp_filesystem->delete($working_dir, true); 255 254 return $result; 256 255 } 257 256 258 257 // Copy update-core.php from the new version into place. 259 258 if ( !$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true) ) {
Note: See TracChangeset
for help on using the changeset viewer.