unrealircd / unrealircd-webpanel

An administration webpanel for UnrealIRCd
https://www.unrealircd.org/docs/UnrealIRCd_webpanel
GNU General Public License v3.0
22 stars 10 forks source link

Plugin Top Countries and update header.php #21

Closed Madriix closed 1 year ago

ValwareIRC commented 1 year ago

Hi Madriix,

This looks like a fun plugin I must say, even though the author says it's made by me apparently ;D

Though I do have to let you know a couple of things, with apologies in advance:

It's exciting to see someone wanting to contribute to the webpanel so soon, so I thank you, but unfortunately cannot merge this.

That said, I would like to invite you to the webpanel development & discussion channel on the UnrealIRCd support network, it would be cool to have you there.

You can join at irc.unrealircd.org on the usual ports, in #unrealircd-webpanel

Hope to see you there!

Madriix commented 1 year ago

Hi @ValwareIRC Ok for the Top Countries, it helps me to see this stat

This morning I tried to learn how to make plugins, I made a 2nd one, it's very small, it just adds a new button in the Spamfilter page.

For a few months I have been using this in MySQL to list all the "" characters that do not have a "." before : `SELECT FROM sysop_gline_kline WHERE raw='spamfilter' and mask REGEXP '(?<!\.)\*' ORDER BY id DESC; `

With the plugin I then added a "Find" button which lists all "*" without "." before. As soon as it finds, just check the characters and update them on IRC with /spamfilter

Here is the plugin: folder: button_find_regex_for_page_spamfilter In this folder add: index.php <?php In this folder add: button_find_regex_for_page_spamfilter.php

<?php

class button_find_regex_for_page_spamfilter
{
    public $name = "button find regex for page spamfilter";
    public $author = "Valware";
    public $version = "1.0";
    public $description = "For page spamfilter, button find regex without '.' before_'*'. Ideal for locating typos because in case of error it blacklists the world.";
    public $email = "v.a.pond@outlook.com";

    function __construct()
    {
        if (preg_match("/(\/spamfilter.php)/i", $_SERVER['PHP_SELF'])) {
            Hook::func(HOOKTYPE_FOOTER, 'button_find_regex_for_page_spamfilter::add');
        }
    }

    public static function add(&$empty)
    {
        echo '
        <style>
        .hidden {
            display: none;
        }
        </style>
        <script>
            $("#main_contain > p").append("<button type=\"button\" class=\"btn btn-primary ml-4 find-mask\">Find masks without \'.\' before \'*\'</button>");

            $(".find-mask" ).click(function() {
                var regex = /(?<!\.)\*/;
                $("#main_contain table tbody tr").each(function() {
                  var col2Value = $(this).find("td").eq(2).text();
                  if (regex.test(col2Value)) {
                    $(this).find("td").parent().removeClass("hidden");
                  } else {
                    $(this).find("td").parent().addClass("hidden");
                  }
                });
            });
        </script>';
    }
}

It can be useful from time to time to search in mass for regex problems