]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - server_bans.php
Make a start on filtering for later
[irc/unrealircd/unrealircd-webpanel.git] / server_bans.php
index 524bbeddfd45a8b0fcf8cb00dae6d421f09c09e2..97ec2fa8c6369cd16ee483ec4ac67bcdbf5e13ad 100644 (file)
@@ -8,86 +8,96 @@ if (!empty($_POST))
 
        do_log($_POST);
 
-       if (!empty($_POST['tklch'])) // User has asked to delete these tkls
+       if (isset($_POST['tklch']) && !empty($_POST['tklch'])) // User has asked to delete these tkls
        {
                foreach ($_POST as $key => $value) {
                        foreach ($value as $tok) {
                                $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");
                        }
                }
        }
-       else if (!($iphost = $_POST['tkl_add']))
-                       Message::Fail("No user was specified");
-       else if (!($bantype = (isset($_POST['bantype'])) ? $_POST['bantype'] : false))
+       elseif (isset($_POST['tkl_add']) && !empty($_POST['tkl_add']))
        {
-               Message::Fail("Unable to add Server Ban: No ban type selected");
-       }
-       else /* It did */
-       {
-               
-               if ((
-                               $bantype == "gline" ||
-                               $bantype == "gzline" ||
-                               $bantype == "shun" ||
-                               $bantype == "eline"
-                       ) && strpos($iphost, "@") == false) // doesn't have full mask
-                       $iphost = "*@" . $iphost;
+               if (!($iphost = $_POST['tkl_add']))
+                       Message::Fail("No mask was specified");
+               else if (!($bantype = (isset($_POST['bantype'])) ? $_POST['bantype'] : false))
+               {
+                       Message::Fail("Unable to add Server Ban: No ban type selected");
+               } else /* It did */{
 
-               $soft = ($_POST['soft']) ? true : false;
+                       if (
+                               (
+                                       $bantype == "gline" ||
+                                       $bantype == "gzline" ||
+                                       $bantype == "shun" ||
+                                       $bantype == "eline"
+                               ) && strpos($iphost, "@") == false
+                       ) // doesn't have full mask
+                               $iphost = "*@" . $iphost;
 
-               if ($soft)
-                       $iphost = "%" . $iphost;
-               /* duplicate code for now [= */
-               $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL;
-               $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL;
-               $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL;
-               $duration = "";
-               if (!$banlen_d && !$banlen_h && !$banlen_w)
-                       $duration .= "0";
-               
-               else
-               {
-                       if ($banlen_w)
-                               $duration .= $banlen_w;
-                       if ($banlen_d)
-                               $duration .= $banlen_d;
-                       if ($banlen_h)
-                               $duration .= $banlen_h;
-               }
-               $msg_msg = ($duration == "0" || $duration == "0w0d0h") ? "permanently" : "for ".rpc_convert_duration_string($duration);
-               $reason = (isset($_POST['ban_reason'])) ? $_POST['ban_reason'] : "No reason";
-               if ($bantype == "qline")
-               {
-                       if ($rpc->nameban()->add($iphost, $reason, $duration))
-                               Message::Success("Name Ban set against \"$iphost\": $reason");
-                       else
-                               Message::Fail("Name Ban could not be set against \"$iphost\": $rpc->error");
-               }
-               elseif ($bantype == "except")
-               {
-                       if ($rpc->exception()->add($iphost, "", $duration, $reason))
-                               Message::Success("Exception set for \"$iphost\": $reason");
-                       else
-                               Message::Fail("Exception could not be set \"$iphost\": $rpc->error");
-               }
-               else if ($rpc->serverban()->add($iphost, $bantype, $duration, $reason))
-               {
-                       Message::Success("Host / IP: $iphost has been $bantype" . "d $msg_msg: $reason");
+                       $soft = ($_POST['soft']) ? true : false;
+
+                       if ($soft)
+                               $iphost = "%" . $iphost;
+                       /* duplicate code for now [= */
+                       $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL;
+                       $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL;
+                       $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL;
+                       $duration = "";
+                       if (!$banlen_d && !$banlen_h && !$banlen_w)
+                               $duration .= "0";
+                       else {
+                               if ($banlen_w)
+                                       $duration .= $banlen_w;
+                               if ($banlen_d)
+                                       $duration .= $banlen_d;
+                               if ($banlen_h)
+                                       $duration .= $banlen_h;
+                       }
+                       $msg_msg = ($duration == "0" || $duration == "0w0d0h") ? "permanently" : "for " . rpc_convert_duration_string($duration);
+                       $reason = (isset($_POST['ban_reason'])) ? $_POST['ban_reason'] : "No reason";
+                       if ($bantype == "qline") {
+                               if ($rpc->nameban()->add($iphost, $reason, $duration))
+                                       Message::Success("Name Ban set against \"$iphost\": $reason");
+                               else
+                                       Message::Fail("Name Ban could not be set against \"$iphost\": $rpc->error");
+                       } elseif ($bantype == "except") {
+                               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");
+                       } else if ($rpc->serverban()->add($iphost, $bantype, $duration, $reason)) {
+                               Message::Success("Host / IP: $iphost has been $bantype" . "d $msg_msg: $reason");
+                       } else
+                               Message::Fail("The $bantype against \"$iphost\" could not be added: $rpc->error");
                }
-               else
-                       Message::Fail("The $bantype against \"$iphost\" could not be added: $rpc->error");
+       }
+       elseif (isset($_POST['search_types']) && !empty($_POST['search_types']))
+       {
+               
        }
 }
 
 $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 +194,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)" /></th>
-       <th>Mask</th>
-       <th>Type</th>
-       <th>Duration</th>
-       <th>Reason</th>
-       <th>Set By</th>
-       <th>Set On</th>
-       <th>Expires</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>";
-                       echo "<td>".$tkl->duration_string."</td>";
-                       echo "<td>".$tkl->reason."</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>";
+                       $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">