]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - users.php
added space
[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 $nick = $rpc->user()->get($user);
40 if (!$nick)
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, $bantype, $duration, $reason))
49 {
50 $c = $nick->client;
51 Message::Success($c->name . " (*@".$c->hostname.") has been $bantype" . "d $msg_msg: $reason");
52 }
53 }
54 }
55 }
56
57 /* Get the user list */
58 $users = $rpc->user()->getAll();
59 ?>
60
61 <div id="Users">
62 <table class='users_filter'>
63 <th class="thuf">Filter by: </th>
64 <th>
65 <form action="users.php" method="post">
66 Nick: <input name="uf_nick" id="uf_nick" type="text">
67 <input class="cute_button2" type="submit" value="Search">
68 </form>
69 </th>
70 <th>
71 <form action="" method="post">
72 Hostname: <input name="uf_host" id="uf_host" type="text">
73 <input class="cute_button2" type="submit" value="Search">
74 </form>
75 </th>
76 <th>
77 <form action="" method="post">
78 IP: <input name="uf_ip" id="uf_ip" type="text">
79 <input class="cute_button2" type="submit" value="Search">
80 </form>
81 </th>
82 <th class="thuffer">
83 <form action="" method="post">
84 Account: <input name="uf_account" id="uf_account" type="text">
85 <input class="cute_button2" type="submit" value="Search">
86 </form>
87 </th>
88 </form>
89 </table>
90 <?php
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
103 ?>
104 <table class='users_overview'>
105 <th><input type="checkbox" label='selectall' onClick="toggle_user(this)" />Select all</th>
106 <th>Nick</th>
107 <th>UID</th>
108 <th>Host / IP</th>
109 <th>Account</th>
110 <th>Usermodes <a href="https://www.unrealircd.org/docs/User_modes" target="_blank">ℹ️</a></th>
111 <th>Oper</th>
112 <th>Secure</th>
113 <th>Connected to</th>
114 <th>Reputation <a href="https://www.unrealircd.org/docs/Reputation_score" target="_blank">ℹ️</a></th>
115
116 <form action="users.php" method="post">
117 <?php
118 foreach($users as $user)
119 {
120
121 /* Some basic filtering for NICK */
122 if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick']) &&
123 strpos(strtolower($user->name), strtolower($_POST['uf_nick'])) !== 0 &&
124 strpos(strtolower($user->name), strtolower($_POST['uf_nick'])) == false)
125 continue;
126
127 /* Some basic filtering for HOST */
128 if (isset($_POST['uf_host']) && strlen($_POST['uf_host']) &&
129 strpos(strtolower($user->hostname), strtolower($_POST['uf_host'])) !== 0 &&
130 strpos(strtolower($user->hostname), strtolower($_POST['uf_host'])) == false)
131 continue;
132
133 /* Some basic filtering for IP */
134 if (isset($_POST['uf_ip']) && strlen($_POST['uf_ip']) &&
135 strpos(strtolower($user->ip), strtolower($_POST['uf_ip'])) !== 0 &&
136 strpos(strtolower($user->ip), strtolower($_POST['uf_ip'])) == false)
137 continue;
138
139 /* Some basic filtering for ACCOUNT */
140 if (isset($_POST['uf_account']) && strlen($_POST['uf_account']) &&
141 strpos(strtolower($user->user->account), strtolower($_POST['uf_account'])) !== 0 &&
142 strpos(strtolower($user->user->account), strtolower($_POST['uf_account'])) == false)
143 continue;
144
145 echo "<tr>";
146 echo "<td><input type=\"checkbox\" value='" . base64_encode($user->id)."' name=\"userch[]\"></td>";
147 $isBot = (strpos($user->user->modes, "B") !== false) ? ' <span class="label">Bot</span>' : "";
148 echo "<td>".$user->name.$isBot.'</td>';
149 echo "<td>".$user->id."</td>";
150 echo "<td>".$user->hostname." (".$user->ip.")</td>";
151 $account = (isset($user->user->account)) ? $user->user->account : '<span class="label bluelabel ">None</span>';
152 echo "<td>".$account."</td>";
153 $modes = (isset($user->user->modes)) ? "+" . $user->user->modes : "<none>";
154 echo "<td>".$modes."</td>";
155 $oper = (isset($user->user->operlogin)) ? $user->user->operlogin." <span class=\"label bluelabel\">".$user->user->operclass."</span>" : "";
156 if (!strlen($oper))
157 $oper = (strpos($user->user->modes, "S") !== false) ? '<span class="label secure-connection">Service</span>' : "";
158 echo "<td>".$oper."</td>";
159 $secure = (isset($user->tls)) ? "<span class=\"label secure-connection\">Secure</span>" : "<span class=\"label redlabel\">Insecure</span>";
160 echo "<td>".$secure."</td>";
161 echo "<td>".$user->user->servername."</td>";
162 echo "<td>".$user->user->reputation."</td>";
163 }
164 ?></table>
165 <label for="bantype">Apply action: </label><br>
166 <select name="bantype" id="bantype">
167 <option value=""></option>
168 <optgroup label="Bans">
169 <option value="gline">GLine</option>
170 <option value="gzline">GZLine</option>
171 </optgroup>
172 </select>
173 <br>
174 <label for="banlen_w">Duration: </label><br>
175 <select name="banlen_w" id="banlen_w">
176 <?php
177 for ($i = 0; $i <= 56; $i++)
178 {
179 if (!$i)
180 echo "<option value=\"0w\"></option>";
181 else
182 {
183 $w = ($i == 1) ? "week" : "weeks";
184 echo "<option value=\"$i" . "w\">$i $w" . "</option>";
185 }
186 }
187 ?>
188 </select>
189 <select name="banlen_d" id="banlen_d">
190 <?php
191 for ($i = 0; $i <= 31; $i++)
192 {
193 if (!$i)
194 echo "<option value=\"0d\"></option>";
195 else
196 {
197 $d = ($i == 1) ? "day" : "days";
198 echo "<option value=\"$i" . "d\">$i $d" . "</option>";
199 }
200 }
201 ?>
202 </select>
203 <select name="banlen_h" id="banlen_h">
204 <?php
205 for ($i = 0; $i <= 24; $i++)
206 {
207 if (!$i)
208 echo "<option value=\"0d\"></option>";
209 else
210 {
211 $h = ($i == 1) ? "hour" : "hours";
212 echo "<option value=\"$i" . "h\">$i $h" . "</option>";
213 }
214 }
215 ?>
216 </select>
217 <br><label for="ban_reason">Reason:<br></label>
218 <textarea name="ban_reason" id="ban_reason">No reason</textarea><br>
219 <input class="cute_button" type="submit" value="Apply">
220 </form>
221
222 </div
223 </div>
224
225 <?php require_once 'footer.php'; ?>