]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
display duration better
authorValerie Pond <redacted>
Fri, 6 Jan 2023 01:22:03 +0000 (01:22 +0000)
committerValerie Pond <redacted>
Fri, 6 Jan 2023 01:22:03 +0000 (01:22 +0000)
Classes/class-rpc.php
index.php

index 30d22b41440a44cc69a3bfe62c46aee2a0511f81..7e2b80dd0582f4a98c216a8aa751e0de3940ce65 100644 (file)
@@ -268,4 +268,17 @@ function rpc_sf_del($name, $mtype, $targets, $action) : bool
                Message::Success("Deleted spamfilter entry: ".$r['name']." [type: ".$r['match_type']."] [targets: ".$r['spamfilter_targets']. "] [action: ".$r['ban_action']."] [reason: ".$r['reason']."] [set by: ".$r['set_by']."]");
        }
        return true;
+}
+
+/** Convert the duration_string */
+function rpc_convert_duration_string($str)
+{
+       $tok = explode("w", $str);
+       $weeks = $tok[0];
+       $tok = explode("d", $tok[1]);
+       $days = $tok[0];
+       $tok = explode("h", $tok[1]);
+       $hours = $tok[0];
+       return "$weeks weeks, $days days and $hours hours";
+       
 }
\ No newline at end of file
index 733ce3d3278258cc98192867b0579aa3a122e27c..b70bd38dad8d643267ae55160fcc9d9e33bc1352 100644 (file)
--- a/index.php
+++ b/index.php
@@ -65,7 +65,7 @@ if (!empty($_POST)) {
                                return;
                        }
 
-                       $msg_msg = ($duration == "0" || $duration == "0w0d0h") ? "permanently" : "for $duration";
+                       $msg_msg = ($duration == "0" || $duration == "0w0d0h") ? "permanently" : "for ".rpc_convert_duration_string($duration);
                        $reason = (isset($_POST['ban_reason'])) ? $_POST['ban_reason'] : "No reason";
                        if (rpc_tkl_add($user, $bantype, $duration, $reason))
                        {