]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - users/index.php
Users: Scratch the "Secure" column, as it's less useful nowadays that
[irc/unrealircd/unrealircd-webpanel.git] / users / index.php
CommitLineData
e98b5a51 1<?php
c06c1713 2require_once "../inc/common.php";
c06c1713 3require_once "../inc/header.php";
e98b5a51 4
10102cdc
VP
5if (!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'];
65a14aac
VP
12
13 if (isset($_GET['servicesonly']) && !isset($_POST['servicesonly']))
14 $_POST['servicesonly'] = $_GET['servicesonly'];
10102cdc 15}
6b218bea 16
65a14aac
VP
17if (!empty($_POST))
18{
8e3bf75e 19 require_once "../inc/connection.php";
e98b5a51 20 do_log($_POST);
c68cfb17 21 $bantype = (isset($_POST['bantype'])) ? $_POST['bantype'] : NULL;
65a14aac 22
d843c1de 23 if (isset($_POST['userch'])) {
65a14aac
VP
24 foreach ($_POST["userch"] as $user)
25 {
d843c1de 26 $user = $name = base64_decode($user);
65a14aac
VP
27
28 if (!$bantype) /* shouldn't happen? */
29 {
e98b5a51 30 Message::Fail("An error occured");
65a14aac
VP
31 }
32
33 else
34 {
d843c1de
VP
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);
65a14aac 51
0d846731 52 if (!$user && $bantype !== "qline") {
d843c1de 53 Message::Fail("Could not find that user: User not online");
65a14aac
VP
54 }
55
56 else
57 {
d843c1de
VP
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";
65a14aac 60
0d846731
VP
61 if ($bantype == "qline")
62 $rpc->nameban()->add($name, $reason, $duration);
65a14aac 63
0b546dde
VP
64 else if ($bantype == "kill")
65 {
66 if ($rpc->user()->kill($user->id, $reason))
67 Message::Success($user->name . "(*@" . $user->hostname . ") has been killed: $reason");
68 else
69 Message::Fail("Could not kill $user->name: $rpc->error");
70 }
0d846731 71 else if ($rpc->serverban()->add($user->id, $bantype, $duration, $reason))
d843c1de 72 Message::Success($user->name . " (*@" . $user->hostname . ") has been $bantype" . "d $msg_msg: $reason");
65a14aac 73
d843c1de
VP
74 else
75 Message::Fail("Could not add $bantype against $name: $rpc->error");
76 }
e98b5a51 77 }
e98b5a51
BM
78 }
79 }
80}
81
e98b5a51 82?>
b111d43c 83<h4>Users Overview</h4>
d1d9caa9 84
62d4ea03 85Click on a username to view more information.
e98b5a51 86
4fa72795 87<div class="usertable">
d1d9caa9 88
e98b5a51 89 <?php
10102cdc 90
e98b5a51
BM
91 if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick']))
92 Message::Info("Listing users which match nick: \"" . $_POST['uf_nick'] . "\"");
93
94 if (isset($_POST['uf_ip']) && strlen($_POST['uf_ip']))
95 Message::Info("Listing users which match IP: \"" . $_POST['uf_ip'] . "\"");
96
97 if (isset($_POST['uf_host']) && strlen($_POST['uf_host']))
98 Message::Info("Listing users which match hostmask: \"" . $_POST['uf_host'] . "\"");
99
100 if (isset($_POST['uf_account']) && strlen($_POST['uf_account']))
101 Message::Info("Listing users which match account: \"" . $_POST['uf_account'] . "\"");
102
a5400f9a
VP
103 if (isset($_POST['uf_server']) && strlen($_POST['uf_server']))
104 Message::Info("Listing users connected to servers matching: \"" . $_POST['uf_server'] . "\"");
105
10102cdc 106
e98b5a51 107 ?>
b111d43c 108
5485abb5 109 <!-- The user list -->
883b1cdf
BM
110 <!-- table id="data_list" class="container-xxl table table-sm table-responsive caption-top table-striped" -->
111 <!-- <table id="data_list" class="table table-striped table-bordered dt-responsive nowrap" style="width:400px"> -->
112 <table id="data_list" class="display responsive nowrap" style="width:100%">
113 <thead>
b111d43c 114 <th scope="col"><input type="checkbox" label='selectall' onClick="toggle_user(this)" /></th>
d1d9caa9 115 <th scope="col">Nick</th>
729a16a0 116 <th class="countrycol" scope="col">Country</th>
d75f6d14 117 <th class="hostname" scope="col">Host / IP</th>
729a16a0
BM
118 <th class="accountcol" 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>
119 <th class="umodescol" scope="col">Usermodes <a href="https://www.unrealircd.org/docs/User_modes" target="_blank">ℹ️</a></th>
d75f6d14 120 <th class="opercol" scope="col">Oper</th>
d75f6d14 121 <th class="uplinkcol" scope="col">Connected to</th>
729a16a0 122 <th class="reputationcol" scope="col"><span id="reputationheader" 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">Rep.</span> <a href="https://www.unrealircd.org/docs/Reputation_score" target="_blank">ℹ️</a></th>
2bc4c695 123 </thead>
5485abb5 124 </table>
e98b5a51 125
5485abb5 126 <!-- User Actions -->
d1d9caa9
VP
127 <table class="table table-responsive table-light">
128 <tr>
129 <td colspan="2">
130 <label for="bantype">Apply action: </label>
e98b5a51
BM
131 <select name="bantype" id="bantype">
132 <option value=""></option>
133 <optgroup label="Bans">
134 <option value="gline">GLine</option>
135 <option value="gzline">GZLine</option>
0b546dde 136 <option value="kill">Kill</option>
e98b5a51 137 </optgroup>
d1d9caa9
VP
138 </select></td><td colspan="2">
139 <label for="banlen_w">Duration: </label>
e98b5a51
BM
140 <select name="banlen_w" id="banlen_w">
141 <?php
142 for ($i = 0; $i <= 56; $i++)
143 {
144 if (!$i)
145 echo "<option value=\"0w\"></option>";
146 else
147 {
148 $w = ($i == 1) ? "week" : "weeks";
149 echo "<option value=\"$i" . "w\">$i $w" . "</option>";
150 }
151 }
152 ?>
153 </select>
154 <select name="banlen_d" id="banlen_d">
155 <?php
156 for ($i = 0; $i <= 31; $i++)
157 {
158 if (!$i)
159 echo "<option value=\"0d\"></option>";
160 else
161 {
162 $d = ($i == 1) ? "day" : "days";
163 echo "<option value=\"$i" . "d\">$i $d" . "</option>";
164 }
165 }
166 ?>
167 </select>
168 <select name="banlen_h" id="banlen_h">
169 <?php
170 for ($i = 0; $i <= 24; $i++)
171 {
172 if (!$i)
173 echo "<option value=\"0d\"></option>";
174 else
175 {
176 $h = ($i == 1) ? "hour" : "hours";
177 echo "<option value=\"$i" . "h\">$i $h" . "</option>";
178 }
179 }
d1d9caa9 180
e98b5a51 181 ?>
0b546dde
VP
182 </select>
183
184 <br></td><tr><td colspan="3">
d1d9caa9
VP
185
186 <label for="ban_reason">Reason: </label>
0b546dde 187 <input class="form-control" type="text" name="ban_reason" id="ban_reason" value="No reason">
8e3bf75e 188 <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#ban_confirmation">
0b546dde 189 Apply
d1d9caa9 190 </button></td></table>
8e3bf75e
BM
191
192 <!-- Ban confirmation modal -->
193 <div class="modal fade" id="ban_confirmation" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
d1d9caa9
VP
194 <div class="modal-dialog modal-dialog-centered" role="document">
195 <div class="modal-content">
196 <div class="modal-header">
8e3bf75e 197 <h5 class="modal-title" id="ban_confirmation_label">Apply ban</h5>
d1d9caa9
VP
198 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
199 <span aria-hidden="true">&times;</span>
200 </button>
201 </div>
202 <div class="modal-body">
203 Are you sure you want to do this?
204
205 </div>
206 <div class="modal-footer">
207 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
0b546dde 208 <button type="submit" action="post" class="btn btn-danger">Apply</button>
d1d9caa9
VP
209
210 </div>
211 </div>
212 </div>
213 </div>
214
e98b5a51 215 </form>
d91b75a2 216
4fa72795
VP
217 <style>
218 #rclickmenu {
219 position: fixed;
220 z-index: 10000;
221 width: 250px;
222 background: #1b1a1a;
223 border-radius: 5px;
cd5d0af0
VP
224 transform: scale(0);
225 transform-origin: top left;
4fa72795
VP
226 }
227 #rclickmenu.visible {
cd5d0af0
VP
228 transform: scale(1);
229 transition: transform 120ms ease-in-out;
4fa72795
VP
230 }
231 #rclickmenu .item {
232 padding: 8px 10px;
233 font-size: 15px;
234 color: #eee;
235 cursor: pointer;
236 border-radius: inherit;
237 }
238 #rclickmenu .item:hover {
239 background: #343434;
240 text-decoration: none;
241 }
242 </style>
243
cd5d0af0 244 <div id='rclickmenu' class="nav-item list-group">
4fa72795
VP
245 <div id="rclick_opt1" class="item list-group-item-action">View details</div>
246 <div id="rclick_opt2" class="item list-group-item-action">Kill</div>
cd5d0af0 247 <div id="rclick_opt3" class="item list-group-item-action">Copy
4fa72795 248 </div>
d91b75a2 249</div>
d1d9caa9
VP
250
251<script>
4fa72795
VP
252 var rclickmenu = document.getElementById('rclickmenu');
253 var scopes = document.querySelectorAll('.userselector');
cd5d0af0 254 document.addEventListener("click", (e) =>
4fa72795 255 {
cd5d0af0
VP
256 if (e.target.offsetParent != rclickmenu)
257 {
258 rclickmenu.classList.remove("visible");
259 }
4fa72795
VP
260 });
261 scopes.forEach((scope) => {
262 scope.addEventListener("contextmenu", (event) =>
263 {
264 event.preventDefault();
265 var { clientX: mouseX, clientY: mouseY } = event;
266 var name = $('#' + scope.id).attr('value')
cd5d0af0 267 document.getElementById("rclick_opt1").innerHTML = 'View details for ' + name;
4fa72795
VP
268 rclickmenu.style.top = `${mouseY}px`;
269 rclickmenu.style.left = `${mouseX}px`;
cd5d0af0
VP
270 rclickmenu.classList.remove("visible");
271 setTimeout(() => { rclickmenu.classList.add("visible"); });
4fa72795 272 });
4fa72795 273 });
cd5d0af0
VP
274 document.addEventListener('keydown', (event) => {
275 if (event.key === 'Escape')
276 {
277 rclickmenu.classList.remove("visible");
278 }
279});
5485abb5
BM
280
281$(document).ready( function () {
8ee706e7 282 args = {
883b1cdf
BM
283 'responsive': true,
284 'fixedHeader': {
285 header: true,
286 headerOffset: 53
287 },
5485abb5
BM
288 'ajax': {
289 'url': '<?php echo get_config("base_url"); ?>api/users.php',
290 dataSrc: ''
291 },
292 'pageLength':100,
293 'order':[[1,'asc']],
5485abb5 294 'columns': [
883b1cdf
BM
295 { 'data': 'Select', 'responsivePriority': 1 },
296 { 'data': 'Nick', 'responsivePriority': 1 },
297 { 'data': 'Country', 'className':'countrycol', 'responsivePriority': 2 },
298 { 'data': 'Host/IP', 'className':'hostname', 'responsivePriority': 5 },
299 { 'data': 'Account', 'className':'accountcol', 'responsivePriority': 3 },
300 { 'data': 'Usermodes', 'className':'umodescol', 'responsivePriority': 7 },
301 { 'data': 'Oper', 'className':'opercol', 'responsivePriority': 8 },
883b1cdf
BM
302 { 'data': 'Connected to', 'className':'uplinkcol', 'responsivePriority': 6 },
303 { 'data': 'Reputation', 'className':'reputationcol', 'responsivePriority': 4 },
5485abb5 304 ],
8ee706e7
BM
305 };
306 /* Hide on mobile */
307 if (window.innerWidth > 800)
308 {
309 args['dom'] = 'Pfrtip';
310 args['searchPanes'] = {
311 'initCollapsed': 'true',
312 'columns': [2,8],
313 'dtOpts': {
314 select: { style: 'multi'},
315 order: [[ 1, "desc" ]]
316 },
317 }
318 }
319
320 $('#data_list').DataTable(args);
5485abb5
BM
321} );
322
d1d9caa9 323</script>
e98b5a51 324
c06c1713 325<?php require_once UPATH.'/inc/footer.php'; ?>