Plugin Directory

Changeset 3049313


Ignore:
Timestamp:
03/11/2024 06:12:36 PM (12 months ago)
Author:
dynahsty
Message:

v1.23

Location:
ip-guard/trunk
Files:
2 copied

Legend:

Unmodified
Added
Removed
  • ip-guard/trunk/ip-guard.php

    r3038844 r3049313  
    33Plugin Name: IPGuard
    44Description: A robust security plugin that empowers administrators to safeguard user accounts by implementing IP address-based lockdowns.
    5 Version: 1.22
    6 Author: <a href="https://mydynasty.link">Dynasty</a>
     5Version: 1.23
     6Author: <a href="https://wa.link/kemj38">Dynasty</a>
    77Contributors: Dynahsty
    88Tags: security, block-IP, login-protect, Auth-security, IP-secure
     
    1717
    1818defined('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
    2021define('IP_GUARD_MAX_IP_ADDRESSES', $max_ip_addresses);
    21 
    2222define('IP_GUARD_MAX_LOCK_DURATION', 7 * 24 * 60 * 60);
    2323
     
    3636
    3737        $client_ip = filter_var($_SERVER['REMOTE_ADDR'], FILTER_SANITIZE_STRING);
    38        
     38
    3939        if (filter_var($client_ip, FILTER_VALIDATE_IP)) {
    4040            $escaped_ip = htmlspecialchars($client_ip, ENT_QUOTES, 'UTF-8');
     
    4747        }
    4848
    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) {
    5254            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'));
    5456        }
    5557    }
     
    5759    return $user;
    5860}
    59 
    60 defined('ABSPATH') or die('No direct access allowed. Kindly exist');
    6161
    6262function ip_guard_manually_lock_user($user_id) {
     
    8888}
    8989
    90 
    91 defined('ABSPATH') or die('No direct access allowed');
    92 
    9390function ip_guard_lock_user($user_id) {
    9491    if (get_user_meta($user_id, '_account_locked', true)) {
     
    160157add_action('admin_menu', 'ip_guard_admin_menu');
    161158
    162 
    163 defined('ABSPATH') or die('No direct access allowed. Kindly exist');
    164159function ip_guard_admin_menu() {
    165160    add_menu_page(
     
    206201}
    207202
    208 defined('ABSPATH') or die('No direct access allowed. Kindly exist');
    209203function ip_guard_dashboard_content() {
    210204    ?>
     
    232226    </div>
    233227
    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>
    301282    <?php
    302283}
     
    324305}
    325306
    326 defined('ABSPATH') or die('No direct access allowed. Kindly exist');
    327 
    328307function ip_guard_admin_page_content() {
    329308    ?>
    330309    <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>
    335321                <?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">
    348327                    <thead>
    349328                        <tr>
    350                             <th><?php esc_html_e('User ID', 'ip-guard'); ?></th>
    351329                            <th><?php esc_html_e('Username', 'ip-guard'); ?></th>
    352330                            <th><?php esc_html_e('Locked Type', 'ip-guard'); ?></th>
     
    365343                            ?>
    366344                            <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>
    369346                                <td><?php esc_html_e('Manual', 'ip-guard'); ?></td>
    370347                                <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'))); ?>">
    372349                                        <?php esc_html_e('Unlock', 'ip-guard'); ?>
    373350                                    </a>
     
    385362                            ?>
    386363                            <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>
    389365                                <td><?php esc_html_e('Exceeded Limit', 'ip-guard'); ?></td>
    390366                                <td>
    391367                                    <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'); ?>
    393369                                    </a>
    394370                                </td>
     
    400376                            ?>
    401377                            <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>
    403379                            </tr>
    404380                            <?php
     
    409385            </div>
    410386        </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>
    411391    </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
    423393    <style>
    424394        .card-container {
     
    429399        }
    430400
    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 {
    432452    background-color: #f5f5f5;
    433453    border: 2px solid #3498db;
    434454    padding: 30px;
    435     box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    436     border-radius: 12px;
     455    border-radius: 20px;
    437456    box-sizing: border-box;
    438     max-width: 100%;
    439     margin-top: 20px;
     457    max-width: 70%;
     458    margin-top: 30px;
     459    overflow-x: auto;
    440460    margin-left: auto;
    441461    margin-right: auto;
    442462}
    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
    454469    </style>
    455470    <?php
    456471}
    457 
    458 defined('ABSPATH') or die('No direct access allowed. Kindly exit.');
    459472
    460473function ip_guard_settings_page_content() {
     
    552565            padding: 30px;
    553566            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    554             border-radius: 12px;
     567            border-radius: 20px;
    555568            box-sizing: border-box;
    556569            max-width: 100%;
     
    569582}
    570583
    571 defined('ABSPATH') or die('No direct access allowed. Kindly exist');
    572584function ip_guard_logs_page_content() {
    573585    ?>
    574586    <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">
    580592                    <thead>
    581593                        <tr>
    582                             <th><?php esc_html_e('User ID', 'ip-guard'); ?></th>
    583594                            <th><?php esc_html_e('Username', 'ip-guard'); ?></th>
    584595                            <th><?php esc_html_e('IP Addresses', 'ip-guard'); ?></th>
     
    597608                            ?>
    598609                            <tr>
    599                                 <td><?php echo esc_html($user->ID); ?></td>
    600610                                <td><?php echo esc_html($user->user_login); ?></td>
    601611                                <td>
     
    625635                            ?>
    626636                            <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>
    628638                            </tr>
    629639                            <?php
     
    635645        </div>
    636646
    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 {
    686655            background-color: #f5f5f5;
    687656            border: 2px solid #3498db;
     
    691660            box-sizing: border-box;
    692661            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;
    694696            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>
    698710    <?php
    699711}
    700712
    701 defined('ABSPATH') or die('No direct access allowed. Kindly exist');
    702713function ip_guard_donation_page_content() {
    703714    ?>
     
    705716        <div class="card-container">
    706717            <div class="card">
    707                 <h1 style="font-family: 'Arial', sans-serif;">
     718                <h1 class="donation-heading">
    708719                    <?php esc_html_e('Donation', 'ip-guard'); ?>
    709720                </h1>
     
    727738        }
    728739
    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
    741758        .donation-container {
    742759            background-color: #f8f9fa;
     
    749766
    750767    <?php
    751    
    752768}
    753769function ip_guard_settings_link($links) {
  • ip-guard/trunk/readme.txt

    r3038844 r3049313  
    1313Requires PHP: 7.4
    1414
    15 Stable tag: 1.22
     15Stable tag: 1.23
    1616
    1717License: GPLv2 or later
     
    122122== Screenshots ==
    123123
    124 1. https://i.postimg.cc/fW3dr5s9/locked.png
     1241. https://i.postimg.cc/L6Fj14xC/Screenshot-1.png
    125125
    1261262. https://i.postimg.cc/Yqkpsz2s/settings.png
    127127
    128 3. https://i.postimg.cc/CKW0Hj6J/ip-logs.png
     1283. https://i.postimg.cc/yNGZY7JT/Screenshot-2.png
    129129
    130130
    131131
    132132== Changelog ==
     133
     134= 1.23 =
     135
     136* Fixed locking mechanism errors for dynamic/similar ip addresses
     137
     138* Improved UI Design
     139
    133140
    134141= 1.22 =
     
    148155== Upgrade Notice ==
    149156
     157= 1.23 =
     158
     159This version fixes some bugs with the plugin such as locking similar/dynamic ip address and also UI has been redesigned.
     160
     161
     162
    150163= 1.22 =
    151164
Note: See TracChangeset for help on using the changeset viewer.