Version Description
- Compatibility with the after login redirection addon: http://wordpress.org/plugins/simple-membership-after-login-redirection/
Download this release
Release Info
| Developer | wp.insider |
| Plugin | |
| Version | 1.5.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.5 to 1.5.1
- classes/class.bAuth.php +17 -6
- readme.txt +5 -1
- simple-wp-membership.php +2 -2
classes/class.bAuth.php
CHANGED
|
@@ -13,13 +13,19 @@ class BAuth {
|
|
| 13 |
$this->isLoggedIn = false;
|
| 14 |
$this->userData = null;
|
| 15 |
$this->protected = BProtection::get_instance();
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
$this->authenticate();
|
| 18 |
}
|
| 19 |
}
|
| 20 |
-
|
| 21 |
public static function get_instance() {
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
| 23 |
return self::$_this;
|
| 24 |
}
|
| 25 |
|
|
@@ -27,6 +33,7 @@ class BAuth {
|
|
| 27 |
global $wpdb;
|
| 28 |
$swpm_user_name = filter_input(INPUT_POST, 'swpm_user_name');
|
| 29 |
$swpm_password = filter_input(INPUT_POST, 'swpm_password');
|
|
|
|
| 30 |
if (!empty($swpm_user_name) && !empty($swpm_password)) {
|
| 31 |
$user = sanitize_user($swpm_user_name);
|
| 32 |
$pass = trim($swpm_password);
|
|
@@ -53,6 +60,7 @@ class BAuth {
|
|
| 53 |
$this->set_cookie($remember);
|
| 54 |
$this->isLoggedIn = true;
|
| 55 |
$this->lastStatusMsg = "Logged In.";
|
|
|
|
| 56 |
do_action('swpm_login', $user, $pass, $remember);
|
| 57 |
return true;
|
| 58 |
}
|
|
@@ -95,6 +103,7 @@ class BAuth {
|
|
| 95 |
}
|
| 96 |
|
| 97 |
public function login($user, $pass, $remember = '', $secure = '') {
|
|
|
|
| 98 |
if ($this->isLoggedIn){
|
| 99 |
return;
|
| 100 |
}
|
|
@@ -148,6 +157,7 @@ class BAuth {
|
|
| 148 |
if (count($cookie_elements) != 3){
|
| 149 |
return false;
|
| 150 |
}
|
|
|
|
| 151 |
list($username, $expiration, $hmac) = $cookie_elements;
|
| 152 |
$expired = $expiration;
|
| 153 |
// Allow a grace period for POST and AJAX requests
|
|
@@ -159,15 +169,16 @@ class BAuth {
|
|
| 159 |
$this->lastStatusMsg = "Session Expired."; //do_action('auth_cookie_expired', $cookie_elements);
|
| 160 |
return false;
|
| 161 |
}
|
|
|
|
| 162 |
global $wpdb;
|
| 163 |
$query = " SELECT * FROM " . $wpdb->prefix . "swpm_members_tbl";
|
| 164 |
$query.= " WHERE user_name = '" . $username . "'";
|
| 165 |
$user = $wpdb->get_row($query);
|
| 166 |
-
if (
|
| 167 |
$this->lastStatusMsg = "Invalid User Name";
|
| 168 |
return false;
|
| 169 |
}
|
| 170 |
-
|
| 171 |
$pass_frag = substr($user->password, 8, 4);
|
| 172 |
$key = BAuth::b_hash($username . $pass_frag . '|' . $expiration);
|
| 173 |
$hash = hash_hmac('md5', $username . '|' . $expiration, $key);
|
|
@@ -175,7 +186,7 @@ class BAuth {
|
|
| 175 |
$this->lastStatusMsg = "Bad Cookie Hash";
|
| 176 |
return false;
|
| 177 |
}
|
| 178 |
-
|
| 179 |
if ($expiration < time()){
|
| 180 |
$GLOBALS['login_grace_period'] = 1;
|
| 181 |
}
|
| 13 |
$this->isLoggedIn = false;
|
| 14 |
$this->userData = null;
|
| 15 |
$this->protected = BProtection::get_instance();
|
| 16 |
+
}
|
| 17 |
+
private function init(){
|
| 18 |
+
$valid = $this->validate();
|
| 19 |
+
Blog::log_simple_debug("init:". ($valid? "valid": "invalid"), true);
|
| 20 |
+
if (!$valid){
|
| 21 |
$this->authenticate();
|
| 22 |
}
|
| 23 |
}
|
|
|
|
| 24 |
public static function get_instance() {
|
| 25 |
+
if (empty(self::$_this)){
|
| 26 |
+
self::$_this = new BAuth();
|
| 27 |
+
self::$_this->init();
|
| 28 |
+
}
|
| 29 |
return self::$_this;
|
| 30 |
}
|
| 31 |
|
| 33 |
global $wpdb;
|
| 34 |
$swpm_user_name = filter_input(INPUT_POST, 'swpm_user_name');
|
| 35 |
$swpm_password = filter_input(INPUT_POST, 'swpm_password');
|
| 36 |
+
Blog::log_simple_debug("Authenticate:" . $swpm_user_name, true);
|
| 37 |
if (!empty($swpm_user_name) && !empty($swpm_password)) {
|
| 38 |
$user = sanitize_user($swpm_user_name);
|
| 39 |
$pass = trim($swpm_password);
|
| 60 |
$this->set_cookie($remember);
|
| 61 |
$this->isLoggedIn = true;
|
| 62 |
$this->lastStatusMsg = "Logged In.";
|
| 63 |
+
Blog::log_simple_debug("swpm_login action.", true);
|
| 64 |
do_action('swpm_login', $user, $pass, $remember);
|
| 65 |
return true;
|
| 66 |
}
|
| 103 |
}
|
| 104 |
|
| 105 |
public function login($user, $pass, $remember = '', $secure = '') {
|
| 106 |
+
Blog::log_simple_debug("login",true);
|
| 107 |
if ($this->isLoggedIn){
|
| 108 |
return;
|
| 109 |
}
|
| 157 |
if (count($cookie_elements) != 3){
|
| 158 |
return false;
|
| 159 |
}
|
| 160 |
+
Blog::log_simple_debug("validate:" . $_COOKIE[$auth_cookie_name],true);
|
| 161 |
list($username, $expiration, $hmac) = $cookie_elements;
|
| 162 |
$expired = $expiration;
|
| 163 |
// Allow a grace period for POST and AJAX requests
|
| 169 |
$this->lastStatusMsg = "Session Expired."; //do_action('auth_cookie_expired', $cookie_elements);
|
| 170 |
return false;
|
| 171 |
}
|
| 172 |
+
Blog::log_simple_debug("validate:Session Expired",true);
|
| 173 |
global $wpdb;
|
| 174 |
$query = " SELECT * FROM " . $wpdb->prefix . "swpm_members_tbl";
|
| 175 |
$query.= " WHERE user_name = '" . $username . "'";
|
| 176 |
$user = $wpdb->get_row($query);
|
| 177 |
+
if (empty($user)) {
|
| 178 |
$this->lastStatusMsg = "Invalid User Name";
|
| 179 |
return false;
|
| 180 |
}
|
| 181 |
+
Blog::log_simple_debug("validate:Invalid User Name:" . serialize($user),true);
|
| 182 |
$pass_frag = substr($user->password, 8, 4);
|
| 183 |
$key = BAuth::b_hash($username . $pass_frag . '|' . $expiration);
|
| 184 |
$hash = hash_hmac('md5', $username . '|' . $expiration, $key);
|
| 186 |
$this->lastStatusMsg = "Bad Cookie Hash";
|
| 187 |
return false;
|
| 188 |
}
|
| 189 |
+
Blog::log_simple_debug("validate:bad hash",true);
|
| 190 |
if ($expiration < time()){
|
| 191 |
$GLOBALS['login_grace_period'] = 1;
|
| 192 |
}
|
readme.txt
CHANGED
|
@@ -4,7 +4,7 @@ Donate link: https://simple-membership-plugin.com/
|
|
| 4 |
Tags: member, members, members only, membership, memberships, register, WordPress membership plugin, content protection, paypal, restrict access, Restrict content
|
| 5 |
Requires at least: 3.3
|
| 6 |
Tested up to: 3.9.1
|
| 7 |
-
Stable tag: 1.5
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
|
@@ -67,6 +67,10 @@ https://simple-membership-plugin.com/
|
|
| 67 |
|
| 68 |
== Changelog ==
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
= 1.5 =
|
| 71 |
- Fixed a bug with sending member email when added via admin dashboard.
|
| 72 |
- Fixed a bug with general settings values resetting.
|
| 4 |
Tags: member, members, members only, membership, memberships, register, WordPress membership plugin, content protection, paypal, restrict access, Restrict content
|
| 5 |
Requires at least: 3.3
|
| 6 |
Tested up to: 3.9.1
|
| 7 |
+
Stable tag: 1.5.1
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
| 67 |
|
| 68 |
== Changelog ==
|
| 69 |
|
| 70 |
+
= 1.5.1 =
|
| 71 |
+
- Compatibility with the after login redirection addon:
|
| 72 |
+
http://wordpress.org/plugins/simple-membership-after-login-redirection/
|
| 73 |
+
|
| 74 |
= 1.5 =
|
| 75 |
- Fixed a bug with sending member email when added via admin dashboard.
|
| 76 |
- Fixed a bug with general settings values resetting.
|
simple-wp-membership.php
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?php
|
| 2 |
/*
|
| 3 |
Plugin Name: Simple WordPress Membership
|
| 4 |
-
Version: v1.5
|
| 5 |
Plugin URI: https://simple-membership-plugin.com/
|
| 6 |
Author: smp7, wp.insider
|
| 7 |
Author URI: https://simple-membership-plugin.com/
|
|
@@ -16,7 +16,7 @@ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"])){
|
|
| 16 |
include_once('classes/class.simple-wp-membership.php');
|
| 17 |
|
| 18 |
define('SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL', home_url());
|
| 19 |
-
define('SIMPLE_WP_MEMBERSHIP_VER', '1.5');
|
| 20 |
define('SIMPLE_WP_MEMBERSHIP_PATH', dirname(__FILE__) . '/');
|
| 21 |
define('SIMPLE_WP_MEMBERSHIP_URL', plugins_url('',__FILE__));
|
| 22 |
define('SIMPLE_WP_MEMBERSHIP_AUTH', 'simple_wp_membership_'. COOKIEHASH);
|
| 1 |
<?php
|
| 2 |
/*
|
| 3 |
Plugin Name: Simple WordPress Membership
|
| 4 |
+
Version: v1.5.1
|
| 5 |
Plugin URI: https://simple-membership-plugin.com/
|
| 6 |
Author: smp7, wp.insider
|
| 7 |
Author URI: https://simple-membership-plugin.com/
|
| 16 |
include_once('classes/class.simple-wp-membership.php');
|
| 17 |
|
| 18 |
define('SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL', home_url());
|
| 19 |
+
define('SIMPLE_WP_MEMBERSHIP_VER', '1.5.1');
|
| 20 |
define('SIMPLE_WP_MEMBERSHIP_PATH', dirname(__FILE__) . '/');
|
| 21 |
define('SIMPLE_WP_MEMBERSHIP_URL', plugins_url('',__FILE__));
|
| 22 |
define('SIMPLE_WP_MEMBERSHIP_AUTH', 'simple_wp_membership_'. COOKIEHASH);
|
