Changeset 2808168
- Timestamp:
- 10/31/2022 05:59:07 PM (3 years ago)
- Location:
- lock-login/trunk
- Files:
-
- 4 edited
-
Readme.txt (modified) (2 diffs)
-
includes/App.php (modified) (4 diffs)
-
includes/DB.php (modified) (1 diff)
-
locklogin.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lock-login/trunk/Readme.txt
r2793732 r2808168 1 1 === Lock Login === 2 2 Contributors: aixeiger 3 Tags: security, login 3 Tags: security, login, lock, unlock, login failed 4 4 Tested up to: 6.0 5 Stable tag: 0.1. 25 Stable tag: 0.1.3 6 6 Requires PHP: 7.4 7 7 License: GPLv2 or later … … 18 18 * Install the plugin 19 19 * That's all 20 * For unlock users go to Settings -> Lock Login and lock on 'Unlock' for the selected user 21 22 ## Changelog 23 24 0.1.3 31-oct-22 Add an admin panel for unlock users gracefully -
lock-login/trunk/includes/App.php
r2793732 r2808168 21 21 add_action('wp_authenticate_user', array($this, 'authenticate_user'), 100, 2); // set at last 22 22 add_filter('shake_error_codes', array($this, 'failure_shake'), 10); 23 24 add_action('admin_init', array($this, 'unlock_users')); 25 add_action('admin_menu', array($this, 'register_admin_menu')); 23 26 } 24 27 … … 30 33 { 31 34 $server_data = $this->get_server_data(); 32 $loaded_from = 'wp _login';35 $loaded_from = 'wp-login'; 33 36 if(isset($GLOBALS['wp_xmlrpc_server']) && is_object($GLOBALS['wp_xmlrpc_server'])){ 34 37 $loaded_from = 'wp_xmlrpc_server'; … … 52 55 if(!$this->db->user_check($user->user_login, $server_data['REMOTE_ADDR'])){ 53 56 $error = new \WP_Error(); 54 $error->add('too_many_retries', "Your user has surpased the limit retries please wait 20 minutes");57 $error->add('too_many_retries', "Your user has surpased the limit retries, please wait 20 minutes"); 55 58 return $error; 56 59 } else { … … 94 97 } 95 98 99 public function unlock_users() 100 { 101 if(current_user_can('manage_options') && isset($_POST['locklogin_id']) && is_numeric($_POST['locklogin_id'])){ 102 $this->db->disable_lock(filter_var($_POST['locklogin_id']), FILTER_VALIDATE_INT); 103 wp_redirect(get_admin_url().'options-general.php?page=lock-login'); 104 exit; 105 } 106 } 107 108 public function register_admin_menu() 109 { 110 add_submenu_page( 111 'options-general.php', 112 'Lock Login', 113 'Lock Login', 114 'manage_options', 115 'lock-login', 116 array($this, 'admin_callback') 117 ); 118 } 119 120 public function admin_callback() 121 { 122 $results = $this->db->get_locked_today(); 123 ?> 124 <div class="wrap"> 125 <h2><?php echo esc_html(get_admin_page_title()); ?></h2> 126 <h3>Lock tracking</h3> 127 <table class="wp-list-table widefat fixed striped table-view-list posts"> 128 <thead> 129 <tr> 130 <td>Username</td> 131 <td>Ip Address</td> 132 <td>Browser</td> 133 <td>Platform</td> 134 <td>Attempts</td> 135 <td>Date</td> 136 <td>Action</td> 137 </tr> 138 </thead> 139 <tbody> 140 <?php 141 if($results): 142 foreach ($results as $obj): 143 ?> 144 <tr> 145 <td><?php echo esc_html($obj->username); ?></td> 146 <td><?php echo esc_html($obj->remote_addr); ?></td> 147 <td><?php echo esc_html($obj->browser); ?></td> 148 <td><?php echo esc_html($obj->platform); ?></td> 149 <td><?php echo esc_html($obj->attempts); ?></td> 150 <td><?php echo esc_html($obj->created_at.' '.$obj->created_time_at); ?></td> 151 <td> 152 <form method="post"> 153 <input type="hidden" name="locklogin_id" value="<?php echo esc_html($obj->id); ?>"> 154 <button type="submit">Unlock</button> 155 </form> 156 </td> 157 </tr> 158 <?php 159 endforeach; 160 endif; 161 ?> 162 </tbody> 163 </table> 164 </div> 165 <?php 166 } 167 96 168 } -
lock-login/trunk/includes/DB.php
r2793732 r2808168 42 42 return false; 43 43 } 44 } 45 46 public function get_locked_today() 47 { 48 $register_name = $this->register_table_name; 49 return $this->wpdb->get_results($this->wpdb->prepare("SELECT id, username, http_host, remote_addr, browser, browser_version, platform, attempts, created_at, created_time_at FROM $register_name WHERE created_at = %s AND attempts > 0", $this->get_current_date())); 50 } 51 52 public function disable_lock($id) 53 { 54 $register_name = $this->register_table_name; 55 $this->wpdb->update( 56 $register_name, 57 array( 58 'attempts' => 0 59 ), 60 array('id' => $id), 61 array('%d') 62 ); 44 63 } 45 64 -
lock-login/trunk/locklogin.php
r2793732 r2808168 5 5 * Author: TocinoDev 6 6 * Author URI: https://tocino.mx 7 * Version: 0.1. 27 * Version: 0.1.3 8 8 * Tested up to: 6.0 9 9 * Requires PHP: 7.4
Note: See TracChangeset
for help on using the changeset viewer.