bbcode help.

Started on the old forum in December 2009 · view the original in the archive · old links redirect here

8 replies · 435 views · started 16 years ago · 1 min read

2 participants
icedroplet1987 Senior · 258 posts #1

hi friends, can anybody help me.. make this bbcode to as i want.. here is the code of bbcode which i have right now..

 $text = preg_replace("/\[clr\=(.*?)\](.*?)\[\/clr\]/is","<font color=\"$1\">$2</font>",$text);
  $text = preg_replace("/\[topic\=(.*?)\](.*?)\[\/topic\]/is","<a href=\"index.php?action=viewtpc&tid=$1&sid=$sid\">$2</a>",$text);
  $text = preg_replace("/\[forum\=(.*?)\](.*?)\[\/forum\]/is","<a href=\"index.php?action=viewfrm&tid=$1&sid=$sid\">$2</a>",$text);
  $text = preg_replace("/\[club\=(.*?)\](.*?)\[\/club\]/is","<a href=\"index.php?action=gocl&clid=$1&sid=$sid\">$2</a>",$text);
  $text = preg_replace("/\[blog\=(.*?)\](.*?)\[\/blog\]/is","<a href=\"index.php?action=viewblog&bid=$1&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
icedroplet1987 Senior · 258 posts #2

here is the bbcode function..

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&sid=$sid\">Inbox $unrd</a>",$text);
  $text = preg_replace("/\[updatepro]/is","<a href=\"index.php?action=uset&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&tid=$1&sid=$sid\">$2</a>",$text);
  $text = preg_replace("/\[forum\=(.*?)\](.*?)\[\/forum\]/is","<a href=\"index.php?action=viewfrm&tid=$1&sid=$sid\">$2</a>",$text);
  $text = preg_replace("/\[club\=(.*?)\](.*?)\[\/club\]/is","<a href=\"index.php?action=gocl&clid=$1&sid=$sid\">$2</a>",$text);
  $text = preg_replace("/\[blog\=(.*?)\](.*?)\[\/blog\]/is","<a href=\"index.php?action=viewblog&bid=$1&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 External image (may be gone) .. 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.

riderz Lead · 975 posts #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


Jacques jacques@gw-designs.co.za http://coding.biz.tm Come join and lets make it a place to learn all the noobies how to code


NEVER FORGET TO CLICK THE TANX BUTTON IF U LIKE WHAT IM SHARING OR HELPING WITH

icedroplet1987 Senior · 258 posts #6

i don know axactly.. but it didnt work.. $text = preg_replace("/\img((.?))/is","<img src="$1">",$text); $text = preg_replace("/\clr-(.?)

\((.*?)\)/is","<font color=\"$1\">$2</font>",$text);
  $text = preg_replace("/\topic\((.*?)\((.*?)\)/is","<a href=\"index.php?action=viewtpc&tid=$1&sid=$sid\">$2</a>",$text);
  $text = preg_replace("/\forum\((.*?)\(.*?)\)/is","<a href=\"index.php?action=viewfrm&tid=$1&sid=$sid\">$2</a>",$text);
  $text = preg_replace("/\club\((.*?)\(.*?)\)/is","<a href=\"index.php?action=gocl&clid=$1&sid=$sid\">$2</a>",$text);
  $text = preg_replace("/\blog\((.*?)\(.*?)\)/is","<a href=\"index.php?action=viewblog&bid=$1&sid=$sid\">$2</a>",$text);

.. now don know wat to do..

riderz Lead · 975 posts #7
 $text = preg_replace("/\[b\)(.*?)\(\/b\)/i","<b>\\1</b>", $text);

 $text = preg_replace("/\(blog\=(.*?)\)(.*?)\(\/blog\)/is","<a href=\"index.php?action=viewblog&bid=$1&sid=$sid\">$2</a>",$text);

try like that


Jacques jacques@gw-designs.co.za http://coding.biz.tm Come join and lets make it a place to learn all the noobies how to code


NEVER FORGET TO CLICK THE TANX BUTTON IF U LIKE WHAT IM SHARING OR HELPING WITH

icedroplet1987 Senior · 258 posts #8

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

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close