Vermillion Posted September 20, 2008 Share Posted September 20, 2008 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: But when I try to edit it, the dbRecover() function does not transform the quote properly: 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 https://forums.phpfreaks.com/topic/125110-help-me-make-a-quote-bbcode/ Share on other sites More sharing options...
effigy Posted September 22, 2008 Share Posted September 22, 2008 Your patterns are using <div class="quote">, which I do not see. Link to comment https://forums.phpfreaks.com/topic/125110-help-me-make-a-quote-bbcode/#findComment-647703 Share on other sites More sharing options...
Vermillion Posted September 22, 2008 Author Share Posted September 22, 2008 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 https://forums.phpfreaks.com/topic/125110-help-me-make-a-quote-bbcode/#findComment-648205 Share on other sites More sharing options...
DarkWater Posted September 22, 2008 Share Posted September 22, 2008 Use a CSS style on the tag that hold quotes. Link to comment https://forums.phpfreaks.com/topic/125110-help-me-make-a-quote-bbcode/#findComment-648235 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.