Changeset 2803974
- Timestamp:
- 10/25/2022 02:32:55 PM (3 years ago)
- Location:
- monitor-login/trunk
- Files:
-
- 3 edited
-
README.txt (modified) (2 diffs)
-
monitorlogin.php (modified) (1 diff)
-
src/App.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
monitor-login/trunk/README.txt
r2798468 r2803974 3 3 Tags: monitor, login, access, access login, monitor login, email, login notifications, notifications 4 4 Tested up to: 6.0 5 Stable tag: 0.1. 15 Stable tag: 0.1.2 6 6 Requires PHP: 7.4 7 7 License: GPLv2 or later … … 24 24 * On the first installation the plugin notifications will be enabled by default 25 25 * Change in this section if you don't want to receive plugins notifications 26 * On update by default the plugin notifications are disabled 26 27 27 28 ## Changelog 28 29 29 30 0.1.1 Add support for notifications for enable/disable/deleted plugins activity 31 0.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 5 5 * Author: TocinoDev 6 6 * Author URI: https://tocino.mx 7 * Version: 0.1. 17 * Version: 0.1.2 8 8 * Tested up to: 6.0 9 9 * Requires PHP: 7.4 -
monitor-login/trunk/src/App.php
r2798468 r2803974 95 95 } 96 96 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 97 112 /** 98 113 * @param string $username … … 107 122 $host = $this->get_host($remote_addr); 108 123 $blogname = get_bloginfo('name'); 124 $gate = $this->get_gate(); 109 125 $mailto = get_option('monitorlogin_email'); 126 $is_vpn_or_proxy = $this->is_vpn_or_proxy($host); 110 127 if(!$mailto) 111 128 return; … … 113 130 $mailto, 114 131 "[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), 116 133 array('Content-Type: text/html; charset=UTF-8') 117 134 ); … … 139 156 $user = wp_get_current_user(); 140 157 $blogname = get_bloginfo('name'); 158 $gate = $this->get_gate(); 141 159 $remote_addr = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP); 142 160 $browser = new Browser(); … … 144 162 $platform = $browser->getPlatform(); 145 163 $host = $this->get_host($remote_addr); 164 $is_vpn_or_proxy = $this->is_vpn_or_proxy($host); 146 165 147 166 wp_mail( 148 167 $mailto, 149 168 "[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), 151 170 array('Content-Type: text/html; charset=UTF-8') 152 171 ); … … 174 193 $user = wp_get_current_user(); 175 194 $blogname = get_bloginfo('name'); 195 $gate = $this->get_gate(); 176 196 $remote_addr = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP); 177 197 $browser = new Browser(); … … 179 199 $platform = $browser->getPlatform(); 180 200 $host = $this->get_host($remote_addr); 201 $is_vpn_or_proxy = $this->is_vpn_or_proxy($host); 181 202 182 203 wp_mail( 183 204 $mailto, 184 205 "[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), 186 207 array('Content-Type: text/html; charset=UTF-8') 187 208 ); … … 209 230 $user = wp_get_current_user(); 210 231 $blogname = get_bloginfo('name'); 232 $gate = $this->get_gate(); 211 233 $remote_addr = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP); 212 234 $browser = new Browser(); … … 214 236 $platform = $browser->getPlatform(); 215 237 $host = $this->get_host($remote_addr); 238 $is_vpn_or_proxy = $this->is_vpn_or_proxy($host); 216 239 217 240 wp_mail( 218 241 $mailto, 219 242 "[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), 221 244 array('Content-Type: text/html; charset=UTF-8') 222 245 ); 223 246 } 224 247 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) 226 249 { 227 250 ob_start(); … … 266 289 <p class="text-center">Login Access to your website: <strong><?php echo esc_html($blogname); ?></strong></p> 267 290 <p>The User: <strong><?php echo esc_html($username); ?></strong></p> 291 <p>From Gate: <strong><?php echo esc_html($gate); ?></strong></p> 268 292 <p>Has logged from the IP: <strong><?php echo esc_html($remote_addr); ?></strong></p> 269 293 <p>Browser: <strong><?php echo esc_html($current_browser); ?></strong></p> 270 294 <p>Platform: <strong><?php echo esc_html($platform); ?></strong></p> 271 295 <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; ?> 272 299 <p class="text-center">Monitor Login.</p> 273 300 </div> … … 279 306 } 280 307 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) 282 309 { 283 310 ob_start(); … … 326 353 <p>Platform: <strong><?php echo esc_html($platform); ?></strong></p> 327 354 <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; ?> 328 358 <p class="text-center">Monitor Login.</p> 329 359 </div> … … 388 418 <div> 389 419 <select name="monitorlogin_plugs"> 420 <option value="no" <?php if($monitorplugs == 'no'){echo 'selected="selected"';} ?>>No</option> 390 421 <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>392 422 </select> 393 423 </div>
Note: See TracChangeset
for help on using the changeset viewer.