Changeset 440

Show
Ignore:
Timestamp:
06/10/07 10:43:48 (1 year ago)
Author:
louisedade
Message:

avatar-upload: committing version 0.4.1 - minor bug fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • avatar-upload/trunk/avatar-upload.php

    r437 r440  
    33Plugin Name: Avatar Upload 
    44Plugin URI: http://bbpress.org/plugins/topic/46 
    5 Version: 0.4 
     5Version: 0.4.1 
    66Description: Allows users to upload an avatar (gif, jpeg/jpg or png) image to bbPress. 
    77Author: Louise Dade 
     
    5050 
    5151        // Grab file extension 
    52         $img_ext = substr($img_name, strrpos($img_name, ".")+1); 
     52        $img_ext = strtolower(substr($img_name, strrpos($img_name, ".")+1)); 
    5353 
    5454        // Build the user's avatar filename 
     
    6565 
    6666        // 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)) ) 
    6868        { 
    6969                $img_errs = 4; 
     
    7171 
    7272        // 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)) ) 
    7474        { 
    7575                $img_errs = 8; 
     
    8686        { 
    8787                // Get the dimensions 
    88                 $dims = getimagesize($img_temp); 
     88                $dims = @getimagesize($img_temp); 
    8989                $img_w = $dims[0]; 
    9090                $img_h = $dims[1]; 
     
    9797 
    9898        // 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) ) 
    100100        { 
    101101                $img_errs = 11; 
     
    111111                        // If different, delete 'current' - this will only occur when 
    112112                        // 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]); 
    114114                } 
    115115 
  • avatar-upload/trunk/my-plugins/bb-avatar-upload.php

    r437 r440  
    33Plugin Name: Avatar Upload 
    44Plugin URI: http://bbpress.org/plugins/topic/46 
    5 Version: 0.4 
     5Version: 0.4.1 
    66Description: Allows users to upload an avatar (gif, jpeg/jpg or png) image to bbPress. 
    77Author: Louise Dade 
     
    7575                echo '<img src="'.$a[0]; 
    7676                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].'" />'; 
    7878        } else { 
    7979                $config = new avatarupload_config(); 
     
    118118                $a[0] = bb_get_option('uri') . $config->avatar_dir . $a[0]; 
    119119        } 
     120 
     121        // Add the username for use in 'alt' attribute to end of array 
     122        $a[] = $user->user_login; 
     123 
    120124        return $a; 
    121125} 
  • avatar-upload/trunk/readme.txt

    r437 r440  
    44Requires at least: 0.8 
    55Tested up to: 0.8.1 
    6 Stable Tag: 0.4 
     6Stable Tag: 0.4.1 
    77 
    88Allows users to upload an avatar (gif, jpeg/jpg or png) image to bbPress. Admins can configure maximum allowed file size and image dimensions. 
     
    1010== Description == 
    1111 
     12Allows users to upload an avatar (gif, jpeg/jpg or png) image to bbPress, and provides template functions to display the uploaded image. 
     13 
    1214Plugin URI: http://bbpress.org/plugins/topic/46 
    13 Author: Louise Dade 
     15 
    1416Author URI: http://www.classical-webdesigns.co.uk/ 
    1517 
    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 = 
    1719 
    18 Features: 
    1920* Bozos can not upload avatars. 
     21 
    2022* Admins can configure maximum allowed file size (bytes) and dimensions (pixels) of images. 
     23 
    2124  - Currently done from within the script (no Admin page interface at this time). 
     25 
    2226* Anybody with the 'moderate' capability can upload another user's avatar 
     27 
    2328  - this to ensures that inappropriate images can be removed. 
     29 
    2430  - 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 
    2532* Option to display a default avatar for users who do not upload their own. 
     33 
    2634* 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 
    2735 
     
    3038UPGRADING?  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. 
    3139 
    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. 
     401. 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. 
    3341 
    34422. 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: 
    3543 
    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>` 
    3745 
    38    Use the available $user->ID for the page you place the link on. 
     46   Use the available `$user->ID` for the page you place the link on. 
    3947 
    40483. To display an uploaded avatar, insert the following template function. 
    4149 
    42    a) On the user's profile page ('profile.php' template). 
     50   a) On the user's profile page (`profile.php` template). 
    4351       
    44       <?php avatarupload_display($user->ID); ?> 
     52      `<?php avatarupload_display($user->ID); ?>` 
    4553 
    4654      This grabs the avatar info file directly from the current user's profile information. 
    4755 
    48    b) On each user's forum posts ('post.php' template) 
     56   b) On each user's forum posts (`post.php` template) 
    4957 
    50       <?php avatarupload_display(get_post_author_id()); ?> 
     58      `<?php avatarupload_display(get_post_author_id()); ?>` 
    5159 
    5260   You can include the avatar anywhere else you like, just be sure to have the user's ID available. 
     
    5462  c) If you just want the URI of the avatar (for your own plugins for example): 
    5563 
    56      <?php avatarupload_get_avatar(ID); ?> 
     64     `<?php avatarupload_get_avatar(ID); ?>` 
    5765 
    5866     Where ID is a user ID. Returns false if no avatar exists for that user. 
    5967 
    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. 
     684. OPTIONAL: open up `my-templates/avatar.php` and edit the template if you wish, but be sure not to mess with the upload form. 
    6169 
    62705. Upload the plugin files to the following locations. 
    6371 
    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). 
    6879 
    6980That's it, the 'Avatar Upload' plugin should now be working. 
     
    7788= Are there security risks when allowing users to upload images to my server? = 
    7889 
    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. 
     90The 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. 
    8091 
    8192However, 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! 
    8293 
    83 = I get the following error (or similar): move_uploaded_file(/path/to/bbpress/avatars/username.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 = 
    8495 
    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  
     96You 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. 
    8797 
    8898== Change Log == 
    8999 
    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. 
     1002007-06-10 Ver. 0.4.1 minor bug fixes (and made readme more readable in the plugin browser). 
     101 
     1022007-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 
     1052007-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 
     1082007-04-17 Ver. 0.2   reduced DB calls, added filename checks (to stop things like  
     109                      "myavatar.exe.jpg"). 
     110 
     1112007-04-07 Ver. 0.1   released.