Jump to content

BBCODE still posts html


ambo

Recommended Posts

The for is still postin html tags  ??? Ho can i do a check to remove them or give error

  function bb_encode($Text) {
        
        
        $Text = str_replace("<", "<", $Text);
        $Text = str_replace(">", ">", $Text);
        
        //new lines
        $Text = nl2br($Text);
        
        // [url]
        $URLSearchString = " a-zA-Z0-9:/-?&.=_~#'";
        
        $Text = preg_replace("/[url]([$URLSearchString]*)[/url]/", '<a href="$1" target="_blank">$1</a>', $Text);
        $Text = preg_replace("([url=([$URLSearchString]*)](.+?)[/url])", '<a href="$1" target="_blank">$2</a>', $Text);
        
        // [b]
        $Text = preg_replace("([b](.+?)[/b])is",'<strong>$1</strong>',$Text);
        
        // [i]
        $Text = preg_replace("([i](.+?)[/i])is",'<em>$1</em>',$Text);
        
        // [u]
        $Text = preg_replace("([u](.+?)[/u])is",'<u>$1</u>',$Text);
        
        // [s]
        $Text = preg_replace("([s](.+?)[/s])is",'<del>$1</del>',$Text);
        
        // 
[center]
        $Text = preg_replace("([center](.+?)[/center]
)is",'<div align="center">$1</div>',$Text);
        
        // [color]
        $Text = preg_replace("([color=(.+?)](.+?)[/color])is",'<span style="color: $1">$2</span>',$Text);
        
        // [size]
        $Text = preg_replace("([size=(.+?)](.+?)[/size])is",'<span style="font-size: $1px">$2</span>',$Text);
        
        // [quote]
        $QuoteLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
                            <tr>
                                <td class="codehead"> $1 wrote:</td>
                            </tr>
                            <tr>
                                <td class="quotebody">$2</td>
                            </tr>
                       </table>';
        
        $QuoteLayoutAnon = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
                            <tr>
                                <td class="codehead">Quote:</td>
                            </tr>
                            <tr>
                                <td class="quotebody">$2</td>
                            </tr>
                       </table>';
                       
                 
        $Text = preg_replace("/[quote](.+?)[/quote]/is","$QuoteLayoutAnon", $Text);
        $Text = preg_replace("/[quote=(.+?)](.+?)[/quote]/is","$QuoteLayout", $Text);
        
        // [img]
        $Text = preg_replace("/[img=(.+?)]/", '<img src="$1">', $Text);
            
        // [youtube]
        $youtubeformatting = '<object width="425" height="355"><param name="movie" value="$1"></param><param name="wmode" value="transparent"></param><embed src="$1&hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>';
        $Text = preg_replace("/[youtube](.+?)[/youtube]/", '$youtubeformatting', $Text);
            
        
        return $Text;
    }
    

Link to comment
https://forums.phpfreaks.com/topic/146792-bbcode-still-posts-html/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.