How to prevent BBCodes error from shoutbox

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Originally posted by something else View Post
    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...
    sigpic

    Comment


      #17
      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

      Comment


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

        Comment


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

          Comment


            #20
            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

            Comment


              #21
              hi I am still facing a problem. [b] and [i] code isn't working even when I use it properly. [b]Hellooooooooo[/b ] it is also showing BB Code Error. what to do? @ s. else.
              Wait...
              sigpic

              Comment


                #22
                when [b] and [i] code used in a text shows BB Code Error. actually code is correct. its happening only for this 2 codes.
                Wait...
                sigpic

                Comment


                  #23
                  iv just tested both ways and both are working fine?
                  test file below:
                  test.php
                  PHP Code:
                  <?php
                  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);
                  echo 
                  "1) $bbcheck<br/>";
                  $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*");
                  echo 
                  "3) $checkb<br/>";
                  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
                  }
                  echo 
                  checkbbcode("[b]hello[/b]<br/>");
                  echo 
                  checkbbcode("[b][i]hello[/i][/b]<br/>");
                  ?>

                  Comment


                    #24
                    Problem is solved.
                    Last edited by anderson; 14.09.09, 16:04.
                    Wait...
                    sigpic

                    Comment


                      #25
                      change this line:
                      $testb = array("[/u][/i][/b]","","","[/big]","[/small]");
                      to
                      $testb = array("[/b]","[/i]","[/u]","[/big]","[/small]");

                      coding-talk script messed up coding lol

                      Comment


                        #26
                        First time coding-talk script make me foolish, also make me lol!!
                        Thanks.
                        working now.
                        ===X===
                        Wait...
                        sigpic

                        Comment


                          #27
                          Or ... you can add this in the begining of getbbcode function:D


                          PHP Code:
                          $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 "BBCODE ERROR!!!";
                          return 
                          $text
                          }

                          $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 "BBCODE ERROR!!!";
                          return 
                          $text
                          }


                          $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 "BBCODE ERROR!!!";
                          return 
                          $text
                          }


                          $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 "BBCODE ERROR!!!";
                          return 
                          $text
                          }


                          $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 "BBCODE ERROR!!!";
                          return 
                          $text

                          Last edited by shad0w; 29.12.09, 01:54.
                          whatmp3.name - search mp3 on mobile

                          Comment

                          Working...
                          X