Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/file.php

    r19225 r20313  
    6666        }
    6767
    68         return basename( $file );
     68        return trim( basename( $file ) );
    6969}
    7070
    … …  
    8282        if ( $home != '' && $home != $siteurl ) {
    8383                $wp_path_rel_to_home = str_replace($home, '', $siteurl); /* $siteurl - $home */
    84                 $pos = strpos($_SERVER["SCRIPT_FILENAME"], $wp_path_rel_to_home);
     84                $pos = strrpos($_SERVER["SCRIPT_FILENAME"], $wp_path_rel_to_home);
    8585                $home_path = substr($_SERVER["SCRIPT_FILENAME"], 0, $pos);
    8686                $home_path = trailingslashit( $home_path );
    … …  
    158158 *
    159159 * The filename is based off the passed parameter or defaults to the current unix timestamp,
    160  * while the directory can either be passed as well, or by leaving  it blank, default to a writable temporary directory.
     160 * while the directory can either be passed as well, or by leaving it blank, default to a writable temporary directory.
    161161 *
    162162 * @since 2.6.0
    … …  
    241241        $upload_error_handler = 'wp_handle_upload_error';
    242242
    243         // You may have had one or more 'wp_handle_upload_prefilter' functions error out the file.  Handle that gracefully.
     243        // You may have had one or more 'wp_handle_upload_prefilter' functions error out the file. Handle that gracefully.
    244244        if ( isset( $file['error'] ) && !is_numeric( $file['error'] ) && $file['error'] )
    245245                return $upload_error_handler( $file, $file['error'] );
    … …  
    324324        $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
    325325
    326         $tmp_file = wp_tempnam($filename);
    327 
    328326        // Move the file to the uploads dir
    329         if ( false === @ move_uploaded_file( $file['tmp_name'], $tmp_file ) )
     327        $new_file = $uploads['path'] . "/$filename";
     328        if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) )
    330329                return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) );
    331 
    332         // If a resize was requested, perform the resize.
    333         $image_resize = isset( $_POST['image_resize'] ) && 'true' == $_POST['image_resize'];
    334         $do_resize = apply_filters( 'wp_upload_resize', $image_resize );
    335         $size = @getimagesize( $tmp_file );
    336         if ( $do_resize && $size ) {
    337                 $old_temp = $tmp_file;
    338                 $tmp_file = image_resize( $tmp_file, (int) get_option('large_size_w'), (int) get_option('large_size_h'), 0, 'resized');
    339                 if ( ! is_wp_error($tmp_file) ) {
    340                         unlink($old_temp);
    341                 } else {
    342                         $tmp_file = $old_temp;
    343                 }
    344         }
    345 
    346         // Copy the temporary file into its destination
    347         $new_file = $uploads['path'] . "/$filename";
    348         copy( $tmp_file, $new_file );
    349         unlink($tmp_file);
    350330
    351331        // Set correct file permissions
    … …  
    365345/**
    366346 * Handle sideloads, which is the process of retrieving a media item from another server instead of
    367  * a traditional media upload.  This process involves sanitizing the filename, checking extensions
     347 * a traditional media upload. This process involves sanitizing the filename, checking extensions
    368348 * for mime type, and moving the file to the appropriate directory within the uploads directory.
    369349 *
    … …  
    487467/**
    488468 * Downloads a url to a local temporary file using the WordPress HTTP Class.
    489  * Please note, That the calling function must unlink() the  file.
     469 * Please note, That the calling function must unlink() the file.
    490470 *
    491471 * @since 2.5.0
    … …  
    649629
    650630                if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) )
    651                         return new WP_Error('copy_failed', __('Could not copy file.'), $to . $info['filename']);
     631                        return new WP_Error('copy_failed', __('Could not copy file.'), $to . $info['name']);
    652632        }
    653633
    … …  
    885865
    886866/**
    887  * Displays a form to the user to request for their FTP/SSH details in order to  connect to the filesystem.
     867 * Displays a form to the user to request for their FTP/SSH details in order to connect to the filesystem.
    888868 * All chosen/entered details are saved, Excluding the Password.
    889869 *
    … …  
    897877 * @param string $type the chosen Filesystem method in use
    898878 * @param boolean $error if the current request has failed to connect
    899  * @param string $context The directory which is needed access to, The write-test will be performed on  this directory by get_filesystem_method()
     879 * @param string $context The directory which is needed access to, The write-test will be performed on this directory by get_filesystem_method()
    900880 * @param string $extra_fields Extra POST fields which should be checked for to be included in the post.
    901881 * @return boolean False on failure. True on success.
    … …  
    10761056        return false;
    10771057}
    1078 
    1079 ?>
Note: See TracChangeset for help on using the changeset viewer.