phpBB

Implementation of phpBB v3 Converter.

Defined (1)

The class is defined in the following location(s).

/includes/admin/converters/phpBB.php  
  1. class phpBB extends BBP_Converter_Base { 
  2.  
  3. /** 
  4. * Main Constructor 
  5. * @uses phpBB::setup_globals() 
  6. */ 
  7. function __construct() { 
  8. parent::__construct(); 
  9. $this->setup_globals(); 
  10.  
  11. /** 
  12. * Sets up the field mappings 
  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',  
  21. 'from_fieldname' => 'forum_id',  
  22. 'to_type' => 'forum',  
  23. 'to_fieldname' => '_bbp_forum_id' 
  24. ); 
  25.  
  26. // Forum parent id (If no parent, then 0, Stored in postmeta) 
  27. $this->field_map[] = array( 
  28. 'from_tablename' => 'forums',  
  29. 'from_fieldname' => 'parent_id',  
  30. 'to_type' => 'forum',  
  31. 'to_fieldname' => '_bbp_forum_parent_id' 
  32. ); 
  33.  
  34. // Forum topic count (Stored in postmeta) 
  35. $this->field_map[] = array( 
  36. 'from_tablename' => 'forums',  
  37. 'from_fieldname' => 'forum_topics',  
  38. 'to_type' => 'forum',  
  39. 'to_fieldname' => '_bbp_topic_count' 
  40. ); 
  41.  
  42. // Forum reply count (Stored in postmeta) 
  43. $this->field_map[] = array( 
  44. 'from_tablename' => 'forums',  
  45. 'from_fieldname' => 'forum_posts',  
  46. 'to_type' => 'forum',  
  47. 'to_fieldname' => '_bbp_reply_count' 
  48. ); 
  49.  
  50. // Forum total topic count (Includes unpublished topics, Stored in postmeta) 
  51. $this->field_map[] = array( 
  52. 'from_tablename' => 'forums',  
  53. 'from_fieldname' => 'forum_topics_real',  
  54. 'to_type' => 'forum',  
  55. 'to_fieldname' => '_bbp_total_topic_count' 
  56. ); 
  57.  
  58. // Forum total reply count (Includes unpublished replies, Stored in postmeta) 
  59. $this->field_map[] = array( 
  60. 'from_tablename' => 'forums',  
  61. 'from_fieldname' => 'forum_posts',  
  62. 'to_type' => 'forum',  
  63. 'to_fieldname' => '_bbp_total_reply_count' 
  64. ); 
  65.  
  66. // Forum title. 
  67. $this->field_map[] = array( 
  68. 'from_tablename' => 'forums',  
  69. 'from_fieldname' => 'forum_name',  
  70. 'to_type' => 'forum',  
  71. 'to_fieldname' => 'post_title' 
  72. ); 
  73.  
  74. // Forum slug (Clean name to avoid conflicts) 
  75. $this->field_map[] = array( 
  76. 'from_tablename' => 'forums',  
  77. 'from_fieldname' => 'forum_name',  
  78. 'to_type' => 'forum',  
  79. 'to_fieldname' => 'post_name',  
  80. 'callback_method' => 'callback_slug' 
  81. ); 
  82.  
  83. // Forum description. 
  84. $this->field_map[] = array( 
  85. 'from_tablename' => 'forums',  
  86. 'from_fieldname' => 'forum_desc',  
  87. 'to_type' => 'forum',  
  88. 'to_fieldname' => 'post_content',  
  89. 'callback_method' => 'callback_null' 
  90. ); 
  91.  
  92. // Forum display order (Starts from 1) 
  93. $this->field_map[] = array( 
  94. 'from_tablename' => 'forums',  
  95. 'from_fieldname' => 'left_id',  
  96. 'to_type' => 'forum',  
  97. 'to_fieldname' => 'menu_order' 
  98. ); 
  99.  
  100. // Forum type (Category = 0 or Forum = 1, Stored in postmeta) 
  101. $this->field_map[] = array( 
  102. 'from_tablename' => 'forums',  
  103. 'from_fieldname' => 'forum_type',  
  104. 'to_type' => 'forum',  
  105. 'to_fieldname' => '_bbp_forum_type',  
  106. 'callback_method' => 'callback_forum_type' 
  107. ); 
  108.  
  109. // Forum status (Unlocked = 0 or Locked = 1, Stored in postmeta) 
  110. $this->field_map[] = array( 
  111. 'from_tablename' => 'forums',  
  112. 'from_fieldname' => 'forum_status',  
  113. 'to_type' => 'forum',  
  114. 'to_fieldname' => '_bbp_status',  
  115. 'callback_method' => 'callback_forum_status' 
  116. ); 
  117.  
  118. // Forum dates. 
  119. $this->field_map[] = array( 
  120. 'to_type' => 'forum',  
  121. 'to_fieldname' => 'post_date',  
  122. 'default' => date('Y-m-d H:i:s') 
  123. ); 
  124. $this->field_map[] = array( 
  125. 'to_type' => 'forum',  
  126. 'to_fieldname' => 'post_date_gmt',  
  127. 'default' => date('Y-m-d H:i:s') 
  128. ); 
  129. $this->field_map[] = array( 
  130. 'to_type' => 'forum',  
  131. 'to_fieldname' => 'post_modified',  
  132. 'default' => date('Y-m-d H:i:s') 
  133. ); 
  134. $this->field_map[] = array( 
  135. 'to_type' => 'forum',  
  136. 'to_fieldname' => 'post_modified_gmt',  
  137. 'default' => date('Y-m-d H:i:s') 
  138. ); 
  139.  
  140. /** Topic Section *****************************************************/ 
  141.  
  142. // Topic id (Stored in postmeta) 
  143. $this->field_map[] = array( 
  144. 'from_tablename' => 'topics',  
  145. 'from_fieldname' => 'topic_id',  
  146. 'to_type' => 'topic',  
  147. 'to_fieldname' => '_bbp_topic_id' 
  148. ); 
  149.  
  150. // Topic reply count (Stored in postmeta) 
  151. $this->field_map[] = array( 
  152. 'from_tablename' => 'topics',  
  153. 'from_fieldname' => 'topic_replies',  
  154. 'to_type' => 'topic',  
  155. 'to_fieldname' => '_bbp_reply_count',  
  156. 'callback_method' => 'callback_topic_reply_count' 
  157. ); 
  158.  
  159. // Topic total reply count (Includes unpublished replies, Stored in postmeta) 
  160. $this->field_map[] = array( 
  161. 'from_tablename' => 'topics',  
  162. 'from_fieldname' => 'topic_replies_real',  
  163. 'to_type' => 'topic',  
  164. 'to_fieldname' => '_bbp_total_reply_count',  
  165. 'callback_method' => 'callback_topic_reply_count' 
  166. ); 
  167.  
  168. // Topic parent forum id (If no parent, then 0. Stored in postmeta) 
  169. $this->field_map[] = array( 
  170. 'from_tablename' => 'topics',  
  171. 'from_fieldname' => 'forum_id',  
  172. 'to_type' => 'topic',  
  173. 'to_fieldname' => '_bbp_forum_id',  
  174. 'callback_method' => 'callback_forumid' 
  175. ); 
  176.  
  177. // Topic author. 
  178. $this->field_map[] = array( 
  179. 'from_tablename' => 'topics',  
  180. 'from_fieldname' => 'topic_poster',  
  181. 'to_type' => 'topic',  
  182. 'to_fieldname' => 'post_author',  
  183. 'callback_method' => 'callback_userid' 
  184. ); 
  185.  
  186. // Topic Author ip (Stored in postmeta) 
  187. $this->field_map[] = array( 
  188. 'from_tablename' => 'posts',  
  189. 'from_fieldname' => 'poster_ip',  
  190. 'join_tablename' => 'topics',  
  191. 'join_type' => 'INNER',  
  192. 'join_expression' => 'USING (topic_id) WHERE posts.post_id = topics.topic_first_post_id',  
  193. 'to_type' => 'topic',  
  194. 'to_fieldname' => '_bbp_author_ip' 
  195. ); 
  196.  
  197. // Topic content. 
  198. // Note: We join the 'posts' table because 'topics' does not include topic content. 
  199. $this->field_map[] = array( 
  200. 'from_tablename' => 'posts',  
  201. 'from_fieldname' => 'post_text',  
  202. 'join_tablename' => 'topics',  
  203. 'join_type' => 'INNER',  
  204. 'join_expression' => 'USING (topic_id) WHERE posts.post_id = topics.topic_first_post_id',  
  205. 'to_type' => 'topic',  
  206. 'to_fieldname' => 'post_content',  
  207. 'callback_method' => 'callback_html' 
  208. ); 
  209.  
  210. // Topic title. 
  211. $this->field_map[] = array( 
  212. 'from_tablename' => 'topics',  
  213. 'from_fieldname' => 'topic_title',  
  214. 'to_type' => 'topic',  
  215. 'to_fieldname' => 'post_title' 
  216. ); 
  217.  
  218. // Topic slug (Clean name to avoid conflicts) 
  219. $this->field_map[] = array( 
  220. 'from_tablename' => 'topics',  
  221. 'from_fieldname' => 'topic_title',  
  222. 'to_type' => 'topic',  
  223. 'to_fieldname' => 'post_name',  
  224. 'callback_method' => 'callback_slug' 
  225. ); 
  226.  
  227. // Topic status (Open or Closed) 
  228. $this->field_map[] = array( 
  229. 'from_tablename' => 'topics',  
  230. 'from_fieldname' => 'topic_status',  
  231. 'to_type' => 'topic',  
  232. 'to_fieldname' => 'post_status',  
  233. 'callback_method' => 'callback_topic_status' 
  234. ); 
  235.  
  236. // Topic parent forum id (If no parent, then 0) 
  237. $this->field_map[] = array( 
  238. 'from_tablename' => 'topics',  
  239. 'from_fieldname' => 'forum_id',  
  240. 'to_type' => 'topic',  
  241. 'to_fieldname' => 'post_parent',  
  242. 'callback_method' => 'callback_forumid' 
  243. ); 
  244.  
  245. // Sticky status (Stored in postmeta)) 
  246. $this->field_map[] = array( 
  247. 'from_tablename' => 'topics',  
  248. 'from_fieldname' => 'topic_type',  
  249. 'to_type' => 'topic',  
  250. 'to_fieldname' => '_bbp_old_sticky_status',  
  251. 'callback_method' => 'callback_sticky_status' 
  252. ); 
  253.  
  254. // Topic dates. 
  255. $this->field_map[] = array( 
  256. 'from_tablename' => 'topics',  
  257. 'from_fieldname' => 'topic_time',  
  258. 'to_type' => 'topic',  
  259. 'to_fieldname' => 'post_date',  
  260. 'callback_method' => 'callback_datetime' 
  261. ); 
  262. $this->field_map[] = array( 
  263. 'from_tablename' => 'topics',  
  264. 'from_fieldname' => 'topic_time',  
  265. 'to_type' => 'topic',  
  266. 'to_fieldname' => 'post_date_gmt',  
  267. 'callback_method' => 'callback_datetime' 
  268. ); 
  269. $this->field_map[] = array( 
  270. 'from_tablename' => 'topics',  
  271. 'from_fieldname' => 'topic_time',  
  272. 'to_type' => 'topic',  
  273. 'to_fieldname' => 'post_modified',  
  274. 'callback_method' => 'callback_datetime' 
  275. ); 
  276. $this->field_map[] = array( 
  277. 'from_tablename' => 'topics',  
  278. 'from_fieldname' => 'topic_time',  
  279. 'to_type' => 'topic',  
  280. 'to_fieldname' => 'post_modified_gmt',  
  281. 'callback_method' => 'callback_datetime' 
  282. ); 
  283. $this->field_map[] = array( 
  284. 'from_tablename' => 'topics',  
  285. 'from_fieldname' => 'topic_last_post_time',  
  286. 'to_type' => 'topic',  
  287. 'to_fieldname' => '_bbp_last_active_time',  
  288. 'callback_method' => 'callback_datetime' 
  289. ); 
  290.  
  291. /** Tags Section ******************************************************/ 
  292.  
  293. /** 
  294. * phpBB Forums do not support topic tags 
  295. */ 
  296.  
  297. /** Reply Section *****************************************************/ 
  298.  
  299. // Reply id (Stored in postmeta) 
  300. $this->field_map[] = array( 
  301. 'from_tablename' => 'posts',  
  302. 'from_fieldname' => 'post_id',  
  303. 'to_type' => 'reply',  
  304. 'to_fieldname' => '_bbp_post_id' 
  305. ); 
  306.  
  307. // Setup reply section table joins 
  308. $this->field_map[] = array( 
  309. 'from_tablename' => 'topics',  
  310. 'from_fieldname' => 'topic_id',  
  311. 'join_tablename' => 'posts',  
  312. 'join_type' => 'LEFT',  
  313. 'join_expression' => 'USING (topic_id) WHERE posts.post_id != topics.topic_first_post_id',  
  314. 'to_type' => 'reply' 
  315. ); 
  316.  
  317. // Reply parent forum id (If no parent, then 0. Stored in postmeta) 
  318. $this->field_map[] = array( 
  319. 'from_tablename' => 'posts',  
  320. 'from_fieldname' => 'forum_id',  
  321. 'to_type' => 'reply',  
  322. 'to_fieldname' => '_bbp_forum_id',  
  323. 'callback_method' => 'callback_topicid_to_forumid' 
  324. ); 
  325.  
  326. // Reply parent topic id (If no parent, then 0. Stored in postmeta) 
  327. $this->field_map[] = array( 
  328. 'from_tablename' => 'posts',  
  329. 'from_fieldname' => 'topic_id',  
  330. 'to_type' => 'reply',  
  331. 'to_fieldname' => '_bbp_topic_id',  
  332. 'callback_method' => 'callback_topicid' 
  333. ); 
  334.  
  335. // Reply author ip (Stored in postmeta) 
  336. $this->field_map[] = array( 
  337. 'from_tablename' => 'posts',  
  338. 'from_fieldname' => 'poster_ip',  
  339. 'to_type' => 'reply',  
  340. 'to_fieldname' => '_bbp_author_ip' 
  341. ); 
  342.  
  343. // Reply author. 
  344. $this->field_map[] = array( 
  345. 'from_tablename' => 'posts',  
  346. 'from_fieldname' => 'poster_id',  
  347. 'to_type' => 'reply',  
  348. 'to_fieldname' => 'post_author',  
  349. 'callback_method' => 'callback_userid' 
  350. ); 
  351.  
  352. // Reply title. 
  353. $this->field_map[] = array( 
  354. 'from_tablename' => 'posts',  
  355. 'from_fieldname' => 'post_subject',  
  356. 'to_type' => 'reply',  
  357. 'to_fieldname' => 'post_title',  
  358. 'callback_method' => 'callback_reply_title' 
  359. ); 
  360.  
  361. // Reply slug (Clean name to avoid conflicts) 
  362. $this->field_map[] = array( 
  363. 'from_tablename' => 'posts',  
  364. 'from_fieldname' => 'post_subject',  
  365. 'to_type' => 'reply',  
  366. 'to_fieldname' => 'post_name',  
  367. 'callback_method' => 'callback_slug' 
  368. ); 
  369.  
  370. // Reply content. 
  371. $this->field_map[] = array( 
  372. 'from_tablename' => 'posts',  
  373. 'from_fieldname' => 'post_text',  
  374. 'to_type' => 'reply',  
  375. 'to_fieldname' => 'post_content',  
  376. 'callback_method' => 'callback_html' 
  377. ); 
  378.  
  379. // Reply parent topic id (If no parent, then 0) 
  380. $this->field_map[] = array( 
  381. 'from_tablename' => 'posts',  
  382. 'from_fieldname' => 'topic_id',  
  383. 'to_type' => 'reply',  
  384. 'to_fieldname' => 'post_parent',  
  385. 'callback_method' => 'callback_topicid' 
  386. ); 
  387.  
  388. // Reply dates. 
  389. $this->field_map[] = array( 
  390. 'from_tablename' => 'posts',  
  391. 'from_fieldname' => 'post_time',  
  392. 'to_type' => 'reply',  
  393. 'to_fieldname' => 'post_date',  
  394. 'callback_method' => 'callback_datetime' 
  395. ); 
  396. $this->field_map[] = array( 
  397. 'from_tablename' => 'posts',  
  398. 'from_fieldname' => 'post_time',  
  399. 'to_type' => 'reply',  
  400. 'to_fieldname' => 'post_date_gmt',  
  401. 'callback_method' => 'callback_datetime' 
  402. ); 
  403. $this->field_map[] = array( 
  404. 'from_tablename' => 'posts',  
  405. 'from_fieldname' => 'post_time',  
  406. 'to_type' => 'reply',  
  407. 'to_fieldname' => 'post_modified',  
  408. 'callback_method' => 'callback_datetime' 
  409. ); 
  410. $this->field_map[] = array( 
  411. 'from_tablename' => 'posts',  
  412. 'from_fieldname' => 'post_time',  
  413. 'to_type' => 'reply',  
  414. 'to_fieldname' => 'post_modified_gmt',  
  415. 'callback_method' => 'callback_datetime' 
  416. ); 
  417.  
  418. /** User Section ******************************************************/ 
  419.  
  420. // Store old User id (Stored in usermeta) 
  421. $this->field_map[] = array( 
  422. 'from_tablename' => 'users',  
  423. 'from_fieldname' => 'user_id',  
  424. 'to_type' => 'user',  
  425. 'to_fieldname' => '_bbp_user_id' 
  426. ); 
  427.  
  428. // Store old User password (Stored in usermeta serialized with salt) 
  429. $this->field_map[] = array( 
  430. 'from_tablename' => 'users',  
  431. 'from_fieldname' => 'user_password',  
  432. 'to_type' => 'user',  
  433. 'to_fieldname' => '_bbp_password',  
  434. 'callback_method' => 'callback_savepass' 
  435. ); 
  436.  
  437. // Store old User Salt (This is only used for the SELECT row info for the above password save) 
  438. $this->field_map[] = array( 
  439. 'from_tablename' => 'users',  
  440. 'from_fieldname' => 'user_form_salt',  
  441. 'to_type' => 'user',  
  442. 'to_fieldname' => '' 
  443. ); 
  444.  
  445. // User password verify class (Stored in usermeta for verifying password) 
  446. $this->field_map[] = array( 
  447. 'to_type' => 'user',  
  448. 'to_fieldname' => '_bbp_class',  
  449. 'default' => 'phpBB' 
  450. ); 
  451.  
  452. // User name. 
  453. $this->field_map[] = array( 
  454. 'from_tablename' => 'users',  
  455. 'from_fieldname' => 'username',  
  456. 'to_type' => 'user',  
  457. 'to_fieldname' => 'user_login' 
  458. ); 
  459.  
  460. // User email. 
  461. $this->field_map[] = array( 
  462. 'from_tablename' => 'users',  
  463. 'from_fieldname' => 'user_email',  
  464. 'to_type' => 'user',  
  465. 'to_fieldname' => 'user_email' 
  466. ); 
  467.  
  468. // User homepage. 
  469. $this->field_map[] = array( 
  470. 'from_tablename' => 'users',  
  471. 'from_fieldname' => 'user_website',  
  472. 'to_type' => 'user',  
  473. 'to_fieldname' => 'user_url' 
  474. ); 
  475.  
  476. // User registered. 
  477. $this->field_map[] = array( 
  478. 'from_tablename' => 'users',  
  479. 'from_fieldname' => 'user_regdate',  
  480. 'to_type' => 'user',  
  481. 'to_fieldname' => 'user_registered',  
  482. 'callback_method' => 'callback_datetime' 
  483. ); 
  484.  
  485. // User AIM (Stored in usermeta) 
  486. $this->field_map[] = array( 
  487. 'from_tablename' => 'users',  
  488. 'from_fieldname' => 'user_aim',  
  489. 'to_type' => 'user',  
  490. 'to_fieldname' => 'aim' 
  491. ); 
  492.  
  493. // User Yahoo (Stored in usermeta) 
  494. $this->field_map[] = array( 
  495. 'from_tablename' => 'users',  
  496. 'from_fieldname' => 'user_yim',  
  497. 'to_type' => 'user',  
  498. 'to_fieldname' => 'yim' 
  499. ); 
  500.  
  501. // Store ICQ (Stored in usermeta) 
  502. $this->field_map[] = array( 
  503. 'from_tablename' => 'users',  
  504. 'from_fieldname' => 'user_icq',  
  505. 'to_type' => 'user',  
  506. 'to_fieldname' => '_bbp_phpbb_user_icq' 
  507. ); 
  508.  
  509. // Store MSN (Stored in usermeta) 
  510. $this->field_map[] = array( 
  511. 'from_tablename' => 'users',  
  512. 'from_fieldname' => 'user_msnm',  
  513. 'to_type' => 'user',  
  514. 'to_fieldname' => '_bbp_phpbb_user_msnm' 
  515. ); 
  516.  
  517. // Store Jabber 
  518. $this->field_map[] = array( 
  519. 'from_tablename' => 'users',  
  520. 'from_fieldname' => 'user_jabber',  
  521. 'to_type' => 'user',  
  522. 'to_fieldname' => 'jabber' 
  523. ); 
  524.  
  525. // Store Occupation (Stored in usermeta) 
  526. $this->field_map[] = array( 
  527. 'from_tablename' => 'users',  
  528. 'from_fieldname' => 'user_occ',  
  529. 'to_type' => 'user',  
  530. 'to_fieldname' => '_bbp_phpbb_user_occ' 
  531. ); 
  532.  
  533. // Store Interests (Stored in usermeta) 
  534. $this->field_map[] = array( 
  535. 'from_tablename' => 'users',  
  536. 'from_fieldname' => 'user_interests',  
  537. 'to_type' => 'user',  
  538. 'to_fieldname' => '_bbp_phpbb_user_interests' 
  539. ); 
  540.  
  541. // Store Signature (Stored in usermeta) 
  542. $this->field_map[] = array( 
  543. 'from_tablename' => 'users',  
  544. 'from_fieldname' => 'user_sig',  
  545. 'to_type' => 'user',  
  546. 'to_fieldname' => '_bbp_phpbb_user_sig',  
  547. 'callback_method' => 'callback_html' 
  548. ); 
  549.  
  550. // Store Location (Stored in usermeta) 
  551. $this->field_map[] = array( 
  552. 'from_tablename' => 'users',  
  553. 'from_fieldname' => 'user_from',  
  554. 'to_type' => 'user',  
  555. 'to_fieldname' => '_bbp_phpbb_user_from' 
  556. ); 
  557.  
  558. // Store Avatar Filename (Stored in usermeta) 
  559. $this->field_map[] = array( 
  560. 'from_tablename' => 'users',  
  561. 'from_fieldname' => 'user_avatar',  
  562. 'to_type' => 'user',  
  563. 'to_fieldname' => '_bbp_phpbb_user_avatar' 
  564. ); 
  565.  
  566. // Store old role (Stored in usermeta) 
  567.  
  568. /** 
  569. * This method allows us to indicates what is or is not converted for each 
  570. * converter. 
  571. */ 
  572. public function info() { 
  573. return ''; 
  574.  
  575. /** 
  576. * This method is to save the salt and password together. That 
  577. * way when it is authenticate it we can get it out of the database 
  578. * as one value. 
  579. */ 
  580. public function callback_savepass( $field, $row ) { 
  581. return array( 
  582. 'hash' => $field,  
  583. 'salt' => $row['salt'] 
  584. ); 
  585.  
  586. /** 
  587. * Check for correct password 
  588. * @param string $password The password in plain text 
  589. * @param string $hash The stored password hash 
  590. * @link Original source for password functions http://openwall.com/phpass/ 
  591. * @link phpass is now included in WP Core http://core.trac.wordpress.org/browser/trunk/wp-includes/class-phpass.php 
  592. * @return bool Returns true if the password is correct, false if not. 
  593. */ 
  594. public function authenticate_pass( $password, $serialized_pass ) { 
  595. $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; 
  596. $pass_array = unserialize( $serialized_pass ); 
  597. if ( strlen( $pass_array['hash'] ) == 34 ) { 
  598. return ( $this->_hash_crypt_private( $password, $pass_array['hash'], $itoa64 ) === $pass_array['hash'] ) ? true : false; 
  599.  
  600. return ( md5( $password ) === $pass_array['hash'] ) ? true : false; 
  601.  
  602. /** 
  603. * The crypt function/replacement 
  604. */ 
  605. private function _hash_crypt_private( $password, $setting, &$itoa64 ) { 
  606. $output = '*'; 
  607.  
  608. // Check for correct hash 
  609. if ( substr( $setting, 0, 3 ) != '$H$' ) { 
  610. return $output; 
  611.  
  612. $count_log2 = strpos( $itoa64, $setting[3] ); 
  613.  
  614. if ( $count_log2 < 7 || $count_log2 > 30 ) { 
  615. return $output; 
  616.  
  617. $count = 1 << $count_log2; 
  618. $salt = substr( $setting, 4, 8 ); 
  619.  
  620. if ( strlen( $salt ) != 8 ) { 
  621. return $output; 
  622.  
  623. /** 
  624. * We're kind of forced to use MD5 here since it's the only 
  625. * cryptographic primitive available in all versions of PHP 
  626. * currently in use. To implement our own low-level crypto 
  627. * in PHP would result in much worse performance and 
  628. * consequently in lower iteration counts and hashes that are 
  629. * quicker to crack (by non-PHP code). 
  630. */ 
  631. if ( floatval( phpversion() ) >= 5 ) { 
  632. $hash = md5( $salt . $password, true ); 
  633. do 
  634. $hash = md5( $hash . $password, true ); 
  635. while ( --$count ); 
  636. } else { 
  637. $hash = pack( 'H*', md5( $salt . $password ) ); 
  638. do { 
  639. $hash = pack( 'H*', md5( $hash . $password ) ); 
  640. while ( --$count ); 
  641.  
  642. $output = substr($setting, 0, 12); 
  643. $output .= $this->_hash_encode64($hash, 16, $itoa64); 
  644.  
  645. return $output; 
  646.  
  647. /** 
  648. * Encode hash 
  649. */ 
  650. private function _hash_encode64( $input, $count, &$itoa64 ) { 
  651. $output = ''; 
  652. $i = 0; 
  653.  
  654. do { 
  655. $value = ord( $input[$i++] ); 
  656. $output .= $itoa64[$value & 0x3f]; 
  657.  
  658. if ($i < $count) { 
  659. $value |= ord( $input[$i] ) << 8; 
  660.  
  661. $output .= $itoa64[( $value >> 6 ) & 0x3f]; 
  662.  
  663. if ( $i++ >= $count ) { 
  664. break; 
  665.  
  666. if ( $i < $count ) { 
  667. $value |= ord( $input[$i] ) << 16; 
  668.  
  669. $output .= $itoa64[( $value >> 12 ) & 0x3f]; 
  670.  
  671. if ( $i++ >= $count ) { 
  672. break; 
  673.  
  674. $output .= $itoa64[($value >> 18) & 0x3f]; 
  675. } while ( $i < $count ); 
  676.  
  677. return $output; 
  678.  
  679. /** 
  680. * Translate the forum type from phpBB v3.x numeric's to WordPress's strings. 
  681. * @param int $status phpBB v3.x numeric forum type 
  682. * @return string WordPress safe 
  683. */ 
  684. public function callback_forum_type( $status = 1 ) { 
  685. switch ( $status ) { 
  686. case 0 : 
  687. $status = 'category'; 
  688. break; 
  689.  
  690. case 1 : 
  691. default : 
  692. $status = 'forum'; 
  693. break; 
  694. return $status; 
  695.  
  696. /** 
  697. * Translate the forum status from phpBB v3.x numeric's to WordPress's strings. 
  698. * @param int $status phpBB v3.x numeric forum status 
  699. * @return string WordPress safe 
  700. */ 
  701. public function callback_forum_status( $status = 0 ) { 
  702. switch ( $status ) { 
  703. case 1 : 
  704. $status = 'closed'; 
  705. break; 
  706.  
  707. case 0 : 
  708. default : 
  709. $status = 'open'; 
  710. break; 
  711. return $status; 
  712.  
  713. /** 
  714. * Translate the topic status from phpBB v3.x numeric's to WordPress's strings. 
  715. * @param int $status phpBB v3.x numeric topic status 
  716. * @return string WordPress safe 
  717. */ 
  718. public function callback_topic_status( $status = 0 ) { 
  719. switch ( $status ) { 
  720. case 1 : 
  721. $status = 'closed'; 
  722. break; 
  723.  
  724. case 0 : 
  725. default : 
  726. $status = 'publish'; 
  727. break; 
  728. return $status; 
  729.  
  730. /** 
  731. * Translate the topic sticky status type from phpBB 3.x numeric's to WordPress's strings. 
  732. * @param int $status phpBB 3.x numeric forum type 
  733. * @return string WordPress safe 
  734. */ 
  735. public function callback_sticky_status( $status = 0 ) { 
  736. switch ( $status ) { 
  737. case 3 : 
  738. $status = 'super-sticky'; // phpBB Global Sticky 'topic_type = 3' 
  739. break; 
  740.  
  741. case 2 : 
  742. $status = 'super-sticky'; // phpBB Announcement Sticky 'topic_type = 2' 
  743. break; 
  744.  
  745. case 1 : 
  746. $status = 'sticky'; // phpBB Sticky 'topic_type = 1' 
  747. break; 
  748.  
  749. case 0 : 
  750. default : 
  751. $status = 'normal'; // phpBB normal topic 'topic_type = 0' 
  752. break; 
  753. return $status; 
  754.  
  755. /** 
  756. * Verify the topic reply count. 
  757. * @param int $count phpBB v3.x reply count 
  758. * @return string WordPress safe 
  759. */ 
  760. public function callback_topic_reply_count( $count = 1 ) { 
  761. $count = absint( (int) $count - 1 ); 
  762. return $count; 
  763.  
  764. /** 
  765. * Set the reply title 
  766. * @param string $title phpBB v3.x topic title of this reply 
  767. * @return string Prefixed topic title, or empty string 
  768. */ 
  769. public function callback_reply_title( $title = '' ) { 
  770. $title = !empty( $title ) ? __( 'Re: ', 'bbpress' ) . html_entity_decode( $title ) : ''; 
  771. return $title; 
  772.  
  773. /** 
  774. * This callback processes any custom parser.php attributes and custom code with preg_replace 
  775. */ 
  776. protected function callback_html( $field ) { 
  777.  
  778. // Strips custom phpBB 'magic_url' and 'bbcode_uid' first from $field before parsing $field to parser.php 
  779. $phpbb_uid = $field; 
  780. $phpbb_uid = html_entity_decode( $phpbb_uid ); 
  781.  
  782. // Replace '[b:XXXXXXX]' with '<strong>' 
  783. $phpbb_uid = preg_replace( '/\[b:(.*?)\]/', '<strong>', $phpbb_uid ); 
  784. // Replace '[/b:XXXXXXX]' with '</strong>' 
  785. $phpbb_uid = preg_replace( '/\[\/b:(.*?)\]/', '</strong>', $phpbb_uid ); 
  786.  
  787. // Replace '[i:XXXXXXX]' with '<em>' 
  788. $phpbb_uid = preg_replace( '/\[i:(.*?)\]/', '<em>', $phpbb_uid ); 
  789. // Replace '[/i:XXXXXXX]' with '</em>' 
  790. $phpbb_uid = preg_replace( '/\[\/i:(.*?)\]/', '</em>', $phpbb_uid ); 
  791.  
  792. // Replace '[u:XXXXXXX]' with '<u>' 
  793. $phpbb_uid = preg_replace( '/\[u:(.*?)\]/', '<u>', $phpbb_uid ); 
  794. // Replace '[/u:XXXXXXX]' with '</u>' 
  795. $phpbb_uid = preg_replace( '/\[\/u:(.*?)\]/', '</u>', $phpbb_uid ); 
  796.  
  797. // Replace '[quote:XXXXXXX]' with '<blockquote>' 
  798. $phpbb_uid = preg_replace( '/\[quote:(.*?)\]/', '<blockquote>', $phpbb_uid ); 
  799. // Replace '[quote="$1"]' with '<em>$1 wrote:</em><blockquote>" 
  800. $phpbb_uid = preg_replace( '/\[quote="(.*?)":(.*?)\]/', '<em>@$1 wrote:</em><blockquote>', $phpbb_uid ); 
  801. // Replace '[/quote:XXXXXXX]' with '</blockquote>' 
  802. $phpbb_uid = preg_replace( '/\[\/quote:(.*?)\]/', '</blockquote>', $phpbb_uid ); 
  803.  
  804. // Replace '[img:XXXXXXX]' with '<img src="' 
  805. $phpbb_uid = preg_replace( '/\[img:(.*?)\]/', '<img src="', $phpbb_uid ); 
  806. // Replace '[/img:XXXXXXX]' with ' alt="">' 
  807. $phpbb_uid = preg_replace( '/\[\/img:(.*?)\]/', '" alt="">', $phpbb_uid ); 
  808.  
  809. // Replace '<!-- s$1 --><img src=\"{SMILIES_PATH}$2 -->' with '$1' 
  810. $phpbb_uid = preg_replace( '/<!-- s(.*?) --><img src=\"{SMILIES_PATH}(.*?)-->/', '$1', $phpbb_uid ); 
  811.  
  812. // Replace '<!-- m --><a class="postlink" href="$1">$1</a><!-- m -->' with '$1' 
  813. $phpbb_uid = preg_replace( '/\<!-- m --\>\<a class="postlink" href="([^\[]+?)"\>([^\[]+?)\<\/a\>\<!-- m --\>/', '$1', $phpbb_uid ); 
  814.  
  815. // Replace '[url:XXXXXXX]$1[/url:XXXXXXX]' with '<a href="http://$1">$1</a>' 
  816. $phpbb_uid = preg_replace( '/\[url:(?:[^\]]+)\]([^\[]+?)\[\/url:(?:[^\]]+)\]/', '<a href="http://$1">$1</a>', $phpbb_uid ); 
  817. // Replace '[url=http://$1:XXXXXXX]$3[/url:XXXXXXX]' with '<a href="http://$1">$3</a>' 
  818. $phpbb_uid = preg_replace( '/\[url\=http\:\/\/(.*?)\:(.*?)\](.*?)\[\/url:(.*?)\]/i', '<a href="http://$1">$3</a>', $phpbb_uid ); 
  819. // Replace '[url=https://$1:XXXXXXX]$3[/url:XXXXXXX]' with '<a href="http://$1">$3</a>' 
  820. $phpbb_uid = preg_replace( '/\[url\=https\:\/\/(.*?)\:(.*?)\](.*?)\[\/url:(.*?)\]/i', '<a href="https://$1">$3</a>', $phpbb_uid ); 
  821.  
  822. // Replace '[email:XXXXXXX]' with '<a href="mailto:$2">$2</a>' 
  823. $phpbb_uid = preg_replace( '/\[email:(.*?)\](.*?)\[\/email:(.*?)\]/', '<a href="mailto:$2">$2</a>', $phpbb_uid ); 
  824. // Replace '<!-- e -->no.one@domain.adr<!-- e -->' with '$1' 
  825. $phpbb_uid = preg_replace( '/\<!-- e --\>(.*?)\<!-- e --\>/', '$1', $phpbb_uid ); 
  826.  
  827. // Replace '[code:XXXXXXX]' with '<pre><code>' 
  828. $phpbb_uid = preg_replace( '/\[code:(.*?)\]/', '<pre><code>', $phpbb_uid ); 
  829. // Replace '[/code:XXXXXXX]' with '</code></pre>' 
  830. $phpbb_uid = preg_replace( '/\[\/code:(.*?)\]/', '</code></pre>', $phpbb_uid ); 
  831.  
  832. // Replace '[color=$1:XXXXXXXX]' with '<span style="color:$1">' 
  833. $phpbb_uid = preg_replace( '/\[color=(.*?)\:(.*?)\]/', '<span style="color: $1">', $phpbb_uid ); 
  834. // Replace '[/color:XXXXXXX]' with '</span>' 
  835. $phpbb_uid = preg_replace( '/\[\/color:(.*?)\]/', '</span>', $phpbb_uid ); 
  836.  
  837. // Replace '[size=$1:XXXXXXXX]' with '<span style="font-size:$1%;">$3</span>' 
  838. $phpbb_uid = preg_replace( '/\[size=(.*?):(.*?)\]/', '<span style="font-size:$1%;">', $phpbb_uid ); 
  839. // Replace '[/size:XXXXXXX]' with '' 
  840. $phpbb_uid = preg_replace( '/\[\/size:(.*?)\]/', '</span>', $phpbb_uid ); 
  841.  
  842. // Replace '[list:XXXXXXX]' with '<ul>' 
  843. $phpbb_uid = preg_replace( '/\[list:(.*?)\]/', '<ul>', $phpbb_uid ); 
  844. // Replace '[list=a:XXXXXXX]' with '<ol type="a">' 
  845. $phpbb_uid = preg_replace( '/\[list=a:(.*?)\]/', '<ol type="a">', $phpbb_uid ); 
  846. // Replace '[list=1:XXXXXXX]' with '<ol>' 
  847. $phpbb_uid = preg_replace( '/\[list=1:(.*?)\]/', '<ol>', $phpbb_uid ); 
  848. // Replace '[*:XXXXXXX]' with '<li>' 
  849. $phpbb_uid = preg_replace( '/\[\*:(.*?)\]/', '<li>', $phpbb_uid ); 
  850. // Replace '[/*:m:XXXXXXX]' with '</li>' 
  851. $phpbb_uid = preg_replace( '/\[\/\*:m:(.*?)\]/', '</li>', $phpbb_uid ); 
  852. // Replace '[/list:u:XXXXXXX]' with '</ul>' 
  853. $phpbb_uid = preg_replace( '/\[\/list:u:(.*?)\]/', '</ul>', $phpbb_uid ); 
  854. // Replace '[/list:o:XXXXXXX]' with '</ol>' 
  855. $phpbb_uid = preg_replace( '/\[\/list:o:(.*?)\]/', '</ol>', $phpbb_uid ); 
  856.  
  857. // Now that phpBB's 'magic_url' and 'bbcode_uid' have been stripped put the cleaned HTML back in $field 
  858. $field = $phpbb_uid; 
  859.  
  860. // Parse out any bbCodes in $field with the BBCode 'parser.php' 
  861. require_once( bbpress()->admin->admin_dir . 'parser.php' ); 
  862. $bbcode = BBCode::getInstance(); 
  863. $bbcode->enable_smileys = false; 
  864. $bbcode->smiley_regex = false; 
  865. return html_entity_decode( $bbcode->Parse( $field ) );