Changeset 3049313
- Timestamp:
- 03/11/2024 06:12:36 PM (12 months ago)
- Location:
- ip-guard/trunk
- Files:
-
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
ip-guard/trunk/ip-guard.php
r3038844 r3049313 3 3 Plugin Name: IPGuard 4 4 Description: A robust security plugin that empowers administrators to safeguard user accounts by implementing IP address-based lockdowns. 5 Version: 1.2 26 Author: <a href="https:// mydynasty.link">Dynasty</a>5 Version: 1.23 6 Author: <a href="https://wa.link/kemj38">Dynasty</a> 7 7 Contributors: Dynahsty 8 8 Tags: security, block-IP, login-protect, Auth-security, IP-secure … … 17 17 18 18 defined('ABSPATH') or die('No direct access allowed. Kindly exist'); 19 $max_ip_addresses = get_option('ip-guard_max_ip_addresses', 2); 19 $max_ip_addresses = get_option('ip_guard_max_ip_addresses', 2); 20 20 21 define('IP_GUARD_MAX_IP_ADDRESSES', $max_ip_addresses); 21 22 22 define('IP_GUARD_MAX_LOCK_DURATION', 7 * 24 * 60 * 60); 23 23 … … 36 36 37 37 $client_ip = filter_var($_SERVER['REMOTE_ADDR'], FILTER_SANITIZE_STRING); 38 38 39 39 if (filter_var($client_ip, FILTER_VALIDATE_IP)) { 40 40 $escaped_ip = htmlspecialchars($client_ip, ENT_QUOTES, 'UTF-8'); … … 47 47 } 48 48 49 $max_ip_addresses = get_option('ip-guard_max_ip_addresses', 2); 50 51 if (count($stored_ips) > $max_ip_addresses) { 49 $max_ip_addresses = intval(get_option('ip_guard_max_ip_addresses', 2)); 50 51 $all_similar = count(array_unique($stored_ips)) === 1; 52 53 if (!$all_similar && count($stored_ips) >= $max_ip_addresses) { 52 54 ip_guard_lock_user($user->ID); 53 return new WP_Error('account_locked', __('Account locked due to unusual activity. contact our support team.', 'ip-guard'));55 return new WP_Error('account_locked', __('Account locked due to unusual activity. Contact our support team.', 'ip-guard')); 54 56 } 55 57 } … … 57 59 return $user; 58 60 } 59 60 defined('ABSPATH') or die('No direct access allowed. Kindly exist');61 61 62 62 function ip_guard_manually_lock_user($user_id) { … … 88 88 } 89 89 90 91 defined('ABSPATH') or die('No direct access allowed');92 93 90 function ip_guard_lock_user($user_id) { 94 91 if (get_user_meta($user_id, '_account_locked', true)) { … … 160 157 add_action('admin_menu', 'ip_guard_admin_menu'); 161 158 162 163 defined('ABSPATH') or die('No direct access allowed. Kindly exist');164 159 function ip_guard_admin_menu() { 165 160 add_menu_page( … … 206 201 } 207 202 208 defined('ABSPATH') or die('No direct access allowed. Kindly exist');209 203 function ip_guard_dashboard_content() { 210 204 ?> … … 232 226 </div> 233 227 234 <style> 235 .dashboard-container { 236 padding: 20px; 237 background-color: #f8f9fa; 238 border: 1px solid #ddd; 239 border-radius: 8px; 240 margin-bottom: 20px; 241 } 242 243 .dashboard-title { 244 font-family: 'Arial', sans-serif; 245 font-weight: bold; 246 text-transform: uppercase; 247 margin-bottom: 10px; 248 } 249 250 .card-container { 251 display: flex; 252 flex-wrap: wrap; 253 gap: 20px; 254 justify-content: space-between; 255 } 256 257 .card { 258 background-color: #f5f5f5; 259 border: 2px solid #3498db; 260 padding: 30px; 261 box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2); 262 border-radius: 12px; 263 box-sizing: border-box; 264 max-width: 100%; 265 margin-top: 20px; 266 margin-left: auto; 267 margin-right: auto; 268 } 269 270 .user-count, 271 .admin-count, 272 .locked-count { 273 background-color: #007bff; 274 color: #fff; 275 padding: 10px; 276 border-radius: 5px; 277 display: inline-block; 278 } 279 280 .admin-count { 281 background-color: #dc3545; 282 } 283 284 .locked-count { 285 background-color: #28a745; 286 } 287 288 .instructions-container { 289 background-color: #f5f5f5; 290 border: 2px solid #3498db; 291 padding: 30px; 292 box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2); 293 border-radius: 12px; 294 box-sizing: border-box; 295 max-width: 100%; 296 width: 20%; 297 box-sizing: border-box; 298 } 299 </style> 300 </div> 228 <style> 229 .dashboard-container { 230 padding: 20px; 231 background-color: #f8f9fa; 232 border: 1px solid #ddd; 233 border-radius: 8px; 234 margin-bottom: 20px; 235 } 236 237 .dashboard-title { 238 font-family: 'Arial', sans-serif; 239 font-weight: bold; 240 text-transform: uppercase; 241 margin-bottom: 10px; 242 } 243 244 .card-container { 245 display: flex; 246 flex-wrap: wrap; 247 gap: 20px; 248 justify-content: space-between; 249 } 250 251 .card { 252 background-color: #f5f5f5; 253 border: 2px solid #3498db; 254 padding: 30px; 255 box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2); 256 border-radius: 12px; 257 box-sizing: border-box; 258 max-width: 100%; 259 margin-top: 20px; 260 margin-left: auto; 261 margin-right: auto; 262 } 263 264 .user-count, 265 .admin-count, 266 .locked-count { 267 background-color: #007bff; 268 color: #fff; 269 padding: 10px; 270 border-radius: 5px; 271 display: inline-block; 272 } 273 274 .admin-count { 275 background-color: #dc3545; 276 } 277 278 .locked-count { 279 background-color: #28a745; 280 } 281 </style> 301 282 <?php 302 283 } … … 324 305 } 325 306 326 defined('ABSPATH') or die('No direct access allowed. Kindly exist');327 328 307 function ip_guard_admin_page_content() { 329 308 ?> 330 309 <div class="wrap"> 331 <div class="card-container"> 332 <div class="card"> 333 <h1 class="wp-heading-inline"><?php esc_html_e('Locked Accounts', 'ip-guard'); ?></h1> 334 310 <div class="card"> 311 <h1 class="locked-heading"><?php esc_html_e('Locked Accounts', 'ip-guard'); ?></h1> 312 313 <?php 314 if (isset($_GET['action']) && $_GET['action'] === 'unlock_account' && isset($_GET['user_id'])) { 315 $user_id = absint($_GET['user_id']); 316 ip_guard_manually_unlock_user($user_id); 317 ?> 318 <div id="message" class="updated notice is-dismissible"> 319 <p><?php esc_html_e('User account has been successfully unlocked. An email notification has been sent to the user.', 'ip-guard'); ?></p> 320 </div> 335 321 <?php 336 if (isset($_GET['action']) && $_GET['action'] === 'unlock_account' && isset($_GET['user_id'])) { 337 $user_id = absint($_GET['user_id']); 338 ip_guard_manually_unlock_user($user_id); 339 ?> 340 <div id="message" class="updated notice is-dismissible"> 341 <p><?php esc_html_e('User account has been successfully unlocked. An email notification has been sent to the user.', 'ip-guard'); ?></p> 342 </div> 343 <?php 344 } 345 ?> 346 347 <table class="wp-list-table widefat fixed striped"> 322 } 323 ?> 324 325 <div class="table-container"> 326 <table class="ip-guard-table"> 348 327 <thead> 349 328 <tr> 350 <th><?php esc_html_e('User ID', 'ip-guard'); ?></th>351 329 <th><?php esc_html_e('Username', 'ip-guard'); ?></th> 352 330 <th><?php esc_html_e('Locked Type', 'ip-guard'); ?></th> … … 365 343 ?> 366 344 <tr> 367 <td><?php echo esc_html($user->ID); ?></td> 368 <td style="color: #dc3545;"><?php echo esc_html($user->user_login); ?></td> 345 <td><?php echo esc_html($user->user_login); ?></td> 369 346 <td><?php esc_html_e('Manual', 'ip-guard'); ?></td> 370 347 <td> 371 <a class="button unlock-button" href="<?php echo esc_url(add_query_arg(array('action' => 'unlock_account', 'user_id' => $user->ID), admin_url('admin.php?page=ip_guard_admin_page'))); ?>">348 <a class="button button-primary unlock-button" href="<?php echo esc_url(add_query_arg(array('action' => 'unlock_account', 'user_id' => $user->ID), admin_url('admin.php?page=ip_guard_admin_page'))); ?>"> 372 349 <?php esc_html_e('Unlock', 'ip-guard'); ?> 373 350 </a> … … 385 362 ?> 386 363 <tr> 387 <td><?php echo esc_html($user->ID); ?></td> 388 <td style="color: #dc3545;"><?php echo esc_html($user->user_login); ?></td> 364 <td><?php echo esc_html($user->user_login); ?></td> 389 365 <td><?php esc_html_e('Exceeded Limit', 'ip-guard'); ?></td> 390 366 <td> 391 367 <a class="button unlock-button" href="<?php echo esc_url(add_query_arg(array('action' => 'unlock_account', 'user_id' => $user->ID), admin_url('admin.php?page=ip_guard_admin_page'))); ?>"> 392 <?php esc_html_e(' Manual Unlock', 'ip-guard'); ?>368 <?php esc_html_e('Unlock User', 'ip-guard'); ?> 393 369 </a> 394 370 </td> … … 400 376 ?> 401 377 <tr> 402 <td colspan=" 4"><?php esc_html_e('No detected accounts found.', 'ip-guard'); ?></td>378 <td colspan="3"><?php esc_html_e('No detected accounts found.', 'ip-guard'); ?></td> 403 379 </tr> 404 380 <?php … … 409 385 </div> 410 386 </div> 387 <div class="about-plugin-card"> 388 <h2><?php esc_html_e('Locked Account Tab', 'ip-guard'); ?></h2> 389 <p><?php esc_html_e('This page displays a list of locked users with a button for manual unlocking. Automatic unlock is set at 7 days', 'ip-guard'); ?></p> 390 </div> 411 391 </div> 412 <style> 413 .unlock-button { 414 background-color: #28a745 !important; 415 color: #fff !important; 416 } 417 </style> 418 <div class="card about-plugin-card"> 419 <h2><?php esc_html_e('Locked Account Tab', 'ip-guard'); ?></h2> 420 <p><?php esc_html_e('This page displays a list of locked users with a button for manual unlocking. Automatic unlock is set at 7 days', 'ip-guard'); ?></p> 421 </div> 422 </div> 392 423 393 <style> 424 394 .card-container { … … 429 399 } 430 400 431 .card { 401 .card { 402 background-color: #f5f5f5; 403 border: 2px solid #3498db; 404 padding: 30px; 405 box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2); 406 border-radius: 12px; 407 box-sizing: border-box; 408 max-width: 100%; 409 margin-top: 20px; 410 margin-left: auto; 411 margin-right: auto; 412 overflow-x: auto; 413 } 414 415 .locked-heading { 416 font-family: "Arial", sans-serif; 417 font-weight: bold; 418 } 419 420 .table-container { 421 overflow-x: auto; 422 } 423 424 .ip-guard-table { 425 width: 100%; 426 border-collapse: collapse; 427 } 428 429 .ip-guard-table th, 430 .ip-guard-table td { 431 padding: 12px 15px; 432 text-align: left; 433 border-bottom: 1px solid #ddd; 434 } 435 436 .ip-guard-table th { 437 background-color: #3498db; 438 color: #fff; 439 font-weight: bold; 440 } 441 442 .unlock-button { 443 background-color: #0073aa !important; 444 color: #fff !important; 445 padding: 8px 16px; 446 box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); 447 text-decoration: none; 448 border-radius: 4px; 449 } 450 451 .about-plugin-card { 432 452 background-color: #f5f5f5; 433 453 border: 2px solid #3498db; 434 454 padding: 30px; 435 box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2); 436 border-radius: 12px; 455 border-radius: 20px; 437 456 box-sizing: border-box; 438 max-width: 100%; 439 margin-top: 20px; 457 max-width: 70%; 458 margin-top: 30px; 459 overflow-x: auto; 440 460 margin-left: auto; 441 461 margin-right: auto; 442 462 } 443 .about-plugin-card { 444 background-color: #f5f5f5; 445 border: 2px solid #3498db; 446 padding: 30px; 447 box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2); 448 border-radius: 12px; 449 box-sizing: border-box; 450 max-width: 100%; 451 width: 20%; 452 box-sizing: border-box; 453 } 463 464 .about-plugin-card h2, 465 .about-plugin-card p { 466 margin: 0; 467 } 468 454 469 </style> 455 470 <?php 456 471 } 457 458 defined('ABSPATH') or die('No direct access allowed. Kindly exit.');459 472 460 473 function ip_guard_settings_page_content() { … … 552 565 padding: 30px; 553 566 box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2); 554 border-radius: 12px;567 border-radius: 20px; 555 568 box-sizing: border-box; 556 569 max-width: 100%; … … 569 582 } 570 583 571 defined('ABSPATH') or die('No direct access allowed. Kindly exist');572 584 function ip_guard_logs_page_content() { 573 585 ?> 574 586 <div class="wrap"> 575 <div class="card -container">576 < div class="card">577 <h1><?php esc_html_e('IP Logs', 'ip-guard'); ?></h1> 578 579 <table class=" wp-list-table widefat fixed striped">587 <div class="card"> 588 <h1 class="logs-heading"><?php esc_html_e('IP Logs', 'ip-guard'); ?></h1> 589 590 <div class="table-responsive"> 591 <table class="table ip-guard-table"> 580 592 <thead> 581 593 <tr> 582 <th><?php esc_html_e('User ID', 'ip-guard'); ?></th>583 594 <th><?php esc_html_e('Username', 'ip-guard'); ?></th> 584 595 <th><?php esc_html_e('IP Addresses', 'ip-guard'); ?></th> … … 597 608 ?> 598 609 <tr> 599 <td><?php echo esc_html($user->ID); ?></td>600 610 <td><?php echo esc_html($user->user_login); ?></td> 601 611 <td> … … 625 635 ?> 626 636 <tr> 627 <td colspan=" 4"><?php esc_html_e('No logs found.', 'ip-guard'); ?></td>637 <td colspan="3"><?php esc_html_e('No logs found.', 'ip-guard'); ?></td> 628 638 </tr> 629 639 <?php … … 635 645 </div> 636 646 637 <div class="card instructions-container"> 638 <h2><?php esc_html_e('IP Logs Tab', 'ip-guard'); ?></h2> 639 <p><?php esc_html_e('This page displays the total number of IP Addresses connected to the locked account.', 'ip-guard'); ?></p> 640 </div> 641 642 <style> 643 .card-container { 644 display: flex; 645 gap: 20px; 646 justify-content: space-between; 647 flex-wrap: wrap; 648 } 649 650 .card { 651 background-color: #f5f5f5; 652 border: 2px solid #3498db; 653 padding: 30px; 654 box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2); 655 border-radius: 12px; 656 box-sizing: border-box; 657 max-width: 100%; 658 margin-top: 20px; 659 margin-left: auto; 660 margin-right: auto; 661 } 662 663 .wp-list-table { 664 width: 100%; 665 margin-top: 20px; 666 border-collapse: collapse; 667 } 668 669 .wp-list-table thead th, 670 .wp-list-table tbody td { 671 padding: 12px 15px; 672 text-align: left; 673 border-bottom: 1px solid #ddd; 674 } 675 676 .wp-list-table thead th { 677 background-color: #f8f9fa; 678 font-weight: bold; 679 } 680 681 .wp-list-table tbody tr:nth-child(even) { 682 background-color: #f9f9f9; 683 } 684 685 .instructions-container { 647 <div class="instructions-container"> 648 <h2><?php esc_html_e('IP Logs Tab', 'ip-guard'); ?></h2> 649 <p><?php esc_html_e('This page displays the total number of IP Addresses connected to the locked account.', 'ip-guard'); ?></p> 650 </div> 651 </div> 652 653 <style> 654 .card { 686 655 background-color: #f5f5f5; 687 656 border: 2px solid #3498db; … … 691 660 box-sizing: border-box; 692 661 max-width: 100%; 693 width: 20%; 662 margin-top: 20px; 663 margin-left: auto; 664 margin-right: auto; 665 overflow-x: auto; 666 } 667 668 .logs-heading { 669 font-family: Arial, sans-serif; 670 font-weight: bold; 671 } 672 673 .ip-guard-table { 674 width: 100%; 675 } 676 677 .ip-guard-table th, 678 .ip-guard-table td { 679 padding: 12px 15px; 680 text-align: left; 681 border-bottom: 1px solid #ddd; 682 } 683 684 .ip-guard-table th { 685 background-color: #3498db; 686 color: #fff; 687 font-weight: bold; 688 } 689 690 .instructions-container { 691 background-color: #f5f5f5; 692 border: 2px solid #3498db; 693 padding: 30px; 694 box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2); 695 border-radius: 20px; 694 696 box-sizing: border-box; 695 } 696 </style> 697 </div> 697 max-width: 100%; 698 margin-top: 30px; 699 overflow-x: auto; 700 width: 70%; 701 margin-left: auto; 702 margin-right: auto; 703 } 704 705 .instructions-container h2, 706 .instructions-container p { 707 margin: 0; 708 } 709 </style> 698 710 <?php 699 711 } 700 712 701 defined('ABSPATH') or die('No direct access allowed. Kindly exist');702 713 function ip_guard_donation_page_content() { 703 714 ?> … … 705 716 <div class="card-container"> 706 717 <div class="card"> 707 <h1 style="font-family: 'Arial', sans-serif;">718 <h1 class="donation-heading"> 708 719 <?php esc_html_e('Donation', 'ip-guard'); ?> 709 720 </h1> … … 727 738 } 728 739 729 .card { 730 background-color: #f5f5f5; 731 border: 2px solid #3498db; 732 padding: 30px; 733 box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2); 734 border-radius: 12px; 735 box-sizing: border-box; 736 max-width: 100%; 737 margin-top: 20px; 738 margin-left: auto; 739 margin-right: auto; 740 } 740 .card { 741 background-color: #f5f5f5; 742 border: 2px solid #3498db; 743 padding: 30px; 744 box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2); 745 border-radius: 12px; 746 box-sizing: border-box; 747 max-width: 100%; 748 margin-top: 20px; 749 margin-left: auto; 750 margin-right: auto; 751 } 752 753 .donation-heading { 754 font-family: 'Arial', sans-serif; 755 font-weight: bold; 756 } 757 741 758 .donation-container { 742 759 background-color: #f8f9fa; … … 749 766 750 767 <?php 751 752 768 } 753 769 function ip_guard_settings_link($links) { -
ip-guard/trunk/readme.txt
r3038844 r3049313 13 13 Requires PHP: 7.4 14 14 15 Stable tag: 1.2 215 Stable tag: 1.23 16 16 17 17 License: GPLv2 or later … … 122 122 == Screenshots == 123 123 124 1. https://i.postimg.cc/ fW3dr5s9/locked.png124 1. https://i.postimg.cc/L6Fj14xC/Screenshot-1.png 125 125 126 126 2. https://i.postimg.cc/Yqkpsz2s/settings.png 127 127 128 3. https://i.postimg.cc/ CKW0Hj6J/ip-logs.png128 3. https://i.postimg.cc/yNGZY7JT/Screenshot-2.png 129 129 130 130 131 131 132 132 == Changelog == 133 134 = 1.23 = 135 136 * Fixed locking mechanism errors for dynamic/similar ip addresses 137 138 * Improved UI Design 139 133 140 134 141 = 1.22 = … … 148 155 == Upgrade Notice == 149 156 157 = 1.23 = 158 159 This version fixes some bugs with the plugin such as locking similar/dynamic ip address and also UI has been redesigned. 160 161 162 150 163 = 1.22 = 151 164
Note: See TracChangeset
for help on using the changeset viewer.