Plugin Directory

Changeset 2808130


Ignore:
Timestamp:
10/31/2022 05:00:46 PM (3 years ago)
Author:
aixeiger
Message:

add theme switching notifications

Location:
monitor-login/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • monitor-login/trunk/README.txt

    r2803974 r2808130  
    11=== Monitor Login ===
    22Contributors: aixeiger
    3 Tags: monitor, login, access, access login, monitor login, email, login notifications, notifications
     3Tags: monitor, login, access, access login, monitor login, email, login notifications, notifications, themes, plugins
    44Tested up to: 6.0
    5 Stable tag: 0.1.2
     5Stable tag: 0.1.3
    66Requires PHP: 7.4
    77License: GPLv2 or later
     
    1212== Description ==
    1313
    14 Monitor Login helps you to monitor the user access login to your website, every time than a user log into your website, you will receive a very simply email with the Username, IP address, Browser, Platform and Internet service provider, this help you to maintain informed of where a usually a user login and help you to indentify if a user password is leaked if a login contain data from foreign ip addresses or internet service providers.
     14Monitor Login helps you to monitor the user access login to your website, every time than a user log into your website, you will receive a very simply email with the Username, IP address, Browser, Platform and Internet service provider, this help you to maintain informed of where a usually a user login and help you to indentify if a user password is leaked if a login contain data from foreign ip addresses or internet service providers. And the plugin activation/deactivation/delete notications are included too, as the Theme switch notifications, this can be enabled or disabled in the configurations plugins section
    1515
    1616## How works
     
    2222* And set the new email and save
    2323* On the first installation the email will be the same as the wordpress installation
    24 * On the first installation the plugin notifications will be enabled by default
    25 * Change in this section if you don't want to receive plugins notifications
    26 * On update by default the plugin notifications are disabled
     24* On the first installaiton the plugins and themes notifications are enabled by default
     25* for enable or disable plugins or themes notifications change in this section
    2726
    2827## Changelog
     
    30290.1.1   Add support for notifications for enable/disable/deleted plugins activity
    31300.1.2   25-10-2022      Add support for detect login gate: wp-login.php or XML_RPC, and detect if the user is behind a proxy or vpn
     310.1.3   31-10-2022      Add support for detect theme switching
  • monitor-login/trunk/monitorlogin.php

    r2803974 r2808130  
    55 * Author: TocinoDev
    66 * Author URI: https://tocino.mx
    7  * Version: 0.1.2
     7 * Version: 0.1.3
    88 * Tested up to: 6.0
    99 * Requires PHP: 7.4
  • monitor-login/trunk/src/App.php

    r2803974 r2808130  
    1919        add_action('deactivated_plugin', array($this, 'send_deactivate_plug_alert'), 20, 2);
    2020        add_action('deleted_plugin', array($this, 'send_deleted_plug_alert'), 20, 2);
     21        add_action('switch_theme', array($this, 'send_switch_theme_alert'), 20, 3);
     22        //add_action('after_switch_theme', array($this, 'send_switch_theme_alert'), 20, 2);
    2123    }
    2224
     
    130132            $mailto,
    131133            "[Alert] Login access to your website: ".esc_html($blogname),
    132             $this->get_login_tmpl($blogname, $username, $remote_addr, $gate, $current_browser, $platform, $host, $is_vpn_or_proxy),
     134            $this->get_login_tmpl(
     135                $blogname,
     136                $username,
     137                $remote_addr,
     138                $gate,
     139                $current_browser,
     140                $platform,
     141                $host,
     142                $is_vpn_or_proxy
     143            ),
    133144            array('Content-Type: text/html; charset=UTF-8')
    134145        );
     
    167178            $mailto,
    168179            "[Alert] Plugin activation on your website: ".esc_html($blogname),
    169             $this->get_plug_tmpl("activated", $blogname, $plugin, $user->user_login, $remote_addr, $current_browser, $platform, $host, $is_vpn_or_proxy),
     180            $this->get_plug_tmpl(
     181                "activated",
     182                $blogname,
     183                $plugin,
     184                $user->user_login,
     185                $remote_addr,
     186                $current_browser,
     187                $platform,
     188                $host,
     189                $is_vpn_or_proxy
     190            ),
    170191            array('Content-Type: text/html; charset=UTF-8')
    171192        );
     
    204225            $mailto,
    205226            "[Alert] Plugin deactivation on your website: ".esc_html($blogname),
    206             $this->get_plug_tmpl("deactivated", $blogname, $plugin, $user->user_login, $remote_addr, $current_browser, $platform, $host, $is_vpn_or_proxy),
     227            $this->get_plug_tmpl(
     228                "deactivated",
     229                $blogname,
     230                $plugin,
     231                $user->user_login,
     232                $remote_addr,
     233                $current_browser,
     234                $platform,
     235                $host,
     236                $is_vpn_or_proxy
     237            ),
    207238            array('Content-Type: text/html; charset=UTF-8')
    208239        );
     
    241272            $mailto,
    242273            "[Alert] Plugin deleted on your website: ".esc_html($blogname),
    243             $this->get_plug_tmpl("deleted", $blogname, $plugin, $user->user_login, $remote_addr, $current_browser, $platform, $host, $is_vpn_or_proxy),
     274            $this->get_plug_tmpl(
     275                "deleted",
     276                $blogname,
     277                $plugin,
     278                $user->user_login,
     279                $remote_addr,
     280                $current_browser,
     281                $platform,
     282                $host,
     283                $is_vpn_or_proxy
     284            ),
     285            array('Content-Type: text/html; charset=UTF-8')
     286        );
     287    }
     288
     289    /**
     290     * @param       string      $new_name
     291     * @param       WP_Theme    $new_theme
     292     * @param       WP_Theme    $old_theme
     293     */
     294    public function send_switch_theme_alert($new_name, $new_theme, $old_theme)
     295    //public function send_switch_theme_alert($new_theme, $old_theme)
     296    {
     297        $monitorthemes = get_option('monitorlogin_themes');
     298        if($monitorthemes == 'no')
     299            return;
     300
     301        $mailto = get_option('monitorlogin_email');
     302        if(!$mailto)
     303            return;
     304
     305        $old_name = $old_theme->get('Name');
     306
     307        $user = wp_get_current_user();
     308        $blogname = get_bloginfo('name');
     309        $gate = $this->get_gate();
     310        $remote_addr = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
     311        $browser = new Browser();
     312        $current_browser = $browser->getBrowser();
     313        $platform = $browser->getPlatform();
     314        $host = $this->get_host($remote_addr);
     315        $is_vpn_or_proxy = $this->is_vpn_or_proxy($host);
     316
     317        wp_mail(
     318            $mailto,
     319            "[Alert] Switch theme on your website: ".esc_html($blogname),
     320            $this->get_theme_tmpl(
     321                $blogname,
     322                $new_name,
     323                $old_name,
     324                $user->user_login,
     325                $remote_addr,
     326                $current_browser,
     327                $platform,
     328                $host,
     329                $is_vpn_or_proxy
     330            ),
    244331            array('Content-Type: text/html; charset=UTF-8')
    245332        );
     
    365452    }
    366453
     454    private function get_theme_tmpl($blogname, $new_name, $old_name, $username, $remote_addr, $current_browser, $platform, $host, $is_vpn_or_proxy)
     455    {
     456ob_start();
     457?>
     458<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     459<html xmlns="http://www.w3.org/1999/xhtml">
     460<head>
     461<meta name="viewport" content="width=device-width, initial-scale=1.0" />
     462<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
     463<meta name="color-scheme" content="light">
     464<meta name="supported-color-schemes" content="light">
     465<style>
     466.body{
     467    background: #f0f0f1;
     468    color: #718096;
     469    width: 100%;
     470    text-align: center;
     471}
     472.container{
     473    width: 100%;
     474}
     475.data{
     476    width: 570px;
     477    margin: 0 auto;
     478    background-color: #dde5ed;
     479    padding: 10px 20px;
     480    margin-top: 20px;
     481}
     482.text-center{
     483    text-align: center;
     484}
     485@media(max-width: 480px){
     486    .data{
     487        width: 100%;
     488    }
     489}
     490</style>
     491</head>
     492<body>
     493    <div class="container">
     494        <div class="data">
     495            <p>The active theme has switched from <strong><?php echo esc_html($old_name); ?></strong> to <strong><?php echo esc_html($new_name); ?></strong> on your wordpress website: <strong><?php echo esc_html($blogname); ?></strong></p>
     496            <p>By the User: <strong><?php echo esc_html($username); ?></strong></p>
     497            <p>From the IP: <strong><?php echo esc_html($remote_addr); ?></strong></p>
     498            <p>Browser: <strong><?php echo esc_html($current_browser); ?></strong></p>
     499            <p>Platform: <strong><?php echo esc_html($platform); ?></strong></p>
     500            <p>Internet service provider: <strong><?php echo esc_html($host); ?></strong></p>
     501            <?php if($is_vpn_or_proxy): ?>
     502            <p><strong>[WARNING]</strong> The user is behind a Proxy or VPN</p>
     503            <?php endif; ?>
     504            <p class="text-center">Monitor Login.</p>
     505        </div>
     506    </div>
     507</body>
     508</html>
     509<?php
     510return ob_get_clean();     
     511    }
     512
    367513    public function install()
    368514    {
    369515        update_option('monitorlogin_email', get_option('admin_email'));
    370516        update_option('monitorlogin_plugs', 'yes');
     517        update_option('monitorlogin_themes', 'yes');
    371518    }
    372519
     
    375522        delete_option('monitorlogin_email');
    376523        delete_option('monitorlogin_plugs');
     524        delete_option('monitorlogin_themes');
    377525    }
    378526
     
    381529        register_setting('monitorlogin_settings', 'monitorlogin_email');
    382530        register_setting('monitorlogin_settings', 'monitorlogin_plugs');
     531        register_setting('monitorlogin_settings', 'monitorlogin_themes');
    383532    }
    384533
     
    399548        $monitoremail = get_option('monitorlogin_email');
    400549        $monitorplugs = get_option('monitorlogin_plugs');
     550        $monitorthemes = get_option('monitorlogin_themes');
    401551        ?>
    402552        <div class="wrap">
     
    422572                        </select>
    423573                    </div>
     574                    <div style="margin-top: 25px;">
     575                        <p>Themes switching notifications</p>
     576                    </div>
     577                    <div>
     578                        <select name="monitorlogin_themes">
     579                            <option value="no" <?php if($monitorthemes == 'no'){echo 'selected="selected"';} ?>>No</option>
     580                            <option value="yes" <?php if($monitorthemes == 'yes'){echo 'selected="selected"';} ?>>Yes</option>
     581                        </select>
     582                    </div>
    424583                </div>
    425584                <?php submit_button('save'); ?>
Note: See TracChangeset for help on using the changeset viewer.