PluginProbe
Easy Basic Authentication – Add basic auth to site or admin area / 3.0
Easy Basic Authentication – Add basic auth to site or admin area v3.0
trunk 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4 1.4.1 1.5 1.5.1 1.5.2 1.5.3 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.7 1.7.1 1.8 1.8.1 1.9 All 50 releases
← All changes | class/easy-basic-authentication-class.php +8 -16 1.63.0 View file →
@@ -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) {