]>
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 $tkl = $rpc->serverban()->getAll();
116 <div
class="tkl_add_boxheader">
119 <div
class="tkl_add_form">
121 <form action
="spamfilter.php" method
="post">
122 <div
class="align_label">Entry
: </div
><input
class="input_text" type
="text" id
="sf_add" name
="sf_add"><br
>
123 <div
class="align_label">MatchType
: </div
><select name
="matchtype" id
="matchtype">
124 <option value
="simple">Simple
</option
>
125 <option value
="regex">Regular Expression
</option
>
127 <div
class="align_label">Action
: </div
><select name
="sf_bantype" id
="sf_bantype">
128 <option value
=""></option
>
129 <optgroup label
="Bans">
130 <option value
="kline">Kill
Line (KLine
)</option
>
131 <option value
="gline">Global Kill
Line (GLine
)</option
>
132 <option value
="zline">Zap
Line (ZLine
)</option
>
133 <option value
="gzline">Global Zap
Line (GZLine
)</option
>
136 <optgroup label
="Restrictions">
137 <option value
="tempshun">Temporary
Shun (Session only
)</option
>
138 <option value
="shun">Shun
</option
>
139 <option value
="block">Block
</option
>
140 <option value
="dccblock">DCC Block
</option
>
141 <option value
="viruschan">Send to
"Virus Chan"</option
>
143 <optgroup label
="Other">
144 <option value
="warn">Warn the user
</option
>
148 <div
class="align_label"><label
for="banlen_w">Targets
: </label
></div
>
149 <input type
="checkbox" class="input_text" id
="target_channel" name
="target_channel">Channel messages
<br
>
150 <div
class="align_label"><label
></label
></div
><input type
="checkbox" class="input_text" id
="target_private" name
="target_private">Private messages
<br
>
151 <div
class="align_label"><label
></label
></div
><input type
="checkbox" class="input_text" id
="target_channel_notice" name
="target_channel_notice">Channel notices
<br
>
152 <div
class="align_label"><label
></label
></div
><input type
="checkbox" class="input_text" id
="target_private_notice" name
="target_private_notice">Private notices
<br
>
153 <div
class="align_label"><label
></label
></div
><input type
="checkbox" class="input_text" id
="target_part" name
="target_part">Part reason
<br
>
154 <div
class="align_label"><label
></label
></div
><input type
="checkbox" class="input_text" id
="target_dcc" name
="target_dcc">DCC Filename
<br
>
155 <div
class="align_label"><label
></label
></div
><input type
="checkbox" class="input_text" id
="target_away" name
="target_away">Away messages
<br
>
156 <div
class="align_label"><label
></label
></div
><input type
="checkbox" class="input_text" id
="target_topic" name
="target_topic">Channel topic
<br
>
157 <div
class="align_label"><label
></label
></div
><input type
="checkbox" class="input_text" id
="target_messagetag" name
="target_messagetag">MessageTags
<br
>
158 <div
class="align_label"><label
></label
></div
><input type
="checkbox" class="input_text" id
="target_user" name
="target_user">Userhost (nick
!user
@host
:realname
)<br
>
159 <div
class="align_label"><label
for="banlen_w">Duration
: </label
></div
>
160 <select name
="banlen_w" id
="banlen_w">
162 for ($i = 0; $i <= 56; $i++
)
165 echo "<option value=\"0w\"></option>";
168 $w = ($i == 1) ? "week" : "weeks";
169 echo "<option value=\"$i" . "w\"
>$i $w" . "</option>";
174 <select name
="banlen_d" id
="banlen_d">
176 for ($i = 0; $i <= 31; $i++
)
179 echo "<option value=\"0d\"></option>";
182 $d = ($i == 1) ? "day" : "days";
183 echo "<option value=\"$i" . "d\"
>$i $d" . "</option>";
188 <select name
="banlen_h" id
="banlen_h">
190 for ($i = 0; $i <= 24; $i++
)
193 echo "<option value=\"0d\"></option>";
196 $h = ($i == 1) ? "hour" : "hours";
197 echo "<option value=\"$i" . "h\"
>$i $h" . "</option>";
202 <br
><div
class="align_label"><label
for="ban_reason">Reason
: </label
></div
>
203 <input
class="input_text" type
="text" id
="ban_reason" name
="ban_reason"><br
>
204 <input
class="input_text" type
="checkbox" id
="soft" name
="soft">Don
't affect logged-in users (soft)
205 <div class="align_right_button_tkl_add"><input class="cute_button" type="submit" id="submit" value="Submit"></div>
208 <table class='users_overview
'>
209 <form action="spamfilter.php" method="post">
210 <th><input type="checkbox" label='selectall
' onClick="toggle_sf(this)" />Select all</th>
219 <th>Action Duration</th>
224 foreach(RPC_List::$spamfilter as $sf)
227 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>";
228 echo "<td>".$sf->name."</td>";
229 echo "<td>".$sf->type_string."</td>";
230 echo "<td>".$sf->set_by."</td>";
231 echo "<td>".$sf->set_at_string."</td>";
232 echo "<td>".$sf->expire_at_string."</td>";
233 echo "<td>".$sf->duration_string."</td>";
234 echo "<td>".$sf->match_type."</td>";
235 echo "<td>".$sf->ban_action."</td>";
236 echo "<td>".$sf->ban_duration_string."</td>";
237 for ($i = 0, $targs = ""; $i < strlen($sf->spamfilter_targets); $i++)
239 $c = $sf->spamfilter_targets[$i];
241 $targs .= "Channel, ";
243 $targs .= "Private,";
245 $targs .= "Notice, ";
247 $targs .= "Channel notice, ";
249 $targs .= "Part message, ";
251 $targs .= "Quit message, ";
253 $targs .= "DCC filename, ";
255 $targs .= "Away message, ";
257 $targs .= "Channel topic, ";
259 $targs .= "MessageTag, ";
261 $targs .= "Usermask, ";
263 $targs = rtrim($targs,", ");
264 echo "<td>".$targs."</td>";
265 echo "<td>".$sf->reason."</td>";
268 ?></table><p><input class="cute_button" type="submit" value="Delete selected"></p></form></div></div>
271 <?php require_once 'footer
.php
'; ?>