}
}
$topicset = false;
+$del_ex = false;
+$del_inv = false;
+$del_ban = false;
+$checkboxes = [];
if (isset($_POST))
{
if (isset($_POST['update_topic']) && isset($_POST['set_topic']))
{
if (isset($channelObj))
{
- if (isset($channelObj->topic)) // if the set topic is different
- {
- if (strcmp($channelObj->topic,$_POST['set_topic']))
- {
- $user = (function_exists('unreal_get_current_user') && $u = unreal_get_current_user()) ? $u->username : NULL;
- $topicset = $rpc->channel()->set_topic($channelObj->name, $_POST['set_topic'], $user);
- $channelObj->topic = $_POST['set_topic'];
- }
- }
- else
+ if (!isset($channelObj->topic) || strcmp($channelObj->topic,$_POST['set_topic'])) // if the set topic is different
{
$user = (function_exists('unreal_get_current_user') && $u = unreal_get_current_user()) ? $u->username : NULL;
$topicset = $rpc->channel()->set_topic($channelObj->name, $_POST['set_topic'], $user);
}
}
}
+ $checkboxes = (isset($_POST['ban_checkboxes'])) ? $_POST['ban_checkboxes'] : [];
+ if (isset($_POST['delete_sel_ex']))
+ {
+ foreach($_POST['ce_checkboxes'] as $c)
+ $checkboxes[] = $c;
+ $del_ex = true;
+ chlkup_autoload_modal("excepts_modal");
+ }
+ else if (isset($_POST['delete_sel_inv']))
+ {
+ foreach($_POST['ci_checkboxes'] as $c)
+ $checkboxes[] = $c;
+ $del_inv = true;
+ chlkup_autoload_modal("invites_modal");
+ }
+ else if (isset($_POST['delete_sel_ban']))
+ {
+ foreach($_POST['cb_checkboxes'] as $c)
+ $checkboxes[] = $c;
+ $del_ban = true;
+ chlkup_autoload_modal("bans_modal");
+ }
+
}
?>
<br>
<form method="get" action="details.php">
<div class="container-xxl">
- <div class="input-group short-form-control">
- <input class="short-form-control" id="chan" name="chan" type="text" value="<?php echo $channame; ?>">
+ <div class="input-group">
+ <input class="form-control" id="chan" name="chan" type="text" value="<?php echo $channame; ?>">
<div class="input-group-append">
<button type="submit" class="btn btn-primary">Go</button>
</div>
<br>
<h3>
- Topic:<br></h3><h4>
+ Topic:<br></h3>
<form method="post" action="details.php?chan=<?php echo urlencode($channelObj->name); ?>">
- <div class="input-group short-form-control">
- <input maxlength="360" type="text" class="short-form-control" name="set_topic" value="<?php echo (isset($channelObj->topic)) ? htmlspecialchars($channelObj->topic) : ""; ?>">
+ <div class="input-group">
+ <input maxlength="360" type="text" class="input-group form-control" name="set_topic" value="<?php echo (isset($channelObj->topic)) ? htmlspecialchars($channelObj->topic) : ""; ?>">
<div class="input-group-append"><button type="submit" name="update_topic" value="true" class="btn btn-info">Update Topic</button></div></div>
</form>
-</h4>
<?php
if ($topicset)
Message::Success("The topic for $channelObj->name has been updated to be: \"".htmlspecialchars($channelObj->topic)."\"");
</button>
</div>
<div class="modal-body">
+ <?php if ($del_ban) do_delete_chanban($channelObj, $checkboxes); ?>
<form method="post">
<?php generate_chanbans_table($channelObj); ?>
</form>
</button>
</div>
<div class="modal-body">
+ <?php if ($del_inv) do_delete_invite($channelObj, $checkboxes); ?>
<form method="post">
<?php generate_chaninvites_table($channelObj); ?>
</form>
</button>
</div>
<div class="modal-body">
+ <?php if ($del_ex) do_delete_chanex($channelObj, $checkboxes); ?>
<form method="post">
<?php generate_chanexcepts_table($channelObj); ?>
</form>
function generate_chanbans_table($channel)
{
- ?>
- <form method="post"><p>
- <button class="btn btn-info btn-sm" type="submit" name="delete_sel_ban">Delete</button>
- </p>
- <table class="table table-responsive table-hover">
- <thead class="table-info">
- <th><input type="checkbox" label='selectall' onClick="toggle_checkbox(this)" /></th>
- <th>Name</th>
- <th>Set by</th>
- <th>Set at</th>
- <th></th>
- </thead>
- <tbody>
- <?php
- foreach ($channel->bans as $ban) {
- echo "<tr>";
- echo "<td scope=\"row\"><input type=\"checkbox\" value='$ban->name' name=\"checkboxes[]\"></td>";
- echo "<td><code>".htmlspecialchars($ban->name)."</code></td>";
- $set_by = htmlspecialchars($ban->set_by);
- echo "<td>$set_by</td>";
- $set_at = $ban->set_at;
- echo "<td>$set_at</td>";
- echo "<td></td>";
- echo "</tr>";
- }
-
- ?>
- </tbody>
- </table>
- </form>
- <?php
+ global $rpc;
+ $channel = $rpc->channel()->get($channel->name);
+ ?>
+ <form method="post"><p>
+ <button class="btn btn-info btn-sm" type="submit" name="delete_sel_ban">Delete</button>
+ </p>
+ <table class="table table-responsive table-hover">
+ <thead class="table-info">
+ <th><input type="checkbox" label='selectall' onClick="toggle_chanbans(this)" /></th>
+ <th>Name</th>
+ <th>Set by</th>
+ <th>Set at</th>
+ <th></th>
+ </thead>
+ <tbody>
+ <?php
+ foreach ($channel->bans as $ban) {
+ echo "<tr>";
+ echo "<td scope=\"row\"><input type=\"checkbox\" value='$ban->name' name=\"cb_checkboxes[]\"></td>";
+ echo "<td><code>".htmlspecialchars($ban->name)."</code></td>";
+ $set_by = htmlspecialchars($ban->set_by);
+ echo "<td>$set_by</td>";
+ $set_at = $ban->set_at;
+ echo "<td>$set_at</td>";
+ echo "<td></td>";
+ echo "</tr>";
+ }
+
+ ?>
+ </tbody>
+ </table>
+ </form>
+ <?php
}
function generate_chaninvites_table($channel)
{
- ?>
- <form method="post"><p>
- <button class="btn btn-info btn-sm" type="submit" name="delete_sel_inv">Delete</button>
- </p>
- <table class="table table-responsive table-hover">
- <thead class="table-info">
- <th><input type="checkbox" label='selectall' onClick="toggle_checkbox(this)" /></th>
- <th>Name</th>
- <th>Set by</th>
- <th>Set at</th>
- <th></th>
- </thead>
- <tbody>
- <?php
- foreach ($channel->invite_exceptions as $inv) {
- echo "<tr>";
- echo "<td scope=\"row\"><input type=\"checkbox\" value='$inv->name' name=\"checkboxes[]\"></td>";
- echo "<td><code>".htmlspecialchars($inv->name)."</code></td>";
- $set_by = htmlspecialchars($inv->set_by);
- echo "<td>$set_by</td>";
- $set_at = $inv->set_at;
- echo "<td>$set_at</td>";
- echo "<td></td>";
- echo "</tr>";
- }
-
- ?>
- </tbody>
- </table>
- </form>
- <?php
+ global $rpc;
+ $channel = $rpc->channel()->get($channel->name);
+ ?>
+ <form method="post"><p>
+ <button class="btn btn-info btn-sm" type="submit" name="delete_sel_inv">Delete</button>
+ </p>
+ <table class="table table-responsive table-hover">
+ <thead class="table-info">
+ <th><input type="checkbox" label='selectall' onClick="toggle_chaninvs(this)" /></th>
+ <th>Name</th>
+ <th>Set by</th>
+ <th>Set at</th>
+ <th></th>
+ </thead>
+ <tbody>
+ <?php
+ foreach ($channel->invite_exceptions as $inv) {
+ echo "<tr>";
+ echo "<td scope=\"row\"><input type=\"checkbox\" value='$inv->name' name=\"ci_checkboxes[]\"></td>";
+ echo "<td><code>".htmlspecialchars($inv->name)."</code></td>";
+ $set_by = htmlspecialchars($inv->set_by);
+ echo "<td>$set_by</td>";
+ $set_at = $inv->set_at;
+ echo "<td>$set_at</td>";
+ echo "<td></td>";
+ echo "</tr>";
+ }
+
+ ?>
+ </tbody>
+ </table>
+ </form>
+ <?php
}
function generate_chanexcepts_table($channel)
{
- ?>
- <form method="post"><p>
- <button class="btn btn-info btn-sm" type="submit" name="delete_sel_ex">Delete</button>
- </p>
- <table class="table table-responsive table-hover">
- <thead class="table-info">
- <th><input type="checkbox" label='selectall' onClick="toggle_checkbox(this)" /></th>
- <th>Name</th>
- <th>Set by</th>
- <th>Set at</th>
- <th></th>
- </thead>
- <tbody>
- <?php
- foreach ($channel->ban_exemptions as $ex) {
- echo "<tr>";
- echo "<td scope=\"row\"><input type=\"checkbox\" value='$ex->name' name=\"checkboxes[]\"></td>";
- echo "<td><code>".htmlspecialchars($ex->name)."</code></td>";
- $set_by = htmlspecialchars($ex->set_by);
- echo "<td>$set_by</td>";
- $set_at = $ex->set_at;
- echo "<td>$set_at</td>";
- echo "<td></td>";
- echo "</tr>";
- }
-
- ?>
- </tbody>
- </table>
- </form>
- <?php
-}
+ global $rpc;
+ $channel = $rpc->channel()->get($channel->name);
+ ?>
+ <form method="post"><p>
+ <button class="btn btn-info btn-sm" type="submit" name="delete_sel_ex">Delete</button>
+ </p>
+ <table class="table table-responsive table-hover">
+ <thead class="table-info">
+ <th><input type="checkbox" label='selectall' onClick="toggle_chanexs(this)" /></th>
+ <th>Name</th>
+ <th>Set by</th>
+ <th>Set at</th>
+ <th></th>
+ </thead>
+ <tbody>
+ <?php
+ foreach ($channel->ban_exemptions as $ex) {
+ echo "<tr>";
+ echo "<td scope=\"row\"><input type=\"checkbox\" value='$ex->name' name=\"ce_checkboxes[]\"></td>";
+ echo "<td><code>".htmlspecialchars($ex->name)."</code></td>";
+ $set_by = htmlspecialchars($ex->set_by);
+ echo "<td>$set_by</td>";
+ $set_at = $ex->set_at;
+ echo "<td>$set_at</td>";
+ echo "<td></td>";
+ echo "</tr>";
+ }
+ ?>
+ </tbody>
+ </table>
+ </form>
+ <?php
+}
+/**
+ * Generate the user list of a channel
+ *
+ * Why is it called chan occupants? o.o
+ * For the code, to avoid mixups
+ * It's called "User List" on the website
+ * @param mixed $channel
+ * @return void
+ */
function generate_chan_occupants_table($channel)
{
- ?>
- <form method="post"><p>
-
- </p>
- <table class="table table-responsive table-hover">
- <thead class="table-info">
- <th><input type="checkbox" label='selectall' onClick="toggle_checkbox(this)" /></th>
- <th>Name</th>
- <th>Status</th>
- <th>Actions</th>
- <th></th>
- </thead>
- <tbody>
- <?php
- foreach ($channel->members as $member) {
- echo "<tr>";
- echo "<td scope=\"row\"><input type=\"checkbox\" value='$member->id' name=\"checkboxes[]\"></td>";
- echo "<td><a href=\"".BASE_URL."users/details.php?nick=$member->id\">".htmlspecialchars($member->name)."</a></td>";
- echo "<td>Status</td>";
- echo "<td>Op</td>";
- echo "<td>Deop</td>";
- echo "</tr>";
- }
-
- ?>
- </tbody>
- </table>
- </form>
-
- <?php
+ ?>
+ <form method="post"><p>
+
+ </p>
+ <table class="table table-responsive table-hover">
+ <thead class="table-info">
+ <th><input type="checkbox" label='selectall' onClick="toggle_checkbox(this)" /></th>
+ <th>Name</th>
+ <th>Status</th>
+ <th>Actions</th>
+ <th></th>
+ </thead>
+ <tbody>
+ <?php
+ foreach ($channel->members as $member) {
+ echo "<tr>";
+ echo "<td scope=\"row\"><input type=\"checkbox\" value='$member->id' name=\"checkboxes[]\"></td>";
+ echo "<td><a href=\"".BASE_URL."users/details.php?nick=$member->id\">".htmlspecialchars($member->name)."</a></td>";
+ echo "<td>Status</td>";
+ echo "<td>Op</td>";
+ echo "<td>Deop</td>";
+ echo "</tr>";
+ }
+
+ ?>
+ </tbody>
+ </table>
+ </form>
+
+ <?php
+}
+
+function chlkup_autoload_modal($name)
+{
+ ?>
+ <script>
+ $(document).ready(function () {
+ $("#<?php echo $name; ?>").modal("show");
+ });
+ </script>
+ <?php
+}
+
+
+function _do_chan_item_delete($chan, string $type, array $list, array &$errors) : bool
+{
+ global $rpc;
+ $n = "";
+ $str = "";
+
+ if ($type == "invite")
+ $char = "I";
+ elseif ($type == "ban")
+ $char = "b";
+ elseif ($type == "except")
+ $char = "e";
+ else
+ return false;
+
+ foreach($list as $l)
+ {
+ $n .= $char;
+ $str .= " ".$l;
+ }
+ if ($rpc->channel()->set_mode($chan->name, "-$n", $str))
+ {
+ Message::Success("Deleted successfully");
+ return true;
+ }
+ $errors[] = $rpc->error . " ($rpc->errno)";
+ Message::Fail("An error occurred: $rpc->error");
+ return false;
+}
+
+function do_delete_invite($chan, $list)
+{
+ $errs = [];
+ _do_chan_item_delete($chan, "invite", $list, $errs);
+}
+
+function do_delete_chanban($chan, $list)
+{
+ $errs = [];
+ _do_chan_item_delete($chan, "ban", $list, $errs);
+}
+
+function do_delete_chanex($chan, $list)
+{
+ $errs = [];
+ _do_chan_item_delete($chan, "except", $list, $errs);
}
\ No newline at end of file