منتدى استراحات زايد

منتدى استراحات زايد (http://vb.ma7room.com/index.php)
-   منتدى أخبار المواقع والمنتديات العربية والأجنبية (http://vb.ma7room.com/forumdisplay.php?f=183)
-   -   ImpEx does not handle PHPBB3 avatars correctly (http://vb.ma7room.com/showthread.php?t=348943)

محروم.كوم 03-07-2010 08:40 AM

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 //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 //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 //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!


الساعة الآن 03:47 PM

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.5.2 TranZ By Almuhajir


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227