| @@ -1,35 +1,91 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * Implementation of phpBB converter. | |
| 4 | + * bbPress phpBB 3.x Converter | |
| 5 | + * | |
| 6 | + * @package bbPress | |
| 7 | + * @subpackage Converters | |
| 5 | 8 | */ |
| 9 | + | |
| 10 | +/** | |
| 11 | + * Implementation of phpBB v3 Converter. | |
| 12 | + * | |
| 13 | + * @since 2.3.0 bbPress (r4689) | |
| 14 | + * | |
| 15 | + * @link Codex Docs https://codex.bbpress.org/import-forums/phpbb | |
| 16 | + */ | |
| 6 | 17 | class phpBB extends BBP_Converter_Base { |
| 7 | - function __construct() { | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * Main Constructor | |
| 21 | + * | |
| 22 | + */ | |
| 23 | + public function __construct() { | |
| 8 | 24 | parent::__construct(); |
| 9 | - $this->setup_globals(); | |
| 10 | 25 | } |
| 11 | 26 | |
| 27 | + /** | |
| 28 | + * Sets up the field mappings | |
| 29 | + */ | |
| 12 | 30 | public function setup_globals() { |
| 13 | 31 | |
| 14 | - /** Forum Section ******************************************************/ | |
| 32 | + // Setup smiley URL & path | |
| 33 | + $this->bbcode_parser_properties = array( | |
| 34 | + 'smiley_url' => false, | |
| 35 | + 'smiley_dir' => false | |
| 36 | + ); | |
| 15 | 37 | |
| 16 | - // Forum id. Stored in postmeta. | |
| 38 | + /** Forum Section *****************************************************/ | |
| 39 | + | |
| 40 | + // Old forum id (Stored in postmeta) | |
| 17 | 41 | $this->field_map[] = array( |
| 18 | 42 | 'from_tablename' => 'forums', |
| 19 | 43 | 'from_fieldname' => 'forum_id', |
| 20 | 44 | 'to_type' => 'forum', |
| 21 | - 'to_fieldname' => '_bbp_forum_id' | |
| 45 | + 'to_fieldname' => '_bbp_old_forum_id' | |
| 22 | 46 | ); |
| 23 | - | |
| 24 | - // Forum parent id. If no parent, than 0. Stored in postmeta. | |
| 47 | + | |
| 48 | + // Forum parent id (If no parent, then 0, Stored in postmeta) | |
| 25 | 49 | $this->field_map[] = array( |
| 26 | 50 | 'from_tablename' => 'forums', |
| 27 | 51 | 'from_fieldname' => 'parent_id', |
| 28 | 52 | 'to_type' => 'forum', |
| 29 | - 'to_fieldname' => '_bbp_parent_id' | |
| 53 | + 'to_fieldname' => '_bbp_old_forum_parent_id' | |
| 30 | 54 | ); |
| 31 | - | |
| 55 | + | |
| 56 | + // Forum topic count (Stored in postmeta) | |
| 57 | + $this->field_map[] = array( | |
| 58 | + 'from_tablename' => 'forums', | |
| 59 | + 'from_fieldname' => 'forum_topics_approved', | |
| 60 | + 'to_type' => 'forum', | |
| 61 | + 'to_fieldname' => '_bbp_topic_count' | |
| 62 | + ); | |
| 63 | + | |
| 64 | + // Forum reply count (Stored in postmeta) | |
| 65 | + $this->field_map[] = array( | |
| 66 | + 'from_tablename' => 'forums', | |
| 67 | + 'from_fieldname' => 'forum_posts_approved', | |
| 68 | + 'to_type' => 'forum', | |
| 69 | + 'to_fieldname' => '_bbp_reply_count' | |
| 70 | + ); | |
| 71 | + | |
| 72 | + // Forum total topic count (Includes unpublished topics, Stored in postmeta) | |
| 73 | + $this->field_map[] = array( | |
| 74 | + 'from_tablename' => 'forums', | |
| 75 | + 'from_fieldname' => 'forum_topics_approved', | |
| 76 | + 'to_type' => 'forum', | |
| 77 | + 'to_fieldname' => '_bbp_total_topic_count' | |
| 78 | + ); | |
| 79 | + | |
| 80 | + // Forum total reply count (Includes unpublished replies, Stored in postmeta) | |
| 81 | + $this->field_map[] = array( | |
| 82 | + 'from_tablename' => 'forums', | |
| 83 | + 'from_fieldname' => 'forum_posts_approved', | |
| 84 | + 'to_type' => 'forum', | |
| 85 | + 'to_fieldname' => '_bbp_total_reply_count' | |
| 86 | + ); | |
| 87 | + | |
| 32 | 88 | // Forum title. |
| 33 | 89 | $this->field_map[] = array( |
| 34 | 90 | 'from_tablename' => 'forums', |
| 35 | 91 | 'from_fieldname' => 'forum_name', |
| @@ -35,10 +91,10 @@ | ||
| 35 | 91 | 'from_fieldname' => 'forum_name', |
| 36 | 92 | 'to_type' => 'forum', |
| 37 | 93 | 'to_fieldname' => 'post_title' |
| 38 | 94 | ); |
| 39 | - | |
| 40 | - // Forum slug. Clean name. | |
| 95 | + | |
| 96 | + // Forum slug (Clean name to avoid conflicts) | |
| 41 | 97 | $this->field_map[] = array( |
| 42 | 98 | 'from_tablename' => 'forums', |
| 43 | 99 | 'from_fieldname' => 'forum_name', |
| 44 | 100 | 'to_type' => 'forum', |
| @@ -44,9 +100,9 @@ | ||
| 44 | 100 | 'to_type' => 'forum', |
| 45 | 101 | 'to_fieldname' => 'post_name', |
| 46 | 102 | 'callback_method' => 'callback_slug' |
| 47 | 103 | ); |
| 48 | - | |
| 104 | + | |
| 49 | 105 | // Forum description. |
| 50 | 106 | $this->field_map[] = array( |
| 51 | 107 | 'from_tablename' => 'forums', |
| 52 | 108 | 'from_fieldname' => 'forum_desc', |
| @@ -53,58 +109,113 @@ | ||
| 53 | 109 | 'to_type' => 'forum', |
| 54 | 110 | 'to_fieldname' => 'post_content', |
| 55 | 111 | 'callback_method' => 'callback_null' |
| 56 | 112 | ); |
| 57 | - | |
| 58 | - // Forum display order. Starts from 1. | |
| 113 | + | |
| 114 | + // Forum display order (Starts from 1) | |
| 59 | 115 | $this->field_map[] = array( |
| 60 | 116 | 'from_tablename' => 'forums', |
| 61 | - 'from_fieldname' => 'display_on_index', | |
| 117 | + 'from_fieldname' => 'left_id', | |
| 62 | 118 | 'to_type' => 'forum', |
| 63 | 119 | 'to_fieldname' => 'menu_order' |
| 64 | 120 | ); |
| 65 | - | |
| 66 | - // Forum date update. | |
| 121 | + | |
| 122 | + // Forum type (Category = 0 or Forum = 1, Stored in postmeta) | |
| 67 | 123 | $this->field_map[] = array( |
| 68 | - 'to_type' => 'forums', | |
| 69 | - 'to_fieldname' => 'forum_last_post_time', | |
| 70 | - 'default' => date('Y-m-d H:i:s') | |
| 124 | + 'from_tablename' => 'forums', | |
| 125 | + 'from_fieldname' => 'forum_type', | |
| 126 | + 'to_type' => 'forum', | |
| 127 | + 'to_fieldname' => '_bbp_forum_type', | |
| 128 | + 'callback_method' => 'callback_forum_type' | |
| 71 | 129 | ); |
| 130 | + | |
| 131 | + // Forum status (Unlocked = 0 or Locked = 1, Stored in postmeta) | |
| 72 | 132 | $this->field_map[] = array( |
| 73 | - 'to_type' => 'forums', | |
| 74 | - 'to_fieldname' => 'forum_last_post_time', | |
| 75 | - 'default' => date('Y-m-d H:i:s') | |
| 133 | + 'from_tablename' => 'forums', | |
| 134 | + 'from_fieldname' => 'forum_status', | |
| 135 | + 'to_type' => 'forum', | |
| 136 | + 'to_fieldname' => '_bbp_status', | |
| 137 | + 'callback_method' => 'callback_forum_status' | |
| 76 | 138 | ); |
| 139 | + | |
| 140 | + // Forum dates. | |
| 77 | 141 | $this->field_map[] = array( |
| 78 | - 'to_type' => 'forums', | |
| 79 | - 'to_fieldname' => 'forum_last_post_time', | |
| 80 | - 'default' => date('Y-m-d H:i:s') | |
| 142 | + 'to_type' => 'forum', | |
| 143 | + 'to_fieldname' => 'post_date', | |
| 144 | + 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date | |
| 81 | 145 | ); |
| 82 | 146 | $this->field_map[] = array( |
| 83 | - 'to_type' => 'forums', | |
| 84 | - 'to_fieldname' => 'forum_last_post_time', | |
| 85 | - 'default' => date('Y-m-d H:i:s') | |
| 147 | + 'to_type' => 'forum', | |
| 148 | + 'to_fieldname' => 'post_date_gmt', | |
| 149 | + 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date | |
| 86 | 150 | ); |
| 151 | + $this->field_map[] = array( | |
| 152 | + 'to_type' => 'forum', | |
| 153 | + 'to_fieldname' => 'post_modified', | |
| 154 | + 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date | |
| 155 | + ); | |
| 156 | + $this->field_map[] = array( | |
| 157 | + 'to_type' => 'forum', | |
| 158 | + 'to_fieldname' => 'post_modified_gmt', | |
| 159 | + 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date | |
| 160 | + ); | |
| 87 | 161 | |
| 88 | - /** Topic Section ******************************************************/ | |
| 162 | + /** Forum Subscriptions Section ***************************************/ | |
| 89 | 163 | |
| 90 | - // Topic id. Stored in postmeta. | |
| 164 | + // Subscribed forum ID (Stored in usermeta) | |
| 91 | 165 | $this->field_map[] = array( |
| 166 | + 'from_tablename' => 'forums_watch', | |
| 167 | + 'from_fieldname' => 'forum_id', | |
| 168 | + 'to_type' => 'forum_subscriptions', | |
| 169 | + 'to_fieldname' => '_bbp_forum_subscriptions' | |
| 170 | + ); | |
| 171 | + | |
| 172 | + // Subscribed user ID (Stored in usermeta) | |
| 173 | + $this->field_map[] = array( | |
| 174 | + 'from_tablename' => 'forums_watch', | |
| 175 | + 'from_fieldname' => 'user_id', | |
| 176 | + 'to_type' => 'forum_subscriptions', | |
| 177 | + 'to_fieldname' => 'user_id', | |
| 178 | + 'callback_method' => 'callback_userid' | |
| 179 | + ); | |
| 180 | + | |
| 181 | + /** Topic Section *****************************************************/ | |
| 182 | + | |
| 183 | + // Old topic id (Stored in postmeta) | |
| 184 | + $this->field_map[] = array( | |
| 92 | 185 | 'from_tablename' => 'topics', |
| 93 | 186 | 'from_fieldname' => 'topic_id', |
| 94 | 187 | 'to_type' => 'topic', |
| 95 | - 'to_fieldname' => '_bbp_topic_id' | |
| 188 | + 'to_fieldname' => '_bbp_old_topic_id' | |
| 96 | 189 | ); |
| 97 | - | |
| 98 | - // Forum id. Stored in postmeta. | |
| 190 | + | |
| 191 | + // Topic reply count (Stored in postmeta) | |
| 99 | 192 | $this->field_map[] = array( |
| 100 | 193 | 'from_tablename' => 'topics', |
| 194 | + 'from_fieldname' => 'topic_posts_approved', | |
| 195 | + 'to_type' => 'topic', | |
| 196 | + 'to_fieldname' => '_bbp_reply_count', | |
| 197 | + 'callback_method' => 'callback_topic_reply_count' | |
| 198 | + ); | |
| 199 | + | |
| 200 | + // Topic total reply count (Includes unpublished replies, Stored in postmeta) | |
| 201 | + $this->field_map[] = array( | |
| 202 | + 'from_tablename' => 'topics', | |
| 203 | + 'from_fieldname' => 'topic_posts_approved', | |
| 204 | + 'to_type' => 'topic', | |
| 205 | + 'to_fieldname' => '_bbp_total_reply_count', | |
| 206 | + 'callback_method' => 'callback_topic_reply_count' | |
| 207 | + ); | |
| 208 | + | |
| 209 | + // Topic parent forum id (If no parent, then 0. Stored in postmeta) | |
| 210 | + $this->field_map[] = array( | |
| 211 | + 'from_tablename' => 'topics', | |
| 101 | 212 | 'from_fieldname' => 'forum_id', |
| 102 | 213 | 'to_type' => 'topic', |
| 103 | 214 | 'to_fieldname' => '_bbp_forum_id', |
| 104 | 215 | 'callback_method' => 'callback_forumid' |
| 105 | 216 | ); |
| 106 | - | |
| 217 | + | |
| 107 | 218 | // Topic author. |
| 108 | 219 | $this->field_map[] = array( |
| 109 | 220 | 'from_tablename' => 'topics', |
| 110 | 221 | 'from_fieldname' => 'topic_poster', |
| @@ -112,9 +223,38 @@ | ||
| 112 | 223 | 'to_fieldname' => 'post_author', |
| 113 | 224 | 'callback_method' => 'callback_userid' |
| 114 | 225 | ); |
| 115 | 226 | |
| 227 | + // Topic author name (Stored in postmeta as _bbp_anonymous_name) | |
| 228 | + $this->field_map[] = array( | |
| 229 | + 'from_tablename' => 'topics', | |
| 230 | + 'from_fieldname' => 'topic_first_poster_name', | |
| 231 | + 'to_type' => 'topic', | |
| 232 | + 'to_fieldname' => '_bbp_old_topic_author_name_id' | |
| 233 | + ); | |
| 234 | + | |
| 235 | + // Is the topic anonymous (Stored in postmeta) | |
| 236 | + $this->field_map[] = array( | |
| 237 | + 'from_tablename' => 'topics', | |
| 238 | + 'from_fieldname' => 'topic_poster', | |
| 239 | + 'to_type' => 'topic', | |
| 240 | + 'to_fieldname' => '_bbp_old_is_topic_anonymous_id', | |
| 241 | + 'callback_method' => 'callback_check_anonymous' | |
| 242 | + ); | |
| 243 | + | |
| 244 | + // Topic Author ip (Stored in postmeta) | |
| 245 | + $this->field_map[] = array( | |
| 246 | + 'from_tablename' => 'posts', | |
| 247 | + 'from_fieldname' => 'poster_ip', | |
| 248 | + 'join_tablename' => 'topics', | |
| 249 | + 'join_type' => 'INNER', | |
| 250 | + 'join_expression' => 'USING (topic_id) WHERE posts.post_id = topics.topic_first_post_id', | |
| 251 | + 'to_type' => 'topic', | |
| 252 | + 'to_fieldname' => '_bbp_author_ip' | |
| 253 | + ); | |
| 254 | + | |
| 116 | 255 | // Topic content. |
| 256 | + // Note: We join the 'posts' table because 'topics' does not include topic content. | |
| 117 | 257 | $this->field_map[] = array( |
| 118 | 258 | 'from_tablename' => 'posts', |
| 119 | 259 | 'from_fieldname' => 'post_text', |
| 120 | 260 | 'join_tablename' => 'topics', |
| @@ -122,9 +262,9 @@ | ||
| 122 | 262 | 'join_expression' => 'USING (topic_id) WHERE posts.post_id = topics.topic_first_post_id', |
| 123 | 263 | 'to_type' => 'topic', |
| 124 | 264 | 'to_fieldname' => 'post_content', |
| 125 | 265 | 'callback_method' => 'callback_html' |
| 126 | - ); | |
| 266 | + ); | |
| 127 | 267 | |
| 128 | 268 | // Topic title. |
| 129 | 269 | $this->field_map[] = array( |
| 130 | 270 | 'from_tablename' => 'topics', |
| @@ -131,10 +271,10 @@ | ||
| 131 | 271 | 'from_fieldname' => 'topic_title', |
| 132 | 272 | 'to_type' => 'topic', |
| 133 | 273 | 'to_fieldname' => 'post_title' |
| 134 | 274 | ); |
| 135 | - | |
| 136 | - // Topic slug. Clean name. | |
| 275 | + | |
| 276 | + // Topic slug (Clean name to avoid conflicts) | |
| 137 | 277 | $this->field_map[] = array( |
| 138 | 278 | 'from_tablename' => 'topics', |
| 139 | 279 | 'from_fieldname' => 'topic_title', |
| 140 | 280 | 'to_type' => 'topic', |
| @@ -140,12 +280,21 @@ | ||
| 140 | 280 | 'to_type' => 'topic', |
| 141 | 281 | 'to_fieldname' => 'post_name', |
| 142 | 282 | 'callback_method' => 'callback_slug' |
| 143 | 283 | ); |
| 144 | - | |
| 145 | - // Forum id. If no parent, than 0. | |
| 284 | + | |
| 285 | + // Topic status (Open or Closed) | |
| 146 | 286 | $this->field_map[] = array( |
| 147 | 287 | 'from_tablename' => 'topics', |
| 288 | + 'from_fieldname' => 'topic_status', | |
| 289 | + 'to_type' => 'topic', | |
| 290 | + 'to_fieldname' => '_bbp_old_closed_status_id', | |
| 291 | + 'callback_method' => 'callback_topic_status' | |
| 292 | + ); | |
| 293 | + | |
| 294 | + // Topic parent forum id (If no parent, then 0) | |
| 295 | + $this->field_map[] = array( | |
| 296 | + 'from_tablename' => 'topics', | |
| 148 | 297 | 'from_fieldname' => 'forum_id', |
| 149 | 298 | 'to_type' => 'topic', |
| 150 | 299 | 'to_fieldname' => 'post_parent', |
| 151 | 300 | 'callback_method' => 'callback_forumid' |
| @@ -150,11 +299,20 @@ | ||
| 150 | 299 | 'to_fieldname' => 'post_parent', |
| 151 | 300 | 'callback_method' => 'callback_forumid' |
| 152 | 301 | ); |
| 153 | 302 | |
| 154 | - // Topic date update. | |
| 303 | + // Sticky status (Stored in postmeta) | |
| 155 | 304 | $this->field_map[] = array( |
| 156 | 305 | 'from_tablename' => 'topics', |
| 306 | + 'from_fieldname' => 'topic_type', | |
| 307 | + 'to_type' => 'topic', | |
| 308 | + 'to_fieldname' => '_bbp_old_sticky_status_id', | |
| 309 | + 'callback_method' => 'callback_sticky_status' | |
| 310 | + ); | |
| 311 | + | |
| 312 | + // Topic dates. | |
| 313 | + $this->field_map[] = array( | |
| 314 | + 'from_tablename' => 'topics', | |
| 157 | 315 | 'from_fieldname' => 'topic_time', |
| 158 | 316 | 'to_type' => 'topic', |
| 159 | 317 | 'to_fieldname' => 'post_date', |
| 160 | 318 | 'callback_method' => 'callback_datetime' |
| @@ -179,43 +337,71 @@ | ||
| 179 | 337 | 'to_type' => 'topic', |
| 180 | 338 | 'to_fieldname' => 'post_modified_gmt', |
| 181 | 339 | 'callback_method' => 'callback_datetime' |
| 182 | 340 | ); |
| 183 | - | |
| 341 | + $this->field_map[] = array( | |
| 342 | + 'from_tablename' => 'topics', | |
| 343 | + 'from_fieldname' => 'topic_last_post_time', | |
| 344 | + 'to_type' => 'topic', | |
| 345 | + 'to_fieldname' => '_bbp_last_active_time', | |
| 346 | + 'callback_method' => 'callback_datetime' | |
| 347 | + ); | |
| 348 | + | |
| 184 | 349 | /** Tags Section ******************************************************/ |
| 185 | - /* | |
| 186 | - // Topic id. | |
| 350 | + | |
| 351 | + /** | |
| 352 | + * phpBB Forums do not support topic tags | |
| 353 | + */ | |
| 354 | + | |
| 355 | + /** Topic Subscriptions Section ***************************************/ | |
| 356 | + | |
| 357 | + // Subscribed topic ID (Stored in usermeta) | |
| 187 | 358 | $this->field_map[] = array( |
| 188 | - 'from_tablename' => 'tagcontent', | |
| 189 | - 'from_fieldname' => 'contentid', | |
| 190 | - 'to_type' => 'tags', | |
| 191 | - 'to_fieldname' => 'objectid', | |
| 192 | - 'callback_method' => 'callback_topicid' | |
| 359 | + 'from_tablename' => 'topics_watch', | |
| 360 | + 'from_fieldname' => 'topic_id', | |
| 361 | + 'to_type' => 'topic_subscriptions', | |
| 362 | + 'to_fieldname' => '_bbp_subscriptions' | |
| 193 | 363 | ); |
| 194 | - | |
| 195 | - // Tags text. | |
| 364 | + | |
| 365 | + // Subscribed user ID (Stored in usermeta) | |
| 196 | 366 | $this->field_map[] = array( |
| 197 | - 'from_tablename' => 'tag', | |
| 198 | - 'from_fieldname' => 'tagtext', | |
| 199 | - 'join_tablename' => 'tagcontent', | |
| 200 | - 'join_type' => 'INNER', | |
| 201 | - 'join_expression' => 'USING (tagid)', | |
| 202 | - 'to_type' => 'tags', | |
| 203 | - 'to_fieldname' => 'name' | |
| 204 | - ); | |
| 205 | - */ | |
| 206 | - | |
| 207 | - /** Post Section ******************************************************/ | |
| 367 | + 'from_tablename' => 'topics_watch', | |
| 368 | + 'from_fieldname' => 'user_id', | |
| 369 | + 'to_type' => 'topic_subscriptions', | |
| 370 | + 'to_fieldname' => 'user_id', | |
| 371 | + 'callback_method' => 'callback_userid' | |
| 372 | + ); | |
| 208 | 373 | |
| 209 | - // Post id. Stores in postmeta. | |
| 374 | + /** Favorites Section *************************************************/ | |
| 375 | + | |
| 376 | + // Favorited topic ID (Stored in usermeta) | |
| 210 | 377 | $this->field_map[] = array( |
| 378 | + 'from_tablename' => 'bookmarks', | |
| 379 | + 'from_fieldname' => 'topic_id', | |
| 380 | + 'to_type' => 'favorites', | |
| 381 | + 'to_fieldname' => '_bbp_favorites' | |
| 382 | + ); | |
| 383 | + | |
| 384 | + // Favorited user ID (Stored in usermeta) | |
| 385 | + $this->field_map[] = array( | |
| 386 | + 'from_tablename' => 'bookmarks', | |
| 387 | + 'from_fieldname' => 'user_id', | |
| 388 | + 'to_type' => 'favorites', | |
| 389 | + 'to_fieldname' => 'user_id', | |
| 390 | + 'callback_method' => 'callback_userid' | |
| 391 | + ); | |
| 392 | + | |
| 393 | + /** Reply Section *****************************************************/ | |
| 394 | + | |
| 395 | + // Old reply id (Stored in postmeta) | |
| 396 | + $this->field_map[] = array( | |
| 211 | 397 | 'from_tablename' => 'posts', |
| 212 | 398 | 'from_fieldname' => 'post_id', |
| 213 | 399 | 'to_type' => 'reply', |
| 214 | - 'to_fieldname' => '_bbp_post_id' | |
| 400 | + 'to_fieldname' => '_bbp_old_reply_id' | |
| 215 | 401 | ); |
| 216 | - | |
| 217 | - // Topic content. | |
| 402 | + | |
| 403 | + // Setup reply section table joins | |
| 218 | 404 | $this->field_map[] = array( |
| 219 | 405 | 'from_tablename' => 'topics', |
| 220 | 406 | 'from_fieldname' => 'topic_id', |
| 221 | 407 | 'join_tablename' => 'posts', |
| @@ -221,20 +407,20 @@ | ||
| 221 | 407 | 'join_tablename' => 'posts', |
| 222 | 408 | 'join_type' => 'LEFT', |
| 223 | 409 | 'join_expression' => 'USING (topic_id) WHERE posts.post_id != topics.topic_first_post_id', |
| 224 | 410 | 'to_type' => 'reply' |
| 225 | - ); | |
| 226 | - | |
| 227 | - // Forum id. Stores in postmeta. | |
| 411 | + ); | |
| 412 | + | |
| 413 | + // Reply parent forum id (If no parent, then 0. Stored in postmeta) | |
| 228 | 414 | $this->field_map[] = array( |
| 229 | 415 | 'from_tablename' => 'posts', |
| 230 | 416 | 'from_fieldname' => 'forum_id', |
| 231 | 417 | 'to_type' => 'reply', |
| 232 | 418 | 'to_fieldname' => '_bbp_forum_id', |
| 233 | - 'callback_method' => 'callback_topicid_to_forumid' | |
| 419 | + 'callback_method' => 'callback_forumid' | |
| 234 | 420 | ); |
| 235 | - | |
| 236 | - // Topic id. Stores in postmeta. | |
| 421 | + | |
| 422 | + // Reply parent topic id (If no parent, then 0. Stored in postmeta) | |
| 237 | 423 | $this->field_map[] = array( |
| 238 | 424 | 'from_tablename' => 'posts', |
| 239 | 425 | 'from_fieldname' => 'topic_id', |
| 240 | 426 | 'to_type' => 'reply', |
| @@ -240,18 +426,18 @@ | ||
| 240 | 426 | 'to_type' => 'reply', |
| 241 | 427 | 'to_fieldname' => '_bbp_topic_id', |
| 242 | 428 | 'callback_method' => 'callback_topicid' |
| 243 | 429 | ); |
| 244 | - | |
| 245 | - // Author ip. | |
| 430 | + | |
| 431 | + // Reply author ip (Stored in postmeta) | |
| 246 | 432 | $this->field_map[] = array( |
| 247 | 433 | 'from_tablename' => 'posts', |
| 248 | 434 | 'from_fieldname' => 'poster_ip', |
| 249 | 435 | 'to_type' => 'reply', |
| 250 | 436 | 'to_fieldname' => '_bbp_author_ip' |
| 251 | - ); | |
| 252 | - | |
| 253 | - // Post author. | |
| 437 | + ); | |
| 438 | + | |
| 439 | + // Reply author. | |
| 254 | 440 | $this->field_map[] = array( |
| 255 | 441 | 'from_tablename' => 'posts', |
| 256 | 442 | 'from_fieldname' => 'poster_id', |
| 257 | 443 | 'to_type' => 'reply', |
| @@ -257,27 +443,27 @@ | ||
| 257 | 443 | 'to_type' => 'reply', |
| 258 | 444 | 'to_fieldname' => 'post_author', |
| 259 | 445 | 'callback_method' => 'callback_userid' |
| 260 | 446 | ); |
| 261 | - | |
| 262 | - // Topic title. | |
| 447 | + | |
| 448 | + // Reply author name (Stored in postmeta as _bbp_anonymous_name) | |
| 263 | 449 | $this->field_map[] = array( |
| 264 | - 'from_tablename' => 'posts', | |
| 265 | - 'from_fieldname' => 'post_subject', | |
| 266 | - 'to_type' => 'reply', | |
| 267 | - 'to_fieldname' => 'post_title' | |
| 450 | + 'from_tablename' => 'posts', | |
| 451 | + 'from_fieldname' => 'post_username', | |
| 452 | + 'to_type' => 'reply', | |
| 453 | + 'to_fieldname' => '_bbp_old_reply_author_name_id' | |
| 268 | 454 | ); |
| 269 | - | |
| 270 | - // Topic slug. Clean name. | |
| 455 | + | |
| 456 | + // Is the reply anonymous (Stored in postmeta) | |
| 271 | 457 | $this->field_map[] = array( |
| 272 | 458 | 'from_tablename' => 'posts', |
| 273 | - 'from_fieldname' => 'post_subject', | |
| 459 | + 'from_fieldname' => 'poster_id', | |
| 274 | 460 | 'to_type' => 'reply', |
| 275 | - 'to_fieldname' => 'post_name', | |
| 276 | - 'callback_method' => 'callback_slug' | |
| 461 | + 'to_fieldname' => '_bbp_old_is_reply_anonymous_id', | |
| 462 | + 'callback_method' => 'callback_check_anonymous' | |
| 277 | 463 | ); |
| 278 | - | |
| 279 | - // Post content. | |
| 464 | + | |
| 465 | + // Reply content. | |
| 280 | 466 | $this->field_map[] = array( |
| 281 | 467 | 'from_tablename' => 'posts', |
| 282 | 468 | 'from_fieldname' => 'post_text', |
| 283 | 469 | 'to_type' => 'reply', |
| @@ -283,10 +469,10 @@ | ||
| 283 | 469 | 'to_type' => 'reply', |
| 284 | 470 | 'to_fieldname' => 'post_content', |
| 285 | 471 | 'callback_method' => 'callback_html' |
| 286 | 472 | ); |
| 287 | - | |
| 288 | - // Topic id. If no parent, than 0. | |
| 473 | + | |
| 474 | + // Reply parent topic id (If no parent, then 0) | |
| 289 | 475 | $this->field_map[] = array( |
| 290 | 476 | 'from_tablename' => 'posts', |
| 291 | 477 | 'from_fieldname' => 'topic_id', |
| 292 | 478 | 'to_type' => 'reply', |
| @@ -293,9 +479,9 @@ | ||
| 293 | 479 | 'to_fieldname' => 'post_parent', |
| 294 | 480 | 'callback_method' => 'callback_topicid' |
| 295 | 481 | ); |
| 296 | 482 | |
| 297 | - // Topic date update. | |
| 483 | + // Reply dates. | |
| 298 | 484 | $this->field_map[] = array( |
| 299 | 485 | 'from_tablename' => 'posts', |
| 300 | 486 | 'from_fieldname' => 'post_time', |
| 301 | 487 | 'to_type' => 'reply', |
| @@ -325,17 +511,18 @@ | ||
| 325 | 511 | ); |
| 326 | 512 | |
| 327 | 513 | /** User Section ******************************************************/ |
| 328 | 514 | |
| 329 | - // Store old User id. Stores in usermeta. | |
| 515 | + // Store old user id (Stored in usermeta) | |
| 516 | + // Don't import users with id 2, these are phpBB bot/crawler accounts | |
| 330 | 517 | $this->field_map[] = array( |
| 331 | - 'from_tablename' => 'users', | |
| 332 | - 'from_fieldname' => 'user_id', | |
| 333 | - 'to_type' => 'user', | |
| 334 | - 'to_fieldname' => '_bbp_user_id' | |
| 518 | + 'from_tablename' => 'users', | |
| 519 | + 'from_fieldname' => 'user_id', | |
| 520 | + 'to_type' => 'user', | |
| 521 | + 'to_fieldname' => '_bbp_old_user_id' | |
| 335 | 522 | ); |
| 336 | - | |
| 337 | - // Store old User password. Stores in usermeta serialized with salt. | |
| 523 | + | |
| 524 | + // Store old user password (Stored in usermeta serialized with salt) | |
| 338 | 525 | $this->field_map[] = array( |
| 339 | 526 | 'from_tablename' => 'users', |
| 340 | 527 | 'from_fieldname' => 'user_password', |
| 341 | 528 | 'to_type' => 'user', |
| @@ -342,9 +529,9 @@ | ||
| 342 | 529 | 'to_fieldname' => '_bbp_password', |
| 343 | 530 | 'callback_method' => 'callback_savepass' |
| 344 | 531 | ); |
| 345 | 532 | |
| 346 | - // Store old User Salt. This is only used for the SELECT row info for the above password save | |
| 533 | + // Store old user salt (This is only used for the SELECT row info for the above password save) | |
| 347 | 534 | $this->field_map[] = array( |
| 348 | 535 | 'from_tablename' => 'users', |
| 349 | 536 | 'from_fieldname' => 'user_form_salt', |
| 350 | 537 | 'to_type' => 'user', |
| @@ -349,16 +536,16 @@ | ||
| 349 | 536 | 'from_fieldname' => 'user_form_salt', |
| 350 | 537 | 'to_type' => 'user', |
| 351 | 538 | 'to_fieldname' => '' |
| 352 | 539 | ); |
| 353 | - | |
| 354 | - // User password verify class. Stores in usermeta for verifying password. | |
| 540 | + | |
| 541 | + // User password verify class (Stored in usermeta for verifying password) | |
| 355 | 542 | $this->field_map[] = array( |
| 356 | 543 | 'to_type' => 'user', |
| 357 | 544 | 'to_fieldname' => '_bbp_class', |
| 358 | 545 | 'default' => 'phpBB' |
| 359 | 546 | ); |
| 360 | - | |
| 547 | + | |
| 361 | 548 | // User name. |
| 362 | 549 | $this->field_map[] = array( |
| 363 | 550 | 'from_tablename' => 'users', |
| 364 | 551 | 'from_fieldname' => 'username', |
| @@ -364,9 +551,9 @@ | ||
| 364 | 551 | 'from_fieldname' => 'username', |
| 365 | 552 | 'to_type' => 'user', |
| 366 | 553 | 'to_fieldname' => 'user_login' |
| 367 | 554 | ); |
| 368 | - | |
| 555 | + | |
| 369 | 556 | // User email. |
| 370 | 557 | $this->field_map[] = array( |
| 371 | 558 | 'from_tablename' => 'users', |
| 372 | 559 | 'from_fieldname' => 'user_email', |
| @@ -372,17 +559,20 @@ | ||
| 372 | 559 | 'from_fieldname' => 'user_email', |
| 373 | 560 | 'to_type' => 'user', |
| 374 | 561 | 'to_fieldname' => 'user_email' |
| 375 | 562 | ); |
| 376 | - | |
| 563 | + | |
| 377 | 564 | // User homepage. |
| 378 | 565 | $this->field_map[] = array( |
| 379 | - 'from_tablename' => 'users', | |
| 380 | - 'from_fieldname' => 'user_website', | |
| 381 | - 'to_type' => 'user', | |
| 382 | - 'to_fieldname' => 'user_url' | |
| 566 | + 'from_tablename' => 'profile_fields_data', | |
| 567 | + 'from_fieldname' => 'pf_phpbb_website', | |
| 568 | + 'join_tablename' => 'users', | |
| 569 | + 'join_type' => 'LEFT', | |
| 570 | + 'join_expression' => 'USING (user_id) WHERE users.user_type !=2', | |
| 571 | + 'to_type' => 'user', | |
| 572 | + 'to_fieldname' => 'user_url' | |
| 383 | 573 | ); |
| 384 | - | |
| 574 | + | |
| 385 | 575 | // User registered. |
| 386 | 576 | $this->field_map[] = array( |
| 387 | 577 | 'from_tablename' => 'users', |
| 388 | 578 | 'from_fieldname' => 'user_regdate', |
| @@ -389,24 +579,131 @@ | ||
| 389 | 579 | 'to_type' => 'user', |
| 390 | 580 | 'to_fieldname' => 'user_registered', |
| 391 | 581 | 'callback_method' => 'callback_datetime' |
| 392 | 582 | ); |
| 393 | - | |
| 394 | - // User aim. | |
| 583 | + | |
| 584 | + // User AOL/AIM (Stored in usermeta) | |
| 395 | 585 | $this->field_map[] = array( |
| 586 | + 'from_tablename' => 'profile_fields_data', | |
| 587 | + 'from_fieldname' => 'pf_phpbb_aol', | |
| 588 | + 'to_type' => 'user', | |
| 589 | + 'to_fieldname' => '_bbp_phpbb_user_aim' | |
| 590 | + ); | |
| 591 | + | |
| 592 | + // User Yahoo (Stored in usermeta) | |
| 593 | + $this->field_map[] = array( | |
| 594 | + 'from_tablename' => 'profile_fields_data', | |
| 595 | + 'from_fieldname' => 'pf_phpbb_yahoo', | |
| 596 | + 'to_type' => 'user', | |
| 597 | + 'to_fieldname' => '_bbp_phpbb_user_yim' | |
| 598 | + ); | |
| 599 | + | |
| 600 | + // Store ICQ (Stored in usermeta) | |
| 601 | + $this->field_map[] = array( | |
| 602 | + 'from_tablename' => 'profile_fields_data', | |
| 603 | + 'from_fieldname' => 'pf_phpbb_icq', | |
| 604 | + 'to_type' => 'user', | |
| 605 | + 'to_fieldname' => '_bbp_phpbb_user_icq' | |
| 606 | + ); | |
| 607 | + | |
| 608 | + // Store MSN/WLM (Stored in usermeta) | |
| 609 | + $this->field_map[] = array( | |
| 610 | + 'from_tablename' => 'profile_fields_data', | |
| 611 | + 'from_fieldname' => 'pf_phpbb_wlm', | |
| 612 | + 'to_type' => 'user', | |
| 613 | + 'to_fieldname' => '_bbp_phpbb_user_msnm' | |
| 614 | + ); | |
| 615 | + | |
| 616 | + // Store Facebook (Stored in usermeta) | |
| 617 | + $this->field_map[] = array( | |
| 618 | + 'from_tablename' => 'profile_fields_data', | |
| 619 | + 'from_fieldname' => 'pf_phpbb_facebook', | |
| 620 | + 'to_type' => 'user', | |
| 621 | + 'to_fieldname' => '_bbp_phpbb_user_facebook' | |
| 622 | + ); | |
| 623 | + | |
| 624 | + // Store Google+ (Stored in usermeta) | |
| 625 | + $this->field_map[] = array( | |
| 626 | + 'from_tablename' => 'profile_fields_data', | |
| 627 | + 'from_fieldname' => 'pf_phpbb_googleplus', | |
| 628 | + 'to_type' => 'user', | |
| 629 | + 'to_fieldname' => '_bbp_phpbb_user_googleplus' | |
| 630 | + ); | |
| 631 | + | |
| 632 | + // Store Skype (Stored in usermeta) | |
| 633 | + $this->field_map[] = array( | |
| 634 | + 'from_tablename' => 'profile_fields_data', | |
| 635 | + 'from_fieldname' => 'pf_phpbb_skype', | |
| 636 | + 'to_type' => 'user', | |
| 637 | + 'to_fieldname' => '_bbp_phpbb_user_skype' | |
| 638 | + ); | |
| 639 | + | |
| 640 | + // Store Twitter (Stored in usermeta) | |
| 641 | + $this->field_map[] = array( | |
| 642 | + 'from_tablename' => 'profile_fields_data', | |
| 643 | + 'from_fieldname' => 'pf_phpbb_twitter', | |
| 644 | + 'to_type' => 'user', | |
| 645 | + 'to_fieldname' => '_bbp_phpbb_user_twitter' | |
| 646 | + ); | |
| 647 | + | |
| 648 | + // Store Youtube (Stored in usermeta) | |
| 649 | + $this->field_map[] = array( | |
| 650 | + 'from_tablename' => 'profile_fields_data', | |
| 651 | + 'from_fieldname' => 'pf_phpbb_youtube', | |
| 652 | + 'to_type' => 'user', | |
| 653 | + 'to_fieldname' => '_bbp_phpbb_user_youtube' | |
| 654 | + ); | |
| 655 | + | |
| 656 | + // Store Jabber | |
| 657 | + $this->field_map[] = array( | |
| 396 | 658 | 'from_tablename' => 'users', |
| 397 | - 'from_fieldname' => 'user_aim', | |
| 659 | + 'from_fieldname' => 'user_jabber', | |
| 398 | 660 | 'to_type' => 'user', |
| 399 | - 'to_fieldname' => 'aim' | |
| 661 | + 'to_fieldname' => '_bbp_phpbb_user_jabber' | |
| 400 | 662 | ); |
| 401 | - | |
| 402 | - // User yahoo. | |
| 663 | + | |
| 664 | + // Store Occupation (Stored in usermeta) | |
| 403 | 665 | $this->field_map[] = array( |
| 666 | + 'from_tablename' => 'profile_fields_data', | |
| 667 | + 'from_fieldname' => 'pf_phpbb_occupation', | |
| 668 | + 'to_type' => 'user', | |
| 669 | + 'to_fieldname' => '_bbp_phpbb_user_occ' | |
| 670 | + ); | |
| 671 | + | |
| 672 | + // Store Interests (Stored in usermeta) | |
| 673 | + $this->field_map[] = array( | |
| 674 | + 'from_tablename' => 'profile_fields_data', | |
| 675 | + 'from_fieldname' => 'pf_phpbb_interests', | |
| 676 | + 'to_type' => 'user', | |
| 677 | + 'to_fieldname' => '_bbp_phpbb_user_interests' | |
| 678 | + ); | |
| 679 | + | |
| 680 | + // Store Signature (Stored in usermeta) | |
| 681 | + $this->field_map[] = array( | |
| 404 | 682 | 'from_tablename' => 'users', |
| 405 | - 'from_fieldname' => 'user_yim', | |
| 683 | + 'from_fieldname' => 'user_sig', | |
| 406 | 684 | 'to_type' => 'user', |
| 407 | - 'to_fieldname' => 'yim' | |
| 408 | - ); | |
| 685 | + 'to_fieldname' => '_bbp_phpbb_user_sig', | |
| 686 | + 'callback_method' => 'callback_html' | |
| 687 | + ); | |
| 688 | + | |
| 689 | + // Store Location (Stored in usermeta) | |
| 690 | + $this->field_map[] = array( | |
| 691 | + 'from_tablename' => 'profile_fields_data', | |
| 692 | + 'from_fieldname' => 'pf_phpbb_location', | |
| 693 | + 'to_type' => 'user', | |
| 694 | + 'to_fieldname' => '_bbp_phpbb_user_from' | |
| 695 | + ); | |
| 696 | + | |
| 697 | + // Store Avatar Filename (Stored in usermeta) | |
| 698 | + $this->field_map[] = array( | |
| 699 | + 'from_tablename' => 'users', | |
| 700 | + 'from_fieldname' => 'user_avatar', | |
| 701 | + 'to_type' => 'user', | |
| 702 | + 'to_fieldname' => '_bbp_phpbb_user_avatar' | |
| 703 | + ); | |
| 704 | + | |
| 705 | + // Store old role (Stored in usermeta) | |
| 409 | 706 | } |
| 410 | 707 | |
| 411 | 708 | /** |
| 412 | 709 | * This method allows us to indicates what is or is not converted for each |
| @@ -417,58 +714,84 @@ | ||
| 417 | 714 | } |
| 418 | 715 | |
| 419 | 716 | /** |
| 420 | 717 | * This method is to save the salt and password together. That |
| 421 | - * way when it is authenticate it we can get it out of the database | |
| 718 | + * way when we authenticate it we can get it out of the database | |
| 422 | 719 | * as one value. |
| 423 | 720 | */ |
| 424 | 721 | public function callback_savepass( $field, $row ) { |
| 425 | - $pass_array = array('hash' => $field, 'salt' => $row['salt']); | |
| 426 | - return $pass_array; | |
| 722 | + return array( | |
| 723 | + 'hash' => $field, | |
| 724 | + 'salt' => $row['user_form_salt'] | |
| 725 | + ); | |
| 427 | 726 | } |
| 428 | - | |
| 727 | + | |
| 429 | 728 | /** |
| 430 | 729 | * Check for correct password |
| 431 | 730 | * |
| 432 | 731 | * @param string $password The password in plain text |
| 433 | - * @param string $hash The stored password hash | |
| 732 | + * @param string $serialized_pass The stored password hash | |
| 434 | 733 | * |
| 734 | + * @link Original source for password functions http://openwall.com/phpass/ | |
| 735 | + * @link phpass is now included in WP Core https://core.trac.wordpress.org/browser/trunk/wp-includes/class-phpass.php | |
| 736 | + * | |
| 435 | 737 | * @return bool Returns true if the password is correct, false if not. |
| 436 | 738 | */ |
| 437 | - public function authenticate_pass($password, $serialized_pass) { | |
| 438 | - $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; | |
| 439 | - $pass_array = unserialize($serialized_pass); | |
| 440 | - if (strlen($pass_array['hash']) == 34) { | |
| 441 | - return ($this->_hash_crypt_private($password, $pass_array['hash'], $itoa64) === $pass_array['hash']) ? true : false; | |
| 739 | + public function authenticate_pass( $password, $serialized_pass ) { | |
| 740 | + | |
| 741 | + // Unserialize the password, with safeguards | |
| 742 | + $pass_array = unserialize( | |
| 743 | + $serialized_pass, | |
| 744 | + array( | |
| 745 | + 'allowed_classes' => false, | |
| 746 | + 'max_depth' => 1 | |
| 747 | + ) | |
| 748 | + ); | |
| 749 | + | |
| 750 | + // Encrypted | |
| 751 | + if ( strlen( $pass_array['hash'] ) === 34 ) { | |
| 752 | + | |
| 753 | + // ASCII | |
| 754 | + $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; | |
| 755 | + | |
| 756 | + // Compare using private crypt | |
| 757 | + return hash_equals( | |
| 758 | + $this->_hash_crypt_private( $password, $pass_array['hash'], $itoa64 ), | |
| 759 | + $pass_array['hash'] | |
| 760 | + ); | |
| 442 | 761 | } |
| 443 | - | |
| 444 | - return (md5($password) === $pass_array['hash']) ? true : false; | |
| 762 | + | |
| 763 | + // Unencrypted | |
| 764 | + return hash_equals( | |
| 765 | + md5( $password ), | |
| 766 | + $pass_array['hash'] | |
| 767 | + ); | |
| 445 | 768 | } |
| 446 | - | |
| 769 | + | |
| 447 | 770 | /** |
| 448 | 771 | * The crypt function/replacement |
| 449 | 772 | */ |
| 450 | - private function _hash_crypt_private($password, $setting, &$itoa64) { | |
| 773 | + private function _hash_crypt_private( $password, $setting, &$itoa64 ) { | |
| 451 | 774 | $output = '*'; |
| 452 | - | |
| 775 | + | |
| 453 | 776 | // Check for correct hash |
| 454 | - if (substr($setting, 0, 3) != '$H$') { | |
| 777 | + if ( substr( $setting, 0, 3 ) !== '$H$' ) { | |
| 455 | 778 | return $output; |
| 456 | 779 | } |
| 457 | - | |
| 458 | - $count_log2 = strpos($itoa64, $setting[3]); | |
| 459 | - | |
| 460 | - if ($count_log2 < 7 || $count_log2 > 30) { | |
| 780 | + | |
| 781 | + $count_log2 = strpos( $itoa64, $setting[3] ); | |
| 782 | + | |
| 783 | + if ( $count_log2 < 7 || $count_log2 > 30 ) { | |
| 461 | 784 | return $output; |
| 462 | 785 | } |
| 463 | - | |
| 786 | + | |
| 464 | 787 | $count = 1 << $count_log2; |
| 465 | - $salt = substr($setting, 4, 8); | |
| 466 | - | |
| 467 | - if (strlen($salt) != 8) { | |
| 788 | + $salt = substr( $setting, 4, 8 ); | |
| 789 | + | |
| 790 | + if ( strlen( $salt ) !== 8 ) { | |
| 468 | 791 | return $output; |
| 469 | 792 | } |
| 470 | - | |
| 793 | + | |
| 471 | 794 | /** |
| 472 | 795 | * We're kind of forced to use MD5 here since it's the only |
| 473 | 796 | * cryptographic primitive available in all versions of PHP |
| 474 | 797 | * currently in use. To implement our own low-level crypto |
| @@ -475,64 +798,249 @@ | ||
| 475 | 798 | * in PHP would result in much worse performance and |
| 476 | 799 | * consequently in lower iteration counts and hashes that are |
| 477 | 800 | * quicker to crack (by non-PHP code). |
| 478 | 801 | */ |
| 479 | - if (floatval(phpversion()) >= 5) { | |
| 480 | - $hash = md5($salt . $password, true); | |
| 481 | - do | |
| 482 | - { | |
| 483 | - $hash = md5($hash . $password, true); | |
| 484 | - } | |
| 485 | - while (--$count); | |
| 802 | + if ( floatval( phpversion() ) >= 5 ) { | |
| 803 | + $hash = md5( $salt . $password, true ); | |
| 804 | + do { | |
| 805 | + $hash = md5( $hash . $password, true ); | |
| 806 | + } while ( --$count ); | |
| 486 | 807 | } else { |
| 487 | - $hash = pack('H*', md5($salt . $password)); | |
| 808 | + $hash = pack( 'H*', md5( $salt . $password ) ); | |
| 488 | 809 | do { |
| 489 | - $hash = pack('H*', md5($hash . $password)); | |
| 490 | - } | |
| 491 | - while (--$count); | |
| 810 | + $hash = pack( 'H*', md5( $hash . $password ) ); | |
| 811 | + } while ( --$count ); | |
| 492 | 812 | } |
| 493 | 813 | |
| 494 | - $output = substr($setting, 0, 12); | |
| 495 | - $output .= $this->_hash_encode64($hash, 16, $itoa64); | |
| 496 | - | |
| 814 | + $output = substr( $setting, 0, 12 ); | |
| 815 | + $output .= $this->_hash_encode64( $hash, 16, $itoa64 ); | |
| 816 | + | |
| 497 | 817 | return $output; |
| 498 | 818 | } |
| 499 | - | |
| 819 | + | |
| 500 | 820 | /** |
| 501 | 821 | * Encode hash |
| 502 | 822 | */ |
| 503 | - private function _hash_encode64($input, $count, &$itoa64) { | |
| 823 | + private function _hash_encode64( $input, $count, &$itoa64 ) { | |
| 504 | 824 | $output = ''; |
| 505 | 825 | $i = 0; |
| 506 | - | |
| 826 | + | |
| 507 | 827 | do { |
| 508 | - $value = ord($input[$i++]); | |
| 509 | - $output .= $itoa64[$value & 0x3f]; | |
| 510 | - | |
| 511 | - if ($i < $count) { | |
| 512 | - $value |= ord($input[$i]) << 8; | |
| 828 | + $value = ord( $input[ $i++ ] ); | |
| 829 | + $output .= $itoa64[ $value & 0x3f ]; | |
| 830 | + | |
| 831 | + if ( $i < $count ) { | |
| 832 | + $value |= ord( $input[ $i ] ) << 8; | |
| 513 | 833 | } |
| 514 | - | |
| 515 | - $output .= $itoa64[($value >> 6) & 0x3f]; | |
| 516 | - | |
| 517 | - if ($i++ >= $count) { | |
| 834 | + | |
| 835 | + $output .= $itoa64[ ( $value >> 6 ) & 0x3f ]; | |
| 836 | + | |
| 837 | + if ( $i++ >= $count ) { | |
| 518 | 838 | break; |
| 519 | 839 | } |
| 520 | - | |
| 521 | - if ($i < $count) { | |
| 522 | - $value |= ord($input[$i]) << 16; | |
| 840 | + | |
| 841 | + if ( $i < $count ) { | |
| 842 | + $value |= ord( $input[ $i ] ) << 16; | |
| 523 | 843 | } |
| 524 | - | |
| 525 | - $output .= $itoa64[($value >> 12) & 0x3f]; | |
| 526 | - | |
| 527 | - if ($i++ >= $count) { | |
| 844 | + | |
| 845 | + $output .= $itoa64[ ( $value >> 12 ) & 0x3f ]; | |
| 846 | + | |
| 847 | + if ( $i++ >= $count ) { | |
| 528 | 848 | break; |
| 529 | 849 | } |
| 530 | - | |
| 531 | - $output .= $itoa64[($value >> 18) & 0x3f]; | |
| 850 | + | |
| 851 | + $output .= $itoa64[ ( $value >> 18 ) & 0x3f ]; | |
| 852 | + } while ( $i < $count ); | |
| 853 | + | |
| 854 | + return $output; | |
| 855 | + } | |
| 856 | + | |
| 857 | + /** | |
| 858 | + * Translate the forum type from phpBB v3.x numerics to WordPress's strings. | |
| 859 | + * | |
| 860 | + * @param int $status phpBB v3.x numeric forum type | |
| 861 | + * @return string WordPress safe | |
| 862 | + */ | |
| 863 | + public function callback_forum_type( $status = 1 ) { | |
| 864 | + switch ( $status ) { | |
| 865 | + case 0 : | |
| 866 | + $status = 'category'; | |
| 867 | + break; | |
| 868 | + | |
| 869 | + case 1 : | |
| 870 | + default : | |
| 871 | + $status = 'forum'; | |
| 872 | + break; | |
| 532 | 873 | } |
| 533 | - while ($i < $count); | |
| 534 | - | |
| 535 | - return $output; | |
| 874 | + return $status; | |
| 536 | 875 | } |
| 537 | 876 | |
| 877 | + /** | |
| 878 | + * Translate the forum status from phpBB v3.x numerics to WordPress's strings. | |
| 879 | + * | |
| 880 | + * @param int $status phpBB v3.x numeric forum status | |
| 881 | + * @return string WordPress safe | |
| 882 | + */ | |
| 883 | + public function callback_forum_status( $status = 0 ) { | |
| 884 | + switch ( $status ) { | |
| 885 | + case 1 : | |
| 886 | + $status = 'closed'; | |
| 887 | + break; | |
| 888 | + | |
| 889 | + case 0 : | |
| 890 | + default : | |
| 891 | + $status = 'open'; | |
| 892 | + break; | |
| 893 | + } | |
| 894 | + return $status; | |
| 895 | + } | |
| 896 | + | |
| 897 | + /** | |
| 898 | + * Translate the topic status from phpBB v3.x numerics to WordPress's strings. | |
| 899 | + * | |
| 900 | + * @param int $status phpBB v3.x numeric topic status | |
| 901 | + * @return string WordPress safe | |
| 902 | + */ | |
| 903 | + public function callback_topic_status( $status = 0 ) { | |
| 904 | + switch ( $status ) { | |
| 905 | + case 1 : | |
| 906 | + $status = 'closed'; | |
| 907 | + break; | |
| 908 | + | |
| 909 | + case 0 : | |
| 910 | + default : | |
| 911 | + $status = 'publish'; | |
| 912 | + break; | |
| 913 | + } | |
| 914 | + return $status; | |
| 915 | + } | |
| 916 | + | |
| 917 | + /** | |
| 918 | + * Translate the topic sticky status type from phpBB 3.x numerics to WordPress's strings. | |
| 919 | + * | |
| 920 | + * @param int $status phpBB 3.x numeric forum type | |
| 921 | + * @return string WordPress safe | |
| 922 | + */ | |
| 923 | + public function callback_sticky_status( $status = 0 ) { | |
| 924 | + switch ( $status ) { | |
| 925 | + case 3 : | |
| 926 | + $status = 'super-sticky'; // phpBB Global Sticky 'topic_type = 3' | |
| 927 | + break; | |
| 928 | + | |
| 929 | + case 2 : | |
| 930 | + $status = 'super-sticky'; // phpBB Announcement Sticky 'topic_type = 2' | |
| 931 | + break; | |
| 932 | + | |
| 933 | + case 1 : | |
| 934 | + $status = 'sticky'; // phpBB Sticky 'topic_type = 1' | |
| 935 | + break; | |
| 936 | + | |
| 937 | + case 0 : | |
| 938 | + default : | |
| 939 | + $status = 'normal'; // phpBB normal topic 'topic_type = 0' | |
| 940 | + break; | |
| 941 | + } | |
| 942 | + return $status; | |
| 943 | + } | |
| 944 | + | |
| 945 | + /** | |
| 946 | + * Verify the topic reply count. | |
| 947 | + * | |
| 948 | + * @param int $count phpBB v3.x reply count | |
| 949 | + * @return string WordPress safe | |
| 950 | + */ | |
| 951 | + public function callback_topic_reply_count( $count = 1 ) { | |
| 952 | + $count = absint( (int) $count - 1 ); | |
| 953 | + return $count; | |
| 954 | + } | |
| 955 | + | |
| 956 | + /** | |
| 957 | + * This callback processes any custom parser.php attributes and custom code with preg_replace | |
| 958 | + */ | |
| 959 | + protected function callback_html( $field ) { | |
| 960 | + | |
| 961 | + // Strips custom phpBB 'magic_url' and 'bbcode_uid' first from $field before parsing $field to parser.php | |
| 962 | + $phpbb_uid = $field; | |
| 963 | + $phpbb_uid = html_entity_decode( $phpbb_uid ); | |
| 964 | + | |
| 965 | + // Replace '[b:XXXXXXX]' with '<strong>' | |
| 966 | + $phpbb_uid = preg_replace( '/\[b:(.*?)\]/', '<strong>', $phpbb_uid ); | |
| 967 | + // Replace '[/b:XXXXXXX]' with '</strong>' | |
| 968 | + $phpbb_uid = preg_replace( '/\[\/b:(.*?)\]/', '</strong>', $phpbb_uid ); | |
| 969 | + | |
| 970 | + // Replace '[i:XXXXXXX]' with '<em>' | |
| 971 | + $phpbb_uid = preg_replace( '/\[i:(.*?)\]/', '<em>', $phpbb_uid ); | |
| 972 | + // Replace '[/i:XXXXXXX]' with '</em>' | |
| 973 | + $phpbb_uid = preg_replace( '/\[\/i:(.*?)\]/', '</em>', $phpbb_uid ); | |
| 974 | + | |
| 975 | + // Replace '[u:XXXXXXX]' with '<u>' | |
| 976 | + $phpbb_uid = preg_replace( '/\[u:(.*?)\]/', '<u>', $phpbb_uid ); | |
| 977 | + // Replace '[/u:XXXXXXX]' with '</u>' | |
| 978 | + $phpbb_uid = preg_replace( '/\[\/u:(.*?)\]/', '</u>', $phpbb_uid ); | |
| 979 | + | |
| 980 | + // Replace '[quote:XXXXXXX]' with '<blockquote>' | |
| 981 | + $phpbb_uid = preg_replace( '/\[quote:(.*?)\]/', '<blockquote>', $phpbb_uid ); | |
| 982 | + // Replace '[quote="$1"]' with '<em>$1 wrote:</em><blockquote>" | |
| 983 | + $phpbb_uid = preg_replace( '/\[quote="(.*?)":(.*?)\]/', '<em>@$1 wrote:</em><blockquote>', $phpbb_uid ); | |
| 984 | + // Replace '[/quote:XXXXXXX]' with '</blockquote>' | |
| 985 | + $phpbb_uid = preg_replace( '/\[\/quote:(.*?)\]/', '</blockquote>', $phpbb_uid ); | |
| 986 | + | |
| 987 | + // Replace '[img:XXXXXXX]' with '<img src="' | |
| 988 | + $phpbb_uid = preg_replace( '/\[img:(.*?)\]/', '<img src="', $phpbb_uid ); | |
| 989 | + // Replace '[/img:XXXXXXX]' with ' alt="">' | |
| 990 | + $phpbb_uid = preg_replace( '/\[\/img:(.*?)\]/', '" alt="">', $phpbb_uid ); | |
| 991 | + | |
| 992 | + // Replace '<!-- s$1 --><img src=\"{SMILIES_PATH}$2 -->' with '$1' | |
| 993 | + $phpbb_uid = preg_replace( '/<!-- s(.*?) --><img src=\"{SMILIES_PATH}(.*?)-->/', '$1', $phpbb_uid ); | |
| 994 | + | |
| 995 | + // Replace '<!-- m --><a class="postlink" href="$1">$1</a><!-- m -->' with '$1' | |
| 996 | + $phpbb_uid = preg_replace( '/\<!-- m --\>\<a class="postlink" href="([^\[]+?)"\>([^\[]+?)\<\/a\>\<!-- m --\>/', '$1', $phpbb_uid ); | |
| 997 | + | |
| 998 | + // Replace '[url:XXXXXXX]$1[/url:XXXXXXX]' with '<a href="http://$1">$1</a>' | |
| 999 | + $phpbb_uid = preg_replace( '/\[url:(?:[^\]]+)\]([^\[]+?)\[\/url:(?:[^\]]+)\]/', '<a href="http://$1">$1</a>', $phpbb_uid ); | |
| 1000 | + // Replace '[url=http://$1:XXXXXXX]$3[/url:XXXXXXX]' with '<a href="http://$1">$3</a>' | |
| 1001 | + $phpbb_uid = preg_replace( '/\[url\=http\:\/\/(.*?)\:(.*?)\](.*?)\[\/url:(.*?)\]/i', '<a href="http://$1">$3</a>', $phpbb_uid ); | |
| 1002 | + // Replace '[url=https://$1:XXXXXXX]$3[/url:XXXXXXX]' with '<a href="http://$1">$3</a>' | |
| 1003 | + $phpbb_uid = preg_replace( '/\[url\=https\:\/\/(.*?)\:(.*?)\](.*?)\[\/url:(.*?)\]/i', '<a href="https://$1">$3</a>', $phpbb_uid ); | |
| 1004 | + | |
| 1005 | + // Replace '[email:XXXXXXX]' with '<a href="mailto:$2">$2</a>' | |
| 1006 | + $phpbb_uid = preg_replace( '/\[email:(.*?)\](.*?)\[\/email:(.*?)\]/', '<a href="mailto:$2">$2</a>', $phpbb_uid ); | |
| 1007 | + // Replace '<!-- e -->no.one@domain.adr<!-- e -->' with '$1' | |
| 1008 | + $phpbb_uid = preg_replace( '/\<!-- e --\>(.*?)\<!-- e --\>/', '$1', $phpbb_uid ); | |
| 1009 | + | |
| 1010 | + // Replace '[code:XXXXXXX]' with '<pre><code>' | |
| 1011 | + $phpbb_uid = preg_replace( '/\[code:(.*?)\]/', '<pre><code>', $phpbb_uid ); | |
| 1012 | + // Replace '[/code:XXXXXXX]' with '</code></pre>' | |
| 1013 | + $phpbb_uid = preg_replace( '/\[\/code:(.*?)\]/', '</code></pre>', $phpbb_uid ); | |
| 1014 | + | |
| 1015 | + // Replace '[color=$1:XXXXXXXX]' with '<span style="color:$1">' | |
| 1016 | + $phpbb_uid = preg_replace( '/\[color=(.*?)\:(.*?)\]/', '<span style="color: $1">', $phpbb_uid ); | |
| 1017 | + // Replace '[/color:XXXXXXX]' with '</span>' | |
| 1018 | + $phpbb_uid = preg_replace( '/\[\/color:(.*?)\]/', '</span>', $phpbb_uid ); | |
| 1019 | + | |
| 1020 | + // Replace '[size=$1:XXXXXXXX]' with '<span style="font-size:$1%;">$3</span>' | |
| 1021 | + $phpbb_uid = preg_replace( '/\[size=(.*?):(.*?)\]/', '<span style="font-size:$1%;">', $phpbb_uid ); | |
| 1022 | + // Replace '[/size:XXXXXXX]' with '' | |
| 1023 | + $phpbb_uid = preg_replace( '/\[\/size:(.*?)\]/', '</span>', $phpbb_uid ); | |
| 1024 | + | |
| 1025 | + // Replace '[list:XXXXXXX]' with '<ul>' | |
| 1026 | + $phpbb_uid = preg_replace( '/\[list:(.*?)\]/', '<ul>', $phpbb_uid ); | |
| 1027 | + // Replace '[list=a:XXXXXXX]' with '<ol type="a">' | |
| 1028 | + $phpbb_uid = preg_replace( '/\[list=a:(.*?)\]/', '<ol type="a">', $phpbb_uid ); | |
| 1029 | + // Replace '[list=1:XXXXXXX]' with '<ol>' | |
| 1030 | + $phpbb_uid = preg_replace( '/\[list=1:(.*?)\]/', '<ol>', $phpbb_uid ); | |
| 1031 | + // Replace '[*:XXXXXXX]' with '<li>' | |
| 1032 | + $phpbb_uid = preg_replace( '/\[\*:(.*?)\]/', '<li>', $phpbb_uid ); | |
| 1033 | + // Replace '[/*:m:XXXXXXX]' with '</li>' | |
| 1034 | + $phpbb_uid = preg_replace( '/\[\/\*:m:(.*?)\]/', '</li>', $phpbb_uid ); | |
| 1035 | + // Replace '[/list:u:XXXXXXX]' with '</ul>' | |
| 1036 | + $phpbb_uid = preg_replace( '/\[\/list:u:(.*?)\]/', '</ul>', $phpbb_uid ); | |
| 1037 | + // Replace '[/list:o:XXXXXXX]' with '</ol>' | |
| 1038 | + $phpbb_uid = preg_replace( '/\[\/list:o:(.*?)\]/', '</ol>', $phpbb_uid ); | |
| 1039 | + | |
| 1040 | + // Now that phpBB's 'magic_url' and 'bbcode_uid' have been stripped put the cleaned HTML back in $field | |
| 1041 | + $field = $phpbb_uid; | |
| 1042 | + | |
| 1043 | + // Parse out any bbCodes in $field with the BBCode 'parser.php' | |
| 1044 | + return parent::callback_html( $field ); | |
| 1045 | + } | |
| 538 | 1046 | } |