PHP user-defined UBB code
Function ubb ($ Text) {$ Text = trim ($ Text); // $ Text = htmlspecialchars ($ Text ); // http://blog.ddian.cn $ Text = preg_replace ("// \ t/is", "", $ Text); $ Text = preg_replace ("/\ [h1 \] (. + ?) \ [\/H1 \]/is "," \ 1 ", $ Text); $ Text = preg_replace ("/\ [h2 \] (. + ?) \ [\/H2 \]/is "," \ 1 ", $ Text); $ Text = preg_replace ("/\ [h3 \] (. + ?) \ [\/H3 \]/is "," \ 1 ", $ Text); $ Text = preg_replace ("/\ [h4 \] (. + ?) \ [\/H4 \]/is "," \ 1 ", $ Text); $ Text = preg_replace ("/\ [h5 \] (. + ?) \ [\/H5 \]/is "," \ 1 ", $ Text); $ Text = preg_replace ("/\ [h6 \] (. + ?) \ [\/H6 \]/is "," \ 1 ", $ Text); $ Text = preg_replace ("/\ [separator \]/is ","", $ Text); $ Text = preg_replace ("/\ [center \] (. + ?) \ [\/Center \]/is ","
\ 1
", $ Text); $ Text = preg_replace ("/\ [url = http: \/([^ \ [] *) \] (. + ?) \ [\/Url \]/is "," \ 2 ", $ Text); $ Text = preg_replace ("/\ [url = ([^ \ [] *) \] (. + ?) \ [\/Url \]/is "," \ 2 ", $ Text); $ Text = preg_replace ("/\ [url \] http: \/([^ \ [] *) \ [\/url \]/is "," \ 1 ", $ Text ); $ Text = preg_replace ("/\ [url \] ([^ \ [] *) \ [\/url \]/is", "\ 1 ", $ Text); $ Text = preg_replace ("/\ [img \] (. + ?) \ [\/Img \]/is "," ", $ Text); $ Text = preg_replace ("/\ [color = (. + ?) \] (. + ?) \ [\/Color \]/is "," \ 2 ", $ Text); $ Text = preg_replace ("/\ [size = (. + ?) \] (. + ?) \ [\/Size \]/is "," \ 2 ", $ Text); $ Text = preg_replace ("/\ [sup \] (. + ?) \ [\/Sup \]/is "," \ 1 ", $ Text); $ Text = preg_replace ("/\ [sub \] (. + ?) \ [\/Sub \]/is "," \ 1 ", $ Text); $ Text = preg_replace ("/\ [pre \] (. + ?) \ [\/Pre \]/is ","\\1
", $ Text); $ Text = preg_replace ("/\ [email \] (. + ?) \ [\/Email \]/is "," \ 1 ", $ Text); $ Text = preg_replace ("/\ [colorTxt \] (. + ?) \ [\/ColorTxt \]/eis "," color_txt ('\ 1') ", $ Text); $ Text = preg_replace ("/\ [emot \] (. + ?) \ [\/Emot \]/eis "," emot ('\ 1') ", $ Text); $ Text = preg_replace ("/\ [I \] (. + ?) \ [\/I \]/is ","\ 1", $ Text); $ Text = preg_replace ("/\ [u \] (. + ?) \ [\/U \]/is ","\ 1", $ Text); $ Text = preg_replace ("/\ [B \] (. + ?) \ [\/B \]/is ","\ 1", $ Text); $ Text = preg_replace ("/\ [quote \] (. + ?) \ [\/Quote \]/is ","Reference:
\ 1
", $ Text); $ Text = preg_replace ("/\ [code \] (. + ?) \ [\/Code \]/eis "," highlight_code ('\ 1') ", $ Text); $ Text = preg_replace ("/\ [php \] (. + ?) \ [\/Php \]/eis "," highlight_code ('\ 1') ", $ Text); $ Text = preg_replace ("/\ [sig \] (. + ?) \ [\/Sig \]/is ","\ 1
", $ Text); $ Text = preg_replace ("/\ n/is ","
", $ Text); return $ Text ;}