Changeset 3050475
- Timestamp:
- 03/13/2024 12:01:11 PM (12 months ago)
- Location:
- ip-guard/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
ip-guard/trunk/ip-guard.php
r3049436 r3050475 62 62 } 63 63 64 function construct_email_body($logo_url, $email_body) { 65 $body = '<div style="background-color: #f4f4f4; padding: 20px; border-radius: 5px; font-family: \'Helvetica Neue\', Helvetica, Arial, sans-serif;">'; 66 $body .= '<img src="' . esc_url($logo_url) . '" alt="Logo" style="max-width: 150px; margin-bottom: 20px; display: block; margin: 0 auto;">'; 67 $body .= '<div style="background-color: #ffffff; padding: 20px; border-radius: 5px;">'; 68 $body .= '<div style="color: #333; font-size: 16px; line-height: 1.6; text-align: left;">' . ($email_body ? wpautop($email_body) : 'Default email body') . '</div>'; 69 $body .= '</div>'; 70 $body .= '<div style="text-align: center; margin-top: 20px; color: #888; font-size: 12px;">'; 71 $body .= esc_html(get_option('ip_guard_copyright_text', '')); 72 $body .= '</div>'; 73 $body .= '</div>'; 74 return $body; 75 } 64 76 function ip_guard_manually_lock_user($user_id) { 65 77 update_user_meta($user_id, '_ip_guard_account_manually_locked', true); … … 68 80 $subject = __('Your account has been locked', 'ip-guard'); 69 81 $lock_email_body = get_option('ip_guard_lock_email_body', ''); 70 $message = $lock_email_body ? $lock_email_body : __('Default lock email body', 'ip-guard'); 71 wp_mail($to, $subject, $message); 82 $logo_url = get_option('ip_guard_logo_url', ''); 83 84 $message = construct_email_body($logo_url, $lock_email_body); 85 86 $headers[] = 'Content-Type: text/html; charset=UTF-8'; 87 wp_mail($to, $subject, $message, $headers); 72 88 } 73 89 … … 82 98 $subject = __('Your account has been unlocked', 'ip-guard'); 83 99 $unlock_email_body = get_option('ip_guard_unlock_email_body', ''); 84 $ message = $unlock_email_body ? $unlock_email_body : __('Default unlock email body', 'ip-guard');85 wp_mail($to, $subject, $message);86 } 87 88 function ip_guard_is_user_manually_locked($user_id) { 89 return get_user_meta($user_id, '_ip_guard_account_manually_locked', true) == 1;100 $logo_url = get_option('ip_guard_logo_url', ''); 101 102 $message = construct_email_body($logo_url, $unlock_email_body); 103 104 $headers[] = 'Content-Type: text/html; charset=UTF-8'; 105 wp_mail($to, $subject, $message, $headers); 90 106 } 91 107 … … 101 117 $to = $user_info->user_email; 102 118 $subject = __('Your account has been locked', 'ip-guard'); 103 $lock_email_body = get_option('ip_guard_lock_email_body', __('Default lock email body', 'ip-guard')); 104 $message = wp_kses_post($lock_email_body ? $lock_email_body : __('Default lock email body', 'ip-guard')); 105 106 if (isset($to, $subject, $message)) { 107 wp_mail($to, $subject, $message); 108 } 119 $lock_email_body = get_option('ip_guard_lock_email_body', ''); 120 $logo_url = get_option('ip_guard_logo_url', ''); 121 122 $message = construct_email_body($logo_url, $lock_email_body); 123 124 $headers[] = 'Content-Type: text/html; charset=UTF-8'; 125 wp_mail($to, $subject, $message, $headers); 109 126 } 110 127 … … 115 132 116 133 $lock_time = get_user_meta($user_id, '_lock_time', true); 117 $lock_duration = 7 * 24 * 60 * 60; //134 $lock_duration = 7 * 24 * 60 * 60; 118 135 119 136 if (time() - $lock_time >= $lock_duration) { … … 125 142 $to = $user_info->user_email; 126 143 $subject = __('Your account has been automatically unlocked', 'ip-guard'); 127 $unlock_email_body = get_option('ip_guard_unlock_email_body', __('', 'ip-guard')); 128 $message = $unlock_email_body ? $unlock_email_body : __('Default unlock email body', 'ip-guard'); 129 130 wp_mail($to, $subject, $message); 144 $unlock_email_body = get_option('ip_guard_unlock_email_body', ''); 145 $logo_url = get_option('ip_guard_logo_url', ''); 146 147 $message = construct_email_body($logo_url, $unlock_email_body); 148 149 $headers[] = 'Content-Type: text/html; charset=UTF-8'; 150 wp_mail($to, $subject, $message, $headers); 131 151 return; 132 152 } … … 147 167 $to = $user_info->user_email; 148 168 $subject = __('Your account has been manually unlocked', 'ip-guard'); 149 $unlock_email_body = get_option('ip_guard_unlock_email_body', __('Default unlock email body', 'ip-guard')); 150 $message = $unlock_email_body ? $unlock_email_body : __('Default unlock email body', 'ip-guard'); 151 152 wp_mail($to, $subject, $message); 169 $unlock_email_body = get_option('ip_guard_unlock_email_body', ''); 170 $logo_url = get_option('ip_guard_logo_url', ''); 171 172 $message = construct_email_body($logo_url, $unlock_email_body); 173 174 $headers[] = 'Content-Type: text/html; charset=UTF-8'; 175 wp_mail($to, $subject, $message, $headers); 153 176 set_transient('unlock_user_' . $user_id, true, MINUTE_IN_SECONDS); 154 177 } 155 178 156 function ip_guard_is_user_locked($user_id) { 157 return get_user_meta($user_id, '_account_locked', true); 158 } 179 159 180 add_action('admin_menu', 'ip_guard_admin_menu'); 160 181 … … 487 508 $unlock_email_body = isset($_POST['unlock_email_body']) ? wp_kses_post(wp_unslash($_POST['unlock_email_body'])) : ''; 488 509 update_option('ip_guard_unlock_email_body', $unlock_email_body); 510 511 $logo_url = isset($_POST['logo_url']) ? esc_url_raw($_POST['logo_url']) : ''; 512 update_option('ip_guard_logo_url', $logo_url); 513 514 $copyright_text = isset($_POST['copyright_text']) ? sanitize_text_field($_POST['copyright_text']) : ''; 515 update_option('ip_guard_copyright_text', $copyright_text); 489 516 490 517 echo '<div id="message" class="updated notice is-dismissible"><p>' … … 495 522 $lock_email_body = get_option('ip_guard_lock_email_body', ''); 496 523 $unlock_email_body = get_option('ip_guard_unlock_email_body', ''); 524 $logo_url = get_option('ip_guard_logo_url', ''); 525 $copyright_text = get_option('ip_guard_copyright_text', ''); 497 526 498 527 ?> 499 528 500 <div class="wrap"> 501 <div class="card"> 502 <h1><?php esc_html_e('Settings', 'ip-guard'); ?></h1> 503 504 <form method="post" action=""> 505 <?php wp_nonce_field('ip_guard_settings_nonce'); ?> 506 507 <div class="form-group" style="max-width: 400px; margin: 0 auto;"> 508 <label for="max_ip_addresses" style="display: inline-block; margin-bottom: 5px;"><?php esc_html_e('Maximum IP Addresses Allowed:', 'ip-guard'); ?></label> 509 <input type="number" id="max_ip_addresses" name="max_ip_addresses" value="<?php echo esc_attr($max_ip_addresses); ?>" min="1" required style="display: inline-block; width: calc(100% - 10px); box-sizing: border-box; margin-bottom: 15px;"> 510 <p class="description" style="text-align: left;"><?php esc_html_e('Enter the maximum number of allowed IP addresses per account.', 'ip-guard'); ?></p> 511 </div> 512 513 <div class="form-group"> 514 <label for="lock_email_body"><?php esc_html_e('Locked Email Body:', 'ip-guard'); ?></label> 515 <textarea id="lock_email_body" name="lock_email_body" rows="4"><?php echo esc_textarea($lock_email_body); ?></textarea> 516 <p class="description"><?php esc_html_e('Enter the body text for the email sent when an account is locked.', 'ip-guard'); ?></p> 517 </div> 518 519 <div class="form-group"> 520 <label for="unlock_email_body"><?php esc_html_e('Unlocked Email Body:', 'ip-guard'); ?></label> 521 <textarea id="unlock_email_body" name="unlock_email_body" rows="4"><?php echo esc_textarea($unlock_email_body); ?></textarea> 522 <p class="description"><?php esc_html_e('Enter the body text for the email sent when an account is unlocked.', 'ip-guard'); ?></p> 523 </div> 524 525 <p><input type="submit" name="submit" class="button-primary" style="background-color:#0073aa;" value="<?php esc_attr_e('Save Settings', 'ip-guard'); ?>"></p> 526 </form> 527 </div> 529 <div class="wrap"> 530 <div class="card"> 531 <h1><?php esc_html_e('Settings', 'ip-guard'); ?></h1> 532 533 <form method="post" action=""> 534 <?php wp_nonce_field('ip_guard_settings_nonce'); ?> 535 536 <div class="form-group" style="max-width: 400px; margin: 0 auto;"> 537 <label for="max_ip_addresses" style="display: inline-block; margin-bottom: 5px;"><?php esc_html_e('Maximum IP Addresses Allowed:', 'ip-guard'); ?></label> 538 <input type="number" id="max_ip_addresses" name="max_ip_addresses" value="<?php echo esc_attr($max_ip_addresses); ?>" min="1" required style="display: inline-block; width: calc(100% - 10px); box-sizing: border-box; margin-bottom: 15px;"> 539 <p class="description" style="text-align: left;"><?php esc_html_e('Enter the maximum number of allowed IP addresses per account.', 'ip-guard'); ?></p> 540 </div> 541 542 <div class="form-group"> 543 <label for="lock_email_body"><?php esc_html_e('Locked Email Body:', 'ip-guard'); ?></label> 544 <?php wp_editor($lock_email_body, 'lock_email_body', array('textarea_name' => 'lock_email_body', 'textarea_rows' => 4)); ?> 545 <p class="description"><?php esc_html_e('Enter the body text for the email sent when an account is locked.', 'ip-guard'); ?></p> 546 </div> 547 548 <div class="form-group"> 549 <label for="unlock_email_body"><?php esc_html_e('Unlocked Email Body:', 'ip-guard'); ?></label> 550 <?php wp_editor($unlock_email_body, 'unlock_email_body', array('textarea_name' => 'unlock_email_body', 'textarea_rows' => 4)); ?> 551 <p class="description"><?php esc_html_e('Enter the body text for the email sent when an account is unlocked.', 'ip-guard'); ?></p> 552 </div> 553 554 <div class="form-group"> 555 <label for="logo_url"><?php esc_html_e('Logo URL:', 'ip-guard'); ?></label> 556 <input type="text" id="logo_url" name="logo_url" value="<?php echo esc_attr($logo_url); ?>" style="width: 80%;" placeholder="<?php esc_attr_e('Enter the URL to your logo image', 'ip-guard'); ?>"> 557 </div> 558 559 <div class="form-group"> 560 <label for="copyright_text"><?php esc_html_e('Copyright Text:', 'ip-guard'); ?></label> 561 <input type="text" id="copyright_text" name="copyright_text" value="<?php echo esc_attr($copyright_text); ?>" style="width: 50%;"> 562 </div> 563 564 <p><input type="submit" name="submit" class="button-primary" style="background-color:#0073aa;" value="<?php esc_attr_e('Save Settings', 'ip-guard'); ?>"></p> 565 </form> 566 </div> 528 567 <div class="card instructions-container"> 529 568 <h2><?php esc_html_e('Instructions', 'ip-guard'); ?></h2> … … 532 571 </div> 533 572 </div> 534 535 573 <style> 536 574 .form-group { … … 559 597 margin-left: auto; 560 598 margin-right: auto; 561 text-align: center; /* Center the content */599 text-align: center; 562 600 } 563 601 -
ip-guard/trunk/readme.txt
r3049313 r3050475 49 49 4. A admin logs page which displays the detected IP address, username and country 50 50 51 5. A admin settings page for configuration of the plugin such as setting the maximum IP address allowed, body text for locked and unlocked emails 51 5. A admin settings page for configuration of the plugin such as setting the maximum IP address allowed, body text for locked and unlocked emails, custom mail notification logo and copyright text 52 52 53 53 6. A user statistics page which displays total number of registered users, administrators and locked accounts 54 55 56 57 * Pro Features*58 59 1. New pro features coming soon60 54 61 55 … … 124 118 1. https://i.postimg.cc/L6Fj14xC/Screenshot-1.png 125 119 126 2. https://i.postimg.cc/Yqkpsz2s/settings.png120 2.https://i.postimg.cc/FF0kdb0L/Screenshot-settings.png 127 121 128 122 3. https://i.postimg.cc/yNGZY7JT/Screenshot-2.png … … 134 128 = 1.23 = 135 129 136 * Fixed locking mechanism errors for dynamic/similar ip addresses130 * Fixed locking mechanism errors for similar ip address 137 131 138 * Improved UI Design 132 * Improved UI Design for Locked account, Settings and Logs page 139 133 140 134 … … 157 151 = 1.23 = 158 152 159 This version fixes some bugs with the plugin such as locking similar /dynamic ipaddress and also UI has been redesigned.153 This version fixes some bugs with the plugin such as locking similar address and also UI has been redesigned. 160 154 161 155
Note: See TracChangeset
for help on using the changeset viewer.