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