PluginProbe
bbPress / 2.2.2
bbPress v2.2.2
trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.2.2 All 71 releases
bbpress / includes / admin / converters / Invision.php

Invision.php in bbPress 2.2.2, at includes/admin/converters/Invision.php

364 lines 11.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Implementation of Invision Power Board converter.
5 */
6 class Invision extends BBP_Converter_Base
7 {
8 function __construct()
9 {
10 parent::__construct();
11 $this->setup_globals();
12 }
13
14 public function setup_globals()
15 {
16 /** Forum Section ******************************************************/
17
18 // Forum id. Stored in postmeta.
19 $this->field_map[] = array(
20 'from_tablename' => 'forums', 'from_fieldname' => 'id',
21 'to_type' => 'forum', 'to_fieldname' => '_bbp_forum_id'
22 );
23
24 // Forum parent id. If no parent, than 0. Stored in postmeta.
25 $this->field_map[] = array(
26 'from_tablename' => 'forums', 'from_fieldname' => 'parent_id',
27 'to_type' => 'forum', 'to_fieldname' => '_bbp_parent_id'
28 );
29
30 // Forum title.
31 $this->field_map[] = array(
32 'from_tablename' => 'forums', 'from_fieldname' => 'name',
33 'to_type' => 'forum', 'to_fieldname' => 'post_title'
34 );
35
36 // Forum slug. Clean name.
37 $this->field_map[] = array(
38 'from_tablename' => 'forums', 'from_fieldname' => 'name',
39 'to_type' => 'forum', 'to_fieldname' => 'post_name',
40 'callback_method' => 'callback_slug'
41 );
42
43 // Forum description.
44 $this->field_map[] = array(
45 'from_tablename' => 'forums', 'from_fieldname' => 'description',
46 'to_type' => 'forum', 'to_fieldname' => 'post_content',
47 'callback_method' => 'callback_null'
48 );
49
50 // Forum display order. Starts from 1.
51 $this->field_map[] = array(
52 'from_tablename' => 'forums', 'from_fieldname' => 'position',
53 'to_type' => 'forum', 'to_fieldname' => 'menu_order'
54 );
55
56 // Forum date update.
57 $this->field_map[] = array(
58 'to_type' => 'forum', 'to_fieldname' => 'post_date',
59 'default' => date('Y-m-d H:i:s')
60 );
61 $this->field_map[] = array(
62 'to_type' => 'forum', 'to_fieldname' => 'post_date_gmt',
63 'default' => date('Y-m-d H:i:s')
64 );
65 $this->field_map[] = array(
66 'to_type' => 'forum', 'to_fieldname' => 'post_modified',
67 'default' => date('Y-m-d H:i:s')
68 );
69 $this->field_map[] = array(
70 'to_type' => 'forum', 'to_fieldname' => 'post_modified_gmt',
71 'default' => date('Y-m-d H:i:s')
72 );
73
74 /** Topic Section ******************************************************/
75
76 // Topic id. Stored in postmeta.
77 $this->field_map[] = array(
78 'from_tablename' => 'topics', 'from_fieldname' => 'tid',
79 'to_type' => 'topic', 'to_fieldname' => '_bbp_topic_id'
80 );
81
82 // Forum id. Stored in postmeta.
83 $this->field_map[] = array(
84 'from_tablename' => 'topics', 'from_fieldname' => 'forum_id',
85 'to_type' => 'topic', 'to_fieldname' => '_bbp_forum_id',
86 'callback_method' => 'callback_forumid'
87 );
88
89 // Topic author.
90 $this->field_map[] = array(
91 'from_tablename' => 'topics', 'from_fieldname' => 'starter_id',
92 'to_type' => 'topic', 'to_fieldname' => 'post_author',
93 'callback_method' => 'callback_userid'
94 );
95
96 // Topic content.
97 $this->field_map[] = array(
98 'from_tablename' => 'posts', 'from_fieldname' => 'post',
99 'join_tablename' => 'topics', 'join_type' => 'INNER', 'join_expression' => 'ON(topics.tid = posts.topic_id) WHERE posts.new_topic = 1',
100 'to_type' => 'topic', 'to_fieldname' => 'post_content',
101 'callback_method' => 'callback_html'
102 );
103
104 // Topic title.
105 $this->field_map[] = array(
106 'from_tablename' => 'topics', 'from_fieldname' => 'title',
107 'to_type' => 'topic', 'to_fieldname' => 'post_title'
108 );
109
110 // Topic slug. Clean name.
111 $this->field_map[] = array(
112 'from_tablename' => 'topics', 'from_fieldname' => 'title',
113 'to_type' => 'topic', 'to_fieldname' => 'post_name',
114 'callback_method' => 'callback_slug'
115 );
116
117 // Forum id. If no parent, than 0.
118 $this->field_map[] = array(
119 'from_tablename' => 'topics', 'from_fieldname' => 'forum_id',
120 'to_type' => 'topic', 'to_fieldname' => 'post_parent',
121 'callback_method' => 'callback_forumid'
122 );
123
124 // Topic date update.
125 $this->field_map[] = array(
126 'from_tablename' => 'topics', 'from_fieldname' => 'start_date',
127 'to_type' => 'topic', 'to_fieldname' => 'post_date',
128 'callback_method' => 'callback_datetime'
129 );
130 $this->field_map[] = array(
131 'from_tablename' => 'topics', 'from_fieldname' => 'start_date',
132 'to_type' => 'topic', 'to_fieldname' => 'post_date_gmt',
133 'callback_method' => 'callback_datetime'
134 );
135 $this->field_map[] = array(
136 'from_tablename' => 'topics', 'from_fieldname' => 'last_post',
137 'to_type' => 'topic', 'to_fieldname' => 'post_modified',
138 'callback_method' => 'callback_datetime'
139 );
140 $this->field_map[] = array(
141 'from_tablename' => 'topics', 'from_fieldname' => 'last_post',
142 'to_type' => 'topic', 'to_fieldname' => 'post_modified_gmt',
143 'callback_method' => 'callback_datetime'
144 );
145
146 /** Tags Section ******************************************************/
147
148 // Topic id.
149 $this->field_map[] = array(
150 'from_tablename' => 'core_tags', 'from_fieldname' => 'tag_meta_id',
151 'to_type' => 'tags', 'to_fieldname' => 'objectid',
152 'callback_method' => 'callback_topicid'
153 );
154
155 // Tags text.
156 $this->field_map[] = array(
157 'from_tablename' => 'core_tags', 'from_fieldname' => 'tag_text',
158 'to_type' => 'tags', 'to_fieldname' => 'name'
159 );
160
161 /** Post Section ******************************************************/
162
163 // Post id. Stores in postmeta.
164 $this->field_map[] = array(
165 'from_tablename' => 'posts', 'from_fieldname' => 'pid', 'from_expression' => 'WHERE posts.new_topic = 0',
166 'to_type' => 'reply', 'to_fieldname' => '_bbp_post_id'
167 );
168
169 // Forum id. Stores in postmeta.
170 $this->field_map[] = array(
171 'from_tablename' => 'posts', 'from_fieldname' => 'topic_id',
172 'to_type' => 'reply', 'to_fieldname' => '_bbp_forum_id',
173 'callback_method' => 'callback_topicid_to_forumid'
174 );
175
176 // Topic id. Stores in postmeta.
177 $this->field_map[] = array(
178 'from_tablename' => 'posts', 'from_fieldname' => 'topic_id',
179 'to_type' => 'reply', 'to_fieldname' => '_bbp_topic_id',
180 'callback_method' => 'callback_topicid'
181 );
182
183 // Author ip.
184 $this->field_map[] = array(
185 'from_tablename' => 'posts', 'from_fieldname' => 'ip_address',
186 'to_type' => 'reply', 'to_fieldname' => '__bbp_author_ip'
187 );
188
189 // Post author.
190 $this->field_map[] = array(
191 'from_tablename' => 'posts', 'from_fieldname' => 'author_id',
192 'to_type' => 'reply', 'to_fieldname' => 'post_author',
193 'callback_method' => 'callback_userid'
194 );
195
196 // Topic title.
197 $this->field_map[] = array(
198 'from_tablename' => 'posts', 'from_fieldname' => 'post_title',
199 'to_type' => 'reply', 'to_fieldname' => 'post_title'
200 );
201
202 // Topic slug. Clean name.
203 $this->field_map[] = array(
204 'from_tablename' => 'posts', 'from_fieldname' => 'post_title',
205 'to_type' => 'reply', 'to_fieldname' => 'post_name',
206 'callback_method' => 'callback_slug'
207 );
208
209 // Post content.
210 $this->field_map[] = array(
211 'from_tablename' => 'posts', 'from_fieldname' => 'post',
212 'to_type' => 'reply', 'to_fieldname' => 'post_content',
213 'callback_method' => 'callback_html'
214 );
215
216 // Topic id. If no parent, than 0.
217 $this->field_map[] = array(
218 'from_tablename' => 'posts', 'from_fieldname' => 'topic_id',
219 'to_type' => 'reply', 'to_fieldname' => 'post_parent',
220 'callback_method' => 'callback_topicid'
221 );
222
223 // Topic date update.
224 $this->field_map[] = array(
225 'from_tablename' => 'posts', 'from_fieldname' => 'post_date',
226 'to_type' => 'reply', 'to_fieldname' => 'post_date',
227 'callback_method' => 'callback_datetime'
228 );
229 $this->field_map[] = array(
230 'from_tablename' => 'posts', 'from_fieldname' => 'post_date',
231 'to_type' => 'reply', 'to_fieldname' => 'post_date_gmt',
232 'callback_method' => 'callback_datetime'
233 );
234 $this->field_map[] = array(
235 'from_tablename' => 'posts', 'from_fieldname' => 'edit_time',
236 'to_type' => 'reply', 'to_fieldname' => 'post_modified',
237 'callback_method' => 'callback_datetime'
238 );
239 $this->field_map[] = array(
240 'from_tablename' => 'posts', 'from_fieldname' => 'edit_time',
241 'to_type' => 'reply', 'to_fieldname' => 'post_modified_gmt',
242 'callback_method' => 'callback_datetime'
243 );
244
245 /** User Section ******************************************************/
246
247 // Store old User id. Stores in usermeta.
248 $this->field_map[] = array(
249 'from_tablename' => 'members', 'from_fieldname' => 'member_id',
250 'to_type' => 'user', 'to_fieldname' => '_bbp_user_id'
251 );
252
253 // Store old User password. Stores in usermeta serialized with salt.
254 $this->field_map[] = array(
255 'from_tablename' => 'members', 'from_fieldname' => 'members_pass_hash',
256 'to_type' => 'user', 'to_fieldname' => '_bbp_password',
257 'callback_method' => 'callback_savepass'
258 );
259
260 // Store old User Salt. This is only used for the SELECT row info for the above password save
261 $this->field_map[] = array(
262 'from_tablename' => 'members', 'from_fieldname' => 'members_pass_salt',
263 'to_type' => 'user', 'to_fieldname' => ''
264 );
265
266 // User password verify class. Stores in usermeta for verifying password.
267 $this->field_map[] = array(
268 'to_type' => 'user', 'to_fieldname' => '_bbp_class',
269 'default' => 'Invision'
270 );
271
272 // User name.
273 $this->field_map[] = array(
274 'from_tablename' => 'members', 'from_fieldname' => 'name',
275 'to_type' => 'user', 'to_fieldname' => 'user_login'
276 );
277
278 // User email.
279 $this->field_map[] = array(
280 'from_tablename' => 'members', 'from_fieldname' => 'email',
281 'to_type' => 'user', 'to_fieldname' => 'user_email'
282 );
283
284 // User registered.
285 $this->field_map[] = array(
286 'from_tablename' => 'members', 'from_fieldname' => 'joined',
287 'to_type' => 'user', 'to_fieldname' => 'user_registered',
288 'callback_method' => 'callback_datetime'
289 );
290
291 /*
292 * Table pfields_content AND pfields_data
293 // User homepage.
294 $this->field_map[] = array(
295 'from_tablename' => 'members', 'from_fieldname' => 'homepage',
296 'to_type' => 'user', 'to_fieldname' => 'user_url'
297 );
298
299 // User aim.
300 $this->field_map[] = array(
301 'from_tablename' => 'members', 'from_fieldname' => 'aim',
302 'to_type' => 'user', 'to_fieldname' => 'aim'
303 );
304
305 // User yahoo.
306 $this->field_map[] = array(
307 'from_tablename' => 'members', 'from_fieldname' => 'yahoo',
308 'to_type' => 'user', 'to_fieldname' => 'yim'
309 );
310 */
311
312 }
313
314 /**
315 * This method allows us to indicates what is or is not converted for each
316 * converter.
317 */
318 public function info()
319 {
320 return '';
321 }
322
323 /**
324 * This method is to save the salt and password together. That
325 * way when we authenticate it we can get it out of the database
326 * as one value. Array values are auto sanitized by wordpress.
327 */
328 public function callback_savepass( $field, $row )
329 {
330 $pass_array = array( 'hash' => $field, 'salt' => $row['members_pass_salt'] );
331 return $pass_array;
332 }
333
334 /**
335 * This method is to take the pass out of the database and compare
336 * to a pass the user has typed in.
337 */
338 public function authenticate_pass( $password, $serialized_pass )
339 {
340 $pass_array = unserialize( $serialized_pass );
341 return ( $pass_array['hash'] == md5( md5( $pass_array['salt'] ) . md5( $this->to_char( $password ) ) ) );
342 }
343
344 public function to_char( $input )
345 {
346 $output = "";
347 for( $i = 0; $i < strlen( $input ); $i++ )
348 {
349 $j = ord( $input{$i} );
350 if( ( $j >= 65 && $j <= 90 )
351 || ( $j >= 97 && $j <= 122 )
352 || ( $j >= 48 && $j <= 57 ) )
353 {
354 $output .= $input{$i};
355 }
356 else
357 {
358 $output .= "&#" . ord( $input{$i} ) . ";";
359 }
360 }
361 return $output;
362 }
363 }
364