Plugin Directory

Changeset 2803974


Ignore:
Timestamp:
10/25/2022 02:32:55 PM (3 years ago)
Author:
aixeiger
Message:

add support for detect login gate: wp_login.php or XML_RPC, and detect if the user is behind a proxi or vpn

Location:
monitor-login/trunk
Files:
3 edited

Legend:

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

    r2798468 r2803974  
    33Tags: monitor, login, access, access login, monitor login, email, login notifications, notifications
    44Tested up to: 6.0
    5 Stable tag: 0.1.1
     5Stable tag: 0.1.2
    66Requires PHP: 7.4
    77License: GPLv2 or later
     
    2424* On the first installation the plugin notifications will be enabled by default
    2525* Change in this section if you don't want to receive plugins notifications
     26* On update by default the plugin notifications are disabled
    2627
    2728## Changelog
    2829
    29300.1.1   Add support for notifications for enable/disable/deleted plugins activity
     310.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
  • monitor-login/trunk/monitorlogin.php

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

    r2798468 r2803974  
    9595    }
    9696
     97    private function get_gate()
     98    {
     99        $gate = 'wp_login.php';
     100        if(isset($GLOBALS['wp_xmlrpc_server']) && is_object($GLOBALS['wp_xmlrpc_server'])){
     101            $gate = 'xml_rpc';
     102        }
     103
     104        return $gate;
     105    }
     106
     107    private function is_vpn_or_proxy($host)
     108    {
     109        return filter_var($host, FILTER_VALIDATE_IP) ? true : false;
     110    }
     111
    97112    /**
    98113     * @param   string      $username
     
    107122        $host = $this->get_host($remote_addr);
    108123        $blogname = get_bloginfo('name');
     124        $gate = $this->get_gate();
    109125        $mailto = get_option('monitorlogin_email');
     126        $is_vpn_or_proxy = $this->is_vpn_or_proxy($host);
    110127        if(!$mailto)
    111128            return;
     
    113130            $mailto,
    114131            "[Alert] Login access to your website: ".esc_html($blogname),
    115             $this->get_login_tmpl($blogname, $username, $remote_addr, $current_browser, $platform, $host),
     132            $this->get_login_tmpl($blogname, $username, $remote_addr, $gate, $current_browser, $platform, $host, $is_vpn_or_proxy),
    116133            array('Content-Type: text/html; charset=UTF-8')
    117134        );
     
    139156        $user = wp_get_current_user();
    140157        $blogname = get_bloginfo('name');
     158        $gate = $this->get_gate();
    141159        $remote_addr = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
    142160        $browser = new Browser();
     
    144162        $platform = $browser->getPlatform();
    145163        $host = $this->get_host($remote_addr);
     164        $is_vpn_or_proxy = $this->is_vpn_or_proxy($host);
    146165
    147166        wp_mail(
    148167            $mailto,
    149168            "[Alert] Plugin activation on your website: ".esc_html($blogname),
    150             $this->get_plug_tmpl("activated", $blogname, $plugin, $user->user_login, $remote_addr, $current_browser, $platform, $host),
     169            $this->get_plug_tmpl("activated", $blogname, $plugin, $user->user_login, $remote_addr, $current_browser, $platform, $host, $is_vpn_or_proxy),
    151170            array('Content-Type: text/html; charset=UTF-8')
    152171        );
     
    174193        $user = wp_get_current_user();
    175194        $blogname = get_bloginfo('name');
     195        $gate = $this->get_gate();
    176196        $remote_addr = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
    177197        $browser = new Browser();
     
    179199        $platform = $browser->getPlatform();
    180200        $host = $this->get_host($remote_addr);
     201        $is_vpn_or_proxy = $this->is_vpn_or_proxy($host);
    181202
    182203        wp_mail(
    183204            $mailto,
    184205            "[Alert] Plugin deactivation on your website: ".esc_html($blogname),
    185             $this->get_plug_tmpl("deactivated", $blogname, $plugin, $user->user_login, $remote_addr, $current_browser, $platform, $host),
     206            $this->get_plug_tmpl("deactivated", $blogname, $plugin, $user->user_login, $remote_addr, $current_browser, $platform, $host, $is_vpn_or_proxy),
    186207            array('Content-Type: text/html; charset=UTF-8')
    187208        );
     
    209230        $user = wp_get_current_user();
    210231        $blogname = get_bloginfo('name');
     232        $gate = $this->get_gate();
    211233        $remote_addr = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
    212234        $browser = new Browser();
     
    214236        $platform = $browser->getPlatform();
    215237        $host = $this->get_host($remote_addr);
     238        $is_vpn_or_proxy = $this->is_vpn_or_proxy($host);
    216239
    217240        wp_mail(
    218241            $mailto,
    219242            "[Alert] Plugin deleted on your website: ".esc_html($blogname),
    220             $this->get_plug_tmpl("deleted", $blogname, $plugin, $user->user_login, $remote_addr, $current_browser, $platform, $host),
     243            $this->get_plug_tmpl("deleted", $blogname, $plugin, $user->user_login, $remote_addr, $current_browser, $platform, $host, $is_vpn_or_proxy),
    221244            array('Content-Type: text/html; charset=UTF-8')
    222245        );
    223246    }
    224247
    225     private function get_login_tmpl($blogname, $username, $remote_addr, $current_browser, $platform, $host)
     248    private function get_login_tmpl($blogname, $username, $remote_addr, $gate, $current_browser, $platform, $host, $is_vpn_or_proxy)
    226249    {
    227250ob_start();
     
    266289            <p class="text-center">Login Access to your website: <strong><?php echo esc_html($blogname); ?></strong></p>
    267290            <p>The User: <strong><?php echo esc_html($username); ?></strong></p>
     291            <p>From Gate: <strong><?php echo esc_html($gate); ?></strong></p>
    268292            <p>Has logged from the IP: <strong><?php echo esc_html($remote_addr); ?></strong></p>
    269293            <p>Browser: <strong><?php echo esc_html($current_browser); ?></strong></p>
    270294            <p>Platform: <strong><?php echo esc_html($platform); ?></strong></p>
    271295            <p>Internet service provider: <strong><?php echo esc_html($host); ?></strong></p>
     296            <?php if($is_vpn_or_proxy): ?>
     297            <p><strong>[WARNING]</strong> The user is behind a Proxy or VPN</p>
     298            <?php endif; ?>
    272299            <p class="text-center">Monitor Login.</p>
    273300        </div>
     
    279306    }
    280307
    281     private function get_plug_tmpl($status, $blogname, $plugin, $username, $remote_addr, $current_browser, $platform, $host)
     308    private function get_plug_tmpl($status, $blogname, $plugin, $username, $remote_addr, $current_browser, $platform, $host, $is_vpn_or_proxy)
    282309    {
    283310ob_start();
     
    326353            <p>Platform: <strong><?php echo esc_html($platform); ?></strong></p>
    327354            <p>Internet service provider: <strong><?php echo esc_html($host); ?></strong></p>
     355            <?php if($is_vpn_or_proxy): ?>
     356            <p><strong>[WARNING]</strong> The user is behind a Proxy or VPN</p>
     357            <?php endif; ?>
    328358            <p class="text-center">Monitor Login.</p>
    329359        </div>
     
    388418                    <div>
    389419                        <select name="monitorlogin_plugs">
     420                            <option value="no" <?php if($monitorplugs == 'no'){echo 'selected="selected"';} ?>>No</option>
    390421                            <option value="yes" <?php if($monitorplugs == 'yes'){echo 'selected="selected"';} ?>>Yes</option>
    391                             <option value="no" <?php if($monitorplugs == 'no'){echo 'selected="selected"';} ?>>No</option>
    392422                        </select>
    393423                    </div>
Note: See TracChangeset for help on using the changeset viewer.