'<', '>' => '>', '&' => '&', '"' => '"', "\n" => '
', "\r" => '')); if($input[0] == '[') { strtok(' ' . $input, '['); $out = ''; } else $out = strtok($input, '['); while($part = strtok('[')) { if($tmpok) { if(substr($part, 0, strlen($tmpend)) == $tmpend) { $out .= $tmpok . substr($part, strlen($tmpend)); $tags = $tmptag . $tags; $lists = $tmplist . $lists; $tl = strcspn($tags, ']'); $tmpok = ''; $tmpnok = ''; $tmptag = ''; $tmpend = ''; $tmplist = ''; continue; } else { $out .= '[' . $tmpnok; $tmpok = ''; $tmpnok = ''; $tmptag = ''; $tmpend = ''; $tmplist = ''; } } if(substr($part, 0, 2) == 'b]') { $out .= '' . substr($part, 2); $tags = '[/b]' . $tags; } elseif(substr($part, 0, 2) == 'i]') { $out .= '' . substr($part, 2); $tags = '[/i]' . $tags; } elseif(substr($part, 0, 2) == 'u]') { $out .= '' . substr($part, 2); $tags = '[/u]' . $tags; } elseif(substr($part, 0, 5) == 'size=') { $size = intval(substr($part, 5)); if($size == 9 && $part[6] == ']') { $out .= '' . substr($part, 7); $tags = '[/size]' . $tags; } elseif(($size >= 10 && $size <= 24) && $part[7] == ']') { $out .= '' . substr($part, 8); $tags = '[/size]' . $tags; } else $out .= '[' . $part; } elseif(substr($part, 0, 6) == 'color=') { $l = strspn(substr($part, 6), 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890#(),%'); if($part[$l+6] == ']') { $out .= '' . substr($part, $l+7); $tags = '[/color]' . $tags; } else $out .= '[' . $part; } elseif(substr($part, 0, 5) == 'code]') { $out .= '
Code:
' . substr($part, 5); $tags = '[/code]' . $tags; } elseif(substr($part, 0, 4) == 'url]') { $tmpok = '' . substr($part, 4) . ''; $tmpnok = $part; $tmpend = '/url]'; } elseif(substr($part, 0, 4) == 'url=') { $l = strcspn(substr($part, 4), '[] '); if($part[$l+4] == ']') { $out .= '' . substr($part, $l+5); $tags = '[/url]' . $tags; } else $out .= '[' . $part; } elseif(substr($part, 0, 6) == 'email]') { $tmpok = '' . substr($part, 6) . ''; $tmpnok = $part; $tmpend = '/email]'; } elseif(substr($part, 0, 6) == 'email=') { $l = strcspn(substr($part, 6), '[] '); if($part[$l+6] == ']') { $out .= '' . substr($part, $l+7); $tags = '[/email]' . $tags; } else $out .= '[' . $part; } elseif(substr($part, 0, 4) == 'img]') { $tmpok = ''; $tmpnok = $part; $tmpend = '/img]'; } elseif(substr($part, 0, 5) == 'list]') { $tmpok = substr($part, 5) . '
'; break; case 'list': $out .= ''; $lists = substr($lists, 1); } $out .= substr($part, $tl); } else $out .= '[' . $part; $tl = strcspn($tags, ']'); } if($tmpok) $out .= '[' . $tmpnok; $part = strtok($tags, '['); while($part) { $tags = substr($tags, $tl+1); switch(substr($part, 1, $tl-2)) { case 'b': case 'i': case 'u': case 'size': case 'color': $out .= '
'; break; case 'url': case 'email': $out .= ''; break; case 'code': $out .= ''; break; case 'list': $out .= ''; $lists = substr($lists, 1); } $tl = strcspn($tags, ']'); $part = strtok('['); } return $out; } } $GLOBALS['bbcode'] = new BBCode; ?>