]>
jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - spamfilter.php
2 require_once "common.php";
4 require_once "header.php";
11 if ($sf = $_POST['sf_add']) // if it was a spamfilter entry
14 $targets = []; // empty arrae
15 foreach($_POST as $key => $value)
17 if (substr($key, 0, 7) == "target_")
18 $targets[] = str_replace(["target_", "_"], ["", "-"], $key);
21 Message
::Fail("No target was specified");
23 if (!isset($_POST['sf_bantype']))
24 Message
::Fail("No action was chosen");
29 $bantype = $_POST['sf_bantype'];
31 foreach($targets as $targ)
40 case "channel-notice":
43 case "private-notice":
69 /* duplicate code for now [= */
70 $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL;
71 $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL;
72 $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL;
74 if (!$banlen_d && !$banlen_h && !$banlen_w)
80 $duration .= $banlen_w;
82 $duration .= $banlen_d;
84 $duration .= $banlen_h;
86 $match_type = $_POST['matchtype']; // should default to 'simple'
87 $reason = isset($_POST['ban_reason']) ? $_POST['ban_reason'] : "No reason";
88 $soft = (isset($_POST['soft'])) ? true : false;
90 $targ_chars = "%" . $targ_chars;
91 if ($rpc->spamfilter()->add($sf, $match_type, $targ_chars, $bantype, $duration, $reason))
92 Message
::Success("Added spamfilter entry \"$sf\" [match type: $match_type] [targets: $targ_chars] [reason: $reason]");
94 Message
::Fail("Could not add spamfilter entry \"$sf\" [match type: $match_type] [targets: $targ_chars] [reason: $reason]: $rpc->error");
97 else if (!empty($_POST['sf']))
98 foreach ($_POST as $key => $value)
99 foreach ($value as $tok)
101 $tok = explode(",", $tok);
102 $name = base64_decode($tok[0]);
103 $match_type = base64_decode($tok[1]);
104 $spamfilter_targets = base64_decode($tok[2]);
105 $ban_action = base64_decode($tok[3]);
106 if ($rpc->spamfilter()->delete($name, $match_type, $spamfilter_targets, $ban_action))
107 Message
::Success("Spamfilter on $name has been removed");
109 Message
::Fail("Unable to remove spamfilter on $name: $rpc->error");
114 $spamfilter = $rpc->spamfilter()->getAll();
117 <h4
>Spamfilter Overview
</h4
><br
>
118 <p
><button type
="button" class="btn btn-primary" data
-toggle
="modal" data
-target
="#myModal">
121 <div
class="modal fade" id
="myModal" tabindex
="-1" role
="dialog" aria
-labelledby
="confirmModalCenterTitle" aria
-hidden
="true">
122 <div
class="modal-dialog modal-dialog-centered" role
="document">
123 <div
class="modal-content">
124 <div
class="modal-header">
125 <h5
class="modal-title" id
="myModalLabel">Add
new Spamfilter Entry
</h5
>
126 <button type
="button" class="close" data
-dismiss
="modal" aria
-label
="Close">
127 <span aria
-hidden
="true">×
;</span
>
130 <div
class="modal-body">
132 <form action
="spamfilter.php" method
="post">
133 <div
class="align_label curvy">Entry
: </div
> <input
class="curvy" type
="text" id
="sf_add" name
="sf_add"><br
>
134 <div
class="align_label curvy">MatchType
: </div
> <select name
="matchtype" id
="matchtype">
135 <option value
="simple">Simple
</option
>
136 <option value
="regex">Regular Expression
</option
>
138 <div
class="align_label curvy">Action
: </div
> <select name
="sf_bantype" id
="sf_bantype">
139 <option value
=""></option
>
140 <optgroup label
="Bans">
141 <option value
="kline">Kill
Line (KLine
)</option
>
142 <option value
="gline">Global Kill
Line (GLine
)</option
>
143 <option value
="zline">Zap
Line (ZLine
)</option
>
144 <option value
="gzline">Global Zap
Line (GZLine
)</option
>
147 <optgroup label
="Restrictions">
148 <option value
="tempshun">Temporary
Shun (Session only
)</option
>
149 <option value
="shun">Shun
</option
>
150 <option value
="block">Block
</option
>
151 <option value
="dccblock">DCC Block
</option
>
152 <option value
="viruschan">Send to
"Virus Chan"</option
>
154 <optgroup label
="Other">
155 <option value
="warn">Warn the user
</option
>
159 <div
class="align_label curvy"><label
for="banlen_w">Targets
: </label
></div
>
161 <input type
="checkbox" class="curvy" id
="target_channel" name
="target_channel">Channel messages
<br
>
162 <div
class="align_label curvy"><label
></label
></div
><input type
="checkbox" class="curvy" id
="target_private" name
="target_private">Private messages
<br
>
163 <div
class="align_label curvy"><label
></label
></div
><input type
="checkbox" class="curvy" id
="target_channel_notice" name
="target_channel_notice">Channel notices
<br
>
164 <div
class="align_label curvy"><label
></label
></div
><input type
="checkbox" class="curvy" id
="target_private_notice" name
="target_private_notice">Private notices
<br
>
165 <div
class="align_label curvy"><label
></label
></div
><input type
="checkbox" class="curvy" id
="target_part" name
="target_part">Part reason
<br
>
166 <div
class="align_label curvy"><label
></label
></div
><input type
="checkbox" class="curvy" id
="target_dcc" name
="target_dcc">DCC Filename
<br
>
167 <div
class="align_label curvy"><label
></label
></div
><input type
="checkbox" class="curvy" id
="target_away" name
="target_away">Away messages
<br
>
168 <div
class="align_label curvy"><label
></label
></div
><input type
="checkbox" class="curvy" id
="target_topic" name
="target_topic">Channel topic
<br
>
169 <div
class="align_label curvy"><label
></label
></div
><input type
="checkbox" class="curvy" id
="target_messagetag" name
="target_messagetag">MessageTags
<br
>
170 <div
class="align_label curvy"><label
></label
></div
><input type
="checkbox" class="curvy" id
="target_user" name
="target_user">Userhost (nick
!user
@host
:realname
)<br
>
171 <div
class="align_label curvy"><label
for="banlen_w">Duration
: </label
></div
>
172 <select name
="banlen_w" id
="banlen_w">
174 for ($i = 0; $i <= 56; $i++
)
177 echo "<option value=\"0w\"></option>";
180 $w = ($i == 1) ? "week" : "weeks";
181 echo "<option value=\"$i" . "w\"
>$i $w" . "</option>";
186 <select name
="banlen_d" id
="banlen_d">
188 for ($i = 0; $i <= 31; $i++
)
191 echo "<option value=\"0d\"></option>";
194 $d = ($i == 1) ? "day" : "days";
195 echo "<option value=\"$i" . "d\"
>$i $d" . "</option>";
200 <select name
="banlen_h" id
="banlen_h">
202 for ($i = 0; $i <= 24; $i++
)
205 echo "<option value=\"0d\"></option>";
208 $h = ($i == 1) ? "hour" : "hours";
209 echo "<option value=\"$i" . "h\"
>$i $h" . "</option>";
214 <br
><div
class="align_label curvy"><label
for="ban_reason">Reason
: </label
></div
>
215 <input
class="curvy" type
="text" id
="ban_reason" name
="ban_reason"><br
>
216 <input
class="curvy" type
="checkbox" id
="soft" name
="soft">Don
't affect logged-in users (soft)
219 <div class="modal-footer">
220 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
221 <button type="submit" action="post" class="btn btn-danger">Add Spamfilter Entry</button>
223 </div></div></div></div>
226 <table class="table table-responsive caption-top table-striped">
227 <thead class="table-primary"><form action="spamfilter.php" method="post">
228 <th><input type="checkbox" label='selectall
' onClick="toggle_sf(this)" />Select all</th>
237 <th>Action Duration</th>
243 foreach($spamfilter as $sf)
246 echo "<td><input type=\"checkbox\" value='" . base64_encode($sf->name).",".base64_encode($sf->match_type).",".base64_encode($sf->spamfilter_targets).",".base64_encode($sf->ban_action) . "' name=\"sf[]\"></td>";
247 echo "<td>".$sf->name."</td>";
248 echo "<td>".$sf->type_string."</td>";
249 echo "<td>".$sf->set_by."</td>";
250 echo "<td>".$sf->set_at_string."</td>";
251 echo "<td>".$sf->expire_at_string."</td>";
252 echo "<td>".$sf->duration_string."</td>";
253 echo "<td>".$sf->match_type."</td>";
254 echo "<td>".$sf->ban_action."</td>";
255 echo "<td>".$sf->ban_duration_string."</td>";
256 for ($i = 0, $targs = ""; $i < strlen($sf->spamfilter_targets); $i++)
258 $c = $sf->spamfilter_targets[$i];
260 $targs .= "Channel, ";
262 $targs .= "Private,";
264 $targs .= "Notice, ";
266 $targs .= "Channel notice, ";
268 $targs .= "Part message, ";
270 $targs .= "Quit message, ";
272 $targs .= "DCC filename, ";
274 $targs .= "Away message, ";
276 $targs .= "Channel topic, ";
278 $targs .= "MessageTag, ";
280 $targs .= "Usermask, ";
282 $targs = rtrim($targs,", ");
283 echo "<td>".$targs."</td>";
284 echo "<td>".$sf->reason."</td>";
287 ?></table><p><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModal2">
290 <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
291 <div class="modal-dialog modal-dialog-centered" role="document">
292 <div class="modal-content">
293 <div class="modal-header">
294 <h5 class="modal-title" id="myModalLabel">Delete</h5>
295 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
296 <span aria-hidden="true">×</span>
299 <div class="modal-body">
300 Are you sure you want to do this?<br>
301 This cannot be undone.
303 <div class="modal-footer">
304 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
305 <button type="submit" action="post" class="btn btn-danger">Delete</button>
314 <?php require_once 'footer
.php
'; ?>