s2Member Framework (Member Roles, Capabilities, Membership, PayPal Members) - Version 3.2.3

Version Description

  • New Feature - "Alternative View Protection". Check your Dashboard: s2Member -> General Options -> Alternative View Protection. This new feature deals with some long awaited (protection) for things like: search results, RSS/XML feeds, and custom queries; where excerpts of protected content may slip through, depending on your theme. This feature is NEW, and still in an experimental state. It is disabled by default, but we encourage you to try it with different settings, and report back to us through the support forums for s2Member.
  • New Feature - "Query Conditionals" for developers. Check your Dashboard: s2Member -> API Scripting -> Query Conditionals. s2Member now provides several built-in API Functions that are tailored to meet the needs of developers integrating s2Member into their themes. Such as: is_category_protected_by_s2member($cat_id), is_category_permitted_by_s2member($cat_id), is_tag_protected_by_s2member($tag_id [slug or tag name]), is_tag_permitted_by_s2member($tag_id [slug or tag name]), is_post_protected_by_s2member($post_id), is_post_permitted_by_s2member($post_id), is_page_protected_by_s2member($page_id), is_page_permitted_by_s2member($page_id), is_uri_protected_by_s2member($uri [or full url]), is_uri_permitted_by_s2member($uri [ or full url]). In addition, there are two special functions that can be applied by theme authors before making custom queries: attach_s2member_query_filters(), detach_s2member_query_filters(). These can be used before and after a call to query_posts() for example. s2Member will automatically filter all protected content ( not available to the current User/Member ). Further details on these functions is available under the API Scripting section in your Dashboard. You can also have a look at this file: /s2member/includes/functions/api-functions.inc.php.
  • Compatiblity. s2Member is now compatible with the Page Tagger plugin for WordPress. Installing this plugin will allow you to protect Pages with Tags ( optional ). s2Member is also compatible with HeadSpace2 SEO, which can also enable Tags for Pages.
  • Bug fix. A bug was found in s2Member's handling of PayPal EOT responses. This bug was affecting site owners with newer PayPal accounts ( i.e. their Subscription IDs start with I- ). These newer PayPal accounts trigger subscr_eot events upon last payment, instead of when time has actually expired. s2Member v3.2.3 has been updated to correct its handling of subscr_eot events in this scenario. An obvious symptom of this bug, was to sell a non-recurring Subscription, and have that Subscription EOT on the very same day as the first payment ( which was also the last payment ), because it was non-recurring. This has been resolved in s2Member v3.2.3+.
  • New API Notification. s2Member v3.2.3 includes a new API Notification that can provide details about Refund/Reversal events, which are related to transactions for "Specific Post/Page Access". s2Member has always provided Refund/Reversal Notifications, but NOT for Specific Post/Page Access. There are now two API Notifications for Specific Post/Page Access. One for initial Sales, and another for Refunds/Reversals ( i.e. chargebacks ).
  • Replacement Codes. s2Member v3.2.3 adds two additional Replacement Codes to the API Notification for cancellations. These two additional Replacement Codes are: %%item_number%%, and %%item_name%%. See: s2Member -> API Notifications -> Cancellations for further details.
  • Optimization. Some of s2Member's larger routines have been moved into the /functions/separates/ directory, and they're now loaded "as needed", as opposed to being loaded by default. This will further optimize sites powered by s2Member. In addition, ( FYI for developers ) there are plans to implement SPL Autoload into a future release of s2Member, through classes assigned to various parts of the s2Member software package.
  • Improvement. s2Member's Meta Box panels in the Post/Page editing stations are now designed to disable themselves automatically on special Pages that are handled automatically by s2Member; ( i.e. the Membership Options Page, Login Welcome Page, Download Limit Exceeded Page ). s2Member also provides site owners with a clearer picture of how it handles these special Pages through the Meta Box panel.
  • General Maintenance. These two files paypal-notify.inc.php, and paypal-return.inc.php have BOTH been through another round of testing. Log file analysis ( with the help of other site owners ) indicated there were a few tweaks needed here and there. Minor changes were performed to improve compatibility for both PayPal Standard and PayPal Pro IPN handling ( across both old and new PayPal accounts ). Things like product_name vs. item_name vs. item_name1; and item_number vs. item_number1, vs. rp_invoice_id parsing.
  • New Shortcode Attribute. s2Member now accepts another PayPal Button Shortcode attribute ( ns="1" ) is s2Member's default setting. This controls the no_shipping variable in your PayPal Button. 0 to prompt for a shipping address, but NOT require one ( enables shipping details via IPN ). 1 to NEVER prompt for a shipping address. 2 to prompt for a shipping address, AND require one ( enables shipping details via IPN ).
  • Coming soon. Improvements to s2Member's support for Custom Fields did NOT make it into the official release of s2Member v3.2.3. Further beta testing is required. Support for selects, radios, checkboxes, and other improvements will come in s2Member v3.2.5.
  • Additional changes in "s2Member Pro" have been recorded here.
Download this release

Release Info

Developer PriMoThemes
Plugin Icon 128x128 s2Member Framework (Member Roles, Capabilities, Membership, PayPal Members)
Version 3.2.3
Comparing to
See all releases

Code changes from version 3.2.2 to 3.2.3

Files changed (52) hide show
  1. images/lock-icon.png +0 -0
  2. includes/codes.inc.php +0 -17
  3. includes/functions/api-functions.inc.php +304 -24
  4. includes/functions/catg-level-access.inc.php +119 -92
  5. includes/functions/constants.inc.php +4 -4
  6. includes/functions/file-download-access.inc.php +15 -31
  7. includes/functions/force-ssl.inc.php +65 -63
  8. includes/functions/hide-some-systematics.inc.php +0 -42
  9. includes/functions/is-systematic.inc.php +51 -4
  10. includes/functions/list-servers.inc.php +5 -6
  11. includes/functions/login-redirection.inc.php +59 -25
  12. includes/functions/membership-options.inc.php +6 -2
  13. includes/functions/meta-boxes.inc.php +61 -47
  14. includes/functions/ms-meta-caps.inc.php +2 -0
  15. includes/functions/nocache.inc.php +12 -4
  16. includes/functions/page-level-access.inc.php +169 -48
  17. includes/functions/paypal-button.inc.php +5 -3
  18. includes/functions/paypal-notify.inc.php +4 -1272
  19. includes/functions/paypal-return.inc.php +3 -416
  20. includes/functions/paypal-utilities.inc.php +113 -22
  21. includes/functions/post-level-access.inc.php +178 -40
  22. includes/functions/ptag-level-access.inc.php +130 -69
  23. includes/functions/query-level-access.inc.php +233 -0
  24. includes/functions/ruri-level-access.inc.php +95 -36
  25. includes/functions/sc-get-details.inc.php +5 -1
  26. includes/functions/sc-old-conditionals.inc.php +0 -173
  27. includes/functions/security-gate.inc.php +83 -0
  28. includes/functions/separates/index.php +0 -0
  29. includes/functions/separates/paypal-notify.inc.php +1488 -0
  30. includes/functions/separates/paypal-return.inc.php +445 -0
  31. includes/functions/sp-access.inc.php +21 -21
  32. includes/functions/translations.inc.php +5 -5
  33. includes/functions/utilities.inc.php +151 -3
  34. includes/hooks.inc.php +5 -8
  35. includes/menu-pages/api-ops.inc.php +106 -14
  36. includes/menu-pages/code-samples/custom-queries-loop.php +17 -0
  37. includes/menu-pages/code-samples/custom-queries.php +17 -0
  38. includes/menu-pages/code-samples/query-conditional-examples.php +33 -0
  39. includes/menu-pages/code-samples/specific-category-restrictions.php +12 -0
  40. includes/menu-pages/code-samples/specific-page-restrictions.php +12 -0
  41. includes/menu-pages/code-samples/specific-post-restrictions.php +18 -0
  42. includes/menu-pages/code-samples/specific-tag-restrictions.php +13 -0
  43. includes/menu-pages/menu-pages-s-min.js +1 -1
  44. includes/menu-pages/menu-pages-s.js +4 -4
  45. includes/menu-pages/options.inc.php +110 -61
  46. includes/menu-pages/scripting.inc.php +53 -0
  47. includes/syscon.inc.php +27 -11
  48. includes/templates/shortcodes/paypal-checkout-button-shortcode.html +1 -1
  49. includes/templates/shortcodes/paypal-sp-checkout-button-shortcode.html +1 -1
  50. ms.txt +1 -1
  51. readme.txt +18 -4
  52. s2member.php +4 -4
images/lock-icon.png ADDED
Binary file
includes/codes.inc.php CHANGED
@@ -25,21 +25,4 @@ add_shortcode ("__s2If", "ws_plugin__s2member_sc_if_conditionals");
25
  add_shortcode ("___s2If", "ws_plugin__s2member_sc_if_conditionals");
26
  /**/
27
  add_shortcode ("s2Member-PayPal-Button", "ws_plugin__s2member_sc_paypal_button");
28
- /*
29
- ----------------------------------------------------------------------------------------
30
- The following Shortcodes were deprecated in v3.2.2.
31
- Going forward, use [s2If] instead ( it's more powerful ).
32
- @NOTE: These Shortcodes were ONLY available in v3.2.1.
33
- ~ These WILL all be removed in a future release.
34
- ----------------------------------------------------------------------------------------
35
- */
36
- add_shortcode ("s2All", "ws_plugin__s2member_sc_old_conditionals");
37
- add_shortcode ("_s2All", "ws_plugin__s2member_sc_old_conditionals");
38
- add_shortcode ("__s2All", "ws_plugin__s2member_sc_old_conditionals");
39
- add_shortcode ("___s2All", "ws_plugin__s2member_sc_old_conditionals");
40
- /**/
41
- add_shortcode ("s2Any", "ws_plugin__s2member_sc_old_conditionals");
42
- add_shortcode ("_s2Any", "ws_plugin__s2member_sc_old_conditionals");
43
- add_shortcode ("__s2Any", "ws_plugin__s2member_sc_old_conditionals");
44
- add_shortcode ("___s2Any", "ws_plugin__s2member_sc_old_conditionals");
45
  ?>
25
  add_shortcode ("___s2If", "ws_plugin__s2member_sc_if_conditionals");
26
  /**/
27
  add_shortcode ("s2Member-PayPal-Button", "ws_plugin__s2member_sc_paypal_button");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  ?>
includes/functions/api-functions.inc.php CHANGED
@@ -12,7 +12,7 @@ If not, see: <http://www.gnu.org/licenses/>.
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit("Do not access this file directly.");
16
  /*
17
  API function for Conditionals.
18
  This matches up with a Simple Conditional made available through a Shortcode.
@@ -29,6 +29,8 @@ if (!function_exists ("is_user_not_logged_in"))
29
  API function for Conditionals.
30
  This matches up with a Simple Conditional made available through a Shortcode.
31
  Function `current_user_can()` already exists in WordPress® core.
 
 
32
  */
33
  if (!function_exists ("current_user_is"))
34
  {
@@ -42,6 +44,8 @@ if (!function_exists ("current_user_is"))
42
  API function for Conditionals.
43
  This matches up with a Simple Conditional made available through a Shortcode.
44
  Function `current_user_can()` already exists in WordPress® core.
 
 
45
  */
46
  if (!function_exists ("current_user_is_not"))
47
  {
@@ -55,6 +59,9 @@ if (!function_exists ("current_user_is_not"))
55
  API function for Conditionals.
56
  This matches up with a Simple Conditional made available through a Shortcode.
57
  Function `current_user_can_for_blog()` already exists in WordPress® core.
 
 
 
58
  */
59
  if (!function_exists ("current_user_is_for_blog"))
60
  {
@@ -68,6 +75,9 @@ if (!function_exists ("current_user_is_for_blog"))
68
  API function for Conditionals.
69
  This matches up with a Simple Conditional made available through a Shortcode.
70
  Function `current_user_can_for_blog()` already exists in WordPress® core.
 
 
 
71
  */
72
  if (!function_exists ("current_user_is_not_for_blog"))
73
  {
@@ -81,6 +91,8 @@ if (!function_exists ("current_user_is_not_for_blog"))
81
  API function for Conditionals.
82
  This matches up with a Simple Conditional made available through a Shortcode.
83
  Function `current_user_can()` already exists in WordPress® core.
 
 
84
  */
85
  if (!function_exists ("current_user_cannot"))
86
  {
@@ -93,6 +105,9 @@ if (!function_exists ("current_user_cannot"))
93
  API function for Conditionals.
94
  This matches up with a Simple Conditional made available through a Shortcode.
95
  Function `current_user_can_for_blog()` already exists in WordPress® core.
 
 
 
96
  */
97
  if (!function_exists ("current_user_cannot_for_blog"))
98
  {
@@ -102,51 +117,316 @@ if (!function_exists ("current_user_cannot_for_blog"))
102
  }
103
  }
104
  /*
105
- Alias function for API Scripting usage.
106
- Deprecated in v3.0.5. This will be removed in a future release.
107
- Alias to: `ws_plugin__s2member_encrypt()`.
 
 
 
 
108
  */
109
- if (!function_exists ("s2member_encrypt"))
110
  {
111
- function s2member_encrypt ($string = FALSE, $key = FALSE)
112
  {
113
- return ws_plugin__s2member_encrypt ($string, $key);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  }
115
  }
116
  /*
117
- Alias function for API Scripting usage.
118
- Deprecated in v3.0.5. This will be removed in a future release.
119
- Alias to: `ws_plugin__s2member_decrypt()`.
 
 
 
120
  */
121
- if (!function_exists ("s2member_decrypt"))
122
  {
123
- function s2member_decrypt ($base64 = FALSE, $key = FALSE)
124
  {
125
- return ws_plugin__s2member_decrypt ($base64, $key);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  }
127
  }
128
  /*
129
- Alias function for API Scripting usage.
130
- Deprecated in v3.0.5. This will be removed in a future release.
131
- Alias to: `ws_plugin__s2member_xencrypt()`.
 
 
 
132
  */
133
- if (!function_exists ("s2member_xencrypt"))
134
  {
135
- function s2member_xencrypt ($string = FALSE, $key = FALSE)
136
  {
137
- return ws_plugin__s2member_xencrypt ($string, $key);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  }
139
  }
140
  /*
141
  Alias function for API Scripting usage.
142
- Deprecated in v3.0.5. This will be removed in a future release.
143
- Alias to: `ws_plugin__s2member_xdecrypt()`.
 
 
 
 
 
 
144
  */
145
- if (!function_exists ("s2member_xdecrypt"))
146
  {
147
- function s2member_xdecrypt ($base64 = FALSE, $key = FALSE)
148
  {
149
- return ws_plugin__s2member_xdecrypt ($base64, $key);
150
  }
151
  }
152
  ?>
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit ("Do not access this file directly.");
16
  /*
17
  API function for Conditionals.
18
  This matches up with a Simple Conditional made available through a Shortcode.
29
  API function for Conditionals.
30
  This matches up with a Simple Conditional made available through a Shortcode.
31
  Function `current_user_can()` already exists in WordPress® core.
32
+
33
+ $role - required argument.
34
  */
35
  if (!function_exists ("current_user_is"))
36
  {
44
  API function for Conditionals.
45
  This matches up with a Simple Conditional made available through a Shortcode.
46
  Function `current_user_can()` already exists in WordPress® core.
47
+
48
+ $role - required argument.
49
  */
50
  if (!function_exists ("current_user_is_not"))
51
  {
59
  API function for Conditionals.
60
  This matches up with a Simple Conditional made available through a Shortcode.
61
  Function `current_user_can_for_blog()` already exists in WordPress® core.
62
+
63
+ $blog_id - required argument.
64
+ $role - required argument.
65
  */
66
  if (!function_exists ("current_user_is_for_blog"))
67
  {
75
  API function for Conditionals.
76
  This matches up with a Simple Conditional made available through a Shortcode.
77
  Function `current_user_can_for_blog()` already exists in WordPress® core.
78
+
79
+ $blog_id - required argument.
80
+ $role - required argument.
81
  */
82
  if (!function_exists ("current_user_is_not_for_blog"))
83
  {
91
  API function for Conditionals.
92
  This matches up with a Simple Conditional made available through a Shortcode.
93
  Function `current_user_can()` already exists in WordPress® core.
94
+
95
+ $capability - required argument.
96
  */
97
  if (!function_exists ("current_user_cannot"))
98
  {
105
  API function for Conditionals.
106
  This matches up with a Simple Conditional made available through a Shortcode.
107
  Function `current_user_can_for_blog()` already exists in WordPress® core.
108
+
109
+ $blog_id - required argument.
110
+ $capability - required argument.
111
  */
112
  if (!function_exists ("current_user_cannot_for_blog"))
113
  {
117
  }
118
  }
119
  /*
120
+ API function for Conditionals.
121
+ Allows developers to integrate s2Member ( via Themes ).
122
+ Is a specific [Category, Tag, Post, Page, or URI] protected by s2Member?
123
+
124
+ $__id - optional argument. Defaults to current $post->ID in The Loop.
125
+ $__type - optional argument. One of: `category`, `tag`, `post`, `page`, `singular`, `uri`. Defaults to: `singular`.
126
+ $check_user - optional ( consider the current User? ) defaults to: false.
127
  */
128
+ if (!function_exists ("is_protected_by_s2member"))
129
  {
130
+ function is_protected_by_s2member ($__id = FALSE, $__type = FALSE, $check_user = FALSE)
131
  {
132
+ global $post; /* Global reference to $post in The Loop. */
133
+ /**/
134
+ $__id = ($__id) ? $__id : ( (is_object ($post)) ? $post->ID : false);
135
+ $__type = ($__type) ? strtolower ($__type) : "singular";
136
+ /**/
137
+ if ($__type === "category" && ($array = ws_plugin__s2member_check_specific_catg_level_access ($__id, $check_user)))
138
+ return $array; /* A non-empty array with ["s2member_level_req"]. */
139
+ /**/
140
+ else if ($__type === "tag" && ($array = ws_plugin__s2member_check_specific_ptag_level_access ($__id, $check_user)))
141
+ return $array; /* A non-empty array with ["s2member_level_req"]. */
142
+ /**/
143
+ else if (($__type === "post" || $__type === "singular") && ($array = ws_plugin__s2member_check_specific_post_level_access ($__id, $check_user)))
144
+ return $array; /* A non-empty array with ["s2member_(level|sp|ccap)_req"]. */
145
+ /**/
146
+ else if (($__type === "page" || $__type === "singular") && ($array = ws_plugin__s2member_check_specific_page_level_access ($__id, $check_user)))
147
+ return $array; /* A non-empty array with ["s2member_(level|sp|ccap)_req"]. */
148
+ /**/
149
+ else if ($__type === "uri" && ($array = ws_plugin__s2member_check_specific_ruri_level_access ($__id, $check_user)))
150
+ return $array; /* A non-empty array with ["s2member_level_req"]. */
151
+ /**/
152
+ return false;
153
  }
154
  }
155
  /*
156
+ API function for Conditionals.
157
+ Allows developers to integrate s2Member ( via Themes ).
158
+ Is the current User permitted to access this [Category, Tag, Post, Page, or URI]?
159
+
160
+ $__id - optional argument. Defaults to current $post->ID in The Loop.
161
+ $__type - optional argument. One of: `category`, `tag`, `post`, `page`, `singular`, `uri`. Defaults to: `singular`.
162
  */
163
+ if (!function_exists ("is_permitted_by_s2member"))
164
  {
165
+ function is_permitted_by_s2member ($__id = FALSE, $__type = FALSE)
166
  {
167
+ global $post; /* Global reference to $post in The Loop. */
168
+ /**/
169
+ $__id = ($__id) ? $__id : ( (is_object ($post)) ? $post->ID : false);
170
+ $__type = ($__type) ? strtolower ($__type) : "singular";
171
+ /**/
172
+ if ($__type === "category" && ws_plugin__s2member_check_specific_catg_level_access ($__id, true))
173
+ return false;
174
+ /**/
175
+ else if ($__type === "tag" && ws_plugin__s2member_check_specific_ptag_level_access ($__id, true))
176
+ return false;
177
+ /**/
178
+ else if (($__type === "post" || $__type === "singular") && ws_plugin__s2member_check_specific_post_level_access ($__id, true))
179
+ return false;
180
+ /**/
181
+ else if (($__type === "page" || $__type === "singular") && ws_plugin__s2member_check_specific_page_level_access ($__id, true))
182
+ return false;
183
+ /**/
184
+ else if ($__type === "uri" && ws_plugin__s2member_check_specific_ruri_level_access ($__id, true))
185
+ return false;
186
+ /**/
187
+ return true;
188
  }
189
  }
190
  /*
191
+ API function for Conditionals.
192
+ Allows developers to integrate s2Member ( via Themes ).
193
+ Is a specific Category protected by s2Member?
194
+
195
+ $cat_id - required argument.
196
+ $check_user - optional ( consider the current User? ) defaults to: false.
197
  */
198
+ if (!function_exists ("is_category_protected_by_s2member"))
199
  {
200
+ function is_category_protected_by_s2member ($cat_id = FALSE, $check_user = FALSE)
201
  {
202
+ if ($cat_id && ($array = ws_plugin__s2member_check_specific_catg_level_access ($cat_id, $check_user)))
203
+ return $array; /* A non-empty array with ["s2member_level_req"]. */
204
+ /**/
205
+ return false;
206
+ }
207
+ }
208
+ /*
209
+ API function for Conditionals.
210
+ Allows developers to integrate s2Member ( via Themes ).
211
+ Is the current User permitted to access this Category?
212
+
213
+ $cat_id - required argument.
214
+ */
215
+ if (!function_exists ("is_category_permitted_by_s2member"))
216
+ {
217
+ function is_category_permitted_by_s2member ($cat_id = FALSE)
218
+ {
219
+ if ($cat_id && ws_plugin__s2member_check_specific_catg_level_access ($cat_id, true))
220
+ return false;
221
+ /**/
222
+ return true;
223
+ }
224
+ }
225
+ /*
226
+ API function for Conditionals.
227
+ Allows developers to integrate s2Member ( via Themes ).
228
+ Is a specific Tag protected by s2Member?
229
+
230
+ $tag_id_slug_or_name - required argument.
231
+ $check_user - optional ( consider the current User? ) defaults to: false.
232
+ */
233
+ if (!function_exists ("is_tag_protected_by_s2member"))
234
+ {
235
+ function is_tag_protected_by_s2member ($tag_id_slug_or_name = FALSE, $check_user = FALSE)
236
+ {
237
+ if ($tag_id_slug_or_name && ($array = ws_plugin__s2member_check_specific_ptag_level_access ($tag_id_slug_or_name, $check_user)))
238
+ return $array; /* A non-empty array with ["s2member_level_req"]. */
239
+ /**/
240
+ return false;
241
+ }
242
+ }
243
+ /*
244
+ API function for Conditionals.
245
+ Allows developers to integrate s2Member ( via Themes ).
246
+ Is the current User permitted to access this Tag?
247
+
248
+ $tag_id_slug_or_name - required argument.
249
+ */
250
+ if (!function_exists ("is_tag_permitted_by_s2member"))
251
+ {
252
+ function is_tag_permitted_by_s2member ($tag_id_slug_or_name = FALSE)
253
+ {
254
+ if ($tag_id_slug_or_name && ws_plugin__s2member_check_specific_ptag_level_access ($tag_id_slug_or_name, true))
255
+ return false;
256
+ /**/
257
+ return true;
258
+ }
259
+ }
260
+ /*
261
+ API function for Conditionals.
262
+ Allows developers to integrate s2Member ( via Themes ).
263
+ Is a specific Post protected by s2Member?
264
+
265
+ $post_id - required argument.
266
+ $check_user - optional ( consider the current User? ) defaults to: false.
267
+ */
268
+ if (!function_exists ("is_post_protected_by_s2member"))
269
+ {
270
+ function is_post_protected_by_s2member ($post_id = FALSE, $check_user = FALSE)
271
+ {
272
+ if ($post_id && ($array = ws_plugin__s2member_check_specific_post_level_access ($post_id, $check_user)))
273
+ return $array; /* A non-empty array with ["s2member_(level|sp|ccap)_req"]. */
274
+ /**/
275
+ return false;
276
+ }
277
+ }
278
+ /*
279
+ API function for Conditionals.
280
+ Allows developers to integrate s2Member ( via Themes ).
281
+ Is the current User permitted to access this Post?
282
+
283
+ $post_id - required argument.
284
+ */
285
+ if (!function_exists ("is_post_permitted_by_s2member"))
286
+ {
287
+ function is_post_permitted_by_s2member ($post_id = FALSE)
288
+ {
289
+ if ($post_id && ws_plugin__s2member_check_specific_post_level_access ($post_id, true))
290
+ return false;
291
+ /**/
292
+ return true;
293
+ }
294
+ }
295
+ /*
296
+ API function for Conditionals.
297
+ Allows developers to integrate s2Member ( via Themes ).
298
+ Is a specific Page protected by s2Member?
299
+
300
+ $page_id - required argument.
301
+ $check_user - optional ( consider the current User? ) defaults to: false.
302
+ */
303
+ if (!function_exists ("is_page_protected_by_s2member"))
304
+ {
305
+ function is_page_protected_by_s2member ($page_id = FALSE, $check_user = FALSE)
306
+ {
307
+ if ($page_id && ($array = ws_plugin__s2member_check_specific_page_level_access ($page_id, $check_user)))
308
+ return $array; /* A non-empty array with ["s2member_(level|sp|ccap)_req"]. */
309
+ /**/
310
+ return false;
311
+ }
312
+ }
313
+ /*
314
+ API function for Conditionals.
315
+ Allows developers to integrate s2Member ( via Themes ).
316
+ Is the current User permitted to access this Page?
317
+
318
+ $page_id - required argument.
319
+ */
320
+ if (!function_exists ("is_page_permitted_by_s2member"))
321
+ {
322
+ function is_page_permitted_by_s2member ($page_id = FALSE)
323
+ {
324
+ if ($page_id && ws_plugin__s2member_check_specific_page_level_access ($page_id, true))
325
+ return false;
326
+ /**/
327
+ return true;
328
+ }
329
+ }
330
+ /*
331
+ API function for Conditionals.
332
+ Allows developers to integrate s2Member ( via Themes ).
333
+ Is a specific URI/URL protected by s2Member?
334
+
335
+ NOTE: This will ONLY check s2Member's URI Level Access restrictions.
336
+ - So unlike s2Member's other Query Conditionals,
337
+ this will NOT check everything.
338
+
339
+ Use of this function is usually NOT required, because all of these
340
+ other Conditionals already check URI restrictions inclusively:
341
+ - is_category_protected_by_s2member($cat_id);
342
+ - is_tag_protected_by_s2member($tag_id [ or slug ]);
343
+ - is_post_protected_by_s2member($post_id);
344
+ - is_page_protected_by_s2member($page_id);
345
+
346
+ $uri_or_full_url - required argument.
347
+ $check_user - optional ( consider the current User? ) defaults to: false.
348
+ */
349
+ if (!function_exists ("is_uri_protected_by_s2member"))
350
+ {
351
+ function is_uri_protected_by_s2member ($uri_or_full_url = FALSE, $check_user = FALSE)
352
+ {
353
+ if ($uri_or_full_url && ($array = ws_plugin__s2member_check_specific_ruri_level_access ($uri_or_full_url, $check_user)))
354
+ return $array; /* A non-empty array with ["s2member_level_req"]. */
355
+ /**/
356
+ return false;
357
+ }
358
+ }
359
+ /*
360
+ API function for Conditionals.
361
+ Allows developers to integrate s2Member ( via Themes ).
362
+ Is the current URI/URL permitted to access this Page?
363
+
364
+ NOTE: This will ONLY check s2Member's URI Level Access restrictions.
365
+ - So unlike s2Member's other Query Conditionals,
366
+ this will NOT check everything.
367
+
368
+ Use of this function is usually NOT required, because all of these
369
+ other Conditionals already check URI restrictions inclusively:
370
+ - is_category_permitted_by_s2member($cat_id);
371
+ - is_tag_permitted_by_s2member($tag_id [ or slug ]);
372
+ - is_post_permitted_by_s2member($post_id);
373
+ - is_page_permitted_by_s2member($page_id);
374
+
375
+ $uri_or_full_url - required argument.
376
+ */
377
+ if (!function_exists ("is_uri_permitted_by_s2member"))
378
+ {
379
+ function is_uri_permitted_by_s2member ($uri_or_full_url = FALSE)
380
+ {
381
+ if ($uri_or_full_url && ws_plugin__s2member_check_specific_ruri_level_access ($uri_or_full_url, true))
382
+ return false;
383
+ /**/
384
+ return true;
385
+ }
386
+ }
387
+ /*
388
+ API function for custom queries.
389
+ Allows developers to integrate s2Member ( via Themes ).
390
+ Attaches s2Member's query filters; hiding protected content.
391
+ Don't forget to call: `detach_s2member_query_filters()`.
392
+ */
393
+ if (!function_exists ("attach_s2member_query_filters"))
394
+ {
395
+ function attach_s2member_query_filters ()
396
+ {
397
+ remove_action ("pre_get_posts", "ws_plugin__s2member_security_gate_query", 20);
398
+ add_action ("pre_get_posts", "ws_plugin__s2member_force_query_level_access", 20);
399
+ }
400
+ }
401
+ /*
402
+ API function for custom queries.
403
+ Allows developers to integrate s2Member ( via Themes ).
404
+ Detaches filters applied by: `attach_s2member_query_filters()`.
405
+ */
406
+ if (!function_exists ("detach_s2member_query_filters"))
407
+ {
408
+ function detach_s2member_query_filters ()
409
+ {
410
+ remove_action ("pre_get_posts", "ws_plugin__s2member_force_query_level_access", 20);
411
+ add_action ("pre_get_posts", "ws_plugin__s2member_security_gate_query", 20);
412
  }
413
  }
414
  /*
415
  Alias function for API Scripting usage.
416
+ Function creates a special File Download Key.
417
+ Uses: date("Y-m-d") . $_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"] . $file.
418
+
419
+ The optional second argument can be passed in for compatiblity with Quick Cache / WP Super Cache.
420
+ When $cache_compatible is passed in, the salt is reduced to only the $file value.
421
+ - which is NOT as secure. So use that with caution.
422
+
423
+ $file - required argument.
424
  */
425
+ if (!function_exists ("s2member_file_download_key"))
426
  {
427
+ function s2member_file_download_key ($file = FALSE, $cache_compatible = FALSE)
428
  {
429
+ return ws_plugin__s2member_file_download_key ($file, $cache_compatible);
430
  }
431
  }
432
  ?>
includes/functions/catg-level-access.inc.php CHANGED
@@ -14,122 +14,149 @@ Direct access denial.
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /*
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 () && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
 
 
 
 
 
 
 
33
  {
34
- $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"]["level0_catgs"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && wp_redirect (add_query_arg ("s2member_level_req", "0", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
39
- exit ();
40
- /**/
41
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_catgs"] && in_array ($cat_ID, ($level0_catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_catgs"]))) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && wp_redirect (add_query_arg ("s2member_level_req", "0", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
42
- exit ();
43
- /**/
44
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_catgs"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
45
- exit ();
46
- /**/
47
- 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 (true) !== "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")
48
- exit ();
49
- /**/
50
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_catgs"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
51
- exit ();
52
- /**/
53
- 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 (true) !== "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")
54
- exit ();
55
- /**/
56
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_catgs"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
57
- exit ();
58
- /**/
59
- 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 (true) !== "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")
60
- exit ();
61
- /**/
62
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_catgs"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
63
- exit ();
64
- /**/
65
- 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 (true) !== "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")
66
- exit ();
67
- /**/
68
- if ($level0_catgs)
69
- foreach ($level0_catgs as $catg)
70
- if ($catg && cat_is_ancestor_of ($catg, $cat_ID) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && wp_redirect (add_query_arg ("s2member_level_req", "0", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
71
- exit ();
72
- /**/
73
- if ($level1_catgs)
74
- foreach ($level1_catgs as $catg)
75
- if ($catg && cat_is_ancestor_of ($catg, $cat_ID) && ws_plugin__s2member_nocache_constants (true) !== "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")
76
- exit ();
77
- /**/
78
- if ($level2_catgs)
79
- foreach ($level2_catgs as $catg)
80
- if ($catg && cat_is_ancestor_of ($catg, $cat_ID) && ws_plugin__s2member_nocache_constants (true) !== "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")
81
- exit ();
82
- /**/
83
- if ($level3_catgs)
84
- foreach ($level3_catgs as $catg)
85
- if ($catg && cat_is_ancestor_of ($catg, $cat_ID) && ws_plugin__s2member_nocache_constants (true) !== "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")
86
- exit ();
87
- /**/
88
- if ($level4_catgs)
89
- foreach ($level4_catgs as $catg)
90
- if ($catg && cat_is_ancestor_of ($catg, $cat_ID) && ws_plugin__s2member_nocache_constants (true) !== "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")
91
- exit ();
92
  }
93
- else if (is_single () && !is_page () && $post_ID)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  {
95
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_catgs"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && wp_redirect (add_query_arg ("s2member_level_req", "0", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
96
- exit ();
97
- /**/
98
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_catgs"] && (in_category (($level0_catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_catgs"])), $post_ID) || ws_plugin__s2member_in_descendant_category ($level0_catgs, $post_ID)) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && wp_redirect (add_query_arg ("s2member_level_req", "0", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
99
- exit ();
100
- /**/
101
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_catgs"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
102
- exit ();
103
- /**/
104
- 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 (true) !== "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")
105
- exit ();
106
- /**/
107
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_catgs"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
108
- exit ();
109
- /**/
110
- 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 (true) !== "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")
111
- exit ();
112
  /**/
113
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_catgs"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
114
- exit ();
115
  /**/
116
- 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 (true) !== "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")
117
- exit ();
118
- /**/
119
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_catgs"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
120
- exit ();
121
- /**/
122
- 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 (true) !== "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")
123
- exit ();
124
  }
125
  /**/
126
- do_action ("ws_plugin__s2member_during_check_catg_level_access", get_defined_vars ());
 
 
 
 
 
 
127
  }
 
 
128
  }
129
  /**/
130
- do_action ("ws_plugin__s2member_after_check_catg_level_access", get_defined_vars ());
131
- /**/
132
- return;
133
  }
134
  }
135
  ?>
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /*
17
+ Function for handling Category Level Access permissions.
18
  Attach to: add_action("template_redirect");
19
+
20
+ Don't call this function directly, use one of these API functions:
21
+
22
+ Is it protected by s2Member at all?
23
+ - is_category_protected_by_s2member($cat_id);
24
+ - is_protected_by_s2member($cat_id, "category");
25
+
26
+ Is the current User permitted/authorized?
27
+ - is_category_permitted_by_s2member($cat_id);
28
+ - is_permitted_by_s2member($cat_id, "category");
29
+
30
+ see: `/s2member/includes/functions/api-functions.inc.php`.
31
  */
32
  if (!function_exists ("ws_plugin__s2member_check_catg_level_access"))
33
  {
34
  function ws_plugin__s2member_check_catg_level_access ()
35
  {
36
+ global $post; /* get_the_ID() is NOT available outside The Loop. */
37
  /**/
38
  do_action ("ws_plugin__s2member_before_check_catg_level_access", get_defined_vars ());
39
  /**/
40
  $excluded = apply_filters ("ws_plugin__s2member_check_catg_level_access_excluded", false, get_defined_vars ());
41
  /**/
42
+ if (!$excluded && is_category () && ($cat_id = get_query_var ("cat")) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
43
  {
44
+ $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
45
+ /**/
46
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = ws_plugin__s2member_login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")))
47
+ {
48
+ wp_redirect (add_query_arg ("s2member_level_req", 0, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
49
+ exit ();
50
+ }
51
+ else if (!ws_plugin__s2member_is_systematic_use_page ()) /* Do NOT protect Systematics. However, there is 1 exception above ^. */
52
  {
53
+ for ($i = 0; $i <= 4; $i++) /* Category Level restrictions. Go through each Membership Level. We also check nested Categories, using `cat_is_ancestor_of()`. */
54
+ {
55
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
56
+ {
57
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
58
+ exit ();
59
+ }
60
+ /**/
61
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] && in_array ($cat_id, ($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]))) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
62
+ {
63
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
64
+ exit ();
65
+ }
66
+ /**/
67
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]) /* Check Category ancestry. */
68
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]) as $catg)
69
+ if ($catg && cat_is_ancestor_of ($catg, $cat_id) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
70
+ {
71
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
72
+ exit ();
73
+ }
74
+ }
75
  /**/
76
+ for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
77
  {
78
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
79
+ foreach (preg_split ("/[\r\n\t]+/", ws_plugin__s2member_fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
80
+ if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
81
+ {
82
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
83
+ exit ();
84
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  }
86
+ }
87
+ /**/
88
+ do_action ("ws_plugin__s2member_during_check_catg_level_access", get_defined_vars ());
89
+ }
90
+ /**/
91
+ do_action ("ws_plugin__s2member_after_check_catg_level_access", get_defined_vars ());
92
+ /**/
93
+ return; /* For uniformity. */
94
+ }
95
+ }
96
+ /*
97
+ Function checks Category Level Access permissions- for a specific Category.
98
+
99
+ Don't call this function directly, use one of these API functions:
100
+
101
+ Is it protected by s2Member at all?
102
+ - is_category_protected_by_s2member($cat_id);
103
+ - is_protected_by_s2member($cat_id, "category");
104
+
105
+ Is the current User permitted/authorized?
106
+ - is_category_permitted_by_s2member($cat_id);
107
+ - is_permitted_by_s2member($cat_id, "category");
108
+
109
+ see: `/s2member/includes/functions/api-functions.inc.php`.
110
+ */
111
+ if (!function_exists ("ws_plugin__s2member_check_specific_catg_level_access"))
112
+ {
113
+ function ws_plugin__s2member_check_specific_catg_level_access ($cat_id = FALSE, $check_user = TRUE)
114
+ {
115
+ do_action ("ws_plugin__s2member_before_check_specific_catg_level_access", get_defined_vars ());
116
+ /**/
117
+ $excluded = apply_filters ("ws_plugin__s2member_check_specific_catg_level_access_excluded", false, get_defined_vars ());
118
+ /**/
119
+ if (!$excluded && $cat_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Check? */
120
+ {
121
+ $cat_link = get_category_link ($cat_id); /* Determine link to this Category. */
122
+ $cat_path = parse_url ($cat_link, PHP_URL_PATH); /* Parse req path. */
123
+ $cat_query = parse_url ($cat_link, PHP_URL_QUERY); /* Parse query. */
124
+ $cat_uri = ($cat_query) ? $cat_path . "?" . $cat_query : $cat_path;
125
+ /**/
126
+ $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
127
+ /**/
128
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = ws_plugin__s2member_login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $cat_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level0")))
129
+ return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
130
+ /**/
131
+ else if (!ws_plugin__s2member_is_systematic_use_specific_page (null, $cat_uri)) /* Never restrict Systematic Use Pages. However, there is 1 exception above ^. */
132
+ {
133
+ for ($i = 0; $i <= 4; $i++) /* Category Level restrictions. Go through each Membership Level. We also check nested Categories, using `cat_is_ancestor_of()`. */
134
  {
135
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] === "all" && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
136
+ return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  /**/
138
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] && in_array ($cat_id, ($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]))) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
139
+ return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
140
  /**/
141
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]) /* Check Category ancestry. */
142
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]) as $catg)
143
+ if ($catg && cat_is_ancestor_of ($catg, $cat_id) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
144
+ return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
 
 
 
 
145
  }
146
  /**/
147
+ for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
148
+ {
149
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
150
+ foreach (preg_split ("/[\r\n\t]+/", ws_plugin__s2member_fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
151
+ if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $cat_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
152
+ return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
153
+ }
154
  }
155
+ /**/
156
+ do_action ("ws_plugin__s2member_during_check_specific_catg_level_access", get_defined_vars ());
157
  }
158
  /**/
159
+ return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", null, get_defined_vars ());
 
 
160
  }
161
  }
162
  ?>
includes/functions/constants.inc.php CHANGED
@@ -12,7 +12,7 @@ If not, see: <http://www.gnu.org/licenses/>.
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /*
17
  Define several API Constants for s2Member.
18
  Note that these are duplicated into the JavaScript API as well.
@@ -34,9 +34,9 @@ if (!function_exists ("ws_plugin__s2member_constants"))
34
  $custom = ($current_user) ? get_user_option ("s2member_custom", $current_user->ID) : "";
35
  $custom_fields = ($current_user) ? get_user_option ("s2member_custom_fields", $current_user->ID) : array ();
36
  /**/
37
- $login_redirection_override = ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"]) ? ws_plugin__s2member_fill_login_redirect_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"], $current_user) : "";
38
  /**/
39
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
40
  do_action ("ws_plugin__s2member_during_constants", get_defined_vars ());
41
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
42
  /**/
@@ -71,7 +71,7 @@ if (!function_exists ("ws_plugin__s2member_constants"))
71
  define ("S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL", ($c[] = get_bloginfo ("wpurl") . "/?s2member_profile=1"));
72
  define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL", ($c[] = (string)$links["file_download_limit_exceeded_page"]));
73
  define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL", ($c[] = (string)$links["membership_options_page"]));
74
- define ("S2MEMBER_LOGIN_WELCOME_PAGE_URL", ($c[] = (($login_redirection_override) ? (string)$login_redirection_override : (string)$links["login_welcome_page"])));
75
  define ("S2MEMBER_LOGOUT_PAGE_URL", ($c[] = (string)wp_logout_url ()));
76
  define ("S2MEMBER_LOGIN_PAGE_URL", ($c[] = (string)wp_login_url ()));
77
  /**/
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit("Do not access this file directly.");
16
  /*
17
  Define several API Constants for s2Member.
18
  Note that these are duplicated into the JavaScript API as well.
34
  $custom = ($current_user) ? get_user_option ("s2member_custom", $current_user->ID) : "";
35
  $custom_fields = ($current_user) ? get_user_option ("s2member_custom_fields", $current_user->ID) : array ();
36
  /**/
37
+ $login_redirection_url = ws_plugin__s2member_login_redirection_url ($current_user);
38
  /**/
39
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
40
  do_action ("ws_plugin__s2member_during_constants", get_defined_vars ());
41
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
42
  /**/
71
  define ("S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL", ($c[] = get_bloginfo ("wpurl") . "/?s2member_profile=1"));
72
  define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL", ($c[] = (string)$links["file_download_limit_exceeded_page"]));
73
  define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL", ($c[] = (string)$links["membership_options_page"]));
74
+ define ("S2MEMBER_LOGIN_WELCOME_PAGE_URL", ($c[] = (($login_redirection_url) ? (string)$login_redirection_url : (string)$links["login_welcome_page"])));
75
  define ("S2MEMBER_LOGOUT_PAGE_URL", ($c[] = (string)wp_logout_url ()));
76
  define ("S2MEMBER_LOGIN_PAGE_URL", ($c[] = (string)wp_login_url ()));
77
  /**/
includes/functions/file-download-access.inc.php CHANGED
@@ -24,24 +24,16 @@ if (!function_exists ("ws_plugin__s2member_max_download_period"))
24
  do_action ("ws_plugin__s2member_before_max_download_period", get_defined_vars ());
25
  /**/
26
  if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"])
27
- {
28
- $max = ($max < $days) ? $days : $max;
29
- }
30
  /**/
31
  if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"])
32
- {
33
- $max = ($max < $days) ? $days : $max;
34
- }
35
  /**/
36
  if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"])
37
- {
38
- $max = ($max < $days) ? $days : $max;
39
- }
40
  /**/
41
  if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"])
42
- {
43
- $max = ($max < $days) ? $days : $max;
44
- }
45
  /**/
46
  return apply_filters ("ws_plugin__s2member_max_download_period", (($max > 365) ? 365 : (int)$max), get_defined_vars ());
47
  }
@@ -115,25 +107,19 @@ if (!function_exists ("ws_plugin__s2member_min_level_4_downloads"))
115
  $file_download_access_is_allowed = $min_level_4_downloads = false; /* Test with === false, which means no access is allowed at all. */
116
  /**/
117
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed_days"])
118
- {
119
- $file_download_access_is_allowed = $min_level_4_downloads = 0;
120
- }
121
  else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"])
122
- {
123
- $file_download_access_is_allowed = $min_level_4_downloads = 1;
124
- }
125
  else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"])
126
- {
127
- $file_download_access_is_allowed = $min_level_4_downloads = 2;
128
- }
129
  else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"])
130
- {
131
- $file_download_access_is_allowed = $min_level_4_downloads = 3;
132
- }
133
  else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"])
134
- {
135
- $file_download_access_is_allowed = $min_level_4_downloads = 4;
136
- }
137
  /**/
138
  return apply_filters ("ws_plugin__s2member_min_level_4_downloads", ($file_download_access_is_allowed = $min_level_4_downloads), get_defined_vars ());
139
  }
@@ -288,8 +274,10 @@ if (!function_exists ("ws_plugin__s2member_check_file_download_access"))
288
  /*
289
  Function creates a special File Download Key.
290
  Uses: date("Y-m-d") . $_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"] . $file.
 
291
  The optional second argument can be passed in for compatiblity with Quick Cache / WP Super Cache.
292
  When $cache_compatible is passed in, the salt is reduced to only the $file value.
 
293
  */
294
  if (!function_exists ("ws_plugin__s2member_file_download_key"))
295
  {
@@ -307,9 +295,5 @@ if (!function_exists ("ws_plugin__s2member_file_download_key"))
307
  /**/
308
  return apply_filters ("ws_plugin__s2member_file_download_key", $key, get_defined_vars ());
309
  }
310
- function s2member_file_download_key ($file = FALSE, $cache_compatible = FALSE)
311
- {
312
- return ws_plugin__s2member_file_download_key ($file, $cache_compatible);
313
- }
314
  }
315
  ?>
24
  do_action ("ws_plugin__s2member_before_max_download_period", get_defined_vars ());
25
  /**/
26
  if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"])
27
+ $max = ($max < $days) ? $days : $max;
 
 
28
  /**/
29
  if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"])
30
+ $max = ($max < $days) ? $days : $max;
 
 
31
  /**/
32
  if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"])
33
+ $max = ($max < $days) ? $days : $max;
 
 
34
  /**/
35
  if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"])
36
+ $max = ($max < $days) ? $days : $max;
 
 
37
  /**/
38
  return apply_filters ("ws_plugin__s2member_max_download_period", (($max > 365) ? 365 : (int)$max), get_defined_vars ());
39
  }
107
  $file_download_access_is_allowed = $min_level_4_downloads = false; /* Test with === false, which means no access is allowed at all. */
108
  /**/
109
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed_days"])
110
+ $file_download_access_is_allowed = $min_level_4_downloads = 0;
111
+ /**/
 
112
  else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"])
113
+ $file_download_access_is_allowed = $min_level_4_downloads = 1;
114
+ /**/
 
115
  else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"])
116
+ $file_download_access_is_allowed = $min_level_4_downloads = 2;
117
+ /**/
 
118
  else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"])
119
+ $file_download_access_is_allowed = $min_level_4_downloads = 3;
120
+ /**/
 
121
  else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"])
122
+ $file_download_access_is_allowed = $min_level_4_downloads = 4;
 
 
123
  /**/
124
  return apply_filters ("ws_plugin__s2member_min_level_4_downloads", ($file_download_access_is_allowed = $min_level_4_downloads), get_defined_vars ());
125
  }
274
  /*
275
  Function creates a special File Download Key.
276
  Uses: date("Y-m-d") . $_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"] . $file.
277
+
278
  The optional second argument can be passed in for compatiblity with Quick Cache / WP Super Cache.
279
  When $cache_compatible is passed in, the salt is reduced to only the $file value.
280
+ - which is NOT as secure. So use that with caution.
281
  */
282
  if (!function_exists ("ws_plugin__s2member_file_download_key"))
283
  {
295
  /**/
296
  return apply_filters ("ws_plugin__s2member_file_download_key", $key, get_defined_vars ());
297
  }
 
 
 
 
298
  }
299
  ?>
includes/functions/force-ssl.inc.php CHANGED
@@ -33,69 +33,71 @@ if (!function_exists ("ws_plugin__s2member_check_force_ssl"))
33
  /**/
34
  do_action ("ws_plugin__s2member_before_check_force_ssl", get_defined_vars ());
35
  /**/
36
- if (is_singular () && ($force_ssl = get_post_meta ($post->ID, "s2member_force_ssl", true)))
37
- {
38
- if (!is_ssl ()) /* SSL must be enabled here. Redirect to https:// scheme. */
39
- {
40
- $ssl_host = preg_replace ("/\:[0-9]+$/", "", $_SERVER["HTTP_HOST"]);
41
- $ssl_port = (is_numeric ($force_ssl) && $force_ssl > 1) ? $force_ssl : 0;
42
- $ssl_host_port = $ssl_host . (($ssl_port) ? ":" . $ssl_port : "");
43
- /**/
44
- wp_redirect ("https://" . $ssl_host_port . $_SERVER["REQUEST_URI"]);
45
- exit (); /* ^ So let's redirect to the SSL enabled version. */
46
- }
47
- else /* Otherwise, we buffer all output, and switch all content over to https. */
48
- {
49
- $ssl_host = preg_replace ("/\:[0-9]+$/", "", $_SERVER["HTTP_HOST"]);
50
- $ssl_port = (is_numeric ($force_ssl) && $force_ssl > 1) ? $force_ssl : 0;
51
- $ssl_host_port = $ssl_host . (($ssl_port) ? ":" . $ssl_port : "");
52
- /**/
53
- define ("_ws_plugin__s2member_force_ssl_host", $ssl_host);
54
- define ("_ws_plugin__s2member_force_ssl_port", $ssl_port);
55
- define ("_ws_plugin__s2member_force_ssl_host_port", $ssl_host_port);
56
- /**/
57
- /* Except these. We do NOT want to create a sitewide https conversion! */
58
- add_filter ("home_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 3);
59
- add_filter ("network_home_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 3);
60
- add_filter ("site_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 3);
61
- add_filter ("network_site_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 3);
62
- /**/
63
- function _ws_plugin__s2member_force_non_ssl_scheme ($url = FALSE, $path = FALSE, $scheme = FALSE)
64
- {
65
- return ($scheme) ? $url : preg_replace ("/^https\:\/\//i", "http://", $url);
66
- }
67
- /**/
68
- function _ws_plugin__s2member_force_ssl_buffer ($buffer = FALSE)
69
- {
70
- $o_pcre = ini_get ("pcre.backtrack_limit");
71
- /**/
72
- ini_set ("pcre.backtrack_limit", 10000000);
73
- /**/
74
- $tags = "script|style|link|img|input|iframe|object|embed"; /* Specific tags. */
75
- /**/
76
- $tags = apply_filters ("_ws_plugin__s2member_force_ssl_buffer_tags", $tags, get_defined_vars ());
77
- /**/
78
- $buffer = preg_replace_callback ("/\<(" . $tags . ")[^\>]+\>/i", "_ws_plugin__s2member_force_ssl_buffer_callback", $buffer);
79
- $buffer = preg_replace_callback ("/\<style[^\>]*\>(.+?)\<\/style\>/is", "_ws_plugin__s2member_force_ssl_buffer_callback", $buffer);
80
- /**/
81
- ini_set ("pcre.backtrack_limit", $o_pcre);
82
- /**/
83
- return apply_filters ("_ws_plugin__s2member_force_ssl_buffer", $buffer, get_defined_vars ());
84
- }
85
- /**/
86
- function _ws_plugin__s2member_force_ssl_buffer_callback ($m = FALSE)
87
- {
88
- $c = preg_replace ("/http\:\/\//i", "https://", $m[0]);
89
- /**/
90
- if (_ws_plugin__s2member_force_ssl_port && _ws_plugin__s2member_force_ssl_host && _ws_plugin__s2member_force_ssl_host_port) /* Do we ALSO need port conversions? */
91
- $c = preg_replace ("/\/" . preg_quote (_ws_plugin__s2member_force_ssl_host, "/") . "(\:[0-9]+)?\//i", "/" . _ws_plugin__s2member_force_ssl_host_port . "/", $c);
92
- /**/
93
- return $c; /* Return string with conversions. */
94
- }
95
- /**/
96
- ob_start ("_ws_plugin__s2member_force_ssl_buffer"); /* Buffer. */
97
- }
98
- }
 
 
99
  /**/
100
  do_action ("ws_plugin__s2member_after_check_force_ssl", get_defined_vars ());
101
  /**/
33
  /**/
34
  do_action ("ws_plugin__s2member_before_check_force_ssl", get_defined_vars ());
35
  /**/
36
+ if (is_singular () && is_object ($post) && ($__id = $post->ID)) /* Singular? */
37
+ /**/
38
+ if (($force_ssl = get_post_meta ($__id, "s2member_force_ssl", true))) /* Forcing? */
39
+ {
40
+ if (!is_ssl ()) /* SSL must be enabled here. Redirect to https:// scheme. */
41
+ {
42
+ $ssl_host = preg_replace ("/\:[0-9]+$/", "", $_SERVER["HTTP_HOST"]);
43
+ $ssl_port = (is_numeric ($force_ssl) && $force_ssl > 1) ? $force_ssl : 0;
44
+ $ssl_host_port = $ssl_host . (($ssl_port) ? ":" . $ssl_port : "");
45
+ /**/
46
+ wp_redirect ("https://" . $ssl_host_port . $_SERVER["REQUEST_URI"]);
47
+ exit (); /* ^ So let's redirect to the SSL enabled version. */
48
+ }
49
+ else /* Otherwise, we buffer all output, and switch all content over to https. */
50
+ {
51
+ $ssl_host = preg_replace ("/\:[0-9]+$/", "", $_SERVER["HTTP_HOST"]);
52
+ $ssl_port = (is_numeric ($force_ssl) && $force_ssl > 1) ? $force_ssl : 0;
53
+ $ssl_host_port = $ssl_host . (($ssl_port) ? ":" . $ssl_port : "");
54
+ /**/
55
+ define ("_ws_plugin__s2member_force_ssl_host", $ssl_host);
56
+ define ("_ws_plugin__s2member_force_ssl_port", $ssl_port);
57
+ define ("_ws_plugin__s2member_force_ssl_host_port", $ssl_host_port);
58
+ /**/
59
+ /* Except these. We do NOT want to create a sitewide https conversion! */
60
+ add_filter ("home_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 3);
61
+ add_filter ("network_home_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 3);
62
+ add_filter ("site_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 3);
63
+ add_filter ("network_site_url", "_ws_plugin__s2member_force_non_ssl_scheme", 10, 3);
64
+ /**/
65
+ function _ws_plugin__s2member_force_non_ssl_scheme ($url = FALSE, $path = FALSE, $scheme = FALSE)
66
+ {
67
+ return ($scheme) ? $url : preg_replace ("/^https\:\/\//i", "http://", $url);
68
+ }
69
+ /**/
70
+ function _ws_plugin__s2member_force_ssl_buffer ($buffer = FALSE)
71
+ {
72
+ $o_pcre = ini_get ("pcre.backtrack_limit");
73
+ /**/
74
+ ini_set ("pcre.backtrack_limit", 10000000);
75
+ /**/
76
+ $tags = "script|style|link|img|input|iframe|object|embed"; /* Specific tags. */
77
+ /**/
78
+ $tags = apply_filters ("_ws_plugin__s2member_force_ssl_buffer_tags", $tags, get_defined_vars ());
79
+ /**/
80
+ $buffer = preg_replace_callback ("/\<(" . $tags . ")[^\>]+\>/i", "_ws_plugin__s2member_force_ssl_buffer_callback", $buffer);
81
+ $buffer = preg_replace_callback ("/\<style[^\>]*\>(.+?)\<\/style\>/is", "_ws_plugin__s2member_force_ssl_buffer_callback", $buffer);
82
+ /**/
83
+ ini_set ("pcre.backtrack_limit", $o_pcre);
84
+ /**/
85
+ return apply_filters ("_ws_plugin__s2member_force_ssl_buffer", $buffer, get_defined_vars ());
86
+ }
87
+ /**/
88
+ function _ws_plugin__s2member_force_ssl_buffer_callback ($m = FALSE)
89
+ {
90
+ $c = preg_replace ("/http\:\/\//i", "https://", $m[0]);
91
+ /**/
92
+ if (_ws_plugin__s2member_force_ssl_port && _ws_plugin__s2member_force_ssl_host && _ws_plugin__s2member_force_ssl_host_port) /* Do we ALSO need port conversions? */
93
+ $c = preg_replace ("/\/" . preg_quote (_ws_plugin__s2member_force_ssl_host, "/") . "(\:[0-9]+)?\//i", "/" . _ws_plugin__s2member_force_ssl_host_port . "/", $c);
94
+ /**/
95
+ return $c; /* Return string with conversions. */
96
+ }
97
+ /**/
98
+ ob_start ("_ws_plugin__s2member_force_ssl_buffer"); /* Buffer. */
99
+ }
100
+ }
101
  /**/
102
  do_action ("ws_plugin__s2member_after_check_force_ssl", get_defined_vars ());
103
  /**/
includes/functions/hide-some-systematics.inc.php DELETED
@@ -1,42 +0,0 @@
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("Do not access this file directly.");
16
- /*
17
- Function that hides some of the systematic use pages.
18
- Attach to: add_filter("posts_where");
19
- */
20
- if (!function_exists ("ws_plugin__s2member_hide_some_systematics"))
21
- {
22
- function ws_plugin__s2member_hide_some_systematics ($where = FALSE)
23
- {
24
- global $wpdb; /* Need this to get the table name. */
25
- /**/
26
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
27
- do_action ("ws_plugin__s2member_before_hide_some_systematics", get_defined_vars ());
28
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
29
- /**/
30
- if (is_search ()) /* Here we exclude a few systematic use pages from the search query. */
31
- {
32
- $where .= " AND " . $wpdb->posts . ".ID NOT IN ('" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] . "', '" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] . "', '" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] . "')";
33
- /**/
34
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
35
- do_action ("ws_plugin__s2member_during_hide_some_systematics", get_defined_vars ());
36
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
37
- }
38
- /**/
39
- return apply_filters ("ws_plugin__s2member_hide_some_systematics", $where, get_defined_vars ());
40
- }
41
- }
42
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/functions/is-systematic.inc.php CHANGED
@@ -12,9 +12,9 @@ If not, see: <http://www.gnu.org/licenses/>.
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /*
17
- Function that determines whether we are on a systematic use page.
18
  */
19
  if (!function_exists ("ws_plugin__s2member_is_systematic_use_page"))
20
  {
@@ -26,7 +26,7 @@ if (!function_exists ("ws_plugin__s2member_is_systematic_use_page"))
26
  {
27
  return $is_systematic; /* Filters will have already been applied. */
28
  }
29
- else if (is_admin ()) /* In the admin area? - All administrational pages are considered systematic. */
30
  {
31
  return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
32
  }
@@ -50,7 +50,7 @@ if (!function_exists ("ws_plugin__s2member_is_systematic_use_page"))
50
  {
51
  return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
52
  }
53
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_override = ws_plugin__s2member_fill_login_redirect_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"])) && ($login_redirect_path = parse_url ($login_redirection_override, PHP_URL_PATH)) !== "nill" && ($login_redirect_query = parse_url ($login_redirection_override, PHP_URL_QUERY)) !== "nill" && ($login_redirect_uri = (($login_redirect_query) ? $login_redirect_path . "?" . $login_redirect_query : $login_redirect_path)) && preg_match ("/^" . preg_quote ($login_redirect_uri, "/") . "$/", $_SERVER["REQUEST_URI"]))
54
  {
55
  return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
56
  }
@@ -68,4 +68,51 @@ if (!function_exists ("ws_plugin__s2member_is_systematic_use_page"))
68
  }
69
  }
70
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  ?>
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit("Do not access this file directly.");
16
  /*
17
+ Function that determines whether we are on a Systematic Use Page.
18
  */
19
  if (!function_exists ("ws_plugin__s2member_is_systematic_use_page"))
20
  {
26
  {
27
  return $is_systematic; /* Filters will have already been applied. */
28
  }
29
+ else if (is_admin ()) /* In the admin area? - All administrational pages are considered Systematic. */
30
  {
31
  return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
32
  }
50
  {
51
  return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
52
  }
53
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = ws_plugin__s2member_login_redirection_uri ()) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]))
54
  {
55
  return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
56
  }
68
  }
69
  }
70
  }
71
+ /*
72
+ Function that determines whether a specific Page, is a Systematic Use Page.
73
+ */
74
+ if (!function_exists ("ws_plugin__s2member_is_systematic_use_specific_page"))
75
+ {
76
+ function ws_plugin__s2member_is_systematic_use_specific_page ($page_id = FALSE, $uri = FALSE)
77
+ {
78
+ static $is_systematic; /* For optimization. */
79
+ /**/
80
+ if (isset ($is_systematic)) /* Already cached? This saves time. */
81
+ {
82
+ return $is_systematic; /* Filters will have already been applied. */
83
+ }
84
+ else if ($uri && preg_match ("/\/wp-admin\//", $uri)) /* In the admin area? - All admin pages are considered Systematic. */
85
+ {
86
+ return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
87
+ }
88
+ else if ($uri && preg_match ("/\/wp-(signup|register|activate|login)\.php/", $uri))
89
+ {
90
+ return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
91
+ }
92
+ else if ($page_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
93
+ {
94
+ return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
95
+ }
96
+ else if ($page_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])
97
+ {
98
+ return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
99
+ }
100
+ else if ($uri && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = ws_plugin__s2member_login_redirection_uri ()) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $uri))
101
+ {
102
+ return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
103
+ }
104
+ else if ($page_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"])
105
+ {
106
+ return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
107
+ }
108
+ else if ($uri && preg_match ("/^s2member/", parse_url ($uri, PHP_URL_QUERY)) && (parse_url ($uri, PHP_URL_PATH) === "/" || parse_url (rtrim ($uri, "/"), PHP_URL_PATH) === parse_url (rtrim (get_bloginfo ("wpurl"), "/"), PHP_URL_PATH)))
109
+ {
110
+ return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_specific_page", true, get_defined_vars ()));
111
+ }
112
+ else /* Otherwise, we return false. */
113
+ {
114
+ return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_specific_page", false, get_defined_vars ()));
115
+ }
116
+ }
117
+ }
118
  ?>
includes/functions/list-servers.inc.php CHANGED
@@ -12,7 +12,7 @@ If not, see: <http://www.gnu.org/licenses/>.
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /*
17
  Function that process list server integrations for s2Member.
18
  */
@@ -20,7 +20,7 @@ if (!function_exists ("ws_plugin__s2member_process_list_servers"))
20
  {
21
  function ws_plugin__s2member_process_list_servers ($level = FALSE, $email = FALSE, $fname = FALSE, $lname = FALSE, $ip = FALSE, $opt_in = FALSE)
22
  {
23
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
24
  do_action ("ws_plugin__s2member_before_process_list_servers", get_defined_vars ());
25
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
26
  /**/
@@ -46,12 +46,12 @@ if (!function_exists ("ws_plugin__s2member_process_list_servers"))
46
  "From: \"" . preg_replace ("/\"/", "", $fname . " " . $lname) . "\" <" . $email . ">\r\nContent-Type: text/plain; charset=utf-8");
47
  }
48
  /**/
49
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
50
  do_action ("ws_plugin__s2member_during_process_list_servers", get_defined_vars ());
51
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
52
  }
53
  /**/
54
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
55
  do_action ("ws_plugin__s2member_after_process_list_servers", get_defined_vars ());
56
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
57
  /**/
@@ -69,8 +69,7 @@ if (!function_exists ("ws_plugin__s2member_list_servers_integrated"))
69
  do_action ("ws_plugin__s2member_before_list_servers_integrated", get_defined_vars ());
70
  /**/
71
  for ($i = 0; $i <= 4; $i++)
72
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_mailchimp_list_ids"]/**/
73
- || $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_aweber_list_ids"])
74
  return apply_filters ("ws_plugin__s2member_list_servers_integrated", true, get_defined_vars ());
75
  /**/
76
  return apply_filters ("ws_plugin__s2member_list_servers_integrated", false, get_defined_vars ());
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit("Do not access this file directly.");
16
  /*
17
  Function that process list server integrations for s2Member.
18
  */
20
  {
21
  function ws_plugin__s2member_process_list_servers ($level = FALSE, $email = FALSE, $fname = FALSE, $lname = FALSE, $ip = FALSE, $opt_in = FALSE)
22
  {
23
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
24
  do_action ("ws_plugin__s2member_before_process_list_servers", get_defined_vars ());
25
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
26
  /**/
46
  "From: \"" . preg_replace ("/\"/", "", $fname . " " . $lname) . "\" <" . $email . ">\r\nContent-Type: text/plain; charset=utf-8");
47
  }
48
  /**/
49
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
50
  do_action ("ws_plugin__s2member_during_process_list_servers", get_defined_vars ());
51
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
52
  }
53
  /**/
54
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
55
  do_action ("ws_plugin__s2member_after_process_list_servers", get_defined_vars ());
56
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
57
  /**/
69
  do_action ("ws_plugin__s2member_before_list_servers_integrated", get_defined_vars ());
70
  /**/
71
  for ($i = 0; $i <= 4; $i++)
72
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_mailchimp_list_ids"] || $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_aweber_list_ids"])
 
73
  return apply_filters ("ws_plugin__s2member_list_servers_integrated", true, get_defined_vars ());
74
  /**/
75
  return apply_filters ("ws_plugin__s2member_list_servers_integrated", false, get_defined_vars ());
includes/functions/login-redirection.inc.php CHANGED
@@ -12,7 +12,7 @@ If not, see: <http://www.gnu.org/licenses/>.
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /*
17
  Function for handling login redirections.
18
  Attach to: add_action("wp_login");
@@ -21,7 +21,7 @@ if (!function_exists ("ws_plugin__s2member_login_redirect"))
21
  {
22
  function ws_plugin__s2member_login_redirect ($username = FALSE)
23
  {
24
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
25
  do_action ("ws_plugin__s2member_before_login_redirect", get_defined_vars ());
26
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
27
  /**/
@@ -31,31 +31,28 @@ if (!function_exists ("ws_plugin__s2member_login_redirect"))
31
  /**/
32
  if (!is_object ($user = new WP_User ($username)) || !($user_id = $user->ID) || !$user->has_cap ("edit_posts"))
33
  {
34
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
35
  do_action ("ws_plugin__s2member_during_login_redirect", get_defined_vars ());
36
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
37
  /**/
38
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
39
- if (function_exists ("ws_plugin__s2member_generate_password"))
40
- {
41
- delete_user_setting ("default_password_nag"); /* setcookie() */
42
- update_user_option ($user_id, "default_password_nag", false, true);
43
- }
44
  /**/
45
- if (ws_plugin__s2member_ip_restrictions_ok ($_SERVER["REMOTE_ADDR"], strtolower ($username)))
46
  {
47
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"])
48
- wp_redirect (ws_plugin__s2member_fill_login_redirect_rc_vars /* Special. */
49
- ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"], $user));
50
  /**/
51
- else /* Otherwise, use the Login Welcome Page for s2Member. */
52
- wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
53
  }
54
  /**/
55
  exit ();
56
  }
57
  /**/
58
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
59
  do_action ("ws_plugin__s2member_after_login_redirect", get_defined_vars ());
60
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
61
  /**/
@@ -63,26 +60,63 @@ if (!function_exists ("ws_plugin__s2member_login_redirect"))
63
  }
64
  }
65
  /*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  Function that fills replacement code variables in special redirection URLs.
67
  */
68
  if (!function_exists ("ws_plugin__s2member_fill_login_redirect_rc_vars"))
69
  {
70
- function ws_plugin__s2member_fill_login_redirect_rc_vars ($url = FALSE, $current_user = FALSE)
71
  {
72
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
73
  do_action ("ws_plugin__s2member_before_fill_login_redirect_rc_vars", get_defined_vars ());
74
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
75
  /**/
76
- $current_user = (is_object ($current_user)) ? $current_user : wp_get_current_user ();
77
- $current_user_login = (is_object ($current_user)) ? strtolower ($current_user->user_login) : "";
78
- $current_user_ID = (is_object ($current_user)) ? (string)$current_user->ID : "";
79
- $current_user_level = (string)ws_plugin__s2member_user_access_level ($current_user);
80
  /**/
81
- $url = preg_replace ("/%%current_user_login%%/i", ws_plugin__s2member_esc_ds ($current_user_login), $url);
82
- $url = preg_replace ("/%%current_user_ID%%/i", ws_plugin__s2member_esc_ds ($current_user_ID), $url);
83
- $url = preg_replace ("/%%current_user_level%%/i", ws_plugin__s2member_esc_ds ($current_user_level), $url);
84
  /**/
85
  return apply_filters ("ws_plugin__s2member_fill_login_redirect_rc_vars", $url, get_defined_vars ());
86
  }
87
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  ?>
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit("Do not access this file directly.");
16
  /*
17
  Function for handling login redirections.
18
  Attach to: add_action("wp_login");
21
  {
22
  function ws_plugin__s2member_login_redirect ($username = FALSE)
23
  {
24
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
25
  do_action ("ws_plugin__s2member_before_login_redirect", get_defined_vars ());
26
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
27
  /**/
31
  /**/
32
  if (!is_object ($user = new WP_User ($username)) || !($user_id = $user->ID) || !$user->has_cap ("edit_posts"))
33
  {
34
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
35
  do_action ("ws_plugin__s2member_during_login_redirect", get_defined_vars ());
36
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
37
  /**/
38
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"] && function_exists ("ws_plugin__s2member_generate_password"))
39
+ {
40
+ delete_user_setting("default_password_nag"); /* setcookie() */
41
+ update_user_option ($user_id, "default_password_nag", false, true);
42
+ }
 
43
  /**/
44
+ if (strtolower ($username) === "demo" || ws_plugin__s2member_ip_restrictions_ok ($_SERVER["REMOTE_ADDR"], strtolower ($username)))
45
  {
46
+ if ($special_redirection_url = ws_plugin__s2member_login_redirection_url ($user))
47
+ wp_redirect($special_redirection_url);
 
48
  /**/
49
+ else wp_redirect(get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
 
50
  }
51
  /**/
52
  exit ();
53
  }
54
  /**/
55
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
56
  do_action ("ws_plugin__s2member_after_login_redirect", get_defined_vars ());
57
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
58
  /**/
60
  }
61
  }
62
  /*
63
+ This function formulates a possible ( Special ) Login Redirection URL.
64
+ */
65
+ if (!function_exists ("ws_plugin__s2member_login_redirection_url"))
66
+ {
67
+ function ws_plugin__s2member_login_redirection_url ($user = FALSE)
68
+ {
69
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
70
+ do_action ("ws_plugin__s2member_before_login_redirection_url", get_defined_vars ());
71
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
72
+ /**/
73
+ $url = ws_plugin__s2member_fill_login_redirect_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"], $user);
74
+ /**/
75
+ return apply_filters ("ws_plugin__s2member_login_redirection_url", $url, get_defined_vars ());
76
+ }
77
+ }
78
+ /*
79
  Function that fills replacement code variables in special redirection URLs.
80
  */
81
  if (!function_exists ("ws_plugin__s2member_fill_login_redirect_rc_vars"))
82
  {
83
+ function ws_plugin__s2member_fill_login_redirect_rc_vars ($url = FALSE, $user = FALSE)
84
  {
85
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
86
  do_action ("ws_plugin__s2member_before_fill_login_redirect_rc_vars", get_defined_vars ());
87
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
88
  /**/
89
+ $user = (is_object ($user)) ? $user : wp_get_current_user ();
90
+ $user_login = (is_object ($user)) ? strtolower ($user->user_login) : "";
91
+ $user_id = (is_object ($user)) ? (string)$user->ID : "";
92
+ $user_level = (string)ws_plugin__s2member_user_access_level ($user);
93
  /**/
94
+ $url = preg_replace ("/%%current_user_login%%/i", ws_plugin__s2member_esc_ds ($user_login), $url);
95
+ $url = preg_replace ("/%%current_user_id%%/i", ws_plugin__s2member_esc_ds ($user_id), $url);
96
+ $url = preg_replace ("/%%current_user_level%%/i", ws_plugin__s2member_esc_ds ($user_level), $url);
97
  /**/
98
  return apply_filters ("ws_plugin__s2member_fill_login_redirect_rc_vars", $url, get_defined_vars ());
99
  }
100
  }
101
+ /*
102
+ Parses the URI out of a possible ( Special ) Login Redirection URL.
103
+ */
104
+ if (!function_exists ("ws_plugin__s2member_login_redirection_uri"))
105
+ {
106
+ function ws_plugin__s2member_login_redirection_uri ($user = FALSE)
107
+ {
108
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
109
+ do_action ("ws_plugin__s2member_before_login_redirection_uri", get_defined_vars ());
110
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
111
+ /**/
112
+ if ($url = ws_plugin__s2member_login_redirection_url ($user))
113
+ {
114
+ $path = parse_url ($url, PHP_URL_PATH);
115
+ $query = parse_url ($url, PHP_URL_QUERY);
116
+ $uri = ($query) ? $path . "?" . $query : $path;
117
+ }
118
+ /**/
119
+ return apply_filters ("ws_plugin__s2member_login_redirection_uri", $uri, get_defined_vars ());
120
+ }
121
+ }
122
  ?>
includes/functions/membership-options.inc.php CHANGED
@@ -12,12 +12,16 @@ If not, see: <http://www.gnu.org/licenses/>.
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /*
17
  This forces a redirection to the Membership Options Page for s2Member.
18
  This can be used by 3rd party applications that are not aware of which
19
  Page is currently set as the Membership Options Page.
 
 
 
20
  Attach to: add_action("template_redirect");
 
21
  */
22
  if (!function_exists ("ws_plugin__s2member_membership_options_page"))
23
  {
@@ -28,7 +32,7 @@ if (!function_exists ("ws_plugin__s2member_membership_options_page"))
28
  if ($_GET["s2member_membership_options_page"] && !is_page ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))
29
  {
30
  $_GET["s2member_level_req"] = (strlen ($_GET["s2member_level_req"])) ? $_GET["s2member_level_req"] : "0";
31
- wp_redirect (add_query_arg ("s2member_level_req", $_GET["s2member_level_req"], get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
32
  exit ();
33
  }
34
  /**/
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit("Do not access this file directly.");
16
  /*
17
  This forces a redirection to the Membership Options Page for s2Member.
18
  This can be used by 3rd party applications that are not aware of which
19
  Page is currently set as the Membership Options Page.
20
+
21
+ This is used by s2Member's bbPress Bridge integration.
22
+
23
  Attach to: add_action("template_redirect");
24
+ Example usage: http://example.com/?s2member_membership_options_page=1
25
  */
26
  if (!function_exists ("ws_plugin__s2member_membership_options_page"))
27
  {
32
  if ($_GET["s2member_membership_options_page"] && !is_page ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))
33
  {
34
  $_GET["s2member_level_req"] = (strlen ($_GET["s2member_level_req"])) ? $_GET["s2member_level_req"] : "0";
35
+ wp_redirect(add_query_arg ("s2member_level_req", $_GET["s2member_level_req"], get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
36
  exit ();
37
  }
38
  /**/
includes/functions/meta-boxes.inc.php CHANGED
@@ -12,7 +12,7 @@ If not, see: <http://www.gnu.org/licenses/>.
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit("Do not access this file directly.");
16
  /*
17
  Function adds meta boxes to Post/Page editing stations.
18
  Attach to: add_action("admin_menu");
@@ -40,45 +40,59 @@ if (!function_exists ("ws_plugin__s2member_security_meta_box"))
40
  {
41
  function ws_plugin__s2member_security_meta_box ($post = FALSE)
42
  {
43
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
44
  do_action ("ws_plugin__s2member_before_security_meta_box", get_defined_vars ());
45
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
46
  /**/
47
- if (is_object ($post) && ($post_id = $post->ID) && (($post->post_type === "page" && current_user_can ("edit_page", $post_id)) || current_user_can ("edit_post", $post_id)))
48
  {
49
- echo '<input type="hidden" name="ws_plugin__s2member_security_meta_box_save" id="ws-plugin--s2member-security-meta-box-save" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-security-meta-box-save")) . '" />' . "\n";
50
- echo '<input type="hidden" name="ws_plugin__s2member_security_meta_box_save_id" id="ws-plugin--s2member-security-meta-box-save-id" value="' . esc_attr ($post_id) . '" />' . "\n";
51
- /**/
52
  if ($post->post_type === "page" && ($page_id = $post_id)) /* OK. So we're dealing with a Page classification. */
53
  {
54
- $pages["0"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_pages"]);
55
- $pages["1"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_pages"]);
56
- $pages["2"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_pages"]);
57
- $pages["3"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_pages"]);
58
- $pages["4"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_pages"]);
59
- /**/
60
- echo '<p style="margin-left:2px;"><strong>Page Level Restriction?</strong></p>' . "\n";
61
- echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-level">Add Level Restriction?</label>' . "\n";
62
- echo '<select name="ws_plugin__s2member_security_meta_box_level" id="ws-plugin--s2member-security-meta-box-level" style="width:99%;">' . "\n";
63
- echo '<option value=""></option>' . "\n"; /* By default, we allow public access to any Post/Page. */
64
- echo ($pages["0"] !== array ("all")) ? '<option value="0"' . ((in_array ($page_id, $pages["0"])) ? ' selected="selected"' : '') . '>Require Level# 0 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #0 ( already protects "all" Pages )</option>';
65
- echo ($pages["1"] !== array ("all")) ? '<option value="1"' . ((in_array ($page_id, $pages["1"])) ? ' selected="selected"' : '') . '>Require Level# 1 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #1 ( already protects "all" Pages )</option>';
66
- echo ($pages["2"] !== array ("all")) ? '<option value="2"' . ((in_array ($page_id, $pages["2"])) ? ' selected="selected"' : '') . '>Require Level# 2 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #2 ( already protects "all" Pages )</option>';
67
- echo ($pages["3"] !== array ("all")) ? '<option value="3"' . ((in_array ($page_id, $pages["3"])) ? ' selected="selected"' : '') . '>Require Level# 3 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #3 ( already protects "all" Pages )</option>';
68
- echo ($pages["4"] !== array ("all")) ? '<option value="4"' . ((in_array ($page_id, $pages["4"])) ? ' selected="selected"' : '') . '>Require Level# 4 ( highest level )</option>' . "\n" : '<option value="" disabled="disabled">Level #4 ( already protects "all" Pages )</option>';
69
- echo '</select><br /><small>* see: <code>General Options -> Page Level Access</code></small>' . "\n";
70
- /**/
71
- if (!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ())
72
- /* ^ Will change once Custom Capabilities are compatible with a Blog Farm. */
73
  {
74
- echo '<p style="margin-top:15px; margin-left:2px;"><strong>Require Custom Capabilities?</strong></p>' . "\n";
75
- echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-ccaps">Custom Capabilities?</label>' . "\n";
76
- echo '<input type="text" name="ws_plugin__s2member_security_meta_box_ccaps" id="ws-plugin--s2member-security-meta-box-ccaps" value="' . format_to_edit (implode (",", (array)get_post_meta ($page_id, "s2member_ccaps_req", true))) . '" onkeyup="if(this.value.match(/[^a-z_0-9,]/)) this.value = jQuery.trim (jQuery.trim (this.value).replace (/[ \-]/g, \'_\').replace (/[^A-Z_0-9,]/gi, \'\').toLowerCase ());" style="width:99%;" />' . "\n";
77
- echo '<br /><small>* see: <code>API Scripting -> Custom Capabilities</code></small>' . "\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  }
 
 
 
 
 
 
 
 
79
  }
80
  else /* Otherwise, we assume this is a Post, or possibly a Custom Post Type. It's NOT a Page. */
81
  {
 
 
 
82
  $posts["0"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_posts"]);
83
  $posts["1"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_posts"]);
84
  $posts["2"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_posts"]);
@@ -89,11 +103,11 @@ if (!function_exists ("ws_plugin__s2member_security_meta_box"))
89
  echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-level">Add Level Restriction?</label>' . "\n";
90
  echo '<select name="ws_plugin__s2member_security_meta_box_level" id="ws-plugin--s2member-security-meta-box-level" style="width:99%;">' . "\n";
91
  echo '<option value=""></option>' . "\n"; /* By default, we allow public access to any Post/Page. */
92
- echo ($posts["0"] !== array ("all")) ? '<option value="0"' . ((in_array ($post_id, $posts["0"])) ? ' selected="selected"' : '') . '>Require Level# 0 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #0 ( already protects "all" Posts )</option>';
93
- echo ($posts["1"] !== array ("all")) ? '<option value="1"' . ((in_array ($post_id, $posts["1"])) ? ' selected="selected"' : '') . '>Require Level# 1 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #1 ( already protects "all" Posts )</option>';
94
- echo ($posts["2"] !== array ("all")) ? '<option value="2"' . ((in_array ($post_id, $posts["2"])) ? ' selected="selected"' : '') . '>Require Level# 2 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #2 ( already protects "all" Posts )</option>';
95
- echo ($posts["3"] !== array ("all")) ? '<option value="3"' . ((in_array ($post_id, $posts["3"])) ? ' selected="selected"' : '') . '>Require Level# 3 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #3 ( already protects "all" Posts )</option>';
96
- echo ($posts["4"] !== array ("all")) ? '<option value="4"' . ((in_array ($post_id, $posts["4"])) ? ' selected="selected"' : '') . '>Require Level# 4 ( highest level )</option>' . "\n" : '<option value="" disabled="disabled">Level #4 ( already protects "all" Posts )</option>';
97
  echo '</select><br /><small>* see: <code>General Options -> Post Level Access</code></small>' . "\n";
98
  /**/
99
  if (!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ())
@@ -121,7 +135,7 @@ if (!function_exists ("ws_plugin__s2member_save_meta_boxes"))
121
  {
122
  function ws_plugin__s2member_save_meta_boxes ($post_id = FALSE)
123
  {
124
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
125
  do_action ("ws_plugin__s2member_before_save_meta_boxes", get_defined_vars ());
126
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
127
  /**/
@@ -144,15 +158,15 @@ if (!function_exists ("ws_plugin__s2member_save_meta_boxes"))
144
  $pages["4"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_pages"]));
145
  /**/
146
  if (($i = array_search ($page_id, $pages["0"])) !== false) /* Remove $page_id from existing options. */
147
- unset($pages["0"][$i]);
148
  else if (($i = array_search ($page_id, $pages["1"])) !== false)
149
- unset($pages["1"][$i]);
150
  else if (($i = array_search ($page_id, $pages["2"])) !== false)
151
- unset($pages["2"][$i]);
152
  else if (($i = array_search ($page_id, $pages["3"])) !== false)
153
- unset($pages["3"][$i]);
154
  else if (($i = array_search ($page_id, $pages["4"])) !== false)
155
- unset($pages["4"][$i]);
156
  /**/
157
  if (strlen ($_p["ws_plugin__s2member_security_meta_box_level"]) && is_array ($pages[$_p["ws_plugin__s2member_security_meta_box_level"]]))
158
  if (!$pages[$_p["ws_plugin__s2member_security_meta_box_level"]] !== array ("all"))
@@ -160,7 +174,7 @@ if (!function_exists ("ws_plugin__s2member_save_meta_boxes"))
160
  /**/
161
  $new_options = array_merge ((array)$new_options, array ("ws_plugin__s2member_level0_pages" => implode (",", $pages[0]), "ws_plugin__s2member_level1_pages" => implode (",", $pages[1]), "ws_plugin__s2member_level2_pages" => implode (",", $pages[2]), "ws_plugin__s2member_level3_pages" => implode (",", $pages[3]), "ws_plugin__s2member_level4_pages" => implode (",", $pages[4])));
162
  /**/
163
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
164
  do_action ("ws_plugin__s2member_during_save_meta_boxes", get_defined_vars ());
165
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
166
  /**/
@@ -179,15 +193,15 @@ if (!function_exists ("ws_plugin__s2member_save_meta_boxes"))
179
  $posts["4"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_posts"]));
180
  /**/
181
  if (($i = array_search ($post_id, $posts["0"])) !== false) /* Remove $post_id from existing options. */
182
- unset($posts["0"][$i]);
183
  else if (($i = array_search ($post_id, $posts["1"])) !== false)
184
- unset($posts["1"][$i]);
185
  else if (($i = array_search ($post_id, $posts["2"])) !== false)
186
- unset($posts["2"][$i]);
187
  else if (($i = array_search ($post_id, $posts["3"])) !== false)
188
- unset($posts["3"][$i]);
189
  else if (($i = array_search ($post_id, $posts["4"])) !== false)
190
- unset($posts["4"][$i]);
191
  /**/
192
  if (strlen ($_p["ws_plugin__s2member_security_meta_box_level"]) && is_array ($posts[$_p["ws_plugin__s2member_security_meta_box_level"]]))
193
  if (!$posts[$_p["ws_plugin__s2member_security_meta_box_level"]] !== array ("all"))
@@ -195,7 +209,7 @@ if (!function_exists ("ws_plugin__s2member_save_meta_boxes"))
195
  /**/
196
  $new_options = array_merge ((array)$new_options, array ("ws_plugin__s2member_level0_posts" => implode (",", $posts[0]), "ws_plugin__s2member_level1_posts" => implode (",", $posts[1]), "ws_plugin__s2member_level2_posts" => implode (",", $posts[2]), "ws_plugin__s2member_level3_posts" => implode (",", $posts[3]), "ws_plugin__s2member_level4_posts" => implode (",", $posts[4])));
197
  /**/
198
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
199
  do_action ("ws_plugin__s2member_during_save_meta_boxes", get_defined_vars ());
200
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
201
  /**/
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit ("Do not access this file directly.");
16
  /*
17
  Function adds meta boxes to Post/Page editing stations.
18
  Attach to: add_action("admin_menu");
40
  {
41
  function ws_plugin__s2member_security_meta_box ($post = FALSE)
42
  {
43
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
44
  do_action ("ws_plugin__s2member_before_security_meta_box", get_defined_vars ());
45
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
46
  /**/
47
+ if (is_object ($post) && ($post_id = $post->ID) && ( ($post->post_type === "page" && current_user_can ("edit_page", $post_id)) || current_user_can ("edit_post", $post_id)))
48
  {
 
 
 
49
  if ($post->post_type === "page" && ($page_id = $post_id)) /* OK. So we're dealing with a Page classification. */
50
  {
51
+ if (!in_array ($page_id, array ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"], $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"], $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"])))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  {
53
+ echo '<input type="hidden" name="ws_plugin__s2member_security_meta_box_save" id="ws-plugin--s2member-security-meta-box-save" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-security-meta-box-save")) . '" />' . "\n";
54
+ echo '<input type="hidden" name="ws_plugin__s2member_security_meta_box_save_id" id="ws-plugin--s2member-security-meta-box-save-id" value="' . esc_attr ($page_id) . '" />' . "\n";
55
+ /**/
56
+ $pages["0"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_pages"]);
57
+ $pages["1"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_pages"]);
58
+ $pages["2"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_pages"]);
59
+ $pages["3"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_pages"]);
60
+ $pages["4"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_pages"]);
61
+ /**/
62
+ echo '<p style="margin-left:2px;"><strong>Page Level Restriction?</strong></p>' . "\n";
63
+ echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-level">Add Level Restriction?</label>' . "\n";
64
+ echo '<select name="ws_plugin__s2member_security_meta_box_level" id="ws-plugin--s2member-security-meta-box-level" style="width:99%;">' . "\n";
65
+ echo '<option value=""></option>' . "\n"; /* By default, we allow public access to any Post/Page. */
66
+ echo ($pages["0"] !== array ("all")) ? '<option value="0"' . ( (in_array ($page_id, $pages["0"])) ? ' selected="selected"' : '') . '>Require Level# 0 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #0 ( already protects "all" Pages )</option>';
67
+ echo ($pages["1"] !== array ("all")) ? '<option value="1"' . ( (in_array ($page_id, $pages["1"])) ? ' selected="selected"' : '') . '>Require Level# 1 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #1 ( already protects "all" Pages )</option>';
68
+ echo ($pages["2"] !== array ("all")) ? '<option value="2"' . ( (in_array ($page_id, $pages["2"])) ? ' selected="selected"' : '') . '>Require Level# 2 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #2 ( already protects "all" Pages )</option>';
69
+ echo ($pages["3"] !== array ("all")) ? '<option value="3"' . ( (in_array ($page_id, $pages["3"])) ? ' selected="selected"' : '') . '>Require Level# 3 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #3 ( already protects "all" Pages )</option>';
70
+ echo ($pages["4"] !== array ("all")) ? '<option value="4"' . ( (in_array ($page_id, $pages["4"])) ? ' selected="selected"' : '') . '>Require Level# 4 ( highest level )</option>' . "\n" : '<option value="" disabled="disabled">Level #4 ( already protects "all" Pages )</option>';
71
+ echo '</select><br /><small>* see: <code>General Options -> Page Level Access</code></small>' . "\n";
72
+ /**/
73
+ if (!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ())
74
+ /* ^ Will change once Custom Capabilities are compatible with a Blog Farm. */
75
+ {
76
+ echo '<p style="margin-top:15px; margin-left:2px;"><strong>Require Custom Capabilities?</strong></p>' . "\n";
77
+ echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-ccaps">Custom Capabilities?</label>' . "\n";
78
+ echo '<input type="text" name="ws_plugin__s2member_security_meta_box_ccaps" id="ws-plugin--s2member-security-meta-box-ccaps" value="' . format_to_edit (implode (",", (array)get_post_meta ($page_id, "s2member_ccaps_req", true))) . '" onkeyup="if(this.value.match(/[^a-z_0-9,]/)) this.value = jQuery.trim (jQuery.trim (this.value).replace (/[ \-]/g, \'_\').replace (/[^A-Z_0-9,]/gi, \'\').toLowerCase ());" style="width:99%;" />' . "\n";
79
+ echo '<br /><small>* see: <code>API Scripting -> Custom Capabilities</code></small>' . "\n";
80
+ }
81
  }
82
+ else if ($page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
83
+ echo 'This Page is your:<br /><strong>Membership Options Page</strong><br />( always publicly available )';
84
+ /**/
85
+ else if ($page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])
86
+ echo 'This Page is your:<br /><strong>Login Welcome Page</strong><br />( automatically guarded by s2Member )';
87
+ /**/
88
+ else if ($page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"])
89
+ echo 'This Page is your:<br /><strong>Download Limit Exceeded Page</strong><br />( automatically guarded by s2Member )';
90
  }
91
  else /* Otherwise, we assume this is a Post, or possibly a Custom Post Type. It's NOT a Page. */
92
  {
93
+ echo '<input type="hidden" name="ws_plugin__s2member_security_meta_box_save" id="ws-plugin--s2member-security-meta-box-save" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-security-meta-box-save")) . '" />' . "\n";
94
+ echo '<input type="hidden" name="ws_plugin__s2member_security_meta_box_save_id" id="ws-plugin--s2member-security-meta-box-save-id" value="' . esc_attr ($post_id) . '" />' . "\n";
95
+ /**/
96
  $posts["0"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_posts"]);
97
  $posts["1"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_posts"]);
98
  $posts["2"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_posts"]);
103
  echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-level">Add Level Restriction?</label>' . "\n";
104
  echo '<select name="ws_plugin__s2member_security_meta_box_level" id="ws-plugin--s2member-security-meta-box-level" style="width:99%;">' . "\n";
105
  echo '<option value=""></option>' . "\n"; /* By default, we allow public access to any Post/Page. */
106
+ echo ($posts["0"] !== array ("all")) ? '<option value="0"' . ( (in_array ($post_id, $posts["0"])) ? ' selected="selected"' : '') . '>Require Level# 0 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #0 ( already protects "all" Posts )</option>';
107
+ echo ($posts["1"] !== array ("all")) ? '<option value="1"' . ( (in_array ($post_id, $posts["1"])) ? ' selected="selected"' : '') . '>Require Level# 1 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #1 ( already protects "all" Posts )</option>';
108
+ echo ($posts["2"] !== array ("all")) ? '<option value="2"' . ( (in_array ($post_id, $posts["2"])) ? ' selected="selected"' : '') . '>Require Level# 2 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #2 ( already protects "all" Posts )</option>';
109
+ echo ($posts["3"] !== array ("all")) ? '<option value="3"' . ( (in_array ($post_id, $posts["3"])) ? ' selected="selected"' : '') . '>Require Level# 3 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #3 ( already protects "all" Posts )</option>';
110
+ echo ($posts["4"] !== array ("all")) ? '<option value="4"' . ( (in_array ($post_id, $posts["4"])) ? ' selected="selected"' : '') . '>Require Level# 4 ( highest level )</option>' . "\n" : '<option value="" disabled="disabled">Level #4 ( already protects "all" Posts )</option>';
111
  echo '</select><br /><small>* see: <code>General Options -> Post Level Access</code></small>' . "\n";
112
  /**/
113
  if (!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ())
135
  {
136
  function ws_plugin__s2member_save_meta_boxes ($post_id = FALSE)
137
  {
138
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
139
  do_action ("ws_plugin__s2member_before_save_meta_boxes", get_defined_vars ());
140
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
141
  /**/
158
  $pages["4"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_pages"]));
159
  /**/
160
  if (($i = array_search ($page_id, $pages["0"])) !== false) /* Remove $page_id from existing options. */
161
+ unset ($pages["0"][$i]);
162
  else if (($i = array_search ($page_id, $pages["1"])) !== false)
163
+ unset ($pages["1"][$i]);
164
  else if (($i = array_search ($page_id, $pages["2"])) !== false)
165
+ unset ($pages["2"][$i]);
166
  else if (($i = array_search ($page_id, $pages["3"])) !== false)
167
+ unset ($pages["3"][$i]);
168
  else if (($i = array_search ($page_id, $pages["4"])) !== false)
169
+ unset ($pages["4"][$i]);
170
  /**/
171
  if (strlen ($_p["ws_plugin__s2member_security_meta_box_level"]) && is_array ($pages[$_p["ws_plugin__s2member_security_meta_box_level"]]))
172
  if (!$pages[$_p["ws_plugin__s2member_security_meta_box_level"]] !== array ("all"))
174
  /**/
175
  $new_options = array_merge ((array)$new_options, array ("ws_plugin__s2member_level0_pages" => implode (",", $pages[0]), "ws_plugin__s2member_level1_pages" => implode (",", $pages[1]), "ws_plugin__s2member_level2_pages" => implode (",", $pages[2]), "ws_plugin__s2member_level3_pages" => implode (",", $pages[3]), "ws_plugin__s2member_level4_pages" => implode (",", $pages[4])));
176
  /**/
177
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
178
  do_action ("ws_plugin__s2member_during_save_meta_boxes", get_defined_vars ());
179
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
180
  /**/
193
  $posts["4"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_posts"]));
194
  /**/
195
  if (($i = array_search ($post_id, $posts["0"])) !== false) /* Remove $post_id from existing options. */
196
+ unset ($posts["0"][$i]);
197
  else if (($i = array_search ($post_id, $posts["1"])) !== false)
198
+ unset ($posts["1"][$i]);
199
  else if (($i = array_search ($post_id, $posts["2"])) !== false)
200
+ unset ($posts["2"][$i]);
201
  else if (($i = array_search ($post_id, $posts["3"])) !== false)
202
+ unset ($posts["3"][$i]);
203
  else if (($i = array_search ($post_id, $posts["4"])) !== false)
204
+ unset ($posts["4"][$i]);
205
  /**/
206
  if (strlen ($_p["ws_plugin__s2member_security_meta_box_level"]) && is_array ($posts[$_p["ws_plugin__s2member_security_meta_box_level"]]))
207
  if (!$posts[$_p["ws_plugin__s2member_security_meta_box_level"]] !== array ("all"))
209
  /**/
210
  $new_options = array_merge ((array)$new_options, array ("ws_plugin__s2member_level0_posts" => implode (",", $posts[0]), "ws_plugin__s2member_level1_posts" => implode (",", $posts[1]), "ws_plugin__s2member_level2_posts" => implode (",", $posts[2]), "ws_plugin__s2member_level3_posts" => implode (",", $posts[3]), "ws_plugin__s2member_level4_posts" => implode (",", $posts[4])));
211
  /**/
212
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
213
  do_action ("ws_plugin__s2member_during_save_meta_boxes", get_defined_vars ());
214
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
215
  /**/
includes/functions/ms-meta-caps.inc.php CHANGED
@@ -33,6 +33,7 @@ if (!function_exists ("ws_plugin__s2member_ms_map_meta_cap"))
33
  $caps = array ($map[$cap]);
34
  }
35
  }
 
36
  return apply_filters ("ws_plugin__s2member_ms_map_meta_cap", $caps, get_defined_vars ());
37
  }
38
  }
@@ -54,6 +55,7 @@ if (!function_exists ("ws_plugin__s2member_ms_allow_edits"))
54
  {
55
  $allow = true; /* Yes, allow editing. */
56
  }
 
57
  return apply_filters ("ws_plugin__s2member_ms_allow_edits", $allow, get_defined_vars ());
58
  }
59
  }
33
  $caps = array ($map[$cap]);
34
  }
35
  }
36
+ /**/
37
  return apply_filters ("ws_plugin__s2member_ms_map_meta_cap", $caps, get_defined_vars ());
38
  }
39
  }
55
  {
56
  $allow = true; /* Yes, allow editing. */
57
  }
58
+ /**/
59
  return apply_filters ("ws_plugin__s2member_ms_allow_edits", $allow, get_defined_vars ());
60
  }
61
  }
includes/functions/nocache.inc.php CHANGED
@@ -12,7 +12,7 @@ If not, see: <http://www.gnu.org/licenses/>.
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit("Do not access this file directly.");
16
  /*
17
  Handles no-cache headers and compatible constants for s2Member.
18
  This is compatible with Quick Cache and also with WP Super Cache.
@@ -60,14 +60,18 @@ if (!function_exists ("ws_plugin__s2member_nocache_constants"))
60
  {
61
  function ws_plugin__s2member_nocache_constants ($nocache = FALSE)
62
  {
63
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
 
 
64
  do_action ("ws_plugin__s2member_before_nocache_constants", get_defined_vars ());
65
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
66
  /**/
67
- if (!$_GET["qcAC"] && ($nocache || is_user_logged_in () || (preg_match ("/^s2member/", $_SERVER["QUERY_STRING"]) && (parse_url ($_SERVER["REQUEST_URI"], PHP_URL_PATH) === "/" || parse_url (rtrim ($_SERVER["REQUEST_URI"], "/"), PHP_URL_PATH) === parse_url (rtrim (get_bloginfo ("wpurl"), "/"), PHP_URL_PATH)))))
68
  {
69
  define ("QUICK_CACHE_ALLOWED", false) . define ("DONOTCACHEPAGE", true);
70
  /**/
 
 
71
  do_action ("ws_plugin__s2member_during_nocache_constants", get_defined_vars ());
72
  }
73
  /**/
@@ -86,9 +90,11 @@ if (!function_exists ("ws_plugin__s2member_nocache_headers"))
86
  {
87
  function ws_plugin__s2member_nocache_headers () /* Cache-Control header. */
88
  {
 
 
89
  do_action ("ws_plugin__s2member_before_nocache_headers", get_defined_vars ());
90
  /**/
91
- if (!$_GET["qcABC"]) /* Always obey the Quick Cache plugin. */
92
  {
93
  if (is_array ($headers = headers_list ()))
94
  foreach ($headers as $k => $header)
@@ -98,6 +104,8 @@ if (!function_exists ("ws_plugin__s2member_nocache_headers"))
98
  if (!$no_cache_already_sent)
99
  nocache_headers ();
100
  /**/
 
 
101
  do_action ("ws_plugin__s2member_during_nocache_headers", get_defined_vars ());
102
  }
103
  /**/
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit ("Do not access this file directly.");
16
  /*
17
  Handles no-cache headers and compatible constants for s2Member.
18
  This is compatible with Quick Cache and also with WP Super Cache.
60
  {
61
  function ws_plugin__s2member_nocache_constants ($nocache = FALSE)
62
  {
63
+ static $once; /* We only need to set these Constants once. */
64
+ /**/
65
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
66
  do_action ("ws_plugin__s2member_before_nocache_constants", get_defined_vars ());
67
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
68
  /**/
69
+ if (!$once && !$_GET["qcAC"] && ($nocache || is_user_logged_in () || (preg_match ("/^s2member/", $_SERVER["QUERY_STRING"]) && (parse_url ($_SERVER["REQUEST_URI"], PHP_URL_PATH) === "/" || parse_url (rtrim ($_SERVER["REQUEST_URI"], "/"), PHP_URL_PATH) === parse_url (rtrim (get_bloginfo ("wpurl"), "/"), PHP_URL_PATH)))))
70
  {
71
  define ("QUICK_CACHE_ALLOWED", false) . define ("DONOTCACHEPAGE", true);
72
  /**/
73
+ $once = true; /* Only need to set these Constants one time. */
74
+ /**/
75
  do_action ("ws_plugin__s2member_during_nocache_constants", get_defined_vars ());
76
  }
77
  /**/
90
  {
91
  function ws_plugin__s2member_nocache_headers () /* Cache-Control header. */
92
  {
93
+ static $once; /* We only need to set these headers one time. */
94
+ /**/
95
  do_action ("ws_plugin__s2member_before_nocache_headers", get_defined_vars ());
96
  /**/
97
+ if (!$once && !$_GET["qcABC"]) /* Obey Quick Cache. */
98
  {
99
  if (is_array ($headers = headers_list ()))
100
  foreach ($headers as $k => $header)
104
  if (!$no_cache_already_sent)
105
  nocache_headers ();
106
  /**/
107
+ $once = true; /* Only need to set these headers once. */
108
+ /**/
109
  do_action ("ws_plugin__s2member_during_nocache_headers", get_defined_vars ());
110
  }
111
  /**/
includes/functions/page-level-access.inc.php CHANGED
@@ -12,76 +12,110 @@ If not, see: <http://www.gnu.org/licenses/>.
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit("Do not access this file directly.");
16
  /*
17
  Function for handling Page Level Access permissions.
18
- Attach to: add_action("template_redirect");
 
 
 
 
 
 
 
 
 
 
 
19
  */
20
  if (!function_exists ("ws_plugin__s2member_check_page_level_access"))
21
  {
22
  function ws_plugin__s2member_check_page_level_access ()
23
  {
24
- global $post; /* get_the_ID() not yet available here. */
25
  /**/
26
  do_action ("ws_plugin__s2member_before_check_page_level_access", get_defined_vars ());
27
  /**/
28
  $excluded = apply_filters ("ws_plugin__s2member_check_page_level_access_excluded", false, get_defined_vars ());
29
  /**/
30
- if (!$excluded && is_page () && is_object ($post) && ($page_ID = $post->ID) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
31
  {
32
  $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
33
  /**/
34
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && $page_ID == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && $page_ID != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && wp_redirect (add_query_arg ("s2member_level_req", "0", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
35
- exit ();
36
- /**/
37
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_override = ws_plugin__s2member_fill_login_redirect_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"])) && ($login_redirect_path = parse_url ($login_redirection_override, PHP_URL_PATH)) !== "nill" && ($login_redirect_query = parse_url ($login_redirection_override, PHP_URL_QUERY)) !== "nill" && ($login_redirect_uri = (($login_redirect_query) ? $login_redirect_path . "?" . $login_redirect_query : $login_redirect_path)) && preg_match ("/^" . preg_quote ($login_redirect_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && $page_ID != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && wp_redirect (add_query_arg ("s2member_level_req", "0", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
38
- exit ();
39
- /**/
40
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && $page_ID == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && $page_ID != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && wp_redirect (add_query_arg ("s2member_level_req", "0", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
41
- exit ();
42
- /**/
43
- else if (!ws_plugin__s2member_is_systematic_use_page ()) /* Never restrict systematic use pages. Except for the two pages above ^. They MUST be protected at all times. */
44
  {
45
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_pages"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && wp_redirect (add_query_arg ("s2member_level_req", "0", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
46
- exit ();
47
- /**/
48
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_pages"] && in_array ($page_ID, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_pages"])) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && wp_redirect (add_query_arg ("s2member_level_req", "0", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
49
- exit ();
50
- /**/
51
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_pages"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
52
- exit ();
53
- /**/
54
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_pages"] && in_array ($page_ID, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_pages"])) && ws_plugin__s2member_nocache_constants (true) !== "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")
55
- exit ();
56
- /**/
57
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_pages"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
58
- exit ();
59
- /**/
60
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_pages"] && in_array ($page_ID, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_pages"])) && ws_plugin__s2member_nocache_constants (true) !== "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")
61
- exit ();
62
- /**/
63
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_pages"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
64
- exit ();
65
- /**/
66
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_pages"] && in_array ($page_ID, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_pages"])) && ws_plugin__s2member_nocache_constants (true) !== "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")
67
- exit ();
68
- /**/
69
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_pages"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
70
- exit ();
 
 
 
71
  /**/
72
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_pages"] && in_array ($page_ID, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_pages"])) && ws_plugin__s2member_nocache_constants (true) !== "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")
73
- exit ();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  /**/
75
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array ($page_ID, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && ws_plugin__s2member_nocache_constants (true) !== "nill" && !ws_plugin__s2member_sp_access ($page_ID) && wp_redirect (add_query_arg ("s2member_sp_req", $page_ID, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
76
- exit ();
 
 
 
 
 
 
 
 
77
  /**/
78
- else if (is_array ($ccaps_req = get_post_meta ($page_ID, "s2member_ccaps_req", true))) /* Check for per Post Custom Capability requirements. */
79
- foreach ($ccaps_req as $ccap) /* The $current_user MUST satisfy ALL Custom Capability requirements. These are all stored as a serialized array. */
80
  if (strlen ($ccap) && (!$current_user || !$current_user->has_cap ("access_s2member_ccap_" . $ccap)))
81
  {
82
- wp_redirect(add_query_arg ("s2member_ccap_req", $ccap, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
83
  exit ();
84
  }
 
 
 
 
 
 
85
  }
86
  /**/
87
  do_action ("ws_plugin__s2member_during_check_page_level_access", get_defined_vars ());
@@ -89,7 +123,94 @@ if (!function_exists ("ws_plugin__s2member_check_page_level_access"))
89
  /**/
90
  do_action ("ws_plugin__s2member_after_check_page_level_access", get_defined_vars ());
91
  /**/
92
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  }
94
  }
95
  ?>
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit ("Do not access this file directly.");
16
  /*
17
  Function for handling Page Level Access permissions.
18
+
19
+ Don't call this function directly, use one of these API functions:
20
+
21
+ Is it protected by s2Member at all?
22
+ - is_page_protected_by_s2member($page_id);
23
+ - is_protected_by_s2member($page_id, "page");
24
+
25
+ Is the current User permitted/authorized?
26
+ - is_page_permitted_by_s2member($page_id);
27
+ - is_permitted_by_s2member($page_id, "page");
28
+
29
+ see: `/s2member/includes/functions/api-functions.inc.php`.
30
  */
31
  if (!function_exists ("ws_plugin__s2member_check_page_level_access"))
32
  {
33
  function ws_plugin__s2member_check_page_level_access ()
34
  {
35
+ global $post; /* get_the_ID() unavailable outside The Loop. */
36
  /**/
37
  do_action ("ws_plugin__s2member_before_check_page_level_access", get_defined_vars ());
38
  /**/
39
  $excluded = apply_filters ("ws_plugin__s2member_check_page_level_access_excluded", false, get_defined_vars ());
40
  /**/
41
+ if (!$excluded && is_page () && is_object ($post) && ($page_id = $post->ID) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
42
  {
43
  $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
44
  /**/
45
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
 
 
 
 
 
 
 
 
 
46
  {
47
+ wp_redirect (add_query_arg ("s2member_level_req", 0, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
48
+ exit ();
49
+ }
50
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = ws_plugin__s2member_login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
51
+ {
52
+ wp_redirect (add_query_arg ("s2member_level_req", 0, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
53
+ exit ();
54
+ }
55
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
56
+ {
57
+ wp_redirect (add_query_arg ("s2member_level_req", 0, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
58
+ exit ();
59
+ }
60
+ else if (!ws_plugin__s2member_is_systematic_use_page ()) /* Never restrict Systematic Use Pages. However, there are 3 exceptions above ^. */
61
+ {
62
+ for ($i = 0; $i <= 4; $i++) /* Page Level restrictions. Go through each Membership Level. */
63
+ {
64
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
65
+ {
66
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
67
+ exit ();
68
+ }
69
+ /**/
70
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"])) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
71
+ {
72
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
73
+ exit ();
74
+ }
75
+ }
76
  /**/
77
+ if (has_tag ()) /* Here we take a look to see if this Page has any Tags. If so, we need to run the full set of routines against Tags also. */
78
+ {
79
+ for ($i = 0; $i <= 4; $i++) /* Tag Level restrictions ( possibly through Page Tagger ). Go through each Membership Level. */
80
+ {
81
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
82
+ {
83
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
84
+ exit ();
85
+ }
86
+ /**/
87
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"])) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
88
+ {
89
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
90
+ exit ();
91
+ }
92
+ }
93
+ }
94
  /**/
95
+ for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
96
+ {
97
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
98
+ foreach (preg_split ("/[\r\n\t]+/", ws_plugin__s2member_fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
99
+ if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
100
+ {
101
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
102
+ exit ();
103
+ }
104
+ }
105
  /**/
106
+ if (is_array ($ccaps_req = get_post_meta ($page_id, "s2member_ccaps_req", true)) && ws_plugin__s2member_nocache_constants (true) !== "nill")
107
+ foreach ($ccaps_req as $ccap) /* The $current_user MUST satisfy ALL Custom Capability requirements. Stored as a serialized array. */
108
  if (strlen ($ccap) && (!$current_user || !$current_user->has_cap ("access_s2member_ccap_" . $ccap)))
109
  {
110
+ wp_redirect (add_query_arg ("s2member_ccap_req", $ccap, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
111
  exit ();
112
  }
113
+ /**/
114
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && ws_plugin__s2member_nocache_constants (true) !== "nill" && !ws_plugin__s2member_sp_access ($page_id))
115
+ {
116
+ wp_redirect (add_query_arg ("s2member_sp_req", $page_id, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
117
+ exit ();
118
+ }
119
  }
120
  /**/
121
  do_action ("ws_plugin__s2member_during_check_page_level_access", get_defined_vars ());
123
  /**/
124
  do_action ("ws_plugin__s2member_after_check_page_level_access", get_defined_vars ());
125
  /**/
126
+ return; /* For uniformity. */
127
+ }
128
+ }
129
+ /*
130
+ Function checks Page Level Access permissions - for a specific Page.
131
+
132
+ Don't call this function directly, use one of these API functions:
133
+
134
+ Is it protected by s2Member at all?
135
+ - is_page_protected_by_s2member($page_id);
136
+ - is_protected_by_s2member($page_id, "page");
137
+
138
+ Is the current User permitted/authorized?
139
+ - is_page_permitted_by_s2member($page_id);
140
+ - is_permitted_by_s2member($page_id, "page");
141
+
142
+ see: `/s2member/includes/functions/api-functions.inc.php`.
143
+ */
144
+ if (!function_exists ("ws_plugin__s2member_check_specific_page_level_access"))
145
+ {
146
+ function ws_plugin__s2member_check_specific_page_level_access ($page_id = FALSE, $check_user = TRUE)
147
+ {
148
+ do_action ("ws_plugin__s2member_before_check_specific_page_level_access", get_defined_vars ());
149
+ /**/
150
+ $excluded = apply_filters ("ws_plugin__s2member_check_specific_page_level_access_excluded", false, get_defined_vars ());
151
+ /**/
152
+ if (!$excluded && $page_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Check? */
153
+ {
154
+ $page_link = get_page_link ($page_id); /* Determine link to this Page. */
155
+ $page_path = parse_url ($page_link, PHP_URL_PATH); /* Parse req path. */
156
+ $page_query = parse_url ($page_link, PHP_URL_QUERY); /* Parse query. */
157
+ $page_uri = ($page_query) ? $page_path . "?" . $page_query : $page_path;
158
+ /**/
159
+ $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
160
+ /**/
161
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && (!$check_user || !$current_user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
162
+ return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
163
+ /**/
164
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = ws_plugin__s2member_login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $page_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
165
+ return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
166
+ /**/
167
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && (!$check_user || !$current_user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
168
+ return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
169
+ /**/
170
+ else if (!ws_plugin__s2member_is_systematic_use_specific_page ($page_id, $page_uri)) /* However, there are 3 exceptions above ^. */
171
+ {
172
+ for ($i = 0; $i <= 4; $i++) /* Page Level restrictions. Go through each Membership Level. */
173
+ {
174
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"] === "all" && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
175
+ return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
176
+ /**/
177
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"])) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
178
+ return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
179
+ }
180
+ /**/
181
+ if (has_tag ("", $page_id)) /* Here we take a look to see if this Page has any Tags. If so, we need to run the full set of routines against Tags also. */
182
+ {
183
+ for ($i = 0; $i <= 4; $i++) /* Tag Level restrictions ( possibly through Page Tagger ). Go through each Membership Level. */
184
+ {
185
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] === "all" && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
186
+ return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
187
+ /**/
188
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"]), $page_id) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
189
+ return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
190
+ }
191
+ }
192
+ /**/
193
+ for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
194
+ {
195
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
196
+ foreach (preg_split ("/[\r\n\t]+/", ws_plugin__s2member_fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
197
+ if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $page_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
198
+ return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
199
+ }
200
+ /**/
201
+ if (is_array ($ccaps_req = get_post_meta ($page_id, "s2member_ccaps_req", true))) /* Custom Capabilities. */
202
+ foreach ($ccaps_req as $ccap) /* The $current_user MUST satisfy ALL Custom Capabilities. Serialized array. */
203
+ if (strlen ($ccap) && (!$check_user || !$current_user || !$current_user->has_cap ("access_s2member_ccap_" . $ccap)))
204
+ return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_ccap_req" => $ccap), get_defined_vars ());
205
+ /**/
206
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && (!$check_user || !ws_plugin__s2member_sp_access ($page_id, "read-only")))
207
+ return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_sp_req" => $page_id), get_defined_vars ());
208
+ }
209
+ /**/
210
+ do_action ("ws_plugin__s2member_during_check_specific_page_level_access", get_defined_vars ());
211
+ }
212
+ /**/
213
+ return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", null, get_defined_vars ());
214
  }
215
  }
216
  ?>
includes/functions/paypal-button.inc.php CHANGED
@@ -17,8 +17,8 @@ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
17
  Function that handles the Shortcode for [s2Member-PayPal-Button /].
18
  Attach to: add_shortcode("s2Member-PayPal-Button");
19
 
20
- [s2Member-PayPal-Button level="1" ccaps="" desc="" ps="paypal" cc="USD" custom="www.domain.com" tp="0" tt="D" ra="0.01" rp="1" rt="M" rr="1" image="default" /]
21
- [s2Member-PayPal-Button page="0" exp="72" desc="Specific Post/Page Access" ps="paypal" cc="USD" custom="www.domain.com" ra="0.01" sp="1" image="default" /]
22
  The image="" attribute will be used as a custom image; when provided; and not equal to "default".
23
 
24
  - PayPal® Cancellation Buttons are identified by cancel="1".
@@ -46,7 +46,7 @@ if (!function_exists ("ws_plugin__s2member_sc_paypal_button"))
46
  $attr["cancel"] = (!$attr["cancel"] && $attr["cb"]) ? $attr["cb"] : $attr["cancel"]; /* Backward compatibilty for "cb", which was renamed to "cancel" in v3.0.5. */
47
  $attr["ids"] = (!$attr["ids"] && $attr["page"]) ? $attr["page"] : $attr["ids"]; /* Backward compatibilty for "page", which was renamed to "ids" in s2Member v3.0. */
48
  /**/
49
- $attr = shortcode_atts (array ("ids" => "0", "exp" => "72", "level" => "1", "ccaps" => "", "desc" => "", "ps" => "paypal", "cc" => "USD", "custom" => $_SERVER["HTTP_HOST"], "tp" => "0", "tt" => "D", "ra" => "0.01", "rp" => "1", "rt" => "M", "rr" => "1", "modify" => "0", "cancel" => "0", "sp" => "0", "image" => "default"), $attr);
50
  /**/
51
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
52
  do_action ("ws_plugin__s2member_before_sc_paypal_button_after_shortcode_atts", get_defined_vars ());
@@ -77,6 +77,7 @@ if (!function_exists ("ws_plugin__s2member_sc_paypal_button"))
77
  $code = preg_replace ("/%%return%%/", ws_plugin__s2member_esc_ds (esc_attr (get_bloginfo ("wpurl") . "/?s2member_paypal_return=1")), $code);
78
  $code = preg_replace ("/%%domain%%/", ws_plugin__s2member_esc_ds (esc_attr ($_SERVER["HTTP_HOST"])), $code);
79
  /**/
 
80
  $code = preg_replace ('/ name\="item_name" value\="(.*?)"/', ' name="item_name" value="' . ws_plugin__s2member_esc_ds (esc_attr ($attr["desc"])) . '"', $code);
81
  $code = preg_replace ('/ name\="item_number" value\="(.*?)"/', ' name="item_number" value="' . ws_plugin__s2member_esc_ds (esc_attr ($attr["sp_ids_exp"])) . '"', $code);
82
  $code = preg_replace ('/ name\="page_style" value\="(.*?)"/', ' name="page_style" value="' . ws_plugin__s2member_esc_ds (esc_attr ($attr["ps"])) . '"', $code);
@@ -114,6 +115,7 @@ if (!function_exists ("ws_plugin__s2member_sc_paypal_button"))
114
  $code = ($attr["rr"] !== "BN") ? preg_replace ('/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/', " $1_xclick-subscriptions$3", $code) : $code;
115
  $code = ($attr["rr"] !== "BN") ? preg_replace ('/ (\<input type\="hidden" name\="amount" value\="(.*?)" \/\>)/', " <!--$1-->", $code) : $code;
116
  /**/
 
117
  $code = preg_replace ('/ name\="item_name" value\="(.*?)"/', ' name="item_name" value="' . ws_plugin__s2member_esc_ds (esc_attr ($attr["desc"])) . '"', $code);
118
  $code = preg_replace ('/ name\="item_number" value\="(.*?)"/', ' name="item_number" value="' . ws_plugin__s2member_esc_ds (esc_attr ($attr["level_ccaps_eotper"])) . '"', $code);
119
  $code = preg_replace ('/ name\="page_style" value\="(.*?)"/', ' name="page_style" value="' . ws_plugin__s2member_esc_ds (esc_attr ($attr["ps"])) . '"', $code);
17
  Function that handles the Shortcode for [s2Member-PayPal-Button /].
18
  Attach to: add_shortcode("s2Member-PayPal-Button");
19
 
20
+ [s2Member-PayPal-Button level="1" ccaps="" desc="" ps="paypal" cc="USD" ns="1" custom="www.domain.com" tp="0" tt="D" ra="0.01" rp="1" rt="M" rr="1" image="default" /]
21
+ [s2Member-PayPal-Button page="0" exp="72" desc="Specific Post/Page Access" ps="paypal" cc="USD" ns="1" custom="www.domain.com" ra="0.01" sp="1" image="default" /]
22
  The image="" attribute will be used as a custom image; when provided; and not equal to "default".
23
 
24
  - PayPal® Cancellation Buttons are identified by cancel="1".
46
  $attr["cancel"] = (!$attr["cancel"] && $attr["cb"]) ? $attr["cb"] : $attr["cancel"]; /* Backward compatibilty for "cb", which was renamed to "cancel" in v3.0.5. */
47
  $attr["ids"] = (!$attr["ids"] && $attr["page"]) ? $attr["page"] : $attr["ids"]; /* Backward compatibilty for "page", which was renamed to "ids" in s2Member v3.0. */
48
  /**/
49
+ $attr = shortcode_atts (array ("ids" => "0", "exp" => "72", "level" => "1", "ccaps" => "", "desc" => "", "ps" => "paypal", "cc" => "USD", "ns" => "1", "custom" => $_SERVER["HTTP_HOST"], "tp" => "0", "tt" => "D", "ra" => "0.01", "rp" => "1", "rt" => "M", "rr" => "1", "modify" => "0", "cancel" => "0", "sp" => "0", "image" => "default"), $attr);
50
  /**/
51
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
52
  do_action ("ws_plugin__s2member_before_sc_paypal_button_after_shortcode_atts", get_defined_vars ());
77
  $code = preg_replace ("/%%return%%/", ws_plugin__s2member_esc_ds (esc_attr (get_bloginfo ("wpurl") . "/?s2member_paypal_return=1")), $code);
78
  $code = preg_replace ("/%%domain%%/", ws_plugin__s2member_esc_ds (esc_attr ($_SERVER["HTTP_HOST"])), $code);
79
  /**/
80
+ $code = preg_replace ('/ name\="no_shipping" value\="(.*?)"/', ' name="no_shipping" value="' . ws_plugin__s2member_esc_ds (esc_attr ($attr["ns"])) . '"', $code);
81
  $code = preg_replace ('/ name\="item_name" value\="(.*?)"/', ' name="item_name" value="' . ws_plugin__s2member_esc_ds (esc_attr ($attr["desc"])) . '"', $code);
82
  $code = preg_replace ('/ name\="item_number" value\="(.*?)"/', ' name="item_number" value="' . ws_plugin__s2member_esc_ds (esc_attr ($attr["sp_ids_exp"])) . '"', $code);
83
  $code = preg_replace ('/ name\="page_style" value\="(.*?)"/', ' name="page_style" value="' . ws_plugin__s2member_esc_ds (esc_attr ($attr["ps"])) . '"', $code);
115
  $code = ($attr["rr"] !== "BN") ? preg_replace ('/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/', " $1_xclick-subscriptions$3", $code) : $code;
116
  $code = ($attr["rr"] !== "BN") ? preg_replace ('/ (\<input type\="hidden" name\="amount" value\="(.*?)" \/\>)/', " <!--$1-->", $code) : $code;
117
  /**/
118
+ $code = preg_replace ('/ name\="no_shipping" value\="(.*?)"/', ' name="no_shipping" value="' . ws_plugin__s2member_esc_ds (esc_attr ($attr["ns"])) . '"', $code);
119
  $code = preg_replace ('/ name\="item_name" value\="(.*?)"/', ' name="item_name" value="' . ws_plugin__s2member_esc_ds (esc_attr ($attr["desc"])) . '"', $code);
120
  $code = preg_replace ('/ name\="item_number" value\="(.*?)"/', ' name="item_number" value="' . ws_plugin__s2member_esc_ds (esc_attr ($attr["level_ccaps_eotper"])) . '"', $code);
121
  $code = preg_replace ('/ name\="page_style" value\="(.*?)"/', ' name="page_style" value="' . ws_plugin__s2member_esc_ds (esc_attr ($attr["ps"])) . '"', $code);
includes/functions/paypal-notify.inc.php CHANGED
@@ -16,7 +16,7 @@ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
16
  /*
17
  Handles PayPal® IPN URL processing.
18
  These same routines also handle s2Member Pro/PayPal® Pro operations;
19
- giving you the ability ( as needed ) to hook into these routines using
20
  WordPress® Hooks/Filters; as seen in the source code below.
21
 
22
  Please do NOT modify the source code directly.
@@ -31,1280 +31,12 @@ if (!function_exists ("ws_plugin__s2member_paypal_notify"))
31
  {
32
  function ws_plugin__s2member_paypal_notify ()
33
  {
34
- include_once ABSPATH . "wp-admin/includes/admin.php";
35
- /**/
36
- global $current_site, $current_blog; /* For Multisite support. */
37
- /**/
38
- do_action ("ws_plugin__s2member_before_paypal_notify", get_defined_vars ());
39
- /**/
40
- if ($_GET["s2member_paypal_notify"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"])
41
  {
42
- if (is_array ($paypal = ws_plugin__s2member_paypal_postvars ())) /* Verify PayPal® POST vars. */
43
- {
44
- $paypal["s2member_log"][] = "IPN received on: " . date ("D M j, Y g:i:s a T");
45
- $paypal["s2member_log"][] = "s2Member POST vars verified through a POST back to PayPal®.";
46
- /**/
47
- $paypal["custom"] = (!$paypal["custom"]) ? ws_plugin__s2member_paypal_custom ($paypal["recurring_payment_id"]) : $paypal["custom"];
48
- /**/
49
- $payment_status_issues = "/^(failed|denied|expired|refunded|reversed|reversal|canceled_reversal|voided)$/i";
50
- /**/
51
- /* Notifications following the PayPal® Pro format for recurring payments, do NOT carry the "custom" value, so we do a lookup.
52
- This is only crucial for one IPN call in Standard Integration: `txn_type=recurring_payment_suspended_due_to_max_failed_payment`.
53
- In Pro Integrations, we just need to make sure the "custom" field is assigned for each account during on-site checkout.
54
- This way the "custom" value will always be available when it needs to be; for both Standard and Pro services. */
55
- if (preg_match ("/^" . preg_quote (preg_replace ("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $paypal["custom"]))
56
- { /* The business address validation was removed from this routine, because PayPal® always fills that with the primary
57
- email address. In cases where an alternate PayPal® address is being paid, validation was not possible. */
58
- $paypal["s2member_log"][] = "s2Member originating domain ( _SERVER[HTTP_HOST] ) validated.";
59
- /*
60
- Custom conditionals can be applied by filters.
61
- */
62
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
63
- if (!apply_filters ("ws_plugin__s2member_during_paypal_notify_conditionals", false, get_defined_vars ()))
64
- {
65
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
66
- /*
67
- Virtual Terminal transactions.
68
- This is not really necessary. It is only here because this txn_type could
69
- be necessary in a future release of s2Member. For now, it's just a fill-in.
70
- These Hooks/Filters will remain, so you can use them now; if you need to.
71
- */
72
- if (/**/preg_match ("/^virtual_terminal$/i", $paypal["txn_type"])/**/
73
- && !preg_match ($payment_status_issues, $paypal["payment_status"])/**/
74
- && $paypal["txn_id"]/**/)
75
- {
76
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
77
- do_action ("ws_plugin__s2member_during_paypal_notify_before_virtual_terminal", get_defined_vars ());
78
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
79
- /**/
80
- $paypal["s2member_log"][] = "s2Member txn_type identified as virtual_terminal.";
81
- /**/
82
- $processing = $during = true; /* Yes, we ARE processing this. */
83
- /**/
84
- $paypal["s2member_log"][] = "The txn_type does not require any action on the part of s2Member.";
85
- /**/
86
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
87
- do_action ("ws_plugin__s2member_during_paypal_notify_during_virtual_terminal", get_defined_vars ());
88
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
89
- /**/
90
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
91
- do_action ("ws_plugin__s2member_during_paypal_notify_after_virtual_terminal", get_defined_vars ());
92
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
93
- }
94
- /*
95
- Express Checkout transactions.
96
- This is not really necessary. It is only here because this txn_type could
97
- be necessary in a future release of s2Member. For now, it's just a fill-in.
98
- These Hooks/Filters will remain, so you can use them now; if you need to.
99
- */
100
- else if (/**/preg_match ("/^express_checkout$/i", $paypal["txn_type"])/**/
101
- && !preg_match ($payment_status_issues, $paypal["payment_status"])/**/
102
- && $paypal["txn_id"]/**/)
103
- {
104
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
105
- do_action ("ws_plugin__s2member_during_paypal_notify_before_express_checkout", get_defined_vars ());
106
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
107
- /**/
108
- $paypal["s2member_log"][] = "s2Member txn_type identified as express_checkout.";
109
- /**/
110
- $processing = $during = true; /* Yes, we ARE processing this. */
111
- /**/
112
- $paypal["s2member_log"][] = "The txn_type does not require any action on the part of s2Member.";
113
- $paypal["s2member_log"][] = "s2Member Pro handles Express Checkout events on-site, with an IPN proxy.";
114
- /**/
115
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
116
- do_action ("ws_plugin__s2member_during_paypal_notify_during_express_checkout", get_defined_vars ());
117
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
118
- /**/
119
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
120
- do_action ("ws_plugin__s2member_during_paypal_notify_after_express_checkout", get_defined_vars ());
121
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
122
- }
123
- /*
124
- Cart ( Line Item ) transactions.
125
- This is not really necessary. It is only here because this txn_type could
126
- be necessary in a future release of s2Member. For now, it's just a fill-in.
127
- These Hooks/Filters will remain, so you can use them now; if you need to.
128
- */
129
- else if (/**/preg_match ("/^cart$/i", $paypal["txn_type"])/**/
130
- && !preg_match ($payment_status_issues, $paypal["payment_status"])/**/
131
- && $paypal["txn_id"]/**/)
132
- {
133
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
134
- do_action ("ws_plugin__s2member_during_paypal_notify_before_cart", get_defined_vars ());
135
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
136
- /**/
137
- $paypal["s2member_log"][] = "s2Member txn_type identified as cart.";
138
- /**/
139
- $processing = $during = true; /* Yes, we ARE processing this. */
140
- /**/
141
- $paypal["s2member_log"][] = "The txn_type does not require any action on the part of s2Member.";
142
- $paypal["s2member_log"][] = "s2Member Pro handles Cart events on-site, with an IPN proxy.";
143
- /**/
144
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
145
- do_action ("ws_plugin__s2member_during_paypal_notify_during_cart", get_defined_vars ());
146
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
147
- /**/
148
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
149
- do_action ("ws_plugin__s2member_during_paypal_notify_after_cart", get_defined_vars ());
150
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
151
- }
152
- /*
153
- Specific Post/Page Access.
154
- */
155
- else if (/**/preg_match ("/^web_accept$/i", $paypal["txn_type"])/**/
156
- && preg_match ("/^sp\:[0-9,]+\:[0-9]+$/", $paypal["item_number"])/**/
157
- && !preg_match ($payment_status_issues, $paypal["payment_status"])/**/
158
- && $paypal["payer_email"] && $paypal["txn_id"]/**/)
159
- {
160
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
161
- do_action ("ws_plugin__s2member_during_paypal_notify_before_sp_access", get_defined_vars ());
162
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
163
- /**/
164
- $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept) for Specific Post/Page Access.";
165
- /**/
166
- list (, $paypal["sp_ids"], $paypal["hours"]) = preg_split ("/\:/", $paypal["item_number"], 3);
167
- /**/
168
- if (($sp_access_url = ws_plugin__s2member_sp_access_link_gen ($paypal["sp_ids"], $paypal["hours"])) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
169
- {
170
- $processing = $during = true; /* Yes, we ARE processing this. */
171
- /**/
172
- $sbj = preg_replace ("/%%sp_access_url%%/i", ws_plugin__s2member_esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_GET["s2member_paypal_proxy"] === "s2member-pro-module") ? "pro_" : "") . "sp_email_subject"]);
173
- $sbj = preg_replace ("/%%sp_access_exp%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours"))), $sbj);
174
- /**/
175
- $msg = preg_replace ("/%%sp_access_url%%/i", ws_plugin__s2member_esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_GET["s2member_paypal_proxy"] === "s2member-pro-module") ? "pro_" : "") . "sp_email_message"]);
176
- $msg = preg_replace ("/%%sp_access_exp%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours"))), $msg);
177
- /**/
178
- $rec = preg_replace ("/%%sp_access_url%%/i", ws_plugin__s2member_esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_GET["s2member_paypal_proxy"] === "s2member-pro-module") ? "pro_" : "") . "sp_email_recipients"]);
179
- $rec = preg_replace ("/%%sp_access_exp%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours"))), $rec);
180
- /**/
181
- if (($rec = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $rec)) && ($rec = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["txn_id"]), $rec)))
182
- if (($rec = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $rec))) /* Full amount of the payment, before fee is subtracted. */
183
- if (($rec = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $rec)) && ($rec = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $rec)))
184
- if (($rec = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_dq (ws_plugin__s2member_esc_ds ($paypal["first_name"])), $rec)) && ($rec = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_dq (ws_plugin__s2member_esc_ds ($paypal["last_name"])), $rec)))
185
- if (($rec = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_dq (ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $rec))) /* **NOTE** ws_plugin__s2member_esc_dq() is applied here. ( ex. "N\"ame" <email> ). */
186
- if (($rec = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $rec)))
187
- if (($recipients = preg_split ("/;+/", $rec))) /* Here we break the recipients into an array. */
188
- /**/
189
- if (($sbj = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)) && ($sbj = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["txn_id"]), $sbj)))
190
- if (($sbj = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $sbj))) /* Full amount of the payment, before fee is subtracted. */
191
- if (($sbj = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $sbj)) && ($sbj = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $sbj)))
192
- if (($sbj = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $sbj)) && ($sbj = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $sbj)))
193
- if (($sbj = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)))
194
- if (($sbj = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $sbj)))
195
- /**/
196
- if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["txn_id"]), $msg)))
197
- if (($msg = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $msg))) /* Full amount of the payment, before fee is subtracted. */
198
- if (($msg = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $msg)))
199
- if (($msg = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $msg)))
200
- if (($msg = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
201
- if (($msg = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $msg)))
202
- /**/
203
- if (($sbj = trim ($sbj)) && ($msg = trim ($msg))) /* Make sure they are not empty. */
204
- {
205
- foreach (ws_plugin__s2member_trim_deep ($recipients) as $recipient) /* Go through the full list of recipients. */
206
- /**/
207
- ($recipient) ? mail ($recipient, $sbj, $msg, "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
208
- /**/
209
- $paypal["s2member_log"][] = "Specific Post/Page Confirmation Email sent to: " . implode ("; ", $recipients) . ".";
210
- }
211
- /**/
212
- if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_notification_urls"])
213
- {
214
- foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_notification_urls"]) as $url)
215
- /**/
216
- if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%sp_access_url%%/i", ws_plugin__s2member_esc_ds (rawurlencode ($sp_access_url)), $url)))
217
- if (($url = preg_replace ("/%%sp_access_exp%%/i", ws_plugin__s2member_esc_ds (urlencode (ws_plugin__s2member_approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours")))), $url)))
218
- if (($url = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["txn_id"])), $url)))
219
- if (($url = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_name"])), $url)))
220
- if (($url = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["last_name"])), $url)))
221
- if (($url = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
222
- if (($url = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["payer_email"])), $url)))
223
- /**/
224
- if (($url = trim ($url))) /* Empty? */
225
- ws_plugin__s2member_remote ($url);
226
- /**/
227
- $paypal["s2member_log"][] = "Specific Post/Page Access Notification URLs have been processed.";
228
- }
229
- /**/
230
- if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_notification_recipients"])
231
- {
232
- $msg = $sbj = "( s2Member / API Notification Email ) - Specific Post/Page Access";
233
- $msg .= "\n\n"; /* Spacing in the message body. */
234
- $msg .= "sp_access_url: %%sp_access_url%%\n";
235
- $msg .= "sp_access_exp: %%sp_access_exp%%\n";
236
- $msg .= "amount: %%amount%%\n";
237
- $msg .= "txn_id: %%txn_id%%\n";
238
- $msg .= "item_number: %%item_number%%\n";
239
- $msg .= "item_name: %%item_name%%\n";
240
- $msg .= "first_name: %%first_name%%\n";
241
- $msg .= "last_name: %%last_name%%\n";
242
- $msg .= "full_name: %%full_name%%\n";
243
- $msg .= "payer_email: %%payer_email%%\n";
244
- $msg .= "cv0: %%cv0%%\n";
245
- $msg .= "cv1: %%cv1%%\n";
246
- $msg .= "cv2: %%cv2%%\n";
247
- $msg .= "cv3: %%cv3%%\n";
248
- $msg .= "cv4: %%cv4%%\n";
249
- $msg .= "cv5: %%cv5%%\n";
250
- $msg .= "cv6: %%cv6%%\n";
251
- $msg .= "cv7: %%cv7%%\n";
252
- $msg .= "cv8: %%cv8%%\n";
253
- $msg .= "cv9: %%cv9%%";
254
- /**/
255
- if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%sp_access_url%%/i", ws_plugin__s2member_esc_ds ($sp_access_url), $msg)))
256
- if (($msg = preg_replace ("/%%sp_access_exp%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours"))), $msg)))
257
- if (($msg = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $msg)) && ($msg = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["txn_id"]), $msg)))
258
- if (($msg = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $msg)))
259
- if (($msg = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $msg)))
260
- if (($msg = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
261
- if (($msg = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $msg)))
262
- /**/
263
- foreach (ws_plugin__s2member_trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_notification_recipients"])) as $recipient)
264
- /**/
265
- ($recipient) ? mail ($recipient, $sbj, apply_filters ("ws_plugin__s2member_sp_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
266
- /**/
267
- $paypal["s2member_log"][] = "Specific Post/Page Access Notification Emails have been processed.";
268
- }
269
- /**/
270
- if ($processing && ($url = $paypal["proxy_return_url"])) /* A proxy is requesting a return URL for this transaction? */
271
- {
272
- if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%sp_access_url%%/i", ws_plugin__s2member_esc_ds (rawurlencode ($sp_access_url)), $url)))
273
- if (($url = preg_replace ("/%%sp_access_exp%%/i", ws_plugin__s2member_esc_ds (urlencode (ws_plugin__s2member_approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours")))), $url)))
274
- if (($url = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["txn_id"])), $url)))
275
- if (($url = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_name"])), $url)))
276
- if (($url = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["last_name"])), $url)))
277
- if (($url = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
278
- if (($url = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["payer_email"])), $url)))
279
- /**/
280
- if (($url = trim ($url))) /* Empty? */
281
- $paypal["proxy_return_url"] = $url;
282
- /**/
283
- $paypal["s2member_log"][] = "Specific Post/Page Return, a Proxy Return URL is ready.";
284
- }
285
- /**/
286
- if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_tracking_codes"]))
287
- {
288
- if (($code = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $code)) && ($code = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["txn_id"]), $code)))
289
- if (($code = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $code)) && ($code = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $code)))
290
- if (($code = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $code)) && ($code = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $code)))
291
- if (($code = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
292
- if (($code = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $code)))
293
- /**/
294
- if (($code = trim ($code))) /* Make sure it is not empty. This gets stored into a Transient Queue. */
295
- {
296
- $paypal["s2member_log"][] = "Storing Specific Post/Page Tracking Codes into a Transient Queue for s2Member. These will be processed on-site.";
297
- set_transient (md5 ("s2member_transient_sp_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
298
- }
299
- }
300
- /**/
301
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
302
- do_action ("ws_plugin__s2member_during_paypal_notify_during_sp_access", get_defined_vars ());
303
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
304
- }
305
- else
306
- {
307
- $paypal["s2member_log"][] = "Unable to generate Access Link for Specific Post/Page Access. Does your Leading Post/Page still exist?";
308
- }
309
- /**/
310
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
311
- do_action ("ws_plugin__s2member_during_paypal_notify_after_sp_access", get_defined_vars ());
312
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
313
- }
314
- /*
315
- New Subscriptions.
316
- Possibly containing advanced update vars
317
- ( option_name1, option_selection1 ); which allow account modifications.
318
- */
319
- else if (/**/preg_match ("/^(web_accept|subscr_signup)$/i", $paypal["txn_type"])/**/
320
- && preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])/**/
321
- && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["txn_id"]))/**/
322
- && !preg_match ($payment_status_issues, $paypal["payment_status"])/**/
323
- && $paypal["payer_email"]/**/)
324
- {
325
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
326
- do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_signup", get_defined_vars ());
327
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
328
- /**/
329
- $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup).";
330
- /**/
331
- list ($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split ("/\:/", $paypal["item_number"], 3);
332
- /**/
333
- if (preg_match ("/^web_accept$/i", $paypal["txn_type"])) /* Conversions for Lifetime & Fixed-Term sales. */
334
- {
335
- $paypal["period3"] = ($paypal["eotper"]) ? $paypal["eotper"] : "1 L"; /* This defaults to exactly 1 Lifetime. */
336
- $paypal["mc_amount3"] = $paypal["mc_gross"]; /* The "Buy Now" amount. */
337
- }
338
- /**/
339
- $paypal["initial_term"] = $paypal["period1"] ? $paypal["period1"] : "0 D"; /* Do not allow the initial period to be empty. Defaults to 0 D. */
340
- $paypal["initial"] = (isset ($paypal["mc_amount1"]) && preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
341
- $paypal["regular"] = $paypal["mc_amount3"]; /* This is the regular payment amount that is charged to the customer. Always required by PayPal. */
342
- $paypal["regular_term"] = $paypal["period3"]; /* This is just set to keep a standard; this way both initial_term & regular_term are available. */
343
- $paypal["recurring"] = ($paypal["recurring"]) ? $paypal["mc_amount3"] : "0"; /* If non-recurring, this should be zero, otherwise regular. */
344
- /*
345
- New Subscription with advanced update vars ( option_name1, option_selection1 ).
346
- */
347
- if (preg_match ("/(updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) /* This is an advanced way to handle Subscription update modifications. */
348
- /* This advanced method is required whenever a Subscription that is already completed, or was never setup to recur in the first place needs to be modified. PayPal will not allow the
349
- modify=1|2 parameter to be used in those scenarios, because technically there is nothing to update. The only thing that actually needs to be updated is the account. */
350
- {
351
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
352
- do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_signup_w_update_vars", get_defined_vars ());
353
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
354
- /**/
355
- $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup) w/ update vars.";
356
- /**/
357
- /* Check for both the old & new subscr_id's, just in case the Return routine already changed it. */
358
- if (($user_id = ws_plugin__s2member_paypal_user_id ($paypal["subscr_id"], $paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
359
- {
360
- if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
361
- {
362
- $processing = $modifying = $during = true; /* Yes, we ARE processing this. */
363
- /**/
364
- $user->set_role ("s2member_level" . $paypal["level"]);
365
- /**/
366
- foreach ($user->allcaps as $cap => $cap_enabled)
367
- if (preg_match ("/^access_s2member_ccap_/", $cap))
368
- $user->remove_cap ($ccap = $cap);
369
- /**/
370
- foreach (preg_split ("/[\r\n\t\s;,]+/", $paypal["ccaps"]) as $ccap)
371
- if (strlen ($ccap)) /* Don't add empty capabilities. */
372
- $user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
373
- /**/
374
- update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
375
- update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
376
- /**/
377
- delete_user_option ($user_id, "s2member_file_download_access_arc");
378
- delete_user_option ($user_id, "s2member_file_download_access_log");
379
- /**/
380
- if (preg_match ("/^web_accept$/i", $paypal["txn_type"]) && $paypal["eotper"])
381
- update_user_option ($user_id, "s2member_auto_eot_time", ws_plugin__s2member_paypal_auto_eot_time (0, 0, 0, $paypal["eotper"]));
382
- else /* Otherwise, we need to clear the eot time. */
383
- delete_user_option ($user_id, "s2member_auto_eot_time");
384
- /**/
385
- ws_plugin__s2member_clear_user_note_lines ($user_id, "/^Demoted by s2Member\:/");
386
- /**/
387
- $paypal["s2member_log"][] = "s2Member Level/Capabilities updated w/ advanced update routines.";
388
- /**/
389
- mail ($paypal["payer_email"], "Thank You! Your membership has been updated.", "Thank You! Your membership has been updated to:\n" . $paypal["item_name"] . "\n\nYou'll need to log back in now.\n" . wp_login_url (), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8");
390
- /**/
391
- $paypal["s2member_log"][] = "Modification Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.";
392
- /**/
393
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
394
- do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_signup_w_update_vars", get_defined_vars ());
395
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
396
- }
397
- else
398
- {
399
- $paypal["s2member_log"][] = "Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
400
- }
401
- }
402
- else
403
- {
404
- $paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB. Please check the on0 and os0 variables in your Button Code.";
405
- }
406
- /**/
407
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
408
- do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_signup_w_update_vars", get_defined_vars ());
409
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
410
- }
411
- /*
412
- New Subscription. Normal Subscription signup, we are not updating anything for a past Subscription.
413
- */
414
- else /* Else this is a normal Subscription signup, we are not updating anything. */
415
- {
416
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
417
- do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_signup_wo_update_vars", get_defined_vars ());
418
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
419
- /**/
420
- $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup) w/o update vars.";
421
- /**/
422
- if (($registration_url = ws_plugin__s2member_register_link_gen ($paypal["subscr_id"], $paypal["custom"], $paypal["item_number"])) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
423
- {
424
- $processing = $during = true; /* Yes, we ARE processing this. */
425
- /**/
426
- $sbj = preg_replace ("/%%registration_url%%/i", ws_plugin__s2member_esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_GET["s2member_paypal_proxy"] === "s2member-pro-module") ? "pro_" : "") . "signup_email_subject"]);
427
- $msg = preg_replace ("/%%registration_url%%/i", ws_plugin__s2member_esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_GET["s2member_paypal_proxy"] === "s2member-pro-module") ? "pro_" : "") . "signup_email_message"]);
428
- $rec = preg_replace ("/%%registration_url%%/i", ws_plugin__s2member_esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_GET["s2member_paypal_proxy"] === "s2member-pro-module") ? "pro_" : "") . "signup_email_recipients"]);
429
- /**/
430
- if (($rec = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $rec)) && ($rec = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $rec)))
431
- if (($rec = preg_replace ("/%%initial%%/i", ws_plugin__s2member_esc_ds ($paypal["initial"]), $rec)) && ($rec = preg_replace ("/%%regular%%/i", ws_plugin__s2member_esc_ds ($paypal["regular"]), $rec)))
432
- if (($rec = preg_replace ("/%%initial_term%%/i", ws_plugin__s2member_esc_ds ($paypal["initial_term"]), $rec)) && ($rec = preg_replace ("/%%regular_term%%/i", ws_plugin__s2member_esc_ds ($paypal["regular_term"]), $rec)))
433
- if (($rec = preg_replace ("/%%initial_cycle%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_paypal_term_cycle ($paypal["initial_term"])), $rec)) && ($rec = preg_replace ("/%%regular_cycle%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_paypal_term_cycle ($paypal["regular_term"])), $rec)))
434
- if (($rec = preg_replace ("/%%recurring%%/i", ws_plugin__s2member_esc_ds ($paypal["recurring"]), $rec)) && ($rec = preg_replace ("/%%recurring\/regular_cycle%%/i", ws_plugin__s2member_esc_ds ((($paypal["recurring"]) ? $paypal["recurring"] . " / " . ws_plugin__s2member_paypal_term_cycle ($paypal["regular_term"]) : "0 / non-recurring")), $rec)))
435
- if (($rec = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $rec)) && ($rec = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $rec)))
436
- if (($rec = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_dq (ws_plugin__s2member_esc_ds ($paypal["first_name"])), $rec)) && ($rec = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_dq (ws_plugin__s2member_esc_ds ($paypal["last_name"])), $rec)))
437
- if (($rec = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_dq (ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $rec))) /* **NOTE** ws_plugin__s2member_esc_dq() is applied here. ( ex. "N\"ame" <email> ). */
438
- if (($rec = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $rec)))
439
- if (($recipients = preg_split ("/;+/", $rec))) /* Here we break the recipients into an array. */
440
- /**/
441
- if (($sbj = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)) && ($sbj = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $sbj)))
442
- if (($sbj = preg_replace ("/%%initial%%/i", ws_plugin__s2member_esc_ds ($paypal["initial"]), $sbj)) && ($sbj = preg_replace ("/%%regular%%/i", ws_plugin__s2member_esc_ds ($paypal["regular"]), $sbj)))
443
- if (($sbj = preg_replace ("/%%initial_term%%/i", ws_plugin__s2member_esc_ds ($paypal["initial_term"]), $sbj)) && ($sbj = preg_replace ("/%%regular_term%%/i", ws_plugin__s2member_esc_ds ($paypal["regular_term"]), $sbj)))
444
- if (($sbj = preg_replace ("/%%initial_cycle%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_paypal_term_cycle ($paypal["initial_term"])), $sbj)) && ($sbj = preg_replace ("/%%regular_cycle%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_paypal_term_cycle ($paypal["regular_term"])), $sbj)))
445
- if (($sbj = preg_replace ("/%%recurring%%/i", ws_plugin__s2member_esc_ds ($paypal["recurring"]), $sbj)) && ($sbj = preg_replace ("/%%recurring\/regular_cycle%%/i", ws_plugin__s2member_esc_ds ((($paypal["recurring"]) ? $paypal["recurring"] . " / " . ws_plugin__s2member_paypal_term_cycle ($paypal["regular_term"]) : "0 / non-recurring")), $sbj)))
446
- if (($sbj = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $sbj)) && ($sbj = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $sbj)))
447
- if (($sbj = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $sbj)) && ($sbj = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $sbj)))
448
- if (($sbj = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)))
449
- if (($sbj = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $sbj)))
450
- /**/
451
- if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $msg)))
452
- if (($msg = preg_replace ("/%%initial%%/i", ws_plugin__s2member_esc_ds ($paypal["initial"]), $msg)) && ($msg = preg_replace ("/%%regular%%/i", ws_plugin__s2member_esc_ds ($paypal["regular"]), $msg)))
453
- if (($msg = preg_replace ("/%%initial_term%%/i", ws_plugin__s2member_esc_ds ($paypal["initial_term"]), $msg)) && ($msg = preg_replace ("/%%regular_term%%/i", ws_plugin__s2member_esc_ds ($paypal["regular_term"]), $msg)))
454
- if (($msg = preg_replace ("/%%initial_cycle%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_paypal_term_cycle ($paypal["initial_term"])), $msg)) && ($msg = preg_replace ("/%%regular_cycle%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_paypal_term_cycle ($paypal["regular_term"])), $msg)))
455
- if (($msg = preg_replace ("/%%recurring%%/i", ws_plugin__s2member_esc_ds ($paypal["recurring"]), $msg)) && ($msg = preg_replace ("/%%recurring\/regular_cycle%%/i", ws_plugin__s2member_esc_ds ((($paypal["recurring"]) ? $paypal["recurring"] . " / " . ws_plugin__s2member_paypal_term_cycle ($paypal["regular_term"]) : "0 / non-recurring")), $msg)))
456
- if (($msg = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $msg)))
457
- if (($msg = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $msg)))
458
- if (($msg = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
459
- if (($msg = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $msg)))
460
- /**/
461
- if (($sbj = trim ($sbj)) && ($msg = trim ($msg))) /* Make sure they are not empty. */
462
- {
463
- foreach (ws_plugin__s2member_trim_deep ($recipients) as $recipient) /* Go through the full list of recipients. */
464
- /**/
465
- ($recipient) ? mail ($recipient, $sbj, $msg, "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
466
- /**/
467
- $paypal["s2member_log"][] = "Signup Confirmation Email sent to: " . implode ("; ", $recipients) . ".";
468
- }
469
- /**/
470
- if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
471
- {
472
- foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_urls"]) as $url)
473
- /**/
474
- if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["subscr_id"])), $url)))
475
- if (($url = preg_replace ("/%%initial%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["initial"])), $url)) && ($url = preg_replace ("/%%regular%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["regular"])), $url)) && ($url = preg_replace ("/%%recurring%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["recurring"])), $url)))
476
- if (($url = preg_replace ("/%%initial_term%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["initial_term"])), $url)) && ($url = preg_replace ("/%%regular_term%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["regular_term"])), $url)))
477
- if (($url = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_name"])), $url)))
478
- if (($url = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["last_name"])), $url)))
479
- if (($url = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
480
- if (($url = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["payer_email"])), $url)))
481
- /**/
482
- if (($url = trim ($url))) /* Empty? */
483
- ws_plugin__s2member_remote ($url);
484
- /**/
485
- $paypal["s2member_log"][] = "Signup Notification URLs have been processed.";
486
- }
487
- /**/
488
- if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
489
- {
490
- $msg = $sbj = "( s2Member / API Notification Email ) - Signup";
491
- $msg .= "\n\n"; /* Spacing in the message body. */
492
- $msg .= "subscr_id: %%subscr_id%%\n";
493
- $msg .= "initial: %%initial%%\n";
494
- $msg .= "regular: %%regular%%\n";
495
- $msg .= "recurring: %%recurring%%\n";
496
- $msg .= "initial_term: %%initial_term%%\n";
497
- $msg .= "regular_term: %%regular_term%%\n";
498
- $msg .= "item_number: %%item_number%%\n";
499
- $msg .= "item_name: %%item_name%%\n";
500
- $msg .= "first_name: %%first_name%%\n";
501
- $msg .= "last_name: %%last_name%%\n";
502
- $msg .= "full_name: %%full_name%%\n";
503
- $msg .= "payer_email: %%payer_email%%\n";
504
- $msg .= "cv0: %%cv0%%\n";
505
- $msg .= "cv1: %%cv1%%\n";
506
- $msg .= "cv2: %%cv2%%\n";
507
- $msg .= "cv3: %%cv3%%\n";
508
- $msg .= "cv4: %%cv4%%\n";
509
- $msg .= "cv5: %%cv5%%\n";
510
- $msg .= "cv6: %%cv6%%\n";
511
- $msg .= "cv7: %%cv7%%\n";
512
- $msg .= "cv8: %%cv8%%\n";
513
- $msg .= "cv9: %%cv9%%";
514
- /**/
515
- if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $msg)))
516
- if (($msg = preg_replace ("/%%initial%%/i", ws_plugin__s2member_esc_ds ($paypal["initial"]), $msg)) && ($msg = preg_replace ("/%%regular%%/i", ws_plugin__s2member_esc_ds ($paypal["regular"]), $msg)) && ($msg = preg_replace ("/%%recurring%%/i", ws_plugin__s2member_esc_ds ($paypal["recurring"]), $msg)))
517
- if (($msg = preg_replace ("/%%initial_term%%/i", ws_plugin__s2member_esc_ds ($paypal["initial_term"]), $msg)) && ($msg = preg_replace ("/%%regular_term%%/i", ws_plugin__s2member_esc_ds ($paypal["regular_term"]), $msg)))
518
- if (($msg = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $msg)))
519
- if (($msg = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $msg)))
520
- if (($msg = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
521
- if (($msg = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $msg)))
522
- /**/
523
- foreach (ws_plugin__s2member_trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_recipients"])) as $recipient)
524
- /**/
525
- ($recipient) ? mail ($recipient, $sbj, apply_filters ("ws_plugin__s2member_signup_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
526
- /**/
527
- $paypal["s2member_log"][] = "Signup Notification Emails have been processed.";
528
- }
529
- /**/
530
- if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
531
- {
532
- if (($code = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $code)))
533
- if (($code = preg_replace ("/%%initial%%/i", ws_plugin__s2member_esc_ds ($paypal["initial"]), $code)) && ($code = preg_replace ("/%%regular%%/i", ws_plugin__s2member_esc_ds ($paypal["regular"]), $code)) && ($code = preg_replace ("/%%recurring%%/i", ws_plugin__s2member_esc_ds ($paypal["recurring"]), $code)))
534
- if (($code = preg_replace ("/%%initial_term%%/i", ws_plugin__s2member_esc_ds ($paypal["initial_term"]), $code)) && ($code = preg_replace ("/%%regular_term%%/i", ws_plugin__s2member_esc_ds ($paypal["regular_term"]), $code)))
535
- if (($code = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $code)) && ($code = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $code)))
536
- if (($code = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $code)) && ($code = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $code)))
537
- if (($code = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
538
- if (($code = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $code)))
539
- /**/
540
- if (($code = trim ($code))) /* Make sure it is not empty. This gets stored into a Transient Queue. */
541
- {
542
- $paypal["s2member_log"][] = "Storing Signup Tracking Codes into a Transient Queue for s2Member. These will be processed on-site.";
543
- set_transient (md5 ("s2member_transient_signup_tracking_codes_" . $paypal["subscr_id"]), $code, 43200);
544
- }
545
- }
546
- /**/
547
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
548
- do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_signup_wo_update_vars", get_defined_vars ());
549
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
550
- }
551
- else
552
- {
553
- $paypal["s2member_log"][] = "Unable to generate Registration URL for Membership Access. Possible data corruption within the IPN response.";
554
- }
555
- /**/
556
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
557
- do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_signup_wo_update_vars", get_defined_vars ());
558
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
559
- }
560
- /**/
561
- if ($processing && ($url = $paypal["proxy_return_url"])) /* A proxy is requesting a return URL for this transaction? */
562
- {
563
- if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["subscr_id"])), $url)))
564
- if (($url = preg_replace ("/%%initial%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["initial"])), $url)) && ($url = preg_replace ("/%%regular%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["regular"])), $url)) && ($url = preg_replace ("/%%recurring%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["recurring"])), $url)))
565
- if (($url = preg_replace ("/%%initial_term%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["initial_term"])), $url)) && ($url = preg_replace ("/%%regular_term%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["regular_term"])), $url)))
566
- if (($url = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_name"])), $url)))
567
- if (($url = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["last_name"])), $url)))
568
- if (($url = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
569
- if (($url = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["payer_email"])), $url)))
570
- if (($url = preg_replace ("/%%modification%%/i", ws_plugin__s2member_esc_ds (urlencode ((int)$modifying)), $url)))
571
- /* The modification variable indicates whether this was a modification, or a new signup. */
572
- if (($url = trim ($url))) /* Empty? */
573
- $paypal["proxy_return_url"] = $url;
574
- /**/
575
- $paypal["s2member_log"][] = "Subscr. Return ( modification=" . (int)$modifying . " ), a Proxy Return URL is ready.";
576
- }
577
- /**/
578
- if ($processing && preg_match ("/^web_accept$/i", $paypal["txn_type"]) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
579
- {
580
- foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url)
581
- /**/
582
- if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["subscr_id"])), $url)))
583
- if (($url = preg_replace ("/%%subscr_payment%%/i", ws_plugin__s2member_esc_ds (urlencode ("0")), $url)) && ($url = preg_replace ("/%%subscr_payment_user_id%%/i", ws_plugin__s2member_esc_ds (urlencode ("")), $url)))
584
- if (($url = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["txn_id"])), $url)))
585
- if (($url = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_name"])), $url)))
586
- if (($url = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["last_name"])), $url)))
587
- if (($url = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
588
- if (($url = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["payer_email"])), $url)))
589
- /**/
590
- if (($url = trim ($url))) /* Empty? */
591
- ws_plugin__s2member_remote ($url);
592
- /**/
593
- $paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
594
- }
595
- /**/
596
- if ($processing && preg_match ("/^web_accept$/i", $paypal["txn_type"]) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
597
- {
598
- $msg = $sbj = "( s2Member / API Notification Email ) - Payment";
599
- $msg .= "\n\n"; /* Spacing in the message body. */
600
- $msg .= "subscr_id: %%subscr_id%%\n";
601
- $msg .= "subscr_payment: %%subscr_payment%%\n";
602
- $msg .= "subscr_payment_user_id: %%subscr_payment_user_id%%\n";
603
- $msg .= "amount: %%amount%%\n";
604
- $msg .= "txn_id: %%txn_id%%\n";
605
- $msg .= "item_number: %%item_number%%\n";
606
- $msg .= "item_name: %%item_name%%\n";
607
- $msg .= "first_name: %%first_name%%\n";
608
- $msg .= "last_name: %%last_name%%\n";
609
- $msg .= "full_name: %%full_name%%\n";
610
- $msg .= "payer_email: %%payer_email%%\n";
611
- $msg .= "cv0: %%cv0%%\n";
612
- $msg .= "cv1: %%cv1%%\n";
613
- $msg .= "cv2: %%cv2%%\n";
614
- $msg .= "cv3: %%cv3%%\n";
615
- $msg .= "cv4: %%cv4%%\n";
616
- $msg .= "cv5: %%cv5%%\n";
617
- $msg .= "cv6: %%cv6%%\n";
618
- $msg .= "cv7: %%cv7%%\n";
619
- $msg .= "cv8: %%cv8%%\n";
620
- $msg .= "cv9: %%cv9%%";
621
- /**/
622
- if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $msg)))
623
- if (($msg = preg_replace ("/%%subscr_payment%%/i", ws_plugin__s2member_esc_ds ("0"), $msg)) && ($msg = preg_replace ("/%%subscr_payment_user_id%%/i", ws_plugin__s2member_esc_ds (""), $msg)))
624
- if (($msg = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $msg)) && ($msg = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["txn_id"]), $msg)))
625
- if (($msg = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $msg)))
626
- if (($msg = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $msg)))
627
- if (($msg = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
628
- if (($msg = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $msg)))
629
- /**/
630
- foreach (ws_plugin__s2member_trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"])) as $recipient)
631
- /**/
632
- ($recipient) ? mail ($recipient, $sbj, apply_filters ("ws_plugin__s2member_payment_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
633
- /**/
634
- $paypal["s2member_log"][] = "Payment Notification Emails have been processed.";
635
- }
636
- /**/
637
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
638
- do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_signup", get_defined_vars ());
639
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
640
- }
641
- /*
642
- Recurring payment profile creation.
643
- This is not really necessary. It is only here because this txn_type could
644
- be necessary in a future release of s2Member. For now, it's just a fill-in.
645
- These Hooks/Filters will remain, so you can use them now; if you need to.
646
- */
647
- else if (/**/preg_match ("/^recurring_payment_profile_created$/i", $paypal["txn_type"])/**/
648
- && ($paypal["item_number"] || ($paypal["item_number"] = ws_plugin__s2member_paypal_pro_item_number ($paypal)))/**/
649
- && preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])/**/
650
- && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["recurring_payment_id"]))/**/
651
- && ($paypal["item_name"] || ($paypal["item_name"] = $paypal["product_name"]))/**/)
652
- /* "payer_email" is not passed in `recurring_payment_profile_created` ?? */
653
- {
654
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
655
- do_action ("ws_plugin__s2member_during_paypal_notify_before_recurring_payment_profile_created", get_defined_vars ());
656
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
657
- /**/
658
- $paypal["s2member_log"][] = "s2Member txn_type identified as recurring_payment_profile_created.";
659
- /**/
660
- $processing = $during = true; /* Yes, we ARE processing this. */
661
- /**/
662
- $paypal["s2member_log"][] = "The txn_type does not require any action on the part of s2Member.";
663
- $paypal["s2member_log"][] = "s2Member Pro handles this event on-site, with an IPN proxy.";
664
- /**/
665
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
666
- do_action ("ws_plugin__s2member_during_paypal_notify_during_recurring_payment_profile_created", get_defined_vars ());
667
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
668
- /**/
669
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
670
- do_action ("ws_plugin__s2member_during_paypal_notify_after_recurring_payment_profile_created", get_defined_vars ());
671
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
672
- }
673
- /*
674
- Subscription modifications.
675
- */
676
- else if (/**/preg_match ("/^subscr_modify$/i", $paypal["txn_type"])/**/
677
- && preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])/**/
678
- && $paypal["subscr_id"] && $paypal["payer_email"]/**/)
679
- {
680
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
681
- do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_modify", get_defined_vars ());
682
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
683
- /**/
684
- $paypal["s2member_log"][] = "s2Member txn_type identified as subscr_modify.";
685
- /**/
686
- list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
687
- /**/
688
- if (($user_id = ws_plugin__s2member_paypal_user_id ($paypal["subscr_id"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
689
- {
690
- if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
691
- {
692
- $processing = $modifying = $during = true; /* Yes, we ARE processing this. */
693
- /**/
694
- $user->set_role ("s2member_level" . $paypal["level"]);
695
- /**/
696
- foreach ($user->allcaps as $cap => $cap_enabled)
697
- if (preg_match ("/^access_s2member_ccap_/", $cap))
698
- $user->remove_cap ($ccap = $cap);
699
- /**/
700
- foreach (preg_split ("/[\r\n\t\s;,]+/", $paypal["ccaps"]) as $ccap)
701
- if (strlen ($ccap)) /* Don't add empty capabilities. */
702
- $user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
703
- /**/
704
- update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
705
- update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
706
- /**/
707
- delete_user_option ($user_id, "s2member_file_download_access_arc");
708
- delete_user_option ($user_id, "s2member_file_download_access_log");
709
- /**/
710
- delete_user_option ($user_id, "s2member_auto_eot_time");
711
- /**/
712
- ws_plugin__s2member_clear_user_note_lines ($user_id, "/^Demoted by s2Member\:/");
713
- /**/
714
- $paypal["s2member_log"][] = "s2Member Level/Capabilities updated on Subscription modification.";
715
- /**/
716
- mail ($paypal["payer_email"], "Thank You! Your membership has been updated.", "Thank You! Your membership has been updated to:\n" . $paypal["item_name"] . "\n\nYou'll need to log back in now.\n" . wp_login_url (), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8");
717
- /**/
718
- $paypal["s2member_log"][] = "Modification Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.";
719
- /**/
720
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
721
- do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_modify", get_defined_vars ());
722
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
723
- }
724
- else
725
- {
726
- $paypal["s2member_log"][] = "Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
727
- }
728
- }
729
- else
730
- {
731
- $paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB.";
732
- }
733
- /**/
734
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
735
- do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_modify", get_defined_vars ());
736
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
737
- }
738
- /*
739
- Subscription payment notifications.
740
- We need these to update: `s2member_last_payment_time`.
741
- */
742
- else if (/**/preg_match ("/^(subscr_payment|recurring_payment)$/i", $paypal["txn_type"])/**/
743
- && ($paypal["item_number"] || ($paypal["item_number"] = ws_plugin__s2member_paypal_pro_item_number ($paypal)))/**/
744
- && preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])/**/
745
- && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["recurring_payment_id"]))/**/
746
- && !preg_match ($payment_status_issues, $paypal["payment_status"]) /* Status OK? */
747
- && ($paypal["item_name"] || ($paypal["item_name"] = $paypal["product_name"]))/**/
748
- && $paypal["payer_email"] && $paypal["txn_id"] && $paypal["mc_gross"]/**/)
749
- {
750
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
751
- do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_payment", get_defined_vars ());
752
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
753
- /**/
754
- $paypal["s2member_log"][] = "s2Member txn_type identified as subscr_payment|recurring_payment.";
755
- $paypal["s2member_log"][] = "Sleeping for 2 seconds. Waiting for a possible subscr_signup|subscr_modify|recurring_payment_profile_created.";
756
- sleep (2); /* Sleep here for a moment. PayPal® sometimes sends a subscr_payment before the subscr_signup, subscr_modify.
757
- It is NOT a big deal if they do. However, s2Member goes to sleep here, just to help keep the log files in a logical order. */
758
- $paypal["s2member_log"][] = "Awake. It's " . date ("D M j, Y g:i:s a T") . ". s2Member txn_type identified as subscr_payment|recurring_payment.";
759
- /**/
760
- list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
761
- /**/
762
- if (($user_id = ws_plugin__s2member_paypal_user_id ($paypal["subscr_id"], $paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
763
- {
764
- $processing = $during = true; /* Yes, we ARE processing this. */
765
- /**/
766
- update_user_option ($user_id, "s2member_last_payment_time", time ());
767
- /**/
768
- $paypal["s2member_log"][] = "Updated Last Payment Time for this Member.";
769
- /**/
770
- if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
771
- {
772
- foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url)
773
- /**/
774
- if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["subscr_id"])), $url)))
775
- if (($url = preg_replace ("/%%subscr_payment%%/i", ws_plugin__s2member_esc_ds (urlencode ("1")), $url)) && ($url = preg_replace ("/%%subscr_payment_user_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($user_id)), $url)))
776
- if (($url = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["txn_id"])), $url)))
777
- if (($url = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_name"])), $url)))
778
- if (($url = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["last_name"])), $url)))
779
- if (($url = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
780
- if (($url = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["payer_email"])), $url)))
781
- /**/
782
- if (($url = trim ($url))) /* Empty? */
783
- ws_plugin__s2member_remote ($url);
784
- /**/
785
- $paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
786
- }
787
- /**/
788
- if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
789
- {
790
- $msg = $sbj = "( s2Member / API Notification Email ) - Payment";
791
- $msg .= "\n\n"; /* Spacing in the message body. */
792
- $msg .= "subscr_id: %%subscr_id%%\n";
793
- $msg .= "subscr_payment: %%subscr_payment%%\n";
794
- $msg .= "subscr_payment_user_id: %%subscr_payment_user_id%%\n";
795
- $msg .= "amount: %%amount%%\n";
796
- $msg .= "txn_id: %%txn_id%%\n";
797
- $msg .= "item_number: %%item_number%%\n";
798
- $msg .= "item_name: %%item_name%%\n";
799
- $msg .= "first_name: %%first_name%%\n";
800
- $msg .= "last_name: %%last_name%%\n";
801
- $msg .= "full_name: %%full_name%%\n";
802
- $msg .= "payer_email: %%payer_email%%\n";
803
- $msg .= "cv0: %%cv0%%\n";
804
- $msg .= "cv1: %%cv1%%\n";
805
- $msg .= "cv2: %%cv2%%\n";
806
- $msg .= "cv3: %%cv3%%\n";
807
- $msg .= "cv4: %%cv4%%\n";
808
- $msg .= "cv5: %%cv5%%\n";
809
- $msg .= "cv6: %%cv6%%\n";
810
- $msg .= "cv7: %%cv7%%\n";
811
- $msg .= "cv8: %%cv8%%\n";
812
- $msg .= "cv9: %%cv9%%";
813
- /**/
814
- if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $msg)))
815
- if (($msg = preg_replace ("/%%subscr_payment%%/i", ws_plugin__s2member_esc_ds ("1"), $msg)) && ($msg = preg_replace ("/%%subscr_payment_user_id%%/i", ws_plugin__s2member_esc_ds ($user_id), $msg)))
816
- if (($msg = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $msg)) && ($msg = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["txn_id"]), $msg)))
817
- if (($msg = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $msg)))
818
- if (($msg = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $msg)))
819
- if (($msg = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
820
- if (($msg = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $msg)))
821
- /**/
822
- foreach (ws_plugin__s2member_trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"])) as $recipient)
823
- /**/
824
- ($recipient) ? mail ($recipient, $sbj, apply_filters ("ws_plugin__s2member_payment_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
825
- /**/
826
- $paypal["s2member_log"][] = "Payment Notification Emails have been processed.";
827
- }
828
- /**/
829
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
830
- do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_payment", get_defined_vars ());
831
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
832
- }
833
- else
834
- {
835
- $paypal["s2member_log"][] = "Skipping this IPN response, for now. The Subscr. ID is not associated with a registered Member.";
836
- $paypal["s2member_log"][] = "Storing this IPN response into a Transient Queue for s2Member. This will be re-processed when registration occurs.";
837
- set_transient (md5 ("s2member_transient_ipn_subscr_payment_" . $paypal["subscr_id"]), $_POST, 43200);
838
- }
839
- /**/
840
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
841
- do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_payment", get_defined_vars ());
842
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
843
- }
844
- /*
845
- Subscription failed payment notifications.
846
- This is not really necessary. It is only here because this txn_type could
847
- be necessary in a future release of s2Member. For now, it's just a fill-in.
848
- These Hooks/Filters will remain, so you can use them now; if you need to.
849
- */
850
- else if (/**/preg_match ("/^(subscr_failed|recurring_payment_failed|recurring_payment_skipped)$/i", $paypal["txn_type"])/**/
851
- && ($paypal["item_number"] || ($paypal["item_number"] = ws_plugin__s2member_paypal_pro_item_number ($paypal)))/**/
852
- && preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])/**/
853
- && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["recurring_payment_id"]))/**/
854
- && ($paypal["item_name"] || ($paypal["item_name"] = $paypal["product_name"]))/**/
855
- && $paypal["payer_email"]/**/)
856
- {
857
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
858
- do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_failed", get_defined_vars ());
859
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
860
- /**/
861
- $paypal["s2member_log"][] = "s2Member txn_type identified as subscr_failed|recurring_payment_failed|recurring_payment_skipped.";
862
- /**/
863
- $processing = $during = true; /* Yes, we ARE processing this. */
864
- /**/
865
- $paypal["s2member_log"][] = "This txn_type does not require any action on the part of s2Member.";
866
- $paypal["s2member_log"][] = "s2Member does NOT respond to individual failed payments, only multiple consecutive failed payments.";
867
- $paypal["s2member_log"][] = "When multiple consecutive payments fail, a special IPN response will be triggered.";
868
- /**/
869
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
870
- do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_failed", get_defined_vars ());
871
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
872
- /**/
873
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
874
- do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_failed", get_defined_vars ());
875
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
876
- }
877
- /*
878
- Subscription cancellations. s2Member can use this, to determine when/if it should Auto-EOT (demote|delete) a Member's account.
879
- The IPN for `subscr_cancel` is compatible with newer PayPal® accounts that do NOT send a subscr_eot when an account is cancelled.
880
- This works in conjunction with `s2member_last_payment_time`, and the s2Member Auto-EOT System.
881
- For further details & examples of stupidity, see: https://www.x.com/thread/41155?start=15&tstart=0
882
- */
883
- else if (/**/preg_match ("/^(subscr_cancel|recurring_payment_profile_cancel)$/i", $paypal["txn_type"])/**/
884
- && !(preg_match ("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]) && preg_match ("/^failed$/i", $paypal["initial_payment_status"]))/**/
885
- && ($paypal["item_number"] || ($paypal["item_number"] = ws_plugin__s2member_paypal_pro_item_number ($paypal)))/**/
886
- && preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])/**/
887
- && ($paypal["period1"] || ($paypal["period1"] = ws_plugin__s2member_paypal_pro_period1 ($paypal)))/**/
888
- && ($paypal["period3"] || ($paypal["period3"] = ws_plugin__s2member_paypal_pro_period3 ($paypal)))/**/
889
- && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["recurring_payment_id"]))/**/
890
- && $paypal["payer_email"]/**/)
891
- {
892
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
893
- do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_cancel", get_defined_vars ());
894
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
895
- /**/
896
- $paypal["s2member_log"][] = "s2Member txn_type identified as subscr_cancel|recurring_payment_profile_cancel.";
897
- /**/
898
- list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
899
- /**/
900
- if (($user_id = ws_plugin__s2member_paypal_user_id ($paypal["subscr_id"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
901
- {
902
- if (!get_user_option ("s2member_auto_eot_time", $user_id)) /* Respect existing. */
903
- {
904
- $processing = $during = true; /* Yes, we ARE processing this. */
905
- /**/
906
- $auto_eot_time = ws_plugin__s2member_paypal_auto_eot_time ($user_id, $paypal["period1"], $paypal["period3"]);
907
- /**/
908
- update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time); /* s2Member will follow-up on this later. */
909
- /**/
910
- $paypal["s2member_log"][] = "Auto-EOT Time for this account: " . date ("D M j, Y g:i a T", $auto_eot_time);
911
- /**/
912
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
913
- do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_cancel", get_defined_vars ());
914
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
915
- }
916
- else
917
- {
918
- $paypal["s2member_log"][] = "Ignoring Cancellation. An Auto-EOT Time is already set for this Member. An s2Member API Notification will still be processed however.";
919
- }
920
- /**/
921
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
922
- {
923
- foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_urls"]) as $url) /* Handle Cancellation Notifications. */
924
- /**/
925
- if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["subscr_id"])), $url)))
926
- if (($url = preg_replace ("/%%user_first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->first_name)), $url)) && ($url = preg_replace ("/%%user_last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->last_name)), $url)))
927
- if (($url = preg_replace ("/%%user_full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
928
- if (($url = preg_replace ("/%%user_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->user_email)), $url)))
929
- if (($url = preg_replace ("/%%user_login%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->user_login)), $url)))
930
- if (($url = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($user_id)), $url)))
931
- /**/
932
- if (($url = trim ($url))) /* Empty? */
933
- ws_plugin__s2member_remote ($url);
934
- /**/
935
- $paypal["s2member_log"][] = "Cancellation Notification URLs have been processed.";
936
- }
937
- /**/
938
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
939
- {
940
- $msg = $sbj = "( s2Member / API Notification Email ) - Cancellation";
941
- $msg .= "\n\n"; /* Spacing in the message body. */
942
- $msg .= "subscr_id: %%subscr_id%%\n";
943
- $msg .= "user_first_name: %%user_first_name%%\n";
944
- $msg .= "user_last_name: %%user_last_name%%\n";
945
- $msg .= "user_full_name: %%user_full_name%%\n";
946
- $msg .= "user_email: %%user_email%%\n";
947
- $msg .= "user_login: %%user_login%%\n";
948
- $msg .= "user_id: %%user_id%%\n";
949
- $msg .= "cv0: %%cv0%%\n";
950
- $msg .= "cv1: %%cv1%%\n";
951
- $msg .= "cv2: %%cv2%%\n";
952
- $msg .= "cv3: %%cv3%%\n";
953
- $msg .= "cv4: %%cv4%%\n";
954
- $msg .= "cv5: %%cv5%%\n";
955
- $msg .= "cv6: %%cv6%%\n";
956
- $msg .= "cv7: %%cv7%%\n";
957
- $msg .= "cv8: %%cv8%%\n";
958
- $msg .= "cv9: %%cv9%%";
959
- /**/
960
- if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $msg)))
961
- if (($msg = preg_replace ("/%%user_first_name%%/i", ws_plugin__s2member_esc_ds ($user->first_name), $msg)) && ($msg = preg_replace ("/%%user_last_name%%/i", ws_plugin__s2member_esc_ds ($user->last_name), $msg)))
962
- if (($msg = preg_replace ("/%%user_full_name%%/i", ws_plugin__s2member_esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
963
- if (($msg = preg_replace ("/%%user_email%%/i", ws_plugin__s2member_esc_ds ($user->user_email), $msg)))
964
- if (($msg = preg_replace ("/%%user_login%%/i", ws_plugin__s2member_esc_ds ($user->user_login), $msg)))
965
- if (($msg = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds ($user_id), $msg)))
966
- /**/
967
- foreach (ws_plugin__s2member_trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_recipients"])) as $recipient)
968
- /**/
969
- ($recipient) ? mail ($recipient, $sbj, apply_filters ("ws_plugin__s2member_cancellation_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
970
- /**/
971
- $paypal["s2member_log"][] = "Cancellation Notification Emails have been processed.";
972
- }
973
- }
974
- else
975
- {
976
- $paypal["s2member_log"][] = "Unable to handle Cancellation. Could not get the existing User ID from the DB.";
977
- }
978
- /**/
979
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
980
- do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_cancel", get_defined_vars ());
981
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
982
- }
983
- /*
984
- Subscription terminations, max failed payments, initial payment failed, chargebacks, refunds, and reversals.
985
- An immediate EOT is necessary under MANY different conditions. This consolidates them all, with a sub-classification for refunds/reversals.
986
- */
987
- else if (/**/(/**/preg_match ("/^(subscr_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment)$/i", $paypal["txn_type"])/**/
988
- || (preg_match ("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]) && preg_match ("/^failed$/i", $paypal["initial_payment_status"]))/**/
989
- || (preg_match ("/^new_case$/i", $paypal["txn_type"]) && preg_match ("/^chargeback$/i", $paypal["case_type"]))/**/
990
- || (!$paypal["txn_type"] && preg_match ("/^(refunded|reversed)$/i", $paypal["payment_status"]))/**/)/**/
991
- && ($paypal["item_number"] || ($paypal["item_number"] = ws_plugin__s2member_paypal_pro_item_number ($paypal)))/**/
992
- && preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])/**/
993
- && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["recurring_payment_id"]) || ($paypal["subscr_id"] = $paypal["parent_txn_id"]))/**/)
994
- {
995
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
996
- do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_eot", get_defined_vars ());
997
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
998
- /**/
999
- $is_refund = (!$paypal["txn_type"] && preg_match ("/^refunded$/i", $paypal["payment_status"]) && $paypal["parent_txn_id"]);
1000
- $is_reversal = (!$paypal["txn_type"] && preg_match ("/^reversed$/i", $paypal["payment_status"]) && $paypal["parent_txn_id"]);
1001
- $is_refund_or_reversal = (!$paypal["txn_type"] && preg_match ("/^(refunded|reversed)$/i", $paypal["payment_status"]) && $paypal["parent_txn_id"]);
1002
- /**/
1003
- $paypal["s2member_log"][] = "s2Member txn_type identified as (subscr_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment) - or - recurring_payment_profile_cancel w/ initial_payment_status (failed) - or - new_case w/ case_type (chargeback) - or - !txn_type w/ payment_status (refunded|reversed).";
1004
- /**/
1005
- if (($user_id = ws_plugin__s2member_paypal_user_id ($paypal["subscr_id"], $paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
1006
- {
1007
- if ( /* Here we take action, but based on some advanced behavioral settings. */
1008
- (!$is_refund_or_reversal && !get_user_option ("s2member_auto_eot_time", $user_id))/**/
1009
- || ($is_refund_or_reversal && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "refunds,reversals")/**/
1010
- || ($is_reversal && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "reversals")/**/
1011
- || ($is_refund && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "refunds")/**/)
1012
- {
1013
- if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
1014
- {
1015
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"]) /* EOT enabled? */
1016
- {
1017
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote")
1018
- {
1019
- $processing = $during = true; /* Yes, we ARE processing this. */
1020
- /**/
1021
- $demotion_role = ws_plugin__s2member_force_demotion_role ("subscriber");
1022
- $user->set_role ($demotion_role); /* Defaults to Free Subscriber. */
1023
- /**/
1024
- foreach ($user->allcaps as $cap => $cap_enabled)
1025
- if (preg_match ("/^access_s2member_ccap_/", $cap))
1026
- $user->remove_cap ($ccap = $cap);
1027
- /**/
1028
- delete_user_option ($user_id, "s2member_custom");
1029
- delete_user_option ($user_id, "s2member_subscr_id");
1030
- delete_user_option ($user_id, "s2member_last_payment_time");
1031
- delete_user_option ($user_id, "s2member_auto_eot_time");
1032
- /**/
1033
- delete_user_option ($user_id, "s2member_file_download_access_arc");
1034
- delete_user_option ($user_id, "s2member_file_download_access_log");
1035
- /**/
1036
- ws_plugin__s2member_append_user_notes ($user_id, "Demoted by s2Member: " . date ("D M j, Y g:i a T"));
1037
- /**/
1038
- $paypal["s2member_log"][] = "Member Level/Capabilities demoted to: " . ucwords (preg_replace ("/_/", " ", $demotion_role)) . ".";
1039
- /**/
1040
- if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
1041
- {
1042
- foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"]) as $url) /* Handle EOT Notifications. */
1043
- /**/
1044
- if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["subscr_id"])), $url)))
1045
- if (($url = preg_replace ("/%%user_first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->first_name)), $url)) && ($url = preg_replace ("/%%user_last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->last_name)), $url)))
1046
- if (($url = preg_replace ("/%%user_full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
1047
- if (($url = preg_replace ("/%%user_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->user_email)), $url)))
1048
- if (($url = preg_replace ("/%%user_login%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->user_login)), $url)))
1049
- if (($url = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($user_id)), $url)))
1050
- /**/
1051
- if (($url = trim ($url))) /* Empty? */
1052
- ws_plugin__s2member_remote ($url);
1053
- /**/
1054
- $paypal["s2member_log"][] = "EOT/Deletion Notification URLs have been processed.";
1055
- }
1056
- /**/
1057
- if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
1058
- {
1059
- $msg = $sbj = "( s2Member / API Notification Email ) - EOT/Deletion";
1060
- $msg .= "\n\n"; /* Spacing in the message body. */
1061
- $msg .= "subscr_id: %%subscr_id%%\n";
1062
- $msg .= "user_first_name: %%user_first_name%%\n";
1063
- $msg .= "user_last_name: %%user_last_name%%\n";
1064
- $msg .= "user_full_name: %%user_full_name%%\n";
1065
- $msg .= "user_email: %%user_email%%\n";
1066
- $msg .= "user_login: %%user_login%%\n";
1067
- $msg .= "user_id: %%user_id%%\n";
1068
- $msg .= "cv0: %%cv0%%\n";
1069
- $msg .= "cv1: %%cv1%%\n";
1070
- $msg .= "cv2: %%cv2%%\n";
1071
- $msg .= "cv3: %%cv3%%\n";
1072
- $msg .= "cv4: %%cv4%%\n";
1073
- $msg .= "cv5: %%cv5%%\n";
1074
- $msg .= "cv6: %%cv6%%\n";
1075
- $msg .= "cv7: %%cv7%%\n";
1076
- $msg .= "cv8: %%cv8%%\n";
1077
- $msg .= "cv9: %%cv9%%";
1078
- /**/
1079
- if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $msg)))
1080
- if (($msg = preg_replace ("/%%user_first_name%%/i", ws_plugin__s2member_esc_ds ($user->first_name), $msg)) && ($msg = preg_replace ("/%%user_last_name%%/i", ws_plugin__s2member_esc_ds ($user->last_name), $msg)))
1081
- if (($msg = preg_replace ("/%%user_full_name%%/i", ws_plugin__s2member_esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
1082
- if (($msg = preg_replace ("/%%user_email%%/i", ws_plugin__s2member_esc_ds ($user->user_email), $msg)))
1083
- if (($msg = preg_replace ("/%%user_login%%/i", ws_plugin__s2member_esc_ds ($user->user_login), $msg)))
1084
- if (($msg = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds ($user_id), $msg)))
1085
- /**/
1086
- foreach (ws_plugin__s2member_trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"])) as $recipient)
1087
- /**/
1088
- ($recipient) ? mail ($recipient, $sbj, apply_filters ("ws_plugin__s2member_eot_del_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
1089
- /**/
1090
- $paypal["s2member_log"][] = "EOT/Deletion Notification Emails have been processed.";
1091
- }
1092
- /**/
1093
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1094
- do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_demote", get_defined_vars ());
1095
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
1096
- }
1097
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete")
1098
- {
1099
- $processing = $during = true; /* Yes, we ARE processing this. */
1100
- /**/
1101
- if (is_multisite ()) /* Multisite does NOT actually delete; ONLY removes. */
1102
- {
1103
- remove_user_from_blog ($user_id, $current_blog->blog_id);
1104
- /* This will automatically trigger `eot_del_notification_urls` as well. */
1105
- ws_plugin__s2member_handle_ms_user_deletions ($user_id, $current_blog->blog_id, "s2says");
1106
- }
1107
- /**/
1108
- else /* Otherwise, we can actually delete them. */
1109
- /* This will automatically trigger `eot_del_notification_urls` as well. */
1110
- wp_delete_user ($user_id); /* `ws_plugin__s2member_handle_user_deletions()` */
1111
- /**/
1112
- $paypal["s2member_log"][] = "This Member's account has been " . ((is_multisite ()) ? "removed" : "deleted") . ".";
1113
- /**/
1114
- $paypal["s2member_log"][] = "EOT/Deletion Notification URLs have been processed.";
1115
- /**/
1116
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1117
- do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_delete", get_defined_vars ());
1118
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
1119
- }
1120
- /**/
1121
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1122
- do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot", get_defined_vars ());
1123
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
1124
- }
1125
- /**/
1126
- else /* Otherwise, treat this as if it were a cancellation. EOTs are currently disabled. */
1127
- {
1128
- $processing = $during = true; /* Yes, we ARE processing this. */
1129
- /**/
1130
- update_user_option ($user_id, "s2member_auto_eot_time", ($auto_eot_time = strtotime ("now")));
1131
- /**/
1132
- $paypal["s2member_log"][] = "Auto-EOT is currently disabled. Skipping immediate EOT (demote|delete), for now.";
1133
- $paypal["s2member_log"][] = "Recording the Auto-EOT Time for this Member's account: " . date ("D M j, Y g:i a T", $auto_eot_time);
1134
- /**/
1135
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1136
- do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_disabled", get_defined_vars ());
1137
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
1138
- }
1139
- }
1140
- else
1141
- {
1142
- $paypal["s2member_log"][] = "Unable to (demote|delete) Member. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
1143
- }
1144
- }
1145
- else if (!$is_refund_or_reversal)
1146
- {
1147
- $paypal["s2member_log"][] = "Skipping (demote|delete) Member, for now. An Auto-EOT Time is already set for this account. When an Auto-EOT Time has been recorded, s2Member will handle EOT (demote|delete) events using it's own Auto-EOT System - internally.";
1148
- }
1149
- else if ($is_reversal)
1150
- {
1151
- $paypal["s2member_log"][] = "Skipping (demote|delete) Member. Your configuration dictates that s2Member should NOT take any immediate action on an EOT associated with a Chargeback Reversal. An s2Member API Notification will still be processed however.";
1152
- }
1153
- else if ($is_refund)
1154
- {
1155
- $paypal["s2member_log"][] = "Skipping (demote|delete) Member. Your configuration dictates that s2Member should NOT take any immediate action on an EOT associated with a Refund. An s2Member API Notification will still be processed however.";
1156
- }
1157
- }
1158
- else
1159
- {
1160
- $paypal["s2member_log"][] = "Unable to (demote|delete) Member. Could not get the existing User ID from the DB. It's possible that it was already removed manually by a Site Administrator, or by s2Member's Auto-EOT System.";
1161
- }
1162
- /*
1163
- Refunds and chargeback reversals. This is excluded from the processing check, because a Member *could* have already been (demoted|deleted).
1164
- In other words, s2Member sends `Refund/Reversal` Notifications ANYTIME a Refund/Reversal occurs; even if s2Member did not process it otherwise.
1165
- Since this routine ignores the processing check, it is *possible* that Refund/Reversal Notification URLs will be contacted more than once.
1166
- If you're writing scripts that depend on Refund/Reversal Notifications, please keep this in mind.
1167
- */
1168
- if ($is_refund_or_reversal) /* Here we access this variable that was previously assigned as a quick method of Refund/Reversal detection. */
1169
- {
1170
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
1171
- {
1172
- foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"]) as $url)
1173
- /**/
1174
- if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["subscr_id"])), $url)) && ($url = preg_replace ("/%%parent_txn_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["parent_txn_id"])), $url)))
1175
- if (($url = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_name"])), $url)))
1176
- if (($url = preg_replace ("/%%-amount%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%-fee%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["mc_fee"])), $url)))
1177
- if (($url = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["last_name"])), $url)))
1178
- if (($url = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
1179
- if (($url = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["payer_email"])), $url)))
1180
- if (($url = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($user_id)), $url)))
1181
- /**/
1182
- if (($url = trim ($url))) /* Empty? */
1183
- ws_plugin__s2member_remote ($url);
1184
- /**/
1185
- $paypal["s2member_log"][] = "Refund/Reversal Notification URLs have been processed.";
1186
- }
1187
- /**/
1188
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
1189
- {
1190
- $msg = $sbj = "( s2Member / API Notification Email ) - Refund/Reversal";
1191
- $msg .= "\n\n"; /* Spacing in the message body. */
1192
- $msg .= "subscr_id: %%subscr_id%%\n";
1193
- $msg .= "parent_txn_id: %%parent_txn_id%%\n";
1194
- $msg .= "item_number: %%item_number%%\n";
1195
- $msg .= "item_name: %%item_name%%\n";
1196
- $msg .= "-amount: %%-amount%%\n";
1197
- $msg .= "-fee: %%-fee%%\n";
1198
- $msg .= "first_name: %%first_name%%\n";
1199
- $msg .= "last_name: %%last_name%%\n";
1200
- $msg .= "full_name: %%full_name%%\n";
1201
- $msg .= "payer_email: %%payer_email%%\n";
1202
- $msg .= "user_id: %%user_id%%\n";
1203
- $msg .= "cv0: %%cv0%%\n";
1204
- $msg .= "cv1: %%cv1%%\n";
1205
- $msg .= "cv2: %%cv2%%\n";
1206
- $msg .= "cv3: %%cv3%%\n";
1207
- $msg .= "cv4: %%cv4%%\n";
1208
- $msg .= "cv5: %%cv5%%\n";
1209
- $msg .= "cv6: %%cv6%%\n";
1210
- $msg .= "cv7: %%cv7%%\n";
1211
- $msg .= "cv8: %%cv8%%\n";
1212
- $msg .= "cv9: %%cv9%%";
1213
- /**/
1214
- if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $msg)) && ($msg = preg_replace ("/%%parent_txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["parent_txn_id"]), $msg)))
1215
- if (($msg = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $msg)))
1216
- if (($msg = preg_replace ("/%%-amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $msg)) && ($msg = preg_replace ("/%%-fee%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_fee"]), $msg)))
1217
- if (($msg = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $msg)))
1218
- if (($msg = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
1219
- if (($msg = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $msg)))
1220
- if (($msg = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds ($user_id), $msg)))
1221
- /**/
1222
- foreach (ws_plugin__s2member_trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_recipients"])) as $recipient)
1223
- /**/
1224
- ($recipient) ? mail ($recipient, $sbj, apply_filters ("ws_plugin__s2member_ref_rev_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
1225
- /**/
1226
- $paypal["s2member_log"][] = "Refund/Reversal Notification Emails have been processed.";
1227
- }
1228
- /**/
1229
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1230
- do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_refund_reversal", get_defined_vars ());
1231
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
1232
- }
1233
- /**/
1234
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1235
- do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_eot", get_defined_vars ());
1236
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
1237
- }
1238
- else
1239
- {
1240
- $paypal["s2member_log"][] = "Ignoring this IPN request. The txn_type/status does not require any action on the part of s2Member.";
1241
- }
1242
- }
1243
- else /* Else a custom conditional has been applied by filters. */
1244
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
1245
- }
1246
- /*
1247
- Else, check on cancelled recurring profiles.
1248
- */
1249
- else if (preg_match ("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]))
1250
- {
1251
- $paypal["s2member_log"][] = "Transaction type ( recurring_payment_profile_cancel ), but there is no match to an existing account; so verification of _SERVER[HTTP_HOST] was not possible.";
1252
- $paypal["s2member_log"][] = "It's likely this account was just upgraded/downgraded by s2Member Pro; so the Subscr. ID has probably been updated on-site; nothing to worry about here.";
1253
- }
1254
- /*
1255
- Else, check on other ^recurring_ transaction types.
1256
- */
1257
- else if (preg_match ("/^recurring_/i", $paypal["txn_type"])) /* Otherwise, is this a ^recurring_ txn_type? */
1258
- {
1259
- $paypal["s2member_log"][] = "Transaction type ( ^recurring_? ), but there is no match to an existing account; so verification of _SERVER[HTTP_HOST] was not possible.";
1260
- }
1261
- /**/
1262
- else /* Else, use the default _SERVER[HTTP_HOST] error. */
1263
- $paypal["s2member_log"][] = "Unable to verify _SERVER[HTTP_HOST]. Possibly caused by a fraudulent request. If this error continues, please check the `custom` value in your Form and/or Button Code. It MUST always start with your domain name.";
1264
- }
1265
- /*
1266
- Otherwise, POST vars could not even be verified. This needs to be reported in the logs.
1267
- */
1268
- else /* Extensive log reporting here. This is an area where many site owners find trouble. Depending on server configuration; remote HTTPS connections may fail. */
1269
- {
1270
- $paypal["s2member_log"][] = "Unable to verify POST vars. Possibly caused by a fraudulent request. If this error continues, please run IPN tests against your server from a PayPal® Sandbox account. They provide special diagnostic tools to assist you.";
1271
- $paypal["s2member_log"][] = "If you're absolutely SURE that your PayPal® configuration is valid, you may want to run some tests on your server, just to be sure \$_POST variables are populated, and that your server is able to connect to PayPal® over an HTTPS connection.";
1272
- $paypal["s2member_log"][] = "s2Member uses the WP_Http class for remote connections; which will try to use cURL first, and then fall back on the FOPEN method when cURL is not available. On a Windows® server, you may have to disable your cURL extension. Instead, set allow_url_fopen = yes in your php.ini file. The cURL extension (usually) does NOT support SSL connections on a Windows® server.";
1273
- $paypal["s2member_log"][] = var_export ($_POST, true); /* Recording _POST vars for analysis and debugging. */
1274
- }
1275
- /*
1276
- Add IPN proxy identification ( when available ) to the $paypal array for log reporting.
1277
- */
1278
- if ($_GET["s2member_paypal_proxy"]) /* For proxy identification. */
1279
- $paypal["s2member_paypal_proxy"] = $_GET["s2member_paypal_proxy"];
1280
- /*
1281
- Also add IPN proxy self-verification ( when available ) to the $paypal array.
1282
- */
1283
- if ($_GET["s2member_paypal_proxy_verification"]) /* Proxy identification w/verification. */
1284
- $paypal["s2member_paypal_proxy_verification"] = $_GET["s2member_paypal_proxy_verification"];
1285
- /*
1286
- If debugging/logging is enabled; we need to append $paypal to the log file.
1287
- Logging now supports Multisite Networking as well.
1288
- */
1289
- $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
1290
- $log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
1291
- $log2 = (is_multisite () && !is_main_site ()) ? "paypal-ipn-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-ipn.log";
1292
  /**/
1293
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_debug"]) /* Append to log? */
1294
- if (is_dir ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
1295
- if (is_writable ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
1296
- file_put_contents ($logs_dir . "/" . $log2, $log4 . "\n" . var_export ($paypal, true) . "\n\n", FILE_APPEND);
1297
- /**/
1298
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1299
- do_action ("ws_plugin__s2member_during_paypal_notify", get_defined_vars ());
1300
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
1301
- /**/
1302
- exit ($paypal["proxy_return_url"]); /* Return, if/when applicable. */
1303
  }
1304
- /**/
1305
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1306
- do_action ("ws_plugin__s2member_after_paypal_notify", get_defined_vars ());
1307
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
1308
  }
1309
  }
1310
  ?>
16
  /*
17
  Handles PayPal® IPN URL processing.
18
  These same routines also handle s2Member Pro/PayPal® Pro operations;
19
+ giving you the ability ( as needed ) to Hook into these routines using
20
  WordPress® Hooks/Filters; as seen in the source code below.
21
 
22
  Please do NOT modify the source code directly.
31
  {
32
  function ws_plugin__s2member_paypal_notify ()
33
  {
34
+ if ($_GET["s2member_paypal_notify"]) /* Loads separate function handler. */
 
 
 
 
 
 
35
  {
36
+ include_once dirname (__FILE__) . "/separates/paypal-notify.inc.php";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  /**/
38
+ s__ws_plugin__s2member_paypal_notify (); /* Process. */
 
 
 
 
 
 
 
 
 
39
  }
 
 
 
 
40
  }
41
  }
42
  ?>
includes/functions/paypal-return.inc.php CHANGED
@@ -22,425 +22,12 @@ if (!function_exists ("ws_plugin__s2member_paypal_return"))
22
  {
23
  function ws_plugin__s2member_paypal_return ()
24
  {
25
- global $current_site, $current_blog; /* For Multisite support. */
26
- /**/
27
- do_action ("ws_plugin__s2member_before_paypal_return", get_defined_vars ());
28
- /**/
29
- if ($_GET["s2member_paypal_return"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"])
30
  {
31
- if (is_array ($paypal = ws_plugin__s2member_paypal_postvars ())) /* Verify PayPal® POST vars. */
32
- {
33
- $paypal["s2member_log"][] = "Return-Data received on: " . date ("D M j, Y g:i:s a T");
34
- $paypal["s2member_log"][] = "s2Member POST vars verified through a POST back to PayPal®.";
35
- /**/
36
- $payment_status_issues = "/^(failed|denied|expired|refunded|reversed|reversal|canceled_reversal|voided)$/i";
37
- /**/
38
- if (preg_match ("/^" . preg_quote (preg_replace ("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $paypal["custom"]))
39
- { /* The business address validation was removed from this routine, because PayPal® always fills that with the primary
40
- email address. In cases where an alternate PayPal® address is being paid, validation was not possible. */
41
- $paypal["s2member_log"][] = "s2Member originating domain ( _SERVER[HTTP_HOST] ) validated.";
42
- /*
43
- Custom conditionals can be applied by filters.
44
- */
45
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
46
- if (!apply_filters ("ws_plugin__s2member_during_paypal_return_conditionals", false, get_defined_vars ()))
47
- {
48
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
49
- /*
50
- Specific Post/Page Access.
51
- */
52
- if (/**/preg_match ("/^web_accept$/i", $paypal["txn_type"])/**/
53
- && preg_match ("/^sp\:[0-9,]+\:[0-9]+$/", $paypal["item_number"])/**/
54
- && !preg_match ($payment_status_issues, $paypal["payment_status"])/**/
55
- && $paypal["txn_id"]/**/)
56
- {
57
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
58
- do_action ("ws_plugin__s2member_during_paypal_return_before_sp_access", get_defined_vars ());
59
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
60
- /**/
61
- $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept) for Specific Post/Page access.";
62
- /**/
63
- list (, $paypal["sp_ids"], $paypal["hours"]) = preg_split ("/\:/", $paypal["item_number"], 3);
64
- /**/
65
- if (($sp_access_url = ws_plugin__s2member_sp_access_link_gen ($paypal["sp_ids"], $paypal["hours"], false)))
66
- {
67
- $processing = $during = true; /* Yes, we ARE processing this. */
68
- /**/
69
- setcookie ("s2member_sp_tracking", ws_plugin__s2member_encrypt ($paypal["txn_id"]), time () + 31556926, "/");
70
- /**/
71
- $paypal["s2member_log"][] = "Transient Tracking Cookie set on (web_accept) for Specific Post/Page Access.";
72
- /**/
73
- if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
74
- {
75
- if (($code = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $code)) && ($code = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["txn_id"]), $code)))
76
- if (($code = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $code)) && ($code = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $code)))
77
- if (($code = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $code)) && ($code = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $code)))
78
- if (($code = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
79
- if (($code = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $code)))
80
- /**/
81
- if (($code = trim ($code))) /* Make sure it is not empty. This gets stored into a Transient Queue. */
82
- {
83
- $paypal["s2member_log"][] = "Storing Specific Post/Page Tracking Codes into a Transient Queue for s2Member. These will be processed on-site.";
84
- set_transient (md5 ("s2member_transient_sp_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
85
- }
86
- }
87
- /**/
88
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
89
- do_action ("ws_plugin__s2member_during_paypal_return_during_sp_access", get_defined_vars ());
90
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
91
- /**/
92
- $paypal["s2member_log"][] = "Redirecting Customer to the Specific Post/Page.";
93
- /**/
94
- header ("Location: " . $sp_access_url);
95
- }
96
- else /* Otherwise, the ID must have been invalid. Or the Post/Page was deleted. */
97
- {
98
- $paypal["s2member_log"][] = "Unable to generate Specific Post/Page Access Link. Does your Leading Post/Page still exist?";
99
- /**/
100
- $paypal["s2member_log"][] = "Redirecting Customer to the Home Page, due to an error that occurred.";
101
- /**/
102
- echo '<script type="text/javascript">' . "\n";
103
- echo "alert('ERROR: Unable to generate Access Link. Please contact Support for assistance.');" . "\n";
104
- echo "window.location = '" . esc_js (get_bloginfo ("url")) . "';";
105
- echo '</script>' . "\n";
106
- }
107
- /**/
108
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
109
- do_action ("ws_plugin__s2member_during_paypal_return_after_sp_access", get_defined_vars ());
110
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
111
- }
112
- /*
113
- New Subscriptions.
114
- Possibly containing advanced update vars
115
- ( option_name1, option_selection1 ); which allow account modifications.
116
- */
117
- else if (/**/preg_match ("/^(web_accept|subscr_signup|subscr_payment)$/i", $paypal["txn_type"])/**/
118
- && preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])/**/
119
- && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["txn_id"]))/**/
120
- && !preg_match ($payment_status_issues, $paypal["payment_status"])/**/)
121
- { /* With Auto-Return/PDT, PayPal will send subscr_payment instead of subscr_signup to the return URL.
122
- So we need to look for (web_accept|subscr_signup|subscr_payment), and treat them as the same. */
123
- /**/
124
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
125
- do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_signup", get_defined_vars ());
126
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
127
- /**/
128
- $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup|subscr_payment).";
129
- /**/
130
- list ($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split ("/\:/", $paypal["item_number"], 3);
131
- /*
132
- New Subscription with advanced update vars ( option_name1, option_selection1 ).
133
- */
134
- if (preg_match ("/(updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) /* Advanced Subscription update modifications. */
135
- /* This advanced method is required whenever a Subscription that is already completed, or was never setup to recur in the first place needs to be modified. PayPal® will not allow the
136
- modify=2 parameter to be used in those scenarios, because technically there is nothing to update. The only thing to be updated is the account. */
137
- {
138
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
139
- do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_signup_w_update_vars", get_defined_vars ());
140
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
141
- /**/
142
- $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup|subscr_payment) w/ update vars.";
143
- /**/
144
- /* Check for both the old & new subscr_id's, just in case the IPN routine already changed it. */
145
- if (($user_id = ws_plugin__s2member_paypal_user_id ($paypal["subscr_id"], $paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
146
- {
147
- if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
148
- {
149
- $processing = $during = true; /* Yes, we ARE processing this. */
150
- /**/
151
- $user->set_role ("s2member_level" . $paypal["level"]);
152
- /**/
153
- foreach ($user->allcaps as $cap => $cap_enabled)
154
- if (preg_match ("/^access_s2member_ccap_/", $cap))
155
- $user->remove_cap ($ccap = $cap);
156
- /**/
157
- foreach (preg_split ("/[\r\n\t\s;,]+/", $paypal["ccaps"]) as $ccap)
158
- if (strlen ($ccap)) /* Don't add empty capabilities. */
159
- $user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
160
- /**/
161
- update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
162
- update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
163
- /**/
164
- delete_user_option ($user_id, "s2member_file_download_access_arc");
165
- delete_user_option ($user_id, "s2member_file_download_access_log");
166
- /**/
167
- if (preg_match ("/^web_accept$/i", $paypal["txn_type"]) && $paypal["eotper"])
168
- update_user_option ($user_id, "s2member_auto_eot_time", ws_plugin__s2member_paypal_auto_eot_time (0, 0, 0, $paypal["eotper"]));
169
- else /* Otherwise, we need to clear the eot time. */
170
- delete_user_option ($user_id, "s2member_auto_eot_time");
171
- /**/
172
- ws_plugin__s2member_clear_user_note_lines ($user_id, "/^Demoted by s2Member\:/");
173
- /**/
174
- $paypal["s2member_log"][] = "s2Member Level/Capabilities updated w/ advanced update routines.";
175
- /**/
176
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
177
- do_action ("ws_plugin__s2member_during_paypal_return_during_subscr_signup_w_update_vars", get_defined_vars ());
178
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
179
- /**/
180
- $paypal["s2member_log"][] = "Redirecting Customer to the Login Page. They need to log back in after this modification.";
181
- /**/
182
- echo '<script type="text/javascript">' . "\n";
183
- echo "alert('Thank You! Your membership has been updated to:\\n\\n" . esc_js ($paypal["item_name"]) . "\\n\\nYou\\'ll need to log back in now.');" . "\n";
184
- echo "window.location = '" . wp_login_url () . "';" . "\n";
185
- echo '</script>' . "\n";
186
- }
187
- else
188
- {
189
- $paypal["s2member_log"][] = "Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
190
- /**/
191
- $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
192
- /**/
193
- echo '<script type="text/javascript">' . "\n";
194
- echo "alert('ERROR: Unable to modify Subscription. Please contact Support for assistance.\\n\\nThe existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access. Please make sure that you are NOT logged in as an Administrator while testing.');" . "\n";
195
- echo "window.location = '" . esc_js (wp_login_url ()) . "';";
196
- echo '</script>' . "\n";
197
- }
198
- }
199
- else
200
- {
201
- $paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB. Please check the on0 and os0 variables in your Button Code.";
202
- /**/
203
- $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
204
- /**/
205
- echo '<script type="text/javascript">' . "\n";
206
- echo "alert('ERROR: Unable to modify Subscription. Please contact Support for assistance.\\n\\nCould not get the existing User ID from the DB.');" . "\n";
207
- echo "window.location = '" . esc_js (wp_login_url ()) . "';";
208
- echo '</script>' . "\n";
209
- }
210
- /**/
211
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
212
- do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_signup_w_update_vars", get_defined_vars ());
213
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
214
- }
215
- /*
216
- New Subscription. Normal Subscription signup, we are not updating anything for a past Subscription.
217
- */
218
- else /* Else this is a normal Subscription signup, we are not updating an existing Subscription. */
219
- {
220
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
221
- do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_signup_wo_update_vars", get_defined_vars ());
222
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
223
- /**/
224
- $processing = $during = true; /* Yes, we ARE processing this new Subscription request. */
225
- /**/
226
- $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup|subscr_payment) w/o update vars.";
227
- /**/
228
- setcookie ("s2member_subscr_id", ws_plugin__s2member_encrypt ($paypal["subscr_id"]), time () + 31556926, "/");
229
- setcookie ("s2member_custom", ws_plugin__s2member_encrypt ($paypal["custom"]), time () + 31556926, "/");
230
- setcookie ("s2member_level", ws_plugin__s2member_encrypt ($paypal["item_number"]), time () + 31556926, "/");
231
- /**/
232
- $paypal["s2member_log"][] = "Registration Cookies set on (web_accept|subscr_signup|subscr_payment) w/o update vars.";
233
- /**/
234
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
235
- do_action ("ws_plugin__s2member_during_paypal_return_during_subscr_signup_wo_update_vars", get_defined_vars ());
236
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
237
- /**/
238
- $paypal["s2member_log"][] = "Redirecting Customer to Registration Page. They need to Register now.";
239
- /**/
240
- if (is_multisite () && ws_plugin__s2member_is_multisite_farm () && is_main_site ())
241
- {
242
- echo '<script type="text/javascript">' . "\n";
243
- echo "alert('Thank You! Your account has been approved.\\nThe next step is to Register.\\n\\nPlease click OK to Register now.');" . "\n";/**/
244
- echo "window.location = '" . esc_js (apply_filters ("wp_signup_location", get_bloginfo ("wpurl") . "/wp-signup.php")) . "';" . "\n";
245
- echo '</script>' . "\n";
246
- }
247
- else /* Otherwise, this is NOT a Multisite install. Or it is, but the Super Administrator is NOT selling Blog creation. */
248
- {
249
- echo '<script type="text/javascript">' . "\n";
250
- echo "alert('Thank You! Your account has been approved.\\nThe next step is to Register a Username.\\n\\nPlease click OK to Register now.');" . "\n";/**/
251
- echo "window.location = '" . esc_js (add_query_arg ("action", "register", wp_login_url ())) . "';" . "\n";
252
- echo '</script>' . "\n";
253
- }
254
- /**/
255
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
256
- do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_signup_wo_update_vars", get_defined_vars ());
257
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
258
- }
259
- /**/
260
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
261
- do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_signup", get_defined_vars ());
262
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
263
- }
264
- /*
265
- Subscription modifications.
266
- */
267
- else if (/**/preg_match ("/^subscr_modify$/i", $paypal["txn_type"])/**/
268
- && preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])/**/
269
- && $paypal["subscr_id"]/**/)
270
- {
271
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
272
- do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_modify", get_defined_vars ());
273
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
274
- /**/
275
- $paypal["s2member_log"][] = "s2Member txn_type identified as subscr_modify.";
276
- /**/
277
- list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
278
- /**/
279
- if (($user_id = ws_plugin__s2member_paypal_user_id ($paypal["subscr_id"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
280
- {
281
- if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
282
- {
283
- $processing = $during = true; /* Yes, we ARE processing this. */
284
- /**/
285
- $user->set_role ("s2member_level" . $paypal["level"]);
286
- /**/
287
- foreach ($user->allcaps as $cap => $cap_enabled)
288
- if (preg_match ("/^access_s2member_ccap_/", $cap))
289
- $user->remove_cap ($ccap = $cap);
290
- /**/
291
- foreach (preg_split ("/[\r\n\t\s;,]+/", $paypal["ccaps"]) as $ccap)
292
- if (strlen ($ccap)) /* Don't add empty capabilities. */
293
- $user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
294
- /**/
295
- update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
296
- update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
297
- /**/
298
- delete_user_option ($user_id, "s2member_file_download_access_arc");
299
- delete_user_option ($user_id, "s2member_file_download_access_log");
300
- /**/
301
- delete_user_option ($user_id, "s2member_auto_eot_time");
302
- /**/
303
- ws_plugin__s2member_clear_user_note_lines ($user_id, "/^Demoted by s2Member\:/");
304
- /**/
305
- $paypal["s2member_log"][] = "s2Member Level/Capabilities updated on Subscription modification.";
306
- /**/
307
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
308
- do_action ("ws_plugin__s2member_during_paypal_return_during_subscr_modify", get_defined_vars ());
309
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
310
- /**/
311
- $paypal["s2member_log"][] = "Redirecting Customer to the Login Page. They need to log back in after this modification.";
312
- /**/
313
- echo '<script type="text/javascript">' . "\n";
314
- echo "alert('Thank You! Your membership has been updated to:\\n\\n" . esc_js ($paypal["item_name"]) . "\\n\\nYou\\'ll need to log back in now.');" . "\n";
315
- echo "window.location = '" . esc_js (wp_login_url ()) . "';";
316
- echo '</script>' . "\n";
317
- }
318
- else
319
- {
320
- $paypal["s2member_log"][] = "Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
321
- /**/
322
- $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
323
- /**/
324
- echo '<script type="text/javascript">' . "\n";
325
- echo "alert('ERROR: Unable to modify Subscription. Please contact Support for assistance.\\n\\nThe existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access. Please make sure that you are NOT logged in as an Administrator while testing.');" . "\n";
326
- echo "window.location = '" . esc_js (wp_login_url ()) . "';";
327
- echo '</script>' . "\n";
328
- }
329
- }
330
- else
331
- {
332
- $paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB.";
333
- /**/
334
- $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
335
- /**/
336
- echo '<script type="text/javascript">' . "\n";
337
- echo "alert('ERROR: Unable to modify Subscription. Please contact Support for assistance.\\n\\nCould not get the existing User ID from the DB.');" . "\n";
338
- echo "window.location = '" . esc_js (wp_login_url ()) . "';";
339
- echo '</script>' . "\n";
340
- }
341
- /**/
342
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
343
- do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_modify", get_defined_vars ());
344
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
345
- }
346
- else
347
- {
348
- $paypal["s2member_log"][] = "Unexpected txn_type. The PayPal® txn_type/status did not match a required action.";
349
- /**/
350
- $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
351
- /**/
352
- echo '<script type="text/javascript">' . "\n";
353
- echo "alert('ERROR: Unexpected txn_type/status. Please contact Support for assistance.\\n\\nThe PayPal® txn_type/status did not match a required action.');" . "\n";
354
- echo "window.location = '" . esc_js (wp_login_url ()) . "';";
355
- echo '</script>' . "\n";
356
- }
357
- }
358
- else /* Else a custom conditional has been applied by filters. */
359
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
360
- }
361
- else
362
- {
363
- $paypal["s2member_log"][] = "Unable to verify _SERVER[HTTP_HOST]. Please check the `custom` value in your Button Code. It MUST start with your domain name.";
364
- /**/
365
- $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
366
- /**/
367
- echo '<script type="text/javascript">' . "\n";
368
- echo "alert('ERROR: Unable to verify _SERVER[HTTP_HOST]. Please contact Support for assistance.\\n\\nIf you are the site owner, please check the `custom` value in your Button Code. It MUST start with your domain name.');" . "\n";
369
- echo "window.location = '" . esc_js (wp_login_url ()) . "';";
370
- echo '</script>' . "\n";
371
- }
372
- }
373
- else if (!isset ($_GET["tx"]) && (empty ($_POST) || $_POST["auth"]))
374
- {
375
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
376
- do_action ("ws_plugin__s2member_during_paypal_return_before_no_return_data", get_defined_vars ());
377
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
378
- /**/
379
- $paypal["s2member_log"][] = "No Return-Data from PayPal®. Customer must wait for Email Confirmation.";
380
- /**/
381
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
382
- do_action ("ws_plugin__s2member_during_paypal_return_during_no_return_data", get_defined_vars ());
383
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
384
- /**/
385
- $paypal["s2member_log"][] = "Redirecting Customer to the Home Page.";
386
- /**/
387
- echo '<script type="text/javascript">' . "\n";
388
- echo "alert('Thank You! ( please check your email ).\\n\\n* Note: It can take ( up to 15 minutes ) for Email Confirmation. If you don\'t receive email confirmation in the next 15 minutes, please contact Support.');" . "\n";
389
- echo ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "alert('** Sandbox Mode ** You will probably NOT receive this Email Confirmation in Sandbox Mode. Sandbox addresses are usually bogus ( for testing ).');" . "\n" : "";
390
- echo "window.location = '" . esc_js (get_bloginfo ("url")) . "';";
391
- echo '</script>' . "\n";
392
- /**/
393
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
394
- do_action ("ws_plugin__s2member_during_paypal_return_after_no_return_data", get_defined_vars ());
395
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
396
- }
397
- else /* Extensive log reporting here. This is an area where many site owners find trouble. Depending on server configuration; remote HTTPS connections may fail. */
398
- {
399
- $paypal["s2member_log"][] = "Unable to verify POST vars. This is most likely related to an invalid PayPal® configuration. Please check: s2Member -> PayPal® Options.";
400
- $paypal["s2member_log"][] = "If you're absolutely SURE that your PayPal® configuration is valid, you may want to run some tests on your server, just to be sure \$_POST variables are populated, and that your server is able to connect to PayPal® over an HTTPS connection.";
401
- $paypal["s2member_log"][] = "s2Member uses the WP_Http class for remote connections; which will try to use cURL first, and then fall back on the FOPEN method when cURL is not available. On a Windows® server, you may have to disable your cURL extension. Instead, set allow_url_fopen = yes in your php.ini file. The cURL extension (usually) does NOT support SSL connections on a Windows® server.";
402
- $paypal["s2member_log"][] = var_export ($_POST, true); /* Recording _POST vars for analysis and debugging. */
403
- /**/
404
- $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
405
- /**/
406
- echo '<script type="text/javascript">' . "\n";
407
- echo "alert('ERROR: Unable to verify POST vars. Please contact Support for assistance.\\n\\nThis is most likely related to an invalid PayPal® configuration. If you are the site owner, please check: s2Member -> PayPal® Options.');" . "\n";
408
- echo "window.location = '" . esc_js (wp_login_url ()) . "';";
409
- echo '</script>' . "\n";
410
- }
411
- /*
412
- Add RTN proxy identification ( when available ) to the $paypal array for log reporting.
413
- */
414
- if ($_GET["s2member_paypal_proxy"]) /* For proxy identification. */
415
- $paypal["s2member_paypal_proxy"] = $_GET["s2member_paypal_proxy"];
416
- /*
417
- Also add RTN proxy self-verification ( when available ) to the $paypal array.
418
- */
419
- if ($_GET["s2member_paypal_proxy_verification"]) /* Proxy identification w/verification. */
420
- $paypal["s2member_paypal_proxy_verification"] = $_GET["s2member_paypal_proxy_verification"];
421
- /*
422
- If debugging/logging is enabled; we need to append $paypal to the log file.
423
- Logging now supports Multisite Networking as well.
424
- */
425
- $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
426
- $log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
427
- $log2 = (is_multisite () && !is_main_site ()) ? "paypal-rtn-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-rtn.log";
428
  /**/
429
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_debug"]) /* Append to log? */
430
- if (is_dir ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) /* Dir exists? */
431
- if (is_writable ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
432
- file_put_contents ($logs_dir . "/" . $log2, $log4 . "\n" . var_export ($paypal, true) . "\n\n", FILE_APPEND);
433
- /**/
434
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
435
- do_action ("ws_plugin__s2member_during_paypal_return", get_defined_vars ());
436
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
437
- /**/
438
- exit ();
439
  }
440
- /**/
441
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
442
- do_action ("ws_plugin__s2member_after_paypal_return", get_defined_vars ());
443
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
444
  }
445
  }
446
  ?>
22
  {
23
  function ws_plugin__s2member_paypal_return ()
24
  {
25
+ if ($_GET["s2member_paypal_return"]) /* Loads separate function handler. */
 
 
 
 
26
  {
27
+ include_once dirname (__FILE__) . "/separates/paypal-return.inc.php";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  /**/
29
+ s__ws_plugin__s2member_paypal_return (); /* Process. */
 
 
 
 
 
 
 
 
 
30
  }
 
 
 
 
31
  }
32
  }
33
  ?>
includes/functions/paypal-utilities.inc.php CHANGED
@@ -12,7 +12,7 @@ If not, see: <http://www.gnu.org/licenses/>.
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit("Do not access this file directly.");
16
  /*
17
  Get POST vars from PayPal®, verify and return array.
18
  */
@@ -20,14 +20,14 @@ if (!function_exists ("ws_plugin__s2member_paypal_postvars"))
20
  {
21
  function ws_plugin__s2member_paypal_postvars ()
22
  {
23
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
24
  do_action ("ws_plugin__s2member_before_paypal_postvars", get_defined_vars ());
25
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
26
  /*
27
  Custom conditionals can be applied by filters.
28
  */
29
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
30
- if (!($postvars = apply_filters ("ws_plugin__s2member_during_paypal_postvars_conditionals", array (), get_defined_vars ())))
31
  {
32
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
33
  /**/
@@ -96,7 +96,7 @@ if (!function_exists ("ws_plugin__s2member_paypal_proxy_key_gen"))
96
  {
97
  global $current_site, $current_blog; /* Multisite Networking. */
98
  /**/
99
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
100
  do_action ("ws_plugin__s2member_before_paypal_proxy_key_gen", get_defined_vars ());
101
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
102
  /**/
@@ -120,7 +120,7 @@ if (!function_exists ("ws_plugin__s2member_paypal_custom"))
120
  {
121
  global $wpdb; /* Need global DB obj. */
122
  /**/
123
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
124
  do_action ("ws_plugin__s2member_before_paypal_custom", get_defined_vars ());
125
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
126
  /**/
@@ -152,7 +152,7 @@ if (!function_exists ("ws_plugin__s2member_paypal_user_id"))
152
  {
153
  global $wpdb; /* Need global DB obj. */
154
  /**/
155
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
156
  do_action ("ws_plugin__s2member_before_paypal_user_id", get_defined_vars ());
157
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
158
  /**/
@@ -172,6 +172,38 @@ if (!function_exists ("ws_plugin__s2member_paypal_user_id"))
172
  }
173
  }
174
  /*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  Calculate Auto-EOT Time, based on last_payment_time, period1, and period3.
176
  This is used by s2Member's built-in Auto-EOT System, and by its IPN routines.
177
  */
@@ -179,7 +211,7 @@ if (!function_exists ("ws_plugin__s2member_paypal_auto_eot_time"))
179
  {
180
  function ws_plugin__s2member_paypal_auto_eot_time ($user_id = FALSE, $period1 = FALSE, $period3 = FALSE, $eotper = FALSE)
181
  {
182
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
183
  do_action ("ws_plugin__s2member_before_paypal_auto_eot_time", get_defined_vars ());
184
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
185
  /**/
@@ -188,7 +220,7 @@ if (!function_exists ("ws_plugin__s2member_paypal_auto_eot_time"))
188
  $registration_time = strtotime ($user->user_registered);
189
  $last_payment_time = (int)get_user_option ("s2member_last_payment_time", $user_id);
190
  /**/
191
- if (!($p1_time = 0) && ($period1 = trim (strtoupper ($period1))))
192
  {
193
  list ($num, $span) = preg_split ("/ /", $period1, 2);
194
  /**/
@@ -206,7 +238,7 @@ if (!function_exists ("ws_plugin__s2member_paypal_auto_eot_time"))
206
  $p1_time = $p1_days * 86400;
207
  }
208
  /**/
209
- if (!($p3_time = 0) && ($period3 = trim (strtoupper ($period3))))
210
  {
211
  list ($num, $span) = preg_split ("/ /", $period3, 2);
212
  /**/
@@ -242,7 +274,7 @@ if (!function_exists ("ws_plugin__s2member_paypal_auto_eot_time"))
242
  /**/
243
  else if ($eotper) /* Otherwise, if we have a specific EOT period; calculate from today. */
244
  {
245
- if (!($eot_time = 0) && ($eotper = trim (strtoupper ($eotper))))
246
  {
247
  list ($num, $span) = preg_split ("/ /", $eotper, 2);
248
  /**/
@@ -275,7 +307,7 @@ if (!function_exists ("ws_plugin__s2member_paypal_pro_term"))
275
  {
276
  function ws_plugin__s2member_paypal_pro_term ($term = FALSE)
277
  {
278
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
279
  do_action ("ws_plugin__s2member_before_paypal_pro_term", get_defined_vars ());
280
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
281
  /**/
@@ -292,7 +324,7 @@ if (!function_exists ("ws_plugin__s2member_paypal_std_term"))
292
  {
293
  function ws_plugin__s2member_paypal_std_term ($term = FALSE)
294
  {
295
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
296
  do_action ("ws_plugin__s2member_before_paypal_std_term", get_defined_vars ());
297
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
298
  /**/
@@ -311,7 +343,7 @@ if (!function_exists ("ws_plugin__s2member_paypal_term_cycle"))
311
  {
312
  function ws_plugin__s2member_paypal_term_cycle ($term_or_period_term = FALSE)
313
  {
314
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
315
  do_action ("ws_plugin__s2member_before_paypal_term_cycle", get_defined_vars ());
316
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
317
  /**/
@@ -322,34 +354,93 @@ if (!function_exists ("ws_plugin__s2member_paypal_term_cycle"))
322
  }
323
  }
324
  /*
325
- Parse/validate item_number from either an array with
326
- PROFILEREFERENCE|rp_invoice_id, or parse/validate an existing string
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
327
  to make sure it is a valid "level:ccaps:eotper" combination.
328
  */
329
  if (!function_exists ("ws_plugin__s2member_paypal_pro_item_number"))
330
  {
331
  function ws_plugin__s2member_paypal_pro_item_number ($array_or_string = FALSE)
332
  {
333
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
334
  do_action ("ws_plugin__s2member_before_paypal_pro_item_number", get_defined_vars ());
335
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
336
  /**/
337
- if (is_array ($array = $array_or_string))
 
 
 
 
338
  {
339
  $r = (!$r && $array["PROFILEREFERENCE"]) ? $array["PROFILEREFERENCE"] : $r;
340
  $r = (!$r && $array["rp_invoice_id"]) ? $array["rp_invoice_id"] : $r;
341
  /**/
342
  list ($reference, $domain, $item_number) = preg_split ("/~/", $r, 3);
343
  }
344
- /**/
345
  else if (is_string ($string = $array_or_string))
346
  $item_number = $string;
347
  /**/
348
  if ($item_number) /* Were we able to get an item_number string parsed out? */
 
349
  if (preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $item_number))
350
  return apply_filters ("ws_plugin__s2member_paypal_pro_item_number", $item_number, get_defined_vars ());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
351
  /**/
352
- return apply_filters ("ws_plugin__s2member_paypal_pro_item_number", "1", get_defined_vars ());
353
  }
354
  }
355
  /*
@@ -363,7 +454,7 @@ if (!function_exists ("ws_plugin__s2member_paypal_pro_period1"))
363
  {
364
  function ws_plugin__s2member_paypal_pro_period1 ($array_or_string = FALSE)
365
  {
366
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
367
  do_action ("ws_plugin__s2member_before_paypal_pro_period1", get_defined_vars ());
368
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
369
  /**/
@@ -408,7 +499,7 @@ if (!function_exists ("ws_plugin__s2member_paypal_pro_period3"))
408
  {
409
  function ws_plugin__s2member_paypal_pro_period3 ($array_or_string = FALSE)
410
  {
411
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
412
  do_action ("ws_plugin__s2member_before_paypal_pro_period3", get_defined_vars ());
413
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
414
  /**/
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit ("Do not access this file directly.");
16
  /*
17
  Get POST vars from PayPal®, verify and return array.
18
  */
20
  {
21
  function ws_plugin__s2member_paypal_postvars ()
22
  {
23
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
24
  do_action ("ws_plugin__s2member_before_paypal_postvars", get_defined_vars ());
25
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
26
  /*
27
  Custom conditionals can be applied by filters.
28
  */
29
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
30
+ if (! ($postvars = apply_filters ("ws_plugin__s2member_during_paypal_postvars_conditionals", array (), get_defined_vars ())))
31
  {
32
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
33
  /**/
96
  {
97
  global $current_site, $current_blog; /* Multisite Networking. */
98
  /**/
99
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
100
  do_action ("ws_plugin__s2member_before_paypal_proxy_key_gen", get_defined_vars ());
101
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
102
  /**/
120
  {
121
  global $wpdb; /* Need global DB obj. */
122
  /**/
123
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
124
  do_action ("ws_plugin__s2member_before_paypal_custom", get_defined_vars ());
125
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
126
  /**/
152
  {
153
  global $wpdb; /* Need global DB obj. */
154
  /**/
155
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
156
  do_action ("ws_plugin__s2member_before_paypal_user_id", get_defined_vars ());
157
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
158
  /**/
172
  }
173
  }
174
  /*
175
+ Get the email value for an existing Member, referenced by a Subscr. ID.
176
+ A second lookup parameter can be provided, which will trigger some additional routines.
177
+ The $os0 value comes from advanced update vars, pertaining to subscription modifications.
178
+ */
179
+ if (!function_exists ("ws_plugin__s2member_paypal_email"))
180
+ {
181
+ function ws_plugin__s2member_paypal_email ($subscr_id = FALSE, $os0 = FALSE)
182
+ {
183
+ global $wpdb; /* Need global DB obj. */
184
+ /**/
185
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
186
+ do_action ("ws_plugin__s2member_before_paypal_email", get_defined_vars ());
187
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
188
+ /**/
189
+ if ($subscr_id && $os0) /* This case includes some additional routines that can use the $os0 value. */
190
+ {
191
+ if (($q = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND (`meta_value` = '" . $wpdb->escape ($subscr_id) . "' OR `meta_value` = '" . $wpdb->escape ($os0) . "') LIMIT 1"))/**/
192
+ || ($q = $wpdb->get_row ("SELECT `ID` AS `user_id` FROM `" . $wpdb->users . "` WHERE `ID` = '" . $wpdb->escape ($os0) . "' LIMIT 1")))
193
+ if (is_object ($user = new WP_User ($q->user_id)) && ($email = $user->user_email))
194
+ return apply_filters ("ws_plugin__s2member_paypal_email", $email, get_defined_vars ());
195
+ }
196
+ else if ($subscr_id) /* Otherwise, if all we have is a Subscr. ID value. */
197
+ {
198
+ if ($q = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($subscr_id) . "' LIMIT 1"))
199
+ if (is_object ($user = new WP_User ($q->user_id)) && ($email = $user->user_email))
200
+ return apply_filters ("ws_plugin__s2member_paypal_email", $email, get_defined_vars ());
201
+ }
202
+ /**/
203
+ return apply_filters ("ws_plugin__s2member_paypal_email", false, get_defined_vars ());
204
+ }
205
+ }
206
+ /*
207
  Calculate Auto-EOT Time, based on last_payment_time, period1, and period3.
208
  This is used by s2Member's built-in Auto-EOT System, and by its IPN routines.
209
  */
211
  {
212
  function ws_plugin__s2member_paypal_auto_eot_time ($user_id = FALSE, $period1 = FALSE, $period3 = FALSE, $eotper = FALSE)
213
  {
214
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
215
  do_action ("ws_plugin__s2member_before_paypal_auto_eot_time", get_defined_vars ());
216
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
217
  /**/
220
  $registration_time = strtotime ($user->user_registered);
221
  $last_payment_time = (int)get_user_option ("s2member_last_payment_time", $user_id);
222
  /**/
223
+ if (! ($p1_time = 0) && ($period1 = trim (strtoupper ($period1))))
224
  {
225
  list ($num, $span) = preg_split ("/ /", $period1, 2);
226
  /**/
238
  $p1_time = $p1_days * 86400;
239
  }
240
  /**/
241
+ if (! ($p3_time = 0) && ($period3 = trim (strtoupper ($period3))))
242
  {
243
  list ($num, $span) = preg_split ("/ /", $period3, 2);
244
  /**/
274
  /**/
275
  else if ($eotper) /* Otherwise, if we have a specific EOT period; calculate from today. */
276
  {
277
+ if (! ($eot_time = 0) && ($eotper = trim (strtoupper ($eotper))))
278
  {
279
  list ($num, $span) = preg_split ("/ /", $eotper, 2);
280
  /**/
307
  {
308
  function ws_plugin__s2member_paypal_pro_term ($term = FALSE)
309
  {
310
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
311
  do_action ("ws_plugin__s2member_before_paypal_pro_term", get_defined_vars ());
312
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
313
  /**/
324
  {
325
  function ws_plugin__s2member_paypal_std_term ($term = FALSE)
326
  {
327
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
328
  do_action ("ws_plugin__s2member_before_paypal_std_term", get_defined_vars ());
329
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
330
  /**/
343
  {
344
  function ws_plugin__s2member_paypal_term_cycle ($term_or_period_term = FALSE)
345
  {
346
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
347
  do_action ("ws_plugin__s2member_before_paypal_term_cycle", get_defined_vars ());
348
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
349
  /**/
354
  }
355
  }
356
  /*
357
+ Parse/validate item_name from either an array with recurring_payment_id, or use an existing string.
358
+ */
359
+ if (!function_exists ("ws_plugin__s2member_paypal_pro_subscr_id"))
360
+ {
361
+ function ws_plugin__s2member_paypal_pro_subscr_id ($array_or_string = FALSE)
362
+ {
363
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
364
+ do_action ("ws_plugin__s2member_before_paypal_pro_subscr_id", get_defined_vars ());
365
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
366
+ /**/
367
+ if (is_array ($array = $array_or_string) && $array["recurring_payment_id"])
368
+ {
369
+ $subscr_id = $array["recurring_payment_id"];
370
+ }
371
+ else if (is_string ($string = $array_or_string))
372
+ $subscr_id = $string;
373
+ /**/
374
+ if ($subscr_id) /* Were we able to get an subscr_id string parsed out? */
375
+ return apply_filters ("ws_plugin__s2member_paypal_pro_subscr_id", $subscr_id, get_defined_vars ());
376
+ /**/
377
+ return apply_filters ("ws_plugin__s2member_paypal_pro_subscr_id", false, get_defined_vars ());
378
+ }
379
+ }
380
+ /*
381
+ Parse/validate item_number from either an array with:
382
+ item_number1|PROFILEREFERENCE|rp_invoice_id, or parse/validate an existing string
383
  to make sure it is a valid "level:ccaps:eotper" combination.
384
  */
385
  if (!function_exists ("ws_plugin__s2member_paypal_pro_item_number"))
386
  {
387
  function ws_plugin__s2member_paypal_pro_item_number ($array_or_string = FALSE)
388
  {
389
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
390
  do_action ("ws_plugin__s2member_before_paypal_pro_item_number", get_defined_vars ());
391
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
392
  /**/
393
+ if (is_array ($array = $array_or_string) && $array["item_number1"])
394
+ {
395
+ $item_number = $array["item_number1"];
396
+ }
397
+ else if (is_array ($array = $array_or_string))
398
  {
399
  $r = (!$r && $array["PROFILEREFERENCE"]) ? $array["PROFILEREFERENCE"] : $r;
400
  $r = (!$r && $array["rp_invoice_id"]) ? $array["rp_invoice_id"] : $r;
401
  /**/
402
  list ($reference, $domain, $item_number) = preg_split ("/~/", $r, 3);
403
  }
 
404
  else if (is_string ($string = $array_or_string))
405
  $item_number = $string;
406
  /**/
407
  if ($item_number) /* Were we able to get an item_number string parsed out? */
408
+ /**/
409
  if (preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $item_number))
410
  return apply_filters ("ws_plugin__s2member_paypal_pro_item_number", $item_number, get_defined_vars ());
411
+ /**/
412
+ else if (preg_match ("/^sp\:[0-9,]+\:[0-9]+$/", $item_number))
413
+ return apply_filters ("ws_plugin__s2member_paypal_pro_item_number", $item_number, get_defined_vars ());
414
+ /**/
415
+ return apply_filters ("ws_plugin__s2member_paypal_pro_item_number", false, get_defined_vars ());
416
+ }
417
+ }
418
+ /*
419
+ Parse/validate item_name from either an array with: item_name1|product_name, or use an existing string.
420
+ */
421
+ if (!function_exists ("ws_plugin__s2member_paypal_pro_item_name"))
422
+ {
423
+ function ws_plugin__s2member_paypal_pro_item_name ($array_or_string = FALSE)
424
+ {
425
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
426
+ do_action ("ws_plugin__s2member_before_paypal_pro_item_name", get_defined_vars ());
427
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
428
+ /**/
429
+ if (is_array ($array = $array_or_string) && $array["item_name1"])
430
+ {
431
+ $item_name = $array["item_name1"];
432
+ }
433
+ else if (is_array ($array = $array_or_string) && $array["product_name"])
434
+ {
435
+ $item_name = $array["product_name"];
436
+ }
437
+ else if (is_string ($string = $array_or_string))
438
+ $item_name = $string;
439
+ /**/
440
+ if ($item_name) /* Were we able to get an item_name string parsed out? */
441
+ return apply_filters ("ws_plugin__s2member_paypal_pro_item_name", $item_name, get_defined_vars ());
442
  /**/
443
+ return apply_filters ("ws_plugin__s2member_paypal_pro_item_name", false, get_defined_vars ());
444
  }
445
  }
446
  /*
454
  {
455
  function ws_plugin__s2member_paypal_pro_period1 ($array_or_string = FALSE)
456
  {
457
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
458
  do_action ("ws_plugin__s2member_before_paypal_pro_period1", get_defined_vars ());
459
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
460
  /**/
499
  {
500
  function ws_plugin__s2member_paypal_pro_period3 ($array_or_string = FALSE)
501
  {
502
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
503
  do_action ("ws_plugin__s2member_before_paypal_pro_period3", get_defined_vars ());
504
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
505
  /**/
includes/functions/post-level-access.inc.php CHANGED
@@ -14,73 +14,211 @@ Direct access denial.
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /*
17
- Function for handling post level access permissions.
18
- Attach to: add_action("template_redirect");
 
 
 
 
 
 
 
 
 
 
 
19
  */
20
  if (!function_exists ("ws_plugin__s2member_check_post_level_access"))
21
  {
22
  function ws_plugin__s2member_check_post_level_access ()
23
  {
24
- global $post; /* get_the_ID() not yet available here. */
25
  /**/
26
  do_action ("ws_plugin__s2member_before_check_post_level_access", get_defined_vars ());
27
  /**/
28
  $excluded = apply_filters ("ws_plugin__s2member_check_post_level_access_excluded", false, get_defined_vars ());
29
  /**/
30
- if (!$excluded && is_single () && !is_page () && is_object ($post) && ($post_ID = $post->ID))
31
  {
32
- if (!ws_plugin__s2member_is_systematic_use_page () && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
 
 
33
  {
34
- $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
35
- /**/
36
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_posts"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && wp_redirect (add_query_arg ("s2member_level_req", "0", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
37
- exit ();
38
- /**/
39
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_posts"] && in_array ($post_ID, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_posts"])) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && wp_redirect (add_query_arg ("s2member_level_req", "0", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
40
- exit ();
41
- /**/
42
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_posts"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
43
- exit ();
44
- /**/
45
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_posts"] && in_array ($post_ID, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_posts"])) && ws_plugin__s2member_nocache_constants (true) !== "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")
46
- exit ();
47
- /**/
48
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_posts"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
49
- exit ();
50
- /**/
51
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_posts"] && in_array ($post_ID, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_posts"])) && ws_plugin__s2member_nocache_constants (true) !== "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")
52
- exit ();
53
- /**/
54
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_posts"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
55
- exit ();
56
- /**/
57
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_posts"] && in_array ($post_ID, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_posts"])) && ws_plugin__s2member_nocache_constants (true) !== "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")
58
- exit ();
59
  /**/
60
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_posts"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
61
- exit ();
 
 
 
 
 
 
 
 
 
 
 
 
62
  /**/
63
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_posts"] && in_array ($post_ID, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_posts"])) && ws_plugin__s2member_nocache_constants (true) !== "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")
64
- exit ();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  /**/
66
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array ($post_ID, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && ws_plugin__s2member_nocache_constants (true) !== "nill" && !ws_plugin__s2member_sp_access ($post_ID) && wp_redirect (add_query_arg ("s2member_sp_req", $post_ID, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
67
- exit ();
 
 
 
 
 
 
 
 
68
  /**/
69
- else if (is_array ($ccaps_req = get_post_meta ($post_ID, "s2member_ccaps_req", true))) /* Check for per Post Custom Capability requirements. */
70
- foreach ($ccaps_req as $ccap) /* The $current_user MUST satisfy ALL Custom Capability requirements. These are all stored as a serialized array. */
71
  if (strlen ($ccap) && (!$current_user || !$current_user->has_cap ("access_s2member_ccap_" . $ccap)))
72
  {
73
  wp_redirect (add_query_arg ("s2member_ccap_req", $ccap, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
74
  exit ();
75
  }
76
  /**/
77
- do_action ("ws_plugin__s2member_during_check_post_level_access", get_defined_vars ());
 
 
 
 
78
  }
 
 
79
  }
80
  /**/
81
  do_action ("ws_plugin__s2member_after_check_post_level_access", get_defined_vars ());
82
  /**/
83
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  }
85
  }
86
  ?>
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /*
17
+ Function for handling Post Level Access restrictions.
18
+
19
+ Don't call this function directly, use one of these API functions:
20
+
21
+ Is it protected by s2Member at all?
22
+ - is_post_protected_by_s2member($post_id);
23
+ - is_protected_by_s2member($post_id, "post");
24
+
25
+ Is the current User permitted/authorized?
26
+ - is_post_permitted_by_s2member($post_id);
27
+ - is_permitted_by_s2member($post_id, "post");
28
+
29
+ see: `/s2member/includes/functions/api-functions.inc.php`.
30
  */
31
  if (!function_exists ("ws_plugin__s2member_check_post_level_access"))
32
  {
33
  function ws_plugin__s2member_check_post_level_access ()
34
  {
35
+ global $post; /* get_the_ID() unavailable outside The Loop. */
36
  /**/
37
  do_action ("ws_plugin__s2member_before_check_post_level_access", get_defined_vars ());
38
  /**/
39
  $excluded = apply_filters ("ws_plugin__s2member_check_post_level_access_excluded", false, get_defined_vars ());
40
  /**/
41
+ if (!$excluded && is_single () && is_object ($post) && ($post_id = $post->ID) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
42
  {
43
+ $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
44
+ /**/
45
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = ws_plugin__s2member_login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")))
46
  {
47
+ wp_redirect (add_query_arg ("s2member_level_req", 0, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
48
+ exit ();
49
+ }
50
+ else if (!ws_plugin__s2member_is_systematic_use_page ()) /* Do NOT protect Systematics. However, there is 1 exception above ^. */
51
+ {
52
+ for ($i = 0; $i <= 4; $i++) /* Post Level restrictions ( including Custom Post Types ). Go through each Membership Level. */
53
+ {
54
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
55
+ {
56
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
57
+ exit ();
58
+ }
59
+ /**/
60
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"] && in_array ($post_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"])) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
61
+ {
62
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
63
+ exit ();
64
+ }
65
+ }
 
 
 
 
 
 
66
  /**/
67
+ for ($i = 0; $i <= 4; $i++) /* Category Level restrictions. Go through each Membership Level. */
68
+ {
69
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
70
+ {
71
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
72
+ exit ();
73
+ }
74
+ /**/
75
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] && (in_category (($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"])), $post_id) || ws_plugin__s2member_in_descendant_category ($catgs, $post_id)) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
76
+ {
77
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
78
+ exit ();
79
+ }
80
+ }
81
  /**/
82
+ if (has_tag ()) /* Here we take a look to see if this Post has any Tags. If so, we need to run the full set of routines against Tags also. */
83
+ {
84
+ for ($i = 0; $i <= 4; $i++) /* Tag Level restrictions. Go through each Membership Level. */
85
+ {
86
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
87
+ {
88
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
89
+ exit ();
90
+ }
91
+ /**/
92
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"])) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
93
+ {
94
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
95
+ exit ();
96
+ }
97
+ }
98
+ }
99
  /**/
100
+ for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
101
+ {
102
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
103
+ foreach (preg_split ("/[\r\n\t]+/", ws_plugin__s2member_fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
104
+ if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
105
+ {
106
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
107
+ exit ();
108
+ }
109
+ }
110
  /**/
111
+ if (is_array ($ccaps_req = get_post_meta ($post_id, "s2member_ccaps_req", true)) && ws_plugin__s2member_nocache_constants (true) !== "nill")
112
+ foreach ($ccaps_req as $ccap) /* The $current_user MUST satisfy ALL Custom Capability requirements. Stored as a serialized array. */
113
  if (strlen ($ccap) && (!$current_user || !$current_user->has_cap ("access_s2member_ccap_" . $ccap)))
114
  {
115
  wp_redirect (add_query_arg ("s2member_ccap_req", $ccap, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
116
  exit ();
117
  }
118
  /**/
119
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array ($post_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && ws_plugin__s2member_nocache_constants (true) !== "nill" && !ws_plugin__s2member_sp_access ($post_id))
120
+ {
121
+ wp_redirect (add_query_arg ("s2member_sp_req", $post_id, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
122
+ exit ();
123
+ }
124
  }
125
+ /**/
126
+ do_action ("ws_plugin__s2member_during_check_post_level_access", get_defined_vars ());
127
  }
128
  /**/
129
  do_action ("ws_plugin__s2member_after_check_post_level_access", get_defined_vars ());
130
  /**/
131
+ return; /* For uniformity. */
132
+ }
133
+ }
134
+ /*
135
+ Function checks Post Level Access restrictions - for a specific Post.
136
+
137
+ Don't call this function directly, use one of these API functions:
138
+
139
+ Is it protected by s2Member at all?
140
+ - is_post_protected_by_s2member($post_id);
141
+ - is_protected_by_s2member($post_id, "post");
142
+
143
+ Is the current User permitted/authorized?
144
+ - is_post_permitted_by_s2member($post_id);
145
+ - is_permitted_by_s2member($post_id, "post");
146
+
147
+ see: `/s2member/includes/functions/api-functions.inc.php`.
148
+ */
149
+ if (!function_exists ("ws_plugin__s2member_check_specific_post_level_access"))
150
+ {
151
+ function ws_plugin__s2member_check_specific_post_level_access ($post_id = FALSE, $check_user = TRUE)
152
+ {
153
+ do_action ("ws_plugin__s2member_before_check_specific_post_level_access", get_defined_vars ());
154
+ /**/
155
+ $excluded = apply_filters ("ws_plugin__s2member_check_specific_post_level_access_excluded", false, get_defined_vars ());
156
+ /**/
157
+ if (!$excluded && $post_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Check? */
158
+ {
159
+ $post_link = get_permalink ($post_id); /* Determine link to this Post. */
160
+ $post_path = parse_url ($post_link, PHP_URL_PATH); /* Parse req path. */
161
+ $post_query = parse_url ($post_link, PHP_URL_QUERY); /* Parse query. */
162
+ $post_uri = ($post_query) ? $post_path . "?" . $post_query : $post_path;
163
+ /**/
164
+ $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
165
+ /**/
166
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = ws_plugin__s2member_login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $post_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level0")))
167
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
168
+ /**/
169
+ else if (!ws_plugin__s2member_is_systematic_use_specific_page (null, $post_uri)) /* Never restrict Systematic Use Pages. However, there is 1 exception above ^. */
170
+ {
171
+ for ($i = 0; $i <= 4; $i++) /* Post Level restrictions ( including Custom Post Types ). Go through each Membership Level. */
172
+ {
173
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"] === "all" && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
174
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
175
+ /**/
176
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"] && in_array ($post_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"])) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
177
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
178
+ }
179
+ /**/
180
+ for ($i = 0; $i <= 4; $i++) /* Category Level Access against this Post. Go through each Membership Level. */
181
+ {
182
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] === "all" && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
183
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
184
+ /**/
185
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] && (in_category (($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"])), $post_id) || ws_plugin__s2member_in_descendant_category ($catgs, $post_id)) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
186
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
187
+ }
188
+ /**/
189
+ if (has_tag ("", $post_id)) /* Here we take a look to see if this Post has any Tags. If so, we need to run the full set of routines against Tags also. */
190
+ {
191
+ for ($i = 0; $i <= 4; $i++) /* Tag Level restrictions now. Go through each Membership Level. */
192
+ {
193
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] === "all" && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
194
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
195
+ /**/
196
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"]), $post_id) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
197
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
198
+ }
199
+ }
200
+ /**/
201
+ for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
202
+ {
203
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
204
+ foreach (preg_split ("/[\r\n\t]+/", ws_plugin__s2member_fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
205
+ if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $post_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
206
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
207
+ }
208
+ /**/
209
+ if (is_array ($ccaps_req = get_post_meta ($post_id, "s2member_ccaps_req", true))) /* Custom Capabilities. */
210
+ foreach ($ccaps_req as $ccap) /* The $current_user MUST satisfy ALL Custom Capabilities. Serialized array. */
211
+ if (strlen ($ccap) && (!$check_user || !$current_user || !$current_user->has_cap ("access_s2member_ccap_" . $ccap)))
212
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_ccap_req" => $ccap), get_defined_vars ());
213
+ /**/
214
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array ($post_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && (!$check_user || !ws_plugin__s2member_sp_access ($post_id, "read-only")))
215
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_sp_req" => $post_id), get_defined_vars ());
216
+ }
217
+ /**/
218
+ do_action ("ws_plugin__s2member_during_check_specific_post_level_access", get_defined_vars ());
219
+ }
220
+ /**/
221
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", null, get_defined_vars ());
222
  }
223
  }
224
  ?>
includes/functions/ptag-level-access.inc.php CHANGED
@@ -14,97 +14,158 @@ Direct access denial.
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /*
17
- Function for handling ptag level access permissions.
18
- Attach to: add_action("template_redirect");
 
 
 
 
 
 
 
 
 
 
 
19
  */
20
  if (!function_exists ("ws_plugin__s2member_check_ptag_level_access"))
21
  {
22
  function ws_plugin__s2member_check_ptag_level_access ()
23
  {
24
- global $post; /* get_the_ID() not yet available here. */
25
  /**/
26
  do_action ("ws_plugin__s2member_before_check_ptag_level_access", get_defined_vars ());
27
  /**/
28
  $excluded = apply_filters ("ws_plugin__s2member_check_ptag_level_access_excluded", false, get_defined_vars ());
29
  /**/
30
- if (!$excluded && ((is_tag () && ($tag_ID = get_query_var ("tag"))) || (is_single () && has_tag () && is_object ($post) && ($post_ID = $post->ID))))
31
  {
32
- if (!ws_plugin__s2member_is_systematic_use_page () && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
 
 
 
 
 
 
 
33
  {
34
- $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  /**/
36
- if (is_tag () && $tag_ID) /* We also check if this is a post or page with tags, having a restricted tag. */
37
  {
38
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_ptags"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && wp_redirect (add_query_arg ("s2member_level_req", "0", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
39
- exit ();
40
- /**/
41
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_ptags"] && is_tag (preg_split ("/[\r\n\t;,]+/", preg_replace ("/( +)/", "-", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_ptags"]))) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && wp_redirect (add_query_arg ("s2member_level_req", "0", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
42
- exit ();
43
- /**/
44
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_ptags"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
45
- exit ();
46
- /**/
47
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_ptags"] && is_tag (preg_split ("/[\r\n\t;,]+/", preg_replace ("/( +)/", "-", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_ptags"]))) && ws_plugin__s2member_nocache_constants (true) !== "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")
48
- exit ();
49
- /**/
50
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_ptags"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
51
- exit ();
52
- /**/
53
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_ptags"] && is_tag (preg_split ("/[\r\n\t;,]+/", preg_replace ("/( +)/", "-", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_ptags"]))) && ws_plugin__s2member_nocache_constants (true) !== "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")
54
- exit ();
55
- /**/
56
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_ptags"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
57
- exit ();
58
- /**/
59
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_ptags"] && is_tag (preg_split ("/[\r\n\t;,]+/", preg_replace ("/( +)/", "-", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_ptags"]))) && ws_plugin__s2member_nocache_constants (true) !== "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")
60
- exit ();
61
- /**/
62
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_catgs"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
63
- exit ();
64
- /**/
65
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_ptags"] && is_tag (preg_split ("/[\r\n\t;,]+/", preg_replace ("/( +)/", "-", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_ptags"]))) && ws_plugin__s2member_nocache_constants (true) !== "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")
66
- exit ();
67
  }
68
- else if (is_single () && has_tag () && $post_ID)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  {
70
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_ptags"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && wp_redirect (add_query_arg ("s2member_level_req", "0", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
71
- exit ();
72
- /**/
73
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", preg_replace ("/( +)/", "-", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_ptags"]))) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && wp_redirect (add_query_arg ("s2member_level_req", "0", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
74
- exit ();
75
- /**/
76
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_ptags"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
77
- exit ();
78
- /**/
79
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", preg_replace ("/( +)/", "-", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_ptags"]))) && ws_plugin__s2member_nocache_constants (true) !== "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")
80
- exit ();
81
- /**/
82
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_ptags"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
83
- exit ();
84
- /**/
85
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", preg_replace ("/( +)/", "-", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_ptags"]))) && ws_plugin__s2member_nocache_constants (true) !== "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")
86
- exit ();
87
- /**/
88
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_ptags"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
89
- exit ();
90
  /**/
91
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", preg_replace ("/( +)/", "-", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_ptags"]))) && ws_plugin__s2member_nocache_constants (true) !== "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")
92
- exit ();
93
- /**/
94
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_ptags"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "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")
95
- exit ();
96
- /**/
97
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", preg_replace ("/( +)/", "-", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_ptags"]))) && ws_plugin__s2member_nocache_constants (true) !== "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")
98
- exit ();
99
  }
100
  /**/
101
- do_action ("ws_plugin__s2member_during_check_ptag_level_access", get_defined_vars ());
 
 
 
 
 
 
102
  }
 
 
103
  }
104
  /**/
105
- do_action ("ws_plugin__s2member_after_check_ptag_level_access", get_defined_vars ());
106
- /**/
107
- return;
108
  }
109
  }
110
  ?>
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /*
17
+ Function for handling Tag Level Access permissions.
18
+
19
+ Don't call this function directly, use one of these API functions:
20
+
21
+ Is it protected by s2Member at all?
22
+ - is_tag_protected_by_s2member($tag_id [ or slug, or tag name ]);
23
+ - is_protected_by_s2member($tag_id [ or slug, or tag name ], "tag");
24
+
25
+ Is the current User permitted/authorized?
26
+ - is_tag_permitted_by_s2member($tag_id [ or slug, or tag name ]);
27
+ - is_permitted_by_s2member($tag_id [ or slug, or tag name ], "tag");
28
+
29
+ see: `/s2member/includes/functions/api-functions.inc.php`.
30
  */
31
  if (!function_exists ("ws_plugin__s2member_check_ptag_level_access"))
32
  {
33
  function ws_plugin__s2member_check_ptag_level_access ()
34
  {
35
+ global $post; /* get_the_ID() is NOT available outside The Loop. */
36
  /**/
37
  do_action ("ws_plugin__s2member_before_check_ptag_level_access", get_defined_vars ());
38
  /**/
39
  $excluded = apply_filters ("ws_plugin__s2member_check_ptag_level_access_excluded", false, get_defined_vars ());
40
  /**/
41
+ if (!$excluded && is_tag () && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Check? */
42
  {
43
+ $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
44
+ /**/
45
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = ws_plugin__s2member_login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")))
46
+ {
47
+ wp_redirect (add_query_arg ("s2member_level_req", 0, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
48
+ exit ();
49
+ }
50
+ else if (!ws_plugin__s2member_is_systematic_use_page ()) /* Do NOT protect Systematics. However, there is 1 exception above ^. */
51
  {
52
+ for ($i = 0; $i <= 4; $i++) /* Tag Level restrictions. Go through each Membership Level. This is pretty simple. We're just checking Tags. */
53
+ {
54
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] === "all" && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
55
+ {
56
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
57
+ exit ();
58
+ }
59
+ /**/
60
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] && is_tag (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"])) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
61
+ {
62
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
63
+ exit ();
64
+ }
65
+ }
66
  /**/
67
+ for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
68
  {
69
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
70
+ foreach (preg_split ("/[\r\n\t]+/", ws_plugin__s2member_fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
71
+ if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
72
+ {
73
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
74
+ exit ();
75
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  }
77
+ }
78
+ /**/
79
+ do_action ("ws_plugin__s2member_during_check_ptag_level_access", get_defined_vars ());
80
+ }
81
+ /**/
82
+ do_action ("ws_plugin__s2member_after_check_ptag_level_access", get_defined_vars ());
83
+ /**/
84
+ return; /* For uniformity. */
85
+ }
86
+ }
87
+ /*
88
+ Function checks Tag Level Access permissions - for a specific Tag.
89
+
90
+ Don't call this function directly, use one of these API functions:
91
+
92
+ Is it protected by s2Member at all?
93
+ - is_tag_protected_by_s2member($tag_id [ or slug, or tag name ]);
94
+ - is_protected_by_s2member($tag_id [ or slug, or tag name ], "tag");
95
+
96
+ Is the current User permitted/authorized?
97
+ - is_tag_permitted_by_s2member($tag_id [ or slug, or tag name ]);
98
+ - is_permitted_by_s2member($tag_id [ or slug, or tag name ], "tag");
99
+
100
+ see: `/s2member/includes/functions/api-functions.inc.php`.
101
+ */
102
+ if (!function_exists ("ws_plugin__s2member_check_specific_ptag_level_access"))
103
+ {
104
+ function ws_plugin__s2member_check_specific_ptag_level_access ($__tag = FALSE, $check_user = TRUE)
105
+ {
106
+ do_action ("ws_plugin__s2member_before_check_specific_ptag_level_access", get_defined_vars ());
107
+ /**/
108
+ if ($__tag && is_numeric ($__tag) && is_object ($term = get_term_by ("id", $__tag, "post_tag")))
109
+ {
110
+ $tag_id = $__tag; /* We need the $tag_id, $tag_slug, and also the $tag_name. */
111
+ $tag_slug = $term->slug; /* Tag slug. */
112
+ $tag_name = $term->name; /* Tag name. */
113
+ }
114
+ else if ($__tag && is_string ($__tag)) /* A string? Either a Tag name or a slug. */
115
+ {
116
+ /* Here, we give "name" priority, because it's likely to be a Tag name. */
117
+ if (is_object ($term = get_term_by ("name", $__tag, "post_tag")))
118
+ {
119
+ $tag_name = $__tag; /* A name was passed in. */
120
+ $tag_id = $term->term_id; /* Tag ID. */
121
+ $tag_slug = $term->slug; /* Tag slug. */
122
+ }
123
+ else if (is_object ($term = get_term_by ("slug", $__tag, "post_tag")))
124
+ {
125
+ $tag_slug = $__tag; /* A slug was passed in. */
126
+ $tag_id = $term->term_id; /* Tag ID. */
127
+ $tag_name = $term->name; /* Tag name. */
128
+ }
129
+ }
130
+ /**/
131
+ $excluded = apply_filters ("ws_plugin__s2member_check_specific_ptag_level_access_excluded", false, get_defined_vars ());
132
+ /**/
133
+ if (!$excluded && $tag_id && $tag_slug && $tag_name && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
134
+ {
135
+ $tag_link = get_tag_link ($tag_id); /* Determine link to this Tag. */
136
+ $tag_path = parse_url ($tag_link, PHP_URL_PATH); /* Parse req path. */
137
+ $tag_query = parse_url ($tag_link, PHP_URL_QUERY); /* Parse query. */
138
+ $tag_uri = ($tag_query) ? $tag_path . "?" . $tag_query : $tag_path;
139
+ /**/
140
+ $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
141
+ /**/
142
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = ws_plugin__s2member_login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $tag_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level0")))
143
+ return apply_filters ("ws_plugin__s2member_check_specific_ptag_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
144
+ /**/
145
+ else if (!ws_plugin__s2member_is_systematic_use_specific_page (null, $tag_uri)) /* Never restrict Systematic Use Pages. However, there is 1 exception above ^. */
146
+ {
147
+ for ($i = 0; $i <= 4; $i++) /* Tag Level restrictions. Go through each Membership Level. This is pretty simple. We're just checking Tags. */
148
  {
149
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] === "all" && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
150
+ return apply_filters ("ws_plugin__s2member_check_specific_ptag_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  /**/
152
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] && (in_array ($tag_name, ($tags = preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"]))) || in_array ($tag_slug, $tags)) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
153
+ return apply_filters ("ws_plugin__s2member_check_specific_ptag_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
 
 
 
 
 
 
154
  }
155
  /**/
156
+ for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
157
+ {
158
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
159
+ foreach (preg_split ("/[\r\n\t]+/", ws_plugin__s2member_fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
160
+ if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $tag_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
161
+ return apply_filters ("ws_plugin__s2member_check_specific_ptag_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
162
+ }
163
  }
164
+ /**/
165
+ do_action ("ws_plugin__s2member_during_check_specific_ptag_level_access", get_defined_vars ());
166
  }
167
  /**/
168
+ return apply_filters ("ws_plugin__s2member_check_specific_ptag_level_access", null, get_defined_vars ());
 
 
169
  }
170
  }
171
  ?>
includes/functions/query-level-access.inc.php ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ("Do not access this file directly.");
16
+ /*
17
+ This can filter all WordPress® Post/Page queries.
18
+ ( based on s2Member's configuration )
19
+
20
+ s2Member respects the query var: `suppress_filters`.
21
+ If you need to make a query without it being filtered,
22
+ $wp_query->set ("suppress_filters", true);
23
+
24
+ WordPress® 3.0+ Menus set: `suppress_filters`.
25
+ So this will NOT affect WP Menus.
26
+ ( intended behavior )
27
+
28
+ Don't call this function directly, use one of these API functions:
29
+
30
+ Attach query filters:
31
+ - attach_s2member_query_filters();
32
+
33
+ Detach query filters:
34
+ - detach_s2member_query_filters();
35
+
36
+ see: `/s2member/includes/functions/api-functions.inc.php`.
37
+ */
38
+ if (!function_exists ("ws_plugin__s2member_query_level_access"))
39
+ {
40
+ function ws_plugin__s2member_query_level_access (&$wp_query = FALSE, $force = FALSE)
41
+ {
42
+ static $initial_query = true; /* Tracks initial query filtering. */
43
+ /**/
44
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
45
+ do_action ("ws_plugin__s2member_before_query_level_access", get_defined_vars ());
46
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
47
+ /**/
48
+ if (($o = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["filter_wp_query"]) !== "none" || $force) /* If `none`, the ONLY way to filter is with $force. */
49
+ if ($force /* Forcing this routine bypasses all of these conditions. This works with the API function `attach_s2member_query_filters()`. */
50
+ || ($initial_query && preg_match ("/^(all|searches,feeds|searches)$/", $o) && is_search ()) /* Initial query; filter search results? */
51
+ || ($initial_query && preg_match ("/^(all|searches,feeds|feeds)$/", $o) && is_feed ()) /* Initital query; filter feed listings? */
52
+ || ($o === "all" && ! ($initial_query && is_singular ())) /* << do NOT create 404's. Allow the Security Gate to handle these. */)
53
+ {
54
+ if (!is_admin () && is_object ($wp_query) && !$wp_query->get ("suppress_filters")) /* These are ALWAYS requirements. */
55
+ {
56
+ $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
57
+ /*
58
+ Filter all Posts/Pages requiring Custom Capabilities that the current User does NOT have access to.
59
+ */
60
+ if (is_array ($ccaps = ws_plugin__s2member_get_singular_ids_with_ccaps_req ($current_user)) && !empty ($ccaps))
61
+ $wp_query->set ("post__not_in", array_unique (array_merge ((array)$wp_query->get ("post__not_in"), $ccaps)));
62
+ /*
63
+ Filter all Posts/Pages requiring Specific Post/Page Access that the current Visitor does NOT have access to.
64
+ */
65
+ if (is_array ($sps = ws_plugin__s2member_get_singular_ids_with_sp_req ()) && !empty ($sps))
66
+ $wp_query->set ("post__not_in", array_unique (array_merge ((array)$wp_query->get ("post__not_in"), $sps)));
67
+ /**/
68
+ for ($i = 0; $i <= 4; $i++) /* Category Level Restrictions. Go through each Membership Level. */
69
+ {
70
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] === "all" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
71
+ {
72
+ $wp_query->set ("category__not_in", ws_plugin__s2member_get_all_category_ids ());
73
+ break; /* All Categories will be locked down. */
74
+ }
75
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
76
+ {
77
+ $catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]);
78
+ $wp_query->set ("category__not_in", array_unique (array_merge ((array)$wp_query->get ("category__not_in"), $catgs)));
79
+ }
80
+ }
81
+ /**/
82
+ for ($i = 0; $i <= 4; $i++) /* Tag Level Restrictions. Go through each Membership Level. */
83
+ {
84
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] === "all" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
85
+ {
86
+ $wp_query->set ("tag__not_in", ws_plugin__s2member_get_all_tag_ids ());
87
+ break; /* ALL Tags will be locked down. */
88
+ }
89
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
90
+ {
91
+ $tags = ws_plugin__s2member_convert_tags_2_ids ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"]);
92
+ $wp_query->set ("tag__not_in", array_unique (array_merge ((array)$wp_query->get ("tag__not_in"), $tags)));
93
+ }
94
+ }
95
+ /**/
96
+ for ($i = 0; $i <= 4; $i++) /* Post Level Restrictions. Go through each Membership Level. */
97
+ {
98
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"] === "all" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
99
+ {
100
+ $wp_query->set ("post__not_in", ws_plugin__s2member_get_all_post_ids ());
101
+ break; /* ALL Posts will be locked down. */
102
+ }
103
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"] && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
104
+ {
105
+ $posts = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"]);
106
+ $wp_query->set ("post__not_in", array_unique (array_merge ((array)$wp_query->get ("post__not_in"), $posts)));
107
+ }
108
+ }
109
+ /**/
110
+ for ($i = 0; $i <= 4; $i++) /* Page Level Restrictions. Go through each Membership Level. */
111
+ {
112
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"] === "all" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
113
+ {
114
+ $wp_query->set ("post__not_in", ws_plugin__s2member_get_all_page_ids ());
115
+ break; /* ALL Pages will be locked down. */
116
+ }
117
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"] && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
118
+ {
119
+ $pages = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"]);
120
+ $wp_query->set ("post__not_in", array_unique (array_merge ((array)$wp_query->get ("post__not_in"), $pages)));
121
+ }
122
+ }
123
+ /**/
124
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
125
+ do_action ("ws_plugin__s2member_during_query_level_access", get_defined_vars ());
126
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
127
+ }
128
+ }
129
+ /**/
130
+ if ($initial_query && !is_admin ()) /* Systematics. */
131
+ _ws_plugin__s2member_query_level_access_sys($wp_query);
132
+ /**/
133
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
134
+ do_action ("ws_plugin__s2member_after_query_level_access", get_defined_vars ());
135
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
136
+ /**/
137
+ $initial_query = false; /* No longer. */
138
+ /**/
139
+ return; /* For uniformity. */
140
+ }
141
+ }
142
+ /*
143
+ This filters Systematics in search results & feeds.
144
+
145
+ Specifically, these 3 Pages:
146
+ - Membership Options
147
+ - Login Welcome
148
+ - Download Limit Exceeded
149
+
150
+ s2Member respects the query var: `suppress_filters`.
151
+ If you need to make a query without it being filtered,
152
+ $wp_query->set ("suppress_filters", true);
153
+
154
+ Don't call this function directly, use one of these API functions:
155
+
156
+ Attach query filters:
157
+ - attach_s2member_query_filters();
158
+
159
+ Detach query filters:
160
+ - detach_s2member_query_filters();
161
+
162
+ see: `/s2member/includes/functions/api-functions.inc.php`.
163
+ */
164
+ if (!function_exists ("_ws_plugin__s2member_query_level_access_sys"))
165
+ {
166
+ function _ws_plugin__s2member_query_level_access_sys (&$wp_query = FALSE)
167
+ {
168
+ static $initial_query = true; /* Tracks initial query filtering. */
169
+ /**/
170
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
171
+ do_action ("_ws_plugin__s2member_before_query_level_access_sys", get_defined_vars ());
172
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
173
+ /**/
174
+ if ($initial_query && !is_admin () && (is_search () || is_feed ())) /* Searches/feeds. */
175
+ /**/
176
+ if (is_object ($wp_query) && !$wp_query->get ("suppress_filters")) /* Respect. */
177
+ {
178
+ $s[] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"];
179
+ $s[] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"];
180
+ $s[] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"];
181
+ /**/
182
+ $wp_query->set ("post__not_in", array_unique (array_merge ((array)$wp_query->get ("post__not_in"), $s)));
183
+ /**/
184
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
185
+ do_action ("_ws_plugin__s2member_during_query_level_access_sys", get_defined_vars ());
186
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
187
+ }
188
+ /**/
189
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
190
+ do_action ("_ws_plugin__s2member_after_query_level_access_sys", get_defined_vars ());
191
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
192
+ /**/
193
+ $initial_query = false; /* No longer. */
194
+ /**/
195
+ return; /* For uniformity. */
196
+ }
197
+ }
198
+ /*
199
+ Forces query filters ( on-demand ).
200
+ But still respects: `suppress_filters`.
201
+
202
+ s2Member respects the query var: `suppress_filters`.
203
+ If you need to make a query without it being filtered,
204
+ $wp_query->set ("suppress_filters", true);
205
+
206
+ Don't call this function directly, use one of these API functions:
207
+
208
+ Attach query filters:
209
+ - attach_s2member_query_filters();
210
+
211
+ Detach query filters:
212
+ - detach_s2member_query_filters();
213
+
214
+ see: `/s2member/includes/functions/api-functions.inc.php`.
215
+ */
216
+ if (!function_exists ("ws_plugin__s2member_force_query_level_access"))
217
+ {
218
+ function ws_plugin__s2member_force_query_level_access (&$wp_query = FALSE)
219
+ {
220
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
221
+ do_action ("ws_plugin__s2member_before_force_query_level_access", get_defined_vars ());
222
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
223
+ /**/
224
+ ws_plugin__s2member_query_level_access ($wp_query, "force-filters");
225
+ /**/
226
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
227
+ do_action ("ws_plugin__s2member_after_force_query_level_access", get_defined_vars ());
228
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
229
+ /**/
230
+ return; /* For uniformity. */
231
+ }
232
+ }
233
+ ?>
includes/functions/ruri-level-access.inc.php CHANGED
@@ -14,8 +14,19 @@ Direct access denial.
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /*
17
- Function for handling Request URI Level Access permissions.
18
- Attach to: add_action("template_redirect");
 
 
 
 
 
 
 
 
 
 
 
19
  */
20
  if (!function_exists ("ws_plugin__s2member_check_ruri_level_access"))
21
  {
@@ -25,41 +36,89 @@ if (!function_exists ("ws_plugin__s2member_check_ruri_level_access"))
25
  /**/
26
  $excluded = apply_filters ("ws_plugin__s2member_check_ruri_level_access_excluded", false, get_defined_vars ());
27
  /**/
28
- if (!$excluded && !ws_plugin__s2member_is_systematic_use_page () && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
29
  {
30
  $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
31
  /**/
32
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_ruris"])
33
- foreach (preg_split ("/[\r\n\t]+/", ws_plugin__s2member_fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_ruris"], $current_user)) as $str)
34
- if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && wp_redirect (add_query_arg ("s2member_level_req", "0", get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
35
- exit ();
36
- /**/
37
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_ruris"])
38
- foreach (preg_split ("/[\r\n\t]+/", ws_plugin__s2member_fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_ruris"], $current_user)) as $str)
39
- if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "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")
40
- exit ();
41
- /**/
42
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_ruris"])
43
- foreach (preg_split ("/[\r\n\t]+/", ws_plugin__s2member_fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_ruris"], $current_user)) as $str)
44
- if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "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
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_ruris"])
48
- foreach (preg_split ("/[\r\n\t]+/", ws_plugin__s2member_fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_ruris"], $current_user)) as $str)
49
- if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "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")
50
- exit ();
51
- /**/
52
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_ruris"])
53
- foreach (preg_split ("/[\r\n\t]+/", ws_plugin__s2member_fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_ruris"], $current_user)) as $str)
54
- if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "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
  do_action ("ws_plugin__s2member_during_check_ruri_level_access", get_defined_vars ());
58
  }
59
  /**/
60
  do_action ("ws_plugin__s2member_after_check_ruri_level_access", get_defined_vars ());
61
  /**/
62
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  }
64
  }
65
  /*
@@ -67,20 +126,20 @@ Function that fills replacement code variables in URIs; collectively.
67
  */
68
  if (!function_exists ("ws_plugin__s2member_fill_ruri_level_access_rc_vars"))
69
  {
70
- function ws_plugin__s2member_fill_ruri_level_access_rc_vars ($uris = FALSE, $current_user = FALSE)
71
  {
72
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
73
  do_action ("ws_plugin__s2member_before_fill_ruri_level_access_rc_vars", get_defined_vars ());
74
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
75
  /**/
76
- $current_user = (is_object ($current_user)) ? $current_user : wp_get_current_user ();
77
- $current_user_login = (is_object ($current_user)) ? strtolower ($current_user->user_login) : "";
78
- $current_user_ID = (is_object ($current_user)) ? (string)$current_user->ID : "";
79
- $current_user_level = (string)ws_plugin__s2member_user_access_level ($current_user);
80
  /**/
81
- $uris = preg_replace ("/%%current_user_login%%/i", ws_plugin__s2member_esc_ds ($current_user_login), $uris);
82
- $uris = preg_replace ("/%%current_user_ID%%/i", ws_plugin__s2member_esc_ds ($current_user_ID), $uris);
83
- $uris = preg_replace ("/%%current_user_level%%/i", ws_plugin__s2member_esc_ds ($current_user_level), $uris);
84
  /**/
85
  return apply_filters ("ws_plugin__s2member_fill_ruri_level_access_rc_vars", $uris, get_defined_vars ());
86
  }
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /*
17
+ Function for handling Request URI Level Access restrictions.
18
+
19
+ Don't call this function directly, use one of these API functions:
20
+
21
+ Is it protected by s2Member at all?
22
+ - is_uri_protected_by_s2member($uri [ or full url ]);
23
+ - is_protected_by_s2member($uri [ or full url ], "uri");
24
+
25
+ Is the current User permitted/authorized?
26
+ - is_uri_permitted_by_s2member($uri [ or full url ]);
27
+ - is_permitted_by_s2member($uri [ or full url ], "uri");
28
+
29
+ see: `/s2member/includes/functions/api-functions.inc.php`.
30
  */
31
  if (!function_exists ("ws_plugin__s2member_check_ruri_level_access"))
32
  {
36
  /**/
37
  $excluded = apply_filters ("ws_plugin__s2member_check_ruri_level_access_excluded", false, get_defined_vars ());
38
  /**/
39
+ if (!$excluded && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Has it been excluded? */
40
  {
41
  $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
42
  /**/
43
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = ws_plugin__s2member_login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")))
44
+ {
45
+ wp_redirect (add_query_arg ("s2member_level_req", 0, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
46
+ exit ();
47
+ }
48
+ else if (!ws_plugin__s2member_is_systematic_use_page ()) /* Do NOT protect Systematics. However, there is 1 exception above ^. */
49
+ {
50
+ for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
51
+ {
52
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
53
+ foreach (preg_split ("/[\r\n\t]+/", ws_plugin__s2member_fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
54
+ if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && ws_plugin__s2member_nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
55
+ {
56
+ wp_redirect (add_query_arg ("s2member_level_req", $i, get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])));
57
+ exit ();
58
+ }
59
+ }
60
+ }
 
 
 
 
 
 
61
  /**/
62
  do_action ("ws_plugin__s2member_during_check_ruri_level_access", get_defined_vars ());
63
  }
64
  /**/
65
  do_action ("ws_plugin__s2member_after_check_ruri_level_access", get_defined_vars ());
66
  /**/
67
+ return; /* For uniformity. */
68
+ }
69
+ }
70
+ /*
71
+ Function checks Request URI Level Access restrictions - for a specific URI/URL.
72
+
73
+ Don't call this function directly, use one of these API functions:
74
+
75
+ Is it protected by s2Member at all?
76
+ - is_uri_protected_by_s2member($uri [ or full url ]);
77
+ - is_protected_by_s2member($uri [ or full url ], "uri");
78
+
79
+ Is the current User permitted/authorized?
80
+ - is_uri_permitted_by_s2member($uri [ or full url ]);
81
+ - is_permitted_by_s2member($uri [ or full url ], "uri");
82
+
83
+ see: `/s2member/includes/functions/api-functions.inc.php`.
84
+ */
85
+ if (!function_exists ("ws_plugin__s2member_check_specific_ruri_level_access"))
86
+ {
87
+ function ws_plugin__s2member_check_specific_ruri_level_access ($__uri = FALSE, $check_user = TRUE)
88
+ {
89
+ do_action ("ws_plugin__s2member_before_check_specific_ruri_level_access", get_defined_vars ());
90
+ /**/
91
+ if ($__uri && is_string ($__uri)) /* We need to parse a URI. A full URL can be passed in. */
92
+ {
93
+ $path = parse_url ($__uri, PHP_URL_PATH); /* Parse req path. */
94
+ $query = parse_url ($__uri, PHP_URL_QUERY); /* Parse query. */
95
+ $uri = ($query) ? $path . "?" . $query : $path;
96
+ }
97
+ /**/
98
+ $excluded = apply_filters ("ws_plugin__s2member_check_specific_ruri_level_access_excluded", false, get_defined_vars ());
99
+ /**/
100
+ if (!$excluded && $uri && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Has it been excluded? */
101
+ {
102
+ $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
103
+ /**/
104
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = ws_plugin__s2member_login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level0")))
105
+ return apply_filters ("ws_plugin__s2member_check_specific_ruri_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
106
+ /**/
107
+ else if (!ws_plugin__s2member_is_systematic_use_specific_page (null, $uri)) /* Never restrict Systematic Use Pages. However, there is 1 exception above ^. */
108
+ {
109
+ for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
110
+ {
111
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
112
+ foreach (preg_split ("/[\r\n\t]+/", ws_plugin__s2member_fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
113
+ if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
114
+ return apply_filters ("ws_plugin__s2member_check_specific_ruri_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
115
+ }
116
+ }
117
+ /**/
118
+ do_action ("ws_plugin__s2member_during_check_specific_ruri_level_access", get_defined_vars ());
119
+ }
120
+ /**/
121
+ return apply_filters ("ws_plugin__s2member_check_specific_ruri_level_access", null, get_defined_vars ());
122
  }
123
  }
124
  /*
126
  */
127
  if (!function_exists ("ws_plugin__s2member_fill_ruri_level_access_rc_vars"))
128
  {
129
+ function ws_plugin__s2member_fill_ruri_level_access_rc_vars ($uris = FALSE, $user = FALSE)
130
  {
131
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
132
  do_action ("ws_plugin__s2member_before_fill_ruri_level_access_rc_vars", get_defined_vars ());
133
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
134
  /**/
135
+ $user = (is_object ($user)) ? $user : wp_get_current_user ();
136
+ $user_login = (is_object ($user)) ? strtolower ($user->user_login) : "";
137
+ $user_id = (is_object ($user)) ? (string)$user->ID : "";
138
+ $user_level = (string)ws_plugin__s2member_user_access_level ($user);
139
  /**/
140
+ $uris = preg_replace ("/%%current_user_login%%/i", ws_plugin__s2member_esc_ds ($user_login), $uris);
141
+ $uris = preg_replace ("/%%current_user_id%%/i", ws_plugin__s2member_esc_ds ($user_id), $uris);
142
+ $uris = preg_replace ("/%%current_user_level%%/i", ws_plugin__s2member_esc_ds ($user_level), $uris);
143
  /**/
144
  return apply_filters ("ws_plugin__s2member_fill_ruri_level_access_rc_vars", $uris, get_defined_vars ());
145
  }
includes/functions/sc-get-details.inc.php CHANGED
@@ -14,7 +14,11 @@ Direct access denial.
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit("Do not access this file directly.");
16
  /*
17
- Function that handles the Shortcode for [s2Get constant="S2MEMBER_CURRENT_USER_DISPLAY_NAME" /].
 
 
 
 
18
  Attach to: add_shortcode("s2Get");
19
  */
20
  if (!function_exists ("ws_plugin__s2member_sc_get_details"))
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit("Do not access this file directly.");
16
  /*
17
+ Function that handles the Shortcode for:
18
+ [s2Get constant="S2MEMBER_CURRENT_USER_DISPLAY_NAME" /]
19
+ [s2Get user_field="a_custom_registration_field" /]
20
+ [s2Get user_option="s2member_subscr_id" /]
21
+
22
  Attach to: add_shortcode("s2Get");
23
  */
24
  if (!function_exists ("ws_plugin__s2member_sc_get_details"))
includes/functions/sc-old-conditionals.inc.php DELETED
@@ -1,173 +0,0 @@
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("Do not access this file directly.");
16
- /*
17
- The following Shortcodes were deprecated in v3.2.2.
18
- Going forward, use [s2If] instead ( it's more powerful ).
19
- @NOTE: These Shortcodes were ONLY available in v3.2.1.
20
- ~ These WILL all be removed in the next release.
21
-
22
- Function that handles the Shortcode for [s2All ... simple conditionals][/s2All].
23
- Function that handles the Shortcode for [s2Any ... simple conditionals][/s2Any].
24
-
25
- Attach to: add_shortcode("s2All"), add_shortcode("_s2All"), add_shortcode("__s2All"), add_shortcode("___s2All");
26
- Attach to: add_shortcode("s2Any"), add_shortcode("_s2Any"), add_shortcode("__s2Any"), add_shortcode("___s2Any");
27
-
28
- [s2All is_user_logged_in="yes" current_user_can="access_s2member_level1"]
29
-
30
- Content appears here for Members with access to Level #1.
31
-
32
- [_s2All current_user_can="access_s2member_ccap_free_gift"]
33
- Free gift here with nested Custom Capability check.
34
- [/_s2All]
35
-
36
- [/s2All]
37
-
38
-
39
- [s2Any current_user_is="s2member_level1" current_user_is="s2member_level2"]
40
-
41
- Content appears here for Members at Level #1 and Level #2.
42
-
43
- [_s2Any current_user_can="access_s2member_ccap_free_gift"]
44
- Free gift here with nested Custom Capability check.
45
- [/_s2Any]
46
-
47
- [/s2Any]
48
-
49
- */
50
- if (!function_exists ("ws_plugin__s2member_sc_old_conditionals"))
51
- {
52
- function ws_plugin__s2member_sc_old_conditionals ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
53
- {
54
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
55
- do_action ("ws_plugin__s2member_before_sc_old_conditionals", get_defined_vars ());
56
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
57
- /**/
58
- $attr = ws_plugin__s2member_trim_quot_deep ($attr); /* Fix &quot; in Shortcode attrs
59
- that have been corrupted by a non-default visual editor; ( i.e. CKEditor does this ). */
60
- /**/
61
- if (is_multisite () && ws_plugin__s2member_is_multisite_farm () && !is_main_site ()) /* Restrict to a subset of the most useful Conditionals on a Blog Farm. */
62
- $attr = shortcode_atts (array ("is_user_logged_in" => "", "is_user_not_logged_in" => "", "current_user_is" => "", "current_user_is_not" => "", "current_user_is_for_blog" => "", "current_user_is_not_for_blog" => "", "current_user_can" => "", "current_user_cannot" => "", "current_user_can_for_blog" => "", "current_user_cannot_for_blog" => "", "is_404" => "", "is_home" => "", "is_front_page" => "", "is_singular" => "", "is_single" => "", "is_page" => "", "is_page_template" => "", "is_attachment" => "", "is_feed" => "", "is_archive" => "", "is_search" => "", "is_category" => "", "is_tax" => "", "is_tag" => "", "has_tag" => "", "is_author" => "", "is_date" => "", "is_day" => "", "is_month" => "", "is_time" => "", "is_year" => "", "is_sticky" => "", "is_paged" => "", "is_preview" => "", "in_the_loop" => "", "comments_open" => "", "pings_open" => "", "has_excerpt" => "", "has_post_image" => ""), $attr);
63
- /**/
64
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
65
- do_action ("ws_plugin__s2member_before_sc_old_conditionals_after_shortcode_atts", get_defined_vars ());
66
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
67
- /**/
68
- if (preg_match ("/^(_*)s2All$/i", $shortcode)) /* This is the AND variation. This routine analyzes conditionals using AND logic, instead of OR. */
69
- {
70
- foreach ($attr as $conditional => $_args) /* All conditions must evaluate to true; except for basic yes|no argument values that are = "no". */
71
- {
72
- if (strlen ($_args) && strlen ($_args = preg_replace ("/^array\(/i", "(", $_args))) /* Remove array() prefixes and leave only the () indicator. */
73
- if (strlen ($_args = preg_replace ("/[\r\n\t\s ]/", "", $_args)) && is_array ($args = preg_split ("/[;,]+/", $_args, 0, PREG_SPLIT_NO_EMPTY)) && !empty ($args))
74
- {
75
- $args_are_yes_no = preg_match ("/^(true|yes|false|no)$/", $_args); /* Args can be passed as a simple yes|no. ( is_tag="yes" ). */
76
- $args_are_yes = ($args_are_yes_no && preg_match ("/^(true|yes)$/", $_args)); /* Passed as a simple yes|no. ( is_tag="yes" ). */
77
- $args_are_array = (!$args_are_yes_no && preg_match ("/^\((.+?)\)$/", $_args)); /* Example: has_tag="(cheese,butter,salt)" */
78
- /**/
79
- try /* Using try/catch here to protect this routine from errors due to invalid arguments passed through Shortcode attrs. */
80
- {
81
- if ($args_are_yes_no) /* No args. Only testing the return value. */
82
- {
83
- if ($args_are_yes && !call_user_func ($conditional))
84
- {
85
- $condition_failed = true;
86
- break;
87
- }
88
- /**/
89
- else if (call_user_func ($conditional))
90
- {
91
- $condition_failed = true;
92
- break;
93
- }
94
- }
95
- /**/
96
- else if ($args_are_array && !call_user_func ($conditional, $args))
97
- {
98
- $condition_failed = true;
99
- break;
100
- }
101
- /**/
102
- else if (!call_user_func_array ($conditional, $args))
103
- {
104
- $condition_failed = true;
105
- break;
106
- }
107
- }
108
- /**/
109
- catch (Exception $e) /* Catch errors silently. */
110
- {
111
- $condition_failed = true;
112
- break;
113
- }
114
- }
115
- }
116
- /* Supports nested Shortcodes. */
117
- return do_shortcode (apply_filters ("ws_plugin__s2member_sc_old_conditionals", (($condition_failed) ? "" : $content), get_defined_vars ()));
118
- }
119
- /**/
120
- else if (preg_match ("/^(_*)s2Any$/i", $shortcode)) /* This is the OR variation. This routine analyzes conditionals using OR logic, instead of AND. */
121
- {
122
- foreach ($attr as $conditional => $_args) /* Any condition can evaluate to true; except for basic yes|no argument values that are = "no". */
123
- {
124
- if (strlen ($_args) && strlen ($_args = preg_replace ("/^array\(/i", "(", $_args))) /* Remove array() prefixes and leave only the () indicator. */
125
- if (strlen ($_args = preg_replace ("/[\r\n\t\s ]/", "", $_args)) && is_array ($args = preg_split ("/[;,]+/", $_args, 0, PREG_SPLIT_NO_EMPTY)) && !empty ($args))
126
- {
127
- $args_are_yes_no = preg_match ("/^(true|yes|false|no)$/", $_args); /* Args can be passed as a simple yes|no. ( is_tag="yes" ). */
128
- $args_are_yes = ($args_are_yes_no && preg_match ("/^(true|yes)$/", $_args)); /* Passed as a simple yes|no. ( is_tag="yes" ). */
129
- $args_are_array = (!$args_are_yes_no && preg_match ("/^\((.+?)\)$/", $_args)); /* Example: has_tag="(cheese,butter,salt)" */
130
- /**/
131
- try /* Using try/catch here to protect this routine from errors due to invalid arguments passed through Shortcode attrs. */
132
- {
133
- if ($args_are_yes_no) /* No args. Only testing the return value. */
134
- {
135
- if ($args_are_yes && call_user_func ($conditional))
136
- {
137
- $condition_succeeded = true;
138
- break;
139
- }
140
- /**/
141
- else if (!call_user_func ($conditional))
142
- {
143
- $condition_succeeded = true;
144
- break;
145
- }
146
- }
147
- /**/
148
- else if ($args_are_array && call_user_func ($conditional, $args))
149
- {
150
- $condition_succeeded = true;
151
- break;
152
- }
153
- /**/
154
- else if (call_user_func_array ($conditional, $args))
155
- {
156
- $condition_succeeded = true;
157
- break;
158
- }
159
- }
160
- /**/
161
- catch (Exception $e) /* Catch errors silently. */
162
- {
163
- $condition_succeeded = false;
164
- break;
165
- }
166
- }
167
- }
168
- /* Supports nested Shortcodes. */
169
- return do_shortcode (apply_filters ("ws_plugin__s2member_sc_old_conditionals", (($condition_succeeded) ? $content : ""), get_defined_vars ()));
170
- }
171
- }
172
- }
173
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/functions/security-gate.inc.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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("Do not access this file directly.");
16
+ /*
17
+ Function handles security/access routines.
18
+ ~ s2Member's Security Gate.
19
+ Highly optimized.
20
+ Attach to: add_action("pre_get_posts");
21
+ */
22
+ if (!function_exists ("ws_plugin__s2member_security_gate_query"))
23
+ {
24
+ function ws_plugin__s2member_security_gate_query (&$wp_query = FALSE)
25
+ {
26
+ do_action ("ws_plugin__s2member_before_security_gate_query", get_defined_vars ());
27
+ /**/
28
+ ws_plugin__s2member_query_level_access($wp_query); /* By reference. */
29
+ /**/
30
+ do_action ("ws_plugin__s2member_after_security_gate_query", get_defined_vars ());
31
+ /**/
32
+ return;
33
+ }
34
+ }
35
+ /*
36
+ Function handles security/access routines.
37
+ ~ s2Member's Security Gate.
38
+ Highly optimized.
39
+ Attach to: add_action("template_redirect");
40
+ */
41
+ if (!function_exists ("ws_plugin__s2member_security_gate"))
42
+ {
43
+ function ws_plugin__s2member_security_gate () /* s2Member's Security Gate. */
44
+ {
45
+ do_action ("ws_plugin__s2member_before_security_gate", get_defined_vars ());
46
+ /*
47
+ Category Level Restrictions ( inclusively ).
48
+ - Including URI protections too.
49
+ */
50
+ if (is_category ()) /* Categories. */
51
+ ws_plugin__s2member_check_catg_level_access ();
52
+ /*
53
+ Tag Level Restrictions ( inclusively ).
54
+ - Including URI protections too.
55
+ */
56
+ else if (is_tag ()) /* Tags. */
57
+ ws_plugin__s2member_check_ptag_level_access ();
58
+ /*
59
+ Post Level Restrictions ( inclusively, even Custom Post Types ).
60
+ - Including Category, Tag, URI, Capability, and Specifics too.
61
+ */
62
+ else if (is_single ()) /* Posts & Custom Types. */
63
+ ws_plugin__s2member_check_post_level_access ();
64
+ /*
65
+ Page Level Restrictions ( inclusively ).
66
+ - Including Category, Tag, URI, Capability, and Specifics too.
67
+ */
68
+ else if (is_page ()) /* Pages. */
69
+ ws_plugin__s2member_check_page_level_access ();
70
+ /*
71
+ Else just apply URI Level Restrictions ( only URIs ).
72
+ */
73
+ else /* This optimizes things nicely. */
74
+ ws_plugin__s2member_check_ruri_level_access ();
75
+ /*
76
+ Hook after Security Gate.
77
+ */
78
+ do_action ("ws_plugin__s2member_after_security_gate", get_defined_vars ());
79
+ /**/
80
+ return;
81
+ }
82
+ }
83
+ ?>
includes/functions/separates/index.php ADDED
File without changes
includes/functions/separates/paypal-notify.inc.php ADDED
@@ -0,0 +1,1488 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ("Do not access this file directly.");
16
+ /*
17
+ Handles PayPal® IPN URL processing.
18
+ These same routines also handle s2Member Pro/PayPal® Pro operations;
19
+ giving you the ability ( as needed ) to Hook into these routines using
20
+ WordPress® Hooks/Filters; as seen in the source code below.
21
+
22
+ Please do NOT modify the source code directly.
23
+ Instead, use WordPress® Hooks/Filters.
24
+
25
+ For example, if you'd like to add your own custom conditionals, use:
26
+ add_filter ("ws_plugin__s2member_during_paypal_notify_conditionals", "your_function");
27
+ */
28
+ if (!function_exists ("s__ws_plugin__s2member_paypal_notify"))
29
+ {
30
+ function s__ws_plugin__s2member_paypal_notify ()
31
+ {
32
+ include_once ABSPATH . "wp-admin/includes/admin.php";
33
+ /**/
34
+ global $current_site, $current_blog; /* For Multisite support. */
35
+ /**/
36
+ do_action ("ws_plugin__s2member_before_paypal_notify", get_defined_vars ());
37
+ /**/
38
+ if ($_GET["s2member_paypal_notify"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"])
39
+ {
40
+ if (is_array ($paypal = ws_plugin__s2member_paypal_postvars ())) /* Verify PayPal® POST vars. */
41
+ {
42
+ $paypal["s2member_log"][] = "IPN received on: " . date ("D M j, Y g:i:s a T");
43
+ $paypal["s2member_log"][] = "s2Member POST vars verified through a POST back to PayPal®.";
44
+ /**/
45
+ $payment_status_issues = "/^(failed|denied|expired|refunded|partially_refunded|reversed|reversal|canceled_reversal|voided)$/i";
46
+ /**/
47
+ $paypal["custom"] = (!$paypal["custom"]) ? ws_plugin__s2member_paypal_custom ($paypal["recurring_payment_id"]) : $paypal["custom"];
48
+ /* Notifications following the PayPal® Pro format for recurring payments, do NOT carry the "custom" value, so we do a lookup.
49
+ This is only crucial for one IPN call in Standard Integration: `txn_type=recurring_payment_suspended_due_to_max_failed_payment`.
50
+ In Pro Integrations, we just need to make sure the "custom" field is assigned for each account during on-site checkout.
51
+ This way the "custom" value will always be available when it needs to be; for both Standard and Pro services. */
52
+ if (preg_match ("/^" . preg_quote (preg_replace ("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $paypal["custom"]))
53
+ { /* The business address validation was removed from this routine, because PayPal® always fills that with the primary
54
+ email address. In cases where an alternate PayPal® address is being paid, validation was not possible. */
55
+ $paypal["s2member_log"][] = "s2Member originating domain ( _SERVER[HTTP_HOST] ) validated.";
56
+ /*
57
+ Custom conditionals can be applied by Filters.
58
+ */
59
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
60
+ if (!apply_filters ("ws_plugin__s2member_during_paypal_notify_conditionals", false, get_defined_vars ()))
61
+ {
62
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
63
+ /*
64
+ Virtual Terminal transactions.
65
+ This is not really necessary. It is only here because this txn_type could
66
+ be necessary in a future release of s2Member. For now, it's just a fill-in.
67
+ These Hooks/Filters will remain, so you can use them now; if you need to.
68
+ */
69
+ if (/**/(preg_match ("/^virtual_terminal$/i", $paypal["txn_type"]))/**/
70
+ && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
71
+ && ($paypal["txn_id"])/**/)
72
+ {
73
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
74
+ do_action ("ws_plugin__s2member_during_paypal_notify_before_virtual_terminal", get_defined_vars ());
75
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
76
+ /**/
77
+ $paypal["s2member_log"][] = "s2Member txn_type identified as virtual_terminal.";
78
+ /**/
79
+ $processing = $during = true; /* Yes, we ARE processing this. */
80
+ /**/
81
+ $paypal["s2member_log"][] = "The txn_type does not require any action on the part of s2Member.";
82
+ /**/
83
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
84
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_virtual_terminal", get_defined_vars ());
85
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
86
+ /**/
87
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
88
+ do_action ("ws_plugin__s2member_during_paypal_notify_after_virtual_terminal", get_defined_vars ());
89
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
90
+ }
91
+ /*
92
+ Express Checkout transactions.
93
+ This is not really necessary. It is only here because this txn_type could
94
+ be necessary in a future release of s2Member. For now, it's just a fill-in.
95
+ These Hooks/Filters will remain, so you can use them now; if you need to.
96
+ */
97
+ else if (/**/(preg_match ("/^express_checkout$/i", $paypal["txn_type"]))/**/
98
+ && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
99
+ && ($paypal["txn_id"])/**/)
100
+ {
101
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
102
+ do_action ("ws_plugin__s2member_during_paypal_notify_before_express_checkout", get_defined_vars ());
103
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
104
+ /**/
105
+ $paypal["s2member_log"][] = "s2Member txn_type identified as express_checkout.";
106
+ /**/
107
+ $processing = $during = true; /* Yes, we ARE processing this. */
108
+ /**/
109
+ $paypal["s2member_log"][] = "The txn_type does not require any action on the part of s2Member.";
110
+ $paypal["s2member_log"][] = "s2Member Pro handles Express Checkout events on-site, with an IPN proxy.";
111
+ /**/
112
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
113
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_express_checkout", get_defined_vars ());
114
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
115
+ /**/
116
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
117
+ do_action ("ws_plugin__s2member_during_paypal_notify_after_express_checkout", get_defined_vars ());
118
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
119
+ }
120
+ /*
121
+ Cart ( Line Item ) transactions.
122
+ This is not really necessary. It is only here because this txn_type could
123
+ be necessary in a future release of s2Member. For now, it's just a fill-in.
124
+ These Hooks/Filters will remain, so you can use them now; if you need to.
125
+ */
126
+ else if (/**/(preg_match ("/^cart$/i", $paypal["txn_type"]))/**/
127
+ && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
128
+ && ($paypal["txn_id"])/**/)
129
+ {
130
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
131
+ do_action ("ws_plugin__s2member_during_paypal_notify_before_cart", get_defined_vars ());
132
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
133
+ /**/
134
+ $paypal["s2member_log"][] = "s2Member txn_type identified as cart.";
135
+ /**/
136
+ $processing = $during = true; /* Yes, we ARE processing this. */
137
+ /**/
138
+ $paypal["s2member_log"][] = "The txn_type does not require any action on the part of s2Member.";
139
+ $paypal["s2member_log"][] = "s2Member Pro handles Cart events on-site, with an IPN proxy.";
140
+ /**/
141
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
142
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_cart", get_defined_vars ());
143
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
144
+ /**/
145
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
146
+ do_action ("ws_plugin__s2member_during_paypal_notify_after_cart", get_defined_vars ());
147
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
148
+ }
149
+ /*
150
+ Send Money / Mobile transactions.
151
+ This is not really necessary. It is only here because this txn_type could
152
+ be necessary in a future release of s2Member. For now, it's just a fill-in.
153
+ These Hooks/Filters will remain, so you can use them now; if you need to.
154
+ */
155
+ else if (/**/(preg_match ("/^send_money$/i", $paypal["txn_type"]))/**/
156
+ && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
157
+ && ($paypal["txn_id"])/**/)
158
+ {
159
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
160
+ do_action ("ws_plugin__s2member_during_paypal_notify_before_send_money", get_defined_vars ());
161
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
162
+ /**/
163
+ $paypal["s2member_log"][] = "s2Member txn_type identified as send_money.";
164
+ /**/
165
+ $processing = $during = true; /* Yes, we ARE processing this. */
166
+ /**/
167
+ $paypal["s2member_log"][] = "The txn_type does not require any action on the part of s2Member.";
168
+ /**/
169
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
170
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_send_money", get_defined_vars ());
171
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
172
+ /**/
173
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
174
+ do_action ("ws_plugin__s2member_during_paypal_notify_after_send_money", get_defined_vars ());
175
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
176
+ }
177
+ /*
178
+ Specific Post/Page Access ~ Sales.
179
+ */
180
+ else if (/**/(preg_match ("/^web_accept$/i", $paypal["txn_type"]))/**/
181
+ && (preg_match ("/^sp\:[0-9,]+\:[0-9]+$/", $paypal["item_number"]))/**/
182
+ && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
183
+ && ($paypal["payer_email"] && $paypal["txn_id"])/**/)
184
+ {
185
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
186
+ do_action ("ws_plugin__s2member_during_paypal_notify_before_sp_access", get_defined_vars ());
187
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
188
+ /**/
189
+ $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept) for Specific Post/Page Access.";
190
+ /**/
191
+ list (, $paypal["sp_ids"], $paypal["hours"]) = preg_split ("/\:/", $paypal["item_number"], 3);
192
+ /**/
193
+ if (($sp_access_url = ws_plugin__s2member_sp_access_link_gen ($paypal["sp_ids"], $paypal["hours"])) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
194
+ {
195
+ $processing = $during = true; /* Yes, we ARE processing this. */
196
+ /**/
197
+ $sbj = preg_replace ("/%%sp_access_url%%/i", ws_plugin__s2member_esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][ ( ($_GET["s2member_paypal_proxy"] === "s2member-pro-module") ? "pro_" : "") . "sp_email_subject"]);
198
+ $sbj = preg_replace ("/%%sp_access_exp%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours"))), $sbj);
199
+ /**/
200
+ $msg = preg_replace ("/%%sp_access_url%%/i", ws_plugin__s2member_esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][ ( ($_GET["s2member_paypal_proxy"] === "s2member-pro-module") ? "pro_" : "") . "sp_email_message"]);
201
+ $msg = preg_replace ("/%%sp_access_exp%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours"))), $msg);
202
+ /**/
203
+ $rec = preg_replace ("/%%sp_access_url%%/i", ws_plugin__s2member_esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][ ( ($_GET["s2member_paypal_proxy"] === "s2member-pro-module") ? "pro_" : "") . "sp_email_recipients"]);
204
+ $rec = preg_replace ("/%%sp_access_exp%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours"))), $rec);
205
+ /**/
206
+ if (($rec = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $rec)) && ($rec = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["txn_id"]), $rec)))
207
+ if (($rec = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $rec))) /* Full amount of the payment, before fee is subtracted. */
208
+ if (($rec = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $rec)) && ($rec = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $rec)))
209
+ if (($rec = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_dq (ws_plugin__s2member_esc_ds ($paypal["first_name"])), $rec)) && ($rec = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_dq (ws_plugin__s2member_esc_ds ($paypal["last_name"])), $rec)))
210
+ if (($rec = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_dq (ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $rec))) /* **NOTE** ws_plugin__s2member_esc_dq() is applied here. ( ex. "N\"ame" <email> ). */
211
+ if (($rec = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $rec)))
212
+ if (($recipients = preg_split ("/;+/", $rec))) /* Here we break the recipients into an array. */
213
+ /**/
214
+ if (($sbj = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)) && ($sbj = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["txn_id"]), $sbj)))
215
+ if (($sbj = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $sbj))) /* Full amount of the payment, before fee is subtracted. */
216
+ if (($sbj = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $sbj)) && ($sbj = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $sbj)))
217
+ if (($sbj = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $sbj)) && ($sbj = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $sbj)))
218
+ if (($sbj = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)))
219
+ if (($sbj = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $sbj)))
220
+ /**/
221
+ if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["txn_id"]), $msg)))
222
+ if (($msg = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $msg))) /* Full amount of the payment, before fee is subtracted. */
223
+ if (($msg = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $msg)))
224
+ if (($msg = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $msg)))
225
+ if (($msg = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
226
+ if (($msg = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $msg)))
227
+ /**/
228
+ if (($sbj = trim ($sbj)) && ($msg = trim ($msg))) /* Make sure they are not empty. */
229
+ {
230
+ foreach (ws_plugin__s2member_trim_deep ($recipients) as $recipient) /* Go through the full list of recipients. */
231
+ /**/
232
+ ($recipient) ? mail ($recipient, $sbj, $msg, "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
233
+ /**/
234
+ $paypal["s2member_log"][] = "Specific Post/Page Confirmation Email sent to: " . implode ("; ", $recipients) . ".";
235
+ }
236
+ /**/
237
+ if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_urls"])
238
+ {
239
+ foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_urls"]) as $url)
240
+ /**/
241
+ if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%sp_access_url%%/i", ws_plugin__s2member_esc_ds (rawurlencode ($sp_access_url)), $url)))
242
+ if (($url = preg_replace ("/%%sp_access_exp%%/i", ws_plugin__s2member_esc_ds (urlencode (ws_plugin__s2member_approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours")))), $url)))
243
+ if (($url = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["txn_id"])), $url)))
244
+ if (($url = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_name"])), $url)))
245
+ if (($url = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["last_name"])), $url)))
246
+ if (($url = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
247
+ if (($url = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["payer_email"])), $url)))
248
+ /**/
249
+ if (($url = trim ($url))) /* Empty? */
250
+ ws_plugin__s2member_remote($url);
251
+ /**/
252
+ $paypal["s2member_log"][] = "Specific Post/Page ~ Sale Notification URLs have been processed.";
253
+ }
254
+ /**/
255
+ if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_recipients"])
256
+ {
257
+ $msg = $sbj = "( s2Member / API Notification Email ) - Specific Post/Page ~ Sale";
258
+ $msg .= "\n\n"; /* Spacing in the message body. */
259
+ $msg .= "sp_access_url: %%sp_access_url%%\n";
260
+ $msg .= "sp_access_exp: %%sp_access_exp%%\n";
261
+ $msg .= "amount: %%amount%%\n";
262
+ $msg .= "txn_id: %%txn_id%%\n";
263
+ $msg .= "item_number: %%item_number%%\n";
264
+ $msg .= "item_name: %%item_name%%\n";
265
+ $msg .= "first_name: %%first_name%%\n";
266
+ $msg .= "last_name: %%last_name%%\n";
267
+ $msg .= "full_name: %%full_name%%\n";
268
+ $msg .= "payer_email: %%payer_email%%\n";
269
+ $msg .= "cv0: %%cv0%%\n";
270
+ $msg .= "cv1: %%cv1%%\n";
271
+ $msg .= "cv2: %%cv2%%\n";
272
+ $msg .= "cv3: %%cv3%%\n";
273
+ $msg .= "cv4: %%cv4%%\n";
274
+ $msg .= "cv5: %%cv5%%\n";
275
+ $msg .= "cv6: %%cv6%%\n";
276
+ $msg .= "cv7: %%cv7%%\n";
277
+ $msg .= "cv8: %%cv8%%\n";
278
+ $msg .= "cv9: %%cv9%%";
279
+ /**/
280
+ if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%sp_access_url%%/i", ws_plugin__s2member_esc_ds ($sp_access_url), $msg)))
281
+ if (($msg = preg_replace ("/%%sp_access_exp%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours"))), $msg)))
282
+ if (($msg = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $msg)) && ($msg = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["txn_id"]), $msg)))
283
+ if (($msg = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $msg)))
284
+ if (($msg = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $msg)))
285
+ if (($msg = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
286
+ if (($msg = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $msg)))
287
+ /**/
288
+ foreach (ws_plugin__s2member_trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_recipients"])) as $recipient)
289
+ /**/
290
+ ($recipient) ? mail ($recipient, $sbj, apply_filters ("ws_plugin__s2member_sp_sale_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
291
+ /**/
292
+ $paypal["s2member_log"][] = "Specific Post/Page ~ Sale Notification Emails have been processed.";
293
+ }
294
+ /**/
295
+ if ($processing && ($url = $paypal["proxy_return_url"])) /* A proxy is requesting a return URL for this transaction? */
296
+ {
297
+ if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%sp_access_url%%/i", ws_plugin__s2member_esc_ds (rawurlencode ($sp_access_url)), $url)))
298
+ if (($url = preg_replace ("/%%sp_access_exp%%/i", ws_plugin__s2member_esc_ds (urlencode (ws_plugin__s2member_approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours")))), $url)))
299
+ if (($url = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["txn_id"])), $url)))
300
+ if (($url = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_name"])), $url)))
301
+ if (($url = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["last_name"])), $url)))
302
+ if (($url = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
303
+ if (($url = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["payer_email"])), $url)))
304
+ /**/
305
+ if (($url = trim ($url))) /* Empty? */
306
+ $paypal["proxy_return_url"] = $url;
307
+ /**/
308
+ $paypal["s2member_log"][] = "Specific Post/Page Return, a Proxy Return URL is ready.";
309
+ }
310
+ /**/
311
+ if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_tracking_codes"]))
312
+ {
313
+ if (($code = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $code)) && ($code = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["txn_id"]), $code)))
314
+ if (($code = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $code)) && ($code = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $code)))
315
+ if (($code = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $code)) && ($code = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $code)))
316
+ if (($code = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
317
+ if (($code = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $code)))
318
+ /**/
319
+ if (($code = trim ($code))) /* Make sure it is not empty. This gets stored into a Transient Queue. */
320
+ {
321
+ $paypal["s2member_log"][] = "Storing Specific Post/Page Tracking Codes into a Transient Queue for s2Member. These will be processed on-site.";
322
+ set_transient (md5 ("s2member_transient_sp_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
323
+ }
324
+ }
325
+ /**/
326
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
327
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_sp_access", get_defined_vars ());
328
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
329
+ }
330
+ else
331
+ {
332
+ $paypal["s2member_log"][] = "Unable to generate Access Link for Specific Post/Page Access. Does your Leading Post/Page still exist?";
333
+ }
334
+ /**/
335
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
336
+ do_action ("ws_plugin__s2member_during_paypal_notify_after_sp_access", get_defined_vars ());
337
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
338
+ }
339
+ /*
340
+ New Subscriptions.
341
+ Possibly containing advanced update vars
342
+ ( option_name1, option_selection1 ); which allow account modifications.
343
+ */
344
+ else if (/**/(preg_match ("/^(web_accept|subscr_signup)$/i", $paypal["txn_type"]))/**/
345
+ && (preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"]))/**/
346
+ && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["txn_id"]))/**/
347
+ && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
348
+ && ($paypal["payer_email"])/**/)
349
+ {
350
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
351
+ do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_signup", get_defined_vars ());
352
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
353
+ /**/
354
+ $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup).";
355
+ /**/
356
+ list ($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split ("/\:/", $paypal["item_number"], 3);
357
+ /**/
358
+ if (preg_match ("/^web_accept$/i", $paypal["txn_type"])) /* Conversions for Lifetime & Fixed-Term sales. */
359
+ {
360
+ $paypal["period3"] = ($paypal["eotper"]) ? $paypal["eotper"] : "1 L"; /* This defaults to exactly 1 Lifetime. */
361
+ $paypal["mc_amount3"] = $paypal["mc_gross"]; /* The "Buy Now" amount. */
362
+ }
363
+ /**/
364
+ $paypal["initial_term"] = $paypal["period1"] ? $paypal["period1"] : "0 D"; /* Do not allow the initial period to be empty. Defaults to 0 D. */
365
+ $paypal["initial"] = (isset ($paypal["mc_amount1"]) && preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
366
+ $paypal["regular"] = $paypal["mc_amount3"]; /* This is the regular payment amount that is charged to the customer. Always required by PayPal. */
367
+ $paypal["regular_term"] = $paypal["period3"]; /* This is just set to keep a standard; this way both initial_term & regular_term are available. */
368
+ $paypal["recurring"] = ($paypal["recurring"]) ? $paypal["mc_amount3"] : "0"; /* If non-recurring, this should be zero, otherwise regular. */
369
+ /*
370
+ New Subscription with advanced update vars ( option_name1, option_selection1 ).
371
+ */
372
+ if (preg_match ("/(updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) /* This is an advanced way to handle Subscription update modifications. */
373
+ /* This advanced method is required whenever a Subscription that is already completed, or was never setup to recur in the first place needs to be modified. PayPal will not allow the
374
+ modify=1|2 parameter to be used in those scenarios, because technically there is nothing to update. The only thing that actually needs to be updated is the account. */
375
+ {
376
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
377
+ do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_signup_w_update_vars", get_defined_vars ());
378
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
379
+ /**/
380
+ $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup) w/ update vars.";
381
+ /**/
382
+ /* Check for both the old & new subscr_id's, just in case the Return routine already changed it. */
383
+ if (($user_id = ws_plugin__s2member_paypal_user_id ($paypal["subscr_id"], $paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
384
+ {
385
+ if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
386
+ {
387
+ $processing = $modifying = $during = true; /* Yes, we ARE processing this. */
388
+ /**/
389
+ $user->set_role ("s2member_level" . $paypal["level"]);
390
+ /**/
391
+ foreach ($user->allcaps as $cap => $cap_enabled)
392
+ if (preg_match ("/^access_s2member_ccap_/", $cap))
393
+ $user->remove_cap ($ccap = $cap);
394
+ /**/
395
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $paypal["ccaps"]) as $ccap)
396
+ if (strlen ($ccap)) /* Don't add empty capabilities. */
397
+ $user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
398
+ /**/
399
+ update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
400
+ update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
401
+ /**/
402
+ delete_user_option ($user_id, "s2member_file_download_access_arc");
403
+ delete_user_option ($user_id, "s2member_file_download_access_log");
404
+ /**/
405
+ if (preg_match ("/^web_accept$/i", $paypal["txn_type"]) && $paypal["eotper"])
406
+ update_user_option ($user_id, "s2member_auto_eot_time", ws_plugin__s2member_paypal_auto_eot_time (0, 0, 0, $paypal["eotper"]));
407
+ else /* Otherwise, we need to clear the eot time. */
408
+ delete_user_option ($user_id, "s2member_auto_eot_time");
409
+ /**/
410
+ ws_plugin__s2member_clear_user_note_lines ($user_id, "/^Demoted by s2Member\:/");
411
+ /**/
412
+ $paypal["s2member_log"][] = "s2Member Level/Capabilities updated w/ advanced update routines.";
413
+ /**/
414
+ mail ($paypal["payer_email"], "Thank You! Your membership has been updated.", "Thank You! Your membership has been updated to:\n" . $paypal["item_name"] . "\n\nYou'll need to log back in now.\n" . wp_login_url (), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8");
415
+ /**/
416
+ $paypal["s2member_log"][] = "Modification Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.";
417
+ /**/
418
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
419
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_signup_w_update_vars", get_defined_vars ());
420
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
421
+ }
422
+ else
423
+ {
424
+ $paypal["s2member_log"][] = "Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
425
+ }
426
+ }
427
+ else
428
+ {
429
+ $paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB. Please check the on0 and os0 variables in your Button Code.";
430
+ }
431
+ /**/
432
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
433
+ do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_signup_w_update_vars", get_defined_vars ());
434
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
435
+ }
436
+ /*
437
+ New Subscription. Normal Subscription signup, we are not updating anything for a past Subscription.
438
+ */
439
+ else /* Else this is a normal Subscription signup, we are not updating anything. */
440
+ {
441
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
442
+ do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_signup_wo_update_vars", get_defined_vars ());
443
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
444
+ /**/
445
+ $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup) w/o update vars.";
446
+ /**/
447
+ if (($registration_url = ws_plugin__s2member_register_link_gen ($paypal["subscr_id"], $paypal["custom"], $paypal["item_number"])) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
448
+ {
449
+ $processing = $during = true; /* Yes, we ARE processing this. */
450
+ /**/
451
+ $sbj = preg_replace ("/%%registration_url%%/i", ws_plugin__s2member_esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][ ( ($_GET["s2member_paypal_proxy"] === "s2member-pro-module") ? "pro_" : "") . "signup_email_subject"]);
452
+ $msg = preg_replace ("/%%registration_url%%/i", ws_plugin__s2member_esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][ ( ($_GET["s2member_paypal_proxy"] === "s2member-pro-module") ? "pro_" : "") . "signup_email_message"]);
453
+ $rec = preg_replace ("/%%registration_url%%/i", ws_plugin__s2member_esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][ ( ($_GET["s2member_paypal_proxy"] === "s2member-pro-module") ? "pro_" : "") . "signup_email_recipients"]);
454
+ /**/
455
+ if (($rec = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $rec)) && ($rec = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $rec)))
456
+ if (($rec = preg_replace ("/%%initial%%/i", ws_plugin__s2member_esc_ds ($paypal["initial"]), $rec)) && ($rec = preg_replace ("/%%regular%%/i", ws_plugin__s2member_esc_ds ($paypal["regular"]), $rec)))
457
+ if (($rec = preg_replace ("/%%initial_term%%/i", ws_plugin__s2member_esc_ds ($paypal["initial_term"]), $rec)) && ($rec = preg_replace ("/%%regular_term%%/i", ws_plugin__s2member_esc_ds ($paypal["regular_term"]), $rec)))
458
+ if (($rec = preg_replace ("/%%initial_cycle%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_paypal_term_cycle ($paypal["initial_term"])), $rec)) && ($rec = preg_replace ("/%%regular_cycle%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_paypal_term_cycle ($paypal["regular_term"])), $rec)))
459
+ if (($rec = preg_replace ("/%%recurring%%/i", ws_plugin__s2member_esc_ds ($paypal["recurring"]), $rec)) && ($rec = preg_replace ("/%%recurring\/regular_cycle%%/i", ws_plugin__s2member_esc_ds (( ($paypal["recurring"]) ? $paypal["recurring"] . " / " . ws_plugin__s2member_paypal_term_cycle ($paypal["regular_term"]) : "0 / non-recurring")), $rec)))
460
+ if (($rec = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $rec)) && ($rec = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $rec)))
461
+ if (($rec = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_dq (ws_plugin__s2member_esc_ds ($paypal["first_name"])), $rec)) && ($rec = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_dq (ws_plugin__s2member_esc_ds ($paypal["last_name"])), $rec)))
462
+ if (($rec = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_dq (ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $rec))) /* **NOTE** ws_plugin__s2member_esc_dq() is applied here. ( ex. "N\"ame" <email> ). */
463
+ if (($rec = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $rec)))
464
+ if (($recipients = preg_split ("/;+/", $rec))) /* Here we break the recipients into an array. */
465
+ /**/
466
+ if (($sbj = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)) && ($sbj = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $sbj)))
467
+ if (($sbj = preg_replace ("/%%initial%%/i", ws_plugin__s2member_esc_ds ($paypal["initial"]), $sbj)) && ($sbj = preg_replace ("/%%regular%%/i", ws_plugin__s2member_esc_ds ($paypal["regular"]), $sbj)))
468
+ if (($sbj = preg_replace ("/%%initial_term%%/i", ws_plugin__s2member_esc_ds ($paypal["initial_term"]), $sbj)) && ($sbj = preg_replace ("/%%regular_term%%/i", ws_plugin__s2member_esc_ds ($paypal["regular_term"]), $sbj)))
469
+ if (($sbj = preg_replace ("/%%initial_cycle%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_paypal_term_cycle ($paypal["initial_term"])), $sbj)) && ($sbj = preg_replace ("/%%regular_cycle%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_paypal_term_cycle ($paypal["regular_term"])), $sbj)))
470
+ if (($sbj = preg_replace ("/%%recurring%%/i", ws_plugin__s2member_esc_ds ($paypal["recurring"]), $sbj)) && ($sbj = preg_replace ("/%%recurring\/regular_cycle%%/i", ws_plugin__s2member_esc_ds (( ($paypal["recurring"]) ? $paypal["recurring"] . " / " . ws_plugin__s2member_paypal_term_cycle ($paypal["regular_term"]) : "0 / non-recurring")), $sbj)))
471
+ if (($sbj = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $sbj)) && ($sbj = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $sbj)))
472
+ if (($sbj = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $sbj)) && ($sbj = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $sbj)))
473
+ if (($sbj = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)))
474
+ if (($sbj = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $sbj)))
475
+ /**/
476
+ if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $msg)))
477
+ if (($msg = preg_replace ("/%%initial%%/i", ws_plugin__s2member_esc_ds ($paypal["initial"]), $msg)) && ($msg = preg_replace ("/%%regular%%/i", ws_plugin__s2member_esc_ds ($paypal["regular"]), $msg)))
478
+ if (($msg = preg_replace ("/%%initial_term%%/i", ws_plugin__s2member_esc_ds ($paypal["initial_term"]), $msg)) && ($msg = preg_replace ("/%%regular_term%%/i", ws_plugin__s2member_esc_ds ($paypal["regular_term"]), $msg)))
479
+ if (($msg = preg_replace ("/%%initial_cycle%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_paypal_term_cycle ($paypal["initial_term"])), $msg)) && ($msg = preg_replace ("/%%regular_cycle%%/i", ws_plugin__s2member_esc_ds (ws_plugin__s2member_paypal_term_cycle ($paypal["regular_term"])), $msg)))
480
+ if (($msg = preg_replace ("/%%recurring%%/i", ws_plugin__s2member_esc_ds ($paypal["recurring"]), $msg)) && ($msg = preg_replace ("/%%recurring\/regular_cycle%%/i", ws_plugin__s2member_esc_ds (( ($paypal["recurring"]) ? $paypal["recurring"] . " / " . ws_plugin__s2member_paypal_term_cycle ($paypal["regular_term"]) : "0 / non-recurring")), $msg)))
481
+ if (($msg = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $msg)))
482
+ if (($msg = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $msg)))
483
+ if (($msg = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
484
+ if (($msg = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $msg)))
485
+ /**/
486
+ if (($sbj = trim ($sbj)) && ($msg = trim ($msg))) /* Make sure they are not empty. */
487
+ {
488
+ foreach (ws_plugin__s2member_trim_deep ($recipients) as $recipient) /* Go through the full list of recipients. */
489
+ /**/
490
+ ($recipient) ? mail ($recipient, $sbj, $msg, "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
491
+ /**/
492
+ $paypal["s2member_log"][] = "Signup Confirmation Email sent to: " . implode ("; ", $recipients) . ".";
493
+ }
494
+ /**/
495
+ if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
496
+ {
497
+ foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_urls"]) as $url)
498
+ /**/
499
+ if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["subscr_id"])), $url)))
500
+ if (($url = preg_replace ("/%%initial%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["initial"])), $url)) && ($url = preg_replace ("/%%regular%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["regular"])), $url)) && ($url = preg_replace ("/%%recurring%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["recurring"])), $url)))
501
+ if (($url = preg_replace ("/%%initial_term%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["initial_term"])), $url)) && ($url = preg_replace ("/%%regular_term%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["regular_term"])), $url)))
502
+ if (($url = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_name"])), $url)))
503
+ if (($url = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["last_name"])), $url)))
504
+ if (($url = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
505
+ if (($url = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["payer_email"])), $url)))
506
+ /**/
507
+ if (($url = trim ($url))) /* Empty? */
508
+ ws_plugin__s2member_remote($url);
509
+ /**/
510
+ $paypal["s2member_log"][] = "Signup Notification URLs have been processed.";
511
+ }
512
+ /**/
513
+ if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
514
+ {
515
+ $msg = $sbj = "( s2Member / API Notification Email ) - Signup";
516
+ $msg .= "\n\n"; /* Spacing in the message body. */
517
+ $msg .= "subscr_id: %%subscr_id%%\n";
518
+ $msg .= "initial: %%initial%%\n";
519
+ $msg .= "regular: %%regular%%\n";
520
+ $msg .= "recurring: %%recurring%%\n";
521
+ $msg .= "initial_term: %%initial_term%%\n";
522
+ $msg .= "regular_term: %%regular_term%%\n";
523
+ $msg .= "item_number: %%item_number%%\n";
524
+ $msg .= "item_name: %%item_name%%\n";
525
+ $msg .= "first_name: %%first_name%%\n";
526
+ $msg .= "last_name: %%last_name%%\n";
527
+ $msg .= "full_name: %%full_name%%\n";
528
+ $msg .= "payer_email: %%payer_email%%\n";
529
+ $msg .= "cv0: %%cv0%%\n";
530
+ $msg .= "cv1: %%cv1%%\n";
531
+ $msg .= "cv2: %%cv2%%\n";
532
+ $msg .= "cv3: %%cv3%%\n";
533
+ $msg .= "cv4: %%cv4%%\n";
534
+ $msg .= "cv5: %%cv5%%\n";
535
+ $msg .= "cv6: %%cv6%%\n";
536
+ $msg .= "cv7: %%cv7%%\n";
537
+ $msg .= "cv8: %%cv8%%\n";
538
+ $msg .= "cv9: %%cv9%%";
539
+ /**/
540
+ if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $msg)))
541
+ if (($msg = preg_replace ("/%%initial%%/i", ws_plugin__s2member_esc_ds ($paypal["initial"]), $msg)) && ($msg = preg_replace ("/%%regular%%/i", ws_plugin__s2member_esc_ds ($paypal["regular"]), $msg)) && ($msg = preg_replace ("/%%recurring%%/i", ws_plugin__s2member_esc_ds ($paypal["recurring"]), $msg)))
542
+ if (($msg = preg_replace ("/%%initial_term%%/i", ws_plugin__s2member_esc_ds ($paypal["initial_term"]), $msg)) && ($msg = preg_replace ("/%%regular_term%%/i", ws_plugin__s2member_esc_ds ($paypal["regular_term"]), $msg)))
543
+ if (($msg = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $msg)))
544
+ if (($msg = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $msg)))
545
+ if (($msg = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
546
+ if (($msg = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $msg)))
547
+ /**/
548
+ foreach (ws_plugin__s2member_trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_recipients"])) as $recipient)
549
+ /**/
550
+ ($recipient) ? mail ($recipient, $sbj, apply_filters ("ws_plugin__s2member_signup_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
551
+ /**/
552
+ $paypal["s2member_log"][] = "Signup Notification Emails have been processed.";
553
+ }
554
+ /**/
555
+ if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
556
+ {
557
+ if (($code = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $code)))
558
+ if (($code = preg_replace ("/%%initial%%/i", ws_plugin__s2member_esc_ds ($paypal["initial"]), $code)) && ($code = preg_replace ("/%%regular%%/i", ws_plugin__s2member_esc_ds ($paypal["regular"]), $code)) && ($code = preg_replace ("/%%recurring%%/i", ws_plugin__s2member_esc_ds ($paypal["recurring"]), $code)))
559
+ if (($code = preg_replace ("/%%initial_term%%/i", ws_plugin__s2member_esc_ds ($paypal["initial_term"]), $code)) && ($code = preg_replace ("/%%regular_term%%/i", ws_plugin__s2member_esc_ds ($paypal["regular_term"]), $code)))
560
+ if (($code = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $code)) && ($code = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $code)))
561
+ if (($code = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $code)) && ($code = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $code)))
562
+ if (($code = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
563
+ if (($code = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $code)))
564
+ /**/
565
+ if (($code = trim ($code))) /* Make sure it is not empty. This gets stored into a Transient Queue. */
566
+ {
567
+ $paypal["s2member_log"][] = "Storing Signup Tracking Codes into a Transient Queue for s2Member. These will be processed on-site.";
568
+ set_transient (md5 ("s2member_transient_signup_tracking_codes_" . $paypal["subscr_id"]), $code, 43200);
569
+ }
570
+ }
571
+ /**/
572
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
573
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_signup_wo_update_vars", get_defined_vars ());
574
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
575
+ }
576
+ else
577
+ {
578
+ $paypal["s2member_log"][] = "Unable to generate Registration URL for Membership Access. Possible data corruption within the IPN response.";
579
+ }
580
+ /**/
581
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
582
+ do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_signup_wo_update_vars", get_defined_vars ());
583
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
584
+ }
585
+ /**/
586
+ if ($processing && ($url = $paypal["proxy_return_url"])) /* A proxy is requesting a return URL for this transaction? */
587
+ {
588
+ if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["subscr_id"])), $url)))
589
+ if (($url = preg_replace ("/%%initial%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["initial"])), $url)) && ($url = preg_replace ("/%%regular%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["regular"])), $url)) && ($url = preg_replace ("/%%recurring%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["recurring"])), $url)))
590
+ if (($url = preg_replace ("/%%initial_term%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["initial_term"])), $url)) && ($url = preg_replace ("/%%regular_term%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["regular_term"])), $url)))
591
+ if (($url = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_name"])), $url)))
592
+ if (($url = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["last_name"])), $url)))
593
+ if (($url = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
594
+ if (($url = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["payer_email"])), $url)))
595
+ if (($url = preg_replace ("/%%modification%%/i", ws_plugin__s2member_esc_ds (urlencode ((int)$modifying)), $url)))
596
+ /* The modification variable indicates whether this was a modification, or a new signup. */
597
+ if (($url = trim ($url))) /* Empty? */
598
+ $paypal["proxy_return_url"] = $url;
599
+ /**/
600
+ $paypal["s2member_log"][] = "Subscr. Return ( modification=" . (int)$modifying . " ), a Proxy Return URL is ready.";
601
+ }
602
+ /**/
603
+ if ($processing && preg_match ("/^web_accept$/i", $paypal["txn_type"]) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
604
+ {
605
+ foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url)
606
+ /**/
607
+ if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["subscr_id"])), $url)))
608
+ if (($url = preg_replace ("/%%subscr_payment%%/i", ws_plugin__s2member_esc_ds (urlencode ("0")), $url)) && ($url = preg_replace ("/%%subscr_payment_user_id%%/i", ws_plugin__s2member_esc_ds (urlencode ("")), $url)))
609
+ if (($url = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["txn_id"])), $url)))
610
+ if (($url = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_name"])), $url)))
611
+ if (($url = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["last_name"])), $url)))
612
+ if (($url = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
613
+ if (($url = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["payer_email"])), $url)))
614
+ /**/
615
+ if (($url = trim ($url))) /* Empty? */
616
+ ws_plugin__s2member_remote($url);
617
+ /**/
618
+ $paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
619
+ }
620
+ /**/
621
+ if ($processing && preg_match ("/^web_accept$/i", $paypal["txn_type"]) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
622
+ {
623
+ $msg = $sbj = "( s2Member / API Notification Email ) - Payment";
624
+ $msg .= "\n\n"; /* Spacing in the message body. */
625
+ $msg .= "subscr_id: %%subscr_id%%\n";
626
+ $msg .= "subscr_payment: %%subscr_payment%%\n";
627
+ $msg .= "subscr_payment_user_id: %%subscr_payment_user_id%%\n";
628
+ $msg .= "amount: %%amount%%\n";
629
+ $msg .= "txn_id: %%txn_id%%\n";
630
+ $msg .= "item_number: %%item_number%%\n";
631
+ $msg .= "item_name: %%item_name%%\n";
632
+ $msg .= "first_name: %%first_name%%\n";
633
+ $msg .= "last_name: %%last_name%%\n";
634
+ $msg .= "full_name: %%full_name%%\n";
635
+ $msg .= "payer_email: %%payer_email%%\n";
636
+ $msg .= "cv0: %%cv0%%\n";
637
+ $msg .= "cv1: %%cv1%%\n";
638
+ $msg .= "cv2: %%cv2%%\n";
639
+ $msg .= "cv3: %%cv3%%\n";
640
+ $msg .= "cv4: %%cv4%%\n";
641
+ $msg .= "cv5: %%cv5%%\n";
642
+ $msg .= "cv6: %%cv6%%\n";
643
+ $msg .= "cv7: %%cv7%%\n";
644
+ $msg .= "cv8: %%cv8%%\n";
645
+ $msg .= "cv9: %%cv9%%";
646
+ /**/
647
+ if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $msg)))
648
+ if (($msg = preg_replace ("/%%subscr_payment%%/i", ws_plugin__s2member_esc_ds ("0"), $msg)) && ($msg = preg_replace ("/%%subscr_payment_user_id%%/i", ws_plugin__s2member_esc_ds (""), $msg)))
649
+ if (($msg = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $msg)) && ($msg = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["txn_id"]), $msg)))
650
+ if (($msg = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $msg)))
651
+ if (($msg = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $msg)))
652
+ if (($msg = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
653
+ if (($msg = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $msg)))
654
+ /**/
655
+ foreach (ws_plugin__s2member_trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"])) as $recipient)
656
+ /**/
657
+ ($recipient) ? mail ($recipient, $sbj, apply_filters ("ws_plugin__s2member_payment_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
658
+ /**/
659
+ $paypal["s2member_log"][] = "Payment Notification Emails have been processed.";
660
+ }
661
+ /**/
662
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
663
+ do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_signup", get_defined_vars ());
664
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
665
+ }
666
+ /*
667
+ Recurring payment profile creation.
668
+ This is not really necessary. It is only here because this txn_type could
669
+ be necessary in a future release of s2Member. For now, it's just a fill-in.
670
+ These Hooks/Filters will remain, so you can use them now; if you need to.
671
+ */
672
+ else if (/**/(preg_match ("/^recurring_payment_profile_created$/i", $paypal["txn_type"]))/**/
673
+ && ($paypal["item_number"] || ($paypal["item_number"] = ws_plugin__s2member_paypal_pro_item_number ($paypal)))/**/
674
+ && (preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"]))/**/
675
+ && ($paypal["subscr_id"] || ($paypal["subscr_id"] = ws_plugin__s2member_paypal_pro_subscr_id ($paypal)))/**/
676
+ && ($paypal["item_name"] || ($paypal["item_name"] = ws_plugin__s2member_paypal_pro_item_name ($paypal)))/**/
677
+ && ($paypal["payer_email"] || ($paypal["payer_email"] = ws_plugin__s2member_paypal_email ($paypal["subscr_id"])))/**/)
678
+ {
679
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
680
+ do_action ("ws_plugin__s2member_during_paypal_notify_before_recurring_payment_profile_created", get_defined_vars ());
681
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
682
+ /**/
683
+ $paypal["s2member_log"][] = "s2Member txn_type identified as recurring_payment_profile_created.";
684
+ /**/
685
+ $processing = $during = true; /* Yes, we ARE processing this. */
686
+ /**/
687
+ $paypal["s2member_log"][] = "The txn_type does not require any action on the part of s2Member.";
688
+ $paypal["s2member_log"][] = "s2Member Pro handles this event on-site, with an IPN proxy.";
689
+ /**/
690
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
691
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_recurring_payment_profile_created", get_defined_vars ());
692
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
693
+ /**/
694
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
695
+ do_action ("ws_plugin__s2member_during_paypal_notify_after_recurring_payment_profile_created", get_defined_vars ());
696
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
697
+ }
698
+ /*
699
+ Subscription modifications.
700
+ */
701
+ else if (/**/(preg_match ("/^subscr_modify$/i", $paypal["txn_type"]))/**/
702
+ && (preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"]))/**/
703
+ && ($paypal["subscr_id"] && $paypal["payer_email"])/**/)
704
+ {
705
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
706
+ do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_modify", get_defined_vars ());
707
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
708
+ /**/
709
+ $paypal["s2member_log"][] = "s2Member txn_type identified as subscr_modify.";
710
+ /**/
711
+ list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
712
+ /**/
713
+ if (($user_id = ws_plugin__s2member_paypal_user_id ($paypal["subscr_id"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
714
+ {
715
+ if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
716
+ {
717
+ $processing = $modifying = $during = true; /* Yes, we ARE processing this. */
718
+ /**/
719
+ $user->set_role ("s2member_level" . $paypal["level"]);
720
+ /**/
721
+ foreach ($user->allcaps as $cap => $cap_enabled)
722
+ if (preg_match ("/^access_s2member_ccap_/", $cap))
723
+ $user->remove_cap ($ccap = $cap);
724
+ /**/
725
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $paypal["ccaps"]) as $ccap)
726
+ if (strlen ($ccap)) /* Don't add empty capabilities. */
727
+ $user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
728
+ /**/
729
+ update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
730
+ update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
731
+ /**/
732
+ delete_user_option ($user_id, "s2member_file_download_access_arc");
733
+ delete_user_option ($user_id, "s2member_file_download_access_log");
734
+ /**/
735
+ delete_user_option ($user_id, "s2member_auto_eot_time");
736
+ /**/
737
+ ws_plugin__s2member_clear_user_note_lines ($user_id, "/^Demoted by s2Member\:/");
738
+ /**/
739
+ $paypal["s2member_log"][] = "s2Member Level/Capabilities updated on Subscription modification.";
740
+ /**/
741
+ mail ($paypal["payer_email"], "Thank You! Your membership has been updated.", "Thank You! Your membership has been updated to:\n" . $paypal["item_name"] . "\n\nYou'll need to log back in now.\n" . wp_login_url (), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8");
742
+ /**/
743
+ $paypal["s2member_log"][] = "Modification Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.";
744
+ /**/
745
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
746
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_modify", get_defined_vars ());
747
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
748
+ }
749
+ else
750
+ {
751
+ $paypal["s2member_log"][] = "Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
752
+ }
753
+ }
754
+ else
755
+ {
756
+ $paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB.";
757
+ }
758
+ /**/
759
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
760
+ do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_modify", get_defined_vars ());
761
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
762
+ }
763
+ /*
764
+ Subscription payment notifications.
765
+ We need these to update: `s2member_last_payment_time`.
766
+ */
767
+ else if (/**/(preg_match ("/^(subscr_payment|recurring_payment)$/i", $paypal["txn_type"]))/**/
768
+ && ($paypal["item_number"] || ($paypal["item_number"] = ws_plugin__s2member_paypal_pro_item_number ($paypal)))/**/
769
+ && (preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"]))/**/
770
+ && ($paypal["subscr_id"] || ($paypal["subscr_id"] = ws_plugin__s2member_paypal_pro_subscr_id ($paypal)))/**/
771
+ && (!preg_match ($payment_status_issues, $paypal["payment_status"])) /* Status OK? */
772
+ && ($paypal["item_name"] || ($paypal["item_name"] = ws_plugin__s2member_paypal_pro_item_name ($paypal)))/**/
773
+ && ($paypal["payer_email"] || ($paypal["payer_email"] = ws_plugin__s2member_paypal_email ($paypal["subscr_id"])))/**/
774
+ && ($paypal["txn_id"] && $paypal["mc_gross"])/**/)
775
+ {
776
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
777
+ do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_payment", get_defined_vars ());
778
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
779
+ /**/
780
+ $paypal["s2member_log"][] = "s2Member txn_type identified as subscr_payment|recurring_payment.";
781
+ $paypal["s2member_log"][] = "Sleeping for 2 seconds. Waiting for a possible subscr_signup|subscr_modify|recurring_payment_profile_created.";
782
+ sleep (2); /* Sleep here for a moment. PayPal® sometimes sends a subscr_payment before the subscr_signup, subscr_modify.
783
+ It is NOT a big deal if they do. However, s2Member goes to sleep here, just to help keep the log files in a logical order. */
784
+ $paypal["s2member_log"][] = "Awake. It's " . date ("D M j, Y g:i:s a T") . ". s2Member txn_type identified as subscr_payment|recurring_payment.";
785
+ /**/
786
+ list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
787
+ /**/
788
+ if (($user_id = ws_plugin__s2member_paypal_user_id ($paypal["subscr_id"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
789
+ {
790
+ $processing = $during = true; /* Yes, we ARE processing this. */
791
+ /**/
792
+ update_user_option ($user_id, "s2member_last_payment_time", time ());
793
+ /**/
794
+ $paypal["s2member_log"][] = "Updated Last Payment Time for this Member.";
795
+ /**/
796
+ if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
797
+ {
798
+ foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url)
799
+ /**/
800
+ if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["subscr_id"])), $url)))
801
+ if (($url = preg_replace ("/%%subscr_payment%%/i", ws_plugin__s2member_esc_ds (urlencode ("1")), $url)) && ($url = preg_replace ("/%%subscr_payment_user_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($user_id)), $url)))
802
+ if (($url = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["txn_id"])), $url)))
803
+ if (($url = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_name"])), $url)))
804
+ if (($url = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["last_name"])), $url)))
805
+ if (($url = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
806
+ if (($url = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["payer_email"])), $url)))
807
+ /**/
808
+ if (($url = trim ($url))) /* Empty? */
809
+ ws_plugin__s2member_remote($url);
810
+ /**/
811
+ $paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
812
+ }
813
+ /**/
814
+ if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
815
+ {
816
+ $msg = $sbj = "( s2Member / API Notification Email ) - Payment";
817
+ $msg .= "\n\n"; /* Spacing in the message body. */
818
+ $msg .= "subscr_id: %%subscr_id%%\n";
819
+ $msg .= "subscr_payment: %%subscr_payment%%\n";
820
+ $msg .= "subscr_payment_user_id: %%subscr_payment_user_id%%\n";
821
+ $msg .= "amount: %%amount%%\n";
822
+ $msg .= "txn_id: %%txn_id%%\n";
823
+ $msg .= "item_number: %%item_number%%\n";
824
+ $msg .= "item_name: %%item_name%%\n";
825
+ $msg .= "first_name: %%first_name%%\n";
826
+ $msg .= "last_name: %%last_name%%\n";
827
+ $msg .= "full_name: %%full_name%%\n";
828
+ $msg .= "payer_email: %%payer_email%%\n";
829
+ $msg .= "cv0: %%cv0%%\n";
830
+ $msg .= "cv1: %%cv1%%\n";
831
+ $msg .= "cv2: %%cv2%%\n";
832
+ $msg .= "cv3: %%cv3%%\n";
833
+ $msg .= "cv4: %%cv4%%\n";
834
+ $msg .= "cv5: %%cv5%%\n";
835
+ $msg .= "cv6: %%cv6%%\n";
836
+ $msg .= "cv7: %%cv7%%\n";
837
+ $msg .= "cv8: %%cv8%%\n";
838
+ $msg .= "cv9: %%cv9%%";
839
+ /**/
840
+ if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $msg)))
841
+ if (($msg = preg_replace ("/%%subscr_payment%%/i", ws_plugin__s2member_esc_ds ("1"), $msg)) && ($msg = preg_replace ("/%%subscr_payment_user_id%%/i", ws_plugin__s2member_esc_ds ($user_id), $msg)))
842
+ if (($msg = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $msg)) && ($msg = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["txn_id"]), $msg)))
843
+ if (($msg = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $msg)))
844
+ if (($msg = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $msg)))
845
+ if (($msg = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
846
+ if (($msg = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $msg)))
847
+ /**/
848
+ foreach (ws_plugin__s2member_trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"])) as $recipient)
849
+ /**/
850
+ ($recipient) ? mail ($recipient, $sbj, apply_filters ("ws_plugin__s2member_payment_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
851
+ /**/
852
+ $paypal["s2member_log"][] = "Payment Notification Emails have been processed.";
853
+ }
854
+ /**/
855
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
856
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_payment", get_defined_vars ());
857
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
858
+ }
859
+ else
860
+ {
861
+ $paypal["s2member_log"][] = "Skipping this IPN response, for now. The Subscr. ID is not associated with a registered Member.";
862
+ $paypal["s2member_log"][] = "Storing this IPN response into a Transient Queue for s2Member. This will be re-processed when registration occurs.";
863
+ set_transient (md5 ("s2member_transient_ipn_subscr_payment_" . $paypal["subscr_id"]), $_POST, 43200);
864
+ }
865
+ /**/
866
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
867
+ do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_payment", get_defined_vars ());
868
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
869
+ }
870
+ /*
871
+ Subscription failed payment notifications.
872
+ This is not really necessary. It is only here because this txn_type could
873
+ be necessary in a future release of s2Member. For now, it's just a fill-in.
874
+ These Hooks/Filters will remain, so you can use them now; if you need to.
875
+ */
876
+ else if (/**/(preg_match ("/^(subscr_failed|recurring_payment_failed|recurring_payment_skipped)$/i", $paypal["txn_type"]))/**/
877
+ && ($paypal["item_number"] || ($paypal["item_number"] = ws_plugin__s2member_paypal_pro_item_number ($paypal)))/**/
878
+ && (preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"]))/**/
879
+ && ($paypal["subscr_id"] || ($paypal["subscr_id"] = ws_plugin__s2member_paypal_pro_subscr_id ($paypal)))/**/
880
+ && ($paypal["item_name"] || ($paypal["item_name"] = ws_plugin__s2member_paypal_pro_item_name ($paypal)))/**/
881
+ && ($paypal["payer_email"] || ($paypal["payer_email"] = ws_plugin__s2member_paypal_email ($paypal["subscr_id"])))/**/)
882
+ {
883
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
884
+ do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_failed", get_defined_vars ());
885
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
886
+ /**/
887
+ $paypal["s2member_log"][] = "s2Member txn_type identified as subscr_failed|recurring_payment_failed|recurring_payment_skipped.";
888
+ /**/
889
+ $processing = $during = true; /* Yes, we ARE processing this. */
890
+ /**/
891
+ $paypal["s2member_log"][] = "This txn_type does not require any action on the part of s2Member.";
892
+ $paypal["s2member_log"][] = "s2Member does NOT respond to individual failed payments, only multiple consecutive failed payments.";
893
+ $paypal["s2member_log"][] = "When multiple consecutive payments fail, a special IPN response will be triggered.";
894
+ /**/
895
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
896
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_failed", get_defined_vars ());
897
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
898
+ /**/
899
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
900
+ do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_failed", get_defined_vars ());
901
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
902
+ }
903
+ /*
904
+ Subscription cancellations. s2Member can use this, to determine when/if it should Auto-EOT (demote|delete) a Member's account.
905
+ This processing routine for `subscr_cancel` is compatible with newer PayPal® accounts that do NOT send a subscr_eot after cancellation.
906
+ This works in conjunction with `s2member_last_payment_time`, and the s2Member Auto-EOT System.
907
+ For further details, see: https://www.x.com/thread/41155?start=15&tstart=0
908
+ */
909
+ else if (/**/(preg_match ("/^(subscr_cancel|recurring_payment_profile_cancel)$/i", $paypal["txn_type"]))/**/
910
+ && ! (preg_match ("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]) && preg_match ("/^failed$/i", $paypal["initial_payment_status"]))
911
+ /* ^^ Bypass this case ( for now ) "recurring_payment_profile_cancel" with an initial failed payment warrants an Immediate EOT instead. */
912
+ && ($paypal["item_number"] || ($paypal["item_number"] = ws_plugin__s2member_paypal_pro_item_number ($paypal)))/**/
913
+ && (preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"]))/**/
914
+ && ($paypal["period1"] || ($paypal["period1"] = ws_plugin__s2member_paypal_pro_period1 ($paypal)))/**/
915
+ && ($paypal["period3"] || ($paypal["period3"] = ws_plugin__s2member_paypal_pro_period3 ($paypal)))/**/
916
+ && ($paypal["subscr_id"] || ($paypal["subscr_id"] = ws_plugin__s2member_paypal_pro_subscr_id ($paypal)))/**/
917
+ && ($paypal["item_name"] || ($paypal["item_name"] = ws_plugin__s2member_paypal_pro_item_name ($paypal)))/**/
918
+ && ($paypal["payer_email"] || ($paypal["payer_email"] = ws_plugin__s2member_paypal_email ($paypal["subscr_id"])))/**/)
919
+ {
920
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
921
+ do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_cancel", get_defined_vars ());
922
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
923
+ /**/
924
+ $paypal["s2member_log"][] = "s2Member txn_type identified as subscr_cancel|recurring_payment_profile_cancel.";
925
+ /**/
926
+ list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
927
+ /**/
928
+ if (($user_id = ws_plugin__s2member_paypal_user_id ($paypal["subscr_id"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
929
+ {
930
+ if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
931
+ {
932
+ if (!get_user_option ("s2member_auto_eot_time", $user_id)) /* Respect existing. */
933
+ {
934
+ $processing = $during = true; /* Yes, we ARE processing this. */
935
+ /**/
936
+ $auto_eot_time = ws_plugin__s2member_paypal_auto_eot_time ($user_id, $paypal["period1"], $paypal["period3"]);
937
+ /**/
938
+ update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time); /* s2Member will follow-up on this later. */
939
+ /**/
940
+ $paypal["s2member_log"][] = "Auto-EOT Time for this account: " . date ("D M j, Y g:i a T", $auto_eot_time);
941
+ /**/
942
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
943
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_cancel", get_defined_vars ());
944
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
945
+ }
946
+ else
947
+ {
948
+ $paypal["s2member_log"][] = "Ignoring Cancellation. An Auto-EOT Time is already set for this Member. An s2Member API Notification will still be processed however.";
949
+ }
950
+ }
951
+ else
952
+ {
953
+ $paypal["s2member_log"][] = "Ignoring Cancellation. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
954
+ }
955
+ /**/
956
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
957
+ {
958
+ foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_urls"]) as $url) /* Handle Cancellation Notifications. */
959
+ /**/
960
+ if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["subscr_id"])), $url)))
961
+ if (($url = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_name"])), $url)))
962
+ if (($url = preg_replace ("/%%user_first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->first_name)), $url)) && ($url = preg_replace ("/%%user_last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->last_name)), $url)))
963
+ if (($url = preg_replace ("/%%user_full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
964
+ if (($url = preg_replace ("/%%user_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->user_email)), $url)))
965
+ if (($url = preg_replace ("/%%user_login%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->user_login)), $url)))
966
+ if (($url = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($user_id)), $url)))
967
+ /**/
968
+ if (($url = trim ($url))) /* Empty? */
969
+ ws_plugin__s2member_remote($url);
970
+ /**/
971
+ $paypal["s2member_log"][] = "Cancellation Notification URLs have been processed.";
972
+ }
973
+ /**/
974
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
975
+ {
976
+ $msg = $sbj = "( s2Member / API Notification Email ) - Cancellation";
977
+ $msg .= "\n\n"; /* Spacing in the message body. */
978
+ $msg .= "subscr_id: %%subscr_id%%\n";
979
+ $msg .= "item_number: %%item_number%%\n";
980
+ $msg .= "item_name: %%item_name%%\n";
981
+ $msg .= "user_first_name: %%user_first_name%%\n";
982
+ $msg .= "user_last_name: %%user_last_name%%\n";
983
+ $msg .= "user_full_name: %%user_full_name%%\n";
984
+ $msg .= "user_email: %%user_email%%\n";
985
+ $msg .= "user_login: %%user_login%%\n";
986
+ $msg .= "user_id: %%user_id%%\n";
987
+ $msg .= "cv0: %%cv0%%\n";
988
+ $msg .= "cv1: %%cv1%%\n";
989
+ $msg .= "cv2: %%cv2%%\n";
990
+ $msg .= "cv3: %%cv3%%\n";
991
+ $msg .= "cv4: %%cv4%%\n";
992
+ $msg .= "cv5: %%cv5%%\n";
993
+ $msg .= "cv6: %%cv6%%\n";
994
+ $msg .= "cv7: %%cv7%%\n";
995
+ $msg .= "cv8: %%cv8%%\n";
996
+ $msg .= "cv9: %%cv9%%";
997
+ /**/
998
+ if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $msg)))
999
+ if (($msg = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $msg)))
1000
+ if (($msg = preg_replace ("/%%user_first_name%%/i", ws_plugin__s2member_esc_ds ($user->first_name), $msg)) && ($msg = preg_replace ("/%%user_last_name%%/i", ws_plugin__s2member_esc_ds ($user->last_name), $msg)))
1001
+ if (($msg = preg_replace ("/%%user_full_name%%/i", ws_plugin__s2member_esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
1002
+ if (($msg = preg_replace ("/%%user_email%%/i", ws_plugin__s2member_esc_ds ($user->user_email), $msg)))
1003
+ if (($msg = preg_replace ("/%%user_login%%/i", ws_plugin__s2member_esc_ds ($user->user_login), $msg)))
1004
+ if (($msg = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds ($user_id), $msg)))
1005
+ /**/
1006
+ foreach (ws_plugin__s2member_trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_recipients"])) as $recipient)
1007
+ /**/
1008
+ ($recipient) ? mail ($recipient, $sbj, apply_filters ("ws_plugin__s2member_cancellation_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
1009
+ /**/
1010
+ $paypal["s2member_log"][] = "Cancellation Notification Emails have been processed.";
1011
+ }
1012
+ }
1013
+ else
1014
+ {
1015
+ $paypal["s2member_log"][] = "Unable to handle Cancellation. Could not get the existing User ID from the DB.";
1016
+ }
1017
+ /**/
1018
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1019
+ do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_cancel", get_defined_vars ());
1020
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
1021
+ }
1022
+ /*
1023
+ Subscription terminations, max failed payments, initial payment failed, chargebacks, refunds, and reversals.
1024
+ An immediate EOT is necessary under MANY different conditions. However, in some cases, a delayed EOT is required.
1025
+ Delayed EOTs work in conjunction with `s2member_last_payment_time`, and the s2Member Auto-EOT System.
1026
+
1027
+ ~ NOTE: newer PayPal® accounts ( i.e. Billing Profiles that start with "I-" ), will trigger a "subscr_eot" upon last payment.
1028
+ So those are treated as delayed EOTs - ( s2Member was updated at v3.2.3 to deal with this scenario gracefully ).
1029
+ In the case of "subscr_eot" with "I-", s2Member calculates the EOT Time, and records it for future processing.
1030
+
1031
+ ~ NOTE: "new_case" with "case_type=chargeback" is NOT actually processed. It's only been integrated for the future compatibility.
1032
+ At this time, PayPal® doesn't send enough information through "new_case" transactions for s2Member to process anything.
1033
+ However, that's OK. Refunds and Reversals ( i.e. chargebacks ) are still detected through "payment_status".
1034
+
1035
+ ~ NOTE: Partial Refunds ( i.e. payment_status=partially_refunded ) is NOT processed by this routine, or any other s2Member routine.
1036
+ ( This is the intended behavior. A Partial Refund does NOT clearly indicate that s2Member should do anything at all. )
1037
+ HOWEVER. PayPal® does NOT always send payment_status=partially_refunded. This is well documented on their site, but in
1038
+ practice it never seems to happen. It's best to check the negative mc_gross amount instead.
1039
+ */
1040
+ else if (/**/(/**/ (preg_match ("/^(subscr_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment)$/i", $paypal["txn_type"]))/**/
1041
+ || (preg_match ("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]) && preg_match ("/^failed$/i", $paypal["initial_payment_status"]))/**/
1042
+ || (preg_match ("/^new_case$/i", $paypal["txn_type"]) && preg_match ("/^chargeback$/i", $paypal["case_type"])) /* For future compatibility. */
1043
+ || (preg_match ("/^(refunded|reversed|reversal)$/i", $paypal["payment_status"])) /* The "txn_type" is irrelevant in all of these special cases. */)/**/
1044
+ && (!preg_match ("/^subscr_eot$/i", $paypal["txn_type"]) || $paypal["period1"] || ($paypal["period1"] = ws_plugin__s2member_paypal_pro_period1 ($paypal)))/**/
1045
+ && (!preg_match ("/^subscr_eot$/i", $paypal["txn_type"]) || $paypal["period3"] || ($paypal["period3"] = ws_plugin__s2member_paypal_pro_period3 ($paypal)))/**/
1046
+ && ($paypal["item_number"] || ($paypal["item_number"] = ws_plugin__s2member_paypal_pro_item_number ($paypal))) /* We MUST have a valid "item_number". */
1047
+ && (preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])) /* Only "Membership Access". NOT for Specific Posts/Pages. */
1048
+ && ($paypal["subscr_id"] || ($paypal["subscr_id"] = ws_plugin__s2member_paypal_pro_subscr_id ($paypal)) || ($paypal["subscr_id"] = $paypal["parent_txn_id"]))/**/
1049
+ && ($paypal["item_name"] || ($paypal["item_name"] = ws_plugin__s2member_paypal_pro_item_name ($paypal)))/**/
1050
+ && ($paypal["payer_email"] || ($paypal["payer_email"] = ws_plugin__s2member_paypal_email ($paypal["subscr_id"])))/**/)
1051
+ {
1052
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1053
+ do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_eot", get_defined_vars ());
1054
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
1055
+ /**/
1056
+ $is_refund = (preg_match ("/^refunded$/i", $paypal["payment_status"]) && $paypal["parent_txn_id"]);
1057
+ $is_reversal = (preg_match ("/^(reversed|reversal)$/i", $paypal["payment_status"]) && $paypal["parent_txn_id"]);
1058
+ $is_reversal = (!$is_reversal) ? (preg_match ("/^new_case$/i", $paypal["txn_type"]) && preg_match ("/^chargeback$/i", $paypal["case_type"])) : $is_reversal;
1059
+ $is_refund_or_reversal = ($is_refund || $is_reversal); /* If any of the previous tests evaluated to true; it's a Refund or Reversal. */
1060
+ $is_delayed_eot = (preg_match ("/^subscr_eot$/i", $paypal["txn_type"]) && preg_match ("/^I-/i", $paypal["subscr_id"])); /* Delayed? */
1061
+ /**/
1062
+ if ($is_refund_or_reversal)
1063
+ $paypal["s2member_log"][] = "s2Member txn_type identified as [empty or irrelevant] w/ payment_status (refunded|reversed|reversal) - or - new_case w/ case_type (chargeback).";
1064
+ else
1065
+ $paypal["s2member_log"][] = "s2Member txn_type identified as (subscr_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment) - or - recurring_payment_profile_cancel w/ initial_payment_status (failed).";
1066
+ /**/
1067
+ if (($user_id = ws_plugin__s2member_paypal_user_id ($paypal["subscr_id"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
1068
+ {
1069
+ if ( /* Here we take action, BUT based on Auto EOT Behavior options; as configured by the Site Owner. */
1070
+ (!$is_refund_or_reversal && !$is_delayed_eot && !get_user_option ("s2member_auto_eot_time", $user_id))/**/
1071
+ || ($is_refund_or_reversal && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "refunds,reversals")/**/
1072
+ || ($is_reversal && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "reversals")/**/
1073
+ || ($is_refund && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "refunds")/**/)
1074
+ {
1075
+ if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
1076
+ {
1077
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"]) /* EOT enabled? */
1078
+ {
1079
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote")
1080
+ {
1081
+ $processing = $during = true; /* Yes, we ARE processing this. */
1082
+ /**/
1083
+ $demotion_role = ws_plugin__s2member_force_demotion_role ("subscriber");
1084
+ $user->set_role ($demotion_role); /* Defaults to Free Subscriber. */
1085
+ /**/
1086
+ foreach ($user->allcaps as $cap => $cap_enabled)
1087
+ if (preg_match ("/^access_s2member_ccap_/", $cap))
1088
+ $user->remove_cap ($ccap = $cap);
1089
+ /**/
1090
+ delete_user_option ($user_id, "s2member_custom");
1091
+ delete_user_option ($user_id, "s2member_subscr_id");
1092
+ delete_user_option ($user_id, "s2member_last_payment_time");
1093
+ delete_user_option ($user_id, "s2member_auto_eot_time");
1094
+ /**/
1095
+ delete_user_option ($user_id, "s2member_file_download_access_arc");
1096
+ delete_user_option ($user_id, "s2member_file_download_access_log");
1097
+ /**/
1098
+ ws_plugin__s2member_append_user_notes ($user_id, "Demoted by s2Member: " . date ("D M j, Y g:i a T"));
1099
+ /**/
1100
+ $paypal["s2member_log"][] = "Member Level/Capabilities demoted to: " . ucwords (preg_replace ("/_/", " ", $demotion_role)) . ".";
1101
+ /**/
1102
+ if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
1103
+ {
1104
+ foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"]) as $url) /* Handle EOT Notifications. */
1105
+ /**/
1106
+ if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["subscr_id"])), $url)))
1107
+ if (($url = preg_replace ("/%%user_first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->first_name)), $url)) && ($url = preg_replace ("/%%user_last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->last_name)), $url)))
1108
+ if (($url = preg_replace ("/%%user_full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
1109
+ if (($url = preg_replace ("/%%user_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->user_email)), $url)))
1110
+ if (($url = preg_replace ("/%%user_login%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->user_login)), $url)))
1111
+ if (($url = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($user_id)), $url)))
1112
+ /**/
1113
+ if (($url = trim ($url))) /* Empty? */
1114
+ ws_plugin__s2member_remote($url);
1115
+ /**/
1116
+ $paypal["s2member_log"][] = "EOT/Deletion Notification URLs have been processed.";
1117
+ }
1118
+ /**/
1119
+ if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
1120
+ {
1121
+ $msg = $sbj = "( s2Member / API Notification Email ) - EOT/Deletion";
1122
+ $msg .= "\n\n"; /* Spacing in the message body. */
1123
+ $msg .= "subscr_id: %%subscr_id%%\n";
1124
+ $msg .= "user_first_name: %%user_first_name%%\n";
1125
+ $msg .= "user_last_name: %%user_last_name%%\n";
1126
+ $msg .= "user_full_name: %%user_full_name%%\n";
1127
+ $msg .= "user_email: %%user_email%%\n";
1128
+ $msg .= "user_login: %%user_login%%\n";
1129
+ $msg .= "user_id: %%user_id%%\n";
1130
+ $msg .= "cv0: %%cv0%%\n";
1131
+ $msg .= "cv1: %%cv1%%\n";
1132
+ $msg .= "cv2: %%cv2%%\n";
1133
+ $msg .= "cv3: %%cv3%%\n";
1134
+ $msg .= "cv4: %%cv4%%\n";
1135
+ $msg .= "cv5: %%cv5%%\n";
1136
+ $msg .= "cv6: %%cv6%%\n";
1137
+ $msg .= "cv7: %%cv7%%\n";
1138
+ $msg .= "cv8: %%cv8%%\n";
1139
+ $msg .= "cv9: %%cv9%%";
1140
+ /**/
1141
+ if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $msg)))
1142
+ if (($msg = preg_replace ("/%%user_first_name%%/i", ws_plugin__s2member_esc_ds ($user->first_name), $msg)) && ($msg = preg_replace ("/%%user_last_name%%/i", ws_plugin__s2member_esc_ds ($user->last_name), $msg)))
1143
+ if (($msg = preg_replace ("/%%user_full_name%%/i", ws_plugin__s2member_esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
1144
+ if (($msg = preg_replace ("/%%user_email%%/i", ws_plugin__s2member_esc_ds ($user->user_email), $msg)))
1145
+ if (($msg = preg_replace ("/%%user_login%%/i", ws_plugin__s2member_esc_ds ($user->user_login), $msg)))
1146
+ if (($msg = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds ($user_id), $msg)))
1147
+ /**/
1148
+ foreach (ws_plugin__s2member_trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"])) as $recipient)
1149
+ /**/
1150
+ ($recipient) ? mail ($recipient, $sbj, apply_filters ("ws_plugin__s2member_eot_del_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
1151
+ /**/
1152
+ $paypal["s2member_log"][] = "EOT/Deletion Notification Emails have been processed.";
1153
+ }
1154
+ /**/
1155
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1156
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_demote", get_defined_vars ());
1157
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
1158
+ }
1159
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete")
1160
+ {
1161
+ $processing = $during = true; /* Yes, we ARE processing this. */
1162
+ /**/
1163
+ if (is_multisite ()) /* Multisite does NOT actually delete; ONLY removes. */
1164
+ {
1165
+ remove_user_from_blog ($user_id, $current_blog->blog_id);
1166
+ /* This will automatically trigger `eot_del_notification_urls` as well. */
1167
+ ws_plugin__s2member_handle_ms_user_deletions ($user_id, $current_blog->blog_id, "s2says");
1168
+ }
1169
+ /**/
1170
+ else /* Otherwise, we can actually delete them. */
1171
+ /* This will automatically trigger `eot_del_notification_urls` as well. */
1172
+ wp_delete_user($user_id); /* `ws_plugin__s2member_handle_user_deletions()` */
1173
+ /**/
1174
+ $paypal["s2member_log"][] = "This Member's account has been " . ( (is_multisite ()) ? "removed" : "deleted") . ".";
1175
+ /**/
1176
+ $paypal["s2member_log"][] = "EOT/Deletion Notification URLs have been processed.";
1177
+ /**/
1178
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1179
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_delete", get_defined_vars ());
1180
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
1181
+ }
1182
+ /**/
1183
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1184
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot", get_defined_vars ());
1185
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
1186
+ }
1187
+ /**/
1188
+ else /* Otherwise, treat this as if it were a cancellation. EOTs are currently disabled. */
1189
+ {
1190
+ $processing = $during = true; /* Yes, we ARE processing this. */
1191
+ /**/
1192
+ update_user_option ($user_id, "s2member_auto_eot_time", ($auto_eot_time = strtotime ("now")));
1193
+ /**/
1194
+ $paypal["s2member_log"][] = "Auto-EOT is currently disabled. Skipping immediate EOT (demote|delete), for now.";
1195
+ $paypal["s2member_log"][] = "Recording the Auto-EOT Time for this Member's account: " . date ("D M j, Y g:i a T", $auto_eot_time);
1196
+ /**/
1197
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1198
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_disabled", get_defined_vars ());
1199
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
1200
+ }
1201
+ }
1202
+ else
1203
+ {
1204
+ $paypal["s2member_log"][] = "Unable to (demote|delete) Member. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
1205
+ }
1206
+ }
1207
+ else if ($is_delayed_eot && !get_user_option ("s2member_auto_eot_time", $user_id))
1208
+ {
1209
+ if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
1210
+ {
1211
+ $processing = $during = true; /* Yes, we ARE processing this. */
1212
+ /**/
1213
+ $auto_eot_time = ws_plugin__s2member_paypal_auto_eot_time ($user_id, $paypal["period1"], $paypal["period3"]);
1214
+ /**/
1215
+ update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time); /* s2Member will follow-up on this later. */
1216
+ /**/
1217
+ $paypal["s2member_log"][] = "Auto-EOT Time for this account ( delayed ), set to: " . date ("D M j, Y g:i a T", $auto_eot_time);
1218
+ /**/
1219
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1220
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_delayed", get_defined_vars ());
1221
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
1222
+ }
1223
+ else
1224
+ {
1225
+ $paypal["s2member_log"][] = "Ignoring Delayed EOT. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
1226
+ }
1227
+ }
1228
+ else if (!$is_refund_or_reversal || $is_delayed_eot)
1229
+ {
1230
+ $paypal["s2member_log"][] = "Skipping (demote|delete) Member, for now. An Auto-EOT Time is already set for this account. When an Auto-EOT Time has been recorded, s2Member will handle EOT (demote|delete) events using it's own Auto-EOT System - internally.";
1231
+ }
1232
+ else if ($is_reversal)
1233
+ {
1234
+ $paypal["s2member_log"][] = "Skipping (demote|delete) Member. Your configuration dictates that s2Member should NOT take any immediate action on an EOT associated with a Chargeback Reversal. An s2Member API Notification will still be processed however.";
1235
+ }
1236
+ else if ($is_refund)
1237
+ {
1238
+ $paypal["s2member_log"][] = "Skipping (demote|delete) Member. Your configuration dictates that s2Member should NOT take any immediate action on an EOT associated with a Refund. An s2Member API Notification will still be processed however.";
1239
+ }
1240
+ }
1241
+ else
1242
+ $paypal["s2member_log"][] = "Unable to (demote|delete) Member. Could not get the existing User ID from the DB. It's possible that it was ALREADY processed through another IPN, removed manually by a Site Administrator, or by s2Member's Auto-EOT Sys.";
1243
+ /*
1244
+ Refunds and chargeback reversals. This is excluded from the processing check, because a Member *could* have already been (demoted|deleted).
1245
+ In other words, s2Member sends `Refund/Reversal` Notifications ANYTIME a Refund/Reversal occurs; even if s2Member did not process it otherwise.
1246
+ Since this routine ignores the processing check, it is *possible* that Refund/Reversal Notification URLs will be contacted more than once.
1247
+ If you're writing scripts that depend on Refund/Reversal Notifications, please keep this in mind.
1248
+ */
1249
+ if ($is_refund_or_reversal) /* Here we access this variable that was previously assigned as a quick method of Refund/Reversal detection. */
1250
+ {
1251
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
1252
+ {
1253
+ foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"]) as $url)
1254
+ /**/
1255
+ if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["subscr_id"])), $url)) && ($url = preg_replace ("/%%parent_txn_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["parent_txn_id"])), $url)))
1256
+ if (($url = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_name"])), $url)))
1257
+ if (($url = preg_replace ("/%%-amount%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%-fee%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["mc_fee"])), $url)))
1258
+ if (($url = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["last_name"])), $url)))
1259
+ if (($url = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
1260
+ if (($url = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["payer_email"])), $url)))
1261
+ if (($url = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($user_id)), $url)))
1262
+ /**/
1263
+ if (($url = trim ($url))) /* Empty? */
1264
+ ws_plugin__s2member_remote($url);
1265
+ /**/
1266
+ $paypal["s2member_log"][] = "Refund/Reversal Notification URLs have been processed.";
1267
+ }
1268
+ /**/
1269
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
1270
+ {
1271
+ $msg = $sbj = "( s2Member / API Notification Email ) - Refund/Reversal";
1272
+ $msg .= "\n\n"; /* Spacing in the message body. */
1273
+ $msg .= "subscr_id: %%subscr_id%%\n";
1274
+ $msg .= "parent_txn_id: %%parent_txn_id%%\n";
1275
+ $msg .= "item_number: %%item_number%%\n";
1276
+ $msg .= "item_name: %%item_name%%\n";
1277
+ $msg .= "-amount: %%-amount%%\n";
1278
+ $msg .= "-fee: %%-fee%%\n";
1279
+ $msg .= "first_name: %%first_name%%\n";
1280
+ $msg .= "last_name: %%last_name%%\n";
1281
+ $msg .= "full_name: %%full_name%%\n";
1282
+ $msg .= "payer_email: %%payer_email%%\n";
1283
+ $msg .= "user_id: %%user_id%%\n";
1284
+ $msg .= "cv0: %%cv0%%\n";
1285
+ $msg .= "cv1: %%cv1%%\n";
1286
+ $msg .= "cv2: %%cv2%%\n";
1287
+ $msg .= "cv3: %%cv3%%\n";
1288
+ $msg .= "cv4: %%cv4%%\n";
1289
+ $msg .= "cv5: %%cv5%%\n";
1290
+ $msg .= "cv6: %%cv6%%\n";
1291
+ $msg .= "cv7: %%cv7%%\n";
1292
+ $msg .= "cv8: %%cv8%%\n";
1293
+ $msg .= "cv9: %%cv9%%";
1294
+ /**/
1295
+ if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds ($paypal["subscr_id"]), $msg)) && ($msg = preg_replace ("/%%parent_txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["parent_txn_id"]), $msg)))
1296
+ if (($msg = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $msg)))
1297
+ if (($msg = preg_replace ("/%%-amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $msg)) && ($msg = preg_replace ("/%%-fee%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_fee"]), $msg)))
1298
+ if (($msg = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $msg)))
1299
+ if (($msg = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
1300
+ if (($msg = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $msg)))
1301
+ if (($msg = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds ($user_id), $msg)))
1302
+ /**/
1303
+ foreach (ws_plugin__s2member_trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_recipients"])) as $recipient)
1304
+ /**/
1305
+ ($recipient) ? mail ($recipient, $sbj, apply_filters ("ws_plugin__s2member_ref_rev_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
1306
+ /**/
1307
+ $paypal["s2member_log"][] = "Refund/Reversal Notification Emails have been processed.";
1308
+ }
1309
+ /**/
1310
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1311
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_refund_reversal", get_defined_vars ());
1312
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
1313
+ }
1314
+ /**/
1315
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1316
+ do_action ("ws_plugin__s2member_during_paypal_notify_after_subscr_eot", get_defined_vars ());
1317
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
1318
+ }
1319
+ /*
1320
+ Refunds/Reversals for Specific Post/Page Access.
1321
+ These are handled separately.
1322
+
1323
+ ~ NOTE: "new_case" with "case_type=chargeback" is NOT actually processed. It's only been integrated for the future compatibility.
1324
+ At this time, PayPal® doesn't send enough information through "new_case" transactions for s2Member to process anything.
1325
+ However, that's OK. Refunds and Reversals ( i.e. chargebacks ) are still detected through "payment_status".
1326
+
1327
+ ~ NOTE: Partial Refunds ( i.e. payment_status=partially_refunded ) is NOT processed by this routine, or any other s2Member routine.
1328
+ ( This is the intended behavior. A Partial Refund does NOT clearly indicate that s2Member should do anything at all. )
1329
+ HOWEVER. PayPal® does NOT always send payment_status=partially_refunded. This is well documented on their site, but in
1330
+ practice it never seems to happen. It's best to check the negative mc_gross amount instead.
1331
+ */
1332
+ else if (/**/(/**/ (preg_match ("/^new_case$/i", $paypal["txn_type"]) && preg_match ("/^chargeback$/i", $paypal["case_type"])) /* Future compatibility. */
1333
+ || (preg_match ("/^(refunded|reversed|reversal)$/i", $paypal["payment_status"])) /* The "txn_type" is irrelevant in all of these special cases. */)/**/
1334
+ && ($paypal["item_number"] || ($paypal["item_number"] = ws_plugin__s2member_paypal_pro_item_number ($paypal))) /* We MUST have a valid "item_number". */
1335
+ && (preg_match ("/^sp\:[0-9,]+\:[0-9]+$/", $paypal["item_number"])) /* Only for "Specific Post/Page Access" here. NOT for Membership. */
1336
+ && ($paypal["item_name"] || ($paypal["item_name"] = ws_plugin__s2member_paypal_pro_item_name ($paypal)))/**/
1337
+ && ($paypal["payer_email"] || ($paypal["payer_email"] = ws_plugin__s2member_paypal_email ($paypal["subscr_id"])))/**/
1338
+ && ($paypal["parent_txn_id"])/**/)
1339
+ {
1340
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1341
+ do_action ("ws_plugin__s2member_during_paypal_notify_before_sp_refund_reversal", get_defined_vars ());
1342
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
1343
+ /**/
1344
+ $paypal["s2member_log"][] = "s2Member txn_type identified as [empty or irrelevant] w/ payment_status (refunded|reversed|reversal) - or - new_case w/ case_type (chargeback).";
1345
+ /**/
1346
+ $processing = $during = true; /* Yes, we ARE processing this. */
1347
+ /*
1348
+ Refunds and chargeback reversals. This is excluded from the processing check.
1349
+ In other words, s2Member sends `Refund/Reversal` Notifications ANYTIME a Refund/Reversal occurs; even if s2Member did not process it otherwise.
1350
+ Since this routine ignores the processing check, it is *possible* that Refund/Reversal Notification URLs will be contacted more than once.
1351
+ If you're writing scripts that depend on Refund/Reversal Notifications, please keep this in mind.
1352
+ */
1353
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
1354
+ {
1355
+ foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_urls"]) as $url)
1356
+ /**/
1357
+ if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%parent_txn_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["parent_txn_id"])), $url)))
1358
+ if (($url = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["item_name"])), $url)))
1359
+ if (($url = preg_replace ("/%%-amount%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["mc_gross"])), $url)) && ($url = preg_replace ("/%%-fee%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["mc_fee"])), $url)))
1360
+ if (($url = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["last_name"])), $url)))
1361
+ if (($url = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
1362
+ if (($url = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($paypal["payer_email"])), $url)))
1363
+ /**/
1364
+ if (($url = trim ($url))) /* Empty? */
1365
+ ws_plugin__s2member_remote($url);
1366
+ /**/
1367
+ $paypal["s2member_log"][] = "Specific Post/Page ~ Refund/Reversal Notification URLs have been processed.";
1368
+ }
1369
+ /**/
1370
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
1371
+ {
1372
+ $msg = $sbj = "( s2Member / API Notification Email ) - Specific Post/Page ~ Refund/Reversal";
1373
+ $msg .= "\n\n"; /* Spacing in the message body. */
1374
+ $msg .= "parent_txn_id: %%parent_txn_id%%\n";
1375
+ $msg .= "item_number: %%item_number%%\n";
1376
+ $msg .= "item_name: %%item_name%%\n";
1377
+ $msg .= "-amount: %%-amount%%\n";
1378
+ $msg .= "-fee: %%-fee%%\n";
1379
+ $msg .= "first_name: %%first_name%%\n";
1380
+ $msg .= "last_name: %%last_name%%\n";
1381
+ $msg .= "full_name: %%full_name%%\n";
1382
+ $msg .= "payer_email: %%payer_email%%\n";
1383
+ $msg .= "cv0: %%cv0%%\n";
1384
+ $msg .= "cv1: %%cv1%%\n";
1385
+ $msg .= "cv2: %%cv2%%\n";
1386
+ $msg .= "cv3: %%cv3%%\n";
1387
+ $msg .= "cv4: %%cv4%%\n";
1388
+ $msg .= "cv5: %%cv5%%\n";
1389
+ $msg .= "cv6: %%cv6%%\n";
1390
+ $msg .= "cv7: %%cv7%%\n";
1391
+ $msg .= "cv8: %%cv8%%\n";
1392
+ $msg .= "cv9: %%cv9%%";
1393
+ /**/
1394
+ if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%parent_txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["parent_txn_id"]), $msg)))
1395
+ if (($msg = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $msg)))
1396
+ if (($msg = preg_replace ("/%%-amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $msg)) && ($msg = preg_replace ("/%%-fee%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_fee"]), $msg)))
1397
+ if (($msg = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $msg)))
1398
+ if (($msg = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
1399
+ if (($msg = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $msg)))
1400
+ /**/
1401
+ foreach (ws_plugin__s2member_trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_recipients"])) as $recipient)
1402
+ /**/
1403
+ ($recipient) ? mail ($recipient, $sbj, apply_filters ("ws_plugin__s2member_sp_ref_rev_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
1404
+ /**/
1405
+ $paypal["s2member_log"][] = "Specific Post/Page ~ Refund/Reversal Notification Emails have been processed.";
1406
+ }
1407
+ /**/
1408
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1409
+ do_action ("ws_plugin__s2member_during_paypal_notify_during_sp_refund_reversal", get_defined_vars ());
1410
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
1411
+ /**/
1412
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1413
+ do_action ("ws_plugin__s2member_during_paypal_notify_after_sp_refund_reversal", get_defined_vars ());
1414
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
1415
+ }
1416
+ else
1417
+ {
1418
+ $paypal["s2member_log"][] = "Ignoring this IPN request. The txn_type/status does not require any action on the part of s2Member.";
1419
+ }
1420
+ }
1421
+ else /* Else a custom conditional has been applied by Filters. */
1422
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
1423
+ }
1424
+ /*
1425
+ Else, check on cancelled recurring profiles.
1426
+ */
1427
+ else if (preg_match ("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]))
1428
+ {
1429
+ $paypal["s2member_log"][] = "Transaction type ( recurring_payment_profile_cancel ), but there is no match to an existing account; so verification of _SERVER[HTTP_HOST] was not possible.";
1430
+ $paypal["s2member_log"][] = "It's likely this account was just upgraded/downgraded by s2Member Pro; so the Subscr. ID has probably been updated on-site; nothing to worry about here.";
1431
+ }
1432
+ /*
1433
+ Else, check on other ^recurring_ transaction types.
1434
+ */
1435
+ else if (preg_match ("/^recurring_/i", $paypal["txn_type"])) /* Otherwise, is this a ^recurring_ txn_type? */
1436
+ {
1437
+ $paypal["s2member_log"][] = "Transaction type ( ^recurring_? ), but there is no match to an existing account; so verification of _SERVER[HTTP_HOST] was not possible.";
1438
+ }
1439
+ /**/
1440
+ else /* Else, use the default _SERVER[HTTP_HOST] error. */
1441
+ $paypal["s2member_log"][] = "Unable to verify _SERVER[HTTP_HOST]. Possibly caused by a fraudulent request. If this error continues, please check the `custom` value in your Form and/or Button Code. It MUST always start with your domain name.";
1442
+ }
1443
+ /*
1444
+ Otherwise, POST vars could not even be verified. This needs to be reported in the logs.
1445
+ */
1446
+ else /* Extensive log reporting here. This is an area where many site owners find trouble. Depending on server configuration; remote HTTPS connections may fail. */
1447
+ {
1448
+ $paypal["s2member_log"][] = "Unable to verify POST vars. Possibly caused by a fraudulent request. If this error continues, please run IPN tests against your server from a PayPal® Sandbox account. They provide special diagnostic tools to assist you.";
1449
+ $paypal["s2member_log"][] = "If you're absolutely SURE that your PayPal® configuration is valid, you may want to run some tests on your server, just to be sure \$_POST variables are populated, and that your server is able to connect to PayPal® over an HTTPS connection.";
1450
+ $paypal["s2member_log"][] = "s2Member uses the WP_Http class for remote connections; which will try to use cURL first, and then fall back on the FOPEN method when cURL is not available. On a Windows® server, you may have to disable your cURL extension. Instead, set allow_url_fopen = yes in your php.ini file. The cURL extension (usually) does NOT support SSL connections on a Windows® server.";
1451
+ $paypal["s2member_log"][] = var_export ($_POST, true); /* Recording _POST vars for analysis and debugging. */
1452
+ }
1453
+ /*
1454
+ Add IPN proxy identification ( when available ) to the $paypal array for log reporting.
1455
+ */
1456
+ if ($_GET["s2member_paypal_proxy"]) /* For proxy identification. */
1457
+ $paypal["s2member_paypal_proxy"] = $_GET["s2member_paypal_proxy"];
1458
+ /*
1459
+ Also add IPN proxy self-verification ( when available ) to the $paypal array.
1460
+ */
1461
+ if ($_GET["s2member_paypal_proxy_verification"]) /* Proxy identification w/verification. */
1462
+ $paypal["s2member_paypal_proxy_verification"] = $_GET["s2member_paypal_proxy_verification"];
1463
+ /*
1464
+ If debugging/logging is enabled; we need to append $paypal to the log file.
1465
+ Logging now supports Multisite Networking as well.
1466
+ */
1467
+ $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
1468
+ $log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
1469
+ $log2 = (is_multisite () && !is_main_site ()) ? "paypal-ipn-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-ipn.log";
1470
+ /**/
1471
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_debug"]) /* Append to log? */
1472
+ if (is_dir ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
1473
+ if (is_writable ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
1474
+ file_put_contents ($logs_dir . "/" . $log2, $log4 . "\n" . var_export ($paypal, true) . "\n\n", FILE_APPEND);
1475
+ /**/
1476
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1477
+ do_action ("ws_plugin__s2member_during_paypal_notify", get_defined_vars ());
1478
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
1479
+ /**/
1480
+ exit ($paypal["proxy_return_url"]); /* Return, if/when applicable. */
1481
+ }
1482
+ /**/
1483
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1484
+ do_action ("ws_plugin__s2member_after_paypal_notify", get_defined_vars ());
1485
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
1486
+ }
1487
+ }
1488
+ ?>
includes/functions/separates/paypal-return.inc.php ADDED
@@ -0,0 +1,445 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ("Do not access this file directly.");
16
+ /*
17
+ Handles PayPal® Return URL processing.
18
+ This is used ONLY in PayPal® Standard Integration.
19
+ */
20
+ if (!function_exists ("s__ws_plugin__s2member_paypal_return"))
21
+ {
22
+ function s__ws_plugin__s2member_paypal_return ()
23
+ {
24
+ global $current_site, $current_blog; /* For Multisite support. */
25
+ /**/
26
+ do_action ("ws_plugin__s2member_before_paypal_return", get_defined_vars ());
27
+ /**/
28
+ if ($_GET["s2member_paypal_return"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"])
29
+ {
30
+ if (is_array ($paypal = ws_plugin__s2member_paypal_postvars ())) /* Verify PayPal® POST vars. */
31
+ {
32
+ $paypal["s2member_log"][] = "Return-Data received on: " . date ("D M j, Y g:i:s a T");
33
+ $paypal["s2member_log"][] = "s2Member POST vars verified through a POST back to PayPal®.";
34
+ /**/
35
+ $payment_status_issues = "/^(failed|denied|expired|refunded|partially_refunded|reversed|reversal|canceled_reversal|voided)$/i";
36
+ /**/
37
+ if (preg_match ("/^" . preg_quote (preg_replace ("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $paypal["custom"]))
38
+ { /* The business address validation was removed from this routine, because PayPal® always fills that with the primary
39
+ email address. In cases where an alternate PayPal® address is being paid, validation was not possible. */
40
+ $paypal["s2member_log"][] = "s2Member originating domain ( _SERVER[HTTP_HOST] ) validated.";
41
+ /*
42
+ Custom conditionals can be applied by filters.
43
+ */
44
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
45
+ if (!apply_filters ("ws_plugin__s2member_during_paypal_return_conditionals", false, get_defined_vars ()))
46
+ {
47
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
48
+ /*
49
+ Specific Post/Page Access ~ Sales.
50
+ */
51
+ if (/**/(preg_match ("/^web_accept$/i", $paypal["txn_type"]))/**/
52
+ && (preg_match ("/^sp\:[0-9,]+\:[0-9]+$/", $paypal["item_number"]))/**/
53
+ && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
54
+ && ($paypal["txn_id"])/**/)
55
+ {
56
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
57
+ do_action ("ws_plugin__s2member_during_paypal_return_before_sp_access", get_defined_vars ());
58
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
59
+ /**/
60
+ $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept) for Specific Post/Page Access.";
61
+ /**/
62
+ list (, $paypal["sp_ids"], $paypal["hours"]) = preg_split ("/\:/", $paypal["item_number"], 3);
63
+ /**/
64
+ if (($sp_access_url = ws_plugin__s2member_sp_access_link_gen ($paypal["sp_ids"], $paypal["hours"], false)))
65
+ {
66
+ $processing = $during = true; /* Yes, we ARE processing this. */
67
+ /**/
68
+ setcookie ("s2member_sp_tracking", ws_plugin__s2member_encrypt ($paypal["txn_id"]), time () + 31556926, "/");
69
+ /**/
70
+ $paypal["s2member_log"][] = "Transient Tracking Cookie set on (web_accept) for Specific Post/Page Access.";
71
+ /**/
72
+ if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_tracking_codes"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
73
+ {
74
+ if (($code = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace ("/%%amount%%/i", ws_plugin__s2member_esc_ds ($paypal["mc_gross"]), $code)) && ($code = preg_replace ("/%%txn_id%%/i", ws_plugin__s2member_esc_ds ($paypal["txn_id"]), $code)))
75
+ if (($code = preg_replace ("/%%item_number%%/i", ws_plugin__s2member_esc_ds ($paypal["item_number"]), $code)) && ($code = preg_replace ("/%%item_name%%/i", ws_plugin__s2member_esc_ds ($paypal["item_name"]), $code)))
76
+ if (($code = preg_replace ("/%%first_name%%/i", ws_plugin__s2member_esc_ds ($paypal["first_name"]), $code)) && ($code = preg_replace ("/%%last_name%%/i", ws_plugin__s2member_esc_ds ($paypal["last_name"]), $code)))
77
+ if (($code = preg_replace ("/%%full_name%%/i", ws_plugin__s2member_esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
78
+ if (($code = preg_replace ("/%%payer_email%%/i", ws_plugin__s2member_esc_ds ($paypal["payer_email"]), $code)))
79
+ /**/
80
+ if (($code = trim ($code))) /* Make sure it is not empty. This gets stored into a Transient Queue. */
81
+ {
82
+ $paypal["s2member_log"][] = "Storing Specific Post/Page Tracking Codes into a Transient Queue for s2Member. These will be processed on-site.";
83
+ set_transient (md5 ("s2member_transient_sp_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
84
+ }
85
+ }
86
+ /**/
87
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
88
+ do_action ("ws_plugin__s2member_during_paypal_return_during_sp_access", get_defined_vars ());
89
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
90
+ /**/
91
+ $paypal["s2member_log"][] = "Redirecting Customer to the Specific Post/Page.";
92
+ /**/
93
+ wp_redirect($sp_access_url); /* Redirect Customer immediately. */
94
+ }
95
+ else /* Otherwise, the ID must have been invalid. Or the Post/Page was deleted. */
96
+ {
97
+ $paypal["s2member_log"][] = "Unable to generate Specific Post/Page Access Link. Does your Leading Post/Page still exist?";
98
+ /**/
99
+ $paypal["s2member_log"][] = "Redirecting Customer to the Home Page, due to an error that occurred.";
100
+ /**/
101
+ echo '<script type="text/javascript">' . "\n";
102
+ echo "alert('ERROR: Unable to generate Access Link. Please contact Support for assistance.');" . "\n";
103
+ echo "window.location = '" . esc_js (get_bloginfo ("url")) . "';";
104
+ echo '</script>' . "\n";
105
+ }
106
+ /**/
107
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
108
+ do_action ("ws_plugin__s2member_during_paypal_return_after_sp_access", get_defined_vars ());
109
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
110
+ }
111
+ /*
112
+ New Subscriptions.
113
+ Possibly containing advanced update vars
114
+ ( option_name1, option_selection1 ); which allow account modifications.
115
+ */
116
+ else if (/**/(preg_match ("/^(web_accept|subscr_signup|subscr_payment)$/i", $paypal["txn_type"]))/**/
117
+ && (preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"]))/**/
118
+ && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["txn_id"]))/**/
119
+ && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/)
120
+ { /* With Auto-Return/PDT, PayPal will send subscr_payment instead of subscr_signup to the return URL.
121
+ So we need to look for (web_accept|subscr_signup|subscr_payment), and treat them as the same. */
122
+ /**/
123
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
124
+ do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_signup", get_defined_vars ());
125
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
126
+ /**/
127
+ $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup|subscr_payment).";
128
+ /**/
129
+ list ($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split ("/\:/", $paypal["item_number"], 3);
130
+ /*
131
+ New Subscription with advanced update vars ( option_name1, option_selection1 ).
132
+ */
133
+ if (preg_match ("/(updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) /* Advanced Subscription update modifications. */
134
+ /* This advanced method is required whenever a Subscription that is already completed, or was never setup to recur in the first place needs to be modified. PayPal® will not allow the
135
+ modify=2 parameter to be used in those scenarios, because technically there is nothing to update. The only thing to be updated is the account. */
136
+ {
137
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
138
+ do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_signup_w_update_vars", get_defined_vars ());
139
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
140
+ /**/
141
+ $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup|subscr_payment) w/ update vars.";
142
+ /**/
143
+ /* Check for both the old & new subscr_id's, just in case the IPN routine already changed it. */
144
+ if (($user_id = ws_plugin__s2member_paypal_user_id ($paypal["subscr_id"], $paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
145
+ {
146
+ if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
147
+ {
148
+ $processing = $during = true; /* Yes, we ARE processing this. */
149
+ /**/
150
+ $user->set_role ("s2member_level" . $paypal["level"]);
151
+ /**/
152
+ foreach ($user->allcaps as $cap => $cap_enabled)
153
+ if (preg_match ("/^access_s2member_ccap_/", $cap))
154
+ $user->remove_cap ($ccap = $cap);
155
+ /**/
156
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $paypal["ccaps"]) as $ccap)
157
+ if (strlen ($ccap)) /* Don't add empty capabilities. */
158
+ $user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
159
+ /**/
160
+ update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
161
+ update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
162
+ /**/
163
+ delete_user_option ($user_id, "s2member_file_download_access_arc");
164
+ delete_user_option ($user_id, "s2member_file_download_access_log");
165
+ /**/
166
+ if (preg_match ("/^web_accept$/i", $paypal["txn_type"]) && $paypal["eotper"])
167
+ update_user_option ($user_id, "s2member_auto_eot_time", ws_plugin__s2member_paypal_auto_eot_time (0, 0, 0, $paypal["eotper"]));
168
+ else /* Otherwise, we need to clear the eot time. */
169
+ delete_user_option ($user_id, "s2member_auto_eot_time");
170
+ /**/
171
+ ws_plugin__s2member_clear_user_note_lines ($user_id, "/^Demoted by s2Member\:/");
172
+ /**/
173
+ $paypal["s2member_log"][] = "s2Member Level/Capabilities updated w/ advanced update routines.";
174
+ /**/
175
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
176
+ do_action ("ws_plugin__s2member_during_paypal_return_during_subscr_signup_w_update_vars", get_defined_vars ());
177
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
178
+ /**/
179
+ $paypal["s2member_log"][] = "Redirecting Customer to the Login Page. They need to log back in after this modification.";
180
+ /**/
181
+ echo '<script type="text/javascript">' . "\n";
182
+ echo "alert('Thank You! Your membership has been updated to:\\n\\n" . esc_js ($paypal["item_name"]) . "\\n\\nYou\\'ll need to log back in now.');" . "\n";
183
+ echo "window.location = '" . wp_login_url () . "';" . "\n";
184
+ echo '</script>' . "\n";
185
+ }
186
+ else
187
+ {
188
+ $paypal["s2member_log"][] = "Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
189
+ /**/
190
+ $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
191
+ /**/
192
+ echo '<script type="text/javascript">' . "\n";
193
+ echo "alert('ERROR: Unable to modify Subscription. Please contact Support for assistance.\\n\\nThe existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access. Please make sure that you are NOT logged in as an Administrator while testing.');" . "\n";
194
+ echo "window.location = '" . esc_js (wp_login_url ()) . "';";
195
+ echo '</script>' . "\n";
196
+ }
197
+ }
198
+ else
199
+ {
200
+ $paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB. Please check the on0 and os0 variables in your Button Code.";
201
+ /**/
202
+ $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
203
+ /**/
204
+ echo '<script type="text/javascript">' . "\n";
205
+ echo "alert('ERROR: Unable to modify Subscription. Please contact Support for assistance.\\n\\nCould not get the existing User ID from the DB.');" . "\n";
206
+ echo "window.location = '" . esc_js (wp_login_url ()) . "';";
207
+ echo '</script>' . "\n";
208
+ }
209
+ /**/
210
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
211
+ do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_signup_w_update_vars", get_defined_vars ());
212
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
213
+ }
214
+ /*
215
+ New Subscription. Normal Subscription signup, we are not updating anything for a past Subscription.
216
+ */
217
+ else /* Else this is a normal Subscription signup, we are not updating an existing Subscription. */
218
+ {
219
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
220
+ do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_signup_wo_update_vars", get_defined_vars ());
221
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
222
+ /**/
223
+ $processing = $during = true; /* Yes, we ARE processing this new Subscription request. */
224
+ /**/
225
+ $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup|subscr_payment) w/o update vars.";
226
+ /**/
227
+ setcookie ("s2member_subscr_id", ws_plugin__s2member_encrypt ($paypal["subscr_id"]), time () + 31556926, "/");
228
+ setcookie ("s2member_custom", ws_plugin__s2member_encrypt ($paypal["custom"]), time () + 31556926, "/");
229
+ setcookie ("s2member_level", ws_plugin__s2member_encrypt ($paypal["item_number"]), time () + 31556926, "/");
230
+ /**/
231
+ $paypal["s2member_log"][] = "Registration Cookies set on (web_accept|subscr_signup|subscr_payment) w/o update vars.";
232
+ /**/
233
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
234
+ do_action ("ws_plugin__s2member_during_paypal_return_during_subscr_signup_wo_update_vars", get_defined_vars ());
235
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
236
+ /**/
237
+ $paypal["s2member_log"][] = "Redirecting Customer to Registration Page. They need to Register now.";
238
+ /**/
239
+ if (is_multisite () && ws_plugin__s2member_is_multisite_farm () && is_main_site ())
240
+ {
241
+ echo '<script type="text/javascript">' . "\n";
242
+ echo "alert('Thank You! Your account has been approved.\\nThe next step is to Register.\\n\\nPlease click OK to Register now.');" . "\n";/**/
243
+ echo "window.location = '" . esc_js (apply_filters ("wp_signup_location", get_bloginfo ("wpurl") . "/wp-signup.php")) . "';" . "\n";
244
+ echo '</script>' . "\n";
245
+ }
246
+ else /* Otherwise, this is NOT a Multisite install. Or it is, but the Super Administrator is NOT selling Blog creation. */
247
+ {
248
+ echo '<script type="text/javascript">' . "\n";
249
+ echo "alert('Thank You! Your account has been approved.\\nThe next step is to Register a Username.\\n\\nPlease click OK to Register now.');" . "\n";/**/
250
+ echo "window.location = '" . esc_js (add_query_arg ("action", "register", wp_login_url ())) . "';" . "\n";
251
+ echo '</script>' . "\n";
252
+ }
253
+ /**/
254
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
255
+ do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_signup_wo_update_vars", get_defined_vars ());
256
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
257
+ }
258
+ /**/
259
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
260
+ do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_signup", get_defined_vars ());
261
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
262
+ }
263
+ /*
264
+ Subscription modifications.
265
+ */
266
+ else if (/**/(preg_match ("/^subscr_modify$/i", $paypal["txn_type"]))/**/
267
+ && (preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"]))/**/
268
+ && ($paypal["subscr_id"])/**/)
269
+ {
270
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
271
+ do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_modify", get_defined_vars ());
272
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
273
+ /**/
274
+ $paypal["s2member_log"][] = "s2Member txn_type identified as subscr_modify.";
275
+ /**/
276
+ list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
277
+ /**/
278
+ if (($user_id = ws_plugin__s2member_paypal_user_id ($paypal["subscr_id"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
279
+ {
280
+ if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
281
+ {
282
+ $processing = $during = true; /* Yes, we ARE processing this. */
283
+ /**/
284
+ $user->set_role ("s2member_level" . $paypal["level"]);
285
+ /**/
286
+ foreach ($user->allcaps as $cap => $cap_enabled)
287
+ if (preg_match ("/^access_s2member_ccap_/", $cap))
288
+ $user->remove_cap ($ccap = $cap);
289
+ /**/
290
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $paypal["ccaps"]) as $ccap)
291
+ if (strlen ($ccap)) /* Don't add empty capabilities. */
292
+ $user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
293
+ /**/
294
+ update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
295
+ update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
296
+ /**/
297
+ delete_user_option ($user_id, "s2member_file_download_access_arc");
298
+ delete_user_option ($user_id, "s2member_file_download_access_log");
299
+ /**/
300
+ delete_user_option ($user_id, "s2member_auto_eot_time");
301
+ /**/
302
+ ws_plugin__s2member_clear_user_note_lines ($user_id, "/^Demoted by s2Member\:/");
303
+ /**/
304
+ $paypal["s2member_log"][] = "s2Member Level/Capabilities updated on Subscription modification.";
305
+ /**/
306
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
307
+ do_action ("ws_plugin__s2member_during_paypal_return_during_subscr_modify", get_defined_vars ());
308
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
309
+ /**/
310
+ $paypal["s2member_log"][] = "Redirecting Customer to the Login Page. They need to log back in after this modification.";
311
+ /**/
312
+ echo '<script type="text/javascript">' . "\n";
313
+ echo "alert('Thank You! Your membership has been updated to:\\n\\n" . esc_js ($paypal["item_name"]) . "\\n\\nYou\\'ll need to log back in now.');" . "\n";
314
+ echo "window.location = '" . esc_js (wp_login_url ()) . "';";
315
+ echo '</script>' . "\n";
316
+ }
317
+ else
318
+ {
319
+ $paypal["s2member_log"][] = "Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access.";
320
+ /**/
321
+ $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
322
+ /**/
323
+ echo '<script type="text/javascript">' . "\n";
324
+ echo "alert('ERROR: Unable to modify Subscription. Please contact Support for assistance.\\n\\nThe existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access. Please make sure that you are NOT logged in as an Administrator while testing.');" . "\n";
325
+ echo "window.location = '" . esc_js (wp_login_url ()) . "';";
326
+ echo '</script>' . "\n";
327
+ }
328
+ }
329
+ else
330
+ {
331
+ $paypal["s2member_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB.";
332
+ /**/
333
+ $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
334
+ /**/
335
+ echo '<script type="text/javascript">' . "\n";
336
+ echo "alert('ERROR: Unable to modify Subscription. Please contact Support for assistance.\\n\\nCould not get the existing User ID from the DB.');" . "\n";
337
+ echo "window.location = '" . esc_js (wp_login_url ()) . "';";
338
+ echo '</script>' . "\n";
339
+ }
340
+ /**/
341
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
342
+ do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_modify", get_defined_vars ());
343
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
344
+ }
345
+ else
346
+ {
347
+ $paypal["s2member_log"][] = "Unexpected txn_type. The PayPal® txn_type/status did not match a required action.";
348
+ /**/
349
+ $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
350
+ /**/
351
+ echo '<script type="text/javascript">' . "\n";
352
+ echo "alert('ERROR: Unexpected txn_type/status. Please contact Support for assistance.\\n\\nThe PayPal® txn_type/status did not match a required action.');" . "\n";
353
+ echo "window.location = '" . esc_js (wp_login_url ()) . "';";
354
+ echo '</script>' . "\n";
355
+ }
356
+ }
357
+ else /* Else a custom conditional has been applied by filters. */
358
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
359
+ }
360
+ else
361
+ {
362
+ $paypal["s2member_log"][] = "Unable to verify _SERVER[HTTP_HOST]. Please check the `custom` value in your Button Code. It MUST start with your domain name.";
363
+ /**/
364
+ $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
365
+ /**/
366
+ echo '<script type="text/javascript">' . "\n";
367
+ echo "alert('ERROR: Unable to verify _SERVER[HTTP_HOST]. Please contact Support for assistance.\\n\\nIf you are the site owner, please check the `custom` value in your Button Code. It MUST start with your domain name.');" . "\n";
368
+ echo "window.location = '" . esc_js (wp_login_url ()) . "';";
369
+ echo '</script>' . "\n";
370
+ }
371
+ }
372
+ else if (!isset ($_GET["tx"]) && (empty ($_POST) || $_POST["auth"]))
373
+ {
374
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
375
+ do_action ("ws_plugin__s2member_during_paypal_return_before_no_return_data", get_defined_vars ());
376
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
377
+ /**/
378
+ $paypal["s2member_log"][] = "No Return-Data from PayPal®. Customer must wait for Email Confirmation.";
379
+ /**/
380
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
381
+ do_action ("ws_plugin__s2member_during_paypal_return_during_no_return_data", get_defined_vars ());
382
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
383
+ /**/
384
+ $paypal["s2member_log"][] = "Redirecting Customer to the Home Page.";
385
+ /**/
386
+ echo '<script type="text/javascript">' . "\n";
387
+ echo "alert('Thank You! ( please check your email ).\\n\\n* Note: It can take ( up to 15 minutes ) for Email Confirmation. If you don\'t receive email confirmation in the next 15 minutes, please contact Support.');" . "\n";
388
+ echo ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "alert('** Sandbox Mode ** You will probably NOT receive this Email Confirmation in Sandbox Mode. Sandbox addresses are usually bogus ( for testing ).');" . "\n" : "";
389
+ echo "window.location = '" . esc_js (get_bloginfo ("url")) . "';";
390
+ echo '</script>' . "\n";
391
+ /**/
392
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
393
+ do_action ("ws_plugin__s2member_during_paypal_return_after_no_return_data", get_defined_vars ());
394
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
395
+ }
396
+ else /* Extensive log reporting here. This is an area where many site owners find trouble. Depending on server configuration; remote HTTPS connections may fail. */
397
+ {
398
+ $paypal["s2member_log"][] = "Unable to verify POST vars. This is most likely related to an invalid PayPal® configuration. Please check: s2Member -> PayPal® Options.";
399
+ $paypal["s2member_log"][] = "If you're absolutely SURE that your PayPal® configuration is valid, you may want to run some tests on your server, just to be sure \$_POST variables are populated, and that your server is able to connect to PayPal® over an HTTPS connection.";
400
+ $paypal["s2member_log"][] = "s2Member uses the WP_Http class for remote connections; which will try to use cURL first, and then fall back on the FOPEN method when cURL is not available. On a Windows® server, you may have to disable your cURL extension. Instead, set allow_url_fopen = yes in your php.ini file. The cURL extension (usually) does NOT support SSL connections on a Windows® server.";
401
+ $paypal["s2member_log"][] = var_export ($_POST, true); /* Recording _POST vars for analysis and debugging. */
402
+ /**/
403
+ $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
404
+ /**/
405
+ echo '<script type="text/javascript">' . "\n";
406
+ echo "alert('ERROR: Unable to verify POST vars. Please contact Support for assistance.\\n\\nThis is most likely related to an invalid PayPal® configuration. If you are the site owner, please check: s2Member -> PayPal® Options.');" . "\n";
407
+ echo "window.location = '" . esc_js (wp_login_url ()) . "';";
408
+ echo '</script>' . "\n";
409
+ }
410
+ /*
411
+ Add RTN proxy identification ( when available ) to the $paypal array for log reporting.
412
+ */
413
+ if ($_GET["s2member_paypal_proxy"]) /* For proxy identification. */
414
+ $paypal["s2member_paypal_proxy"] = $_GET["s2member_paypal_proxy"];
415
+ /*
416
+ Also add RTN proxy self-verification ( when available ) to the $paypal array.
417
+ */
418
+ if ($_GET["s2member_paypal_proxy_verification"]) /* Proxy identification w/verification. */
419
+ $paypal["s2member_paypal_proxy_verification"] = $_GET["s2member_paypal_proxy_verification"];
420
+ /*
421
+ If debugging/logging is enabled; we need to append $paypal to the log file.
422
+ Logging now supports Multisite Networking as well.
423
+ */
424
+ $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
425
+ $log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
426
+ $log2 = (is_multisite () && !is_main_site ()) ? "paypal-rtn-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-rtn.log";
427
+ /**/
428
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_debug"]) /* Append to log? */
429
+ if (is_dir ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) /* Dir exists? */
430
+ if (is_writable ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
431
+ file_put_contents ($logs_dir . "/" . $log2, $log4 . "\n" . var_export ($paypal, true) . "\n\n", FILE_APPEND);
432
+ /**/
433
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
434
+ do_action ("ws_plugin__s2member_during_paypal_return", get_defined_vars ());
435
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
436
+ /**/
437
+ exit ();
438
+ }
439
+ /**/
440
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
441
+ do_action ("ws_plugin__s2member_after_paypal_return", get_defined_vars ());
442
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
443
+ }
444
+ }
445
+ ?>
includes/functions/sp-access.inc.php CHANGED
@@ -12,25 +12,26 @@ If not, see: <http://www.gnu.org/licenses/>.
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit("Do not access this file directly.");
16
  /*
17
  Generates Specific Post/Page Access links.
18
  */
19
  if (!function_exists ("ws_plugin__s2member_sp_access_link_gen"))
20
  {
21
- function ws_plugin__s2member_sp_access_link_gen ($sp_IDs = FALSE, $hours = 72, $shrink = TRUE)
22
  {
23
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
24
  do_action ("ws_plugin__s2member_before_sp_access_link_gen", get_defined_vars ());
25
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
26
  /**/
27
- if (($sp_IDs = preg_replace ("/[^0-9;,]/", "", $sp_IDs)) && ($leading_ID = preg_replace ("/^([0-9]+)(.*?)$/", "$1", $sp_IDs)) && $hours)
28
  {
29
- $sp_access = ws_plugin__s2member_encrypt ("sp_time_hours:.:|:.:" . $sp_IDs . ":.:|:.:" . strtotime ("now") . ":.:|:.:" . $hours);
30
- $sp_access_link = add_query_arg ("s2member_sp_access", $sp_access, get_permalink ($leading_ID));
31
  /**/
32
  if ($shrink && ($tinyurl = ws_plugin__s2member_remote ("http://tinyurl.com/api-create.php?url=" . rawurlencode ($sp_access_link))))
33
- return apply_filters ("ws_plugin__s2member_sp_access_link_gen", $tinyurl, get_defined_vars ()); /* tinyURL is easier to work with. */
 
34
  else /* Else use the long one; tinyURL will fail when/if their server is down periodically. */
35
  return apply_filters ("ws_plugin__s2member_sp_access_link_gen", $sp_access_link, get_defined_vars ());
36
  }
@@ -60,38 +61,36 @@ Handles Specific Post/Page Access authentication.
60
  */
61
  if (!function_exists ("ws_plugin__s2member_sp_access"))
62
  {
63
- function ws_plugin__s2member_sp_access ($sp_ID = FALSE)
64
  {
65
  do_action ("ws_plugin__s2member_before_sp_access", get_defined_vars ());
66
  /**/
67
  $excluded = apply_filters ("ws_plugin__s2member_sp_access_excluded", false, get_defined_vars ());
68
  /**/
69
- if ($excluded || current_user_can ("edit_posts"))
70
- return true; /* Excluded? Or editing? */
71
  /**/
72
- else if ($sp_ID /* Looking for either a _GET request, or a non-empty session. */
73
- && (($_GET["s2member_sp_access"] && is_array ($sp_access_values = (array)$_GET["s2member_sp_access"]))/**/
74
- || (is_array ($sp_access_values = ws_plugin__s2member_sp_access_session ()) && !empty ($sp_access_values))))
75
  {
76
  foreach ($sp_access_values as $sp_access_value) /* Supports multiple access values in a session. */
77
  {
78
  if (is_array ($sp_access = preg_split ("/\:\.\:\|\:\.\:/", ws_plugin__s2member_decrypt ($sp_access_value))))
79
  {
80
- if (count ($sp_access) === 4 && $sp_access[0] === "sp_time_hours" && in_array ($sp_ID, preg_split ("/[\r\n\t\s;,]+/", $sp_access[1])))
81
  {
82
  if ($sp_access[2] <= strtotime ("now") && ($sp_access[2] + ($sp_access[3] * 3600)) >= strtotime ("now"))
83
  {
84
- if ($_GET["s2member_sp_access"]) /* Store request in a session. */
85
- ws_plugin__s2member_sp_access_session($_GET["s2member_sp_access"]);
86
  /**/
87
- if (ws_plugin__s2member_ip_restrictions_ok ($_SERVER["REMOTE_ADDR"], $sp_access_value))
88
  return apply_filters ("ws_plugin__s2member_sp_access", true, get_defined_vars ());
89
  }
90
  }
91
  }
92
  }
93
  /**/
94
- if ($_GET["s2member_sp_access"]) /* If this is a Specific Post/Page Link, fail with expiration. */
95
  {
96
  echo '<strong>Your Link Expired:</strong><br />Please contact Support if you need assistance.';
97
  /**/
@@ -101,7 +100,7 @@ if (!function_exists ("ws_plugin__s2member_sp_access"))
101
  return apply_filters ("ws_plugin__s2member_sp_access", false, get_defined_vars ());
102
  }
103
  /**/
104
- else /* Access is not possible. */
105
  return apply_filters ("ws_plugin__s2member_sp_access", false, get_defined_vars ());
106
  }
107
  }
@@ -113,7 +112,7 @@ if (!function_exists ("ws_plugin__s2member_sp_access_session"))
113
  {
114
  function ws_plugin__s2member_sp_access_session ($add_sp_access_value = FALSE)
115
  {
116
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
117
  do_action ("ws_plugin__s2member_before_sp_access_session", get_defined_vars ());
118
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
119
  /**/
@@ -122,13 +121,14 @@ if (!function_exists ("ws_plugin__s2member_sp_access_session"))
122
  if ($add_sp_access_value && !in_array ($add_sp_access_value, $sp_access_values)) /* If it's not in the session already. */
123
  {
124
  $sp_access_values[] = $add_sp_access_value; /* Add an access value, and update the delimited session cookie. */
 
125
  /**/
126
  $cookie = implode (":.:|:.:", $sp_access_values); /* Implode the access values into a delimited string. */
127
  $cookie = (strlen ($cookie) >= 4096) ? $add_sp_access_value : $cookie; /* Max cookie size is 4kbs. */
128
  /**/
129
  setcookie ("s2member_sp_access", $cookie, time () + 31556926, "/");
130
  /**/
131
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
132
  do_action ("ws_plugin__s2member_during_sp_access_session", get_defined_vars ());
133
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
134
  }
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit ("Do not access this file directly.");
16
  /*
17
  Generates Specific Post/Page Access links.
18
  */
19
  if (!function_exists ("ws_plugin__s2member_sp_access_link_gen"))
20
  {
21
+ function ws_plugin__s2member_sp_access_link_gen ($sp_ids = FALSE, $hours = 72, $shrink = TRUE)
22
  {
23
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
24
  do_action ("ws_plugin__s2member_before_sp_access_link_gen", get_defined_vars ());
25
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
26
  /**/
27
+ if (($sp_ids = preg_replace ("/[^0-9;,]/", "", $sp_ids)) && ($leading_id = preg_replace ("/^([0-9]+)(.*?)$/", "$1", $sp_ids)) && $hours)
28
  {
29
+ $sp_access = ws_plugin__s2member_encrypt ("sp_time_hours:.:|:.:" . $sp_ids . ":.:|:.:" . strtotime ("now") . ":.:|:.:" . $hours);
30
+ $sp_access_link = add_query_arg ("s2member_sp_access", $sp_access, get_permalink ($leading_id));
31
  /**/
32
  if ($shrink && ($tinyurl = ws_plugin__s2member_remote ("http://tinyurl.com/api-create.php?url=" . rawurlencode ($sp_access_link))))
33
+ return apply_filters ("ws_plugin__s2member_sp_access_link_gen", $tinyurl, get_defined_vars ()); /* tinyURL is recommended. */
34
+ /**/
35
  else /* Else use the long one; tinyURL will fail when/if their server is down periodically. */
36
  return apply_filters ("ws_plugin__s2member_sp_access_link_gen", $sp_access_link, get_defined_vars ());
37
  }
61
  */
62
  if (!function_exists ("ws_plugin__s2member_sp_access"))
63
  {
64
+ function ws_plugin__s2member_sp_access ($sp_id = FALSE, $read_only = FALSE)
65
  {
66
  do_action ("ws_plugin__s2member_before_sp_access", get_defined_vars ());
67
  /**/
68
  $excluded = apply_filters ("ws_plugin__s2member_sp_access_excluded", false, get_defined_vars ());
69
  /**/
70
+ if ($excluded || current_user_can ("edit_posts")) /* Apply Filter here as well. */
71
+ return apply_filters ("ws_plugin__s2member_sp_access", true, get_defined_vars ());
72
  /**/
73
+ else if ($sp_id && ( ($_GET["s2member_sp_access"] && is_array ($sp_access_values = (array)$_GET["s2member_sp_access"])) || (is_array ($sp_access_values = ws_plugin__s2member_sp_access_session ()) && !empty ($sp_access_values))))
 
 
74
  {
75
  foreach ($sp_access_values as $sp_access_value) /* Supports multiple access values in a session. */
76
  {
77
  if (is_array ($sp_access = preg_split ("/\:\.\:\|\:\.\:/", ws_plugin__s2member_decrypt ($sp_access_value))))
78
  {
79
+ if (count ($sp_access) === 4 && $sp_access[0] === "sp_time_hours" && in_array ($sp_id, preg_split ("/[\r\n\t\s;,]+/", $sp_access[1])))
80
  {
81
  if ($sp_access[2] <= strtotime ("now") && ($sp_access[2] + ($sp_access[3] * 3600)) >= strtotime ("now"))
82
  {
83
+ if (!$read_only && $_GET["s2member_sp_access"]) /* Store request in a session. */
84
+ ws_plugin__s2member_sp_access_session ($_GET["s2member_sp_access"]);
85
  /**/
86
+ if ($read_only || ws_plugin__s2member_ip_restrictions_ok ($_SERVER["REMOTE_ADDR"], $sp_access_value))
87
  return apply_filters ("ws_plugin__s2member_sp_access", true, get_defined_vars ());
88
  }
89
  }
90
  }
91
  }
92
  /**/
93
+ if (!$read_only && $_GET["s2member_sp_access"]) /* If this is a Specific Post/Page Link, fail with expiration. */
94
  {
95
  echo '<strong>Your Link Expired:</strong><br />Please contact Support if you need assistance.';
96
  /**/
100
  return apply_filters ("ws_plugin__s2member_sp_access", false, get_defined_vars ());
101
  }
102
  /**/
103
+ else
104
  return apply_filters ("ws_plugin__s2member_sp_access", false, get_defined_vars ());
105
  }
106
  }
112
  {
113
  function ws_plugin__s2member_sp_access_session ($add_sp_access_value = FALSE)
114
  {
115
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
116
  do_action ("ws_plugin__s2member_before_sp_access_session", get_defined_vars ());
117
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
118
  /**/
121
  if ($add_sp_access_value && !in_array ($add_sp_access_value, $sp_access_values)) /* If it's not in the session already. */
122
  {
123
  $sp_access_values[] = $add_sp_access_value; /* Add an access value, and update the delimited session cookie. */
124
+ $sp_access_values = array_unique ($sp_access_values); /* Keep this array unique; disallow double-stacking. */
125
  /**/
126
  $cookie = implode (":.:|:.:", $sp_access_values); /* Implode the access values into a delimited string. */
127
  $cookie = (strlen ($cookie) >= 4096) ? $add_sp_access_value : $cookie; /* Max cookie size is 4kbs. */
128
  /**/
129
  setcookie ("s2member_sp_access", $cookie, time () + 31556926, "/");
130
  /**/
131
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
132
  do_action ("ws_plugin__s2member_during_sp_access_session", get_defined_vars ());
133
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
134
  }
includes/functions/translations.inc.php CHANGED
@@ -12,7 +12,7 @@ If not, see: <http://www.gnu.org/licenses/>.
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit("Do not access this file directly.");
16
  /*
17
  Mangles internal translations.
18
  Attach to: add_filter("gettext");
@@ -39,9 +39,9 @@ if (!function_exists ("ws_plugin__s2member_translation_mangler"))
39
  $is_admin_media_upload = false;
40
  }
41
  /**/
42
- if ((!isset ($is_wp_signup) || $is_wp_signup) && is_multisite () && is_main_site ())
43
  {
44
- if ($is_wp_signup || preg_match ("/\/wp-signup\.php/", $_SERVER["REQUEST_URI"]))
45
  {
46
  $is_wp_signup = true; /* Yes, we are in this area. */
47
  /**/
@@ -57,10 +57,10 @@ if (!function_exists ("ws_plugin__s2member_translation_mangler"))
57
  $current_user_blogs = ($current_user_blogs >= 0) ? $current_user_blogs : 0;
58
  /**/
59
  if ($current_user_blogs >= 1) /* So here they already have at least 1 Blog. This message works fine. */
60
- $translated = apply_filters ("ws_plugin__s2member_translation_mangler", "Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. You may create up to " . $blogs_allowed . " site" . (($blogs_allowed < 1 || $blogs_allowed > 1) ? "s" : "") . "; but please write responsibly<em>!</em>", get_defined_vars ());
61
  /**/
62
  else /* Otherwise, we need a different message. One that is NOT confusing to a new Customer. */
63
- $translated = apply_filters ("ws_plugin__s2member_translation_mangler", "Hi %s. By filling out the form below, you can <strong>add a site to your account</strong>. You may create up to " . $blogs_allowed . " site" . (($blogs_allowed < 1 || $blogs_allowed > 1) ? "s" : "") . "; but please write responsibly<em>!</em>", get_defined_vars ());
64
  }
65
  }
66
  }
12
  Direct access denial.
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit ("Do not access this file directly.");
16
  /*
17
  Mangles internal translations.
18
  Attach to: add_filter("gettext");
39
  $is_admin_media_upload = false;
40
  }
41
  /**/
42
+ if (!isset ($is_wp_signup) || $is_wp_signup)
43
  {
44
+ if ($is_wp_signup || (is_multisite () && is_main_site () && preg_match ("/\/wp-signup\.php/", $_SERVER["REQUEST_URI"])))
45
  {
46
  $is_wp_signup = true; /* Yes, we are in this area. */
47
  /**/
57
  $current_user_blogs = ($current_user_blogs >= 0) ? $current_user_blogs : 0;
58
  /**/
59
  if ($current_user_blogs >= 1) /* So here they already have at least 1 Blog. This message works fine. */
60
+ $translated = apply_filters ("ws_plugin__s2member_translation_mangler", "Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. You may create up to " . $blogs_allowed . " site" . ( ($blogs_allowed < 1 || $blogs_allowed > 1) ? "s" : "") . "; but please write responsibly<em>!</em>", get_defined_vars ());
61
  /**/
62
  else /* Otherwise, we need a different message. One that is NOT confusing to a new Customer. */
63
+ $translated = apply_filters ("ws_plugin__s2member_translation_mangler", "Hi %s. By filling out the form below, you can <strong>add a site to your account</strong>. You may create up to " . $blogs_allowed . " site" . ( ($blogs_allowed < 1 || $blogs_allowed > 1) ? "s" : "") . "; but please write responsibly<em>!</em>", get_defined_vars ());
64
  }
65
  }
66
  }
includes/functions/utilities.inc.php CHANGED
@@ -236,7 +236,7 @@ if (!function_exists ("ws_plugin__s2member_is_multisite_farm"))
236
  {
237
  function ws_plugin__s2member_is_multisite_farm ()
238
  {
239
- return (is_multisite () && ((is_main_site () && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_file"] === "wp-signup") || (defined ("MULTISITE_FARM") && MULTISITE_FARM)));
240
  }
241
  }
242
  /*
@@ -256,12 +256,12 @@ Function checks if a post is in a child category.
256
  */
257
  if (!function_exists ("ws_plugin__s2member_in_descendant_category"))
258
  {
259
- function ws_plugin__s2member_in_descendant_category ($cats = FALSE, $post_ID = FALSE)
260
  {
261
  foreach ((array)$cats as $cat)
262
  {
263
  $descendants = get_term_children ((int)$cat, "category");
264
- if ($descendants && in_category ($descendants, $post_ID))
265
  return true;
266
  }
267
  /**/
@@ -269,6 +269,154 @@ if (!function_exists ("ws_plugin__s2member_in_descendant_category"))
269
  }
270
  }
271
  /*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
  RIJNDAEL 256: two-way encryption/decryption, with a url-safe base64 wrapper.
273
  Includes a built-in fallback on XOR encryption when mcrypt is not available.
274
  */
236
  {
237
  function ws_plugin__s2member_is_multisite_farm ()
238
  {
239
+ return (is_multisite () && ( (is_main_site () && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_file"] === "wp-signup") || (defined ("MULTISITE_FARM") && MULTISITE_FARM)));
240
  }
241
  }
242
  /*
256
  */
257
  if (!function_exists ("ws_plugin__s2member_in_descendant_category"))
258
  {
259
+ function ws_plugin__s2member_in_descendant_category ($cats = FALSE, $post_id = FALSE)
260
  {
261
  foreach ((array)$cats as $cat)
262
  {
263
  $descendants = get_term_children ((int)$cat, "category");
264
+ if ($descendants && in_category ($descendants, $post_id))
265
  return true;
266
  }
267
  /**/
269
  }
270
  }
271
  /*
272
+ Function retrieves a list of all Category IDs from the database.
273
+ */
274
+ if (!function_exists ("ws_plugin__s2member_get_all_category_ids"))
275
+ {
276
+ function ws_plugin__s2member_get_all_category_ids ()
277
+ {
278
+ $ids = get_all_category_ids ();
279
+ /**/
280
+ return (array)$ids;
281
+ }
282
+ }
283
+ /*
284
+ Function retrieves a list of all Tag IDs from the database.
285
+ */
286
+ if (!function_exists ("ws_plugin__s2member_get_all_tag_ids"))
287
+ {
288
+ function ws_plugin__s2member_get_all_tag_ids ()
289
+ {
290
+ global $wpdb; /* Need global DB obj. */
291
+ /**/
292
+ foreach ((array)get_tags () as $tag)
293
+ $ids[] = $tag->term_id;
294
+ /**/
295
+ return (array)$ids;
296
+ }
297
+ }
298
+ /*
299
+ Function retrieves a list of all Post IDs from the database.
300
+ - Includes Custom Post Types.
301
+ */
302
+ if (!function_exists ("ws_plugin__s2member_get_all_post_ids"))
303
+ {
304
+ function ws_plugin__s2member_get_all_post_ids ()
305
+ {
306
+ global $wpdb; /* Need global DB obj. */
307
+ /**/
308
+ $ids = $wpdb->get_col ("SELECT `ID` FROM `" . $wpdb->posts . "` WHERE `post_status` = 'publish' AND `post_type` NOT IN('page','attachment','revision')");
309
+ /**/
310
+ return (array)$ids;
311
+ }
312
+ }
313
+ /*
314
+ Function retrieves a list of all Page IDs from the database.
315
+ */
316
+ if (!function_exists ("ws_plugin__s2member_get_all_page_ids"))
317
+ {
318
+ function ws_plugin__s2member_get_all_page_ids ()
319
+ {
320
+ global $wpdb; /* Need global DB obj. */
321
+ /**/
322
+ $ids = $wpdb->get_col ("SELECT `ID` FROM `" . $wpdb->posts . "` WHERE `post_status` = 'publish' AND `post_type` = 'page'");
323
+ /**/
324
+ return (array)$ids;
325
+ }
326
+ }
327
+ /*
328
+ Function converts a comma-delimited list of:
329
+ Tag slugs/names/ids - into all IDs.
330
+ */
331
+ if (!function_exists ("ws_plugin__s2member_convert_tags_2_ids"))
332
+ {
333
+ function ws_plugin__s2member_convert_tags_2_ids ($tags = FALSE)
334
+ {
335
+ foreach (preg_split ("/[\r\n\t;,]+/", $tags) as $tag)
336
+ {
337
+ if (($tag = trim ($tag)) && is_numeric ($tag))
338
+ {
339
+ $ids[] = $tag;
340
+ }
341
+ else if ($tag && is_string ($tag))
342
+ {
343
+ if (is_object ($term = get_term_by ("name", $tag, "post_tag")))
344
+ {
345
+ $ids[] = $term->term_id;
346
+ }
347
+ else if (is_object ($term = get_term_by ("slug", $tag, "post_tag")))
348
+ {
349
+ $ids[] = $term->term_id;
350
+ }
351
+ }
352
+ }
353
+ /**/
354
+ return (array)$ids;
355
+ }
356
+ }
357
+ /*
358
+ Function retrieves a list of singular IDs from the database.
359
+ - Only returns Posts that require Custom Capabilities.
360
+ and ONLY those which are NOT satisfied by $user.
361
+ */
362
+ if (!function_exists ("ws_plugin__s2member_get_singular_ids_with_ccaps_req"))
363
+ {
364
+ function ws_plugin__s2member_get_singular_ids_with_ccaps_req ($user = FALSE)
365
+ {
366
+ global $wpdb; /* Need global DB obj. */
367
+ /**/
368
+ if (is_array ($results = $wpdb->get_results ("SELECT `post_id`, `meta_value` FROM `" . $wpdb->postmeta . "` WHERE `meta_key` = 's2member_ccaps_req' AND `meta_value` != ''")))
369
+ {
370
+ foreach ($results as $result) /* Now we need to check Custom Capabilities against $user. */
371
+ {
372
+ if (!$result->meta_value) /* Empty? */
373
+ continue;
374
+ /**/
375
+ else if ($result->meta_value === 'a:1:{i:0;s:0:"";}')
376
+ continue; /* An empty array? */
377
+ /**/
378
+ else if (!$user) /* Optimization. Saves time when NOT even logged into the site. */
379
+ $ids[] = $result->post_id; /* There's no way to satisfy anything here. */
380
+ /**/
381
+ else if (is_array ($ccaps = @unserialize ($result->meta_value)))
382
+ /**/
383
+ foreach ($ccaps as $ccap) /* Test all Custom Capability requirements. */
384
+ if (strlen ($ccap)) /* Quick (empty) check here. */
385
+ if (!$user->has_cap ("access_s2member_ccap_" . $ccap))
386
+ {
387
+ $ids[] = $result->post_id;
388
+ break;
389
+ }
390
+ }
391
+ }
392
+ /**/
393
+ return (array)$ids;
394
+ }
395
+ }
396
+ /*
397
+ Function retrieves a list of singular IDs from the database.
398
+ - Only returns Posts that require Specific Post/Page Access.
399
+ & ONLY those which are NOT satisfied by the current Visitor.
400
+ */
401
+ if (!function_exists ("ws_plugin__s2member_get_singular_ids_with_sp_req"))
402
+ {
403
+ function ws_plugin__s2member_get_singular_ids_with_sp_req ()
404
+ {
405
+ global $wpdb; /* Need global DB obj. */
406
+ /**/
407
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && is_array ($sps = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])))
408
+ {
409
+ foreach ($sps as $sp) /* Now we need to check access against the current Visitor. */
410
+ {
411
+ if ($sp && !ws_plugin__s2member_sp_access ($sp, "read-only"))
412
+ $ids[] = $sp;
413
+ }
414
+ }
415
+ /**/
416
+ return (array)$ids;
417
+ }
418
+ }
419
+ /*
420
  RIJNDAEL 256: two-way encryption/decryption, with a url-safe base64 wrapper.
421
  Includes a built-in fallback on XOR encryption when mcrypt is not available.
422
  */
includes/hooks.inc.php CHANGED
@@ -16,6 +16,10 @@ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
16
  /*
17
  Add the plugin actions/filters here.
18
  */
 
 
 
 
19
  add_action ("init", "ws_plugin__s2member_nocache");
20
  add_action ("init", "ws_plugin__s2member_constants");
21
  add_action ("init", "ws_plugin__s2member_register");
@@ -34,19 +38,13 @@ add_action ("init", "ws_plugin__s2member_auto_eot_system_via_cron");
34
  add_action ("template_redirect", "ws_plugin__s2member_profile");
35
  add_action ("template_redirect", "ws_plugin__s2member_membership_options_page");
36
  add_action ("template_redirect", "ws_plugin__s2member_check_force_ssl");
37
- /**/
38
- add_action ("template_redirect", "ws_plugin__s2member_check_ruri_level_access", 1);
39
- add_action ("template_redirect", "ws_plugin__s2member_check_catg_level_access", 1);
40
- add_action ("template_redirect", "ws_plugin__s2member_check_ptag_level_access", 1);
41
- add_action ("template_redirect", "ws_plugin__s2member_check_post_level_access", 1);
42
- add_action ("template_redirect", "ws_plugin__s2member_check_page_level_access", 1);
43
  /**/
44
  add_filter ("widget_text", "do_shortcode"); /* Shortcodes in widgets. */
45
  /**/
46
  add_action ("wp_print_styles", "ws_plugin__s2member_add_css");
47
  add_action ("wp_print_scripts", "ws_plugin__s2member_add_js_w_globals");
48
  add_filter ("gettext", "ws_plugin__s2member_translation_mangler", 10, 3);
49
- add_filter ("posts_where", "ws_plugin__s2member_hide_some_systematics");
50
  /**/
51
  add_action ("delete_user", "ws_plugin__s2member_handle_user_deletions");
52
  add_action ("wpmu_delete_user", "ws_plugin__s2member_handle_ms_user_deletions");
@@ -104,7 +102,6 @@ add_action ("personal_options_update", "ws_plugin__s2member_users_list_update_co
104
  add_filter ("show_password_fields", "ws_plugin__s2member_demo_hide_password_fields", 10, 2);
105
  /**/
106
  add_filter ("cron_schedules", "ws_plugin__s2member_extend_cron_schedules");
107
- /**/
108
  add_action ("ws_plugin__s2member_auto_eot_system__schedule", "ws_plugin__s2member_auto_eot_system");
109
  /*
110
  Register the activation | de-activation routines.
16
  /*
17
  Add the plugin actions/filters here.
18
  */
19
+ add_action ("pre_get_posts", /* WP Query. */
20
+ "ws_plugin__s2member_security_gate_query", 20);
21
+ /* Priority matches `/api-functions.inc.php`.
22
+ /**/
23
  add_action ("init", "ws_plugin__s2member_nocache");
24
  add_action ("init", "ws_plugin__s2member_constants");
25
  add_action ("init", "ws_plugin__s2member_register");
38
  add_action ("template_redirect", "ws_plugin__s2member_profile");
39
  add_action ("template_redirect", "ws_plugin__s2member_membership_options_page");
40
  add_action ("template_redirect", "ws_plugin__s2member_check_force_ssl");
41
+ add_action ("template_redirect", "ws_plugin__s2member_security_gate");
 
 
 
 
 
42
  /**/
43
  add_filter ("widget_text", "do_shortcode"); /* Shortcodes in widgets. */
44
  /**/
45
  add_action ("wp_print_styles", "ws_plugin__s2member_add_css");
46
  add_action ("wp_print_scripts", "ws_plugin__s2member_add_js_w_globals");
47
  add_filter ("gettext", "ws_plugin__s2member_translation_mangler", 10, 3);
 
48
  /**/
49
  add_action ("delete_user", "ws_plugin__s2member_handle_user_deletions");
50
  add_action ("wpmu_delete_user", "ws_plugin__s2member_handle_ms_user_deletions");
102
  add_filter ("show_password_fields", "ws_plugin__s2member_demo_hide_password_fields", 10, 2);
103
  /**/
104
  add_filter ("cron_schedules", "ws_plugin__s2member_extend_cron_schedules");
 
105
  add_action ("ws_plugin__s2member_auto_eot_system__schedule", "ws_plugin__s2member_auto_eot_system");
106
  /*
107
  Register the activation | de-activation routines.
includes/menu-pages/api-ops.inc.php CHANGED
@@ -340,6 +340,8 @@ if (apply_filters ("ws_plugin__s2member_during_api_ops_page_during_left_sections
340
  echo '<strong>You can also use these special Replacement Codes if you need them:</strong>' . "\n";
341
  echo '<ul>' . "\n";
342
  echo '<li><code>%%subscr_id%%</code> = The PayPal® Subscription ID, which remained constant throughout the lifetime of the Membership. [ <a href="#" onclick="alert(\'There is one exception. If you are selling Lifetime or Fixed-Term ( non-recurring ) access, using Buy Now functionality; the %%subscr_id%% is actually set to the original Transaction ID for the purchase.\\n\\nPayPal® does not provide a specific Subscription ID for Buy Now purchases. Since Lifetime &amp; Fixed-Term Subscriptions are NOT recurring ( i.e. there was only ONE payment ), using the Transaction ID as the Subscription ID is a graceful way to deal with this minor conflict.\'); return false;">?</a> ]</li>' . "\n";
 
 
343
  echo '<li><code>%%user_first_name%%</code> = The First Name listed on their User account. This might be different than what is on file at PayPal®.</li>' . "\n";
344
  echo '<li><code>%%user_last_name%%</code> = The Last Name listed on their User account. This might be different than what is on file at PayPal®.</li>' . "\n";
345
  echo '<li><code>%%user_full_name%%</code> = The Full Name listed on their User account. This might be different than what is on file at PayPal®.</li>' . "\n";
@@ -580,24 +582,24 @@ if (apply_filters ("ws_plugin__s2member_during_api_ops_page_during_left_sections
580
  do_action ("ws_plugin__s2member_during_api_ops_page_during_left_sections_after_refund_reversal_notifications", get_defined_vars ());
581
  }
582
  /**/
583
- if (apply_filters ("ws_plugin__s2member_during_api_ops_page_during_left_sections_display_sp_notifications", true, get_defined_vars ()))
584
  {
585
- do_action ("ws_plugin__s2member_during_api_ops_page_during_left_sections_before_sp_notifications", get_defined_vars ());
586
  /**/
587
- echo '<div class="ws-menu-page-group" title="Specific Post/Page Access Notifications">' . "\n";
588
  /**/
589
- echo '<div class="ws-menu-page-section ws-plugin--s2member-sp-notifications-section">' . "\n";
590
- echo '<h3>Specific Post/Page Access Notification URLs ( optional )</h3>' . "\n";
591
- echo '<p>If you use affiliate software, or have back-office routines that need to be notified whenever Specific Post/Page transactions take place, you\'ll want to read this section. This is marked `Specific Post/Page`, because the URLs that you list below, will be notified each time a payment occurs, for access to a Specific Post/Page sale. This is the only Notification that is sent for Specific Post/Page Access. All of the other API Notifications are designed for Membership Level Access. Please note, this feature is not to be confused with the PayPal® IPN service. PayPal® IPN integration is already built into s2Member, and it remains active at all times. These Payment Notifications are an added layer of functionality, and they are completely optional.</p>' . "\n";
592
- do_action ("ws_plugin__s2member_during_api_ops_page_during_left_sections_during_sp_notifications", get_defined_vars ());
593
  /**/
594
  echo '<table class="form-table">' . "\n";
595
  echo '<tbody>' . "\n";
596
  echo '<tr>' . "\n";
597
  /**/
598
  echo '<th>' . "\n";
599
- echo '<label for="ws-plugin--s2member-sp-notification-urls">' . "\n";
600
- echo 'Specific Post/Page Notification URLs:' . "\n";
601
  echo '</label>' . "\n";
602
  echo '</th>' . "\n";
603
  /**/
@@ -606,8 +608,8 @@ if (apply_filters ("ws_plugin__s2member_during_api_ops_page_during_left_sections
606
  /**/
607
  echo '<td>' . "\n";
608
  echo 'You can input multiple Notification URLs by inserting one per line.<br />' . "\n";
609
- echo '<textarea name="ws_plugin__s2member_sp_notification_urls" id="ws-plugin--s2member-sp-notification-urls" rows="3" wrap="off">' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_notification_urls"]) . '</textarea><br />' . "\n";
610
- echo 'Specific Post/Page Notifications take place silently behind-the-scene, using an HTTP connection. Each URL will be notified every time a sale occurs.<br /><br />' . "\n";
611
  echo '<strong>You can also use these special Replacement Codes if you need them:</strong>' . "\n";
612
  echo '<ul>' . "\n";
613
  echo '<li><code>%%sp_access_url%%</code> = The full URL ( generated by s2Member ) where the Customer can gain access.</li>' . "\n";
@@ -647,7 +649,97 @@ if (apply_filters ("ws_plugin__s2member_during_api_ops_page_during_left_sections
647
  echo '<tr>' . "\n";
648
  /**/
649
  echo '<th style="padding-top:0;">' . "\n";
650
- echo '<label for="ws-plugin--s2member-sp-notification-recipients">' . "\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
651
  echo 'Send An Email Transaction Log Of This Event?' . "\n";
652
  echo '</label>' . "\n";
653
  echo '</th>' . "\n";
@@ -656,7 +748,7 @@ if (apply_filters ("ws_plugin__s2member_during_api_ops_page_during_left_sections
656
  echo '<tr>' . "\n";
657
  /**/
658
  echo '<td>' . "\n";
659
- echo '<input type="text" name="ws_plugin__s2member_sp_notification_recipients" id="ws-plugin--s2member-sp-notification-recipients" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_notification_recipients"]) . '" /><br />' . "\n";
660
  echo 'This is a semicolon ( ; ) delimited list of Recipients. Here is an example:<br />' . "\n";
661
  echo '<code>"John" &lt;john@example.com&gt;; admin@example.com; "Webmaster" &lt;webmaster@example.com&gt;</code>' . "\n";
662
  echo '</td>' . "\n";
@@ -668,7 +760,7 @@ if (apply_filters ("ws_plugin__s2member_during_api_ops_page_during_left_sections
668
  /**/
669
  echo '</div>' . "\n";
670
  /**/
671
- do_action ("ws_plugin__s2member_during_api_ops_page_during_left_sections_after_sp_notifications", get_defined_vars ());
672
  }
673
  /**/
674
  do_action ("ws_plugin__s2member_during_api_ops_page_after_left_sections", get_defined_vars ());
340
  echo '<strong>You can also use these special Replacement Codes if you need them:</strong>' . "\n";
341
  echo '<ul>' . "\n";
342
  echo '<li><code>%%subscr_id%%</code> = The PayPal® Subscription ID, which remained constant throughout the lifetime of the Membership. [ <a href="#" onclick="alert(\'There is one exception. If you are selling Lifetime or Fixed-Term ( non-recurring ) access, using Buy Now functionality; the %%subscr_id%% is actually set to the original Transaction ID for the purchase.\\n\\nPayPal® does not provide a specific Subscription ID for Buy Now purchases. Since Lifetime &amp; Fixed-Term Subscriptions are NOT recurring ( i.e. there was only ONE payment ), using the Transaction ID as the Subscription ID is a graceful way to deal with this minor conflict.\'); return false;">?</a> ]</li>' . "\n";
343
+ echo '<li><code>%%item_number%%</code> = The Item Number ( colon separated <em>level:custom_capabilities:fixed term</em> ) that the Subscription was for.</li>' . "\n";
344
+ echo '<li><code>%%item_name%%</code> = The Item Name ( as provided by the <code>desc=""</code> attribute in your Shortcode, which briefly describes the Item Number ).</li>' . "\n";
345
  echo '<li><code>%%user_first_name%%</code> = The First Name listed on their User account. This might be different than what is on file at PayPal®.</li>' . "\n";
346
  echo '<li><code>%%user_last_name%%</code> = The Last Name listed on their User account. This might be different than what is on file at PayPal®.</li>' . "\n";
347
  echo '<li><code>%%user_full_name%%</code> = The Full Name listed on their User account. This might be different than what is on file at PayPal®.</li>' . "\n";
582
  do_action ("ws_plugin__s2member_during_api_ops_page_during_left_sections_after_refund_reversal_notifications", get_defined_vars ());
583
  }
584
  /**/
585
+ if (apply_filters ("ws_plugin__s2member_during_api_ops_page_during_left_sections_display_sp_sale_notifications", true, get_defined_vars ()))
586
  {
587
+ do_action ("ws_plugin__s2member_during_api_ops_page_during_left_sections_before_sp_sale_notifications", get_defined_vars ());
588
  /**/
589
+ echo '<div class="ws-menu-page-group" title="Specific Post/Page ~ Sale Notifications">' . "\n";
590
  /**/
591
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-sp-sale-notifications-section">' . "\n";
592
+ echo '<h3>Specific Post/Page ~ Sale Notification URLs ( optional )</h3>' . "\n";
593
+ echo '<p>If you use affiliate software, or have back-office routines that need to be notified whenever Specific Post/Page sales take place, you\'ll want to read this section. This is marked `Specific Post/Page`, because the URLs that you list below, will be notified each time a payment occurs, on a sale providing access to a Specific Post/Page. This is one of only TWO Notifications that are sent for Specific Post/Page Access ( i.e. this one, and another below - for Refunds/Reversals ). All of the other API Notifications are designed for Membership Level Access. Please note, this feature is not to be confused with the PayPal® IPN service. PayPal® IPN integration is already built into s2Member, and it remains active at all times. These Sale Notifications are an added layer of functionality, and they are completely optional.</p>' . "\n";
594
+ do_action ("ws_plugin__s2member_during_api_ops_page_during_left_sections_during_sp_sale_notifications", get_defined_vars ());
595
  /**/
596
  echo '<table class="form-table">' . "\n";
597
  echo '<tbody>' . "\n";
598
  echo '<tr>' . "\n";
599
  /**/
600
  echo '<th>' . "\n";
601
+ echo '<label for="ws-plugin--s2member-sp-sale-notification-urls">' . "\n";
602
+ echo 'Specific Post/Page ~ Sale Notification URLs:' . "\n";
603
  echo '</label>' . "\n";
604
  echo '</th>' . "\n";
605
  /**/
608
  /**/
609
  echo '<td>' . "\n";
610
  echo 'You can input multiple Notification URLs by inserting one per line.<br />' . "\n";
611
+ echo '<textarea name="ws_plugin__s2member_sp_sale_notification_urls" id="ws-plugin--s2member-sp-sale-notification-urls" rows="3" wrap="off">' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_urls"]) . '</textarea><br />' . "\n";
612
+ echo 'Specific Post/Page ~ Sale Notifications take place silently behind-the-scene, using an HTTP connection. Each URL will be notified every time a sale occurs.<br /><br />' . "\n";
613
  echo '<strong>You can also use these special Replacement Codes if you need them:</strong>' . "\n";
614
  echo '<ul>' . "\n";
615
  echo '<li><code>%%sp_access_url%%</code> = The full URL ( generated by s2Member ) where the Customer can gain access.</li>' . "\n";
649
  echo '<tr>' . "\n";
650
  /**/
651
  echo '<th style="padding-top:0;">' . "\n";
652
+ echo '<label for="ws-plugin--s2member-sp-sale-notification-recipients">' . "\n";
653
+ echo 'Send An Email Transaction Log Of This Event?' . "\n";
654
+ echo '</label>' . "\n";
655
+ echo '</th>' . "\n";
656
+ /**/
657
+ echo '</tr>' . "\n";
658
+ echo '<tr>' . "\n";
659
+ /**/
660
+ echo '<td>' . "\n";
661
+ echo '<input type="text" name="ws_plugin__s2member_sp_sale_notification_recipients" id="ws-plugin--s2member-sp-sale-notification-recipients" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_recipients"]) . '" /><br />' . "\n";
662
+ echo 'This is a semicolon ( ; ) delimited list of Recipients. Here is an example:<br />' . "\n";
663
+ echo '<code>"John" &lt;john@example.com&gt;; admin@example.com; "Webmaster" &lt;webmaster@example.com&gt;</code>' . "\n";
664
+ echo '</td>' . "\n";
665
+ /**/
666
+ echo '</tr>' . "\n";
667
+ echo '</tbody>' . "\n";
668
+ echo '</table>' . "\n";
669
+ echo '</div>' . "\n";
670
+ /**/
671
+ echo '</div>' . "\n";
672
+ /**/
673
+ do_action ("ws_plugin__s2member_during_api_ops_page_during_left_sections_after_sp_sale_notifications", get_defined_vars ());
674
+ }
675
+ /**/
676
+ if (apply_filters ("ws_plugin__s2member_during_api_ops_page_during_left_sections_display_sp_refund_reversal_notifications", true, get_defined_vars ()))
677
+ {
678
+ do_action ("ws_plugin__s2member_during_api_ops_page_during_left_sections_before_sp_refund_reversal_notifications", get_defined_vars ());
679
+ /**/
680
+ echo '<div class="ws-menu-page-group" title="Specific Post/Page ~ Refund/Reversal Notifications">' . "\n";
681
+ /**/
682
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-sp-refund-reversal-notifications-section">' . "\n";
683
+ echo '<h3>Specific Post/Page ~ Refund/Reversal Notification URLs ( optional )</h3>' . "\n";
684
+ echo '<p>If you use affiliate software, or have back-office routines that need to be notified whenever sales have been refunded or reversed ( i.e. charged back to you ), you\'ll want to read this section. This is marked `Specific Post/Page`, because the URLs that you list below, will be notified each time a Refund or Reversal occurs, on a sale that provided access to a Specific Post/Page. This is one of ONLY two Notifications that are sent for Specific Post/Page Access ( i.e. this one, and another above - for Sales ). All of the other API Notifications are designed for Membership Level Access. Please note, this feature is not to be confused with the PayPal® IPN service. PayPal® IPN integration is already built into s2Member, and it remains active at all times. These Refund/Reversal Notifications are an added layer of functionality, and they are completely optional.</p>' . "\n";
685
+ do_action ("ws_plugin__s2member_during_api_ops_page_during_left_sections_during_sp_refund_reversal_notifications", get_defined_vars ());
686
+ /**/
687
+ echo '<table class="form-table">' . "\n";
688
+ echo '<tbody>' . "\n";
689
+ echo '<tr>' . "\n";
690
+ /**/
691
+ echo '<th>' . "\n";
692
+ echo '<label for="ws-plugin--s2member-sp-ref-rev-notification-urls">' . "\n";
693
+ echo 'Specific Post/Page ~ Refund/Reversal Notification URLs:' . "\n";
694
+ echo '</label>' . "\n";
695
+ echo '</th>' . "\n";
696
+ /**/
697
+ echo '</tr>' . "\n";
698
+ echo '<tr>' . "\n";
699
+ /**/
700
+ echo '<td>' . "\n";
701
+ echo 'You can input multiple Notification URLs by inserting one per line.<br />' . "\n";
702
+ echo '<textarea name="ws_plugin__s2member_sp_ref_rev_notification_urls" id="ws-plugin--s2member-sp-ref-rev-notification-urls" rows="3" wrap="off">' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_urls"]) . '</textarea><br />' . "\n";
703
+ echo 'Specific Post/Page ~ Refund/Reversal Notifications take place silently behind-the-scene, using an HTTP connection. Each URL will be notified every time a payment is refunded through PayPal® or a chargeback occurs.<br /><br />' . "\n";
704
+ echo '<strong>You can also use these special Replacement Codes if you need them:</strong>' . "\n";
705
+ echo '<ul>' . "\n";
706
+ echo '<li><code>%%parent_txn_id%%</code> = The PayPal® Transaction ID, associated with the original payment that is being refunded/reversed.</li>' . "\n";
707
+ echo '<li><code>%%-amount%%</code> = The Negative Amount of the payment, that was refunded or reversed back to the Customer.</li>' . "\n";
708
+ echo '<li><code>%%-fee%%</code> = The Negative PayPal® fee, that was refunded back to you as the Merchant/Seller.</li>' . "\n";
709
+ echo '<li><code>%%first_name%%</code> = The First Name of the Customer who purchased access to a Specific Post/Page.</li>' . "\n";
710
+ echo '<li><code>%%last_name%%</code> = The Last Name of the Customer who purchased access to a Specific Post/Page.</li>' . "\n";
711
+ echo '<li><code>%%full_name%%</code> = The Full Name ( First &amp; Last ) of the Customer who purchased access to a Specific Post/Page.</li>' . "\n";
712
+ echo '<li><code>%%payer_email%%</code> = The Email Address of the Customer who purchased access to a Specific Post/Page.</li>' . "\n";
713
+ echo '<li><code>%%item_number%%</code> = The Item Number. Ex: <code><em>sp:13,24,36:72</em></code> ( translates to: <code><em>sp:comma-delimited IDs:expiration hours</em></code> ).</li>' . "\n";
714
+ echo '<li><code>%%item_name%%</code> = The Item Name ( as provided by the <code>desc=""</code> attribute in your Shortcode, which briefly describes the Item Number ).</li>' . "\n";
715
+ echo '</ul>' . "\n";
716
+ /**/
717
+ if (!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ())
718
+ {
719
+ echo '<strong>Custom Replacement Codes can also be inserted using these instructions:</strong>' . "\n";
720
+ echo '<ul>' . "\n";
721
+ echo '<li><code>%%cv0%%</code> = The domain of your site, which is passed through the `custom` attribute in your Shortcode.</li>' . "\n";
722
+ echo '<li><code>%%cv1%%</code> = If you need to track additional custom variables, you can pipe delimit them into the `custom` attribute, inside your Shortcode, like this: <code>custom="' . esc_html ($_SERVER["HTTP_HOST"]) . '|cv1|cv2|cv3"</code>. You can have an unlimited number of custom variables that track IP addresses, affiliate IDs, etc. In some cases you may need to use PHP code to insert a value into the custom field dynamically. Obviously this is for advanced webmasters, but the functionality has been made available for those who need it.</li>' . "\n";
723
+ echo '</ul>' . "\n";
724
+ echo '<strong>This example uses cv1 to track a User\'s IP address:</strong><br />' . "\n";
725
+ echo '<em>( The IP address could be referenced using <code>%%cv1%%</code> )</em><br />' . "\n";
726
+ echo '<code>custom="' . esc_html ($_SERVER["HTTP_HOST"]) . '|&lt;?php echo $_SERVER["REMOTE_ADDR"]; ?&gt;"</code>' . "\n";
727
+ }
728
+ /**/
729
+ echo '</td>' . "\n";
730
+ /**/
731
+ echo '</tr>' . "\n";
732
+ echo '</tbody>' . "\n";
733
+ echo '</table>' . "\n";
734
+ /**/
735
+ echo '<div class="ws-menu-page-hr"></div>' . "\n";
736
+ /**/
737
+ echo '<table class="form-table" style="margin-top:0;">' . "\n";
738
+ echo '<tbody>' . "\n";
739
+ echo '<tr>' . "\n";
740
+ /**/
741
+ echo '<th style="padding-top:0;">' . "\n";
742
+ echo '<label for="ws-plugin--s2member-sp-ref-rev-notification-recipients">' . "\n";
743
  echo 'Send An Email Transaction Log Of This Event?' . "\n";
744
  echo '</label>' . "\n";
745
  echo '</th>' . "\n";
748
  echo '<tr>' . "\n";
749
  /**/
750
  echo '<td>' . "\n";
751
+ echo '<input type="text" name="ws_plugin__s2member_sp_ref_rev_notification_recipients" id="ws-plugin--s2member-sp-ref-rev-notification-recipients" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_recipients"]) . '" /><br />' . "\n";
752
  echo 'This is a semicolon ( ; ) delimited list of Recipients. Here is an example:<br />' . "\n";
753
  echo '<code>"John" &lt;john@example.com&gt;; admin@example.com; "Webmaster" &lt;webmaster@example.com&gt;</code>' . "\n";
754
  echo '</td>' . "\n";
760
  /**/
761
  echo '</div>' . "\n";
762
  /**/
763
+ do_action ("ws_plugin__s2member_during_api_ops_page_during_left_sections_after_sp_refund_reversal_notifications", get_defined_vars ());
764
  }
765
  /**/
766
  do_action ("ws_plugin__s2member_during_api_ops_page_after_left_sections", get_defined_vars ());
includes/menu-pages/code-samples/custom-queries-loop.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ detach_s2member_query_filters();
3
+ query_posts("posts_per_page=5");
4
+
5
+ if (have_posts()):
6
+ while (have_posts()):
7
+ the_post();
8
+
9
+ if(!is_permitted_by_s2member())
10
+ continue;
11
+ /* Skip it. The current User/Member has NO access. */
12
+
13
+ endwhile;
14
+ endif;
15
+
16
+ wp_reset_query();
17
+ ?>
includes/menu-pages/code-samples/custom-queries.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ attach_s2member_query_filters();
3
+ query_posts("posts_per_page=5");
4
+
5
+ if (have_posts()):
6
+ while (have_posts()):
7
+ the_post();
8
+ /*
9
+ Protected content will be excluded automatically.
10
+ ( based on the current User/Member status )
11
+ */
12
+ endwhile;
13
+ endif;
14
+
15
+ wp_reset_query();
16
+ detach_s2member_query_filters();
17
+ ?>
includes/menu-pages/code-samples/query-conditional-examples.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Is a specific [Category, Tag, Post, Page, or URI] protected by s2Member?
2
+ <?php is_protected_by_s2member ($__id, $__type, $check_user); ?>
3
+ ( * This ignores the current User/Member status.
4
+ Just "is it protected" by s2Member at all? )
5
+
6
+ If true, returns a non-empty array containing one of these elements.
7
+ ["s2member_level_req"] = Level required for access.
8
+ ["s2member_ccap_req"] = Custom Capability required.
9
+ ["s2member_sp_req"] = "Specific Post/Page ID" required.
10
+ Otherwise returns false.
11
+
12
+ $__id - optional argument. Defaults to current $post->ID in The Loop.
13
+ $__type - optional argument. One of: `category`, `tag`, `post`, `page`, `singular`, `uri`. Defaults to: `singular`.
14
+ $check_user - optional ( consider the current User? ) defaults to: false.
15
+
16
+ -----------------------------------------------------------------------------
17
+
18
+ Is the current User permitted to access this [Category, Tag, Post, Page, or URI]?
19
+ <?php is_permitted_by_s2member ($__id, $__type); ?>
20
+
21
+ Returns true or false.
22
+
23
+ Similar to:
24
+ <?php is_protected_by_s2member ($__id, $__type, $check_user = TRUE); ?>
25
+ - BUT `is_permitted_by_s2member()` does NOT return an array.
26
+
27
+ $__id - optional argument. Defaults to current $post->ID in The Loop.
28
+ $__type - optional argument. One of: `category`, `tag`, `post`, `page`, `singular`, `uri`. Defaults to: `singular`.
29
+
30
+ -----------------------------------------------------------------------------
31
+
32
+ Further details and additional functions can be found inside:
33
+ /s2member/includes/functions/api-functions.inc.php
includes/menu-pages/code-samples/specific-category-restrictions.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ($categories = get_categories ())
3
+ {
4
+ foreach ($categories as $category)
5
+ {
6
+ if (!is_permitted_by_s2member ($category->cat_ID, "category"))
7
+ continue;
8
+ /* Skip it. The current User/Member CANNOT access this Category,
9
+ or any Posts inside this Category, or any of its sub-Categories. */
10
+ }
11
+ }
12
+ ?>
includes/menu-pages/code-samples/specific-page-restrictions.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ($pages = get_pages ())
3
+ {
4
+ foreach ($pages as $page)
5
+ {
6
+ if (!is_permitted_by_s2member ($page->ID, "page"))
7
+ continue;
8
+ /* Skip it. The current User/Member
9
+ CANNOT access this particular Page. */
10
+ }
11
+ }
12
+ ?>
includes/menu-pages/code-samples/specific-post-restrictions.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ($posts = get_posts ())
3
+ {
4
+ foreach ($posts as $post)
5
+ {
6
+ if (!is_permitted_by_s2member ($post->ID, "post"))
7
+ continue;
8
+ /* Skip it. The current User/Member
9
+ CANNOT access this particular Post. */
10
+
11
+ $post_or_page_id = $post->ID;
12
+ if (!is_permitted_by_s2member ($post_or_page_id, "singular"))
13
+ continue;
14
+ /* The "singular" attribute can check both Pages and Posts the same time.
15
+ So if this was actually a "Page", that would be valid, w/ "singular". */
16
+ }
17
+ }
18
+ ?>
includes/menu-pages/code-samples/specific-tag-restrictions.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ($tags = get_the_tags ())
3
+ {
4
+ foreach ($tags as $tag)
5
+ {
6
+ if (!is_permitted_by_s2member ($tag->name, "tag"))
7
+ continue;
8
+ /* Skip it. The current User/Member
9
+ CANNOT access this Tag Archive,
10
+ or any Posts/Pages with this Tag. */
11
+ }
12
+ }
13
+ ?>
includes/menu-pages/menu-pages-s-min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(b){var a=esc_html=function(c){return String(c).replace(/"/g,"&quot;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;")};if(location.href.match(/page\=ws-plugin--s2member-mms-options/)){b("select#ws-plugin--s2member-mms-registration-file").change(function(){if(b(this).val()==="wp-signup"){b("div#ws-plugin--s2member-mms-registration-support-package-details-wrapper").show(),b("div.ws-plugin--s2member-mms-registration-wp-login, table.ws-plugin--s2member-mms-registration-wp-login").hide(),b("div.ws-plugin--s2member-mms-registration-wp-signup, table.ws-plugin--s2member-mms-registration-wp-signup").show()}else{if(b(this).val()==="wp-login"){b("div#ws-plugin--s2member-mms-registration-support-package-details-wrapper").hide(),b("div.ws-plugin--s2member-mms-registration-wp-login, table.ws-plugin--s2member-mms-registration-wp-login").show(),b("div.ws-plugin--s2member-mms-registration-wp-signup, table.ws-plugin--s2member-mms-registration-wp-signup").hide()}}b("div.ws-plugin--s2member-mms-registration-wp-signup-blogs-level0, table.ws-plugin--s2member-mms-registration-wp-signup-blogs-level0")[((b("select#ws-plugin--s2member-mms-registration-grants").val()==="all")?"show":"hide")](),b("input#ws-plugin--s2member-mms-registration-blogs-level0").val(((b("select#ws-plugin--s2member-mms-registration-grants").val()==="all")?"1":"0"))}).trigger("change");b("select#ws-plugin--s2member-mms-registration-grants").change(function(){b("select#ws-plugin--s2member-mms-registration-file").trigger("change")})}else{if(location.href.match(/page\=ws-plugin--s2member-options/)){ws_plugin__s2member_generateSecurityKey=function(){var f=function(h,g){h=(arguments.length<1)?0:h;g=(arguments.length<2)?2147483647:g;return Math.floor(Math.random()*(g-h+1))+h};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()";for(var d=0,c="";d<56;d++){c+=e.substr(f(0,e.length-1),1)}b("input#ws-plugin--s2member-sec-encryption-key").val(c);return false};ws_plugin__s2member_enableSecurityKey=function(){if(confirm("Edit Key? Are you sure?\nThis could break your installation!\n\n*Note* If you've been testing s2Member, feel free to change this Key before you go live. Just don't go live, and then change it. You'll have some very unhappy Customers. Data corruption WILL occur!\n\nFor your safety, s2Member keeps a history of the last 10 Keys that you've used. If you get yourself into a real situation, s2Member will let you revert back to a previous Key.")){b("input#ws-plugin--s2member-sec-encryption-key").attr("disabled",false)}return false};ws_plugin__s2member_securityKeyHistory=function(){b("div#ws-plugin--s2member-sec-encryption-key-history").toggle();return false}}else{if(location.href.match(/page\=ws-plugin--s2member-paypal-ops/)){b("select#ws-plugin--s2member-auto-eot-system-enabled").change(function(){var d=b(this),e=d.val();var c=b("p#ws-plugin--s2member-auto-eot-system-enabled-via-cron");if(e==2){c.show()}else{c.hide()}})}else{if(location.href.match(/page\=ws-plugin--s2member-els-ops/)){b("select#ws-plugin--s2member-custom-reg-opt-in").change(function(){var e=b(this),f=e.val();var d=b("tr.ws-plugin--s2member-custom-reg-opt-in-label-row");var c=b("img.ws-plugin--s2member-custom-reg-opt-in-label-prev-img");if(f<=0){d.css("display","none"),c.attr("src",c.attr("src").replace(/\/checked\.png$/,"/unchecked.png"))}else{if(f==1){d.css("display",""),c.attr("src",c.attr("src").replace(/\/unchecked\.png$/,"/checked.png"))}else{if(f==2){d.css("display",""),c.attr("src",c.attr("src").replace(/\/checked\.png$/,"/unchecked.png"))}}}})}else{if(location.href.match(/page\=ws-plugin--s2member-paypal-buttons/)){b("select#ws-plugin--s2member-level1-term, select#ws-plugin--s2member-level2-term, select#ws-plugin--s2member-level3-term, select#ws-plugin--s2member-level4-term, select#ws-plugin--s2member-modification-term").change(function(){var d=this.id.replace(/^ws-plugin--s2member-(.+?)-term$/g,"$1");var c=(b(this).val().split("-")[2].replace(/[^0-1BN]/g,"")==="BN")?1:0;b("p#ws-plugin--s2member-"+d+"-trial-line").css("display",(c?"none":""));b("span#ws-plugin--s2member-"+d+"-trial-then").css("display",(c?"none":""));b("span#ws-plugin--s2member-"+d+"-20p-rule").css("display",(c?"none":""));(c)?b("input#ws-plugin--s2member-"+form+"-trial-period").val(0):null});b("input#ws-plugin--s2member-level1-ccaps, input#ws-plugin--s2member-level2-ccaps, input#ws-plugin--s2member-level3-ccaps, input#ws-plugin--s2member-level4-ccaps, input#ws-plugin--s2member-modification-ccaps").keyup(function(){if(this.value.match(/[^a-z_0-9,]/)){this.value=b.trim(b.trim(this.value).replace(/[ \-]/g,"_").replace(/[^A-Z_0-9,]/gi,"").toLowerCase())}});ws_plugin__s2member_paypalButtonGenerate=function(f){var c='[s2Member-PayPal-Button %%attrs%% image="default" /]',q="",t={};t.level0='<?php echo ws_plugin__s2member_esc_sq ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_label"]); ?>';t.level1='<?php echo ws_plugin__s2member_esc_sq ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_label"]); ?>';t.level2='<?php echo ws_plugin__s2member_esc_sq ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_label"]); ?>';t.level3='<?php echo ws_plugin__s2member_esc_sq ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_label"]); ?>';t.level4='<?php echo ws_plugin__s2member_esc_sq ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_label"]); ?>';var o=b("input#ws-plugin--s2member-"+f+"-shortcode");var g=b("textarea#ws-plugin--s2member-"+f+"-button");var k=b("select#ws-plugin--s2member-modification-level");var h=(f==="modification")?k.val().split(":",2)[1]:f.replace(/^level/,"");var l=t["level"+h].replace(/"/g,"");var d=b("input#ws-plugin--s2member-"+f+"-trial-period").val().replace(/[^0-9]/g,"");var j=b("select#ws-plugin--s2member-"+f+"-trial-term").val().replace(/[^A-Z]/g,"");var m=b("input#ws-plugin--s2member-"+f+"-amount").val().replace(/[^0-9\.]/g,"");var s=b("select#ws-plugin--s2member-"+f+"-term").val().split("-")[0].replace(/[^0-9]/g,"");var u=b("select#ws-plugin--s2member-"+f+"-term").val().split("-")[1].replace(/[^A-Z]/g,"");var r=b("select#ws-plugin--s2member-"+f+"-term").val().split("-")[2].replace(/[^0-1BN]/g,"");var e=b.trim(b("input#ws-plugin--s2member-"+f+"-page-style").val().replace(/"/g,""));var i=b("select#ws-plugin--s2member-"+f+"-currency").val().replace(/[^A-Z]/g,"");var n=b.trim(b.trim(b("input#ws-plugin--s2member-"+f+"-ccaps").val()).replace(/[ \-]/g,"_").replace(/[^A-Z_0-9,]/gi,"").toLowerCase());d=(r==="BN")?"0":d;var p=(r==="BN"&&u!=="L")?h+":"+n+":"+s+" "+u:h+":"+n;p=p.replace(/\:+$/g,"");if(j==="D"&&d>7){alert("Oops, a slight problem:\n\nMaximum Free Days is: 7.\nIf you want to offer more than 7 days free, please choose Weeks or Months from the drop-down.");return false}else{if(j==="W"&&d>52){alert("Oops, a slight problem:\n\nMaximum Free Weeks is: 52.\nIf you want to offer more than 52 weeks free, please choose Months from the drop-down.");return false}else{if(j==="M"&&d>12){alert("Oops, a slight problem:\n\nMaximum Free Months is: 12.\nIf you want to offer more than 12 months free, please choose Years from the drop-down.");return false}else{if(j==="Y"&&d>1){alert("Oops, a slight problem:\n\nMax Trial Period Years is: 1. *This is a PayPal® limitation.");return false}else{if(!m||isNaN(m)||m<0.01){alert("Oops, a slight problem:\n\nAmount must be >= 0.01");return false}else{if(m>10000){alert("Oops, a slight problem:\n\nMaximum amount is: 10000.00");return false}}}}}}g.val(g.val().replace(/ \<\!--(\<input type\="hidden" name\="(amount|src|sra|a1|p1|t1|a3|p3|t3)" value\="(.*?)" \/\>)--\>/g," $1"));(parseInt(d)<=0)?g.val(g.val().replace(/ (\<input type\="hidden" name\="(a1|p1|t1)" value\="(.*?)" \/\>)/g," <!--$1-->")):null;(r==="BN")?g.val(g.val().replace(/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/g," $1_xclick$3")):null;(r==="BN")?g.val(g.val().replace(/ (\<input type\="hidden" name\="(src|sra|a1|p1|t1|a3|p3|t3)" value\="(.*?)" \/\>)/g," <!--$1-->")):null;(r!=="BN")?g.val(g.val().replace(/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/g," $1_xclick-subscriptions$3")):null;(r!=="BN")?g.val(g.val().replace(/ (\<input type\="hidden" name\="amount" value\="(.*?)" \/\>)/g," <!--$1-->")):null;q+='level="'+a(h)+'" ccaps="'+a(n)+'" desc="'+a(l)+'" ps="'+a(e)+'" cc="'+a(i)+'" custom="<?php echo esc_attr ($_SERVER["HTTP_HOST"]); ?>"';q+=' tp="'+a(d)+'" tt="'+a(j)+'" ra="'+a(m)+'" rp="'+a(s)+'" rt="'+a(u)+'" rr="'+a(r)+'"';q+=(f==="modification")?' modify="1"':"";o.val(c.replace(/%%attrs%%/,q));g.val(g.val().replace(/ name\="item_name" value\="(.*?)"/,' name="item_name" value="'+a(l)+'"'));g.val(g.val().replace(/ name\="item_number" value\="(.*?)"/,' name="item_number" value="'+a(p)+'"'));g.val(g.val().replace(/ name\="page_style" value\="(.*?)"/,' name="page_style" value="'+a(e)+'"'));g.val(g.val().replace(/ name\="currency_code" value\="(.*?)"/,' name="currency_code" value="'+a(i)+'"'));g.val(g.val().replace(/ name\="custom" value\="(.*?)"/,' name="custom" value="<?php echo esc_attr ($_SERVER["HTTP_HOST"]); ?>"'));g.val(g.val().replace(/ name\="modify" value\="(.*?)"/,' name="modify" value="'+((f==="modification")?"1":"0")+'"'));g.val(g.val().replace(/ name\="amount" value\="(.*?)"/,' name="amount" value="'+a(m)+'"'));g.val(g.val().replace(/ name\="src" value\="(.*?)"/,' name="src" value="'+a(r)+'"'));g.val(g.val().replace(/ name\="p1" value\="(.*?)"/,' name="p1" value="'+a(d)+'"'));g.val(g.val().replace(/ name\="t1" value\="(.*?)"/,' name="t1" value="'+a(j)+'"'));g.val(g.val().replace(/ name\="a3" value\="(.*?)"/,' name="a3" value="'+a(m)+'"'));g.val(g.val().replace(/ name\="p3" value\="(.*?)"/,' name="p3" value="'+a(s)+'"'));g.val(g.val().replace(/ name\="t3" value\="(.*?)"/,' name="t3" value="'+a(u)+'"'));b("div#ws-plugin--s2member-"+f+"-button-prev").html(g.val().replace(/\<form/,'<form target="_blank"').replace(/\<\?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_(ON0|OS0); \?\>/g,""));(f==="modification")?alert("Your Modification Button has been generated.\nPlease copy/paste the Shortcode Format into your Login Welcome Page, or wherever you feel it would be most appropriate."):alert("Your Button has been generated.\nPlease copy/paste the Shortcode Format into your Membership Options Page.");o.each(function(){this.focus(),this.select()});return false};ws_plugin__s2member_paypalSpButtonGenerate=function(){var q='[s2Member-PayPal-Button %%attrs%% image="default" /]',p="";var n=b("input#ws-plugin--s2member-sp-shortcode");var e=b("textarea#ws-plugin--s2member-sp-button");var f=b("select#ws-plugin--s2member-sp-leading-id").val().replace(/[^0-9]/g,"");var h=b("select#ws-plugin--s2member-sp-additional-ids").val()||[];var o=b("select#ws-plugin--s2member-sp-hours").val().replace(/[^0-9]/g,"");var k=b("input#ws-plugin--s2member-sp-amount").val().replace(/[^0-9\.]/g,"");var j=b.trim(b("input#ws-plugin--s2member-sp-desc").val().replace(/"/g,""));var m=b.trim(b("input#ws-plugin--s2member-sp-page-style").val().replace(/"/g,""));var d=b("select#ws-plugin--s2member-sp-currency").val().replace(/[^A-Z]/g,"");if(!f){alert("Oops, a slight problem:\n\nPlease select a Leading Post/Page.\n\n*Tip* If there are no Posts/Pages in the menu, it's because you've not configured s2Member for Specific Post/Page Access yet. See: s2Member -> General Options -> Specific Post/Page Access Restrictions.");return false}else{if(!k||isNaN(k)||k<0.01){alert("Oops, a slight problem:\n\nAmount must be >= 0.01");return false}else{if(k>10000){alert("Oops, a slight problem:\n\nMaximum amount is: 10000.00");return false}else{if(!j){alert("Oops, a slight problem:\n\nPlease type a Description for this Button.");return false}}}}for(var g=0,c=f;g<h.length;g++){if(h[g]&&h[g]!==f){c+=","+h[g]}}var l="sp:"+c+":"+o;p+='ids="'+a(c)+'" exp="'+a(o)+'" desc="'+a(j)+'" ps="'+a(m)+'" cc="'+a(d)+'"';p+=' custom="<?php echo esc_attr ($_SERVER["HTTP_HOST"]); ?>" ra="'+a(k)+'" sp="1"';n.val(q.replace(/%%attrs%%/,p));e.val(e.val().replace(/ name\="item_name" value\="(.*?)"/,' name="item_name" value="'+a(j)+'"'));e.val(e.val().replace(/ name\="item_number" value\="(.*?)"/,' name="item_number" value="'+a(l)+'"'));e.val(e.val().replace(/ name\="page_style" value\="(.*?)"/,' name="page_style" value="'+a(m)+'"'));e.val(e.val().replace(/ name\="currency_code" value\="(.*?)"/,' name="currency_code" value="'+a(d)+'"'));e.val(e.val().replace(/ name\="custom" value\="(.*?)"/,' name="custom" value="<?php echo esc_attr ($_SERVER["HTTP_HOST"]); ?>"'));e.val(e.val().replace(/ name\="amount" value\="(.*?)"/,' name="amount" value="'+a(k)+'"'));b("div#ws-plugin--s2member-sp-button-prev").html(e.val().replace(/\<form/,'<form target="_blank"'));alert("Your Button has been generated.\nPlease copy/paste the Shortcode Format into your Membership Options Page.");n.each(function(){this.focus(),this.select()});return false};ws_plugin__s2member_paypalSpLinkGenerate=function(){var j=b("select#ws-plugin--s2member-sp-link-leading-id").val().replace(/[^0-9]/g,"");var h=b("select#ws-plugin--s2member-sp-link-additional-ids").val()||[];var c=b("select#ws-plugin--s2member-sp-link-hours").val().replace(/[^0-9]/g,"");var d=b("p#ws-plugin--s2member-sp-link"),g=b("img#ws-plugin--s2member-sp-link-loading");if(!j){alert("Oops, a slight problem:\n\nPlease select a Leading Post/Page.\n\n*Tip* If there are no Posts/Pages in the menu, it's because you've not configured s2Member for Specific Post/Page Access yet. See: s2Member -> General Options -> Specific Post/Page Access Restrictions.");return false}for(var e=0,f=j;e<h.length;e++){if(h[e]&&h[e]!==j){f+=","+h[e]}}d.hide(),g.show(),b.post(ajaxurl,{action:"s2member_sp_access_link",s2member_sp_access_link:'<?php echo ws_plugin__s2member_esc_sq (wp_create_nonce ("ws-plugin--s2member-sp-access-link")); ?>',s2member_sp_access_link_ids:f,s2member_sp_access_link_hours:c},function(i){d.show().html('<a href="'+a(i)+'" target="_blank" rel="external">'+esc_html(i)+"</a>"),g.hide()});return false}}}}}}});
1
+ jQuery(document).ready(function(b){var a=esc_html=function(c){return String(c).replace(/"/g,"&quot;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;")};if(location.href.match(/page\=ws-plugin--s2member-mms-options/)){b("select#ws-plugin--s2member-mms-registration-file").change(function(){if(b(this).val()==="wp-signup"){b("div#ws-plugin--s2member-mms-registration-support-package-details-wrapper").show(),b("div.ws-plugin--s2member-mms-registration-wp-login, table.ws-plugin--s2member-mms-registration-wp-login").hide(),b("div.ws-plugin--s2member-mms-registration-wp-signup, table.ws-plugin--s2member-mms-registration-wp-signup").show()}else{if(b(this).val()==="wp-login"){b("div#ws-plugin--s2member-mms-registration-support-package-details-wrapper").hide(),b("div.ws-plugin--s2member-mms-registration-wp-login, table.ws-plugin--s2member-mms-registration-wp-login").show(),b("div.ws-plugin--s2member-mms-registration-wp-signup, table.ws-plugin--s2member-mms-registration-wp-signup").hide()}}b("div.ws-plugin--s2member-mms-registration-wp-signup-blogs-level0, table.ws-plugin--s2member-mms-registration-wp-signup-blogs-level0")[((b("select#ws-plugin--s2member-mms-registration-grants").val()==="all")?"show":"hide")](),b("input#ws-plugin--s2member-mms-registration-blogs-level0").val(((b("select#ws-plugin--s2member-mms-registration-grants").val()==="all")?"1":"0"))}).trigger("change");b("select#ws-plugin--s2member-mms-registration-grants").change(function(){b("select#ws-plugin--s2member-mms-registration-file").trigger("change")})}else{if(location.href.match(/page\=ws-plugin--s2member-options/)){ws_plugin__s2member_generateSecurityKey=function(){var f=function(h,g){h=(arguments.length<1)?0:h;g=(arguments.length<2)?2147483647:g;return Math.floor(Math.random()*(g-h+1))+h};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()";for(var d=0,c="";d<56;d++){c+=e.substr(f(0,e.length-1),1)}b("input#ws-plugin--s2member-sec-encryption-key").val(c);return false};ws_plugin__s2member_enableSecurityKey=function(){if(confirm("Edit Key? Are you sure?\nThis could break your installation!\n\n*Note* If you've been testing s2Member, feel free to change this Key before you go live. Just don't go live, and then change it. You'll have some very unhappy Customers. Data corruption WILL occur!\n\nFor your safety, s2Member keeps a history of the last 10 Keys that you've used. If you get yourself into a real situation, s2Member will let you revert back to a previous Key.")){b("input#ws-plugin--s2member-sec-encryption-key").attr("disabled",false)}return false};ws_plugin__s2member_securityKeyHistory=function(){b("div#ws-plugin--s2member-sec-encryption-key-history").toggle();return false}}else{if(location.href.match(/page\=ws-plugin--s2member-paypal-ops/)){b("select#ws-plugin--s2member-auto-eot-system-enabled").change(function(){var d=b(this),e=d.val();var c=b("p#ws-plugin--s2member-auto-eot-system-enabled-via-cron");if(e==2){c.show()}else{c.hide()}})}else{if(location.href.match(/page\=ws-plugin--s2member-els-ops/)){b("select#ws-plugin--s2member-custom-reg-opt-in").change(function(){var e=b(this),f=e.val();var d=b("tr.ws-plugin--s2member-custom-reg-opt-in-label-row");var c=b("img.ws-plugin--s2member-custom-reg-opt-in-label-prev-img");if(f<=0){d.css("display","none"),c.attr("src",c.attr("src").replace(/\/checked\.png$/,"/unchecked.png"))}else{if(f==1){d.css("display",""),c.attr("src",c.attr("src").replace(/\/unchecked\.png$/,"/checked.png"))}else{if(f==2){d.css("display",""),c.attr("src",c.attr("src").replace(/\/checked\.png$/,"/unchecked.png"))}}}})}else{if(location.href.match(/page\=ws-plugin--s2member-paypal-buttons/)){b("select#ws-plugin--s2member-level1-term, select#ws-plugin--s2member-level2-term, select#ws-plugin--s2member-level3-term, select#ws-plugin--s2member-level4-term, select#ws-plugin--s2member-modification-term").change(function(){var d=this.id.replace(/^ws-plugin--s2member-(.+?)-term$/g,"$1");var c=(b(this).val().split("-")[2].replace(/[^0-1BN]/g,"")==="BN")?1:0;b("p#ws-plugin--s2member-"+d+"-trial-line").css("display",(c?"none":""));b("span#ws-plugin--s2member-"+d+"-trial-then").css("display",(c?"none":""));b("span#ws-plugin--s2member-"+d+"-20p-rule").css("display",(c?"none":""));(c)?b("input#ws-plugin--s2member-"+form+"-trial-period").val(0):null});b("input#ws-plugin--s2member-level1-ccaps, input#ws-plugin--s2member-level2-ccaps, input#ws-plugin--s2member-level3-ccaps, input#ws-plugin--s2member-level4-ccaps, input#ws-plugin--s2member-modification-ccaps").keyup(function(){if(this.value.match(/[^a-z_0-9,]/)){this.value=b.trim(b.trim(this.value).replace(/[ \-]/g,"_").replace(/[^A-Z_0-9,]/gi,"").toLowerCase())}});ws_plugin__s2member_paypalButtonGenerate=function(f){var c='[s2Member-PayPal-Button %%attrs%% image="default" /]',q="",t={};t.level0='<?php echo ws_plugin__s2member_esc_sq ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_label"]); ?>';t.level1='<?php echo ws_plugin__s2member_esc_sq ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_label"]); ?>';t.level2='<?php echo ws_plugin__s2member_esc_sq ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_label"]); ?>';t.level3='<?php echo ws_plugin__s2member_esc_sq ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_label"]); ?>';t.level4='<?php echo ws_plugin__s2member_esc_sq ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_label"]); ?>';var o=b("input#ws-plugin--s2member-"+f+"-shortcode");var g=b("textarea#ws-plugin--s2member-"+f+"-button");var k=b("select#ws-plugin--s2member-modification-level");var h=(f==="modification")?k.val().split(":",2)[1]:f.replace(/^level/,"");var l=t["level"+h].replace(/"/g,"");var d=b("input#ws-plugin--s2member-"+f+"-trial-period").val().replace(/[^0-9]/g,"");var j=b("select#ws-plugin--s2member-"+f+"-trial-term").val().replace(/[^A-Z]/g,"");var m=b("input#ws-plugin--s2member-"+f+"-amount").val().replace(/[^0-9\.]/g,"");var s=b("select#ws-plugin--s2member-"+f+"-term").val().split("-")[0].replace(/[^0-9]/g,"");var u=b("select#ws-plugin--s2member-"+f+"-term").val().split("-")[1].replace(/[^A-Z]/g,"");var r=b("select#ws-plugin--s2member-"+f+"-term").val().split("-")[2].replace(/[^0-1BN]/g,"");var e=b.trim(b("input#ws-plugin--s2member-"+f+"-page-style").val().replace(/"/g,""));var i=b("select#ws-plugin--s2member-"+f+"-currency").val().replace(/[^A-Z]/g,"");var n=b.trim(b.trim(b("input#ws-plugin--s2member-"+f+"-ccaps").val()).replace(/[ \-]/g,"_").replace(/[^A-Z_0-9,]/gi,"").toLowerCase());d=(r==="BN")?"0":d;var p=(r==="BN"&&u!=="L")?h+":"+n+":"+s+" "+u:h+":"+n;p=p.replace(/\:+$/g,"");if(j==="D"&&d>7){alert("Oops, a slight problem:\n\nMaximum Free Days is: 7.\nIf you want to offer more than 7 days free, please choose Weeks or Months from the drop-down.");return false}else{if(j==="W"&&d>52){alert("Oops, a slight problem:\n\nMaximum Free Weeks is: 52.\nIf you want to offer more than 52 weeks free, please choose Months from the drop-down.");return false}else{if(j==="M"&&d>12){alert("Oops, a slight problem:\n\nMaximum Free Months is: 12.\nIf you want to offer more than 12 months free, please choose Years from the drop-down.");return false}else{if(j==="Y"&&d>1){alert("Oops, a slight problem:\n\nMax Trial Period Years is: 1. *This is a PayPal® limitation.");return false}else{if(!m||isNaN(m)||m<0.01){alert("Oops, a slight problem:\n\nAmount must be >= 0.01");return false}else{if(m>10000){alert("Oops, a slight problem:\n\nMaximum amount is: 10000.00");return false}}}}}}g.val(g.val().replace(/ \<\!--(\<input type\="hidden" name\="(amount|src|sra|a1|p1|t1|a3|p3|t3)" value\="(.*?)" \/\>)--\>/g," $1"));(parseInt(d)<=0)?g.val(g.val().replace(/ (\<input type\="hidden" name\="(a1|p1|t1)" value\="(.*?)" \/\>)/g," <!--$1-->")):null;(r==="BN")?g.val(g.val().replace(/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/g," $1_xclick$3")):null;(r==="BN")?g.val(g.val().replace(/ (\<input type\="hidden" name\="(src|sra|a1|p1|t1|a3|p3|t3)" value\="(.*?)" \/\>)/g," <!--$1-->")):null;(r!=="BN")?g.val(g.val().replace(/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/g," $1_xclick-subscriptions$3")):null;(r!=="BN")?g.val(g.val().replace(/ (\<input type\="hidden" name\="amount" value\="(.*?)" \/\>)/g," <!--$1-->")):null;q+='level="'+a(h)+'" ccaps="'+a(n)+'" desc="'+a(l)+'" ps="'+a(e)+'" cc="'+a(i)+'" ns="1" custom="<?php echo esc_attr ($_SERVER["HTTP_HOST"]); ?>"';q+=' tp="'+a(d)+'" tt="'+a(j)+'" ra="'+a(m)+'" rp="'+a(s)+'" rt="'+a(u)+'" rr="'+a(r)+'"';q+=(f==="modification")?' modify="1"':"";o.val(c.replace(/%%attrs%%/,q));g.val(g.val().replace(/ name\="item_name" value\="(.*?)"/,' name="item_name" value="'+a(l)+'"'));g.val(g.val().replace(/ name\="item_number" value\="(.*?)"/,' name="item_number" value="'+a(p)+'"'));g.val(g.val().replace(/ name\="page_style" value\="(.*?)"/,' name="page_style" value="'+a(e)+'"'));g.val(g.val().replace(/ name\="currency_code" value\="(.*?)"/,' name="currency_code" value="'+a(i)+'"'));g.val(g.val().replace(/ name\="custom" value\="(.*?)"/,' name="custom" value="<?php echo esc_attr ($_SERVER["HTTP_HOST"]); ?>"'));g.val(g.val().replace(/ name\="modify" value\="(.*?)"/,' name="modify" value="'+((f==="modification")?"1":"0")+'"'));g.val(g.val().replace(/ name\="amount" value\="(.*?)"/,' name="amount" value="'+a(m)+'"'));g.val(g.val().replace(/ name\="src" value\="(.*?)"/,' name="src" value="'+a(r)+'"'));g.val(g.val().replace(/ name\="p1" value\="(.*?)"/,' name="p1" value="'+a(d)+'"'));g.val(g.val().replace(/ name\="t1" value\="(.*?)"/,' name="t1" value="'+a(j)+'"'));g.val(g.val().replace(/ name\="a3" value\="(.*?)"/,' name="a3" value="'+a(m)+'"'));g.val(g.val().replace(/ name\="p3" value\="(.*?)"/,' name="p3" value="'+a(s)+'"'));g.val(g.val().replace(/ name\="t3" value\="(.*?)"/,' name="t3" value="'+a(u)+'"'));b("div#ws-plugin--s2member-"+f+"-button-prev").html(g.val().replace(/\<form/,'<form target="_blank"').replace(/\<\?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_(ON0|OS0); \?\>/g,""));(f==="modification")?alert("Your Modification Button has been generated.\nPlease copy/paste the Shortcode Format into your Login Welcome Page, or wherever you feel it would be most appropriate."):alert("Your Button has been generated.\nPlease copy/paste the Shortcode Format into your Membership Options Page.");o.each(function(){this.focus(),this.select()});return false};ws_plugin__s2member_paypalSpButtonGenerate=function(){var q='[s2Member-PayPal-Button %%attrs%% image="default" /]',p="";var n=b("input#ws-plugin--s2member-sp-shortcode");var e=b("textarea#ws-plugin--s2member-sp-button");var f=b("select#ws-plugin--s2member-sp-leading-id").val().replace(/[^0-9]/g,"");var h=b("select#ws-plugin--s2member-sp-additional-ids").val()||[];var o=b("select#ws-plugin--s2member-sp-hours").val().replace(/[^0-9]/g,"");var k=b("input#ws-plugin--s2member-sp-amount").val().replace(/[^0-9\.]/g,"");var j=b.trim(b("input#ws-plugin--s2member-sp-desc").val().replace(/"/g,""));var m=b.trim(b("input#ws-plugin--s2member-sp-page-style").val().replace(/"/g,""));var d=b("select#ws-plugin--s2member-sp-currency").val().replace(/[^A-Z]/g,"");if(!f){alert("Oops, a slight problem:\n\nPlease select a Leading Post/Page.\n\n*Tip* If there are no Posts/Pages in the menu, it's because you've not configured s2Member for Specific Post/Page Access yet. See: s2Member -> General Options -> Specific Post/Page Access Restrictions.");return false}else{if(!k||isNaN(k)||k<0.01){alert("Oops, a slight problem:\n\nAmount must be >= 0.01");return false}else{if(k>10000){alert("Oops, a slight problem:\n\nMaximum amount is: 10000.00");return false}else{if(!j){alert("Oops, a slight problem:\n\nPlease type a Description for this Button.");return false}}}}for(var g=0,c=f;g<h.length;g++){if(h[g]&&h[g]!==f){c+=","+h[g]}}var l="sp:"+c+":"+o;p+='ids="'+a(c)+'" exp="'+a(o)+'" desc="'+a(j)+'" ps="'+a(m)+'" cc="'+a(d)+'" ns="1"';p+=' custom="<?php echo esc_attr ($_SERVER["HTTP_HOST"]); ?>" ra="'+a(k)+'" sp="1"';n.val(q.replace(/%%attrs%%/,p));e.val(e.val().replace(/ name\="item_name" value\="(.*?)"/,' name="item_name" value="'+a(j)+'"'));e.val(e.val().replace(/ name\="item_number" value\="(.*?)"/,' name="item_number" value="'+a(l)+'"'));e.val(e.val().replace(/ name\="page_style" value\="(.*?)"/,' name="page_style" value="'+a(m)+'"'));e.val(e.val().replace(/ name\="currency_code" value\="(.*?)"/,' name="currency_code" value="'+a(d)+'"'));e.val(e.val().replace(/ name\="custom" value\="(.*?)"/,' name="custom" value="<?php echo esc_attr ($_SERVER["HTTP_HOST"]); ?>"'));e.val(e.val().replace(/ name\="amount" value\="(.*?)"/,' name="amount" value="'+a(k)+'"'));b("div#ws-plugin--s2member-sp-button-prev").html(e.val().replace(/\<form/,'<form target="_blank"'));alert("Your Button has been generated.\nPlease copy/paste the Shortcode Format into your Membership Options Page.");n.each(function(){this.focus(),this.select()});return false};ws_plugin__s2member_paypalSpLinkGenerate=function(){var j=b("select#ws-plugin--s2member-sp-link-leading-id").val().replace(/[^0-9]/g,"");var h=b("select#ws-plugin--s2member-sp-link-additional-ids").val()||[];var c=b("select#ws-plugin--s2member-sp-link-hours").val().replace(/[^0-9]/g,"");var d=b("p#ws-plugin--s2member-sp-link"),g=b("img#ws-plugin--s2member-sp-link-loading");if(!j){alert("Oops, a slight problem:\n\nPlease select a Leading Post/Page.\n\n*Tip* If there are no Posts/Pages in the menu, it's because you've not configured s2Member for Specific Post/Page Access yet. See: s2Member -> General Options -> Specific Post/Page Access Restrictions.");return false}for(var e=0,f=j;e<h.length;e++){if(h[e]&&h[e]!==j){f+=","+h[e]}}d.hide(),g.show(),b.post(ajaxurl,{action:"s2member_sp_access_link",s2member_sp_access_link:'<?php echo ws_plugin__s2member_esc_sq (wp_create_nonce ("ws-plugin--s2member-sp-access-link")); ?>',s2member_sp_access_link_ids:f,s2member_sp_access_link_hours:c},function(i){d.show().html('<a href="'+a(i)+'" target="_blank" rel="external">'+esc_html(i)+"</a>"),g.hide()});return false}}}}}}});
includes/menu-pages/menu-pages-s.js CHANGED
@@ -30,7 +30,7 @@ jQuery (document).ready (function($)
30
  $ ('div#ws-plugin--s2member-mms-registration-support-package-details-wrapper').hide (), $ ('div.ws-plugin--s2member-mms-registration-wp-login, table.ws-plugin--s2member-mms-registration-wp-login').show (), $ ('div.ws-plugin--s2member-mms-registration-wp-signup, table.ws-plugin--s2member-mms-registration-wp-signup').hide ();
31
  }
32
  /**/
33
- $ ('div.ws-plugin--s2member-mms-registration-wp-signup-blogs-level0, table.ws-plugin--s2member-mms-registration-wp-signup-blogs-level0')[ ( ($ ('select#ws-plugin--s2member-mms-registration-grants').val () === 'all') ? 'show' : 'hide')] (), $ ('input#ws-plugin--s2member-mms-registration-blogs-level0').val ( ( ($ ('select#ws-plugin--s2member-mms-registration-grants').val () === 'all') ? '1' : '0'));
34
  /**/
35
  }).trigger ('change'); /* Fire on ready too. */
36
  /**/
@@ -194,7 +194,7 @@ jQuery (document).ready (function($)
194
  (regRecur !== 'BN') ? code.val (code.val ().replace (/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/g, " $1_xclick-subscriptions$3")) : null;
195
  (regRecur !== 'BN') ? code.val (code.val ().replace (/ (\<input type\="hidden" name\="amount" value\="(.*?)" \/\>)/g, " <!--$1-->")) : null;
196
  /**/
197
- shortCodeTemplateAttrs += 'level="' + esc_attr (level) + '" ccaps="' + esc_attr (cCaps) + '" desc="' + esc_attr (label) + '" ps="' + esc_attr (pageStyle) + '" cc="' + esc_attr (currencyCode) + '" custom="<?php echo esc_attr ($_SERVER["HTTP_HOST"]); ?>"';
198
  shortCodeTemplateAttrs += ' tp="' + esc_attr (trialPeriod) + '" tt="' + esc_attr (trialTerm) + '" ra="' + esc_attr (regAmount) + '" rp="' + esc_attr (regPeriod) + '" rt="' + esc_attr (regTerm) + '" rr="' + esc_attr (regRecur) + '"';
199
  shortCodeTemplateAttrs += (button === 'modification') ? ' modify="1"' : ''; /* For Modification Buttons. */
200
  shortCode.val (shortCodeTemplate.replace (/%%attrs%%/, shortCodeTemplateAttrs));
@@ -204,7 +204,7 @@ jQuery (document).ready (function($)
204
  code.val (code.val ().replace (/ name\="page_style" value\="(.*?)"/, ' name="page_style" value="' + esc_attr (pageStyle) + '"'));
205
  code.val (code.val ().replace (/ name\="currency_code" value\="(.*?)"/, ' name="currency_code" value="' + esc_attr (currencyCode) + '"'));
206
  code.val (code.val ().replace (/ name\="custom" value\="(.*?)"/, ' name="custom" value="<?php echo esc_attr ($_SERVER["HTTP_HOST"]); ?>"'));
207
- code.val (code.val ().replace (/ name\="modify" value\="(.*?)"/, ' name="modify" value="' + ( (button === 'modification') ? '1' : '0') + '"'));
208
  code.val (code.val ().replace (/ name\="amount" value\="(.*?)"/, ' name="amount" value="' + esc_attr (regAmount) + '"'));
209
  code.val (code.val ().replace (/ name\="src" value\="(.*?)"/, ' name="src" value="' + esc_attr (regRecur) + '"'));
210
  code.val (code.val ().replace (/ name\="p1" value\="(.*?)"/, ' name="p1" value="' + esc_attr (trialPeriod) + '"'));
@@ -267,7 +267,7 @@ jQuery (document).ready (function($)
267
  /**/
268
  var spIdsHours = 'sp:' + ids + ':' + hours; /* Combined sp:ids:expiration hours. */
269
  /**/
270
- shortCodeTemplateAttrs += 'ids="' + esc_attr (ids) + '" exp="' + esc_attr (hours) + '" desc="' + esc_attr (desc) + '" ps="' + esc_attr (pageStyle) + '" cc="' + esc_attr (currencyCode) + '"';
271
  shortCodeTemplateAttrs += ' custom="<?php echo esc_attr ($_SERVER["HTTP_HOST"]); ?>" ra="' + esc_attr (regAmount) + '" sp="1"';
272
  shortCode.val (shortCodeTemplate.replace (/%%attrs%%/, shortCodeTemplateAttrs));
273
  /**/
30
  $ ('div#ws-plugin--s2member-mms-registration-support-package-details-wrapper').hide (), $ ('div.ws-plugin--s2member-mms-registration-wp-login, table.ws-plugin--s2member-mms-registration-wp-login').show (), $ ('div.ws-plugin--s2member-mms-registration-wp-signup, table.ws-plugin--s2member-mms-registration-wp-signup').hide ();
31
  }
32
  /**/
33
+ $ ('div.ws-plugin--s2member-mms-registration-wp-signup-blogs-level0, table.ws-plugin--s2member-mms-registration-wp-signup-blogs-level0')[(($ ('select#ws-plugin--s2member-mms-registration-grants').val () === 'all') ? 'show' : 'hide')] (), $ ('input#ws-plugin--s2member-mms-registration-blogs-level0').val ((($ ('select#ws-plugin--s2member-mms-registration-grants').val () === 'all') ? '1' : '0'));
34
  /**/
35
  }).trigger ('change'); /* Fire on ready too. */
36
  /**/
194
  (regRecur !== 'BN') ? code.val (code.val ().replace (/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/g, " $1_xclick-subscriptions$3")) : null;
195
  (regRecur !== 'BN') ? code.val (code.val ().replace (/ (\<input type\="hidden" name\="amount" value\="(.*?)" \/\>)/g, " <!--$1-->")) : null;
196
  /**/
197
+ shortCodeTemplateAttrs += 'level="' + esc_attr (level) + '" ccaps="' + esc_attr (cCaps) + '" desc="' + esc_attr (label) + '" ps="' + esc_attr (pageStyle) + '" cc="' + esc_attr (currencyCode) + '" ns="1" custom="<?php echo esc_attr ($_SERVER["HTTP_HOST"]); ?>"';
198
  shortCodeTemplateAttrs += ' tp="' + esc_attr (trialPeriod) + '" tt="' + esc_attr (trialTerm) + '" ra="' + esc_attr (regAmount) + '" rp="' + esc_attr (regPeriod) + '" rt="' + esc_attr (regTerm) + '" rr="' + esc_attr (regRecur) + '"';
199
  shortCodeTemplateAttrs += (button === 'modification') ? ' modify="1"' : ''; /* For Modification Buttons. */
200
  shortCode.val (shortCodeTemplate.replace (/%%attrs%%/, shortCodeTemplateAttrs));
204
  code.val (code.val ().replace (/ name\="page_style" value\="(.*?)"/, ' name="page_style" value="' + esc_attr (pageStyle) + '"'));
205
  code.val (code.val ().replace (/ name\="currency_code" value\="(.*?)"/, ' name="currency_code" value="' + esc_attr (currencyCode) + '"'));
206
  code.val (code.val ().replace (/ name\="custom" value\="(.*?)"/, ' name="custom" value="<?php echo esc_attr ($_SERVER["HTTP_HOST"]); ?>"'));
207
+ code.val (code.val ().replace (/ name\="modify" value\="(.*?)"/, ' name="modify" value="' + ((button === 'modification') ? '1' : '0') + '"'));
208
  code.val (code.val ().replace (/ name\="amount" value\="(.*?)"/, ' name="amount" value="' + esc_attr (regAmount) + '"'));
209
  code.val (code.val ().replace (/ name\="src" value\="(.*?)"/, ' name="src" value="' + esc_attr (regRecur) + '"'));
210
  code.val (code.val ().replace (/ name\="p1" value\="(.*?)"/, ' name="p1" value="' + esc_attr (trialPeriod) + '"'));
267
  /**/
268
  var spIdsHours = 'sp:' + ids + ':' + hours; /* Combined sp:ids:expiration hours. */
269
  /**/
270
+ shortCodeTemplateAttrs += 'ids="' + esc_attr (ids) + '" exp="' + esc_attr (hours) + '" desc="' + esc_attr (desc) + '" ps="' + esc_attr (pageStyle) + '" cc="' + esc_attr (currencyCode) + '" ns="1"';
271
  shortCodeTemplateAttrs += ' custom="<?php echo esc_attr ($_SERVER["HTTP_HOST"]); ?>" ra="' + esc_attr (regAmount) + '" sp="1"';
272
  shortCode.val (shortCodeTemplate.replace (/%%attrs%%/, shortCodeTemplateAttrs));
273
  /**/
includes/menu-pages/options.inc.php CHANGED
@@ -53,7 +53,7 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
53
  /**/
54
  echo '<th>' . "\n";
55
  echo '<label for="ws-plugin--s2member-sec-encryption-key">' . "\n";
56
- echo 'Security Encryption Key:' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key"]) ? ' ( <a href="#" onclick="ws_plugin__s2member_enableSecurityKey();" title="( not recommended )">edit key</a> )' : ' ( <a href="#" onclick="ws_plugin__s2member_generateSecurityKey();" title="Insert an auto-generated Key. ( recommended )">auto-generate</a> )') . "\n";
57
  echo '</label>' . "\n";
58
  echo '</th>' . "\n";
59
  /**/
@@ -61,7 +61,7 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
61
  echo '<tr>' . "\n";
62
  /**/
63
  echo '<td>' . "\n";
64
- echo '<input type="text" name="ws_plugin__s2member_sec_encryption_key" id="ws-plugin--s2member-sec-encryption-key" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key"]) . '" maxlength="256" autocomplete="off"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key"]) ? ' disabled="disabled"' : '') . ' />' . "\n";
65
  echo (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key"]) ? '<br />This may contain letters, numbers, spaces; even punctuation. Up to 256 characters.<br /><em>Ex: <code>' . esc_html (strtoupper (ws_plugin__s2member_random_str_gen (56))) . '</code></em>' . "\n" : '';
66
  echo (count ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key_history"]) > 1) ? '<br /><a href="#" onclick="ws_plugin__s2member_securityKeyHistory();">Click here</a> for a history of your last 10 Encryption Keys.<div id="ws-plugin--s2member-sec-encryption-key-history" style="display:none;"><code>' . implode ('</code><br /><code>', $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key_history"]) . '</code></div>' . "\n" : '';
67
  echo '</td>' . "\n";
@@ -158,8 +158,8 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
158
  /**/
159
  echo '<td>' . "\n";
160
  echo '<select name="ws_plugin__s2member_allow_subscribers_in" id="ws-plugin--s2member-allow-subscribers-in">' . "\n";
161
- echo '<option value="0"' . ((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["allow_subscribers_in"]) ? ' selected="selected"' : '') . '>No ( do NOT allow Open Registration )</option>' . "\n";
162
- echo '<option value="1"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["allow_subscribers_in"]) ? ' selected="selected"' : '') . '>Yes ( allow Open Registration; Free Subscribers at Level #0 )</option>' . "\n";
163
  echo '</select><br />' . "\n";
164
  echo 'If you set this to <code>Yes</code>, you\'re unlocking <a href="' . add_query_arg ("action", "register", wp_login_url ()) . '" target="_blank" rel="external">wp-login.php?action=register</a>. When a visitor registers without paying, they\'ll automatically become a Free Subscriber, at Level #0. The s2Member software reserves Level #0; to be used ONLY for Free Subscribers. All other Membership Levels [1-4] require payment.' . "\n";
165
  echo '</td>' . "\n";
@@ -353,10 +353,10 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
353
  /**/
354
  echo '<td>' . "\n";
355
  echo '<select name="ws_plugin__s2member_login_reg_background_image_repeat" id="ws-plugin--s2member-login-reg-background-image-repeat">' . "\n";
356
- echo '<option value="repeat"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image_repeat"] === "repeat") ? ' selected="selected"' : '') . '>Seamless Tile ( background-repeat: repeat; )</option>' . "\n";
357
- echo '<option value="repeat-x"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image_repeat"] === "repeat-x") ? ' selected="selected"' : '') . '>Tile Horizontally ( background-repeat: repeat-x; )</option>' . "\n";
358
- echo '<option value="repeat-y"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image_repeat"] === "repeat-y") ? ' selected="selected"' : '') . '>Tile Vertically ( background-repeat: repeat-y; )</option>' . "\n";
359
- echo '<option value="no-repeat"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image_repeat"] === "no-repeat") ? ' selected="selected"' : '') . '>No Tiles ( background-repeat: no-repeat; )</option>' . "\n";
360
  echo '</select><br />' . "\n";
361
  echo 'This controls the way your Background Image is styled with CSS. [ <a href="http://www.w3schools.com/css/pr_background-repeat.asp" target="_blank" rel="external">learn more</a> ]' . "\n";
362
  echo '</td>' . "\n";
@@ -573,9 +573,9 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
573
  echo '<tr>' . "\n";
574
  /**/
575
  echo '<td>' . "\n";
576
- echo '<select name="ws_plugin__s2member_custom_reg_password" id="ws-plugin--s2member-custom-reg-password"' . ((!function_exists ("ws_plugin__s2member_generate_password") || (is_multisite () && ws_plugin__s2member_is_multisite_farm () && is_main_site () && !$GLOBALS["WS_PLUGIN__"]["s2member_pro"])) ? ' disabled="disabled"' : '') . '>' . "\n";
577
- echo '<option value="0"' . ((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"]) ? ' selected="selected"' : '') . '>No ( send auto-generated passwords via email; after registration )</option>' . "\n";
578
- echo '<option value="1"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"]) ? ' selected="selected"' : '') . '>Yes ( allow members to create their own password during registration )</option>' . "\n";
579
  echo '</select><br />' . "\n";
580
  echo 'Auto-generated Passwords are recommended for best security; because, this also serves as a form of email confirmation.' . "\n";
581
  echo '</td>' . "\n";
@@ -618,10 +618,10 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
618
  echo '<select name="ws_plugin__s2member_login_welcome_page" id="ws-plugin--s2member-login-welcome-page">' . "\n";
619
  echo '<option value="">&mdash; Select &mdash;</option>' . "\n";
620
  foreach (($ws_plugin__s2member_temp_a = array_merge ((array)get_pages ())) as $ws_plugin__s2member_temp_o)
621
- echo '<option value="' . esc_attr ($ws_plugin__s2member_temp_o->ID) . '"' . ((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && $ws_plugin__s2member_temp_o->ID == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]) ? ' selected="selected"' : '') . '>' . esc_html ($ws_plugin__s2member_temp_o->post_title) . '</option>' . "\n";
622
  echo '</select><br />' . "\n";
623
  echo 'Please choose a Page to be used as the first page Members will see after logging in. This Page can contain anything you like. We recommend the following title: <code>Welcome To Our Members Area</code>.<br /><br />' . "\n";
624
- echo '&darr; Or, you may configure a Special Redirection URL, if you prefer. You\'ll need to type in the full URL, starting with: <code>http://</code>. <em>A few <a href="#" onclick="alert(\'Replacement Codes:\\n\\n%%current_user_login%% = The current User\\\'s login ( their Username, lowercase ).\\n%%current_user_ID%% = The current User\\\'s ID.\\n%%current_user_level%% = The current User\\\'s s2Member Level.\\n\\nFor example, if you\\\'re using BuddyPress, and you want to redirect Members to their BuddyPress Profile page after logging in, you would setup a Special Redirection URL, like this: ' . get_bloginfo ("wpurl") . '/members/%%current_user_login%%/profile/\\n\\nOr ... using %%current_user_level%%, you could have a separate Login Welcome Page for each Membership Level that you plan to offer. BuddyPress not required.\'); return false;">Replacement Codes</a> are also supported here.</em>' . "\n";
625
  echo '<input type="text" name="ws_plugin__s2member_login_redirection_override" id="ws-plugin--s2member-login-redirection-override" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"]) . '" /><br />' . "\n";
626
  echo '</td>' . "\n";
627
  /**/
@@ -663,7 +663,7 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
663
  echo '<select name="ws_plugin__s2member_membership_options_page" id="ws-plugin--s2member-membership-options-page">' . "\n";
664
  echo '<option value="">&mdash; Select &mdash;</option>' . "\n";
665
  foreach (($ws_plugin__s2member_temp_a = array_merge ((array)get_pages ())) as $ws_plugin__s2member_temp_o)
666
- echo '<option value="' . esc_attr ($ws_plugin__s2member_temp_o->ID) . '"' . (($ws_plugin__s2member_temp_o->ID == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) ? ' selected="selected"' : '') . '>' . esc_html ($ws_plugin__s2member_temp_o->post_title) . '</option>' . "\n";
667
  echo '</select><br />' . "\n";
668
  echo 'Please choose a Page that provides Users a way to signup for Membership. This Page should also contain your PayPal&reg Subscription button(s). We recommend the following title: <code>Membership Signup</code>.' . "\n";
669
  echo '</td>' . "\n";
@@ -686,8 +686,9 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
686
  /**/
687
  echo '<div class="ws-menu-page-section ws-plugin--s2member-post-level-access-section">' . "\n";
688
  echo '<h3>Post Level Access Restrictions ( optional )</h3>' . "\n";
689
- echo '<p>Here you can specify Posts that are restricted to certain Membership Access Levels. These fields also support Custom Post Types, which were first introduced in WordPress® 3.0. If you have a theme/plugin installed that has enabled Custom Post Types ( i.e. Music/Videos/etc ), you can put the IDs for those Posts here.</p>' . "\n";
690
- echo ((!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ()) && !$GLOBALS["WS_PLUGIN__"]["wp_show_ids"]) ? '<p><em><strong>*Tip*</strong> Can\'t find your Post IDs? Get <a href="http://www.primothemes.com/post/wp-show-ids-plugin/" target="_blank" rel="external">WP Show IDs</a>.</em></p>' . "\n" : '';
 
691
  do_action ("ws_plugin__s2member_during_options_page_during_left_sections_during_post_level_access", get_defined_vars ());
692
  /**/
693
  echo '<table class="form-table">' . "\n";
@@ -795,7 +796,7 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
795
  echo '<div class="ws-menu-page-section ws-plugin--s2member-page-level-access-section">' . "\n";
796
  echo '<h3>Page Level Access Restrictions ( optional )</h3>' . "\n";
797
  echo '<p>Here you can specify Pages that are restricted to certain Membership Access Levels.</p>' . "\n";
798
- echo ((!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ()) && !$GLOBALS["WS_PLUGIN__"]["wp_show_ids"]) ? '<p><em><strong>*Tip*</strong> Can\'t find your Page IDs? Get <a href="http://www.primothemes.com/post/wp-show-ids-plugin/" target="_blank" rel="external">WP Show IDs</a>.</em></p>' . "\n" : '';
799
  do_action ("ws_plugin__s2member_during_options_page_during_left_sections_during_page_level_access", get_defined_vars ());
800
  /**/
801
  echo '<table class="form-table">' . "\n";
@@ -902,7 +903,8 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
902
  /**/
903
  echo '<div class="ws-menu-page-section ws-plugin--s2member-tag-level-access-section">' . "\n";
904
  echo '<h3>Tag Level Access Restrictions ( optional )</h3>' . "\n";
905
- echo '<p>Here you can specify Tags that are restricted to certain Membership Access Levels. Tag restrictions are a bit more complex. When you restrict access to a Tag, it also restricts access to any Posts that may have the Tag. In other words, restricting a Tag protects that Tag Archive, and it also protects any Posts that have the Tag; even if they have other Tags.</p>' . "\n";
 
906
  do_action ("ws_plugin__s2member_during_options_page_during_left_sections_during_tag_level_access", get_defined_vars ());
907
  /**/
908
  echo '<table class="form-table">' . "\n";
@@ -920,7 +922,7 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
920
  /**/
921
  echo '<td>' . "\n";
922
  echo '<input type="text" name="ws_plugin__s2member_level0_ptags" id="ws-plugin--s2member-level0-ptags" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_ptags"]) . '" /><br />' . "\n";
923
- echo 'Tags in comma delimited format. Example: <code>free,registration required</code> — or you can type: <code>all</code>.' . "\n";
924
  echo '</td>' . "\n";
925
  /**/
926
  echo '</tr>' . "\n";
@@ -937,7 +939,7 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
937
  /**/
938
  echo '<td>' . "\n";
939
  echo '<input type="text" name="ws_plugin__s2member_level1_ptags" id="ws-plugin--s2member-level1-ptags" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_ptags"]) . '" /><br />' . "\n";
940
- echo 'Tags in comma delimited format. Example: <code>premium,restricted</code> — or you can type: <code>all</code>.' . "\n";
941
  echo '</td>' . "\n";
942
  /**/
943
  echo '</tr>' . "\n";
@@ -954,7 +956,7 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
954
  /**/
955
  echo '<td>' . "\n";
956
  echo '<input type="text" name="ws_plugin__s2member_level2_ptags" id="ws-plugin--s2member-level2-ptags" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_ptags"]) . '" /><br />' . "\n";
957
- echo 'Tags in comma delimited format. Example: <code>premium,restricted</code> — or you can type: <code>all</code>.' . "\n";
958
  echo '</td>' . "\n";
959
  /**/
960
  echo '</tr>' . "\n";
@@ -971,7 +973,7 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
971
  /**/
972
  echo '<td>' . "\n";
973
  echo '<input type="text" name="ws_plugin__s2member_level3_ptags" id="ws-plugin--s2member-level3-ptags" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_ptags"]) . '" /><br />' . "\n";
974
- echo 'Tags in comma delimited format. Example: <code>premium,restricted</code> — or you can type: <code>all</code>.' . "\n";
975
  echo '</td>' . "\n";
976
  /**/
977
  echo '</tr>' . "\n";
@@ -988,7 +990,7 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
988
  /**/
989
  echo '<td>' . "\n";
990
  echo '<input type="text" name="ws_plugin__s2member_level4_ptags" id="ws-plugin--s2member-level4-ptags" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_ptags"]) . '" /><br />' . "\n";
991
- echo 'Tags in comma delimited format. Example: <code>premium,restricted</code> — or you can type: <code>all</code>.' . "\n";
992
  echo '</td>' . "\n";
993
  /**/
994
  echo '</tr>' . "\n";
@@ -1009,8 +1011,8 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
1009
  /**/
1010
  echo '<div class="ws-menu-page-section ws-plugin--s2member-category-level-access-section">' . "\n";
1011
  echo '<h3>Category Level Access Restrictions ( optional )</h3>' . "\n";
1012
- echo '<p>Here you can specify Categories that are restricted to certain Membership Access Levels. Category restrictions are a bit more complex. When you restrict access to a Category, it also restricts access to any child Categories it may have ( aka: sub-Categories ). In other words, restricting a Category protects that Category Archive, all of its child Category Archives, and any Posts contained within the Category, or its child Categories.</p>' . "\n";
1013
- echo ((!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ()) && !$GLOBALS["WS_PLUGIN__"]["wp_show_ids"]) ? '<p><em><strong>*Tip*</strong> Can\'t find your Category IDs? Get <a href="http://www.primothemes.com/post/wp-show-ids-plugin/" target="_blank" rel="external">WP Show IDs</a>.</em></p>' . "\n" : '';
1014
  do_action ("ws_plugin__s2member_during_options_page_during_left_sections_during_category_level_access", get_defined_vars ());
1015
  /**/
1016
  echo '<table class="form-table">' . "\n";
@@ -1118,7 +1120,7 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
1118
  echo '<div class="ws-menu-page-section ws-plugin--s2member-uri-level-access-section">' . "\n";
1119
  echo '<h3>URI Level Access Restrictions ( optional )</h3>' . "\n";
1120
  echo '<p>Here you can specify URIs ( or word fragments found in URIs ) that are restricted to certain Membership Access Levels. Control over URIs is a little more complex. This section is intended for advanced webmasters only. That being said, here are the basics... A REQUEST_URI, is the portion of the URL that comes after the domain. This is a URL <code>http://www.example.com/path/to/file.php</code>, and this is the URI: <code>/path/to/file.php</code>.</p>' . "\n";
1121
- echo '<p>In the fields below, you can provide a list ( one per line ) of URIs on your site that should be off-limits based on Membership Level. You can also use word fragments instead of a full URI. If a word fragment is found anywhere in the URI, it will be protected. Wildcards and other regex patterns are not supported here, and therefore you don\'t need to escape special characters or anything. Please note, these ARE caSe sensitive. You must be specific with respect to case sensitivity. The word fragment <code>some-path/</code> would NOT match a URI that contains <code>some-Path/</code>. <em>A few <a href="#" onclick="alert(\'URI Replacement Codes:\\n\\n%%current_user_login%% = The current User\\\'s login ( their Username, lowercase ).\\n%%current_user_ID%% = The current User\\\'s ID.\\n%%current_user_level%% = The current User\\\'s s2Member Level.\\n\\nFor example, if you\\\'re using BuddyPress, and want to protect BuddyPress Groups, you could add URI protection, like this: /members/%%current_user_login%%/groups/\'); return false;">Replacement Codes</a> are also supported here.</em></p>' . "\n";
1122
  do_action ("ws_plugin__s2member_during_options_page_during_left_sections_during_uri_level_access", get_defined_vars ());
1123
  /**/
1124
  echo '<table class="form-table">' . "\n";
@@ -1217,6 +1219,53 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
1217
  do_action ("ws_plugin__s2member_during_options_page_during_left_sections_after_uri_level_access", get_defined_vars ());
1218
  }
1219
  /**/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1220
  if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections_display_sp_access", true, get_defined_vars ()))
1221
  {
1222
  do_action ("ws_plugin__s2member_during_options_page_during_left_sections_before_sp_access", get_defined_vars ());
@@ -1229,7 +1278,7 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
1229
  echo '<p>In other words, Customers will NOT need to login, just to receive access to the Specific Post/Page they purchased access to. s2Member will immediately redirect the Customer to the Specific Post/Page after checkout is completed successfully. An email is also sent to the Customer with a link ( see: <code>s2Member -> PayPal® Options -> Specific Post/Page Email</code> ). Authentication is handled automatically through self-expiring links, good for 72 hours by default.</p>' . "\n";
1230
  echo '<p>Specific Post/Page Access, is sort of like selling a product. Only, instead of shipping anything to the Customer, you just give them access to a specific Post/Page on your site; one that you created in WordPress®. A Specific Post/Page that is protected by s2Member, might contain a download link for your eBook, access to file &amp; music downloads, access to additional support services, and the list goes on and on. The possibilities with this are endless; as long as your digital product can be delivered through access to a WordPress® Post/Page that you\'ve created.</p>' . "\n";
1231
  echo '<p>Very simple. All you do is protect the Specific Post/Page IDs that are being sold on your site. Then, you can go to <code>s2Member -> PayPal® Buttons -> Specific Post/Page</code> to generate "Buy Now" Buttons that you can insert into your WordPress® Editor, and make available on your site. The Button Generator for s2Member, will even let you Package Additional Posts/Pages together into one transaction.</p>' . "\n";
1232
- echo ((!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ()) && !$GLOBALS["WS_PLUGIN__"]["wp_show_ids"]) ? '<p><em><strong>*Tip*</strong> Can\'t find your Post/Page IDs? Get <a href="http://www.primothemes.com/post/wp-show-ids-plugin/" target="_blank" rel="external">WP Show IDs</a>.</em></p>' . "\n" : '';
1233
  do_action ("ws_plugin__s2member_during_options_page_during_left_sections_during_sp_access", get_defined_vars ());
1234
  /**/
1235
  echo '<table class="form-table">' . "\n";
@@ -1290,18 +1339,18 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
1290
  echo '<td>' . "\n";
1291
  echo '<select name="ws_plugin__s2member_max_ip_restriction" id="ws-plugin--s2member-max-ip-restriction">' . "\n";
1292
  $ws_plugin__s2member_temp_s = apply_filters ("ws_plugin__s2member_ip_restrictions__concurrency_time_per_ip", "30 days");
1293
- echo '<option value="1"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 1) ? ' selected="selected"' : '') . '>Allow up to 1 unique IP per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1294
- echo '<option value="2"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 2) ? ' selected="selected"' : '') . '>Allow up to 2 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1295
- echo '<option value="3"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 3) ? ' selected="selected"' : '') . '>Allow up to 3 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1296
- echo '<option value="4"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 4) ? ' selected="selected"' : '') . '>Allow up to 4 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1297
- echo '<option value="5"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 5) ? ' selected="selected"' : '') . '>Allow up to 5 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1298
- echo '<option value="10"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 10) ? ' selected="selected"' : '') . '>Allow up to 10 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1299
- echo '<option value="20"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 20) ? ' selected="selected"' : '') . '>Allow up to 20 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1300
- echo '<option value="30"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 30) ? ' selected="selected"' : '') . '>Allow up to 30 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1301
- echo '<option value="40"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 40) ? ' selected="selected"' : '') . '>Allow up to 40 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1302
- echo '<option value="50"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 50) ? ' selected="selected"' : '') . '>Allow up to 50 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1303
- echo '<option value="75"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 75) ? ' selected="selected"' : '') . '>Allow up to 75 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1304
- echo '<option value="100"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 100) ? ' selected="selected"' : '') . '>Allow up to 100 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1305
  echo '</select><br />' . "\n";
1306
  echo 'The default period of "30 days" could be modified through this WordPress® Filter:<br /><code>ws_plugin__s2member_ip_restrictions__concurrency_time_per_ip</code>' . "\n";
1307
  echo '</td>' . "\n";
@@ -1320,24 +1369,24 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
1320
  /**/
1321
  echo '<td>' . "\n";
1322
  echo '<select name="ws_plugin__s2member_max_ip_restriction_time" id="ws-plugin--s2member-max-ip-restriction-time">' . "\n";
1323
- echo '<option value="900"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 900) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 15 mins )</option>' . "\n";
1324
- echo '<option value="1800"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 1800) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 30 mins )</option>' . "\n";
1325
- echo '<option value="3600"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 3600) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 1 hour )</option>' . "\n";
1326
- echo '<option value="7200"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 7200) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 2 hours )</option>' . "\n";
1327
- echo '<option value="14400"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 14400) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 4 hours )</option>' . "\n";
1328
- echo '<option value="21600"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 21600) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 6 hours )</option>' . "\n";
1329
- echo '<option value="28800"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 28800) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 8 hours )</option>' . "\n";
1330
- echo '<option value="43200"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 43200) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 12 hours )</option>' . "\n";
1331
- echo '<option value="86400"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 86400) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 24 hours )</option>' . "\n";
1332
- echo '<option value="172800"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 172800) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 2 days )</option>' . "\n";
1333
- echo '<option value="345600"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 345600) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 4 days )</option>' . "\n";
1334
- echo '<option value="604800"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 604800) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 1 week )</option>' . "\n";
1335
- echo '<option value="1209600"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 1209600) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 2 weeks )</option>' . "\n";
1336
- echo '<option value="2629743"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 2629743) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 1 month )</option>' . "\n";
1337
- echo '<option value="5259487"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 5259487) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 2 months )</option>' . "\n";
1338
- echo '<option value="7889231"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 7889231) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 3 months )</option>' . "\n";
1339
- echo '<option value="15778463"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 15778463) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 6 months )</option>' . "\n";
1340
- echo '<option value="31556926"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 31556926) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 1 year )</option>' . "\n";
1341
  echo '</select><br />' . "\n";
1342
  echo 'When/if you change this, it will take X amount of time to update; based on your previous configuration.' . "\n";
1343
  echo '</td>' . "\n";
@@ -1394,8 +1443,8 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
1394
  /**/
1395
  echo '<td>' . "\n";
1396
  echo '<select name="ws_plugin__s2member_force_admin_lockouts" id="ws-plugin--s2member-force-admin-lockouts">' . "\n";
1397
- echo '<option value="0"' . ((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"]) ? ' selected="selected"' : '') . '>No ( I want to leave all options available to my Members )</option>' . "\n";
1398
- echo '<option value="1"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"]) ? ' selected="selected"' : '') . '>Yes ( redirect Members to their Login Welcome Page )</option>' . "\n";
1399
  echo '</select><br />' . "\n";
1400
  echo 'Recommended setting ( <code>Yes</code> ). The Stand-Alone version is better.<br />' . "\n";
1401
  echo 'You\'ll want to embed the Stand-Alone version into your Login Welcome Page.<br />' . "\n";
@@ -1437,8 +1486,8 @@ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections
1437
  /**/
1438
  echo '<td>' . "\n";
1439
  echo '<select name="ws_plugin__s2member_run_deactivation_routines" id="ws-plugin--s2member-run-deactivation-routines">' . "\n";
1440
- echo '<option value="1"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["run_deactivation_routines"]) ? ' selected="selected"' : '') . '></option>' . "\n";
1441
- echo '<option value="0"' . ((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["run_deactivation_routines"]) ? ' selected="selected"' : '') . '>Yes ( safeguard all data/options )</option>' . "\n";
1442
  echo '</select><br />' . "\n";
1443
  echo 'Recommended setting: ( <code>Yes, safeguard all data/options</code> )' . "\n";
1444
  echo '</td>' . "\n";
53
  /**/
54
  echo '<th>' . "\n";
55
  echo '<label for="ws-plugin--s2member-sec-encryption-key">' . "\n";
56
+ echo 'Security Encryption Key:' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key"]) ? ' ( <a href="#" onclick="ws_plugin__s2member_enableSecurityKey();" title="( not recommended )">edit key</a> )' : ' ( <a href="#" onclick="ws_plugin__s2member_generateSecurityKey();" title="Insert an auto-generated Key. ( recommended )">auto-generate</a> )') . "\n";
57
  echo '</label>' . "\n";
58
  echo '</th>' . "\n";
59
  /**/
61
  echo '<tr>' . "\n";
62
  /**/
63
  echo '<td>' . "\n";
64
+ echo '<input type="text" name="ws_plugin__s2member_sec_encryption_key" id="ws-plugin--s2member-sec-encryption-key" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key"]) . '" maxlength="256" autocomplete="off"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key"]) ? ' disabled="disabled"' : '') . ' />' . "\n";
65
  echo (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key"]) ? '<br />This may contain letters, numbers, spaces; even punctuation. Up to 256 characters.<br /><em>Ex: <code>' . esc_html (strtoupper (ws_plugin__s2member_random_str_gen (56))) . '</code></em>' . "\n" : '';
66
  echo (count ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key_history"]) > 1) ? '<br /><a href="#" onclick="ws_plugin__s2member_securityKeyHistory();">Click here</a> for a history of your last 10 Encryption Keys.<div id="ws-plugin--s2member-sec-encryption-key-history" style="display:none;"><code>' . implode ('</code><br /><code>', $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key_history"]) . '</code></div>' . "\n" : '';
67
  echo '</td>' . "\n";
158
  /**/
159
  echo '<td>' . "\n";
160
  echo '<select name="ws_plugin__s2member_allow_subscribers_in" id="ws-plugin--s2member-allow-subscribers-in">' . "\n";
161
+ echo '<option value="0"' . ( (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["allow_subscribers_in"]) ? ' selected="selected"' : '') . '>No ( do NOT allow Open Registration )</option>' . "\n";
162
+ echo '<option value="1"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["allow_subscribers_in"]) ? ' selected="selected"' : '') . '>Yes ( allow Open Registration; Free Subscribers at Level #0 )</option>' . "\n";
163
  echo '</select><br />' . "\n";
164
  echo 'If you set this to <code>Yes</code>, you\'re unlocking <a href="' . add_query_arg ("action", "register", wp_login_url ()) . '" target="_blank" rel="external">wp-login.php?action=register</a>. When a visitor registers without paying, they\'ll automatically become a Free Subscriber, at Level #0. The s2Member software reserves Level #0; to be used ONLY for Free Subscribers. All other Membership Levels [1-4] require payment.' . "\n";
165
  echo '</td>' . "\n";
353
  /**/
354
  echo '<td>' . "\n";
355
  echo '<select name="ws_plugin__s2member_login_reg_background_image_repeat" id="ws-plugin--s2member-login-reg-background-image-repeat">' . "\n";
356
+ echo '<option value="repeat"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image_repeat"] === "repeat") ? ' selected="selected"' : '') . '>Seamless Tile ( background-repeat: repeat; )</option>' . "\n";
357
+ echo '<option value="repeat-x"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image_repeat"] === "repeat-x") ? ' selected="selected"' : '') . '>Tile Horizontally ( background-repeat: repeat-x; )</option>' . "\n";
358
+ echo '<option value="repeat-y"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image_repeat"] === "repeat-y") ? ' selected="selected"' : '') . '>Tile Vertically ( background-repeat: repeat-y; )</option>' . "\n";
359
+ echo '<option value="no-repeat"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image_repeat"] === "no-repeat") ? ' selected="selected"' : '') . '>No Tiles ( background-repeat: no-repeat; )</option>' . "\n";
360
  echo '</select><br />' . "\n";
361
  echo 'This controls the way your Background Image is styled with CSS. [ <a href="http://www.w3schools.com/css/pr_background-repeat.asp" target="_blank" rel="external">learn more</a> ]' . "\n";
362
  echo '</td>' . "\n";
573
  echo '<tr>' . "\n";
574
  /**/
575
  echo '<td>' . "\n";
576
+ echo '<select name="ws_plugin__s2member_custom_reg_password" id="ws-plugin--s2member-custom-reg-password"' . ( (!function_exists ("ws_plugin__s2member_generate_password") || (is_multisite () && ws_plugin__s2member_is_multisite_farm () && is_main_site () && !$GLOBALS["WS_PLUGIN__"]["s2member_pro"])) ? ' disabled="disabled"' : '') . '>' . "\n";
577
+ echo '<option value="0"' . ( (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"]) ? ' selected="selected"' : '') . '>No ( send auto-generated passwords via email; after registration )</option>' . "\n";
578
+ echo '<option value="1"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"]) ? ' selected="selected"' : '') . '>Yes ( allow members to create their own password during registration )</option>' . "\n";
579
  echo '</select><br />' . "\n";
580
  echo 'Auto-generated Passwords are recommended for best security; because, this also serves as a form of email confirmation.' . "\n";
581
  echo '</td>' . "\n";
618
  echo '<select name="ws_plugin__s2member_login_welcome_page" id="ws-plugin--s2member-login-welcome-page">' . "\n";
619
  echo '<option value="">&mdash; Select &mdash;</option>' . "\n";
620
  foreach (($ws_plugin__s2member_temp_a = array_merge ((array)get_pages ())) as $ws_plugin__s2member_temp_o)
621
+ echo '<option value="' . esc_attr ($ws_plugin__s2member_temp_o->ID) . '"' . ( (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && $ws_plugin__s2member_temp_o->ID == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]) ? ' selected="selected"' : '') . '>' . esc_html ($ws_plugin__s2member_temp_o->post_title) . '</option>' . "\n";
622
  echo '</select><br />' . "\n";
623
  echo 'Please choose a Page to be used as the first page Members will see after logging in. This Page can contain anything you like. We recommend the following title: <code>Welcome To Our Members Area</code>.<br /><br />' . "\n";
624
+ echo '&darr; Or, you may configure a Special Redirection URL, if you prefer. You\'ll need to type in the full URL, starting with: <code>http://</code>. <em>A few <a href="#" onclick="alert(\'Replacement Codes:\\n\\n%%current_user_login%% = The current User\\\'s login ( their Username, lowercase ).\\n%%current_user_id%% = The current User\\\'s ID.\\n%%current_user_level%% = The current User\\\'s s2Member Level.\\n\\nFor example, if you\\\'re using BuddyPress, and you want to redirect Members to their BuddyPress Profile page after logging in, you would setup a Special Redirection URL, like this: ' . get_bloginfo ("wpurl") . '/members/%%current_user_login%%/profile/\\n\\nOr ... using %%current_user_level%%, you could have a separate Login Welcome Page for each Membership Level that you plan to offer. BuddyPress not required.\'); return false;">Replacement Codes</a> are also supported here.</em>' . "\n";
625
  echo '<input type="text" name="ws_plugin__s2member_login_redirection_override" id="ws-plugin--s2member-login-redirection-override" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"]) . '" /><br />' . "\n";
626
  echo '</td>' . "\n";
627
  /**/
663
  echo '<select name="ws_plugin__s2member_membership_options_page" id="ws-plugin--s2member-membership-options-page">' . "\n";
664
  echo '<option value="">&mdash; Select &mdash;</option>' . "\n";
665
  foreach (($ws_plugin__s2member_temp_a = array_merge ((array)get_pages ())) as $ws_plugin__s2member_temp_o)
666
+ echo '<option value="' . esc_attr ($ws_plugin__s2member_temp_o->ID) . '"' . ( ($ws_plugin__s2member_temp_o->ID == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) ? ' selected="selected"' : '') . '>' . esc_html ($ws_plugin__s2member_temp_o->post_title) . '</option>' . "\n";
667
  echo '</select><br />' . "\n";
668
  echo 'Please choose a Page that provides Users a way to signup for Membership. This Page should also contain your PayPal&reg Subscription button(s). We recommend the following title: <code>Membership Signup</code>.' . "\n";
669
  echo '</td>' . "\n";
686
  /**/
687
  echo '<div class="ws-menu-page-section ws-plugin--s2member-post-level-access-section">' . "\n";
688
  echo '<h3>Post Level Access Restrictions ( optional )</h3>' . "\n";
689
+ echo '<p>Here you can specify Posts that are restricted to certain Membership Access Levels. s2Member also supports Custom Post Types here, which were first introduced in WordPress® 3.0. If you have a theme or plugin installed, that has enabled Custom Post Types ( i.e. Music/Videos or something else ), you can put the IDs for those Posts here.</p>' . "\n";
690
+ echo '<p><em><strong>*Note*</strong> Protecting individual Posts, ONLY protects the Permalinks for those Posts. It is still possible for excerpts of protected content to be seen in search results generated by WordPress®, feeds, and Archive views; such as your Home Page, inside a Category listing, or through other queries formulated by your theme. This is the intended functionality. Excerpts are a great way to "tease" public visitors. In other words, public visitors may have access to excerpts introduced by your theme, but any attempt to view the full Post ( i.e. the Permalink ) will result in an automatic redirect to your Membership Options Page; requiring registration. All of that being said, if you would like to protect many Posts at once ( including Archive views ), you can use Category Level Restrictions, Tag Level Restrictions, or have a look down below at s2Member\'s options for "Alternative View Protection", which deals with search results, as well as feeds.</em></p>' . "\n";
691
+ echo ( (!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ()) && !$GLOBALS["WS_PLUGIN__"]["wp_show_ids"]) ? '<p><em><strong>*Tip*</strong> Can\'t find your Post IDs? Get <a href="http://www.primothemes.com/post/wp-show-ids-plugin/" target="_blank" rel="external">WP Show IDs</a>.</em></p>' . "\n" : '';
692
  do_action ("ws_plugin__s2member_during_options_page_during_left_sections_during_post_level_access", get_defined_vars ());
693
  /**/
694
  echo '<table class="form-table">' . "\n";
796
  echo '<div class="ws-menu-page-section ws-plugin--s2member-page-level-access-section">' . "\n";
797
  echo '<h3>Page Level Access Restrictions ( optional )</h3>' . "\n";
798
  echo '<p>Here you can specify Pages that are restricted to certain Membership Access Levels.</p>' . "\n";
799
+ echo ( (!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ()) && !$GLOBALS["WS_PLUGIN__"]["wp_show_ids"]) ? '<p><em><strong>*Tip*</strong> Can\'t find your Page IDs? Get <a href="http://www.primothemes.com/post/wp-show-ids-plugin/" target="_blank" rel="external">WP Show IDs</a>.</em></p>' . "\n" : '';
800
  do_action ("ws_plugin__s2member_during_options_page_during_left_sections_during_page_level_access", get_defined_vars ());
801
  /**/
802
  echo '<table class="form-table">' . "\n";
903
  /**/
904
  echo '<div class="ws-menu-page-section ws-plugin--s2member-tag-level-access-section">' . "\n";
905
  echo '<h3>Tag Level Access Restrictions ( optional )</h3>' . "\n";
906
+ echo '<p>Here you can specify Tags that are restricted to certain Membership Access Levels. This is very similar to Category Level Access. When you restrict access to a Tag Archive, it also restricts access to any Post having that Tag; even if a Post has other Tags. <em>*Tip*</em> ... Tags can be applied to any Post, without affecting your Category structure at all. If you\'d like to use Tags with Pages, get <a href="http://wordpress.org/extend/plugins/page-tagger/" target="_blank" rel="external">Page Tagger</a> <em>( compatible with s2Member )</em>.</p>' . "\n";
907
+ echo '<p>Tags are caSe sensitive. The Tag <code>members only</code> is NOT the same as <code>Members Only</code>.</p>' . "\n";
908
  do_action ("ws_plugin__s2member_during_options_page_during_left_sections_during_tag_level_access", get_defined_vars ());
909
  /**/
910
  echo '<table class="form-table">' . "\n";
922
  /**/
923
  echo '<td>' . "\n";
924
  echo '<input type="text" name="ws_plugin__s2member_level0_ptags" id="ws-plugin--s2member-level0-ptags" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_ptags"]) . '" /><br />' . "\n";
925
+ echo 'Tags in comma delimited format. Example: <code>free,subscribers only</code> — or you can type: <code>all</code>.' . "\n";
926
  echo '</td>' . "\n";
927
  /**/
928
  echo '</tr>' . "\n";
939
  /**/
940
  echo '<td>' . "\n";
941
  echo '<input type="text" name="ws_plugin__s2member_level1_ptags" id="ws-plugin--s2member-level1-ptags" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_ptags"]) . '" /><br />' . "\n";
942
+ echo 'Tags in comma delimited format. Example: <code>premium,members only</code> — or you can type: <code>all</code>.' . "\n";
943
  echo '</td>' . "\n";
944
  /**/
945
  echo '</tr>' . "\n";
956
  /**/
957
  echo '<td>' . "\n";
958
  echo '<input type="text" name="ws_plugin__s2member_level2_ptags" id="ws-plugin--s2member-level2-ptags" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_ptags"]) . '" /><br />' . "\n";
959
+ echo 'Tags in comma delimited format. Example: <code>premium,members only</code> — or you can type: <code>all</code>.' . "\n";
960
  echo '</td>' . "\n";
961
  /**/
962
  echo '</tr>' . "\n";
973
  /**/
974
  echo '<td>' . "\n";
975
  echo '<input type="text" name="ws_plugin__s2member_level3_ptags" id="ws-plugin--s2member-level3-ptags" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_ptags"]) . '" /><br />' . "\n";
976
+ echo 'Tags in comma delimited format. Example: <code>premium,members only</code> — or you can type: <code>all</code>.' . "\n";
977
  echo '</td>' . "\n";
978
  /**/
979
  echo '</tr>' . "\n";
990
  /**/
991
  echo '<td>' . "\n";
992
  echo '<input type="text" name="ws_plugin__s2member_level4_ptags" id="ws-plugin--s2member-level4-ptags" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_ptags"]) . '" /><br />' . "\n";
993
+ echo 'Tags in comma delimited format. Example: <code>premium,members only</code> — or you can type: <code>all</code>.' . "\n";
994
  echo '</td>' . "\n";
995
  /**/
996
  echo '</tr>' . "\n";
1011
  /**/
1012
  echo '<div class="ws-menu-page-section ws-plugin--s2member-category-level-access-section">' . "\n";
1013
  echo '<h3>Category Level Access Restrictions ( optional )</h3>' . "\n";
1014
+ echo '<p>Here you can specify Categories that are restricted to certain Membership Access Levels. Category restrictions are a bit more complex. When you restrict access to a Category, it also restricts access to any child Categories it may have ( aka: sub-Categories ). In other words, restricting a Category protects a Category Archive, all of its child Category Archives, and any Posts contained within the Category, or its child Categories.</p>' . "\n";
1015
+ echo ( (!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ()) && !$GLOBALS["WS_PLUGIN__"]["wp_show_ids"]) ? '<p><em><strong>*Tip*</strong> Can\'t find your Category IDs? Get <a href="http://www.primothemes.com/post/wp-show-ids-plugin/" target="_blank" rel="external">WP Show IDs</a>.</em></p>' . "\n" : '';
1016
  do_action ("ws_plugin__s2member_during_options_page_during_left_sections_during_category_level_access", get_defined_vars ());
1017
  /**/
1018
  echo '<table class="form-table">' . "\n";
1120
  echo '<div class="ws-menu-page-section ws-plugin--s2member-uri-level-access-section">' . "\n";
1121
  echo '<h3>URI Level Access Restrictions ( optional )</h3>' . "\n";
1122
  echo '<p>Here you can specify URIs ( or word fragments found in URIs ) that are restricted to certain Membership Access Levels. Control over URIs is a little more complex. This section is intended for advanced webmasters only. That being said, here are the basics... A REQUEST_URI, is the portion of the URL that comes after the domain. This is a URL <code>http://www.example.com/path/to/file.php</code>, and this is the URI: <code>/path/to/file.php</code>.</p>' . "\n";
1123
+ echo '<p>In the fields below, you can provide a list ( one per line ) of URIs on your site that should be off-limits based on Membership Level. You can also use word fragments instead of a full URI. If a word fragment is found anywhere in the URI, it will be protected. Wildcards and other regex patterns are not supported here, and therefore you don\'t need to escape special characters or anything. Please note, these ARE caSe sensitive. You must be specific with respect to case sensitivity. The word fragment <code>some-path/</code> would NOT match a URI that contains <code>some-Path/</code>. <em>A few <a href="#" onclick="alert(\'URI Replacement Codes:\\n\\n%%current_user_login%% = The current User\\\'s login ( their Username, lowercase ).\\n%%current_user_id%% = The current User\\\'s ID.\\n%%current_user_level%% = The current User\\\'s s2Member Level.\\n\\nFor example, if you\\\'re using BuddyPress, and want to protect BuddyPress Groups, you could add URI protection, like this: /members/%%current_user_login%%/groups/\'); return false;">Replacement Codes</a> are also supported here.</em></p>' . "\n";
1124
  do_action ("ws_plugin__s2member_during_options_page_during_left_sections_during_uri_level_access", get_defined_vars ());
1125
  /**/
1126
  echo '<table class="form-table">' . "\n";
1219
  do_action ("ws_plugin__s2member_during_options_page_during_left_sections_after_uri_level_access", get_defined_vars ());
1220
  }
1221
  /**/
1222
+ if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections_display_query_level_access", true, get_defined_vars ()))
1223
+ {
1224
+ do_action ("ws_plugin__s2member_during_options_page_during_left_sections_before_query_level_access", get_defined_vars ());
1225
+ /**/
1226
+ echo '<div class="ws-menu-page-group" title="Alternative View Protection">' . "\n";
1227
+ /**/
1228
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-query-level-access-section">' . "\n";
1229
+ echo '<h3>Alternative View Protection ( optional / experimental )</h3>' . "\n";
1230
+ echo '<p>s2Member protects Categories, Tags, Posts, Pages, Files, URIs &amp; more. BUT, even with all of those security restrictions, it\'s still possible for protected content excerpts to be seen through XML feeds, in search results generated by WordPress®; and/or ( depending on your theme ), possibly in other Archive views; which might include: Posts by Author, Posts by Date, a list of featured items formulated by your theme, OR even through other widgets/plugins adding functionality to your site. ~ We refer to all of these collectively, as "Alternative Views".</p>' . "\n";
1231
+ echo '<p>Using the options below, you can tell s2Member to protect some ( or all ) of these "Alternative Views", by filtering WordPress® database queries for you. s2Member can automatically hide protected content that is NOT available to the current User/Member. In other words, s2Member is capable of pre-filtering ALL database queries, so that excerpts of protected content will not be allowed to slip through. This is marked "experimental", because we\'re still testing this against MANY widget/plugin/theme combinations. Please <a href="' . ws_plugin__s2member_parse_readme_value ("Forum URI") . '" target="_blank">report</a> all bugs.</p>' . "\n";
1232
+ do_action ("ws_plugin__s2member_during_options_page_during_left_sections_during_uri_level_access", get_defined_vars ());
1233
+ /**/
1234
+ echo '<table class="form-table">' . "\n";
1235
+ echo '<tbody>' . "\n";
1236
+ echo '<tr>' . "\n";
1237
+ /**/
1238
+ echo '<th>' . "\n";
1239
+ echo '<label for="ws-plugin--s2member-filter-wp-query">' . "\n";
1240
+ echo 'Protect Alternative Views?' . "\n";
1241
+ echo '</label>' . "\n";
1242
+ echo '</th>' . "\n";
1243
+ /**/
1244
+ echo '</tr>' . "\n";
1245
+ echo '<tr>' . "\n";
1246
+ /**/
1247
+ echo '<td>' . "\n";
1248
+ echo '<select name="ws_plugin__s2member_filter_wp_query" id="ws-plugin--s2member-filter-wp-query">' . "\n";
1249
+ echo '<option value="none"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["filter_wp_query"] === "none") ? ' selected="selected"' : '') . '>None ( do NOT filter any WordPress® queries )</option>' . "\n";
1250
+ echo '<option value="feeds"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["filter_wp_query"] === "feeds") ? ' selected="selected"' : '') . '>Feeds Only ( hide protected content in feeds only )</option>' . "\n";
1251
+ echo '<option value="searches"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["filter_wp_query"] === "searches") ? ' selected="selected"' : '') . '>Searches Only ( hide protected content in search results only )</option>' . "\n";
1252
+ echo '<option value="searches,feeds"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["filter_wp_query"] === "searches,feeds") ? ' selected="selected"' : '') . '>Searches &amp; Feeds Only ( hide protected content in search results &amp; feeds only )</option>' . "\n";
1253
+ echo '<option value="all"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["filter_wp_query"] === "all") ? ' selected="selected"' : '') . '>Yes ( filter ALL WordPress® queries; protecting all Alternative Views )</option>' . "\n";
1254
+ echo '</select><br />' . "\n";
1255
+ echo 'Attn: Developers. This could also be disabled dynamically, using this technique:<br />' . "\n";
1256
+ echo '<code>query_posts(" ... &suppress_filters=true");</code>' . "\n";
1257
+ echo '</td>' . "\n";
1258
+ /**/
1259
+ echo '</tr>' . "\n";
1260
+ echo '</tbody>' . "\n";
1261
+ echo '</table>' . "\n";
1262
+ echo '</div>' . "\n";
1263
+ /**/
1264
+ echo '</div>' . "\n";
1265
+ /**/
1266
+ do_action ("ws_plugin__s2member_during_options_page_during_left_sections_after_query_level_access", get_defined_vars ());
1267
+ }
1268
+ /**/
1269
  if (apply_filters ("ws_plugin__s2member_during_options_page_during_left_sections_display_sp_access", true, get_defined_vars ()))
1270
  {
1271
  do_action ("ws_plugin__s2member_during_options_page_during_left_sections_before_sp_access", get_defined_vars ());
1278
  echo '<p>In other words, Customers will NOT need to login, just to receive access to the Specific Post/Page they purchased access to. s2Member will immediately redirect the Customer to the Specific Post/Page after checkout is completed successfully. An email is also sent to the Customer with a link ( see: <code>s2Member -> PayPal® Options -> Specific Post/Page Email</code> ). Authentication is handled automatically through self-expiring links, good for 72 hours by default.</p>' . "\n";
1279
  echo '<p>Specific Post/Page Access, is sort of like selling a product. Only, instead of shipping anything to the Customer, you just give them access to a specific Post/Page on your site; one that you created in WordPress®. A Specific Post/Page that is protected by s2Member, might contain a download link for your eBook, access to file &amp; music downloads, access to additional support services, and the list goes on and on. The possibilities with this are endless; as long as your digital product can be delivered through access to a WordPress® Post/Page that you\'ve created.</p>' . "\n";
1280
  echo '<p>Very simple. All you do is protect the Specific Post/Page IDs that are being sold on your site. Then, you can go to <code>s2Member -> PayPal® Buttons -> Specific Post/Page</code> to generate "Buy Now" Buttons that you can insert into your WordPress® Editor, and make available on your site. The Button Generator for s2Member, will even let you Package Additional Posts/Pages together into one transaction.</p>' . "\n";
1281
+ echo ( (!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ()) && !$GLOBALS["WS_PLUGIN__"]["wp_show_ids"]) ? '<p><em><strong>*Tip*</strong> Can\'t find your Post/Page IDs? Get <a href="http://www.primothemes.com/post/wp-show-ids-plugin/" target="_blank" rel="external">WP Show IDs</a>.</em></p>' . "\n" : '';
1282
  do_action ("ws_plugin__s2member_during_options_page_during_left_sections_during_sp_access", get_defined_vars ());
1283
  /**/
1284
  echo '<table class="form-table">' . "\n";
1339
  echo '<td>' . "\n";
1340
  echo '<select name="ws_plugin__s2member_max_ip_restriction" id="ws-plugin--s2member-max-ip-restriction">' . "\n";
1341
  $ws_plugin__s2member_temp_s = apply_filters ("ws_plugin__s2member_ip_restrictions__concurrency_time_per_ip", "30 days");
1342
+ echo '<option value="1"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 1) ? ' selected="selected"' : '') . '>Allow up to 1 unique IP per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1343
+ echo '<option value="2"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 2) ? ' selected="selected"' : '') . '>Allow up to 2 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1344
+ echo '<option value="3"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 3) ? ' selected="selected"' : '') . '>Allow up to 3 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1345
+ echo '<option value="4"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 4) ? ' selected="selected"' : '') . '>Allow up to 4 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1346
+ echo '<option value="5"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 5) ? ' selected="selected"' : '') . '>Allow up to 5 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1347
+ echo '<option value="10"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 10) ? ' selected="selected"' : '') . '>Allow up to 10 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1348
+ echo '<option value="20"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 20) ? ' selected="selected"' : '') . '>Allow up to 20 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1349
+ echo '<option value="30"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 30) ? ' selected="selected"' : '') . '>Allow up to 30 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1350
+ echo '<option value="40"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 40) ? ' selected="selected"' : '') . '>Allow up to 40 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1351
+ echo '<option value="50"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 50) ? ' selected="selected"' : '') . '>Allow up to 50 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1352
+ echo '<option value="75"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 75) ? ' selected="selected"' : '') . '>Allow up to 75 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1353
+ echo '<option value="100"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] == 100) ? ' selected="selected"' : '') . '>Allow up to 100 different IPs per Customer ( every ' . $ws_plugin__s2member_temp_s . ' )</option>' . "\n";
1354
  echo '</select><br />' . "\n";
1355
  echo 'The default period of "30 days" could be modified through this WordPress® Filter:<br /><code>ws_plugin__s2member_ip_restrictions__concurrency_time_per_ip</code>' . "\n";
1356
  echo '</td>' . "\n";
1369
  /**/
1370
  echo '<td>' . "\n";
1371
  echo '<select name="ws_plugin__s2member_max_ip_restriction_time" id="ws-plugin--s2member-max-ip-restriction-time">' . "\n";
1372
+ echo '<option value="900"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 900) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 15 mins )</option>' . "\n";
1373
+ echo '<option value="1800"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 1800) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 30 mins )</option>' . "\n";
1374
+ echo '<option value="3600"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 3600) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 1 hour )</option>' . "\n";
1375
+ echo '<option value="7200"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 7200) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 2 hours )</option>' . "\n";
1376
+ echo '<option value="14400"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 14400) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 4 hours )</option>' . "\n";
1377
+ echo '<option value="21600"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 21600) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 6 hours )</option>' . "\n";
1378
+ echo '<option value="28800"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 28800) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 8 hours )</option>' . "\n";
1379
+ echo '<option value="43200"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 43200) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 12 hours )</option>' . "\n";
1380
+ echo '<option value="86400"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 86400) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 24 hours )</option>' . "\n";
1381
+ echo '<option value="172800"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 172800) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 2 days )</option>' . "\n";
1382
+ echo '<option value="345600"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 345600) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 4 days )</option>' . "\n";
1383
+ echo '<option value="604800"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 604800) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 1 week )</option>' . "\n";
1384
+ echo '<option value="1209600"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 1209600) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 2 weeks )</option>' . "\n";
1385
+ echo '<option value="2629743"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 2629743) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 1 month )</option>' . "\n";
1386
+ echo '<option value="5259487"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 5259487) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 2 months )</option>' . "\n";
1387
+ echo '<option value="7889231"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 7889231) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 3 months )</option>' . "\n";
1388
+ echo '<option value="15778463"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 15778463) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 6 months )</option>' . "\n";
1389
+ echo '<option value="31556926"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"] == 31556926) ? ' selected="selected"' : '') . '>If limit is exceeded ( punish for 1 year )</option>' . "\n";
1390
  echo '</select><br />' . "\n";
1391
  echo 'When/if you change this, it will take X amount of time to update; based on your previous configuration.' . "\n";
1392
  echo '</td>' . "\n";
1443
  /**/
1444
  echo '<td>' . "\n";
1445
  echo '<select name="ws_plugin__s2member_force_admin_lockouts" id="ws-plugin--s2member-force-admin-lockouts">' . "\n";
1446
+ echo '<option value="0"' . ( (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"]) ? ' selected="selected"' : '') . '>No ( I want to leave all options available to my Members )</option>' . "\n";
1447
+ echo '<option value="1"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"]) ? ' selected="selected"' : '') . '>Yes ( redirect Members to their Login Welcome Page )</option>' . "\n";
1448
  echo '</select><br />' . "\n";
1449
  echo 'Recommended setting ( <code>Yes</code> ). The Stand-Alone version is better.<br />' . "\n";
1450
  echo 'You\'ll want to embed the Stand-Alone version into your Login Welcome Page.<br />' . "\n";
1486
  /**/
1487
  echo '<td>' . "\n";
1488
  echo '<select name="ws_plugin__s2member_run_deactivation_routines" id="ws-plugin--s2member-run-deactivation-routines">' . "\n";
1489
+ echo '<option value="1"' . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["run_deactivation_routines"]) ? ' selected="selected"' : '') . '></option>' . "\n";
1490
+ echo '<option value="0"' . ( (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["run_deactivation_routines"]) ? ' selected="selected"' : '') . '>Yes ( safeguard all data/options )</option>' . "\n";
1491
  echo '</select><br />' . "\n";
1492
  echo 'Recommended setting: ( <code>Yes, safeguard all data/options</code> )' . "\n";
1493
  echo '</td>' . "\n";
includes/menu-pages/scripting.inc.php CHANGED
@@ -177,6 +177,59 @@ if (apply_filters ("ws_plugin__s2member_during_scripting_page_during_left_sectio
177
  do_action ("ws_plugin__s2member_during_scripting_page_during_left_sections_after_api_advanced_way", get_defined_vars ());
178
  }
179
  /**/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  if (apply_filters ("ws_plugin__s2member_during_scripting_page_during_left_sections_display_custom_capabilities", true, get_defined_vars ()))
181
  {
182
  do_action ("ws_plugin__s2member_during_scripting_page_during_left_sections_before_custom_capabilities", get_defined_vars ());
177
  do_action ("ws_plugin__s2member_during_scripting_page_during_left_sections_after_api_advanced_way", get_defined_vars ());
178
  }
179
  /**/
180
+ if (apply_filters ("ws_plugin__s2member_during_scripting_page_during_left_sections_display_api_queries", true, get_defined_vars ()))
181
+ {
182
+ do_action ("ws_plugin__s2member_during_scripting_page_during_left_sections_before_api_queries", get_defined_vars ());
183
+ /**/
184
+ echo '<div class="ws-menu-page-group" title="Advanced Query Conditionals">' . "\n";
185
+ /**/
186
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-api-advanced-way-section">' . "\n";
187
+ echo '<h3>Advanced Query Conditionals ( some PHP scripting required )</h3>' . "\n";
188
+ echo '<p>s2Member provides several built-in API Functions that are tailored to meet the needs of developers integrating s2Member into their themes. Such as: <strong><code>is_protected_by_s2member($id, "[category,tag,post,page,singular,uri]")</code></strong>, <strong><code>is_permitted_by_s2member($id, "[category,tag,post,page,singular,uri]")</code></strong>, <strong><code>is_category_protected_by_s2member($cat_id)</code></strong>, <strong><code>is_category_permitted_by_s2member($cat_id)</code></strong>, <strong><code>is_tag_protected_by_s2member($tag_id [slug or tag name])</code></strong>, <strong><code>is_tag_permitted_by_s2member($tag_id [slug or tag name])</code></strong>, <strong><code>is_post_protected_by_s2member($post_id)</code></strong>, <strong><code>is_post_permitted_by_s2member($post_id)</code></strong>, <strong><code>is_page_protected_by_s2member($page_id)</code></strong>, <strong><code>is_page_permitted_by_s2member($page_id)</code></strong>, <strong><code>is_uri_protected_by_s2member($uri [or full url])</code></strong>, <strong><code>is_uri_permitted_by_s2member($uri [ or full url])</code></strong>.</p>' . "\n";
189
+ echo '<p>In addition, there are two special functions that can be applied by theme authors before making custom queries: <strong><code>attach_s2member_query_filters()</code></strong>, <strong><code>detach_s2member_query_filters()</code></strong>. These can be used before and after a call to <strong><code>query_posts()</code></strong> for example. s2Member will automatically filter all protected content ( not available to the current User/Member ).</p>' . "\n";
190
+ do_action ("ws_plugin__s2member_during_scripting_page_during_left_sections_during_api_queries", get_defined_vars ());
191
+ /**/
192
+ echo '<div class="ws-menu-page-hr"></div>' . "\n";
193
+ /**/
194
+ echo '<p><strong>Example #1:</strong> Pre-filtering custom queries in WordPress®.</strong></p>' . "\n";
195
+ echo '<p>' . ws_plugin__s2member_highlight_php (file_get_contents (dirname (__FILE__) . "/code-samples/custom-queries.php")) . '</p>' . "\n";
196
+ /**/
197
+ echo '<div class="ws-menu-page-hr"></div>' . "\n";
198
+ /**/
199
+ echo '<p><strong>Example #2:</strong> OR, instead of pre-filtering; check Access Restrictions in The Loop.</strong></p>' . "\n";
200
+ echo '<p>' . ws_plugin__s2member_highlight_php (file_get_contents (dirname (__FILE__) . "/code-samples/custom-queries-loop.php")) . '</p>' . "\n";
201
+ /**/
202
+ echo '<div class="ws-menu-page-hr"></div>' . "\n";
203
+ /**/
204
+ echo '<p><strong>Example #3:</strong> Checking Tag Restrictions.</strong></p>' . "\n";
205
+ echo '<p>' . ws_plugin__s2member_highlight_php (file_get_contents (dirname (__FILE__) . "/code-samples/specific-tag-restrictions.php")) . '</p>' . "\n";
206
+ /**/
207
+ echo '<div class="ws-menu-page-hr"></div>' . "\n";
208
+ /**/
209
+ echo '<p><strong>Example #4:</strong> Checking Category Restrictions.</strong></p>' . "\n";
210
+ echo '<p>' . ws_plugin__s2member_highlight_php (file_get_contents (dirname (__FILE__) . "/code-samples/specific-category-restrictions.php")) . '</p>' . "\n";
211
+ /**/
212
+ echo '<div class="ws-menu-page-hr"></div>' . "\n";
213
+ /**/
214
+ echo '<p><strong>Example #5:</strong> Checking Page Restrictions.</strong></p>' . "\n";
215
+ echo '<p>' . ws_plugin__s2member_highlight_php (file_get_contents (dirname (__FILE__) . "/code-samples/specific-page-restrictions.php")) . '</p>' . "\n";
216
+ /**/
217
+ echo '<div class="ws-menu-page-hr"></div>' . "\n";
218
+ /**/
219
+ echo '<p><strong>Example #6:</strong> Checking Post Restrictions, including Custom Post Types.</strong></p>' . "\n";
220
+ echo '<p>' . ws_plugin__s2member_highlight_php (file_get_contents (dirname (__FILE__) . "/code-samples/specific-post-restrictions.php")) . '</p>' . "\n";
221
+ /**/
222
+ echo '<div class="ws-menu-page-hr"></div>' . "\n";
223
+ /**/
224
+ echo '<p><strong>Additional examples:</strong> documentation on these function calls.</strong></p>' . "\n";
225
+ echo '<p>' . ws_plugin__s2member_highlight_php (file_get_contents (dirname (__FILE__) . "/code-samples/query-conditional-examples.php")) . '</p>' . "\n";
226
+ echo '</div>' . "\n";
227
+ /**/
228
+ echo '</div>' . "\n";
229
+ /**/
230
+ do_action ("ws_plugin__s2member_during_scripting_page_during_left_sections_after_api_queries", get_defined_vars ());
231
+ }
232
+ /**/
233
  if (apply_filters ("ws_plugin__s2member_during_scripting_page_during_left_sections_display_custom_capabilities", true, get_defined_vars ()))
234
  {
235
  do_action ("ws_plugin__s2member_during_scripting_page_during_left_sections_before_custom_capabilities", get_defined_vars ());
includes/syscon.inc.php CHANGED
@@ -81,6 +81,7 @@ function ws_plugin__s2member_configure_options_and_their_defaults ($options = FA
81
  "mms_registration_blogs_level3" => "25", /* A Customer on a Multisite Farm can create how many Blogs? */
82
  "mms_registration_blogs_level4" => "100", /* A Customer on a Multisite Farm can create how many Blogs? */
83
  "force_admin_lockouts" => "0", /* Redirects admin Pages/Profile to the Login Welcome Page. */
 
84
  /**/
85
  "login_welcome_page" => "", /* Defaults to the Home Page. */
86
  "login_redirection_override" => "", /* Alternate redirection location; instead of the Welcome Page. */
@@ -136,7 +137,8 @@ function ws_plugin__s2member_configure_options_and_their_defaults ($options = FA
136
  "cancellation_notification_urls" => "", /* A line-delimited list of Cancellation Notification URLs. */
137
  "eot_del_notification_urls" => "", /* A line-delimited list of EOT/Del Notification URLs. */
138
  "ref_rev_notification_urls" => "", /* A line-delimited list of Ref/Rev Notification URLs. */
139
- "sp_notification_urls" => "", /* A line-delimited list of Specific Post/Page Notification URLs. */
 
140
  /**/
141
  "signup_notification_recipients" => "", /* Signup Notification recipients. */
142
  "registration_notification_recipients" => "", /* Registration Notification recipients. */
@@ -144,7 +146,8 @@ function ws_plugin__s2member_configure_options_and_their_defaults ($options = FA
144
  "cancellation_notification_recipients" => "", /* Cancellation Notification recipients. */
145
  "eot_del_notification_recipients" => "", /* EOT/Del Notification recipients. */
146
  "ref_rev_notification_recipients" => "", /* Ref/Rev Notification recipients. */
147
- "sp_notification_recipients" => "", /* Specific Post/Page Notification recipients. */
 
148
  /**/
149
  "level0_label" => "Free", /* This is just an initial generic Level Label. */
150
  "level1_label" => "Bronze", /* This is just an initial generic Level Label. */
@@ -210,7 +213,17 @@ function ws_plugin__s2member_configure_options_and_their_defaults ($options = FA
210
  /*
211
  Here they are merged. User options will overwrite some or all default values.
212
  */
213
- $GLOBALS["WS_PLUGIN__"]["s2member"]["o"] = array_merge ($default_options, (($options !== false) ? (array)$options : (array)get_option ("ws_plugin__s2member_options")));
 
 
 
 
 
 
 
 
 
 
214
  /*
215
  Validate each option, possibly reverting back to the default value if invalid.
216
  Also check if options were passed in on some of these, in case empty values are to be allowed.
@@ -271,6 +284,9 @@ function ws_plugin__s2member_configure_options_and_their_defaults ($options = FA
271
  else if ($key === "force_admin_lockouts" && (!is_string ($value) || !is_numeric ($value)))
272
  $value = $default_options[$key];
273
  /**/
 
 
 
274
  else if ($key === "login_welcome_page" && (!is_string ($value) || !is_numeric ($value)))
275
  $value = $default_options[$key];
276
  /**/
@@ -355,10 +371,10 @@ function ws_plugin__s2member_configure_options_and_their_defaults ($options = FA
355
  else if (preg_match ("/^level[0-4]_aweber_list_ids$/", $key) && (!is_string ($value) || !strlen ($value = preg_replace ("/\s+/", "", $value))))
356
  $value = $default_options[$key];
357
  /**/
358
- else if (preg_match ("/^(signup|registration|payment|cancellation|eot_del|ref_rev|sp)_notification_urls$/", $key) && (!is_string ($value) || !strlen ($value)))
359
  $value = $default_options[$key];
360
  /**/
361
- else if (preg_match ("/^(signup|registration|payment|cancellation|eot_del|ref_rev|sp)_notification_recipients$/", $key) && (!is_string ($value) || !strlen ($value)))
362
  $value = $default_options[$key];
363
  /**/
364
  else if (preg_match ("/^level[0-4]_label$/", $key) && (!is_string ($value) || !strlen ($value)))
@@ -373,25 +389,25 @@ function ws_plugin__s2member_configure_options_and_their_defaults ($options = FA
373
  else if ($key === "file_download_limit_exceeded_page" && (!is_string ($value) || !is_numeric ($value)))
374
  $value = $default_options[$key];
375
  /**/
376
- else if ($key === "file_download_inline_extensions" && (!is_string ($value) || !($value = strtolower (preg_replace ("/\s+/", "", $value)))))
377
  $value = $default_options[$key];
378
  /**/
379
  else if (preg_match ("/^level[0-4]_ruris$/", $key) && (!is_string ($value) || !strlen ($value)))
380
  $value = $default_options[$key];
381
  /**/
382
- else if (preg_match ("/^level[0-4]_catgs$/", $key) && (!is_string ($value) || !($value = (($value === "all") ? $value : trim (preg_replace ("/[^0-9,]/", "", $value), ",")))))
383
  $value = $default_options[$key];
384
  /**/
385
- else if (preg_match ("/^level[0-4]_ptags$/", $key) && (!is_string ($value) || !($value = (($value === "all") ? $value : strtolower (preg_replace ("/( +)/", " ", trim (preg_replace ("/( *),( *)/", ",", $value))))))))
386
  $value = $default_options[$key];
387
  /**/
388
- else if (preg_match ("/^level[0-4]_posts$/", $key) && (!is_string ($value) || !($value = (($value === "all") ? $value : trim (preg_replace ("/[^0-9,]/", "", $value), ",")))))
389
  $value = $default_options[$key];
390
  /**/
391
- else if (preg_match ("/^level[0-4]_pages$/", $key) && (!is_string ($value) || !($value = (($value === "all") ? $value : trim (preg_replace ("/[^0-9,]/", "", $value), ",")))))
392
  $value = $default_options[$key];
393
  /**/
394
- else if ($key === "specific_ids" && (!is_string ($value) || !($value = trim (preg_replace ("/[^0-9,]/", "", $value), ","))))
395
  $value = $default_options[$key];
396
  /**/
397
  else if ($key === "triggers_immediate_eot" && (!is_string ($value) || !preg_match ("/^(none|refunds|reversals|refunds,reversals)$/", $value)))
81
  "mms_registration_blogs_level3" => "25", /* A Customer on a Multisite Farm can create how many Blogs? */
82
  "mms_registration_blogs_level4" => "100", /* A Customer on a Multisite Farm can create how many Blogs? */
83
  "force_admin_lockouts" => "0", /* Redirects admin Pages/Profile to the Login Welcome Page. */
84
+ "filter_wp_query" => "none", /* Off by default (none|searches|feeds|searches,feeds|all). */
85
  /**/
86
  "login_welcome_page" => "", /* Defaults to the Home Page. */
87
  "login_redirection_override" => "", /* Alternate redirection location; instead of the Welcome Page. */
137
  "cancellation_notification_urls" => "", /* A line-delimited list of Cancellation Notification URLs. */
138
  "eot_del_notification_urls" => "", /* A line-delimited list of EOT/Del Notification URLs. */
139
  "ref_rev_notification_urls" => "", /* A line-delimited list of Ref/Rev Notification URLs. */
140
+ "sp_sale_notification_urls" => "", /* A line-delimited list of Specific Post/Page Notification URLs. */
141
+ "sp_ref_rev_notification_urls" => "", /* A line-delimited list of Specific Post/Page Notification URLs. */
142
  /**/
143
  "signup_notification_recipients" => "", /* Signup Notification recipients. */
144
  "registration_notification_recipients" => "", /* Registration Notification recipients. */
146
  "cancellation_notification_recipients" => "", /* Cancellation Notification recipients. */
147
  "eot_del_notification_recipients" => "", /* EOT/Del Notification recipients. */
148
  "ref_rev_notification_recipients" => "", /* Ref/Rev Notification recipients. */
149
+ "sp_sale_notification_recipients" => "", /* Specific Post/Page Notification recipients. */
150
+ "sp_ref_rev_notification_recipients" => "", /* Specific Post/Page Notification recipients. */
151
  /**/
152
  "level0_label" => "Free", /* This is just an initial generic Level Label. */
153
  "level1_label" => "Bronze", /* This is just an initial generic Level Label. */
213
  /*
214
  Here they are merged. User options will overwrite some or all default values.
215
  */
216
+ $GLOBALS["WS_PLUGIN__"]["s2member"]["o"] = array_merge ($default_options, ( ($options !== false) ? (array)$options : (array)get_option ("ws_plugin__s2member_options")));
217
+ /*
218
+ Backward compatibility for "sp_notification_urls", which was renamed in v3.2.3 to "sp_sale_notification_urls".
219
+ */
220
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_notification_urls"] && !$options["sp_sale_notification_urls"])
221
+ $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_urls"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_notification_urls"];
222
+ /*
223
+ Backward compatibility for "sp_notification_recipients", which was renamed in v3.2.3 to "sp_sale_notification_recipients".
224
+ */
225
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_notification_recipients"] && !$options["sp_sale_notification_recipients"])
226
+ $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_recipients"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_notification_recipients"];
227
  /*
228
  Validate each option, possibly reverting back to the default value if invalid.
229
  Also check if options were passed in on some of these, in case empty values are to be allowed.
284
  else if ($key === "force_admin_lockouts" && (!is_string ($value) || !is_numeric ($value)))
285
  $value = $default_options[$key];
286
  /**/
287
+ else if ($key === "filter_wp_query" && (!is_string ($value) || !preg_match ("/^(none|searches|feeds|searches,feeds|all)$/", $value)))
288
+ $value = $default_options[$key];
289
+ /**/
290
  else if ($key === "login_welcome_page" && (!is_string ($value) || !is_numeric ($value)))
291
  $value = $default_options[$key];
292
  /**/
371
  else if (preg_match ("/^level[0-4]_aweber_list_ids$/", $key) && (!is_string ($value) || !strlen ($value = preg_replace ("/\s+/", "", $value))))
372
  $value = $default_options[$key];
373
  /**/
374
+ else if (preg_match ("/^(signup|registration|payment|cancellation|eot_del|ref_rev|sp_sale|sp_ref_rev)_notification_urls$/", $key) && (!is_string ($value) || !strlen ($value)))
375
  $value = $default_options[$key];
376
  /**/
377
+ else if (preg_match ("/^(signup|registration|payment|cancellation|eot_del|ref_rev|sp_sale|sp_ref_rev)_notification_recipients$/", $key) && (!is_string ($value) || !strlen ($value)))
378
  $value = $default_options[$key];
379
  /**/
380
  else if (preg_match ("/^level[0-4]_label$/", $key) && (!is_string ($value) || !strlen ($value)))
389
  else if ($key === "file_download_limit_exceeded_page" && (!is_string ($value) || !is_numeric ($value)))
390
  $value = $default_options[$key];
391
  /**/
392
+ else if ($key === "file_download_inline_extensions" && (!is_string ($value) || ! ($value = strtolower (preg_replace ("/\s+/", "", $value)))))
393
  $value = $default_options[$key];
394
  /**/
395
  else if (preg_match ("/^level[0-4]_ruris$/", $key) && (!is_string ($value) || !strlen ($value)))
396
  $value = $default_options[$key];
397
  /**/
398
+ else if (preg_match ("/^level[0-4]_catgs$/", $key) && (!is_string ($value) || ! ($value = ( ($value === "all") ? $value : trim (preg_replace ("/[^0-9,]/", "", $value), ",")))))
399
  $value = $default_options[$key];
400
  /**/
401
+ else if (preg_match ("/^level[0-4]_ptags$/", $key) && (!is_string ($value) || ! ($value = ( ($value === "all") ? $value : trim (preg_replace ("/( +)/", " ", trim (preg_replace ("/( *),( *)/", ",", $value))), ",")))))
402
  $value = $default_options[$key];
403
  /**/
404
+ else if (preg_match ("/^level[0-4]_posts$/", $key) && (!is_string ($value) || ! ($value = ( ($value === "all") ? $value : trim (preg_replace ("/[^0-9,]/", "", $value), ",")))))
405
  $value = $default_options[$key];
406
  /**/
407
+ else if (preg_match ("/^level[0-4]_pages$/", $key) && (!is_string ($value) || ! ($value = ( ($value === "all") ? $value : trim (preg_replace ("/[^0-9,]/", "", $value), ",")))))
408
  $value = $default_options[$key];
409
  /**/
410
+ else if ($key === "specific_ids" && (!is_string ($value) || ! ($value = trim (preg_replace ("/[^0-9,]/", "", $value), ","))))
411
  $value = $default_options[$key];
412
  /**/
413
  else if ($key === "triggers_immediate_eot" && (!is_string ($value) || !preg_match ("/^(none|refunds|reversals|refunds,reversals)$/", $value)))
includes/templates/shortcodes/paypal-checkout-button-shortcode.html CHANGED
@@ -1 +1 @@
1
- [s2Member-PayPal-Button level="%%level%%" ccaps="" desc="%%level_label%% description and pricing details here." ps="paypal" cc="USD" custom="%%domain%%" tp="0" tt="D" ra="0.01" rp="1" rt="M" rr="1" image="default" /]
1
+ [s2Member-PayPal-Button level="%%level%%" ccaps="" desc="%%level_label%% description and pricing details here." ps="paypal" cc="USD" ns="1" custom="%%domain%%" tp="0" tt="D" ra="0.01" rp="1" rt="M" rr="1" image="default" /]
includes/templates/shortcodes/paypal-sp-checkout-button-shortcode.html CHANGED
@@ -1 +1 @@
1
- [s2Member-PayPal-Button ids="0" exp="72" desc="Description and pricing details here." ps="paypal" cc="USD" custom="%%domain%%" ra="0.01" sp="1" image="default" /]
1
+ [s2Member-PayPal-Button ids="0" exp="72" desc="Description and pricing details here." ps="paypal" cc="USD" ns="1" custom="%%domain%%" ra="0.01" sp="1" image="default" /]
ms.txt CHANGED
@@ -2,6 +2,6 @@
2
  Yes. s2Member v3.2+, and also s2Member Pro, are BOTH compatible with Multisite Networking enabled. After you enable Multisite Networking, install the s2Member plugin. Then navigate to `s2Member -> Multisite ( Config )` in the Dashboard on your ( Main Site ). You can get started now, by turning on [Multisite Networking](http://codex.wordpress.org/Create_A_Network) inside your installation of WordPress®.
3
 
4
  = What about Multisite Networking ( WPMU ), used on a Blog Farm? =
5
- Yes, preliminary ( experimental ) support for Multisite Blog Farms has also been implemented. If you're running a Multisite Blog Farm ( i.e. you offer Blogs ), please contact s2Member.com for further details. With Multisite Networking enabled, your site could ALSO offer a Customer access to create a Blog of their own, where a Customer becomes a "Member" of your ( Main Site ), and also a Blog Owner/Administrator. With s2Member installed ( network wide ), each of your Blog Owners could offer Membership too, using a single installation of the s2Member plugin ( which is a great selling point! ). We refer to this as a Multisite Blog Farm.
6
 
7
  You can get started now, by turning on [Multisite Networking](http://codex.wordpress.org/Create_A_Network) inside your installation of WordPress®. Then, install the s2Member plugin ( network wide ). In the Dashboard for your Main Site, see: `s2Member -> Multisite ( Config )`. Before you go live, please contact [s2Member.com](http://www.s2member.com/contact/) for full documentation on Multisite Blog Farms. There is some additional functionality that can be enabled for security on a Blog Farm installation; and also some menus/documentation/functionality that can be disabled. NOTE ~ You will be asked to make a donation, or to purchase a Support Package for s2Member.
2
  Yes. s2Member v3.2+, and also s2Member Pro, are BOTH compatible with Multisite Networking enabled. After you enable Multisite Networking, install the s2Member plugin. Then navigate to `s2Member -> Multisite ( Config )` in the Dashboard on your ( Main Site ). You can get started now, by turning on [Multisite Networking](http://codex.wordpress.org/Create_A_Network) inside your installation of WordPress®.
3
 
4
  = What about Multisite Networking ( WPMU ), used on a Blog Farm? =
5
+ Yes, preliminary ( experimental ) support for Multisite Blog Farms has also been implemented. If you're running a Multisite Blog Farm ( i.e. you offer Blogs ), please contact s2Member.com for further details. With Multisite Networking enabled, your site could ALSO offer a Customer access to create a Blog of their own, where a Customer becomes a "Member" of your ( Main Site ), and also a Blog Owner/Administrator. With s2Member installed ( network wide ), each of your Blog Owners could offer Membership too, using a single installation of the s2Member plugin ( which is a great selling point ). We refer to this as a Multisite Blog Farm.
6
 
7
  You can get started now, by turning on [Multisite Networking](http://codex.wordpress.org/Create_A_Network) inside your installation of WordPress®. Then, install the s2Member plugin ( network wide ). In the Dashboard for your Main Site, see: `s2Member -> Multisite ( Config )`. Before you go live, please contact [s2Member.com](http://www.s2member.com/contact/) for full documentation on Multisite Blog Farms. There is some additional functionality that can be enabled for security on a Blog Farm installation; and also some menus/documentation/functionality that can be disabled. NOTE ~ You will be asked to make a donation, or to purchase a Support Package for s2Member.
readme.txt CHANGED
@@ -1,7 +1,7 @@
1
  === s2Member ( Membership w/ PayPal® Integration ) ~ now Multisite compatible! ===
2
 
3
- Version: 3.2.2
4
- Stable tag: 3.2.2
5
  Framework: WS-P-3.0
6
 
7
  SSL Compatible: yes
@@ -47,9 +47,9 @@ This depends on your hosting provider and/or server configuration. Some web host
47
  Yes. s2Member v3.2+, and also s2Member Pro, are BOTH compatible with Multisite Networking enabled. After you enable Multisite Networking, install the s2Member plugin. Then navigate to `s2Member -> Multisite ( Config )` in the Dashboard on your ( Main Site ).
48
 
49
  = What about Multisite Networking ( WPMU ), used on a Blog Farm? =
50
- Yes, preliminary ( experimental ) support for Multisite Blog Farms has also been implemented. If you're running a Multisite Blog Farm ( i.e. you offer Blogs ), please contact s2Member.com for further details. With Multisite Networking enabled, your site could ALSO offer a Customer access to create a Blog of their own, where a Customer becomes a "Member" of your ( Main Site ), and also a Blog Owner/Administrator. With s2Member installed ( network wide ), each of your Blog Owners could offer Membership too, using a single installation of the s2Member plugin ( which is a great selling point! ). We refer to this as a Multisite Blog Farm.
51
 
52
- You can get started now, by turning on [Multisite Networking](http://codex.wordpress.org/Create_A_Network) inside your installation of WordPress®. Then, install the s2Member plugin ( network wide ). In the Dashboard for your Main Site, see: `s2Member -> Multisite ( Config )`. Before you go live, please contact [s2Member.com](http://www.s2member.com/contact/) for full documentation on Multisite Blog Farms. There is some additional functionality that can be enabled for security on a Blog Farm installation; and also some menus/documentation/functionality that can be disabled. NOTE ~ You will be asked to make a donation, or to purchase a Support Package for s2Member.
53
 
54
  == Upgrading To The Latest Version ==
55
 
@@ -170,6 +170,20 @@ Not yet. This is coming soon though. It will be included in a future release of
170
 
171
  == Changelog ==
172
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  = 3.2.2 =
174
  * Simple Conditionals ( completely re-written ). Simple Conditionals, first introduced in s2Member v3.2.1; have been completely re-written to support a wider range of features. The **new Shortcode** is `s2If`. The older Shortcodes have now been deprecated: `s2All, s2Any` ( do NOT use ). The older Shortcodes will continue to work with backward compatiblity, but they'll be removed in a future release of s2Member. Please update any existing Shortcodes referencing `s2All,s2Any` ( do NOT use ), by switching them all over to `s2If` instead. We apologize for the drastic changes to this new feature; but it was a necessary step forward. The initial release of Simple Conditionals was very buggy, and NOT as extensible as the new `s2If` logic is now. If you've been using Simple Conditionals, you will need to re-review all documentation and code samples. The new `s2If` Shortcode is fully documented, inside your WordPress® Dashboard under: `s2Member -> API Scripting -> Simple Conditionals`.
175
  * Starting with s2Member v3.2.3, "Simple Conditionals" are now available to you from within WordPress®, using Shortcodes that are fully compatible with both the Visual Editor, and also the HTML Tab in WordPress®. We've been through all of the documentation for s2Member, and updated (again) ALL code samples to provide you with Shortcode equivalents. You can learn more about this new feature in your WP Dashboard, under: `s2Member -> API Scripting -> Simple Conditionals`. Simple Conditionals are a NEW feature, and they'll have no affect on Advanced Conditionals; which have always been available for s2Member.
1
  === s2Member ( Membership w/ PayPal® Integration ) ~ now Multisite compatible! ===
2
 
3
+ Version: 3.2.3
4
+ Stable tag: 3.2.3
5
  Framework: WS-P-3.0
6
 
7
  SSL Compatible: yes
47
  Yes. s2Member v3.2+, and also s2Member Pro, are BOTH compatible with Multisite Networking enabled. After you enable Multisite Networking, install the s2Member plugin. Then navigate to `s2Member -> Multisite ( Config )` in the Dashboard on your ( Main Site ).
48
 
49
  = What about Multisite Networking ( WPMU ), used on a Blog Farm? =
50
+ Yes, preliminary ( experimental ) support for Multisite Blog Farms has also been implemented. If you're running a Multisite Blog Farm ( i.e. you offer Blogs ), please contact s2Member.com for further details. With Multisite Networking enabled, your site could ALSO offer a Customer access to create a Blog of their own, where a Customer becomes a "Member" of your ( Main Site ), and also a Blog Owner/Administrator. With s2Member installed ( network wide ), each of your Blog Owners could offer Membership too, using a single installation of the s2Member plugin ( which is a great selling point ). We refer to this as a Multisite Blog Farm.
51
 
52
+ You can get started now, by turning on [Multisite Networking](http://codex.wordpress.org/Create_A_Network) inside your installation of WordPress®. Then, install the s2Member plugin ( network wide ). In the Dashboard for your Main Site, see: `s2Member -> Multisite ( Config )`. Before you go live, please contact [s2Member.com](http://www.s2member.com/contact/) for full documentation on Multisite Blog Farms. There is some additional functionality that can be enabled for security on a Blog Farm installation; and also some menus/documentation/functionality that can be disabled.
53
 
54
  == Upgrading To The Latest Version ==
55
 
170
 
171
  == Changelog ==
172
 
173
+ = 3.2.3 =
174
+ * New Feature - "Alternative View Protection". Check your Dashboard: `s2Member -> General Options -> Alternative View Protection`. This new feature deals with some long awaited (protection) for things like: search results, RSS/XML feeds, and custom queries; where excerpts of protected content may slip through, depending on your theme. This feature is NEW, and still in an experimental state. It is disabled by default, but we encourage you to try it with different settings, and report back to us through the support forums for s2Member.
175
+ * New Feature - "Query Conditionals" for developers. Check your Dashboard: `s2Member -> API Scripting -> Query Conditionals`. s2Member now provides several built-in API Functions that are tailored to meet the needs of developers integrating s2Member into their themes. Such as: `is_category_protected_by_s2member($cat_id)`, `is_category_permitted_by_s2member($cat_id)`, `is_tag_protected_by_s2member($tag_id [slug or tag name])`, `is_tag_permitted_by_s2member($tag_id [slug or tag name])`, `is_post_protected_by_s2member($post_id)`, `is_post_permitted_by_s2member($post_id)`, `is_page_protected_by_s2member($page_id)`, `is_page_permitted_by_s2member($page_id)`, `is_uri_protected_by_s2member($uri [or full url])`, `is_uri_permitted_by_s2member($uri [ or full url])`. In addition, there are two special functions that can be applied by theme authors before making custom queries: `attach_s2member_query_filters()`, `detach_s2member_query_filters()`. These can be used before and after a call to `query_posts()` for example. s2Member will automatically filter all protected content ( not available to the current User/Member ). Further details on these functions is available under the `API Scripting` section in your Dashboard. You can also have a look at this file: `/s2member/includes/functions/api-functions.inc.php`.
176
+ * Compatiblity. s2Member is now compatible with the [Page Tagger](http://wordpress.org/extend/plugins/page-tagger/) plugin for WordPress®. Installing this plugin will allow you to protect Pages with Tags ( optional ). s2Member is also compatible with HeadSpace2 SEO, which can also enable Tags for Pages.
177
+ * Bug fix. A bug was found in s2Member's handling of PayPal® EOT responses. This bug was affecting site owners with newer PayPal® accounts ( i.e. their Subscription IDs start with `I-` ). These newer PayPal® accounts trigger `subscr_eot` events upon last payment, instead of when time has actually expired. s2Member v3.2.3 has been updated to correct its handling of `subscr_eot` events in this scenario. An obvious symptom of this bug, was to sell a non-recurring Subscription, and have that Subscription EOT on the very same day as the first payment ( which was also the last payment ), because it was non-recurring. This has been resolved in s2Member v3.2.3+.
178
+ * New API Notification. s2Member v3.2.3 includes a new API Notification that can provide details about Refund/Reversal events, which are related to transactions for "Specific Post/Page Access". s2Member has always provided Refund/Reversal Notifications, but NOT for Specific Post/Page Access. There are now two API Notifications for Specific Post/Page Access. One for initial Sales, and another for Refunds/Reversals ( i.e. chargebacks ).
179
+ * Replacement Codes. s2Member v3.2.3 adds two additional Replacement Codes to the API Notification for cancellations. These two additional Replacement Codes are: `%%item_number%%`, and `%%item_name%%`. See: `s2Member -> API Notifications -> Cancellations` for further details.
180
+ * Optimization. Some of s2Member's larger routines have been moved into the `/functions/separates/` directory, and they're now loaded "as needed", as opposed to being loaded by default. This will further optimize sites powered by s2Member. In addition, ( FYI for developers ) there are plans to implement `SPL Autoload` into a future release of s2Member, through classes assigned to various parts of the s2Member software package.
181
+ * Improvement. s2Member's Meta Box panels in the Post/Page editing stations are now designed to disable themselves automatically on special Pages that are handled automatically by s2Member; ( i.e. the Membership Options Page, Login Welcome Page, Download Limit Exceeded Page ). s2Member also provides site owners with a clearer picture of how it handles these special Pages through the Meta Box panel.
182
+ * General Maintenance. These two files `paypal-notify.inc.php`, and `paypal-return.inc.php` have BOTH been through another round of testing. Log file analysis ( with the help of other site owners ) indicated there were a few tweaks needed here and there. Minor changes were performed to improve compatibility for both PayPal® Standard and PayPal® Pro IPN handling ( across both old and new PayPal® accounts ). Things like `product_name` vs. `item_name` vs. `item_name1`; and `item_number` vs. `item_number1`, vs. `rp_invoice_id` parsing.
183
+ * New Shortcode Attribute. s2Member now accepts another PayPal® Button Shortcode attribute ( `ns="1"` ) is s2Member's default setting. This controls the `no_shipping` variable in your PayPal® Button. `0` – to prompt for a shipping address, but NOT require one ( enables shipping details via IPN ). `1` – to NEVER prompt for a shipping address. `2` – to prompt for a shipping address, AND require one ( enables shipping details via IPN ).
184
+ * Coming soon. Improvements to s2Member's support for Custom Fields did NOT make it into the official release of s2Member v3.2.3. Further beta testing is required. Support for selects, radios, checkboxes, and other improvements will come in s2Member v3.2.5.
185
+ * Additional changes in "s2Member Pro" have been [recorded here](http://www.s2member.com/).
186
+
187
  = 3.2.2 =
188
  * Simple Conditionals ( completely re-written ). Simple Conditionals, first introduced in s2Member v3.2.1; have been completely re-written to support a wider range of features. The **new Shortcode** is `s2If`. The older Shortcodes have now been deprecated: `s2All, s2Any` ( do NOT use ). The older Shortcodes will continue to work with backward compatiblity, but they'll be removed in a future release of s2Member. Please update any existing Shortcodes referencing `s2All,s2Any` ( do NOT use ), by switching them all over to `s2If` instead. We apologize for the drastic changes to this new feature; but it was a necessary step forward. The initial release of Simple Conditionals was very buggy, and NOT as extensible as the new `s2If` logic is now. If you've been using Simple Conditionals, you will need to re-review all documentation and code samples. The new `s2If` Shortcode is fully documented, inside your WordPress® Dashboard under: `s2Member -> API Scripting -> Simple Conditionals`.
189
  * Starting with s2Member v3.2.3, "Simple Conditionals" are now available to you from within WordPress®, using Shortcodes that are fully compatible with both the Visual Editor, and also the HTML Tab in WordPress®. We've been through all of the documentation for s2Member, and updated (again) ALL code samples to provide you with Shortcode equivalents. You can learn more about this new feature in your WP Dashboard, under: `s2Member -> API Scripting -> Simple Conditionals`. Simple Conditionals are a NEW feature, and they'll have no affect on Advanced Conditionals; which have always been available for s2Member.
s2member.php CHANGED
@@ -9,8 +9,8 @@ along with this software. In the main directory, see: /licensing/
9
  If not, see: <http://www.gnu.org/licenses/>.
10
  */
11
  /*
12
- Version: 3.2.2
13
- Stable tag: 3.2.2
14
  Framework: WS-P-3.0
15
 
16
  SSL Compatible: yes
@@ -48,10 +48,10 @@ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
48
  /*
49
  Define versions.
50
  */
51
- define ("WS_PLUGIN__S2MEMBER_VERSION", "3.2.2");
52
  define ("WS_PLUGIN__S2MEMBER_MIN_PHP_VERSION", "5.2");
53
  define ("WS_PLUGIN__S2MEMBER_MIN_WP_VERSION", "3.0");
54
- define ("WS_PLUGIN__S2MEMBER_MIN_PRO_VERSION", "1.2.1");
55
  /*
56
  Compatibility checks.
57
  */
9
  If not, see: <http://www.gnu.org/licenses/>.
10
  */
11
  /*
12
+ Version: 3.2.3
13
+ Stable tag: 3.2.3
14
  Framework: WS-P-3.0
15
 
16
  SSL Compatible: yes
48
  /*
49
  Define versions.
50
  */
51
+ define ("WS_PLUGIN__S2MEMBER_VERSION", "3.2.3");
52
  define ("WS_PLUGIN__S2MEMBER_MIN_PHP_VERSION", "5.2");
53
  define ("WS_PLUGIN__S2MEMBER_MIN_WP_VERSION", "3.0");
54
+ define ("WS_PLUGIN__S2MEMBER_MIN_PRO_VERSION", "1.2.3");
55
  /*
56
  Compatibility checks.
57
  */