Skip to content

Commit

Permalink
Dev (#18)
Browse files Browse the repository at this point in the history
* readme updated

* handled the removed function - create_function

* removed the role filter to improve the sql query performance

* updated version info for 2.1.2
  • Loading branch information
faiyazalam authored Oct 5, 2023
1 parent 7027b9b commit 2896c7d
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 37 deletions.
15 changes: 12 additions & 3 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
=== User Login History ===
Contributors: faiyazalam,w3reign,nekokun,harm10
Donate link: https://www.paypal.me/erfaiyazalam/
Tags: login log,rename admin,brute force indicator,security, history
Tags: login log,login activity,brute force indicator,security,history,tool
Requires at least: 5.0.0
Requires PHP: 5.6.40
Tested up to: 6.1.1
Stable tag: 2.1.1
Tested up to: 6.3.1
Stable tag: 2.1.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -214,6 +214,15 @@ It means that:

== Changelog ==

= 2.1.2 (05th October 2023) =

* Code refactoring for the settings page
* Removed the role filter to improve the sql query performance

= 2.1.1 (21st May 2023) =

* Fixed error [issue](https://wordpress.org/support/topic/plugin-error-2-1-0/)

= 2.1.0 (17th February 2021) =

* Fixed geo location [issue](https://wordpress.org/support/topic/no-geo-location-user-agent-not-properly-defined/)
Expand Down
8 changes: 2 additions & 6 deletions inc/admin/class-admin-login-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ public function get_rows( $per_page = 20, $page_number = 1 ) {
$table = $wpdb->prefix . $this->table;
$sql = ' SELECT'
. ' FaUserLogin.*, '
. ' UserMeta.meta_value as role, TIMESTAMPDIFF(SECOND,FaUserLogin.time_login,FaUserLogin.time_last_seen) as duration'
. ' TIMESTAMPDIFF(SECOND,FaUserLogin.time_login,FaUserLogin.time_last_seen) as duration'
. ' FROM ' . $table . ' AS FaUserLogin'
. " LEFT JOIN $wpdb->usermeta AS UserMeta ON ( UserMeta.user_id=FaUserLogin.user_id"
. " AND UserMeta.meta_key LIKE '" . $wpdb->prefix . "capabilities' )"
. ' WHERE 1 ';

$where_query = $this->prepare_where_query();

if ( $where_query ) {
$sql .= $where_query;
}
Expand Down Expand Up @@ -78,10 +77,7 @@ public function record_count() {
$sql = ' SELECT'
. ' COUNT(FaUserLogin.id) AS total'
. ' FROM ' . $table . ' AS FaUserLogin'
. " LEFT JOIN $wpdb->usermeta AS UserMeta ON ( UserMeta.user_id=FaUserLogin.user_id"
. " AND UserMeta.meta_key LIKE '" . $wpdb->prefix . "capabilities' )"
. ' WHERE 1 ';

$where_query = $this->prepare_where_query();

if ( $where_query ) {
Expand Down
5 changes: 0 additions & 5 deletions inc/admin/class-login-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ public function prepare_where_query() {
}
}

if ( ! empty( $_GET['role'] ) ) {
$where_query .= " AND `UserMeta`.`meta_value` LIKE '%" . esc_sql( $_GET['role'] ) . "%'";
}

if ( ! empty( $_GET['date_type'] ) ) {
$user_profile = new User_Profile( $this->plugin_name, $this->version );
$input_timezone = $user_profile->get_user_timezone();
Expand Down Expand Up @@ -235,7 +231,6 @@ public function get_sortable_columns() {
'duration' => array( 'duration', false ),
);

return $columns;
}

/**
Expand Down
6 changes: 1 addition & 5 deletions inc/admin/class-network-admin-login-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,14 @@ private function prepare_sql_queries() {
. ' FaUserLogin.user_agent,'
. ' FaUserLogin.login_status,'
. ' FaUserLogin.is_super_admin,'
. ' UserMeta.meta_value as role, '
. ' TIMESTAMPDIFF(SECOND,FaUserLogin.time_login,FaUserLogin.time_last_seen) as duration,'
. " $blog_id as blog_id"
. " FROM $table AS FaUserLogin"
. " LEFT JOIN $wpdb->usermeta AS UserMeta ON (UserMeta.user_id=FaUserLogin.user_id"
. " AND UserMeta.meta_key LIKE '" . $blog_prefix . "capabilities' )"
. ' WHERE 1 ';

$this->count_sql .= ' SELECT'
. ' COUNT(FaUserLogin.id) AS count'
. " FROM $table AS FaUserLogin"
. " LEFT JOIN $wpdb->usermeta AS UserMeta ON (UserMeta.user_id=FaUserLogin.user_id"
. " AND UserMeta.meta_key LIKE '" . $blog_prefix . "capabilities' )"
. ' WHERE 1 ';

if ( $where_query ) {
Expand All @@ -137,6 +132,7 @@ private function prepare_sql_queries() {

$this->rows_sql = "SELECT * FROM ({$this->rows_sql}) AS FaUserLoginAllRows";
$this->count_sql = "SELECT SUM(count) as total FROM ({$this->count_sql}) AS FaUserLoginCount";

}

/**
Expand Down
4 changes: 3 additions & 1 deletion inc/admin/class-settings-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ function admin_init() {

if ( isset( $section['desc'] ) && ! empty( $section['desc'] ) ) {
$section['desc'] = '<div class="inside">' . $section['desc'] . '</div>';
$callback = create_function( '', 'echo "' . str_replace( '"', '\"', $section['desc'] ) . '";' );
$callback = function () use ($section) {
echo str_replace('"', '\"', $section['desc']);
};
} elseif ( isset( $section['callback'] ) ) {
$callback = $section['callback'];
} else {
Expand Down
10 changes: 0 additions & 10 deletions inc/admin/views/forms/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@
<option value="unknown" <?php selected( $selected_timezone, 'unknown' ); ?> ><?php esc_html_e( 'Unknown', 'faulh' ); ?></option>
<?php Template_Helper::dropdown_timezones( $selected_timezone ); ?>
</select></div>
<div><label for="role" ><?php esc_html_e( 'Current Role', 'faulh' ); ?></label><select id="role" name="role">
<option value=""><?php esc_html_e( 'Select Current Role', 'faulh' ); ?></option>
<?php
$selected_role = isset( $_GET['role'] ) ? $_GET['role'] : null;
wp_dropdown_roles( $selected_role );
?>
<?php if ( is_network_admin() ) { ?>
<option value="superadmin" <?php selected( $selected_role, 'superadmin' ); ?> ><?php esc_html_e( 'Super Administrator', 'faulh' ); ?></option>
<?php } ?>
</select></div>
<div><label for="old_role" ><?php esc_html_e( 'Old Role', 'faulh' ); ?></label><select id="old_role" name="old_role">
<option value=""><?php esc_html_e( 'Select Old Role', 'faulh' ); ?></option>
<?php
Expand Down
6 changes: 1 addition & 5 deletions inc/frontend/class-frontend-login-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,8 @@ public function get_rows() {
global $wpdb;
$sql = ' SELECT'
. ' FaUserLogin.*, '
. ' UserMeta.meta_value as role, TIMESTAMPDIFF(SECOND,FaUserLogin.time_login,FaUserLogin.time_last_seen) as duration'
. ' TIMESTAMPDIFF(SECOND,FaUserLogin.time_login,FaUserLogin.time_last_seen) as duration'
. ' FROM ' . $this->table . ' AS FaUserLogin'
. " LEFT JOIN $wpdb->usermeta AS UserMeta ON ( UserMeta.user_id=FaUserLogin.user_id"
. " AND UserMeta.meta_key LIKE '" . $wpdb->prefix . "capabilities' )"
. ' WHERE 1 ';

$where_query = $this->prepare_where_query();
Expand Down Expand Up @@ -322,8 +320,6 @@ public function record_count() {
$sql = ' SELECT'
. ' COUNT(FaUserLogin.id) as total '
. ' FROM ' . $this->table . ' AS FaUserLogin'
. " LEFT JOIN $wpdb->usermeta AS UserMeta ON ( UserMeta.user_id=FaUserLogin.user_id"
. " AND UserMeta.meta_key LIKE '" . $wpdb->prefix . "capabilities' )"
. ' WHERE 1 ';

$where_query = $this->prepare_where_query();
Expand Down
4 changes: 2 additions & 2 deletions user-login-history.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Plugin Name: User Login History
* Plugin URI: http://userloginhistory.com/home/
* Description: Helps you to know your website's visitors by tracking their login related information like login/logout time, country, browser and many more.
* Version: 2.1.1
* Version: 2.1.2
* Author: Er Faiyaz Alam
* Author URI: http://userloginhistory.com/
* License: GPL-2.0+
Expand Down Expand Up @@ -43,7 +43,7 @@

define( NS . 'USER_LOGIN_HISTORY', 'faulh' );

define( NS . 'PLUGIN_VERSION', '2.1.1' );
define( NS . 'PLUGIN_VERSION', '2.1.2' );

define( NS . 'USER_LOGIN_HISTORY_DIR', plugin_dir_path( __FILE__ ) );

Expand Down

0 comments on commit 2896c7d

Please sign in to comment.