]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - users/index.php
Sometimes users do not have an IP due to being pseudobots or whatever
[irc/unrealircd/unrealircd-webpanel.git] / users / index.php
index 9d799df268d11ecb1a37adaaa15acf89cbbd38a7..c8316ade6e0aa8c5a5633539d62d9103479cfec5 100644 (file)
@@ -1,17 +1,37 @@
 <?php
 require_once "../common.php";
-require_once UPATH . "/header.php";
+require_once "../header.php";
 
-if (!empty($_POST)) {
+if (!empty($_GET))
+{
+       if (isset($_GET['account']) && !isset($_POST['uf_account']))
+               $_POST['uf_account'] = $_GET['account'];
+
+       if (isset($_GET['operonly']) && !isset($_POST['operonly']))
+               $_POST['operonly'] = $_GET['operonly'];
+
+       if (isset($_GET['servicesonly']) && !isset($_POST['servicesonly']))
+               $_POST['servicesonly'] = $_GET['servicesonly'];
+}
+
+if (!empty($_POST))
+{
        do_log($_POST);
        $bantype = $_POST['bantype'];
+
        if (isset($_POST['userch'])) {
-               foreach ($_POST["userch"] as $user) {
+               foreach ($_POST["userch"] as $user)
+               {
                        $user = $name = base64_decode($user);
                        $bantype = (isset($_POST['bantype'])) ? $_POST['bantype'] : NULL;
-                       if (!$bantype) /* shouldn't happen? */{
+
+                       if (!$bantype) /* shouldn't happen? */
+                       {
                                Message::Fail("An error occured");
-                       } else {
+                       }
+                       
+                       else
+                       {
                                $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;
@@ -28,15 +48,22 @@ if (!empty($_POST)) {
                                                $duration .= $banlen_h;
                                }
                                $user = $rpc->user()->get($user);
+
                                if (!$user && $bantype !== "qline") {
                                        Message::Fail("Could not find that user: User not online");
-                               } else {
+                               }
+                               
+                               else
+                               {
                                        $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")
                                                $rpc->nameban()->add($name, $reason, $duration);
+
                                        else if ($rpc->serverban()->add($user->id, $bantype, $duration, $reason))
                                                Message::Success($user->name . " (*@" . $user->hostname . ") has been $bantype" . "d $msg_msg: $reason");
+
                                        else
                                                Message::Fail("Could not add $bantype against $name: $rpc->error");
                                }
@@ -55,6 +82,7 @@ Click on a username to view more information.
 <div id="Users">
        
        <?php
+
        if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick']))
                Message::Info("Listing users which match nick: \"" . $_POST['uf_nick'] . "\"");
 
@@ -67,19 +95,32 @@ Click on a username to view more information.
        if (isset($_POST['uf_account']) && strlen($_POST['uf_account']))
                Message::Info("Listing users which match account: \"" . $_POST['uf_account'] . "\"");
 
+       if (isset($_POST['uf_server']) && strlen($_POST['uf_server']))
+               Message::Info("Listing users connected to servers matching: \"" . $_POST['uf_server'] . "\"");
+
+
        ?>
        <table class="container-xxl table table-responsive caption-top table-striped">
        <thead>
-               <th scope="col"><h5>Filter:</h5></th>
                <form action="" method="post">
-               <th scope="col" colspan="2">Nick <input name="uf_nick" type="text" class="form-control short-form-control">
-               <th scope="col" colspan="2">Host <input name="uf_host" type="text" class="form-control short-form-control"></th>
-               <th scope="col" colspan="2">IP <input name="uf_ip" type="text" class="form-control short-form-control"></th>
-               <th scope="col" colspan="2">Account <input name="uf_account" type="text" class="form-control short-form-control"></th>
-               <th scope="col"> <input class="btn btn-primary" type="submit" value="Search"></th></form>
+                       <tr>    
+                               <th scope="col"><h5>Filter:</h5></th>
+                               <th scope="col" colspan="2"><input <?php echo (isset($_POST['operonly'])) ? "checked" : ""; ?> name="operonly" type="checkbox" value=""> Opers Only</th>
+                               <th scope="col" colspan="2"><input <?php echo (isset($_POST['servicesonly'])) ? "checked" : ""; ?> name="servicesonly" type="checkbox" value=""> Services Only</th>
+                       </tr>
+                       <tr>                    
+                               <th scope="col" colspan="2">Nick <input name="uf_nick" type="text" class="form-control short-form-control">
+                               <th scope="col" colspan="2">Host <input name="uf_host" type="text" class="form-control short-form-control"></th>
+                               <th scope="col" colspan="2">IP <input name="uf_ip" type="text" class="form-control short-form-control"></th>
+                               <th scope="col" colspan="2">Account <input name="uf_account" type="text" class="form-control short-form-control"></th>
+                               <th scope="col" colspan="2">Server <input name="uf_server" type="text" class="form-control short-form-control"></th>
+                               
+                               <th scope="col"> <input class="btn btn-primary" type="submit" value="Search"></th>
+                       </tr>
+               </form>
        </thead></table>
 
-       <table class="container-xxl table table-responsive caption-top table-striped">
+       <table class="container-xxl table table-sm table-responsive caption-top table-striped">
        <thead class="table-primary">
                <th scope="col"><input type="checkbox" label='selectall' onClick="toggle_user(this)" /></th>
                <th scope="col">Nick</th>
@@ -124,26 +165,43 @@ Click on a username to view more information.
                        strpos(strtolower($user->user->account), strtolower($_POST['uf_account'])) == false)
                                continue;
 
-                       echo "<tr>";
+                       /* Some basic filtering for ACCOUNT */
+                       if (isset($_POST['uf_server']) && strlen($_POST['uf_server']) && 
+                       strpos(strtolower($user->user->servername), strtolower($_POST['uf_server'])) !== 0 &&
+                       strpos(strtolower($user->user->servername), strtolower($_POST['uf_server'])) == false)
+                               continue;
+
+                       /* Some basic filtering for OPER */
+                       if (isset($_POST['operonly']) &&
+                       (strpos($user->user->modes, "o") == false || strpos($user->user->modes,"S") !== false))
+                               continue;
+
+                       /* Some basic filtering for SERVICES */
+                       if (isset($_POST['servicesonly']) &&
+                       (strpos($user->user->modes,"S") == false))
+                               continue;
+
+                       echo "\n<tr>";
                        echo "<th scope=\"row\"><input type=\"checkbox\" value='" . base64_encode($user->id)."' name=\"userch[]\"></th>";
-                       $isBot = (strpos($user->user->modes, "B") !== false) ? ' <span class="badge-pill badge-dark">Bot</span>' : "";
+                       $isBot = (strpos($user->user->modes, "B") !== false) ? ' <span class="badge rounded-pill badge-dark">Bot</span>' : "";
                        echo "<td><a href=\"details.php?nick=".$user->id."\">$user->name$isBot</a></td>";
-                       echo "<td>".$user->hostname." (".$user->ip.")</td>";
-                       $account = (isset($user->user->account)) ? $user->user->account : '<span class="badge-pill badge-primary">None</span>';
+                       echo "<td>".htmlspecialchars($user->hostname)." (".htmlspecialchars($user->ip ?? "None").")</td>";
+                       $account = (isset($user->user->account)) ? "<a href=\"".BASE_URL."users/?account=".$user->user->account."\">".htmlspecialchars($user->user->account)."</a>" : '<span class="badge rounded-pill badge-primary">None</span>';
                        echo "<td>".$account."</td>";
                        $modes = (isset($user->user->modes)) ? "+" . $user->user->modes : "<none>";
                        echo "<td>".$modes."</td>";
-                       $oper = (isset($user->user->operlogin)) ? $user->user->operlogin." <span class=\"badge-pill badge-secondary\">".$user->user->operclass."</span>" : "";
+                       $oper = (isset($user->user->operlogin)) ? $user->user->operlogin." <span class=\"badge rounded-pill badge-secondary\">".$user->user->operclass."</span>" : "";
                        if (!strlen($oper))
-                               $oper = (strpos($user->user->modes, "S") !== false) ? '<span class="badge-pill badge-warning">Services Bot</span>' : "";
+                               $oper = (strpos($user->user->modes, "S") !== false) ? '<span class="badge rounded-pill badge-warning">Services Bot</span>' : "";
                        echo "<td>".$oper."</td>";
 
-                       $secure = (isset($user->tls)) ? "<span class=\"badge-pill badge-success\">Secure</span>" : "<span class=\"badge-pill badge-danger\">Insecure</span>";
+                       $secure = (isset($user->tls) || $user->hostname !== "localhost") ? "<span class=\"badge rounded-pill badge-success\">Secure</span>" : "<span class=\"badge rounded-pill badge-danger\">Insecure</span>";
                        if (strpos($user->user->modes, "S") !== false)
                                $secure = "";
                        echo "<td>".$secure."</td>";
-                       echo "<td>".$user->user->servername."</td>";
+                       echo "<td><a href=\"".BASE_URL."servers/details.php?server=".substr($user->id, 0, 3)."\">".$user->user->servername."</a></td>";
                        echo "<td>".$user->user->reputation."</td>";
+                       echo "</tr>";
                }
        ?>
        </tbody></table>