Changeset 440
- Timestamp:
- 06/10/07 10:43:48 (1 year ago)
- Files:
-
- avatar-upload/trunk/avatar-upload.php (modified) (7 diffs)
- avatar-upload/trunk/my-plugins/bb-avatar-upload.php (modified) (3 diffs)
- avatar-upload/trunk/readme.txt (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
avatar-upload/trunk/avatar-upload.php
r437 r440 3 3 Plugin Name: Avatar Upload 4 4 Plugin URI: http://bbpress.org/plugins/topic/46 5 Version: 0.4 5 Version: 0.4.1 6 6 Description: Allows users to upload an avatar (gif, jpeg/jpg or png) image to bbPress. 7 7 Author: Louise Dade … … 50 50 51 51 // Grab file extension 52 $img_ext = s ubstr($img_name, strrpos($img_name, ".")+1);52 $img_ext = strtolower(substr($img_name, strrpos($img_name, ".")+1)); 53 53 54 54 // Build the user's avatar filename … … 65 65 66 66 // Is file uploaded to temp folder? 67 if ($img_errs == 0 && (! file_exists($img_temp) || !is_uploaded_file($img_temp)) )67 if ($img_errs == 0 && (!@file_exists($img_temp) || !@is_uploaded_file($img_temp)) ) 68 68 { 69 69 $img_errs = 4; … … 71 71 72 72 // Is file extension valid and does it match the mime-type? 73 if ($img_errs == 0 && (! in_array($img_type, $config->mime_types[$img_ext]) || !in_array($img_ext, $config->file_extns)) )73 if ($img_errs == 0 && (!@in_array($img_type, $config->mime_types[$img_ext]) || !@in_array($img_ext, $config->file_extns)) ) 74 74 { 75 75 $img_errs = 8; … … 86 86 { 87 87 // Get the dimensions 88 $dims = getimagesize($img_temp);88 $dims = @getimagesize($img_temp); 89 89 $img_w = $dims[0]; 90 90 $img_h = $dims[1]; … … 97 97 98 98 // Did we move the image to the avatar folder successfully? 99 if ($img_errs == 0 && ! move_uploaded_file($img_temp, BBPATH . $config->avatar_dir . $user_filename) )99 if ($img_errs == 0 && !@move_uploaded_file($img_temp, BBPATH . $config->avatar_dir . $user_filename) ) 100 100 { 101 101 $img_errs = 11; … … 111 111 // If different, delete 'current' - this will only occur when 112 112 // the new and current avatars have different file extensions. 113 unlink(BBPATH . $config->avatar_dir . $current_avatar[0]);113 @unlink(BBPATH . $config->avatar_dir . $current_avatar[0]); 114 114 } 115 115 avatar-upload/trunk/my-plugins/bb-avatar-upload.php
r437 r440 3 3 Plugin Name: Avatar Upload 4 4 Plugin URI: http://bbpress.org/plugins/topic/46 5 Version: 0.4 5 Version: 0.4.1 6 6 Description: Allows users to upload an avatar (gif, jpeg/jpg or png) image to bbPress. 7 7 Author: Louise Dade … … 75 75 echo '<img src="'.$a[0]; 76 76 echo ($status == 'new') ? '?'.time() : ''; 77 echo'" width="'.$a[1].'" height="'.$a[2].'" alt=" Avatar" />';77 echo'" width="'.$a[1].'" height="'.$a[2].'" alt="'.$a[4].'" />'; 78 78 } else { 79 79 $config = new avatarupload_config(); … … 118 118 $a[0] = bb_get_option('uri') . $config->avatar_dir . $a[0]; 119 119 } 120 121 // Add the username for use in 'alt' attribute to end of array 122 $a[] = $user->user_login; 123 120 124 return $a; 121 125 } avatar-upload/trunk/readme.txt
r437 r440 4 4 Requires at least: 0.8 5 5 Tested up to: 0.8.1 6 Stable Tag: 0.4 6 Stable Tag: 0.4.1 7 7 8 8 Allows users to upload an avatar (gif, jpeg/jpg or png) image to bbPress. Admins can configure maximum allowed file size and image dimensions. … … 10 10 == Description == 11 11 12 Allows users to upload an avatar (gif, jpeg/jpg or png) image to bbPress, and provides template functions to display the uploaded image. 13 12 14 Plugin URI: http://bbpress.org/plugins/topic/46 13 Author: Louise Dade 15 14 16 Author URI: http://www.classical-webdesigns.co.uk/ 15 17 16 Allows users to upload an avatar (gif, jpeg/jpg or png) image to bbPress, and provides template functions to display the uploaded image. 18 = Features = 17 19 18 Features:19 20 * Bozos can not upload avatars. 21 20 22 * Admins can configure maximum allowed file size (bytes) and dimensions (pixels) of images. 23 21 24 - Currently done from within the script (no Admin page interface at this time). 25 22 26 * Anybody with the 'moderate' capability can upload another user's avatar 27 23 28 - this to ensures that inappropriate images can be removed. 29 24 30 - there is no "delete avatar" function at this time, but an inappropriate image can be removed by uploading a 'safe' image (e.g. a blank 1x1 pixel image) to replace it (you could them manually set that user as a bozo to stop them re-uploading inappropriate images). 31 25 32 * Option to display a default avatar for users who do not upload their own. 33 26 34 * Can be extended with fel64's "Identicons" plugin to give users the option of displaying an identicon instead of uploading an image (becomes their 'default' avatar). http://bbpress.org/forums/topic/1027?replies=25#post-6759 27 35 … … 30 38 UPGRADING? If you are using an older version of this plugin, you need to follow these installation instructions because the template functions are incompatible with older versions. 31 39 32 1. Open up the 'my-plugins/bb-avatar-upload.php' file and configure the "Configuration Settings". At least make sure the '$avatar_dir'variable is correct.40 1. Open up the `my-plugins/bb-avatar-upload.php` file and configure the "Configuration Settings". At least make sure the `$avatar_dir` variable is correct. 33 41 34 42 2. The avatar upload page should appear as a tab ("Avatar") on the user's Profile menu. If you'd prefer the link to be elsewhere, insert the following "Upload Avatar" link wherever you wish: 35 43 36 <a href="<?php profile_tab_link($user->ID, 'avatar'); ?>"><?php _e("Upload Avatar"); ?></a>44 `<a href="<?php profile_tab_link($user->ID, 'avatar'); ?>"><?php _e("Upload Avatar"); ?></a>` 37 45 38 Use the available $user->IDfor the page you place the link on.46 Use the available `$user->ID` for the page you place the link on. 39 47 40 48 3. To display an uploaded avatar, insert the following template function. 41 49 42 a) On the user's profile page ( 'profile.php'template).50 a) On the user's profile page (`profile.php` template). 43 51 44 <?php avatarupload_display($user->ID); ?>52 `<?php avatarupload_display($user->ID); ?>` 45 53 46 54 This grabs the avatar info file directly from the current user's profile information. 47 55 48 b) On each user's forum posts ( 'post.php'template)56 b) On each user's forum posts (`post.php` template) 49 57 50 <?php avatarupload_display(get_post_author_id()); ?>58 `<?php avatarupload_display(get_post_author_id()); ?>` 51 59 52 60 You can include the avatar anywhere else you like, just be sure to have the user's ID available. … … 54 62 c) If you just want the URI of the avatar (for your own plugins for example): 55 63 56 <?php avatarupload_get_avatar(ID); ?>64 `<?php avatarupload_get_avatar(ID); ?>` 57 65 58 66 Where ID is a user ID. Returns false if no avatar exists for that user. 59 67 60 4. OPTIONAL: open up 'my-templates/avatar.php'and edit the template if you wish, but be sure not to mess with the upload form.68 4. OPTIONAL: open up `my-templates/avatar.php` and edit the template if you wish, but be sure not to mess with the upload form. 61 69 62 70 5. Upload the plugin files to the following locations. 63 71 64 'avatars/default.png' - both 'avatars/' dir and image into the bbPress root dir. 65 'avatar-upload.php' - bbPress root dir. 66 'my-templates/avatar.php' - your 'my-templates/my-template-name/' (or kakumei) dir. 67 'my-plugins/bb-avatar-upload.php' - your 'my-plugins/' dir (and activated). 72 `avatars/default.png` - both `avatars/` dir and image into the bbPress root dir. 73 74 `avatar-upload.php` - bbPress root dir. 75 76 `my-templates/avatar.php` - your `my-templates/my-template-name/` (or kakumei) dir. 77 78 `my-plugins/bb-avatar-upload.php` - your `my-plugins/` dir (and activated). 68 79 69 80 That's it, the 'Avatar Upload' plugin should now be working. … … 77 88 = Are there security risks when allowing users to upload images to my server? = 78 89 79 The plugin checks the images upon upload to ensure that only gifs, jpegs/jpgs and pngs are allowed. It checks both the file extension (e.g. '.gif') AND the content-type (e.g. 'image/gif'), as well as ensuring the two match.90 The plugin checks the images upon upload to ensure that only gifs, jpegs/jpgs and pngs are allowed. It checks both the file extension (e.g. `.gif`) AND the content-type (e.g. `image/gif`), as well as ensuring the two match. 80 91 81 92 However, one can never 100% sure and there is always some security risks when allowing users to upload to your server. USE THIS PLUGIN AT YOUR OWN RISK! 82 93 83 = I get the following error (or similar): move_uploaded_file(/path/to/bbpress/avatars/user name.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /path/to/bbpress/avatar-upload.php on line XXX =94 = I get the following error (or similar): move_uploaded_file(/path/to/bbpress/avatars/user.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /path/to/bbpress/avatar-upload.php on line XXX = 84 95 85 You need to set the file permissions (chmod) of the 'avatars' folder to 666 to allow the plugin to write to the folder. You can do this using SHH or alternatively (and more easily) many FTP applications allow permissions setting. Please refer to your web host for their advice if you do not know how to do this. 86 96 You need to set the file permissions (chmod) of the `avatars` folder to `666` to allow the plugin to write to the folder. You can do this using SHH or alternatively (and more easily) many FTP applications allow permissions setting. Please refer to your web host for their advice if you do not know how to do this. 87 97 88 98 == Change Log == 89 99 90 2007-06-02 Ver. 0.4 made config vars into a class, totally overhauled upload script (streamlined), 91 amended readme instructions and fixed problem with pretty permalinks. 92 2007-05-02 Ver. 0.3 rewritten, config vars moved to plugin script, enabled default avatar, 93 added profile tab and made it possible to use plugin with other plugins. 94 2007-04-17 Ver. 0.2 reduced DB calls, added filename checks (to stop things like 95 "myavatar.exe.jpg"). 96 2007-04-07 Ver. 0.1 released. 100 2007-06-10 Ver. 0.4.1 minor bug fixes (and made readme more readable in the plugin browser). 101 102 2007-06-02 Ver. 0.4 made config vars into a class, totally overhauled upload script (streamlined), 103 amended readme instructions and fixed problem with pretty permalinks. 104 105 2007-05-02 Ver. 0.3 rewritten, config vars moved to plugin script, enabled default avatar, 106 added profile tab and made it possible to use plugin with other plugins. 107 108 2007-04-17 Ver. 0.2 reduced DB calls, added filename checks (to stop things like 109 "myavatar.exe.jpg"). 110 111 2007-04-07 Ver. 0.1 released.
