File Editor
Directories:
.. (Back)
Files:
access-cap-times.inc.php
admin-css-js-in.inc.php
admin-css-js.inc.php
admin-lockouts.inc.php
admin-notices.inc.php
auto-eots.inc.php
aweber-e.inc.php
aweber.inc.php
brute-force.inc.php
cache.inc.php
catgs-sp.inc.php
catgs.inc.php
check-activation.inc.php
constants.inc.php
cron-jobs-in.inc.php
cron-jobs.inc.php
css-js-in.inc.php
css-js-themes.inc.php
css-js.inc.php
custom-reg-fields-4bp.inc.php
custom-reg-fields.inc.php
database.inc.php
email-configs.inc.php
files-in.inc.php
files.inc.php
getresponse.inc.php
installation.inc.php
ip-restrictions.inc.php
labels.inc.php
list-server-base.inc.php
list-servers.inc.php
login-checks.inc.php
login-customizations.inc.php
login-redirects-r.inc.php
login-redirects.inc.php
mailchimp-o.inc.php
mailchimp.inc.php
menu-pages-rs.inc.php
menu-pages-tb.inc.php
menu-pages.inc.php
meta-box-saves.inc.php
meta-box-security.inc.php
meta-boxes.inc.php
mo-page-in.inc.php
mo-page.inc.php
no-cache.inc.php
op-notices.inc.php
option-forces.inc.php
pages-sp.inc.php
pages.inc.php
paypal-notify-in-billing-agreement-signup.inc.php
paypal-notify-in-cart.inc.php
paypal-notify-in-express-checkout.inc.php
paypal-notify-in-rec-profile-creation-w-level.inc.php
paypal-notify-in-send-money.inc.php
paypal-notify-in-sp-refund-reversal.inc.php
paypal-notify-in-subscr-modify-w-level.inc.php
paypal-notify-in-subscr-or-rp-cancellation-w-level.inc.php
paypal-notify-in-subscr-or-rp-eots-w-level.inc.php
paypal-notify-in-subscr-or-rp-payment-failed-w-level.inc.php
paypal-notify-in-subscr-or-rp-payment-w-level.inc.php
paypal-notify-in-subscr-or-wa-w-level.inc.php
paypal-notify-in-virtual-terminal.inc.php
paypal-notify-in-wa-ccaps-wo-level.inc.php
paypal-notify-in-web-accept-sp.inc.php
paypal-notify-in.inc.php
paypal-notify.inc.php
paypal-return-in-no-tx-data.inc.php
paypal-return-in-proxy-ty-email.inc.php
paypal-return-in-proxy-x-preview.inc.php
paypal-return-in-subscr-modify-w-level.inc.php
paypal-return-in-subscr-or-wa-w-level.inc.php
paypal-return-in-wa-ccaps-wo-level.inc.php
paypal-return-in-web-accept-sp.inc.php
paypal-return-in.inc.php
paypal-return.inc.php
paypal-utilities.inc.php
posts-sp.inc.php
posts.inc.php
profile-in.inc.php
profile-mods-4bp-in.inc.php
profile-mods-4bp.inc.php
profile-mods-in.inc.php
profile-mods.inc.php
profile.inc.php
ptags-sp.inc.php
ptags.inc.php
querys.inc.php
readmes.inc.php
register-access.inc.php
register-in.inc.php
register.inc.php
registration-times.inc.php
registrations.inc.php
return-templates.inc.php
roles-caps.inc.php
ruris-sp.inc.php
ruris.inc.php
s-badge-status-in.inc.php
s-badge-status.inc.php
sc-eots-in.inc.php
sc-eots.inc.php
sc-files-in.inc.php
sc-files.inc.php
sc-gets-in.inc.php
sc-gets.inc.php
sc-if-conds-in.inc.php
sc-if-conds.inc.php
sc-keys-in.inc.php
sc-keys.inc.php
sc-paypal-button-e.inc.php
sc-paypal-button-in.inc.php
sc-paypal-button.inc.php
sc-profile-in.inc.php
sc-profile.inc.php
sc-s-badge-in.inc.php
sc-s-badge.inc.php
security-rest.inc.php
security.inc.php
sp-access.inc.php
ssl-in.inc.php
ssl.inc.php
systematics-sp.inc.php
systematics.inc.php
tracking-codes.inc.php
tracking-cookies-in.inc.php
tracking-cookies.inc.php
translations.inc.php
user-access.inc.php
user-deletions.inc.php
user-new-in.inc.php
user-new.inc.php
user-notes.inc.php
user-securities.inc.php
users-list-in.inc.php
users-list.inc.php
utilities.inc.php
utils-arrays.inc.php
utils-captchas.inc.php
utils-conds.inc.php
utils-css.inc.php
utils-cur.inc.php
utils-defuse.inc.php
utils-dirs.inc.php
utils-encryption.inc.php
utils-forms.inc.php
utils-gets.inc.php
utils-html.inc.php
utils-ip.inc.php
utils-logs.inc.php
utils-s2o.inc.php
utils-strings.inc.php
utils-time.inc.php
utils-urls.inc.php
utils-users.inc.php
wp-footer.inc.php
Create New File
Create
Edit File: posts.inc.php
<?php // @codingStandardsIgnoreFile /** * s2Member's Post protection routines *(for current Post)*. * * Copyright: © 2009-2011 * {@link http://websharks-inc.com/ WebSharks, Inc.} * (coded in the USA) * * Released under the terms of the GNU General Public License. * You should have received a copy of the GNU General Public License, * along with this software. In the main directory, see: /licensing/ * If not, see: {@link http://www.gnu.org/licenses/}. * * @package s2Member\Posts * @since 3.5 */ if(!defined('WPINC')) // MUST have WordPress. exit ('Do not access this file directly.'); if(!class_exists('c_ws_plugin__s2member_posts')) { /** * s2Member's Post protection routines *(for current Post)*. * * @package s2Member\Posts * @since 3.5 */ class c_ws_plugin__s2member_posts { /** * Handles Post Level Access permissions *(for current Post)*. * * @package s2Member\Posts * @since 3.5 * * @return null Or exits script execution after redirection. */ public static function check_post_level_access() { global $post; // ``get_the_ID()`` unavailable outside The Loop. 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']) { if(!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page()) // Do NOT touch WordPress Systematics. This excludes all WordPress Systematics. { $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, '/').'$/'.$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. { $bbpress_restrictions_enable = apply_filters('ws_plugin__s2member_bbpress_restrictions_enable', TRUE); $bbpress_installed = c_ws_plugin__s2member_utils_conds::bbp_is_installed(); // bbPress is installed? $bbpress_forum_post_type = $bbpress_installed ? bbp_get_forum_post_type() : ''; // Acquire the current post type for forums. $bbpress_topic_post_type = $bbpress_installed ? bbp_get_topic_post_type() : ''; // Acquire the current post type for topics. $bbpress_topic_forum_id = $bbpress_installed && $post->post_type === $bbpress_topic_post_type ? bbp_get_topic_forum_id($post->ID) : 0; for($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) // Post Level restrictions. { if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_posts'] === 'all' && 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']).exit (); else if(strpos($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_posts'], 'all-') !== FALSE && (in_array('all-'.$post->post_type, preg_split('/['."\r\n\t".'\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_posts'])) || in_array('all-'.$post->post_type.'s', preg_split('/['."\r\n\t".'\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_posts']))) && 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']).exit (); else if($bbpress_restrictions_enable && $bbpress_installed && $post->post_type === $bbpress_topic_post_type && strpos($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_posts'], 'all-') !== FALSE && (in_array('all-'.$bbpress_forum_post_type, preg_split('/['."\r\n\t".'\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_posts'])) || in_array('all-'.$bbpress_forum_post_type.'s', preg_split('/['."\r\n\t".'\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_posts']))) && 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']).exit (); else if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_posts'] && in_array($post_id, preg_split('/['."\r\n\t".'\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_posts'])) && 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']).exit (); } if($bbpress_restrictions_enable && $bbpress_installed && $post->post_type === $bbpress_topic_post_type && $bbpress_topic_forum_id) for($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) // Forum restrictions. { if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_posts'] && in_array($bbpress_topic_forum_id, preg_split('/['."\r\n\t".'\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_posts'])) && 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', $bbpress_topic_forum_id, 'level', $n, $_SERVER['REQUEST_URI']).exit (); } for($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) // Category Level restrictions. { if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_catgs'] === 'all' && 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'], 'catg').exit (); else if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_catgs'] && (in_category(($catgs = preg_split('/['."\r\n\t".'\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_catgs'])), $post_id) || c_ws_plugin__s2member_utils_conds::in_descendant_category($catgs, $post_id)) && 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'], 'catg').exit (); } if(has_tag()) // Here we take a look to see if this Post has any Tags. If so, we need to run the full set of routines against Tags also. { for($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) // Tag Level restrictions. { if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ptags'] === 'all' && 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'], 'ptag').exit (); else if($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ptags'] && has_tag(preg_split('/['."\r\n\t".';,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$n.'_ptags'])) && 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'], 'ptag').exit (); } } for($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) // URIs. { 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, '/').'/'.$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')) { foreach($ccaps_req as $ccap) // The ``$user`` MUST satisfy ALL Custom Capability requirements. Stored as an array of Custom Capabilities. if(strlen($ccap) && (!$user || !$user->has_cap('access_s2member_ccap_'.$ccap)) /* Does this ``$user``, have this Custom Capability? */) c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'ccap', $ccap, $_SERVER['REQUEST_URI'], 'ccap').exit (); } if($bbpress_restrictions_enable && $bbpress_installed && $post->post_type === $bbpress_topic_post_type && $bbpress_topic_forum_id) if(is_array($ccaps_req = get_post_meta($bbpress_topic_forum_id, 's2member_ccaps_req', TRUE)) && !empty($ccaps_req) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted')) { foreach($ccaps_req as $ccap) // The ``$user`` MUST satisfy ALL Custom Capability requirements. Stored as an array of Custom Capabilities. if(strlen($ccap) && (!$user || !$user->has_cap('access_s2member_ccap_'.$ccap)) /* Does this ``$user``, have this Custom Capability? */) c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $bbpress_topic_forum_id, 'ccap', $ccap, $_SERVER['REQUEST_URI'], 'ccap').exit (); } if($GLOBALS['WS_PLUGIN__']['s2member']['o']['specific_ids'] && in_array($post_id, preg_split('/['."\r\n\t".'\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['specific_ids'])) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && !c_ws_plugin__s2member_sp_access::sp_access($post_id)) c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'sp', $post_id, $_SERVER['REQUEST_URI'], 'sp').exit (); } do_action('ws_plugin__s2member_during_check_post_level_access', get_defined_vars()); } } do_action('ws_plugin__s2member_after_check_post_level_access', get_defined_vars()); } } }
Save Changes
Rename File
Rename