Changeset 2821811
- Timestamp:
- 11/22/2022 02:08:07 AM (20 months ago)
- Location:
- wp-basic-auth
- Files:
-
- 2 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
wp-basic-auth/tags/1.1.4/plugin.php
r1133557 r2821811 5 5 Description: Enabling this plugin allows you to set up Basic authentication on your site using your WordPress's user name and password. 6 6 Author: wokamoto 7 Version: 1.1. 38 Author URI: http ://dogmap.jp/7 Version: 1.1. 8 Author URI: http://dogmap.jp/ 9 9 10 10 License: 11 11 Released under the GPL license 12 12 http://www.gnu.org/copyleft/gpl.html 13 Copyright 2013-20 15wokamoto (email : wokamoto1973@gmail.com)13 Copyright 2013-20 wokamoto (email : wokamoto1973@gmail.com) 14 14 15 15 This program is free software; you can redistribute it and/or modify … … 44 44 self::$instance = $this; 45 45 46 add_action( 'template_redirect', array($this, 'basic_auth'), 1);46 add_action(); 47 47 48 register_activation_hook( __FILE__, array($this, 'activate'));49 register_deactivation_hook( __FILE__, array($this, 'deactivate'));48 register_activation_hook(); 49 register_deactivation_hook(); 50 50 } 51 51 52 52 public function activate(){ 53 if (!file_exists(ABSPATH.'.htaccess')) 53 if ( ! file_exists( ABSPATH.'.htaccess' ) ) 54 { 54 55 return; 55 $htaccess = file_get_contents(ABSPATH.'.htaccess'); 56 if (strpos($htaccess, self::HTACCES_REWRITE_RULE) !== false) 56 } 57 $htaccess = file_get_contents( ABSPATH.'.htaccess' ); 58 if ( strpos( $htaccess, self::HTACCES_REWRITE_RULE ) !== false ) 59 { 57 60 return; 58 file_put_contents(ABSPATH.'.htaccess', self::HTACCES_REWRITE_RULE . $htaccess); 61 } 62 file_put_contents( 63 ABSPATH.'.htaccess', 64 self::HTACCES_REWRITE_RULE . $htaccess 65 ); 59 66 } 60 67 61 68 public function deactivate(){ 62 if (!file_exists(ABSPATH.'.htaccess')) 69 if ( ! file_exists( ABSPATH.'.htaccess' ) ) 70 { 63 71 return; 64 $htaccess = file_get_contents(ABSPATH.'.htaccess'); 65 if (strpos($htaccess, self::HTACCES_REWRITE_RULE) === false) 72 } 73 $htaccess = file_get_contents( ABSPATH.'.htaccess' ); 74 if ( strpos( $htaccess, self::HTACCES_REWRITE_RULE ) === false ) 75 { 66 76 return; 67 file_put_contents(ABSPATH.'.htaccess', str_replace(self::HTACCES_REWRITE_RULE, '', $htaccess)); 77 } 78 file_put_contents( 79 ABSPATH.'.htaccess', 80 str_replace( self::HTACCES_REWRITE_RULE, '', $htaccess ) 81 ); 68 82 } 69 83 … … 71 85 nocache_headers(); 72 86 if ( is_user_logged_in() ) 87 73 88 return; 89 74 90 75 $usr = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : ''; 76 $pwd = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : ''; 77 if (empty($usr) && empty($pwd) && isset($_SERVER['HTTP_AUTHORIZATION']) && $_SERVER['HTTP_AUTHORIZATION']) { 78 list($type, $auth) = explode(' ', $_SERVER['HTTP_AUTHORIZATION']); 79 if (strtolower($type) === 'basic') { 80 list($usr, $pwd) = explode(':', base64_decode($auth)); 91 $usr = isset( $_SERVER['PHP_AUTH_USER'] ) ? $_SERVER['PHP_AUTH_USER'] : ''; 92 $pwd = isset( $_SERVER['PHP_AUTH_PW'] ) ? $_SERVER['PHP_AUTH_PW'] : ''; 93 if ( empty($usr) && empty($pwd) && isset($_SERVER['HTTP_AUTHORIZATION']) && $_SERVER['HTTP_AUTHORIZATION'] ) 94 { 95 list( $type, $auth ) = explode( ' ', $_SERVER['HTTP_AUTHORIZATION'] ); 96 if ( strtolower( $type ) === 'basic') { 97 list( $usr, $pwd ) = explode(':', base64_decode( $auth )); 81 98 } 82 99 } … … 84 101 $is_authenticated = wp_authenticate($usr, $pwd); 85 102 if ( !is_wp_error( $is_authenticated ) ) 103 86 104 return; 105 87 106 88 header( 'WWW-Authenticate: Basic realm="Please Enter Your Password"');107 header(); 89 108 wp_die( 90 109 'You need to enter a Username and a Password if you want to see this website.', 91 110 'Authorization Required', 92 111 array( 'response' => 401 ) 93 112 ); 94 113 } 95 114 } -
wp-basic-auth/tags/1.1.4/readme.txt
r1133557 r2821811 4 4 Tags: BASIC Auth, Auth 5 5 Requires at least: 3.0 6 Tested up to: 4.1.17 Stable tag: 1.1. 36 Tested up to: .1.1 7 Stable tag: 1.1. 8 8 9 9 Enabling this plugin allows you to set up Basic authentication on your site using your WordPress's user name and password. … … 27 27 == Changelog == 28 28 29 30 31 32 29 33 **1.1.3 - March, 13, 2015** 30 34 -
wp-basic-auth/trunk/plugin.php
r1133557 r2821811 5 5 Description: Enabling this plugin allows you to set up Basic authentication on your site using your WordPress's user name and password. 6 6 Author: wokamoto 7 Version: 1.1. 38 Author URI: http ://dogmap.jp/7 Version: 1.1. 8 Author URI: http://dogmap.jp/ 9 9 10 10 License: 11 11 Released under the GPL license 12 12 http://www.gnu.org/copyleft/gpl.html 13 Copyright 2013-20 15wokamoto (email : wokamoto1973@gmail.com)13 Copyright 2013-20 wokamoto (email : wokamoto1973@gmail.com) 14 14 15 15 This program is free software; you can redistribute it and/or modify … … 44 44 self::$instance = $this; 45 45 46 add_action( 'template_redirect', array($this, 'basic_auth'), 1);46 add_action(); 47 47 48 register_activation_hook( __FILE__, array($this, 'activate'));49 register_deactivation_hook( __FILE__, array($this, 'deactivate'));48 register_activation_hook(); 49 register_deactivation_hook(); 50 50 } 51 51 52 52 public function activate(){ 53 if (!file_exists(ABSPATH.'.htaccess')) 53 if ( ! file_exists( ABSPATH.'.htaccess' ) ) 54 { 54 55 return; 55 $htaccess = file_get_contents(ABSPATH.'.htaccess'); 56 if (strpos($htaccess, self::HTACCES_REWRITE_RULE) !== false) 56 } 57 $htaccess = file_get_contents( ABSPATH.'.htaccess' ); 58 if ( strpos( $htaccess, self::HTACCES_REWRITE_RULE ) !== false ) 59 { 57 60 return; 58 file_put_contents(ABSPATH.'.htaccess', self::HTACCES_REWRITE_RULE . $htaccess); 61 } 62 file_put_contents( 63 ABSPATH.'.htaccess', 64 self::HTACCES_REWRITE_RULE . $htaccess 65 ); 59 66 } 60 67 61 68 public function deactivate(){ 62 if (!file_exists(ABSPATH.'.htaccess')) 69 if ( ! file_exists( ABSPATH.'.htaccess' ) ) 70 { 63 71 return; 64 $htaccess = file_get_contents(ABSPATH.'.htaccess'); 65 if (strpos($htaccess, self::HTACCES_REWRITE_RULE) === false) 72 } 73 $htaccess = file_get_contents( ABSPATH.'.htaccess' ); 74 if ( strpos( $htaccess, self::HTACCES_REWRITE_RULE ) === false ) 75 { 66 76 return; 67 file_put_contents(ABSPATH.'.htaccess', str_replace(self::HTACCES_REWRITE_RULE, '', $htaccess)); 77 } 78 file_put_contents( 79 ABSPATH.'.htaccess', 80 str_replace( self::HTACCES_REWRITE_RULE, '', $htaccess ) 81 ); 68 82 } 69 83 … … 71 85 nocache_headers(); 72 86 if ( is_user_logged_in() ) 87 73 88 return; 89 74 90 75 $usr = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : ''; 76 $pwd = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : ''; 77 if (empty($usr) && empty($pwd) && isset($_SERVER['HTTP_AUTHORIZATION']) && $_SERVER['HTTP_AUTHORIZATION']) { 78 list($type, $auth) = explode(' ', $_SERVER['HTTP_AUTHORIZATION']); 79 if (strtolower($type) === 'basic') { 80 list($usr, $pwd) = explode(':', base64_decode($auth)); 91 $usr = isset( $_SERVER['PHP_AUTH_USER'] ) ? $_SERVER['PHP_AUTH_USER'] : ''; 92 $pwd = isset( $_SERVER['PHP_AUTH_PW'] ) ? $_SERVER['PHP_AUTH_PW'] : ''; 93 if ( empty($usr) && empty($pwd) && isset($_SERVER['HTTP_AUTHORIZATION']) && $_SERVER['HTTP_AUTHORIZATION'] ) 94 { 95 list( $type, $auth ) = explode( ' ', $_SERVER['HTTP_AUTHORIZATION'] ); 96 if ( strtolower( $type ) === 'basic') { 97 list( $usr, $pwd ) = explode(':', base64_decode( $auth )); 81 98 } 82 99 } … … 84 101 $is_authenticated = wp_authenticate($usr, $pwd); 85 102 if ( !is_wp_error( $is_authenticated ) ) 103 86 104 return; 105 87 106 88 header( 'WWW-Authenticate: Basic realm="Please Enter Your Password"');107 header(); 89 108 wp_die( 90 109 'You need to enter a Username and a Password if you want to see this website.', 91 110 'Authorization Required', 92 111 array( 'response' => 401 ) 93 112 ); 94 113 } 95 114 } -
wp-basic-auth/trunk/readme.txt
r1133557 r2821811 4 4 Tags: BASIC Auth, Auth 5 5 Requires at least: 3.0 6 Tested up to: 4.1.17 Stable tag: 1.1. 36 Tested up to: .1.1 7 Stable tag: 1.1. 8 8 9 9 Enabling this plugin allows you to set up Basic authentication on your site using your WordPress's user name and password. … … 27 27 == Changelog == 28 28 29 30 31 32 29 33 **1.1.3 - March, 13, 2015** 30 34
Note: See TracChangeset
for help on using the changeset viewer.