bbcode help.

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

    bbcode help.

    hi friends, can anybody help me.. make this bbcode to as i want.. here is the code of bbcode which i have right now..
    PHP Code:
     $text preg_replace("/\[clr\=(.*?)\](.*?)\[\/clr\]/is","<font color=\"$1\">$2</font>",$text);
      
    $text preg_replace("/\[topic\=(.*?)\](.*?)\[\/topic\]/is","<a href=\"index.php?action=viewtpc&amp;tid=$1&amp;sid=$sid\">$2</a>",$text);
      
    $text preg_replace("/\[forum\=(.*?)\](.*?)\[\/forum\]/is","<a href=\"index.php?action=viewfrm&amp;tid=$1&amp;sid=$sid\">$2</a>",$text);
      
    $text preg_replace("/\[club\=(.*?)\](.*?)\[\/club\]/is","<a href=\"index.php?action=gocl&amp;clid=$1&amp;sid=$sid\">$2</a>",$text);
      
    $text preg_replace("/\[blog\=(.*?)\](.*?)\[\/blog\]/is","<a href=\"index.php?action=viewblog&amp;bid=$1&amp;sid=$sid\">$2</a>",$text); 
    .. i want them to work as .. clr-red(anytext) for colour , topic-topicid .. for topics, club- clubid .. for clubs, blog- blogid for blogs .. hope any from you 'll surely help me.. thnx

    #2
    here is the bbcode function..
    PHP Code:
    function getbbcode($text$sid="")
    {
            
    $unreadinbox=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM hfjgn_private WHERE unread='1' AND touid='".$uid."'"));
            
    $pmtotl=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM hfjgn_private WHERE touid='".$uid."'"));
            
    $unrd="[".$unreadinbox[0]."l".$pmtotl[0]."]";
            
    $text preg_replace("/\[inbox]/is","<a href=\"121inbox121.php?action=main&amp;sid=$sid\">Inbox $unrd</a>",$text);
      
    $text preg_replace("/\[updatepro]/is","<a href=\"index.php?action=uset&amp;sid=$sid\">Update Profie</a>",$text);
    $text preg_replace("/\[image\=((.*?)(.php|php4|php5|xhtml|html))\]/i","Im trying To Hack"$text);
      
    $text preg_replace("/\[b\](.*?)\[\/b\]/i","<b>\\1</b>"$text);
      
    $text preg_replace("/\[i\](.*?)\[\/i\]/i","<i>\\1</i>"$text);
      
    $text preg_replace("/\[u\](.*?)\[\/u\]/i","<u>\\1</u>"$text);
      
    $text preg_replace("/\[big\](.*?)\[\/big\]/i","<big>\\1</big>"$text);
      
    $text preg_replace("/\[small\](.*?)\[\/small\]/i","<small>\\1</small>"$text);
     
    $text=ereg_replace("http://[A-Za-z0-9./=?-_]+","<a href=\"\\0\">\\0</a>"$text);
    //$text=preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/is","<a href=\"http://$1\">$2</a>",$text);
     
    $text preg_replace("/\[img\=(.*?)\]/is","<img src=\"$1\">",$text);
      
    $text preg_replace("/\[clr\=(.*?)\](.*?)\[\/clr\]/is","<font color=\"$1\">$2</font>",$text);
      
    $text preg_replace("/\[topic\=(.*?)\](.*?)\[\/topic\]/is","<a href=\"index.php?action=viewtpc&amp;tid=$1&amp;sid=$sid\">$2</a>",$text);
      
    $text preg_replace("/\[forum\=(.*?)\](.*?)\[\/forum\]/is","<a href=\"index.php?action=viewfrm&amp;tid=$1&amp;sid=$sid\">$2</a>",$text);
      
    $text preg_replace("/\[club\=(.*?)\](.*?)\[\/club\]/is","<a href=\"index.php?action=gocl&amp;clid=$1&amp;sid=$sid\">$2</a>",$text);
      
    $text preg_replace("/\[blog\=(.*?)\](.*?)\[\/blog\]/is","<a href=\"index.php?action=viewblog&amp;bid=$1&amp;sid=$sid\">$2</a>",$text);
      
    //$text = ereg_replace("http://[A-Za-z0-9./=?-_]+","<a href=\"\\0\">\\0</a>", $text);
      
    if(substr_count($text,"[br/]")<=5){
        
    $text str_replace("[br/]","<br/>",$text);
      }

      return 
    $text;

    .. it all is like [img=htt://xxx.com/xx.gif] [/img] .. i want it like img(http://xxx.com/xx.gif) .. i want to replace all codes with mine desired1 .. which i already told in my topic message.. wat i want for which code.

    Comment


      #3
      anybody reply

      Comment


        #4
        well why dnt u just replace it then with ur own codes try it see what happen if u dnt get right post the code u tried and we will see again

        Comment


          #5
          yes i tried to do so.. wait posting..

          Comment


            #6
            i don know axactly.. but it didnt work.. $text = preg_replace("/\img\((.*?)\)/is","<img src=\"$1\">",$text);
            $text = preg_replace("/\clr\-(.*?)
            PHP Code:
            \((.*?)\)/is","<font color=\"$1\">$2</font>",$text);
              
            $text preg_replace("/\topic\((.*?)\((.*?)\)/is","<a href=\"index.php?action=viewtpc&amp;tid=$1&amp;sid=$sid\">$2</a>",$text);
              
            $text preg_replace("/\forum\((.*?)\(.*?)\)/is","<a href=\"index.php?action=viewfrm&amp;tid=$1&amp;sid=$sid\">$2</a>",$text);
              
            $text preg_replace("/\club\((.*?)\(.*?)\)/is","<a href=\"index.php?action=gocl&amp;clid=$1&amp;sid=$sid\">$2</a>",$text);
              
            $text preg_replace("/\blog\((.*?)\(.*?)\)/is","<a href=\"index.php?action=viewblog&amp;bid=$1&amp;sid=$sid\">$2</a>",$text); 
            .. now don know wat to do..

            Comment


              #7
              Code:
               $text = preg_replace("/\[b\)(.*?)\(\/b\)/i","<b>\\1</b>", $text);
              
               $text = preg_replace("/\(blog\=(.*?)\)(.*?)\(\/blog\)/is","<a href=\"index.php?action=viewblog&amp;bid=$1&amp;sid=$sid\">$2</a>",$text);
              try like that

              Comment


                #8
                yes its fine.. but i don want like (blog=22) name (/blog), instead i want it like blog-blogid ..

                Comment


                  #9
                  img(http://dfdsff.com/gg.gif) like this

                  Comment

                  Working...
                  X