bbcode url reverse help!

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

    bbcode url reverse help!

    hi in bbcode i did use this to using url
    PHP Code:
    $text preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/is","<a href=\"$1\">$2</a>",$text); 
    but how to reverse it. i mean while editing, how to reverse it like [ url = siteurl] siteurl [ /url]

    #2
    PHP Code:
    $text preg_replace("/<a href=\"(.*?)\">(.*?)<\/a>/is","[url=$1]$2[/url]",$text); 
    but far better off not saving it in database as html

    Comment


      #3
      Originally posted by something else View Post

      but far better off not saving it in database as html
      any problem/exploit can be happen if i use saving as html in database?
      i use htmlspecialchars() while input in database and htmlspecialchars_decode() to show in front end.
      please reply

      Comment


        #4
        na should be fine .... it just means your having to store more than you need in your database

        Comment


          #5
          then what should i do to leverage this? btw, i also can't reverse the img bbcode
          PHP Code:
          [img][/img
          please reverse this.

          Comment


            #6
            pls does any one have johncms 4.4.0 bbcode for titled link, i.e if i post a link 9jamobile.net - File host
            it wil replace it to the site title

            Added after 8 minutes:

            just like what has happend above
            Last edited by bestman; 22.03.12, 13:58.

            Comment


              #7
              Originally posted by asifnayem View Post
              then what should i do to leverage this? btw, i also can't reverse the img bbcode
              PHP Code:
              [img][/img
              please reverse this.
              PHP Code:
              $text preg_replace("/<img src=\"(.*?)\" alt=\"(.*?)\"\/>/is","[img]$1[/img]",$text); 
              You may have to alter it slightly depending on number of space in your <img> tag

              Added after 11 minutes:

              Originally posted by bestman View Post
              pls does any one have johncms 4.4.0 bbcode for titled link, i.e if i post a link 9jamobile.net - File host
              it wil replace it to the site title

              Added after 8 minutes:

              just like what has happend above
              heres with DOM :
              PHP Code:
              function gettitle($url)
              {
                      
              $dom = new DOMDocument();
                      if(
              $dom->loadHTMLFile($url))
                      {

                          
              $list $dom->getElementsByTagName("title");
                          if (
              $list->length 0)
                          {
                              return 
              $list->item(0)->textContent;
                          }
                      }
              }


              $in=array('`((?:https?|ftp)://\S+[[:alnum:]]/?)`si','`((?<!//)(www\.\S+[[:alnum:]]/?))`si');
              $out=array('<a href="$1">'.gettitle($1).'</a>','<a href="http://$1">'.gettitle('http://'.$1).'</a>');
              $text preg_replace($in,$out,$text);

              //ugh some bug with opera doesnt let you see end of php file on this forum so i put this comment in there just so i can see the bottom line 
              otherwise you would have to use curl or get_file_contents()
              Last edited by something else; 22.03.12, 16:08.

              Comment


                #8
                Originally posted by something else View Post
                heres with DOM :
                PHP Code:
                function gettitle($url)
                {
                        
                $dom = new DOMDocument();
                        if(
                $dom->loadHTMLFile($url))
                        {

                            
                $list $dom->getElementsByTagName("title");
                            if (
                $list->length 0)
                            {
                                return 
                $list->item(0)->textContent;
                            }
                        }
                }


                $in=array('`((?:https?|ftp)://\S+[[:alnum:]]/?)`si','`((?<!//)(www\.\S+[[:alnum:]]/?))`si');
                $out=array('<a href="$1">'.gettitle($1).'</a>','<a href="http://$1">'.gettitle('http://'.$1).'</a>');
                $text preg_replace($in,$out,$text);

                //ugh some bug with opera doesnt let you see end of php file on this forum so i put this comment in there just so i can see the bottom line 
                otherwise you would have to use curl or get_file_contents()
                oops wont work with array but you can use the dom function to add to a different auto url bb

                Comment


                  #9
                  Thank let me try it

                  Comment


                    #10
                    Originally posted by something else View Post
                    You may have to alter it slightly depending on number of space in your <img> tag
                    i am using this
                    PHP Code:
                        $text preg_replace("/\[img\](.*?)\[\/img\]/""<img src=\"http://localhost/blog/thumb.php?image=$1&amp;w=150&amp;h=150\" alt='*' class='imf'/>"$text); 
                    its not working then i use

                    PHP Code:
                    $text preg_replace("/<img src=\"(.*?)\" alt=\"(.*?)\" class=\"imf\"\/>/is","[img]$1[/img]",$text); 
                    it shows the whole http://localhost/blog/............

                    Comment


                      #11
                      Hi i found this html code for the live traffic feed. i want this converted to BBcode so that i can put ot on a site that supports only BBcode,. say a site like songs - Listen to free music .. I need help. Can someone help me out with converting this html to BBcode. i tried a few online converters.. but none of them work..

                      this is the code..

                      Code:
                      <script type="text/javascript" src="http://feedjit.com/serve/?vv=693&tf… href="http://feedjit.com/">Feedjit Live Blog Stats</a></noscript>

                      Comment

                      Working...
                      X