From: Valerie Pond Date: Mon, 9 Jan 2023 17:48:03 +0000 (+0000) Subject: Users.php Fix user variable X-Git-Tag: 0.9~540 X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/commitdiff_plain/6ec00ecace4b1b814999e2598d1afb32c1d889cd Users.php Fix user variable --- diff --git a/users.php b/users.php index ff9240c..506687e 100644 --- a/users.php +++ b/users.php @@ -37,7 +37,7 @@ if (!empty($_POST)) } $user = $rpc->user()->get($user); - if (!user) + if (!$user) { Message::Fail("Could not find that user. Maybe they disconnected after you clicked this?"); return; diff --git a/vendor/unrealircd/unrealircd-rpc/lib/NameBan.php b/vendor/unrealircd/unrealircd-rpc/lib/NameBan.php new file mode 100644 index 0000000..4f969b0 --- /dev/null +++ b/vendor/unrealircd/unrealircd-rpc/lib/NameBan.php @@ -0,0 +1,98 @@ +connection = $conn; + } + + /** + * Add a name ban (QLine). + * + * @param string $name + * @param string $reason + * @param string $duration Optional + * @param string $set_by Optional + * @return stdClass|array|bool + * @throws Exception + */ + public function add(string $name, string $reason, string $duration = NULL, $set_by = NULL): stdClass|array|bool + { + $query = [ + 'name' => $name, + 'reason' => $reason, + 'duration_string' => $duration ?? '0', + ]; + + if ($set_by) + $query['set_by'] = $set_by; + + $response = $this->connection->query('name_ban.add', $query); + if (property_exists($response, 'tkl')) + return $response->tkl; + return FALSE; + } + + /** + * Delete a ban. + * + * @param string $name + * @return stdClass|array|bool + * @throws Exception + */ + public function delete(string $name): stdClass|array|bool + { + $response = $this->connection->query('name_ban.del', [ + 'name' => $name, + ]); + if (property_exists($response, 'tkl')) + return $response->tkl; + return FALSE; + } + + /** + * Return a list of all bans. + * + * @return stdClass|array|bool + * @throws Exception + */ + public function getAll(): stdClass|array|bool + { + $response = $this->connection->query('name_ban.list'); + + if (!is_bool($response)) { + return $response->list; + } + + throw new Exception('Invalid JSON Response from UnrealIRCd RPC.'); + } + + /** + * Get a specific ban. + * + * @param string $name + * @return stdClass|array|bool + * @throws Exception + */ + public function get(string $name): stdClass|array|bool + { + $response = $this->connection->query('name_ban.get', [ + 'name' => $name, + ]); + + if (!is_bool($response)) { + return $response->tkl; + } + + throw new Exception('Invalid JSON Response from UnrealIRCd RPC.'); + } +}