func printTag1(tag, src, dest) if(tag) println('$tx = preg_replace(' + replace(src, '¦', tag) + ', ' + dest + ', $tx);') end end func printTag2(tag, src, dest) if(tag) println('$tx = str_replace(' + replace(src, '¦', tag) + ', ' + dest + ', $tx);') end end func doBbCodeCreate(_data) fvar(old) old = block.select(BLK_HEAD) println('function ' + code(Name) + '($text) {') block.inclvl() println('$tarray = explode("\r", " ".htmlspecialchars($text));') println('$_text = "";') println('$code = 0;') if(TableTag) println('$table = 0;') println('$inc = 0;') println('$cs = 0;') end println('for($i = 0; $i < count($tarray); $i++) {') println(' $tx = $tarray[$i];') println(' if (strpos($tx,"[' + code(CodeTag) + ']")) {') println(' $code++;') println(' $tx = str_replace("[' + code(CodeTag) + ']", "
", $tx);') println(' }') println(' if ($code > 0) {') println(' $tx = str_replace(" ","  ",$tx);') println(' if (strpos($tx," ") === 1)') println(' $tx = " ".$tx;') println(' $tx .= "
";') println(' }') println(' else {') if(TableTag) println(' if (strpos($tx,"[' + code(TableTag) + '"))') println(' $table++;') println(' if (strpos($tx,"[/' + code(TableTag) + ']"))') println(' $table--;') end printTag1(Bold, "#\[¦\](.*?)\[/¦\]#is", "\\\\1") printTag1(Italic, "#\[¦\](.*?)\[/¦\]#is", "\\\\1") printTag1(Underline, "#\[¦\](.*?)\[/¦\]#is", "\\\\1") printTag2(Line, "[¦]", "
") printTag2(Tab, "[¦]", "  ") printTag2(SimpleList, "[¦]", "") printTag2(NumericList, "[¦]", "
    ") printTag2(NumericList, "[/¦]", "
") printTag2(Item, "[¦]", "
  • ") // $tx = preg_replace("/\[form=(.*?)\]/si", "
    ", $tx); // $tx = preg_replace("#\[itext=(.*?)\](.*?)\[/itext\]#is", "", $tx); // $tx = preg_replace("/\[isubmit=(.*?)\]/si", "", $tx); // $tx = str_replace("[/form]", "
    ", $tx); printTag2(IP, "[¦]", 'getenv("REMOTE_ADDR")') printTag1(Image, "#\[¦\]([a-zA-Z\.\/\-:]+)\[/¦\]#is", "") printTag1(QuoteTag, "/\[¦=(.*?)\]/si", "
    \\\\1 " + TitleText + "") printTag2(QuoteTag, "[¦]", "
    ") printTag2(QuoteTag, "[/¦]", "
    ") printTag1(Anchor, "/\[¦=(.*?)\]/si", " ") printTag1(GoTo, "#\[¦=(.*?)\](.*?)\[/¦\]#is", "\\\\2") // ("#\[img=(.*?) align=(.*?)\](.*?)\[/img\]#is", "
    \\1
    ", $tx); printTag1(Color, "#\[¦=(.*?)\](.*?)\[/¦\]#is", "\\\\2") printTag1(Size, "#\[¦=(.*?)\](.*?)\[/¦\]#is", "\\\\2") // $tx = preg_replace("/\=== (.*?) ===/si", "
    \\1
    ", $tx); //$tx = preg_replace("/\== (.*?) ==/si", "
    \\1
    ", $tx); // $tx = preg_replace("/\== (.*?) ==/si", "
    \\1
    ", $tx); // $tx = preg_replace("/>> (.*?) <\\1", $tx); if(TableTag) printTag2(TableTag, "[¦]", "") printTag1(TableTag, "#\[¦=(.*?)\]#is", "
    ") printTag2(TableTag, "[/¦]", "
    ") println(' if ($table > 0) {') println(' if (strpos($tx,"||") !== false) {') println(' $tx = "".$tx."";') println(' $old = strlen($tx);') println(' $tx = str_replace(' + Header + ', "", $tx);') println(' $cs = (strlen($tx) - $old)/(16 - 2) + 1;') println(' $inc++;') println(' }') println(' else if (strpos($tx,' + Row + ') !== false) {') println(' $tx = "".$tx."";') println(' $old = strlen($tx);') println(' $tx = str_replace(' + Row + ', "", $tx);') println(' $cs = (strlen($tx) - $old)/(9 - 1) + 1;') println(' $inc++;') println(' }') println(' else if ($cs) {') println(' $tx = "".$tx."";') println(' $inc++;') println(' }') println(' }') println(' else $cs = 0;') end printTag1(Url, "#\[¦\]([\w]+?://[^ \\\"\\n\\r\\t<]*?)\[/¦\]#is","\\\\1") printTag1(Url, "#\[¦\]((www|ftp)\.[^ \\\"\\n\\r\\t<]*?)\[/¦\]#is","\\\\1") printTag1(Url, "#\[¦=((www|ftp)\.[^ \\\"\\n\\r\\t<]*?)\](.*?)\[/¦\]#is","\\\\3") // printTag1("#\[burl=((www|ftp)\.[^ \"\n\r\t<]*?)\](.*?)\[/burl\]#is","\\3", $tx); printTag1(Tag, "#\[¦=(.*?)\]#is", "[\\\\1]") if(TableName) println('$r = mysql_query("SELECT * FROM ' + code(TableName) + '");') println('for($j = 0; $j < mysql_num_rows($r); $j++) {') println(' $tx = str_replace(mysql_result($r,$j,' + CodeField + '),"",$tx);') println('}') end if(TableTag) println('if ($table <= 0)') println(' $tx .= "
    ";') end println('}') println('if (strpos($tx,"[/' + code(CodeTag) + ']")) {') println(' $code--;') printTag2(CodeTag, "[/¦]", "
  • ") println('}') println('$_text .= $tx;') println('}') println('return $_text;') block.declvl() println('}') block.select(old) event(onBbCodeCreate, _data_) end