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

Version Description

  • Powerful new feature! - s2Member now supports unlimited Custom Capabilities. This allows you to create an unlimited number of Membership Packages, all with different Capabilities ( customized specifically for what your site offers ). Custom Capabilities can also be configured on a per-User basis through your WordPress Dashboard, under Users. For further details, see: s2Member -> API Scripting -> Custom Capability Packages.
  • Powerful new feature! - Now you can sell Single-Page Access too, using "Buy Now" buttons. Single-Page Access works independently from Member Level Access. That is, you can sell an unlimited number of Pages using "Buy Now" Buttons, and your Customers will NOT be required to have a Membership Account with your site in order to receive access. If they are already a Member, that's fine, but they won't need to be. Further details are provided under s2Member -> PayPal Buttons.
  • MailChimp integration. s2Member can now be integrated with MailChimp. MailChimp is an email marketing service. MailChimp makes it easy to send email newsletters to your Customers, manage your MailChimp subscriber lists, and track campaign performance. Although s2Member can be integrated with almost ANY list server, we highly recommend MailChimp; because of their powerful API for MailChimp services. In future versions of s2Member, we plan to build additional features into s2Member that work with, and extend, MailChimp services.
  • AWeber integration. As a secondary option, s2Member can also be integrated with AWeber. AWeber is an email marketing service. Whether you're looking to get your first email campaign off the ground, or you're a seasoned veteran who wants to dig into advanced tools like detailed email web analytics, activity based segmentation, geo-targeting and broadcast split-testing, AWeber's got just what you need to make email marketing work for you.
  • Bug fix. Some of the %%replacement_codes%% for email messages were returning URL-encoded values. Replacement codes DO return URL-encoded values for API Notifications, because those are designed for use within URLs. However, they should NOT be encoded for email messages. This has been corrected in s2Member v2.8.6.
  • Bug fix. S2MEMBER_LOGIN_WELCOME_PAGE_URL was missing in the s2Member JavaScript API. This has been corrected in s2Member v2.8.6.
  • Important change. The API Constant: S2MEMBER_CURRENT_USER_FIELDS is now a JSON-encoded array, rather than a serialized array. Check s2Member -> API Scripting for code samples. This makes S2MEMBER_CURRENT_USER_FIELDS compatible with the PHP API, and also with the s2Member JavaScript API. In PHP, use json_decode() instead of unserialize().
  • Important change. The API Constant: S2MEMBER_CURRENT_USER_IS_LOGGED_IN works a little bit differently than it has in previous versions. Starting with s2Member v2.8.6, you should change any existing references to: S2MEMBER_CURRENT_USER_IS_LOGGED_IN, into this new API Constant: S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER. These two API Constants are documented under s2Member -> API Scripting. We're not getting rid of S2MEMBER_CURRENT_USER_IS_LOGGED_IN ( it's still useful ), but it does work a bit differently than it has in previous versions. Check the documentation if you're unsure, and we're sorry for the change-up.
  • Under s2Member -> General Options, there is a new configuration option for Profile Modifications.
  • Under s2Member -> PayPal Options, there is a new configuration option for EOT behavior.
  • The s2Member -> API Tracking field for Signup Confirmation, now supports PHP code too!
  • The PayPal Button Generator for s2Member, now supports Subscription Modification Buttons.
  • The PayPal Button Generator for s2Member, now supports Subscription Cancellation Buttons.
  • A new s2Member API Notification event has been added for Single-Page Access.
  • The PayPal Button Generator for s2Member, now supports "Buy Now" Buttons.
  • A new s2Member API Notification event has been added for Registrations.
  • We've added a new Quick Start Guide for site owners.
  • Documentation and code samples updated throughout.
  • Support for WordPress MU has been dropped, for now. Once WP 3.0 is released, we will come back to this. If anyone can help contribute to this effort, I would be very appreciative.
Download this release

Release Info

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

Code changes from version 2.8.5 to 2.8.6

Files changed (115) hide show
  1. images/ajax-loader.gif +0 -0
  2. images/aweber-logo.png +0 -0
  3. images/brand-installation.fla +0 -0
  4. images/brand-installation.png +0 -0
  5. images/logo.fla +0 -0
  6. images/logo.png +0 -0
  7. images/mailchimp-stamp.png +0 -0
  8. includes/functions/activate-deactivate.inc.php +13 -0
  9. includes/functions/admin-lockout.inc.php +2 -3
  10. includes/functions/constants.inc.php +8 -4
  11. includes/functions/js-globals.inc.php +6 -0
  12. includes/functions/menu-pages.inc.php +31 -19
  13. includes/functions/page-level-access.inc.php +3 -0
  14. includes/functions/paypal-notify.inc.php +221 -128
  15. includes/functions/paypal-register.inc.php +0 -40
  16. includes/functions/paypal-return.inc.php +144 -65
  17. includes/functions/register-access.inc.php +202 -8
  18. includes/functions/shortcodes.inc.php +73 -32
  19. includes/functions/sp-access.inc.php +73 -0
  20. includes/functions/user-deletions.inc.php +7 -6
  21. includes/functions/users-list.inc.php +36 -3
  22. includes/functions/utilities.inc.php +25 -18
  23. includes/hooks.inc.php +2 -1
  24. includes/mailchimp/index.php +0 -0
  25. includes/mailchimp/nc-mcapi.inc.php +1814 -0
  26. includes/menu-pages/api-ops.inc.php +152 -47
  27. includes/menu-pages/button.html +9 -8
  28. includes/menu-pages/buttons.inc.php +254 -26
  29. includes/menu-pages/c-button.html +3 -0
  30. includes/menu-pages/c-shortcode.html +1 -0
  31. includes/menu-pages/{con-samps/current_user_access_label.php → code-samples/current-user-access-label.php} +0 -0
  32. includes/menu-pages/code-samples/current-user-access-level-conditional-upgrades.php +11 -0
  33. includes/menu-pages/{con-samps/current_user_access_level.php → code-samples/current-user-access-level.php} +6 -6
  34. includes/menu-pages/code-samples/current-user-can-ccaps-1.php +15 -0
  35. includes/menu-pages/code-samples/current-user-can-ccaps-2.php +28 -0
  36. includes/menu-pages/code-samples/current-user-can-constants-1.php +7 -0
  37. includes/menu-pages/code-samples/current-user-can-constants-2.php +13 -0
  38. includes/menu-pages/code-samples/current-user-can-full-access.php +5 -0
  39. includes/menu-pages/code-samples/current-user-can-specific-content.php +13 -0
  40. includes/menu-pages/{con-samps/current_user_custom.php → code-samples/current-user-custom.php} +0 -0
  41. includes/menu-pages/{con-samps/current_user_display_name.php → code-samples/current-user-display-name.php} +0 -0
  42. includes/menu-pages/{con-samps/current_user_downloads_allowed_days.php → code-samples/current-user-downloads-allowed-days.php} +0 -0
  43. includes/menu-pages/{con-samps/current_user_downloads_allowed_is_unlimited.php → code-samples/current-user-downloads-allowed-is-unlimited.php} +0 -0
  44. includes/menu-pages/{con-samps/current_user_downloads_allowed.php → code-samples/current-user-downloads-allowed.php} +0 -0
  45. includes/menu-pages/{con-samps/current_user_downloads_currently.php → code-samples/current-user-downloads-currently.php} +0 -0
  46. includes/menu-pages/{con-samps/current_user_email.php → code-samples/current-user-email.php} +0 -0
  47. includes/menu-pages/code-samples/current-user-fields.php +7 -0
  48. includes/menu-pages/{con-samps/current_user_first_name.php → code-samples/current-user-first-name.php} +0 -0
  49. includes/menu-pages/{con-samps/current_user_id.php → code-samples/current-user-id.php} +0 -0
  50. includes/menu-pages/{con-samps/current_user_ip.php → code-samples/current-user-ip.php} +0 -0
  51. includes/menu-pages/code-samples/current-user-is-logged-in-as-member.php +3 -0
  52. includes/menu-pages/code-samples/current-user-is-logged-in.php +3 -0
  53. includes/menu-pages/{con-samps/current_user_last_name.php → code-samples/current-user-last-name.php} +0 -0
  54. includes/menu-pages/{con-samps/current_user_login.php → code-samples/current-user-login.php} +0 -0
  55. includes/menu-pages/code-samples/current-user-profile-modification-page-url-1.php +1 -0
  56. includes/menu-pages/code-samples/current-user-profile-modification-page-url-2.php +5 -0
  57. includes/menu-pages/code-samples/current-user-profile-modification-page-url-3.php +1 -0
  58. includes/menu-pages/code-samples/current-user-registration-days-dripping.php +17 -0
  59. includes/menu-pages/code-samples/current-user-registration-days.php +22 -0
  60. includes/menu-pages/{con-samps/current_user_registration_time.php → code-samples/current-user-registration-time.php} +0 -0
  61. includes/menu-pages/{con-samps/current_user_subscr_id.php → code-samples/current-user-subscr-id.php} +0 -0
  62. includes/menu-pages/code-samples/current-user-value-for-pp-on0-os0.php +4 -0
  63. includes/menu-pages/{con-samps/file_download_limit_exceeded_page_url.php → code-samples/file-download-limit-exceeded-page-url.php} +0 -0
  64. includes/menu-pages/code-samples/index.php +0 -0
  65. includes/menu-pages/code-samples/is-user-logged-in.php +5 -0
  66. includes/menu-pages/{con-samps/level1_file_downloads_allowed.php → code-samples/level1-file-downloads-allowed-days.php} +0 -0
  67. includes/menu-pages/{con-samps/level1_file_downloads_allowed_days.php → code-samples/level1-file-downloads-allowed.php} +0 -0
  68. includes/menu-pages/{con-samps/level1_label.php → code-samples/level1-label.php} +0 -0
  69. includes/menu-pages/{con-samps/level2_file_downloads_allowed.php → code-samples/level2-file-downloads-allowed-days.php} +0 -0
  70. includes/menu-pages/{con-samps/level2_file_downloads_allowed_days.php → code-samples/level2-file-downloads-allowed.php} +0 -0
  71. includes/menu-pages/{con-samps/level2_label.php → code-samples/level2-label.php} +0 -0
  72. includes/menu-pages/{con-samps/level3_file_downloads_allowed.php → code-samples/level3-file-downloads-allowed-days.php} +0 -0
  73. includes/menu-pages/{con-samps/level3_file_downloads_allowed_days.php → code-samples/level3-file-downloads-allowed.php} +0 -0
  74. includes/menu-pages/{con-samps/level3_label.php → code-samples/level3-label.php} +0 -0
  75. includes/menu-pages/{con-samps/level4_file_downloads_allowed.php → code-samples/level4-file-downloads-allowed-days.php} +0 -0
  76. includes/menu-pages/{con-samps/level4_file_downloads_allowed_days.php → code-samples/level4-file-downloads-allowed.php} +0 -0
  77. includes/menu-pages/{con-samps/level4_label.php → code-samples/level4-label.php} +0 -0
  78. includes/menu-pages/{con-samps/login_page_url.php → code-samples/login-page-url.php} +0 -0
  79. includes/menu-pages/{con-samps/login_welcome_page_url.php → code-samples/login-welcome-page-url.php} +0 -0
  80. includes/menu-pages/{con-samps/logout_page_url.php → code-samples/logout-page-url.php} +0 -0
  81. includes/menu-pages/{con-samps/membership_options_page_url.php → code-samples/membership-options-page-url.php} +0 -0
  82. includes/menu-pages/{con-samps/paypal_business.php → code-samples/paypal-business.php} +0 -0
  83. includes/menu-pages/{con-samps/paypal_endpoint.php → code-samples/paypal-endpoint.php} +0 -0
  84. includes/menu-pages/{con-samps/paypal_notify_url.php → code-samples/paypal-notify-url.php} +0 -0
  85. includes/menu-pages/{con-samps/paypal_return_url.php → code-samples/paypal-return-url.php} +0 -0
  86. includes/menu-pages/{con-samps/reg_email_from_email.php → code-samples/reg-email-from-email.php} +0 -0
  87. includes/menu-pages/{con-samps/reg_email_from_name.php → code-samples/reg-email-from-name.php} +0 -0
  88. includes/menu-pages/con-samps/current_user_fields.php +0 -7
  89. includes/menu-pages/con-samps/current_user_is_logged_in.php +0 -3
  90. includes/menu-pages/con-samps/current_user_profile_modification_page_url.php +0 -8
  91. includes/menu-pages/con-samps/current_user_registration_days.php +0 -15
  92. includes/menu-pages/cur-samps.php +0 -33
  93. includes/menu-pages/down-ops.inc.php +7 -5
  94. includes/menu-pages/drip-samps.php +0 -9
  95. includes/menu-pages/els-ops.inc.php +291 -0
  96. includes/menu-pages/events.inc.php +0 -118
  97. includes/menu-pages/info.inc.php +2 -0
  98. includes/menu-pages/menu-pages.css +10 -1
  99. includes/menu-pages/menu-pages.js +153 -81
  100. includes/menu-pages/mod-samps.php +0 -33
  101. includes/menu-pages/options.inc.php +143 -38
  102. includes/menu-pages/paypal-ops.inc.php +129 -25
  103. includes/menu-pages/s2m-samps.php +0 -33
  104. includes/menu-pages/scripting.inc.php +196 -99
  105. includes/menu-pages/shortcode.html +1 -1
  106. includes/menu-pages/sp-button.html +20 -0
  107. includes/menu-pages/sp-shortcode.html +1 -0
  108. includes/menu-pages/start.inc.php +147 -0
  109. includes/menu-pages/trk-ops.inc.php +33 -22
  110. includes/s2member-min.js +1 -1
  111. includes/s2member.js +1 -1
  112. includes/syscon.inc.php +71 -8
  113. licensing/license.txt +17 -3
  114. readme.txt +45 -17
  115. s2member.php +4 -3
images/ajax-loader.gif ADDED
Binary file
images/aweber-logo.png ADDED
Binary file
images/brand-installation.fla ADDED
Binary file
images/brand-installation.png ADDED
Binary file
images/logo.fla CHANGED
Binary file
images/logo.png CHANGED
Binary file
images/mailchimp-stamp.png ADDED
Binary file
includes/functions/activate-deactivate.inc.php CHANGED
@@ -108,6 +108,19 @@ function ws_plugin__s2member_activate ()
108
if (!is_array (get_option ("ws_plugin__s2member_options")))
109
update_option ("ws_plugin__s2member_options", array ());
110
/**/
111
return;
112
}
113
/*
108
if (!is_array (get_option ("ws_plugin__s2member_options")))
109
update_option ("ws_plugin__s2member_options", array ());
110
/**/
111
+ if (get_option ("ws_plugin__s2member_configured")) /* If they already have s2Member configured, read the Changelog. */
112
+ {
113
+ $notice = '<strong>s2Member</strong> has been <strong>re-activated</strong>, with the latest version.<br />';
114
+ $notice .= 'Have fun, <a href="admin.php?page=ws-plugin--s2member-info">read the Changelog</a>, and make some money! :-)';
115
+ ws_plugin__s2member_enqueue_admin_notice ($notice, array ("plugins.php", "ws-plugin--s2member-options"));
116
+ }
117
+ else /* Otherwise, we'll help the site owner out by giving them a link to the Quick Start Guide. */
118
+ {
119
+ $notice = '<strong>s2Member</strong> has been <strong>activated</strong>, with the latest version.<br />';
120
+ $notice .= 'Have fun, <a href="admin.php?page=ws-plugin--s2member-start">read the Quick Start Guide</a>, and make some money! :-)';
121
+ ws_plugin__s2member_enqueue_admin_notice ($notice, array ("plugins.php", "ws-plugin--s2member-options"));
122
+ }
123
+ /**/
124
return;
125
}
126
/*
includes/functions/admin-lockout.inc.php CHANGED
@@ -19,9 +19,8 @@ Attach to: add_action("admin_init");
19
*/
20
function ws_plugin__s2member_admin_lockout ()
21
{
22
- /* This prevents users ( who cannot edit ) from gaining any access to the admin area. */
23
- /* WordPress® handles most of this on its own, but this prevents profile access also. */
24
- if (!current_user_can ("edit_posts") /* In other words, if they are a subscriber or a member. */
25
&& wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])) !== "nill")
26
exit;
27
/**/
19
*/
20
function ws_plugin__s2member_admin_lockout ()
21
{
22
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"]/**/
23
+ && !current_user_can ("edit_posts") /* In other words: Subscribers and Members. */
24
&& wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])) !== "nill")
25
exit;
26
/**/
includes/functions/constants.inc.php CHANGED
@@ -27,8 +27,9 @@ function ws_plugin__s2member_constants ()
27
$file_downloads = ws_plugin__s2member_user_downloads ("", $metas["s2member_file_download_access_log"]);
28
$login_redirection_override = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"];
29
/**/
30
- define ("S2MEMBER_CURRENT_USER_IS_LOGGED_IN", (($level >= 1) ? true : false)); /* This will always be (bool) true or false. False if they are not currently logged in. */
31
- 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 w/o access. */
32
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. */
33
define ("S2MEMBER_CURRENT_USER_SUBSCR_ID", (($current_user) ? (($metas["s2member_subscr_id"]) ? $metas["s2member_subscr_id"] : $current_user->ID) : "")); /* Empty if not logged in. */
34
define ("S2MEMBER_CURRENT_USER_CUSTOM", (($current_user) ? $metas["s2member_custom"] : "")); /* This will always a (string). However, it will be empty if not logged in. */
@@ -41,10 +42,10 @@ function ws_plugin__s2member_constants ()
41
define ("S2MEMBER_CURRENT_USER_EMAIL", (($current_user) ? $current_user->user_email : "")); /* This will always be a (string). Empty if not logged in. */
42
define ("S2MEMBER_CURRENT_USER_IP", $_SERVER["REMOTE_ADDR"]); /* This will always be a (string). It may be empty if the user is browsing anonymously. */
43
define ("S2MEMBER_CURRENT_USER_ID", (($current_user) ? (int)$current_user->ID : 0)); /* This will always be an (int). Zero if not logged in. */
44
- define ("S2MEMBER_CURRENT_USER_FIELDS", (($current_user) ? serialize (array_merge /* Always a serialized (array). This includes custom fields. */
45
(array ("id" => S2MEMBER_CURRENT_USER_ID, "ip" => S2MEMBER_CURRENT_USER_IP, "email" => S2MEMBER_CURRENT_USER_EMAIL, "login" => S2MEMBER_CURRENT_USER_LOGIN,/**/
46
"first_name" => S2MEMBER_CURRENT_USER_FIRST_NAME, "last_name" => S2MEMBER_CURRENT_USER_LAST_NAME, "display_name" => S2MEMBER_CURRENT_USER_DISPLAY_NAME,/**/
47
- "subscr_id" => S2MEMBER_CURRENT_USER_SUBSCR_ID, "custom" => S2MEMBER_CURRENT_USER_CUSTOM), $metas["s2member_custom_fields"])) : serialize (array ())));
48
/**/
49
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED", (int)$file_downloads["allowed"]); /* This will always be an integer value (int) >= 0 where 0 means no access. */
50
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED", (($file_downloads["allowed"] >= 999999999) ? true : false)); /* This will always be (bool). */
@@ -85,6 +86,9 @@ function ws_plugin__s2member_constants ()
85
define ("S2MEMBER_PAYPAL_ENDPOINT", (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com")); /* Using sandbox? */
86
define ("S2MEMBER_PAYPAL_BUSINESS", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"]); /* This is the email address that identifies your paypal business. */
87
/**/
88
return;
89
}
90
/*
27
$file_downloads = ws_plugin__s2member_user_downloads ("", $metas["s2member_file_download_access_log"]);
28
$login_redirection_override = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"];
29
/**/
30
+ 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. */
31
+ 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. */
32
+ 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. */
33
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. */
34
define ("S2MEMBER_CURRENT_USER_SUBSCR_ID", (($current_user) ? (($metas["s2member_subscr_id"]) ? $metas["s2member_subscr_id"] : $current_user->ID) : "")); /* Empty if not logged in. */
35
define ("S2MEMBER_CURRENT_USER_CUSTOM", (($current_user) ? $metas["s2member_custom"] : "")); /* This will always a (string). However, it will be empty if not logged in. */
42
define ("S2MEMBER_CURRENT_USER_EMAIL", (($current_user) ? $current_user->user_email : "")); /* This will always be a (string). Empty if not logged in. */
43
define ("S2MEMBER_CURRENT_USER_IP", $_SERVER["REMOTE_ADDR"]); /* This will always be a (string). It may be empty if the user is browsing anonymously. */
44
define ("S2MEMBER_CURRENT_USER_ID", (($current_user) ? (int)$current_user->ID : 0)); /* This will always be an (int). Zero if not logged in. */
45
+ define ("S2MEMBER_CURRENT_USER_FIELDS", (($current_user) ? json_encode (array_merge /* Always a json_encode (array). This includes custom fields. */
46
(array ("id" => S2MEMBER_CURRENT_USER_ID, "ip" => S2MEMBER_CURRENT_USER_IP, "email" => S2MEMBER_CURRENT_USER_EMAIL, "login" => S2MEMBER_CURRENT_USER_LOGIN,/**/
47
"first_name" => S2MEMBER_CURRENT_USER_FIRST_NAME, "last_name" => S2MEMBER_CURRENT_USER_LAST_NAME, "display_name" => S2MEMBER_CURRENT_USER_DISPLAY_NAME,/**/
48
+ "subscr_id" => S2MEMBER_CURRENT_USER_SUBSCR_ID, "custom" => S2MEMBER_CURRENT_USER_CUSTOM), $metas["s2member_custom_fields"])) : json_encode (array ())));
49
/**/
50
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED", (int)$file_downloads["allowed"]); /* This will always be an integer value (int) >= 0 where 0 means no access. */
51
define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED", (($file_downloads["allowed"] >= 999999999) ? true : false)); /* This will always be (bool). */
86
define ("S2MEMBER_PAYPAL_ENDPOINT", (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com")); /* Using sandbox? */
87
define ("S2MEMBER_PAYPAL_BUSINESS", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"]); /* This is the email address that identifies your paypal business. */
88
/**/
89
+ define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0", ((S2MEMBER_CURRENT_USER_SUBSCR_ID) ? "Updating Subscr" : "")); /* Auto-fills the on0 value in PayPal buttons. */
90
+ define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0", ((S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0) ? S2MEMBER_CURRENT_USER_SUBSCR_ID : "")); /* For the os0 value. */
91
+ /**/
92
return;
93
}
94
/*
includes/functions/js-globals.inc.php CHANGED
@@ -61,6 +61,7 @@ function ws_plugin__s2member_js_w_globals ()
61
header ("Pragma: public");
62
/**/
63
$g = "var S2MEMBER_CURRENT_USER_IS_LOGGED_IN = " . ((S2MEMBER_CURRENT_USER_IS_LOGGED_IN) ? "true" : "false") . ",";
64
$g .= "S2MEMBER_CURRENT_USER_ACCESS_LEVEL = " . S2MEMBER_CURRENT_USER_ACCESS_LEVEL . ",";
65
$g .= "S2MEMBER_CURRENT_USER_ACCESS_LABEL = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_ACCESS_LABEL) . "',";
66
$g .= "S2MEMBER_CURRENT_USER_SUBSCR_ID = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_SUBSCR_ID) . "',";
@@ -74,6 +75,7 @@ function ws_plugin__s2member_js_w_globals ()
74
$g .= "S2MEMBER_CURRENT_USER_EMAIL = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_EMAIL) . "',";
75
$g .= "S2MEMBER_CURRENT_USER_IP = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_IP) . "',";
76
$g .= "S2MEMBER_CURRENT_USER_ID = " . S2MEMBER_CURRENT_USER_ID . ",";
77
/**/
78
$g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED = " . S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED . ",";
79
$g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED = " . ((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED) ? "true" : "false") . ",";
@@ -87,6 +89,7 @@ function ws_plugin__s2member_js_w_globals ()
87
$g .= "S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL) . "',";
88
$g .= "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL) . "',";
89
$g .= "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL) . "',";
90
$g .= "S2MEMBER_LOGOUT_PAGE_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_LOGOUT_PAGE_URL) . "',";
91
$g .= "S2MEMBER_LOGIN_PAGE_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_LOGIN_PAGE_URL) . "',";
92
/**/
@@ -113,6 +116,9 @@ function ws_plugin__s2member_js_w_globals ()
113
$g .= "S2MEMBER_PAYPAL_ENDPOINT = '" . preg_replace ("/'/", "\'", S2MEMBER_PAYPAL_ENDPOINT) . "',";
114
$g .= "S2MEMBER_PAYPAL_BUSINESS = '" . preg_replace ("/'/", "\'", S2MEMBER_PAYPAL_BUSINESS) . "',";
115
/**/
116
$g = trim ($g, " ,") . ";"; /* Trim & add semicolon. */
117
$j = file_get_contents (dirname (dirname (__FILE__)) . "/s2member-min.js");
118
$j = preg_replace ("/('|\")%%globals%%('|\");/", $g, $j);
61
header ("Pragma: public");
62
/**/
63
$g = "var S2MEMBER_CURRENT_USER_IS_LOGGED_IN = " . ((S2MEMBER_CURRENT_USER_IS_LOGGED_IN) ? "true" : "false") . ",";
64
+ $g .= "S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER = " . ((S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER) ? "true" : "false") . ",";
65
$g .= "S2MEMBER_CURRENT_USER_ACCESS_LEVEL = " . S2MEMBER_CURRENT_USER_ACCESS_LEVEL . ",";
66
$g .= "S2MEMBER_CURRENT_USER_ACCESS_LABEL = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_ACCESS_LABEL) . "',";
67
$g .= "S2MEMBER_CURRENT_USER_SUBSCR_ID = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_SUBSCR_ID) . "',";
75
$g .= "S2MEMBER_CURRENT_USER_EMAIL = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_EMAIL) . "',";
76
$g .= "S2MEMBER_CURRENT_USER_IP = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_IP) . "',";
77
$g .= "S2MEMBER_CURRENT_USER_ID = " . S2MEMBER_CURRENT_USER_ID . ",";
78
+ $g .= "S2MEMBER_CURRENT_USER_FIELDS = " . S2MEMBER_CURRENT_USER_FIELDS . ",";
79
/**/
80
$g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED = " . S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED . ",";
81
$g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED = " . ((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED) ? "true" : "false") . ",";
89
$g .= "S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL) . "',";
90
$g .= "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL) . "',";
91
$g .= "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL) . "',";
92
+ $g .= "S2MEMBER_LOGIN_WELCOME_PAGE_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_LOGIN_WELCOME_PAGE_URL) . "',";
93
$g .= "S2MEMBER_LOGOUT_PAGE_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_LOGOUT_PAGE_URL) . "',";
94
$g .= "S2MEMBER_LOGIN_PAGE_URL = '" . preg_replace ("/'/", "\'", S2MEMBER_LOGIN_PAGE_URL) . "',";
95
/**/
116
$g .= "S2MEMBER_PAYPAL_ENDPOINT = '" . preg_replace ("/'/", "\'", S2MEMBER_PAYPAL_ENDPOINT) . "',";
117
$g .= "S2MEMBER_PAYPAL_BUSINESS = '" . preg_replace ("/'/", "\'", S2MEMBER_PAYPAL_BUSINESS) . "',";
118
/**/
119
+ $g .= "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0 = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0) . "',";
120
+ $g .= "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0 = '" . preg_replace ("/'/", "\'", S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0) . "',";
121
+ /**/
122
$g = trim ($g, " ,") . ";"; /* Trim & add semicolon. */
123
$j = file_get_contents (dirname (dirname (__FILE__)) . "/s2member-min.js");
124
$j = preg_replace ("/('|\")%%globals%%('|\");/", $g, $j);
includes/functions/menu-pages.inc.php CHANGED
@@ -59,16 +59,17 @@ function ws_plugin__s2member_add_admin_options ()
59
{
60
add_filter ("plugin_action_links", "_ws_plugin__s2member_add_settings_link", 10, 2);
61
/**/
62
- add_menu_page ("s2Member Options", "s2Member", "edit_plugins", "ws-plugin--s2member-options", "ws_plugin__s2member_options_page");
63
- add_submenu_page ("ws-plugin--s2member-options", "s2Member General Options", "General Options", "edit_plugins", "ws-plugin--s2member-options", "ws_plugin__s2member_options_page");
64
- 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");
65
- add_submenu_page ("ws-plugin--s2member-options", "s2Member PayPal® Buttons", "PayPal® Buttons", "edit_plugins", "ws-plugin--s2member-buttons", "ws_plugin__s2member_buttons_page");
66
- 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");
67
- 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");
68
- 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");
69
- add_submenu_page ("ws-plugin--s2member-options", "s2Member API / Scripting", "API / Scripting", "edit_plugins", "ws-plugin--s2member-scripting", "ws_plugin__s2member_scripting_page");
70
- add_submenu_page ("ws-plugin--s2member-options", "s2Member Flow Of Events", "Flow Of Events", "edit_plugins", "ws-plugin--s2member-events", "ws_plugin__s2member_events_page");
71
- add_submenu_page ("ws-plugin--s2member-options", "s2Member Information", "s2Member Info", "edit_plugins", "ws-plugin--s2member-info", "ws_plugin__s2member_info_page");
72
/**/
73
return;
74
}
@@ -160,6 +161,15 @@ function ws_plugin__s2member_menu_pages_css ()
160
}
161
}
162
/*
163
Function for building and handling the General Options page.
164
*/
165
function ws_plugin__s2member_options_page ()
@@ -248,6 +258,17 @@ function ws_plugin__s2member_trk_ops_page ()
248
return;
249
}
250
/*
251
Function for building and handling the API Notifications page.
252
*/
253
function ws_plugin__s2member_api_ops_page ()
@@ -277,15 +298,6 @@ function ws_plugin__s2member_scripting_page ()
277
return;
278
}
279
/*
280
- Function for building the Flow Of Events page.
281
- */
282
- function ws_plugin__s2member_events_page ()
283
- {
284
- include_once dirname (dirname (__FILE__)) . "/menu-pages/events.inc.php";
285
- /**/
286
- return;
287
- }
288
- /*
289
Function for building the s2Member Info page.
290
*/
291
function ws_plugin__s2member_info_page ()
59
{
60
add_filter ("plugin_action_links", "_ws_plugin__s2member_add_settings_link", 10, 2);
61
/**/
62
+ add_menu_page ("s2Member Options", "s2Member", "edit_plugins", "ws-plugin--s2member-start", "ws_plugin__s2member_start_page");
63
+ add_submenu_page ("ws-plugin--s2member-start", "s2Member Quick Start Guide", "Quick Start Guide", "edit_plugins", "ws-plugin--s2member-start", "ws_plugin__s2member_start_page");
64
+ add_submenu_page ("ws-plugin--s2member-start", "s2Member General Options", "General Options", "edit_plugins", "ws-plugin--s2member-options", "ws_plugin__s2member_options_page");
65
+ add_submenu_page ("ws-plugin--s2member-start", "s2Member PayPal Options", "PayPal® Options", "edit_plugins", "ws-plugin--s2member-paypal-ops", "ws_plugin__s2member_paypal_ops_page");
66
+ add_submenu_page ("ws-plugin--s2member-start", "s2Member PayPal® Buttons", "PayPal® Buttons", "edit_plugins", "ws-plugin--s2member-buttons", "ws_plugin__s2member_buttons_page");
67
+ add_submenu_page ("ws-plugin--s2member-start", "s2Member File Download Options", "Download Options", "edit_plugins", "ws-plugin--s2member-down-ops", "ws_plugin__s2member_down_ops_page");
68
+ add_submenu_page ("ws-plugin--s2member-start", "s2Member API / Tracking", "API / Tracking", "edit_plugins", "ws-plugin--s2member-trk-ops", "ws_plugin__s2member_trk_ops_page");
69
+ add_submenu_page ("ws-plugin--s2member-start", "s2Member API / List Servers", "API / List Servers", "edit_plugins", "ws-plugin--s2member-els-ops", "ws_plugin__s2member_els_ops_page");
70
+ add_submenu_page ("ws-plugin--s2member-start", "s2Member API / Notifications", "API / Notifications", "edit_plugins", "ws-plugin--s2member-api-ops", "ws_plugin__s2member_api_ops_page");
71
+ add_submenu_page ("ws-plugin--s2member-start", "s2Member API / Scripting", "API / Scripting", "edit_plugins", "ws-plugin--s2member-scripting", "ws_plugin__s2member_scripting_page");
72
+ add_submenu_page ("ws-plugin--s2member-start", "s2Member Information", "s2Member Info", "edit_plugins", "ws-plugin--s2member-info", "ws_plugin__s2member_info_page");
73
/**/
74
return;
75
}
161
}
162
}
163
/*
164
+ Function for building and handling the Quick Start page.
165
+ */
166
+ function ws_plugin__s2member_start_page ()
167
+ {
168
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/start.inc.php";
169
+ /**/
170
+ return;
171
+ }
172
+ /*
173
Function for building and handling the General Options page.
174
*/
175
function ws_plugin__s2member_options_page ()
258
return;
259
}
260
/*
261
+ Function for building and handling the API List Server options page.
262
+ */
263
+ function ws_plugin__s2member_els_ops_page ()
264
+ {
265
+ ws_plugin__s2member_update_all_options ();
266
+ /**/
267
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/els-ops.inc.php";
268
+ /**/
269
+ return;
270
+ }
271
+ /*
272
Function for building and handling the API Notifications page.
273
*/
274
function ws_plugin__s2member_api_ops_page ()
298
return;
299
}
300
/*
301
Function for building the s2Member Info page.
302
*/
303
function ws_plugin__s2member_info_page ()
includes/functions/page-level-access.inc.php CHANGED
@@ -54,6 +54,9 @@ function ws_plugin__s2member_check_page_level_access ()
54
/**/
55
else if (in_array ($page_ID, preg_split ("/,/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_pages"])) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level4")) && !ws_plugin__s2member_is_systematic_use_page () && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=4")) !== "nill")
56
exit;
57
}
58
/**/
59
return;
54
/**/
55
else if (in_array ($page_ID, preg_split ("/,/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_pages"])) && ws_plugin__s2member_nocache_constants () !== "nill" && (!$current_user || !current_user_can ("access_s2member_level4")) && !ws_plugin__s2member_is_systematic_use_page () && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_level_req=4")) !== "nill")
56
exit;
57
+ /**/
58
+ else if (in_array ($page_ID, preg_split ("/,/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["single_pages"])) && ws_plugin__s2member_nocache_constants () !== "nill" && !ws_plugin__s2member_sp_access ($page_ID) && !ws_plugin__s2member_is_systematic_use_page () && wp_redirect (ws_plugin__s2member_append_query_var (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]), "s2member_sp_req=" . urlencode ($page_ID))) !== "nill")
59
+ exit;
60
}
61
/**/
62
return;
includes/functions/paypal-notify.inc.php CHANGED
@@ -31,14 +31,73 @@ function ws_plugin__s2member_paypal_notify ()
31
{ /* The business address validation was removed from this routine, because PayPal® always fills that with the primary
32
email address. In cases where an alternate PayPal® address is being paid, validation is not possible. */
33
$paypal["s2member_log"][] = "s2Member originating domain ( _SERVER[HTTP_HOST] ) validated.";
34
- /**/
35
- if (preg_match ("/^(web_accept|subscr_signup)#x2F;i", $paypal["txn_type"]) && $paypal["payer_email"] && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["txn_id"])) && preg_match ("/^[1-4]#x2F;", $paypal["item_number"]))
36
{
37
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup).";
38
/**/
39
if (preg_match ("/(updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) /* This is an advanced way to handle subscription update modifications. */
40
/* This advanced method is required whenever a subscription that is already completed, or was never setup to recur in the first place needs to be modified. PayPal will not allow the
41
- modify=2 parameter to be used in those scenarios, because technically there is nothing to update. The only thing that actually needs to be updated is their existing account. */
42
{
43
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup) w/ update vars.";
44
/**/
@@ -49,112 +108,79 @@ function ws_plugin__s2member_paypal_notify ()
49
if ($user_id = $q->user_id) /* Got it! */
50
{
51
$user = new WP_User ($user_id);
52
- $user->set_role ("s2member_level" . $paypal["item_number"]);
53
update_usermeta ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
54
update_usermeta ($user_id, "s2member_custom", $paypal["custom"]);
55
delete_usermeta ($user_id, "s2member_file_download_access_arc");
56
delete_usermeta ($user_id, "s2member_file_download_access_log");
57
/**/
58
- $paypal["s2member_log"][] = "s2Member level updated w/ advanced update routines.";
59
}
60
else
61
{
62
- $paypal["s2member_log"][] = "Unable to get user_id from the DB.";
63
}
64
}
65
else
66
{
67
- $paypal["s2member_log"][] = "Unable to find subscription/subscriber in the DB.";
68
}
69
}
70
else /* Else this is a normal subscription signup, we are not updating anything for a past subscription. */
71
{
72
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup) w/o update vars.";
73
/**/
74
- if ($subscr_id_custom_item_number_xencrypted = ws_plugin__s2member_xencrypt ("subscr_id_custom_item_number:.:|:.:" . $paypal["subscr_id"] . ":.:|:.:" . $paypal["custom"] . ":.:|:.:" . $paypal["item_number"]))
75
{
76
- if ($tinyurl = @file_get_contents ("http://tinyurl.com/api-create.php?url=" . rawurlencode (get_bloginfo ("url") . "/?s2member_paypal_register=" . urlencode ($subscr_id_custom_item_number_xencrypted))))
77
- {
78
- if (is_array ($cv = preg_split ("/\|/", $paypal["custom"]))) /* Values passed through the "custom" field to PayPal. */
79
- {
80
- $sbj = preg_replace ("/%%registration_url%%/i", $tinyurl, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_email_subject"]);
81
- $msg = preg_replace ("/%%registration_url%%/i", $tinyurl, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_email_message"]);
82
- /**/
83
- if (preg_match ("/^web_accept#x2F;i", $paypal["txn_type"]))
84
- {
85
- $paypal["period3"] = "1 L"; /* 1 Lifetime. */
86
- $paypal["amount3"] = $paypal["payment_gross"];
87
- }
88
- /**/
89
- $initial_term = $paypal["period1"] ? $paypal["period1"] : "0 D"; /* Do not allow the initial period to be empty. */
90
- $initial = (isset ($paypal["amount1"]) && preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["amount1"] : $paypal["amount3"];
91
- $regular = $paypal["amount3"]; /* This is the regular payment amount that is charged to the customer. Always required by PayPal. */
92
- $recurring = ($paypal["recurring"]) ? $paypal["amount3"] : "0"; /* If non-recurring, this should be zero, otherwise regular. */
93
- /* The initial amount will only be $0 if a trial was offered. If no trial was offered, they were charged a regular rate. */
94
- if (($sbj = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $sbj)) && ($sbj = preg_replace ("/%%subscr_id%%/i", urlencode ($paypal["subscr_id"]), $sbj)))
95
- if (($sbj = preg_replace ("/%%initial%%/i", urlencode ($initial), $sbj)) && ($sbj = preg_replace ("/%%recurring%%/i", urlencode ($recurring), $sbj))) /* Adv calculations. */
96
- if (($sbj = preg_replace ("/%%regular%%/i", urlencode ($regular), $sbj))) /* This is provided mostly for rare cases where a trial is offered, and there is NO recurrence. */
97
- /* In cases where there is a free trial offered, and no recurring charges either ( could happen ), both initial & recurring are 0. So regular should be reported then. */
98
- if (($sbj = preg_replace ("/%%initial_term%%/i", urlencode ($initial_term), $sbj)) && ($sbj = preg_replace ("/%%regular_term%%/i", urlencode ($paypal["period3"]), $sbj)))
99
- if (($sbj = preg_replace ("/%%item_number%%/i", urlencode ($paypal["item_number"]), $sbj)) && ($sbj = preg_replace ("/%%item_name%%/i", urlencode ($paypal["item_name"]), $sbj)))
100
- if (($sbj = preg_replace ("/%%first_name%%/i", urlencode ($paypal["first_name"]), $sbj)) && ($sbj = preg_replace ("/%%last_name%%/i", urlencode ($paypal["last_name"]), $sbj)))
101
- if (($sbj = preg_replace ("/%%full_name%%/i", urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)))
102
- if (($sbj = preg_replace ("/%%payer_email%%/i", urlencode ($paypal["payer_email"]), $sbj)) && ($sbj = trim ($sbj)))
103
- if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", urlencode ($paypal["subscr_id"]), $msg)))
104
- if (($msg = preg_replace ("/%%initial%%/i", urlencode ($initial), $msg)) && ($msg = preg_replace ("/%%recurring%%/i", urlencode ($recurring), $msg))) /* Adv calculations. */
105
- if (($msg = preg_replace ("/%%regular%%/i", urlencode ($regular), $msg))) /* This is provided mostly for rare cases where a trial is offered, and there is NO recurrence. */
106
- /* In cases where there is a free trial offered, and no recurring charges either ( could happen ), both initial & recurring are 0. So regular should be reported then. */
107
- if (($msg = preg_replace ("/%%initial_term%%/i", urlencode ($initial_term), $msg)) && ($msg = preg_replace ("/%%regular_term%%/i", urlencode ($paypal["period3"]), $msg)))
108
- if (($msg = preg_replace ("/%%item_number%%/i", urlencode ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", urlencode ($paypal["item_name"]), $msg)))
109
- if (($msg = preg_replace ("/%%first_name%%/i", urlencode ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", urlencode ($paypal["last_name"]), $msg)))
110
- if (($msg = preg_replace ("/%%full_name%%/i", urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
111
- if (($msg = preg_replace ("/%%payer_email%%/i", urlencode ($paypal["payer_email"]), $msg)) && ($msg = trim ($msg)))
112
- @mail ($paypal["payer_email"], $sbj, $msg, "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8", "-f " . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"]);
113
- /**/
114
- $paypal["s2member_log"][] = "Email sent after signup, ( w/tiny URL ) to assist customer w/ registration.";
115
- }
116
- }
117
- else if ($longurl = get_bloginfo ("url") . "/?s2member_paypal_register=" . urlencode ($subscr_id_custom_item_number_xencrypted))
118
{
119
- if (is_array ($cv = preg_split ("/\|/", $paypal["custom"]))) /* Values passed through the "custom" field to PayPal. */
120
- {
121
- $sbj = preg_replace ("/%%registration_url%%/i", $longurl, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_email_subject"]);
122
- $msg = preg_replace ("/%%registration_url%%/i", $longurl, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_email_message"]);
123
- /**/
124
- if (preg_match ("/^web_accept#x2F;i", $paypal["txn_type"]))
125
- {
126
- $paypal["period3"] = "1 L"; /* 1 Lifetime. */
127
- $paypal["amount3"] = $paypal["payment_gross"];
128
- }
129
- /**/
130
- $initial_term = $paypal["period1"] ? $paypal["period1"] : "0 D"; /* Do not allow the initial period to be empty. */
131
- $initial = (isset ($paypal["amount1"]) && preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["amount1"] : $paypal["amount3"];
132
- $regular = $paypal["amount3"]; /* This is the regular payment amount that is charged to the customer. Always required by PayPal. */
133
- $recurring = ($paypal["recurring"]) ? $paypal["amount3"] : "0"; /* If non-recurring, this should be zero, otherwise regular. */
134
- /* The initial amount will only be $0 if a trial was offered. If no trial was offered, they were charged a regular rate. */
135
- if (($sbj = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $sbj)) && ($sbj = preg_replace ("/%%subscr_id%%/i", urlencode ($paypal["subscr_id"]), $sbj)))
136
- if (($sbj = preg_replace ("/%%initial%%/i", urlencode ($initial), $sbj)) && ($sbj = preg_replace ("/%%recurring%%/i", urlencode ($recurring), $sbj))) /* Adv calculations. */
137
- if (($sbj = preg_replace ("/%%regular%%/i", urlencode ($regular), $sbj))) /* This is provided mostly for rare cases where a trial is offered, and there is NO recurrence. */
138
- /* In cases where there is a free trial offered, and no recurring charges either ( could happen ), both initial & recurring are 0. So regular should be reported then. */
139
- if (($sbj = preg_replace ("/%%initial_term%%/i", urlencode ($initial_term), $sbj)) && ($sbj = preg_replace ("/%%regular_term%%/i", urlencode ($paypal["period3"]), $sbj)))
140
- if (($sbj = preg_replace ("/%%item_number%%/i", urlencode ($paypal["item_number"]), $sbj)) && ($sbj = preg_replace ("/%%item_name%%/i", urlencode ($paypal["item_name"]), $sbj)))
141
- if (($sbj = preg_replace ("/%%first_name%%/i", urlencode ($paypal["first_name"]), $sbj)) && ($sbj = preg_replace ("/%%last_name%%/i", urlencode ($paypal["last_name"]), $sbj)))
142
- if (($sbj = preg_replace ("/%%full_name%%/i", urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)))
143
- if (($sbj = preg_replace ("/%%payer_email%%/i", urlencode ($paypal["payer_email"]), $sbj)) && ($sbj = trim ($sbj)))
144
- if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", urlencode ($paypal["subscr_id"]), $msg)))
145
- if (($msg = preg_replace ("/%%initial%%/i", urlencode ($initial), $msg)) && ($msg = preg_replace ("/%%recurring%%/i", urlencode ($recurring), $msg))) /* Adv calculations. */
146
- if (($msg = preg_replace ("/%%regular%%/i", urlencode ($regular), $msg))) /* This is provided mostly for rare cases where a trial is offered, and there is NO recurrence. */
147
- /* In cases where there is a free trial offered, and no recurring charges either ( could happen ), both initial & recurring are 0. So regular should be reported then. */
148
- if (($msg = preg_replace ("/%%initial_term%%/i", urlencode ($initial_term), $msg)) && ($msg = preg_replace ("/%%regular_term%%/i", urlencode ($paypal["period3"]), $msg)))
149
- if (($msg = preg_replace ("/%%item_number%%/i", urlencode ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", urlencode ($paypal["item_name"]), $msg)))
150
- if (($msg = preg_replace ("/%%first_name%%/i", urlencode ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", urlencode ($paypal["last_name"]), $msg)))
151
- if (($msg = preg_replace ("/%%full_name%%/i", urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
152
- if (($msg = preg_replace ("/%%payer_email%%/i", urlencode ($paypal["payer_email"]), $msg)) && ($msg = trim ($msg)))
153
- @mail ($paypal["payer_email"], $sbj, $msg, "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8", "-f " . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"]);
154
- /**/
155
- $paypal["s2member_log"][] = "Email sent after signup, ( w/long URL ) to assist customer w/ registration.";
156
- }
157
}
158
}
159
}
160
/**/
@@ -163,90 +189,155 @@ function ws_plugin__s2member_paypal_notify ()
163
if (preg_match ("/^web_accept#x2F;i", $paypal["txn_type"]))
164
{
165
$paypal["period3"] = "1 L"; /* 1 Lifetime. */
166
- $paypal["amount3"] = $paypal["payment_gross"];
167
}
168
/**/
169
- $initial_term = $paypal["period1"] ? $paypal["period1"] : "0 D"; /* Do not allow the initial period to be empty. */
170
- $initial = (isset ($paypal["amount1"]) && preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["amount1"] : $paypal["amount3"];
171
- $regular = $paypal["amount3"]; /* This is the regular payment amount that is charged to the customer. Always required by PayPal. */
172
- $recurring = ($paypal["recurring"]) ? $paypal["amount3"] : "0"; /* If non-recurring, this should be zero, otherwise regular. */
173
/* The initial amount will only be $0 if a trial was offered. If no trial was offered, they were charged a regular rate. */
174
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_urls"]) as $url)
175
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", urlencode ($paypal["subscr_id"]), $url)))
176
- if (($url = preg_replace ("/%%initial%%/i", urlencode ($initial), $url)) && ($url = preg_replace ("/%%recurring%%/i", urlencode ($recurring), $url))) /* Adv calculations. */
177
- if (($url = preg_replace ("/%%regular%%/i", urlencode ($regular), $url))) /* This is provided mostly for rare cases where a trial is offered, and there is NO recurrence. */
178
- /* In cases where there is a free trial offered, and no recurring charges either ( could happen ), both initial & recurring are 0. So regular should be reported then. */
179
- if (($url = preg_replace ("/%%initial_term%%/i", urlencode ($initial_term), $url)) && ($url = preg_replace ("/%%regular_term%%/i", urlencode ($paypal["period3"]), $url)))
180
- if (($url = preg_replace ("/%%item_number%%/i", urlencode ($paypal["item_number"]), $url)) && ($url = preg_replace ("/%%item_name%%/i", urlencode ($paypal["item_name"]), $url)))
181
- if (($url = preg_replace ("/%%first_name%%/i", urlencode ($paypal["first_name"]), $url)) && ($url = preg_replace ("/%%last_name%%/i", urlencode ($paypal["last_name"]), $url)))
182
- if (($url = preg_replace ("/%%full_name%%/i", urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $url)))
183
- if (($url = preg_replace ("/%%payer_email%%/i", urlencode ($paypal["payer_email"]), $url)))
184
- if (($url = trim ($url))) /* Make sure it is not empty now. */
185
- ws_plugin__s2member_curlpsr ($url, "s2member=1");
186
/**/
187
- $paypal["s2member_log"][] = "Signup notification URLs have been processed.";
188
}
189
}
190
- else if (preg_match ("/^subscr_modify#x2F;i", $paypal["txn_type"]) && $paypal["subscr_id"] && preg_match ("/^[1-4]#x2F;", $paypal["item_number"]))
191
{
192
$paypal["s2member_log"][] = "s2Member txn_type identified as subscr_modify.";
193
/**/
194
if ($q = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = 's2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($paypal["subscr_id"]) . "' LIMIT 1"))
195
{
196
if ($user_id = $q->user_id) /* Got it! */
197
{
198
$user = new WP_User ($user_id);
199
- $user->set_role ("s2member_level" . $paypal["item_number"]);
200
update_usermeta ($user_id, "s2member_custom", $paypal["custom"]);
201
/**/
202
- $paypal["s2member_log"][] = "s2Member level updated on subscription modification.";
203
}
204
else
205
{
206
- $paypal["s2member_log"][] = "Unable to get user_id from the DB.";
207
}
208
}
209
else
210
{
211
- $paypal["s2member_log"][] = "Unable to find subscription in the DB.";
212
}
213
}
214
- else if (preg_match ("/^subscr_payment#x2F;i", $paypal["txn_type"]) && $paypal["payer_email"] && $paypal["subscr_id"] && preg_match ("/^[1-4]#x2F;", $paypal["item_number"]) && $paypal["txn_id"] && $paypal["payment_gross"])
215
{
216
$paypal["s2member_log"][] = "s2Member txn_type identified as subscr_payment.";
217
/**/
218
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
219
{
220
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url)
221
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", urlencode ($paypal["subscr_id"]), $url)))
222
- if (($url = preg_replace ("/%%amount%%/i", urlencode ($paypal["payment_gross"]), $url)) && ($url = preg_replace ("/%%txn_id%%/i", urlencode ($paypal["txn_id"]), $url)))
223
if (($url = preg_replace ("/%%item_number%%/i", urlencode ($paypal["item_number"]), $url)) && ($url = preg_replace ("/%%item_name%%/i", urlencode ($paypal["item_name"]), $url)))
224
if (($url = preg_replace ("/%%first_name%%/i", urlencode ($paypal["first_name"]), $url)) && ($url = preg_replace ("/%%last_name%%/i", urlencode ($paypal["last_name"]), $url)))
225
if (($url = preg_replace ("/%%full_name%%/i", urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $url)))
226
if (($url = preg_replace ("/%%payer_email%%/i", urlencode ($paypal["payer_email"]), $url)))
227
- if (($url = trim ($url))) /* Make sure it is not empty now. */
228
ws_plugin__s2member_curlpsr ($url, "s2member=1");
229
/**/
230
- $paypal["s2member_log"][] = "Payment notification URLs have been processed.";
231
}
232
}
233
- else if ((preg_match ("/^subscr_eot#x2F;i", $paypal["txn_type"]) || preg_match ("/^(refunded|reversed)#x2F;i", $paypal["payment_status"])) && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["parent_txn_id"])) && preg_match ("/^[1-4]#x2F;", $paypal["item_number"]))
234
{
235
$paypal["s2member_log"][] = "s2Member txn_type identified as subscr_eot - or - payment_status (refunded|reversed).";
236
/**/
237
if ($q = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = 's2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($paypal["subscr_id"]) . "' LIMIT 1"))
238
{
239
- if ($user_id = $q->user_id) /* Delete the user. Note that `ws_plugin__s2member_handle_user_deletions()` is fired too; it handles the `eot_del_notification_urls`. */
240
{
241
- wp_delete_user ($user_id); /* This triggers `ws_plugin__s2member_handle_user_deletions()` */
242
- /**/
243
- $paypal["s2member_log"][] = "User account automatically deleted from the system.";
244
- /**/
245
- $paypal["s2member_log"][] = "EOT/Deletion notification URLs have been processed.";
246
}
247
else
248
{
249
- $paypal["s2member_log"][] = "Unable to get user_id from the DB.";
250
}
251
/**/
252
if (!preg_match ("/^subscr_eot#x2F;i", $paypal["txn_type"]) && preg_match ("/^(refunded|reversed)#x2F;i", $paypal["payment_status"]) && $paypal["parent_txn_id"])
@@ -254,37 +345,39 @@ function ws_plugin__s2member_paypal_notify ()
254
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
255
{
256
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"]) as $url)
257
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", urlencode ($paypal["subscr_id"]), $url)))
258
- if (($url = preg_replace ("/%%-amount%%/i", urlencode ($paypal["payment_gross"]), $url)) && ($url = preg_replace ("/%%parent_txn_id%%/i", urlencode ($paypal["parent_txn_id"]), $url)))
259
if (($url = preg_replace ("/%%item_number%%/i", urlencode ($paypal["item_number"]), $url)) && ($url = preg_replace ("/%%item_name%%/i", urlencode ($paypal["item_name"]), $url)))
260
if (($url = preg_replace ("/%%first_name%%/i", urlencode ($paypal["first_name"]), $url)) && ($url = preg_replace ("/%%last_name%%/i", urlencode ($paypal["last_name"]), $url)))
261
if (($url = preg_replace ("/%%full_name%%/i", urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $url)))
262
if (($url = preg_replace ("/%%payer_email%%/i", urlencode ($paypal["payer_email"]), $url)))
263
- if (($url = trim ($url))) /* Make sure it is not empty now. */
264
ws_plugin__s2member_curlpsr ($url, "s2member=1");
265
/**/
266
- $paypal["s2member_log"][] = "Refund/Reversal notification URLs have been processed.";
267
}
268
}
269
}
270
else
271
{
272
- $paypal["s2member_log"][] = "Unable to find subscription in the DB.";
273
}
274
}
275
else
276
{
277
- $paypal["s2member_log"][] = "The txn_type does not require any action on the part of s2Member.";
278
}
279
}
280
else
281
{
282
- $paypal["s2member_log"][] = "Unable to verify _SERVER[HTTP_HOST].";
283
}
284
}
285
else
286
{
287
- $paypal["s2member_log"][] = "Unable to verify POST vars.";
288
}
289
/**/
290
if ($_GET["s2member_paypal_proxy"]) /* For proxy identification. */
31
{ /* The business address validation was removed from this routine, because PayPal® always fills that with the primary
32
email address. In cases where an alternate PayPal® address is being paid, validation is not possible. */
33
$paypal["s2member_log"][] = "s2Member originating domain ( _SERVER[HTTP_HOST] ) validated.";
34
+ /*
35
+ Single-Page Access.
36
+ */
37
+ if (preg_match ("/^web_accept#x2F;i", $paypal["txn_type"]) && $paypal["payer_email"] && $paypal["txn_id"] && preg_match ("/^sp\:[0-9]+#x2F;", $paypal["item_number"]))
38
+ {
39
+ $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept) for Single-Page access.";
40
+ /**/
41
+ list (, $paypal["page"]) = preg_split ("/\:/", $paypal["item_number"], 2);
42
+ /**/
43
+ if (($sp_access_url = ws_plugin__s2member_sp_access_link_gen ($paypal["page"])) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
44
+ {
45
+ $sbj = preg_replace ("/%%sp_access_url%%/i", $sp_access_url, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["single_page_email_subject"]);
46
+ $msg = preg_replace ("/%%sp_access_url%%/i", $sp_access_url, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["single_page_email_message"]);
47
+ /**/
48
+ if (($sbj = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)) && ($sbj = preg_replace ("/%%txn_id%%/i", $paypal["txn_id"], $sbj)))
49
+ if (($sbj = preg_replace ("/%%amount%%/i", $paypal["mc_gross"], $sbj))) /* Full amount of the payment, before fee is subtracted. */
50
+ if (($sbj = preg_replace ("/%%item_number%%/i", $paypal["item_number"], $sbj)) && ($sbj = preg_replace ("/%%item_name%%/i", $paypal["item_name"], $sbj)))
51
+ if (($sbj = preg_replace ("/%%first_name%%/i", $paypal["first_name"], $sbj)) && ($sbj = preg_replace ("/%%last_name%%/i", $paypal["last_name"], $sbj)))
52
+ if (($sbj = preg_replace ("/%%full_name%%/i", trim ($paypal["first_name"] . " " . $paypal["last_name"]), $sbj)))
53
+ if (($sbj = preg_replace ("/%%payer_email%%/i", $paypal["payer_email"], $sbj)))
54
+ /**/
55
+ if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%txn_id%%/i", $paypal["txn_id"], $msg)))
56
+ if (($msg = preg_replace ("/%%amount%%/i", $paypal["mc_gross"], $msg))) /* Full amount of the payment, before fee is subtracted. */
57
+ if (($msg = preg_replace ("/%%item_number%%/i", $paypal["item_number"], $msg)) && ($msg = preg_replace ("/%%item_name%%/i", $paypal["item_name"], $msg)))
58
+ if (($msg = preg_replace ("/%%first_name%%/i", $paypal["first_name"], $msg)) && ($msg = preg_replace ("/%%last_name%%/i", $paypal["last_name"], $msg)))
59
+ if (($msg = preg_replace ("/%%full_name%%/i", trim ($paypal["first_name"] . " " . $paypal["last_name"]), $msg)))
60
+ if (($msg = preg_replace ("/%%payer_email%%/i", $paypal["payer_email"], $msg)))
61
+ /**/
62
+ if (($sbj = trim ($sbj)) && ($msg = trim ($msg))) /* Make sure they are not empty. */
63
+ {
64
+ @mail ($paypal["payer_email"], $sbj, $msg, "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8", "-f " . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"]);
65
+ /**/
66
+ $paypal["s2member_log"][] = "Email sent after purchase, with a URL that provides the Customer with Single-Page Access.";
67
+ }
68
+ /**/
69
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_notification_urls"])
70
+ {
71
+ foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_notification_urls"]) as $url)
72
+ /**/
73
+ if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%sp_access_url%%/i", rawurlencode ($sp_access_url), $url)))
74
+ if (($url = preg_replace ("/%%amount%%/i", urlencode ($paypal["mc_gross"]), $url)) && ($url = preg_replace ("/%%txn_id%%/i", urlencode ($paypal["txn_id"]), $url)))
75
+ if (($url = preg_replace ("/%%item_number%%/i", urlencode ($paypal["item_number"]), $url)) && ($url = preg_replace ("/%%item_name%%/i", urlencode ($paypal["item_name"]), $url)))
76
+ if (($url = preg_replace ("/%%first_name%%/i", urlencode ($paypal["first_name"]), $url)) && ($url = preg_replace ("/%%last_name%%/i", urlencode ($paypal["last_name"]), $url)))
77
+ if (($url = preg_replace ("/%%full_name%%/i", urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $url)))
78
+ if (($url = preg_replace ("/%%payer_email%%/i", urlencode ($paypal["payer_email"]), $url)))
79
+ /**/
80
+ if (($url = trim ($url))) /* Make sure it is not empty. */
81
+ ws_plugin__s2member_curlpsr ($url, "s2member=1");
82
+ /**/
83
+ $paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
84
+ }
85
+ }
86
+ }
87
+ /*
88
+ New subscriptions. Possibly containing advanced updated vars ( option_name1, option_selection1 ); which allow account modifications.
89
+ */
90
+ else if (preg_match ("/^(web_accept|subscr_signup)#x2F;i", $paypal["txn_type"]) && $paypal["payer_email"] && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["txn_id"])) && preg_match ("/^[1-4](\:|$)/", $paypal["item_number"]))
91
{
92
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup).";
93
/**/
94
+ list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
95
+ /*
96
+ New subscription with advanced update vars ( option_name1, option_selection1 ).
97
+ */
98
if (preg_match ("/(updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) /* This is an advanced way to handle subscription update modifications. */
99
/* This advanced method is required whenever a subscription that is already completed, or was never setup to recur in the first place needs to be modified. PayPal will not allow the
100
+ modify=1|2 parameter to be used in those scenarios, because technically there is nothing to update. The only thing that actually needs to be updated is their existing account. */
101
{
102
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup) w/ update vars.";
103
/**/
108
if ($user_id = $q->user_id) /* Got it! */
109
{
110
$user = new WP_User ($user_id);
111
+ $user->set_role ("s2member_level" . $paypal["level"]);
112
update_usermeta ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
113
update_usermeta ($user_id, "s2member_custom", $paypal["custom"]);
114
+ /**/
115
+ foreach ($user->allcaps as $cap => $cap_enabled)
116
+ if (preg_match ("/^access_s2member_ccap_/", $cap))
117
+ $user->remove_cap ($ccap = $cap);
118
+ /**/
119
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $paypal["ccaps"]) as $ccap)
120
+ if (strlen ($ccap)) /* Don't add empty capabilities. */
121
+ $user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
122
+ /**/
123
delete_usermeta ($user_id, "s2member_file_download_access_arc");
124
delete_usermeta ($user_id, "s2member_file_download_access_log");
125
/**/
126
+ $paypal["s2member_log"][] = "s2Member Level/Capabilities updated w/ advanced update routines.";
127
}
128
else
129
{
130
+ $paypal["s2member_log"][] = "Unable to modify subscription. Could not get the existing user_id from the DB. Please check the on0 and os0 variables in your Button Code.";
131
}
132
}
133
else
134
{
135
+ $paypal["s2member_log"][] = "Unable to modify subscription. Could not find existing subscription in the DB. Please check the on0 and os0 variables in your Button Code.";
136
}
137
}
138
+ /*
139
+ New subscription. Normal subscription signup, we are not updating anything for a past subscription.
140
+ */
141
else /* Else this is a normal subscription signup, we are not updating anything for a past subscription. */
142
{
143
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup) w/o update vars.";
144
/**/
145
+ if ($registration_url = ws_plugin__s2member_register_link_gen ($paypal["subscr_id"], $paypal["custom"], $paypal["item_number"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
146
{
147
+ $sbj = preg_replace ("/%%registration_url%%/i", $registration_url, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_email_subject"]);
148
+ $msg = preg_replace ("/%%registration_url%%/i", $registration_url, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_email_message"]);
149
+ /**/
150
+ if (preg_match ("/^web_accept#x2F;i", $paypal["txn_type"]))
151
{
152
+ $paypal["period3"] = "1 L"; /* 1 Lifetime. */
153
+ $paypal["mc_amount3"] = $paypal["mc_gross"];
154
}
155
+ /**/
156
+ $initial_term = $paypal["period1"] ? $paypal["period1"] : "0 D"; /* Do not allow the initial period to be empty. Defaults to 0 D. */
157
+ $initial = (isset ($paypal["mc_amount1"]) && preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
158
+ $regular = $paypal["mc_amount3"]; /* This is the regular payment amount that is charged to the customer. Always required by PayPal. */
159
+ $recurring = ($paypal["recurring"]) ? $paypal["mc_amount3"] : "0"; /* If non-recurring, this should be zero, otherwise regular. */
160
+ /* The initial amount will only be $0 if a trial was offered. If no trial was offered, they were charged a regular rate. */
161
+ /**/
162
+ if (($sbj = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)) && ($sbj = preg_replace ("/%%subscr_id%%/i", $paypal["subscr_id"], $sbj)))
163
+ if (($sbj = preg_replace ("/%%initial%%/i", $initial, $sbj)) && ($sbj = preg_replace ("/%%recurring%%/i", $recurring, $sbj)) && ($sbj = preg_replace ("/%%regular%%/i", $regular, $sbj)))
164
+ if (($sbj = preg_replace ("/%%initial_term%%/i", $initial_term, $sbj)) && ($sbj = preg_replace ("/%%regular_term%%/i", $paypal["period3"], $sbj)))
165
+ if (($sbj = preg_replace ("/%%item_number%%/i", $paypal["item_number"], $sbj)) && ($sbj = preg_replace ("/%%item_name%%/i", $paypal["item_name"], $sbj)))
166
+ if (($sbj = preg_replace ("/%%first_name%%/i", $paypal["first_name"], $sbj)) && ($sbj = preg_replace ("/%%last_name%%/i", $paypal["last_name"], $sbj)))
167
+ if (($sbj = preg_replace ("/%%full_name%%/i", trim ($paypal["first_name"] . " " . $paypal["last_name"]), $sbj)))
168
+ if (($sbj = preg_replace ("/%%payer_email%%/i", $paypal["payer_email"], $sbj)))
169
+ /**/
170
+ if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", $paypal["subscr_id"], $msg)))
171
+ if (($msg = preg_replace ("/%%initial%%/i", $initial, $msg)) && ($msg = preg_replace ("/%%recurring%%/i", $recurring, $msg)) && ($msg = preg_replace ("/%%regular%%/i", $regular, $msg)))
172
+ if (($msg = preg_replace ("/%%initial_term%%/i", $initial_term, $msg)) && ($msg = preg_replace ("/%%regular_term%%/i", $paypal["period3"], $msg)))
173
+ if (($msg = preg_replace ("/%%item_number%%/i", $paypal["item_number"], $msg)) && ($msg = preg_replace ("/%%item_name%%/i", $paypal["item_name"], $msg)))
174
+ if (($msg = preg_replace ("/%%first_name%%/i", $paypal["first_name"], $msg)) && ($msg = preg_replace ("/%%last_name%%/i", $paypal["last_name"], $msg)))
175
+ if (($msg = preg_replace ("/%%full_name%%/i", trim ($paypal["first_name"] . " " . $paypal["last_name"]), $msg)))
176
+ if (($msg = preg_replace ("/%%payer_email%%/i", $paypal["payer_email"], $msg)))
177
+ /**/
178
+ if (($sbj = trim ($sbj)) && ($msg = trim ($msg))) /* Make sure they are not empty. */
179
+ {
180
+ @mail ($paypal["payer_email"], $sbj, $msg, "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8", "-f " . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"]);
181
+ /**/
182
+ $paypal["s2member_log"][] = "Email sent after signup, with a URL to assist Customer w/ registration.";
183
+ }
184
}
185
}
186
/**/
189
if (preg_match ("/^web_accept#x2F;i", $paypal["txn_type"]))
190
{
191
$paypal["period3"] = "1 L"; /* 1 Lifetime. */
192
+ $paypal["mc_amount3"] = $paypal["mc_gross"];
193
}
194
/**/
195
+ $initial_term = $paypal["period1"] ? $paypal["period1"] : "0 D"; /* Do not allow the initial period to be empty. Defaults to 0 D. */
196
+ $initial = (isset ($paypal["mc_amount1"]) && preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
197
+ $regular = $paypal["mc_amount3"]; /* This is the regular payment amount that is charged to the customer. Always required by PayPal. */
198
+ $recurring = ($paypal["recurring"]) ? $paypal["mc_amount3"] : "0"; /* If non-recurring, this should be zero, otherwise regular. */
199
/* The initial amount will only be $0 if a trial was offered. If no trial was offered, they were charged a regular rate. */
200
+ /**/
201
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_urls"]) as $url)
202
+ /**/
203
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", urlencode ($paypal["subscr_id"]), $url)))
204
+ if (($url = preg_replace ("/%%initial%%/i", urlencode ($initial), $url)) && ($url = preg_replace ("/%%recurring%%/i", urlencode ($recurring), $url)) && ($url = preg_replace ("/%%regular%%/i", urlencode ($regular), $url)))
205
+ if (($url = preg_replace ("/%%initial_term%%/i", urlencode ($initial_term), $url)) && ($url = preg_replace ("/%%regular_term%%/i", urlencode ($paypal["period3"]), $url)))
206
+ if (($url = preg_replace ("/%%item_number%%/i", urlencode ($paypal["item_number"]), $url)) && ($url = preg_replace ("/%%item_name%%/i", urlencode ($paypal["item_name"]), $url)))
207
+ if (($url = preg_replace ("/%%first_name%%/i", urlencode ($paypal["first_name"]), $url)) && ($url = preg_replace ("/%%last_name%%/i", urlencode ($paypal["last_name"]), $url)))
208
+ if (($url = preg_replace ("/%%full_name%%/i", urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $url)))
209
+ if (($url = preg_replace ("/%%payer_email%%/i", urlencode ($paypal["payer_email"]), $url)))
210
+ /**/
211
+ if (($url = trim ($url))) /* Make sure it is not empty. */
212
+ ws_plugin__s2member_curlpsr ($url, "s2member=1");
213
/**/
214
+ $paypal["s2member_log"][] = "Signup Notification URLs have been processed.";
215
}
216
}
217
+ /*
218
+ Subscription modifications.
219
+ */
220
+ else if (preg_match ("/^subscr_modify#x2F;i", $paypal["txn_type"]) && $paypal["subscr_id"] && preg_match ("/^[1-4](\:|$)/", $paypal["item_number"]))
221
{
222
$paypal["s2member_log"][] = "s2Member txn_type identified as subscr_modify.";
223
/**/
224
+ list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
225
+ /**/
226
if ($q = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = 's2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($paypal["subscr_id"]) . "' LIMIT 1"))
227
{
228
if ($user_id = $q->user_id) /* Got it! */
229
{
230
$user = new WP_User ($user_id);
231
+ $user->set_role ("s2member_level" . $paypal["level"]);
232
+ update_usermeta ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
233
update_usermeta ($user_id, "s2member_custom", $paypal["custom"]);
234
/**/
235
+ foreach ($user->allcaps as $cap => $cap_enabled)
236
+ if (preg_match ("/^access_s2member_ccap_/", $cap))
237
+ $user->remove_cap ($ccap = $cap);
238
+ /**/
239
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $paypal["ccaps"]) as $ccap)
240
+ if (strlen ($ccap)) /* Don't add empty capabilities. */
241
+ $user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
242
+ /**/
243
+ delete_usermeta ($user_id, "s2member_file_download_access_arc");
244
+ delete_usermeta ($user_id, "s2member_file_download_access_log");
245
+ /**/
246
+ $paypal["s2member_log"][] = "s2Member Level/Capabilities updated on subscription modification.";
247
}
248
else
249
{
250
+ $paypal["s2member_log"][] = "Unable to modify subscription. Could not get the existing user_id from the DB.";
251
}
252
}
253
else
254
{
255
+ $paypal["s2member_log"][] = "Unable to modify subscription. Could not find existing subscription in the DB.";
256
}
257
}
258
+ /*
259
+ Subscription payments.
260
+ */
261
+ else if (preg_match ("/^subscr_payment#x2F;i", $paypal["txn_type"]) && $paypal["payer_email"] && $paypal["subscr_id"] && preg_match ("/^[1-4](\:|$)/", $paypal["item_number"]) && $paypal["txn_id"] && $paypal["mc_gross"])
262
{
263
$paypal["s2member_log"][] = "s2Member txn_type identified as subscr_payment.";
264
/**/
265
+ list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
266
+ /**/
267
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
268
{
269
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url)
270
+ /**/
271
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", urlencode ($paypal["subscr_id"]), $url)))
272
+ if (($url = preg_replace ("/%%amount%%/i", urlencode ($paypal["mc_gross"]), $url)) && ($url = preg_replace ("/%%txn_id%%/i", urlencode ($paypal["txn_id"]), $url)))
273
if (($url = preg_replace ("/%%item_number%%/i", urlencode ($paypal["item_number"]), $url)) && ($url = preg_replace ("/%%item_name%%/i", urlencode ($paypal["item_name"]), $url)))
274
if (($url = preg_replace ("/%%first_name%%/i", urlencode ($paypal["first_name"]), $url)) && ($url = preg_replace ("/%%last_name%%/i", urlencode ($paypal["last_name"]), $url)))
275
if (($url = preg_replace ("/%%full_name%%/i", urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $url)))
276
if (($url = preg_replace ("/%%payer_email%%/i", urlencode ($paypal["payer_email"]), $url)))
277
+ /**/
278
+ if (($url = trim ($url))) /* Make sure it is not empty. */
279
ws_plugin__s2member_curlpsr ($url, "s2member=1");
280
/**/
281
+ $paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
282
}
283
}
284
+ /*
285
+ Subscription terminations.
286
+ */
287
+ else if ((preg_match ("/^subscr_eot#x2F;i", $paypal["txn_type"]) || preg_match ("/^(refunded|reversed)#x2F;i", $paypal["payment_status"])) && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["parent_txn_id"])) && preg_match ("/^[1-4](\:|$)/", $paypal["item_number"]))
288
{
289
$paypal["s2member_log"][] = "s2Member txn_type identified as subscr_eot - or - payment_status (refunded|reversed).";
290
/**/
291
+ list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
292
+ /**/
293
if ($q = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = 's2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($paypal["subscr_id"]) . "' LIMIT 1"))
294
{
295
+ if ($user_id = $q->user_id) /* Demote to Free Subscriber, or delete the Member completely. */
296
{
297
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote")
298
+ {
299
+ $user = new WP_User ($user_id);
300
+ $user->set_role ("subscriber");
301
+ delete_usermeta ($user_id, "s2member_custom");
302
+ delete_usermeta ($user_id, "s2member_subscr_id");
303
+ /**/
304
+ foreach ($user->allcaps as $cap => $cap_enabled)
305
+ if (preg_match ("/^access_s2member_ccap_/", $cap))
306
+ $user->remove_cap ($ccap = $cap);
307
+ /**/
308
+ delete_usermeta ($user_id, "s2member_file_download_access_arc");
309
+ delete_usermeta ($user_id, "s2member_file_download_access_log");
310
+ /**/
311
+ $paypal["s2member_log"][] = "Member Level/Capabilities demoted to a Free Subscriber.";
312
+ /**/
313
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
314
+ {
315
+ foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"]) as $url) /* Handle eot notifications. */
316
+ /**/
317
+ if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", urlencode ($paypal["subscr_id"]), $url)))
318
+ if (($url = preg_replace ("/%%user_first_name%%/i", urlencode ($user->first_name), $url)) && ($url = preg_replace ("/%%user_last_name%%/i", urlencode ($user->last_name), $url)))
319
+ if (($url = preg_replace ("/%%user_full_name%%/i", urlencode (trim ($user->first_name . " " . $user->last_name)), $url)))
320
+ if (($url = preg_replace ("/%%user_email%%/i", urlencode ($user->user_email), $url)))
321
+ /**/
322
+ if (($url = trim ($url))) /* Make sure it is not empty. */
323
+ ws_plugin__s2member_curlpsr ($url, "s2member=1");
324
+ /**/
325
+ $paypal["s2member_log"][] = "EOT/Deletion Notification URLs have been processed.";
326
+ }
327
+ }
328
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete")
329
+ {
330
+ wp_delete_user ($user_id); /* Triggers: `ws_plugin__s2member_handle_user_deletions()` */
331
+ /* `ws_plugin__s2member_handle_user_deletions()` triggers `eot_del_notification_urls` */
332
+ /**/
333
+ $paypal["s2member_log"][] = "The Member's account has been deleted completely.";
334
+ /**/
335
+ $paypal["s2member_log"][] = "EOT/Deletion Notification URLs have been processed.";
336
+ }
337
}
338
else
339
{
340
+ $paypal["s2member_log"][] = "Unable to (demote|delete) Member. Could not get the existing user_id from the DB. It's possible that it was already removed manually by a site administrator.";
341
}
342
/**/
343
if (!preg_match ("/^subscr_eot#x2F;i", $paypal["txn_type"]) && preg_match ("/^(refunded|reversed)#x2F;i", $paypal["payment_status"]) && $paypal["parent_txn_id"])
345
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
346
{
347
foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"]) as $url)
348
+ /**/
349
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", urlencode ($paypal["subscr_id"]), $url)))
350
+ if (($url = preg_replace ("/%%-amount%%/i", urlencode ($paypal["mc_gross"]), $url)) && ($url = preg_replace ("/%%parent_txn_id%%/i", urlencode ($paypal["parent_txn_id"]), $url)))
351
if (($url = preg_replace ("/%%item_number%%/i", urlencode ($paypal["item_number"]), $url)) && ($url = preg_replace ("/%%item_name%%/i", urlencode ($paypal["item_name"]), $url)))
352
if (($url = preg_replace ("/%%first_name%%/i", urlencode ($paypal["first_name"]), $url)) && ($url = preg_replace ("/%%last_name%%/i", urlencode ($paypal["last_name"]), $url)))
353
if (($url = preg_replace ("/%%full_name%%/i", urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $url)))
354
if (($url = preg_replace ("/%%payer_email%%/i", urlencode ($paypal["payer_email"]), $url)))
355
+ /**/
356
+ if (($url = trim ($url))) /* Make sure it is not empty. */
357
ws_plugin__s2member_curlpsr ($url, "s2member=1");
358
/**/
359
+ $paypal["s2member_log"][] = "Refund/Reversal Notification URLs have been processed.";
360
}
361
}
362
}
363
else
364
{
365
+ $paypal["s2member_log"][] = "Unable to (demote|delete) Member. Could not find existing subscription in the DB. It's possible that it was already removed manually by a site administrator.";
366
}
367
}
368
else
369
{
370
+ $paypal["s2member_log"][] = "Properly ignoring this IPN request. The txn_type does not require any action on the part of s2Member.";
371
}
372
}
373
else
374
{
375
+ $paypal["s2member_log"][] = "Unable to verify _SERVER[HTTP_HOST]. Possibly caused by a fraudulent request. If this error continues, please check the `custom` value in your Button Code. It MUST start with your domain name.";
376
}
377
}
378
else
379
{
380
+ $paypal["s2member_log"][] = "Unable to verify POST vars. Possibly caused by a fraudulent request. If this error continues, please run IPN tests against your server from a PayPal® Sandbox account. They provide special diagnostic tools that may assist you.";
381
}
382
/**/
383
if ($_GET["s2member_paypal_proxy"]) /* For proxy identification. */
includes/functions/paypal-register.inc.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
13
- */
14
- if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit;
16
- /*
17
- Handles paypal registration links.
18
- Attach to: add_action("init");
19
- */
20
- function ws_plugin__s2member_paypal_register ()
21
- {
22
- if ($_GET["s2member_paypal_register"])
23
- {
24
- if (is_array ($registered = preg_split ("/\:\.\:\|\:\.\:/", ws_plugin__s2member_xdecrypt ($_GET["s2member_paypal_register"]))))
25
- {
26
- if (count ($registered) === 4 && $registered[0] === "subscr_id_custom_item_number" && $registered[1] && $registered[2] && $registered[3])
27
- {
28
- setcookie ("s2member_subscr_id", $registered[1], time () + 31556926, "/");
29
- setcookie ("s2member_custom", $registered[2], time () + 31556926, "/");
30
- setcookie ("s2member_level", $registered[3], time () + 31556926, "/");
31
- /**/
32
- echo '<script type="text/javascript">' . "\n";
33
- echo "window.location = '" . esc_js (add_query_arg ("action", "register", wp_login_url ())) . "';";
34
- echo '</script>' . "\n";
35
- }
36
- }
37
- exit;
38
- }
39
- }
40
- ?>
includes/functions/paypal-return.inc.php CHANGED
@@ -34,12 +34,43 @@ function ws_plugin__s2member_paypal_return ()
34
{ /* The business address validation was removed from this routine, because PayPal® always fills that with the primary
35
email address. In cases where an alternate PayPal® address is being paid, validation is not possible. */
36
$paypal["s2member_log"][] = "s2Member originating domain ( _SERVER[HTTP_HOST] ) validated.";
37
- /**/
38
- if (preg_match ("/^(web_accept|subscr_signup|subscr_payment)#x2F;i", $paypal["txn_type"]) && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["txn_id"])) && preg_match ("/^[1-4]#x2F;", $paypal["item_number"]))
39
{ /* With Auto-Return/PDT, PayPal will send subscr_payment instead of subscr_signup to the return URL.
40
So we need to look for (web_accept|subscr_signup|subscr_payment), and treat them as the same. */
41
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup|subscr_payment).";
42
/**/
43
if (preg_match ("/(updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) /* Advanced subscription update modifications. */
44
/* This advanced method is required whenever a subscription that is already completed, or was never setup to recur in the first place needs to be modified. PayPal® will not allow the
45
modify=2 parameter to be used in those scenarios, because technically there is nothing to update. The only thing to be updated is the existing account. */
@@ -53,19 +84,28 @@ function ws_plugin__s2member_paypal_return ()
53
if ($user_id = $q->user_id) /* Got it! */
54
{
55
$user = new WP_User ($user_id);
56
- $user->set_role ("s2member_level" . $paypal["item_number"]);
57
update_usermeta ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
58
update_usermeta ($user_id, "s2member_custom", $paypal["custom"]);
59
delete_usermeta ($user_id, "s2member_file_download_access_arc");
60
delete_usermeta ($user_id, "s2member_file_download_access_log");
61
/**/
62
- $paypal["s2member_log"][] = "s2Member level updated w/ advanced update routines.";
63
/**/
64
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
65
echo '<html xmlns="http://www.w3.org/1999/xhtml" ', language_attributes (), '>' . "\n";
66
echo '<head profile="http://gmpg.org/xfn/11">' . "\n";
67
echo '<meta http-equiv="Content-Type" content="' . get_bloginfo ("html_type") . '; charset=' . get_bloginfo ("charset") . '" />' . "\n";
68
- echo '<script type="text/javascript">' . "\n"; /* Onload allows any pixel codes to finish loading. */
69
echo "window.onload = function(){ " . "\n"; /* After everything has finished loading, we alert and then redirect. */
70
echo "alert('Thank You! Your membership has been updated to:\\n\\n" . esc_js ($paypal["item_name"]) . "\\n\\nYou\\'ll need to log back in now.');" . "\n";
71
echo "window.location = '" . wp_login_url () . "'; };" . "\n";
@@ -74,58 +114,71 @@ function ws_plugin__s2member_paypal_return ()
74
/**/
75
echo '<body style="background:#' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_color"] . ' url(' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image"] . ');">' . "\n";
76
/**/
77
- echo '<!-- Pixel Tracking codes from the s2Member plugin for WordPress. -->' . "\n";
78
/**/
79
- if (($code = trim ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_pixel_tracking_codes"])) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
80
{
81
if (preg_match ("/^subscr_signup#x2F;i", $paypal["txn_type"]))
82
- $initial = (isset ($paypal["amount1"]) && preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["amount1"] : $paypal["amount3"];
83
/* The initial amount will only be $0 if a trial was offered. If no trial was offered, they were charged a regular rate. */
84
else if (preg_match ("/^(web_accept|subscr_payment)#x2F;i", $paypal["txn_type"])) /* PDT w/Auto-Return sends subscr_payment. */
85
- $initial = $paypal["payment_gross"]; /* Here, the initial payment is provided clearly as the payment gross. */
86
/**/
87
- if (($code = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $code)) && ($code = preg_replace ("/%%subscr_id%%/i", urlencode ($paypal["subscr_id"]), $code)))
88
- if (($code = preg_replace ("/%%initial%%/i", urlencode ($initial), $code))) /* Adv calculations here. We have to support both sets of variables, subscr_signup & subscr_payment. */
89
- if (($code = preg_replace ("/%%item_number%%/i", urlencode ($paypal["item_number"]), $code)) && ($code = preg_replace ("/%%item_name%%/i", urlencode ($paypal["item_name"]), $code)))
90
- if (($code = preg_replace ("/%%first_name%%/i", urlencode ($paypal["first_name"]), $code)) && ($code = preg_replace ("/%%last_name%%/i", urlencode ($paypal["last_name"]), $code)))
91
- if (($code = preg_replace ("/%%full_name%%/i", urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
92
- if (($code = preg_replace ("/%%payer_email%%/i", urlencode ($paypal["payer_email"]), $code)))
93
- if (($code = trim ($code))) /* Make sure it is not empty now. */
94
- echo $code . "\n"; /* Everything here must finish loading. */
95
- /**/
96
- $paypal["s2member_log"][] = "Signup Pixel Tracking codes have been processed.";
97
}
98
- echo '<!-- Pixel Tracking codes from the s2Member plugin for WordPress. -->' . "\n";
99
/**/
100
- $paypal["s2member_log"][] = "Redirecting user to login page.";
101
/**/
102
echo '</body>' . "\n";
103
echo '</html>';
104
}
105
else
106
{
107
- $paypal["s2member_log"][] = "Unable to get user_id from the DB.";
108
/**/
109
echo '<script type="text/javascript">' . "\n";
110
- echo "alert('Thank you very much... please click OK!');" . "\n";
111
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
112
echo '</script>' . "\n";
113
/**/
114
- $paypal["s2member_log"][] = "Redirecting user to login page.";
115
}
116
}
117
else
118
{
119
- $paypal["s2member_log"][] = "Unable to find subscription/subscriber in the DB.";
120
/**/
121
echo '<script type="text/javascript">' . "\n";
122
- echo "alert('Thank you very much... please click OK!');" . "\n";
123
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
124
echo '</script>' . "\n";
125
/**/
126
- $paypal["s2member_log"][] = "Redirecting user to login page.";
127
}
128
}
129
else /* Else this is a normal subscription signup, we are not updating anything for a past subscription. */
130
{
131
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup|subscr_payment) w/o update vars.";
@@ -140,124 +193,150 @@ function ws_plugin__s2member_paypal_return ()
140
echo '<html xmlns="http://www.w3.org/1999/xhtml" ', language_attributes (), '>' . "\n";
141
echo '<head profile="http://gmpg.org/xfn/11">' . "\n";
142
echo '<meta http-equiv="Content-Type" content="' . get_bloginfo ("html_type") . '; charset=' . get_bloginfo ("charset") . '" />' . "\n";
143
- echo '<script type="text/javascript">' . "\n"; /* Onload allows any pixel codes to finish loading. */
144
echo "window.onload = function(){ " . "\n"; /* After everything has finished loading, we alert and then redirect. */
145
- echo "alert('Thank You! Your membership has been approved.\\nThe next step is to Register a Username.\\n\\nPlease click OK to Register now.');" . "\n";/**/
146
echo "window.location = '" . esc_js (add_query_arg ("action", "register", wp_login_url ())) . "'; };" . "\n";
147
echo '</script>' . "\n";
148
echo '</head>' . "\n";
149
/**/
150
echo '<body style="background:#' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_color"] . ' url(' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image"] . ');">' . "\n";
151
/**/
152
- echo '<!-- Pixel Tracking codes from the s2Member plugin for WordPress. -->' . "\n";
153
/**/
154
- if (($code = trim ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_pixel_tracking_codes"])) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
155
{
156
if (preg_match ("/^subscr_signup#x2F;i", $paypal["txn_type"]))
157
- $initial = (isset ($paypal["amount1"]) && preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["amount1"] : $paypal["amount3"];
158
/* The initial amount will only be $0 if a trial was offered. If no trial was offered, they were charged a regular rate. */
159
else if (preg_match ("/^(web_accept|subscr_payment)#x2F;i", $paypal["txn_type"])) /* PDT w/Auto-Return sends subscr_payment. */
160
- $initial = $paypal["payment_gross"]; /* Here, the initial payment is provided clearly as the payment gross. */
161
- /**/
162
- if (($code = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $code)) && ($code = preg_replace ("/%%subscr_id%%/i", urlencode ($paypal["subscr_id"]), $code)))
163
- if (($code = preg_replace ("/%%initial%%/i", urlencode ($initial), $code))) /* Adv calculations here. We have to support both sets of variables, subscr_signup & subscr_payment. */
164
- if (($code = preg_replace ("/%%item_number%%/i", urlencode ($paypal["item_number"]), $code)) && ($code = preg_replace ("/%%item_name%%/i", urlencode ($paypal["item_name"]), $code)))
165
- if (($code = preg_replace ("/%%first_name%%/i", urlencode ($paypal["first_name"]), $code)) && ($code = preg_replace ("/%%last_name%%/i", urlencode ($paypal["last_name"]), $code)))
166
- if (($code = preg_replace ("/%%full_name%%/i", urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
167
- if (($code = preg_replace ("/%%payer_email%%/i", urlencode ($paypal["payer_email"]), $code)))
168
- if (($code = trim ($code))) /* Make sure it is not empty now. */
169
- echo $code . "\n"; /* Everything here must finish loading. */
170
/**/
171
- $paypal["s2member_log"][] = "Signup Pixel Tracking codes have been processed.";
172
}
173
- echo '<!-- Pixel Tracking codes from the s2Member plugin for WordPress. -->' . "\n";
174
/**/
175
- $paypal["s2member_log"][] = "Redirecting user to registration page.";
176
/**/
177
echo '</body>' . "\n";
178
echo '</html>';
179
}
180
}
181
- /**/
182
- else if (preg_match ("/^subscr_modify#x2F;i", $paypal["txn_type"]) && $paypal["subscr_id"] && preg_match ("/^[1-4]#x2F;", $paypal["item_number"]))
183
{
184
$paypal["s2member_log"][] = "s2Member txn_type identified as subscr_modify.";
185
/**/
186
if ($q = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = 's2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($paypal["subscr_id"]) . "' LIMIT 1"))
187
{
188
if ($user_id = $q->user_id) /* Got it! */
189
{
190
$user = new WP_User ($user_id);
191
- $user->set_role ("s2member_level" . $paypal["item_number"]);
192
update_usermeta ($user_id, "s2member_custom", $paypal["custom"]);
193
/**/
194
- $paypal["s2member_log"][] = "s2Member level updated on subscription modification.";
195
/**/
196
echo '<script type="text/javascript">' . "\n";
197
echo "alert('Thank You! Your membership has been updated to:\\n\\n" . esc_js ($paypal["item_name"]) . "\\n\\nYou\\'ll need to log back in now.');" . "\n";
198
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
199
echo '</script>' . "\n";
200
/**/
201
- $paypal["s2member_log"][] = "Redirecting user to login page.";
202
}
203
else
204
{
205
- $paypal["s2member_log"][] = "Unable to get user_id from the DB.";
206
/**/
207
echo '<script type="text/javascript">' . "\n";
208
- echo "alert('Thank you very much... please click OK!');" . "\n";
209
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
210
echo '</script>' . "\n";
211
/**/
212
- $paypal["s2member_log"][] = "Redirecting user to login page.";
213
}
214
}
215
else
216
{
217
- $paypal["s2member_log"][] = "Unable to find subscription in the DB.";
218
/**/
219
echo '<script type="text/javascript">' . "\n";
220
- echo "alert('Thank you very much... please click OK!');" . "\n";
221
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
222
echo '</script>' . "\n";
223
/**/
224
- $paypal["s2member_log"][] = "Redirecting user to login page.";
225
}
226
}
227
else
228
{
229
- $paypal["s2member_log"][] = "The txn_type does not require any action on the part of s2Member.";
230
/**/
231
echo '<script type="text/javascript">' . "\n";
232
- echo "alert('Thank you very much... please click OK!');" . "\n";
233
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
234
echo '</script>' . "\n";
235
/**/
236
- $paypal["s2member_log"][] = "Redirecting user to login page.";
237
}
238
}
239
else
240
{
241
- $paypal["s2member_log"][] = "Unable to verify _SERVER[HTTP_HOST].";
242
/**/
243
echo '<script type="text/javascript">' . "\n";
244
- echo "alert('Thank you very much... please click OK!');" . "\n";
245
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
246
echo '</script>' . "\n";
247
/**/
248
- $paypal["s2member_log"][] = "Redirecting user to login page.";
249
}
250
}
251
else
252
{
253
- $paypal["s2member_log"][] = "Unable to verify POST vars.";
254
/**/
255
echo '<script type="text/javascript">' . "\n";
256
- echo "alert('Thank you very much... please click OK!');" . "\n";
257
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
258
echo '</script>' . "\n";
259
/**/
260
- $paypal["s2member_log"][] = "Redirecting user to login page.";
261
}
262
/**/
263
if ($_GET["s2member_paypal_proxy"]) /* For proxy identification. */
34
{ /* The business address validation was removed from this routine, because PayPal® always fills that with the primary
35
email address. In cases where an alternate PayPal® address is being paid, validation is not possible. */
36
$paypal["s2member_log"][] = "s2Member originating domain ( _SERVER[HTTP_HOST] ) validated.";
37
+ /*
38
+ Single-Page Access.
39
+ */
40
+ if (preg_match ("/^web_accept#x2F;i", $paypal["txn_type"]) && $paypal["txn_id"] && preg_match ("/^sp\:[0-9]+#x2F;", $paypal["item_number"]))
41
+ {
42
+ $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept) for Single-Page access.";
43
+ /**/
44
+ list (, $paypal["page"]) = preg_split ("/\:/", $paypal["item_number"], 2);
45
+ /**/
46
+ if (($sp_access_url = ws_plugin__s2member_sp_access_link_gen ($paypal["page"], false)))
47
+ {
48
+ header ("Location: " . $sp_access_url);
49
+ }
50
+ else /* Otherwise, the page ID must have been invalid. Or it's possible that the Page was deleted. */
51
+ {
52
+ $paypal["s2member_log"][] = "Unable to generate Single-Page Access Link.";
53
+ /**/
54
+ echo '<script type="text/javascript">' . "\n";
55
+ echo "alert('ERROR: Unable to generate Access Link. Please contact Support for assistance.');" . "\n";
56
+ echo "window.location = '" . esc_js (get_bloginfo ("url")) . "';";
57
+ echo '</script>' . "\n";
58
+ /**/
59
+ $paypal["s2member_log"][] = "Redirecting Customer to the Home Page, due to an error that occurred.";
60
+ }
61
+ }
62
+ /*
63
+ New subscriptions. Possibly containing advanced updated vars ( option_name1, option_selection1 ); which allow account modifications.
64
+ */
65
+ else if (preg_match ("/^(web_accept|subscr_signup|subscr_payment)#x2F;i", $paypal["txn_type"]) && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["txn_id"])) && preg_match ("/^[1-4](\:|$)/", $paypal["item_number"]))
66
{ /* With Auto-Return/PDT, PayPal will send subscr_payment instead of subscr_signup to the return URL.
67
So we need to look for (web_accept|subscr_signup|subscr_payment), and treat them as the same. */
68
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup|subscr_payment).";
69
/**/
70
+ list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
71
+ /*
72
+ New subscription with advanced update vars ( option_name1, option_selection1 ).
73
+ */
74
if (preg_match ("/(updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) /* Advanced subscription update modifications. */
75
/* This advanced method is required whenever a subscription that is already completed, or was never setup to recur in the first place needs to be modified. PayPal® will not allow the
76
modify=2 parameter to be used in those scenarios, because technically there is nothing to update. The only thing to be updated is the existing account. */
84
if ($user_id = $q->user_id) /* Got it! */
85
{
86
$user = new WP_User ($user_id);
87
+ $user->set_role ("s2member_level" . $paypal["level"]);
88
update_usermeta ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
89
update_usermeta ($user_id, "s2member_custom", $paypal["custom"]);
90
+ /**/
91
+ foreach ($user->allcaps as $cap => $cap_enabled)
92
+ if (preg_match ("/^access_s2member_ccap_/", $cap))
93
+ $user->remove_cap ($ccap = $cap);
94
+ /**/
95
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $paypal["ccaps"]) as $ccap)
96
+ if (strlen ($ccap)) /* Don't add empty capabilities. */
97
+ $user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
98
+ /**/
99
delete_usermeta ($user_id, "s2member_file_download_access_arc");
100
delete_usermeta ($user_id, "s2member_file_download_access_log");
101
/**/
102
+ $paypal["s2member_log"][] = "s2Member Level/Capabilities updated w/ advanced update routines.";
103
/**/
104
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
105
echo '<html xmlns="http://www.w3.org/1999/xhtml" ', language_attributes (), '>' . "\n";
106
echo '<head profile="http://gmpg.org/xfn/11">' . "\n";
107
echo '<meta http-equiv="Content-Type" content="' . get_bloginfo ("html_type") . '; charset=' . get_bloginfo ("charset") . '" />' . "\n";
108
+ echo '<script type="text/javascript">' . "\n"; /* Onload allows any tracking codes to finish loading. */
109
echo "window.onload = function(){ " . "\n"; /* After everything has finished loading, we alert and then redirect. */
110
echo "alert('Thank You! Your membership has been updated to:\\n\\n" . esc_js ($paypal["item_name"]) . "\\n\\nYou\\'ll need to log back in now.');" . "\n";
111
echo "window.location = '" . wp_login_url () . "'; };" . "\n";
114
/**/
115
echo '<body style="background:#' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_color"] . ' url(' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image"] . ');">' . "\n";
116
/**/
117
+ echo '<!-- Tracking codes from the s2Member plugin for WordPress. -->' . "\n";
118
/**/
119
+ if (($code = trim ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_tracking_codes"])) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
120
{
121
if (preg_match ("/^subscr_signup#x2F;i", $paypal["txn_type"]))
122
+ $initial = (isset ($paypal["mc_amount1"]) && preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
123
/* The initial amount will only be $0 if a trial was offered. If no trial was offered, they were charged a regular rate. */
124
else if (preg_match ("/^(web_accept|subscr_payment)#x2F;i", $paypal["txn_type"])) /* PDT w/Auto-Return sends subscr_payment. */
125
+ $initial = $paypal["mc_gross"]; /* Here, the initial payment is provided clearly as the payment gross. */
126
/**/
127
+ if (($code = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace ("/%%subscr_id%%/i", $paypal["subscr_id"], $code)))
128
+ if (($code = preg_replace ("/%%initial%%/i", $initial, $code))) /* Adv calculations here. We have to support both sets of variables, subscr_signup & subscr_payment. */
129
+ if (($code = preg_replace ("/%%item_number%%/i", $paypal["item_number"], $code)) && ($code = preg_replace ("/%%item_name%%/i", $paypal["item_name"], $code)))
130
+ if (($code = preg_replace ("/%%first_name%%/i", $paypal["first_name"], $code)) && ($code = preg_replace ("/%%last_name%%/i", $paypal["last_name"], $code)))
131
+ if (($code = preg_replace ("/%%full_name%%/i", trim ($paypal["first_name"] . " " . $paypal["last_name"]), $code)))
132
+ if (($code = preg_replace ("/%%payer_email%%/i", $paypal["payer_email"], $code)))
133
+ /**/
134
+ if (($code = trim ($code))) /* Make sure it is not empty. */
135
+ /**/
136
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["is_wpmu"])
137
+ {
138
+ echo $code . "\n"; /* No PHP allowed here. */
139
+ $paypal["s2member_log"][] = "Signup Tracking codes have been processed.";
140
+ }
141
+ else /* Otherwise, it's safe to allow PHP code. */
142
+ {
143
+ eval ("?>" . $code);
144
+ $paypal["s2member_log"][] = "Signup Tracking codes have been evaluated.";
145
+ }
146
}
147
/**/
148
+ echo '<!-- Tracking codes from the s2Member plugin for WordPress. -->' . "\n";
149
+ /**/
150
+ $paypal["s2member_log"][] = "Success! Redirecting Customer to the Login Page. They need to log back in after this modification.";
151
/**/
152
echo '</body>' . "\n";
153
echo '</html>';
154
}
155
else
156
{
157
+ $paypal["s2member_log"][] = "Unable to modify subscription. Could not get the existing user_id from the DB. Please check the on0 and os0 variables in your Button Code.";
158
/**/
159
echo '<script type="text/javascript">' . "\n";
160
+ echo "alert('ERROR: Unable to modify subscription. Please contact Support for assistance.\\n\\nCould not get the existing user_id from the DB.');" . "\n";
161
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
162
echo '</script>' . "\n";
163
/**/
164
+ $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
165
}
166
}
167
else
168
{
169
+ $paypal["s2member_log"][] = "Unable to modify subscription. Could not find existing subscription in the DB. Please check the on0 and os0 variables in your Button Code.";
170
/**/
171
echo '<script type="text/javascript">' . "\n";
172
+ echo "alert('ERROR: Unable to modify subscription. Please contact Support for assistance.\\n\\nCould not find existing subscription in the DB.');" . "\n";
173
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
174
echo '</script>' . "\n";
175
/**/
176
+ $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
177
}
178
}
179
+ /*
180
+ New subscription. Normal subscription signup, we are not updating anything for a past subscription.
181
+ */
182
else /* Else this is a normal subscription signup, we are not updating anything for a past subscription. */
183
{
184
$paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup|subscr_payment) w/o update vars.";
193
echo '<html xmlns="http://www.w3.org/1999/xhtml" ', language_attributes (), '>' . "\n";
194
echo '<head profile="http://gmpg.org/xfn/11">' . "\n";
195
echo '<meta http-equiv="Content-Type" content="' . get_bloginfo ("html_type") . '; charset=' . get_bloginfo ("charset") . '" />' . "\n";
196
+ echo '<script type="text/javascript">' . "\n"; /* Onload allows any tracking codes to finish loading. */
197
echo "window.onload = function(){ " . "\n"; /* After everything has finished loading, we alert and then redirect. */
198
+ echo "alert('Thank You! Your account has been approved.\\nThe next step is to Register a Username.\\n\\nPlease click OK to Register now.');" . "\n";/**/
199
echo "window.location = '" . esc_js (add_query_arg ("action", "register", wp_login_url ())) . "'; };" . "\n";
200
echo '</script>' . "\n";
201
echo '</head>' . "\n";
202
/**/
203
echo '<body style="background:#' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_color"] . ' url(' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image"] . ');">' . "\n";
204
/**/
205
+ echo '<!-- Tracking codes from the s2Member plugin for WordPress. -->' . "\n";
206
/**/
207
+ if (($code = trim ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_tracking_codes"])) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
208
{
209
if (preg_match ("/^subscr_signup#x2F;i", $paypal["txn_type"]))
210
+ $initial = (isset ($paypal["mc_amount1"]) && preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
211
/* The initial amount will only be $0 if a trial was offered. If no trial was offered, they were charged a regular rate. */
212
else if (preg_match ("/^(web_accept|subscr_payment)#x2F;i", $paypal["txn_type"])) /* PDT w/Auto-Return sends subscr_payment. */
213
+ $initial = $paypal["mc_gross"]; /* Here, the initial payment is provided clearly as the payment gross. */
214
/**/
215
+ if (($code = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace ("/%%subscr_id%%/i", $paypal["subscr_id"], $code)))
216
+ if (($code = preg_replace ("/%%initial%%/i", $initial, $code))) /* Adv calculations here. We have to support both sets of variables, subscr_signup & subscr_payment. */
217
+ if (($code = preg_replace ("/%%item_number%%/i", $paypal["item_number"], $code)) && ($code = preg_replace ("/%%item_name%%/i", $paypal["item_name"], $code)))
218
+ if (($code = preg_replace ("/%%first_name%%/i", $paypal["first_name"], $code)) && ($code = preg_replace ("/%%last_name%%/i", $paypal["last_name"], $code)))
219
+ if (($code = preg_replace ("/%%full_name%%/i", trim ($paypal["first_name"] . " " . $paypal["last_name"]), $code)))
220
+ if (($code = preg_replace ("/%%payer_email%%/i", $paypal["payer_email"], $code)))
221
+ /**/
222
+ if (($code = trim ($code))) /* Make sure it is not empty. */
223
+ /**/
224
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["is_wpmu"])
225
+ {
226
+ echo $code . "\n"; /* No PHP allowed here. */
227
+ $paypal["s2member_log"][] = "Signup Tracking codes have been processed.";
228
+ }
229
+ else /* Otherwise, it's safe to allow PHP code. */
230
+ {
231
+ eval ("?>" . $code);
232
+ $paypal["s2member_log"][] = "Signup Tracking codes have been evaluated.";
233
+ }
234
}
235
/**/
236
+ echo '<!-- Tracking codes from the s2Member plugin for WordPress. -->' . "\n";
237
+ /**/
238
+ $paypal["s2member_log"][] = "Success! Redirecting Customer to Registration Page. They need to register a Username now.";
239
/**/
240
echo '</body>' . "\n";
241
echo '</html>';
242
}
243
}
244
+ /*
245
+ Subscription modifications.
246
+ */
247
+ else if (preg_match ("/^subscr_modify#x2F;i", $paypal["txn_type"]) && $paypal["subscr_id"] && preg_match ("/^[1-4](\:|$)/", $paypal["item_number"]))
248
{
249
$paypal["s2member_log"][] = "s2Member txn_type identified as subscr_modify.";
250
/**/
251
+ list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
252
+ /**/
253
if ($q = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = 's2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($paypal["subscr_id"]) . "' LIMIT 1"))
254
{
255
if ($user_id = $q->user_id) /* Got it! */
256
{
257
$user = new WP_User ($user_id);
258
+ $user->set_role ("s2member_level" . $paypal["level"]);
259
+ update_usermeta ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
260
update_usermeta ($user_id, "s2member_custom", $paypal["custom"]);
261
/**/
262
+ foreach ($user->allcaps as $cap => $cap_enabled)
263
+ if (preg_match ("/^access_s2member_ccap_/", $cap))
264
+ $user->remove_cap ($ccap = $cap);
265
+ /**/
266
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $paypal["ccaps"]) as $ccap)
267
+ if (strlen ($ccap)) /* Don't add empty capabilities. */
268
+ $user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
269
+ /**/
270
+ delete_usermeta ($user_id, "s2member_file_download_access_arc");
271
+ delete_usermeta ($user_id, "s2member_file_download_access_log");
272
+ /**/
273
+ $paypal["s2member_log"][] = "s2Member Level/Capabilities updated on subscription modification.";
274
/**/
275
echo '<script type="text/javascript">' . "\n";
276
echo "alert('Thank You! Your membership has been updated to:\\n\\n" . esc_js ($paypal["item_name"]) . "\\n\\nYou\\'ll need to log back in now.');" . "\n";
277
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
278
echo '</script>' . "\n";
279
/**/
280
+ $paypal["s2member_log"][] = "Success! Redirecting Customer to the Login Page. They need to log back in after this modification.";
281
}
282
else
283
{
284
+ $paypal["s2member_log"][] = "Unable to modify subscription. Could not get the existing user_id from the DB.";
285
/**/
286
echo '<script type="text/javascript">' . "\n";
287
+ echo "alert('ERROR: Unable to modify subscription. Please contact Support for assistance.\\n\\nCould not get the existing user_id from the DB.');" . "\n";
288
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
289
echo '</script>' . "\n";
290
/**/
291
+ $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
292
}
293
}
294
else
295
{
296
+ $paypal["s2member_log"][] = "Unable to modify subscription. Could not find existing subscription in the DB.";
297
/**/
298
echo '<script type="text/javascript">' . "\n";
299
+ echo "alert('ERROR: Unable to modify subscription. Please contact Support for assistance.\\n\\nCould not find existing subscription in the DB.');" . "\n";
300
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
301
echo '</script>' . "\n";
302
/**/
303
+ $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
304
}
305
}
306
else
307
{
308
+ $paypal["s2member_log"][] = "Unexpected txn_type. The PayPal® txn_type did not match a required action.";
309
/**/
310
echo '<script type="text/javascript">' . "\n";
311
+ echo "alert('ERROR: Unexpected txn_type. Please contact Support for assistance.\\n\\nThe PayPal® txn_type did not match a required action.');" . "\n";
312
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
313
echo '</script>' . "\n";
314
/**/
315
+ $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
316
}
317
}
318
else
319
{
320
+ $paypal["s2member_log"][] = "Unable to verify _SERVER[HTTP_HOST]. Please check the `custom` value in your Button Code. It MUST start with your domain name.";
321
/**/
322
echo '<script type="text/javascript">' . "\n";
323
+ echo "alert('ERROR: Unable to verify _SERVER[HTTP_HOST]. Please contact Support for assistance.\\n\\nIf you are the site owner, please check the `custom` value in your Button Code. It MUST start with your domain name.');" . "\n";
324
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
325
echo '</script>' . "\n";
326
/**/
327
+ $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
328
}
329
}
330
else
331
{
332
+ $paypal["s2member_log"][] = "Unable to verify POST vars. This is most likely related to an invalid PayPal® configuration. Please check: s2Member -> PayPal® Options -> PDT/Auto-Return.";
333
/**/
334
echo '<script type="text/javascript">' . "\n";
335
+ echo "alert('ERROR: Unable to verify POST vars. Please contact Support for assistance.\\n\\nThis is most likely related to an invalid PayPal® configuration. If you are the site owner, please check: s2Member -> PayPal® Options -> PDT/Auto-Return.');" . "\n";
336
echo "window.location = '" . esc_js (wp_login_url ()) . "';";
337
echo '</script>' . "\n";
338
/**/
339
+ $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
340
}
341
/**/
342
if ($_GET["s2member_paypal_proxy"]) /* For proxy identification. */
includes/functions/register-access.inc.php CHANGED
@@ -33,7 +33,7 @@ function ws_plugin__s2member_check_register_access ($users_can_register = FALSE)
33
{
34
return ($users_can_register = "1");
35
}
36
- else if ($pagenow !== "options-general.php" && $_COOKIE["s2member_subscr_id"] && $_COOKIE["s2member_custom"] && preg_match ("/^[1-4]#x2F;", $_COOKIE["s2member_level"]))
37
{
38
global $wpdb; /* Global database object reference. */
39
/**/
@@ -117,28 +117,134 @@ function ws_plugin__s2member_custom_registration_fields ()
117
return;
118
}
119
/*
120
Function for configuring new users.
121
Attach to: add_action("user_register");
122
Attach to: add_action("bp_core_signup_user");
123
*/
124
function ws_plugin__s2member_configure_user_registration ($user_id = FALSE)
125
{
126
static $processed; /* Prevents duplicate processing when attached to multiple hooks in support of plugins like BuddyPress. */
127
/**/
128
if (!$processed && $user_id && is_array ($_POST = stripslashes_deep ($_POST)) && is_object ($user = new WP_User ($user_id)) && ($processed = true))
129
{
130
ws_plugin__s2member_email_config (); /* Configures From: header that will be used in new user notifications. */
131
/**/
132
- if ($_COOKIE["s2member_subscr_id"] && $_COOKIE["s2member_custom"] && preg_match ("/^[1-4]#x2F;", $_COOKIE["s2member_level"]))
133
{
134
- global $wpdb; /* Global database object required for this routine. We need to check the uniqueness of their s2member_subscr_id. */
135
/**/
136
if (!$usermeta = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = 's2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($_COOKIE["s2member_subscr_id"]) . "' LIMIT 1"))
137
{
138
- $user->set_role ("s2member_level" . $_COOKIE["s2member_level"]);
139
/**/
140
update_usermeta ($user_id, "s2member_subscr_id", $_COOKIE["s2member_subscr_id"]);
141
update_usermeta ($user_id, "s2member_custom", $_COOKIE["s2member_custom"]);
142
}
143
/**/
144
setcookie ("s2member_subscr_id", "", time () + 31556926, "/");
@@ -146,13 +252,100 @@ function ws_plugin__s2member_configure_user_registration ($user_id = FALSE)
146
setcookie ("s2member_level", "", time () + 31556926, "/");
147
}
148
/**/
149
- if (!defined ("BP_VERSION")) /* Custom fields are not compatible when running together with BuddyPress. */
150
{
151
- if ($first_name = trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]))
152
update_usermeta ($user_id, "first_name", $first_name) . /* And display name. */
153
wp_update_user (array ("ID" => $user_id, "display_name" => $first_name));
154
/**/
155
- if ($last_name = trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]))
156
update_usermeta ($user_id, "last_name", $last_name);
157
/**/
158
foreach (preg_split ("/[\r\n\t,;]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) as $field)
@@ -160,7 +353,8 @@ function ws_plugin__s2member_configure_user_registration ($user_id = FALSE)
160
if ($field = trim ($field, "* \t\n\r\0\x0B")) /* Don't process empty fields. */
161
{
162
$field = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field));
163
- $fields[$field] = trim ($_POST["ws_plugin__s2member_custom_reg_field_" . $field]);
164
}
165
}
166
/**/
33
{
34
return ($users_can_register = "1");
35
}
36
+ else if ($pagenow !== "options-general.php" && $_COOKIE["s2member_subscr_id"] && $_COOKIE["s2member_custom"] && preg_match ("/^[1-4](\:|$)/", $_COOKIE["s2member_level"]))
37
{
38
global $wpdb; /* Global database object reference. */
39
/**/
117
return;
118
}
119
/*
120
+ Generates registration links.
121
+ */
122
+ function ws_plugin__s2member_register_link_gen ($subscr_id = FALSE, $custom = FALSE, $item_number = FALSE, $shrink = TRUE)
123
+ {
124
+ if ($subscr_id && $custom && $item_number) /* Must have all of these. */
125
+ {
126
+ $register = ws_plugin__s2member_xencrypt ("subscr_id_custom_item_number:.:|:.:" . $subscr_id . ":.:|:.:" . $custom . ":.:|:.:" . $item_number);
127
+ $register_link = ws_plugin__s2member_append_query_var (get_bloginfo ("url") . "/", "s2member_register=" . urlencode ($register));
128
+ /**/
129
+ if ($shrink && ($tinyurl = @file_get_contents ("http://tinyurl.com/api-create.php?url=" . rawurlencode ($register_link))))
130
+ return $tinyurl; /* tinyURL is easier to work with, but fails if allow_url_fopen = no. */
131
+ else /* Else use the long one. */
132
+ return $register_link;
133
+ }
134
+ /**/
135
+ return false;
136
+ }
137
+ /*
138
+ Handles registration links.
139
+ Attach to: add_action("init");
140
+ $_GET["s2member_paypal_register"] deprecated in v2.8.6.
141
+ */
142
+ function ws_plugin__s2member_register ()
143
+ {
144
+ if ($_GET["s2member_register"] || ($_GET["s2member_register"] = $_GET["s2member_paypal_register"]))
145
+ {
146
+ if (is_array ($register = preg_split ("/\:\.\:\|\:\.\:/", ws_plugin__s2member_xdecrypt ($_GET["s2member_register"]))))
147
+ {
148
+ if (count ($register) === 4 && $register[0] === "subscr_id_custom_item_number" && $register[1] && $register[2] && $register[3])
149
+ {
150
+ setcookie ("s2member_subscr_id", $register[1], time () + 31556926, "/");
151
+ setcookie ("s2member_custom", $register[2], time () + 31556926, "/");
152
+ setcookie ("s2member_level", $register[3], time () + 31556926, "/");
153
+ /**/
154
+ echo '<script type="text/javascript">' . "\n";
155
+ echo "window.location = '" . esc_js (add_query_arg ("action", "register", wp_login_url ())) . "';";
156
+ echo '</script>' . "\n";
157
+ }
158
+ }
159
+ exit;
160
+ }
161
+ }
162
+ /*
163
Function for configuring new users.
164
Attach to: add_action("user_register");
165
Attach to: add_action("bp_core_signup_user");
166
*/
167
function ws_plugin__s2member_configure_user_registration ($user_id = FALSE)
168
{
169
+ global $wpdb; /* Global database object may be required for this routine. */
170
static $processed; /* Prevents duplicate processing when attached to multiple hooks in support of plugins like BuddyPress. */
171
/**/
172
if (!$processed && $user_id && is_array ($_POST = stripslashes_deep ($_POST)) && is_object ($user = new WP_User ($user_id)) && ($processed = true))
173
{
174
ws_plugin__s2member_email_config (); /* Configures From: header that will be used in new user notifications. */
175
/**/
176
+ if (!is_admin () /* Only run this particular routine whenever a Member is registering themselves. */
177
+ && $_COOKIE["s2member_subscr_id"] && $_COOKIE["s2member_custom"] && preg_match ("/^[1-4](\:|$)/", $_COOKIE["s2member_level"]))
178
{
179
+ list ($level, $ccaps) = preg_split ("/\:/", $_COOKIE["s2member_level"], 2); /* Supports colon separated level:custom_capability,custom_capability. */
180
/**/
181
if (!$usermeta = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = 's2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($_COOKIE["s2member_subscr_id"]) . "' LIMIT 1"))
182
{
183
+ $user->set_role ("s2member_level" . $level);
184
+ /**/
185
+ if ($ccaps) /* Add custom capabilities. */
186
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $ccaps) as $ccap)
187
+ if (strlen ($ccap)) /* Don't add empty capabilities. */
188
+ $user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
189
/**/
190
update_usermeta ($user_id, "s2member_subscr_id", $_COOKIE["s2member_subscr_id"]);
191
update_usermeta ($user_id, "s2member_custom", $_COOKIE["s2member_custom"]);
192
+ /**/
193
+ if (($mailchimp_api_key = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]) && ($mailchimp_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]))
194
+ {
195
+ if (!class_exists ("NC_MCAPI"))
196
+ include_once dirname (dirname (__FILE__)) . "/mailchimp/nc-mcapi.inc.php";
197
+ /**/
198
+ $MCAPI = new NC_MCAPI ($mailchimp_api_key); /* MailChimp® API class. */
199
+ /**/
200
+ $email = $user->user_email;
201
+ $login = $user->user_login;
202
+ $fname = ($user->first_name) ? $user->first_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]);
203
+ $lname = ($user->last_name) ? $user->last_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]);
204
+ /**/
205
+ foreach (preg_split ("/[\r\n\t,;]+/", $mailchimp_list_ids) as $mailchimp_list_id)
206
+ $MCAPI->listSubscribe ($mailchimp_list_id, $email, array ("FNAME" => $fname, "LNAME" => $lname, "OPTINIP" => $_SERVER["REMOTE_ADDR"]));
207
+ }
208
+ /**/
209
+ if ($aweber_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"])
210
+ {
211
+ $email = $user->user_email;
212
+ $login = $user->user_login;
213
+ $fname = ($user->first_name) ? $user->first_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]);
214
+ $lname = ($user->last_name) ? $user->last_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]);
215
+ /**/
216
+ foreach (preg_split ("/[\r\n\t,;]+/", $aweber_list_ids) as $aweber_list_id)
217
+ @mail ($aweber_list_id . "@aweber.com", "s2Member Subscription Request",/**/
218
+ "s2Member Subscription Request\ns2Member w/ PayPal Email ID\nBuyer: " . $fname . " " . $lname . "\n - end.",/**/
219
+ "From: \"" . preg_replace ("/\"/", "", $fname . " " . $lname) . "\" <" . $email . ">\r\nContent-Type: text/plain; charset=utf-8");
220
+ }
221
+ /**/
222
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_urls"])
223
+ {
224
+ $email = $user->user_email;
225
+ $login = $user->user_login;
226
+ $fname = ($user->first_name) ? $user->first_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]);
227
+ $lname = ($user->last_name) ? $user->last_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]);
228
+ /**/
229
+ if (function_exists ("ws_plugin__s2member_generate_password"))
230
+ if (!defined ("BP_VERSION") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
231
+ if (wp_verify_nonce (trim (stripslashes ($_POST["ws_plugin__s2member_registration"])), "ws-plugin--s2member-registration"))
232
+ if ($pass = trim (stripslashes ($_POST["ws_plugin__s2member_custom_reg_field_user_pass"])))
233
+ $pass = $pass;
234
+ /**/
235
+ if (is_array ($cv = preg_split ("/\|/", $_COOKIE["s2member_custom"])))
236
+ foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_urls"]) as $url)
237
+ if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)))
238
+ if (($url = preg_replace ("/%%level%%/i", urlencode ($level), $url)))
239
+ if (($url = preg_replace ("/%%user_first_name%%/i", urlencode ($fname), $url)))
240
+ if (($url = preg_replace ("/%%user_last_name%%/i", urlencode ($lname), $url)))
241
+ if (($url = preg_replace ("/%%user_full_name%%/i", urlencode (trim ($fname . " " . $lname)), $url)))
242
+ if (($url = preg_replace ("/%%user_email%%/i", urlencode ($email), $url)))
243
+ if (($url = preg_replace ("/%%user_login%%/i", urlencode ($login), $url)))
244
+ if (($url = preg_replace ("/%%user_pass%%/i", urlencode ($pass), $url)))
245
+ if (($url = trim ($url))) /* Make sure it is not empty now. */
246
+ ws_plugin__s2member_curlpsr ($url, "s2member=1");
247
+ }
248
}
249
/**/
250
setcookie ("s2member_subscr_id", "", time () + 31556926, "/");
252
setcookie ("s2member_level", "", time () + 31556926, "/");
253
}
254
/**/
255
+ else if (is_admin () && preg_match ("/wp-admin\/user-new\.php/", $_POST["_wp_http_referer"]) && preg_match ("/^(subscriber|s2member_level[1-4])#x2F;", $_POST["role"]))
256
+ {
257
+ if ($_POST["role"] === "subscriber" && ($mailchimp_api_key = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]) && ($mailchimp_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_mailchimp_list_ids"]))
258
+ {
259
+ if (!class_exists ("NC_MCAPI"))
260
+ include_once dirname (dirname (__FILE__)) . "/mailchimp/nc-mcapi.inc.php";
261
+ /**/
262
+ $MCAPI = new NC_MCAPI ($mailchimp_api_key); /* MailChimp® API class. */
263
+ /**/
264
+ $email = $user->user_email;
265
+ $login = $user->user_login;
266
+ $fname = ($user->first_name) ? $user->first_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]);
267
+ $lname = ($user->last_name) ? $user->last_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]);
268
+ /**/
269
+ foreach (preg_split ("/[\r\n\t,;]+/", $mailchimp_list_ids) as $mailchimp_list_id)
270
+ $MCAPI->listSubscribe ($mailchimp_list_id, $email, array ("FNAME" => $fname, "LNAME" => $lname, "OPTINIP" => ""));
271
+ }
272
+ /**/
273
+ else if (($level = preg_replace ("/[^1-4]/", "", $_POST["role"])) && ($mailchimp_api_key = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]) && ($mailchimp_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]))
274
+ {
275
+ if (!class_exists ("NC_MCAPI"))
276
+ include_once dirname (dirname (__FILE__)) . "/mailchimp/nc-mcapi.inc.php";
277
+ /**/
278
+ $MCAPI = new NC_MCAPI ($mailchimp_api_key); /* MailChimp® API class. */
279
+ /**/
280
+ $email = $user->user_email;
281
+ $login = $user->user_login;
282
+ $fname = ($user->first_name) ? $user->first_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]);
283
+ $lname = ($user->last_name) ? $user->last_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]);
284
+ /**/
285
+ foreach (preg_split ("/[\r\n\t,;]+/", $mailchimp_list_ids) as $mailchimp_list_id)
286
+ $MCAPI->listSubscribe ($mailchimp_list_id, $email, array ("FNAME" => $fname, "LNAME" => $lname, "OPTINIP" => ""));
287
+ }
288
+ /**/
289
+ if ($_POST["role"] === "subscriber" && ($aweber_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_aweber_list_ids"]))
290
+ {
291
+ $email = $user->user_email;
292
+ $login = $user->user_login;
293
+ $fname = ($user->first_name) ? $user->first_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]);
294
+ $lname = ($user->last_name) ? $user->last_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]);
295
+ /**/
296
+ foreach (preg_split ("/[\r\n\t,;]+/", $aweber_list_ids) as $aweber_list_id)
297
+ @mail ($aweber_list_id . "@aweber.com", "s2Member Subscription Request",/**/
298
+ "s2Member Subscription Request\ns2Member w/ PayPal Email ID\nBuyer: " . $fname . " " . $lname . "\n - end.",/**/
299
+ "From: \"" . preg_replace ("/\"/", "", $fname . " " . $lname) . "\" <" . $email . ">\r\nContent-Type: text/plain; charset=utf-8");
300
+ }
301
+ /**/
302
+ else if (($level = preg_replace ("/[^1-4]/", "", $_POST["role"])) && ($aweber_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]))
303
+ {
304
+ $email = $user->user_email;
305
+ $login = $user->user_login;
306
+ $fname = ($user->first_name) ? $user->first_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]);
307
+ $lname = ($user->last_name) ? $user->last_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]);
308
+ /**/
309
+ foreach (preg_split ("/[\r\n\t,;]+/", $aweber_list_ids) as $aweber_list_id)
310
+ @mail ($aweber_list_id . "@aweber.com", "s2Member Subscription Request",/**/
311
+ "s2Member Subscription Request\ns2Member w/ PayPal Email ID\nBuyer: " . $fname . " " . $lname . "\n - end.",/**/
312
+ "From: \"" . preg_replace ("/\"/", "", $fname . " " . $lname) . "\" <" . $email . ">\r\nContent-Type: text/plain; charset=utf-8");
313
+ }
314
+ /**/
315
+ if (($_POST["role"] === "subscriber" || ($level = preg_replace ("/[^1-4]/", "", $_POST["role"])))/**/
316
+ && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_urls"])
317
+ {
318
+ $email = $user->user_email;
319
+ $login = $user->user_login;
320
+ $level = ($_POST["role"] === "subscriber") ? "0" : $level;
321
+ $fname = ($user->first_name) ? $user->first_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]);
322
+ $lname = ($user->last_name) ? $user->last_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]);
323
+ /**/
324
+ if ($pass = trim (stripslashes ($_POST["pass1"])))
325
+ $pass = $pass; /* From the `Users -> Add New` form.
326
+ /**/
327
+ if (is_array ($cv = preg_split ("/\|/", $_COOKIE["s2member_custom"])))
328
+ foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_urls"]) as $url)
329
+ if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)))
330
+ if (($url = preg_replace ("/%%level%%/i", urlencode ($level), $url)))
331
+ if (($url = preg_replace ("/%%user_first_name%%/i", urlencode ($fname), $url)))
332
+ if (($url = preg_replace ("/%%user_last_name%%/i", urlencode ($lname), $url)))
333
+ if (($url = preg_replace ("/%%user_full_name%%/i", urlencode (trim ($fname . " " . $lname)), $url)))
334
+ if (($url = preg_replace ("/%%user_email%%/i", urlencode ($email), $url)))
335
+ if (($url = preg_replace ("/%%user_login%%/i", urlencode ($login), $url)))
336
+ if (($url = preg_replace ("/%%user_pass%%/i", urlencode ($pass), $url)))
337
+ if (($url = trim ($url))) /* Make sure it is not empty now. */
338
+ ws_plugin__s2member_curlpsr ($url, "s2member=1");
339
+ }
340
+ }
341
+ /**/
342
+ if (!is_admin () && !defined ("BP_VERSION")) /* This processes Custom Fields. */
343
{
344
+ if (!$user->first_name && ($first_name = trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"])))
345
update_usermeta ($user_id, "first_name", $first_name) . /* And display name. */
346
wp_update_user (array ("ID" => $user_id, "display_name" => $first_name));
347
/**/
348
+ if (!$user->last_name && ($last_name = trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"])))
349
update_usermeta ($user_id, "last_name", $last_name);
350
/**/
351
foreach (preg_split ("/[\r\n\t,;]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) as $field)
353
if ($field = trim ($field, "* \t\n\r\0\x0B")) /* Don't process empty fields. */
354
{
355
$field = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field));
356
+ if (strlen ($_POST["ws_plugin__s2member_custom_reg_field_" . $field]))
357
+ $fields[$field] = trim ($_POST["ws_plugin__s2member_custom_reg_field_" . $field]);
358
}
359
}
360
/**/
includes/functions/shortcodes.inc.php CHANGED
@@ -15,44 +15,85 @@ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
exit;
16
/*
17
Function that handles the Shortcode for [s2Member-PayPal-Button /].
18
- [s2Member-PayPal-Button level="1" ps="paypal" cc="USD" on0="" os0="" modify="0" custom="www.domain.com" tp="0" tt="D" ra="0.01" rp="1" rt="M" rr="1" /]
19
Attach to: add_shortcode("s2Member-PayPal-Button");
20
*/
21
function ws_plugin__s2member_paypal_button ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
22
{
23
- $sc = shortcode_atts (array ("level" => "1", "ps" => "paypal", "cc" => "USD", "on0" => "", "os0" => "", "modify" => "0", "custom" => $_SERVER["HTTP_HOST"], "tp" => "0", "tt" => "D", "ra" => "0.01", "rp" => "1", "rt" => "M", "rr" => "1"), $attr);
24
- /**/
25
- $code = trim (file_get_contents (dirname (dirname (__FILE__)) . "/menu-pages/button.html"));
26
- $code = preg_replace ("/%%endpoint%%/", (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com"), $code);
27
- $code = preg_replace ("/%%paypal_business%%/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"], $code);
28
- $code = preg_replace ("/%%level_label%%/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $sc["level"] . "_label"], $code);
29
- $code = preg_replace ("/%%cancel_return%%/", get_bloginfo ("url"), $code);
30
- $code = preg_replace ("/%%notify_url%%/", get_bloginfo ("url") . "/?s2member_paypal_notify=1", $code);
31
- $code = preg_replace ("/%%return%%/", get_bloginfo ("url") . "/?s2member_paypal_return=1", $code);
32
- $code = preg_replace ("/%%domain%%/", strtolower ($_SERVER["HTTP_HOST"]), $code);
33
- $code = preg_replace ("/%%level%%/", $sc["level"], $code);
34
/**/
35
- $code = preg_replace ('/ \<\!--(\<input type\="hidden" name\="(amount|modify|src|sra|a1|p1|t1|a3|p3|t3)" value\="(.*?)" \/\>)--\>/', " $1", $code);
36
- $code = ($sc["on0"] || $sc["os0"]) ? preg_replace ('/ \<\!--(\<input type\="hidden" name\="(on0|os0)" value\="(.*?)" \/\>)--\>/', " $1", $code) : $code;
37
- $code = ($sc["tp"] <= 0) ? preg_replace ('/ (\<input type\="hidden" name\="(a1|p1|t1)" value\="(.*?)" \/\>)/', " <!--$1-->", $code) : $code;
38
- $code = ($sc["rt"] === "L") ? preg_replace ('/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/', " $1_xclick$3", $code) : $code;
39
- $code = ($sc["rt"] === "L") ? preg_replace ('/ (\<input type\="hidden" name\="(modify|src|sra|a1|p1|t1|a3|p3|t3)" value\="(.*?)" \/\>)/', " <!--$1-->", $code) : $code;
40
- $code = ($sc["rt"] !== "L") ? preg_replace ('/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/', " $1_xclick-subscriptions$3", $code) : $code;
41
- $code = ($sc["rt"] !== "L") ? preg_replace ('/ (\<input type\="hidden" name\="amount" value\="(.*?)" \/\>)/', " <!--$1-->", $code) : $code;
42
/**/
43
- $code = preg_replace ('/ name\="page_style" value\="(.*?)"/', ' name="page_style" value="' . $sc["ps"] . '"', $code);
44
- $code = preg_replace ('/ name\="currency_code" value\="(.*?)"/', ' name="currency_code" value="' . $sc["cc"] . '"', $code);
45
- $code = preg_replace ('/ name\="on0" value\="(.*?)"/', ' name="on0" value="' . $sc["on0"] . '"', $code);
46
- $code = preg_replace ('/ name\="os0" value\="(.*?)"/', ' name="os0" value="' . $sc["os0"] . '"', $code);
47
- $code = preg_replace ('/ name\="modify" value\="(.*?)"/', ' name="modify" value="' . $sc["modify"] . '"', $code);
48
- $code = preg_replace ('/ name\="custom" value\="(.*?)"/', ' name="custom" value="' . $sc["custom"] . '"', $code);
49
- $code = preg_replace ('/ name\="amount" value\="(.*?)"/', ' name="amount" value="' . $sc["ra"] . '"', $code);
50
- $code = preg_replace ('/ name\="src" value\="(.*?)"/', ' name="src" value="' . $sc["rr"] . '"', $code);
51
- $code = preg_replace ('/ name\="p1" value\="(.*?)"/', ' name="p1" value="' . $sc["tp"] . '"', $code);
52
- $code = preg_replace ('/ name\="t1" value\="(.*?)"/', ' name="t1" value="' . $sc["tt"] . '"', $code);
53
- $code = preg_replace ('/ name\="a3" value\="(.*?)"/', ' name="a3" value="' . $sc["ra"] . '"', $code);
54
- $code = preg_replace ('/ name\="p3" value\="(.*?)"/', ' name="p3" value="' . $sc["rp"] . '"', $code);
55
- $code = preg_replace ('/ name\="t3" value\="(.*?)"/', ' name="t3" value="' . $sc["rt"] . '"', $code);
56
/**/
57
return $code; /* The finished PayPal® Button. */
58
}
15
exit;
16
/*
17
Function that handles the Shortcode for [s2Member-PayPal-Button /].
18
+
19
+ [s2Member-PayPal-Button level="1" ccaps="" desc="" ps="paypal" cc="USD" custom="www.domain.com" tp="0" tt="D" ra="0.01" rp="1" rt="M" rr="1" /]
20
+ [s2Member-PayPal-Button page="0" desc="Single-Page Access" ps="paypal" cc="USD" custom="www.domain.com" ra="0.01" sp="1" /]
21
+
22
+ The desc attribute is only required for Single-Page buttons, optional for others.
23
+ The page attribute is only used for Single-Page buttons.
24
+
25
+ PayPal® Modification Buttons are identified by mb="1".
26
+ PayPal® Cancellation Buttons are identified by cb="1".
27
+ PayPal® Single-Page Buttons are identified by sp="1".
28
+
29
Attach to: add_shortcode("s2Member-PayPal-Button");
30
*/
31
function ws_plugin__s2member_paypal_button ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
32
{
33
+ $sc = shortcode_atts (array ("page" => "0", "level" => "1", "ccaps" => "", "desc" => "", "ps" => "paypal", "cc" => "USD", "custom" => $_SERVER["HTTP_HOST"], "tp" => "0", "tt" => "D", "ra" => "0.01", "rp" => "1", "rt" => "M", "rr" => "1", "mb" => "0", "cb" => "0", "sp" => "0"), $attr);
34
/**/
35
+ if ($sc["cb"]) /* This is a special routine for Cancellation Buttons. Cancellation Buttons use a different template. */
36
+ {
37
+ $code = trim (file_get_contents (dirname (dirname (__FILE__)) . "/menu-pages/c-button.html"));
38
+ $code = preg_replace ("/%%endpoint%%/", (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com"), $code);
39
+ $code = preg_replace ("/%%paypal_business%%/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"], $code);
40
+ }
41
/**/
42
+ else if ($sc["sp"]) /* This is a special routine for Single-Page Buttons. Single-Page Buttons use a different template. */
43
+ {
44
+ $code = trim (file_get_contents (dirname (dirname (__FILE__)) . "/menu-pages/sp-button.html"));
45
+ $code = preg_replace ("/%%endpoint%%/", (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com"), $code);
46
+ $code = preg_replace ("/%%paypal_business%%/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"], $code);
47
+ $code = preg_replace ("/%%cancel_return%%/", get_bloginfo ("url"), $code);
48
+ $code = preg_replace ("/%%notify_url%%/", get_bloginfo ("url") . "/?s2member_paypal_notify=1", $code);
49
+ $code = preg_replace ("/%%return%%/", get_bloginfo ("url") . "/?s2member_paypal_return=1", $code);
50
+ $code = preg_replace ("/%%domain%%/", strtolower ($_SERVER["HTTP_HOST"]), $code);
51
+ /**/
52
+ $code = preg_replace ('/ name\="item_name" value\="(.*?)"/', ' name="item_name" value="' . $sc["desc"] . '"', $code);
53
+ $code = preg_replace ('/ name\="item_number" value\="(.*?)"/', ' name="item_number" value="sp:' . $sc["page"] . '"', $code);
54
+ $code = preg_replace ('/ name\="page_style" value\="(.*?)"/', ' name="page_style" value="' . $sc["ps"] . '"', $code);
55
+ $code = preg_replace ('/ name\="currency_code" value\="(.*?)"/', ' name="currency_code" value="' . $sc["cc"] . '"', $code);
56
+ $code = preg_replace ('/ name\="custom" value\="(.*?)"/', ' name="custom" value="' . $sc["custom"] . '"', $code);
57
+ $code = preg_replace ('/ name\="amount" value\="(.*?)"/', ' name="amount" value="' . $sc["ra"] . '"', $code);
58
+ }
59
+ else /* Otherwise, we'll process this Button normally, using the Membership routines. Also handles Modification Buttons. */
60
+ {
61
+ $sc["desc"] = (!$sc["desc"]) ? $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $sc["level"] . "_label"] : $sc["desc"];
62
+ $sc["level_ccaps"] = ($sc["ccaps"]) ? $sc["level"] . ":" . $sc["ccaps"] : $sc["level"];
63
+ /**/
64
+ $code = trim (file_get_contents (dirname (dirname (__FILE__)) . "/menu-pages/button.html"));
65
+ $code = preg_replace ("/%%endpoint%%/", (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com"), $code);
66
+ $code = preg_replace ("/%%paypal_business%%/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"], $code);
67
+ $code = preg_replace ("/%%level_label%%/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $sc["level"] . "_label"], $code);
68
+ $code = preg_replace ("/%%cancel_return%%/", get_bloginfo ("url"), $code);
69
+ $code = preg_replace ("/%%notify_url%%/", get_bloginfo ("url") . "/?s2member_paypal_notify=1", $code);
70
+ $code = preg_replace ("/%%return%%/", get_bloginfo ("url") . "/?s2member_paypal_return=1", $code);
71
+ $code = preg_replace ("/%%domain%%/", strtolower ($_SERVER["HTTP_HOST"]), $code);
72
+ $code = preg_replace ("/%%level%%/", $sc["level"], $code);
73
+ /**/
74
+ $code = preg_replace ('/ \<\!--(\<input type\="hidden" name\="(amount|src|sra|a1|p1|t1|a3|p3|t3)" value\="(.*?)" \/\>)--\>/', " $1", $code);
75
+ $code = ($sc["tp"] <= 0) ? preg_replace ('/ (\<input type\="hidden" name\="(a1|p1|t1)" value\="(.*?)" \/\>)/', " <!--$1-->", $code) : $code;
76
+ $code = ($sc["rt"] === "L") ? preg_replace ('/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/', " $1_xclick$3", $code) : $code;
77
+ $code = ($sc["rt"] === "L") ? preg_replace ('/ (\<input type\="hidden" name\="(src|sra|a1|p1|t1|a3|p3|t3)" value\="(.*?)" \/\>)/', " <!--$1-->", $code) : $code;
78
+ $code = ($sc["rt"] !== "L") ? preg_replace ('/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/', " $1_xclick-subscriptions$3", $code) : $code;
79
+ $code = ($sc["rt"] !== "L") ? preg_replace ('/ (\<input type\="hidden" name\="amount" value\="(.*?)" \/\>)/', " <!--$1-->", $code) : $code;
80
+ /**/
81
+ $code = preg_replace ('/ name\="item_name" value\="(.*?)"/', ' name="item_name" value="' . $sc["desc"] . '"', $code);
82
+ $code = preg_replace ('/ name\="item_number" value\="(.*?)"/', ' name="item_number" value="' . $sc["level_ccaps"] . '"', $code);
83
+ $code = preg_replace ('/ name\="page_style" value\="(.*?)"/', ' name="page_style" value="' . $sc["ps"] . '"', $code);
84
+ $code = preg_replace ('/ name\="currency_code" value\="(.*?)"/', ' name="currency_code" value="' . $sc["cc"] . '"', $code);
85
+ $code = preg_replace ('/ name\="custom" value\="(.*?)"/', ' name="custom" value="' . $sc["custom"] . '"', $code);
86
+ $code = preg_replace ('/ name\="on0" value\="(.*?)"/', ' name="on0" value="' . S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0 . '"', $code);
87
+ $code = preg_replace ('/ name\="os0" value\="(.*?)"/', ' name="os0" value="' . S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0 . '"', $code);
88
+ $code = preg_replace ('/ name\="modify" value\="(.*?)"/', ' name="modify" value="1"', $code);
89
+ $code = preg_replace ('/ name\="amount" value\="(.*?)"/', ' name="amount" value="' . $sc["ra"] . '"', $code);
90
+ $code = preg_replace ('/ name\="src" value\="(.*?)"/', ' name="src" value="' . $sc["rr"] . '"', $code);
91
+ $code = preg_replace ('/ name\="p1" value\="(.*?)"/', ' name="p1" value="' . $sc["tp"] . '"', $code);
92
+ $code = preg_replace ('/ name\="t1" value\="(.*?)"/', ' name="t1" value="' . $sc["tt"] . '"', $code);
93
+ $code = preg_replace ('/ name\="a3" value\="(.*?)"/', ' name="a3" value="' . $sc["ra"] . '"', $code);
94
+ $code = preg_replace ('/ name\="p3" value\="(.*?)"/', ' name="p3" value="' . $sc["rp"] . '"', $code);
95
+ $code = preg_replace ('/ name\="t3" value\="(.*?)"/', ' name="t3" value="' . $sc["rt"] . '"', $code);
96
+ }
97
/**/
98
return $code; /* The finished PayPal® Button. */
99
}
includes/functions/sp-access.inc.php ADDED
@@ -0,0 +1,73 @@
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