Version Description
- Over 100 new Hooks/Filters have been added to the s2Member framework. Many of these Hooks/Filters now pass variables by reference.
- All of s2Member's function calls have been wrapped inside
if(!function_exists()){}
. This gives developers the ability to override built-in functions - as needed. We suggest using Hooks/Filters, but when all else fails, you can now override built-in functions. - IMPORTANT: ( Attention Developers ) All of s2Member's internal Hooks/Filters have been prefixed with
ws_plugin__
starting with v3.0.4. Given the number of Hooks/Filters spread throughout the s2Member framework ( now over 200 ); it was important to establish a standard for prefixing all Hooks/Filters. This will prevent future namespace clashes. If you've hooked into s2Member using your own custom programming routines, please update all of your Hooks/Filters by prefixing them withws_plugin__
. - Security fix. It was possible for a Customer to use a Registration Access Link generated by s2Member; coming from a previously canceled purchased, to re-register under certain circumstances. This has been resolved in v3.0.4.
Download this release
Release Info
Developer | PriMoThemes |
Plugin | ![]() |
Version | 3.0.4 |
Comparing to | |
See all releases |
Code changes from version 3.0.2 to 3.0.4
- images/brand-donations.fla +0 -0
- images/brand-donations.jpg +0 -0
- includes/codes.inc.php +21 -0
- includes/funcs.inc.php +6 -6
- includes/functions/activate-deactivate.inc.php +165 -159
- includes/functions/admin-lockout.inc.php +15 -12
- includes/functions/admin-notices.inc.php +68 -45
- includes/functions/auto-eots.inc.php +130 -104
- includes/functions/catg-level-access.inc.php +84 -81
- includes/functions/constants.inc.php +178 -159
- includes/functions/email-configs.inc.php +26 -17
- includes/functions/file-download-access.inc.php +184 -170
- includes/functions/hide-some-systematics.inc.php +18 -9
- includes/functions/ip-restrictions.inc.php +44 -34
- includes/functions/is-systematic.inc.php +44 -43
- includes/functions/js-globals.inc.php +122 -106
- includes/functions/list-servers.inc.php +46 -34
- includes/functions/login-customizations.inc.php +63 -46
- includes/functions/login-redirection.inc.php +42 -28
- includes/functions/menu-pages.inc.php +333 -253
- includes/functions/nocache.inc.php +44 -33
- includes/functions/page-level-access.inc.php +46 -43
- includes/functions/paypal-notify.inc.php +588 -517
- includes/functions/paypal-return.inc.php +312 -261
- includes/functions/paypal-utilities.inc.php +166 -132
- includes/functions/post-level-access.inc.php +46 -43
- includes/functions/profile-modifications.inc.php +56 -46
- includes/functions/ptag-level-access.inc.php +68 -65
- includes/functions/readme-parsing.inc.php +85 -66
- includes/functions/register-access.inc.php +394 -293
- includes/functions/ruri-level-access.inc.php +47 -39
- includes/functions/shortcodes.inc.php +97 -87
- includes/functions/sp-access.inc.php +83 -62
- includes/functions/tracking-codes.inc.php +72 -56
- includes/functions/translations.inc.php +31 -34
- includes/functions/user-access-level.inc.php +32 -31
- includes/functions/user-deletions.inc.php +31 -22
- includes/functions/user-has-wp-role.inc.php +21 -16
- includes/functions/user-notes.inc.php +41 -22
- includes/functions/users-list.inc.php +225 -141
- includes/functions/utilities.inc.php +273 -222
- includes/hooks.inc.php +2 -3
- includes/menu-pages/api-ops.inc.php +370 -317
- includes/menu-pages/buttons.inc.php +596 -518
- includes/menu-pages/down-ops.inc.php +198 -167
- includes/menu-pages/els-ops.inc.php +327 -288
- includes/menu-pages/info.inc.php +26 -11
- includes/menu-pages/menu-pages-s.js +261 -0
- includes/menu-pages/menu-pages.css +27 -45
- includes/menu-pages/menu-pages.js +3 -248
- includes/menu-pages/options.inc.php +730 -1114
images/brand-donations.fla
CHANGED
Binary file
|
images/brand-donations.jpg
CHANGED
Binary file
|
includes/codes.inc.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
|
4 |
+
<mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
|
5 |
+
|
6 |
+
Released under the terms of the GNU General Public License.
|
7 |
+
You should have received a copy of the GNU General Public License,
|
8 |
+
along with this software. In the main directory, see: /licensing/
|
9 |
+
If not, see: <http://www.gnu.org/licenses/>.
|
10 |
+
*/
|
11 |
+
/*
|
12 |
+
Direct access denial.
|
13 |
+
*/
|
14 |
+
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
15 |
+
exit;
|
16 |
+
/*
|
17 |
+
Add WordPress® Editor Shortcodes.
|
18 |
+
http://codex.wordpress.org/Shortcode_API
|
19 |
+
*/
|
20 |
+
add_shortcode ("s2Member-PayPal-Button", "ws_plugin__s2member_paypal_button");
|
21 |
+
?>
|
includes/funcs.inc.php
CHANGED
@@ -11,14 +11,14 @@ If not, see: <http://www.gnu.org/licenses/>.
|
|
11 |
/*
|
12 |
Direct access denial.
|
13 |
*/
|
14 |
-
if (realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
|
15 |
exit;
|
16 |
/*
|
17 |
Include all of the functions that came with this plugin.
|
18 |
*/
|
19 |
-
if (is_dir(dirname(__FILE__) . "/functions"))
|
20 |
-
if ($ws_plugin__s2member_temp_r = opendir(dirname(__FILE__) . "/functions"))
|
21 |
-
while (($ws_plugin__s2member_temp_s = readdir($ws_plugin__s2member_temp_r)) !== false)
|
22 |
-
if (preg_match("/\.php$/", $ws_plugin__s2member_temp_s) && !preg_match("/^index\.php$/i", $ws_plugin__s2member_temp_s))
|
23 |
-
include_once dirname(__FILE__) . "/functions/" . $ws_plugin__s2member_temp_s;
|
24 |
?>
|
11 |
/*
|
12 |
Direct access denial.
|
13 |
*/
|
14 |
+
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
15 |
exit;
|
16 |
/*
|
17 |
Include all of the functions that came with this plugin.
|
18 |
*/
|
19 |
+
if (is_dir (dirname (__FILE__) . "/functions"))
|
20 |
+
if ($ws_plugin__s2member_temp_r = opendir (dirname (__FILE__) . "/functions"))
|
21 |
+
while (($ws_plugin__s2member_temp_s = readdir ($ws_plugin__s2member_temp_r)) !== false)
|
22 |
+
if (preg_match ("/\.php$/", $ws_plugin__s2member_temp_s) && !preg_match ("/^index\.php$/i", $ws_plugin__s2member_temp_s))
|
23 |
+
include_once dirname (__FILE__) . "/functions/" . $ws_plugin__s2member_temp_s;
|
24 |
?>
|
includes/functions/activate-deactivate.inc.php
CHANGED
@@ -23,186 +23,192 @@ Initializing these options will force them to be
|
|
23 |
autoloaded into WordPress® instead of generating
|
24 |
extra queries before they are set.
|
25 |
*/
|
26 |
-
|
27 |
{
|
28 |
-
|
29 |
-
/**/
|
30 |
-
add_role ("s2member_level1", "s2Member Level 1");
|
31 |
-
add_role ("s2member_level2", "s2Member Level 2");
|
32 |
-
add_role ("s2member_level3", "s2Member Level 3");
|
33 |
-
add_role ("s2member_level4", "s2Member Level 4");
|
34 |
-
/**/
|
35 |
-
$role = &get_role ("s2member_level1");
|
36 |
-
$role->add_cap ("read");
|
37 |
-
$role->add_cap ("level_0");
|
38 |
-
$role->add_cap ("access_s2member_level1");
|
39 |
-
/**/
|
40 |
-
$role = &get_role ("s2member_level2");
|
41 |
-
$role->add_cap ("read");
|
42 |
-
$role->add_cap ("level_0");
|
43 |
-
$role->add_cap ("access_s2member_level2");
|
44 |
-
$role->add_cap ("access_s2member_level1");
|
45 |
-
/**/
|
46 |
-
$role = &get_role ("s2member_level3");
|
47 |
-
$role->add_cap ("read");
|
48 |
-
$role->add_cap ("level_0");
|
49 |
-
$role->add_cap ("access_s2member_level3");
|
50 |
-
$role->add_cap ("access_s2member_level2");
|
51 |
-
$role->add_cap ("access_s2member_level1");
|
52 |
-
/**/
|
53 |
-
$role = &get_role ("s2member_level4");
|
54 |
-
$role->add_cap ("read");
|
55 |
-
$role->add_cap ("level_0");
|
56 |
-
$role->add_cap ("access_s2member_level4");
|
57 |
-
$role->add_cap ("access_s2member_level3");
|
58 |
-
$role->add_cap ("access_s2member_level2");
|
59 |
-
$role->add_cap ("access_s2member_level1");
|
60 |
-
/**/
|
61 |
-
$role = &get_role ("administrator");
|
62 |
-
$role->add_cap ("access_s2member_level1");
|
63 |
-
$role->add_cap ("access_s2member_level2");
|
64 |
-
$role->add_cap ("access_s2member_level3");
|
65 |
-
$role->add_cap ("access_s2member_level4");
|
66 |
-
/**/
|
67 |
-
$role = &get_role ("editor");
|
68 |
-
$role->add_cap ("access_s2member_level1");
|
69 |
-
$role->add_cap ("access_s2member_level2");
|
70 |
-
$role->add_cap ("access_s2member_level3");
|
71 |
-
$role->add_cap ("access_s2member_level4");
|
72 |
-
/**/
|
73 |
-
$role = &get_role ("author");
|
74 |
-
$role->add_cap ("access_s2member_level1");
|
75 |
-
$role->add_cap ("access_s2member_level2");
|
76 |
-
$role->add_cap ("access_s2member_level3");
|
77 |
-
$role->add_cap ("access_s2member_level4");
|
78 |
-
/**/
|
79 |
-
$role = &get_role ("contributor");
|
80 |
-
$role->add_cap ("access_s2member_level1");
|
81 |
-
$role->add_cap ("access_s2member_level2");
|
82 |
-
$role->add_cap ("access_s2member_level3");
|
83 |
-
$role->add_cap ("access_s2member_level4");
|
84 |
-
/**/
|
85 |
-
if (!is_dir ($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]))
|
86 |
-
if (is_writable (dirname ($files_dir)))
|
87 |
-
mkdir ($files_dir, 0777);
|
88 |
-
/**/
|
89 |
-
if (is_dir ($files_dir) && is_writable ($files_dir))
|
90 |
-
if (!file_exists ($htaccess = $files_dir . "/.htaccess"))
|
91 |
-
file_put_contents ($htaccess, "deny from all");
|
92 |
-
/**/
|
93 |
-
if (!is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
94 |
-
if (is_writable (dirname ($logs_dir)))
|
95 |
-
mkdir ($logs_dir, 0777);
|
96 |
-
/**/
|
97 |
-
if (is_dir ($logs_dir) && is_writable ($logs_dir))
|
98 |
-
if (!file_exists ($htaccess = $logs_dir . "/.htaccess"))
|
99 |
-
file_put_contents ($htaccess, "deny from all");
|
100 |
-
/**/
|
101 |
-
if (!is_numeric (get_option ("ws_plugin__s2member_configured")))
|
102 |
-
update_option ("ws_plugin__s2member_configured", "0");
|
103 |
-
/**/
|
104 |
-
if (!is_array (get_option ("ws_plugin__s2member_cache")))
|
105 |
-
update_option ("ws_plugin__s2member_cache", array ());
|
106 |
-
/**/
|
107 |
-
if (!is_array (get_option ("ws_plugin__s2member_notices")))
|
108 |
-
update_option ("ws_plugin__s2member_notices", array ());
|
109 |
-
/**/
|
110 |
-
if (!is_array (get_option ("ws_plugin__s2member_options")))
|
111 |
-
update_option ("ws_plugin__s2member_options", array ());
|
112 |
-
/**/
|
113 |
-
if (get_option ("ws_plugin__s2member_configured")) /* If they already have s2Member configured, read the Changelog. */
|
114 |
{
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
$
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
|
|
|
|
145 |
/**/
|
146 |
$role = &get_role ("administrator");
|
147 |
-
$role->
|
148 |
-
$role->
|
149 |
-
$role->
|
150 |
-
$role->
|
151 |
/**/
|
152 |
$role = &get_role ("editor");
|
153 |
-
$role->
|
154 |
-
$role->
|
155 |
-
$role->
|
156 |
-
$role->
|
157 |
/**/
|
158 |
$role = &get_role ("author");
|
159 |
-
$role->
|
160 |
-
$role->
|
161 |
-
$role->
|
162 |
-
$role->
|
163 |
/**/
|
164 |
$role = &get_role ("contributor");
|
165 |
-
$role->
|
166 |
-
$role->
|
167 |
-
$role->
|
168 |
-
$role->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
/**/
|
170 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
{
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
/**/
|
176 |
-
@rmdir ($files_dir);
|
177 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
/**/
|
179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
{
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
/**/
|
185 |
-
if (
|
186 |
-
|
187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
/**/
|
189 |
-
|
190 |
-
|
191 |
-
|
|
|
192 |
/**/
|
193 |
-
|
194 |
}
|
195 |
/**/
|
196 |
-
|
197 |
-
delete_option ("ws_plugin__s2member_cache");
|
198 |
-
delete_option ("ws_plugin__s2member_notices");
|
199 |
-
delete_option ("ws_plugin__s2member_options");
|
200 |
/**/
|
201 |
-
|
202 |
}
|
203 |
-
/**/
|
204 |
-
do_action ("s2member_after_deactivation", get_defined_vars ());
|
205 |
-
/**/
|
206 |
-
return;
|
207 |
}
|
208 |
?>
|
23 |
autoloaded into WordPress® instead of generating
|
24 |
extra queries before they are set.
|
25 |
*/
|
26 |
+
if (!function_exists ("ws_plugin__s2member_activate"))
|
27 |
{
|
28 |
+
function ws_plugin__s2member_activate ()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
{
|
30 |
+
do_action ("ws_plugin__s2member_before_activation", get_defined_vars ());
|
31 |
+
/**/
|
32 |
+
add_role ("s2member_level1", "s2Member Level 1");
|
33 |
+
add_role ("s2member_level2", "s2Member Level 2");
|
34 |
+
add_role ("s2member_level3", "s2Member Level 3");
|
35 |
+
add_role ("s2member_level4", "s2Member Level 4");
|
36 |
+
/**/
|
37 |
+
$role = &get_role ("s2member_level1");
|
38 |
+
$role->add_cap ("read");
|
39 |
+
$role->add_cap ("level_0");
|
40 |
+
$role->add_cap ("access_s2member_level1");
|
41 |
+
/**/
|
42 |
+
$role = &get_role ("s2member_level2");
|
43 |
+
$role->add_cap ("read");
|
44 |
+
$role->add_cap ("level_0");
|
45 |
+
$role->add_cap ("access_s2member_level2");
|
46 |
+
$role->add_cap ("access_s2member_level1");
|
47 |
+
/**/
|
48 |
+
$role = &get_role ("s2member_level3");
|
49 |
+
$role->add_cap ("read");
|
50 |
+
$role->add_cap ("level_0");
|
51 |
+
$role->add_cap ("access_s2member_level3");
|
52 |
+
$role->add_cap ("access_s2member_level2");
|
53 |
+
$role->add_cap ("access_s2member_level1");
|
54 |
+
/**/
|
55 |
+
$role = &get_role ("s2member_level4");
|
56 |
+
$role->add_cap ("read");
|
57 |
+
$role->add_cap ("level_0");
|
58 |
+
$role->add_cap ("access_s2member_level4");
|
59 |
+
$role->add_cap ("access_s2member_level3");
|
60 |
+
$role->add_cap ("access_s2member_level2");
|
61 |
+
$role->add_cap ("access_s2member_level1");
|
62 |
/**/
|
63 |
$role = &get_role ("administrator");
|
64 |
+
$role->add_cap ("access_s2member_level1");
|
65 |
+
$role->add_cap ("access_s2member_level2");
|
66 |
+
$role->add_cap ("access_s2member_level3");
|
67 |
+
$role->add_cap ("access_s2member_level4");
|
68 |
/**/
|
69 |
$role = &get_role ("editor");
|
70 |
+
$role->add_cap ("access_s2member_level1");
|
71 |
+
$role->add_cap ("access_s2member_level2");
|
72 |
+
$role->add_cap ("access_s2member_level3");
|
73 |
+
$role->add_cap ("access_s2member_level4");
|
74 |
/**/
|
75 |
$role = &get_role ("author");
|
76 |
+
$role->add_cap ("access_s2member_level1");
|
77 |
+
$role->add_cap ("access_s2member_level2");
|
78 |
+
$role->add_cap ("access_s2member_level3");
|
79 |
+
$role->add_cap ("access_s2member_level4");
|
80 |
/**/
|
81 |
$role = &get_role ("contributor");
|
82 |
+
$role->add_cap ("access_s2member_level1");
|
83 |
+
$role->add_cap ("access_s2member_level2");
|
84 |
+
$role->add_cap ("access_s2member_level3");
|
85 |
+
$role->add_cap ("access_s2member_level4");
|
86 |
+
/**/
|
87 |
+
if (!is_dir ($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]))
|
88 |
+
if (is_writable (dirname ($files_dir)))
|
89 |
+
mkdir ($files_dir, 0777);
|
90 |
+
/**/
|
91 |
+
if (is_dir ($files_dir) && is_writable ($files_dir))
|
92 |
+
if (!file_exists ($htaccess = $files_dir . "/.htaccess"))
|
93 |
+
file_put_contents ($htaccess, "deny from all");
|
94 |
+
/**/
|
95 |
+
if (!is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
96 |
+
if (is_writable (dirname ($logs_dir)))
|
97 |
+
mkdir ($logs_dir, 0777);
|
98 |
+
/**/
|
99 |
+
if (is_dir ($logs_dir) && is_writable ($logs_dir))
|
100 |
+
if (!file_exists ($htaccess = $logs_dir . "/.htaccess"))
|
101 |
+
file_put_contents ($htaccess, "deny from all");
|
102 |
+
/**/
|
103 |
+
if (!is_numeric (get_option ("ws_plugin__s2member_configured")))
|
104 |
+
update_option ("ws_plugin__s2member_configured", "0");
|
105 |
+
/**/
|
106 |
+
if (!is_array (get_option ("ws_plugin__s2member_cache")))
|
107 |
+
update_option ("ws_plugin__s2member_cache", array ());
|
108 |
/**/
|
109 |
+
if (!is_array (get_option ("ws_plugin__s2member_notices")))
|
110 |
+
update_option ("ws_plugin__s2member_notices", array ());
|
111 |
+
/**/
|
112 |
+
if (!is_array (get_option ("ws_plugin__s2member_options")))
|
113 |
+
update_option ("ws_plugin__s2member_options", array ());
|
114 |
+
/**/
|
115 |
+
if (get_option ("ws_plugin__s2member_configured")) /* If they already have s2Member configured, read the Changelog. */
|
116 |
{
|
117 |
+
$notice = '<strong>s2Member</strong> has been <strong>re-activated</strong>, with the latest version. Your existing configuration remains intact.<br />';
|
118 |
+
$notice .= 'Have fun, <a href="admin.php?page=ws-plugin--s2member-info">read the Changelog</a>, and make some money! :-)';
|
119 |
+
ws_plugin__s2member_enqueue_admin_notice ($notice, array ("plugins.php", "ws-plugin--s2member-options"));
|
|
|
|
|
120 |
}
|
121 |
+
else /* Otherwise, we'll help the site owner out by giving them a link to the Quick Start Guide. */
|
122 |
+
{
|
123 |
+
$notice = '<strong>s2Member</strong> has been <strong>activated</strong>, with the latest version. Nice work!<br />';
|
124 |
+
$notice .= 'Have fun, <a href="admin.php?page=ws-plugin--s2member-start">read the Quick Start Guide</a>, and make some money! :-)';
|
125 |
+
ws_plugin__s2member_enqueue_admin_notice ($notice, array ("plugins.php", "ws-plugin--s2member-options"));
|
126 |
+
}
|
127 |
+
/**/
|
128 |
+
do_action ("ws_plugin__s2member_after_activation", get_defined_vars ());
|
129 |
/**/
|
130 |
+
return;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
/*
|
134 |
+
Function for handling de-activation cleanup routines.
|
135 |
+
This function should match the array key for this plugin:
|
136 |
+
ws_plugin__$plugin_key_deactivate() is called by our themes.
|
137 |
+
*/
|
138 |
+
if (!function_exists ("ws_plugin__s2member_deactivate"))
|
139 |
+
{
|
140 |
+
function ws_plugin__s2member_deactivate ()
|
141 |
+
{
|
142 |
+
do_action ("ws_plugin__s2member_before_deactivation", get_defined_vars ());
|
143 |
+
/**/
|
144 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["run_deactivation_routines"])
|
145 |
{
|
146 |
+
remove_role ("s2member_level1");
|
147 |
+
remove_role ("s2member_level2");
|
148 |
+
remove_role ("s2member_level3");
|
149 |
+
remove_role ("s2member_level4");
|
150 |
+
/**/
|
151 |
+
$role = &get_role ("administrator");
|
152 |
+
$role->remove_cap ("access_s2member_level1");
|
153 |
+
$role->remove_cap ("access_s2member_level2");
|
154 |
+
$role->remove_cap ("access_s2member_level3");
|
155 |
+
$role->remove_cap ("access_s2member_level4");
|
156 |
+
/**/
|
157 |
+
$role = &get_role ("editor");
|
158 |
+
$role->remove_cap ("access_s2member_level1");
|
159 |
+
$role->remove_cap ("access_s2member_level2");
|
160 |
+
$role->remove_cap ("access_s2member_level3");
|
161 |
+
$role->remove_cap ("access_s2member_level4");
|
162 |
+
/**/
|
163 |
+
$role = &get_role ("author");
|
164 |
+
$role->remove_cap ("access_s2member_level1");
|
165 |
+
$role->remove_cap ("access_s2member_level2");
|
166 |
+
$role->remove_cap ("access_s2member_level3");
|
167 |
+
$role->remove_cap ("access_s2member_level4");
|
168 |
+
/**/
|
169 |
+
$role = &get_role ("contributor");
|
170 |
+
$role->remove_cap ("access_s2member_level1");
|
171 |
+
$role->remove_cap ("access_s2member_level2");
|
172 |
+
$role->remove_cap ("access_s2member_level3");
|
173 |
+
$role->remove_cap ("access_s2member_level4");
|
174 |
+
/**/
|
175 |
+
if (is_dir ($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]))
|
176 |
+
{
|
177 |
+
if (file_exists ($htaccess = $files_dir . "/.htaccess"))
|
178 |
+
if (is_writable ($htaccess))
|
179 |
+
unlink ($htaccess);
|
180 |
+
/**/
|
181 |
+
@rmdir ($files_dir);
|
182 |
+
}
|
183 |
/**/
|
184 |
+
if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
|
185 |
+
{
|
186 |
+
if (file_exists ($htaccess = $logs_dir . "/.htaccess"))
|
187 |
+
if (is_writable ($htaccess))
|
188 |
+
unlink ($htaccess);
|
189 |
+
/**/
|
190 |
+
if (file_exists ($log = $logs_dir . "/paypal-ipn.log"))
|
191 |
+
if (is_writable ($log))
|
192 |
+
unlink ($log);
|
193 |
+
/**/
|
194 |
+
if (file_exists ($log = $logs_dir . "/paypal-rtn.log"))
|
195 |
+
if (is_writable ($log))
|
196 |
+
unlink ($log);
|
197 |
+
/**/
|
198 |
+
@rmdir ($logs_dir);
|
199 |
+
}
|
200 |
/**/
|
201 |
+
delete_option ("ws_plugin__s2member_configured");
|
202 |
+
delete_option ("ws_plugin__s2member_cache");
|
203 |
+
delete_option ("ws_plugin__s2member_notices");
|
204 |
+
delete_option ("ws_plugin__s2member_options");
|
205 |
/**/
|
206 |
+
do_action ("ws_plugin__s2member_during_deactivation", get_defined_vars ());
|
207 |
}
|
208 |
/**/
|
209 |
+
do_action ("ws_plugin__s2member_after_deactivation", get_defined_vars ());
|
|
|
|
|
|
|
210 |
/**/
|
211 |
+
return;
|
212 |
}
|
|
|
|
|
|
|
|
|
213 |
}
|
214 |
?>
|
includes/functions/admin-lockout.inc.php
CHANGED
@@ -17,18 +17,21 @@ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
|
17 |
Function for handling admin lockouts.
|
18 |
Attach to: add_action("admin_init");
|
19 |
*/
|
20 |
-
|
21 |
{
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
33 |
}
|
34 |
?>
|
17 |
Function for handling admin lockouts.
|
18 |
Attach to: add_action("admin_init");
|
19 |
*/
|
20 |
+
if (!function_exists ("ws_plugin__s2member_admin_lockout"))
|
21 |
{
|
22 |
+
function ws_plugin__s2member_admin_lockout ()
|
23 |
+
{
|
24 |
+
do_action ("ws_plugin__s2member_before_admin_lockouts", get_defined_vars ());
|
25 |
+
/**/
|
26 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"]/**/
|
27 |
+
&& !current_user_can ("edit_posts") /* In other words: Subscribers and Members. */
|
28 |
+
&& apply_filters ("ws_plugin__s2member_admin_lockout", true, get_defined_vars ()) && /* Give filters a chance. */
|
29 |
+
wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])) !== "nill")
|
30 |
+
exit;
|
31 |
+
/**/
|
32 |
+
do_action ("ws_plugin__s2member_after_admin_lockouts", get_defined_vars ());
|
33 |
+
/**/
|
34 |
+
return;
|
35 |
+
}
|
36 |
}
|
37 |
?>
|
includes/functions/admin-notices.inc.php
CHANGED
@@ -16,79 +16,102 @@ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
|
16 |
/*
|
17 |
Function displays an admin notice immediately.
|
18 |
*/
|
19 |
-
|
20 |
{
|
21 |
-
|
22 |
-
/**/
|
23 |
-
if ($notice && $error) /* Special format for errors. */
|
24 |
{
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
-
/**/
|
32 |
-
do_action ("s2member_after_display_admin_notice", get_defined_vars ());
|
33 |
-
/**/
|
34 |
-
return;
|
35 |
}
|
36 |
/*
|
37 |
Function that enqueues admin notices.
|
38 |
*/
|
39 |
-
|
40 |
{
|
41 |
-
|
42 |
-
/**/
|
43 |
-
if ($notice && is_string ($notice)) /* If we have a valid string. */
|
44 |
{
|
45 |
-
|
|
|
|
|
46 |
/**/
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
/**/
|
49 |
-
do_action ("
|
50 |
/**/
|
51 |
-
|
52 |
}
|
53 |
-
/**/
|
54 |
-
do_action ("s2member_after_enqueue_admin_notice", get_defined_vars ());
|
55 |
-
/**/
|
56 |
-
return;
|
57 |
}
|
58 |
/*
|
59 |
Function that displays admin notices.
|
60 |
Attach to: add_action("admin_notices");
|
61 |
*/
|
62 |
-
|
63 |
{
|
64 |
-
|
65 |
-
/**/
|
66 |
-
do_action ("s2member_before_admin_notices", get_defined_vars ());
|
67 |
-
/**/
|
68 |
-
if (is_array ($notices = get_option ("ws_plugin__s2member_notices")) && !empty ($notices))
|
69 |
{
|
70 |
-
|
|
|
|
|
|
|
|
|
71 |
{
|
72 |
-
|
73 |
{
|
74 |
-
if (
|
75 |
{
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
80 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
}
|
82 |
/**/
|
83 |
-
do_action ("
|
84 |
-
/**/
|
85 |
-
$notices = array_merge ($notices); /* Re-index. */
|
86 |
/**/
|
87 |
-
|
88 |
}
|
89 |
-
/**/
|
90 |
-
do_action ("s2member_after_admin_notices", get_defined_vars ());
|
91 |
-
/**/
|
92 |
-
return;
|
93 |
}
|
94 |
?>
|
16 |
/*
|
17 |
Function displays an admin notice immediately.
|
18 |
*/
|
19 |
+
if (!function_exists ("ws_plugin__s2member_display_admin_notice"))
|
20 |
{
|
21 |
+
function ws_plugin__s2member_display_admin_notice ($notice = FALSE, $error = FALSE)
|
|
|
|
|
22 |
{
|
23 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
24 |
+
do_action ("ws_plugin__s2member_before_display_admin_notice", get_defined_vars ());
|
25 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
26 |
+
/**/
|
27 |
+
if ($notice && $error) /* Special format for errors. */
|
28 |
+
{
|
29 |
+
echo '<div class="error fade"><p>' . $notice . '</p></div>';
|
30 |
+
}
|
31 |
+
else if ($notice) /* Otherwise, we just send it as an update notice. */
|
32 |
+
{
|
33 |
+
echo '<div class="updated fade"><p>' . $notice . '</p></div>';
|
34 |
+
}
|
35 |
+
/**/
|
36 |
+
do_action ("ws_plugin__s2member_after_display_admin_notice", get_defined_vars ());
|
37 |
+
/**/
|
38 |
+
return;
|
39 |
}
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
/*
|
42 |
Function that enqueues admin notices.
|
43 |
*/
|
44 |
+
if (!function_exists ("ws_plugin__s2member_enqueue_admin_notice"))
|
45 |
{
|
46 |
+
function ws_plugin__s2member_enqueue_admin_notice ($notice = FALSE, $on_pages = FALSE, $error = FALSE, $time = FALSE)
|
|
|
|
|
47 |
{
|
48 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
49 |
+
do_action ("ws_plugin__s2member_before_enqueue_admin_notice", get_defined_vars ());
|
50 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
51 |
/**/
|
52 |
+
if ($notice && is_string ($notice)) /* If we have a valid string. */
|
53 |
+
{
|
54 |
+
$notices = (array)get_option ("ws_plugin__s2member_notices");
|
55 |
+
/**/
|
56 |
+
array_push ($notices, array ("notice" => $notice, "on_pages" => $on_pages, "error" => $error, "time" => $time));
|
57 |
+
/**/
|
58 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
59 |
+
do_action ("ws_plugin__s2member_during_enqueue_admin_notice", get_defined_vars ());
|
60 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
61 |
+
/**/
|
62 |
+
update_option ("ws_plugin__s2member_notices", ws_plugin__s2member_array_unique ($notices));
|
63 |
+
}
|
64 |
/**/
|
65 |
+
do_action ("ws_plugin__s2member_after_enqueue_admin_notice", get_defined_vars ());
|
66 |
/**/
|
67 |
+
return;
|
68 |
}
|
|
|
|
|
|
|
|
|
69 |
}
|
70 |
/*
|
71 |
Function that displays admin notices.
|
72 |
Attach to: add_action("admin_notices");
|
73 |
*/
|
74 |
+
if (!function_exists ("ws_plugin__s2member_admin_notices"))
|
75 |
{
|
76 |
+
function ws_plugin__s2member_admin_notices ()
|
|
|
|
|
|
|
|
|
77 |
{
|
78 |
+
global $pagenow; /* This holds the current page filename. */
|
79 |
+
/**/
|
80 |
+
do_action ("ws_plugin__s2member_before_admin_notices", get_defined_vars ());
|
81 |
+
/**/
|
82 |
+
if (is_array ($notices = get_option ("ws_plugin__s2member_notices")) && !empty ($notices))
|
83 |
{
|
84 |
+
foreach ($notices as $key => $notice) /* Check time on each notice. */
|
85 |
{
|
86 |
+
if (empty ($notice["on_pages"]) || $pagenow === $notice["on_pages"] || in_array ($pagenow, (array)$notice["on_pages"]) || $_GET["page"] === $notice["on_pages"] || in_array ($_GET["page"], (array)$notice["on_pages"]))
|
87 |
{
|
88 |
+
if (strtotime ("now") >= $notice["time"]) /* Time to show it? */
|
89 |
+
{
|
90 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
91 |
+
do_action ("ws_plugin__s2member_during_admin_notices_before_display", get_defined_vars ());
|
92 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
93 |
+
/**/
|
94 |
+
unset ($notices[$key]); /* Clear this notice & display it. */
|
95 |
+
/**/
|
96 |
+
ws_plugin__s2member_display_admin_notice ($notice["notice"], $notice["error"]);
|
97 |
+
/**/
|
98 |
+
do_action ("ws_plugin__s2member_during_admin_notices_after_display", get_defined_vars ());
|
99 |
+
}
|
100 |
}
|
101 |
}
|
102 |
+
/**/
|
103 |
+
$notices = array_merge ($notices); /* Re-index. */
|
104 |
+
/**/
|
105 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
106 |
+
do_action ("ws_plugin__s2member_during_admin_notices", get_defined_vars ());
|
107 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
108 |
+
/**/
|
109 |
+
update_option ("ws_plugin__s2member_notices", $notices);
|
110 |
}
|
111 |
/**/
|
112 |
+
do_action ("ws_plugin__s2member_after_admin_notices", get_defined_vars ());
|
|
|
|
|
113 |
/**/
|
114 |
+
return;
|
115 |
}
|
|
|
|
|
|
|
|
|
116 |
}
|
117 |
?>
|
includes/functions/auto-eots.inc.php
CHANGED
@@ -16,160 +16,186 @@ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
|
16 |
/*
|
17 |
Function processed by WP-Cron. This handles Auto-EOTs.
|
18 |
If you have a HUGE user-base, increase the max eots per process.
|
19 |
-
To increase, use: add_filter("
|
20 |
*/
|
21 |
-
|
22 |
{
|
23 |
-
|
24 |
-
/**/
|
25 |
-
do_action ("s2member_before_auto_eot_system", get_defined_vars ());
|
26 |
-
/**/
|
27 |
-
include_once ABSPATH . "wp-admin/includes/admin.php"; /* Get Admin APIs. */
|
28 |
-
/**/
|
29 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"]) /* Enabled? */
|
30 |
{
|
31 |
-
$
|
32 |
/**/
|
33 |
-
|
|
|
|
|
|
|
|
|
34 |
{
|
35 |
-
|
|
|
|
|
36 |
{
|
37 |
-
$
|
38 |
-
/**/
|
39 |
-
$user = new WP_User ($user_id); /* Acquire user object. */
|
40 |
-
/**/
|
41 |
-
delete_usermeta ($user_id, "s2member_auto_eot_time"); /* Always delete this. */
|
42 |
-
/* Removing this prevents re-runs on non WP Roles. Which are scanned for next. */
|
43 |
-
/**/
|
44 |
-
if (!ws_plugin__s2member_user_has_wp_role ($user)) /* Non WP Roles. */
|
45 |
{
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
{
|
48 |
-
|
49 |
-
/**/
|
50 |
-
$subscr_id = get_usermeta ($user_id, "s2member_subscr_id");
|
51 |
-
$custom = get_usermeta ($user_id, "s2member_custom");
|
52 |
-
/**/
|
53 |
-
delete_usermeta ($user_id, "s2member_custom");
|
54 |
-
delete_usermeta ($user_id, "s2member_subscr_id");
|
55 |
-
delete_usermeta ($user_id, "s2member_last_payment_time");
|
56 |
-
delete_usermeta ($user_id, "s2member_auto_eot_time");
|
57 |
-
/**/
|
58 |
-
foreach ($user->allcaps as $cap => $cap_enabled)
|
59 |
-
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
60 |
-
$user->remove_cap ($ccap = $cap);
|
61 |
-
/**/
|
62 |
-
delete_usermeta ($user_id, "s2member_file_download_access_arc");
|
63 |
-
delete_usermeta ($user_id, "s2member_file_download_access_log");
|
64 |
-
/**/
|
65 |
-
ws_plugin__s2member_append_user_notes ($user_id, "Demoted by s2Member: " . date ("D M j, Y g:i a T"));
|
66 |
-
/**/
|
67 |
-
if ($subscr_id && $custom && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array ($cv = preg_split ("/\|/", $custom)))
|
68 |
{
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
}
|
79 |
/**/
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
{
|
84 |
-
wp_delete_user ($user_id); /* Triggers: `ws_plugin__s2member_handle_user_deletions()` */
|
85 |
-
/* `ws_plugin__s2member_handle_user_deletions()` triggers `eot_del_notification_urls` */
|
86 |
-
/**/
|
87 |
-
do_action ("s2member_during_auto_eot_system_during_delete", get_defined_vars ());
|
88 |
}
|
89 |
-
/**/
|
90 |
-
do_action ("s2member_during_auto_eot_system", get_defined_vars ());
|
91 |
}
|
92 |
}
|
93 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
}
|
95 |
-
/**/
|
96 |
-
do_action ("s2member_after_auto_eot_system", get_defined_vars ());
|
97 |
-
/**/
|
98 |
-
return;
|
99 |
}
|
100 |
/*
|
101 |
This function allows the Auto-EOT Sytem to be
|
102 |
processed through a server-side Cron Job.
|
103 |
Attach to: add_action("init");
|
104 |
*/
|
105 |
-
|
106 |
{
|
107 |
-
|
108 |
-
/**/
|
109 |
-
if ($_GET["s2member_auto_eot_system_via_cron"]) /* Being called through HTTP? */
|
110 |
{
|
111 |
-
|
|
|
|
|
112 |
{
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
114 |
/**/
|
115 |
-
|
116 |
}
|
117 |
/**/
|
118 |
-
|
119 |
}
|
120 |
-
/**/
|
121 |
-
do_action ("s2member_after_auto_eot_system_via_cron", get_defined_vars ());
|
122 |
}
|
123 |
/*
|
124 |
Extends the WP-Cron schedules to support 10 minute intervals.
|
125 |
Attach to: add_filter("cron_schedules");
|
126 |
*/
|
127 |
-
|
128 |
{
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
134 |
}
|
135 |
/*
|
136 |
Adds a scheduled task for s2Member's Auto-EOT System.
|
137 |
*/
|
138 |
-
|
139 |
{
|
140 |
-
|
141 |
-
/**/
|
142 |
-
if (!ws_plugin__s2member_delete_auto_eot_system ())
|
143 |
{
|
144 |
-
|
145 |
-
}
|
146 |
-
else if (function_exists ("wp_cron")) /* Otherwise, we can schedule. */
|
147 |
-
{
|
148 |
-
wp_schedule_event (time (), "every10m", "s2member_auto_eot_system");
|
149 |
/**/
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
}
|
156 |
}
|
157 |
/*
|
158 |
Delete scheduled tasks for s2Member's Auto-EOT System.
|
159 |
*/
|
160 |
-
|
161 |
{
|
162 |
-
|
163 |
-
/**/
|
164 |
-
if (function_exists ("wp_cron"))
|
165 |
{
|
166 |
-
|
167 |
/**/
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
}
|
174 |
}
|
175 |
?>
|
16 |
/*
|
17 |
Function processed by WP-Cron. This handles Auto-EOTs.
|
18 |
If you have a HUGE user-base, increase the max eots per process.
|
19 |
+
To increase, use: add_filter ("ws_plugin__s2member_auto_eot_system_per_process");
|
20 |
*/
|
21 |
+
if (!function_exists ("ws_plugin__s2member_auto_eot_system"))
|
22 |
{
|
23 |
+
function ws_plugin__s2member_auto_eot_system ($per_process = 10)
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
{
|
25 |
+
global $wpdb; /* Need global DB obj. */
|
26 |
/**/
|
27 |
+
include_once ABSPATH . "wp-admin/includes/admin.php";
|
28 |
+
/**/
|
29 |
+
do_action ("ws_plugin__s2member_before_auto_eot_system", get_defined_vars ());
|
30 |
+
/**/
|
31 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"]) /* Enabled? */
|
32 |
{
|
33 |
+
$per_process = apply_filters ("ws_plugin__s2member_auto_eot_system_per_process", $per_process, get_defined_vars ());
|
34 |
+
/**/
|
35 |
+
if ($eots = $wpdb->get_results ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = 's2member_auto_eot_time' AND `meta_value` <= '" . $wpdb->escape (strtotime ("now")) . "' LIMIT " . $per_process))
|
36 |
{
|
37 |
+
foreach ($eots as $eot) /* Go through the array of eots. We need to (demote|delete) each of them. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
{
|
39 |
+
$user_id = $eot->user_id; /* Grab the user ID value from the query. */
|
40 |
+
/**/
|
41 |
+
$user = new WP_User ($user_id); /* Acquire user object. */
|
42 |
+
/**/
|
43 |
+
delete_usermeta ($user_id, "s2member_auto_eot_time"); /* Always delete this. */
|
44 |
+
/* Removing this prevents re-runs on non WP Roles. Which are scanned for next. */
|
45 |
+
/**/
|
46 |
+
if (!ws_plugin__s2member_user_has_wp_role ($user)) /* Non WP Roles. */
|
47 |
{
|
48 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
{
|
50 |
+
$user->set_role ("subscriber");
|
51 |
+
/**/
|
52 |
+
$subscr_id = get_usermeta ($user_id, "s2member_subscr_id");
|
53 |
+
$custom = get_usermeta ($user_id, "s2member_custom");
|
54 |
+
/**/
|
55 |
+
delete_usermeta ($user_id, "s2member_custom");
|
56 |
+
delete_usermeta ($user_id, "s2member_subscr_id");
|
57 |
+
delete_usermeta ($user_id, "s2member_last_payment_time");
|
58 |
+
delete_usermeta ($user_id, "s2member_auto_eot_time");
|
59 |
+
/**/
|
60 |
+
foreach ($user->allcaps as $cap => $cap_enabled)
|
61 |
+
if (preg_match ("/^access_s2member_ccap_/", $cap))
|
62 |
+
$user->remove_cap ($ccap = $cap);
|
63 |
+
/**/
|
64 |
+
delete_usermeta ($user_id, "s2member_file_download_access_arc");
|
65 |
+
delete_usermeta ($user_id, "s2member_file_download_access_log");
|
66 |
+
/**/
|
67 |
+
ws_plugin__s2member_append_user_notes ($user_id, "Demoted by s2Member: " . date ("D M j, Y g:i a T"));
|
68 |
+
/**/
|
69 |
+
if ($subscr_id && $custom && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array ($cv = preg_split ("/\|/", $custom)))
|
70 |
+
{
|
71 |
+
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"]) as $url) /* Handle EOT Notifications. */
|
72 |
+
/**/
|
73 |
+
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", urlencode ($subscr_id), $url)))
|
74 |
+
if (($url = preg_replace ("/%%user_first_name%%/i", urlencode ($user->first_name), $url)) && ($url = preg_replace ("/%%user_last_name%%/i", urlencode ($user->last_name), $url)))
|
75 |
+
if (($url = preg_replace ("/%%user_full_name%%/i", urlencode (trim ($user->first_name . " " . $user->last_name)), $url)))
|
76 |
+
if (($url = preg_replace ("/%%user_email%%/i", urlencode ($user->user_email), $url)))
|
77 |
+
/**/
|
78 |
+
if (($url = trim ($url))) /* Empty? */
|
79 |
+
ws_plugin__s2member_remote ($url);
|
80 |
+
}
|
81 |
+
/**/
|
82 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
83 |
+
do_action ("ws_plugin__s2member_during_auto_eot_system_during_demote", get_defined_vars ());
|
84 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
85 |
+
}
|
86 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete")
|
87 |
+
{
|
88 |
+
wp_delete_user ($user_id); /* Triggers: `ws_plugin__s2member_handle_user_deletions()` */
|
89 |
+
/* `ws_plugin__s2member_handle_user_deletions()` triggers `eot_del_notification_urls` */
|
90 |
+
/**/
|
91 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
92 |
+
do_action ("ws_plugin__s2member_during_auto_eot_system_during_delete", get_defined_vars ());
|
93 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
94 |
}
|
95 |
/**/
|
96 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
97 |
+
do_action ("ws_plugin__s2member_during_auto_eot_system", get_defined_vars ());
|
98 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
|
|
|
|
|
|
|
|
|
|
99 |
}
|
|
|
|
|
100 |
}
|
101 |
}
|
102 |
}
|
103 |
+
/**/
|
104 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
105 |
+
do_action ("ws_plugin__s2member_after_auto_eot_system", get_defined_vars ());
|
106 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
107 |
+
/**/
|
108 |
+
return;
|
109 |
}
|
|
|
|
|
|
|
|
|
110 |
}
|
111 |
/*
|
112 |
This function allows the Auto-EOT Sytem to be
|
113 |
processed through a server-side Cron Job.
|
114 |
Attach to: add_action("init");
|
115 |
*/
|
116 |
+
if (!function_exists ("ws_plugin__s2member_auto_eot_system_via_cron"))
|
117 |
{
|
118 |
+
function ws_plugin__s2member_auto_eot_system_via_cron ()
|
|
|
|
|
119 |
{
|
120 |
+
do_action ("ws_plugin__s2member_before_auto_eot_system_via_cron", get_defined_vars ());
|
121 |
+
/**/
|
122 |
+
if ($_GET["s2member_auto_eot_system_via_cron"]) /* Being called through HTTP? */
|
123 |
{
|
124 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"])
|
125 |
+
{
|
126 |
+
ws_plugin__s2member_auto_eot_system ();
|
127 |
+
/**/
|
128 |
+
do_action ("ws_plugin__s2member_during_auto_eot_system_via_cron", get_defined_vars ());
|
129 |
+
}
|
130 |
/**/
|
131 |
+
exit; /* Exit. */
|
132 |
}
|
133 |
/**/
|
134 |
+
do_action ("ws_plugin__s2member_after_auto_eot_system_via_cron", get_defined_vars ());
|
135 |
}
|
|
|
|
|
136 |
}
|
137 |
/*
|
138 |
Extends the WP-Cron schedules to support 10 minute intervals.
|
139 |
Attach to: add_filter("cron_schedules");
|
140 |
*/
|
141 |
+
if (!function_exists ("ws_plugin__s2member_extend_cron_schedules"))
|
142 |
{
|
143 |
+
function ws_plugin__s2member_extend_cron_schedules ($schedules = array ())
|
144 |
+
{
|
145 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
146 |
+
do_action ("ws_plugin__s2member_before_extend_cron_schedules", get_defined_vars ());
|
147 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
148 |
+
/**/
|
149 |
+
$array = array ("every10m" => array ("interval" => 600, "display" => "Every 10 Minutes"));
|
150 |
+
/**/
|
151 |
+
return apply_filters ("ws_plugin__s2member_extend_cron_schedules", array_merge ($array, $schedules), get_defined_vars ());
|
152 |
+
}
|
153 |
}
|
154 |
/*
|
155 |
Adds a scheduled task for s2Member's Auto-EOT System.
|
156 |
*/
|
157 |
+
if (!function_exists ("ws_plugin__s2member_add_auto_eot_system"))
|
158 |
{
|
159 |
+
function ws_plugin__s2member_add_auto_eot_system ()
|
|
|
|
|
160 |
{
|
161 |
+
do_action ("ws_plugin__s2member_before_add_auto_eot_system", get_defined_vars ());
|
|
|
|
|
|
|
|
|
162 |
/**/
|
163 |
+
if (!ws_plugin__s2member_delete_auto_eot_system ())
|
164 |
+
{
|
165 |
+
return apply_filters ("ws_plugin__s2member_add_auto_eot_system", false, get_defined_vars ());
|
166 |
+
}
|
167 |
+
else if (function_exists ("wp_cron")) /* Otherwise, we can schedule. */
|
168 |
+
{
|
169 |
+
wp_schedule_event (time (), "every10m", "ws_plugin__s2member_auto_eot_system__schedule");
|
170 |
+
/**/
|
171 |
+
return apply_filters ("ws_plugin__s2member_add_auto_eot_system", true, get_defined_vars ());
|
172 |
+
}
|
173 |
+
else /* Otherwise, it would appear that WP-Cron is not available. */
|
174 |
+
{
|
175 |
+
return apply_filters ("ws_plugin__s2member_add_auto_eot_system", false, get_defined_vars ());
|
176 |
+
}
|
177 |
}
|
178 |
}
|
179 |
/*
|
180 |
Delete scheduled tasks for s2Member's Auto-EOT System.
|
181 |
*/
|
182 |
+
if (!function_exists ("ws_plugin__s2member_delete_auto_eot_system"))
|
183 |
{
|
184 |
+
function ws_plugin__s2member_delete_auto_eot_system ()
|
|
|
|
|
185 |
{
|
186 |
+
do_action ("ws_plugin__s2member_before_delete_auto_eot_system", get_defined_vars ());
|
187 |
/**/
|
188 |
+
if (function_exists ("wp_cron"))
|
189 |
+
{
|
190 |
+
wp_clear_scheduled_hook ("s2member_auto_eot_system"); /* This is for backward compatibility. */
|
191 |
+
wp_clear_scheduled_hook ("ws_plugin__s2member_auto_eot_system__schedule"); /* Since v3.0.3. */
|
192 |
+
/**/
|
193 |
+
return apply_filters ("ws_plugin__s2member_delete_auto_eot_system", true, get_defined_vars ());
|
194 |
+
}
|
195 |
+
else /* Otherwise, it would appear that WP-Cron is not available. */
|
196 |
+
{
|
197 |
+
return apply_filters ("ws_plugin__s2member_delete_auto_eot_system", false, get_defined_vars ());
|
198 |
+
}
|
199 |
}
|
200 |
}
|
201 |
?>
|
includes/functions/catg-level-access.inc.php
CHANGED
@@ -17,99 +17,102 @@ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
|
17 |
Function for handling category level access permissions.
|
18 |
Attach to: add_action("template_redirect");
|
19 |
*/
|
20 |
-
|
21 |
{
|
22 |
-
|
23 |
-
/**/
|
24 |
-
do_action ("s2member_before_check_catg_level_access", get_defined_vars ());
|
25 |
-
/**/
|
26 |
-
$excluded = apply_filters ("s2member_check_catg_level_access_excluded", false, get_defined_vars ());
|
27 |
-
/**/
|
28 |
-
if (!$excluded && ((is_category () && ($cat_ID = get_query_var ("cat"))) || (is_single () && !is_page () && is_object ($post) && ($post_ID = $post->ID))))
|
29 |
{
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
{
|
32 |
-
|
33 |
-
/**/
|
34 |
-
if (is_category () && $cat_ID) /* We also check if this is a child category of a restricted category. */
|
35 |
{
|
36 |
-
|
37 |
-
exit;
|
38 |
/**/
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level2")) && wp_redirect (add_query_arg ("s2member_level_req", "2", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
43 |
-
exit;
|
44 |
-
/**/
|
45 |
-
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_catgs"] && in_array ($cat_ID, ($level2_catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_catgs"]))) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level2")) && wp_redirect (add_query_arg ("s2member_level_req", "2", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
46 |
-
exit;
|
47 |
-
/**/
|
48 |
-
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level3")) && wp_redirect (add_query_arg ("s2member_level_req", "3", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
49 |
-
exit;
|
50 |
-
/**/
|
51 |
-
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_catgs"] && in_array ($cat_ID, ($level3_catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_catgs"]))) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level3")) && wp_redirect (add_query_arg ("s2member_level_req", "3", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
52 |
-
exit;
|
53 |
-
/**/
|
54 |
-
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level4")) && wp_redirect (add_query_arg ("s2member_level_req", "4", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
55 |
-
exit;
|
56 |
-
/**/
|
57 |
-
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_catgs"] && in_array ($cat_ID, ($level4_catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_catgs"]))) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level4")) && wp_redirect (add_query_arg ("s2member_level_req", "4", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
58 |
-
exit;
|
59 |
-
/**/
|
60 |
-
if ($level1_catgs)
|
61 |
-
foreach ($level1_catgs as $catg)
|
62 |
-
if ($catg && cat_is_ancestor_of ($catg, $cat_ID) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level1")) && wp_redirect (add_query_arg ("s2member_level_req", "1", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
63 |
exit;
|
64 |
-
|
65 |
-
|
66 |
-
foreach ($level2_catgs as $catg)
|
67 |
-
if ($catg && cat_is_ancestor_of ($catg, $cat_ID) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level2")) && wp_redirect (add_query_arg ("s2member_level_req", "2", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
68 |
exit;
|
69 |
-
|
70 |
-
|
71 |
-
foreach ($level3_catgs as $catg)
|
72 |
-
if ($catg && cat_is_ancestor_of ($catg, $cat_ID) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level3")) && wp_redirect (add_query_arg ("s2member_level_req", "3", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
73 |
exit;
|
74 |
-
|
75 |
-
|
76 |
-
foreach ($level4_catgs as $catg)
|
77 |
-
if ($catg && cat_is_ancestor_of ($catg, $cat_ID) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level4")) && wp_redirect (add_query_arg ("s2member_level_req", "4", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
78 |
exit;
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
/**/
|
103 |
-
|
104 |
-
exit;
|
105 |
}
|
106 |
-
/**/
|
107 |
-
do_action ("s2member_during_check_catg_level_access", get_defined_vars ());
|
108 |
}
|
|
|
|
|
|
|
|
|
109 |
}
|
110 |
-
/**/
|
111 |
-
do_action ("s2member_after_check_catg_level_access", get_defined_vars ());
|
112 |
-
/**/
|
113 |
-
return;
|
114 |
}
|
115 |
?>
|
17 |
Function for handling category level access permissions.
|
18 |
Attach to: add_action("template_redirect");
|
19 |
*/
|
20 |
+
if (!function_exists ("ws_plugin__s2member_check_catg_level_access"))
|
21 |
{
|
22 |
+
function ws_plugin__s2member_check_catg_level_access ()
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
{
|
24 |
+
global $post; /* get_the_ID() not yet available here. */
|
25 |
+
/**/
|
26 |
+
do_action ("ws_plugin__s2member_before_check_catg_level_access", get_defined_vars ());
|
27 |
+
/**/
|
28 |
+
$excluded = apply_filters ("ws_plugin__s2member_check_catg_level_access_excluded", false, get_defined_vars ());
|
29 |
+
/**/
|
30 |
+
if (!$excluded && ((is_category () && ($cat_ID = get_query_var ("cat"))) || (is_single () && !is_page () && is_object ($post) && ($post_ID = $post->ID))))
|
31 |
{
|
32 |
+
if (!ws_plugin__s2member_is_systematic_use_page ()) /* Never restrict systematic use pages. */
|
|
|
|
|
33 |
{
|
34 |
+
$current_user = (is_user_logged_in ()) ? wp_get_current_user () : false;
|
|
|
35 |
/**/
|
36 |
+
if (is_category () && $cat_ID) /* We also check if this is a child category of a restricted category. */
|
37 |
+
{
|
38 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level1")) && wp_redirect (add_query_arg ("s2member_level_req", "1", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
exit;
|
40 |
+
/**/
|
41 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_catgs"] && in_array ($cat_ID, ($level1_catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_catgs"]))) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level1")) && wp_redirect (add_query_arg ("s2member_level_req", "1", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
|
|
|
|
42 |
exit;
|
43 |
+
/**/
|
44 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level2")) && wp_redirect (add_query_arg ("s2member_level_req", "2", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
|
|
|
|
45 |
exit;
|
46 |
+
/**/
|
47 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_catgs"] && in_array ($cat_ID, ($level2_catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_catgs"]))) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level2")) && wp_redirect (add_query_arg ("s2member_level_req", "2", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
|
|
|
|
48 |
exit;
|
49 |
+
/**/
|
50 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level3")) && wp_redirect (add_query_arg ("s2member_level_req", "3", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
51 |
+
exit;
|
52 |
+
/**/
|
53 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_catgs"] && in_array ($cat_ID, ($level3_catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_catgs"]))) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level3")) && wp_redirect (add_query_arg ("s2member_level_req", "3", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
54 |
+
exit;
|
55 |
+
/**/
|
56 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level4")) && wp_redirect (add_query_arg ("s2member_level_req", "4", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
57 |
+
exit;
|
58 |
+
/**/
|
59 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_catgs"] && in_array ($cat_ID, ($level4_catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_catgs"]))) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level4")) && wp_redirect (add_query_arg ("s2member_level_req", "4", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
60 |
+
exit;
|
61 |
+
/**/
|
62 |
+
if ($level1_catgs)
|
63 |
+
foreach ($level1_catgs as $catg)
|
64 |
+
if ($catg && cat_is_ancestor_of ($catg, $cat_ID) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level1")) && wp_redirect (add_query_arg ("s2member_level_req", "1", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
65 |
+
exit;
|
66 |
+
/**/
|
67 |
+
if ($level2_catgs)
|
68 |
+
foreach ($level2_catgs as $catg)
|
69 |
+
if ($catg && cat_is_ancestor_of ($catg, $cat_ID) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level2")) && wp_redirect (add_query_arg ("s2member_level_req", "2", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
70 |
+
exit;
|
71 |
+
/**/
|
72 |
+
if ($level3_catgs)
|
73 |
+
foreach ($level3_catgs as $catg)
|
74 |
+
if ($catg && cat_is_ancestor_of ($catg, $cat_ID) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level3")) && wp_redirect (add_query_arg ("s2member_level_req", "3", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
75 |
+
exit;
|
76 |
+
/**/
|
77 |
+
if ($level4_catgs)
|
78 |
+
foreach ($level4_catgs as $catg)
|
79 |
+
if ($catg && cat_is_ancestor_of ($catg, $cat_ID) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level4")) && wp_redirect (add_query_arg ("s2member_level_req", "4", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
80 |
+
exit;
|
81 |
+
}
|
82 |
+
else if (is_single () && !is_page () && $post_ID)
|
83 |
+
{
|
84 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level1")) && wp_redirect (add_query_arg ("s2member_level_req", "1", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
85 |
+
exit;
|
86 |
+
/**/
|
87 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_catgs"] && (in_category (($level1_catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_catgs"])), $post_ID) || ws_plugin__s2member_in_descendant_category ($level1_catgs, $post_ID)) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level1")) && wp_redirect (add_query_arg ("s2member_level_req", "1", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
88 |
+
exit;
|
89 |
+
/**/
|
90 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level2")) && wp_redirect (add_query_arg ("s2member_level_req", "2", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
91 |
+
exit;
|
92 |
+
/**/
|
93 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_catgs"] && (in_category (($level2_catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_catgs"])), $post_ID) || ws_plugin__s2member_in_descendant_category ($level2_catgs, $post_ID)) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level2")) && wp_redirect (add_query_arg ("s2member_level_req", "2", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
94 |
+
exit;
|
95 |
+
/**/
|
96 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level3")) && wp_redirect (add_query_arg ("s2member_level_req", "3", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
97 |
+
exit;
|
98 |
+
/**/
|
99 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_catgs"] && (in_category (($level3_catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_catgs"])), $post_ID) || ws_plugin__s2member_in_descendant_category ($level3_catgs, $post_ID)) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level3")) && wp_redirect (add_query_arg ("s2member_level_req", "3", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
100 |
+
exit;
|
101 |
+
/**/
|
102 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_catgs"] === "all" && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level4")) && wp_redirect (add_query_arg ("s2member_level_req", "4", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
103 |
+
exit;
|
104 |
+
/**/
|
105 |
+
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_catgs"] && (in_category (($level4_catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_catgs"])), $post_ID) || ws_plugin__s2member_in_descendant_category ($level4_catgs, $post_ID)) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level4")) && wp_redirect (add_query_arg ("s2member_level_req", "4", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
106 |
+
exit;
|
107 |
+
}
|
108 |
/**/
|
109 |
+
do_action ("ws_plugin__s2member_during_check_catg_level_access", get_defined_vars ());
|
|
|
110 |
}
|
|
|
|
|
111 |
}
|
112 |
+
/**/
|
113 |
+
do_action ("ws_plugin__s2member_after_check_catg_level_access", get_defined_vars ());
|
114 |
+
/**/
|
115 |
+
return;
|
116 |
}
|
|
|
|
|
|
|
|
|
117 |
}
|
118 |
?>
|
includes/functions/constants.inc.php
CHANGED
@@ -18,86 +18,95 @@ Define several API Constants for s2Member.
|
|
18 |
Note that these are duplicated into the JavaScript API as well.
|
19 |
Attach to: add_action("init");
|
20 |
*/
|
21 |
-
|
22 |
{
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
}
|
102 |
/*
|
103 |
This function pulls all of the page links needed for Constants.
|
@@ -105,101 +114,111 @@ Page links are cached into the s2member options on 15 min intervals.
|
|
105 |
This allows the API Constants to provide quick access to them without being
|
106 |
forced to execute get_page_link() all the time, which piles up DB queries.
|
107 |
*/
|
108 |
-
|
109 |
{
|
110 |
-
|
111 |
-
/**/
|
112 |
-
$cache_minutes = 15; /* Could be higher? */
|
113 |
-
/**/
|
114 |
-
$l["login_welcome_page"] = (string)"";
|
115 |
-
$l["membership_options_page"] = (string)"";
|
116 |
-
$l["file_download_limit_exceeded_page"] = (string)"";
|
117 |
-
/**/
|
118 |
-
$login_welcome_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"];
|
119 |
-
$membership_options_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"];
|
120 |
-
$file_download_limit_exceeded_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"];
|
121 |
-
/**/
|
122 |
-
$login_welcome_page_cache = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"];
|
123 |
-
$membership_options_page_cache = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"];
|
124 |
-
$file_download_limit_exceeded_page_cache = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"];
|
125 |
-
/**/
|
126 |
-
if ($login_welcome_page && $login_welcome_page_cache["page"] === $login_welcome_page && $login_welcome_page_cache["link"] && $login_welcome_page_cache["time"] >= strtotime ("-" . $cache_minutes . " minutes"))
|
127 |
{
|
128 |
-
|
129 |
-
}
|
130 |
-
else /* Otherwise, we need to query the database using get_page_link() and update the cache. */
|
131 |
-
{
|
132 |
-
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["time"] = strtotime ("now");
|
133 |
-
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["page"] = $login_welcome_page;
|
134 |
-
$l["login_welcome_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["link"] = get_page_link ($login_welcome_page);
|
135 |
/**/
|
136 |
-
$
|
137 |
-
}
|
138 |
-
/**/
|
139 |
-
if ($membership_options_page && $membership_options_page_cache["page"] === $membership_options_page && $membership_options_page_cache["link"] && $membership_options_page_cache["time"] >= strtotime ("-" . $cache_minutes . " minutes"))
|
140 |
-
{
|
141 |
-
$l["membership_options_page"] = $membership_options_page_cache["link"];
|
142 |
-
}
|
143 |
-
else /* Otherwise, we need to query the database using get_page_link() and update the cache. */
|
144 |
-
{
|
145 |
-
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["time"] = strtotime ("now");
|
146 |
-
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["page"] = $membership_options_page;
|
147 |
-
$l["membership_options_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["link"] = get_page_link ($membership_options_page);
|
148 |
/**/
|
149 |
-
$
|
150 |
-
|
151 |
-
|
152 |
-
if ($file_download_limit_exceeded_page && $file_download_limit_exceeded_page_cache["page"] === $file_download_limit_exceeded_page && $file_download_limit_exceeded_page_cache["link"] && $file_download_limit_exceeded_page_cache["time"] >= strtotime ("-" . $cache_minutes . " minutes"))
|
153 |
-
{
|
154 |
-
$l["file_download_limit_exceeded_page"] = $file_download_limit_exceeded_page_cache["link"];
|
155 |
-
}
|
156 |
-
else /* Otherwise, we need to query the database using get_page_link() and update the cache. */
|
157 |
-
{
|
158 |
-
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["time"] = strtotime ("now");
|
159 |
-
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["page"] = $file_download_limit_exceeded_page;
|
160 |
-
$l["file_download_limit_exceeded_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["link"] = get_page_link ($file_download_limit_exceeded_page);
|
161 |
/**/
|
162 |
-
$
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
}
|
169 |
-
/**/
|
170 |
-
return apply_filters ("s2member_constant_links", $l, get_defined_vars ());
|
171 |
}
|
172 |
/*
|
173 |
This function pulls all of the usermeta details needed for Constants.
|
174 |
Pulling them all at once helps to prevent repeated database queries.
|
175 |
*/
|
176 |
-
|
177 |
{
|
178 |
-
|
179 |
-
/**/
|
180 |
-
do_action ("s2member_before_constant_metas", get_defined_vars ());
|
181 |
-
/**/
|
182 |
-
$m["s2member_file_download_access_log"] = array ();
|
183 |
-
$m["s2member_custom_fields"] = array ();
|
184 |
-
$m["s2member_subscr_id"] = (string)"";
|
185 |
-
$m["s2member_custom"] = (string)"";
|
186 |
-
/**/
|
187 |
-
if (($current_user = (is_user_logged_in ()) ? wp_get_current_user () : false))
|
188 |
{
|
189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
{
|
191 |
-
|
192 |
-
|
193 |
-
$
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
}
|
|
|
|
|
201 |
}
|
202 |
-
/**/
|
203 |
-
return apply_filters ("s2member_constant_metas", $m, get_defined_vars ());
|
204 |
}
|
205 |
?>
|
18 |
Note that these are duplicated into the JavaScript API as well.
|
19 |
Attach to: add_action("init");
|
20 |
*/
|
21 |
+
if (!function_exists ("ws_plugin__s2member_constants"))
|
22 |
{
|
23 |
+
function ws_plugin__s2member_constants ()
|
24 |
+
{
|
25 |
+
do_action ("ws_plugin__s2member_before_constants", get_defined_vars ());
|
26 |
+
/**/
|
27 |
+
$links = ws_plugin__s2member_constant_links ();
|
28 |
+
$metas = ws_plugin__s2member_constant_metas ();
|
29 |
+
$level = ws_plugin__s2member_user_access_level ();
|
30 |
+
$current_user = (is_user_logged_in ()) ? wp_get_current_user () : false;
|
31 |
+
$file_downloads = ws_plugin__s2member_user_downloads ("", $metas["s2member_file_download_access_log"]);
|
32 |
+
$login_redirection_override = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"];
|
33 |
+
/**/
|
34 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
35 |
+
do_action ("ws_plugin__s2member_during_constants", get_defined_vars ());
|
36 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
37 |
+
/**/
|
38 |
+
define ("S2MEMBER_VERSION", WS_PLUGIN__S2MEMBER_VERSION); /* Always a (string) containing the version. Available since 3.0. */
|
39 |
+
/**/
|
40 |
+
define ("S2MEMBER_CURRENT_USER_IS_LOGGED_IN", (($current_user) ? true : false)); /* This will always be (bool) true or false. False if they are NOT currently logged in. */
|
41 |
+
define ("S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER", (($current_user && $level >= 1) ? true : false)); /* This will always be (bool) true or false. Level >= 1 for Members. */
|
42 |
+
define ("S2MEMBER_CURRENT_USER_ACCESS_LEVEL", (int)$level); /* This will always be (int) negative 1 thru positive 4. -1 if user is not logged in. 0 if logged in as a Subscriber. */
|
43 |
+
define ("S2MEMBER_CURRENT_USER_ACCESS_LABEL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_label"]); /* This will always be a (string). Empty if not logged in. */
|
44 |
+
define ("S2MEMBER_CURRENT_USER_SUBSCR_ID", (($current_user) ? (($metas["s2member_subscr_id"]) ? $metas["s2member_subscr_id"] : $current_user->ID) : "")); /* Empty if not logged in. */
|
45 |
+
define ("S2MEMBER_CURRENT_USER_CUSTOM", (($current_user) ? $metas["s2member_custom"] : "")); /* This will always a (string). However, it will be empty if not logged in. */
|
46 |
+
define ("S2MEMBER_CURRENT_USER_REGISTRATION_TIME", (($current_user) ? strtotime ($current_user->user_registered) : 0)); /* Always an (int). Or 0 if they're not logged in. */
|
47 |
+
define ("S2MEMBER_CURRENT_USER_REGISTRATION_DAYS", (($current_user) ? floor ((strtotime ("now") - strtotime ($current_user->user_registered)) / 86400) : 0)); /* (int). */
|
48 |
+
define ("S2MEMBER_CURRENT_USER_DISPLAY_NAME", (($current_user) ? $current_user->display_name : "")); /* This will always be a (string). Empty if not logged in. */
|
49 |
+
define ("S2MEMBER_CURRENT_USER_FIRST_NAME", (($current_user) ? $current_user->user_firstname : "")); /* This will always be a (string). Empty if not logged in. */
|
50 |
+
define ("S2MEMBER_CURRENT_USER_LAST_NAME", (($current_user) ? $current_user->user_lastname : "")); /* This will always be a (string). Empty if not logged in. */
|
51 |
+
define ("S2MEMBER_CURRENT_USER_LOGIN", (($current_user) ? $current_user->user_login : "")); /* This will always be a (string). Empty if not logged in. */
|
52 |
+
define ("S2MEMBER_CURRENT_USER_EMAIL", (($current_user) ? $current_user->user_email : "")); /* This will always be a (string). Empty if not logged in. */
|
53 |
+
define ("S2MEMBER_CURRENT_USER_IP", $_SERVER["REMOTE_ADDR"]); /* This will always be a (string). It may be empty if the user is browsing anonymously. */
|
54 |
+
define ("S2MEMBER_CURRENT_USER_ID", (($current_user) ? (int)$current_user->ID : 0)); /* This will always be an (int). Zero if not logged in. */
|
55 |
+
define ("S2MEMBER_CURRENT_USER_FIELDS", (($current_user) ? json_encode (array_merge /* Always a json_encode (array). This includes custom fields. */
|
56 |
+
(array ("id" => S2MEMBER_CURRENT_USER_ID, "ip" => S2MEMBER_CURRENT_USER_IP, "email" => S2MEMBER_CURRENT_USER_EMAIL, "login" => S2MEMBER_CURRENT_USER_LOGIN,/**/
|
57 |
+
"first_name" => S2MEMBER_CURRENT_USER_FIRST_NAME, "last_name" => S2MEMBER_CURRENT_USER_LAST_NAME, "display_name" => S2MEMBER_CURRENT_USER_DISPLAY_NAME,/**/
|
58 |
+
"subscr_id" => S2MEMBER_CURRENT_USER_SUBSCR_ID, "custom" => S2MEMBER_CURRENT_USER_CUSTOM), $metas["s2member_custom_fields"])) : json_encode (array ())));
|
59 |
+
/**/
|
60 |
+
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED", (int)$file_downloads["allowed"]); /* This will always be an integer value (int) >= 0 where 0 means no access. */
|
61 |
+
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED", (($file_downloads["allowed"] >= 999999999) ? true : false)); /* This will always be (bool). */
|
62 |
+
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY", (int)$file_downloads["currently"]); /* This will always be an integer value (int) >= 0 where 0 means none currently. */
|
63 |
+
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS", (int)$file_downloads["allowed_days"]); /* This will always be an integer value (int) >= 0 where 0 means no access. */
|
64 |
+
/**/
|
65 |
+
define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]); /* The exceeded page id (int). */
|
66 |
+
define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]); /* Options page id, always an (int). */
|
67 |
+
define ("S2MEMBER_LOGIN_WELCOME_PAGE_ID", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]); /* The welcome page id, always an (int). */
|
68 |
+
/**/
|
69 |
+
define ("S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL", get_bloginfo ("url") . "/?s2member_profile=1"); /* Where a user modifies their profile. */
|
70 |
+
define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL", $links["file_download_limit_exceeded_page"]); /* Always a string. URL to limit exceeded page. */
|
71 |
+
define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL", $links["membership_options_page"]); /* Always a string. This is the URL to the membership options page. */
|
72 |
+
define ("S2MEMBER_LOGIN_WELCOME_PAGE_URL", (($login_redirection_override) ? $login_redirection_override : $links["login_welcome_page"])); /* Always a string. */
|
73 |
+
define ("S2MEMBER_LOGOUT_PAGE_URL", wp_logout_url ()); /* This is always the same, it is the default wordpress action=logout url generated by wp_logout_url(). */
|
74 |
+
define ("S2MEMBER_LOGIN_PAGE_URL", wp_login_url ()); /* This is always the same, it is the default wordpress login url that is generated by wp_login_url(). */
|
75 |
+
/**/
|
76 |
+
define ("S2MEMBER_LEVEL1_LABEL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_label"]); /* This is the (string) label that you created for membership level number 1. */
|
77 |
+
define ("S2MEMBER_LEVEL2_LABEL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_label"]); /* This is the (string) label that you created for membership level number 2. */
|
78 |
+
define ("S2MEMBER_LEVEL3_LABEL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_label"]); /* This is the (string) label that you created for membership level number 3. */
|
79 |
+
define ("S2MEMBER_LEVEL4_LABEL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_label"]); /* This is the (string) label that you created for membership level number 4. */
|
80 |
+
/**/
|
81 |
+
define ("S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed"]); /* This is the (int) allowed downloads. */
|
82 |
+
define ("S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed"]); /* This is the (int) allowed downloads. */
|
83 |
+
define ("S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed"]); /* This is the (int) allowed downloads. */
|
84 |
+
define ("S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed"]); /* This is the (int) allowed downloads. */
|
85 |
+
/**/
|
86 |
+
define ("S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"]); /* This is (int) allowed days. */
|
87 |
+
define ("S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"]); /* This is (int) allowed days. */
|
88 |
+
define ("S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"]); /* This is (int) allowed days. */
|
89 |
+
define ("S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"]); /* This is (int) allowed days. */
|
90 |
+
/**/
|
91 |
+
define ("S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_inline_extensions"]); /* This is the (string) list of extensions. */
|
92 |
+
/**/
|
93 |
+
define ("S2MEMBER_REG_EMAIL_FROM_NAME", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]); /* This is the name that outgoing email messages are sent by. */
|
94 |
+
define ("S2MEMBER_REG_EMAIL_FROM_EMAIL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"]); /* This is the email that outgoing messages are sent by. */
|
95 |
+
/**/
|
96 |
+
define ("S2MEMBER_PAYPAL_NOTIFY_URL", get_bloginfo ("url") . "/?s2member_paypal_notify=1"); /* This will always be a (string), and it will never be an empty value. */
|
97 |
+
define ("S2MEMBER_PAYPAL_RETURN_URL", get_bloginfo ("url") . "/?s2member_paypal_return=1"); /* This will always be a (string), and it will never be an empty value. */
|
98 |
+
define ("S2MEMBER_PAYPAL_ENDPOINT", (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com")); /* Using sandbox? */
|
99 |
+
define ("S2MEMBER_PAYPAL_BUSINESS", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"]); /* This is the email address that identifies your paypal business. */
|
100 |
+
/**/
|
101 |
+
define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0", ((S2MEMBER_CURRENT_USER_SUBSCR_ID && !ws_plugin__s2member_user_has_wp_role ($current_user)) ? "Updating Subscr. ID" : ""));
|
102 |
+
define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0", ((S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0) ? S2MEMBER_CURRENT_USER_SUBSCR_ID : "")); /* ^ Not for built-in WP Roles. */
|
103 |
+
/**/
|
104 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
105 |
+
do_action ("ws_plugin__s2member_after_constants", get_defined_vars ());
|
106 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
107 |
+
/**/
|
108 |
+
return;
|
109 |
+
}
|
110 |
}
|
111 |
/*
|
112 |
This function pulls all of the page links needed for Constants.
|
114 |
This allows the API Constants to provide quick access to them without being
|
115 |
forced to execute get_page_link() all the time, which piles up DB queries.
|
116 |
*/
|
117 |
+
if (!function_exists ("ws_plugin__s2member_constant_links"))
|
118 |
{
|
119 |
+
function ws_plugin__s2member_constant_links ()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
{
|
121 |
+
do_action ("ws_plugin__s2member_before_constant_links", get_defined_vars ());
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
/**/
|
123 |
+
$cache_minutes = 15; /* Could be higher? */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
/**/
|
125 |
+
$l["login_welcome_page"] = (string)"";
|
126 |
+
$l["membership_options_page"] = (string)"";
|
127 |
+
$l["file_download_limit_exceeded_page"] = (string)"";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
/**/
|
129 |
+
$login_welcome_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"];
|
130 |
+
$membership_options_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"];
|
131 |
+
$file_download_limit_exceeded_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"];
|
132 |
+
/**/
|
133 |
+
$login_welcome_page_cache = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"];
|
134 |
+
$membership_options_page_cache = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"];
|
135 |
+
$file_download_limit_exceeded_page_cache = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"];
|
136 |
+
/**/
|
137 |
+
if ($login_welcome_page && $login_welcome_page_cache["page"] === $login_welcome_page && $login_welcome_page_cache["link"] && $login_welcome_page_cache["time"] >= strtotime ("-" . $cache_minutes . " minutes"))
|
138 |
+
{
|
139 |
+
$l["login_welcome_page"] = $login_welcome_page_cache["link"];
|
140 |
+
}
|
141 |
+
else /* Otherwise, we need to query the database using get_page_link() and update the cache. */
|
142 |
+
{
|
143 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["time"] = strtotime ("now");
|
144 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["page"] = $login_welcome_page;
|
145 |
+
$l["login_welcome_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["link"] = get_page_link ($login_welcome_page);
|
146 |
+
/**/
|
147 |
+
$cache_needs_updating = true;
|
148 |
+
}
|
149 |
+
/**/
|
150 |
+
if ($membership_options_page && $membership_options_page_cache["page"] === $membership_options_page && $membership_options_page_cache["link"] && $membership_options_page_cache["time"] >= strtotime ("-" . $cache_minutes . " minutes"))
|
151 |
+
{
|
152 |
+
$l["membership_options_page"] = $membership_options_page_cache["link"];
|
153 |
+
}
|
154 |
+
else /* Otherwise, we need to query the database using get_page_link() and update the cache. */
|
155 |
+
{
|
156 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["time"] = strtotime ("now");
|
157 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["page"] = $membership_options_page;
|
158 |
+
$l["membership_options_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["link"] = get_page_link ($membership_options_page);
|
159 |
+
/**/
|
160 |
+
$cache_needs_updating = true;
|
161 |
+
}
|
162 |
+
/**/
|
163 |
+
if ($file_download_limit_exceeded_page && $file_download_limit_exceeded_page_cache["page"] === $file_download_limit_exceeded_page && $file_download_limit_exceeded_page_cache["link"] && $file_download_limit_exceeded_page_cache["time"] >= strtotime ("-" . $cache_minutes . " minutes"))
|
164 |
+
{
|
165 |
+
$l["file_download_limit_exceeded_page"] = $file_download_limit_exceeded_page_cache["link"];
|
166 |
+
}
|
167 |
+
else /* Otherwise, we need to query the database using get_page_link() and update the cache. */
|
168 |
+
{
|
169 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["time"] = strtotime ("now");
|
170 |
+
$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["page"] = $file_download_limit_exceeded_page;
|
171 |
+
$l["file_download_limit_exceeded_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["link"] = get_page_link ($file_download_limit_exceeded_page);
|
172 |
+
/**/
|
173 |
+
$cache_needs_updating = true;
|
174 |
+
}
|
175 |
+
/**/
|
176 |
+
if ($cache_needs_updating) /* The cache is also reset when options are updated from a menu page. */
|
177 |
+
{
|
178 |
+
update_option ("ws_plugin__s2member_cache", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]);
|
179 |
+
}
|
180 |
+
/**/
|
181 |
+
return apply_filters ("ws_plugin__s2member_constant_links", $l, get_defined_vars ());
|
182 |
}
|
|
|
|
|
183 |
}
|
184 |
/*
|
185 |
This function pulls all of the usermeta details needed for Constants.
|
186 |
Pulling them all at once helps to prevent repeated database queries.
|
187 |
*/
|
188 |
+
if (!function_exists ("ws_plugin__s2member_constant_metas"))
|
189 |
{
|
190 |
+
function ws_plugin__s2member_constant_metas ()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
{
|
192 |
+
global $wpdb; /* The global database object. */
|
193 |
+
/**/
|
194 |
+
do_action ("ws_plugin__s2member_before_constant_metas", get_defined_vars ());
|
195 |
+
/**/
|
196 |
+
$m["s2member_file_download_access_log"] = array ();
|
197 |
+
$m["s2member_custom_fields"] = array ();
|
198 |
+
$m["s2member_subscr_id"] = (string)"";
|
199 |
+
$m["s2member_custom"] = (string)"";
|
200 |
+
/**/
|
201 |
+
if (($current_user = (is_user_logged_in ()) ? wp_get_current_user () : false))
|
202 |
{
|
203 |
+
if (is_array ($results = $wpdb->get_results ("SELECT `meta_key`, `meta_value` FROM `" . $wpdb->usermeta . "` WHERE `user_id` = '" . $current_user->ID . "' AND (meta_key = 's2member_file_download_access_log' OR meta_key = 's2member_subscr_id' OR meta_key = 's2member_custom') LIMIT 3")))
|
204 |
+
{
|
205 |
+
foreach ($results as $r) /* Fill in the array we need. */
|
206 |
+
if ($r->meta_key === "s2member_file_download_access_log")
|
207 |
+
$m["s2member_file_download_access_log"] = (array)maybe_unserialize ($r->meta_value);
|
208 |
+
else if ($result->meta_key === "s2member_custom_fields")
|
209 |
+
$m["s2member_custom_fields"] = (array)maybe_unserialize ($r->meta_value);
|
210 |
+
else if ($r->meta_key === "s2member_subscr_id")
|
211 |
+
$m["s2member_subscr_id"] = (string)$r->meta_value;
|
212 |
+
else if ($result->meta_key === "s2member_custom")
|
213 |
+
$m["s2member_custom"] = (string)$r->meta_value;
|
214 |
+
/**/
|
215 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
216 |
+
do_action ("ws_plugin__s2member_during_constant_metas", get_defined_vars ());
|
217 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
218 |
+
}
|
219 |
}
|
220 |
+
/**/
|
221 |
+
return apply_filters ("ws_plugin__s2member_constant_metas", $m, get_defined_vars ());
|
222 |
}
|
|
|
|
|
223 |
}
|
224 |
?>
|
includes/functions/email-configs.inc.php
CHANGED
@@ -16,29 +16,38 @@ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
|
16 |
/*
|
17 |
Functions that modify the email From: name/address.
|
18 |
*/
|
19 |
-
|
20 |
{
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
29 |
}
|
30 |
/**/
|
31 |
-
|
32 |
{
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
36 |
}
|
37 |
/**/
|
38 |
-
|
39 |
{
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
43 |
}
|
44 |
?>
|
16 |
/*
|
17 |
Functions that modify the email From: name/address.
|
18 |
*/
|
19 |
+
if (!function_exists ("ws_plugin__s2member_email_config"))
|
20 |
{
|
21 |
+
function ws_plugin__s2member_email_config ()
|
22 |
+
{
|
23 |
+
do_action ("ws_plugin__s2member_before_email_config", get_defined_vars ());
|
24 |
+
/**/
|
25 |
+
add_filter ("wp_mail_from", "_ws_plugin__s2member_email_config_email");
|
26 |
+
add_filter ("wp_mail_from_name", "_ws_plugin__s2member_email_config_name");
|
27 |
+
/**/
|
28 |
+
do_action ("ws_plugin__s2member_after_email_config", get_defined_vars ());
|
29 |
+
/**/
|
30 |
+
return;
|
31 |
+
}
|
32 |
}
|
33 |
/**/
|
34 |
+
if (!function_exists ("_ws_plugin__s2member_email_config_email"))
|
35 |
{
|
36 |
+
function _ws_plugin__s2member_email_config_email ($email = FALSE)
|
37 |
+
{
|
38 |
+
do_action ("_ws_plugin__s2member_before_email_config_email", get_defined_vars ());
|
39 |
+
/**/
|
40 |
+
return apply_filters ("_ws_plugin__s2member_email_config_email", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"], get_defined_vars ());
|
41 |
+
}
|
42 |
}
|
43 |
/**/
|
44 |
+
if (!function_exists ("_ws_plugin__s2member_email_config_name"))
|
45 |
{
|
46 |
+
function _ws_plugin__s2member_email_config_name ($name = FALSE)
|
47 |
+
{
|
48 |
+
do_action ("_ws_plugin__s2member_before_email_config_name", get_defined_vars ());
|
49 |
+
/**/
|
50 |
+
return apply_filters ("_ws_plugin__s2member_email_config_name", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"], get_defined_vars ());
|
51 |
+
}
|
52 |
}
|
53 |
?>
|
includes/functions/file-download-access.inc.php
CHANGED
@@ -17,222 +17,236 @@ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
|
17 |
Function determines the max period in days for download access.
|
18 |
Returns number of days, where 0 means no access to files has been allowed.
|
19 |
*/
|
20 |
-
|
21 |
{
|
22 |
-
|
23 |
-
/**/
|
24 |
-
if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"])
|
25 |
{
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
}
|
43 |
-
/**/
|
44 |
-
return apply_filters ("s2member_max_download_period", (($max > 365) ? 365 : (int)$max), get_defined_vars ());
|
45 |
}
|
46 |
/*
|
47 |
Function determines how many downloads allowed - etc, etc.
|
48 |
Returns an array with 3 elements: allowed, allowed_days, currently.
|
49 |
The 2nd parameter can be used to prevent another database connection.
|
50 |
*/
|
51 |
-
|
52 |
{
|
53 |
-
|
54 |
-
/**/
|
55 |
-
if (($current_user = (is_user_logged_in ()) ? wp_get_current_user () : false))
|
56 |
{
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
$allowed_days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"];
|
61 |
-
}
|
62 |
/**/
|
63 |
-
if (
|
64 |
{
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
80 |
/**/
|
81 |
-
|
82 |
-
foreach ($file_download_access_log as $file_download_access_log_entry_key => $file_download_access_log_entry)
|
83 |
-
if (strtotime ($file_download_access_log_entry["date"]) >= strtotime ("-" . (int)$allowed_days . " days"))
|
84 |
-
if ($file_download_access_log_entry["file"] !== $not_counting_this_particular_file)
|
85 |
-
$currently = ($currently) ? $currently + 1 : 1;
|
86 |
}
|
87 |
-
/**/
|
88 |
-
return apply_filters ("s2member_user_downloads", array ("allowed" => (int)$allowed, "allowed_days" => (int)$allowed_days, "currently" => (int)$currently), get_defined_vars ());
|
89 |
}
|
90 |
/*
|
91 |
Function determines the minimum level required for file download access.
|
92 |
Returns 0-4, where 0 means no access to file downloads has been allowed.
|
93 |
*/
|
94 |
-
|
95 |
{
|
96 |
-
|
97 |
-
/**/
|
98 |
-
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"])
|
99 |
-
{
|
100 |
-
$file_download_access_is_allowed = $min_level_4_downloads = 1;
|
101 |
-
}
|
102 |
-
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"])
|
103 |
{
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
}
|
114 |
-
/**/
|
115 |
-
return apply_filters ("s2member_min_level_4_downloads", (int)$min_level_4_downloads, get_defined_vars ());
|
116 |
}
|
117 |
/*
|
118 |
Function for handling download access permissions.
|
119 |
Attach to: add_action("init");
|
120 |
*/
|
121 |
-
|
122 |
{
|
123 |
-
|
124 |
-
/**/
|
125 |
-
if ($_GET["s2member_file_download"]) /* Filter $excluded to force free downloads. */
|
126 |
{
|
127 |
-
|
128 |
/**/
|
129 |
-
if (
|
130 |
-
/* For backward compatiblity, we also check the xencrypted value, without the hash. This is decprecated as of v2.9. It will be removed completely in a future version. */
|
131 |
-
&& $_GET["s2member_free_file_download_key"] !== ws_plugin__s2member_xencrypt ($_GET["s2member_file_download"]))))
|
132 |
{
|
133 |
-
$
|
134 |
-
/**/
|
135 |
-
$file_download_access_is_allowed = $minimum_level_required_to_download_files = ws_plugin__s2member_min_level_4_downloads ();
|
136 |
-
/**/
|
137 |
-
if (!($current_user = (is_user_logged_in ()) ? wp_get_current_user () : false) /* Redirect Users who are not logged in. */
|
138 |
-
&& wp_redirect (add_query_arg (array ("s2member_level_req" => $minimum_level_required_to_download_files, "s2member_file_download_req" => $_GET["s2member_file_download"]), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
|
139 |
-
exit;
|
140 |
-
/**/
|
141 |
-
else if (!$file_download_access_is_allowed) /* Have file downloads even been enabled? */
|
142 |
-
{
|
143 |
-
header ("HTTP/1.0 503 Service Temporarily Unavailable");
|
144 |
-
echo '503: File Downloads Are Not Enabled.';
|
145 |
-
exit;
|
146 |
-
}
|
147 |
-
/**/
|
148 |
-
else if (!file_exists ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]))
|
149 |
-
{
|
150 |
-
header ("HTTP/1.0 404 Not Found"); /* The file does not even exist. */
|
151 |
-
echo '404: File Download Not Found.';
|
152 |
-
exit;
|
153 |
-
}
|
154 |
-
/**/
|
155 |
-
else if ((!is_array ($file_downloads = ws_plugin__s2member_user_downloads ()) || !$file_downloads["allowed"] || !$file_downloads["allowed_days"])/**/
|
156 |
-
&& wp_redirect (add_query_arg (array ("s2member_file_download_req" => $_GET["s2member_file_download"]), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]))) !== "nill")
|
157 |
-
exit;
|
158 |
-
/**/
|
159 |
-
$previous_file_downloads = 0; /* Here we're going to count how many downloads they've performed. */
|
160 |
-
$max_days_logged = ws_plugin__s2member_max_download_period (); /* The longest period in days. */
|
161 |
-
$file_download_access_log = (array)get_usermeta ($current_user->ID, "s2member_file_download_access_log");
|
162 |
-
$file_download_access_arc = (array)get_usermeta ($current_user->ID, "s2member_file_download_access_arc");
|
163 |
/**/
|
164 |
-
|
165 |
{
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
{
|
168 |
-
|
169 |
-
|
|