]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - users/index.php
Allow clicking on peoples account in places to do a user search with the account...
[irc/unrealircd/unrealircd-webpanel.git] / users / index.php
1 <?php
2 require_once "../common.php";
3 require_once "../header.php";
4
5 if (!empty($_GET) && isset($_GET['account']) && !isset($_POST['uf_account']))
6 $_POST['uf_account'] = $_GET['account'];
7
8 if (!empty($_POST)) {
9 do_log($_POST);
10 $bantype = $_POST['bantype'];
11 if (isset($_POST['userch'])) {
12 foreach ($_POST["userch"] as $user) {
13 $user = $name = base64_decode($user);
14 $bantype = (isset($_POST['bantype'])) ? $_POST['bantype'] : NULL;
15 if (!$bantype) /* shouldn't happen? */{
16 Message::Fail("An error occured");
17 } else {
18 $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL;
19 $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL;
20 $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL;
21
22 $duration = "";
23 if (!$banlen_d && !$banlen_h && !$banlen_w)
24 $duration .= "0";
25 else {
26 if ($banlen_w)
27 $duration .= $banlen_w;
28 if ($banlen_d)
29 $duration .= $banlen_d;
30 if ($banlen_h)
31 $duration .= $banlen_h;
32 }
33 $user = $rpc->user()->get($user);
34 if (!$user && $bantype !== "qline") {
35 Message::Fail("Could not find that user: User not online");
36 } else {
37 $msg_msg = ($duration == "0" || $duration == "0w0d0h") ? "permanently" : "for " . rpc_convert_duration_string($duration);
38 $reason = (isset($_POST['ban_reason'])) ? $_POST['ban_reason'] : "No reason";
39 if ($bantype == "qline")
40 $rpc->nameban()->add($name, $reason, $duration);
41 else if ($rpc->serverban()->add($user->id, $bantype, $duration, $reason))
42 Message::Success($user->name . " (*@" . $user->hostname . ") has been $bantype" . "d $msg_msg: $reason");
43 else
44 Message::Fail("Could not add $bantype against $name: $rpc->error");
45 }
46 }
47 }
48 }
49 }
50
51 /* Get the user list */
52 $users = $rpc->user()->getAll();
53 ?>
54 <h4>Users Overview</h4>
55
56 Click on a username to view more information.
57
58 <div id="Users">
59
60 <?php
61 if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick']))
62 Message::Info("Listing users which match nick: \"" . $_POST['uf_nick'] . "\"");
63
64 if (isset($_POST['uf_ip']) && strlen($_POST['uf_ip']))
65 Message::Info("Listing users which match IP: \"" . $_POST['uf_ip'] . "\"");
66
67 if (isset($_POST['uf_host']) && strlen($_POST['uf_host']))
68 Message::Info("Listing users which match hostmask: \"" . $_POST['uf_host'] . "\"");
69
70 if (isset($_POST['uf_account']) && strlen($_POST['uf_account']))
71 Message::Info("Listing users which match account: \"" . $_POST['uf_account'] . "\"");
72
73 ?>
74 <table class="container-xxl table table-responsive caption-top table-striped">
75 <thead>
76 <th scope="col"><h5>Filter:</h5></th>
77 <form action="" method="post">
78 <th scope="col" colspan="2">Nick <input name="uf_nick" type="text" class="form-control short-form-control">
79 <th scope="col" colspan="2">Host <input name="uf_host" type="text" class="form-control short-form-control"></th>
80 <th scope="col" colspan="2">IP <input name="uf_ip" type="text" class="form-control short-form-control"></th>
81 <th scope="col" colspan="2">Account <input name="uf_account" type="text" class="form-control short-form-control"></th>
82 <th scope="col"> <input class="btn btn-primary" type="submit" value="Search"></th></form>
83 </thead></table>
84
85 <table class="container-xxl table table-sm table-responsive caption-top table-striped">
86 <thead class="table-primary">
87 <th scope="col"><input type="checkbox" label='selectall' onClick="toggle_user(this)" /></th>
88 <th scope="col">Nick</th>
89 <th scope="col">Host / IP</th>
90 <th scope="col"><span data-toggle="tooltip" data-placement="bottom" title="The services account name, if the user identified to services." style="border-bottom: 1px dotted #000000">Account</span></th>
91 <th scope="col">Usermodes <a href="https://www.unrealircd.org/docs/User_modes" target="_blank">ℹ️</a></th>
92 <th scope="col">Oper</th>
93 <th scope="col"><span data-toggle="tooltip" data-placement="bottom" title="This shows [Secure] if the user is using SSL/TLS or is on localhost." style="border-bottom: 1px dotted #000000">Secure</span></th>
94 <th scope="col">Connected to</th>
95 <th scope="col"><span data-toggle="tooltip" data-placement="bottom" title="The reputation score gets higher when someone with this IP address has been connected in the past weeks. A low reputation score (like <10) is an indication of a new IP." style="border-bottom: 1px dotted #000000">Reputation</span> <a href="https://www.unrealircd.org/docs/Reputation_score" target="_blank">ℹ️</a></th>
96 </thead>
97
98 <tbody>
99 <form method="post">
100 <?php
101
102 foreach($users as $user)
103 {
104
105
106 /* Some basic filtering for NICK */
107 if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick']) &&
108 strpos(strtolower($user->name), strtolower($_POST['uf_nick'])) !== 0 &&
109 strpos(strtolower($user->name), strtolower($_POST['uf_nick'])) == false)
110 continue;
111
112 /* Some basic filtering for HOST */
113 if (isset($_POST['uf_host']) && strlen($_POST['uf_host']) &&
114 strpos(strtolower($user->hostname), strtolower($_POST['uf_host'])) !== 0 &&
115 strpos(strtolower($user->hostname), strtolower($_POST['uf_host'])) == false)
116 continue;
117
118 /* Some basic filtering for IP */
119 if (isset($_POST['uf_ip']) && strlen($_POST['uf_ip']) &&
120 strpos(strtolower($user->ip), strtolower($_POST['uf_ip'])) !== 0 &&
121 strpos(strtolower($user->ip), strtolower($_POST['uf_ip'])) == false)
122 continue;
123
124 /* Some basic filtering for ACCOUNT */
125 if (isset($_POST['uf_account']) && strlen($_POST['uf_account']) &&
126 strpos(strtolower($user->user->account), strtolower($_POST['uf_account'])) !== 0 &&
127 strpos(strtolower($user->user->account), strtolower($_POST['uf_account'])) == false)
128 continue;
129
130 echo "\n<tr>";
131 echo "<th scope=\"row\"><input type=\"checkbox\" value='" . base64_encode($user->id)."' name=\"userch[]\"></th>";
132 $isBot = (strpos($user->user->modes, "B") !== false) ? ' <span class="badge rounded-pill badge-dark">Bot</span>' : "";
133 echo "<td><a href=\"details.php?nick=".$user->id."\">$user->name$isBot</a></td>";
134 echo "<td>".$user->hostname." (".$user->ip.")</td>";
135 $account = (isset($user->user->account)) ? "<a href=\"".BASE_URL."users/?account=".$user->user->account."\">".$user->user->account."</a>" : '<span class="badge rounded-pill badge-primary">None</span>';
136 echo "<td>".$account."</td>";
137 $modes = (isset($user->user->modes)) ? "+" . $user->user->modes : "<none>";
138 echo "<td>".$modes."</td>";
139 $oper = (isset($user->user->operlogin)) ? $user->user->operlogin." <span class=\"badge rounded-pill badge-secondary\">".$user->user->operclass."</span>" : "";
140 if (!strlen($oper))
141 $oper = (strpos($user->user->modes, "S") !== false) ? '<span class="badge rounded-pill badge-warning">Services Bot</span>' : "";
142 echo "<td>".$oper."</td>";
143
144 $secure = (isset($user->tls)) ? "<span class=\"badge rounded-pill badge-success\">Secure</span>" : "<span class=\"badge rounded-pill badge-danger\">Insecure</span>";
145 if (strpos($user->user->modes, "S") !== false)
146 $secure = "";
147 echo "<td>".$secure."</td>";
148 echo "<td>".$user->user->servername."</td>";
149 echo "<td>".$user->user->reputation."</td>";
150 }
151 ?>
152 </tbody></table>
153 <table class="table table-responsive table-light">
154 <tr>
155 <td colspan="2">
156 <label for="bantype">Apply action: </label>
157 <select name="bantype" id="bantype">
158 <option value=""></option>
159 <optgroup label="Bans">
160 <option value="gline">GLine</option>
161 <option value="gzline">GZLine</option>
162 </optgroup>
163 </select></td><td colspan="2">
164 <label for="banlen_w">Duration: </label>
165 <select name="banlen_w" id="banlen_w">
166 <?php
167 for ($i = 0; $i <= 56; $i++)
168 {
169 if (!$i)
170 echo "<option value=\"0w\"></option>";
171 else
172 {
173 $w = ($i == 1) ? "week" : "weeks";
174 echo "<option value=\"$i" . "w\">$i $w" . "</option>";
175 }
176 }
177 ?>
178 </select>
179 <select name="banlen_d" id="banlen_d">
180 <?php
181 for ($i = 0; $i <= 31; $i++)
182 {
183 if (!$i)
184 echo "<option value=\"0d\"></option>";
185 else
186 {
187 $d = ($i == 1) ? "day" : "days";
188 echo "<option value=\"$i" . "d\">$i $d" . "</option>";
189 }
190 }
191 ?>
192 </select>
193 <select name="banlen_h" id="banlen_h">
194 <?php
195 for ($i = 0; $i <= 24; $i++)
196 {
197 if (!$i)
198 echo "<option value=\"0d\"></option>";
199 else
200 {
201 $h = ($i == 1) ? "hour" : "hours";
202 echo "<option value=\"$i" . "h\">$i $h" . "</option>";
203 }
204 }
205
206 ?>
207 </select><br></td><tr><td colspan="3">
208
209 <label for="ban_reason">Reason: </label>
210 <input class="form-control short-form-control" type="text" name="ban_reason" id="ban_reason" value="No reason">
211 <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
212 Apply ban
213 </button></td></table>
214 <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
215 <div class="modal-dialog modal-dialog-centered" role="document">
216 <div class="modal-content">
217 <div class="modal-header">
218 <h5 class="modal-title" id="myModalLabel">Apply ban</h5>
219 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
220 <span aria-hidden="true">&times;</span>
221 </button>
222 </div>
223 <div class="modal-body">
224 Are you sure you want to do this?
225
226 </div>
227 <div class="modal-footer">
228 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
229 <button type="submit" action="post" class="btn btn-danger">Ban</button>
230
231 </div>
232 </div>
233 </div>
234 </div>
235
236 </form>
237
238 </div>
239
240 <script>
241
242 $("#myModal").on('shown.bs.modal', function(){
243 $("#CloseButton").focus();
244 });
245 </script>
246
247 <?php require_once UPATH.'/footer.php'; ?>