From 0c45ffac2d8648fec4fa5e935754f4d34952983b Mon Sep 17 00:00:00 2001
From: Jonas Kohl
Date: Sat, 12 Oct 2024 19:54:01 +0200
Subject: Add rich text support
---
src/index.php | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
(limited to 'src/index.php')
diff --git a/src/index.php b/src/index.php
index 6e1522c..4fe060c 100644
--- a/src/index.php
+++ b/src/index.php
@@ -12,7 +12,7 @@ use mystic\forum\utils\RequestUtils;
header_remove("X-Powered-By");
-const MYSTICBB_VERSION = "0.4.6";
+const MYSTICBB_VERSION = "0.5.0";
if (($_SERVER["HTTP_USER_AGENT"] ?? "") === "") {
http_response_code(403);
@@ -163,6 +163,29 @@ function reArrayFiles(&$file_post) {
return $file_ary;
}
+const TAGS_REGEX = '/\[(b|i|u|s|\\^|_|spoiler)\](.+?)\[\/\1\]/s';
+
+function expandTags(string $contents): string {
+ return preg_replace_callback(TAGS_REGEX, function(array $m) {
+ $randomId = "target-" . bin2hex(random_bytes(8));
+ $inner = $m[2];
+ $tag = [
+ "b" => ["", "" ],
+ "i" => ["", "" ],
+ "s" => ["", "" ],
+ "^" => ["", "" ],
+ "_" => ["", "" ],
+ "spoiler" => [ "