Jump to content

Help Me Make A Quote BBCode.


Vermillion

Recommended Posts

Okay, so I have this BBCode script I made by myself:

 

<?php

################################################################################
#                           SCRIPT: Vg Hack BBCode                             #
#                           SCRIPT NAME: regex.php                             #
#                           AUTHOR: Andrés Ibañez | Vermillion.                #
################################################################################

/***********************************
#    Functions to strip HTML,      #
#    and to transform BBCode to    #
#    HTML.                         #
************************************/

function bbcode($message){

   $message = mysql_real_escape_string(nl2br($message));
   $message = preg_replace("/\[b\](.*?)\[\/b\]/is", "<strong>$1</strong>", $message);
   $message = preg_replace("/\[i\](.*?)\[\/i\]/is", "<span style=\"font-style:italic;\">$1</span>", $message);
   $message = preg_replace("/\[u\](.*?)\[\/u\]/is", "<span style=\"text-decoration:underline;\">$1</span>", $message);
   $message = preg_replace("/\[strike\](.*?)\[\/strike\]/is", "<span style=\"text-decoration:line-through;\">$1</span>", $message);
   $message = preg_replace("/\[link name=(.*?)\](.*?)\[\/link\]/is", "<a href=\"$2\" target=\"_blank\">$1</a>", $message);
   $message = preg_replace("/\[q=(.*?)\](.*?)\[\/q\]/is", "<ul><div class=\"quote\"><span class=\"qt\">quote <strong>$1</strong></span><blockquote>$2</blockquote></div></ul>", $message);
   return $message;

}

/*Function to recover the data from the database*/

function dbRecover($message){
   
   $message = strip_tags($message, "<strong>, <span>, <a>, <ul>, <li>, <blockquote>, <ol>");
   $message = preg_replace("/<strong>(.*?)<\/strong>/is", "[b]$1[/b]", $message);
   $message = preg_replace("/<span style=\"font-style:italic;\">(.*?)<\/span>/is", "[i]$1[/i]", $message);
   $message = preg_replace("/<span style=\"text-decoration:underline;\">(.*?)<\/span>/is", "[u]$1[/u]", $message);
   $message = preg_replace("/<span style=\"text-decoration:line-through;\">(.*?)<\/span>/is", "[strike]$1[/strike]", $message);
   $message = preg_replace("/<a href=\"(.*?)\" target=\"_blank\">(.*?)<\/a>/is", "[link name=$2]$1[/link]", $message);
   $message = preg_replace("/<ul><div class=\"quote\"><span class=\"qt\">quote <strong>(.*?)<\/strong><\/span><blockquote>(.*?)<\/blockquote><\/div><\/ul>/is", "[q=$1]$2[/q]", $message);
   return $message;

}

?>

 

The line before the last one on both custom functions is not working well.

 

The output I want (which works fine) is this:

 

5o1zk.jpg

 

But when I try to edit it, the dbRecover() function does not transform the quote properly:

 

65sjrs.jpg

 

And the wanted result is:

 

[q=Moi]I think your quote is [b]messed[/b] up TBH.[/q]

 

Also, I want the quotes to be indented, so when people quote a quote (lol at that ;P), it will be indented.

Link to comment
Share on other sites

Woops haha. Well, I already changed my method though, because that one was giving me problems, so now I changed of method and I only use preg_replace when outputting the content.

 

I just have another problem though, which I don't know how to solve, and that is, how would I indent quote tags? Or is that only done with the HTML tag?

 

I describe more about it here; http://www.neoseeker.com/forums/45/t1060604-to-how/2.htm#22

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.