bbcodes

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

    bbcodes

    ok, i figured i'd post a list of bbcodes i put together...
    PHP Code:
    //////////////////////url bbcode safer////////////////////////////////
    $text preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/is","<a href=\"urlredir.php?redir=$1&who=$user\">$2</a>",$text);
    (
    safe links... i'll upload urlredir.php as attachment)
    //////////////////align codes//////////////////////
    $text=preg_replace("/\[left\](.*?)\[\/left\]/i","<p align=\"left\">\\1</p>", $text);

      $text=preg_replace("/\[center\](.*?)\[\/center\]/i","<p align=\"center\">\\1</p>", $text);

      $text=preg_replace("/\[right\](.*?)\[\/right\]/i","<p align=\"right\">\\1</p>", $text);

     $text = preg_replace("/\[div\=(.*?)\](.*?)\[\/div\]/i","<div align=\"$1\">$2</div>",$text);
    /////////////////////////////////quote/code bbcode/////////////////////////////
    $text = preg_replace("/\[code\](.+?)\[\/code\]/is","<div align=\"left\"><BLOCKQUOTE><b>Code:</b><br/><i>\\1<i/></BLOCKQUOTE></div>", $text);

      $text = preg_replace("/\[quote\](.+?)\[\/quote\]/is","<div align=\"left\"><BLOCKQUOTE><b>Quote:<br/></b>\\1</BLOCKQUOTE></div>", $text);
    //////////////////////////////search engine bbcodes/////////////////////////////
    $text = preg_replace("/\[ufym\=(.*?)\](.*?)\[\/ufym\]/is","<a href=\"http://ufym.net/search.asp?q=$1&s=ufym&sbmt=Search\">ufym:$2</a>",$text);

       $text = preg_replace("/\[google\=(.*?)\](.*?)\[\/google\]/is","<a href=\"http://www.google.com/search?q=$1\">Google:$2</a>",$text);

    $text = preg_replace("/\[gimg\=(.*?)\](.*?)\[\/gimg\]/is","<a href=\"http://www.google.com/m/search?sa=2&q=$1&site=images\">G-IMG:$2</a>",$text);

     $text = preg_replace("/\[vuclip\=(.*?)\](.*?)\[\/vuclip\]/is","<a href=\"http://vuclip.com/s?sn=1&z=1002&k=$1&output=video\">VidSearch:$2</a>",$text);

    $text = preg_replace("/\[h2g2\=(.*?)\](.*?)\[\/h2g2\]/i","<a href=\"http://www.bbc.co.uk/dna/h2g2/pda/search?searchtype=article&searchstring=$1&showapproved=1&show=12\">h2g2:$2</a>",$text);

           $text = preg_replace("/\[news\=(.*?)\](.*?)\[\/news\]/i","<a href=\"http://news.google.com/news/search?q=$1\">news:$2</a>",$text);

       $text = preg_replace("/\[define\=(.*?)\](.*?)\[\/define\]/i","<a href=\"http://lookwayup.com/lwu.exe/lwu/d?s=s&w=$1\">define:$2</a>",$text);

      $text = preg_replace("/\[rhyme\=(.*?)\](.*?)\[\/rhyme\]/i","<a href=\"http://www.rhymezone.com/r/rhyme.cgi?Word=$1&typeofrhyme=perfect&org1=syl&org2=l\">rhymez4:$2</a>",$text);
    //////////////////////////////@linking (twitter style)////////////////////////////////
     if(substr_count($text,"@")<=5)
        {
        $text=preg_replace("/\@(.*?)\@/i","<font color=\"lime\"><b>@</b></font><a href=\"index.php?action=viewuser&user=\\1&sid=$sid\">\\1</a><font color=\"lime\"><b>@</b></font> ", $text);
        }
    ///////////////extra code to post inbox when mentoined///////////////////////////
     if(substr_count($text,"@")<=5)
        {
       $text=preg_replace("/\@(.*?)\ /i","@<a href=extraz.php?action=statusbar&user=$1&sid=$sid>$1</a>", $text);
    (modify to view user)
      $number = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM fun_users WHERE name='
    $1'"));
     if ($number[0]>=1)
              {
             $mem = mysql_fetch_array(mysql_query("SELECT id FROM fun_users WHERE name='
    $1'"));
            $msg = "@$user mentioned you in a status update...";
            autopm($msg, $mem[0]);
        }
        } 
    Last edited by metulj; 14.11.10, 22:05. Reason: looks nicer with [ php ] tag [ / php ] :)
    C3 Themes: http://c3themes.wen.ru/index.html
    Find Files: http://mystarter.tk/?goto=X-search

    #2
    oh, i almost, in fact did forget to attach the urlredir.php file, here it is...
    Attached Files
    C3 Themes: http://c3themes.wen.ru/index.html
    Find Files: http://mystarter.tk/?goto=X-search

    Comment


      #3
      Did you know: BBCodes when not well filtered (^) increases the risk of css/xss attacks.

      Comment


        #4
        yeah i guess you got a point, but i know not how such attacks work, so i got no idea how to start thinking about coding prevention...
        C3 Themes: http://c3themes.wen.ru/index.html
        Find Files: http://mystarter.tk/?goto=X-search

        Comment


          #5
          Lol. One of the hardest attacks to prevent. Read online.

          Comment


            #6
            mmm... I wont add this bbcode only for staff members
            if like my post click:

            http://coding-talk.com/images/totall...ost_thanks.gif

            Comment


              #7
              yeah sure, allow align`s to use. after someone uses that, check out page in html validator.
              Nous Ne Dansos Pas, Nous Sommes Le Danse.!

              Comment


                #8
                if you will allow linking in bbcode it will add the risk for xss attack.. you can use str_replace to prevent it.. and replace the string php they are linking php script in their xss to steal sessions..

                http://wapx.amob.com
                Applications, Games, Wallpapers, Ringtones, Videos, Themes, Screensaver and More!!!

                Comment


                  #9
                  XSS can do waay mur than steal sessions. But if ur so caught up with the stealing cookie ****, i cud load a .js page with xss and stil steal ur cookie. Hell i cud load a .py or .ror file and steal ur ****. But if im to carry out an annoying attack on ur site i'd usually just try to piss ur users off by redirecting them to my page.

                  Comment


                    #10
                    then if you can do so, replace those extensions. commonsense..

                    http://wapx.amob.com
                    Applications, Games, Wallpapers, Ringtones, Videos, Themes, Screensaver and More!!!

                    Comment


                      #11
                      yeah... plus you'll notice the linking ie: url=... would log you out when you click the link... so even if someone gets the session, etc... you're logged out already...

                      urlredir.php
                      C3 Themes: http://c3themes.wen.ru/index.html
                      Find Files: http://mystarter.tk/?goto=X-search

                      Comment

                      Working...
                      X