Changeset 3145651
- Timestamp:
- 09/03/2024 02:54:34 AM (19 months ago)
- Location:
- login-rebuilder/trunk
- Files:
-
- 2 edited
-
login-rebuilder.php (modified) (8 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
login-rebuilder/trunk/login-rebuilder.php
r2990352 r3145651 5 5 Description: 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. 6 6 Author: tmatsuur 7 Version: 2.8. 27 Version: 2.8.3 8 8 Author URI: https://12net.jp/ 9 9 Text Domain: login-rebuilder … … 12 12 13 13 /* 14 Copyright (C) 2013-202 3tmatsuur (Email: takenori dot matsuura at 12net dot jp)14 Copyright (C) 2013-2024 tmatsuur (Email: takenori dot matsuura at 12net dot jp) 15 15 This program is licensed under the GNU GPL Version 2. 16 16 */ 17 17 18 namespace jp12net; 19 18 20 define( 'LOGIN_REBUILDER_DOMAIN', 'login-rebuilder' ); 19 21 define( 'LOGIN_REBUILDER_DB_VERSION_NAME', 'login-rebuilder-db-version' ); 20 define( 'LOGIN_REBUILDER_DB_VERSION', '2.8. 2' );22 define( 'LOGIN_REBUILDER_DB_VERSION', '2.8.3' ); 21 23 define( 'LOGIN_REBUILDER_PROPERTIES', 'login-rebuilder' ); 22 24 define( 'LOGIN_REBUILDER_LOGGING_NAME', 'login-rebuilder-logging' ); 23 25 define( 'LOGIN_REBUILDER_LOGIN_IP_NAME', 'login-rebuilder-login-ip' ); 24 26 define( 'LOGIN_REBUILDER_UNKNOWN_IP_NAME', 'login-rebuilder-unknown-ip' ); 27 28 use jp12net\login_rebuilder; 25 29 26 30 $plugin_login_rebuilder = new login_rebuilder(); … … 121 125 $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; 122 126 $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. 126 130 $this->root_url = ( ( is_ssl() || force_ssl_admin() )? "https://": "http://" ) . $this->host_name; 127 131 $this->root_path = $_SERVER['DOCUMENT_ROOT']; … … 275 279 load_plugin_textdomain( LOGIN_REBUILDER_DOMAIN, false, plugin_basename( dirname( __FILE__ ) ).'/languages' ); 276 280 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 ) ) { 278 283 if ( $this->properties['logging'] == self::LOGIN_REBUILDER_LOGGING_ALL || 279 284 $this->properties['logging'] == self::LOGIN_REBUILDER_LOGGING_INVALID_REQUEST ) { … … 2523 2528 2524 2529 /** 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 /** 2525 2572 * Retrieves information about the currently logged-in users. 2526 2573 * … … 2561 2608 remove_action( 'pre_user_query', array( $this, 'add_session_tokens_value' ) ); 2562 2609 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() ) ) { 2565 2612 $content['message']['text'] = __( 'This account is also logged in elsewhere.', LOGIN_REBUILDER_DOMAIN ); 2566 2613 $content['message']['alert'] = true; … … 2576 2623 $session_tokens = maybe_unserialize( $user->session_tokens ); 2577 2624 if ( is_array( $session_tokens ) ) { 2625 $session_tokens = $this->summarize_user_environment( $session_tokens ); 2578 2626 $alert = ( 1 < count( $session_tokens ) ); 2579 2627 foreach ( $session_tokens as $token => $session ) { … … 2621 2669 * @param WP_User_Query $wp_user_query 2622 2670 */ 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 ) { 2624 2672 global $wpdb; 2625 2673 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 6 6 Requires PHP: 5.6 7 7 Tested up to: 6.6.1 8 Stable tag: 2.8. 28 Stable tag: 2.8.3 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 11 12 This plugin creates a customizable login page for your site, usable in any directory, with separate pages for admins andusers.12 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. 13 13 14 14 == Description == … … 95 95 == Changelog == 96 96 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 97 101 = 2.8.2 = 98 102 * Bug fix: Fixed escaping for "login file keywords" on the settings page.
Note: See TracChangeset
for help on using the changeset viewer.