From 3837ebaa917685203084de1c7d97b8ab009337a1 Mon Sep 17 00:00:00 2001 From: SiskelDev Date: Tue, 10 Jun 2025 13:38:28 +0200 Subject: [PATCH] Changed Search from SQL Like to RegEx --- data/script/furatalog.lib.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/data/script/furatalog.lib.php b/data/script/furatalog.lib.php index 7ad2f4f..9256f3e 100644 --- a/data/script/furatalog.lib.php +++ b/data/script/furatalog.lib.php @@ -114,12 +114,28 @@ class furatalogLib { $whereRequest .= " AND "; } - $tmpVal = implode('%', str_split($tmpVal)); + //$tmpVal = implode('%', str_split($tmpVal)); + $newtmpVal = ""; - $whereRequest .= "(content.name LIKE '%" . $tmpVal . "%' OR - creator.name LIKE '%" . $tmpVal . "%' + + $maxStringPos = strlen($tmpVal); + $currentStringPos = 1; + foreach (str_split($tmpVal) as $key2 => $value2) { + if ($currentStringPos < $maxStringPos) { + $newtmpVal .= $value2 . "[^" . $value2 . "]{0,2}"; + } else { + $newtmpVal .= $value2; + } + $currentStringPos++; + } + + $tmpVal = $newtmpVal; + + + $whereRequest .= "(content.name REGEXP '%" . $tmpVal . "%' OR + creator.name REGEXP '%" . $tmpVal . "%' " . ($section==1 ? - " OR species.name LIKE '%" . $tmpVal . "%' OR species.tag LIKE '%" . $tmpVal . "%') " : + " OR species.name REGEXP '%" . $tmpVal . "%' OR species.tag REGEXP '%" . $tmpVal . "%') " : ")") . ""; } } else {