bbcodes['b'] = '{CONTENT}'; $this->bbcodes['i'] = '{CONTENT}'; $this->bbcodes['u'] = '{CONTENT}'; $this->bbcodes['url'] = '{CONTENT}'; $this->bbcodes2['url'] = '{CONTENT}'; $this->bbcodes['img'] = ''; $this->bbcodes2['img'] = '{PARAM}'; $this->bbcodes['big'] = '{CONTENT}'; $this->bbcodes['small'] = '{CONTENT}'; $this->bbcodes['ul'] = ''; $this->bbcodes['ol'] = '
    {CONTENT}
'; $this->bbcodes['li'] = '
  • {CONTENT}
  • '; $this->bbcodes['code'] = '{CONTENT}'; $this->bbcodes['pre'] = '

    {CONTENT}
    '; $this->bbcodes2['blog'] = '{CONTENT}'; $this->bbcodes['ins'] = '{CONTENT}'; $this->bbcodes['del'] = '{CONTENT}'; $this->bbcodes['bquote'] = '

    {CONTENT}
    Anonymous
    '; $this->bbcodes2['bquote'] = '

    {CONTENT}
    {PARAM}
    '; $this->bbcodes2['abbr'] = '{CONTENT}'; $this->bbcodes['hidden'] = '{CONTENT}'; $this->bbcodes['thumb'] = ''; $this->init = true; } function parseBBCode($text) { if (!$this->init) { $this->init(); } $to_parse = str_replace("\n",'[br]',htmlentities($text)); foreach ($this->bbcodes as $name => $value) { while (strpos($to_parse, '[' . $name . ']') !== FALSE) { $bbcode_uid = unique_id(); $bbpos = strpos($to_parse, '[' . $name . ']'); $to_parse = substr_replace($to_parse, '[' . $name . ':' . $bbcode_uid . ']', $bbpos, strlen($name) + 2); $to_parse = substr_replace($to_parse, '[/' . $name . ':' . $bbcode_uid . ']', strpos(substr($to_parse, $bbpos), '[/' . $name . ']') + $bbpos, strlen($name) + 3); $value = str_replace('{CONTENT}', '\1', $value); $to_parse = preg_replace('/\[' . $name . ':' . $bbcode_uid . '\](.*)\[\/' . $name . ':' . $bbcode_uid . '\]/', $value, $to_parse); } } foreach ($this->bbcodes2 as $name => $value) { while (strpos($to_parse, '[' . $name . '=') !== FALSE) { $bbcode_uid = unique_id(); $bbpos = strpos($to_parse, '[' . $name . '='); $to_parse = substr_replace($to_parse, '[' . $name . ':' . $bbcode_uid . '=', $bbpos, strlen($name) + 2); $to_parse = substr_replace($to_parse, '[/' . $name . ':' . $bbcode_uid . ']', strpos(substr($to_parse, $bbpos), '[/' . $name . ']') + $bbpos, strlen($name) + 3); $value = str_replace('{PARAM}', '\1', $value); $value = str_replace('{CONTENT}', '\2', $value); $to_parse = preg_replace('/\[' . $name . ':' . $bbcode_uid . '=([^\]]*)\](.*)\[\/' . $name . ':' . $bbcode_uid . '\]/', $value, $to_parse); } } return str_replace('[br]','
    ',$to_parse); } } function parseBBCode($text) { global $bbcode; if (!isset($bbcode)) { $bbcode = new BBCode(); } return $bbcode->parseBBCode($text); } ?>