[Release]Cype Advanced BBCode Parser And Custom BBCode

Page 1 of 2 12 LastLast
Results 1 to 25 of 42
  1. #1
    Account Upgraded | Title Enabled! xSilv3rbullet is offline
    MemberRank
    Apr 2009 Join Date
    1,226Posts

    [Release]Cype Advanced BBCode Parser And Custom BBCode

    FAQ:
    What does this do?
    This uses preg_replace instead of str_replace, giving the parser case-insensitivity, and more powerful replaces, with exact traces, unlike str_replace.
    It also allows custom bbcode throught the DB.
    ==================================================
    This is just the SQL Database Part and Cype BBCode Parser Remake- no website UI.

    Go to MySQL, and make a new table called cype_bbcode.

    In it, put the following table structure

    ===========================
    id--INTEGER--Auto Increment
    pattern--TEXT
    replacement--TEXT
    ===========================

    Now, go to sources>parser>bbcode.php

    replace the entire file with:
    PHP Code:
    <?php 
    /*
        Copyright (C) 2009  Murad <Murawd>
                            Josh L. <Josho192837>

    BBCode Parser Modified By silv3rbullet

        This program is free software: you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version.

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.

        You should have received a copy of the GNU General Public License
        along with this program.  If not, see <http://www.gnu.org/licenses/>.
    */

    $c preg_replace('|\[b\](.+?)\[\/b\]|i''<b>$1</b>'$c);
    $c preg_replace('|\[i\](.+?)\[\/i\]|i''<i>$1</i>'$c);
    $c preg_replace('|\[u\](.+?)\[\/u\]|i''<u>$1</u>'$c);
    $c preg_replace('|\[*\](.+?)\[\/*\]|i''<li>$1</li>'$c);
    $c preg_replace('|\[url="(.+?)"\](.+?)\[\/url\]|i''<a href="$1" target="_blank">$2</a>'$c);
    $c preg_replace('|\[center\](.+?)\[\/center\]|i''<center>$1</center>'$c);
    /*
    $c = str_replace(array("[right]", "[/right]"), array("<span align=\"right\">", "</span>"), $c);
    $c = str_replace(array("[left]", "[/left]"), array("<span align=\"left\">", "</span>"), $c);
    */
    $c preg_replace('|\[img\](.+?)\[\/img\]|i''<img src="$1" border="0" alt="">'$c);
    $c preg_replace('|\[font="(.+?)"](.+?)\[\/font\]|i''<font face="$1">$2</font>'$c);
    $c str_replace(":)""<img src=\"sources/parser/smileys/smile.gif\"/>" $c);
    $c str_replace("=)""<img src=\"sources/parser/smileys/smile.gif\"/>" $c);
    $c str_replace("=P""<img src=\"sources/parser/smileys/tounge.gif\"/>" $c);
    $c str_replace(":P""<img src=\"sources/parser/smileys/tounge.gif\"/>" $c);
    $c str_replace(":lol:""<img src=\"sources/parser/smileys/lol.gif\"/>"$c);
    $c str_replace(":haha:""<img src=\"sources/parser/smileys/lol.gif\"/>"$c);
    $c str_replace(":laugh:""<img src=\"sources/parser/smileys/lol.gif\"/>"$c);
    $c str_replace(">=(""<img src=\"sources/parser/smileys/mad.gif\"/>"$c);
    $c str_replace(":mad:""<img src=\"sources/parser/smileys/mad.gif\"/>"$c);
    $c str_replace(">:(""<img src=\"sources/parser/smileys/mad.gif\"/>"$c);
    $c str_replace(":O""<img src=\"sources/parser/smileys/ohmy.gif\"/>"$c);
    $c str_replace("=O""<img src=\"sources/parser/smileys/ohmy.gif\"/>"$c);
    $c str_replace(":(""<img src=\"sources/parser/smileys/sad.gif\"/>"$c);
    $c str_replace("=(""<img src=\"sources/parser/smileys/sad.gif\"/>"$c);
    $c str_replace(";)""<img src=\"sources/parser/smileys/wink.gif\"/>"$c);
    $c str_replace(";D""<img src=\"sources/parser/smileys/wink.gif\"/>"$c);
    $c str_replace(";P""<img src=\"sources/parser/smileys/wink.gif\"/>"$c);
    $c str_replace("=/""<img src=\"sources/parser/smileys/bored.gif\"/>"$c);
    $c str_replace(":bored:""<img src=\"sources/parser/smileys/bored.gif\"/>"$c);
    $c str_replace(":D""<img src=\"sources/parser/smileys/happy.gif\"/>"$c);
    $c str_replace("=D""<img src=\"sources/parser/smileys/happy.gif\"/>"$c);

    $script "SELECT * FROM `cype_bbcode`";
    $query mysql_query($script) or die(mysql_error());

    while(
    $fetch mysql_fetch_array($query))
    {
    $c preg_replace(''.$fetch['pattern'].'|i'$fetch['replacement'], $c);
    }
    ?>
    BBCode Pack 1: http://forum.ragezone.com/f427/relea...ht=bbcode+pack
    Last edited by xSilv3rbullet; 30-09-09 at 03:09 AM.


  2. #2
    Account Upgraded | Title Enabled! ZeroSix is offline
    MemberRank
    Jul 2008 Join Date
    519Posts

    Re: [Release]Cype Advanced BBCode

    Nice job. cant wait for the rest

  3. #3
    Account Upgraded | Title Enabled! xSilv3rbullet is offline
    MemberRank
    Apr 2009 Join Date
    1,226Posts

    Re: [Release]Cype Advanced BBCode

    Quote Originally Posted by xdanl View Post
    Nice job. cant wait for the rest
    Thanks (subliminally tries to tell you to thank me :P)

  4. #4
    Account Upgraded | Title Enabled! ZeroSix is offline
    MemberRank
    Jul 2008 Join Date
    519Posts

    Re: [Release]Cype Advanced BBCode

    Quote Originally Posted by xSilv3rbullet View Post
    Thanks (subliminally tries to tell you to thank me :P)
    ~will do~ *Press thank button* [?]

  5. #5
    Account Upgraded | Title Enabled! xSilv3rbullet is offline
    MemberRank
    Apr 2009 Join Date
    1,226Posts

    Re: [Release]Cype Advanced BBCode

    Quote Originally Posted by xdanl View Post
    ~will do~ *Press thank button* [?]
    OMG, how did you know I wanted that?
    :P

  6. #6
    Account Upgraded | Title Enabled! ZeroSix is offline
    MemberRank
    Jul 2008 Join Date
    519Posts

    Re: [Release]Cype Advanced BBCode

    Quote Originally Posted by xSilv3rbullet View Post
    OMG, how did you know I wanted that?
    :P
    IDK! i was like hmm he recoded cype in some other way he deserves a press on the [?]

  7. #7
    :) Horizon is offline
    MemberRank
    Jan 2009 Join Date
    Illinois, U.S.Location
    2,381Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    This really isn't that advanced at all.

  8. #8
    Account Upgraded | Title Enabled! xSilv3rbullet is offline
    MemberRank
    Apr 2009 Join Date
    1,226Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    It's more advanced than the current parser.

  9. #9
    Infraction Baɴɴed holthelper is offline
    MemberRank
    Apr 2008 Join Date
    1,765Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    Quote Originally Posted by xSilv3rbullet View Post
    It's more advanced than the current parser.
    is it more advanced because you used preg_replace instead of str_replace?

  10. #10
    Mother effin' clouds SaintsIan is offline
    MemberRank
    Apr 2008 Join Date
    fyrechat.netLocation
    2,809Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    Wow thats fucking tedious.

  11. #11
    Infraction Baɴɴed holthelper is offline
    MemberRank
    Apr 2008 Join Date
    1,765Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    lol i just noticed the mysql code at the end...

    people will need knowledge on how the code works and other ways to make the bbcode work. just because i put in [quote ][/quote] its not automatically make it work. theres a format that people will need to understand to make it work fully.

    i just barely figured out how to make spoilers work fully in bbcode. if you want a taste here:
    PHP Code:
    $text preg_replace("/\[spoiler\](.+?)\[\/spoiler\]/is","".$this->spoiler("\\1").""$text); 
    im not going to release the other part but you can get the general idea.

    ps to you copy-pasters, dont bother adding this unless you have at least a way to convert it to make it work. i say this because theres more that goes into code.

    EDIT:
    forgot to mention that i can also change the name of the spoiler button name to give it abit of a "classy" feeling or have it use both classy and non classy spoiler. (not saying that i can only do it because i know people that can do way more then i can)
    Last edited by holthelper; 05-09-09 at 04:39 AM.

  12. #12
    Account Upgraded | Title Enabled! xSilv3rbullet is offline
    MemberRank
    Apr 2009 Join Date
    1,226Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    Quote Originally Posted by holthelper View Post
    is it more advanced because you used preg_replace instead of str_replace?
    Why, yes!
    :)
    preg_replace better fits str_replace or str_ireplace because it's faster, it's REGEX, it's perl, and you can pin point text, unlike with str_replace

    Example:

    str_replace(array("[bob=", "]), array("hi", "bob"));
    str_replace(array("[joe=", "]), array("lol", "joe"));

    Now, even if you use [joe="hi"], it will output lol hi bob, cuz "bob" replaces any instances of "]".



    Also, custom bbcode is added.

  13. #13
    Infraction Baɴɴed holthelper is offline
    MemberRank
    Apr 2008 Join Date
    1,765Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    this seems to be your custom code
    PHP Code:
    $script "SELECT * FROM `cype_bbcode`";
    $query mysql_query($script) or die(mysql_error());

    while(
    $fetch mysql_fetch_array($query))
    {
    $c preg_replace(''.$fetch['pattern'].'|i'$fetch['replacement'], $c);
    }
    ?> 
    i rather have it in a file then in a db. since your going for speed anyways, people will tell you that retrieving from a db is slower then pulling data from a file.

    why make it more complex then it is already?

  14. #14
    Account Upgraded | Title Enabled! xSilv3rbullet is offline
    MemberRank
    Apr 2009 Join Date
    1,226Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    Many people would rather put bbcode in a database, rather than in a file.

    It's less complicated, and easier to use.
    However, it DOES take longer, and cost more memory.

    But you could just use a mysql_free_result()

  15. #15
    Infraction Baɴɴed holthelper is offline
    MemberRank
    Apr 2008 Join Date
    1,765Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    you have a script that will add the bbcode into the db or does the user have to insert it them selfs?

    plz do a thread search of my username and look for my discussion thread then ask. this is basically the same as my thread which i was referring to in my earlier post

  16. #16
    Account Upgraded | Title Enabled! xSilv3rbullet is offline
    MemberRank
    Apr 2009 Join Date
    1,226Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    Quote Originally Posted by holthelper View Post
    you have a script that will add the bbcode into the db or does the user have to insert it them selfs?

    plz do a thread search of my username and look for my discussion thread then ask. this is basically the same as my thread which i was referring to in my earlier post
    By that you mean the CSS and MySQL thread?
    Again, you can use mysql_free_result().

    I just have a bad habit of not using it.

    Example:
    PHP Code:
    #Query#
    $script "SELECT * FROM `table`";
    #Execute#
    $execute mysql_query($script) or die(mysql_error());
    #Fetch Array#
    $array mysql_fetch_array($execute);

    #Free MySQL Memory#
    mysql_free_result($execute);

    echo 
    $array['message']; 
    By using mysql_free_result($query), you immediately free the memory.
    Quote Originally Posted by holthelper View Post
    you have a script that will add the bbcode into the db or does the user have to insert it them selfs?
    ==================================================
    This is just the SQL Database Part and Cype BBCode Parser Remake- no website UI.
    It would be easy though, make a form, and query some stuff

    Example
    PHP Code:
    $pattern mysql_real_escape_string(stripslashes($_POST['pattern']));
    $replace mysql_real_escape_string(stripslashes($_POST['replace']));

    $query mysql_query("INSERT INTO `cype_bbcode` (`pattern`, `replacement`) VALUES ('".$patter."', '".$replace."'") or die("An error occurred: ".mysql_error());

    echo 
    "Succesfully added bbcode!"
    Last edited by xSilv3rbullet; 05-09-09 at 08:05 AM.

  17. #17
    Infraction Baɴɴed holthelper is offline
    MemberRank
    Apr 2008 Join Date
    1,765Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    ok now i see how you set it up.

    this would be considered as anti copy-paste and using the noggin that has formed rust.

    edit:
    quick take out the ex. keep the thread the way it was. i like what you did, just didnt realize it until after a small conversation on this thread LOL
    Last edited by holthelper; 05-09-09 at 08:07 AM.

  18. #18
    The Omega Superfun is offline
    MemberRank
    Dec 2006 Join Date
    The NetherlandsLocation
    5,223Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    mysql_free_result(); isnt needed if you only got a bit of a good computer/dedi/vps

  19. #19
    Infraction Baɴɴed holthelper is offline
    MemberRank
    Apr 2008 Join Date
    1,765Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    i did research and it said:

    mysql_free_result() only needs to be called if you are concerned about how much memory is being used for queries that return large result sets. All associated result memory is automatically freed at the end of the script's execution.

  20. #20
    :) Horizon is offline
    MemberRank
    Jan 2009 Join Date
    Illinois, U.S.Location
    2,381Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    This parser is one of the worst I've ever seen.

  21. #21
    Proficient Member LuckySevenz is offline
    MemberRank
    Feb 2009 Join Date
    In your cockpit...xPLocation
    160Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    Me hacked me bro again. :)

    Quote Originally Posted by holthelper View Post
    ok now i see how you set it up.

    this would be considered as anti copy-paste and using the noggin that has formed rust.

    edit:
    quick take out the ex. keep the thread the way it was. i like what you did, just didnt realize it until after a small conversation on this thread LOL
    what ex?

    Quote Originally Posted by Murawd View Post
    This parser is one of the worst I've ever seen.
    cool story bro.

  22. #22
    Account Upgraded | Title Enabled! Sherry is offline
    MemberRank
    Aug 2009 Join Date
    Your houseLocation
    251Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    Nice custom BBcode.

    nice release.

  23. #23
    Infraction Baɴɴed holthelper is offline
    MemberRank
    Apr 2008 Join Date
    1,765Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    ex = example

    remove the upload example but leave the code lol

  24. #24
    :) Horizon is offline
    MemberRank
    Jan 2009 Join Date
    Illinois, U.S.Location
    2,381Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    By the way, BBCode is supposed to be case-sensitive.

  25. #25
    Alpha Member Anujan is offline
    MemberRank
    May 2008 Join Date
    Ontario, CanadaLocation
    1,633Posts

    Re: [Release]Cype Advanced BBCode Parser And Custom BBCode

    Spoiler:
    No it's not



Page 1 of 2 12 LastLast

Advertisement