]>
jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - spamfilter.php
2 require_once "common.php";
4 require_once "header.php";
11 if (($sf = (isset($_POST['sf_add'])) ? $_POST['sf_add'] : false)) // 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">Match
 
;type
: </div
> <select name
="matchtype" id
="matchtype">
134 <option value
="simple">Simple
</option
>
135 <option value
="regex">Regular Expression
</option
>
137 <div
class="align_label curvy">Entry
: </div
> <input
class="curvy" type
="text" id
="sf_add" name
="sf_add"><br
>
139 <div
class="align_label curvy"><label
for="banlen_w">Targets
: </label
></div
>
141 <input type
="checkbox" class="curvy" id
="target_channel" name
="target_channel">Channel messages
<br
>
142 <div
class="align_label curvy"><label
></label
></div
><input type
="checkbox" class="curvy" id
="target_private" name
="target_private">Private messages
<br
>
143 <div
class="align_label curvy"><label
></label
></div
><input type
="checkbox" class="curvy" id
="target_channel_notice" name
="target_channel_notice">Channel notices
<br
>
144 <div
class="align_label curvy"><label
></label
></div
><input type
="checkbox" class="curvy" id
="target_private_notice" name
="target_private_notice">Private notices
<br
>
145 <div
class="align_label curvy"><label
></label
></div
><input type
="checkbox" class="curvy" id
="target_part" name
="target_part">Part reason
<br
>
146 <div
class="align_label curvy"><label
></label
></div
><input type
="checkbox" class="curvy" id
="target_dcc" name
="target_dcc">DCC Filename
<br
>
147 <div
class="align_label curvy"><label
></label
></div
><input type
="checkbox" class="curvy" id
="target_away" name
="target_away">Away messages
<br
>
148 <div
class="align_label curvy"><label
></label
></div
><input type
="checkbox" class="curvy" id
="target_topic" name
="target_topic">Channel topic
<br
>
149 <div
class="align_label curvy"><label
></label
></div
><input type
="checkbox" class="curvy" id
="target_messagetag" name
="target_messagetag">MessageTags
<br
>
150 <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
>
152 <div
class="align_label curvy">Action
: </div
> <select name
="sf_bantype" id
="sf_bantype">
153 <option value
=""></option
>
154 <optgroup label
="Bans">
155 <option value
="kline">Kill
Line (KLine
)</option
>
156 <option value
="gline">Global Kill
Line (GLine
)</option
>
157 <option value
="zline">Zap
Line (ZLine
)</option
>
158 <option value
="gzline">Global Zap
Line (GZLine
)</option
>
161 <optgroup label
="Restrictions">
162 <option value
="tempshun">Temporary
Shun (Session only
)</option
>
163 <option value
="shun">Shun
</option
>
164 <option value
="block">Block
</option
>
165 <option value
="dccblock">DCC Block
</option
>
166 <option value
="viruschan">Send to
"Virus Chan"</option
>
168 <optgroup label
="Other">
169 <option value
="warn">Warn the user
</option
>
172 <div
class="align_label curvy"><label
for="banlen_w">Duration
: </label
></div
>
173 <select name
="banlen_w" id
="banlen_w">
175 for ($i = 0; $i <= 56; $i++
)
178 echo "<option value=\"0w\"></option>";
181 $w = ($i == 1) ? "week" : "weeks";
182 echo "<option value=\"$i" . "w\"
>$i $w" . "</option>";
187 <select name
="banlen_d" id
="banlen_d">
189 for ($i = 0; $i <= 31; $i++
)
192 echo "<option value=\"0d\"></option>";
195 $d = ($i == 1) ? "day" : "days";
196 echo "<option value=\"$i" . "d\"
>$i $d" . "</option>";
201 <select name
="banlen_h" id
="banlen_h">
203 for ($i = 0; $i <= 24; $i++
)
206 echo "<option value=\"0d\"></option>";
209 $h = ($i == 1) ? "hour" : "hours";
210 echo "<option value=\"$i" . "h\"
>$i $h" . "</option>";
215 <input
class="curvy" type
="checkbox" id
="soft" name
="soft">Don
't affect logged-in users (soft)
216 <br><div class="align_label curvy"><label for="ban_reason">Reason: </label></div>
217 <input class="curvy" type="text" id="ban_reason" name="ban_reason"><br>
220 <div class="modal-footer">
221 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
222 <button type="submit" action="post" class="btn btn-danger">Add Spamfilter Entry</button>
224 </div></div></div></div>
227 <table class="table table-responsive caption-top table-striped">
228 <thead class="table-primary"><form action="spamfilter.php" method="post">
229 <th><input type="checkbox" label='selectall
' onClick="toggle_sf(this)" /></th>
234 <th>Action Duration</th>
241 foreach($spamfilter as $sf)
244 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>";
245 echo "<td>".$sf->match_type."</td>";
246 echo "<td>".$sf->name."</td>";
247 for ($i = 0, $targs = ""; $i < strlen($sf->spamfilter_targets); $i++)
249 $c = $sf->spamfilter_targets[$i];
251 $targs .= "Channel, ";
253 $targs .= "Private,";
255 $targs .= "Notice, ";
257 $targs .= "Channel notice, ";
259 $targs .= "Part message, ";
261 $targs .= "Quit message, ";
263 $targs .= "DCC filename, ";
265 $targs .= "Away message, ";
267 $targs .= "Channel topic, ";
269 $targs .= "MessageTag, ";
271 $targs .= "Usermask, ";
273 $targs = rtrim($targs,", ");
274 echo "<td>".$targs."</td>";
275 echo "<td>".$sf->ban_action."</td>";
276 echo "<td>".$sf->ban_duration_string."</td>";
277 echo "<td>".$sf->reason."</td>";
278 echo "<td>".$sf->set_by."</td>";
279 echo "<td>".$sf->set_at_string."</td>";
282 ?></table><p><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModal2">
285 <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
286 <div class="modal-dialog modal-dialog-centered" role="document">
287 <div class="modal-content">
288 <div class="modal-header">
289 <h5 class="modal-title" id="myModalLabel">Confirm deletion</h5>
290 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
291 <span aria-hidden="true">×</span>
294 <div class="modal-body">
295 Are you sure you want to do this?<br>
296 This cannot be undone.
298 <div class="modal-footer">
299 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
300 <button type="submit" action="post" class="btn btn-danger">Delete</button>
309 <?php require_once 'footer
.php
'; ?>