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