]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - server_bans.php
Add ability to add and delete access to the panel
[irc/unrealircd/unrealircd-webpanel.git] / server_bans.php
index 527a905d3d21940ab0ac1ef93dcb0431f0b2af38..0834bd8f02e3324e4b9ace7e06b4acdce3d51eaa 100644 (file)
@@ -15,7 +15,16 @@ if (!empty($_POST))
                                $tok = explode(",", $tok);
                                $ban = base64_decode($tok[0]);
                                $type = base64_decode($tok[1]);
-                               if ($rpc->serverban()->delete($ban, $type))
+                               $success = false;
+                               if ($type == "except")
+                                       $success = $rpc->serverbanexception()->delete($ban);
+                               else if ($type == "qline" || $type == "local-qline")
+                                       $success = $rpc->nameban()->delete($ban);
+                               else
+                                       $success = $rpc->serverban()->delete($ban, $type);
+
+
+                               if ($success)
                                        Message::Success("$type has been removed for $ban");
                                else
                                        Message::Fail("Unable to remove $type on $ban: $rpc->error");
@@ -71,7 +80,7 @@ if (!empty($_POST))
                }
                elseif ($bantype == "except")
                {
-                       if ($rpc->exception()->add($iphost, "", $duration, $reason))
+                       if ($rpc->serverbanexception()->add($iphost, "", $duration, $reason))
                                Message::Success("Exception set for \"$iphost\": $reason");
                        else
                                Message::Fail("Exception could not be set \"$iphost\": $rpc->error");
@@ -88,6 +97,8 @@ if (!empty($_POST))
 $tkl = $rpc->serverban()->getAll();
 foreach ($rpc->nameban()->getAll() as $v)
        $tkl[] = $v;
+foreach ($rpc->serverbanexception()->getAll() as $v)
+       $tkl[] = $v;
 ?>
 <h4>Server Bans Overview</h4><br>
 <p><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
@@ -184,34 +195,39 @@ foreach ($rpc->nameban()->getAll() as $v)
        </div>
        </div>
 
-       <table class="table table-responsive caption-top table-striped">
+       <table class="container-xxl table table-sm table-responsive caption-top table-striped">
        <thead class="table-primary">
        <form method="post">
-       <th><input type="checkbox" label='selectall' onClick="toggle_tkl(this)" />Select all</th>
-       <th>Mask</th>
-       <th>Type</th>
-       <th>Set By</th>
-       <th>Set On</th>
-       <th>Expires</th>
-       <th>Duration</th>
-       <th>Reason</th>
+       <th scope="col"><input type="checkbox" label='selectall' onClick="toggle_tkl(this)" /></th>
+       <th scope="col">Mask</th>
+       <th scope="col">Type</th>
+       <th scope="col">Duration</th>
+       <th scope="col">Reason</th>
+       <th scope="col">Set By</th>
+       <th scope="col">Set On</th>
+       <th scope="col">Expires</th>
        </thead>
-       
+       <tbody>
        <?php
                foreach($tkl as $tkl)
                {
-                       echo "<tr>";
-                       echo "<td><input type=\"checkbox\" value='" . base64_encode($tkl->name).",".base64_encode($tkl->type) . "' name=\"tklch[]\"></td>";
-                       echo "<td>".$tkl->name."</td>";
-                       echo "<td>".$tkl->type_string."</td>";
-                       $set_by = ($tkl->set_by == "-config-") ? "<span class=\"badge-pill badge-secondary\">Config</span>" : show_nick_only($tkl->set_by);
-                       echo "<td>".$set_by."</td>";
-                       echo "<td>".$tkl->set_at_string."</td>";
-                       echo "<td>".$tkl->expire_at_string."</td>";
-                       echo "<td>".$tkl->duration_string."</td>";
-                       echo "<td>".$tkl->reason."</td>";
+                       $set_in_config = ((isset($tkl->set_in_config) && $tkl->set_in_config) || ($tkl->set_by == "-config-")) ? true : false;
+                       echo "<tr scope='col'>";
+                       if ($set_in_config)
+                               echo "<td scope=\"col\"></td>";
+                       else
+                               echo "<td scope=\"col\"><input type=\"checkbox\" value='" . base64_encode($tkl->name).",".base64_encode($tkl->type) . "' name=\"tklch[]\"></td>";
+                       echo "<td scope=\"col\">".$tkl->name."</td>";
+                       echo "<td scope=\"col\">".$tkl->type_string."</td>";
+                       echo "<td scope=\"col\">".$tkl->duration_string."</td>";
+                       echo "<td scope=\"col\">".$tkl->reason."</td>";
+                       $set_by = $set_in_config ? "<span class=\"badge rounded-pill badge-secondary\">Config</span>" : show_nick_only($tkl->set_by);
+                       echo "<td scope=\"col\">".$set_by."</td>";
+                       echo "<td scope=\"col\">".$tkl->set_at_string."</td>";
+                       echo "<td scope=\"col\">".$tkl->expire_at_string."</td>";
+                       echo "</tr>";
                }
-       ?></table><p><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModal2">
+       ?></tbody></table><p><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModal2">
        Delete selected
        </button></p>
        <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">