Bug in code
-
In the function
apt_generate_post_thumb, you have the following code://Fix for checking file extensions $exts = explode(".",$filename); if (count($exts)>2)return null; $allowed=get_allowed_mime_types(); $ext=pathinfo($new_file,PATHINFO_EXTENSION); if(!array_key_exists($ext,$allowed))return null;You check if, for instance,
jpgexists as a key in the array retrieved fromget_allowed_mime_types. The problem is, it doesn’t. The key for the JPEG MIME type isjpg|jpeg|jpe. Thus, your plugin thinksjpgis not supported.Additionally, a few lines later, you do this:
// Get the file type. Must to use it as a post thumbnail. $wp_filetype = wp_check_filetype( $filename, $mimes ); extract( $wp_filetype ); // No file type! No point to proceed further if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) ) { return null; }The function
wp_check_filetypechecks if the extension is valid AND allowed. The difference is, it does it properly. You should replace the former broken code with the latter:// Get the file type. Must to use it as a post thumbnail. $wp_filetype = wp_check_filetype( $filename ); extract( $wp_filetype ); // No file type! No point to proceed further if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) ) { return null; } file_put_contents($new_file, $file_data); // Set correct file permissions $stat = stat( dirname( $new_file )); $perms = $stat['mode'] & 0000666; @ chmod( $new_file, $perms ); // Compute the URL $url = $uploads['url'] . "/$filename";
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Bug in code’ is closed to new replies.