]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - users.php
Make the navbar look a little smarter
[irc/unrealircd/unrealircd-webpanel.git] / users.php
1 <?php
2 require_once "common.php";
3
4 require_once "header.php";
5
6 if (!empty($_POST))
7 {
8 do_log($_POST);
9 $bantype = $_POST['bantype'];
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
39 $user = $rpc->user()->get($user);
40 if (!$user)
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";
48 if ($rpc->serverban()->add($user->id, $bantype, $duration, $reason))
49 Message::Success($user->name . " (*@".$user->hostname.") has been $bantype" . "d $msg_msg: $reason");
50 }
51 }
52 }
53
54 /* Get the user list */
55 $users = $rpc->user()->getAll();
56 ?>
57
58 <div id="Users">
59 <table class='users_filter'>
60 <th class="thuf">Filter by: </th>
61 <th>
62 <form action="users.php" method="post">
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 ?>
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>
115
116 <tbody>
117 <form action="users.php" method="post">
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>";
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>';
154 echo "<td>".$account."</td>";
155 $modes = (isset($user->user->modes)) ? "+" . $user->user->modes : "<none>";
156 echo "<td>".$modes."</td>";
157 $oper = (isset($user->user->operlogin)) ? $user->user->operlogin." <span class=\"label bluelabel\">".$user->user->operclass."</span>" : "";
158 if (!strlen($oper))
159 $oper = (strpos($user->user->modes, "S") !== false) ? '<span class="label secure-connection">Service</span>' : "";
160 echo "<td>".$oper."</td>";
161 //$secure = (isset($user->tls)) ? "<span class=\"label secure-connection\">Secure</span>" : "<span class=\"label redlabel\">Insecure</span>";
162 $secure = (isset($user->tls)) ? "<span class=\"badge-pill badge-success\">Secure</span>" : "<span class=\"badge-pill badge-danger\">Insecure</span>";
163 echo "<td>".$secure."</td>";
164 echo "<td>".$user->user->servername."</td>";
165 echo "<td>".$user->user->reputation."</td>";
166 }
167 ?>
168 </tbody>
169 </table>
170 <label for="bantype">Apply action: </label><br>
171 <select name="bantype" id="bantype">
172 <option value=""></option>
173 <optgroup label="Bans">
174 <option value="gline">GLine</option>
175 <option value="gzline">GZLine</option>
176 </optgroup>
177 </select>
178 <br>
179 <label for="banlen_w">Duration: </label><br>
180 <select name="banlen_w" id="banlen_w">
181 <?php
182 for ($i = 0; $i <= 56; $i++)
183 {
184 if (!$i)
185 echo "<option value=\"0w\"></option>";
186 else
187 {
188 $w = ($i == 1) ? "week" : "weeks";
189 echo "<option value=\"$i" . "w\">$i $w" . "</option>";
190 }
191 }
192 ?>
193 </select>
194 <select name="banlen_d" id="banlen_d">
195 <?php
196 for ($i = 0; $i <= 31; $i++)
197 {
198 if (!$i)
199 echo "<option value=\"0d\"></option>";
200 else
201 {
202 $d = ($i == 1) ? "day" : "days";
203 echo "<option value=\"$i" . "d\">$i $d" . "</option>";
204 }
205 }
206 ?>
207 </select>
208 <select name="banlen_h" id="banlen_h">
209 <?php
210 for ($i = 0; $i <= 24; $i++)
211 {
212 if (!$i)
213 echo "<option value=\"0d\"></option>";
214 else
215 {
216 $h = ($i == 1) ? "hour" : "hours";
217 echo "<option value=\"$i" . "h\">$i $h" . "</option>";
218 }
219 }
220 ?>
221 </select>
222 <br><label for="ban_reason">Reason:<br></label>
223 <textarea name="ban_reason" id="ban_reason">No reason</textarea><br>
224 <input class="cute_button" type="submit" value="Apply">
225 </form>
226
227 </div
228 </div>
229
230 <?php require_once 'footer.php'; ?>