Plugin Directory

Changeset 2821811

Timestamp:
11/22/2022 02:08:07 AM (20 months ago)
Author:
wokamoto
Message:

[wp-basic-auth] Update ver.1.1.4

Location:
wp-basic-auth
Files:
2 edited
3 copied

Legend:

Unmodified
Added
Removed
  • wp-basic-auth/tags/1.1.4/plugin.php

    r1133557 r2821811  
    55Description: Enabling this plugin allows you to set up Basic authentication on your site using your WordPress's user name and password.
    66Author: wokamoto
    7 Version: 1.1.3
    8 Author URI: http://dogmap.jp/
     7Version: 1.1.
     8Author URI: http://dogmap.jp/
    99
    1010License:
    1111 Released under the GPL license
    1212  http://www.gnu.org/copyleft/gpl.html
    13   Copyright 2013-2015 wokamoto (email : wokamoto1973@gmail.com)
     13  Copyright 2013-20 wokamoto (email : wokamoto1973@gmail.com)
    1414
    1515    This program is free software; you can redistribute it and/or modify
     
    4444        self::$instance = $this;
    4545
    46         add_action('template_redirect', array($this, 'basic_auth'), 1);
     46        add_action();
    4747
    48         register_activation_hook(__FILE__, array($this, 'activate'));
    49         register_deactivation_hook(__FILE__, array($this, 'deactivate'));
     48        register_activation_hook();
     49        register_deactivation_hook();
    5050    }
    5151
    5252    public function activate(){
    53         if (!file_exists(ABSPATH.'.htaccess'))
     53        if ( ! file_exists( ABSPATH.'.htaccess' ) )
     54        {
    5455            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        {
    5760            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        );
    5966    }
    6067
    6168    public function deactivate(){
    62         if (!file_exists(ABSPATH.'.htaccess'))
     69        if ( ! file_exists( ABSPATH.'.htaccess' ) )
     70        {
    6371            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        {
    6676            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        );
    6882    }
    6983
     
    7185        nocache_headers();
    7286        if ( is_user_logged_in() )
     87
    7388            return;
     89
    7490
    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 ));
    8198            }
    8299        }
     
    84101        $is_authenticated = wp_authenticate($usr, $pwd);
    85102        if ( !is_wp_error( $is_authenticated ) )
     103
    86104            return;
     105
    87106
    88         header('WWW-Authenticate: Basic realm="Please Enter Your Password"');
     107        header();
    89108        wp_die(
    90109            'You need to enter a Username and a Password if you want to see this website.',
    91110            'Authorization Required',
    92111            array( 'response' => 401 )
    93             );
     112        );
    94113    }
    95114}
  • wp-basic-auth/tags/1.1.4/readme.txt

    r1133557 r2821811  
    44Tags: BASIC Auth, Auth
    55Requires at least: 3.0
    6 Tested up to: 4.1.1
    7 Stable tag: 1.1.3
     6Tested up to: .1.1
     7Stable tag: 1.1.
    88
    99Enabling this plugin allows you to set up Basic authentication on your site using your WordPress's user name and password.
     
    2727== Changelog ==
    2828
     29
     30
     31
     32
    2933**1.1.3 - March, 13, 2015**
    3034
  • wp-basic-auth/trunk/plugin.php

    r1133557 r2821811  
    55Description: Enabling this plugin allows you to set up Basic authentication on your site using your WordPress's user name and password.
    66Author: wokamoto
    7 Version: 1.1.3
    8 Author URI: http://dogmap.jp/
     7Version: 1.1.
     8Author URI: http://dogmap.jp/
    99
    1010License:
    1111 Released under the GPL license
    1212  http://www.gnu.org/copyleft/gpl.html
    13   Copyright 2013-2015 wokamoto (email : wokamoto1973@gmail.com)
     13  Copyright 2013-20 wokamoto (email : wokamoto1973@gmail.com)
    1414
    1515    This program is free software; you can redistribute it and/or modify
     
    4444        self::$instance = $this;
    4545
    46         add_action('template_redirect', array($this, 'basic_auth'), 1);
     46        add_action();
    4747
    48         register_activation_hook(__FILE__, array($this, 'activate'));
    49         register_deactivation_hook(__FILE__, array($this, 'deactivate'));
     48        register_activation_hook();
     49        register_deactivation_hook();
    5050    }
    5151
    5252    public function activate(){
    53         if (!file_exists(ABSPATH.'.htaccess'))
     53        if ( ! file_exists( ABSPATH.'.htaccess' ) )
     54        {
    5455            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        {
    5760            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        );
    5966    }
    6067
    6168    public function deactivate(){
    62         if (!file_exists(ABSPATH.'.htaccess'))
     69        if ( ! file_exists( ABSPATH.'.htaccess' ) )
     70        {
    6371            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        {
    6676            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        );
    6882    }
    6983
     
    7185        nocache_headers();
    7286        if ( is_user_logged_in() )
     87
    7388            return;
     89
    7490
    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 ));
    8198            }
    8299        }
     
    84101        $is_authenticated = wp_authenticate($usr, $pwd);
    85102        if ( !is_wp_error( $is_authenticated ) )
     103
    86104            return;
     105
    87106
    88         header('WWW-Authenticate: Basic realm="Please Enter Your Password"');
     107        header();
    89108        wp_die(
    90109            'You need to enter a Username and a Password if you want to see this website.',
    91110            'Authorization Required',
    92111            array( 'response' => 401 )
    93             );
     112        );
    94113    }
    95114}
  • wp-basic-auth/trunk/readme.txt

    r1133557 r2821811  
    44Tags: BASIC Auth, Auth
    55Requires at least: 3.0
    6 Tested up to: 4.1.1
    7 Stable tag: 1.1.3
     6Tested up to: .1.1
     7Stable tag: 1.1.
    88
    99Enabling this plugin allows you to set up Basic authentication on your site using your WordPress's user name and password.
     
    2727== Changelog ==
    2828
     29
     30
     31
     32
    2933**1.1.3 - March, 13, 2015**
    3034
Note: See TracChangeset for help on using the changeset viewer.