Plugin Directory

Changeset 3145651


Ignore:
Timestamp:
09/03/2024 02:54:34 AM (19 months ago)
Author:
tmatsuur
Message:

[Update] login rebuilder:2.8.3 Changed to apply 'Unknown' to internally stored hostname when $_SERVERHTTP_HOST? does not exist.

Location:
login-rebuilder/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • login-rebuilder/trunk/login-rebuilder.php

    r2990352 r3145651  
    55Description: This plugin will create a new login page for your site. The new login page can be placed in any directory. You can also create separate login pages for administrators and for other users.
    66Author: tmatsuur
    7 Version: 2.8.2
     7Version: 2.8.3
    88Author URI: https://12net.jp/
    99Text Domain: login-rebuilder
     
    1212
    1313/*
    14  Copyright (C) 2013-2023 tmatsuur (Email: takenori dot matsuura at 12net dot jp)
     14 Copyright (C) 2013-2024 tmatsuur (Email: takenori dot matsuura at 12net dot jp)
    1515This program is licensed under the GNU GPL Version 2.
    1616*/
    1717
     18namespace jp12net;
     19
    1820define( 'LOGIN_REBUILDER_DOMAIN', 'login-rebuilder' );
    1921define( 'LOGIN_REBUILDER_DB_VERSION_NAME', 'login-rebuilder-db-version' );
    20 define( 'LOGIN_REBUILDER_DB_VERSION', '2.8.2' );
     22define( 'LOGIN_REBUILDER_DB_VERSION', '2.8.3' );
    2123define( 'LOGIN_REBUILDER_PROPERTIES', 'login-rebuilder' );
    2224define( 'LOGIN_REBUILDER_LOGGING_NAME', 'login-rebuilder-logging' );
    2325define( 'LOGIN_REBUILDER_LOGIN_IP_NAME', 'login-rebuilder-login-ip' );
    2426define( 'LOGIN_REBUILDER_UNKNOWN_IP_NAME', 'login-rebuilder-unknown-ip' );
     27
     28use jp12net\login_rebuilder;
    2529
    2630$plugin_login_rebuilder = new login_rebuilder();
     
    121125        $this->remote_addr = preg_match( '/^(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3,5}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/', $remote_addr )? $remote_addr: self::INVALID_REMOTE_ADDR;
    122126        $this->request_uri = $this->_sanitize_url( $_SERVER['REQUEST_URI'] );
    123         $this->user_agent = isset( $_SERVER['HTTP_USER_AGENT'] )? wp_specialchars_decode( $_SERVER['HTTP_USER_AGENT'], ENT_QUOTES ): 'None';;
    124 
    125         $this->host_name = $_SERVER['HTTP_HOST']; // [2.6.2] $_SERVER['SERVER_NAME'] was wrong.
     127        $this->user_agent = isset( $_SERVER['HTTP_USER_AGENT'] )? wp_specialchars_decode( $_SERVER['HTTP_USER_AGENT'], ENT_QUOTES ): 'None';
     128
     129        $this->host_name = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST']: 'Unknown'; // [2.8.3][2.6.2] $_SERVER['SERVER_NAME'] was wrong.
    126130        $this->root_url = ( ( is_ssl() || force_ssl_admin() )? "https://": "http://" ) . $this->host_name;
    127131        $this->root_path = $_SERVER['DOCUMENT_ROOT'];
     
    275279        load_plugin_textdomain( LOGIN_REBUILDER_DOMAIN, false, plugin_basename( dirname( __FILE__ ) ).'/languages' );
    276280        if ( preg_match( '/\/wp\-login\.php/u', $this->request_uri ) ||
    277             !( ( $this->_in_url( $this->request_uri, $this->properties['page'] ) || $this->_in_url( $this->request_uri, $this->properties['page_subscriber'] ) ) && defined( 'LOGIN_REBUILDER_SIGNATURE' ) && $this->properties['keyword'] == LOGIN_REBUILDER_SIGNATURE ) ) {
     281            !( ( $this->_in_url( $this->request_uri, $this->properties['page'] ) || $this->_in_url( $this->request_uri, $this->properties['page_subscriber'] ) ) &&
     282            defined( 'LOGIN_REBUILDER_SIGNATURE' ) && $this->properties['keyword'] == LOGIN_REBUILDER_SIGNATURE ) ) {
    278283            if ( $this->properties['logging'] == self::LOGIN_REBUILDER_LOGGING_ALL ||
    279284                 $this->properties['logging'] == self::LOGIN_REBUILDER_LOGGING_INVALID_REQUEST ) {
     
    25232528
    25242529    /**
     2530     * Obtain the number of user environments.
     2531     *
     2532     * @since 2.8.3
     2533     *
     2534     * @access private.
     2535     *
     2536     * @param array $user_sessions;
     2537     * @return int
     2538     */
     2539    private function user_environment( $user_sessions ) {
     2540        $sessions = array();
     2541        foreach ( $user_sessions as $user_session ) {
     2542            $sessions[ $user_session['ua'] . '@' . $user_session['ip'] ][] = $user_session;
     2543        }
     2544        return count( $sessions );
     2545    }
     2546
     2547    /**
     2548     * Summarize session token of the same environment.
     2549     *
     2550     * @since 2.8.3
     2551     *
     2552     * @access private.
     2553     *
     2554     * @param array $session_tokens
     2555     * @return array
     2556     */
     2557    private function summarize_user_environment( $session_tokens ) {
     2558        $sessions = array();
     2559        foreach ( $session_tokens as $session ) {
     2560            if ( isset( $sessions[ $session['ua'] . '@' . $session['ip'] ] ) ) {
     2561                if ( $sessions[ $session['ua'] . '@' . $session['ip'] ]['login'] < $session['login'] ) {
     2562                    $sessions[ $session['ua'] . '@' . $session['ip'] ] = $session;
     2563                }
     2564            } else {
     2565                $sessions[ $session['ua'] . '@' . $session['ip'] ] = $session;
     2566            }
     2567        }
     2568        return array_values( $sessions );
     2569    }
     2570
     2571    /**
    25252572     * Retrieves information about the currently logged-in users.
    25262573     *
     
    25612608        remove_action( 'pre_user_query', array( $this, 'add_session_tokens_value' ) );
    25622609
    2563         $sessions = WP_Session_Tokens::get_instance( $user->ID );
    2564         if ( 1 < count( $sessions->get_all() ) ) {
     2610        $sessions = \WP_Session_Tokens::get_instance( $user->ID );
     2611        if ( 1 < $this->user_environment( $sessions->get_all() ) ) {
    25652612            $content['message']['text'] = __( 'This account is also logged in elsewhere.', LOGIN_REBUILDER_DOMAIN );
    25662613            $content['message']['alert'] = true;
     
    25762623            $session_tokens = maybe_unserialize( $user->session_tokens );
    25772624            if ( is_array( $session_tokens ) ) {
     2625                $session_tokens = $this->summarize_user_environment( $session_tokens );
    25782626                $alert = ( 1 < count( $session_tokens ) );
    25792627                foreach ( $session_tokens as $token => $session ) {
     
    26212669     * @param WP_User_Query $wp_user_query
    26222670     */
    2623     public function add_session_tokens_value( WP_User_Query $wp_user_query ) {
     2671    public function add_session_tokens_value( \WP_User_Query $wp_user_query ) {
    26242672        global $wpdb;
    26252673        if ( isset( $wp_user_query->query_vars['meta_key'] ) && 'session_tokens' === $wp_user_query->query_vars['meta_key'] ) {
  • login-rebuilder/trunk/readme.txt

    r3124278 r3145651  
    66Requires PHP: 5.6
    77Tested up to: 6.6.1
    8 Stable tag: 2.8.2
     8Stable tag: 2.8.3
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1111
    12 This plugin creates a customizable login page for your site, usable in any directory, with separate pages for admins and users.
     12This plugin will create a new login page for your site. The new login page can be placed in any directory. You can also create separate login pages for administrators and for other users.
    1313
    1414== Description ==
     
    9595== Changelog ==
    9696
     97= 2.8.3 =
     98* Bug fix: Changed to apply 'Unknown' to internally stored hostname when $_SERVER['HTTP_HOST'] does not exist.
     99* Tweaked widget showing logged in users.
     100
    97101= 2.8.2 =
    98102* Bug fix: Fixed escaping for "login file keywords" on the settings page.
Note: See TracChangeset for help on using the changeset viewer.