]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - users.php
Make some badges look better
[irc/unrealircd/unrealircd-webpanel.git] / users.php
CommitLineData
e98b5a51
BM
1<?php
2require_once "common.php";
3
4require_once "header.php";
5
6if (!empty($_POST))
7{
8 do_log($_POST);
fe2a6f27 9 $bantype = $_POST['bantype'];
e98b5a51
BM
10 if (isset($_POST['userch']))
11 {
12 foreach ($_POST["userch"] as $user)
13 {
14 $user = base64_decode($user);
15 $bantype = (isset($_POST['bantype'])) ? $_POST['bantype'] : NULL;
16 if (!$bantype) /* shouldn't happen? */
17 {
18 Message::Fail("An error occured");
19 return;
20 }
21 $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL;
22 $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL;
23 $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL;
24
25 $duration = "";
26 if (!$banlen_d && !$banlen_h && !$banlen_w)
27 $duration .= "0";
28
29 else
30 {
31 if ($banlen_w)
32 $duration .= $banlen_w;
33 if ($banlen_d)
34 $duration .= $banlen_d;
35 if ($banlen_h)
36 $duration .= $banlen_h;
37 }
38
fe633176 39 $user = $rpc->user()->get($user);
6ec00eca 40 if (!$user)
e98b5a51
BM
41 {
42 Message::Fail("Could not find that user. Maybe they disconnected after you clicked this?");
43 return;
44 }
45
46 $msg_msg = ($duration == "0" || $duration == "0w0d0h") ? "permanently" : "for ".rpc_convert_duration_string($duration);
47 $reason = (isset($_POST['ban_reason'])) ? $_POST['ban_reason'] : "No reason";
20e2fb07 48 if ($rpc->serverban()->add($user->id, $bantype, $duration, $reason))
fe633176 49 Message::Success($user->name . " (*@".$user->hostname.") has been $bantype" . "d $msg_msg: $reason");
e98b5a51
BM
50 }
51 }
52}
53
54/* Get the user list */
55$users = $rpc->user()->getAll();
56?>
57
1e6ffd06 58<div id="Users">
e98b5a51
BM
59 <table class='users_filter'>
60 <th class="thuf">Filter by: </th>
61 <th>
fe2a6f27 62 <form action="users.php" method="post">
e98b5a51
BM
63 Nick: <input name="uf_nick" id="uf_nick" type="text">
64 <input class="cute_button2" type="submit" value="Search">
65 </form>
66 </th>
67 <th>
68 <form action="" method="post">
69 Hostname: <input name="uf_host" id="uf_host" type="text">
70 <input class="cute_button2" type="submit" value="Search">
71 </form>
72 </th>
73 <th>
74 <form action="" method="post">
75 IP: <input name="uf_ip" id="uf_ip" type="text">
76 <input class="cute_button2" type="submit" value="Search">
77 </form>
78 </th>
79 <th class="thuffer">
80 <form action="" method="post">
81 Account: <input name="uf_account" id="uf_account" type="text">
82 <input class="cute_button2" type="submit" value="Search">
83 </form>
84 </th>
85 </form>
86 </table>
87 <?php
88 if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick']))
89 Message::Info("Listing users which match nick: \"" . $_POST['uf_nick'] . "\"");
90
91 if (isset($_POST['uf_ip']) && strlen($_POST['uf_ip']))
92 Message::Info("Listing users which match IP: \"" . $_POST['uf_ip'] . "\"");
93
94 if (isset($_POST['uf_host']) && strlen($_POST['uf_host']))
95 Message::Info("Listing users which match hostmask: \"" . $_POST['uf_host'] . "\"");
96
97 if (isset($_POST['uf_account']) && strlen($_POST['uf_account']))
98 Message::Info("Listing users which match account: \"" . $_POST['uf_account'] . "\"");
99
100 ?>
2bc4c695
BM
101
102 <table class="table">
103 <thead>
104 <th><input type="checkbox" label='selectall' onClick="toggle_user(this)" />Select all</th>
105 <th>Nick</th>
106 <th>UID</th>
107 <th>Host / IP</th>
108 <th>Account</th>
109 <th>Usermodes <a href="https://www.unrealircd.org/docs/User_modes" target="_blank">ℹ️</a></th>
110 <th>Oper</th>
111 <th>Secure</th>
112 <th>Connected to</th>
113 <th>Reputation <a href="https://www.unrealircd.org/docs/Reputation_score" target="_blank">ℹ️</a></th>
114 </thead>
e98b5a51 115
2bc4c695 116 <tbody>
7b1ba98c 117 <form action="users.php" method="post">
e98b5a51
BM
118 <?php
119 foreach($users as $user)
120 {
121
122 /* Some basic filtering for NICK */
123 if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick']) &&
124 strpos(strtolower($user->name), strtolower($_POST['uf_nick'])) !== 0 &&
125 strpos(strtolower($user->name), strtolower($_POST['uf_nick'])) == false)
126 continue;
127
128 /* Some basic filtering for HOST */
129 if (isset($_POST['uf_host']) && strlen($_POST['uf_host']) &&
130 strpos(strtolower($user->hostname), strtolower($_POST['uf_host'])) !== 0 &&
131 strpos(strtolower($user->hostname), strtolower($_POST['uf_host'])) == false)
132 continue;
133
134 /* Some basic filtering for IP */
135 if (isset($_POST['uf_ip']) && strlen($_POST['uf_ip']) &&
136 strpos(strtolower($user->ip), strtolower($_POST['uf_ip'])) !== 0 &&
137 strpos(strtolower($user->ip), strtolower($_POST['uf_ip'])) == false)
138 continue;
139
140 /* Some basic filtering for ACCOUNT */
141 if (isset($_POST['uf_account']) && strlen($_POST['uf_account']) &&
142 strpos(strtolower($user->user->account), strtolower($_POST['uf_account'])) !== 0 &&
143 strpos(strtolower($user->user->account), strtolower($_POST['uf_account'])) == false)
144 continue;
145
146 echo "<tr>";
147 echo "<td><input type=\"checkbox\" value='" . base64_encode($user->id)."' name=\"userch[]\"></td>";
148 $isBot = (strpos($user->user->modes, "B") !== false) ? ' <span class="label">Bot</span>' : "";
149 echo "<td>".$user->name.$isBot.'</td>';
150 echo "<td>".$user->id."</td>";
151 echo "<td>".$user->hostname." (".$user->ip.")</td>";
2bc4c695
BM
152 //$account = (isset($user->user->account)) ? $user->user->account : '<span class="label bluelabel ">None</span>';
153 $account = (isset($user->user->account)) ? $user->user->account : '<span class="badge-pill badge-primary">None</span>';
e98b5a51
BM
154 echo "<td>".$account."</td>";
155 $modes = (isset($user->user->modes)) ? "+" . $user->user->modes : "<none>";
156 echo "<td>".$modes."</td>";
58478df1 157 $oper = (isset($user->user->operlogin)) ? $user->user->operlogin." <span class=\"badge-pill badge-info\">".$user->user->operclass."</span>" : "";
e98b5a51 158 if (!strlen($oper))
58478df1 159 $oper = (strpos($user->user->modes, "S") !== false) ? '<span class="badge-pill badge-info">Services Bot</span>' : "";
e98b5a51 160 echo "<td>".$oper."</td>";
58478df1 161
370c7bf4 162 $secure = (isset($user->tls)) ? "<span class=\"badge-pill badge-success\">Secure</span>" : "<span class=\"badge-pill badge-danger\">Insecure</span>";
58478df1
VP
163 if (strpos($user->user->modes, "S") !== false)
164 $secure = "";
e98b5a51
BM
165 echo "<td>".$secure."</td>";
166 echo "<td>".$user->user->servername."</td>";
167 echo "<td>".$user->user->reputation."</td>";
168 }
2bc4c695
BM
169 ?>
170 </tbody>
171 </table>
e98b5a51
BM
172 <label for="bantype">Apply action: </label><br>
173 <select name="bantype" id="bantype">
174 <option value=""></option>
175 <optgroup label="Bans">
176 <option value="gline">GLine</option>
177 <option value="gzline">GZLine</option>
178 </optgroup>
179 </select>
180 <br>
181 <label for="banlen_w">Duration: </label><br>
182 <select name="banlen_w" id="banlen_w">
183 <?php
184 for ($i = 0; $i <= 56; $i++)
185 {
186 if (!$i)
187 echo "<option value=\"0w\"></option>";
188 else
189 {
190 $w = ($i == 1) ? "week" : "weeks";
191 echo "<option value=\"$i" . "w\">$i $w" . "</option>";
192 }
193 }
194 ?>
195 </select>
196 <select name="banlen_d" id="banlen_d">
197 <?php
198 for ($i = 0; $i <= 31; $i++)
199 {
200 if (!$i)
201 echo "<option value=\"0d\"></option>";
202 else
203 {
204 $d = ($i == 1) ? "day" : "days";
205 echo "<option value=\"$i" . "d\">$i $d" . "</option>";
206 }
207 }
208 ?>
209 </select>
210 <select name="banlen_h" id="banlen_h">
211 <?php
212 for ($i = 0; $i <= 24; $i++)
213 {
214 if (!$i)
215 echo "<option value=\"0d\"></option>";
216 else
217 {
218 $h = ($i == 1) ? "hour" : "hours";
219 echo "<option value=\"$i" . "h\">$i $h" . "</option>";
220 }
221 }
222 ?>
223 </select>
224 <br><label for="ban_reason">Reason:<br></label>
225 <textarea name="ban_reason" id="ban_reason">No reason</textarea><br>
226 <input class="cute_button" type="submit" value="Apply">
227 </form>
228
1e6ffd06
BM
229 </div
230</div>
e98b5a51
BM
231
232<?php require_once 'footer.php'; ?>