Ticket #2682: remove_upload_abspath.patch
| File remove_upload_abspath.patch, 4.6 KB (added by ryanscheuermann, 7 years ago) |
|---|
-
wp-admin/admin-functions.php
1861 1861 1862 1862 // Increment the file number until we have a unique file to save in $dir. Use $override['unique_filename_callback'] if supplied. 1863 1863 if ( isset($unique_filename_callback) && function_exists($unique_filename_callback) ) { 1864 $filename = $unique_filename_callback( $uploads['path'], $file['name']);1864 $filename = $unique_filename_callback(ABSPATH . $uploads['path'], $file['name']); 1865 1865 } else { 1866 1866 $number = ''; 1867 1867 $filename = str_replace('#', '_', $file['name']); … … 1880 1880 1881 1881 // Move the file to the uploads dir 1882 1882 $new_file = $uploads['path'] . "/$filename"; 1883 if ( false === @ move_uploaded_file($file['tmp_name'], $new_file) )1883 if ( false === @ move_uploaded_file($file['tmp_name'], ABSPATH . $new_file) ) 1884 1884 die(printf(__('The uploaded file could not be moved to %s.'), $file['path'])); 1885 1885 1886 1886 // Set correct file permissions 1887 $stat = stat(dirname( $new_file));1887 $stat = stat(dirname(ABSPATH . $new_file)); 1888 1888 $perms = $stat['mode'] & 0000666; 1889 @ chmod( $new_file, $perms);1889 @ chmod(ABSPATH . $new_file, $perms); 1890 1890 1891 1891 // Compute the URL 1892 1892 $url = $uploads['url'] . "/$filename"; -
wp-admin/inline-uploading.php
73 73 74 74 if ( preg_match('!^image/!', $attachment['post_mime_type']) ) { 75 75 // Generate the attachment's postmeta. 76 $imagesize = getimagesize( $file);76 $imagesize = getimagesize(ABSPATH . $file); 77 77 $imagedata['width'] = $imagesize['0']; 78 78 $imagedata['height'] = $imagesize['1']; 79 79 list($uwidth, $uheight) = get_udims($imagedata['width'], $imagedata['height']); … … 84 84 85 85 if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) { 86 86 if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 ) 87 $thumb = wp_create_thumbnail( $file, 128);87 $thumb = wp_create_thumbnail(ABSPATH . $file, 128); 88 88 elseif ( $imagedata['height'] > 96 ) 89 $thumb = wp_create_thumbnail( $file, 96);89 $thumb = wp_create_thumbnail(ABSPATH . $file, 96); 90 90 91 91 if ( @file_exists($thumb) ) { 92 92 $newdata = $imagedata; -
wp-includes/functions-post.php
921 921 // Returns an array containing the current upload directory's path and url, or an error message. 922 922 function wp_upload_dir() { 923 923 $siteurl = get_settings('siteurl'); 924 // prepend ABSPATH to $dir and $siteurl to $url if they're not already there924 //remove ABSPATH from upload_path if present 925 925 $path = str_replace(ABSPATH, '', trim(get_settings('upload_path'))); 926 $dir = ABSPATH . $path; 926 if($path == '') 927 $path = 'wp-content/uploads'; 928 $dir = $path; 927 929 $url = trailingslashit($siteurl) . $path; 928 930 929 if ( $dir == ABSPATH ) { //the option was empty930 $dir = ABSPATH . 'wp-content/uploads';931 }932 933 931 if ( defined('UPLOADS') ) { 934 $dir = ABSPATH .UPLOADS;932 $dir = UPLOADS; 935 933 $url = trailingslashit($siteurl) . UPLOADS; 936 934 } 937 935 … … 945 943 } 946 944 947 945 // Make sure we have an uploads dir 948 if ( ! wp_mkdir_p( $dir ) ) {949 $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), $dir);946 if ( ! wp_mkdir_p( ABSPATH . $dir ) ) { 947 $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), ABSPATH . $dir); 950 948 return array('error' => $message); 951 949 } 952 950 953 $uploads = array('path' => $dir, 'url' => $url, 'error' => false);951 $uploads = array('path' => $dir, 'url' => $url, 'error' => false); 954 952 return apply_filters('upload_dir', $uploads); 955 953 } 956 954 … … 971 969 $ext = ''; 972 970 else 973 971 $ext = ".$ext"; 974 while ( file_exists( $upload['path'] . "/$filename") ) {972 while ( file_exists(ABSPATH . $upload['path'] . "/$filename") ) { 975 973 if ( '' == "$number$ext" ) 976 974 $filename = $filename . ++$number . $ext; 977 975 else … … 979 977 } 980 978 981 979 $new_file = $upload['path'] . "/$filename"; 982 if ( ! wp_mkdir_p( dirname( $new_file) ) ) {980 if ( ! wp_mkdir_p( dirname(ABSPATH . $new_file) ) ) { 983 981 $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), dirname($new_file)); 984 982 return array('error' => $message); 985 983 } 986 984 987 $ifp = @ fopen( $new_file, 'wb');985 $ifp = @ fopen(ABSPATH . $new_file, 'wb'); 988 986 if ( ! $ifp ) 989 987 return array('error' => "Could not write file $new_file."); 990 988