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

Version Description

  • New Feature. s2Member now provides a small panel ( aka: meta box ) inside your Post/Page editing stations. This new panel makes it possible for you to restrict access to a Post/Page, or even a Custom Post Type ( on-the-fly ) without having to go back to your General Options panel all the time. Starting with s2Member v3.2+, you can also tell s2Member to require Custom Capabilities on a per Post/Page basis. So now, s2Member ( if you prefer ) can handle Custom Capabilities for you! Whenever you edit a Post/Page, you can tell s2Member to require certain Custom Capabilities that you type in, using comma delimited format. In other words, you will need to type in some of the trigger words that you used whenever you created your PayPal Pro Forms and/or Standard PayPal Buttons. This way your Members will have the proper Capabilities to view different kinds of content that you offer. All of this is optional.
  • Compatibility. s2Member, and also the s2Member Pro Module; have both been tested under WordPress 3.0.1. Everything looks good - no conflicts.
  • Multisite Networking. s2Member, and also the s2Member Pro Module; are now compatible with WordPress 3.0+ Multisite Networking, formerly known as WPMU. In addition, 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.
  • A new panel is made available under s2Member -> Multisite ( Config ), whenever Multisite Networking is enabled. This is where a Super Administrator ( operating on the Main Site ) can decide to offer Membership only, or Membership with Blog creation as well. In other words, 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 Customers 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.
  • Bug fix. The s2Member Framework has been updated to fully support installations of WordPress that have two different URLs configured in their WP Settings -> General section. This bug was related to bloginfo("url") vs. bloginfo("wpurl"). In previous versions of s2Member, a major symptom of this bug was an unexpected redirection to the Home Page after checkout, instead of a formal response to the Customer. This bug was only affecting installations of WordPress that were using a different Site Address URL, inside their Settings -> General panel. This has been resolved in s2Member v3.2+.
  • Bug fix. An issue related to protected File Downloads, where a site owner was using sub-directories to guard specific files from specific Levels, was sometimes resulting in an invalid redirection to the Membership Options Page, with a query string indicating 21, ( i.e. s2member_level_req=21 ). This bug has been corrected in s2Member v3.2+.
  • Videos. Over six hours of detailed Video Tutorials are now available for s2Member. Additional videos will be released over the coming days and weeks ahead; covering more advanced topics, marketing tips, and an in-depth look at the s2Member Pro Module, plus Multisite Networking; which is also evolving rapidly.
  • API Behavior. s2Member's API Notification for EOT/Deletions, has been changed slightly. In previous versions, the EOT/Deletion notification was only processed for a ( paid ) Member, who reached the end of their term, OR ... if a ( paid ) Member was manually deleted by an Administrator through the Dashboard. Starting with s2Member v3.2+, an EOT/Deletion Notification will be processed, EVEN if the account is NOT currently associated with a ( paid ) Member. In other words, starting with s2Member v3.2, if you delete an account manually ( through your WP Dashboard ) this will ALWAYS trigger s2Member's EOT/Deletion Notification; no matter what. For further details, check your Dashboard: s2Member -> API Notifications -> EOT/Deletion.
  • Bug fix. Login message filter ( login_messages ) applied to registrations with a custom password entered during the registration process. Registration complete. Please log in. This Hook/Filter was renamed to just ( login_message ) with the release of WordPress 3.0.1. Very minor issue, but this has been corrected with s2Member v3.2+ - in support of WordPress 3.0.1+.
  • Feature. Custom Registration Fields for s2Member, now support an Un-editable Mode ( in other words, if you want specific fields to be un-editable after registration ), you can wrap those Custom Fields inside ^carets^. In your WP Dashboard, see: s2Member -> General Options -> Custom Fields for additional documentation and examples.
  • Profile Editing Panel. The Stand-Alone Profile Modification Page ( provided by s2Member ); now includes a password confirmation field ( in other words, a NEW password must be typed in twice as a confirmation ).
  • BuddyPress/MailChimp. The first/last name fields were NOT being populated into the MailChimp integration with BuddyPress installed. This has been resolved with s2Member v3.2+.
  • Logging routines. s2Member's logging routines have been updated to support Multisite Networking. When Multisite Networking is enabled, s2Member will keep separate log files for each domain/path.
  • Validation. The JavaScript validation routine for the wp-login.php file, now includes the Username/Email Address to help Customers avoid confusion.
  • Feature. Integration of Custom Fields into the Users -> Add New panel. An account can now be created manually, with all details included initially. As opposed to the old way, where you had to go back and Edit the account manually, after the initial creation.
  • Feature. s2Member now exposes its s2member_custom field inside the admin panel. You can go to your Dashboard -> Users panel, and click Edit next to a Member. The Custom String is now editable. You're NOT likely to need this, but s2Member makes it editable anyway. Possibly for advanced usage by a developer.
  • Feature. Integration of Custom Fields into /wp-signup.php has been completed. This is only for Multisite Networking; where s2Member is being used in a Blog Farm environment.
  • PayPal. In the admin panel, a few subtle references to "PayPal" have been changed to just "Paid"; leaving room for additional gateway integration possibilities that are coming soon.
  • Feature. In the admin panel, there is now a shortcut link inside the s2Member menu panel; which leads a Site Administrator to Add A Member using manual entry.
  • Compatibility. On a Multisite Network; s2Member is NOT compatible with configurations that use a different Dashboard Blog; other than the Main Site. This is NOT a good idea to try this with s2Member; it opens the door for all sorts of issues. s2Member now forces your Dashboard Blog to the Main Site for sanity/compatibility/security.
  • Compatibility. Added support for this Conditional Tag current_user_can_for_blog( $blog_id, $capability ) in support of Multisite Networking integration. As well as $user->for_blog( $blog_id ).
  • Compatibility. Updated function calls with usermeta to user_option; including get_user_option(), update_user_option(), delete_user_option(). The usermeta functions were deprecated as of WP 3.0. The new get_user_option() function is also Multisite compatible. If you're a developer, you can take a look at s2Member's source code for examples. Or read this article.
  • Important Database Change. In previous versions of s2Member, data about each Member was stored inside the wp_usermeta table automatically; and it STILL is. However, the meta_key names are now prefixed with $wpdb->prefix, which on most installations of WordPress this translates to wp_ ( e.g. wp_s2member_subscr_id, wp_s2member_custom, etc, etc. ). s2Member will automatically update your database tables upon re-activation. However, if you're a developer, and you've been using get_usermeta($user_id, "s2member_subscr_id"), you should now use get_user_option("s2member_subscr_id", $user_id) instead. No need to specify the wp_ prefix in that function, it's handled internally by WordPress through the get_user_option() call. For more information, please read this article.
  • Bug fix. s2Member's PayPal IPN processor was logging Skipping Auto-EOT for now ..., with Refund/reversal IPNs; when a particular Member already had an EOT-Time set. This was NOT the intended behavior in this scenario. In this release, s2Member has been updated to ignore existing Auto-EOT Times under this one special circumstance ( Refund/Reversal ). A Refund/Reversal will ALWAYS trigger an immediate EOT now.
  • IPN Proxy Keys. s2Member's implementation of the optional Proxy Key for simulated IPN responses, has been updated to support Multisite Networking; through a new PayPal utility function ws_plugin__s2member_paypal_proxy_key_gen (). For further details, check your Dashboard under s2Member -> PayPal Options -> IPN Integration -> Proxy Key.
  • UI Improvement. The tabindex property for [?] icons in the admin panel have been set to tabindex="-1" to prevent an annoyance.
  • Compatibility. On a Windows server, the cURL extension is usually NOT compatible with SSL communications. s2Member now signals to the WP_Http class, that it should temporarily disable the cURL transport when a remote URL is being processed with an https:// prefix. This allows the WP_Http class to recover gracefully (automatically) and fall back on the FOPEN method. If you're running WordPress on a Windows server, you should make sure that you have this inside your php.ini file. ( `allow_url_fopen
Download this release

Release Info

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

Code changes from version 3.1.5 to 3.2

Files changed (65) hide show
  1. images/brand-favicon.fla +0 -0
  2. images/brand-favicon.png +0 -0
  3. images/large-icon.fla +0 -0
  4. images/large-icon.png +0 -0
  5. includes/dropins/bridges/_s2member-bbpress-bridge.php +8 -8
  6. includes/functions/activate-deactivate.inc.php +61 -28
  7. includes/functions/auto-eots.inc.php +36 -21
  8. includes/functions/constants.inc.php +82 -125
  9. includes/functions/css-js-w-globals.inc.php +19 -21
  10. includes/functions/email-configs.inc.php +1 -1
  11. includes/functions/file-download-access.inc.php +34 -38
  12. includes/functions/force-ssl.inc.php +1 -1
  13. includes/functions/hide-some-systematics.inc.php +3 -3
  14. includes/functions/is-systematic.inc.php +2 -2
  15. includes/functions/list-servers.inc.php +1 -1
  16. includes/functions/login-customizations.inc.php +5 -4
  17. includes/functions/login-redirection.inc.php +12 -1
  18. includes/functions/menu-pages.inc.php +136 -32
  19. includes/functions/meta-boxes.inc.php +233 -0
  20. includes/functions/ms-meta-caps.inc.php +60 -0
  21. includes/functions/nocache.inc.php +3 -3
  22. includes/functions/page-level-access.inc.php +8 -0
  23. includes/functions/paypal-button.inc.php +4 -4
  24. includes/functions/paypal-notify.inc.php +136 -110
  25. includes/functions/paypal-return.inc.php +55 -27
  26. includes/functions/paypal-utilities.inc.php +46 -30
  27. includes/functions/post-level-access.inc.php +9 -1
  28. includes/functions/profile-modifications.inc.php +30 -14
  29. includes/functions/readme-parsing.inc.php +90 -28
  30. includes/functions/register-access.inc.php +930 -113
  31. includes/functions/sp-access.inc.php +2 -2
  32. includes/functions/tracking-codes.inc.php +4 -4
  33. includes/functions/translations.inc.php +38 -3
  34. includes/functions/user-access-level.inc.php +1 -1
  35. includes/functions/user-deletions.inc.php +76 -18
  36. includes/functions/user-has-wp-role.inc.php +0 -44
  37. includes/functions/user-notes.inc.php +4 -4
  38. includes/functions/users-list.inc.php +342 -144
  39. includes/functions/utilities.inc.php +38 -3
  40. includes/hooks.inc.php +23 -2
  41. includes/menu-pages/api-ops.inc.php +92 -56
  42. includes/menu-pages/bridges.inc.php +2 -2
  43. includes/menu-pages/code-samples/mms-patch-load.php +4 -0
  44. includes/menu-pages/code-samples/mms-patch-user-new.php +3 -0
  45. includes/menu-pages/code-samples/mms-patch-wp-login.php +7 -0
  46. includes/menu-pages/down-ops.inc.php +3 -3
  47. includes/menu-pages/els-ops.inc.php +3 -3
  48. includes/menu-pages/info.inc.php +1 -1
  49. includes/menu-pages/menu-pages-s-min.js +1 -1
  50. includes/menu-pages/menu-pages-s.js +26 -2
  51. includes/menu-pages/mms-options.inc.php +353 -0
  52. includes/menu-pages/options.inc.php +208 -180
  53. includes/menu-pages/paypal-buttons.inc.php +64 -36
  54. includes/menu-pages/paypal-ops.inc.php +54 -38
  55. includes/menu-pages/scripting.inc.php +6 -7
  56. includes/menu-pages/start.inc.php +10 -18
  57. includes/menu-pages/trk-ops.inc.php +33 -23
  58. includes/profile.inc.php +32 -7
  59. includes/s2member-min.js +1 -1
  60. includes/s2member.css +19 -2
  61. includes/s2member.js +36 -2
  62. includes/syscon.inc.php +30 -19
  63. ms.txt +7 -0
  64. readme.txt +78 -23
  65. s2member.php +15 -14
images/brand-favicon.fla CHANGED
Binary file
images/brand-favicon.png CHANGED
Binary file
images/large-icon.fla ADDED
Binary file
images/large-icon.png ADDED
Binary file
includes/dropins/bridges/_s2member-bbpress-bridge.php CHANGED
@@ -1,12 +1,12 @@
1
<?php
2
/*
3
- Version: 1.0
4
- Stable tag: 1.0
5
Framework: WS-BB-DIP-1.0
6
7
Tested up to: 1.0.2
8
Requires at least: 1.0.2
9
- Requires: s2Member 3.1+, bbPress® 1.0.2+
10
11
Copyright: © 2009 WebSharks, Inc.
12
License: GNU General Public License
@@ -16,7 +16,7 @@ Author: PriMoThemes.com / WebSharks, Inc.
16
Donate link: http://www.primothemes.com/donate/
17
18
Plugin Name: s2Member Bridge
19
- Pro Module / Licensing: http://www.s2member.com/
20
Forum URI: http://www.primothemes.com/forums/viewforum.php?f=4
21
Plugin URI: http://www.primothemes.com/post/s2member-membership-plugin-with-paypal/
22
Professional Installation URI: http://www.primothemes.com/forums/viewtopic.php?f=4&t=107
@@ -46,9 +46,9 @@ function ws_plugin__s2member_bridge_bbpress_roles () /* On-the-fly. */
46
/**/
47
if (empty ($user->roles)) /* Only when no bbPress® Role has been assigned yet. */
48
/**/
49
- foreach ($user->wp_capabilities as $wp_cap => $v) /* Check ^s2member_level[0-9]+ */
50
/**/
51
- if (preg_match ("/^s2member_level[0-9]+#x2F;", $wp_cap)) /* An s2Member Role? */
52
{
53
bb_give_user_default_role($user);
54
break; /* Now a Member! */
@@ -89,9 +89,9 @@ function ws_plugin__s2member_bridge_bbpress_access () /* Check Access. */
89
/**/
90
else if (is_object ($user = bb_get_current_user ()) && $user->ID) /* Logged in? / Got User object? */
91
/**/
92
- foreach ($user->wp_capabilities as $wp_cap => $v) /* Looking for ^(subscriber|s2member_level[0-9]+)$. */
93
/**/
94
- if (preg_match ("/^(subscriber|s2member_level[0-9]+)#x2F;", $wp_cap)) /* Subscribers and/or s2Member Roles. */
95
/**/
96
if (($wp_cap === "subscriber" && $min > 0) || !strlen ($level = preg_replace ("/[^0-9]/", $wp_cap)) || $level < $min)
97
/**/
1
<?php
2
/*
3
+ Version: 1.0.1
4
+ Stable tag: 1.0.1
5
Framework: WS-BB-DIP-1.0
6
7
Tested up to: 1.0.2
8
Requires at least: 1.0.2
9
+ Requires: s2Member 3.2+, bbPress® 1.0.2+
10
11
Copyright: © 2009 WebSharks, Inc.
12
License: GNU General Public License
16
Donate link: http://www.primothemes.com/donate/
17
18
Plugin Name: s2Member Bridge
19
+ Pro Module / Prices: http://www.s2member.com/prices/
20
Forum URI: http://www.primothemes.com/forums/viewforum.php?f=4
21
Plugin URI: http://www.primothemes.com/post/s2member-membership-plugin-with-paypal/
22
Professional Installation URI: http://www.primothemes.com/forums/viewtopic.php?f=4&t=107
46
/**/
47
if (empty ($user->roles)) /* Only when no bbPress® Role has been assigned yet. */
48
/**/
49
+ foreach ($user->wp_capabilities as $wp_cap => $v) /* Check ^s2member_level[1-4]+ */
50
/**/
51
+ if (preg_match ("/^s2member_level[0-4]#x2F;", $wp_cap)) /* An s2Member Role? */
52
{
53
bb_give_user_default_role($user);
54
break; /* Now a Member! */
89
/**/
90
else if (is_object ($user = bb_get_current_user ()) && $user->ID) /* Logged in? / Got User object? */
91
/**/
92
+ foreach ($user->wp_capabilities as $wp_cap => $v) /* Looking for ^(subscriber|s2member_level[0-4])$. */
93
/**/
94
+ if (preg_match ("/^(subscriber|s2member_level[0-4])#x2F;", $wp_cap)) /* Subscribers and/or s2Member Roles. */
95
/**/
96
if (($wp_cap === "subscriber" && $min > 0) || !strlen ($level = preg_replace ("/[^0-9]/", $wp_cap)) || $level < $min)
97
/**/
includes/functions/activate-deactivate.inc.php CHANGED
@@ -19,12 +19,22 @@ Attach to: add_action("admin_init");
19
*/
20
if (!function_exists ("ws_plugin__s2member_check_activation"))
21
{
22
- function ws_plugin__s2member_check_activation () /* Re-activated? */
23
{
24
$v = get_option ("ws_plugin__s2member_activated_version");
25
if (!$v || !version_compare ($v, WS_PLUGIN__S2MEMBER_VERSION, ">="))
26
ws_plugin__s2member_activate ();
27
/**/
28
return;
29
}
30
}
@@ -42,6 +52,9 @@ if (!function_exists ("ws_plugin__s2member_activate"))
42
{
43
function ws_plugin__s2member_activate ()
44
{
45
do_action ("ws_plugin__s2member_before_activation", get_defined_vars ());
46
/**/
47
$role = &get_role ("subscriber");
@@ -126,33 +139,53 @@ if (!function_exists ("ws_plugin__s2member_activate"))
126
if (!file_exists ($htaccess = $logs_dir . "/.htaccess"))
127
file_put_contents ($htaccess, "deny from all");
128
/**/
129
- if (!is_numeric (get_option ("ws_plugin__s2member_configured")))
130
- update_option ("ws_plugin__s2member_configured", "0");
131
- /**/
132
- if (!is_array (get_option ("ws_plugin__s2member_cache")))
133
- update_option ("ws_plugin__s2member_cache", array ());
134
- /**/
135
- if (!is_array (get_option ("ws_plugin__s2member_notices")))
136
- update_option ("ws_plugin__s2member_notices", array ());
137
/**/
138
- if (!is_array (get_option ("ws_plugin__s2member_options")))
139
- update_option ("ws_plugin__s2member_options", array ());
140
- /**/
141
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"]) /* If already configured, read the Changelog. */
142
{
143
$notice = '<strong>s2Member</strong> has been <strong>re-activated</strong>, with the latest version.<br />';
144
- $notice .= 'You now have version ' . WS_PLUGIN__S2MEMBER_VERSION . '. Your existing configuration remains.<br />';
145
- $notice .= 'Have fun, <a href="admin.php?page=ws-plugin--s2member-info">read the Changelog</a>, and make some money! :-)';
146
ws_plugin__s2member_enqueue_admin_notice ($notice, array ("plugins.php", "ws-plugin--s2member-options"));
147
}
148
- else /* Otherwise, we'll help the site owner out by giving them a link to the Quick Start Guide. */
149
{
150
$notice = '<strong>s2Member</strong> v' . WS_PLUGIN__S2MEMBER_VERSION . ' has been <strong>activated</strong>. Nice work!<br />';
151
$notice .= 'Have fun, <a href="admin.php?page=ws-plugin--s2member-start">read the Quick Start Guide</a>, and make some money! :-)';
152
ws_plugin__s2member_enqueue_admin_notice ($notice, array ("plugins.php", "ws-plugin--s2member-options"));
153
}
154
/**/
155
- update_option ("ws_plugin__s2member_activated_version", WS_PLUGIN__S2MEMBER_VERSION);
156
/**/
157
do_action ("ws_plugin__s2member_after_activation", get_defined_vars ());
158
/**/
@@ -168,6 +201,9 @@ if (!function_exists ("ws_plugin__s2member_deactivate"))
168
{
169
function ws_plugin__s2member_deactivate ()
170
{
171
do_action ("ws_plugin__s2member_before_deactivation", get_defined_vars ());
172
/**/
173
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["run_deactivation_routines"])
@@ -219,27 +255,24 @@ if (!function_exists ("ws_plugin__s2member_deactivate"))
219
/**/
220
if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
221
{
222
- if (file_exists ($htaccess = $logs_dir . "/.htaccess"))
223
- if (is_writable ($htaccess))
224
- unlink($htaccess);
225
- /**/
226
- if (file_exists ($log = $logs_dir . "/paypal-ipn.log"))
227
- if (is_writable ($log))
228
- unlink($log);
229
- /**/
230
- if (file_exists ($log = $logs_dir . "/paypal-rtn.log"))
231
- if (is_writable ($log))
232
- unlink($log);
233
/**/
234
@rmdir($logs_dir);
235
}
236
/**/
237
delete_option("ws_plugin__s2member_activated_version");
238
delete_option("ws_plugin__s2member_configured");
239
delete_option("ws_plugin__s2member_cache");
240
delete_option("ws_plugin__s2member_notices");
241
delete_option("ws_plugin__s2member_options");
242
/**/
243
do_action ("ws_plugin__s2member_during_deactivation", get_defined_vars ());
244
}
245
/**/
19
*/
20
if (!function_exists ("ws_plugin__s2member_check_activation"))
21
{
22
+ function ws_plugin__s2member_check_activation () /* Up-to-date? */
23
{
24
$v = get_option ("ws_plugin__s2member_activated_version");
25
if (!$v || !version_compare ($v, WS_PLUGIN__S2MEMBER_VERSION, ">="))
26
ws_plugin__s2member_activate ();
27
/**/
28
+ /* Be ABSOLUTELY sure to use "else if" here. Avoid doubles. */
29
+ /**/
30
+ else if (is_multisite () && is_main_site ())
31
+ /* In case a Multisite Network is enabled later on. */
32
+ {
33
+ $mms_v = get_option ("ws_plugin__s2member_activated_mms_version");
34
+ if (!$mms_v || !version_compare ($mms_v, WS_PLUGIN__S2MEMBER_VERSION, ">="))
35
+ ws_plugin__s2member_activate ();
36
+ }
37
+ /**/
38
return;
39
}
40
}
52
{
53
function ws_plugin__s2member_activate ()
54
{
55
+ global $wpdb; /* To update points of origin on a Multisite Network. */
56
+ global $current_site, $current_blog; /* For Multisite support. */
57
+ /**/
58
do_action ("ws_plugin__s2member_before_activation", get_defined_vars ());
59
/**/
60
$role = &get_role ("subscriber");
139
if (!file_exists ($htaccess = $logs_dir . "/.htaccess"))
140
file_put_contents ($htaccess, "deny from all");
141
/**/
142
+ (!is_numeric (get_option ("ws_plugin__s2member_configured"))) ? update_option ("ws_plugin__s2member_configured", "0") : null;
143
+ (!is_array (get_option ("ws_plugin__s2member_cache"))) ? update_option ("ws_plugin__s2member_cache", array ()) : null;
144
+ (!is_array (get_option ("ws_plugin__s2member_notices"))) ? update_option ("ws_plugin__s2member_notices", array ()) : null;
145
+ (!is_array (get_option ("ws_plugin__s2member_options"))) ? update_option ("ws_plugin__s2member_options", array ()) : null;
146
/**/
147
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"]) /* If already configured, we are re-activating. */
148
{
149
+ $v = get_option ("ws_plugin__s2member_activated_version");
150
+ if (!$v || !version_compare ($v, "3.2", ">=")) /* Needs to be upgraded? */
151
+ /* Version 3.2 is where the `meta_key` names were changed. They're prefixed now. */
152
+ {
153
+ $like = "`meta_key` LIKE 's2member\_%' AND `meta_key` NOT LIKE '%s2member\_originating\_blog%'";
154
+ $wpdb->query ("UPDATE `" . $wpdb->usermeta . "` SET `meta_key` = CONCAT('" . $wpdb->prefix . "', `meta_key`) WHERE " . $like);
155
+ }
156
+ /**/
157
$notice = '<strong>s2Member</strong> has been <strong>re-activated</strong>, with the latest version.<br />';
158
+ $notice .= 'You now have version ' . WS_PLUGIN__S2MEMBER_VERSION . '. Your existing configuration remains.';
159
+ if (!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ()) /* No Changelog on a Multisite Farm. */
160
+ $notice .= '<br />Have fun, <a href="admin.php?page=ws-plugin--s2member-info#rm-changelog">read the Changelog</a>, and make some money! :-)';
161
ws_plugin__s2member_enqueue_admin_notice ($notice, array ("plugins.php", "ws-plugin--s2member-options"));
162
}
163
+ else /* Otherwise, (initial activation); we'll help the Site Owner out by giving them a link to the Quick Start Guide. */
164
{
165
$notice = '<strong>s2Member</strong> v' . WS_PLUGIN__S2MEMBER_VERSION . ' has been <strong>activated</strong>. Nice work!<br />';
166
$notice .= 'Have fun, <a href="admin.php?page=ws-plugin--s2member-start">read the Quick Start Guide</a>, and make some money! :-)';
167
ws_plugin__s2member_enqueue_admin_notice ($notice, array ("plugins.php", "ws-plugin--s2member-options"));
168
}
169
/**/
170
+ update_option ("ws_plugin__s2member_activated_version", WS_PLUGIN__S2MEMBER_VERSION); /* Mark version. */
171
+ /**/
172
+ if (is_multisite () && is_main_site ()) /* Network activation routines. A few quick adjustments. */
173
+ {
174
+ foreach ((array)($users = $wpdb->get_results ("SELECT `ID` FROM `" . $wpdb->users . "`")) as $user)
175
+ {
176
+ /* Here we convert everyone already in the system; without a point of origin.
177
+ This will set their point of origin to the Main Site ( Dashboard Blog ). */
178
+ if (!($originating_blog = get_user_meta ($user->ID, "s2member_originating_blog", true)))
179
+ update_user_meta ($user->ID, "s2member_originating_blog", $current_site->blog_id);
180
+ }
181
+ /**/
182
+ $notice = '<strong>Multisite Network</strong> updated automatically by <strong>s2Member</strong> v' . WS_PLUGIN__S2MEMBER_VERSION . '.<br />';
183
+ $notice .= 'You\'ll want to configure s2Member\'s Multisite options now.<br />';
184
+ $notice .= 'In the Dashboard for your Main Site, see:<br /><code>s2Member -> Multisite ( Config )</code>.';
185
+ ws_plugin__s2member_enqueue_admin_notice ($notice, array ("plugins.php", "ws-plugin--s2member-options"));
186
+ /**/
187
+ update_option ("ws_plugin__s2member_activated_mms_version", WS_PLUGIN__S2MEMBER_VERSION);
188
+ }
189
/**/
190
do_action ("ws_plugin__s2member_after_activation", get_defined_vars ());
191
/**/
201
{
202
function ws_plugin__s2member_deactivate ()
203
{
204
+ global $wpdb; /* May need this for database cleaning. */
205
+ global $current_site, $current_blog; /* For Multisite support. */
206
+ /**/
207
do_action ("ws_plugin__s2member_before_deactivation", get_defined_vars ());
208
/**/
209
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["run_deactivation_routines"])
255
/**/
256
if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
257
{
258
+ foreach (scandir ($logs_dir) as $log_file)
259
+ if (is_writable ($log_file = $logs_dir . "/" . $log_file))
260
+ unlink($log_file);
261
/**/
262
@rmdir($logs_dir);
263
}
264
/**/
265
+ delete_option("ws_plugin__s2member_activated_mms_version");
266
delete_option("ws_plugin__s2member_activated_version");
267
delete_option("ws_plugin__s2member_configured");
268
delete_option("ws_plugin__s2member_cache");
269
delete_option("ws_plugin__s2member_notices");
270
delete_option("ws_plugin__s2member_options");
271
/**/
272
+ $like = "`meta_key` LIKE '%s2member\_%'";
273
+ $wpdb->query ("DELETE FROM `" . $wpdb->postmeta . "` WHERE " . $like);
274
+ $wpdb->query ("DELETE FROM `" . $wpdb->usermeta . "` WHERE " . $like);
275
+ /**/
276
do_action ("ws_plugin__s2member_during_deactivation", get_defined_vars ());
277
}
278
/**/
includes/functions/auto-eots.inc.php CHANGED
@@ -15,14 +15,21 @@ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
exit ("Do not access this file directly.");
16
/*
17
Function processed by WP-Cron. This handles Auto-EOTs.
18
- If you have a HUGE user-base, increase the max eots per process.
19
To increase, use: add_filter ("ws_plugin__s2member_auto_eot_system_per_process");
20
*/
21
if (!function_exists ("ws_plugin__s2member_auto_eot_system"))
22
{
23
function ws_plugin__s2member_auto_eot_system ($per_process = 10)
24
{
25
global $wpdb; /* Need global DB obj. */
26
/**/
27
include_once ABSPATH . "wp-admin/includes/admin.php";
28
/**/
@@ -32,36 +39,35 @@ if (!function_exists ("ws_plugin__s2member_auto_eot_system"))
32
{
33
$per_process = apply_filters ("ws_plugin__s2member_auto_eot_system_per_process", $per_process, get_defined_vars ());
34
/**/
35
- if ($eots = $wpdb->get_results ("SELECT `user_id` AS `ID` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = 's2member_auto_eot_time' AND `meta_value` <= '" . $wpdb->escape (strtotime ("now")) . "' LIMIT " . $per_process))
36
{
37
- foreach ($eots as $eot) /* Go through the array of eots. We need to (demote|delete) each of them. */
38
{
39
if (($user_id = $eot->ID) && is_object ($user = new WP_User ($user_id)) && $user->ID)
40
{
41
- delete_usermeta ($user_id, "s2member_auto_eot_time"); /* Always delete this. */
42
- /* Removing this prevents re-runs on non WP Roles. Which are scanned for next. */
43
/**/
44
- if (!ws_plugin__s2member_user_has_wp_role ($user)) /* Non WP Roles ( Subscriber excluded ). */
45
{
46
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote")
47
{
48
$demotion_role = ws_plugin__s2member_force_demotion_role ("subscriber");
49
$user->set_role ($demotion_role); /* Defaults to Free Subscriber. */
50
/**/
51
- $subscr_id = get_usermeta ($user_id, "s2member_subscr_id");
52
- $custom = get_usermeta ($user_id, "s2member_custom");
53
- /**/
54
- delete_usermeta ($user_id, "s2member_custom");
55
- delete_usermeta ($user_id, "s2member_subscr_id");
56
- delete_usermeta ($user_id, "s2member_last_payment_time");
57
- delete_usermeta ($user_id, "s2member_auto_eot_time");
58
- /**/
59
foreach ($user->allcaps as $cap => $cap_enabled)
60
if (preg_match ("/^access_s2member_ccap_/", $cap))
61
$user->remove_cap ($ccap = $cap);
62
/**/
63
- delete_usermeta ($user_id, "s2member_file_download_access_arc");
64
- delete_usermeta ($user_id, "s2member_file_download_access_log");
65
/**/
66
ws_plugin__s2member_append_user_notes ($user_id, "Demoted by s2Member: " . date ("D M j, Y g:i a T"));
67
/**/
@@ -73,9 +79,10 @@ if (!function_exists ("ws_plugin__s2member_auto_eot_system"))
73
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)))
74
if (($url = preg_replace ("/%%user_full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
75
if (($url = preg_replace ("/%%user_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->user_email)), $url)))
76
- /**/
77
- if (($url = trim ($url))) /* Empty? */
78
- ws_plugin__s2member_remote ($url);
79
}
80
/**/
81
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
@@ -84,8 +91,16 @@ if (!function_exists ("ws_plugin__s2member_auto_eot_system"))
84
}
85
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete")
86
{
87
- wp_delete_user ($user_id); /* Triggers: `ws_plugin__s2member_handle_user_deletions()` */
88
- /* `ws_plugin__s2member_handle_user_deletions()` triggers `eot_del_notification_urls` */
89
/**/
90
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
91
do_action ("ws_plugin__s2member_during_auto_eot_system_during_delete", get_defined_vars ());
15
exit ("Do not access this file directly.");
16
/*
17
Function processed by WP-Cron. This handles Auto-EOTs.
18
+
19
+ If you have a HUGE userbase, increase the max EOTS per process.
20
+ ~ But NOTE, this runs $per_process ( per Blog ) on a Multisite Network.
21
To increase, use: add_filter ("ws_plugin__s2member_auto_eot_system_per_process");
22
+
23
+ s2Member v3.2 ( VERY IMPORTANT ).
24
+ AND `meta_value` != ''
25
+ Because update_user_option() may NOT always delete the key.
26
*/
27
if (!function_exists ("ws_plugin__s2member_auto_eot_system"))
28
{
29
function ws_plugin__s2member_auto_eot_system ($per_process = 10)
30
{
31
global $wpdb; /* Need global DB obj. */
32
+ global $current_site, $current_blog; /* Multisite. */
33
/**/
34
include_once ABSPATH . "wp-admin/includes/admin.php";
35
/**/
39
{
40
$per_process = apply_filters ("ws_plugin__s2member_auto_eot_system_per_process", $per_process, get_defined_vars ());
41
/**/
42
+ if (is_array ($eots = $wpdb->get_results ("SELECT `user_id` AS `ID` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_auto_eot_time' AND `meta_value` != '' AND `meta_value` <= '" . $wpdb->escape (strtotime ("now")) . "' LIMIT " . $per_process)))
43
{
44
+ foreach ($eots as $eot) /* Go through the array of EOTS. We need to (demote|delete) each of them. */
45
{
46
if (($user_id = $eot->ID) && is_object ($user = new WP_User ($user_id)) && $user->ID)
47
{
48
+ delete_user_option ($user_id, "s2member_auto_eot_time"); /* ALWAYS delete this. */
49
/**/
50
+ if (!$user->has_cap ("administrator")) /* Do NOT process Administrator accounts. */
51
{
52
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote")
53
{
54
+ $subscr_id = get_user_option ("s2member_subscr_id", $user_id);
55
+ $custom = get_user_option ("s2member_custom", $user_id);
56
+ /**/
57
$demotion_role = ws_plugin__s2member_force_demotion_role ("subscriber");
58
$user->set_role ($demotion_role); /* Defaults to Free Subscriber. */
59
/**/
60
foreach ($user->allcaps as $cap => $cap_enabled)
61
if (preg_match ("/^access_s2member_ccap_/", $cap))
62
$user->remove_cap ($ccap = $cap);
63
/**/
64
+ delete_user_option ($user_id, "s2member_custom");
65
+ delete_user_option ($user_id, "s2member_subscr_id");
66
+ delete_user_option ($user_id, "s2member_last_payment_time");
67
+ delete_user_option ($user_id, "s2member_auto_eot_time");
68
+ /**/
69
+ delete_user_option ($user_id, "s2member_file_download_access_arc");
70
+ delete_user_option ($user_id, "s2member_file_download_access_log");
71
/**/
72
ws_plugin__s2member_append_user_notes ($user_id, "Demoted by s2Member: " . date ("D M j, Y g:i a T"));
73
/**/
79
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)))
80
if (($url = preg_replace ("/%%user_full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
81
if (($url = preg_replace ("/%%user_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->user_email)), $url)))
82
+ if (($url = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($user_id)), $url)))
83
+ /**/
84
+ if (($url = trim ($url))) /* Empty? */
85
+ ws_plugin__s2member_remote ($url);
86
}
87
/**/
88
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
91
}
92
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete")
93
{
94
+ if (is_multisite ()) /* Multisite does NOT actually delete; ONLY removes. */
95
+ {
96
+ remove_user_from_blog ($user_id, $current_blog->blog_id);
97
+ /* This will automatically trigger `eot_del_notification_urls` as well. */
98
+ ws_plugin__s2member_handle_ms_user_deletions ($user_id, $current_blog->blog_id, "s2says");
99
+ }
100
+ /**/
101
+ else /* Otherwise, we can actually delete them. */
102
+ /* This will automatically trigger `eot_del_notification_urls` as well. */
103
+ wp_delete_user ($user_id); /* `ws_plugin__s2member_handle_user_deletions()` */
104
/**/
105
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
106
do_action ("ws_plugin__s2member_during_auto_eot_system_during_delete", get_defined_vars ());
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.
@@ -25,94 +25,95 @@ if (!function_exists ("ws_plugin__s2member_constants"))
25
do_action ("ws_plugin__s2member_before_constants", get_defined_vars ());
26
/**/
27
$links = ws_plugin__s2member_constant_links ();
28
- $metas = ws_plugin__s2member_constant_metas ();
29
$level = ws_plugin__s2member_user_access_level ();
30
$current_user = (is_user_logged_in ()) ? wp_get_current_user () : false;
31
- $file_downloads = ws_plugin__s2member_user_downloads ("", $metas["s2member_file_download_access_log"]);
32
- $login_redirection_override = ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"]) ? /* Only when applicable. */
33
- ws_plugin__s2member_fill_login_redirect_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"], $current_user) : "";
34
/**/
35
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
36
do_action ("ws_plugin__s2member_during_constants", get_defined_vars ());
37
unset ($__refs, $__v); /* Unset defined __refs, __v. */
38
/**/
39
- define ("S2MEMBER_VERSION", WS_PLUGIN__S2MEMBER_VERSION); /* Always a (string) containing the version. Available since 3.0. */
40
- /**/
41
- define ("S2MEMBER_CURRENT_USER_IS_LOGGED_IN", (($current_user) ? true : false)); /* This will always be (bool) true or false. False if they are NOT currently logged in. */
42
- define ("S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER", (($current_user && $level >= 1) ? true : false)); /* This will always be (bool) true or false. Level >= 1 for Members. */
43
- define ("S2MEMBER_CURRENT_USER_ACCESS_LEVEL", (int)$level); /* This will always be (int) negative 1 thru positive 4. -1 if user is not logged in. 0 if logged in as a Subscriber. */
44
- define ("S2MEMBER_CURRENT_USER_ACCESS_LABEL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_label"]); /* This will always be a (string). Empty if not logged in. */
45
- define ("S2MEMBER_CURRENT_USER_SUBSCR_ID", (($current_user) ? (($metas["s2member_subscr_id"]) ? $metas["s2member_subscr_id"] : $current_user->ID) : "")); /* Empty if not logged in. */
46
- define ("S2MEMBER_CURRENT_USER_CUSTOM", (($current_user) ? $metas["s2member_custom"] : "")); /* This will always a (string). However, it will be empty if not logged in. */
47
- define ("S2MEMBER_CURRENT_USER_REGISTRATION_TIME", (($current_user) ? (int)strtotime ($current_user->user_registered) : 0)); /* Always an (int). Or 0 if they're not logged in. */
48
- define ("S2MEMBER_CURRENT_USER_REGISTRATION_DAYS", (($current_user) ? (int)floor ((strtotime ("now") - strtotime ($current_user->user_registered)) / 86400) : 0)); /* (int). */
49
- define ("S2MEMBER_CURRENT_USER_DISPLAY_NAME", (($current_user) ? $current_user->display_name : "")); /* This will always be a (string). Empty if not logged in. */
50
- define ("S2MEMBER_CURRENT_USER_FIRST_NAME", (($current_user) ? $current_user->user_firstname : "")); /* This will always be a (string). Empty if not logged in. */
51
- define ("S2MEMBER_CURRENT_USER_LAST_NAME", (($current_user) ? $current_user->user_lastname : "")); /* This will always be a (string). Empty if not logged in. */
52
- define ("S2MEMBER_CURRENT_USER_LOGIN", (($current_user) ? $current_user->user_login : "")); /* This will always be a (string). Empty if not logged in. */
53
- define ("S2MEMBER_CURRENT_USER_EMAIL", (($current_user) ? $current_user->user_email : "")); /* This will always be a (string). Empty if not logged in. */
54
- define ("S2MEMBER_CURRENT_USER_IP", $_SERVER["REMOTE_ADDR"]); /* This will always be a (string). It may be empty if the user is browsing anonymously. */
55
- define ("S2MEMBER_CURRENT_USER_ID", (($current_user) ? (int)$current_user->ID : 0)); /* This will always be an (int). Zero if not logged in. */
56
- define ("S2MEMBER_CURRENT_USER_FIELDS", (($current_user) ? json_encode (array_merge /* Always a json_encode (array). This includes custom fields. */
57
- (array ("id" => S2MEMBER_CURRENT_USER_ID, "ip" => S2MEMBER_CURRENT_USER_IP, "email" => S2MEMBER_CURRENT_USER_EMAIL, "login" => S2MEMBER_CURRENT_USER_LOGIN,/**/
58
- "first_name" => S2MEMBER_CURRENT_USER_FIRST_NAME, "last_name" => S2MEMBER_CURRENT_USER_LAST_NAME, "display_name" => S2MEMBER_CURRENT_USER_DISPLAY_NAME,/**/
59
- "subscr_id" => S2MEMBER_CURRENT_USER_SUBSCR_ID, "custom" => S2MEMBER_CURRENT_USER_CUSTOM), $metas["s2member_custom_fields"])) : json_encode (array ())));
60
- /**/
61
- define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED", (int)$file_downloads["allowed"]); /* This will always be an integer value (int) >= 0 where 0 means no access. */
62
- define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED", (($file_downloads["allowed"] >= 999999999) ? true : false)); /* This will always be (bool). */
63
- define ("S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY", (int)$file_downloads["currently"]); /* This will always be an integer value (int) >= 0 where 0 means none currently. */
64
- define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS", (int)$file_downloads["allowed_days"]); /* This will always be an integer value (int) >= 0 where 0 means no access. */
65
- /**/
66
- define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]); /* The exceeded page id (int). */
67
- define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]); /* Options page id, always an (int). */
68
- define ("S2MEMBER_LOGIN_WELCOME_PAGE_ID", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]); /* The welcome page id, always an (int). */
69
- /**/
70
- define ("S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL", get_bloginfo ("url") . "/?s2member_profile=1"); /* Where a user modifies their profile. */
71
- define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL", $links["file_download_limit_exceeded_page"]); /* Always a string. URL to limit exceeded page. */
72
- define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL", $links["membership_options_page"]); /* Always a string. This is the URL to the membership options page. */
73
- define ("S2MEMBER_LOGIN_WELCOME_PAGE_URL", (($login_redirection_override) ? $login_redirection_override : $links["login_welcome_page"])); /* Always a string. */
74
- define ("S2MEMBER_LOGOUT_PAGE_URL", wp_logout_url ()); /* This is always the same, it is the default wordpress action=logout url generated by wp_logout_url(). */
75
- define ("S2MEMBER_LOGIN_PAGE_URL", wp_login_url ()); /* This is always the same, it is the default wordpress login url that is generated by wp_login_url(). */
76
- /**/
77
- define ("S2MEMBER_LEVEL0_LABEL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_label"]); /* This is the (string) label that you created for membership level number 0. */
78
- define ("S2MEMBER_LEVEL1_LABEL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_label"]); /* This is the (string) label that you created for membership level number 1. */
79
- define ("S2MEMBER_LEVEL2_LABEL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_label"]); /* This is the (string) label that you created for membership level number 2. */
80
- define ("S2MEMBER_LEVEL3_LABEL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_label"]); /* This is the (string) label that you created for membership level number 3. */
81
- define ("S2MEMBER_LEVEL4_LABEL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_label"]); /* This is the (string) label that you created for membership level number 4. */
82
- /**/
83
- define ("S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed"]); /* This is the (int) allowed downloads. */
84
- define ("S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed"]); /* This is the (int) allowed downloads. */
85
- define ("S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed"]); /* This is the (int) allowed downloads. */
86
- define ("S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed"]); /* This is the (int) allowed downloads. */
87
- define ("S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed"]); /* This is the (int) allowed downloads. */
88
- /**/
89
- define ("S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed_days"]); /* This is (int) allowed days. */
90
- define ("S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"]); /* This is (int) allowed days. */
91
- define ("S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"]); /* This is (int) allowed days. */
92
- define ("S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"]); /* This is (int) allowed days. */
93
- define ("S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"]); /* This is (int) allowed days. */
94
- /**/
95
- define ("S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_inline_extensions"]); /* This is the (string) list of extensions. */
96
- /**/
97
- define ("S2MEMBER_REG_EMAIL_FROM_NAME", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]); /* This is the name that outgoing email messages are sent by. */
98
- define ("S2MEMBER_REG_EMAIL_FROM_EMAIL", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"]); /* This is the email that outgoing messages are sent by. */
99
- /**/
100
- define ("S2MEMBER_PAYPAL_NOTIFY_URL", get_bloginfo ("url") . "/?s2member_paypal_notify=1"); /* This will always be a (string), and it will never be an empty value. */
101
- define ("S2MEMBER_PAYPAL_RETURN_URL", get_bloginfo ("url") . "/?s2member_paypal_return=1"); /* This will always be a (string), and it will never be an empty value. */
102
- define ("S2MEMBER_PAYPAL_ENDPOINT", (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com")); /* Using sandbox? */
103
- define ("S2MEMBER_PAYPAL_BUSINESS", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"]); /* This is the email address that identifies your paypal business. */
104
- /**/
105
- define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0", ((S2MEMBER_CURRENT_USER_SUBSCR_ID) ? "Updating Subscr. ID" : "")); /* Subscr. ID or $user->ID. Either will work. */
106
- define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0", ((S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0) ? S2MEMBER_CURRENT_USER_SUBSCR_ID : "")); /* Subscr. ID or $user->ID. */
107
/**/
108
do_action ("ws_plugin__s2member_after_constants", get_defined_vars ());
109
/**/
110
- return;
111
}
112
}
113
/*
114
- This function pulls all of the page links needed for Constants.
115
- Page links are cached into the s2member options on 15 min intervals.
116
This allows the API Constants to provide quick access to them without being
117
forced to execute get_page_link() all the time, which piles up DB queries.
118
*/
@@ -122,11 +123,7 @@ if (!function_exists ("ws_plugin__s2member_constant_links"))
122
{
123
do_action ("ws_plugin__s2member_before_constant_links", get_defined_vars ());
124
/**/
125
- $cache_minutes = 15; /* Could be higher? */
126
- /**/
127
- $l["login_welcome_page"] = (string)"";
128
- $l["membership_options_page"] = (string)"";
129
- $l["file_download_limit_exceeded_page"] = (string)"";
130
/**/
131
$login_welcome_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"];
132
$membership_options_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"];
@@ -136,7 +133,7 @@ if (!function_exists ("ws_plugin__s2member_constant_links"))
136
$membership_options_page_cache = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"];
137
$file_download_limit_exceeded_page_cache = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"];
138
/**/
139
- if ($login_welcome_page && $login_welcome_page_cache["page"] === $login_welcome_page && $login_welcome_page_cache["link"] && $login_welcome_page_cache["time"] >= strtotime ("-" . $cache_minutes . " minutes"))
140
{
141
$l["login_welcome_page"] = $login_welcome_page_cache["link"];
142
}
@@ -149,7 +146,7 @@ if (!function_exists ("ws_plugin__s2member_constant_links"))
149
$cache_needs_updating = true;
150
}
151
/**/
152
- if ($membership_options_page && $membership_options_page_cache["page"] === $membership_options_page && $membership_options_page_cache["link"] && $membership_options_page_cache["time"] >= strtotime ("-" . $cache_minutes . " minutes"))
153
{
154
$l["membership_options_page"] = $membership_options_page_cache["link"];
155
}
@@ -162,7 +159,7 @@ if (!function_exists ("ws_plugin__s2member_constant_links"))
162
$cache_needs_updating = true;
163
}
164
/**/
165
- if ($file_download_limit_exceeded_page && $file_download_limit_exceeded_page_cache["page"] === $file_download_limit_exceeded_page && $file_download_limit_exceeded_page_cache["link"] && $file_download_limit_exceeded_page_cache["time"] >= strtotime ("-" . $cache_minutes . " minutes"))
166
{
167
$l["file_download_limit_exceeded_page"] = $file_download_limit_exceeded_page_cache["link"];
168
}
@@ -183,44 +180,4 @@ if (!function_exists ("ws_plugin__s2member_constant_links"))
183
return apply_filters ("ws_plugin__s2member_constant_links", $l, get_defined_vars ());
184
}
185
}
186
- /*
187
- This function pulls all of the usermeta details needed for Constants.
188
- Pulling them all at once helps to prevent repeated database queries.
189
- */
190
- if (!function_exists ("ws_plugin__s2member_constant_metas"))
191
- {
192
- function ws_plugin__s2member_constant_metas ()
193
- {
194
- global $wpdb; /* The global database object. */
195
- /**/
196
- do_action ("ws_plugin__s2member_before_constant_metas", get_defined_vars ());
197
- /**/
198
- $m["s2member_file_download_access_log"] = array ();
199
- $m["s2member_custom_fields"] = array ();
200
- $m["s2member_subscr_id"] = (string)"";
201
- $m["s2member_custom"] = (string)"";
202
- /**/
203
- if (($current_user = (is_user_logged_in ()) ? wp_get_current_user () : false))
204
- {
205
- if (is_array ($results = $wpdb->get_results ("SELECT `meta_key`, `meta_value` FROM `" . $wpdb->usermeta . "` WHERE `user_id` = '" . $current_user->ID . "' AND (meta_key = 's2member_file_download_access_log' OR meta_key = 's2member_custom_fields' OR meta_key = 's2member_subscr_id' OR meta_key = 's2member_custom') LIMIT 3")))
206
- {
207
- foreach ($results as $r) /* Fill in the array we need. */
208
- if ($r->meta_key === "s2member_file_download_access_log")
209
- $m["s2member_file_download_access_log"] = (array)maybe_unserialize ($r->meta_value);
210
- else if ($r->meta_key === "s2member_custom_fields")
211
- $m["s2member_custom_fields"] = (array)maybe_unserialize ($r->meta_value);
212
- else if ($r->meta_key === "s2member_subscr_id")
213
- $m["s2member_subscr_id"] = (string)$r->meta_value;
214
- else if ($r->meta_key === "s2member_custom")
215
- $m["s2member_custom"] = (string)$r->meta_value;
216
- /**/
217
- eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
218
- do_action ("ws_plugin__s2member_during_constant_metas", get_defined_vars ());
219
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
220
- }
221
- }
222
- /**/
223
- return apply_filters ("ws_plugin__s2member_constant_metas", $m, get_defined_vars ());
224
- }
225
- }
226
?>
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.
25
do_action ("ws_plugin__s2member_before_constants", get_defined_vars ());
26
/**/
27
$links = ws_plugin__s2member_constant_links ();
28
$level = ws_plugin__s2member_user_access_level ();
29
+ $file_downloads = ws_plugin__s2member_user_downloads ();
30
+ /**/
31
$current_user = (is_user_logged_in ()) ? wp_get_current_user () : false;
32
/**/
33
+ $subscr_id = ($current_user) ? get_user_option ("s2member_subscr_id", $current_user->ID) : "";
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
/**/
43
+ define ("S2MEMBER_VERSION", WS_PLUGIN__S2MEMBER_VERSION); /* Available since 3.0. */
44
+ /**/
45
+ define ("S2MEMBER_CURRENT_USER_IS_LOGGED_IN", (($current_user) ? true : false));
46
+ define ("S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER", (($current_user && $level >= 1) ? true : false));
47
+ define ("S2MEMBER_CURRENT_USER_ACCESS_LEVEL", (int)$level);
48
+ define ("S2MEMBER_CURRENT_USER_ACCESS_LABEL", (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_label"]);
49
+ define ("S2MEMBER_CURRENT_USER_SUBSCR_ID", (($current_user) ? (($subscr_id) ? (string)$subscr_id : (string)$current_user->ID) : ""));
50
+ define ("S2MEMBER_CURRENT_USER_CUSTOM", (string)$custom);
51
+ define ("S2MEMBER_CURRENT_USER_REGISTRATION_TIME", (($current_user) ? (int)strtotime ($current_user->user_registered) : 0));
52
+ define ("S2MEMBER_CURRENT_USER_REGISTRATION_DAYS", (($current_user) ? (int)floor ((strtotime ("now") - strtotime ($current_user->user_registered)) / 86400) : 0));
53
+ define ("S2MEMBER_CURRENT_USER_DISPLAY_NAME", (($current_user) ? (string)$current_user->display_name : ""));
54
+ define ("S2MEMBER_CURRENT_USER_FIRST_NAME", (($current_user) ? (string)$current_user->first_name : ""));
55
+ define ("S2MEMBER_CURRENT_USER_LAST_NAME", (($current_user) ? (string)$current_user->last_name : ""));
56
+ define ("S2MEMBER_CURRENT_USER_LOGIN", (($current_user) ? (string)$current_user->user_login : ""));
57
+ define ("S2MEMBER_CURRENT_USER_EMAIL", (($current_user) ? (string)$current_user->user_email : ""));
58
+ define ("S2MEMBER_CURRENT_USER_IP", (string)$_SERVER["REMOTE_ADDR"]);
59
+ define ("S2MEMBER_CURRENT_USER_ID", (($current_user) ? (int)$current_user->ID : 0));
60
+ define ("S2MEMBER_CURRENT_USER_FIELDS", (($current_user) ? json_encode (array_merge (array ("id" => S2MEMBER_CURRENT_USER_ID, "ip" => S2MEMBER_CURRENT_USER_IP, "email" => S2MEMBER_CURRENT_USER_EMAIL, "login" => S2MEMBER_CURRENT_USER_LOGIN, "first_name" => S2MEMBER_CURRENT_USER_FIRST_NAME, "last_name" => S2MEMBER_CURRENT_USER_LAST_NAME, "display_name" => S2MEMBER_CURRENT_USER_DISPLAY_NAME, "subscr_id" => S2MEMBER_CURRENT_USER_SUBSCR_ID, "custom" => S2MEMBER_CURRENT_USER_CUSTOM), (array)$custom_fields)) : json_encode (array ())));
61
+ /**/
62
+ define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED", (int)$file_downloads["allowed"]);
63
+ define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED", (($file_downloads["allowed"] >= 999999999) ? true : false));
64
+ define ("S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY", (int)$file_downloads["currently"]);
65
+ define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS", (int)$file_downloads["allowed_days"]);
66
+ /**/
67
+ define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]);
68
+ define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]);
69
+ define ("S2MEMBER_LOGIN_WELCOME_PAGE_ID", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]);
70
+ /**/
71
+ define ("S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL", get_bloginfo ("wpurl") . "/?s2member_profile=1");
72
+ define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL", (string)$links["file_download_limit_exceeded_page"]);
73
+ define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL", (string)$links["membership_options_page"]);
74
+ define ("S2MEMBER_LOGIN_WELCOME_PAGE_URL", (($login_redirection_override) ? (string)$login_redirection_override : (string)$links["login_welcome_page"]));
75
+ define ("S2MEMBER_LOGOUT_PAGE_URL", (string)wp_logout_url ());
76
+ define ("S2MEMBER_LOGIN_PAGE_URL", (string)wp_login_url ());
77
+ /**/
78
+ define ("S2MEMBER_LEVEL0_LABEL", (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_label"]);
79
+ define ("S2MEMBER_LEVEL1_LABEL", (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_label"]);
80
+ define ("S2MEMBER_LEVEL2_LABEL", (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_label"]);
81
+ define ("S2MEMBER_LEVEL3_LABEL", (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_label"]);
82
+ define ("S2MEMBER_LEVEL4_LABEL", (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_label"]);
83
+ /**/
84
+ define ("S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed"]);
85
+ define ("S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed"]);
86
+ define ("S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed"]);
87
+ define ("S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed"]);
88
+ define ("S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed"]);
89
+ /**/
90
+ define ("S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed_days"]);
91
+ define ("S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"]);
92
+ define ("S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"]);
93
+ define ("S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"]);
94
+ define ("S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED_DAYS", (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"]);
95
+ /**/
96
+ define ("S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS", (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_inline_extensions"]);
97
+ /**/
98
+ define ("S2MEMBER_REG_EMAIL_FROM_NAME", (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]);
99
+ define ("S2MEMBER_REG_EMAIL_FROM_EMAIL", (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"]);
100
+ /**/
101
+ define ("S2MEMBER_PAYPAL_NOTIFY_URL", get_bloginfo ("wpurl") . "/?s2member_paypal_notify=1");
102
+ define ("S2MEMBER_PAYPAL_RETURN_URL", get_bloginfo ("wpurl") . "/?s2member_paypal_return=1");
103
+ define ("S2MEMBER_PAYPAL_ENDPOINT", (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com"));
104
+ define ("S2MEMBER_PAYPAL_BUSINESS", (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"]);
105
+ /**/
106
+ define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0", ((S2MEMBER_CURRENT_USER_SUBSCR_ID) ? "Updating Subscr. ID" : ""));
107
+ define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0", ((S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0) ? S2MEMBER_CURRENT_USER_SUBSCR_ID : ""));
108
/**/
109
do_action ("ws_plugin__s2member_after_constants", get_defined_vars ());
110
/**/
111
+ return; /* Return nothing here. Just for uniformity. */
112
}
113
}
114
/*
115
+ This function pulls all of the Page links needed for Constants.
116
+ Page links are cached into the s2Member options on 15 min intervals.
117
This allows the API Constants to provide quick access to them without being
118
forced to execute get_page_link() all the time, which piles up DB queries.
119
*/
123
{
124
do_action ("ws_plugin__s2member_before_constant_links", get_defined_vars ());
125
/**/
126
+ $l = array ("login_welcome_page" => "", "membership_options_page" => "", "file_download_limit_exceeded_page" => "");
127
/**/
128
$login_welcome_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"];
129
$membership_options_page = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"];
133
$membership_options_page_cache = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"];
134
$file_download_limit_exceeded_page_cache = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"];
135
/**/
136
+ if ($login_welcome_page && $login_welcome_page_cache["page"] === $login_welcome_page && $login_welcome_page_cache["link"] && $login_welcome_page_cache["time"] >= strtotime ("-15 minutes"))
137
{
138
$l["login_welcome_page"] = $login_welcome_page_cache["link"];
139
}
146
$cache_needs_updating = true;
147
}
148
/**/
149
+ if ($membership_options_page && $membership_options_page_cache["page"] === $membership_options_page && $membership_options_page_cache["link"] && $membership_options_page_cache["time"] >= strtotime ("-15 minutes"))
150
{
151
$l["membership_options_page"] = $membership_options_page_cache["link"];
152
}
159
$cache_needs_updating = true;
160
}
161
/**/
162
+ if ($file_download_limit_exceeded_page && $file_download_limit_exceeded_page_cache["page"] === $file_download_limit_exceeded_page && $file_download_limit_exceeded_page_cache["link"] && $file_download_limit_exceeded_page_cache["time"] >= strtotime ("-15 minutes"))
163
{
164
$l["file_download_limit_exceeded_page"] = $file_download_limit_exceeded_page_cache["link"];
165
}
180
return apply_filters ("ws_plugin__s2member_constant_links", $l, get_defined_vars ());
181
}
182
}
183
?>
includes/functions/css-js-w-globals.inc.php CHANGED
@@ -12,10 +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 adds styles to the header.
18
- This function is also fired in the admin area.
19
Do NOT enqueue styles in the admin area.
20
Attach to: add_action("wp_print_styles");
21
*/
@@ -25,9 +24,9 @@ if (!function_exists ("ws_plugin__s2member_add_css"))
25
{
26
do_action ("ws_plugin__s2member_before_add_css", get_defined_vars ());
27
/**/
28
- if (!is_admin () /* Not in the admin. */ && (has_action ("ws_plugin__s2member_during_add_css") || has_action ("ws_plugin__s2member_during_css"))) /* Framework support here. Currently this is NOT used unless hooks are attached, in which case it needs to be enqueued. */
29
{
30
- wp_enqueue_style ("ws-plugin--s2member", get_bloginfo ("url") . "/?ws_plugin__s2member_css=1&qcABC=1", array (), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"], "all");
31
/**/
32
do_action ("ws_plugin__s2member_during_add_css", get_defined_vars ());
33
}
@@ -49,16 +48,16 @@ if (!function_exists ("ws_plugin__s2member_css"))
49
/**/
50
if ($_GET["ws_plugin__s2member_css"])
51
{
52
- header ("Content-Type: text/css; charset=utf-8");
53
- header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("+1 week")) . " GMT");
54
- header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
55
- header ("Cache-Control: max-age=604800");
56
- header ("Pragma: public");
57
/**/
58
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
59
$i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images";
60
/**/
61
- ob_start ("ws_plugin__s2member_compress_css"); /* Compress. */
62
/**/
63
include_once dirname (dirname (__FILE__)) . "/s2member.css";
64
/**/
@@ -72,7 +71,6 @@ if (!function_exists ("ws_plugin__s2member_css"))
72
}
73
/*
74
Function for adding scripts to the header.
75
- This function is fired in the admin area also.
76
Do NOT enqueue scripts in the admin area.
77
Attach to: add_action("wp_print_scripts");
78
*/
@@ -88,7 +86,7 @@ if (!function_exists ("ws_plugin__s2member_add_js_w_globals"))
88
{
89
$a = get_defined_constants (true);
90
$c = (array)$a["user"];
91
- unset ($a);
92
/**/
93
foreach ($c as $k => $v)
94
if (preg_match ("/^S2MEMBER_/i", $k))
@@ -96,12 +94,12 @@ if (!function_exists ("ws_plugin__s2member_add_js_w_globals"))
96
/**/
97
$md5 = md5 (serialize ($s2member)); /* This is a hash based on the global key => values. */
98
/* The md5 hash allows the script to be cached in the browser until the globals happen to change. */
99
- /* For instance, the global variables may change when a user who is logged-in changes their profile. */
100
- wp_enqueue_script ("ws-plugin--s2member", get_bloginfo ("url") . "/?ws_plugin__s2member_js_w_globals=1&qcABC=1&" . $md5, array ("jquery"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"]);
101
}
102
- else /* Else if they are not logged in, we distinguish the script by not including the md5 hash. */
103
{ /* This essentially creates 2 versions of the script. One while logged in & another when not. */
104
- wp_enqueue_script ("ws-plugin--s2member", get_bloginfo ("url") . "/?ws_plugin__s2member_js_w_globals=1&qcABC=1", array ("jquery"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"]);
105
}
106
/**/
107
do_action ("ws_plugin__s2member_during_add_js_w_globals", get_defined_vars ());
@@ -124,11 +122,11 @@ if (!function_exists ("ws_plugin__s2member_js_w_globals"))
124
/**/
125
if ($_GET["ws_plugin__s2member_js_w_globals"])
126
{
127
- header ("Content-Type: text/javascript; charset=utf-8");
128
- header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("+1 week")) . " GMT");
129
- header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
130
- header ("Cache-Control: max-age=604800");
131
- header ("Pragma: public");
132
/**/
133
$g = "var S2MEMBER_VERSION = '" . ws_plugin__s2member_esc_sq (S2MEMBER_VERSION) . "',"; /* Since 3.0. */
134
/**/
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 styles to the header.
18
Do NOT enqueue styles in the admin area.
19
Attach to: add_action("wp_print_styles");
20
*/
24
{
25
do_action ("ws_plugin__s2member_before_add_css", get_defined_vars ());
26
/**/
27
+ if (!is_admin ()) /* Not in the admin. */
28
{
29
+ wp_enqueue_style ("ws-plugin--s2member", get_bloginfo ("wpurl") . "/?ws_plugin__s2member_css=1&qcABC=1", array (), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"], "all");
30
/**/
31
do_action ("ws_plugin__s2member_during_add_css", get_defined_vars ());
32
}
48
/**/
49
if ($_GET["ws_plugin__s2member_css"])
50
{
51
+ header("Content-Type: text/css; charset=utf-8");
52
+ header("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("+1 week")) . " GMT");
53
+ header("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
54
+ header("Cache-Control: max-age=604800");
55
+ header("Pragma: public");
56
/**/
57
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
58
$i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images";
59
/**/
60
+ ob_start("ws_plugin__s2member_compress_css"); /* Compress. */
61
/**/
62
include_once dirname (dirname (__FILE__)) . "/s2member.css";
63
/**/
71
}
72
/*
73
Function for adding scripts to the header.
74
Do NOT enqueue scripts in the admin area.
75
Attach to: add_action("wp_print_scripts");
76
*/
86
{
87
$a = get_defined_constants (true);
88
$c = (array)$a["user"];
89
+ unset($a);
90
/**/
91
foreach ($c as $k => $v)
92
if (preg_match ("/^S2MEMBER_/i", $k))
94
/**/
95
$md5 = md5 (serialize ($s2member)); /* This is a hash based on the global key => values. */
96
/* The md5 hash allows the script to be cached in the browser until the globals happen to change. */
97
+ /* For instance, the global variables may change when a User who is logged-in changes their Profile. */
98
+ wp_enqueue_script ("ws-plugin--s2member", get_bloginfo ("wpurl") . "/?ws_plugin__s2member_js_w_globals=1&qcABC=1&" . $md5, array ("jquery"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"]);
99
}
100
+ else /* Else if they are not logged in, we distinguish the JavaScript file by NOT including $md5. */
101
{ /* This essentially creates 2 versions of the script. One while logged in & another when not. */
102
+ wp_enqueue_script ("ws-plugin--s2member", get_bloginfo ("wpurl") . "/?ws_plugin__s2member_js_w_globals=1&qcABC=1", array ("jquery"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"]);
103
}
104
/**/
105
do_action ("ws_plugin__s2member_during_add_js_w_globals", get_defined_vars ());
122
/**/
123
if ($_GET["ws_plugin__s2member_js_w_globals"])
124
{
125
+ header("Content-Type: text/javascript; charset=utf-8");
126
+ header("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("+1 week")) . " GMT");
127
+ header("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
128
+ header("Cache-Control: max-age=604800");
129
+ header("Pragma: public");
130
/**/
131
$g = "var S2MEMBER_VERSION = '" . ws_plugin__s2member_esc_sq (S2MEMBER_VERSION) . "',"; /* Since 3.0. */
132
/**/
includes/functions/email-configs.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
Functions that modify the email From: name/address.
18
*/
12
Direct access denial.
13
*/
14
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit("Do not access this file directly.");
16
/*
17
Functions that modify the email From: name/address.
18
*/
includes/functions/file-download-access.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 determines the max period in days for download access.
18
Returns number of days, where 0 means no access to files has been allowed.
@@ -55,7 +55,7 @@ if (!function_exists ("ws_plugin__s2member_user_downloads"))
55
{
56
function ws_plugin__s2member_user_downloads ($not_counting_this_particular_file = false, $log = null)
57
{
58
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
59
do_action ("ws_plugin__s2member_before_user_downloads", get_defined_vars ());
60
unset ($__refs, $__v); /* Unset defined __refs, __v. */
61
/**/
@@ -91,7 +91,7 @@ if (!function_exists ("ws_plugin__s2member_user_downloads"))
91
$allowed_days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"];
92
}
93
/**/
94
- $file_download_access_log = (isset ($log)) ? (array)$log : (array)get_usermeta ($current_user->ID, "s2member_file_download_access_log");
95
foreach ($file_download_access_log as $file_download_access_log_entry_key => $file_download_access_log_entry)
96
if (strtotime ($file_download_access_log_entry["date"]) >= strtotime ("-" . (int)$allowed_days . " days"))
97
if ($file_download_access_log_entry["file"] !== $not_counting_this_particular_file)
@@ -160,21 +160,21 @@ if (!function_exists ("ws_plugin__s2member_check_file_download_access"))
160
/**/
161
if (!file_exists ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]))
162
{
163
- header ("HTTP/1.0 404 Not Found"); /* The file does NOT even exist. */
164
- exit ("404: Sorry, file not found. Please contact Support for assistance.");
165
}
166
else if ($_GET["s2member_file_download_key"] && !$file_download_key_is_valid) /* Was an invalid Key passed in? */
167
{
168
- header ("HTTP/1.0 503 Service Temporarily Unavailable"); /* Invalid Download Keys are handled separately. */
169
- exit ("503 ( Invalid Key ): Sorry, your access to this file has expired. Please contact Support for assistance.");
170
}
171
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Is a Membership Options Page configured? */
172
/* This file will be processed WITHOUT a Download Key, using Membership Level Access ( w/ possible Custom Capabilities ). */
173
{
174
if (($file_download_access_is_allowed = $min_level_4_downloads = ws_plugin__s2member_min_level_4_downloads ()) === false)
175
{
176
- header ("HTTP/1.0 503 Service Temporarily Unavailable"); /* File downloads are NOT yet configured? */
177
- exit ("503: Sorry, file downloads are not enabled yet. Please contact Support for assistance. If you are the site owner, please configure `s2Member -> Download Options`.");
178
}
179
/**/
180
else if (!($current_user = (is_user_logged_in ()) ? wp_get_current_user () : false) /* NOT logged in? */
@@ -185,36 +185,32 @@ if (!function_exists ("ws_plugin__s2member_check_file_download_access"))
185
&& wp_redirect (add_query_arg (array ("s2member_file_download_req" => $_GET["s2member_file_download"]), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]))) !== "nill")
186
exit ();
187
/**/
188
- else if (preg_match ("/^access[_\-]s2member[_\-]level([0-9]+)\//", $_GET["s2member_file_download"])) /* Level required? */
189
{
190
- list ($level_req) = preg_split ("/\//", $_GET["s2member_file_download"], 2); /* Which Level does this require? */
191
- $level_req = preg_replace ("/[^0-9]/", "", $level_req);
192
- /**/
193
if (!$current_user->has_cap ("access_s2member_level" . $level_req) /* Does the User have access to this Level? */
194
&& wp_redirect (add_query_arg (array ("s2member_level_req" => $level_req, "s2member_file_download_req" => $_GET["s2member_file_download"]), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
195
exit ();
196
}
197
/**/
198
- else if (preg_match ("/^access[_\-]s2member[_\-]ccap[_\-](.+?)\//", $_GET["s2member_file_download"])) /* Custom Capability? */
199
{
200
- list ($ccap_req) = preg_split ("/\//", $_GET["s2member_file_download"], 2); /* Which Capability does this require? */
201
- $ccap_req = preg_replace ("/-/", "_", $ccap_req);
202
- /**/
203
- if (!$current_user->has_cap ($ccap_req) /* Does the User have access to this Custom Capability? */
204
&& wp_redirect (add_query_arg (array ("s2member_ccap_req" => $ccap_req, "s2member_file_download_req" => $_GET["s2member_file_download"]), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
205
exit ();
206
}
207
/**/
208
$previous_file_downloads = 0; /* Here we're going to count how many downloads they've performed. */
209
$max_days_logged = ws_plugin__s2member_max_download_period (); /* The longest period in days. */
210
- $file_download_access_log = (array)get_usermeta ($current_user->ID, "s2member_file_download_access_log");
211
- $file_download_access_arc = (array)get_usermeta ($current_user->ID, "s2member_file_download_access_arc");
212
/**/
213
foreach ($file_download_access_log as $file_download_access_log_entry_key => $file_download_access_log_entry)
214
{
215
if (strtotime ($file_download_access_log_entry["date"]) < strtotime ("-" . $max_days_logged . " days"))
216
{
217
- unset ($file_download_access_log[$file_download_access_log_entry_key]);
218
$file_download_access_arc[] = $file_download_access_log_entry;
219
}
220
else if (strtotime ($file_download_access_log_entry["date"]) >= strtotime ("-" . $file_downloads["allowed_days"] . " days"))
@@ -233,8 +229,8 @@ if (!function_exists ("ws_plugin__s2member_check_file_download_access"))
233
if (!$already_downloaded) /* Only add this file to the log if they have not already downloaded it. */
234
$file_download_access_log[] = array ("date" => date ("Y-m-d"), "file" => $_GET["s2member_file_download"]);
235
/**/
236
- update_usermeta ($current_user->ID, "s2member_file_download_access_arc", ws_plugin__s2member_array_unique ($file_download_access_arc));
237
- update_usermeta ($current_user->ID, "s2member_file_download_access_log", ws_plugin__s2member_array_unique ($file_download_access_log));
238
}
239
}
240
else /* Otherwise... it's either $excluded; or permission was granted with a valid Download Key. */
@@ -243,8 +239,8 @@ if (!function_exists ("ws_plugin__s2member_check_file_download_access"))
243
/**/
244
if (!file_exists ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]))
245
{
246
- header ("HTTP/1.0 404 Not Found"); /* The file does NOT even exist. */
247
- exit ("404: Sorry, file not found. Please contact Support for assistance.");
248
}
249
}
250
/*
@@ -258,28 +254,28 @@ if (!function_exists ("ws_plugin__s2member_check_file_download_access"))
258
$basename = $pathinfo["basename"]; /* The actual file name, including its extension. */
259
$length = filesize ($file); /* The overall file size, in bytes. */
260
/**/
261
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
262
do_action ("ws_plugin__s2member_during_file_download_access", get_defined_vars ());
263
unset ($__refs, $__v); /* Unset defined __refs, __v. */
264
/*
265
Now send the file to the browser.
266
Be sure to turn off output compression.
267
*/
268
- set_time_limit (0); /* Make time. */
269
ini_set ("zlib.output_compression", 0);
270
/**/
271
- header ("Content-Encoding: none");
272
- header ("Content-Type: " . $mimetype);
273
- header ("Content-Length: " . $length);
274
/**/
275
if (!$inline) /* If not inline, we default to serving the file as an attachment. */
276
- header ('Content-Disposition: attachment; filename="' . $basename . '"');
277
/**/
278
- header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
279
- header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
280
- header ("Cache-Control: no-cache, must-revalidate, max-age=0");
281
header ("Cache-Control: post-check=0, pre-check=0", false);
282
- header ("Pragma: no-cache");
283
/**/
284
ob_clean () . flush () . readfile ($file);
285
/**/
@@ -299,15 +295,15 @@ if (!function_exists ("ws_plugin__s2member_file_download_key"))
299
{
300
function ws_plugin__s2member_file_download_key ($file = FALSE, $cache_compatible = FALSE)
301
{
302
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
303
do_action ("ws_plugin__s2member_before_file_download_key", get_defined_vars ());
304
unset ($__refs, $__v); /* Unset defined __refs, __v. */
305
/**/
306
$salt = ($cache_compatible) ? $file : date ("Y-m-d") . $_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"] . $file;
307
- $key = md5 (ws_plugin__s2member_xencrypt ($salt));
308
/**/
309
if (!$cache_compatible) /* Disallow caching. */
310
- ws_plugin__s2member_nocache_constants (true);
311
/**/
312
return apply_filters ("ws_plugin__s2member_file_download_key", $key, get_defined_vars ());
313
}
12
Direct access denial.
13
*/
14
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit("Do not access this file directly.");
16
/*
17
Function determines the max period in days for download access.
18
Returns number of days, where 0 means no access to files has been allowed.
55
{
56
function ws_plugin__s2member_user_downloads ($not_counting_this_particular_file = false, $log = null)
57
{
58
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
59
do_action ("ws_plugin__s2member_before_user_downloads", get_defined_vars ());
60
unset ($__refs, $__v); /* Unset defined __refs, __v. */
61
/**/
91
$allowed_days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"];
92
}
93
/**/
94
+ $file_download_access_log = (isset ($log)) ? (array)$log : (array)get_user_option ("s2member_file_download_access_log", $current_user->ID);
95
foreach ($file_download_access_log as $file_download_access_log_entry_key => $file_download_access_log_entry)
96
if (strtotime ($file_download_access_log_entry["date"]) >= strtotime ("-" . (int)$allowed_days . " days"))
97
if ($file_download_access_log_entry["file"] !== $not_counting_this_particular_file)
160
/**/
161
if (!file_exists ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]))
162
{
163
+ header("HTTP/1.0 404 Not Found"); /* The file does NOT even exist. */
164
+ exit("404: Sorry, file not found. Please contact Support for assistance.");
165
}
166
else if ($_GET["s2member_file_download_key"] && !$file_download_key_is_valid) /* Was an invalid Key passed in? */
167
{
168
+ header("HTTP/1.0 503 Service Temporarily Unavailable"); /* Invalid Download Keys are handled separately. */
169
+ exit("503 ( Invalid Key ): Sorry, your access to this file has expired. Please contact Support for assistance.");
170
}
171
else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Is a Membership Options Page configured? */
172
/* This file will be processed WITHOUT a Download Key, using Membership Level Access ( w/ possible Custom Capabilities ). */
173
{
174
if (($file_download_access_is_allowed = $min_level_4_downloads = ws_plugin__s2member_min_level_4_downloads ()) === false)
175
{
176
+ header("HTTP/1.0 503 Service Temporarily Unavailable"); /* File downloads are NOT yet configured? */
177
+ exit("503: Sorry, file downloads are NOT enabled yet. Please contact Support for assistance. If you are the site owner, please configure `s2Member -> Download Options`.");
178
}
179
/**/
180
else if (!($current_user = (is_user_logged_in ()) ? wp_get_current_user () : false) /* NOT logged in? */
185
&& wp_redirect (add_query_arg (array ("s2member_file_download_req" => $_GET["s2member_file_download"]), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]))) !== "nill")
186
exit ();
187
/**/
188
+ else if (preg_match ("/^access[_\-]s2member[_\-]level([0-4])\//", $_GET["s2member_file_download"], $m))
189
{
190
+ $level_req = $m[1]; /* Which Level does this require? */
191
if (!$current_user->has_cap ("access_s2member_level" . $level_req) /* Does the User have access to this Level? */
192
&& wp_redirect (add_query_arg (array ("s2member_level_req" => $level_req, "s2member_file_download_req" => $_GET["s2member_file_download"]), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
193
exit ();
194
}
195
/**/
196
+ else if (preg_match ("/^access[_\-]s2member[_\-]ccap[_\-](.+?)\//", $_GET["s2member_file_download"], $m))
197
{
198
+ $ccap_req = preg_replace ("/-/", "_", $m[1]); /* Which Capability does this require? */
199
+ if (!$current_user->has_cap ("access_s2member_ccap_" . $ccap_req) /* Does the User have access to this Custom Capability? */
200
&& wp_redirect (add_query_arg (array ("s2member_ccap_req" => $ccap_req, "s2member_file_download_req" => $_GET["s2member_file_download"]), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))) !== "nill")
201
exit ();
202
}
203
/**/
204
$previous_file_downloads = 0; /* Here we're going to count how many downloads they've performed. */
205
$max_days_logged = ws_plugin__s2member_max_download_period (); /* The longest period in days. */
206
+ $file_download_access_log = (array)get_user_option ("s2member_file_download_access_log", $current_user->ID);
207
+ $file_download_access_arc = (array)get_user_option ("s2member_file_download_access_arc", $current_user->ID);
208
/**/
209
foreach ($file_download_access_log as $file_download_access_log_entry_key => $file_download_access_log_entry)
210
{
211
if (strtotime ($file_download_access_log_entry["date"]) < strtotime ("-" . $max_days_logged . " days"))
212
{
213
+ unset($file_download_access_log[$file_download_access_log_entry_key]);
214
$file_download_access_arc[] = $file_download_access_log_entry;
215
}
216
else if (strtotime ($file_download_access_log_entry["date"]) >= strtotime ("-" . $file_downloads["allowed_days"] . " days"))
229
if (!$already_downloaded) /* Only add this file to the log if they have not already downloaded it. */
230
$file_download_access_log[] = array ("date" => date ("Y-m-d"), "file" => $_GET["s2member_file_download"]);
231
/**/
232
+ update_user_option ($current_user->ID, "s2member_file_download_access_arc", ws_plugin__s2member_array_unique ($file_download_access_arc));
233
+ update_user_option ($current_user->ID, "s2member_file_download_access_log", ws_plugin__s2member_array_unique ($file_download_access_log));
234
}
235
}
236
else /* Otherwise... it's either $excluded; or permission was granted with a valid Download Key. */
239
/**/
240
if (!file_exists ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]))
241
{
242
+ header("HTTP/1.0 404 Not Found"); /* The file does NOT even exist. */
243
+ exit("404: Sorry, file not found. Please contact Support for assistance.");
244
}
245
}
246
/*
254
$basename = $pathinfo["basename"]; /* The actual file name, including its extension. */
255
$length = filesize ($file); /* The overall file size, in bytes. */
256
/**/
257
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
258
do_action ("ws_plugin__s2member_during_file_download_access", get_defined_vars ());
259
unset ($__refs, $__v); /* Unset defined __refs, __v. */
260
/*
261
Now send the file to the browser.
262
Be sure to turn off output compression.
263
*/
264
+ set_time_limit(0); /* Make time. */
265
ini_set ("zlib.output_compression", 0);
266
/**/
267
+ header("Content-Encoding: none");
268
+ header("Content-Type: " . $mimetype);
269
+ header("Content-Length: " . $length);
270
/**/
271
if (!$inline) /* If not inline, we default to serving the file as an attachment. */
272
+ header('Content-Disposition: attachment; filename="' . $basename . '"');
273
/**/
274
+ header("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
275
+ header("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
276
+ header("Cache-Control: no-cache, must-revalidate, max-age=0");
277
header ("Cache-Control: post-check=0, pre-check=0", false);
278
+ header("Pragma: no-cache");
279
/**/
280
ob_clean () . flush () . readfile ($file);
281
/**/
295
{
296
function ws_plugin__s2member_file_download_key ($file = FALSE, $cache_compatible = FALSE)
297
{
298
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
299
do_action ("ws_plugin__s2member_before_file_download_key", get_defined_vars ());
300
unset ($__refs, $__v); /* Unset defined __refs, __v. */
301
/**/
302
$salt = ($cache_compatible) ? $file : date ("Y-m-d") . $_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"] . $file;
303
+ $key = md5 (ws_plugin__s2member_xencrypt ($salt)); /* Creates a site-specific/xencrytped hash of the salt.
304
/**/
305
if (!$cache_compatible) /* Disallow caching. */
306
+ ws_plugin__s2member_nocache_constants(true);
307
/**/
308
return apply_filters ("ws_plugin__s2member_file_download_key", $key, get_defined_vars ());
309
}
includes/functions/force-ssl.inc.php CHANGED
@@ -18,7 +18,7 @@ Function that forces SSL on specific Posts/Pages.
18
Attach to: add_action("template_redirect");
19
20
Triggered by Custom Field:
21
- s2member_force_ssl = 1
22
*/
23
if (!function_exists ("ws_plugin__s2member_check_force_ssl"))
24
{
18
Attach to: add_action("template_redirect");
19
20
Triggered by Custom Field:
21
+ s2member_force_ssl = yes
22
*/
23
if (!function_exists ("ws_plugin__s2member_check_force_ssl"))
24
{
includes/functions/hide-some-systematics.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 hides some of the systematic use pages.
18
Attach to: add_filter("posts_where");
@@ -23,7 +23,7 @@ if (!function_exists ("ws_plugin__s2member_hide_some_systematics"))
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
/**/
@@ -31,7 +31,7 @@ if (!function_exists ("ws_plugin__s2member_hide_some_systematics"))
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
}
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");
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
/**/
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
}
includes/functions/is-systematic.inc.php CHANGED
@@ -38,7 +38,7 @@ if (!function_exists ("ws_plugin__s2member_is_systematic_use_page"))
38
{
39
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
40
}
41
- else if (preg_match ("/\/wp-login\.php/", $_SERVER["REQUEST_URI"]))
42
{
43
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
44
}
@@ -58,7 +58,7 @@ if (!function_exists ("ws_plugin__s2member_is_systematic_use_page"))
58
{
59
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
60
}
61
- else if (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 ("url"), "/"), PHP_URL_PATH)))
62
{
63
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
64
}
38
{
39
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
40
}
41
+ else if (preg_match ("/\/wp-(signup|register|activate|login)\.php/", $_SERVER["REQUEST_URI"]))
42
{
43
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
44
}
58
{
59
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
60
}
61
+ else if (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)))
62
{
63
return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
64
}
includes/functions/list-servers.inc.php CHANGED
@@ -24,7 +24,7 @@ if (!function_exists ("ws_plugin__s2member_process_list_servers"))
24
do_action ("ws_plugin__s2member_before_process_list_servers", get_defined_vars ());
25
unset ($__refs, $__v); /* Unset defined __refs, __v. */
26
/**/
27
- if (strlen ($level) && is_email ($email) && $opt_in) /* Must have a level, a valid email, and opt-in permission. */
28
{
29
if (($mailchimp_api_key = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]))
30
if (($mailchimp_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]))
24
do_action ("ws_plugin__s2member_before_process_list_servers", get_defined_vars ());
25
unset ($__refs, $__v); /* Unset defined __refs, __v. */
26
/**/
27
+ if (strlen ($level) && is_email ($email) && $opt_in) /* Must have a Level, a valid email, and opt-in permission. */
28
{
29
if (($mailchimp_api_key = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]))
30
if (($mailchimp_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]))
includes/functions/login-customizations.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 filtering the login logo url.
18
Attach to: add_filter("login_headerurl");
@@ -53,18 +53,19 @@ if (!function_exists ("ws_plugin__s2member_login_header_styles"))
53
{
54
$s = ""; /* Initialize here to give hooks a chance. */
55
/**/
56
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
57
do_action ("ws_plugin__s2member_before_login_header_styles", get_defined_vars ());
58
unset ($__refs, $__v); /* Unset defined __refs, __v. */
59
/**/
60
$s .= "\n" . '<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>' . "\n";
61
- $s .= '<script type="text/javascript" src="' . get_bloginfo ("url") . '/?ws_plugin__s2member_js_w_globals=1&amp;no-cache=' . urlencode (md5 (mt_rand ())) . '"></script>' . "\n";
62
/**/
63
$s .= "\n" . '<style type="text/css">' . "\n";
64
/**/
65
$s .= 'html, body { border: 0 !important; background: none !important; }' . "\n"; /* Clear borders & existing background. */
66
$s .= 'html { background-color: #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_color"] . ' !important; }' . "\n";
67
$s .= 'html { background-image: url(' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image"] . ') !important; }' . "\n";
68
/**/
69
$s .= 'p#backtoblog a, p#backtoblog a:hover, p#backtoblog a:active, p#backtoblog a:focus { color: #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_color"] . ' !important; text-shadow: 1px 1px 3px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_shadow_color"] . ' !important; top: 15px !important; left: 15px !important; padding: 10px !important; border:1px solid #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . ' !important; background-color: #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_color"] . ' !important; -moz-border-radius:3px !important; -webkit-border-radius:3px !important; border-radius:3px !important; }' . "\n";
70
/**/
@@ -83,7 +84,7 @@ if (!function_exists ("ws_plugin__s2member_login_header_styles"))
83
/**/
84
$s .= '</style>' . "\n\n";
85
/**/
86
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
87
do_action ("ws_plugin__s2member_during_login_header_styles", get_defined_vars ());
88
unset ($__refs, $__v); /* Unset defined __refs, __v. */
89
/**/
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 filtering the login logo url.
18
Attach to: add_filter("login_headerurl");
53
{
54
$s = ""; /* Initialize here to give hooks a chance. */
55
/**/
56
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
57
do_action ("ws_plugin__s2member_before_login_header_styles", get_defined_vars ());
58
unset ($__refs, $__v); /* Unset defined __refs, __v. */
59
/**/
60
$s .= "\n" . '<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>' . "\n";
61
+ $s .= '<script type="text/javascript" src="' . get_bloginfo ("wpurl") . '/?ws_plugin__s2member_js_w_globals=1&amp;no-cache=' . urlencode (md5 (mt_rand ())) . '"></script>' . "\n";
62
/**/
63
$s .= "\n" . '<style type="text/css">' . "\n";
64
/**/
65
$s .= 'html, body { border: 0 !important; background: none !important; }' . "\n"; /* Clear borders & existing background. */
66
$s .= 'html { background-color: #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_color"] . ' !important; }' . "\n";
67
$s .= 'html { background-image: url(' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image"] . ') !important; }' . "\n";
68
+ $s .= 'html { background-repeat: ' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image_repeat"] . ' !important; }' . "\n";
69
/**/
70
$s .= 'p#backtoblog a, p#backtoblog a:hover, p#backtoblog a:active, p#backtoblog a:focus { color: #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_color"] . ' !important; text-shadow: 1px 1px 3px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_shadow_color"] . ' !important; top: 15px !important; left: 15px !important; padding: 10px !important; border:1px solid #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . ' !important; background-color: #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_color"] . ' !important; -moz-border-radius:3px !important; -webkit-border-radius:3px !important; border-radius:3px !important; }' . "\n";
71
/**/
84
/**/
85
$s .= '</style>' . "\n\n";
86
/**/
87
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
88
do_action ("ws_plugin__s2member_during_login_header_styles", get_defined_vars ());
89
unset ($__refs, $__v); /* Unset defined __refs, __v. */
90
/**/
includes/functions/login-redirection.inc.php CHANGED
@@ -25,12 +25,23 @@ if (!function_exists ("ws_plugin__s2member_login_redirect"))
25
do_action ("ws_plugin__s2member_before_login_redirect", get_defined_vars ());
26
unset ($__refs, $__v); /* Unset defined __refs, __v. */
27
/**/
28
- if (!is_object ($user = new WP_User ($username)) || !$user->ID || !$user->has_cap ("edit_posts"))
29
{
30
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
31
do_action ("ws_plugin__s2member_during_login_redirect", get_defined_vars ());
32
unset ($__refs, $__v); /* Unset defined __refs, __v. */
33
/**/
34
if (ws_plugin__s2member_ip_restrictions_ok ($_SERVER["REMOTE_ADDR"], strtolower ($username)))
35
{
36
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"])
25
do_action ("ws_plugin__s2member_before_login_redirect", get_defined_vars ());
26
unset ($__refs, $__v); /* Unset defined __refs, __v. */
27
/**/
28
+ $username = (!$username && is_object ($current_user = wp_get_current_user ())) ? $current_user->user_login : $username;
29
+ /* This additional check was added in case wp_signon() fires this event with empty $_POST credentials.
30
+ In this rare case, we can check to see if WordPress® is remembering a previously logged in User. */
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"])
includes/functions/menu-pages.inc.php CHANGED
@@ -18,15 +18,18 @@ Function for saving all options from any page.
18
*/
19
if (!function_exists ("ws_plugin__s2member_update_all_options"))
20
{
21
- function ws_plugin__s2member_update_all_options ()
22
{
23
do_action ("ws_plugin__s2member_before_update_all_options", get_defined_vars ());
24
/**/
25
- if (($nonce = $_POST["ws_plugin__s2member_options_save"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-options-save"))
26
{
27
$options = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]; /* Get current options. */
28
/**/
29
- foreach ($_POST as $key => $value) /* Go through each post variable and look for s2member. */
30
{
31
if (preg_match ("/^" . preg_quote ("ws_plugin__s2member", "/") . "/", $key)) /* Look for keys. */
32
{
@@ -34,7 +37,7 @@ if (!function_exists ("ws_plugin__s2member_update_all_options"))
34
{
35
update_option ("ws_plugin__s2member_configured", trim (stripslashes ($value))); /* Update this option separately. */
36
/**/
37
- $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"] = trim (stripslashes ($value)); /* Update configuration on-the-fly. */
38
}
39
else /* We need to place this option into the array. Here we remove the ws_plugin__s2member_ portion on the beginning. */
40
{
@@ -54,15 +57,24 @@ if (!function_exists ("ws_plugin__s2member_update_all_options"))
54
/**/
55
update_option ("ws_plugin__s2member_options", $options) . update_option ("ws_plugin__s2member_cache", array ());
56
/**/
57
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"] == 1)
58
- ws_plugin__s2member_add_auto_eot_system (); /* 1 == WP-Cron. */
59
- else /* Otherwise, the Auto-EOT System via WP-Cron is disabled. */
60
- ws_plugin__s2member_delete_auto_eot_system ();
61
/**/
62
- ws_plugin__s2member_display_admin_notice('<strong>Options saved.</strong>');
63
/**/
64
if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
65
- ws_plugin__s2member_display_admin_notice ('<strong>NOTE:</strong> s2Member security restrictions will NOT be enforced until you\'ve configured a Membership Options Page. See: <code>s2Member -> General Options -> Membership Options Page</code>.', true);
66
}
67
/**/
68
do_action ("ws_plugin__s2member_after_update_all_options", get_defined_vars ());
@@ -78,46 +90,66 @@ if (!function_exists ("ws_plugin__s2member_add_admin_options"))
78
{
79
function ws_plugin__s2member_add_admin_options ()
80
{
81
- global $menu; /* Need this to work out positioning. */
82
- /**/
83
do_action ("ws_plugin__s2member_before_add_admin_options", get_defined_vars ());
84
/**/
85
add_filter ("plugin_action_links", "_ws_plugin__s2member_add_settings_link", 10, 2);
86
/**/
87
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_create_menu_items", true, get_defined_vars ()))
88
{
89
- add_menu_page ("s2Member Options", "s2Member", "edit_plugins", "ws-plugin--s2member-options", "ws_plugin__s2member_options_page");
90
- add_submenu_page ("ws-plugin--s2member-options", "s2Member General Options", "General Options", "edit_plugins", "ws-plugin--s2member-options", "ws_plugin__s2member_options_page");
91
/**/
92
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_paypal_ops_page", true, get_defined_vars ()))
93
- add_submenu_page ("ws-plugin--s2member-options", "s2Member PayPal Options", "PayPal® Options", "edit_plugins", "ws-plugin--s2member-paypal-ops", "ws_plugin__s2member_paypal_ops_page");
94
/**/
95
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_paypal_buttons_page", true, get_defined_vars ()))
96
- add_submenu_page ("ws-plugin--s2member-options", "s2Member PayPal® Buttons", "PayPal® Buttons", "edit_plugins", "ws-plugin--s2member-paypal-buttons", "ws_plugin__s2member_paypal_buttons_page");
97
/**/
98
- if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_down_ops_page", true, get_defined_vars ()))
99
- add_submenu_page ("ws-plugin--s2member-options", "s2Member File Download Options", "Download Options", "edit_plugins", "ws-plugin--s2member-down-ops", "ws_plugin__s2member_down_ops_page");
100
/**/
101
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_trk_ops_page", true, get_defined_vars ()))
102
- add_submenu_page ("ws-plugin--s2member-options", "s2Member API / Tracking", "API / Tracking", "edit_plugins", "ws-plugin--s2member-trk-ops", "ws_plugin__s2member_trk_ops_page");
103
/**/
104
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_els_ops_page", true, get_defined_vars ()))
105
- add_submenu_page ("ws-plugin--s2member-options", "s2Member API / List Servers", "API / List Servers", "edit_plugins", "ws-plugin--s2member-els-ops", "ws_plugin__s2member_els_ops_page");
106
/**/
107
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_api_ops_page", true, get_defined_vars ()))
108
- add_submenu_page ("ws-plugin--s2member-options", "s2Member API / Notifications", "API / Notifications", "edit_plugins", "ws-plugin--s2member-api-ops", "ws_plugin__s2member_api_ops_page");
109
/**/
110
- if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_scripting_page", true, get_defined_vars ()))
111
- add_submenu_page ("ws-plugin--s2member-options", "s2Member API / Scripting", "API / Scripting", "edit_plugins", "ws-plugin--s2member-scripting", "ws_plugin__s2member_scripting_page");
112
/**/
113
- if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_bridges_page", true, get_defined_vars ()))
114
- add_submenu_page ("ws-plugin--s2member-options", "s2Member Bridge Integrations", "API / Bridges", "edit_plugins", "ws-plugin--s2member-bridges", "ws_plugin__s2member_bridges_page");
115
/**/
116
- if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_info_page", true, get_defined_vars ()))
117
- add_submenu_page ("ws-plugin--s2member-options", "s2Member Information", "s2Member Info", "edit_plugins", "ws-plugin--s2member-info", "ws_plugin__s2member_info_page");
118
/**/
119
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_start_page", true, get_defined_vars ()))
120
- add_submenu_page ("ws-plugin--s2member-options", "s2Member Quick-Start Guide", "Quick-Start Guide", "edit_plugins", "ws-plugin--s2member-start", "ws_plugin__s2member_start_page");
121
}
122
/**/
123
do_action ("ws_plugin__s2member_after_add_admin_options", get_defined_vars ());
@@ -164,7 +196,7 @@ if (!function_exists ("ws_plugin__s2member_add_admin_scripts"))
164
wp_enqueue_script("jquery");
165
wp_enqueue_script("thickbox");
166
wp_enqueue_script("media-upload");
167
- wp_enqueue_script ("ws-plugin--s2member-menu-pages", get_bloginfo ("url") . "/?ws_plugin__s2member_menu_pages_js=1", array ("jquery", "thickbox", "media-upload"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"]);
168
/**/
169
do_action ("ws_plugin__s2member_during_add_admin_scripts", get_defined_vars ());
170
}
@@ -187,7 +219,7 @@ if (!function_exists ("ws_plugin__s2member_add_admin_styles"))
187
if ($_GET["page"] && preg_match ("/ws-plugin--s2member-/", $_GET["page"]))
188
{
189
wp_enqueue_style("thickbox");
190
- wp_enqueue_style ("ws-plugin--s2member-menu-pages", get_bloginfo ("url") . "/?ws_plugin__s2member_menu_pages_css=1", array ("thickbox"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"], "all");
191
/**/
192
do_action ("ws_plugin__s2member_during_add_admin_styles", get_defined_vars ());
193
}
@@ -207,7 +239,7 @@ if (!function_exists ("ws_plugin__s2member_menu_pages_js"))
207
{
208
do_action ("ws_plugin__s2member_before_menu_pages_js", get_defined_vars ());
209
/**/
210
- if ($_GET["ws_plugin__s2member_menu_pages_js"] && is_user_logged_in () && current_user_can ("edit_plugins"))
211
{
212
header("Content-Type: text/javascript; charset=utf-8");
213
header("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
@@ -242,7 +274,7 @@ if (!function_exists ("ws_plugin__s2member_menu_pages_css"))
242
{
243
do_action ("ws_plugin__s2member_before_menu_pages_css", get_defined_vars ());
244
/**/
245
- if ($_GET["ws_plugin__s2member_menu_pages_css"] && is_user_logged_in () && current_user_can ("edit_plugins"))
246
{
247
header("Content-Type: text/css; charset=utf-8");
248
header("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
@@ -270,12 +302,64 @@ if (!function_exists ("ws_plugin__s2member_menu_pages_css"))
270
}
271
}
272
/*
273
Function for building and handling the General Options page.
274
*/
275
if (!function_exists ("ws_plugin__s2member_options_page"))
276
{
277
function ws_plugin__s2member_options_page ()
278
{
279
do_action ("ws_plugin__s2member_before_options_page", get_defined_vars ());
280
/**/
281
ws_plugin__s2member_update_all_options ();
@@ -294,6 +378,8 @@ if (!function_exists ("ws_plugin__s2member_paypal_ops_page"))
294
{
295
function ws_plugin__s2member_paypal_ops_page ()
296
{
297
do_action ("ws_plugin__s2member_before_paypal_ops_page", get_defined_vars ());
298
/**/
299
ws_plugin__s2member_update_all_options ();
@@ -337,6 +423,8 @@ if (!function_exists ("ws_plugin__s2member_down_ops_page"))
337
{
338
function ws_plugin__s2member_down_ops_page ()
339
{
340
do_action ("ws_plugin__s2member_before_down_ops_page", get_defined_vars ());
341
/**/
342
ws_plugin__s2member_update_all_options ();
@@ -374,6 +462,8 @@ if (!function_exists ("ws_plugin__s2member_trk_ops_page"))
374
{
375
function ws_plugin__s2member_trk_ops_page ()
376
{
377
do_action ("ws_plugin__s2member_before_trk_ops_page", get_defined_vars ());
378
/**/
379
ws_plugin__s2member_update_all_options ();
@@ -392,6 +482,8 @@ if (!function_exists ("ws_plugin__s2member_els_ops_page"))
392
{
393
function ws_plugin__s2member_els_ops_page ()
394
{
395
do_action ("ws_plugin__s2member_before_els_ops_page", get_defined_vars ());
396
/**/
397
ws_plugin__s2member_update_all_options ();
@@ -410,6 +502,8 @@ if (!function_exists ("ws_plugin__s2member_api_ops_page"))
410
{
411
function ws_plugin__s2member_api_ops_page ()
412
{
413
do_action ("ws_plugin__s2member_before_api_ops_page", get_defined_vars ());
414
/**/
415
ws_plugin__s2member_update_all_options ();
@@ -428,6 +522,8 @@ if (!function_exists ("ws_plugin__s2member_paypal_buttons_page"))
428
{
429
function ws_plugin__s2member_paypal_buttons_page ()
430
{
431
do_action ("ws_plugin__s2member_before_paypal_buttons_page", get_defined_vars ());
432
/**/
433
if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"]) /* Report error if PayPal® Options are not yet configured. */
@@ -447,6 +543,8 @@ if (!function_exists ("ws_plugin__s2member_scripting_page"))
447
{
448
function ws_plugin__s2member_scripting_page ()
449
{
450
do_action ("ws_plugin__s2member_before_scripting_page", get_defined_vars ());
451
/**/
452
include_once dirname (dirname (__FILE__)) . "/menu-pages/scripting.inc.php";
@@ -463,6 +561,8 @@ if (!function_exists ("ws_plugin__s2member_bridges_page"))
463
{
464
function ws_plugin__s2member_bridges_page ()
465
{
466
do_action ("ws_plugin__s2member_before_bridges_page", get_defined_vars ());
467
/**/
468
if (($nonce = $_POST["ws_plugin__s2member_bridge_bbpress"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-bridge-bbpress"))
@@ -525,6 +625,8 @@ if (!function_exists ("ws_plugin__s2member_info_page"))
525
{
526
function ws_plugin__s2member_info_page ()
527
{
528
do_action ("ws_plugin__s2member_before_info_page", get_defined_vars ());
529
/**/
530
include_once dirname (dirname (__FILE__)) . "/menu-pages/info.inc.php";
@@ -541,6 +643,8 @@ if (!function_exists ("ws_plugin__s2member_start_page"))
541
{
542
function ws_plugin__s2member_start_page ()
543
{
544
do_action ("ws_plugin__s2member_before_start_page", get_defined_vars ());
545
/**/
546
include_once dirname (dirname (__FILE__)) . "/menu-pages/start.inc.php";
18
*/
19
if (!function_exists ("ws_plugin__s2member_update_all_options"))
20
{
21
+ function ws_plugin__s2member_update_all_options ($new_options = FALSE, $verified = FALSE, $update_other = TRUE, $display_notices = TRUE, $enqueue_notices = FALSE)
22
{
23
do_action ("ws_plugin__s2member_before_update_all_options", get_defined_vars ());
24
/**/
25
+ if ($verified || (($nonce = $_POST["ws_plugin__s2member_options_save"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-options-save")))
26
{
27
+ unset($_POST["ws_plugin__s2member_options_save"]); /* Unset this key before we begin. */
28
+ /**/
29
$options = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]; /* Get current options. */
30
+ $new_options = (is_array ($new_options)) ? $new_options : $_POST; /* New! */
31
/**/
32
+ foreach ($new_options as $key => $value) /* Go through each POST variable and look for s2member. */
33
{
34
if (preg_match ("/^" . preg_quote ("ws_plugin__s2member", "/") . "/", $key)) /* Look for keys. */
35
{
37
{
38
update_option ("ws_plugin__s2member_configured", trim (stripslashes ($value))); /* Update this option separately. */
39
/**/
40
+ $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"] = trim (stripslashes ($value)); /* Update on-the-fly. */
41
}
42
else /* We need to place this option into the array. Here we remove the ws_plugin__s2member_ portion on the beginning. */
43
{
57
/**/
58
update_option ("ws_plugin__s2member_options", $options) . update_option ("ws_plugin__s2member_cache", array ());
59
/**/
60
+ if ($update_other === true || (is_array ($update_other) && in_array ("auto_eot_system", $update_other)))
61
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"] == 1)
62
+ ws_plugin__s2member_add_auto_eot_system (); /* 1 == WP-Cron. */
63
+ else /* Otherwise, the Auto-EOT System via WP-Cron is disabled. */
64
+ ws_plugin__s2member_delete_auto_eot_system ();
65
/**/
66
+ if ($display_notices === true || (is_array ($display_notices) && in_array ("options_saved", $display_notices)))
67
+ if ($enqueue_notices === true || (is_array ($enqueue_notices) && in_array ("options_saved", $enqueue_notices)))
68
+ ws_plugin__s2member_enqueue_admin_notice('<strong>Options saved.</strong>');
69
+ else /* Otherwise, we can go ahead and display the notice immediately. Not queuing. */
70
+ ws_plugin__s2member_display_admin_notice('<strong>Options saved.</strong>');
71
/**/
72
if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
73
+ if ($display_notices === true || (is_array ($display_notices) && in_array ("membership_options_page_warning", $display_notices)))
74
+ if ($enqueue_notices === true || (is_array ($enqueue_notices) && in_array ("membership_options_page_warning", $enqueue_notices)))
75
+ ws_plugin__s2member_enqueue_admin_notice ('<strong>NOTE:</strong> s2Member security restrictions will NOT be enforced until you\'ve configured a Membership Options Page. See: <code>s2Member -> General Options -> Membership Options Page</code>.', false, true);
76
+ else /* Otherwise, we can go ahead and display the notice immediately. Not queuing. */
77
+ ws_plugin__s2member_display_admin_notice ('<strong>NOTE:</strong> s2Member security restrictions will NOT be enforced until you\'ve configured a Membership Options Page. See: <code>s2Member -> General Options -> Membership Options Page</code>.', true);
78
}
79
/**/
80
do_action ("ws_plugin__s2member_after_update_all_options", get_defined_vars ());
90
{
91
function ws_plugin__s2member_add_admin_options ()
92
{
93
do_action ("ws_plugin__s2member_before_add_admin_options", get_defined_vars ());
94
/**/
95
add_filter ("plugin_action_links", "_ws_plugin__s2member_add_settings_link", 10, 2);
96
/**/
97
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_create_menu_items", true, get_defined_vars ()))
98
{
99
+ if (is_multisite () && ws_plugin__s2member_is_multisite_farm () && !is_main_site ())
100
+ $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"] = array (); /* Clear right side. */
101
+ /**/
102
+ if (is_multisite () && is_main_site ()) /* Re-organize menu whenever Multisite Networking is enabled; and we're on the Main Site. */
103
+ {
104
+ $menu = "ws-plugin--s2member-mms-options"; /* Used below for nesting additional sub-menu pages. */
105
+ /**/
106
+ add_menu_page ("s2Member Options", "s2Member", "create_users", $menu, "ws_plugin__s2member_mms_options_page", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images/brand-favicon.png");
107
+ /**/
108
+ add_submenu_page ($menu, "s2Member Multisite ( Main Site Configuration )", "Multisite (Config)", "create_users", "ws-plugin--s2member-mms-options", "ws_plugin__s2member_mms_options_page");
109
+ add_submenu_page ($menu, "s2Member General Options", "General Options", "create_users", "ws-plugin--s2member-options", "ws_plugin__s2member_options_page");
110
+ }
111
+ else /* Otherwise, we use the standard menu configuration here. The parent menu is the General Options for s2Member in this case. */
112
+ {
113
+ $menu = "ws-plugin--s2member-options"; /* Used below for nesting additional sub-menu pages. */
114
+ /**/
115
+ add_menu_page ("s2Member Options", "s2Member", "create_users", $menu, "ws_plugin__s2member_options_page", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images/brand-favicon.png");
116
+ /**/
117
+ add_submenu_page ($menu, "s2Member General Options", "General Options", "create_users", "ws-plugin--s2member-options", "ws_plugin__s2member_options_page");
118
+ (!is_multisite ()) ? add_submenu_page ($menu, "s2Member Multisite ( NOT enabled )", "Multisite Config", "create_users", "ws-plugin--s2member-mms-options", "ws_plugin__s2member_mms_options_page") : null;
119
+ }
120
+ /**/
121
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_new_user_page", true, get_defined_vars ())) /* Shortcut. */
122
+ add_submenu_page ($menu, "s2Member / Add A Member", "Add A Member", "create_users", "user-new.php"); /* Shortcut to user-new.php. */
123
/**/
124
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_paypal_ops_page", true, get_defined_vars ()))
125
+ add_submenu_page ($menu, "s2Member PayPal Options", "PayPal® Options", "create_users", "ws-plugin--s2member-paypal-ops", "ws_plugin__s2member_paypal_ops_page");
126
/**/
127
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_paypal_buttons_page", true, get_defined_vars ()))
128
+ add_submenu_page ($menu, "s2Member PayPal® Buttons", "PayPal® Buttons", "create_users", "ws-plugin--s2member-paypal-buttons", "ws_plugin__s2member_paypal_buttons_page");
129
/**/
130
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_down_ops_page", (!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ()), get_defined_vars ()))
131
+ add_submenu_page ($menu, "s2Member File Download Options", "Download Options", "create_users", "ws-plugin--s2member-down-ops", "ws_plugin__s2member_down_ops_page");
132
/**/
133
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_trk_ops_page", true, get_defined_vars ()))
134
+ add_submenu_page ($menu, "s2Member API / Tracking", "API / Tracking", "create_users", "ws-plugin--s2member-trk-ops", "ws_plugin__s2member_trk_ops_page");
135
/**/
136
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_els_ops_page", true, get_defined_vars ()))
137
+ add_submenu_page ($menu, "s2Member API / List Servers", "API / List Servers", "create_users", "ws-plugin--s2member-els-ops", "ws_plugin__s2member_els_ops_page");
138
/**/
139
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_api_ops_page", true, get_defined_vars ()))
140
+ add_submenu_page ($menu, "s2Member API / Notifications", "API / Notifications", "create_users", "ws-plugin--s2member-api-ops", "ws_plugin__s2member_api_ops_page");
141
/**/
142
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_scripting_page", (!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ()), get_defined_vars ()))
143
+ add_submenu_page ($menu, "s2Member API / Scripting", "API / Scripting", "create_users", "ws-plugin--s2member-scripting", "ws_plugin__s2member_scripting_page");
144
/**/
145
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_bridges_page", (!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ()), get_defined_vars ()))
146
+ add_submenu_page ($menu, "s2Member Bridge Integrations", "API / Bridges", "create_users", "ws-plugin--s2member-bridges", "ws_plugin__s2member_bridges_page");
147
/**/
148
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_info_page", (!is_multisite () || !ws_plugin__s2member_is_multisite_farm () || is_main_site ()), get_defined_vars ()))
149
+ add_submenu_page ($menu, "s2Member Information", "s2Member Info", "create_users", "ws-plugin--s2member-info", "ws_plugin__s2member_info_page");
150
/**/
151
if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_start_page", true, get_defined_vars ()))
152
+ add_submenu_page ($menu, "s2Member Quick-Start Guide", "Quick-Start Guide", "create_users", "ws-plugin--s2member-start", "ws_plugin__s2member_start_page");
153
}
154
/**/
155
do_action ("ws_plugin__s2member_after_add_admin_options", get_defined_vars ());
196
wp_enqueue_script("jquery");
197
wp_enqueue_script("thickbox");
198
wp_enqueue_script("media-upload");
199
+ wp_enqueue_script ("ws-plugin--s2member-menu-pages", get_bloginfo ("wpurl") . "/?ws_plugin__s2member_menu_pages_js=1", array ("jquery", "thickbox", "media-upload"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"]);
200
/**/
201
do_action ("ws_plugin__s2member_during_add_admin_scripts", get_defined_vars ());
202
}
219
if ($_GET["page"] && preg_match ("/ws-plugin--s2member-/", $_GET["page"]))
220
{
221
wp_enqueue_style("thickbox");
222
+ wp_enqueue_style ("ws-plugin--s2member-menu-pages", get_bloginfo ("wpurl") . "/?ws_plugin__s2member_menu_pages_css=1", array ("thickbox"), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["options_version"] . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["filemtime"], "all");
223
/**/
224
do_action ("ws_plugin__s2member_during_add_admin_styles", get_defined_vars ());
225
}
239
{
240
do_action ("ws_plugin__s2member_before_menu_pages_js", get_defined_vars ());
241
/**/
242
+ if ($_GET["ws_plugin__s2member_menu_pages_js"] && is_user_logged_in () && current_user_can ("create_users"))
243
{
244
header("Content-Type: text/javascript; charset=utf-8");
245
header("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
274
{
275
do_action ("ws_plugin__s2member_before_menu_pages_css", get_defined_vars ());
276
/**/
277
+ if ($_GET["ws_plugin__s2member_menu_pages_css"] && is_user_logged_in () && current_user_can ("create_users"))
278
{
279
header("Content-Type: text/css; charset=utf-8");
280
header("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
302
}
303
}
304
/*
305
+ Function for building and handling the Main Multisite Options page.
306
+ */
307
+ if (!function_exists ("ws_plugin__s2member_mms_options_page"))
308
+ {
309
+ function ws_plugin__s2member_mms_options_page ()
310
+ {
311
+ global $current_site, $current_blog; /* Multisite Networking. */
312
+ /**/
313
+ do_action ("ws_plugin__s2member_before_mms_options_page", get_defined_vars ());
314
+ /**/
315
+ ws_plugin__s2member_update_all_options ();
316
+ /**/
317
+ if (($nonce = $_POST["ws_plugin__s2member_mms_options_patch_files"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-mms-options-patch-files"))
318
+ {
319
+ $wp_login_file = ABSPATH . "wp-login.php";
320
+ $wp_login_section = "/([\r\n\t\s ]+)(wp_redirect( *?)\(( *?)apply_filters( *?)\(( *?)['\"]wp_signup_location['\"],( *?)get_bloginfo( *?)\(['\"]wpurl['\"]\)( *?)\.( *?)['\"]\/wp-signup\.php['\"]( *?)\)( *?)\);)([\r\n\t\s ]+)(exit;)/";
321
+ $wp_login_replace = "\n\t\t// Modified for full plugin compatiblity.\n\t\t//wp_redirect( apply_filters( 'wp_signup_location', get_bloginfo('wpurl') . '/wp-signup.php' ) );\n\t\t//exit;";
322
+ /**/
323
+ if (file_exists ($wp_login_file) && is_writable ($wp_login_file) && ($wp_login = file_get_contents ($wp_login_file)) && file_put_contents ($wp_login_file, preg_replace ($wp_login_section, $wp_login_replace, $wp_login)))
324
+ ws_plugin__s2member_display_admin_notice('Your <code>/wp-login.php</code> file was patched successfully.');
325
+ else /* Otherwise, we need to report that /wp-login.php could NOT be updated. Possibly a permissions error. */
326
+ ws_plugin__s2member_display_admin_notice ('Your <code>wp-login.php</code> file could NOT be patched. File NOT writable.', true);
327
+ /**/
328
+ $load_file = ABSPATH . WPINC . "/load.php";
329
+ $load_section = "/([\r\n\t\s ]+)(if( *?)\(( *?)empty( *?)\(( *?)\\\$active_plugins( *?)\)( *?)\|\|( *?)defined( *?)\(( *?)['\"]WP_INSTALLING['\"]( *?)\)( *?)\))/";
330
+ $load_replace = "\n\n\t// Modified for full plugin compatiblity.\n\t//if ( empty( \$active_plugins ) || defined( 'WP_INSTALLING' ) )\n\tif ( empty( \$active_plugins ) || ( defined( 'WP_INSTALLING' ) && !preg_match(\"/\/wp-activate\.php/\", \$_SERVER[\"REQUEST_URI\"]) ) )";
331
+ /**/
332
+ if (file_exists ($load_file) && is_writable ($load_file) && ($load = file_get_contents ($load_file)) && file_put_contents ($load_file, preg_replace ($load_section, $load_replace, $load)))
333
+ ws_plugin__s2member_display_admin_notice('Your <code>/wp-includes/load.php</code> file was patched successfully.');
334
+ else /* Otherwise, we need to report that /wp-includes/load.php could NOT be updated. Possibly a permissions error. */
335
+ ws_plugin__s2member_display_admin_notice ('Your <code>/wp-includes/load.php</code> file could NOT be patched. File NOT writable.', true);
336
+ /**/
337
+ $user_new_file = ABSPATH . "wp-admin/user-new.php";
338
+ $user_new_section = "/([\r\n\t\s ]+)(wpmu_signup_user( *?)\(( *?)\\\$new_user_login,( *?)\\\$_REQUEST\[( *?)'email'( *?)\],( *?)array( *?)\(( *?)'add_to_blog'( *?)\=\>( *?)\\\$wpdb->blogid,( *?)'new_role'( *?)\=\>( *?)\\\$_REQUEST\[( *?)'role'( *?)\]( *?)\)( *?)\);)/";
339
+ $user_new_replace = "\n\t\t\t\t// Modified for full plugin compatiblity.\n\t\t\t\t//wpmu_signup_user( \$new_user_login, \$_REQUEST[ 'email' ], array( 'add_to_blog' => \$wpdb->blogid, 'new_role' => \$_REQUEST[ 'role' ] ) );\n\t\t\t\twpmu_signup_user( \$new_user_login, \$_REQUEST[ 'email' ], apply_filters( 'add_signup_meta', array( 'add_to_blog' => \$wpdb->blogid, 'new_role' => \$_REQUEST[ 'role' ] ) ) );";
340
+ /**/
341
+ if (file_exists ($user_new_file) && is_writable ($user_new_file) && ($user_new = file_get_contents ($user_new_file)) && file_put_contents ($user_new_file, preg_replace ($user_new_section, $user_new_replace, $user_new)))
342
+ ws_plugin__s2member_display_admin_notice('Your <code>/wp-admin/user-new.php</code> file was patched successfully.');
343
+ else /* Otherwise, we need to report that /wp-admin/user-new.php could NOT be updated. Possibly a permissions error. */
344
+ ws_plugin__s2member_display_admin_notice ('Your <code>/wp-admin/user-new.php</code> file could NOT be patched. File NOT writable.', true);
345
+ }
346
+ /**/
347
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/mms-options.inc.php";
348
+ /**/
349
+ do_action ("ws_plugin__s2member_after_mms_options_page", get_defined_vars ());
350
+ /**/
351
+ return;
352
+ }
353
+ }
354
+ /*
355
Function for building and handling the General Options page.
356
*/
357
if (!function_exists ("ws_plugin__s2member_options_page"))
358
{
359
function ws_plugin__s2member_options_page ()
360
{
361
+ global $current_site, $current_blog; /* Multisite Networking. */
362
+ /**/
363
do_action ("ws_plugin__s2member_before_options_page", get_defined_vars ());
364
/**/
365
ws_plugin__s2member_update_all_options ();
378
{
379
function ws_plugin__s2member_paypal_ops_page ()
380
{
381
+ global $current_site, $current_blog; /* Multisite Networking. */
382
+ /**/
383
do_action ("ws_plugin__s2member_before_paypal_ops_page", get_defined_vars ());
384
/**/
385
ws_plugin__s2member_update_all_options ();
423
{
424
function ws_plugin__s2member_down_ops_page ()
425
{
426
+ global $current_site, $current_blog; /* Multisite Networking. */
427
+ /**/
428
do_action ("ws_plugin__s2member_before_down_ops_page", get_defined_vars ());
429
/**/
430
ws_plugin__s2member_update_all_options ();
462
{
463
function ws_plugin__s2member_trk_ops_page ()
464
{
465
+ global $current_site, $current_blog; /* Multisite Networking. */
466
+ /**/
467
do_action ("ws_plugin__s2member_before_trk_ops_page", get_defined_vars ());
468
/**/
469
ws_plugin__s2member_update_all_options ();
482
{
483
function ws_plugin__s2member_els_ops_page ()
484
{
485
+ global $current_site, $current_blog; /* Multisite Networking. */
486
+ /**/
487
do_action ("ws_plugin__s2member_before_els_ops_page", get_defined_vars ());
488
/**/
489
ws_plugin__s2member_update_all_options ();
502
{
503
function ws_plugin__s2member_api_ops_page ()
504
{
505
+ global $current_site, $current_blog; /* Multisite Networking. */
506
+ /**/
507
do_action ("ws_plugin__s2member_before_api_ops_page", get_defined_vars ());
508
/**/
509
ws_plugin__s2member_update_all_options ();
522
{
523
function ws_plugin__s2member_paypal_buttons_page ()
524
{
525
+ global $current_site, $current_blog; /* Multisite Networking. */
526
+ /**/
527
do_action ("ws_plugin__s2member_before_paypal_buttons_page", get_defined_vars ());
528
/**/
529
if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"]) /* Report error if PayPal® Options are not yet configured. */
543
{
544
function ws_plugin__s2member_scripting_page ()
545
{
546
+ global $current_site, $current_blog; /* Multisite Networking. */
547
+ /**/
548
do_action ("ws_plugin__s2member_before_scripting_page", get_defined_vars ());
549
/**/
550
include_once dirname (dirname (__FILE__)) . "/menu-pages/scripting.inc.php";
561
{
562
function ws_plugin__s2member_bridges_page ()
563
{
564
+ global $current_site, $current_blog; /* Multisite Networking. */
565
+ /**/
566
do_action ("ws_plugin__s2member_before_bridges_page", get_defined_vars ());
567
/**/
568
if (($nonce = $_POST["ws_plugin__s2member_bridge_bbpress"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-bridge-bbpress"))
625
{
626
function ws_plugin__s2member_info_page ()
627
{
628
+ global $current_site, $current_blog; /* Multisite Networking. */
629
+ /**/
630
do_action ("ws_plugin__s2member_before_info_page", get_defined_vars ());
631
/**/
632
include_once dirname (dirname (__FILE__)) . "/menu-pages/info.inc.php";
643
{
644
function ws_plugin__s2member_start_page ()
645
{
646
+ global $current_site, $current_blog; /* Multisite Networking. */
647
+ /**/
648
do_action ("ws_plugin__s2member_before_start_page", get_defined_vars ());
649
/**/
650
include_once dirname (dirname (__FILE__)) . "/menu-pages/start.inc.php";
includes/functions/meta-boxes.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
+ Function adds meta boxes to Post/Page editing stations.
18
+ Attach to: add_action("admin_menu");
19
+ */
20
+ if (!function_exists ("ws_plugin__s2member_add_meta_boxes"))
21
+ {
22
+ function ws_plugin__s2member_add_meta_boxes ()
23
+ {
24
+ do_action ("ws_plugin__s2member_before_add_meta_boxes", get_defined_vars ());
25
+ /**/
26
+ add_meta_box ("ws-plugin--s2member-security", "s2Member", "ws_plugin__s2member_security_meta_box", "page", "side", "high");
27
+ add_meta_box ("ws-plugin--s2member-security", "s2Member", "ws_plugin__s2member_security_meta_box", "post", "side", "high");
28
+ add_meta_box ("ws-plugin--s2member-security", "s2Member", "ws_plugin__s2member_security_meta_box", "custom_post_type", "side", "high");
29
+ /**/
30
+ do_action ("ws_plugin__s2member_after_add_meta_boxes", get_defined_vars ());
31
+ /**/
32
+ return;
33
+ }
34
+ }
35
+ /*
36
+ Function adds meta boxes to Post/Page editing stations.
37
+ Attach to: add_action("admin_menu");
38
+ */
39
+ 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"]);
85
+ $posts["3"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_posts"]);
86
+ $posts["4"] = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_posts"]);
87
+ /**/
88
+ echo '<p style="margin-left:2px;"><strong>Post Level Restriction?</strong></p>' . "\n"; /* This allows a site owner to automatically add a Page/Post into their s2Member options. */
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 ())
100
+ /* ^ Will change once Custom Capabilities are compatible with a Blog Farm. */
101
+ {
102
+ echo '<p style="margin-top:15px; margin-left:2px;"><strong>Require Custom Capabilities?</strong></p>' . "\n";
103
+ echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-ccaps">Custom Capabilities?</label>' . "\n";
104
+ 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 ($post_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";
105
+ echo '<br /><small>* see: <code>API Scripting -> Custom Capabilities</code></small>' . "\n";
106
+ }
107
+ }
108
+ }
109
+ /**/
110
+ do_action ("ws_plugin__s2member_after_security_meta_box", get_defined_vars ());
111
+ /**/
112
+ return;
113
+ }
114
+ }
115
+ /*
116
+ Function save data entered into meta boxes,
117
+ on Post/Page editing stations.
118
+ Attach to: add_action("save_post");
119
+ */
120
+ 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
+ /**/
128
+ if ($post_id && ($nonce = $_POST["ws_plugin__s2member_security_meta_box_save"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-security-meta-box-save"))
129
+ if ($post_id == $_POST["ws_plugin__s2member_security_meta_box_save_id"]) /* Do NOT process historical revisions. */
130
+ /* We do NOT process historical revisions here; because it causes confusion in the General Options panel for s2Member. */
131
+ {
132
+ $_p = ws_plugin__s2member_trim_deep (stripslashes_deep ($_POST)); /* Clean up all _POST vars; making a local working copy of the array. */
133
+ /**/
134
+ if (($_p["post_type"] === "page" && current_user_can ("edit_page", $post_id)) || current_user_can ("edit_post", $post_id))
135
+ {
136
+ if ($_p["post_type"] === "page" && ($page_id = $post_id)) /* OK. So we're dealing with a Page classification. */
137
+ {
138
+ if (isset ($_p["ws_plugin__s2member_security_meta_box_level"])) /* Just needs to be set. It CAN be empty. */
139
+ {
140
+ $pages["0"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_pages"]));
141
+ $pages["1"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_pages"]));
142
+ $pages["2"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_pages"]));
143
+ $pages["3"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_pages"]));
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"))
159
+ array_push ($pages[$_p["ws_plugin__s2member_security_meta_box_level"]], $page_id);
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
+ /**/
167
+ ws_plugin__s2member_update_all_options ($new_options, true, false, array ("membership_options_page_warning"), true);
168
+ }
169
+ }
170
+ /**/
171
+ else /* Otherwise, we assume this is a Post, or possibly a Custom Post Type. It's NOT a Page. */
172
+ {
173
+ if (isset ($_p["ws_plugin__s2member_security_meta_box_level"])) /* Just needs to be set. It CAN be empty. */
174
+ {
175
+ $posts["0"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_posts"]));
176
+ $posts["1"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_posts"]));
177
+ $posts["2"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_posts"]));
178
+ $posts["3"] = array_unique (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_posts"]));
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"))
194
+ array_push ($posts[$_p["ws_plugin__s2member_security_meta_box_level"]], $post_id);
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
+ /**/
202
+ ws_plugin__s2member_update_all_options ($new_options, true, false, array ("membership_options_page_warning"), true);
203
+ }
204
+ }
205
+ /**/
206
+ if ($_p["post_type"] === "page" && ($page_id = $post_id)) /* OK. So we're dealing with a Page classification. */
207
+ {
208
+ if (isset ($_p["ws_plugin__s2member_security_meta_box_ccaps"])) /* Just needs to be set. It CAN be empty. */
209
+ {
210
+ $ccaps_req = trim (strtolower ($_p["ws_plugin__s2member_security_meta_box_ccaps"]), ",");
211
+ $ccaps_req = trim (preg_replace ("/[^a-z_0-9,]/", "", $ccaps_req), ","); /* Now clean up. */
212
+ update_post_meta ($page_id, "s2member_ccaps_req", preg_split ("/[\r\n\t\s;,]+/", $ccaps_req));
213
+ }
214
+ }
215
+ /**/
216
+ else /* Otherwise, we assume this is a Post, or possibly a Custom Post Type. It's NOT a Page. */
217
+ {
218
+ if (isset ($_p["ws_plugin__s2member_security_meta_box_ccaps"])) /* Just needs to be set. It CAN be empty. */
219
+ {
220
+ $ccaps_req = trim (strtolower ($_p["ws_plugin__s2member_security_meta_box_ccaps"]), ",");
221
+ $ccaps_req = trim (preg_replace ("/[^a-z_0-9,]/", "", $ccaps_req), ","); /* Now clean up. */
222
+ update_post_meta ($post_id, "s2member_ccaps_req", preg_split ("/[\r\n\t\s;,]+/", $ccaps_req));
223
+ }
224
+ }
225
+ }
226
+ }
227
+ /**/
228
+ do_action ("ws_plugin__s2member_after_save_meta_boxes", get_defined_vars ());
229
+ /**/
230
+ return;
231
+ }
232
+ }
233
+ ?>
includes/functions/ms-meta-caps.inc.php ADDED
@@ -0,0 +1,60 @@
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
+ Alters `map_meta_cap()` on a Multisite Blog Farm.
18
+ Attach to: add_action("map_meta_cap");
19
+ */
20
+ if (!function_exists ("ws_plugin__s2member_ms_map_meta_cap"))
21
+ {
22
+ function ws_plugin__s2member_ms_map_meta_cap ($caps = FALSE, $cap = FALSE, $user_id = FALSE)
23
+ {
24
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$__v;');
25
+ do_action ("ws_plugin__s2member_before_ms_map_meta_cap", get_defined_vars ());
26
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
27
+ /**/
28
+ if (is_multisite () && ws_plugin__s2member_is_multisite_farm () && !is_super_admin ())
29
+ {
30
+ if (in_array ($cap, array_keys ($map = array ("edit_user" => "edit_users", "edit_users" => "edit_users"))))
31
+ {
32
+ if (is_object ($user = new WP_User ($user_id)) && $user->allcaps["administrator"])
33
+ $caps = array ($map[$cap]);
34
+ }
35
+ }
36
+ return apply_filters ("ws_plugin__s2member_ms_map_meta_cap", $caps, get_defined_vars ());
37
+ }
38
+ }
39
+ /*
40
+ Alters this Filter inside `/wp-admin/user-edit.php`.
41
+ Attach to: add_filter("enable_edit_any_user_configuration");
42
+ */
43
+ if (!function_exists ("ws_plugin__s2member_ms_allow_edits"))
44
+ {
45
+ function ws_plugin__s2member_ms_allow_edits ($allow = FALSE)
46
+ {
47
+ global $user_id; /* Available inside `/wp-admin/user-edit.php`. */
48
+ /**/