PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 110912
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v110912
260917 260913 260909 260829 260814 260805 110710 110731 110812 110815 110912 110913 110915 110926 110927 111002 111003 111011 111017 111029 111105 111206 111216 111220 120213 All 189 releases
s2member / includes / classes / ruris-sp.inc.php

ruris-sp.inc.php in s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions 110912, at includes/classes/ruris-sp.inc.php

74 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * s2Member's URI protection routines *( for specific URIs )*.
4 *
5 * Copyright: © 2009-2011
6 * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7 * ( coded in the USA )
8 *
9 * Released under the terms of the GNU General Public License.
10 * You should have received a copy of the GNU General Public License,
11 * along with this software. In the main directory, see: /licensing/
12 * If not, see: {@link http://www.gnu.org/licenses/}.
13 *
14 * @package s2Member\URIs
15 * @since 3.5
16 */
17 if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18 exit("Do not access this file directly.");
19 /**/
20 if (!class_exists ("c_ws_plugin__s2member_ruris_sp"))
21 {
22 /**
23 * s2Member's URI protection routines *( for specific URIs )*.
24 *
25 * @package s2Member\URIs
26 * @since 3.5
27 */
28 class c_ws_plugin__s2member_ruris_sp
29 {
30 /**
31 * Handles URI Level Access *( for specific URIs )*.
32 *
33 * @package s2Member\URIs
34 * @since 3.5
35 *
36 * @param str $_uri A URI, or a full URL is also fine.
37 * @param bool $check_user Test permissions against the current User? Defaults to true.
38 * @return null|array Non-empty array ( with details ) if access is denied, else null if access is allowed.
39 */
40 public static function check_specific_ruri_level_access ($_uri = FALSE, $check_user = TRUE)
41 {
42 do_action ("ws_plugin__s2member_before_check_specific_ruri_level_access", get_defined_vars ());
43 /**/
44 if ($_uri && is_string ($_uri)) /* Could be a full URL too. */
45 $uri = c_ws_plugin__s2member_utils_urls::parse_uri ($_uri);
46 /**/
47 $excluded = apply_filters ("ws_plugin__s2member_check_specific_ruri_level_access_excluded", false, get_defined_vars ());
48 /**/
49 if (!$excluded && !empty ($uri) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
50 {
51 $user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
52 /**/
53 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, "/") . "$/", $uri) && (!$check_user || !$user || !current_user_can ("access_s2member_level0")))
54 return apply_filters ("ws_plugin__s2member_check_specific_ruri_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
55 /**/
56 else if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page (null, $uri)) /* Never restrict Systematics. However, there is 1 exception ^. */
57 {
58 for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* URIs. Go through each Level. */
59 {
60 if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"])
61 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)
62 if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $uri) && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
63 return apply_filters ("ws_plugin__s2member_check_specific_ruri_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
64 }
65 }
66 /**/
67 do_action ("ws_plugin__s2member_during_check_specific_ruri_level_access", get_defined_vars ());
68 }
69 /**/
70 return apply_filters ("ws_plugin__s2member_check_specific_ruri_level_access", null, get_defined_vars ());
71 }
72 }
73 }
74 ?>