Index: includes/message_parser.php =================================================================== --- includes/message_parser.php (revision 9248) +++ includes/message_parser.php (working copy) @@ -110,19 +110,19 @@ // order, so it is important to keep [code] in first position and // [quote] in second position. $this->bbcodes = array( - 'code' => array('bbcode_id' => 8, 'regexp' => array('#\[code(?:=([a-z]+))?\](.+\[/code\])#ise' => "\$this->bbcode_code('\$1', '\$2')")), - 'quote' => array('bbcode_id' => 0, 'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\]#ise' => "\$this->bbcode_quote('\$0')")), - 'attachment' => array('bbcode_id' => 12, 'regexp' => array('#\[attachment=([0-9]+)\](.*?)\[/attachment\]#ise' => "\$this->bbcode_attachment('\$1', '\$2')")), - 'b' => array('bbcode_id' => 1, 'regexp' => array('#\[b\](.*?)\[/b\]#ise' => "\$this->bbcode_strong('\$1')")), - 'i' => array('bbcode_id' => 2, 'regexp' => array('#\[i\](.*?)\[/i\]#ise' => "\$this->bbcode_italic('\$1')")), - 'url' => array('bbcode_id' => 3, 'regexp' => array('#\[url(=(.*))?\](.*)\[/url\]#iUe' => "\$this->validate_url('\$2', '\$3')")), - 'img' => array('bbcode_id' => 4, 'regexp' => array('#\[img\](.*)\[/img\]#iUe' => "\$this->bbcode_img('\$1')")), - 'size' => array('bbcode_id' => 5, 'regexp' => array('#\[size=([\-\+]?\d+)\](.*?)\[/size\]#ise' => "\$this->bbcode_size('\$1', '\$2')")), - 'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9a-f]{6}|[a-z\-]+)\](.*?)\[/color\]!ise' => "\$this->bbcode_color('\$1', '\$2')")), - 'u' => array('bbcode_id' => 7, 'regexp' => array('#\[u\](.*?)\[/u\]#ise' => "\$this->bbcode_underline('\$1')")), - 'list' => array('bbcode_id' => 9, 'regexp' => array('#\[list(?:=(?:[a-z0-9]|disc|circle|square))?].*\[/list]#ise' => "\$this->bbcode_parse_list('\$0')")), - 'email' => array('bbcode_id' => 10, 'regexp' => array('#\[email=?(.*?)?\](.*?)\[/email\]#ise' => "\$this->validate_email('\$1', '\$2')")), - 'flash' => array('bbcode_id' => 11, 'regexp' => array('#\[flash=([0-9]+),([0-9]+)\](.*?)\[/flash\]#ie' => "\$this->bbcode_flash('\$1', '\$2', '\$3')")) + 'code' => array('bbcode_id' => BBCODE_CODE_ID, 'regexp' => array('#\[code(?:=([a-z]+))?\](.+\[/code\])#ise' => "\$this->bbcode_code('\$1', '\$2')")), + 'quote' => array('bbcode_id' => BBCODE_QUOTE_ID, 'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\]#ise' => "\$this->bbcode_quote('\$0')")), + 'attachment' => array('bbcode_id' => BBCODE_ATTACH_ID, 'regexp' => array('#\[attachment=([0-9]+)\](.*?)\[/attachment\]#ise' => "\$this->bbcode_attachment('\$1', '\$2')")), + 'b' => array('bbcode_id' => BBCODE_B_ID, 'regexp' => array('#\[b\](.*?)\[/b\]#ise' => "\$this->bbcode_strong('\$1')")), + 'i' => array('bbcode_id' => BBCODE_I_ID, 'regexp' => array('#\[i\](.*?)\[/i\]#ise' => "\$this->bbcode_italic('\$1')")), + 'url' => array('bbcode_id' => BBCODE_URL_ID, 'regexp' => array('#\[url(=(.*))?\](.*)\[/url\]#iUe' => "\$this->validate_url('\$2', '\$3')")), + 'img' => array('bbcode_id' => BBCODE_IMG_ID, 'regexp' => array('#\[img\](.*)\[/img\]#iUe' => "\$this->bbcode_img('\$1')")), + 'size' => array('bbcode_id' => BBCODE_SIZE_ID, 'regexp' => array('#\[size=([\-\+]?\d+)\](.*?)\[/size\]#ise' => "\$this->bbcode_size('\$1', '\$2')")), + 'color' => array('bbcode_id' => BBCODE_COLOR_ID, 'regexp' => array('!\[color=(#[0-9a-f]{6}|[a-z\-]+)\](.*?)\[/color\]!ise' => "\$this->bbcode_color('\$1', '\$2')")), + 'u' => array('bbcode_id' => BBCODE_U_ID, 'regexp' => array('#\[u\](.*?)\[/u\]#ise' => "\$this->bbcode_underline('\$1')")), + 'list' => array('bbcode_id' => BBCODE_LIST_ID, 'regexp' => array('#\[list(?:=(?:[a-z0-9]|disc|circle|square))?].*\[/list]#ise' => "\$this->bbcode_parse_list('\$0')")), + 'email' => array('bbcode_id' => BBCODE_EMAIL_ID, 'regexp' => array('#\[email=?(.*?)?\](.*?)\[/email\]#ise' => "\$this->validate_email('\$1', '\$2')")), + 'flash' => array('bbcode_id' => BBCODE_FLASH_ID, 'regexp' => array('#\[flash=([0-9]+),([0-9]+)\](.*?)\[/flash\]#ie' => "\$this->bbcode_flash('\$1', '\$2', '\$3')")), ); // Zero the parsed items array Index: includes/constants.php =================================================================== --- includes/constants.php (revision 9248) +++ includes/constants.php (working copy) @@ -160,6 +160,21 @@ // Number of core BBCodes define('NUM_CORE_BBCODES', 12); +// BBCode IDs +define('BBCODE_QUOTE_ID', 0); +define('BBCODE_B_ID', 1); +define('BBCODE_I_ID', 2); +define('BBCODE_URL_ID', 3); +define('BBCODE_IMG_ID', 4); +define('BBCODE_SIZE_ID', 5); +define('BBCODE_COLOR_ID', 6); +define('BBCODE_U_ID', 7); +define('BBCODE_CODE_ID', 8); +define('BBCODE_LIST_ID', 9); +define('BBCODE_EMAIL_ID', 10); +define('BBCODE_FLASH_ID', 11); +define('BBCODE_ATTACH_ID', 12); + // Magic url types define('MAGIC_URL_EMAIL', 1); define('MAGIC_URL_FULL', 2); Index: includes/bbcode.php =================================================================== --- includes/bbcode.php (revision 9248) +++ includes/bbcode.php (working copy) @@ -197,7 +197,7 @@ { switch ($bbcode_id) { - case 0: + case BBCODE_QUOTE_ID: $this->bbcode_cache[$bbcode_id] = array( 'str' => array( '[/quote:$uid]' => $this->bbcode_tpl('quote_close', $bbcode_id) @@ -208,7 +208,7 @@ ); break; - case 1: + case BBCODE_B_ID: $this->bbcode_cache[$bbcode_id] = array( 'str' => array( '[b:$uid]' => $this->bbcode_tpl('b_open', $bbcode_id), @@ -217,7 +217,7 @@ ); break; - case 2: + case BBCODE_I_ID: $this->bbcode_cache[$bbcode_id] = array( 'str' => array( '[i:$uid]' => $this->bbcode_tpl('i_open', $bbcode_id), @@ -226,7 +226,7 @@ ); break; - case 3: + case BBCODE_URL_ID: $this->bbcode_cache[$bbcode_id] = array( 'preg' => array( '#\[url:$uid\]((.*?))\[/url:$uid\]#s' => $this->bbcode_tpl('url', $bbcode_id), @@ -235,7 +235,7 @@ ); break; - case 4: + case BBCODE_IMG_ID: if ($user->optionget('viewimg')) { $this->bbcode_cache[$bbcode_id] = array( @@ -254,7 +254,7 @@ } break; - case 5: + case BBCODE_SIZE_ID: $this->bbcode_cache[$bbcode_id] = array( 'preg' => array( '#\[size=([\-\+]?\d+):$uid\](.*?)\[/size:$uid\]#s' => $this->bbcode_tpl('size', $bbcode_id), @@ -262,7 +262,7 @@ ); break; - case 6: + case BBCODE_COLOR_ID: $this->bbcode_cache[$bbcode_id] = array( 'preg' => array( '!\[color=(#[0-9a-f]{6}|[a-z\-]+):$uid\](.*?)\[/color:$uid\]!is' => $this->bbcode_tpl('color', $bbcode_id), @@ -270,7 +270,7 @@ ); break; - case 7: + case BBCODE_U_ID: $this->bbcode_cache[$bbcode_id] = array( 'str' => array( '[u:$uid]' => $this->bbcode_tpl('u_open', $bbcode_id), @@ -279,7 +279,7 @@ ); break; - case 8: + case BBCODE_CODE_ID: $this->bbcode_cache[$bbcode_id] = array( 'preg' => array( '#\[code(?:=([a-z]+))?:$uid\](.*?)\[/code:$uid\]#ise' => "\$this->bbcode_second_pass_code('\$1', '\$2')", @@ -287,7 +287,7 @@ ); break; - case 9: + case BBCODE_LIST_ID: $this->bbcode_cache[$bbcode_id] = array( 'preg' => array( '#(\[\/?(list|\*):[mou]?:?$uid\])[\n]{1}#' => "\$1", @@ -305,7 +305,7 @@ ); break; - case 10: + case BBCODE_EMAIL_ID: $this->bbcode_cache[$bbcode_id] = array( 'preg' => array( '#\[email:$uid\]((.*?))\[/email:$uid\]#is' => $this->bbcode_tpl('email', $bbcode_id), @@ -314,7 +314,7 @@ ); break; - case 11: + case BBCODE_FLASH_ID: if ($user->optionget('viewflash')) { $this->bbcode_cache[$bbcode_id] = array( @@ -333,7 +333,7 @@ } break; - case 12: + case BBCODE_ATTACH_ID: $this->bbcode_cache[$bbcode_id] = array( 'str' => array( '[/attachment:$uid]' => $this->bbcode_tpl('inline_attachment_close', $bbcode_id)