forked from Kunena/com_kunenaimporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
export_phpbb3.php
678 lines (614 loc) · 23.3 KB
/
export_phpbb3.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
<?php
/**
* @version $Id$
* Kunena Forum Importer Component
* @package com_kunenaimporter
*
* Imports forum data into Kunena
*
* @Copyright (C) 2009 - 2010 Kunena Team All rights reserved
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link http://www.kunena.com
*
*/
defined ( '_JEXEC' ) or die ();
// Import Joomla! libraries
jimport ( 'joomla.application.component.model' );
jimport ( 'joomla.application.application' );
require_once (JPATH_COMPONENT . DS . 'models' . DS . 'export.php');
class KunenaimporterModelExport_phpBB3 extends KunenaimporterModelExport {
var $version;
var $auth_method;
var $rokbridge = null;
public function __construct() {
// Get component parameters
$component = JComponentHelper::getComponent ( 'com_kunenaimporter' );
$params = new JParameter ( $component->params );
// Use RokBridge if it has been installed
$rokbridge = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rokbridge' . DS . 'helper.php';
if (is_file ( $rokbridge )) {
require_once ($rokbridge);
$this->rokbridge = new RokBridgeHelper ();
if (isset ( $this->rokbridge->phpbb_db ))
$this->ext_database = $this->rokbridge->phpbb_db;
$this->basepath = JPATH_ROOT."/{$this->rokbridge->phpbb_path}";
$this->relpath = $this->rokbridge->phpbb_path;
}
parent::__construct ();
}
protected function getConfig() {
if (empty($this->config)) {
// Check if database settings are correct
$query = "SELECT config_name, config_value AS value FROM #__config";
$this->ext_database->setQuery ( $query );
$this->config = $this->ext_database->loadObjectList ('config_name');
}
return $this->config;
}
public function checkConfig() {
// Check Kunena compatibility
parent::checkConfig ();
if (JError::isError ( $this->ext_database ))
return;
// Check RokBridge
if ($this->rokbridge) {
$this->addMessage ( '<div>RokBridge: <b style="color:green">detected</b></div>' );
}
// Check if database settings are correct
$config = $this->getConfig();
if (empty($config['version'])) {
$this->error = $this->ext_database->getErrorMsg ();
if (! $this->error)
$this->error = 'Configuration information missing: phpBB version not found';
}
if ($this->error) {
$this->addMessage ( '<div>phpBB version: <b style="color:red">FAILED</b></div>' );
return false;
}
// Check version number
$this->version = $config['version']->value;
if ($this->version [0] == '.')
$this->version = '2' . $this->version;
$version = explode ( '.', $this->version, 3 );
if ($version [0] != 3 || $version [1] != 0)
$this->error = "Unsupported forum: phpBB $this->version";
if ($this->error) {
$this->addMessage ( '<div>phpBB version: <b style="color:red">' . $this->version . '</b></div>' );
$this->addMessage ( '<div><b>Error:</b> ' . $this->error . '</div>' );
return false;
}
$this->addMessage ( '<div>phpBB version: <b style="color:green">' . $this->version . '</b></div>' );
// Check authentication method
$query = "SELECT config_value FROM #__config WHERE config_name='auth_method'";
$this->ext_database->setQuery ( $query );
$this->auth_method = $this->ext_database->loadResult () or die ( "<br />Invalid query:<br />$query<br />" . $this->ext_database->errorMsg () );
$this->addMessage ( '<div>phpBB authentication method: <b style="color:green">' . $this->auth_method . '</b></div>' );
// Find out which field is used as username
$fields = $this->ext_database->getTableFields('#__users');
$this->login_field = isset($fields['#__users']['login_name']);
}
public function getAuthMethod() {
return $this->auth_method;
}
public function buildImportOps() {
// query: (select, from, where, groupby), functions: (count, export)
$importOps = array ();
$importOps ['users'] = array ('count' => 'countUsers', 'export' => 'exportUsers' );
$importOps ['categories'] = array ('count' => 'countCategories', 'export' => 'exportCategories' );
$importOps ['config'] = array ('count' => 'countConfig', 'export' => 'exportConfig' );
$importOps ['messages'] = array ('count' => 'countMessages', 'export' => 'exportMessages' );
$importOps ['attachments'] = array ('count' => 'countAttachments', 'export' => 'exportAttachments' );
$importOps ['sessions'] = array ('count' => 'countSessions', 'export' => 'exportSessions' );
$importOps ['subscriptions'] = array ('count' => 'countSubscriptions', 'export' => 'exportSubscriptions' );
$importOps ['userprofile'] = array ('count' => 'countUserProfile', 'export' => 'exportUserProfile' );
$importOps ['avatargalleries'] = array ('count' => 'countAvatarGalleries', 'export' => 'exportAvatarGalleries' );
$this->importOps = $importOps;
}
public function countCategories() {
$query = "SELECT COUNT(*) FROM #__forums";
return $this->getCount ( $query );
}
public function &exportCategories($start = 0, $limit = 0) {
$query = "SELECT
forum_id AS id,
parent_id AS parent,
forum_name AS name,
0 AS cat_emoticon,
(forum_status=1) AS locked,
0 AS alert_admin,
1 AS moderated,
NULL AS moderators,
0 AS pub_access,
1 AS pub_recurse,
0 AS admin_access,
1 AS admin_recurse,
left_id AS ordering,
0 AS future2,
1 AS published,
0 AS checked_out,
'0000-00-00 00:00:00' AS checked_out_time,
0 AS review,
0 AS allow_anonymous,
0 as post_anonymous,
0 AS hits,
forum_desc AS description,
'' AS headerdesc,
'' AS class_sfx,
0 AS allow_polls,
forum_last_post_id AS id_last_msg,
forum_posts AS numPosts,
forum_topics AS numTopics,
forum_last_post_time AS time_last_msg
FROM #__forums ORDER BY id";
$result = $this->getExportData ( $query, $start, $limit, 'id' );
foreach ( $result as &$row ) {
$row->name = $this->prep ( $row->name );
$row->description = $this->prep ( $row->description );
}
return $result;
}
public function countConfig() {
return 1;
}
public function &exportConfig($start = 0, $limit = 0) {
$config = array ();
if ($start)
return $config;
$query = "SELECT config_name, config_value AS value FROM #__config";
$result = $this->getExportData ( $query, 0, 1000, 'config_name' );
if (! $result)
return $config;
$config ['id'] = 1; // $result['config_id']->value;
$config ['board_title'] = $result ['sitename']->value;
$config ['email'] = $result ['board_email']->value;
$config ['board_offline'] = $result ['board_disable']->value;
$config ['board_ofset'] = $result ['board_timezone']->value;
// $config['offline_message'] = null;
// $config['default_view'] = null;
// $config['enablerss'] = null;
// $config['enablepdf'] = null;
$config ['threads_per_page'] = $result ['topics_per_page']->value;
$config ['messages_per_page'] = $result ['posts_per_page']->value;
// $config['messages_per_page_search'] = null;
// $config['showhistory'] = null;
// $config['historylimit'] = null;
// $config['shownew'] = null;
// $config['newchar'] = null;
// $config['jmambot'] = null;
$config ['disemoticons'] = $result ['allow_smilies']->value ^ 1;
// $config['template'] = null;
// $config['templateimagepath'] = null;
// $config['joomlastyle'] = null;
// $config['showannouncement'] = null;
// $config['avataroncat'] = null;
// $config['catimagepath'] = null;
// $config['numchildcolumn'] = null;
// $config['showchildcaticon'] = null;
// $config['annmodid'] = null;
// $config['rtewidth'] = null;
// $config['rteheight'] = null;
// $config['enablerulespage'] = null;
// $config['enableforumjump'] = null;
// $config['reportmsg'] = null;
// $config['username'] = null;
// $config['askemail'] = null;
// $config['showemail'] = null;
// $config['showuserstats'] = null;
// $config['poststats'] = null;
// $config['statscolor'] = null;
// $config['showkarma'] = null;
// $config['useredit'] = null;
// $config['useredittime'] = null;
// $config['useredittimegrace'] = null;
// $config['editmarkup'] = null;
$config ['allowsubscriptions'] = $result ['allow_topic_notify']->value;
// $config['subscriptionschecked'] = null;
// $config['allowfavorites'] = null;
// $config['wrap'] = null;
// $config['maxsubject'] = null;
$config ['maxsig'] = $result ['allow_sig']->value ? $result ['max_sig_chars']->value : 0;
// $config['regonly'] = null;
$config ['changename'] = $result ['allow_namechange']->value;
// $config['pubwrite'] = null;
$config ['floodprotection'] = $result ['flood_interval']->value;
// $config['mailmod'] = null;
// $config['mailadmin'] = null;
// $config['captcha'] = null;
// $config['mailfull'] = null;
$config ['allowavatar'] = $result ['allow_avatar_upload']->value || $result ['allow_avatar_local']->value;
$config ['allowavatarupload'] = $result ['allow_avatar_upload']->value;
$config ['allowavatargallery'] = $result ['allow_avatar_local']->value;
// $config['imageprocessor'] = null;
$config ['avatarsmallheight'] = $result ['avatar_max_height']->value > 50 ? 50 : $result ['avatar_max_height']->value;
$config ['avatarsmallwidth'] = $result ['avatar_max_width']->value > 50 ? 50 : $result ['avatar_max_width']->value;
$config ['avatarheight'] = $result ['avatar_max_height']->value > 100 ? 100 : $result ['avatar_max_height']->value;
$config ['avatarwidth'] = $result ['avatar_max_width']->value > 100 ? 100 : $result ['avatar_max_width']->value;
$config ['avatarlargeheight'] = $result ['avatar_max_height']->value;
$config ['avatarlargewidth'] = $result ['avatar_max_width']->value;
// $config['avatarquality'] = null;
$config ['avatarsize'] = ( int ) ($result ['avatar_filesize']->value / 1000);
// $config['allowimageupload'] = null;
// $config['allowimageregupload'] = null;
// $config['imageheight'] = null;
// $config['imagewidth'] = null;
// $config['imagesize'] = null;
// $config['allowfileupload'] = null;
// $config['allowfileregupload'] = null;
// $config['filetypes'] = null;
$config ['filesize'] = ( int ) ($result ['max_filesize']->value / 1000);
// $config['showranking'] = null;
// $config['rankimages'] = null;
// $config['avatar_src'] = null;
// $config['fb_profile'] = null;
// $config['pm_component'] = null;
// $config['discussbot'] = null;
// $config['userlist_rows'] = null;
// $config['userlist_online'] = null;
// $config['userlist_avatar'] = null;
// $config['userlist_name'] = null;
// $config['userlist_username'] = null;
// $config['userlist_group'] = null;
// $config['userlist_posts'] = null;
// $config['userlist_karma'] = null;
// $config['userlist_email'] = null;
// $config['userlist_usertype'] = null;
// $config['userlist_joindate'] = null;
// $config['userlist_lastvisitdate'] = null;
// $config['userlist_userhits'] = null;
// $config['showlatest'] = null;
// $config['latestcount'] = null;
// $config['latestcountperpage'] = null;
// $config['latestcategory'] = null;
// $config['latestsinglesubject'] = null;
// $config['latestreplysubject'] = null;
// $config['latestsubjectlength'] = null;
// $config['latestshowdate'] = null;
// $config['latestshowhits'] = null;
// $config['latestshowauthor'] = null;
// $config['showstats'] = null;
// $config['showwhoisonline'] = null;
// $config['showgenstats'] = null;
// $config['showpopuserstats'] = null;
// $config['popusercount'] = null;
// $config['showpopsubjectstats'] = null;
// $config['popsubjectcount'] = null;
// $config['usernamechange'] = null;
// $config['rules_infb'] = null;
// $config['rules_cid'] = null;
// $config['rules_link'] = null;
// $config['enablehelppage'] = null;
// $config['help_infb'] = null;
// $config['help_cid'] = null;
// $config['help_link'] = null;
// $config['showspoilertag'] = null;
// $config['showvideotag'] = null;
// $config['showebaytag'] = null;
// $config['trimlongurls'] = null;
// $config['trimlongurlsfront'] = null;
// $config['trimlongurlsback'] = null;
// $config['autoembedyoutube'] = null;
// $config['autoembedebay'] = null;
// $config['ebaylanguagecode'] = null;
$config ['fbsessiontimeout'] = $result ['session_length']->value;
// $config['highlightcode'] = null;
// $config['rsstype'] = null;
// $config['rsshistory'] = null;
$config ['fbdefaultpage'] = 'categories';
// $config['default_sort'] = null;
$result = array ('1' => $config );
return $result;
}
public function countMessages() {
$query = "SELECT COUNT(*) FROM #__posts";
return $this->getCount ( $query );
}
public function &exportMessages($start = 0, $limit = 0) {
$query = "SELECT
p.post_id AS id,
IF(p.post_id=t.topic_first_post_id,0,t.topic_first_post_id) AS parent,
t.topic_first_post_id AS thread,
t.forum_id AS catid,
IF(p.post_username, p.post_username, u.username) AS name,
p.poster_id AS userid,
u.user_email AS email,
IF(p.post_subject, p.post_subject, t.topic_title) AS subject,
p.post_time AS time,
p.poster_ip AS ip,
0 AS topic_emoticon,
(t.topic_status=1 AND p.post_id=t.topic_first_post_id) AS locked,
((p.post_approved+1)%2) AS hold,
(t.topic_type>0 AND p.post_id=t.topic_first_post_id) AS ordering,
t.topic_views AS hits,
(t.topic_moved_id>0) AS moved,
p.post_edit_user AS modified_by,
p.post_edit_time AS modified_time,
p.post_edit_reason AS modified_reason,
p.post_text AS message
FROM `#__posts` AS p
LEFT JOIN `#__topics` AS t ON p.topic_id = t.topic_id
LEFT JOIN `#__users` AS u ON p.poster_id = u.user_id
ORDER BY p.post_id";
$result = $this->getExportData ( $query, $start, $limit, 'id' );
foreach ( $result as &$row ) {
$row->name = $this->prep ( $row->name );
$row->email = $this->prep ( $row->email );
$row->subject = $this->prep ( $row->subject );
if (! $row->modified_time)
$row->modified_by = 0;
$row->modified_reason = $this->prep ( $row->modified_reason );
$row->message = $this->prep ( $row->message );
}
return $result;
}
public function countAttachments() {
$query = "SELECT COUNT(*) FROM `#__attachments`";
return $this->getCount ( $query );
}
public function &exportAttachments($start = 0, $limit = 0) {
$query = "SELECT
attach_id AS id,
post_msg_id AS mesid,
poster_id AS userid,
NULL AS hash,
filesize AS size,
'phpbb3' AS folder,
IF(LENGTH(mimetype)>0,mimetype,extension) AS filetype,
real_filename AS filename,
physical_filename AS location
FROM `#__attachments`
ORDER BY attach_id";
$result = $this->getExportData ( $query, $start, $limit, 'id' );
foreach ( $result as &$row ) {
$row->location = "{$this->basepath}/files/{$row->location}";
}
return $result;
}
public function countSessions() {
$query = "SELECT COUNT(*) FROM `#__users` AS u WHERE user_lastvisit>0";
return $this->getCount ( $query );
}
public function &exportSessions($start = 0, $limit = 0) {
$query = "SELECT
user_id AS userid,
NULL AS allowed,
user_lastmark AS lasttime,
'' AS readtopics,
user_lastvisit AS currvisit
FROM `#__users`
WHERE user_lastvisit>0";
$result = $this->getExportData ( $query, $start, $limit );
foreach ( $result as $key => &$row ) {
$row->lasttime = date ( "Y-m-d H:i:s", $row->lasttime );
$row->currvisit = date ( "Y-m-d H:i:s", $row->currvisit );
}
return $result;
}
public function countSubscriptions() {
$query = "SELECT COUNT(*) FROM `#__topics_watch`";
return $this->getCount ( $query );
}
public function &exportSubscriptions($start = 0, $limit = 0) {
$query = "SELECT
t.topic_first_post_id AS thread,
w.user_id AS userid,
0 AS future1
FROM `#__topics_watch` AS w
LEFT JOIN `#__topics` AS t ON w.topic_id=t.topic_id";
$result = $this->getExportData ( $query, $start, $limit );
return $result;
}
public function countUserProfile() {
$query = "SELECT COUNT(*) FROM `#__users` AS u WHERE user_id > 0 AND u.user_type != 2";
return $this->getCount ( $query );
}
public function &exportUserProfile($start = 0, $limit = 0) {
$query = "SELECT
u.user_id AS userid,
'flat' AS view,
u.user_sig AS signature,
0 AS moderator,
NULL AS banned,
0 AS ordering,
u.user_posts AS posts,
user_avatar AS avatar,
0 AS karma,
0 AS karma_time,
1 AS group_id,
0 AS uhits,
NULL AS personalText,
0 AS gender,
u.user_birthday AS birthdate,
u.user_from AS location,
u.user_icq AS ICQ,
u.user_aim AS AIM,
u.user_yim AS YIM,
u.user_msnm AS MSN,
NULL AS SKYPE,
NULL AS TWITTER,
NULL AS FACEBOOK,
NULL AS GTALK,
NULL AS MYSPACE,
NULL AS LINKEDIN,
NULL AS DELICIOUS,
NULL AS FRIENDFEED,
NULL AS DIGG,
NULL AS BLOGSPOT,
NULL AS FLICKR,
NULL AS BEBO,
NULL AS websitename,
u.user_website AS websiteurl,
0 AS rank,
1 AS hideEmail,
1 AS showOnline,
user_avatar_type AS avatartype
FROM `#__users` AS u
WHERE u.user_id > 0 AND u.user_type != 2
ORDER BY u.user_id";
$result = $this->getExportData ( $query, $start, $limit, 'userid' );
$path = $this->config['avatar_path']->value;
$salt = $this->config['avatar_salt']->value;
foreach ( $result as &$row ) {
// Convert bbcode in signature
if ($row->avatar) {
switch ($row->avatartype) {
case 1:
// Uploaded
$filename = (int) $row->avatar;
$ext = substr(strrchr($row->avatar, '.'), 1);
$row->avatar = "users/{$row->avatar}";
$row->avatarpath = "{$this->basepath}/{$path}/{$salt}_{$filename}.{$ext}";
break;
case 2:
// URL not supported
$row->avatar = '';
break;
case 3:
// Gallery
$row->avatar = "gallery/{$row->avatar}";
break;
default:
$row->avatar = '';
}
}
$row->signature = $this->prep ( $row->signature );
$row->location = $this->prep ( $row->location );
}
return $result;
}
public function countUsers() {
$query = "SELECT COUNT(*) FROM `#__users` AS u WHERE user_id > 0 AND u.user_type != 2";
return $this->getCount ( $query );
}
public function &exportUsers($start = 0, $limit = 0) {
$username = $this->login_field ? 'login_name' : 'username';
$query = "SELECT
u.user_id AS extid,
u.{$username} AS extusername,
u.username AS name,
u.{$username} AS username,
u.user_email AS email,
u.user_password AS password,
IF(u.user_type=3, 'Administrator', 'Registered') AS usertype,
IF(b.ban_userid, 1, 0) AS block,
0 AS gid,
FROM_UNIXTIME(u.user_regdate) AS registerDate,
IF(u.user_lastvisit>0, FROM_UNIXTIME(u.user_lastvisit), '0000-00-00 00:00:00') AS lastvisitDate,
NULL AS params
FROM `#__users` AS u
LEFT JOIN `#__banlist` AS b ON u.user_id = b.ban_userid
WHERE user_id > 0 AND u.user_type != 2
GROUP BY u.user_id
ORDER BY u.user_id";
$result = $this->getExportData ( $query, $start, $limit, 'extid' );
foreach ( $result as &$row ) {
$row->name = html_entity_decode ( $row->name );
$row->username = html_entity_decode ( $row->username );
}
return $result;
}
protected function &getAvatarGalleries() {
static $galleries = false;
if ($galleries === false) {
$path = "{$this->basepath}/{$this->config['avatar_gallery_path']->value}";
$galleries = array();
$folders = JFolder::folders($path);
foreach ($folders as $folder) {
$galleries[$folder] = "{$path}/{$folder}";
}
}
return $galleries;
}
public function countAvatarGalleries() {
return count($this->getAvatarGalleries());
}
public function &exportAvatarGalleries($start = 0, $limit = 0) {
$galleries = $this->getAvatarGalleries();
return array_slice($galleries, $start, $limit);
}
public function mapJoomlaUser($joomlauser) {
if (!$this->rokbridge) return false;
if($this->login_field) {
// Use login_name created by SMF to phpBB3 convertor
$field = 'login_name';
$username = $joomlauser->username;
} else {
$field = 'username_clean';
$username = utf8_clean_string($joomlauser->username);
}
$query = "SELECT user_id
FROM #__users WHERE {$field}={$this->ext_database->Quote($username)}";
$this->ext_database->setQuery( $query );
$result = intval($this->ext_database->loadResult());
return $result;
}
//--- Function to prepare strings for MySQL storage ---/
protected function prep($s) {
// Parse out the $uid things that fuck up bbcode
$s = preg_replace ( '/\</', '<', $s );
$s = preg_replace ( '/\>/', '>', $s );
$s = preg_replace ( '/\"/', '"', $s );
$s = preg_replace ( '/\&/', '&', $s );
$s = preg_replace ( '/\ /', ' ', $s );
$s = preg_replace ( '/\'/', "'", $s );
$s = preg_replace ( '/\(/', '(', $s );
$s = preg_replace ( '/\)/', ')', $s );
$s = preg_replace ( '/\./', '.', $s );
$s = preg_replace ( '/\:/', ':', $s );
$s = preg_replace ( '/\{/', '{', $s );
$s = preg_replace ( '/\}/', '}', $s );
// <strong> </strong>
$s = preg_replace ( '/\[b:(.*?)\]/', '[b]', $s );
$s = preg_replace ( '/\[\/b:(.*?)\]/', '[/b]', $s );
// <em> </em>
$s = preg_replace ( '/\[i:(.*?)\]/', '[i]', $s );
$s = preg_replace ( '/\[\/i:(.*?)\]/', '[/i]', $s );
// <u> </u>
$s = preg_replace ( '/\[u:(.*?)\]/', '[u]', $s );
$s = preg_replace ( '/\[\/u:(.*?)\]/', '[/u]', $s );
// quote
$s = preg_replace ( '/\[quote:(.*?)\]/', '[quote]', $s );
$s = preg_replace ( '/\[quote(:(.*?))?="(.*?)"\]/', '[b]\\3[/b]\n[quote]', $s );
$s = preg_replace ( '/\[\/quote:(.*?)\]/', '[/quote]', $s );
// image
#$s = preg_replace('/\[img:(.*?)="(.*?)"\]/', '[img="\\2"]', $s);
$s = preg_replace ( '/\[img:(.*?)\](.*?)\[\/img:(.*?)\]/si', '[img]\\2[/img]', $s );
// color
$s = preg_replace ( '/\[color=(.*?):(.*?)\]/', '[color=\\1]', $s );
$s = preg_replace ( '/\[\/color:(.*?)\]/', '[/color]', $s );
// size
$s = preg_replace ( '/\[size=\d:(.*?)\]/', '[size=1]', $s );
$s = preg_replace ( '/\[size=1[0123]:(.*?)\]/', '[size=2]', $s );
$s = preg_replace ( '/\[size=1[4567]:(.*?)\]/', '[size=3]', $s );
$s = preg_replace ( '/\[size=((1[89])|(2[01])):(.*?)\]/', '[size=4]', $s );
$s = preg_replace ( '/\[size=2[234567]:(.*?)\]/', '[size=5]', $s );
$s = preg_replace ( '/\[size=((2[89])|(3[01])):(.*?)\]/', '[size=6]', $s );
$s = preg_replace ( '/\[size=3[2-9]:(.*?)\]/', '[size=7]', $s );
$s = preg_replace ( '/\[\/size:(.*?)\]/', '[/size]', $s );
// code
// $s = preg_replace('/\[code:(.*?):(.*?)\]/', '[code:\\1]', $s);
// $s = preg_replace('/\[\/code:(.*?):(.*?)\]/', '[/code:\\1]', $s);
// $s = preg_replace('/\[code:(.*?):(.*?)\]/', '[code]', $s);
// $s = preg_replace('/\[\/code:(.*?):(.*?)\]/', '[/code]', $s);
$s = preg_replace ( '/\[code:(.*?)]/', '[code]', $s );
$s = preg_replace ( '/\[\/code:(.*?)]/', '[/code]', $s );
// lists
$s = preg_replace ( '/\[list(:(.*?))?\]/', '[ul]', $s );
$s = preg_replace ( '/\[list=([a1]):(.*?)\]/', '[ol]', $s );
$s = preg_replace ( '/\[\/list:u:(.*?)\]/', '[/ul]', $s );
$s = preg_replace ( '/\[\/list:o:(.*?)\]/', '[/ol]', $s );
$s = preg_replace ( '/\[\*:(.*?)\]/', '[li]', $s );
$s = preg_replace ( '/\[\/\*:(.*?)\]/', '[/li]', $s );
$s = preg_replace ( '/<!-- s(.*?) --><img src=\"{SMILIES_PATH}.*?\/><!-- s.*? -->/', ' \\1 ', $s );
$s = preg_replace ( '/\<!-- e(.*?) -->/', '', $s );
$s = preg_replace ( '/\<!-- w(.*?) -->/', '', $s );
$s = preg_replace ( '/\<!-- m(.*?) -->/', '', $s );
$s = preg_replace ( '/\<a class=\"postlink\" href=\"(.*?)\">(.*?)<\/a>/', '[url=\\1]\\2[/url]', $s );
$s = preg_replace ( '/\<a href=\"(.*?)\">(.*?)<\/a>/', '[url=\\1]\\2[/url]', $s );
$s = preg_replace ( '/\<a href=.*?mailto:.*?>/', '', $s );
$s = preg_replace ( '/\[url:(.*?)]/', '[url]', $s );
$s = preg_replace ( '/\[\/url:(.*?)]/', '[/url]', $s );
$s = preg_replace ( '/\<\/a>/', '', $s );
// $s = preg_replace('/\\\\/', '', $s);
return $s;
}
}