ImpEx does not handle PHPBB3 avatars correctly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jay Lucky
    New Member
    • Feb 2010
    • 16
    • 4.0.0

    ImpEx does not handle PHPBB3 avatars correctly

    PHPBB3 (and probably 2) have 3 types of possible avatars - remote aka a URL, user uploaded, and gallery. ImpEx can only handle a remote URL avatar and a gallery avatar, but not a custom user uploaded one.

    I've been digging through the ImpEx and PHPBB code the last few days to make sure and I figured I would post here and let Jerry know (if he doesn't already) a possible solution.

    In the PHPBB users table, there is a field called user_avatar_type. This field has a numeric value that corresponds with the above options.

    0 = AVATAR_REMOTE
    1 = AVATAR_UPLOAD
    2 = AVATAR_GALLERY

    Based on this, you can determine where a users avatar will be. If it's a 0, then the field user_avatar will contain the URL to the avatar and you can simply grab that using the existing ImpEx routine in 004.php. Instead of having to test for the http:// string, you can test if the user_avatar_type field is equal to 0.

    For the second type, AVATAR_UPLOAD, some additional data will be required, so a new data array will need to be created for the configuration data in the PHPBB config table.

    I would suggesting grabbing all of the values here in case future needs arise, but if you simply want to deal only with avatars, you should specifically grab the avatar_path, avatar_gallery_path, and avatar_salt fields. By grabbing the 2 path values, you will not need to ask the user for the avatar path in the 004 module. You will already have this available to you, you only simply need to know the effective forum document root (e.g. /var/www/forums) and you can then combine these values to form the location.

    So, with the new values at your disposal, you can now locate custom avatars that a user has uploaded by testing for the avatar_user_type value of 1. The contents of the user_avatar field now contain something that does not exactly equal what the filename should be... you have to form this filename by doing a couple of things.

    First, you create the filename prefix with the avatar_salt value from the config table and an underscore. This salt value is a 32 bit hash that is set somewhere in the install process. Next, you need to use the value of the user_avatar field to test if this is a group avatar or a user avatar. If the value begins with a 'g', then it is a group avatar and a flag will need to be set to true, otherwise it will be false. Group avatars are set for all members of the particular group, so when importing these, each member of the group should get this particular avatar. The next value after the 'g' will be the group_id number that this is an avatar for, followed by an underscore and the system time in UTC that the avatar was created, with the filetype extension at the end (.png, .jpg, .gif, etc).

    For example:

    Given that the value of user_avatar = g100_1267934473.jpg and avatar_salt = 79d4e37a4f5689df53b92aa6c9a57ed8, the filename will be <FORUM_ROOT>/<avatar_path>/79d4e37a4f5689df53b92aa6c9a57ed8_g100.jpg

    This avatar would need to be set for all members of the group_id = 100.

    For a user avatar, the 'g' will not be present in the user_avatar field, but the rest will remain the same. The difference here is that the value at the beginning is the user_id and not the group_id.

    For example:

    Given that the value of user_avatar = 5_1267934473.png and avatar_salt = 79d4e37a4f5689df53b92aa6c9a57ed8, the filename will be <FORUM_ROOT>/<avatar_path>/79d4e37a4f5689df53b92aa6c9a57ed8_5.png

    This avatar is exclusive to the user_id of 5 and should only be set for this user.

    The last avatar type is the AVATAR_GALLERY one, which can be tested for by the value of 2 in the user_avatar_type field. If this is true, then the avatar resides in the avatar_gallery_path and can be assumed to be the user_avatar value.

    For example:

    Given that the value of user_avatar = muppets/kermit_the_frog.png, the filename will be <FORUM_ROOT>/<avatar_gallery_path>/muppets/kermit_the_frog.png


    Sorry if this is long winded, but I thought I would put this out there in hope that it could be incorporated into a future (hopefully soon ) release of ImpEx. I am working on putting a very ugly kludge into place to do my import using this knowledge, but I dare say that it will be a very usefull and wide functioning patch for everyone.

    Please let me know if there are questions, etc and I will do my best to answer!
  • lyl
    New Member
    • Apr 2010
    • 1
    • 4.0.0

    #2
    Is there a work around for this? I am mainly concerned with uploaded avatars. (Using phpBB3 3.0.7-PL1)

    Comment

    • mbreezy
      New Member
      • May 2010
      • 23
      • 4.0.0

      #3
      Also looking for a work around. phpBB 3.0.5

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...