From e872baf7b4a8db0ff7849bdc8fd1bfeb9a9b6a7d Mon Sep 17 00:00:00 2001 From: aftercase <74765798+aftercase@users.noreply.github.com> Date: Sun, 11 Jul 2021 20:49:31 +0100 Subject: [PATCH] Updated sandwich function Function changes tags to links, plus color coded. --- includes/functions.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 974410a..9d2c399 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -63,11 +63,25 @@ function getreports($conn, $count = 10) { return $query->fetchAll(); } - function sandwitch($str){ +function sandwitch($str){ $output = ""; $arr = explode(",", $str); foreach ($arr as $word){ - $output .= ''.trim($word).''; + $word = ucfirst($word); + if (stripos($word, 'nsfw') !== false) { + $word = strtoupper($word); + $tagcolor = "tag is-danger"; + } + elseif (stripos($word, 'SAFE') !== false) { + $word = strtoupper($word); + $tagcolor = "tag is-success"; + } + elseif (strstr($word, '/')){ + $tagcolor = "tag is-primary"; + }else{ + $tagcolor = "tag is-info"; + } + $output .= ''.trim($word).''; } return $output; }