| @@ -2,8 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | require_once (dirname(__FILE__).'/easy-basic-authentication-log-class.php'); |
| 4 | 4 | require_once (dirname(__FILE__).'/easy-basic-authentication-emailalert-class.php'); |
| 5 | 5 | require_once (dirname(__FILE__).'/easy-basic-authentication-form-class.php'); |
| 6 | +require_once (dirname(__FILE__).'/easy-basic-authentication-notice-class.php'); | |
| 6 | 7 | |
| 7 | 8 | class easy_basic_authentication_class { |
| 8 | 9 | |
| 9 | 10 | private $log; |
| @@ -14,12 +15,13 @@ | ||
| 14 | 15 | { |
| 15 | 16 | $this->log = new easy_basic_authentication_log_class(); |
| 16 | 17 | $this->email = new easy_basic_authentication_emailalert_class(); |
| 17 | 18 | $this->form = new easy_basic_authentication_form_class(); |
| 19 | + $notice = new easy_basic_authentication_notice_class(); | |
| 18 | 20 | |
| 19 | 21 | if(get_option( 'basic_auth_plugin_admin_enable' )) { |
| 20 | 22 | if (in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'))) { |
| 21 | - add_action( 'init', array($this,'basic_auth_admin') ); | |
| 23 | + add_action( 'init', array($this,'basic_auth_root') ); | |
| 22 | 24 | } |
| 23 | 25 | } |
| 24 | 26 | |
| 25 | 27 | if(get_option( 'basic_auth_plugin_enable' ) && get_option( 'basic_auth_plugin_admin_enable' )){ |
| @@ -39,31 +41,21 @@ | ||
| 39 | 41 | public function basic_auth_root() { |
| 40 | 42 | $user = get_option( 'basic_auth_plugin_username' ); |
| 41 | 43 | $pass = get_option( 'basic_auth_plugin_password' ); |
| 42 | 44 | |
| 43 | - if ( !isset( $_SERVER['PHP_AUTH_USER'] ) || !isset( $_SERVER['PHP_AUTH_PW'] ) || | |
| 44 | - $_SERVER['PHP_AUTH_USER'] != $user || !wp_check_password( $_SERVER['PHP_AUTH_PW'], $pass ) ) { | |
| 45 | + if ( !isset( $_SERVER['PHP_AUTH_USER'] ) || !isset( $_SERVER['PHP_AUTH_PW'] ) || | |
| 46 | + $_SERVER['PHP_AUTH_USER'] != $user || !wp_check_password( wp_unslash( $_SERVER['PHP_AUTH_PW'] ), $pass ) ) { | |
| 45 | 47 | |
| 46 | 48 | $this->do_exit(true); |
| 47 | 49 | } |
| 48 | 50 | } |
| 49 | - | |
| 50 | - public function basic_auth_admin() { | |
| 51 | - $user = get_option( 'basic_auth_plugin_username' ); | |
| 52 | - $pass = get_option( 'basic_auth_plugin_password' ); | |
| 53 | - | |
| 54 | - if ( !isset( $_SERVER['PHP_AUTH_USER'] ) || !isset( $_SERVER['PHP_AUTH_PW'] ) || | |
| 55 | - $_SERVER['PHP_AUTH_USER'] != $user || !wp_check_password( $_SERVER['PHP_AUTH_PW'], $pass ) ) { | |
| 56 | - | |
| 57 | - $this->do_exit(true); | |
| 58 | - } | |
| 59 | - } | |
| 60 | - | |
| 51 | + | |
| 61 | 52 | public function do_exit($admin_area = false) { |
| 62 | 53 | |
| 63 | - if (in_array($_SERVER['REMOTE_ADDR'], $this->getWhiteList())) { | |
| 54 | + if (isset($_SERVER['REMOTE_ADDR']) && in_array($_SERVER['REMOTE_ADDR'], $this->getWhiteList())) { | |
| 64 | 55 | return; |
| 65 | 56 | } |
| 57 | + | |
| 66 | 58 | $this->basic_auth_action_failed_access(); |
| 67 | 59 | do_action('basic_auth_before_401'); |
| 68 | 60 | |
| 69 | 61 | if($admin_area) { |