Skip to content

Commit

Permalink
General cleanup/maintenance. URI restrictions caSe sensitivity. See: #…
Browse files Browse the repository at this point in the history
  • Loading branch information
JasWSInc committed Oct 8, 2014
1 parent d54dc1f commit 1f4233d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions s2member/includes/classes/posts-sp.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public static function check_specific_post_level_access($post_id = 0, $check_use
{
do_action('ws_plugin__s2member_before_check_specific_post_level_access', get_defined_vars());

$ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
$excluded = apply_filters('ws_plugin__s2member_check_specific_post_level_access_excluded', FALSE, get_defined_vars());

if(!$excluded && is_numeric($post_id) && ($post_id = (int)$post_id) && ($post = get_post($post_id)) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
Expand All @@ -52,7 +53,7 @@ public static function check_specific_post_level_access($post_id = 0, $check_use
{
$user = (is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID)) ? $user : FALSE; // Current User's object.

if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^'.preg_quote($login_redirection_uri, '/').'$/', $post_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level0')))
if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^'.preg_quote($login_redirection_uri, '/').'$/'.$ci, $post_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level0')))
return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_level_req' => 0), get_defined_vars());

else if(!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page($post->ID, $post_uri)) // However, there is the one exception above.
Expand Down Expand Up @@ -107,7 +108,7 @@ public static function check_specific_post_level_access($post_id = 0, $check_use
if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris']) // URIs configured at this Level?
foreach(preg_split('/['."\r\n\t".']+/', c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris'], $user)) as $str)
if($str && preg_match('/'.preg_quote($str, '/').'/', $post_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level'.$n)))
if($str && preg_match('/'.preg_quote($str, '/').'/'.$ci, $post_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level'.$n)))
return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_level_req' => $n), get_defined_vars());
}
if(is_array($ccaps_req = get_post_meta($post->ID, 's2member_ccaps_req', TRUE)) && !empty($ccaps_req))
Expand Down
5 changes: 3 additions & 2 deletions s2member/includes/classes/posts.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public static function check_post_level_access()

do_action('ws_plugin__s2member_before_check_post_level_access', get_defined_vars());

$ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
$excluded = apply_filters('ws_plugin__s2member_check_post_level_access_excluded', FALSE, get_defined_vars());

if(!$excluded && is_single() && is_object($post) && !empty($post->ID) && ($post_id = (int)$post->ID) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
Expand All @@ -49,7 +50,7 @@ public static function check_post_level_access()
{
$user = (is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID)) ? $user : FALSE; // Current User's object.

if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^'.preg_quote($login_redirection_uri, '/').'$/', $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0')))
if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^'.preg_quote($login_redirection_uri, '/').'$/'.$ci, $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0')))
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'level', 0, $_SERVER['REQUEST_URI'], 'sys').exit ();

else if(!c_ws_plugin__s2member_systematics::is_systematic_use_page()) // However, there is the one exception above.
Expand Down Expand Up @@ -104,7 +105,7 @@ public static function check_post_level_access()
if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris']) // URIs configured at this Level?
foreach(preg_split('/['."\r\n\t".']+/', c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ruris'], $user)) as $str)
if($str && preg_match('/'.preg_quote($str, '/').'/', $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level'.$n)))
if($str && preg_match('/'.preg_quote($str, '/').'/'.$ci, $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level'.$n)))
c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'level', $n, $_SERVER['REQUEST_URI'], 'ruri').exit ();
}
if(is_array($ccaps_req = get_post_meta($post_id, 's2member_ccaps_req', TRUE)) && !empty($ccaps_req) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted'))
Expand Down

0 comments on commit 1f4233d

Please sign in to comment.