Skip to:
Content

bbPress.org

Changeset 4703


Ignore:
Timestamp:
01/22/2013 05:09:51 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Updates to phpBB converter:

  • Cleaned whitespace and updated inline docs and phpdoc for consistency accross all import tools.
  • Fixed '_bbp_forum_parent_id'
  • Added Forum topic count -> '_bbp_topic_count'
  • Added Forum reply count -> '_bbp_reply_count'
  • Added Forum total topic count -> '_bbp_total_topic_count'
  • Added Forum status -> '_bbp_status'
  • Fixed Forum dates -> to_type = 'forum' and to_fieldname = 'post_date'
  • Fixed Forum dates -> to_type = 'forum' and to_fieldname = 'post_date_gmt',
  • Fixed Forum dates -> to_type = 'forum' and to_fieldname = 'post_modified'
  • Fixed Forum dates -> to_type = 'forum' and to_fieldname = 'post_modified_gmt'
  • Added Topic reply count -> '_bbp_reply_count',
  • Added Topic total reply count -> '_bbp_total_reply_count'
  • Added Topic date -> '_bbp_last_active_time'
  • Added Topic author ip -> '_bbp_author_ip'
  • Added phpbb user ICQ -> '_bbp_phpbb_user_icq'
  • Added phpbb user MSNM -> '_bbp_phpbb_user_msnm'
  • Added phpbb user Jabber -> 'jabber'
  • Added phpbb user Occupation -> '_bbp_phpbb_user_occ'
  • Added phpbb user Interests -> '_bbp_phpbb_user_interests'
  • Added phpbb user Signature -> _bbp_phpbb_user_sig','
  • Added phpbb user Location -> '_bbp_phpbb_user_from'
  • Added phpbb user avatar filename -> '_bbp_phpbb_user_avatar'
  • Added function callback_topic_reply_count
  • Added function callback_html (Strips custom phpBB 'magic_url' and 'bbcode_uid' first from $field before parsing $field to parser.php)
  • Added bbPress @mentions to converted phpBB [quote] BBCodes
  • Props netweb.
  • Fixes #1884.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/admin/converters/phpBB.php

    r4627 r4703  
    22
    33/**
    4  * Implementation of phpBB converter.
     4 * Implementation of phpBB v3 Converter.
     5 *
     6 * @since bbPress (r4689)
    57 */
    68class phpBB extends BBP_Converter_Base {
     9
     10    /**
     11     * Main Constructor
     12     *
     13     * @uses phpBB::setup_globals()
     14     */
    715    function __construct() {
    816        parent::__construct();
     
    1018    }
    1119
     20    /**
     21     * Sets up the field mappings
     22     */
     23
    1224    public function setup_globals() {
    1325
    1426        /** Forum Section ******************************************************/
    1527
    16         // Forum id. Stored in postmeta.
     28        // Forum id (Stored in postmeta)
    1729        $this->field_map[] = array(
    1830            'from_tablename' => 'forums',
     
    2133            'to_fieldname'   => '_bbp_forum_id'
    2234        );
    23        
    24         // Forum parent id.  If no parent, than 0. Stored in postmeta.
     35
     36        // Forum parent id (If no parent, than 0, Stored in postmeta)
    2537        $this->field_map[] = array(
    2638            'from_tablename' => 'forums',
    2739            'from_fieldname' => 'parent_id',
    2840            'to_type'        => 'forum',
    29             'to_fieldname'   => '_bbp_parent_id'
    30         );
    31        
     41            'to_fieldname'   => '_bbp_forum_parent_id'
     42        );
     43
     44        // Forum topic count (Stored in postmeta)
     45        $this->field_map[] = array(
     46            'from_tablename' => 'forums',
     47            'from_fieldname' => 'forum_topics',
     48            'to_type'        => 'forum',
     49            'to_fieldname'   => '_bbp_topic_count'
     50        );
     51
     52        // Forum reply count (Stored in postmeta)
     53        $this->field_map[] = array(
     54            'from_tablename' => 'forums',
     55            'from_fieldname' => 'forum_posts',
     56            'to_type'        => 'forum',
     57            'to_fieldname'   => '_bbp_reply_count'
     58        );
     59
     60        // Forum total topic count (Includes unpublished topics, Stored in postmeta)
     61        $this->field_map[] = array(
     62            'from_tablename' => 'forums',
     63            'from_fieldname' => 'forum_topics_real',
     64            'to_type'        => 'forum',
     65            'to_fieldname'   => '_bbp_total_topic_count'
     66        );
     67
    3268        // Forum title.
    3369        $this->field_map[] = array(
     
    3773            'to_fieldname'   => 'post_title'
    3874        );
    39        
    40         // Forum slug. Clean name.
     75
     76        // Forum slug (Clean name to avoid conflicts)
    4177        $this->field_map[] = array(
    4278            'from_tablename'  => 'forums',
     
    4682            'callback_method' => 'callback_slug'
    4783        );
    48        
     84
    4985        // Forum description.
    5086        $this->field_map[] = array(
     
    5591            'callback_method' => 'callback_null'
    5692        );
    57        
    58         // Forum display order.  Starts from 1.
     93
     94        // Forum display order (Starts from 1)
    5995        $this->field_map[] = array(
    6096            'from_tablename' => 'forums',
     
    6399            'to_fieldname'   => 'menu_order'
    64100        );
    65        
    66         // Forum date update.
    67         $this->field_map[] = array(
    68             'to_type'      => 'forums',
    69             'to_fieldname' => 'forum_last_post_time',
     101
     102        // Forum status (Locked =1 Unlocked =0, Stored in postmeta)
     103        $this->field_map[] = array(
     104            'from_tablename' => 'forums',
     105            'from_fieldname' => 'forum_status',
     106            'to_type'        => 'forum',
     107            'to_fieldname'   => '_bbp_status'
     108        );
     109
     110        // Forum dates.
     111        $this->field_map[] = array(
     112            'to_type'      => 'forum',
     113            'to_fieldname' => 'post_date',
    70114            'default'      => date('Y-m-d H:i:s')
    71115        );
    72116        $this->field_map[] = array(
    73             'to_type'      => 'forums',
    74             'to_fieldname' => 'forum_last_post_time',
     117            'to_type'      => 'forum',
     118            'to_fieldname' => 'post_date_gmt',
    75119            'default'      => date('Y-m-d H:i:s')
    76120        );
    77121        $this->field_map[] = array(
    78             'to_type'      => 'forums',
    79             'to_fieldname' => 'forum_last_post_time',
     122            'to_type'      => 'forum',
     123            'to_fieldname' => 'post_modified',
    80124            'default'      => date('Y-m-d H:i:s')
    81125        );
    82126        $this->field_map[] = array(
    83             'to_type'      => 'forums',
    84             'to_fieldname' => 'forum_last_post_time',
     127            'to_type'      => 'forum',
     128            'to_fieldname' => 'post_modified_gmt',
    85129            'default'      => date('Y-m-d H:i:s')
    86130        );
     
    88132        /** Topic Section ******************************************************/
    89133
    90         // Topic id. Stored in postmeta.
     134        // Topic id (Stored in postmeta)
    91135        $this->field_map[] = array(
    92136            'from_tablename' => 'topics',
     
    95139            'to_fieldname'   => '_bbp_topic_id'
    96140        );
    97        
    98         // Forum id. Stored in postmeta.
     141
     142        // Topic reply count (Stored in postmeta)
     143        $this->field_map[] = array(
     144            'from_tablename'  => 'topics',
     145            'from_fieldname'  => 'topic_replies',
     146            'to_type'         => 'topic',
     147            'to_fieldname'    => '_bbp_reply_count',
     148            'callback_method' => 'callback_topic_reply_count'
     149        );
     150
     151        // Topic total reply count (Includes unpublished replies, Stored in postmeta)
     152        $this->field_map[] = array(
     153            'from_tablename'  => 'topics',
     154            'from_fieldname'  => 'topic_replies_real',
     155            'to_type'         => 'topic',
     156            'to_fieldname'    => '_bbp_total_reply_count',
     157            'callback_method' => 'callback_topic_reply_count'
     158        );
     159
     160        // Topic forum id (Stored in postmeta)
    99161        $this->field_map[] = array(
    100162            'from_tablename'  => 'topics',
     
    104166            'callback_method' => 'callback_forumid'
    105167        );
    106                
     168
    107169        // Topic author.
    108170        $this->field_map[] = array(
     
    115177
    116178        // Topic content.
     179        // Note: We join the posts table because topics do not have content.
    117180        $this->field_map[] = array(
    118181            'from_tablename'  => 'posts',
     
    124187            'to_fieldname'    => 'post_content',
    125188            'callback_method' => 'callback_html'
    126         ); 
     189        );
    127190
    128191        // Topic title.
     
    133196            'to_fieldname'   => 'post_title'
    134197        );
    135        
    136         // Topic slug. Clean name.
     198
     199        // Topic slug (Clean name to avoid conflicts)
    137200        $this->field_map[] = array(
    138201            'from_tablename'  => 'topics',
     
    142205            'callback_method' => 'callback_slug'
    143206        );
    144        
    145         // Forum id.  If no parent, than 0.
     207
     208        // Topic forum id (If no parent, than 0)
    146209        $this->field_map[] = array(
    147210            'from_tablename'  => 'topics',
     
    181244            'callback_method' => 'callback_datetime'
    182245        );
     246        $this->field_map[] = array(
     247            'from_tablename' => 'topics',
     248            'from_fieldname' => 'topic_last_post_time',
     249            'to_type'        => 'topic',
     250            'to_fieldname'   => '_bbp_last_active_time',
     251            'callback_method' => 'callback_datetime'
     252        );
    183253
    184254        // Topic status (Open or Closed)
     
    190260            'callback_method' => 'callback_topic_status'
    191261        );
     262
     263        // Topic Author ip (Stored in postmeta)
     264        $this->field_map[] = array(
     265            'from_tablename'  => 'posts',
     266            'from_fieldname'  => 'poster_ip',
     267            'join_tablename'  => 'topics',
     268            'join_type'       => 'INNER',
     269            'join_expression' => 'USING (topic_id) WHERE posts.post_id = topics.topic_first_post_id',
     270            'to_type'         => 'topic',
     271            'to_fieldname'    => '_bbp_author_ip'
     272        );
     273
     274        // Sticky Status
    192275
    193276        /** Tags Section ******************************************************/
     
    201284            'callback_method' => 'callback_topicid'
    202285        );
    203        
     286
    204287        // Tags text.
    205288        $this->field_map[] = array(
     
    211294            'to_type'         => 'tags',
    212295            'to_fieldname'    => 'name'
    213         );     
     296        );
    214297        */
    215        
    216         /** Post Section ******************************************************/
    217 
    218         // Post id. Stored in postmeta.
     298
     299        /** Reply Section *****************************************************/
     300
     301        // Post id (Stored in postmeta)
    219302        $this->field_map[] = array(
    220303            'from_tablename' => 'posts',
     
    223306            'to_fieldname'   => '_bbp_post_id'
    224307        );
    225        
     308
    226309        // Topic content.
    227310        $this->field_map[] = array(
     
    232315            'join_expression' => 'USING (topic_id) WHERE posts.post_id != topics.topic_first_post_id',
    233316            'to_type'         => 'reply'
    234         ); 
    235        
    236         // Forum id. Stored in postmeta.
     317        );
     318
     319        // Forum id (Stored in postmeta)
    237320        $this->field_map[] = array(
    238321            'from_tablename'  => 'posts',
     
    242325            'callback_method' => 'callback_topicid_to_forumid'
    243326        );
    244        
    245         // Topic id. Stored in postmeta.
     327
     328        // Topic id (Stored in postmeta)
    246329        $this->field_map[] = array(
    247330            'from_tablename'  => 'posts',
     
    251334            'callback_method' => 'callback_topicid'
    252335        );
    253        
    254         // Author ip. Stored in postmeta.
     336
     337        // Reply author ip (Stored in postmeta)
    255338        $this->field_map[] = array(
    256339            'from_tablename' => 'posts',
     
    258341            'to_type'        => 'reply',
    259342            'to_fieldname'   => '_bbp_author_ip'
    260         ); 
    261            
    262         // Post author.
     343        );
     344
     345        // Reply author.
    263346        $this->field_map[] = array(
    264347            'from_tablename'  => 'posts',
     
    268351            'callback_method' => 'callback_userid'
    269352        );
    270        
    271         // Topic title.
     353
     354        // Topic title (for reply title).
    272355        $this->field_map[] = array(
    273356            'from_tablename' => 'posts',
     
    276359            'to_fieldname'   => 'post_title'
    277360        );
    278        
    279         // Topic slug. Clean name.
     361
     362        // Reply slug (Clean name to avoid conflicts)
    280363        $this->field_map[] = array(
    281364            'from_tablename'  => 'posts',
     
    285368            'callback_method' => 'callback_slug'
    286369        );
    287        
     370
    288371        // Post content.
    289372        $this->field_map[] = array(
     
    294377            'callback_method' => 'callback_html'
    295378        );
    296        
    297         // Topic id.  If no parent, than 0.
     379
     380        // Parent topic id (If no parent, than 0)
    298381        $this->field_map[] = array(
    299382            'from_tablename'  => 'posts',
     
    304387        );
    305388
    306         // Topic date update.
     389        // Reply dates.
    307390        $this->field_map[] = array(
    308391            'from_tablename'  => 'posts',
     
    336419        /** User Section ******************************************************/
    337420
    338         // Store old User id. Stored in usermeta.
     421        // Store old User id (Stored in usermeta)
    339422        $this->field_map[] = array(
    340423            'from_tablename' => 'users',
     
    343426            'to_fieldname'   => '_bbp_user_id'
    344427        );
    345        
    346         // Store old User password. Stored in usermeta serialized with salt.
     428
     429        // Store old User password (Stored in usermeta serialized with salt)
    347430        $this->field_map[] = array(
    348431            'from_tablename'  => 'users',
     
    353436        );
    354437
    355         // Store old User Salt. This is only used for the SELECT row info for the above password save
     438        // Store old User Salt (This is only used for the SELECT row info for the above password save)
    356439        $this->field_map[] = array(
    357440            'from_tablename' => 'users',
     
    360443            'to_fieldname'   => ''
    361444        );
    362                
    363         // User password verify class. Stored in usermeta for verifying password.
     445
     446        // User password verify class (Stored in usermeta for verifying password)
    364447        $this->field_map[] = array(
    365448            'to_type'      => 'user',
     
    367450            'default'      => 'phpBB'
    368451        );
    369                
     452
    370453        // User name.
    371454        $this->field_map[] = array(
     
    375458            'to_fieldname'   => 'user_login'
    376459        );
    377                
     460
    378461        // User email.
    379462        $this->field_map[] = array(
     
    383466            'to_fieldname'   => 'user_email'
    384467        );
    385        
     468
    386469        // User homepage.
    387470        $this->field_map[] = array(
     
    391474            'to_fieldname'   => 'user_url'
    392475        );
    393        
     476
    394477        // User registered.
    395478        $this->field_map[] = array(
     
    400483            'callback_method' => 'callback_datetime'
    401484        );
    402        
    403         // User aim.
     485
     486        // User AIM (Stored in usermeta)
    404487        $this->field_map[] = array(
    405488            'from_tablename' => 'users',
     
    408491            'to_fieldname'   => 'aim'
    409492        );
    410        
    411         // User yahoo.
     493
     494        // User Yahoo (Stored in usermeta)
    412495        $this->field_map[] = array(
    413496            'from_tablename' => 'users',
     
    415498            'to_type'        => 'user',
    416499            'to_fieldname'   => 'yim'
    417         ); 
     500        );
     501
     502        // Store ICQ (Stored in usermeta)
     503        $this->field_map[] = array(
     504            'from_tablename' => 'users',
     505            'from_fieldname' => 'user_icq',
     506            'to_type'        => 'user',
     507            'to_fieldname'   => '_bbp_phpbb_user_icq'
     508        );
     509
     510        // Store MSN (Stored in usermeta)
     511        $this->field_map[] = array(
     512            'from_tablename' => 'users',
     513            'from_fieldname' => 'user_msnm',
     514            'to_type'        => 'user',
     515            'to_fieldname'   => '_bbp_phpbb_user_msnm'
     516        );
     517
     518        // Store Jabber
     519        $this->field_map[] = array(
     520            'from_tablename' => 'users',
     521            'from_fieldname' => 'user_jabber',
     522            'to_type'        => 'user',
     523            'to_fieldname'   => 'jabber'
     524        );
     525
     526        // Store Occupation (Stored in usermeta)
     527        $this->field_map[] = array(
     528            'from_tablename' => 'users',
     529            'from_fieldname' => 'user_occ',
     530            'to_type'        => 'user',
     531            'to_fieldname'   => '_bbp_phpbb_user_occ'
     532        );
     533
     534        // Store Interests (Stored in usermeta)
     535        $this->field_map[] = array(
     536            'from_tablename' => 'users',
     537            'from_fieldname' => 'user_interests',
     538            'to_type'        => 'user',
     539            'to_fieldname'   => '_bbp_phpbb_user_interests'
     540        );
     541
     542        // Store Signature (Stored in usermeta)
     543        $this->field_map[] = array(
     544            'from_tablename' => 'users',
     545            'from_fieldname' => 'user_sig',
     546            'to_type'        => 'user',
     547            'to_fieldname'   => '_bbp_phpbb_user_sig',
     548            'callback_method' => 'callback_html'
     549        );
     550
     551        // Store Location (Stored in usermeta)
     552        $this->field_map[] = array(
     553            'from_tablename' => 'users',
     554            'from_fieldname' => 'user_from',
     555            'to_type'        => 'user',
     556            'to_fieldname'   => '_bbp_phpbb_user_from'
     557        );
     558
     559        // Store Avatar Filename (Stored in usermeta)
     560        $this->field_map[] = array(
     561            'from_tablename' => 'users',
     562            'from_fieldname' => 'user_avatar',
     563            'to_type'        => 'user',
     564            'to_fieldname'   => '_bbp_phpbb_user_avatar'
     565        );
     566
     567        // Store old role (Stored in usermeta)
    418568    }
    419569
     
    432582     */
    433583    public function callback_savepass( $field, $row ) {
    434         $pass_array = array('hash' => $field, 'salt' => $row['salt']);
    435         return $pass_array;
    436     }
    437    
     584        return array(
     585            'hash' => $field,
     586            'salt' => $row['salt']
     587        );
     588    }
     589
    438590    /**
    439591     * Check for correct password
     
    442594     * @param string $hash The stored password hash
    443595     *
     596     * @link Original source for password functions http://openwall.com/phpass/
     597     * @link phpass is now included in WP Core http://core.trac.wordpress.org/browser/trunk/wp-includes/class-phpass.php
     598     *
    444599     * @return bool Returns true if the password is correct, false if not.
    445600     */
    446     public function authenticate_pass($password, $serialized_pass) {
     601    public function authenticate_pass( $password, $serialized_pass ) {
    447602        $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
    448         $pass_array = unserialize($serialized_pass);
    449         if (strlen($pass_array['hash']) == 34) {               
    450             return ($this->_hash_crypt_private($password, $pass_array['hash'], $itoa64) === $pass_array['hash']) ? true : false;
     603        $pass_array = unserialize( $serialized_pass );
     604        if ( strlen( $pass_array['hash'] ) == 34 ) {
     605            return ( $this->_hash_crypt_private( $password, $pass_array['hash'], $itoa64 ) === $pass_array['hash'] ) ? true : false;
    451606        }
    452    
    453         return (md5($password) === $pass_array['hash']) ? true : false;
    454     }
    455    
     607
     608        return ( md5( $password ) === $pass_array['hash'] ) ? true : false;
     609    }
     610
    456611    /**
    457612     * The crypt function/replacement
    458613     */
    459     private function _hash_crypt_private($password, $setting, &$itoa64) {
     614    private function _hash_crypt_private( $password, $setting, &$itoa64 ) {
    460615        $output = '*';
    461    
     616
    462617        // Check for correct hash
    463         if (substr($setting, 0, 3) != '$H$') {
     618        if ( substr( $setting, 0, 3 ) != '$H$' ) {
    464619            return $output;
    465620        }
    466    
    467         $count_log2 = strpos($itoa64, $setting[3]);
    468    
    469         if ($count_log2 < 7 || $count_log2 > 30) {
     621
     622        $count_log2 = strpos( $itoa64, $setting[3] );
     623
     624        if ( $count_log2 < 7 || $count_log2 > 30 ) {
    470625            return $output;
    471626        }
    472    
     627
    473628        $count = 1 << $count_log2;
    474         $salt = substr($setting, 4, 8);
    475    
    476         if (strlen($salt) != 8) {
     629        $salt  = substr( $setting, 4, 8 );
     630
     631        if ( strlen( $salt ) != 8 ) {
    477632            return $output;
    478633        }
    479    
     634
    480635        /**
    481636         * We're kind of forced to use MD5 here since it's the only
     
    486641         * quicker to crack (by non-PHP code).
    487642         */
    488         if (floatval(phpversion()) >= 5) {
    489             $hash = md5($salt . $password, true);
     643        if ( floatval( phpversion() ) >= 5 ) {
     644            $hash = md5( $salt . $password, true );
    490645            do
    491646            {
    492                 $hash = md5($hash . $password, true);
     647                $hash = md5( $hash . $password, true );
    493648            }
    494             while (--$count);
     649            while ( --$count );
    495650        } else {
    496             $hash = pack('H*', md5($salt . $password));
     651            $hash = pack( 'H*', md5( $salt . $password ) );
    497652            do {
    498                 $hash = pack('H*', md5($hash . $password));
     653                $hash = pack( 'H*', md5( $hash . $password ) );
    499654            }
    500             while (--$count);
     655            while ( --$count );
    501656        }
    502657
    503658        $output = substr($setting, 0, 12);
    504659        $output .= $this->_hash_encode64($hash, 16, $itoa64);
    505    
     660
    506661        return $output;
    507662    }
    508        
     663
    509664    /**
    510665     * Encode hash
    511666     */
    512     private function _hash_encode64($input, $count, &$itoa64) {
     667    private function _hash_encode64( $input, $count, &$itoa64 ) {
    513668        $output = '';
    514669        $i = 0;
    515    
     670
    516671        do {
    517             $value = ord($input[$i++]);
     672            $value = ord( $input[$i++] );
    518673            $output .= $itoa64[$value & 0x3f];
    519    
     674
    520675            if ($i < $count) {
    521                 $value |= ord($input[$i]) << 8;
     676                $value |= ord( $input[$i] ) << 8;
    522677            }
    523    
    524             $output .= $itoa64[($value >> 6) & 0x3f];
    525    
    526             if ($i++ >= $count) {
     678
     679            $output .= $itoa64[( $value >> 6 ) & 0x3f];
     680
     681            if ( $i++ >= $count ) {
    527682                break;
    528683            }
    529    
    530             if ($i < $count) {
    531                 $value |= ord($input[$i]) << 16;
     684
     685            if ( $i < $count ) {
     686                $value |= ord( $input[$i] ) << 16;
    532687            }
    533    
    534             $output .= $itoa64[($value >> 12) & 0x3f];
    535    
    536             if ($i++ >= $count) {
     688
     689            $output .= $itoa64[( $value >> 12 ) & 0x3f];
     690
     691            if ( $i++ >= $count ) {
    537692                break;
    538693            }
    539    
     694
    540695            $output .= $itoa64[($value >> 18) & 0x3f];
    541         }
    542         while ($i < $count);
    543    
     696        } while ( $i < $count );
     697
    544698        return $output;
    545699    }
     
    548702     * Translate the post status from phpBB numeric's to WordPress's strings.
    549703     *
    550      * @param int $status phpBB 3.x numeric topic status
     704     * @param int $status phpBB v3.x numeric topic status
    551705     * @return string WordPress safe
    552706     */
     
    564718        return $status;
    565719    }
     720
     721    /**
     722     * Verify the topic reply count.
     723     *
     724     * @param int $count phpBB v3.x reply count
     725     * @return string WordPress safe
     726     */
     727    public function callback_topic_reply_count( $count = 1 ) {
     728        $count = absint( (int) $count - 1 );
     729        return $count;
     730    }
     731
     732    /**
     733     * This callback processes any custom parser.php attributes and custom code with preg_replace
     734     */
     735    protected function callback_html( $field ) {
     736
     737        // Strips custom phpBB 'magic_url' and 'bbcode_uid' first from $field before parsing $field to parser.php
     738        $phpbb_uid = $field;
     739        $phpbb_uid = html_entity_decode( $phpbb_uid );
     740
     741        // Replace '[b:XXXXXXX]' with '<strong>'
     742        $phpbb_uid = preg_replace( '/\[b:(.*?)\]/',   '<strong>',  $phpbb_uid );
     743        // Replace '[/b:XXXXXXX]' with '</strong>'
     744        $phpbb_uid = preg_replace( '/\[\/b:(.*?)\]/', '</strong>', $phpbb_uid );
     745
     746        // Replace '[i:XXXXXXX]' with '<em>'
     747        $phpbb_uid = preg_replace( '/\[i:(.*?)\]/',   '<em>',      $phpbb_uid );
     748        // Replace '[/i:XXXXXXX]' with '</em>'
     749        $phpbb_uid = preg_replace( '/\[\/i:(.*?)\]/', '</em>',     $phpbb_uid );
     750
     751        // Replace '[u:XXXXXXX]' with '<u>'
     752        $phpbb_uid = preg_replace( '/\[u:(.*?)\]/',   '<u>',       $phpbb_uid );
     753        // Replace '[/u:XXXXXXX]' with '</u>'
     754        $phpbb_uid = preg_replace( '/\[\/u:(.*?)\]/', '</u>',      $phpbb_uid );
     755
     756        // Replace '[quote:XXXXXXX]' with '<blockquote>'
     757        $phpbb_uid = preg_replace( '/\[quote:(.*?)\]/',          '<blockquote>',                   $phpbb_uid );
     758        // Replace '[quote="$1"]' with '<em>$1 wrote:</em><blockquote>"
     759        $phpbb_uid = preg_replace( '/\[quote="(.*?)":(.*?)\]/', '<em>@$1 wrote:</em><blockquote>', $phpbb_uid );
     760        // Replace '[/quote:XXXXXXX]' with '</blockquote>'
     761        $phpbb_uid = preg_replace( '/\[\/quote:(.*?)\]/',       '</blockquote>',                   $phpbb_uid );
     762
     763        // Replace '[img:XXXXXXX]' with '<img src="'
     764        $phpbb_uid = preg_replace( '/\[img:(.*?)\]/',   '<img src="', $phpbb_uid );
     765        // Replace '[/img:XXXXXXX]' with ' alt="">'
     766        $phpbb_uid = preg_replace( '/\[\/img:(.*?)\]/', '" alt="">',  $phpbb_uid );
     767
     768        // Replace '<!-- s$1 --><img src=\"{SMILIES_PATH}$2 -->' with '$1'
     769        $phpbb_uid = preg_replace( '/<!-- s(.*?) --><img src=\"{SMILIES_PATH}(.*?)-->/', '$1', $phpbb_uid );
     770
     771        // Replace '<!-- m --><a class="postlink" href="$1">$1</a><!-- m -->' with '$1'
     772        $phpbb_uid = preg_replace( '/\<!-- m --\>\<a class="postlink" href="([^\[]+?)"\>([^\[]+?)\<\/a\>\<!-- m --\>/', '$1', $phpbb_uid );
     773
     774        // Replace '[url:XXXXXXX]$1[/url:XXXXXXX]' with '<a href="http://$1">$1</a>'
     775        $phpbb_uid = preg_replace( '/\[url:(?:[^\]]+)\]([^\[]+?)\[\/url:(?:[^\]]+)\]/',       '<a href="http://$1">$1</a>',  $phpbb_uid );
     776        // Replace '[url=http://$1:XXXXXXX]$3[/url:XXXXXXX]' with '<a href="http://$1">$3</a>'
     777        $phpbb_uid = preg_replace( '/\[url\=http\:\/\/(.*?)\:(.*?)\](.*?)\[\/url:(.*?)\]/i',  '<a href="http://$1">$3</a>',  $phpbb_uid );
     778        // Replace '[url=https://$1:XXXXXXX]$3[/url:XXXXXXX]' with '<a href="http://$1">$3</a>'
     779        $phpbb_uid = preg_replace( '/\[url\=https\:\/\/(.*?)\:(.*?)\](.*?)\[\/url:(.*?)\]/i', '<a href="https://$1">$3</a>', $phpbb_uid );
     780
     781        // Replace '[email:XXXXXXX]' with '<a href="mailto:$2">$2</a>'
     782        $phpbb_uid = preg_replace( '/\[email:(.*?)\](.*?)\[\/email:(.*?)\]/', '<a href="mailto:$2">$2</a>', $phpbb_uid );
     783        // Replace '<!-- e -->no.one@domain.adr<!-- e -->' with '$1'
     784        $phpbb_uid = preg_replace( '/\<!-- e --\>(.*?)\<!-- e --\>/', '$1', $phpbb_uid );
     785
     786        // Replace '[code:XXXXXXX]' with '<pre><code>'
     787        $phpbb_uid = preg_replace( '/\[code:(.*?)\]/',   '<pre><code>',   $phpbb_uid );
     788        // Replace '[/code:XXXXXXX]' with '</code></pre>'
     789        $phpbb_uid = preg_replace( '/\[\/code:(.*?)\]/', '</code></pre>', $phpbb_uid );
     790
     791        // Replace '[color=$1:XXXXXXXX]' with '<span style="color:$1">'
     792        $phpbb_uid = preg_replace( '/\[color=(.*?)\:(.*?)\]/', '<span style="color: $1">', $phpbb_uid );
     793        // Replace '[/color:XXXXXXX]' with '</span>'
     794        $phpbb_uid = preg_replace( '/\[\/color:(.*?)\]/',      '</span>',                  $phpbb_uid );
     795
     796        // Replace '[size=$1:XXXXXXXX]' with '<span style="font-size:$1%;">$3</span>'
     797        $phpbb_uid = preg_replace( '/\[size=(.*?):(.*?)\]/', '<span style="font-size:$1%;">', $phpbb_uid );
     798        // Replace '[/size:XXXXXXX]' with ''
     799        $phpbb_uid = preg_replace( '/\[\/size:(.*?)\]/',     '</span>',                       $phpbb_uid );
     800
     801        // Replace '[list:XXXXXXX]' with '<ul>'
     802        $phpbb_uid = preg_replace( '/\[list:(.*?)\]/',     '<ul>',          $phpbb_uid );
     803        // Replace '[list=a:XXXXXXX]' with '<ol type="a">'
     804        $phpbb_uid = preg_replace( '/\[list=a:(.*?)\]/',   '<ol type="a">', $phpbb_uid );
     805        // Replace '[list=1:XXXXXXX]' with '<ol>'
     806        $phpbb_uid = preg_replace( '/\[list=1:(.*?)\]/',   '<ol>',          $phpbb_uid );
     807        // Replace '[*:XXXXXXX]' with '<li>'
     808        $phpbb_uid = preg_replace( '/\[\*:(.*?)\]/',       '<li>',          $phpbb_uid );
     809        // Replace '[/*:m:XXXXXXX]' with '</li>'
     810        $phpbb_uid = preg_replace( '/\[\/\*:m:(.*?)\]/',   '</li>',         $phpbb_uid );
     811        // Replace '[/list:u:XXXXXXX]' with '</ul>'
     812        $phpbb_uid = preg_replace( '/\[\/list:u:(.*?)\]/', '</ul>',         $phpbb_uid );
     813        // Replace '[/list:o:XXXXXXX]' with '</ol>'
     814        $phpbb_uid = preg_replace( '/\[\/list:o:(.*?)\]/', '</ol>',         $phpbb_uid );
     815
     816        // Now that phpBB's 'magic_url' and 'bbcode_uid' have been stripped put the cleaned HTML back in $field
     817        $field = $phpbb_uid;
     818
     819        // Parse out any bbCodes in $field with the BBCode 'parser.php'
     820        require_once( bbpress()->admin->admin_dir . 'parser.php' );
     821        $bbcode = BBCode::getInstance();
     822        $bbcode->enable_smileys = false;
     823        $bbcode->smiley_regex   = false;
     824        return html_entity_decode( $bbcode->Parse( $field ) );
     825    }
    566826}
Note: See TracChangeset for help on using the changeset viewer.