X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/d3697d8f8f79799acab4238b491578a150015f84..75c101fdf81cf76433e974b2dd9194aadbd75549:/spamfilter.php diff --git a/spamfilter.php b/spamfilter.php index 2d24264..4f28dd0 100644 --- a/spamfilter.php +++ b/spamfilter.php @@ -1,14 +1,85 @@ Array("short_text" => "usermsg", "long_text" => "User message"), + "n"=>Array("short_text" => "usernotice", "long_text" => "User notice"), + "c"=>Array("short_text" => "chanmsg", "long_text" => "Channel message"), + "N"=>Array("short_text" => "channotice", "long_text" => "Channel notice"), + "P"=>Array("short_text" => "part", "long_text" => "Part message"), + "q"=>Array("short_text" => "quit", "long_text" => "Quit message"), + "d"=>Array("short_text" => "dcc", "long_text" => "DCC Filename"), + "a"=>Array("short_text" => "away", "long_text" => "Away message"), + "t"=>Array("short_text" => "topic", "long_text" => "Channel topic"), + "T"=>Array("short_text" => "message-tag", "long_text" => "Message tag"), + "u"=>Array("short_text" => "usermask", "long_text" => "User mask (nick!user@host:realname)"), +); + +function spamfilter_targets_to_string($targets) +{ + GLOBAL $spamfilter_target_info; + + $ret = ''; + for ($i = 0, $targs = ""; $i < strlen($targets); $i++) + { + $c = $targets[$i]; + if (isset($spamfilter_target_info[$c])) + $ret .= $spamfilter_target_info[$c]["short_text"].", "; + else + $ret .= "??, "; + } + $ret = rtrim($ret,", "); + return $ret; +} + +function spamfilter_targets_to_string_with_info($targets) +{ + GLOBAL $spamfilter_target_info; + + $ret = ''; + for ($i = 0, $targs = ""; $i < strlen($targets); $i++) + { + $c = $targets[$i]; + if (isset($spamfilter_target_info[$c])) + $ret .= "".$spamfilter_target_info[$c]["short_text"].", "; + else + $ret .= "??, "; + } + $ret = rtrim($ret,", "); + return $ret; +} + +function spamfilter_target_name_to_char($name) +{ + GLOBAL $spamfilter_target_info; + + foreach ($spamfilter_target_info as $char=>$e) + { + if ($e["short_text"] == $name) + return $char; + } + return false; +} + +function spamfilter_targets_from_array_to_chars($ar) +{ + $ret = ''; + foreach ($ar as $name) + { + $c = spamfilter_target_name_to_char($name); + if ($c !== false) + $ret .= $c; + } + return $ret; +} + if (!empty($_POST)) { do_log($_POST); - if ($sf = $_POST['sf_add']) // if it was a spamfilter entry + if (($sf = (isset($_POST['sf_add'])) ? $_POST['sf_add'] : false)) // if it was a spamfilter entry { /* get targets */ $targets = []; // empty arrae @@ -27,45 +98,7 @@ if (!empty($_POST)) { $bantype = $_POST['sf_bantype']; - $targ_chars = ""; - foreach($targets as $targ) - { - switch ($targ) { - case "channel": - $targ_chars .= "c"; - break; - case "private": - $targ_chars .= "p"; - break; - case "channel-notice": - $targ_chars .= "N"; - break; - case "private-notice": - $targ_chars .= "n"; - break; - case "part": - $targ_chars .= "P"; - break; - case "quit": - $targ_chars .= "q"; - break; - case "dcc": - $targ_chars .= "d"; - break; - case "away": - $targ_chars .= "a"; - break; - case "topic": - $targ_chars .= "t"; - break; - case "messagetag": - $targ_chars .= "T"; - break; - case "user": - $targ_chars .= "u"; - break; - } - } + $targ_chars = spamfilter_targets_from_array_to_chars($targets); /* duplicate code for now [= */ $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL; $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL; @@ -113,18 +146,43 @@ if (!empty($_POST)) $spamfilter = $rpc->spamfilter()->getAll(); ?> -
- Add Spamfilter Entry -
-
+ +

Spamfilter Overview


+

+