Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 27

Thread: How to prevent BBCodes error from shoutbox

  1. #11
    Senior Member anderson's Avatar
    Join Date
    Jan 2009
    Posts
    146
    Thanks
    1
    Thanked 10 Times in 2 Posts
    Rep Power
    0

    Default

    Quote Originally Posted by something else [Only registered and activated users can see links. Click Here To Register...]
    you only need to apply it 5 times for thoose 5 bb codes if you do it the way i posted it above it also will cover multiple bb codes as posted above

    .... if u were to code it the way you have posted you would end up with so many different combination`s (more than 5)
    Okay. I am applying ur codes but dont know how to process. Should I creat another function like:
    Code:
    function checkbbcode($text)
    {
    $bbcheck=preg_replace("/\[b\](.*?)\[\/b\]/i","b1b2", $text);
    $bbcheck=preg_replace("/\[i\](.*?)\[\/i\]/i","i1i2", $bbcheck);
    $bbcheck=preg_replace("/\[u\](.*?)\[\/u\]/i","u1u2", $bbcheck);
    $bbcheck=preg_replace("/\[big\](.*?)\[\/big\]/i","big1big2", $bbcheck);
    $bbcheck=preg_replace("/\[small\](.*?)\[\/small\]/i","small1small2", $bbcheck);
    $testa = array("b1","i1","u1","big1","small1");
    $checka = substr_count($bbcheck,$testa);
    $testb = array("b2","i2","u2","big2","small2");
    $checkb = substr_count($bbcheck,$testb);
    if($checka!=$checkb){
    $text = "BB Code Error";
    return $text;
    }
    ..............
    ............
    And parse the shout text like:
    Code:
    $text = checkbbcode(getbbcode($text, $sid));
    ?? but how it will work!
    Last edited by anderson; 11-09-09 at 10:55. Reason: more
    Wait...

  2. #12
    Senior Member something else's Avatar
    Join Date
    Feb 2008
    Location
    if($something){echo 'Status code 404'; }else{ echo 'coding-talk.com';}
    Posts
    1,818
    Thanks
    209
    Thanked 447 Times in 202 Posts
    Rep Power
    0

    Default

    Code:
    function checkbbcode($text)
    {
    $bbcheck=preg_replace("/\[b\](.*?)\[\/b\]/i","b1b2", $text);
    $bbcheck=preg_replace("/\[i\](.*?)\[\/i\]/i","i1i2", $bbcheck);
    $bbcheck=preg_replace("/\[u\](.*?)\[\/u\]/i","u1u2", $bbcheck);
    $bbcheck=preg_replace("/\[big\](.*?)\[\/big\]/i","big1big2", $bbcheck);
    $bbcheck=preg_replace("/\[small\](.*?)\[\/small\]/i","small1small2", $bbcheck);
    $testa = array("b1","i1","u1","big1","small1");
    $checka = substr_count($bbcheck,$testa);
    $testb = array("b2","i2","u2","big2","small2");
    $checkb = substr_count($bbcheck,$testb);
    if($checka!=$checkb){
    $text = "BB Code Error";
    }
    $bbcheck=preg_replace("/\[i\](.*?)\[\/i\]/i","i1i2", $text);
    $bbcheck=preg_replace("/\[b\](.*?)\[\/b\]/i","b1b2", $bbcheck);
    $bbcheck=preg_replace("/\[u\](.*?)\[\/u\]/i","u1u2", $bbcheck);
    $bbcheck=preg_replace("/\[big\](.*?)\[\/big\]/i","big1big2", $bbcheck);
    $bbcheck=preg_replace("/\[small\](.*?)\[\/small\]/i","small1small2", $bbcheck);
    $testa = array("b1","i1","u1","big1","small1");
    $checka = substr_count($bbcheck,$testa);
    $testb = array("b2","i2","u2","big2","small2");
    $checkb = substr_count($bbcheck,$testb);
    if($checka!=$checkb){
    $text = "BB Code Error";
    }
    $bbcheck=preg_replace("/\[u\](.*?)\[\/u\]/i","u1u2", $text);
    $bbcheck=preg_replace("/\[i\](.*?)\[\/i\]/i","i1i2", $bbcheck);
    $bbcheck=preg_replace("/\[b\](.*?)\[\/b\]/i","b1b2", $bbcheck);
    $bbcheck=preg_replace("/\[big\](.*?)\[\/big\]/i","big1big2", $bbcheck);
    $bbcheck=preg_replace("/\[small\](.*?)\[\/small\]/i","small1small2", $bbcheck);
    $testa = array("b1","i1","u1","big1","small1");
    $checka = substr_count($bbcheck,$testa);
    $testb = array("b2","i2","u2","big2","small2");
    $checkb = substr_count($bbcheck,$testb);
    if($checka!=$checkb){
    $text = "BB Code Error";
    }
    $bbcheck=preg_replace("/\[big\](.*?)\[\/big\]/i","big1big2", $text);
    $bbcheck=preg_replace("/\[u\](.*?)\[\/u\]/i","u1u2", $bbcheck);
    $bbcheck=preg_replace("/\[i\](.*?)\[\/i\]/i","i1i2", $bbcheck);
    $bbcheck=preg_replace("/\[b\](.*?)\[\/b\]/i","b1b2", $bbcheck);
    $bbcheck=preg_replace("/\[small\](.*?)\[\/small\]/i","small1small2", $bbcheck);
    $testa = array("b1","i1","u1","big1","small1");
    $checka = substr_count($bbcheck,$testa);
    $testb = array("b2","i2","u2","big2","small2");
    $checkb = substr_count($bbcheck,$testb);
    if($checka!=$checkb){
    $text = "BB Code Error";
    }
    $bbcheck=preg_replace("/\[small\](.*?)\[\/small\]/i","small1small2", $text);
    $bbcheck=preg_replace("/\[big\](.*?)\[\/big\]/i","big1big2", $bbcheck);
    $bbcheck=preg_replace("/\[u\](.*?)\[\/u\]/i","u1u2", $bbcheck);
    $bbcheck=preg_replace("/\[i\](.*?)\[\/i\]/i","i1i2", $bbcheck);
    $bbcheck=preg_replace("/\[b\](.*?)\[\/b\]/i","b1b2", $bbcheck);
    $testa = array("b1","i1","u1","big1","small1");
    $checka = substr_count($bbcheck,$testa);
    $testb = array("b2","i2","u2","big2","small2");
    $checkb = substr_count($bbcheck,$testb);
    if($checka!=$checkb){
    $text = "BB Code Error";
    }
    return $text; 
    }
    function parsepm($text,$sid){
    $text=getbbcode($text,$sid):
    $text = checkbbcode($text);
    }
    Last edited by something else; 11-09-09 at 08:24.

    [Only registered and activated users can see links. Click Here To Register...]


  3. #13
    Senior Member something else's Avatar
    Join Date
    Feb 2008
    Location
    if($something){echo 'Status code 404'; }else{ echo 'coding-talk.com';}
    Posts
    1,818
    Thanks
    209
    Thanked 447 Times in 202 Posts
    Rep Power
    0

    Default

    to much to explain lol

    [Only registered and activated users can see links. Click Here To Register...]


  4. #14
    Senior Member anderson's Avatar
    Join Date
    Jan 2009
    Posts
    146
    Thanks
    1
    Thanked 10 Times in 2 Posts
    Rep Power
    0

    Default

    But how it works? because in the function bbcoode is not defined with
    <b > n </b > for [b ] n [/b ].

    I think str_replace is needed that can change bib2 to <b > </b >
    Wait...

  5. #15
    Senior Member something else's Avatar
    Join Date
    Feb 2008
    Location
    if($something){echo 'Status code 404'; }else{ echo 'coding-talk.com';}
    Posts
    1,818
    Thanks
    209
    Thanked 447 Times in 202 Posts
    Rep Power
    0

    Default

    oops yeah sorry it needs to be:

    function parsepm($text,$sid){
    $text = checkbbcode($text);
    $text=getbbcode($text,$sid):
    }

    [Only registered and activated users can see links. Click Here To Register...]


  6. #16
    Senior Member anderson's Avatar
    Join Date
    Jan 2009
    Posts
    146
    Thanks
    1
    Thanked 10 Times in 2 Posts
    Rep Power
    0

    Default

    Quote Originally Posted by something else [Only registered and activated users can see links. Click Here To Register...]
    oops yeah sorry it needs to be:

    function parsepm($text,$sid){
    $text = checkbbcode($text);
    $text=getbbcode($text,$sid):
    }
    Sorry to say, did accordingly but not working. Still error in page!!!
    Wait...

  7. #17
    Senior Member something else's Avatar
    Join Date
    Feb 2008
    Location
    if($something){echo 'Status code 404'; }else{ echo 'coding-talk.com';}
    Posts
    1,818
    Thanks
    209
    Thanked 447 Times in 202 Posts
    Rep Power
    0

    Default

    this should work now:
    PHP Code:
    function checkbbcode($text)
    {
    $bbcheck=preg_replace("/\[b\](.*?)\[\/b\]/i",""$text);
    $testa = array("[b]","[i]","[u]","[big]","[small]");
    $testb = array("[/u][/i][/b][i][u]","[/u][/i][u]","[/u]","[/big]","[/small]");
    $testa str_replace($testa"*bb1*"$bbcheck);
    $testb str_replace($testb"*bb2*"$bbcheck);
    $checka substr_count($testa,"*bb1*");
    $checkb substr_count($testb,"*bb2*");
    if(
    $checka!=$checkb){
    $text "BB Code Error";
    }
    $bbcheck=preg_replace("/\[i\](.*?)\[\/i\]/i",""$text);
    $testa = array("[b]","[i]","[u]","[big]","[small]");
    $testb = array("[/u][/i][/b][i][u]","[/u][/i][u]","[/u]","[/big]","[/small]");
    $testa str_replace($testa"*bb1*"$bbcheck);
    $testb str_replace($testb"*bb2*"$bbcheck);
    $checka substr_count($testa,"*bb1*");
    $checkb substr_count($testb,"*bb2*");
    if(
    $checka!=$checkb){
    $text "BB Code Error";
    }
    $bbcheck=preg_replace("/\[u\](.*?)\[\/u\]/i",""$text);
    $testa = array("[b]","[i]","[u]","[big]","[small]");
    $testb = array("[/u][/i][/b][i][u]","[/u][/i][u]","[/u]","[/big]","[/small]");
    $testa str_replace($testa"*bb1*"$bbcheck);
    $testb str_replace($testb"*bb2*"$bbcheck);
    $checka substr_count($testa,"*bb1*");
    $checkb substr_count($testb,"*bb2*");
    if(
    $checka!=$checkb){
    $text "BB Code Error";
    }
    $bbcheck=preg_replace("/\[big\](.*?)\[\/big\]/i",""$text);
    $testa = array("[b]","[i]","[u]","[big]","[small]");
    $testb = array("[/u][/i][/b][i][u]","[/u][/i][u]","[/u]","[/big]","[/small]");
    $testa str_replace($testa"*bb1*"$bbcheck);
    $testb str_replace($testb"*bb2*"$bbcheck);
    $checka substr_count($testa,"*bb1*");
    $checkb substr_count($testb,"*bb2*");
    if(
    $checka!=$checkb){
    $text "BB Code Error";
    }
    $bbcheck=preg_replace("/\[small\](.*?)\[\/small\]/i",""$text);
    $testa = array("[b]","[i]","[u]","[big]","[small]");
    $testb = array("[/u][/i][/b][i][u]","[/u][/i][u]","[/u]","[/big]","[/small]");
    $testa str_replace($testa"*bb1*"$bbcheck);
    $testb str_replace($testb"*bb2*"$bbcheck);
    $checka substr_count($testa,"*bb1*");
    $checkb substr_count($testb,"*bb2*");
    if(
    $checka!=$checkb){
    $text "BB Code Error";
    }
    return 
    $text


    [Only registered and activated users can see links. Click Here To Register...]


  8. #18
    Senior Member anderson's Avatar
    Join Date
    Jan 2009
    Posts
    146
    Thanks
    1
    Thanked 10 Times in 2 Posts
    Rep Power
    0

    Default

    yes. something else!
    it's working!!! And I cant help thanking you!
    Wait...

  9. #19
    Senior Member anderson's Avatar
    Join Date
    Jan 2009
    Posts
    146
    Thanks
    1
    Thanked 10 Times in 2 Posts
    Rep Power
    0

    Default

    and can I use this code in genproc.php like
    if(!checkbbcode($shtxt)
    { do shout
    }else{
    bbcode error}
    or how?
    Wait...

  10. #20
    Senior Member something else's Avatar
    Join Date
    Feb 2008
    Location
    if($something){echo 'Status code 404'; }else{ echo 'coding-talk.com';}
    Posts
    1,818
    Thanks
    209
    Thanked 447 Times in 202 Posts
    Rep Power
    0

    Default

    just add it in your
    parsepm fuction in core.php
    but make sure it is before :
    $text = getbbcode($text,$sid);
    that way it will cover whole of forum and chat

    [Only registered and activated users can see links. Click Here To Register...]


Page 2 of 3 FirstFirst 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. bbcodes help
    By realcoder in forum Coding Forum
    Replies: 1
    Last Post: 25-05-09, 01:59
  2. Xhtml + Wml Shoutbox Addon Mod
    By subzero in forum Scripts Forum
    Replies: 22
    Last Post: 13-02-09, 13:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19