]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - tkl.php
Change some more labels
[irc/unrealircd/unrealircd-webpanel.git] / tkl.php
1 <?php
2 require_once "common.php";
3
4 require_once "header.php";
5
6 if (!empty($_POST))
7 {
8
9 do_log($_POST);
10
11 if (!empty($_POST['tklch'])) // User has asked to delete these tkls
12 {
13 foreach ($_POST as $key => $value) {
14 foreach ($value as $tok) {
15 $tok = explode(",", $tok);
16 $ban = base64_decode($tok[0]);
17 $type = base64_decode($tok[1]);
18 if ($rpc->serverban()->delete($ban, $type))
19 Message::Success("$type has been removed for $ban");
20 else
21 Message::Fail("Unable to remove $type on $ban: $rpc->error");
22 }
23 }
24 }
25 else if (!($iphost = $_POST['tkl_add']))
26 Message::Fail("No user was specified");
27 else if (!($bantype = (isset($_POST['bantype'])) ? $_POST['bantype'] : false))
28 {
29 Message::Fail("Unable to add Server Ban: No ban type selected");
30 }
31 else /* It did */
32 {
33
34 if ((
35 $bantype == "gline" ||
36 $bantype == "gzline" ||
37 $bantype == "shun" ||
38 $bantype == "eline"
39 ) && strpos($iphost, "@") == false) // doesn't have full mask
40 $iphost = "*@" . $iphost;
41
42 $soft = ($_POST['soft']) ? true : false;
43
44 if ($soft)
45 $iphost = "%" . $iphost;
46 /* duplicate code for now [= */
47 $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL;
48 $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL;
49 $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL;
50 $duration = "";
51 if (!$banlen_d && !$banlen_h && !$banlen_w)
52 $duration .= "0";
53
54 else
55 {
56 if ($banlen_w)
57 $duration .= $banlen_w;
58 if ($banlen_d)
59 $duration .= $banlen_d;
60 if ($banlen_h)
61 $duration .= $banlen_h;
62 }
63 $msg_msg = ($duration == "0" || $duration == "0w0d0h") ? "permanently" : "for ".rpc_convert_duration_string($duration);
64 $reason = (isset($_POST['ban_reason'])) ? $_POST['ban_reason'] : "No reason";
65 if ($rpc->serverban()->add($iphost, $bantype, $duration, $reason))
66 {
67 Message::Success("Host / IP: $iphost has been $bantype" . "d $msg_msg: $reason");
68 }
69 else
70 Message::Fail("The $bantype against \"$iphost\" could not be added: $rpc->error");
71 }
72 }
73
74 $tkl = $rpc->serverban()->getAll();
75 ?>
76 <div class="tkl_add_boxheader">
77 Add Server Ban
78 </div>
79 <div class="tkl_add_form">
80
81 <form action="tkl.php" method="post">
82 <div class="align_label">IP / Host:</div><input class="input_text" type="text" id="tkl_add" name="tkl_add"><br>
83 <div class="align_label">Ban Type:</div><select name="bantype" id="bantype">
84 <option value=""></option>
85 <optgroup label="Bans">
86 <option value="kline">Kill Line (KLine)</option>
87 <option value="gline">Global Kill Line (GLine)</option>
88 <option value="zline">Zap Line (ZLine)</option>
89 <option value="gzline">Global Zap Line (GZLine)</option>
90
91 </optgroup>
92 <optgroup label="Restrictions">
93 <option value="local-qline">Reserve Nick Locally(QLine)</option>
94 <option value="qline">Reserve Nick Globally (QLine)</option>
95 <option value="shun">Shun</option>
96
97 </optgroup>
98 <optgroup label="Settings">
99 <option value="except">Global Exception (ELine)</option>
100 <option value="local-exception">Local Exception (ELine)</option>
101 </optgroup>
102 </select><br>
103 <div class="align_label"><label for="banlen_w">Duration: </label></div>
104 <select name="banlen_w" id="banlen_w">
105 <?php
106 for ($i = 0; $i <= 56; $i++)
107 {
108 if (!$i)
109 echo "<option value=\"0w\"></option>";
110 else
111 {
112 $w = ($i == 1) ? "week" : "weeks";
113 echo "<option value=\"$i" . "w\">$i $w" . "</option>";
114 }
115 }
116 ?>
117 </select>
118 <select name="banlen_d" id="banlen_d">
119 <?php
120 for ($i = 0; $i <= 31; $i++)
121 {
122 if (!$i)
123 echo "<option value=\"0d\"></option>";
124 else
125 {
126 $d = ($i == 1) ? "day" : "days";
127 echo "<option value=\"$i" . "d\">$i $d" . "</option>";
128 }
129 }
130 ?>
131 </select>
132 <select name="banlen_h" id="banlen_h">
133 <?php
134 for ($i = 0; $i <= 24; $i++)
135 {
136 if (!$i)
137 echo "<option value=\"0d\"></option>";
138 else
139 {
140 $h = ($i == 1) ? "hour" : "hours";
141 echo "<option value=\"$i" . "h\">$i $h" . "</option>";
142 }
143 }
144 ?>
145 </select>
146 <br><div class="align_label"><label for="ban_reason">Reason: </label></div>
147 <input class="input_text" type="text" id="ban_reason" name="ban_reason"><br>
148 <input class="input_text" type="checkbox" id="soft" name="soft">Don't affect logged-in users (soft)
149 <div class="align_right_button_tkl_add"><input class="cute_button" type="submit" id="submit" value="Submit"></div>
150 </form>
151 </div>
152 <table class='users_overview'>
153 <form action="tkl.php" method="post">
154 <th><input type="checkbox" label='selectall' onClick="toggle_tkl(this)" />Select all</th>
155 <th>Mask</th>
156 <th>Type</th>
157 <th>Set By</th>
158 <th>Set On</th>
159 <th>Expires</th>
160 <th>Duration</th>
161 <th>Reason</th>
162
163 <?php
164 foreach($tkl as $tkl)
165 {
166 echo "<tr>";
167 echo "<td><input type=\"checkbox\" value='" . base64_encode($tkl->name).",".base64_encode($tkl->type) . "' name=\"tklch[]\"></td>";
168 echo "<td>".$tkl->name."</td>";
169 echo "<td>".$tkl->type_string."</td>";
170 $set_by = ($tkl->set_by == "-config-") ? "<span class=\"badge-pill badge-secondary\">Config</span>" : $tkl->set_by;
171 echo "<td>".$set_by."</td>";
172 echo "<td>".$tkl->set_at_string."</td>";
173 echo "<td>".$tkl->expire_at_string."</td>";
174 echo "<td>".$tkl->duration_string."</td>";
175 echo "<td>".$tkl->reason."</td>";
176 }
177 ?></table><p><input class="cute_button" type="submit" value="Delete selected"></p></form></div></div>
178
179 <?php require_once 'footer.php'; ?>