| @@ -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,8 +15,9 @@ | ||
| 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 | 23 | add_action( 'init', array($this,'basic_auth_admin') ); |
| @@ -59,8 +61,11 @@ | ||
| 59 | 61 | } |
| 60 | 62 | |
| 61 | 63 | public function do_exit($admin_area = false) { |
| 62 | 64 | |
| 65 | + if (in_array($_SERVER['REMOTE_ADDR'], $this->getWhiteList())) { | |
| 66 | + return; | |
| 67 | + } | |
| 63 | 68 | $this->basic_auth_action_failed_access(); |
| 64 | 69 | do_action('basic_auth_before_401'); |
| 65 | 70 | |
| 66 | 71 | if($admin_area) { |
| @@ -73,8 +78,12 @@ | ||
| 73 | 78 | header( 'HTTP/1.1 401 Unauthorized' ); |
| 74 | 79 | header( 'WWW-Authenticate: Basic realm="Admin Area"' ); |
| 75 | 80 | exit; |
| 76 | 81 | } |
| 82 | + } | |
| 83 | + | |
| 84 | + public function getWhiteList() { | |
| 85 | + return get_option( 'basic_auth_plugin_whitelist' )?explode(',',get_option( 'basic_auth_plugin_whitelist' )):[]; | |
| 77 | 86 | } |
| 78 | 87 | |
| 79 | 88 | public function basic_auth_plugin_menu() { |
| 80 | 89 | add_menu_page( |