]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
Updates for new style of unrealircd-json-rpc:
authorBram Matthys <redacted>
Fri, 6 Jan 2023 19:25:49 +0000 (20:25 +0100)
committerBram Matthys <redacted>
Fri, 6 Jan 2023 19:25:49 +0000 (20:25 +0100)
* gets rid of unnecessary ->list in getAll()
* now returns FALSE for failed RPC calls, and then you can use
  $rpc->error and $rpc->errno, as done in the delete calls now.

Classes/class-rpc.php
composer.lock
index.php

index a9a2492de92082b8f51b4082402dc95744f8fc67..a952d0974a773f5493621b5e1b3b3d5120342ccd 100644 (file)
@@ -37,7 +37,7 @@ function rpc_pop_lists()
        $ret = $rpc->user()->getAll();
        // TODO: error checking
 
-       foreach($ret->list as $r)
+       foreach($ret as $r)
        {
                RPC_List::$user[] = $r;
                if (strpos($r->user->modes,"o") !== false && strpos($r->user->modes,"S") == false)
@@ -48,7 +48,7 @@ function rpc_pop_lists()
 
        /* Get the channels list */
        $ret = $rpc->channel()->getAll();
-       foreach($ret->list as $r)
+       foreach($ret as $r)
        {
                RPC_List::$channel[] = $r;
                if ($r->num_users > RPC_List::$channel_pop_count)
@@ -60,12 +60,12 @@ function rpc_pop_lists()
 
        /* Get the tkl list */
        $ret = $rpc->serverban()->getAll();
-       foreach($ret->list as $r)
+       foreach($ret as $r)
                RPC_List::$tkl[] = $r;
 
        /* Get the spamfilter list */
        $ret = $rpc->spamfilter()->getAll();
-       foreach($ret->list as $r)
+       foreach($ret as $r)
                RPC_List::$spamfilter[] = $r;
 
 }
index 8d47ce6728b67c8e7315fd6fc6ad86ef77cacdbb..8b720f8ac5de3443e0f8b11cc3371f0eaa1e5195 100644 (file)
             "source": {
                 "type": "git",
                 "url": "https://github.com/unrealircd/unrealircd-rpc-php.git",
-                "reference": "b0cc6f5911eb37ef5cc87a5d621185783009fad7"
+                "reference": "93f8a3ee8d1ab65e34e8f551d0018db8961955f8"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/unrealircd/unrealircd-rpc-php/zipball/b0cc6f5911eb37ef5cc87a5d621185783009fad7",
-                "reference": "b0cc6f5911eb37ef5cc87a5d621185783009fad7",
+                "url": "https://api.github.com/repos/unrealircd/unrealircd-rpc-php/zipball/93f8a3ee8d1ab65e34e8f551d0018db8961955f8",
+                "reference": "93f8a3ee8d1ab65e34e8f551d0018db8961955f8",
                 "shasum": ""
             },
             "require": {
                 "issues": "https://github.com/unrealircd/unrealircd-rpc-php/issues",
                 "source": "https://github.com/unrealircd/unrealircd-rpc-php/tree/main"
             },
-            "time": "2023-01-06T18:47:33+00:00"
+            "time": "2023-01-06T19:24:54+00:00"
         }
     ],
     "packages-dev": [],
index 39f177f200cb7d716d0f26a653326cf474644f0a..5706cc4aec5e409aae73f6683a2d4887c71f07e9 100644 (file)
--- a/index.php
+++ b/index.php
@@ -78,10 +78,12 @@ if (!empty($_POST)) {
                foreach ($_POST as $key => $value) {
                        foreach ($value as $tok) {
                                $tok = explode(",", $tok);
-                               $a = base64_decode($tok[0]);
-                               $b = base64_decode($tok[1]);
-                               if ($rpc->serverban()->delete($a, $b))
-                                       Message::Success(base64_decode($tok[1])." has been removed for ".base64_decode($tok[0]));
+                               $ban = base64_decode($tok[0]);
+                               $type = base64_decode($tok[1]);
+                               if ($rpc->serverban()->delete($ban, $type))
+                                       Message::Success("$type has been removed for $ban");
+                               else
+                                       Message::Fail("Unable to remove $type on $ban: $rpc->error");
                        }
                }
 
@@ -89,7 +91,14 @@ if (!empty($_POST)) {
                foreach ($_POST as $key => $value) {
                        foreach ($value as $tok) {
                                $tok = explode(",", $tok);
-                               rpc_sf_del(base64_decode($tok[0]), base64_decode($tok[1]), base64_decode($tok[2]), base64_decode($tok[3]));
+                               $name = base64_decode($tok[0]);
+                               $match_type = base64_decode($tok[1]);
+                               $spamfilter_targets = base64_decode($tok[2]);
+                               $ban_action = base64_decode($tok[3]);
+                               if ($rpc->spamfilter()->delete($name, $match_type, $spamfilter_targets, $ban_action))
+                                       Message::Success("Spamfilter on $name has been removed");
+                               else
+                                       Message::Fail("Unable to remove spamfilter on $name: $rpc->error");
                        }
                }
 }