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

Version Description

( instead of s2Member v3.6 ) = * (s2Member/s2Member Pro). Versioning. Starting with this release, s2Member and s2Member Pro will be released with dated versions following this format: yymmdd. The version for this release is: 110604. * (s2Member/s2Member Pro). s2Member Security Badge. An s2Member Security Badge ( optional ), can be used to express your site's concern for security; demonstrating to all Users/Members that your site ( and the s2Member software ), takes security seriously. However, in order to qualify your site, you MUST generate a Security Encryption Key and pass other security standards. For more information, please check your Dashboard under: s2Member -> General Options -> Security Badge. * (s2Member/s2Member Pro). Custom Fields For BuddyPress. s2Member can now integrate your Custom Fields into BuddyPress. Please check your Dashboard for all configuration options. You'll find BuddyPress integration available here: DashBoard -> s2Member -> General Options -> Custom Registration Fields. * (s2Member Pro). PayPal Pro API Updates (First Payment / Recurring Profile Behavior). s2Member's integration with the PayPal Pro API has been updated to API v71.0. There is also a new option available to PayPal Pro Merchants. s2Member now provides site owners the abililty to control the way the first payment in a Recurring Profile is billed. (1)Consolidate w/ Recurring Profile or (2) Real-Time / Direct Pay ( mission critical ) . For further details, please check your Dashboard under: s2Member -> PayPal Options -> Account Details. We recommend: Consolidate w/ Recurring Profile, because this keeps all charges associated with a particular Customer organized in your PayPal account. No matter which option you choose, a first Initial Payment ( when applicable ), will always be charged immediately ( improved in this release ). In cases where it is absolutely critical that a Customer NOT gain access until their first payment has been fully captured, choose: Real-Time / Direct Pay, which tells s2Member to authorize/capture the first payment in real-time during checkout, instead of consolidating it into the Recurring Profile. * (s2Member). bbPress 2.0+. s2Member has been integrated with preliminary support for bbPress 2.0+ ( i.e. the new plugin variation for WordPress ). Please check your Dashboard, under: s2Member -> Other Integrations for further details and a list of current limitations. * (s2Member/s2Member Pro). Field Labels. Some additional for="" attributes in all Pro Form templates. This improves the reliability of s2Member's JavaScript validation routines. Existing s2Member Pro Customers with modified Pro Form templates MUST update their for="" attributes in order for s2Member's JavaScript API to properly validate Customer data entry in this new release. If you're running custom Pro Form templates, check this directory for the updated default templates, so you can merge any changes you've made yourself: /s2member-pro/includes/templates/forms/. * (s2Member). Amazon S3 Support Amazon Simple Storage Service ( Amazon S3 ). Amazon S3 is storage for the Internet. It is designed to make web-scale computing easier for developers. Amazon S3 provides a simple web services interface that can be used to store and retrieve any amount of data, at any time, from anywhere on the web. It gives developers access to the same highly scalable, reliable, secure, fast, inexpensive infrastructure that Amazon uses to run its own global network of web sites. s2Member has been integrated with Amazon S3, so that ( if you wish ), instead of using the /s2member-files/ directory, you can store all of your protected files inside an Amazon S3 Bucket. * (s2Member/s2Member Pro). jQuery. Tested s2Member against jQuery version 1.4.4+, including jQuery v1.6. Fixed a bug with .attr() returning undefined in jQuery v1.6. * (s2Member). Bug fix. Using the Replacement Code %%current_user_login%% in a Special Redirection URL for your Login Welcome Page would sometimes result in your Home Page being protected inadvertently, depending on configuration. * (s2Member/s2Member Pro). IP Address Collection. s2Member now records the original IP Address of a each User, for tracking purposes. In previous versions of s2Member, in order to integrate some tracking systems, ( such as iDevAffiliate's server-side call option ), it was required to use the custom="" Attribute of your Shortcode to grab a Customer's IP Address. That's no longer required, as Replacement Codes are now made available throughout all aspects of s2Member; giving you easy access to the User's IP Address. * (s2Member Pro). Bug fix. Buy Now Coupon descriptions for Specific Post/Page Access were returning invalid details, referencing installments. This bug has been resolved. * (s2Member Pro). SSL. Allow ?s2-ssl without a value ( accept as true ). This has been implemented for advanced site owners running s2Member Pro Forms. * (s2Member/s2Member Pro). API Functions. New API functions for user Level, Role, Custom Capabilities. These will be documented in our official source code documentation system for s2Member ( also new ). Source code documentation will become available in the s2Member forums, shortly after the official public release of this version. * (s2Member/s2Member Pro). New Shortcode Attribute. For PayPal Buttons/Forms, you can now apply Shortcode lc="US". Optional 2 character Locale Code ( i.e. Country Code ). This controls the interface language used if/when a Customer chooses PayPal Express Checkout as their payment method, or upon clicking a Standard PayPal Button. If unspecified, the language is determined by PayPal, when possible, defaulting to US english when not possible. * (s2Member/s2Member Pro). New Shortcode Attribute. For PayPal Buttons/Forms, you can now apply Shortcode rrt="". Regular Recurring Times ( i.e. a fixed number of installments ). Only valid w/ Membership Level Access. When unspecified ( the default ), any recurring charges will remain ongoing until cancelled, or until payments start failing. If this is set to 1 or higher the regular recurring charges will only continue for X billing cycles, depending on what you specify. This is only valid when rr="1" for recurring "Subscriptions". Please note that a fixed number of installments, also means a fixed period of access. If a Customer's billing is monthly, and you set rrt="3", billing will continue for only 3 monthly installments. After that, billing would stop, and their access to the site would be revoked as well ( based on your EOT Behavior setting under: s2Member -> PayPal Options ). * (s2Member/s2Member Pro). New Shortcode Attribute. You can now apply rra="1". This has to do with reattempting failed payments. It has slightly different meanings and option values, depending on whether it's used for a PayPal Button or a PayPal Pro Form Shortcode. For instance, for PayPal Pro Form Shortcodes, this also controls MAXFAILEDPAYMENTS. Please check your Dashboard under: s2Member -> PayPal Buttons/Forms -> Shortcode Attributes Explained. * (s2Member w/s2Member Pro installed). New Shortcode Attribute. You can now apply success="http://..." Attribute to Standard PayPal Buttons. Success Return URL ( optional ). s2Member handles this automatically for you. However, if you would prefer to take control over the landing page after checkout ( i.e. your own custom Thank-You Page ), you can. If supplied, this must be a full URL, starting with http://. Note, s2Member will NOT use this value if an existing account holder is being modified. s2Member handles account updates ( i.e. billing modification ) in a more dynamic way. Your Success Return URL is only applied to (new) Customers. This feature is enabled with s2Member Pro installed. * (s2Member/s2Member Pro). Bug fix. When using ampersands in the success="" Attribute, it would break Success Return URLs on some WordPress installations. s2Member now converts these internally to avoid the issue. * (s2Member). Redirection Status Codes. s2Member's default behavior ( for good reason ), is to send a 301 redirection status when it moves unauthorized Visitors to your Membership Options Page. The reasons for this are well founded. This prevents duplicate content warnings from search engine spiders. However, some web browsers ( like Safari ) make an attempt to cache a 301 redirection into memory, thereby preventing some browsers from reaching the proper areas of your site after logging in, had they been redirected to the Membership Options Page prior. s2Member resolves this problem by detecting all major browser engines ( i.e. msie|trident|gecko|webkit|presto|konqueror|playstation ) and sending web browsers a 302 redirection, while still sending spiders/crawlers ( such as the Google bot ), the proper 301 redirection status. For further details, please check this thread. * (s2Member). Alternative Views. Alternative View Restrictions ( now compatible with Ajax search plugins ). For further details, please check this thread. * (s2Member Pro). Bug fix. Corrected first/last name updates during Pro Form checkout/upgrade routines. s2Member Pro should use ( and update to ) the values submitted, even when already logged-in. * (s2Member/s2Member Pro). Bug fix. s2Member was not properly filling the $_GET["s2member_level_req"] parameter upon certain File Download Restrictions. For instance, s2Member would sometimes return s2member_level_req=0, even though you protected a File inside a Custom Capability and/or Member Level sub-directory. This bug has been corrected. * (s2Member/s2Member Pro). Time Zone. s2Member now displays Registration Dates in your list of Users with date_i18n() for localized time, as opposed to UTC time. UTC time is still the default time zone ( internally ), this is built into the WordPress core. However, certain dates displayed on-site are easier to understand in localized time, based on your WordPress General Settings. * (s2Member). Password Confirmation. s2Member now provides a Password confirmation field on the Standard Registration Form, and in other key areas, such as Profile Editing Panels. * (s2Member/s2Member Pro). Password Strength Meters. This version adds Password strength meters in various places ( where it's helpful ); including s2Member Pro Forms, and even the default Registration Form for WordPress. * (s2Member). Multisite Registration. Cleaned up the default Multisite Registration Form ( i.e. /wp-signup.php ), with structural CSS to better support s2Member features. * (s2Member/s2Member Pro). SI Captchya. s2Member now contains default CSS styles ( just two lines ), and JavaScript validation for the popular SI Capchya plugin; and also for it's own built-in support of Google's reCAPTCHA service for s2Member Pro Forms. * (s2Member/s2Member Pro). Custom Field Default Values. It's now possible to set default text values for single-line and multi-line input/textarea fields too. This only affects Custom Fields you configure with s2Member. * (s2Member/s2Member Pro). Custom Fields By Section. Custom Fields by section ( i.e. dividers ). It's now possible to configure certain Custom Fields, so that they start a new section. Your sections can be simple dividing lines, or you can give them a title that will appear on your Registration and Profile Editing forms. * (s2Member). Bug fix. s2Member was creating window focus/blur issues on Profile updates through its Stand-Alone version of the Profile Editing Panel ( i.e. when it was popped open in a new window ). This was causing odd behavior Firefox 4. * (s2Member/s2Member Pro). Remove First/Last Name. It is now possible to turn off First/Last/Display Name, on Registration and Profile Editing forms. For configuration options, please check your Dashboard, under: s2Member -> Custom Registration Fields. * (s2Member Pro). Data Prefill. s2Member Pro is now capable of prepopulating some Pro Form fields when/if existing Users buy a Specific Post/Page. * (s2Member/s2Member Pro). Bug fix. Fixed nested Custom Registration Field labels for multi option check boxes/radios. Firefox 4+ had issues with this. * (s2Member/s2Member Pro). Registration Link Expiration. The default is built-in, it's (2) days. We don't recommend changing this unless you know what you're doing. Some developers requested the ability to change this dynamically. s2Member now makes this Filter available: ws_plugin__s2member_register_link_exp_time. * (s2Member Pro). Automatic Upgrade Routine. s2Member Pro now places your site into maintenance mode ( temporarily ) during an s2Member Pro Upgrade routine. * (s2Member). New API Notification. New "Modification" Notification now available under: s2Member -> API Notifications. Say that three times fast! * (s2Member/s2Member Pro). MailChimp / AWeber improvements. This release fixes several bugs related to Automatic Unsubscribes, general list removals, and introduces a new feature call Automatic List Transitions. For further details, please check your Dashboard under: s2Member -> API List Servers. * (s2Member). Bug fix. PayPal Button Codes should have been including a charset input variable for UTF-8 encoding. This bug has been corrected now. If you've had trouble getting special characters to appear properly in the PayPal interface, this version should correct those issues for you. * (s2Member/s2Member Pro). Animated Processing... Buttons. This release adds simple animated "processing..." messages to all form submission buttons. * (s2Member/s2Member Pro). MailChimp Interest Groups. Ability to use Interest Groups with Mailchimp List IDs. For examples, please check your Dashboard under: s2Member -> API List Servers -> MailChimp. * (s2Member/s2Member Pro). New EOT Behavior Option. Automatic Extension of EOT Time whenever a Customer is upgrading a paid Subscription? For configuration options, please check your Dashboard under: s2Member -> PayPal Options -> EOT Behavior. * (s2Member/s2Member Pro). Log Entries. WordPress :: s2Member :: s2Member Pro versions now all reported in each log entry. In addition, s2Member now provides logging for all communications with MailChimp and AWeber too. * (s2Member/s2Member Pro). s2Member Now Requires WordPress v3.1+. Backward compatibility for the WordPress 3.0.x series has been removed. Also removed all include() references to /wp-includes/registration.php. Deprecated in WordPress v3.1. This file no longer needs to be included. * (s2Member/s2Member Pro). s2Member Updates. New built-in news updates from s2Member developers. This appears in your Dashboard automatically, inside the s2Member menu panels. * (s2Member/s2Member Pro). Bug fix. Custom Post Types were not appearing in s2Member's Specific Post/Page Button and Form Generators, even when configured properly. This bug has been resolved. * (s2Member/s2Member Pro). Documentation. Built-in documentation updated throughout. * (s2Member/s2Member Pro). UI Panels. Some minor UI improvements.

Download this release

Release Info

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

Code changes from version 3.5.8 to 110604

Files changed (70) hide show
  1. images/amazon-logo.png +0 -0
  2. images/brand-donations.fla +0 -0
  3. images/brand-donations.jpg +0 -0
  4. images/brand-donations.png +0 -0
  5. images/logo.fla +0 -0
  6. images/logo.png +0 -0
  7. images/s2-powered.png +0 -0
  8. includes/{mailchimp → _xtnls}/index.php +0 -0
  9. includes/{markdown → _xtnls/mailchimp}/index.php +0 -0
  10. includes/_xtnls/mailchimp/nc-mcapi.inc.php +2515 -0
  11. includes/_xtnls/markdown/index.php +0 -0
  12. includes/{markdown → _xtnls/markdown}/nc-markdown.inc.php +30 -24
  13. includes/classes/admin-css-js-in.inc.php +56 -31
  14. includes/classes/admin-css-js.inc.php +40 -19
  15. includes/classes/admin-lockouts.inc.php +46 -22
  16. includes/classes/admin-notices.inc.php +75 -41
  17. includes/classes/auto-eots.inc.php +99 -69
  18. includes/classes/brute-force.inc.php +52 -24
  19. includes/classes/cache.inc.php +33 -16
  20. includes/classes/catgs-sp.inc.php +47 -46
  21. includes/classes/catgs.inc.php +43 -42
  22. includes/classes/check-activation.inc.php +33 -26
  23. includes/classes/constants.inc.php +2219 -101
  24. includes/classes/cron-jobs-in.inc.php +40 -18
  25. includes/classes/cron-jobs.inc.php +40 -18
  26. includes/classes/css-js-in.inc.php +70 -35
  27. includes/classes/css-js-themes.inc.php +43 -20
  28. includes/classes/css-js.inc.php +41 -20
  29. includes/classes/custom-reg-fields-4bp.inc.php +280 -0
  30. includes/classes/custom-reg-fields.inc.php +346 -227
  31. includes/classes/email-configs.inc.php +78 -27
  32. includes/classes/files-checks.inc.php +0 -34
  33. includes/classes/files-in.inc.php +151 -76
  34. includes/classes/files.inc.php +136 -107
  35. includes/classes/installation.inc.php +54 -163
  36. includes/classes/ip-restrictions.inc.php +152 -96
  37. includes/classes/labels.inc.php +42 -18
  38. includes/classes/list-servers.inc.php +263 -78
  39. includes/classes/login-customizations.inc.php +97 -58
  40. includes/classes/login-redirects-r.inc.php +33 -16
  41. includes/classes/login-redirects.inc.php +110 -55
  42. includes/classes/menu-pages-rs.inc.php +97 -0
  43. includes/classes/menu-pages.inc.php +276 -155
  44. includes/classes/meta-box-saves.inc.php +32 -17
  45. includes/classes/meta-box-security.inc.php +41 -26
  46. includes/classes/meta-boxes.inc.php +38 -18
  47. includes/classes/mms-patches.inc.php +47 -25
  48. includes/classes/mo-page-in.inc.php +34 -21
  49. includes/classes/mo-page.inc.php +35 -22
  50. includes/classes/no-cache.inc.php +171 -0
  51. includes/classes/nocache.inc.php +0 -124
  52. includes/classes/op-notices.inc.php +55 -40
  53. includes/classes/option-forces.inc.php +109 -45
  54. includes/classes/pages-sp.inc.php +52 -51
  55. includes/classes/pages.inc.php +52 -50
  56. includes/classes/paypal-notify-in.inc.php +664 -325
  57. includes/classes/paypal-notify.inc.php +30 -25
  58. includes/classes/paypal-return-in.inc.php +100 -57
  59. includes/classes/paypal-return.inc.php +30 -15
  60. includes/classes/paypal-utilities.inc.php +188 -101
  61. includes/classes/posts-sp.inc.php +55 -54
  62. includes/classes/posts.inc.php +55 -53
  63. includes/classes/profile-in.inc.php +277 -18
  64. includes/classes/profile-mods-4bp-in.inc.php +112 -0
  65. includes/classes/profile-mods-4bp.inc.php +49 -0
  66. includes/classes/profile-mods-in.inc.php +79 -44
  67. includes/classes/profile-mods.inc.php +31 -16
  68. includes/classes/profile.inc.php +31 -16
  69. includes/classes/ptags-sp.inc.php +52 -51
  70. includes/classes/ptags.inc.php +35 -33
images/amazon-logo.png ADDED
Binary file
images/brand-donations.fla CHANGED
Binary file
images/brand-donations.jpg DELETED
Binary file
images/brand-donations.png ADDED
Binary file
images/logo.fla CHANGED
Binary file
images/logo.png CHANGED
Binary file
images/s2-powered.png ADDED
Binary file
includes/{mailchimp → _xtnls}/index.php RENAMED
File without changes
includes/{markdown → _xtnls/mailchimp}/index.php RENAMED
File without changes
includes/_xtnls/mailchimp/nc-mcapi.inc.php ADDED
@@ -0,0 +1,2515 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MailChimp® API Class.
4
+ *
5
+ * Copyright {@link http://www.mailchimp.com/ MailChimp®}.
6
+ *
7
+ * Modified by {@link http://www.websharks-inc.com/ WebSharks, Inc.}.
8
+ * Uses a custom class name to avoid conflicts with other instances.
9
+ *
10
+ * This version has also been modified to use:
11
+ * {@link s2Member\Utilities\c_ws_plugin__s2member_utils_urls::remote()}
12
+ *
13
+ * @package Xtnls\MailChimp
14
+ * @since 3.0
15
+ */
16
+ class NC_MCAPI {
17
+ var $version = "1.3";
18
+ var $errorMessage;
19
+ var $errorCode;
20
+
21
+ /**
22
+ * Cache the information on the API location on the server
23
+ */
24
+ var $apiUrl;
25
+
26
+ /**
27
+ * Default to a 300 second timeout on server calls
28
+ */
29
+ var $timeout = 300;
30
+
31
+ /**
32
+ * Default to a 8K chunk size
33
+ */
34
+ var $chunkSize = 8192;
35
+
36
+ /**
37
+ * Cache the user api_key so we only have to log in once per client instantiation
38
+ */
39
+ var $api_key;
40
+
41
+ /**
42
+ * Cache the user api_key so we only have to log in once per client instantiation
43
+ */
44
+ var $secure = false;
45
+
46
+ /**
47
+ * Connect to the MailChimp API for a given list.
48
+ *
49
+ * @param string $apikey Your MailChimp apikey
50
+ * @param string $secure Whether or not this should use a secure connection
51
+ */
52
+ function NC_MCAPI($apikey, $secure=false) {
53
+ $this->secure = $secure;
54
+ $this->apiUrl = parse_url("http://api.mailchimp.com/" . $this->version . "/?output=php");
55
+ $this->api_key = $apikey;
56
+ }
57
+ function setTimeout($seconds){
58
+ if (is_int($seconds)){
59
+ $this->timeout = $seconds;
60
+ return true;
61
+ }
62
+ }
63
+ function getTimeout(){
64
+ return $this->timeout;
65
+ }
66
+ function useSecure($val){
67
+ if ($val===true){
68
+ $this->secure = true;
69
+ } else {
70
+ $this->secure = false;
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Unschedule a campaign that is scheduled to be sent in the future
76
+ *
77
+ * @section Campaign Related
78
+ * @example mcapi_campaignUnschedule.php
79
+ * @example xml-rpc_campaignUnschedule.php
80
+ *
81
+ * @param string $cid the id of the campaign to unschedule
82
+ * @return boolean true on success
83
+ */
84
+ function campaignUnschedule($cid) {
85
+ $params = array();
86
+ $params["cid"] = $cid;
87
+ return $this->callServer("campaignUnschedule", $params);
88
+ }
89
+
90
+ /**
91
+ * Schedule a campaign to be sent in the future
92
+ *
93
+ * @section Campaign Related
94
+ * @example mcapi_campaignSchedule.php
95
+ * @example xml-rpc_campaignSchedule.php
96
+ *
97
+ * @param string $cid the id of the campaign to schedule
98
+ * @param string $schedule_time the time to schedule the campaign. For A/B Split "schedule" campaigns, the time for Group A - in YYYY-MM-DD HH:II:SS format in <strong>GMT</strong>
99
+ * @param string $schedule_time_b optional -the time to schedule Group B of an A/B Split "schedule" campaign - in YYYY-MM-DD HH:II:SS format in <strong>GMT</strong>
100
+ * @return boolean true on success
101
+ */
102
+ function campaignSchedule($cid, $schedule_time, $schedule_time_b=NULL) {
103
+ $params = array();
104
+ $params["cid"] = $cid;
105
+ $params["schedule_time"] = $schedule_time;
106
+ $params["schedule_time_b"] = $schedule_time_b;
107
+ return $this->callServer("campaignSchedule", $params);
108
+ }
109
+
110
+ /**
111
+ * Resume sending an AutoResponder or RSS campaign
112
+ *
113
+ * @section Campaign Related
114
+ *
115
+ * @param string $cid the id of the campaign to pause
116
+ * @return boolean true on success
117
+ */
118
+ function campaignResume($cid) {
119
+ $params = array();
120
+ $params["cid"] = $cid;
121
+ return $this->callServer("campaignResume", $params);
122
+ }
123
+
124
+ /**
125
+ * Pause an AutoResponder orRSS campaign from sending
126
+ *
127
+ * @section Campaign Related
128
+ *
129
+ * @param string $cid the id of the campaign to pause
130
+ * @return boolean true on success
131
+ */
132
+ function campaignPause($cid) {
133
+ $params = array();
134
+ $params["cid"] = $cid;
135
+ return $this->callServer("campaignPause", $params);
136
+ }
137
+
138
+ /**
139
+ * Send a given campaign immediately. For RSS campaigns, this will "start" them.
140
+ *
141
+ * @section Campaign Related
142
+ *
143
+ * @example mcapi_campaignSendNow.php
144
+ * @example xml-rpc_campaignSendNow.php
145
+ *
146
+ * @param string $cid the id of the campaign to send
147
+ * @return boolean true on success
148
+ */
149
+ function campaignSendNow($cid) {
150
+ $params = array();
151
+ $params["cid"] = $cid;
152
+ return $this->callServer("campaignSendNow", $params);
153
+ }
154
+
155
+ /**
156
+ * Send a test of this campaign to the provided email address
157
+ *
158
+ * @section Campaign Related
159
+ *
160
+ * @example mcapi_campaignSendTest.php
161
+ * @example xml-rpc_campaignSendTest.php
162
+ *
163
+ * @param string $cid the id of the campaign to test
164
+ * @param array $test_emails an array of email address to receive the test message
165
+ * @param string $send_type optional by default (null) both formats are sent - "html" or "text" send just that format
166
+ * @return boolean true on success
167
+ */
168
+ function campaignSendTest($cid, $test_emails=array (
169
+ ), $send_type=NULL) {
170
+ $params = array();
171
+ $params["cid"] = $cid;
172
+ $params["test_emails"] = $test_emails;
173
+ $params["send_type"] = $send_type;
174
+ return $this->callServer("campaignSendTest", $params);
175
+ }
176
+
177
+ /**
178
+ * Allows one to test their segmentation rules before creating a campaign using them
179
+ *
180
+ * @section Campaign Related
181
+ * @example mcapi_campaignSegmentTest.php
182
+ * @example xml-rpc_campaignSegmentTest.php
183
+ *
184
+ * @param string $list_id the list to test segmentation on - get lists using lists()
185
+ * @param array $options with 2 keys:
186
+ string "match" controls whether to use AND or OR when applying your options - expects "<strong>any</strong>" (for OR) or "<strong>all</strong>" (for AND)
187
+ array "conditions" - up to 10 different criteria to apply while segmenting. Each criteria row must contain 3 keys - "<strong>field</strong>", "<strong>op</strong>", and "<strong>value</strong>" - and possibly a fourth, "<strong>extra</strong>", based on these definitions:
188
+
189
+ Field = "<strong>date</strong>" : Select based on signup date
190
+ Valid Op(eration): <strong>eq</strong> (is) / <strong>gt</strong> (after) / <strong>lt</strong> (before)
191
+ Valid Values:
192
+ string last_campaign_sent uses the date of the last campaign sent
193
+ string campaign_id - uses the send date of the campaign that carriers the Id submitted - see campaigns()
194
+ string YYYY-MM-DD - any date in the form of YYYY-MM-DD - <em>note:</em> anything that appears to start with YYYY will be treated as a date
195
+
196
+ Field = "<strong>interests-X</strong>": where X is the Grouping Id from listInterestGroupings()
197
+ Valid Op(erations): <strong>one</strong> / <strong>none</strong> / <strong>all</strong>
198
+ Valid Values: a comma delimited of interest groups for the list - see listInterestGroupings()
199
+
200
+ Field = "<strong>aim</strong>"
201
+ Valid Op(erations): <strong>open</strong> / <strong>noopen</strong> / <strong>click</strong> / <strong>noclick</strong>
202
+ Valid Values: "<strong>any</strong>" or a valid AIM-enabled Campaign that has been sent
203
+
204
+ Field = "<strong>rating</strong>" : allows matching based on list member ratings
205
+ Valid Op(erations): <strong>eq</strong> (=) / <strong>ne</strong> (!=) / <strong>gt</strong> (&gt;) / <strong>lt</strong> (&lt;)
206
+ Valid Values: a number between 0 and 5
207
+
208
+ Field = "<strong>ecomm_prod</strong>" or "<strong>ecomm_prod</strong>": allows matching product and category names from purchases
209
+ Valid Op(erations):
210
+ <strong>eq</strong> (=) / <strong>ne</strong> (!=) / <strong>gt</strong> (&gt;) / <strong>lt</strong> (&lt;) / <strong>like</strong> (like '%blah%') / <strong>nlike</strong> (not like '%blah%') / <strong>starts</strong> (like 'blah%') / <strong>ends</strong> (like '%blah')
211
+ Valid Values: any string
212
+
213
+ Field = "<strong>ecomm_spent_one</strong>" or "<strong>ecomm_spent_all</strong>" : allows matching purchase amounts on a single order or all orders
214
+ Valid Op(erations): <strong>gt</strong> (&gt;) / <strong>lt</strong> (&lt;)
215
+ Valid Values: a number
216
+
217
+ Field = "<strong>ecomm_date</strong>" : allow matching based on order dates
218
+ Valid Op(eration): <strong>eq</strong> (is) / <strong>gt</strong> (after) / <strong>lt</strong> (before)
219
+ Valid Values:
220
+ string YYYY-MM-DD - any date in the form of YYYY-MM-DD
221
+
222
+ Field = "<strong>social_gender</strong>" : allows matching against the gender acquired from SocialPro
223
+ Valid Op(eration): <strong>eq</strong> (is) / <strong>ne</strong> (is not)
224
+ Valid Values: male, female
225
+
226
+ Field = "<strong>social_age</strong>" : allows matching against the age acquired from SocialPro
227
+ Valid Op(erations): <strong>eq</strong> (=) / <strong>ne</strong> (!=) / <strong>gt</strong> (&gt;) / <strong>lt</strong> (&lt;)
228
+ Valid Values: any number
229
+
230
+ Field = "<strong>social_influence</strong>" : allows matching against the influence acquired from SocialPro
231
+ Valid Op(erations): <strong>eq</strong> (=) / <strong>ne</strong> (!=) / <strong>gt</strong> (&gt;) / <strong>lt</strong> (&lt;)
232
+ Valid Values: a number between 0 and 5
233
+
234
+ Field = "<strong>social_network</strong>" :
235
+ Valid Op(erations): <strong>member</strong> (is a member of) / <strong>notmember</strong> (is not a member of)
236
+ Valid Values: twitter, facebook, myspace, linkedin, flickr
237
+
238
+ Field = "<strong>static_segment</strong>" :
239
+ Valid Op(eration): <strong>eq</strong> (is in) / <strong>ne</strong> (is not in)
240
+ Valid Values: an int - get from listStaticSegments()
241
+
242
+ Field = An <strong>Address</strong> Merge Var. Use <strong>Merge0-Merge30</strong> or the <strong>Custom Tag</strong> you've setup for your merge field - see listMergeVars(). Note, Address fields can still be used with the default operations below - this section is broken out solely to highlight the differences in using the geolocation routines.
243
+ Valid Op(erations): <strong>geoin</strong>
244
+ Valid Values: The number of miles an address should be within
245
+ Extra Value: The Zip Code to be used as the center point
246
+
247
+ Default Field = A Merge Var. Use <strong>Merge0-Merge30</strong> or the <strong>Custom Tag</strong> you've setup for your merge field - see listMergeVars()
248
+ Valid Op(erations):
249
+ <strong>eq</strong> (=) / <strong>ne</strong> (!=) / <strong>gt</strong> (&gt;) / <strong>lt</strong> (&lt;) / <strong>like</strong> (like '%blah%') / <strong>nlike</strong> (not like '%blah%') / <strong>starts</strong> (like 'blah%') / <strong>ends</strong> (like '%blah')
250
+ Valid Values: any string
251
+ * @return int total The total number of subscribers matching your segmentation options
252
+ */
253
+ function campaignSegmentTest($list_id, $options) {
254
+ $params = array();
255
+ $params["list_id"] = $list_id;
256
+ $params["options"] = $options;
257
+ return $this->callServer("campaignSegmentTest", $params);
258
+ }
259
+
260
+ /**
261
+ * Create a new draft campaign to send. You <strong>can not</strong> have more than 32,000 campaigns in your account.
262
+ *
263
+ * @section Campaign Related
264
+ * @example mcapi_campaignCreate.php
265
+ * @example xml-rpc_campaignCreate.php
266
+ * @example xml-rpc_campaignCreateABSplit.php
267
+ * @example xml-rpc_campaignCreateRss.php
268
+ *
269
+ * @param string $type the Campaign Type to create - one of "regular", "plaintext", "absplit", "rss", "trans", "auto"
270
+ * @param array $options a hash of the standard options for this campaign :
271
+ string list_id the list to send this campaign to- get lists using lists()
272
+ string subject the subject line for your campaign message
273
+ string from_email the From: email address for your campaign message
274
+ string from_name the From: name for your campaign message (not an email address)
275
+ string to_name the To: name recipients will see (not email address)
276
+ int template_id optional - use this user-created template to generate the HTML content of the campaign (takes precendence over other template options)
277
+ int gallery_template_id optional - use a template from the public gallery to generate the HTML content of the campaign (takes precendence over base template options)
278
+ int base_template_id optional - use this a base/start-from-scratch template to generate the HTML content of the campaign
279
+ int folder_id optional - automatically file the new campaign in the folder_id passed. Get using folders() - note that Campaigns and Autoresponders have separate folder setupsn
280
+ array tracking optional - set which recipient actions will be tracked, as a struct of boolean values with the following keys: "opens", "html_clicks", and "text_clicks". By default, opens and HTML clicks will be tracked. Click tracking can not be disabled for Free accounts.
281
+ string title optional - an internal name to use for this campaign. By default, the campaign subject will be used.
282
+ boolean authenticate optional - set to true to enable SenderID, DomainKeys, and DKIM authentication, defaults to false.
283
+ array analytics optional - if provided, use a struct with "service type" as a key and the "service tag" as a value. For Google, this should be "google"=>"your_google_analytics_key_here". Note that only "google" is currently supported - a Google Analytics tags will be added to all links in the campaign with this string attached. Others may be added in the future
284
+ boolean auto_footer optional Whether or not we should auto-generate the footer for your content. Mostly useful for content from URLs or Imports
285
+ boolean inline_css optional Whether or not css should be automatically inlined when this campaign is sent, defaults to false.
286
+ boolean generate_text optional Whether of not to auto-generate your Text content from the HTML content. Note that this will be ignored if the Text part of the content passed is not empty, defaults to false.
287
+ boolean auto_tweet optional If set, this campaign will be auto-tweeted when it is sent - defaults to false. Note that if a Twitter account isn't linked, this will be silently ignored.
288
+ boolean timewarp optional If set, this campaign must be scheduled 24 hours in advance of sending - default to false. Only valid for "regular" campaigns and "absplit" campaigns that split on schedule_time.
289
+ boolean ecomm360 optional If set, our <a href="http://www.mailchimp.com/blog/ecommerce-tracking-plugin/" target="_blank">Ecommerce360 tracking</a> will be enabled for links in the campaign
290
+
291
+ * @param array $content the content for this campaign - use a struct with the following keys:
292
+ string html for pasted HTML content
293
+ string text for the plain-text version
294
+ string url to have us pull in content from a URL. Note, this will override any other content options - for lists with Email Format options, you'll need to turn on generate_text as well
295
+ string archive to send a Base64 encoded archive file for us to import all media from. Note, this will override any other content options - for lists with Email Format options, you'll need to turn on generate_text as well
296
+ string archive_type optional - only necessary for the "archive" option. Supported formats are: zip, tar.gz, tar.bz2, tar, tgz, tbz . If not included, we will default to zip
297
+
298
+ If you chose a template instead of pasting in your HTML content, then use "html_" followed by the template sections as keys - for example, use a key of "html_MAIN" to fill in the "MAIN" section of a template. Supported template sections include: "html_HEADER", "html_MAIN", "html_SIDECOLUMN", and "html_FOOTER"
299
+ * @param array $segment_opts optional - if you wish to do Segmentation with this campaign this array should contain: see campaignSegmentTest(). It's suggested that you test your options against campaignSegmentTest(). Also, "trans" campaigns <strong>do not</strong> support segmentation.
300
+ * @param array $type_opts optional -
301
+ For RSS Campaigns this, array should contain:
302
+ string url the URL to pull RSS content from - it will be verified and must exist
303
+ string schedule optional one of "daily", "weekly", "monthly" - defaults to "daily"
304
+ string schedule_hour optional an hour between 0 and 24 - default to 4 (4am <em>local time</em>) - applies to all schedule types
305
+ string schedule_weekday optional for "weekly" only, a number specifying the day of the week to send: 0 (Sunday) - 6 (Saturday) - defaults to 1 (Monday)
306
+ string schedule_monthday optional for "monthly" only, a number specifying the day of the month to send (1 - 28) or "last" for the last day of a given month. Defaults to the 1st day of the month
307
+
308
+ For A/B Split campaigns, this array should contain:
309
+ string split_test The values to segment based on. Currently, one of: "subject", "from_name", "schedule". NOTE, for "schedule", you will need to call campaignSchedule() separately!
310
+ string pick_winner How the winner will be picked, one of: "opens" (by the open_rate), "clicks" (by the click rate), "manual" (you pick manually)
311
+ int wait_units optional the default time unit to wait before auto-selecting a winner - use "3600" for hours, "86400" for days. Defaults to 86400.
312
+ int wait_time optional the number of units to wait before auto-selecting a winner - defaults to 1, so if not set, a winner will be selected after 1 Day.
313
+ int split_size optional this is a percentage of what size the Campaign's List plus any segmentation options results in. "schedule" type forces 50%, all others default to 10%
314
+ string from_name_a optional sort of, required when split_test is "from_name"
315
+ string from_name_b optional sort of, required when split_test is "from_name"
316
+ string from_email_a optional sort of, required when split_test is "from_name"
317
+ string from_email_b optional sort of, required when split_test is "from_name"
318
+ string subject_a optional sort of, required when split_test is "subject"
319
+ string subject_b optional sort of, required when split_test is "subject"
320
+
321
+ For AutoResponder campaigns, this array should contain:
322
+ string offset-units one of "day", "week", "month", "year" - required
323
+ string offset-time optional, sort of - the number of units must be a number greater than 0 for signup based autoresponders
324
+ string offset-dir either "before" or "after"
325
+ string event optional "signup" (default) to base this on double-optin signup, "date" or "annual" to base this on merge field in the list
326
+ string event-datemerge optional sort of, this is required if the event is "date" or "annual"
327
+
328
+ *
329
+ * @return string the ID for the created campaign
330
+ */
331
+ function campaignCreate($type, $options, $content, $segment_opts=NULL, $type_opts=NULL) {
332
+ $params = array();
333
+ $params["type"] = $type;
334
+ $params["options"] = $options;
335
+ $params["content"] = $content;
336
+ $params["segment_opts"] = $segment_opts;
337
+ $params["type_opts"] = $type_opts;
338
+ return $this->callServer("campaignCreate", $params);
339
+ }
340
+
341
+ /** Update just about any setting for a campaign that has <em>not</em> been sent. See campaignCreate() for details.
342
+ *
343
+ *
344
+ * Caveats:<br/><ul>
345
+ * <li>If you set list_id, all segmentation options will be deleted and must be re-added.</li>
346
+ * <li>If you set template_id, you need to follow that up by setting it's 'content'</li>
347
+ * <li>If you set segment_opts, you should have tested your options against campaignSegmentTest() as campaignUpdate() will not allow you to set a segment that includes no members.</li></ul>
348
+ * @section Campaign Related
349
+ *
350
+ * @example mcapi_campaignUpdate.php
351
+ * @example mcapi_campaignUpdateAB.php
352
+ * @example xml-rpc_campaignUpdate.php
353
+ * @example xml-rpc_campaignUpdateAB.php
354
+ *
355
+ * @param string $cid the Campaign Id to update
356
+ * @param string $name the parameter name ( see campaignCreate() ). For items in the <strong>options</strong> array, this will be that parameter's name (subject, from_email, etc.). Additional parameters will be that option name (content, segment_opts). "type_opts" will be the name of the type - rss, auto, trans, etc.
357
+ * @param mixed $value an appropriate value for the parameter ( see campaignCreate() ). For items in the <strong>options</strong> array, this will be that parameter's value. For additional parameters, this is the same value passed to them.
358
+ * @return boolean true if the update succeeds, otherwise an error will be thrown
359
+ */
360
+ function campaignUpdate($cid, $name, $value) {
361
+ $params = array();
362
+ $params["cid"] = $cid;
363
+ $params["name"] = $name;
364
+ $params["value"] = $value;
365
+ return $this->callServer("campaignUpdate", $params);
366
+ }
367
+
368
+ /** Replicate a campaign.
369
+ *
370
+ * @section Campaign Related
371
+ *
372
+ * @example mcapi_campaignReplicate.php
373
+ *
374
+ * @param string $cid the Campaign Id to replicate
375
+ * @return string the id of the replicated Campaign created, otherwise an error will be thrown
376
+ */
377
+ function campaignReplicate($cid) {
378
+ $params = array();
379
+ $params["cid"] = $cid;
380
+ return $this->callServer("campaignReplicate", $params);
381
+ }
382
+
383
+ /** Delete a campaign. Seriously, "poof, gone!" - be careful!
384
+ *
385
+ * @section Campaign Related
386
+ *
387
+ * @example mcapi_campaignDelete.php
388
+ *
389
+ * @param string $cid the Campaign Id to delete
390
+ * @return boolean true if the delete succeeds, otherwise an error will be thrown
391
+ */
392
+ function campaignDelete($cid) {
393
+ $params = array();
394
+ $params["cid"] = $cid;
395
+ return $this->callServer("campaignDelete", $params);
396
+ }
397
+
398
+ /**
399
+ * Get the list of campaigns and their details matching the specified filters
400
+ *
401
+ * @section Campaign Related
402
+ * @example mcapi_campaigns.php
403
+ * @example xml-rpc_campaigns.php
404
+ *
405
+ * @param array $filters a hash of filters to apply to this query - all are optional:
406
+ string campaign_id optional - return a single campaign using a know campaign_id
407
+ string list_id optional - the list to send this campaign to- get lists using lists(). Accepts multiples separated by commas when not using exact matching.
408
+ int folder_id optional - only show campaigns from this folder id - get folders using campaignFolders(). Accepts multiples separated by commas when not using exact matching.
409
+ int template_id optional - only show campaigns using this template id - get templates using templates(). Accepts multiples separated by commas when not using exact matching.
410
+ string status optional - return campaigns of a specific status - one of "sent", "save", "paused", "schedule", "sending". Accepts multiples separated by commas when not using exact matching.
411
+ string type optional - return campaigns of a specific type - one of "regular", "plaintext", "absplit", "rss", "trans", "auto". Accepts multiples separated by commas when not using exact matching.
412
+ string from_name optional - only show campaigns that have this "From Name"
413
+ string from_email optional - only show campaigns that have this "Reply-to Email"
414
+ string title optional - only show campaigns that have this title
415
+ string subject optional - only show campaigns that have this subject
416
+ string sendtime_start optional - only show campaigns that have been sent since this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr)
417
+ string sendtime_end optional - only show campaigns that have been sent before this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr)
418
+ boolean exact optional - flag for whether to filter on exact values when filtering, or search within content for filter values - defaults to true. Using this disables the use of any filters that accept multiples.
419
+ * @param int $start optional - control paging of campaigns, start results at this campaign #, defaults to 1st page of data (page 0)
420
+ * @param int $limit optional - control paging of campaigns, number of campaigns to return with each call, defaults to 25 (max=1000)
421
+ * @return array an array containing a count of all matching campaigns and the specific ones for the current page (see Returned Fields for description)
422
+ * @returnf int total the total number of campaigns matching the filters passed in
423
+ * @returnf array data the data for each campaign being returned
424
+ string id Campaign Id (used for all other campaign functions)
425
+ int web_id The Campaign id used in our web app, allows you to create a link directly to it
426
+ string list_id The List used for this campaign
427
+ int folder_id The Folder this campaign is in
428
+ int template_id The Template this campaign uses
429
+ string content_type How the campaign's content is put together - one of 'template', 'html', 'url'
430
+ string title Title of the campaign
431
+ string type The type of campaign this is (regular,plaintext,absplit,rss,inspection,trans,auto)
432
+ string create_time Creation time for the campaign
433
+ string send_time Send time for the campaign - also the scheduled time for scheduled campaigns.
434
+ int emails_sent Number of emails email was sent to
435
+ string status Status of the given campaign (save,paused,schedule,sending,sent)
436
+ string from_name From name of the given campaign
437
+ string from_email Reply-to email of the given campaign
438
+ string subject Subject of the given campaign
439
+ string to_name Custom "To:" email string using merge variables
440
+ string archive_url Archive link for the given campaign
441
+ boolean inline_css Whether or not the campaign content's css was auto-inlined
442
+ string analytics Either "google" if enabled or "N" if disabled
443
+ string analytics_tag The name/tag the campaign's links were tagged with if analytics were enabled.
444
+ boolean authenticate Whether or not the campaign was authenticated
445
+ boolean ecomm360 Whether or not ecomm360 tracking was appended to links
446
+ boolean auto_tweet Whether or not the campaign was auto tweeted after sending
447
+ string auto_fb_post A comma delimited list of Facebook Profile/Page Ids the campaign was posted to after sending. If not used, blank.
448
+ boolean auto_footer Whether or not the auto_footer was manually turned on
449
+ boolean timewarp Whether or not the campaign used Timewarp
450
+ boolean timewarp_schedule The time, in GMT, that the Timewarp campaign is being sent. For A/B Split campaigns, this is blank and is instead in their schedule_a and schedule_b in the type_opts array
451
+ array tracking containing "text_clicks", "html_clicks", and "opens" as boolean values representing whether or not they were enabled
452
+ string segment_text a string marked-up with HTML explaining the segment used for the campaign in plain English
453
+ array segment_opts the segment used for the campaign - can be passed to campaignSegmentTest() or campaignCreate()
454
+ array type_opts the type-specific options for the campaign - can be passed to campaignCreate()
455
+ */
456
+ function campaigns($filters=array (
457
+ ), $start=0, $limit=25) {
458
+ $params = array();
459
+ $params["filters"] = $filters;
460
+ $params["start"] = $start;
461
+ $params["limit"] = $limit;
462
+ return $this->callServer("campaigns", $params);
463
+ }
464
+
465
+ /**
466
+ * Given a list and a campaign, get all the relevant campaign statistics (opens, bounces, clicks, etc.)
467
+ *
468
+ * @section Campaign Stats
469
+ *
470
+ * @example mcapi_campaignStats.php
471
+ * @example xml-rpc_campaignStats.php
472
+ *
473
+ * @param string $cid the campaign id to pull stats for (can be gathered using campaigns())
474
+ * @return array struct of the statistics for this campaign
475
+ * @returnf int syntax_errors Number of email addresses in campaign that had syntactical errors.
476
+ * @returnf int hard_bounces Number of email addresses in campaign that hard bounced.
477
+ * @returnf int soft_bounces Number of email addresses in campaign that soft bounced.
478
+ * @returnf int unsubscribes Number of email addresses in campaign that unsubscribed.
479
+ * @returnf int abuse_reports Number of email addresses in campaign that reported campaign for abuse.
480
+ * @returnf int forwards Number of times email was forwarded to a friend.
481
+ * @returnf int forwards_opens Number of times a forwarded email was opened.
482
+ * @returnf int opens Number of times the campaign was opened.
483
+ * @returnf date last_open Date of the last time the email was opened.
484
+ * @returnf int unique_opens Number of people who opened the campaign.
485
+ * @returnf int clicks Number of times a link in the campaign was clicked.
486
+ * @returnf int unique_clicks Number of unique recipient/click pairs for the campaign.
487
+ * @returnf date last_click Date of the last time a link in the email was clicked.
488
+ * @returnf int users_who_clicked Number of unique recipients who clicked on a link in the campaign.
489
+ * @returnf int emails_sent Number of email addresses campaign was sent to.
490
+ * @returnf array absplit If this was an absplit campaign, stats for the A and B groups will be returned
491
+ int bounces_a bounces for the A group
492
+ int bounces_b bounces for the B group
493
+ int forwards_a forwards for the A group
494
+ int forwards_b forwards for the B group
495
+ int abuse_reports_a abuse reports for the A group
496
+ int abuse_reports_b abuse reports for the B group
497
+ int unsubs_a unsubs for the A group
498
+ int unsubs_b unsubs for the B group
499
+ int recipients_click_a clicks for the A group
500
+ int recipients_click_b clicks for the B group
501
+ int forwards_opens_a opened forwards for the A group
502
+ int forwards_opens_b opened forwards for the A group
503
+ * @returnf array timewarp If this campaign was a Timewarp campaign, an array of stats from each timezone for it, with the GMT offset as they key. Each timezone will contain:
504
+ int opens opens for this timezone
505
+ string last_open the date/time of the last open for this timezone
506
+ int unique_opens the unique opens for this timezone
507
+ int clicks the total clicks for this timezone
508
+ string last_click the date/time of the last click for this timezone
509
+ int unique_opens the unique clicks for this timezone
510
+ int bounces the total bounces for this timezone
511
+ int total the total number of members sent to in this timezone
512
+ int sent the total number of members delivered to in this timezone
513
+ */
514
+ function campaignStats($cid) {
515
+ $params = array();
516
+ $params["cid"] = $cid;
517
+ return $this->callServer("campaignStats", $params);
518
+ }
519
+
520
+ /**
521
+ * Get an array of the urls being tracked, and their click counts for a given campaign
522
+ *
523
+ * @section Campaign Stats
524
+ *
525
+ * @example mcapi_campaignClickStats.php
526
+ * @example xml-rpc_campaignClickStats.php
527
+ *
528
+ * @param string $cid the campaign id to pull stats for (can be gathered using campaigns())
529
+ * @return struct urls will be keys and contain their associated statistics:
530
+ * @returnf int clicks Number of times the specific link was clicked
531
+ * @returnf int unique Number of unique people who clicked on the specific link
532
+ */
533
+ function campaignClickStats($cid) {
534
+ $params = array();
535
+ $params["cid"] = $cid;
536
+ return $this->callServer("campaignClickStats", $params);
537
+ }
538
+
539
+ /**
540
+ * Get the top 5 performing email domains for this campaign. Users want more than 5 should use campaign campaignEmailStatsAIM()
541
+ * or campaignEmailStatsAIMAll() and generate any additional stats they require.
542
+ *
543
+ * @section Campaign Stats
544
+ *
545
+ * @example mcapi_campaignEmailDomainPerformance.php
546
+ *
547
+ * @param string $cid the campaign id to pull email domain performance for (can be gathered using campaigns())
548
+ * @return array domains email domains and their associated stats
549
+ * @returnf string domain Domain name or special "Other" to roll-up stats past 5 domains
550
+ * @returnf int total_sent Total Email across all domains - this will be the same in every row
551
+ * @returnf int emails Number of emails sent to this domain
552
+ * @returnf int bounces Number of bounces
553
+ * @returnf int opens Number of opens
554
+ * @returnf int clicks Number of clicks
555
+ * @returnf int unsubs Number of unsubs
556
+ * @returnf int delivered Number of deliveries
557
+ * @returnf int emails_pct Percentage of emails that went to this domain (whole number)
558
+ * @returnf int bounces_pct Percentage of bounces from this domain (whole number)
559
+ * @returnf int opens_pct Percentage of opens from this domain (whole number)
560
+ * @returnf int clicks_pct Percentage of clicks from this domain (whole number)
561
+ * @returnf int unsubs_pct Percentage of unsubs from this domain (whole number)
562
+ */
563
+ function campaignEmailDomainPerformance($cid) {
564
+ $params = array();
565
+ $params["cid"] = $cid;
566
+ return $this->callServer("campaignEmailDomainPerformance", $params);
567
+ }
568
+
569
+ /**
570
+ * Get all email addresses the campaign was successfully sent to (ie, no bounces)
571
+ *
572
+ * @section Campaign Stats
573
+ *
574
+ * @param string $cid the campaign id to pull members for (can be gathered using campaigns())
575
+ * @param string $status optional the status to pull - one of 'sent', 'hard' (bounce), or 'soft' (bounce). By default, all records are returned
576
+ * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
577
+ * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
578
+ * @return array a total of all matching emails and the specific emails for this page
579
+ * @returnf int total the total number of members for the campaign and status
580
+ * @returnf array data the full campaign member records
581
+ string email the email address sent to
582
+ string status the status of the send - one of 'sent', 'hard', 'soft'
583
+ string absplit_group if this was an absplit campaign, one of 'a','b', or 'winner'
584
+ string tz_group if this was an timewarp campaign the timezone GMT offset the member was included in
585
+ */
586
+ function campaignMembers($cid, $status=NULL, $start=0, $limit=1000) {
587
+ $params = array();
588
+ $params["cid"] = $cid;
589
+ $params["status"] = $status;
590
+ $params["start"] = $start;
591
+ $params["limit"] = $limit;
592
+ return $this->callServer("campaignMembers", $params);
593
+ }
594
+
595
+ /**
596
+ * <strong>DEPRECATED</strong> Get all email addresses with Hard Bounces for a given campaign
597
+ *
598
+ * @deprecated See campaignMembers() for a replacement
599
+ *
600
+ * @section Campaign Stats
601
+ *
602
+ * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
603
+ * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
604
+ * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
605
+ * @return array a total of all hard bounced emails and the specific emails for this page
606
+ * @returnf int total the total number of hard bounces for the campaign
607
+ * @returnf array data the full email addresses that bounced
608
+ string email the email address that bounced
609
+ */
610
+ function campaignHardBounces($cid, $start=0, $limit=1000) {
611
+ $params = array();
612
+ $params["cid"] = $cid;
613
+ $params["start"] = $start;
614
+ $params["limit"] = $limit;
615
+ return $this->callServer("campaignHardBounces", $params);
616
+ }
617
+
618
+ /**
619
+ * <strong>DEPRECATED</strong> Get all email addresses with Soft Bounces for a given campaign
620
+ *
621
+ * @deprecated See campaignMembers() for a replacement
622
+ *
623
+ * @section Campaign Stats
624
+ *
625
+ * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
626
+ * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
627
+ * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
628
+ * @return array a total of all soft bounced emails and the specific emails for this page
629
+ * @returnf int total the total number of soft bounces for the campaign
630
+ * @returnf array data the full email addresses that bounced
631
+ string email the email address that bounced
632
+ */
633
+ function campaignSoftBounces($cid, $start=0, $limit=1000) {
634
+ $params = array();
635
+ $params["cid"] = $cid;
636
+ $params["start"] = $start;
637
+ $params["limit"] = $limit;
638
+ return $this->callServer("campaignSoftBounces", $params);
639
+ }
640
+
641
+ /**
642
+ * Get all unsubscribed email addresses for a given campaign
643
+ *
644
+ * @section Campaign Stats
645
+ *
646
+ * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
647
+ * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
648
+ * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
649
+ * @return array email addresses that unsubscribed from this campaign along with reasons, if given
650
+ * @return array a total of all unsubscribed emails and the specific emails for this page
651
+ * @returnf int total the total number of unsubscribes for the campaign
652
+ * @returnf array data the full email addresses that unsubscribed
653
+ string email the email address that unsubscribed
654
+ string reason For unsubscribes only - the reason collected for the unsubscribe. If populated, one of 'NORMAL','NOSIGNUP','INAPPROPRIATE','SPAM','OTHER'
655
+ string reason_text For unsubscribes only - if the reason is OTHER, the text entered.
656
+ */
657
+ function campaignUnsubscribes($cid, $start=0, $limit=1000) {
658
+ $params = array();
659
+ $params["cid"] = $cid;
660
+ $params["start"] = $start;
661
+ $params["limit"] = $limit;
662
+ return $this->callServer("campaignUnsubscribes", $params);
663
+ }
664
+
665
+ /**
666
+ * Get all email addresses that complained about a given campaign
667
+ *
668
+ * @section Campaign Stats
669
+ *
670
+ * @example mcapi_campaignAbuseReports.php
671
+ *
672
+ * @param string $cid the campaign id to pull abuse reports for (can be gathered using campaigns())
673
+ * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
674
+ * @param int $limit optional for large data sets, the number of results to return - defaults to 500, upper limit set at 1000
675
+ * @param string $since optional pull only messages since this time - use YYYY-MM-DD HH:II:SS format in <strong>GMT</strong>
676
+ * @return array reports the abuse reports for this campaign
677
+ * @returnf string date date/time the abuse report was received and processed
678
+ * @returnf string email the email address that reported abuse
679
+ * @returnf string type an internal type generally specifying the orginating mail provider - may not be useful outside of filling report views
680
+ */
681
+ function campaignAbuseReports($cid, $since=NULL, $start=0, $limit=500) {
682
+ $params = array();
683
+ $params["cid"] = $cid;
684
+ $params["since"] = $since;
685
+ $params["start"] = $start;
686
+ $params["limit"] = $limit;
687
+ return $this->callServer("campaignAbuseReports", $params);
688
+ }
689
+
690
+ /**
691
+ * Retrieve the text presented in our app for how a campaign performed and any advice we may have for you - best
692
+ * suited for display in customized reports pages. Note: some messages will contain HTML - clean tags as necessary
693
+ *
694
+ * @section Campaign Stats
695
+ *
696
+ * @example mcapi_campaignAdvice.php
697
+ *
698
+ * @param string $cid the campaign id to pull advice text for (can be gathered using campaigns())
699
+ * @return array advice on the campaign's performance
700
+ * @returnf msg the advice message
701
+ * @returnf type the "type" of the message. one of: negative, positive, or neutral
702
+ */
703
+ function campaignAdvice($cid) {
704
+ $params = array();
705
+ $params["cid"] = $cid;
706
+ return $this->callServer("campaignAdvice", $params);
707
+ }
708
+
709
+ /**
710
+ * Retrieve the Google Analytics data we've collected for this campaign. Note, requires Google Analytics Add-on to be installed and configured.
711
+ *
712
+ * @section Campaign Stats
713
+ *
714
+ * @example mcapi_campaignAnalytics.php
715
+ *
716
+ * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
717
+ * @return array analytics we've collected for the passed campaign.
718
+ * @returnf int visits number of visits
719
+ * @returnf int pages number of page views
720
+ * @returnf int new_visits new visits recorded
721
+ * @returnf int bounces vistors who "bounced" from your site
722
+ * @returnf double time_on_site the total time visitors spent on your sites
723
+ * @returnf int goal_conversions number of goals converted
724
+ * @returnf double goal_value value of conversion in dollars
725
+ * @returnf double revenue revenue generated by campaign
726
+ * @returnf int transactions number of transactions tracked
727
+ * @returnf int ecomm_conversions number Ecommerce transactions tracked
728
+ * @returnf array goals an array containing goal names and number of conversions
729
+ */
730
+ function campaignAnalytics($cid) {
731
+ $params = array();
732
+ $params["cid"] = $cid;
733
+ return $this->callServer("campaignAnalytics", $params);
734
+ }
735
+
736
+ /**
737
+ * Retrieve the countries and number of opens tracked for each. Email address are not returned.
738
+ *
739
+ * @section Campaign Stats
740
+ *
741
+ *
742
+ * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
743
+ * @return array countries an array of countries where opens occurred
744
+ * @returnf string code The ISO3166 2 digit country code
745
+ * @returnf string name A version of the country name, if we have it
746
+ * @returnf int opens The total number of opens that occurred in the country
747
+ * @returnf bool region_detail Whether or not a subsequent call to campaignGeoOpensByCountry() will return anything
748
+ */
749
+ function campaignGeoOpens($cid) {
750
+ $params = array();
751
+ $params["cid"] = $cid;
752
+ return $this->callServer("campaignGeoOpens", $params);
753
+ }
754
+
755
+ /**
756
+ * Retrieve the regions and number of opens tracked for a certain country. Email address are not returned.
757
+ *
758
+ * @section Campaign Stats
759
+ *
760
+ *
761
+ * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
762
+ * @param string $code An ISO3166 2 digit country code
763
+ * @return array regions an array of regions within the provided country where opens occurred.
764
+ * @returnf string code An internal code for the region. When this is blank, it indicates we know the country, but not the region
765
+ * @returnf string name The name of the region, if we have one. For blank "code" values, this will be "Rest of Country"
766
+ * @returnf int opens The total number of opens that occurred in the country
767
+ */
768
+ function campaignGeoOpensForCountry($cid, $code) {
769
+ $params = array();
770
+ $params["cid"] = $cid;
771
+ $params["code"] = $code;
772
+ return $this->callServer("campaignGeoOpensForCountry", $params);
773
+ }
774
+
775
+ /**
776
+ * Retrieve the tracked eepurl mentions on Twitter
777
+ *
778
+ * @section Campaign Stats
779
+ *
780
+ *
781
+ * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
782
+ * @return array stats an array containing tweets, retweets, clicks, and referrer related to using the campaign's eepurl
783
+ * @returnf array twitter various Twitter related stats
784
+ int tweets Total number of tweets seen
785
+ string first_tweet date and time of the first tweet seen
786
+ string last_tweet date and time of the last tweet seen
787
+ int retweets Total number of retweets seen
788
+ string first_retweet date and time of the first retweet seen
789
+ string last_retweet date and time of the last retweet seen
790
+ array statuses an array of statuses recorded inclduing the status, screen_name, status_id, and datetime fields plus an is_retweet flag
791
+ * @returnf array clicks stats related to click-throughs on the eepurl
792
+ int clicks Total number of clicks seen
793
+ string first_click date and time of the first click seen
794
+ string last_click date and time of the first click seen
795
+ array locations an array of geographic locations including country, region, and total clicks
796
+ * @returnf array referrers an array of arrays, each containing
797
+ string referrer the referrer, truncated to 100 bytes
798
+ int clicks Total number of clicks seen from this referrer
799
+ string first_click date and time of the first click seen from this referrer
800
+ string last_click date and time of the first click seen from this referrer
801
+ */
802
+ function campaignEepUrlStats($cid) {
803
+ $params = array();
804
+ $params["cid"] = $cid;
805
+ return $this->callServer("campaignEepUrlStats", $params);
806
+ }
807
+
808
+ /**
809
+ * Retrieve the most recent full bounce message for a specific email address on the given campaign.
810
+ * Messages over 30 days old are subject to being removed
811
+ *
812
+ *
813
+ * @section Campaign Stats
814
+ *
815
+ * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
816
+ * @param string $email the email address or unique id of the member to pull a bounce message for.
817
+ * @return array the full bounce message for this email+campaign along with some extra data.
818
+ * @returnf string date date/time the bounce was received and processed
819
+ * @returnf string email the email address that bounced
820
+ * @returnf string message the entire bounce message received
821
+ */
822
+ function campaignBounceMessage($cid, $email) {
823
+ $params = array();
824
+ $params["cid"] = $cid;
825
+ $params["email"] = $email;
826
+ return $this->callServer("campaignBounceMessage", $params);
827
+ }
828
+
829
+ /**
830
+ * Retrieve the full bounce messages for the given campaign. Note that this can return very large amounts
831
+ * of data depending on how large the campaign was and how much cruft the bounce provider returned. Also,
832
+ * message over 30 days old are subject to being removed
833
+ *
834
+ * @section Campaign Stats
835
+ *
836
+ * @example mcapi_campaignBounceMessages.php
837
+ *
838
+ * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
839
+ * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
840
+ * @param int $limit optional for large data sets, the number of results to return - defaults to 25, upper limit set at 50
841
+ * @param string $since optional pull only messages since this time - use YYYY-MM-DD format in <strong>GMT</strong> (we only store the date, not the time)
842
+ * @return array bounces the full bounce messages for this campaign
843
+ * @returnf int total that total number of bounce messages for the campaign
844
+ * @returnf array data an array containing the data for this page
845
+ string date date/time the bounce was received and processed
846
+ string email the email address that bounced
847
+ string message the entire bounce message received
848
+ */
849
+ function campaignBounceMessages($cid, $start=0, $limit=25, $since=NULL) {
850
+ $params = array();
851
+ $params["cid"] = $cid;
852
+ $params["start"] = $start;
853
+ $params["limit"] = $limit;
854
+ $params["since"] = $since;
855
+ return $this->callServer("campaignBounceMessages", $params);
856
+ }
857
+
858
+ /**
859
+ * Retrieve the Ecommerce Orders tracked by campaignEcommOrderAdd()
860
+ *
861
+ * @section Campaign Stats
862
+ *
863
+ * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
864
+ * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
865
+ * @param int $limit optional for large data sets, the number of results to return - defaults to 100, upper limit set at 500
866
+ * @param string $since optional pull only messages since this time - use YYYY-MM-DD HH:II:SS format in <strong>GMT</strong>
867
+ * @return array the total matching orders and the specific orders for the requested page
868
+ * @returnf int total the total matching orders
869
+ * @returnf array data the actual data for each order being returned
870
+ string store_id the store id generated by the plugin used to uniquely identify a store
871
+ string store_name the store name collected by the plugin - often the domain name
872
+ string order_id the internal order id the store tracked this order by
873
+ string email the email address that received this campaign and is associated with this order
874
+ double order_total the order total
875
+ double tax_total the total tax for the order (if collected)
876
+ double ship_total the shipping total for the order (if collected)
877
+ string order_date the date the order was tracked - from the store if possible, otherwise the GMT time we recieved it
878
+ array lines containing detail of the order - product, category, quantity, item cost
879
+ */
880
+ function campaignEcommOrders($cid, $start=0, $limit=100, $since=NULL) {
881
+ $params = array();
882
+ $params["cid"] = $cid;
883
+ $params["start"] = $start;
884
+ $params["limit"] = $limit;
885
+ $params["since"] = $since;
886
+ return $this->callServer("campaignEcommOrders", $params);
887
+ }
888
+
889
+ /**
890
+ * Get the URL to a customized <a href="http://eepurl.com/gKmL" target="_blank">VIP Report</a> for the specified campaign and optionally send an email to someone with links to it. Note subsequent calls will overwrite anything already set for the same campign (eg, the password)
891
+ *
892
+ * @section Campaign Related
893
+ *
894
+ * @param string $cid the campaign id to share a report for (can be gathered using campaigns())
895
+ * @param array $opts optional various parameters which can be used to configure the shared report
896
+ string header_type optional - "text" or "image', defaults to "text'
897
+ string header_data optional - if "header_type" is text, the text to display. if "header_type" is "image" a valid URL to an image file. Note that images will be resized to be no more than 500x150. Defaults to the Accounts Company Name.
898
+ boolean secure optional - whether to require a password for the shared report. defaults to "true"
899
+ string password optional - if secure is true and a password is not included, we will generate one. It is always returned.
900
+ string to_email optional - optional, email address to share the report with - no value means an email will not be sent
901
+ array theme optional - an array containing either 3 or 6 character color code values for: "bg_color", "header_color", "current_tab", "current_tab_text", "normal_tab", "normal_tab_text", "hover_tab", "hover_tab_text"
902
+ string css_url optional - a link to an external CSS file to be included after our default CSS (http://vip-reports.net/css/vip.css) <strong>only if</strong> loaded via the "secure_url" - max 255 bytes
903
+ * @return struct Struct containing details for the shared report
904
+ * @returnf string title The Title of the Campaign being shared
905
+ * @returnf string url The URL to the shared report
906
+ * @returnf string secure_url The URL to the shared report, including the password (good for loading in an IFRAME). For non-secure reports, this will not be returned
907
+ * @returnf string password If secured, the password for the report, otherwise this field will not be returned
908
+ */
909
+ function campaignShareReport($cid, $opts=array (
910
+ )) {
911
+ $params = array();
912
+ $params["cid"] = $cid;
913
+ $params["opts"] = $opts;
914
+ return $this->callServer("campaignShareReport", $params);
915
+ }
916
+
917
+ /**
918
+ * Get the content (both html and text) for a campaign either as it would appear in the campaign archive or as the raw, original content
919
+ *
920
+ * @section Campaign Related
921
+ *
922
+ * @param string $cid the campaign id to get content for (can be gathered using campaigns())
923
+ * @param bool $for_archive optional controls whether we return the Archive version (true) or the Raw version (false), defaults to true
924
+ * @return struct Struct containing all content for the campaign (see Returned Fields for details
925
+ * @returnf string html The HTML content used for the campgain with merge tags intact
926
+ * @returnf string text The Text content used for the campgain with merge tags intact
927
+ */
928
+ function campaignContent($cid, $for_archive=true) {
929
+ $params = array();
930
+ $params["cid"] = $cid;
931
+ $params["for_archive"] = $for_archive;
932
+ return $this->callServer("campaignContent", $params);
933
+ }
934
+
935
+ /**
936
+ * Get the HTML template content sections for a campaign. Note that this <strong>will</strong> return very jagged, non-standard results based on the template
937
+ * a campaign is using. You only want to use this if you want to allow editing template sections in your applicaton.
938
+ *
939
+ * @section Campaign Related
940
+ *
941
+ * @param string $cid the campaign id to get content for (can be gathered using campaigns())
942
+ * @return array array containing all content section for the campaign -
943
+ */
944
+ function campaignTemplateContent($cid) {
945
+ $params = array();
946
+ $params["cid"] = $cid;
947
+ return $this->callServer("campaignTemplateContent", $params);
948
+ }
949
+
950
+ /**
951
+ * Retrieve the list of email addresses that opened a given campaign with how many times they opened - note: this AIM function is free and does
952
+ * not actually require the AIM module to be installed
953
+ *
954
+ * @section Campaign Report Data
955
+ *
956
+ * @param string $cid the campaign id to get opens for (can be gathered using campaigns())
957
+ * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
958
+ * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
959
+ * @return array array containing the total records matched and the specific records for this page
960
+ * @returnf int total the total number of records matched
961
+ * @returnf array data the actual opens data, including:
962
+ string email Email address that opened the campaign
963
+ int open_count Total number of times the campaign was opened by this email address
964
+ */
965
+ function campaignOpenedAIM($cid, $start=0, $limit=1000) {
966
+ $params = array();
967
+ $params["cid"] = $cid;
968
+ $params["start"] = $start;
969
+ $params["limit"] = $limit;
970
+ return $this->callServer("campaignOpenedAIM", $params);
971
+ }
972
+
973
+ /**
974
+ * Retrieve the list of email addresses that did not open a given campaign
975
+ *
976
+ * @section Campaign Report Data
977
+ *
978
+ * @param string $cid the campaign id to get no opens for (can be gathered using campaigns())
979
+ * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
980
+ * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
981
+ * @return array array containing the total records matched and the specific records for this page
982
+ * @returnf int total the total number of records matched
983
+ * @returnf array data the email addresses that did not open the campaign
984
+ string email Email address that opened the campaign
985
+ */
986
+ function campaignNotOpenedAIM($cid, $start=0, $limit=1000) {
987
+ $params = array();
988
+ $params["cid"] = $cid;
989
+ $params["start"] = $start;
990
+ $params["limit"] = $limit;
991
+ return $this->callServer("campaignNotOpenedAIM", $params);
992
+ }
993
+
994
+ /**
995
+ * Return the list of email addresses that clicked on a given url, and how many times they clicked
996
+ *
997
+ * @section Campaign Report Data
998
+ *
999
+ * @param string $cid the campaign id to get click stats for (can be gathered using campaigns())
1000
+ * @param string $url the URL of the link that was clicked on
1001
+ * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
1002
+ * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
1003
+ * @return array array containing the total records matched and the specific records for this page
1004
+ * @returnf int total the total number of records matched
1005
+ * @returnf array data the email addresses that did not open the campaign
1006
+ string email Email address that opened the campaign
1007
+ int clicks Total number of times the URL was clicked on by this email address
1008
+ */
1009
+ function campaignClickDetailAIM($cid, $url, $start=0, $limit=1000) {
1010
+ $params = array();
1011
+ $params["cid"] = $cid;
1012
+ $params["url"] = $url;
1013
+ $params["start"] = $start;
1014
+ $params["limit"] = $limit;
1015
+ return $this->callServer("campaignClickDetailAIM", $params);
1016
+ }
1017
+
1018
+ /**
1019
+ * Given a campaign and email address, return the entire click and open history with timestamps, ordered by time
1020
+ *
1021
+ * @section Campaign Report Data
1022
+ *
1023
+ * @param string $cid the campaign id to get stats for (can be gathered using campaigns())
1024
+ * @param array $email_address an array of up to 50 email addresses to check OR the email "id" returned from listMemberInfo, Webhooks, and Campaigns. For backwards compatibility, if a string is passed, it will be treated as an array with a single element (will not work with XML-RPC).
1025
+ * @return array an array with the keys listed in Returned Fields below
1026
+ * @returnf int success the number of email address records found
1027
+ * @returnf int error the number of email address records which could not be found
1028
+ * @returnf array data arrays containing the actions (opens and clicks) that the email took, with timestamps
1029
+ string action The action taken (open or click)
1030
+ string timestamp Time the action occurred
1031
+ string url For clicks, the URL that was clicked
1032
+ */
1033
+ function campaignEmailStatsAIM($cid, $email_address) {
1034
+ $params = array();
1035
+ $params["cid"] = $cid;
1036
+ $params["email_address"] = $email_address;
1037
+ return $this->callServer("campaignEmailStatsAIM", $params);
1038
+ }
1039
+
1040
+ /**
1041
+ * Given a campaign and correct paging limits, return the entire click and open history with timestamps, ordered by time,
1042
+ * for every user a campaign was delivered to.
1043
+ *
1044
+ * @section Campaign Report Data
1045
+ * @example mcapi_campaignEmailStatsAIMAll.php
1046
+ *
1047
+ * @param string $cid the campaign id to get stats for (can be gathered using campaigns())
1048
+ * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
1049
+ * @param int $limit optional for large data sets, the number of results to return - defaults to 100, upper limit set at 1000
1050
+ * @return array Array containing a total record count and data including the actions (opens and clicks) for each email, with timestamps
1051
+ * @returnf int total the total number of records
1052
+ * @returnf array data each record with their details:
1053
+ string action The action taken (open or click)
1054
+ string timestamp Time the action occurred
1055
+ string url For clicks, the URL that was clicked
1056
+ */
1057
+ function campaignEmailStatsAIMAll($cid, $start=0, $limit=100) {
1058
+ $params = array();
1059
+ $params["cid"] = $cid;
1060
+ $params["start"] = $start;
1061
+ $params["limit"] = $limit;
1062
+ return $this->callServer("campaignEmailStatsAIMAll", $params);
1063
+ }
1064
+
1065
+ /**
1066
+ * Attach Ecommerce Order Information to a Campaign. This will generall be used by ecommerce package plugins
1067
+ * <a href="/plugins/ecomm360.phtml">that we provide</a> or by 3rd part system developers.
1068
+ * @section Campaign Related
1069
+ *
1070
+ * @param array $order an array of information pertaining to the order that has completed. Use the following keys:
1071
+ string id the Order Id
1072
+ string campaign_id the Campaign Id to track this order with (see the "mc_cid" query string variable a campaign passes)
1073
+ string email_id the Email Id of the subscriber we should attach this order to (see the "mc_eid" query string variable a campaign passes)
1074
+ double total The Order Total (ie, the full amount the customer ends up paying)
1075
+ string order_date optional the date of the order - if this is not provided, we will default the date to now
1076
+ double shipping optional the total paid for Shipping Fees
1077
+ double tax optional the total tax paid
1078
+ string store_id a unique id for the store sending the order in (20 bytes max)
1079
+ string store_name optional a "nice" name for the store - typically the base web address (ie, "store.mailchimp.com"). We will automatically update this if it changes (based on store_id)
1080
+ string plugin_id the MailChimp assigned Plugin Id. Get yours by <a href="/register.php">registering here</a>
1081
+ array items the individual line items for an order using these keys:
1082
+ <div style="padding-left:30px"><table><tr><td colspan=*>
1083
+ int line_num optional the line number of the item on the order. We will generate these if they are not passed
1084
+ int product_id the store's internal Id for the product. Lines that do no contain this will be skipped
1085
+ string product_name the product name for the product_id associated with this item. We will auto update these as they change (based on product_id)
1086
+ int category_id the store's internal Id for the (main) category associated with this product. Our testing has found this to be a "best guess" scenario
1087
+ string category_name the category name for the category_id this product is in. Our testing has found this to be a "best guess" scenario. Our plugins walk the category heirarchy up and send "Root - SubCat1 - SubCat4", etc.
1088
+ double qty the quantity of the item ordered
1089
+ double cost the cost of a single item (ie, not the extended cost of the line)
1090
+ </td></tr></table></div>
1091
+ * @return bool true if the data is saved, otherwise an error is thrown.
1092
+ */
1093
+ function campaignEcommOrderAdd($order) {
1094
+ $params = array();
1095
+ $params["order"] = $order;
1096
+ return $this->callServer("campaignEcommOrderAdd", $params);
1097
+ }
1098
+
1099
+ /**
1100
+ * Retrieve all of the lists defined for your user account
1101
+ *
1102
+ * @section List Related
1103
+ * @example mcapi_lists.php
1104
+ * @example xml-rpc_lists.php
1105
+ *
1106
+ * @param array $filters a hash of filters to apply to this query - all are optional:
1107
+ string list_id optional - return a single list using a known list_id. Accepts multiples separated by commas when not using exact matching
1108
+ string list_name optional - only lists that match this name
1109
+ string from_name optional - only lists that have a default from name matching this
1110
+ string from_email optional - only lists that have a default from email matching this
1111
+ string from_subject optional - only lists that have a default from email matching this
1112
+ string created_before optional - only show lists that were created before this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr)
1113
+ string created_after optional - only show lists that were created since this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr)
1114
+ boolean exact optional - flag for whether to filter on exact values when filtering, or search within content for filter values - defaults to true
1115
+ * @param int $start optional - control paging of lists, start results at this list #, defaults to 1st page of data (page 0)
1116
+ * @param int $limit optional - control paging of lists, number of lists to return with each call, defaults to 25 (max=100)
1117
+ * @return array an array with keys listed in Returned Fields below
1118
+ * @returnf int total the total number of lists which matched the provided filters
1119
+ * @returnf array data the lists which matched the provided filters, including the following for
1120
+ string id The list id for this list. This will be used for all other list management functions.
1121
+ int web_id The list id used in our web app, allows you to create a link directly to it
1122
+ string name The name of the list.
1123
+ string date_created The date that this list was created.
1124
+ boolean email_type_option Whether or not the List supports multiple formats for emails or just HTML
1125
+ boolean use_awesomebar Whether or not campaigns for this list use the Awesome Bar in archives by default
1126
+ string default_from_name Default From Name for campaigns using this list
1127
+ string default_from_email Default From Email for campaigns using this list
1128
+ string default_subject Default Subject Line for campaigns using this list
1129
+ string default_language Default Language for this list's forms
1130
+ int list_rating An auto-generated activity score for the list (0 - 5)
1131
+ array stats various stats and counts for the list
1132
+ int member_count The number of active members in the given list.
1133
+ int unsubscribe_count The number of members who have unsubscribed from the given list.
1134
+ int cleaned_count The number of members cleaned from the given list.
1135
+ int member_count_since_send The number of active members in the given list since the last campaign was sent
1136
+ int unsubscribe_count_since_send The number of members who have unsubscribed from the given list since the last campaign was sent
1137
+ int cleaned_count_since_send The number of members cleaned from the given list since the last campaign was sent
1138
+ int campaign_count The number of campaigns in any status that use this list
1139
+ int grouping_count The number of Interest Groupings for this list
1140
+ int group_count The number of Interest Groups (regardless of grouping) for this list
1141
+ int merge_var_count The number of merge vars for this list (not including the required EMAIL one)
1142
+ int avg_sub_rate the average number of subscribe per month for the list (empty value if we haven't calculated this yet)
1143
+ int avg_unsub_rate the average number of unsubscribe per month for the list (empty value if we haven't calculated this yet)
1144
+ int target_sub_rate the target subscription rate for the list to keep it growing (empty value if we haven't calculated this yet)
1145
+ int open_rate the average open rate per campaign for the list (empty value if we haven't calculated this yet)
1146
+ int click_rate the average click rate per campaign for the list (empty value if we haven't calculated this yet)
1147
+ array modules Any list specific modules installed for this list (example is SocialPro)
1148
+ */
1149
+ function lists($filters=array (
1150
+ ), $start=0, $limit=25) {
1151
+ $params = array();
1152
+ $params["filters"] = $filters;
1153
+ $params["start"] = $start;
1154
+ $params["limit"] = $limit;
1155
+ return $this->callServer("lists", $params);
1156
+ }
1157
+
1158
+ /**
1159
+ * Get the list of merge tags for a given list, including their name, tag, and required setting
1160
+ *
1161
+ * @section List Related
1162
+ * @example xml-rpc_listMergeVars.php
1163
+ *
1164
+ * @param string $id the list id to connect to. Get by calling lists()
1165
+ * @return array list of merge tags for the list
1166
+ * @returnf string name Name of the merge field
1167
+ * @returnf bool req Denotes whether the field is required (true) or not (false)
1168
+ * @returnf string field_type The "data type" of this merge var. One of: email, text, number, radio, dropdown, date, address, phone, url, imageurl
1169
+ * @returnf bool public Whether or not this field is visible to list subscribers
1170
+ * @returnf bool show Whether the list owner has this field displayed on their list dashboard
1171
+ * @returnf string order The order the list owner has set this field to display in
1172
+ * @returnf string default The default value the list owner has set for this field
1173
+ * @returnf string size The width of the field to be used
1174
+ * @returnf string tag The merge tag that's used for forms and listSubscribe() and listUpdateMember()
1175
+ * @returnf array choices For radio and dropdown field types, an array of the options available
1176
+ */
1177
+ function listMergeVars($id) {
1178
+ $params = array();
1179
+ $params["id"] = $id;
1180
+ return $this->callServer("listMergeVars", $params);
1181
+ }
1182
+
1183
+ /**
1184
+ * Add a new merge tag to a given list
1185
+ *
1186
+ * @section List Related
1187
+ * @example xml-rpc_listMergeVarAdd.php
1188
+ *
1189
+ * @param string $id the list id to connect to. Get by calling lists()
1190
+ * @param string $tag The merge tag to add, e.g. FNAME
1191
+ * @param string $name The long description of the tag being added, used for user displays
1192
+ * @param array $options optional Various options for this merge var. <em>note:</em> for historical purposes this can also take a "boolean"
1193
+ string field_type optional one of: text, number, radio, dropdown, date, address, phone, url, imageurl - defaults to text
1194
+ boolean req optional indicates whether the field is required - defaults to false
1195
+ boolean public optional indicates whether the field is displayed in public - defaults to true
1196
+ boolean show optional indicates whether the field is displayed in the app's list member view - defaults to true
1197
+ string default_value optional the default value for the field. See listSubscribe() for formatting info. Defaults to blank
1198
+ array choices optional kind of - an array of strings to use as the choices for radio and dropdown type fields
1199
+
1200
+ * @return bool true if the request succeeds, otherwise an error will be thrown
1201
+ */
1202
+ function listMergeVarAdd($id, $tag, $name, $options=array (
1203
+ )) {
1204
+ $params = array();
1205
+ $params["id"] = $id;
1206
+ $params["tag"] = $tag;
1207
+ $params["name"] = $name;
1208
+ $params["options"] = $options;
1209
+ return $this->callServer("listMergeVarAdd", $params);
1210
+ }
1211
+
1212
+ /**
1213
+ * Update most parameters for a merge tag on a given list. You cannot currently change the merge type
1214
+ *
1215
+ * @section List Related
1216
+ *
1217
+ * @param string $id the list id to connect to. Get by calling lists()
1218
+ * @param string $tag The merge tag to update
1219
+ * @param array $options The options to change for a merge var. See listMergeVarAdd() for valid options
1220
+ * @return bool true if the request succeeds, otherwise an error will be thrown
1221
+ */
1222
+ function listMergeVarUpdate($id, $tag, $options) {
1223
+ $params = array();
1224
+ $params["id"] = $id;
1225
+ $params["tag"] = $tag;
1226
+ $params["options"] = $options;
1227
+ return $this->callServer("listMergeVarUpdate", $params);
1228
+ }
1229
+
1230
+ /**
1231
+ * Delete a merge tag from a given list and all its members. Seriously - the data is removed from all members as well!
1232
+ * Note that on large lists this method may seem a bit slower than calls you typically make.
1233
+ *
1234
+ * @section List Related
1235
+ * @example xml-rpc_listMergeVarDel.php
1236
+ *
1237
+ * @param string $id the list id to connect to. Get by calling lists()
1238
+ * @param string $tag The merge tag to delete
1239
+ * @return bool true if the request succeeds, otherwise an error will be thrown
1240
+ */
1241
+ function listMergeVarDel($id, $tag) {
1242
+ $params = array();
1243
+ $params["id"] = $id;
1244
+ $params["tag"] = $tag;
1245
+ return $this->callServer("listMergeVarDel", $params);
1246
+ }
1247
+
1248
+ /**
1249
+ * Get the list of interest groupings for a given list, including the label, form information, and included groups for each
1250
+ *
1251
+ * @section List Related
1252
+ * @example xml-rpc_listInterestGroupings.php
1253
+ *
1254
+ * @param string $id the list id to connect to. Get by calling lists()
1255
+ * @return struct list of interest groups for the list
1256
+ * @returnf string id The id for the Grouping
1257
+ * @returnf string name Name for the Interest groups
1258
+ * @returnf string form_field Gives the type of interest group: checkbox,radio,select
1259
+ * @returnf array groups Array of the grouping options including the "bit" value, "name", "display_order", and number of "subscribers" with the option selected.
1260
+ */
1261
+ function listInterestGroupings($id) {
1262
+ $params = array();
1263
+ $params["id"] = $id;
1264
+ return $this->callServer("listInterestGroupings", $params);
1265
+ }
1266
+
1267
+ /** Add a single Interest Group - if interest groups for the List are not yet enabled, adding the first
1268
+ * group will automatically turn them on.
1269
+ *
1270
+ * @section List Related
1271
+ * @example xml-rpc_listInterestGroupAdd.php
1272
+ *
1273
+ * @param string $id the list id to connect to. Get by calling lists()
1274
+ * @param string $group_name the interest group to add - group names must be unique within a grouping
1275
+ * @param int optional $grouping_id The grouping to add the new group to - get using listInterestGrouping() . If not supplied, the first grouping on the list is used.
1276
+ * @return bool true if the request succeeds, otherwise an error will be thrown
1277
+ */
1278
+ function listInterestGroupAdd($id, $group_name, $grouping_id=NULL) {
1279
+ $params = array();
1280
+ $params["id"] = $id;
1281
+ $params["group_name"] = $group_name;
1282
+ $params["grouping_id"] = $grouping_id;
1283
+ return $this->callServer("listInterestGroupAdd", $params);
1284
+ }
1285
+
1286
+ /** Delete a single Interest Group - if the last group for a list is deleted, this will also turn groups for the list off.
1287
+ *
1288
+ * @section List Related
1289
+ * @example xml-rpc_listInterestGroupDel.php
1290
+ *
1291
+ * @param string $id the list id to connect to. Get by calling lists()
1292
+ * @param string $group_name the interest group to delete
1293
+ * @param int $grouping_id The grouping to delete the group from - get using listInterestGrouping() . If not supplied, the first grouping on the list is used.
1294
+ * @return bool true if the request succeeds, otherwise an error will be thrown
1295
+ */
1296
+ function listInterestGroupDel($id, $group_name, $grouping_id=NULL) {
1297
+ $params = array();
1298
+ $params["id"] = $id;
1299
+ $params["group_name"] = $group_name;
1300
+ $params["grouping_id"] = $grouping_id;
1301
+ return $this->callServer("listInterestGroupDel", $params);
1302
+ }
1303
+
1304
+ /** Change the name of an Interest Group
1305
+ *
1306
+ * @section List Related
1307
+ *
1308
+ * @param string $id the list id to connect to. Get by calling lists()
1309
+ * @param string $old_name the interest group name to be changed
1310
+ * @param string $new_name the new interest group name to be set
1311
+ * @param int optional $grouping_id The grouping to delete the group from - get using listInterestGrouping() . If not supplied, the first grouping on the list is used.
1312
+ * @return bool true if the request succeeds, otherwise an error will be thrown
1313
+ */
1314
+ function listInterestGroupUpdate($id, $old_name, $new_name, $grouping_id=NULL) {
1315
+ $params = array();
1316
+ $params["id"] = $id;
1317
+ $params["old_name"] = $old_name;
1318
+ $params["new_name"] = $new_name;
1319
+ $params["grouping_id"] = $grouping_id;
1320
+ return $this->callServer("listInterestGroupUpdate", $params);
1321
+ }
1322
+
1323
+ /** Add a new Interest Grouping - if interest groups for the List are not yet enabled, adding the first
1324
+ * grouping will automatically turn them on.
1325
+ *
1326
+ * @section List Related
1327
+ * @example xml-rpc_listInterestGroupingAdd.php
1328
+ *
1329
+ * @param string $id the list id to connect to. Get by calling lists()
1330
+ * @param string $name the interest grouping to add - grouping names must be unique
1331
+ * @param string $type The type of the grouping to add - one of "checkboxes", "hidden", "dropdown", "radio"
1332
+ * @param array $groups The lists of initial group names to be added - at least 1 is required and the names must be unique within a grouping. If the number takes you over the 60 group limit, an error will be thrown.
1333
+ * @return int the new grouping id if the request succeeds, otherwise an error will be thrown
1334
+ */
1335
+ function listInterestGroupingAdd($id, $name, $type, $groups) {
1336
+ $params = array();
1337
+ $params["id"] = $id;
1338
+ $params["name"] = $name;
1339
+ $params["type"] = $type;
1340
+ $params["groups"] = $groups;
1341
+ return $this->callServer("listInterestGroupingAdd", $params);
1342
+ }
1343
+
1344
+ /** Update an existing Interest Grouping
1345
+ *
1346
+ * @section List Related
1347
+ * @example xml-rpc_listInterestGroupingUpdate.php
1348
+ *
1349
+ * @param int $grouping_id the interest grouping id - get from listInterestGroupings()
1350
+ * @param string $name The name of the field to update - either "name" or "type". Groups with in the grouping should be manipulated using the standard listInterestGroup* methods
1351
+ * @param string $value The new value of the field. Grouping names must be unique - only "hidden" and "checkboxes" grouping types can be converted between each other.
1352
+ * @return bool true if the request succeeds, otherwise an error will be thrown
1353
+ */
1354
+ function listInterestGroupingUpdate($grouping_id, $name, $value) {
1355
+ $params = array();
1356
+ $params["grouping_id"] = $grouping_id;
1357
+ $params["name"] = $name;
1358
+ $params["value"] = $value;
1359
+ return $this->callServer("listInterestGroupingUpdate", $params);
1360
+ }
1361
+
1362
+ /** Delete an existing Interest Grouping - this will permanently delete all contained interest groups and will remove those selections from all list members
1363
+ *
1364
+ * @section List Related
1365
+ * @example xml-rpc_listInterestGroupingDel.php
1366
+ *
1367
+ * @param int $grouping_id the interest grouping id - get from listInterestGroupings()
1368
+ * @return bool true if the request succeeds, otherwise an error will be thrown
1369
+ */
1370
+ function listInterestGroupingDel($grouping_id) {
1371
+ $params = array();
1372
+ $params["grouping_id"] = $grouping_id;
1373
+ return $this->callServer("listInterestGroupingDel", $params);
1374
+ }
1375
+
1376
+ /** Return the Webhooks configured for the given list
1377
+ *
1378
+ * @section List Related
1379
+ *
1380
+ * @param string $id the list id to connect to. Get by calling lists()
1381
+ * @return array list of webhooks
1382
+ * @returnf string url the URL for this Webhook
1383
+ * @returnf array actions the possible actions and whether they are enabled
1384
+ * @returnf array sources the possible sources and whether they are enabled
1385
+ */
1386
+ function listWebhooks($id) {
1387
+ $params = array();
1388
+ $params["id"] = $id;
1389
+ return $this->callServer("listWebhooks", $params);
1390
+ }
1391
+
1392
+ /** Add a new Webhook URL for the given list
1393
+ *
1394
+ * @section List Related
1395
+ *
1396
+ * @param string $id the list id to connect to. Get by calling lists()
1397
+ * @param string $url a valid URL for the Webhook - it will be validated. note that a url may only exist on a list once.
1398
+ * @param array $actions optional a hash of actions to fire this Webhook for
1399
+ boolean subscribe optional as subscribes occur, defaults to true
1400
+ boolean unsubscribe optional as subscribes occur, defaults to true
1401
+ boolean profile optional as profile updates occur, defaults to true
1402
+ boolean cleaned optional as emails are cleaned from the list, defaults to true
1403
+ boolean upemail optional when subscribers change their email address, defaults to true
1404
+ * @param array $sources optional a hash of sources to fire this Webhook for
1405
+ boolean user optional user/subscriber initiated actions, defaults to true
1406
+ boolean admin optional admin actions in our web app, defaults to true
1407
+ boolean api optional actions that happen via API calls, defaults to false
1408
+ * @return bool true if the call succeeds, otherwise an exception will be thrown
1409
+ */
1410
+ function listWebhookAdd($id, $url, $actions=array (
1411
+ ), $sources=array (
1412
+ )) {
1413
+ $params = array();
1414
+ $params["id"] = $id;
1415
+ $params["url"] = $url;
1416
+ $params["actions"] = $actions;
1417
+ $params["sources"] = $sources;
1418
+ return $this->callServer("listWebhookAdd", $params);
1419
+ }
1420
+
1421
+ /** Delete an existing Webhook URL from a given list
1422
+ *
1423
+ * @section List Related
1424
+ *
1425
+ * @param string $id the list id to connect to. Get by calling lists()
1426
+ * @param string $url the URL of a Webhook on this list
1427
+ * @return boolean true if the call succeeds, otherwise an exception will be thrown
1428
+ */
1429
+ function listWebhookDel($id, $url) {
1430
+ $params = array();
1431
+ $params["id"] = $id;
1432
+ $params["url"] = $url;
1433
+ return $this->callServer("listWebhookDel", $params);
1434
+ }
1435
+
1436
+ /** Retrieve all of the Static Segments for a list.
1437
+ *
1438
+ * @section List Related
1439
+ *
1440
+ * @param string $id the list id to connect to. Get by calling lists()
1441
+ * @return array an array of parameters for each static segment
1442
+ * @returnf int id the id of the segment
1443
+ * @returnf string name the name for the segment
1444
+ * @returnf int member_count the total number of members currently in a segment
1445
+ * @returnf date created_date the date/time the segment was created
1446
+ * @returnf date last_update the date/time the segment was last updated (add or del)
1447
+ * @returnf date last_reset the date/time the segment was last reset (ie had all members cleared from it)
1448
+ */
1449
+ function listStaticSegments($id) {
1450
+ $params = array();
1451
+ $params["id"] = $id;
1452
+ return $this->callServer("listStaticSegments", $params);
1453
+ }
1454
+
1455
+ /** Save a segment against a list for later use. There is no limit to the number of segments which can be saved. Static Segments <strong>are not</strong> tied
1456
+ * to any merge data, interest groups, etc. They essentially allow you to configure an unlimited number of custom segments which will have standard performance.
1457
+ * When using proper segments, Static Segments are one of the available options for segmentation just as if you used a merge var (and they can be used with other segmentation
1458
+ * options), though performance may degrade at that point.
1459
+ *
1460
+ * @section List Related
1461
+ *
1462
+ * @param string $id the list id to connect to. Get by calling lists()
1463
+ * @param string $name a unique name per list for the segment - 50 byte maximum length, anything longer will throw an error
1464
+ * @return int the id of the new segment, otherwise an error will be thrown.
1465
+ */
1466
+ function listStaticSegmentAdd($id, $name) {
1467
+ $params = array();
1468
+ $params["id"] = $id;
1469
+ $params["name"] = $name;
1470
+ return $this->callServer("listStaticSegmentAdd", $params);
1471
+ }
1472
+
1473
+ /** Resets a static segment - removes <strong>all</strong> members from the static segment. Note: does not actually affect list member data
1474
+ *
1475
+ * @section List Related
1476
+ *
1477
+ * @param string $id the list id to connect to. Get by calling lists()
1478
+ * @param int $seg_id the id of the static segment to reset - get from listStaticSegments()
1479
+ * @return bool true if it worked, otherwise an error is thrown.
1480
+ */
1481
+ function listStaticSegmentReset($id, $seg_id) {
1482
+ $params = array();
1483
+ $params["id"] = $id;
1484
+ $params["seg_id"] = $seg_id;
1485
+ return $this->callServer("listStaticSegmentReset", $params);
1486
+ }
1487
+
1488
+ /** Delete a static segment. Note that this will, of course, remove any member affiliations with the segment
1489
+ *
1490
+ * @section List Related
1491
+ *
1492
+ * @param string $id the list id to connect to. Get by calling lists()
1493
+ * @param int $seg_id the id of the static segment to delete - get from listStaticSegments()
1494
+ * @return bool true if it worked, otherwise an error is thrown.
1495
+ */
1496
+ function listStaticSegmentDel($id, $seg_id) {
1497
+ $params = array();
1498
+ $params["id"] = $id;
1499
+ $params["seg_id"] = $seg_id;
1500
+ return $this->callServer("listStaticSegmentDel", $params);
1501
+ }
1502
+
1503
+ /** Add list members to a static segment. It is suggested that you limit batch size to no more than 10,000 addresses per call. Email addresses must exist on the list
1504
+ * in order to be included - this <strong>will not</strong> subscribe them to the list!
1505
+ *
1506
+ * @section List Related
1507
+ *
1508
+ * @param string $id the list id to connect to. Get by calling lists()
1509
+ * @param int $seg_id the id of the static segment to modify - get from listStaticSegments()
1510
+ * @param array $batch an array of email addresses and/or unique_ids to add to the segment
1511
+ * @return array an array with the results of the operation
1512
+ * @returnf int success the total number of successful updates (will include members already in the segment)
1513
+ * @returnf array errors the email address, an error code, and a message explaining why they couldn't be added
1514
+ */
1515
+ function listStaticSegmentMembersAdd($id, $seg_id, $batch) {
1516
+ $params = array();
1517
+ $params["id"] = $id;
1518
+ $params["seg_id"] = $seg_id;
1519
+ $params["batch"] = $batch;
1520
+ return $this->callServer("listStaticSegmentMembersAdd", $params);
1521
+ }
1522
+
1523
+ /** Remove list members from a static segment. It is suggested that you limit batch size to no more than 10,000 addresses per call. Email addresses must exist on the list
1524
+ * in order to be removed - this <strong>will not</strong> unsubscribe them from the list!
1525
+ *
1526
+ * @section List Related
1527
+ *
1528
+ * @param string $id the list id to connect to. Get by calling lists()
1529
+ * @param int $seg_id the id of the static segment to delete - get from listStaticSegments()
1530
+ * @param array $batch an array of email addresses and/or unique_ids to remove from the segment
1531
+ * @return array an array with the results of the operation
1532
+ * @returnf int success the total number of succesful removals
1533
+ * @returnf array errors the email address, an error code, and a message explaining why they couldn't be removed
1534
+ */
1535
+ function listStaticSegmentMembersDel($id, $seg_id, $batch) {
1536
+ $params = array();
1537
+ $params["id"] = $id;
1538
+ $params["seg_id"] = $seg_id;
1539
+ $params["batch"] = $batch;
1540
+ return $this->callServer("listStaticSegmentMembersDel", $params);
1541
+ }
1542
+
1543
+ /**
1544
+ * Subscribe the provided email to a list. By default this sends a confirmation email - you will not see new members until the link contained in it is clicked!
1545
+ *
1546
+ * @section List Related
1547
+ *
1548
+ * @example mcapi_listSubscribe.php
1549
+ * @example json_listSubscribe.php
1550
+ * @example xml-rpc_listSubscribe.php
1551
+ *
1552
+ * @param string $id the list id to connect to. Get by calling lists()
1553
+ * @param string $email_address the email address to subscribe
1554
+ * @param array $merge_vars optional merges for the email (FNAME, LNAME, etc.) (see examples below for handling "blank" arrays). Note that a merge field can only hold up to 255 bytes. Also, there are a few "special" keys:
1555
+ string EMAIL set this to change the email address. This is only respected on calls using update_existing or when passed to listUpdateMember()
1556
+ array GROUPINGS Set Interest Groups by Grouping. Each element in this array should be an array containing the "groups" parameter which contains a comma delimited list of Interest Groups to add. Commas in Interest Group names should be escaped with a backslash. ie, "," =&gt; "\," and either an "id" or "name" parameter to specify the Grouping - get from listInterestGroupings()
1557
+ string OPTINIP Set the Opt-in IP fields. <em>Abusing this may cause your account to be suspended.</em> We do validate this and it must not be a private IP address.
1558
+ array MC_LOCATION Set the members geographic location. By default if this merge field exists, we'll update using the optin_ip if it exists. If the array contains LATITUDE and LONGITUDE keys, they will be used. NOTE - this will slow down each subscribe call a bit, especially for lat/lng pairs in sparsely populated areas. Currently our automated background processes can and will overwrite this based on opens and clicks.
1559
+
1560
+ <strong>Handling Field Data Types</strong> - most fields you can just pass a string and all is well. For some, though, that is not the case...
1561
+ Field values should be formatted as follows:
1562
+ string address For the string version of an Address, the fields should be delimited by <strong>2</strong> spaces. Address 2 can be skipped. The Country should be a 2 character ISO-3166-1 code and will default to your default country if not set
1563
+ array address For the array version of an Address, the requirements for Address 2 and Country are the same as with the string version. Then simply pass us an array with the keys <strong>addr1</strong>, <strong>addr2</strong>, <strong>city</strong>, <strong>state</strong>, <strong>zip</strong>, <strong>country</strong> and appropriate values for each
1564
+
1565
+ string date use YYYY-MM-DD to be safe. Generally, though, anything strtotime() understands we'll understand - <a href="http://us2.php.net/strtotime" target="_blank">http://us2.php.net/strtotime</a>
1566
+ string dropdown can be a normal string - we <em>will</em> validate that the value is a valid option
1567
+ string image must be a valid, existing url. we <em>will</em> check its existence
1568
+ string multi_choice can be a normal string - we <em>will</em> validate that the value is a valid option
1569
+ double number pass in a valid number - anything else will turn in to zero (0). Note, this will be rounded to 2 decimal places
1570
+ string phone If your account has the US Phone numbers option set, this <em>must</em> be in the form of NPA-NXX-LINE (404-555-1212). If not, we assume an International number and will simply set the field with what ever number is passed in.
1571
+ string website This is a standard string, but we <em>will</em> verify that it looks like a valid URL
1572
+
1573
+ * @param string $email_type optional email type preference for the email (html, text, or mobile defaults to html)
1574
+ * @param bool $double_optin optional flag to control whether a double opt-in confirmation message is sent, defaults to true. <em>Abusing this may cause your account to be suspended.</em>
1575
+ * @param bool $update_existing optional flag to control whether a existing subscribers should be updated instead of throwing and error, defaults to false
1576
+ * @param bool $replace_interests optional flag to determine whether we replace the interest groups with the groups provided, or we add the provided groups to the member's interest groups (optional, defaults to true)
1577
+ * @param bool $send_welcome optional if your double_optin is false and this is true, we will send your lists Welcome Email if this subscribe succeeds - this will *not* fire if we end up updating an existing subscriber. If double_optin is true, this has no effect. defaults to false.
1578
+ * @return boolean true on success, false on failure. When using MCAPI.class.php, the value can be tested and error messages pulled from the MCAPI object (see below)
1579
+ */
1580
+ function listSubscribe($id, $email_address, $merge_vars=NULL, $email_type='html', $double_optin=true, $update_existing=false, $replace_interests=true, $send_welcome=false) {
1581
+ $params = array();
1582
+ $params["id"] = $id;
1583
+ $params["email_address"] = $email_address;
1584
+ $params["merge_vars"] = $merge_vars;
1585
+ $params["email_type"] = $email_type;
1586
+ $params["double_optin"] = $double_optin;
1587
+ $params["update_existing"] = $update_existing;
1588
+ $params["replace_interests"] = $replace_interests;
1589
+ $params["send_welcome"] = $send_welcome;
1590
+ return $this->callServer("listSubscribe", $params);
1591
+ }
1592
+
1593
+ /**
1594
+ * Unsubscribe the given email address from the list
1595
+ *
1596
+ * @section List Related
1597
+ * @example mcapi_listUnsubscribe.php
1598
+ * @example xml-rpc_listUnsubscribe.php
1599
+ *
1600
+ * @param string $id the list id to connect to. Get by calling lists()
1601
+ * @param string $email_address the email address to unsubscribe OR the email "id" returned from listMemberInfo, Webhooks, and Campaigns
1602
+ * @param boolean $delete_member flag to completely delete the member from your list instead of just unsubscribing, default to false
1603
+ * @param boolean $send_goodbye flag to send the goodbye email to the email address, defaults to true
1604
+ * @param boolean $send_notify flag to send the unsubscribe notification email to the address defined in the list email notification settings, defaults to true
1605
+ * @return boolean true on success, false on failure. When using MCAPI.class.php, the value can be tested and error messages pulled from the MCAPI object (see below)
1606
+ */
1607
+ function listUnsubscribe($id, $email_address, $delete_member=false, $send_goodbye=true, $send_notify=true) {
1608
+ $params = array();
1609
+ $params["id"] = $id;
1610
+ $params["email_address"] = $email_address;
1611
+ $params["delete_member"] = $delete_member;
1612
+ $params["send_goodbye"] = $send_goodbye;
1613
+ $params["send_notify"] = $send_notify;
1614
+ return $this->callServer("listUnsubscribe", $params);
1615
+ }
1616
+
1617
+ /**
1618
+ * Edit the email address, merge fields, and interest groups for a list member. If you are doing a batch update on lots of users,
1619
+ * consider using listBatchSubscribe() with the update_existing and possible replace_interests parameter.
1620
+ *
1621
+ * @section List Related
1622
+ * @example mcapi_listUpdateMember.php
1623
+ *
1624
+ * @param string $id the list id to connect to. Get by calling lists()
1625
+ * @param string $email_address the current email address of the member to update OR the "id" for the member returned from listMemberInfo, Webhooks, and Campaigns
1626
+ * @param array $merge_vars array of new field values to update the member with. See merge_vars in listSubscribe() for details.
1627
+ * @param string $email_type change the email type preference for the member ("html", "text", or "mobile"). Leave blank to keep the existing preference (optional)
1628
+ * @param boolean $replace_interests flag to determine whether we replace the interest groups with the updated groups provided, or we add the provided groups to the member's interest groups (optional, defaults to true)
1629
+ * @return boolean true on success, false on failure. When using MCAPI.class.php, the value can be tested and error messages pulled from the MCAPI object
1630
+ */
1631
+ function listUpdateMember($id, $email_address, $merge_vars, $email_type='', $replace_interests=true) {
1632
+ $params = array();
1633
+ $params["id"] = $id;
1634
+ $params["email_address"] = $email_address;
1635
+ $params["merge_vars"] = $merge_vars;
1636
+ $params["email_type"] = $email_type;
1637
+ $params["replace_interests"] = $replace_interests;
1638
+ return $this->callServer("listUpdateMember", $params);
1639
+ }
1640
+
1641
+ /**
1642
+ * Subscribe a batch of email addresses to a list at once. If you are using a serialized version of the API, we strongly suggest that you
1643
+ * only run this method as a POST request, and <em>not</em> a GET request. Maximum batch sizes vary based on the amount of data in each record,
1644
+ * though you should cap them at 5k - 10k records, depending on your experience. These calls are also long, so be sure you increase your timeout values.
1645
+ *
1646
+ * @section List Related
1647
+ *
1648
+ * @example mcapi_listBatchSubscribe.php
1649
+ * @example xml-rpc_listBatchSubscribe.php
1650
+ *
1651
+ * @param string $id the list id to connect to. Get by calling lists()
1652
+ * @param array $batch an array of structs for each address to import with two special keys: "EMAIL" for the email address, and "EMAIL_TYPE" for the email type option (html, text, or mobile)
1653
+ * @param boolean $double_optin flag to control whether to send an opt-in confirmation email - defaults to true
1654
+ * @param boolean $update_existing flag to control whether to update members that are already subscribed to the list or to return an error, defaults to false (return error)
1655
+ * @param boolean $replace_interests flag to determine whether we replace the interest groups with the updated groups provided, or we add the provided groups to the member's interest groups (optional, defaults to true)
1656
+ * @return struct Array of result counts and any errors that occurred
1657
+ * @returnf int add_count Number of email addresses that were succesfully added
1658
+ * @returnf int update_count Number of email addresses that were succesfully updated
1659
+ * @returnf int error_count Number of email addresses that failed during addition/updating
1660
+ * @returnf array errors Array of error arrays, each containing:
1661
+ string code the error code
1662
+ string message the full error message
1663
+ string email the email address being processed
1664
+ */
1665
+ function listBatchSubscribe($id, $batch, $double_optin=true, $update_existing=false, $replace_interests=true) {
1666
+ $params = array();
1667
+ $params["id"] = $id;
1668
+ $params["batch"] = $batch;
1669
+ $params["double_optin"] = $double_optin;
1670
+ $params["update_existing"] = $update_existing;
1671
+ $params["replace_interests"] = $replace_interests;
1672
+ return $this->callServer("listBatchSubscribe", $params);
1673
+ }
1674
+
1675
+ /**
1676
+ * Unsubscribe a batch of email addresses to a list
1677
+ *
1678
+ * @section List Related
1679
+ * @example mcapi_listBatchUnsubscribe.php
1680
+ *
1681
+ * @param string $id the list id to connect to. Get by calling lists()
1682
+ * @param array $emails array of email addresses to unsubscribe
1683
+ * @param boolean $delete_member flag to completely delete the member from your list instead of just unsubscribing, default to false
1684
+ * @param boolean $send_goodbye flag to send the goodbye email to the email addresses, defaults to true
1685
+ * @param boolean $send_notify flag to send the unsubscribe notification email to the address defined in the list email notification settings, defaults to false
1686
+ * @return struct Array of result counts and any errors that occurred
1687
+ * @returnf int success_count Number of email addresses that were succesfully added/updated
1688
+ * @returnf int error_count Number of email addresses that failed during addition/updating
1689
+ * @returnf array errors Array of error structs. Each error struct will contain "code", "message", and "email"
1690
+ */
1691
+ function listBatchUnsubscribe($id, $emails, $delete_member=false, $send_goodbye=true, $send_notify=false) {
1692
+ $params = array();
1693
+ $params["id"] = $id;
1694
+ $params["emails"] = $emails;
1695
+ $params["delete_member"] = $delete_member;
1696
+ $params["send_goodbye"] = $send_goodbye;
1697
+ $params["send_notify"] = $send_notify;
1698
+ return $this->callServer("listBatchUnsubscribe", $params);
1699
+ }
1700
+
1701
+ /**
1702
+ * Get all of the list members for a list that are of a particular status. Are you trying to get a dump including lots of merge
1703
+ * data or specific members of a list? If so, checkout the <a href="/api/export">Export API</a>
1704
+ *
1705
+ * @section List Related
1706
+ * @example mcapi_listMembers.php
1707
+ *
1708
+ * @param string $id the list id to connect to. Get by calling lists()
1709
+ * @param string $status the status to get members for - one of(subscribed, unsubscribed, <a target="_blank" href="http://eepurl.com/dwk1">cleaned</a>, updated), defaults to subscribed
1710
+ * @param string $since optional pull all members whose status (subscribed/unsubscribed/cleaned) has changed or whose profile (updated) has changed since this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr)
1711
+ * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
1712
+ * @param int $limit optional for large data sets, the number of results to return - defaults to 100, upper limit set at 15000
1713
+ * @return array Array of a the total records match and matching list member data for this page (see Returned Fields for details)
1714
+ * @returnf int total the total matching records
1715
+ * @returnf array data the data for each member, including:
1716
+ string email Member email address
1717
+ date timestamp timestamp of their associated status date (subscribed, unsubscribed, cleaned, or updated) in GMT
1718
+ string reason For unsubscribes only - the reason collected for the unsubscribe. If populated, one of 'NORMAL','NOSIGNUP','INAPPROPRIATE','SPAM','OTHER'
1719
+ string reason_text For unsubscribes only - if the reason is OTHER, the text entered.
1720
+ */
1721
+ function listMembers($id, $status='subscribed', $since=NULL, $start=0, $limit=100) {
1722
+ $params = array();
1723
+ $params["id"] = $id;
1724
+ $params["status"] = $status;
1725
+ $params["since"] = $since;
1726
+ $params["start"] = $start;
1727
+ $params["limit"] = $limit;
1728
+ return $this->callServer("listMembers", $params);
1729
+ }
1730
+
1731
+ /**
1732
+ * Get all the information for particular members of a list
1733
+ *
1734
+ * @section List Related
1735
+ * @example mcapi_listMemberInfo.php
1736
+ * @example xml-rpc_listMemberInfo.php
1737
+ *
1738
+ * @param string $id the list id to connect to. Get by calling lists()
1739
+ * @param array $email_address an array of up to 50 email addresses to get information for OR the "id"(s) for the member returned from listMembers, Webhooks, and Campaigns. For backwards compatibility, if a string is passed, it will be treated as an array with a single element (will not work with XML-RPC).
1740
+ * @return array array of list members with their info in an array (see Returned Fields for details)
1741
+ * @returnf int success the number of subscribers successfully found on the list
1742
+ * @returnf int errors the number of subscribers who were not found on the list
1743
+ * @returnf array data an array of arrays where each one has member info:
1744
+ string id The unique id for this email address on an account
1745
+ string email The email address associated with this record
1746
+ string email_type The type of emails this customer asked to get: html, text, or mobile
1747
+ array merges An associative array of all the merge tags and the data for those tags for this email address. <em>Note</em>: Interest Groups are returned as comma delimited strings - if a group name contains a comma, it will be escaped with a backslash. ie, "," =&gt; "\,". Groupings will be returned with their "id" and "name" as well as a "groups" field formatted just like Interest Groups
1748
+ string status The subscription status for this email address, either pending, subscribed, unsubscribed, or cleaned
1749
+ string ip_opt IP Address this address opted in from.
1750
+ string ip_signup IP Address this address signed up from.
1751
+ int member_rating the rating of the subscriber. This will be 1 - 5 as described <a href="http://eepurl.com/f-2P" target="_blank">here</a>
1752
+ string campaign_id If the user is unsubscribed and they unsubscribed from a specific campaign, that campaign_id will be listed, otherwise this is not returned.
1753
+ array lists An associative array of the other lists this member belongs to - the key is the list id and the value is their status in that list.
1754
+ date timestamp The time this email address was added to the list
1755
+ date info_changed The last time this record was changed. If the record is old enough, this may be blank.
1756
+ int web_id The Member id used in our web app, allows you to create a link directly to it
1757
+ array clients the various clients we've tracked the address as using - each included array includes client 'name' and 'icon_url'
1758
+ array static_segments the 'id', 'name', and date 'added' for any static segment this member is in
1759
+ */
1760
+ function listMemberInfo($id, $email_address) {
1761
+ $params = array();
1762
+ $params["id"] = $id;
1763
+ $params["email_address"] = $email_address;
1764
+ return $this->callServer("listMemberInfo", $params);
1765
+ }
1766
+
1767
+ /**
1768
+ * Get the most recent 100 activities for particular list members (open, click, bounce, unsub, abuse, sent to)
1769
+ *
1770
+ * @section List Related
1771
+ * @example mcapi_listMemberInfo.php
1772
+ * @example xml-rpc_listMemberInfo.php
1773
+ *
1774
+ * @param string $id the list id to connect to. Get by calling lists()
1775
+ * @param array $email_address an array of up to 50 email addresses to get information for OR the "id"(s) for the member returned from listMembers, Webhooks, and Campaigns.
1776
+ * @return array array of data and success/error counts
1777
+ * @returnf int success the number of subscribers successfully found on the list
1778
+ * @returnf int errors the number of subscribers who were not found on the list
1779
+ * @returnf array data an array of arrays where each activity record has:
1780
+ string action The action name, one of: open, click, bounce, unsub, abuse, sent
1781
+ string timestamp The date/time of the action
1782
+ string url For click actions, the url clicked, otherwise this is empty
1783
+ string bounce_type For bounce actions, the bounce type, otherwise this is empty
1784
+ string campaign_id The campaign id the action was related to, if it exists - otherwise empty (ie, direct unsub from list)
1785
+ */
1786
+ function listMemberActivity($id, $email_address) {
1787
+ $params = array();
1788
+ $params["id"] = $id;
1789
+ $params["email_address"] = $email_address;
1790
+ return $this->callServer("listMemberActivity", $params);
1791
+ }
1792
+
1793
+ /**
1794
+ * Get all email addresses that complained about a given campaign
1795
+ *
1796
+ * @section List Related
1797
+ *
1798
+ * @example mcapi_listAbuseReports.php
1799
+ *
1800
+ * @param string $id the list id to pull abuse reports for (can be gathered using lists())
1801
+ * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
1802
+ * @param int $limit optional for large data sets, the number of results to return - defaults to 500, upper limit set at 1000
1803
+ * @param string $since optional pull only messages since this time - use YYYY-MM-DD HH:II:SS format in <strong>GMT</strong>
1804
+ * @return array the total of all reports and the specific reports reports this page
1805
+ * @returnf int total the total number of matching abuse reports
1806
+ * @returnf array data the actual data for each reports, including:
1807
+ string date date/time the abuse report was received and processed
1808
+ string email the email address that reported abuse
1809
+ string campaign_id the unique id for the campaign that report was made against
1810
+ string type an internal type generally specifying the orginating mail provider - may not be useful outside of filling report views
1811
+ */
1812
+ function listAbuseReports($id, $start=0, $limit=500, $since=NULL) {
1813
+ $params = array();
1814
+ $params["id"] = $id;
1815
+ $params["start"] = $start;
1816
+ $params["limit"] = $limit;
1817
+ $params["since"] = $since;
1818
+ return $this->callServer("listAbuseReports", $params);
1819
+ }
1820
+
1821
+ /**
1822
+ * Access the Growth History by Month for a given list.
1823
+ *
1824
+ * @section List Related
1825
+ *
1826
+ * @example mcapi_listGrowthHistory.php
1827
+ *
1828
+ * @param string $id the list id to connect to. Get by calling lists()
1829
+ * @return array array of months and growth
1830
+ * @returnf string month The Year and Month in question using YYYY-MM format
1831
+ * @returnf int existing number of existing subscribers to start the month
1832
+ * @returnf int imports number of subscribers imported during the month
1833
+ * @returnf int optins number of subscribers who opted-in during the month
1834
+ */
1835
+ function listGrowthHistory($id) {
1836
+ $params = array();
1837
+ $params["id"] = $id;
1838
+ return $this->callServer("listGrowthHistory", $params);
1839
+ }
1840
+
1841
+ /**
1842
+ * Access up to the previous 180 days of daily detailed aggregated activity stats for a given list
1843
+ *
1844
+ * @section List Related
1845
+ *
1846
+ *
1847
+ * @param string $id the list id to connect to. Get by calling lists()
1848
+ * @return array array of array of daily values, each containing:
1849
+ * @returnf string day The day in YYYY-MM-DD
1850
+ * @returnf int emails_sent number of emails sent to the list
1851
+ * @returnf int unique_opens number of unique opens for the list
1852
+ * @returnf int recipient_clicks number of clicks for the list
1853
+ * @returnf int hard_bounce number of hard bounces for the list
1854
+ * @returnf int soft_bounce number of soft bounces for the list
1855
+ * @returnf int abuse_reports number of abuse reports for the list
1856
+ * @returnf int subs number of double optin subscribes for the list
1857
+ * @returnf int unsubs number of manual unsubscribes for the list
1858
+ * @returnf int other_adds number of non-double optin subscribes for the list (manual, API, or import)
1859
+ * @returnf int other_removes number of non-manual unsubscribes for the list (deletions, empties, soft-bounce removals)
1860
+ */
1861
+ function listActivity($id) {
1862
+ $params = array();
1863
+ $params["id"] = $id;
1864
+ return $this->callServer("listActivity", $params);
1865
+ }
1866
+
1867
+ /**
1868
+ * Retrieve the locations (countries) that the list's subscribers have been tagged to based on geocoding their IP address
1869
+ *
1870
+ * @section List Related
1871
+ *
1872
+ * @param string $id the list id to connect to. Get by calling lists()
1873
+ * @return array array of locations
1874
+ * @returnf string country the country name
1875
+ * @returnf string cc the 2 digit country code
1876
+ * @returnf double percent the percent of subscribers in the country
1877
+ * @returnf double total the total number of subscribers in the country
1878
+ */
1879
+ function listLocations($id) {
1880
+ $params = array();
1881
+ $params["id"] = $id;
1882
+ return $this->callServer("listLocations", $params);
1883
+ }
1884
+
1885
+ /**
1886
+ * Retrieve the clients that the list's subscribers have been tagged as being used based on user agents seen. Made possible by <a href="http://user-agent-string.info" target="_blank">user-agent-string.info</a>
1887
+ *
1888
+ * @section List Related
1889
+ *
1890
+ * @param string $id the list id to connect to. Get by calling lists()
1891
+ * @return array the desktop and mobile user agents in use on the list
1892
+ * @returnf array desktop desktop user agents and percentages
1893
+ double penetration the percent of desktop clients in use
1894
+ array clients a record containing the 'client', an 'icon' image url, the 'percent' using the client, and the total 'members' represented
1895
+ * @returnf array mobile mobile user agents and percentages
1896
+ double penetration the percent of mobile clients in use
1897
+ array clients a record containing the 'client', an 'icon' image url, the 'percent' using the client, and the total 'members' represented
1898
+ */
1899
+ function listClients($id) {
1900
+ $params = array();
1901
+ $params["id"] = $id;
1902
+ return $this->callServer("listClients", $params);
1903
+ }
1904
+
1905
+ /**
1906
+ * Retrieve various templates available in the system, allowing some thing similar to our template gallery to be created.
1907
+ *
1908
+ * @section Template Related
1909
+ * @example mcapi_templates.php
1910
+ * @example xml-rpc_templates.php
1911
+ *
1912
+ * @param array $types optional the types of templates to return
1913
+ boolean user Customer template for this user account. Defaults to true.
1914
+ boolean gallery Templates from our Gallery. Note that some templates that require extra configuration are withheld. (eg, the Etsy template). Defaults to false.
1915
+ boolean base Our "start from scratch" extremely basic templates
1916
+ * @param string $category optional for Gallery templates only, limit to a specific template category
1917
+ * @param array $inactives optional options to control how inactive templates are returned, if at all
1918
+ boolean include user templates are not deleted, only set inactive. defaults to false.
1919
+ boolean only only include inactive templates. defaults to false.
1920
+ * @return array An array of structs, one for each template (see Returned Fields for details)
1921
+ * @returnf int id Id of the template
1922
+ * @returnf string name Name of the template
1923
+ * @returnf string layout Layout of the template - "basic", "left_column", "right_column", or "postcard"
1924
+ * @returnf string preview_image If we've generated it, the url of the preview image for the template. We do out best to keep these up to date, but Preview image urls are not guaranteed to be available
1925
+ * @returnf string date_created The date/time the template was created
1926
+ * @returnf bool edit_source Whether or not you are able to edit the source of a template.
1927
+ */
1928
+ function templates($types=array (
1929
+ ), $category=NULL, $inactives=array (
1930
+ )) {
1931
+ $params = array();
1932
+ $params["types"] = $types;
1933
+ $params["category"] = $category;
1934
+ $params["inactives"] = $inactives;
1935
+ return $this->callServer("templates", $params);
1936
+ }
1937
+
1938
+ /**
1939
+ * Pull details for a specific template to help support editing
1940
+ *
1941
+ * @section Template Related
1942
+ *
1943
+ * @param int $tid the template id - get from templates()
1944
+ * @param string $type the template type to load - one of 'user', 'gallery', 'base'
1945
+ * @return array an array of info to be used when editing
1946
+ * @returnf array default_content the default content broken down into the named editable sections for the template
1947
+ * @returnf array sections the valid editable section names
1948
+ * @returnf string source the full source of the template as if you exported it via our template editor
1949
+ * @returnf string preview similar to the source, but the rendered version of the source from our popup preview
1950
+ */
1951
+ function templateInfo($tid, $type='user') {
1952
+ $params = array();
1953
+ $params["tid"] = $tid;
1954
+ $params["type"] = $type;
1955
+ return $this->callServer("templateInfo", $params);
1956
+ }
1957
+
1958
+ /**
1959
+ * Create a new user template, <strong>NOT</strong> campaign content. These templates can then be applied while creating campaigns.
1960
+ *
1961
+ * @section Template Related
1962
+ * @example mcapi_create_template.php
1963
+ * @example xml-rpc_create_template.php
1964
+ *
1965
+ * @param string $name the name for the template - names must be unique and a max of 50 bytes
1966
+ * @param string $html a string specifying the entire template to be created. This is <strong>NOT</strong> campaign content. They are intended to utilize our <a href="http://www.mailchimp.com/resources/email-template-language/" target="_blank">template language</a>.
1967
+ * @return int the new template id, otherwise an error is thrown.
1968
+ */
1969
+ function templateAdd($name, $html) {
1970
+ $params = array();
1971
+ $params["name"] = $name;
1972
+ $params["html"] = $html;
1973
+ return $this->callServer("templateAdd", $params);
1974
+ }
1975
+
1976
+ /**
1977
+ * Replace the content of a user template, <strong>NOT</strong> campaign content.
1978
+ *
1979
+ * @section Template Related
1980
+ *
1981
+ * @param int $id the id of the user template to update
1982
+ * @param array $values the values to updates - while both are optional, at least one should be provided. Both can be updated at the same time.
1983
+ string name optional the name for the template - names must be unique and a max of 50 bytes
1984
+ string html optional a string specifying the entire template to be created. This is <strong>NOT</strong> campaign content. They are intended to utilize our <a href="http://www.mailchimp.com/resources/email-template-language/" target="_blank">template language</a>.
1985
+
1986
+ * @return boolean true if the template was updated, otherwise an error will be thrown
1987
+ */
1988
+ function templateUpdate($id, $values) {
1989
+ $params = array();
1990
+ $params["id"] = $id;
1991
+ $params["values"] = $values;
1992
+ return $this->callServer("templateUpdate", $params);
1993
+ }
1994
+
1995
+ /**
1996
+ * Delete (deactivate) a user template
1997
+ *
1998
+ * @section Template Related
1999
+ *
2000
+ * @param int $id the id of the user template to delete
2001
+ * @return boolean true if the template was deleted, otherwise an error will be thrown
2002
+ */
2003
+ function templateDel($id) {
2004
+ $params = array();
2005
+ $params["id"] = $id;
2006
+ return $this->callServer("templateDel", $params);
2007
+ }
2008
+
2009
+ /**
2010
+ * Undelete (reactivate) a user template
2011
+ *
2012
+ * @section Template Related
2013
+ *
2014
+ * @param int $id the id of the user template to reactivate
2015
+ * @return boolean true if the template was deleted, otherwise an error will be thrown
2016
+ */
2017
+ function templateUndel($id) {
2018
+ $params = array();
2019
+ $params["id"] = $id;
2020
+ return $this->callServer("templateUndel", $params);
2021
+ }
2022
+
2023
+ /**
2024
+ * Retrieve lots of account information including payments made, plan info, some account stats, installed modules,
2025
+ * contact info, and more. No private information like Credit Card numbers is available.
2026
+ *
2027
+ * @section Helper
2028
+ *
2029
+ * @return array containing the details for the account tied to this API Key
2030
+ * @returnf string username The Account username
2031
+ * @returnf string user_id The Account user unique id (for building some links)
2032
+ * @returnf bool is_trial Whether the Account is in Trial mode (can only send campaigns to less than 100 emails)
2033
+ * @returnf string timezone The timezone for the Account - default is "US/Eastern"
2034
+ * @returnf string plan_type Plan Type - "monthly", "payasyougo", or "free"
2035
+ * @returnf int plan_low <em>only for Monthly plans</em> - the lower tier for list size
2036
+ * @returnf int plan_high <em>only for Monthly plans</em> - the upper tier for list size
2037
+ * @returnf string plan_start_date <em>only for Monthly plans</em> - the start date for a monthly plan
2038
+ * @returnf int emails_left <em>only for Free and Pay-as-you-go plans</em> emails credits left for the account
2039
+ * @returnf bool pending_monthly Whether the account is finishing Pay As You Go credits before switching to a Monthly plan
2040
+ * @returnf string first_payment date of first payment
2041
+ * @returnf string last_payment date of most recent payment
2042
+ * @returnf int times_logged_in total number of times the account has been logged into via the web
2043
+ * @returnf string last_login date/time of last login via the web
2044
+ * @returnf string affiliate_link Monkey Rewards link for our Affiliate program
2045
+ * @returnf array contact Contact details for the account
2046
+ string fname First Name
2047
+ string lname Last Name
2048
+ string email Email Address
2049
+ string company Company Name
2050
+ string address1 Address Line 1
2051
+ string address2 Address Line 2
2052
+ string city City
2053
+ string state State or Province
2054
+ string zip Zip or Postal Code
2055
+ string country Country name
2056
+ string url Website URL
2057
+ string phone Phone number
2058
+ string fax Fax number
2059
+ * @returnf array modules Addons installed in the account
2060
+ string name The module name
2061
+ string added The date the module was added
2062
+ * @returnf array orders Order details for the account
2063
+ int order_id The order id
2064
+ string type The order type - either "monthly" or "credits"
2065
+ double amount The order amount
2066
+ string date The order date
2067
+ double credits_used The total credits used
2068
+ * @returnf array rewards Rewards details for the account including credits & inspections earned, number of referals, referal details, and rewards used
2069
+ int referrals_this_month the total number of referrals this month
2070
+ string notify_on whether or not we notify the user when rewards are earned
2071
+ string notify_email the email address address used for rewards notifications
2072
+ array credits Email credits earned "this_month", "total_earned", and "remaining"
2073
+ array inspections Inbox Inspections earned "this_month", "total_earned", and "remaining"
2074
+ array referrals All referrals, including "name", "email", "signup_date", and "type"
2075
+ array applied Applied rewards, including "value", "date", "order_id", and "order_desc"
2076
+ */
2077
+ function getAccountDetails() {
2078
+ $params = array();
2079
+ return $this->callServer("getAccountDetails", $params);
2080
+ }
2081
+
2082
+ /**
2083
+ * Have HTML content auto-converted to a text-only format. You can send: plain HTML, an array of Template content, an existing Campaign Id, or an existing Template Id. Note that this will <b>not</b> save anything to or update any of your lists, campaigns, or templates.
2084
+ *
2085
+ * @section Helper
2086
+ * @example xml-rpc_generateText.php
2087
+ *
2088
+ * @param string $type The type of content to parse. Must be one of: "html", "template", "url", "cid" (Campaign Id), or "tid" (Template Id)
2089
+ * @param mixed $content The content to use. For "html" expects a single string value, "template" expects an array like you send to campaignCreate, "url" expects a valid & public URL to pull from, "cid" expects a valid Campaign Id, and "tid" expects a valid Template Id on your account.
2090
+ * @return string the content pass in converted to text.
2091
+ */
2092
+ function generateText($type, $content) {
2093
+ $params = array();
2094
+ $params["type"] = $type;
2095
+ $params["content"] = $content;
2096
+ return $this->callServer("generateText", $params);
2097
+ }
2098
+
2099
+ /**
2100
+ * Send your HTML content to have the CSS inlined and optionally remove the original styles.
2101
+ *
2102
+ * @section Helper
2103
+ * @example xml-rpc_inlineCss.php
2104
+ *
2105
+ * @param string $html Your HTML content
2106
+ * @param bool $strip_css optional Whether you want the CSS &lt;style&gt; tags stripped from the returned document. Defaults to false.
2107
+ * @return string Your HTML content with all CSS inlined, just like if we sent it.
2108
+ */
2109
+ function inlineCss($html, $strip_css=false) {
2110
+ $params = array();
2111
+ $params["html"] = $html;
2112
+ $params["strip_css"] = $strip_css;
2113
+ return $this->callServer("inlineCss", $params);
2114
+ }
2115
+
2116
+ /**
2117
+ * List all the folders for a user account
2118
+ *
2119
+ * @section Folder Related
2120
+ * @example mcapi_folders.php
2121
+ * @example xml-rpc_folders.php
2122
+ *
2123
+ * @param string $type optional the type of folders to return - either "campaign" or "autoresponder". Defaults to "campaign"
2124
+ * @return array Array of folder structs (see Returned Fields for details)
2125
+ * @returnf int folder_id Folder Id for the given folder, this can be used in the campaigns() function to filter on.
2126
+ * @returnf string name Name of the given folder
2127
+ * @returnf string date_created The date/time the folder was created
2128
+ * @returnf string type The type of the folders being returned, just to make sure you know.
2129
+ */
2130
+ function folders($type='campaign') {
2131
+ $params = array();
2132
+ $params["type"] = $type;
2133
+ return $this->callServer("folders", $params);
2134
+ }
2135
+
2136
+ /**
2137
+ * Add a new folder to file campaigns or autoresponders in
2138
+ *
2139
+ * @section Folder Related
2140
+ * @example mcapi_folderAdd.php
2141
+ * @example xml-rpc_folderAdd.php
2142
+ *
2143
+ * @param string $name a unique name for a folder (max 100 bytes)
2144
+ * @param string $type optional the type of folder to create - either "campaign" or "autoresponder". Defaults to "campaign"
2145
+ * @return int the folder_id of the newly created folder.
2146
+ */
2147
+ function folderAdd($name, $type='campaign') {
2148
+ $params = array();
2149
+ $params["name"] = $name;
2150
+ $params["type"] = $type;
2151
+ return $this->callServer("folderAdd", $params);
2152
+ }
2153
+
2154
+ /**
2155
+ * Update the name of a folder for campaigns or autoresponders
2156
+ *
2157
+ * @section Folder Related
2158
+ *
2159
+ * @param int $fid the folder id to update - retrieve from folders()
2160
+ * @param string $name a new, unique name for the folder (max 100 bytes)
2161
+ * @param string $type optional the type of folder to create - either "campaign" or "autoresponder". Defaults to "campaign"
2162
+ * @return bool true if the update worked, otherwise an exception is thrown
2163
+ */
2164
+ function folderUpdate($fid, $name, $type='campaign') {
2165
+ $params = array();
2166
+ $params["fid"] = $fid;
2167
+ $params["name"] = $name;
2168
+ $params["type"] = $type;
2169
+ return $this->callServer("folderUpdate", $params);
2170
+ }
2171
+
2172
+ /**
2173
+ * Delete a campaign or autoresponder folder. Note that this will simply make campaigns in the folder appear unfiled, they are not removed.
2174
+ *
2175
+ * @section Folder Related
2176
+ *
2177
+ * @param int $fid the folder id to update - retrieve from folders()
2178
+ * @param string $type optional the type of folder to create - either "campaign" or "autoresponder". Defaults to "campaign"
2179
+ * @return bool true if the delete worked, otherwise an exception is thrown
2180
+ */
2181
+ function folderDel($fid, $type='campaign') {
2182
+ $params = array();
2183
+ $params["fid"] = $fid;
2184
+ $params["type"] = $type;
2185
+ return $this->callServer("folderDel", $params);
2186
+ }
2187
+
2188
+ /**
2189
+ * Retrieve the Ecommerce Orders for an account
2190
+ *
2191
+ * @section Ecommerce
2192
+ *
2193
+ * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
2194
+ * @param int $limit optional for large data sets, the number of results to return - defaults to 100, upper limit set at 500
2195
+ * @param string $since optional pull only messages since this time - use YYYY-MM-DD HH:II:SS format in <strong>GMT</strong>
2196
+ * @return array the total matching orders and the specific orders for the requested page
2197
+ * @returnf int total the total matching orders
2198
+ * @returnf array data the actual data for each order being returned
2199
+ string store_id the store id generated by the plugin used to uniquely identify a store
2200
+ string store_name the store name collected by the plugin - often the domain name
2201
+ string order_id the internal order id the store tracked this order by
2202
+ string email the email address that received this campaign and is associated with this order
2203
+ double order_total the order total
2204
+ double tax_total the total tax for the order (if collected)
2205
+ double ship_total the shipping total for the order (if collected)
2206
+ string order_date the date the order was tracked - from the store if possible, otherwise the GMT time we recieved it
2207
+ array lines containing detail of the order - product, category, quantity, item cost
2208
+ */
2209
+ function ecommOrders($start=0, $limit=100, $since=NULL) {
2210
+ $params = array();
2211
+ $params["start"] = $start;
2212
+ $params["limit"] = $limit;
2213
+ $params["since"] = $since;
2214
+ return $this->callServer("ecommOrders", $params);
2215
+ }
2216
+
2217
+ /**
2218
+ * Import Ecommerce Order Information to be used for Segmentation. This will generally be used by ecommerce package plugins
2219
+ * <a href="/plugins/ecomm360.phtml">that we provide</a> or by 3rd part system developers.
2220
+ * @section Ecommerce
2221
+ *
2222
+ * @param array $order an array of information pertaining to the order that has completed. Use the following keys:
2223
+ string id the Order Id
2224
+ string email_id optional (kind of) the Email Id of the subscriber we should attach this order to (see the "mc_eid" query string variable a campaign passes) - either this or <strong>email</strong> is required. If both are provided, email_id takes precedence
2225
+ string email optional (kind of) the Email Address we should attach this order to - either this or <strong>email_id</strong> is required. If both are provided, email_id takes precedence
2226
+ double total The Order Total (ie, the full amount the customer ends up paying)
2227
+ string order_date optional the date of the order - if this is not provided, we will default the date to now
2228
+ double shipping optional the total paid for Shipping Fees
2229
+ double tax optional the total tax paid
2230
+ string store_id a unique id for the store sending the order in (20 bytes max)
2231
+ string store_name optional a "nice" name for the store - typically the base web address (ie, "store.mailchimp.com"). We will automatically update this if it changes (based on store_id)
2232
+ string plugin_id the MailChimp assigned Plugin Id. Get yours by <a href="/api/register.php">registering here</a>
2233
+ string campaign_id optional the Campaign Id to track this order with (see the "mc_cid" query string variable a campaign passes)
2234
+ array items the individual line items for an order using these keys:
2235
+ <div style="padding-left:30px"><table><tr><td colspan=*>
2236
+ int line_num optional the line number of the item on the order. We will generate these if they are not passed
2237
+ int product_id the store's internal Id for the product. Lines that do no contain this will be skipped
2238
+ string product_name the product name for the product_id associated with this item. We will auto update these as they change (based on product_id)
2239
+ int category_id the store's internal Id for the (main) category associated with this product. Our testing has found this to be a "best guess" scenario
2240
+ string category_name the category name for the category_id this product is in. Our testing has found this to be a "best guess" scenario. Our plugins walk the category heirarchy up and send "Root - SubCat1 - SubCat4", etc.
2241
+ double qty the quantity of the item ordered
2242
+ double cost the cost of a single item (ie, not the extended cost of the line)
2243
+ </td></tr></table></div>
2244
+ * @return bool true if the data is saved, otherwise an error is thrown.
2245
+ */
2246
+ function ecommOrderAdd($order) {
2247
+ $params = array();
2248
+ $params["order"] = $order;
2249
+ return $this->callServer("ecommOrderAdd", $params);
2250
+ }
2251
+
2252
+ /**
2253
+ * Delete Ecommerce Order Information used for segmentation. This will generally be used by ecommerce package plugins
2254
+ * <a href="/plugins/ecomm360.phtml">that we provide</a> or by 3rd part system developers.
2255
+ * @section Ecommerce
2256
+ *
2257
+ * @param string $store_id the store id the order belongs to
2258
+ * @param string $order_id the order id (generated by the store) to delete
2259
+ * @return bool true if an order is deleted, otherwise an error is thrown.
2260
+ */
2261
+ function ecommOrderDel($store_id, $order_id) {
2262
+ $params = array();
2263
+ $params["store_id"] = $store_id;
2264
+ $params["order_id"] = $order_id;
2265
+ return $this->callServer("ecommOrderDel", $params);
2266
+ }
2267
+
2268
+ /**
2269
+ * Retrieve all List Ids a member is subscribed to.
2270
+ *
2271
+ * @section Helper
2272
+ *
2273
+ * @param string $email_address the email address to check OR the email "id" returned from listMemberInfo, Webhooks, and Campaigns
2274
+ * @return array An array of list_ids the member is subscribed to.
2275
+ */
2276
+ function listsForEmail($email_address) {
2277
+ $params = array();
2278
+ $params["email_address"] = $email_address;
2279
+ return $this->callServer("listsForEmail", $params);
2280
+ }
2281
+
2282
+ /**
2283
+ * Retrieve all Campaigns Ids a member was sent
2284
+ *
2285
+ * @section Helper
2286
+ *
2287
+ * @param string $email_address the email address to unsubscribe OR the email "id" returned from listMemberInfo, Webhooks, and Campaigns
2288
+ * @return array An array of campaign_ids the member received
2289
+ */
2290
+ function campaignsForEmail($email_address) {
2291
+ $params = array();
2292
+ $params["email_address"] = $email_address;
2293
+ return $this->callServer("campaignsForEmail", $params);
2294
+ }
2295
+
2296
+ /**
2297
+ * Return the current Chimp Chatter messages for an account.
2298
+ *
2299
+ * @section Helper
2300
+ *
2301
+ * @return array An array of chatter messages and properties
2302
+ * @returnf string message The chatter message
2303
+ * @returnf string type The type of the message - one of lists:new-subscriber, lists:unsubscribes, lists:profile-updates, campaigns:facebook-likes, campaigns:facebook-comments, campaigns:forward-to-friend, lists:imports, or campaigns:inbox-inspections
2304
+ * @returnf string url a url into the web app that the message could link to
2305
+ * @returnf string list_id the list_id a message relates to, if applicable
2306
+ * @returnf string campaign_id the list_id a message relates to, if applicable
2307
+ * @returnf string update_time The date/time the message was last updated
2308
+ */
2309
+ function chimpChatter() {
2310
+ $params = array();
2311
+ return $this->callServer("chimpChatter", $params);
2312
+ }
2313
+
2314
+ /**
2315
+ * Retrieve a list of all MailChimp API Keys for this User
2316
+ *
2317
+ * @section Security Related
2318
+ * @example xml-rpc_apikeyAdd.php
2319
+ * @example mcapi_apikeyAdd.php
2320
+ *
2321
+ * @param string $username Your MailChimp user name
2322
+ * @param string $password Your MailChimp password
2323
+ * @param boolean $expired optional - whether or not to include expired keys, defaults to false
2324
+ * @return array an array of API keys including:
2325
+ * @returnf string apikey The api key that can be used
2326
+ * @returnf string created_at The date the key was created
2327
+ * @returnf string expired_at The date the key was expired
2328
+ */
2329
+ function apikeys($username, $password, $expired=false) {
2330
+ $params = array();
2331
+ $params["username"] = $username;
2332
+ $params["password"] = $password;
2333
+ $params["expired"] = $expired;
2334
+ return $this->callServer("apikeys", $params);
2335
+ }
2336
+
2337
+ /**
2338
+ * Add an API Key to your account. We will generate a new key for you and return it.
2339
+ *
2340
+ * @section Security Related
2341
+ * @example xml-rpc_apikeyAdd.php
2342
+ *
2343
+ * @param string $username Your MailChimp user name
2344
+ * @param string $password Your MailChimp password
2345
+ * @return string a new API Key that can be immediately used.
2346
+ */
2347
+ function apikeyAdd($username, $password) {
2348
+ $params = array();
2349
+ $params["username"] = $username;
2350
+ $params["password"] = $password;
2351
+ return $this->callServer("apikeyAdd", $params);
2352
+ }
2353
+
2354
+ /**
2355
+ * Expire a Specific API Key. Note that if you expire all of your keys, just visit <a href="http://admin.mailchimp.com/account/api" target="_blank">your API dashboard</a>
2356
+ * to create a new one. If you are trying to shut off access to your account for an old developer, change your
2357
+ * MailChimp password, then expire all of the keys they had access to. Note that this takes effect immediately, so make
2358
+ * sure you replace the keys in any working application before expiring them! Consider yourself warned...
2359
+ *
2360
+ * @section Security Related
2361
+ * @example mcapi_apikeyExpire.php
2362
+ * @example xml-rpc_apikeyExpire.php
2363
+ *
2364
+ * @param string $username Your MailChimp user name
2365
+ * @param string $password Your MailChimp password
2366
+ * @return boolean true if it worked, otherwise an error is thrown.
2367
+ */
2368
+ function apikeyExpire($username, $password) {
2369
+ $params = array();
2370
+ $params["username"] = $username;
2371
+ $params["password"] = $password;
2372
+ return $this->callServer("apikeyExpire", $params);
2373
+ }
2374
+
2375
+ /**
2376
+ * "Ping" the MailChimp API - a simple method you can call that will return a constant value as long as everything is good. Note
2377
+ * than unlike most all of our methods, we don't throw an Exception if we are having issues. You will simply receive a different
2378
+ * string back that will explain our view on what is going on.
2379
+ *
2380
+ * @section Helper
2381
+ * @example xml-rpc_ping.php
2382
+ *
2383
+ * @return string returns "Everything's Chimpy!" if everything is chimpy, otherwise returns an error message
2384
+ */
2385
+ function ping() {
2386
+ $params = array();
2387
+ return $this->callServer("ping", $params);
2388
+ }
2389
+
2390
+ /**
2391
+ * Internal function - proxy method for certain XML-RPC calls | DO NOT CALL
2392
+ * @param mixed Method to call, with any parameters to pass along
2393
+ * @return mixed the result of the call
2394
+ */
2395
+ function callMethod() {
2396
+ $params = array();
2397
+ return $this->callServer("callMethod", $params);
2398
+ }
2399
+
2400
+ /**
2401
+ * Actually connect to the server and call the requested methods, parsing the result
2402
+ * You should never have to call this function manually
2403
+ */
2404
+ function callServer($method, $params) {
2405
+ $dc = "us1";
2406
+ if (strstr($this->api_key,"-")){
2407
+ list($key, $dc) = explode("-",$this->api_key,2);
2408
+ if (!$dc) $dc = "us1";
2409
+ }
2410
+ $host = $dc.".".$this->apiUrl["host"];
2411
+ $params["apikey"] = $this->api_key;
2412
+
2413
+ $this->errorMessage = "";
2414
+ $this->errorCode = "";
2415
+ $sep_changed = false;
2416
+ //sigh, apparently some distribs change this to &amp; by default
2417
+ if (ini_get("arg_separator.output")!="&"){
2418
+ $sep_changed = true;
2419
+ $orig_sep = ini_get("arg_separator.output");
2420
+ ini_set("arg_separator.output", "&");
2421
+ }
2422
+ $post_vars = http_build_query($params);
2423
+ if ($sep_changed){
2424
+ ini_set("arg_separator.output", $orig_sep);
2425
+ }
2426
+
2427
+ # $payload = "POST " . $this->apiUrl["path"] . "?" . $this->apiUrl["query"] . "&method=" . $method . " HTTP/1.0\r\n";
2428
+ # $payload .= "Host: " . $host . "\r\n";
2429
+ # $payload .= "User-Agent: MCAPI/" . $this->version ."\r\n";
2430
+ # $payload .= "Content-type: application/x-www-form-urlencoded\r\n";
2431
+ # $payload .= "Content-length: " . strlen($post_vars) . "\r\n";
2432
+ # $payload .= "Connection: close \r\n\r\n";
2433
+ # $payload .= $post_vars;
2434
+
2435
+ ob_start();
2436
+
2437
+ $s2_ags = array("user-agent" => "MCAPI/" . $this->version, "timeout" => $this->timeout);
2438
+
2439
+ $s2_url = $host . $this->apiUrl["path"] . "?" . $this->apiUrl["query"] . "&method=" . $method;
2440
+ $s2_url = ($this->secure) ? "https://" . $s2_url : "http://" . $s2_url;
2441
+
2442
+ if (!strlen ($response = c_ws_plugin__s2member_utils_urls::remote ($s2_url, $post_vars, $s2_ags, true))){
2443
+ $this->errorMessage = "Could not connect.";
2444
+ $this->errorCode = "-99";
2445
+ ob_end_clean();
2446
+ return false;
2447
+ }
2448
+
2449
+ ob_end_clean();
2450
+
2451
+ # if ($this->secure){
2452
+ # $sock = fsockopen("ssl://".$host, 443, $errno, $errstr, 30);
2453
+ # } else {
2454
+ # $sock = fsockopen($host, 80, $errno, $errstr, 30);
2455
+ # }
2456
+ # if(!$sock) {
2457
+ # $this->errorMessage = "Could not connect (ERR $errno: $errstr)";
2458
+ # $this->errorCode = "-99";
2459
+ # ob_end_clean();
2460
+ # return false;
2461
+ # }
2462
+
2463
+ # $response = "";
2464
+ # fwrite($sock, $payload);
2465
+ # stream_set_timeout($sock, $this->timeout);
2466
+ # $info = stream_get_meta_data($sock);
2467
+ # while ((!feof($sock)) && (!$info["timed_out"])) {
2468
+ # $response .= fread($sock, $this->chunkSize);
2469
+ # $info = stream_get_meta_data($sock);
2470
+ # }
2471
+ # fclose($sock);
2472
+ # ob_end_clean();
2473
+ # if ($info["timed_out"]) {
2474
+ # $this->errorMessage = "Could not read response (timed out)";
2475
+ # $this->errorCode = -98;
2476
+ # return false;
2477
+ # }
2478
+
2479
+ list($headers, $response) = explode("\r\n\r\n", $response, 2);
2480
+ $headers = explode("\r\n", $headers);
2481
+ $errored = false;
2482
+ foreach($headers as $h){
2483
+ if (substr( /* WebSharks, Inc. ( lowercase ). */
2484
+ strtolower($h),0,26)==="x-mailchimp-api-error-code"){
2485
+ $errored = true;
2486
+ $error_code = trim(substr($h,27));
2487
+ break;
2488
+ }
2489
+ }
2490
+
2491
+ # if(ini_get("magic_quotes_runtime")) $response = stripslashes($response);
2492
+
2493
+ $serial = /* WebSharks, Inc. ( maybe ). */ maybe_unserialize($response);
2494
+
2495
+ if($response && $serial === false) {
2496
+ $response = array("error" => "Bad Response. Got This: " . $response, "code" => "-99");
2497
+ } else {
2498
+ $response = $serial;
2499
+ }
2500
+ if($errored && is_array($response) && isset($response["error"])) {
2501
+ $this->errorMessage = $response["error"];
2502
+ $this->errorCode = $response["code"];
2503
+ return false;
2504
+ } elseif($errored){
2505
+ $this->errorMessage = "No error message was found.";
2506
+ $this->errorCode = $error_code;
2507
+ return false;
2508
+ }
2509
+
2510
+ return $response;
2511
+ }
2512
+
2513
+ }
2514
+
2515
+ ?>
includes/_xtnls/markdown/index.php ADDED
File without changes
includes/{markdown → _xtnls/markdown}/nc-markdown.inc.php RENAMED
@@ -1,37 +1,43 @@
1
  <?php
2
- #
3
- # PHP NC_Markdown ( no conflict version ) Modified by WebSharks, Inc. / 2009
4
- # Uses custom a class name and interface. Excludes WP and the other interfaces.
5
- #
6
- # Original PHP Markdown ( class intact )
7
- # Copyright (c) 2004-2008 Michel Fortin
8
- # <http://www.michelf.com/projects/php-markdown/>
9
- #
10
- # Original Markdown
11
- # Copyright (c) 2004-2006 John Gruber
12
- # <http://daringfireball.net/projects/markdown/>
13
- #
14
-
 
 
 
 
 
 
 
 
 
 
 
15
  function NC_Markdown($text) {
16
- #
17
- # Initialize the parser and return the result of its transform method.
18
- #
19
- # Setup static parser variable.
20
  static $parser;
21
  if (!isset($parser)) {
22
  $parser_class = NC_Markdown_Parser;
23
  $parser = new $parser_class;
24
  }
25
 
26
- # Transform text using parser.
27
  return $parser->transform($text);
28
  }
29
-
30
-
31
- #
32
- # NC_Markdown Parser Class
33
- #
34
-
35
  class NC_Markdown_Parser {
36
 
37
  # Regex to match balanced [brackets].
1
  <?php
2
+ /**
3
+ * PHP Markdown class.
4
+ *
5
+ * Copyright {@link http://www.michelf.com/projects/php-markdown/ Michel Fortin}.
6
+ * Original Markdown. Copyright {@link http://daringfireball.net/projects/markdown/ John Gruber}.
7
+ *
8
+ * Modified by {@link http://www.websharks-inc.com/ WebSharks, Inc.}.
9
+ * Excludes WordPress® and all other interfaces.
10
+ * Uses a custom class name and interface.
11
+ *
12
+ * This file is included with all WordPress® themes/plugins by WebSharks, Inc.
13
+ *
14
+ * @package WebSharks\Xtnls\Markdown
15
+ * @since x.xx
16
+ */
17
+ /**
18
+ * PHP Markdown interface.
19
+ *
20
+ * @package WebSharks\Xtnls\Markdown
21
+ * @since x.xx
22
+ *
23
+ * @param str $text Text to be parsed by the Markdown class.
24
+ * @return str HTML output; after having been parsed by the Markdown class.
25
+ */
26
  function NC_Markdown($text) {
27
+
 
 
 
28
  static $parser;
29
  if (!isset($parser)) {
30
  $parser_class = NC_Markdown_Parser;
31
  $parser = new $parser_class;
32
  }
33
 
 
34
  return $parser->transform($text);
35
  }
36
+ /**
37
+ * PHP Markdown class.
38
+ * @package Xtnls\Markdown
39
+ * @since x.xx
40
+ */
 
41
  class NC_Markdown_Parser {
42
 
43
  # Regex to match balanced [brackets].
includes/classes/admin-css-js-in.inc.php CHANGED
@@ -1,43 +1,58 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_admin_css_js_in"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_admin_css_js_in
20
  {
21
- /*
22
- Function that outputs the CSS for menu pages.
23
- Attach to: add_action("init");
 
 
 
 
 
 
24
  */
25
  public static function menu_pages_css ()
26
  {
27
  do_action ("ws_plugin__s2member_before_menu_pages_css", get_defined_vars ());
28
  /**/
29
- if ($_GET["ws_plugin__s2member_menu_pages_css"] && is_user_logged_in () && current_user_can ("create_users"))
30
  {
31
- header ("Content-Type: text/css; charset=utf-8");
32
- header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
33
- header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
34
- header ("Cache-Control: no-cache, must-revalidate, max-age=0");
35
- header ("Pragma: no-cache");
36
  /**/
37
  $u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
38
  $i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images";
39
  /**/
40
- ob_start ("c_ws_plugin__s2member_utils_css::compress_css"); /* Compress. */
41
  /**/
42
  include_once dirname (dirname (__FILE__)) . "/menu-pages/menu-pages.css";
43
  /**/
@@ -52,25 +67,35 @@ if (!class_exists ("c_ws_plugin__s2member_admin_css_js_in"))
52
  /**/
53
  do_action ("ws_plugin__s2member_after_menu_pages_css", get_defined_vars ());
54
  }
55
- /*
56
- Function that outputs the JS for menu pages.
57
- Attach to: add_action("init");
 
 
 
 
 
 
58
  */
59
  public static function menu_pages_js ()
60
  {
61
  do_action ("ws_plugin__s2member_before_menu_pages_js", get_defined_vars ());
62
  /**/
63
- if ($_GET["ws_plugin__s2member_menu_pages_js"] && is_user_logged_in () && current_user_can ("create_users"))
64
  {
65
- header ("Content-Type: text/javascript; charset=utf-8");
66
- header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
67
- header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
68
- header ("Cache-Control: no-cache, must-revalidate, max-age=0");
69
- header ("Pragma: no-cache");
70
  /**/
71
  $u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
72
  $i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images";
73
  /**/
 
 
 
 
74
  include_once dirname (dirname (__FILE__)) . "/menu-pages/menu-pages-min.js";
75
  /**/
76
  echo "\n"; /* Add a line break before inclusion of this file. */
1
  <?php
2
+ /**
3
+ * Administrative CSS/JS for menu pages ( inner processing routines ).
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Admin_CSS_JS
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_admin_css_js_in"))
21
  {
22
+ /**
23
+ * Administrative CSS/JS for menu pages ( inner processing routines ).
24
+ *
25
+ * @package s2Member\Admin_CSS_JS
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_admin_css_js_in
29
  {
30
+ /**
31
+ * Outputs the CSS for administrative menu pages.
32
+ *
33
+ * @package s2Member\Admin_CSS_JS
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to ``add_action("init");``
37
+ *
38
+ * @return null Or exits script execution after loading CSS.
39
  */
40
  public static function menu_pages_css ()
41
  {
42
  do_action ("ws_plugin__s2member_before_menu_pages_css", get_defined_vars ());
43
  /**/
44
+ if (!empty ($_GET["ws_plugin__s2member_menu_pages_css"]) && is_user_logged_in () && current_user_can ("create_users"))
45
  {
46
+ header("Content-Type: text/css; charset=utf-8");
47
+ header("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
48
+ header("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
49
+ header("Cache-Control: no-cache, must-revalidate, max-age=0");
50
+ header("Pragma: no-cache");
51
  /**/
52
  $u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
53
  $i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images";
54
  /**/
55
+ ob_start("c_ws_plugin__s2member_utils_css::compress_css"); /* Compress. */
56
  /**/
57
  include_once dirname (dirname (__FILE__)) . "/menu-pages/menu-pages.css";
58
  /**/
67
  /**/
68
  do_action ("ws_plugin__s2member_after_menu_pages_css", get_defined_vars ());
69
  }
70
+ /**
71
+ * Outputs the JS for administrative menu pages.
72
+ *
73
+ * @package s2Member\Admin_CSS_JS
74
+ * @since 3.5
75
+ *
76
+ * @attaches-to ``add_action("init");``
77
+ *
78
+ * @return null Or exits script execution after loading JS.
79
  */
80
  public static function menu_pages_js ()
81
  {
82
  do_action ("ws_plugin__s2member_before_menu_pages_js", get_defined_vars ());
83
  /**/
84
+ if (!empty ($_GET["ws_plugin__s2member_menu_pages_js"]) && is_user_logged_in () && current_user_can ("create_users"))
85
  {
86
+ header("Content-Type: text/javascript; charset=utf-8");
87
+ header("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
88
+ header("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
89
+ header("Cache-Control: no-cache, must-revalidate, max-age=0");
90
+ header("Pragma: no-cache");
91
  /**/
92
  $u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
93
  $i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images";
94
  /**/
95
+ for ($n = 0, $labels = ""; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
96
+ $labels .= "labels['level" . $n . "'] = '" . ((!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_label"])) ? c_ws_plugin__s2member_utils_strings::esc_sq (preg_replace ('/"/', "", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_label"])) : "") . "';";
97
+ unset($n);
98
+ /**/
99
  include_once dirname (dirname (__FILE__)) . "/menu-pages/menu-pages-min.js";
100
  /**/
101
  echo "\n"; /* Add a line break before inclusion of this file. */
includes/classes/admin-css-js.inc.php CHANGED
@@ -1,41 +1,62 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_admin_css_js"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_admin_css_js
20
  {
21
- /*
22
- Function that outputs the CSS for menu pages.
23
- Attach to: add_action("init");
 
 
 
 
 
 
24
  */
25
  public static function menu_pages_css ()
26
  {
27
- if ($_GET["ws_plugin__s2member_menu_pages_css"]) /* Call inner function? */
28
  {
29
  return c_ws_plugin__s2member_admin_css_js_in::menu_pages_css ();
30
  }
31
  }
32
- /*
33
- Function that outputs the JS for menu pages.
34
- Attach to: add_action("init");
 
 
 
 
 
 
35
  */
36
  public static function menu_pages_js ()
37
  {
38
- if ($_GET["ws_plugin__s2member_menu_pages_js"]) /* Call inner function? */
39
  {
40
  return c_ws_plugin__s2member_admin_css_js_in::menu_pages_js ();
41
  }
1
  <?php
2
+ /**
3
+ * Administrative CSS/JS for menu pages.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Admin_CSS_JS
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_admin_css_js"))
21
  {
22
+ /**
23
+ * Administrative CSS/JS for menu pages.
24
+ *
25
+ * @package s2Member\Admin_CSS_JS
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_admin_css_js
29
  {
30
+ /**
31
+ * Outputs the CSS for administrative menu pages.
32
+ *
33
+ * @package s2Member\Admin_CSS_JS
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to ``add_action("init");``
37
+ *
38
+ * @return null|inner Return-value of inner routine.
39
  */
40
  public static function menu_pages_css ()
41
  {
42
+ if (!empty ($_GET["ws_plugin__s2member_menu_pages_css"])) /* Call inner routine? */
43
  {
44
  return c_ws_plugin__s2member_admin_css_js_in::menu_pages_css ();
45
  }
46
  }
47
+ /**
48
+ * Outputs the JS for administrative menu pages.
49
+ *
50
+ * @package s2Member\Admin_CSS_JS
51
+ * @since 3.5
52
+ *
53
+ * @attaches-to ``add_action("init");``
54
+ *
55
+ * @return null|inner Return-value of inner routine.
56
  */
57
  public static function menu_pages_js ()
58
  {
59
+ if (!empty ($_GET["ws_plugin__s2member_menu_pages_js"])) /* Call inner routine? */
60
  {
61
  return c_ws_plugin__s2member_admin_css_js_in::menu_pages_js ();
62
  }
includes/classes/admin-lockouts.inc.php CHANGED
@@ -1,38 +1,53 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_admin_lockouts"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_admin_lockouts
20
  {
21
- /*
22
- Function for handling admin lockouts.
23
- Attach to: add_action("admin_init");
 
 
 
 
 
 
24
  */
25
  public static function admin_lockout () /* Prevents admin access. */
26
  {
27
  do_action ("ws_plugin__s2member_before_admin_lockouts", get_defined_vars ());
28
  /**/
29
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"] && /* Now check for these WordPress® functionality Constants too. */
30
- (!defined ("XMLRPC_REQUEST") || !XMLRPC_REQUEST) && (!defined ("APP_REQUEST") || !APP_REQUEST) && (!defined ("DOING_AJAX") || !DOING_AJAX)/**/
31
  && !current_user_can ("edit_posts")) /* And only if the current User is unable to edit Posts; otherwise we allow them in. */
32
  if (apply_filters ("ws_plugin__s2member_admin_lockout", true, get_defined_vars ())) /* Give Filters a chance too. */
33
  {
34
  if ($special_redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ())
35
- wp_redirect($special_redirection_url); /* Special Redirection. */
36
  /**/
37
  else /* Else we use the Login Welcome Page configured for s2Member. */
38
  wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
@@ -44,16 +59,25 @@ if (!class_exists ("c_ws_plugin__s2member_admin_lockouts"))
44
  /**/
45
  return; /* Return for uniformity. */
46
  }
47
- /*
48
- Function for modifying Admin Menu Bars.
49
- Attach to: add_action("admin_bar_menu");
 
 
 
 
 
 
 
50
  */
51
  public static function filter_admin_menu_bar (&$wp_admin_bar = FALSE)
52
  {
53
  do_action ("ws_plugin__s2member_before_filter_admin_menu_bar", get_defined_vars ());
54
  /**/
55
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"] && (!defined ("DOING_AJAX") || !DOING_AJAX) && !current_user_can ("edit_posts"))
56
- if (is_object ($wp_admin_bar) && apply_filters ("ws_plugin__s2member_admin_lockout", true, get_defined_vars ())) /* Give Filters a chance. */
 
 
57
  {
58
  if ($special_redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ())
59
  $lwp = $special_redirection_url; /* Use Special Redirection URL. */
1
  <?php
2
+ /**
3
+ * Locks Users/Members out of admin panels.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Admin_Lockouts
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_admin_lockouts"))
21
  {
22
+ /**
23
+ * Locks Users/Members out of admin panels.
24
+ *
25
+ * @package s2Member\Admin_Lockouts
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_admin_lockouts
29
  {
30
+ /**
31
+ * Locks Users/Members out of admin panels.
32
+ *
33
+ * @package s2Member\Admin_Lockouts
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to ``add_action("admin_init");``
37
+ *
38
+ * @return null Or exits script execution after redirection.
39
  */
40
  public static function admin_lockout () /* Prevents admin access. */
41
  {
42
  do_action ("ws_plugin__s2member_before_admin_lockouts", get_defined_vars ());
43
  /**/
44
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"] /* Now check for these WordPress® functionality Constants too. */
45
+ && (!defined ("XMLRPC_REQUEST") || !XMLRPC_REQUEST) && (!defined ("APP_REQUEST") || !APP_REQUEST) && (!defined ("DOING_AJAX") || !DOING_AJAX)/**/
46
  && !current_user_can ("edit_posts")) /* And only if the current User is unable to edit Posts; otherwise we allow them in. */
47
  if (apply_filters ("ws_plugin__s2member_admin_lockout", true, get_defined_vars ())) /* Give Filters a chance too. */
48
  {
49
  if ($special_redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ())
50
+ wp_redirect ($special_redirection_url); /* Special Redirection. */
51
  /**/
52
  else /* Else we use the Login Welcome Page configured for s2Member. */
53
  wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
59
  /**/
60
  return; /* Return for uniformity. */
61
  }
62
+ /**
63
+ * Filters administrative menu bars.
64
+ *
65
+ * @package s2Member\Admin_Lockouts
66
+ * @since 3.5
67
+ *
68
+ * @attaches-to ``add_action("admin_bar_menu");``
69
+ *
70
+ * @param obj $wp_admin_bar Expects the ``$wp_admin_bar``, by reference; passed in by the Action Hook.
71
+ * @return null After modifying ``$wp_admin_var``.
72
  */
73
  public static function filter_admin_menu_bar (&$wp_admin_bar = FALSE)
74
  {
75
  do_action ("ws_plugin__s2member_before_filter_admin_menu_bar", get_defined_vars ());
76
  /**/
77
+ if (is_object ($wp_admin_bar) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"] /* Now check functionality Constants too. */
78
+ && (!defined ("XMLRPC_REQUEST") || !XMLRPC_REQUEST) && (!defined ("APP_REQUEST") || !APP_REQUEST) && (!defined ("DOING_AJAX") || !DOING_AJAX)/**/
79
+ && !current_user_can ("edit_posts")) /* And only if the current User is unable to edit Posts; otherwise we allow them in. */
80
+ if (apply_filters ("ws_plugin__s2member_admin_lockout", true, get_defined_vars ())) /* Give Filters a chance too. */
81
  {
82
  if ($special_redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ())
83
  $lwp = $special_redirection_url; /* Use Special Redirection URL. */
includes/classes/admin-notices.inc.php CHANGED
@@ -1,39 +1,58 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_admin_notices"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_admin_notices
20
  {
21
- /*
22
- Function that enqueues Admin Notices.
 
 
 
 
 
 
 
 
 
 
23
  */
24
  public static function enqueue_admin_notice ($notice = FALSE, $on_pages = FALSE, $error = FALSE, $time = FALSE, $dismiss = FALSE)
25
  {
26
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
27
  do_action ("ws_plugin__s2member_before_enqueue_admin_notice", get_defined_vars ());
28
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
29
  /**/
30
- if ($notice && is_string ($notice)) /* If we have a valid string. */
31
  {
32
  $notices = (array)get_option ("ws_plugin__s2member_notices");
33
  /**/
34
  array_push ($notices, array ("notice" => $notice, "on_pages" => $on_pages, "error" => $error, "time" => $time, "dismiss" => $dismiss));
35
  /**/
36
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
37
  do_action ("ws_plugin__s2member_during_enqueue_admin_notice", get_defined_vars ());
38
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
39
  /**/
@@ -44,37 +63,52 @@ if (!class_exists ("c_ws_plugin__s2member_admin_notices"))
44
  /**/
45
  return; /* Return for uniformity. */
46
  }
47
- /*
48
- Function displays an Admin Notice immediately.
 
 
 
 
 
 
 
 
49
  */
50
  public static function display_admin_notice ($notice = FALSE, $error = FALSE, $dismiss = FALSE)
51
  {
52
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
53
  do_action ("ws_plugin__s2member_before_display_admin_notice", get_defined_vars ());
54
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
55
  /**/
56
- if ($notice && $error) /* Special format for errors. */
57
  {
58
  $notice .= ($dismiss) ? ' [ <a href="' . add_query_arg ("ws-plugin--s2member-dismiss-admin-notice", urlencode (md5 ($notice)), $_SERVER["REQUEST_URI"]) . '">dismiss message</a> ]' : '';
59
  /**/
60
- echo '<div class="error fade"><p>' . $notice . '</p></div>'; /* Displays the error message. */
61
  }
62
- else if ($notice) /* Otherwise, we send it as an update notice. */
63
  {
64
  $notice .= ($dismiss) ? ' [ <a href="' . add_query_arg ("ws-plugin--s2member-dismiss-admin-notice", urlencode (md5 ($notice)), $_SERVER["REQUEST_URI"]) . '">dismiss message</a> ]' : '';
65
  /**/
66
- echo '<div class="updated fade"><p>' . $notice . '</p></div>'; /* Displays info message. */
67
  }
68
  /**/
69
  do_action ("ws_plugin__s2member_after_display_admin_notice", get_defined_vars ());
70
  /**/
71
  return; /* Return for uniformity. */
72
  }
73
- /*
74
- Function that displays Admin Notices.
75
- Attach to: add_action("admin_notices");
76
- Attach to: add_action("user_admin_notices");
77
- Attach to: add_action("network_admin_notices");
 
 
 
 
 
 
 
78
  */
79
  public static function admin_notices ()
80
  {
@@ -84,13 +118,13 @@ if (!class_exists ("c_ws_plugin__s2member_admin_notices"))
84
  /**/
85
  if (is_admin () && is_array ($notices = get_option ("ws_plugin__s2member_notices")) && !empty ($notices))
86
  {
87
- $a = (c_ws_plugin__s2member_utils_conds::is_blog_admin ()) ? "blog" : $a;
88
- $a = (c_ws_plugin__s2member_utils_conds::is_user_admin ()) ? "user" : $a;
89
- $a = (c_ws_plugin__s2member_utils_conds::is_network_admin ()) ? "network" : $a;
90
  $a = (!$a) ? "blog" : $a; /* Default Blog Admin. */
91
  /**/
92
  foreach ($notices as $i => $notice) /* Check several things about each Notice. */
93
- foreach (( (!$notice["on_pages"]) ? array ("*"): (array)$notice["on_pages"]) as $page)
94
  {
95
  if (!preg_match ("/^(.+?)\:/", $page)) /* NO prefix? */
96
  $page = "blog:" . ltrim ($page, ":"); /* `blog:` */
@@ -98,31 +132,31 @@ if (!class_exists ("c_ws_plugin__s2member_admin_notices"))
98
  $adms = preg_split ("/\|/", preg_replace ("/\:(.*)$/i", "", $page));
99
  $page = preg_replace ("/^([^\:]*)\:/i", "", $page);
100
  /**/
101
- if (empty ($adms) || in_array ("*", $adms) || in_array ($a, $adms) || !version_compare (get_bloginfo ("version"), "3.1-RC", ">="))
102
  if (!$page || "*" === $page || $pagenow === $page || $_GET["page"] === $page)
103
  {
104
  if (strtotime ("now") >= (int)$notice["time"]) /* Time to show it? */
105
  {
106
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
107
  do_action ("ws_plugin__s2member_during_admin_notices_before_display", get_defined_vars ());
108
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
109
  /**/
110
- if (!$notice["dismiss"] || $_GET["ws-plugin--s2member-dismiss-admin-notice"] === md5 ($notice["notice"]))
111
- unset ($notices[$i]); /* Clear this administrative notice now? */
112
  /**/
113
- if (!$notice["dismiss"] || $_GET["ws-plugin--s2member-dismiss-admin-notice"] !== md5 ($notice["notice"]))
114
- c_ws_plugin__s2member_admin_notices::display_admin_notice ($notice["notice"],$notice["error"],$notice["dismiss"]);
115
  /**/
116
  do_action ("ws_plugin__s2member_during_admin_notices_after_display", get_defined_vars ());
117
  }
118
  /**/
119
- continue 2; /* This Notice processed; continue to next. */
120
  }
121
  }
122
  /**/
123
  $notices = array_merge ($notices); /* Re-index array. */
124
  /**/
125
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
126
  do_action ("ws_plugin__s2member_during_admin_notices", get_defined_vars ());
127
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
128
  /**/
1
  <?php
2
+ /**
3
+ * Enqueues/displays administrative notices.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Admin_Notices
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_admin_notices"))
21
  {
22
+ /**
23
+ * Enqueues/displays administrative notices.
24
+ *
25
+ * @package s2Member\Admin_Notices
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_admin_notices
29
  {
30
+ /**
31
+ * Enqueues administrative notices.
32
+ *
33
+ * @package s2Member\Admin_Notices
34
+ * @since 3.5
35
+ *
36
+ * @param str $notice String value of actual notice *( i.e. the message )*.
37
+ * @param str|array $on_pages Optional. Defaults to any page. String or array of pages to display this notice on.
38
+ * @param bool $error Optional. True if this notice is regarding an error. Defaults to false.
39
+ * @param int $time Optional. Unix timestamp indicating when this notice will be displayed.
40
+ * @param bool $dismiss Optional. If true, the notice will remain persistent, until dismissed. Defaults to false.
41
+ * @return null
42
  */
43
  public static function enqueue_admin_notice ($notice = FALSE, $on_pages = FALSE, $error = FALSE, $time = FALSE, $dismiss = FALSE)
44
  {
45
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
46
  do_action ("ws_plugin__s2member_before_enqueue_admin_notice", get_defined_vars ());
47
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
48
  /**/
49
+ if (is_string ($notice) && $notice) /* If we have a valid string. */
50
  {
51
  $notices = (array)get_option ("ws_plugin__s2member_notices");
52
  /**/
53
  array_push ($notices, array ("notice" => $notice, "on_pages" => $on_pages, "error" => $error, "time" => $time, "dismiss" => $dismiss));
54
  /**/
55
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
56
  do_action ("ws_plugin__s2member_during_enqueue_admin_notice", get_defined_vars ());
57
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
58
  /**/
63
  /**/
64
  return; /* Return for uniformity. */
65
  }
66
+ /**
67
+ * Displays an administrative notice.
68
+ *
69
+ * @package s2Member\Admin_Notices
70
+ * @since 3.5
71
+ *
72
+ * @param str $notice String value of actual notice *( i.e. the message )*.
73
+ * @param bool $error Optional. True if this notice is regarding an error. Defaults to false.
74
+ * @param bool $dismiss Optional. If true, the notice will be displayed with a dismissal link. Defaults to false.
75
+ * @return null
76
  */
77
  public static function display_admin_notice ($notice = FALSE, $error = FALSE, $dismiss = FALSE)
78
  {
79
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
80
  do_action ("ws_plugin__s2member_before_display_admin_notice", get_defined_vars ());
81
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
82
  /**/
83
+ if (is_string ($notice) && $notice && $error) /* Slightly different/special format for errors. */
84
  {
85
  $notice .= ($dismiss) ? ' [ <a href="' . add_query_arg ("ws-plugin--s2member-dismiss-admin-notice", urlencode (md5 ($notice)), $_SERVER["REQUEST_URI"]) . '">dismiss message</a> ]' : '';
86
  /**/
87
+ echo '<div class="error fade"><p>' . $notice . '</p></div>'; /* Error. */
88
  }
89
+ else if (is_string ($notice) && $notice)
90
  {
91
  $notice .= ($dismiss) ? ' [ <a href="' . add_query_arg ("ws-plugin--s2member-dismiss-admin-notice", urlencode (md5 ($notice)), $_SERVER["REQUEST_URI"]) . '">dismiss message</a> ]' : '';
92
  /**/
93
+ echo '<div class="updated fade"><p>' . $notice . '</p></div>';
94
  }
95
  /**/
96
  do_action ("ws_plugin__s2member_after_display_admin_notice", get_defined_vars ());
97
  /**/
98
  return; /* Return for uniformity. */
99
  }
100
+ /**
101
+ * Processes all administrative notices.
102
+ *
103
+ * @package s2Member\Admin_Notices
104
+ * @since 3.5
105
+ *
106
+ * @attaches-to ``add_action("admin_notices");``
107
+ * @attaches-to ``add_action("user_admin_notices");``
108
+ * @attaches-to ``add_action("network_admin_notices");``
109
+ * @todo Update to ``add_action("all_admin_notices");``.
110
+ *
111
+ * @return null
112
  */
113
  public static function admin_notices ()
114
  {
118
  /**/
119
  if (is_admin () && is_array ($notices = get_option ("ws_plugin__s2member_notices")) && !empty ($notices))
120
  {
121
+ $a = (is_blog_admin ()) ? "blog" : $a;
122
+ $a = (is_user_admin ()) ? "user" : $a;
123
+ $a = (is_network_admin ()) ? "network" : $a;
124
  $a = (!$a) ? "blog" : $a; /* Default Blog Admin. */
125
  /**/
126
  foreach ($notices as $i => $notice) /* Check several things about each Notice. */
127
+ foreach (((!$notice["on_pages"]) ? array ("*"): (array)$notice["on_pages"]) as $page)
128
  {
129
  if (!preg_match ("/^(.+?)\:/", $page)) /* NO prefix? */
130
  $page = "blog:" . ltrim ($page, ":"); /* `blog:` */
132
  $adms = preg_split ("/\|/", preg_replace ("/\:(.*)$/i", "", $page));
133
  $page = preg_replace ("/^([^\:]*)\:/i", "", $page);
134
  /**/
135
+ if (empty ($adms) || in_array ("*", $adms) || in_array ($a, $adms))
136
  if (!$page || "*" === $page || $pagenow === $page || $_GET["page"] === $page)
137
  {
138
  if (strtotime ("now") >= (int)$notice["time"]) /* Time to show it? */
139
  {
140
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
141
  do_action ("ws_plugin__s2member_during_admin_notices_before_display", get_defined_vars ());
142
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
143
  /**/
144
+ if (!$notice["dismiss"] || (!empty ($_GET["ws-plugin--s2member-dismiss-admin-notice"]) && $_GET["ws-plugin--s2member-dismiss-admin-notice"] === md5 ($notice["notice"])))
145
+ unset($notices[$i]); /* Clear this administrative notice now? */
146
  /**/
147
+ if (!$notice["dismiss"] || empty ($_GET["ws-plugin--s2member-dismiss-admin-notice"]) || $_GET["ws-plugin--s2member-dismiss-admin-notice"] !== md5 ($notice["notice"]))
148
+ c_ws_plugin__s2member_admin_notices::display_admin_notice ($notice["notice"], $notice["error"], $notice["dismiss"]);
149
  /**/
150
  do_action ("ws_plugin__s2member_during_admin_notices_after_display", get_defined_vars ());
151
  }
152
  /**/
153
+ continue 2; /* This Notice processed; continue. */
154
  }
155
  }
156
  /**/
157
  $notices = array_merge ($notices); /* Re-index array. */
158
  /**/
159
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
160
  do_action ("ws_plugin__s2member_during_admin_notices", get_defined_vars ());
161
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
162
  /**/
includes/classes/auto-eots.inc.php CHANGED
@@ -1,25 +1,39 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_auto_eots
20
  {
21
- /*
22
- Adds a scheduled task for s2Member's Auto-EOT System.
 
 
 
 
 
23
  */
24
  public static function add_auto_eot_system ()
25
  {
@@ -40,8 +54,13 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
40
  return apply_filters ("ws_plugin__s2member_add_auto_eot_system", false, get_defined_vars ());
41
  }
42
  }
43
- /*
44
- Delete scheduled tasks for s2Member's Auto-EOT System.
 
 
 
 
 
45
  */
46
  public static function delete_auto_eot_system ()
47
  {
@@ -49,7 +68,7 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
49
  /**/
50
  if (function_exists ("wp_cron")) /* Is `wp_cron()` even available? */
51
  {
52
- wp_clear_scheduled_hook ("ws_plugin__s2member_auto_eot_system__schedule"); /* Since v3.0.3. */
53
  /**/
54
  return apply_filters ("ws_plugin__s2member_delete_auto_eot_system", true, get_defined_vars ());
55
  }
@@ -58,20 +77,23 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
58
  return apply_filters ("ws_plugin__s2member_delete_auto_eot_system", false, get_defined_vars ());
59
  }
60
  }
61
- /*
62
- Function processed by WP-Cron. This handles Auto-EOTs.
63
-
64
- If you have a HUGE userbase, increase the max EOTs per process.
65
- ~ But NOTE, this runs $per_process ( per Blog ) on a Multisite Network.
66
- To increase, use: add_filter ("ws_plugin__s2member_auto_eot_system_per_process");
67
-
68
- s2Member v3.2 ( VERY IMPORTANT ).
69
- AND `meta_value` != ''
70
- Because update_user_option() may NOT always delete the key.
71
-
72
- This function makes an important Hook available: `ws_plugin__s2member_after_auto_eot_system`.
73
- This Hook is used by some of s2Member Pro's Gateway integrations; allowing CRON processing
74
- to run for important communications; which poll Payment Gateway APIs for possible EOTs.
 
 
 
75
  */
76
  public static function auto_eot_system ($per_process = 3)
77
  {
@@ -80,10 +102,10 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
80
  /**/
81
  include_once ABSPATH . "wp-admin/includes/admin.php";
82
  /**/
83
- @set_time_limit (0); /* Make time for processing larger userbases. */
84
  @ini_set ("memory_limit", "256M"); /* Acquire some additional RAM. */
85
  /**/
86
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
87
  do_action ("ws_plugin__s2member_before_auto_eot_system", get_defined_vars ());
88
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
89
  /**/
@@ -103,18 +125,23 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
103
  {
104
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote")
105
  {
 
 
 
106
  $custom = get_user_option ("s2member_custom", $user_id);
107
  $subscr_id = get_user_option ("s2member_subscr_id", $user_id);
108
  $fields = get_user_option ("s2member_custom_fields", $user_id);
109
- /**/
110
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
111
- do_action ("ws_plugin__s2member_during_auto_eot_system_during_before_demote", get_defined_vars ());
112
- do_action ("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars (), "auto-eot-cancellation-expiration-demotion", "cancellation-expiration");
113
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
114
  /**/
115
  $demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role ("subscriber");
116
  $existing_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
117
  /**/
 
 
 
 
 
 
118
  if ($existing_role !== $demotion_role) /* Only if NOT the existing Role. */
119
  $user->set_role ($demotion_role); /* Give User the demotion Role. */
120
  /**/
@@ -132,6 +159,7 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
132
  delete_user_option ($user_id, "s2member_paid_registration_times");
133
  /**/
134
  delete_user_option ($user_id, "s2member_last_status_scan");
 
135
  delete_user_option ($user_id, "s2member_last_payment_time");
136
  delete_user_option ($user_id, "s2member_auto_eot_time");
137
  /**/
@@ -149,16 +177,17 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
149
  if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
150
  if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
151
  if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
152
- if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
153
- {
154
- if (is_array ($fields) && !empty ($fields))
155
- foreach ($fields as $var => $val) /* Custom Registration Fields. */
156
- if (! ($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
157
- break;
158
- /**/
159
- if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
160
- c_ws_plugin__s2member_utils_urls::remote ($url);
161
- }
 
162
  }
163
  /**/
164
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $custom)))
@@ -175,6 +204,7 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
175
  $msg .= "user_full_name: %%user_full_name%%\n";
176
  $msg .= "user_email: %%user_email%%\n";
177
  $msg .= "user_login: %%user_login%%\n";
 
178
  $msg .= "user_id: %%user_id%%\n";
179
  /**/
180
  if (is_array ($fields) && !empty ($fields))
@@ -197,33 +227,33 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
197
  if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
198
  if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
199
  if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
200
- if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
201
- {
202
- if (is_array ($fields) && !empty ($fields))
203
- foreach ($fields as $var => $val) /* Custom Registration Fields. */
204
- if (! ($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
205
- break;
206
- /**/
207
- if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
208
- foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"])) as $recipient)
209
- ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_eot_del_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_eot_del_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
210
- }
 
211
  }
212
  /**/
213
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
214
  do_action ("ws_plugin__s2member_during_auto_eot_system_during_demote", get_defined_vars ());
215
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
216
  }
217
  else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete")
218
  {
219
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
 
 
220
  do_action ("ws_plugin__s2member_during_auto_eot_system_during_before_delete", get_defined_vars ());
221
- do_action ("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars (), "auto-eot-cancellation-expiration-deletion", "cancellation-expiration");
222
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
223
  /**/
224
- $GLOBALS["ws_plugin__s2member_eot_del_type"] = "auto-eot-cancellation-expiration-deletion";
225
- $GLOBALS["ws_plugin__s2member_eot_del_type_spec"] = "cancellation-expiration";
226
- /**/
227
  if (is_multisite ()) /* Multisite does NOT actually delete; ONLY removes. */
228
  {
229
  remove_user_from_blog ($user_id, $current_blog->blog_id);
@@ -233,14 +263,14 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
233
  /**/
234
  else /* Otherwise, we can actually delete them. */
235
  /* This will automatically trigger `eot_del_notification_urls` as well. */
236
- wp_delete_user ($user_id); /* `c_ws_plugin__s2member_user_deletions::handle_user_deletions()` */
237
  /**/
238
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
239
  do_action ("ws_plugin__s2member_during_auto_eot_system_during_delete", get_defined_vars ());
240
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
241
  }
242
  /**/
243
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
244
  do_action ("ws_plugin__s2member_during_auto_eot_system", get_defined_vars ());
245
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
246
  }
@@ -251,7 +281,7 @@ if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
251
  /**/
252
  c_ws_plugin__s2member_utils_logs::cleanup_expired_s2m_transients (); /* Cleanup. */
253
  /**/
254
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
255
  do_action ("ws_plugin__s2member_after_auto_eot_system", get_defined_vars ());
256
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
257
  /**/
1
  <?php
2
+ /**
3
+ * s2Member's Auto-EOT System *( EOT = End Of Term )*.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Auto_EOT_System
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_auto_eots"))
21
  {
22
+ /**
23
+ * s2Member's Auto-EOT System *( EOT = End Of Term )*.
24
+ *
25
+ * @package s2Member\Auto_EOT_System
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_auto_eots
29
  {
30
+ /**
31
+ * Adds a scheduled task for s2Member's Auto-EOT System.
32
+ *
33
+ * @package s2Member\Auto_EOT_System
34
+ * @since 3.5
35
+ *
36
+ * @return bool True if able to add Auto-EOT System schedule, else false.
37
  */
38
  public static function add_auto_eot_system ()
39
  {
54
  return apply_filters ("ws_plugin__s2member_add_auto_eot_system", false, get_defined_vars ());
55
  }
56
  }
57
+ /**
58
+ * Deletes all scheduled tasks for s2Member's Auto-EOT System.
59
+ *
60
+ * @package s2Member\Auto_EOT_System
61
+ * @since 3.5
62
+ *
63
+ * @return bool True if able to delete Auto-EOT System schedule, else false.
64
  */
65
  public static function delete_auto_eot_system ()
66
  {
68
  /**/
69
  if (function_exists ("wp_cron")) /* Is `wp_cron()` even available? */
70
  {
71
+ wp_clear_scheduled_hook("ws_plugin__s2member_auto_eot_system__schedule"); /* Since v3.0.3. */
72
  /**/
73
  return apply_filters ("ws_plugin__s2member_delete_auto_eot_system", true, get_defined_vars ());
74
  }
77
  return apply_filters ("ws_plugin__s2member_delete_auto_eot_system", false, get_defined_vars ());
78
  }
79
  }
80
+ /**
81
+ * Processed by WP_Cron; this handles Auto-EOTs *( EOT = End Of Term )*.
82
+ *
83
+ * If you have a HUGE userbase, increase the max EOTs per process.
84
+ * But NOTE, this runs ``$per_process`` *( per Blog )* on a Multisite Network.
85
+ * To increase, use: ``add_filter ("ws_plugin__s2member_auto_eot_system_per_process");``.
86
+ *
87
+ * This function makes an important Hook available: `ws_plugin__s2member_after_auto_eot_system`.
88
+ * This Hook is used by some of s2Member Pro's Gateway integrations; allowing CRON processing
89
+ * to run for important communications; which poll Payment Gateway APIs for possible EOTs.
90
+ *
91
+ * @package s2Member\Auto_EOT_System
92
+ * @since 3.5
93
+ *
94
+ * @param int $per_process Number of database records to process each time.
95
+ * Can also be Filtered with `ws_plugin__s2member_auto_eot_system_per_process`.
96
+ * @return null
97
  */
98
  public static function auto_eot_system ($per_process = 3)
99
  {
102
  /**/
103
  include_once ABSPATH . "wp-admin/includes/admin.php";
104
  /**/
105
+ @set_time_limit(0); /* Make time for processing larger userbases. */
106
  @ini_set ("memory_limit", "256M"); /* Acquire some additional RAM. */
107
  /**/
108
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
109
  do_action ("ws_plugin__s2member_before_auto_eot_system", get_defined_vars ());
110
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
111
  /**/
125
  {
126
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote")
127
  {
128
+ $eot_del_type = /* Set EOT/Del type. */
129
+ "auto-eot-cancellation-expiration-demotion";
130
+ /**/
131
  $custom = get_user_option ("s2member_custom", $user_id);
132
  $subscr_id = get_user_option ("s2member_subscr_id", $user_id);
133
  $fields = get_user_option ("s2member_custom_fields", $user_id);
134
+ $user_reg_ip = get_user_option ("s2member_registration_ip", $user_id);
 
 
 
 
135
  /**/
136
  $demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role ("subscriber");
137
  $existing_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
138
  /**/
139
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
140
+ do_action ("ws_plugin__s2member_during_auto_eot_system_during_before_demote", get_defined_vars ());
141
+ do_action ("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars (), $eot_del_type, "modification", $demotion_role);
142
+ do_action ("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars (), $eot_del_type, "modification");
143
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
144
+ /**/
145
  if ($existing_role !== $demotion_role) /* Only if NOT the existing Role. */
146
  $user->set_role ($demotion_role); /* Give User the demotion Role. */
147
  /**/
159
  delete_user_option ($user_id, "s2member_paid_registration_times");
160
  /**/
161
  delete_user_option ($user_id, "s2member_last_status_scan");
162
+ delete_user_option ($user_id, "s2member_first_payment_txn_id");
163
  delete_user_option ($user_id, "s2member_last_payment_time");
164
  delete_user_option ($user_id, "s2member_auto_eot_time");
165
  /**/
177
  if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
178
  if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
179
  if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
180
+ if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_reg_ip)), $url)))
181
+ if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
182
+ {
183
+ if (is_array ($fields) && !empty ($fields))
184
+ foreach ($fields as $var => $val) /* Custom Registration Fields. */
185
+ if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
186
+ break;
187
+ /**/
188
+ if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
189
+ c_ws_plugin__s2member_utils_urls::remote ($url);
190
+ }
191
  }
192
  /**/
193
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $custom)))
204
  $msg .= "user_full_name: %%user_full_name%%\n";
205
  $msg .= "user_email: %%user_email%%\n";
206
  $msg .= "user_login: %%user_login%%\n";
207
+ $msg .= "user_ip: %%user_ip%%\n";
208
  $msg .= "user_id: %%user_id%%\n";
209
  /**/
210
  if (is_array ($fields) && !empty ($fields))
227
  if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
228
  if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
229
  if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
230
+ if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_reg_ip), $msg)))
231
+ if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
232
+ {
233
+ if (is_array ($fields) && !empty ($fields))
234
+ foreach ($fields as $var => $val) /* Custom Registration Fields. */
235
+ if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
236
+ break;
237
+ /**/
238
+ if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
239
+ foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"])) as $recipient)
240
+ ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_eot_del_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_eot_del_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
241
+ }
242
  }
243
  /**/
244
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
245
  do_action ("ws_plugin__s2member_during_auto_eot_system_during_demote", get_defined_vars ());
246
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
247
  }
248
  else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "delete")
249
  {
250
+ $eot_del_type = $GLOBALS["ws_plugin__s2member_eot_del_type"] = "auto-eot-cancellation-expiration-deletion";
251
+ /**/
252
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
253
  do_action ("ws_plugin__s2member_during_auto_eot_system_during_before_delete", get_defined_vars ());
254
+ do_action ("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars (), $eot_del_type, "removal-deletion");
255
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
256
  /**/
 
 
 
257
  if (is_multisite ()) /* Multisite does NOT actually delete; ONLY removes. */
258
  {
259
  remove_user_from_blog ($user_id, $current_blog->blog_id);
263
  /**/
264
  else /* Otherwise, we can actually delete them. */
265
  /* This will automatically trigger `eot_del_notification_urls` as well. */
266
+ wp_delete_user($user_id); /* `c_ws_plugin__s2member_user_deletions::handle_user_deletions()` */
267
  /**/
268
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
269
  do_action ("ws_plugin__s2member_during_auto_eot_system_during_delete", get_defined_vars ());
270
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
271
  }
272
  /**/
273
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
274
  do_action ("ws_plugin__s2member_during_auto_eot_system", get_defined_vars ());
275
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
276
  }
281
  /**/
282
  c_ws_plugin__s2member_utils_logs::cleanup_expired_s2m_transients (); /* Cleanup. */
283
  /**/
284
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
285
  do_action ("ws_plugin__s2member_after_auto_eot_system", get_defined_vars ());
286
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
287
  /**/
includes/classes/brute-force.inc.php CHANGED
@@ -1,31 +1,49 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_brute_force"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_brute_force
20
  {
21
- /*
22
- This prevents an attacker from guessing Usernames/Passwords.
23
- Allows only 5 failed login attempts every 30 minutes.
24
- Attach to: add_action("wp_login_failed");
 
 
 
 
 
 
 
 
 
25
  */
26
  public static function track_failed_logins ($username = FALSE)
27
  {
28
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
29
  do_action ("ws_plugin__s2member_before_track_failed_logins", get_defined_vars ());
30
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
31
  /**/
@@ -42,14 +60,24 @@ if (!class_exists ("c_ws_plugin__s2member_brute_force"))
42
  /**/
43
  return; /* Return for uniformity. */
44
  }
45
- /*
46
- This prevents an attacker from guessing Usernames/Passwords.
47
- Allows only 5 failed login attempts every 30 minutes.
48
- Attach to: add_filter("authenticate");
 
 
 
 
 
 
 
 
 
 
49
  */
50
  public static function stop_brute_force_logins ($user = FALSE)
51
  {
52
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
53
  do_action ("ws_plugin__s2member_before_stop_brute_force_logins", get_defined_vars ());
54
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
55
  /**/
@@ -64,13 +92,13 @@ if (!class_exists ("c_ws_plugin__s2member_brute_force"))
64
  {
65
  $errors = new WP_Error ("incorrect_password", "Max failed logins. Please wait " . $about . " and try again.");
66
  /**/
67
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
68
  do_action ("ws_plugin__s2member_during_stop_brute_force_logins", get_defined_vars ());
69
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
70
  }
71
  }
72
  /**/
73
- return apply_filters ("ws_plugin__s2member_stop_brute_force_logins", (($errors) ? $errors : $user), get_defined_vars ());
74
  }
75
  }
76
  }
1
  <?php
2
+ /**
3
+ * s2Member's Brute Force protection routines.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Brute_Force
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_brute_force"))
21
  {
22
+ /**
23
+ * s2Member's Brute Force protection routines.
24
+ *
25
+ * @package s2Member\Brute_Force
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_brute_force
29
  {
30
+ /**
31
+ * Tracks failed login attempts.
32
+ *
33
+ * Prevents an attacker from guessing Usernames/Passwords.
34
+ * Allows only 5 failed login attempts every 30 minutes.
35
+ *
36
+ * @package s2Member\Brute_Force
37
+ * @since 3.5
38
+ *
39
+ * @attaches-to ``add_action("wp_login_failed");``
40
+ *
41
+ * @param str $username Expects the $username to be passed in through the Hook.
42
+ * @return null
43
  */
44
  public static function track_failed_logins ($username = FALSE)
45
  {
46
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
47
  do_action ("ws_plugin__s2member_before_track_failed_logins", get_defined_vars ());
48
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
49
  /**/
60
  /**/
61
  return; /* Return for uniformity. */
62
  }
63
+ /**
64
+ * Stops anyone attempting a Brute Force attack.
65
+ *
66
+ * Prevents an attacker from guessing Usernames/Passwords.
67
+ * Allows only 5 failed login attempts every 30 minutes.
68
+ *
69
+ * @package s2Member\Brute_Force
70
+ * @since 3.5
71
+ *
72
+ * @attaches-to ``add_filter("authenticate");``
73
+ *
74
+ * @param obj $user Expects a WP_User object, or possibly a null value.
75
+ * This parameter value is simply passed through this routine.
76
+ * @return obj|null Either null, the ``$user`` obj, or a `WP_Error` obj.
77
  */
78
  public static function stop_brute_force_logins ($user = FALSE)
79
  {
80
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
81
  do_action ("ws_plugin__s2member_before_stop_brute_force_logins", get_defined_vars ());
82
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
83
  /**/
92
  {
93
  $errors = new WP_Error ("incorrect_password", "Max failed logins. Please wait " . $about . " and try again.");
94
  /**/
95
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
96
  do_action ("ws_plugin__s2member_during_stop_brute_force_logins", get_defined_vars ());
97
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
98
  }
99
  }
100
  /**/
101
+ return apply_filters ("ws_plugin__s2member_stop_brute_force_logins", ((!empty ($errors)) ? $errors : $user), get_defined_vars ());
102
  }
103
  }
104
  }
includes/classes/cache.inc.php CHANGED
@@ -1,27 +1,44 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_cache"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_cache
20
  {
21
- /*
22
- Pulls all of the Page links needed for Constants.
23
- Page links are cached into the s2Member options on 15 min intervals.
24
- This allows the API Constants to provide quick access to them without being forced to execute get_page_link() all the time, which piles up DB queries.
 
 
 
 
 
 
 
 
25
  */
26
  public static function cached_page_links ()
27
  {
1
  <?php
2
+ /**
3
+ * s2Member's caching routines.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Cache
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_cache"))
21
  {
22
+ /**
23
+ * s2Member's caching routines.
24
+ *
25
+ * @package s2Member\Cache
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_cache
29
  {
30
+ /**
31
+ * Page links needed for Constants.
32
+ *
33
+ * Page links are cached into the s2Member options on 15 min intervals.
34
+ * This allows the API Constants to provide quick access to them without being
35
+ * forced to execute {@link http://codex.wordpress.org/Function_Reference/get_page_link get_page_link()}
36
+ * all the time, which piles up DB queries.
37
+ *
38
+ * @package s2Member\Cache
39
+ * @since 3.5
40
+ *
41
+ * @return array Array of cached Page links.
42
  */
43
  public static function cached_page_links ()
44
  {
includes/classes/catgs-sp.inc.php CHANGED
@@ -1,37 +1,41 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_catgs_sp"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_catgs_sp
20
  {
21
- /*
22
- Function checks Category Level Access permissions- for a specific Category.
23
-
24
- Don't call this function directly, use one of these API functions:
25
-
26
- Is it protected by s2Member at all?
27
- - is_category_protected_by_s2member($cat_id);
28
- - is_protected_by_s2member($cat_id, "category");
29
-
30
- Is the current User permitted/authorized?
31
- - is_category_permitted_by_s2member($cat_id);
32
- - is_permitted_by_s2member($cat_id, "category");
33
-
34
- see: `/s2member/includes/functions/api-functions.inc.php`.
35
  */
36
  public static function check_specific_catg_level_access ($cat_id = FALSE, $check_user = TRUE)
37
  {
@@ -41,38 +45,35 @@ if (!class_exists ("c_ws_plugin__s2member_catgs_sp"))
41
  /**/
42
  if (!$excluded && $cat_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Check? */
43
  {
44
- $cat_link = get_category_link ($cat_id); /* Determine link to this Category. */
45
- $cat_path = parse_url ($cat_link, PHP_URL_PATH); /* Parse req path. */
46
- $cat_query = parse_url ($cat_link, PHP_URL_QUERY); /* Parse query. */
47
- $cat_uri = ($cat_query) ? $cat_path . "?" . $cat_query : $cat_path;
48
  /**/
49
- $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
50
  /**/
51
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $cat_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level0")))
52
  return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
53
  /**/
54
- else if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page (null, $cat_uri)) /* Never restrict Systematic Use Pages. However, there is 1 exception above ^. */
55
  {
56
- for ($i = 0; $i <= 4; $i++) /* Category Level restrictions. Go through each Membership Level. We also check nested Categories, using `cat_is_ancestor_of()`. */
57
  {
58
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] === "all" && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
59
- return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
60
  /**/
61
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] && in_array ($cat_id, ($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]))) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
62
- return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
63
  /**/
64
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]) /* Check Category ancestry. */
65
- foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]) as $catg)
66
- if ($catg && cat_is_ancestor_of ($catg, $cat_id) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
67
- return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
68
  }
69
  /**/
70
- for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
71
  {
72
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
73
- foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
74
- if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $cat_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
75
- return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
76
  }
77
  }
78
  /**/
1
  <?php
2
+ /**
3
+ * s2Member's Category protection routines *( for specific Categories )*.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Categories
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_catgs_sp"))
21
  {
22
+ /**
23
+ * s2Member's Category protection routines *( for specific Categories )*.
24
+ *
25
+ * @package s2Member\Categories
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_catgs_sp
29
  {
30
+ /**
31
+ * Handles Category Level Access *( for specific Categories )*.
32
+ *
33
+ * @package s2Member\Categories
34
+ * @since 3.5
35
+ *
36
+ * @param int|str $cat_id Numeric Category ID.
37
+ * @param bool $check_user Test permissions against the current User? Defaults to true.
38
+ * @return null|array Non-empty array ( with details ) if access is denied, else null if access is allowed.
 
 
 
 
 
39
  */
40
  public static function check_specific_catg_level_access ($cat_id = FALSE, $check_user = TRUE)
41
  {
45
  /**/
46
  if (!$excluded && $cat_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Check? */
47
  {
48
+ $cat_uri = c_ws_plugin__s2member_utils_urls::parse_uri (get_category_link ($cat_id));
 
 
 
49
  /**/
50
+ $user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
51
  /**/
52
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $cat_uri) && (!$check_user || !$user || !current_user_can ("access_s2member_level0")))
53
  return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
54
  /**/
55
+ else if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page (null, $cat_uri)) /* Never restrict Systematics. However, there is 1 exception ^. */
56
  {
57
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* Category Level restrictions. Go through each Level. We also check nested Categories. */
58
  {
59
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] === "all" && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
60
+ return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
61
  /**/
62
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] && in_array ($cat_id, ($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]))) && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
63
+ return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
64
  /**/
65
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]) /* Check Category ancestry. */
66
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]) as $catg)
67
+ if ($catg && cat_is_ancestor_of ($catg, $cat_id) && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
68
+ return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
69
  }
70
  /**/
71
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* URIs. Go through each Level. */
72
  {
73
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"])
74
+ foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str)
75
+ if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $cat_uri) && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
76
+ return apply_filters ("ws_plugin__s2member_check_specific_catg_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
77
  }
78
  }
79
  /**/
includes/classes/catgs.inc.php CHANGED
@@ -1,38 +1,39 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_catgs"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_catgs
20
  {
21
- /*
22
- Function for handling Category Level Access permissions.
23
- Attach to: add_action("template_redirect");
24
-
25
- Don't call this function directly, use one of these API functions:
26
-
27
- Is it protected by s2Member at all?
28
- - is_category_protected_by_s2member($cat_id);
29
- - is_protected_by_s2member($cat_id, "category");
30
-
31
- Is the current User permitted/authorized?
32
- - is_category_permitted_by_s2member($cat_id);
33
- - is_permitted_by_s2member($cat_id, "category");
34
-
35
- see: `/s2member/includes/functions/api-functions.inc.php`.
36
  */
37
  public static function check_catg_level_access ()
38
  {
@@ -44,45 +45,45 @@ if (!class_exists ("c_ws_plugin__s2member_catgs"))
44
  /**/
45
  if (!$excluded && is_category () && ($cat_id = get_query_var ("cat")) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
46
  {
47
- $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
48
  /**/
49
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")))
50
  {
51
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "catg-" . $cat_id, "s2member_level_req" => "0")), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
52
  exit ();
53
  }
54
  else if (!c_ws_plugin__s2member_systematics::is_systematic_use_page ()) /* Do NOT protect Systematics. However, there is 1 exception above ^. */
55
  {
56
- for ($i = 0; $i <= 4; $i++) /* Category Level restrictions. Go through each Membership Level. We also check nested Categories, using `cat_is_ancestor_of()`. */
57
  {
58
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] === "all" && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
59
  {
60
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "catg-" . $cat_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
61
  exit ();
62
  }
63
  /**/
64
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] && in_array ($cat_id, ($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]))) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
65
  {
66
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "catg-" . $cat_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
67
  exit ();
68
  }
69
  /**/
70
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]) /* Check Category ancestry. */
71
- foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"]) as $catg)
72
- if ($catg && cat_is_ancestor_of ($catg, $cat_id) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
73
  {
74
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "catg-" . $cat_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
75
  exit ();
76
  }
77
  }
78
  /**/
79
- for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
80
  {
81
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
82
- foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
83
- if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
84
  {
85
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "catg-" . $cat_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
86
  exit ();
87
  }
88
  }
1
  <?php
2
+ /**
3
+ * s2Member's Category protection routines *( for current page )*.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Categories
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_catgs"))
21
  {
22
+ /**
23
+ * s2Member's Category protection routines *( for current page )*.
24
+ *
25
+ * @package s2Member\Categories
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_catgs
29
  {
30
+ /**
31
+ * Handles Category Level Access *( for current page )*.
32
+ *
33
+ * @package s2Member\Categories
34
+ * @since 3.5
35
+ *
36
+ * @return null Or exits script execution after redirection.
 
 
 
 
 
 
 
 
37
  */
38
  public static function check_catg_level_access ()
39
  {
45
  /**/
46
  if (!$excluded && is_category () && ($cat_id = get_query_var ("cat")) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
47
  {
48
+ $user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
49
  /**/
50
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level0")))
51
  {
52
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "catg-" . $cat_id, "s2member_level_req" => "0")), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
53
  exit ();
54
  }
55
  else if (!c_ws_plugin__s2member_systematics::is_systematic_use_page ()) /* Do NOT protect Systematics. However, there is 1 exception above ^. */
56
  {
57
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* Category Level restrictions. Go through each Level. We also check nested Categories. */
58
  {
59
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
60
  {
61
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "catg-" . $cat_id, "s2member_level_req" => $n)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
62
  exit ();
63
  }
64
  /**/
65
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] && in_array ($cat_id, ($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]))) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
66
  {
67
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "catg-" . $cat_id, "s2member_level_req" => $n)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
68
  exit ();
69
  }
70
  /**/
71
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]) /* Check Category ancestry. */
72
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]) as $catg)
73
+ if ($catg && cat_is_ancestor_of ($catg, $cat_id) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
74
  {
75
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "catg-" . $cat_id, "s2member_level_req" => $n)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
76
  exit ();
77
  }
78
  }
79
  /**/
80
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* URIs. Go through each Level. */
81
  {
82
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"])
83
+ foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str)
84
+ if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
85
  {
86
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "catg-" . $cat_id, "s2member_level_req" => $n)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
87
  exit ();
88
  }
89
  }
includes/classes/check-activation.inc.php CHANGED
@@ -1,44 +1,51 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_check_activation"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_check_activation
20
  {
21
- /*
22
- Checks existing installs that are NOT yet re-activated.
23
- Attach to: add_action("admin_init");
 
 
 
 
 
 
24
  */
25
  public static function check () /* Up-to-date? */
26
  {
27
- $v = get_option ("ws_plugin__s2member_activated_version");
28
- /**/
29
- if (!$v || !version_compare ($v, WS_PLUGIN__S2MEMBER_VERSION, ">="))
30
  {
31
  c_ws_plugin__s2member_installation::activate ();
32
  }
33
- /**/
34
- else if (is_multisite () && is_main_site ())
35
  {
36
- $mms_v = get_option ("ws_plugin__s2member_activated_mms_version");
37
- /**/
38
- if (!$mms_v || !version_compare ($mms_v, WS_PLUGIN__S2MEMBER_VERSION, ">="))
39
- {
40
- c_ws_plugin__s2member_installation::activate ();
41
- }
42
  }
43
  /**/
44
  return; /* Return for uniformity. */
1
  <?php
2
+ /**
3
+ * s2Member's self re-activation routines.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Installation
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_check_activation"))
21
  {
22
+ /**
23
+ * s2Member's self re-activation routines.
24
+ *
25
+ * @package s2Member\Installation
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_check_activation
29
  {
30
+ /**
31
+ * Checks for existing installs that are NOT yet re-activated.
32
+ *
33
+ * @package s2Member\Installation
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to ``add_action("admin_init");``
37
+ *
38
+ * @return null
39
  */
40
  public static function check () /* Up-to-date? */
41
  {
42
+ if (!($v = get_option ("ws_plugin__s2member_activated_version")) || !version_compare ($v, WS_PLUGIN__S2MEMBER_VERSION, ">="))
 
 
43
  {
44
  c_ws_plugin__s2member_installation::activate ();
45
  }
46
+ else if (is_multisite () && is_main_site () && (!($mms_v = get_option ("ws_plugin__s2member_activated_mms_version")) || !version_compare ($mms_v, WS_PLUGIN__S2MEMBER_VERSION, ">=")))
 
47
  {
48
+ c_ws_plugin__s2member_installation::activate ();
 
 
 
 
 
49
  }
50
  /**/
51
  return; /* Return for uniformity. */
includes/classes/constants.inc.php CHANGED
@@ -1,27 +1,47 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_constants"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_constants
20
  {
21
- /*
22
- Defines several API Constants for s2Member.
23
- Note that these are duplicated into the JavaScript API as well.
24
- Attach to: add_action("init");
 
 
 
 
 
 
 
 
 
 
 
25
  */
26
  public static function constants ()
27
  {
@@ -38,96 +58,2194 @@ if (!class_exists ("c_ws_plugin__s2member_constants"))
38
  $custom = ($user) ? get_user_option ("s2member_custom", $user->ID) : "";
39
  $subscr_id = ($user) ? get_user_option ("s2member_subscr_id", $user->ID) : "";
40
  $subscr_gateway = ($user) ? get_user_option ("s2member_subscr_gateway", $user->ID) : "";
 
41
  $custom_fields = ($user) ? get_user_option ("s2member_custom_fields", $user->ID) : array ();
42
  $paid_registration_times = ($user) ? get_user_option ("s2member_paid_registration_times", $user->ID) : array ();
43
  /**/
44
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
45
  do_action ("ws_plugin__s2member_during_constants", get_defined_vars ());
46
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
47
- /**/
48
- define ("S2MEMBER_VERSION", ($c[] = (string)WS_PLUGIN__S2MEMBER_VERSION));
49
- /**/
50
- define ("S2MEMBER_CURRENT_USER_IS_LOGGED_IN", ($c[] = (($user) ? true : false)));
51
- define ("S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER", ($c[] = ( ($user && $level >= 1) ? true : false)));
52
- define ("S2MEMBER_CURRENT_USER_ACCESS_LEVEL", ($c[] = (int)$level)); /* Negative -1 through max Membership Level number. */
53
- define ("S2MEMBER_CURRENT_USER_ACCESS_LABEL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_label"]));
54
- define ("S2MEMBER_CURRENT_USER_SUBSCR_ID", ($c[] = (($user) ? (string)$subscr_id : ""))); /* A Member's Paid Subscription ID. */
55
- define ("S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID", ($c[] = (($user) ? (($subscr_id) ? (string)$subscr_id : (string)$user->ID) : "")));
56
- define ("S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY", ($c[] = (($user) ? (string)$subscr_gateway : ""))); /* Payment Gateway. */
57
- define ("S2MEMBER_CURRENT_USER_CUSTOM", ($c[] = (($user) ? (string)$custom : ""))); /* Starts w/ domain name. */
58
- define ("S2MEMBER_CURRENT_USER_REGISTRATION_TIME", ($c[] = ( ($user && $user->user_registered) ? (int)strtotime ($user->user_registered) : 0)));
59
- define ("S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME", ($c[] = ( ($user && (int)$paid_registration_times["level"]) ? (int)$paid_registration_times["level"] : 0)));
60
- define ("S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS", ($c[] = ( ($user && (int)$paid_registration_times["level"]) ? (int)floor ((strtotime ("now") - (int)$paid_registration_times["level"]) / 86400) : 0)));
61
- define ("S2MEMBER_CURRENT_USER_REGISTRATION_DAYS", ($c[] = ( ($user && $user->user_registered) ? (int)floor ((strtotime ("now") - strtotime ($user->user_registered)) / 86400) : 0)));
62
- define ("S2MEMBER_CURRENT_USER_DISPLAY_NAME", ($c[] = (($user) ? (string)$user->display_name : "")));
63
- define ("S2MEMBER_CURRENT_USER_FIRST_NAME", ($c[] = (($user) ? (string)$user->first_name : "")));
64
- define ("S2MEMBER_CURRENT_USER_LAST_NAME", ($c[] = (($user) ? (string)$user->last_name : "")));
65
- define ("S2MEMBER_CURRENT_USER_LOGIN", ($c[] = (($user) ? (string)$user->user_login : "")));
66
- define ("S2MEMBER_CURRENT_USER_EMAIL", ($c[] = (($user) ? (string)$user->user_email : "")));
67
- define ("S2MEMBER_CURRENT_USER_IP", ($c[] = (string)$_SERVER["REMOTE_ADDR"]));
68
- define ("S2MEMBER_CURRENT_USER_ID", ($c[] = (($user) ? (int)$user->ID : 0)));
69
- /**/
70
- define ("S2MEMBER_CURRENT_USER_FIELDS", ($c[] = (($user) ? json_encode (array_merge (array ("id" => S2MEMBER_CURRENT_USER_ID, "ip" => S2MEMBER_CURRENT_USER_IP, "email" => S2MEMBER_CURRENT_USER_EMAIL, "login" => S2MEMBER_CURRENT_USER_LOGIN, "first_name" => S2MEMBER_CURRENT_USER_FIRST_NAME, "last_name" => S2MEMBER_CURRENT_USER_LAST_NAME, "display_name" => S2MEMBER_CURRENT_USER_DISPLAY_NAME, "subscr_id" => S2MEMBER_CURRENT_USER_SUBSCR_ID, "subscr_or_wp_id" => S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID, "subscr_gateway" => S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY, "custom" => S2MEMBER_CURRENT_USER_CUSTOM), (array)$custom_fields)) : json_encode (array ()))));
71
- /**/
72
- define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED", ($c[] = (int)$file_downloads["allowed"]));
73
- define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED", ($c[] = ( ($file_downloads["allowed"] >= 999999999) ? true : false)));
74
- define ("S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY", ($c[] = (int)$file_downloads["currently"]));
75
- define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS", ($c[] = (int)$file_downloads["allowed_days"]));
76
- /**/
77
- define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]));
78
- define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]));
79
- define ("S2MEMBER_LOGIN_WELCOME_PAGE_ID", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
80
- /**/
81
- define ("S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL", ($c[] = (string)site_url ("/?s2member_profile=1")));
82
- define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL", ($c[] = (string)$links["file_download_limit_exceeded_page"]));
83
- define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL", ($c[] = (string)$links["membership_options_page"])); /* Signup page. */
84
- define ("S2MEMBER_LOGIN_WELCOME_PAGE_URL", ($c[] = (($login_redirection_url) ? (string)$login_redirection_url : (string)$links["login_welcome_page"])));
85
- define ("S2MEMBER_LOGOUT_PAGE_URL", ($c[] = (string)wp_logout_url ())); /* This triggers `wp_nonce_tick()`; watch out for dynamic changes. */
86
- define ("S2MEMBER_LOGIN_PAGE_URL", ($c[] = (string)wp_login_url ())); /* Will not trigger `wp_nonce_tick()`, no worries in this case. */
87
- /**/
88
- define ("S2MEMBER_LEVEL0_LABEL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_label"]));
89
- define ("S2MEMBER_LEVEL1_LABEL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_label"]));
90
- define ("S2MEMBER_LEVEL2_LABEL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_label"]));
91
- define ("S2MEMBER_LEVEL3_LABEL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_label"]));
92
- define ("S2MEMBER_LEVEL4_LABEL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_label"]));
93
- /**/
94
- define ("S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed"]));
95
- define ("S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed"]));
96
- define ("S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed"]));
97
- define ("S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed"]));
98
- define ("S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed"]));
99
- /**/
100
- define ("S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED_DAYS", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed_days"]));
101
- define ("S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED_DAYS", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"]));
102
- define ("S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED_DAYS", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"]));
103
- define ("S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED_DAYS", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"]));
104
- define ("S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED_DAYS", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"]));
105
- /**/
106
- define ("S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_inline_extensions"]));
107
- /**/
108
- define ("S2MEMBER_REG_EMAIL_FROM_NAME", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]));
109
- define ("S2MEMBER_REG_EMAIL_FROM_EMAIL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"]));
110
- /**/
111
- define ("S2MEMBER_PAYPAL_NOTIFY_URL", ($c[] = (string)site_url ("/?s2member_paypal_notify=1")));
112
- define ("S2MEMBER_PAYPAL_RETURN_URL", ($c[] = (string)site_url ("/?s2member_paypal_return=1")));
113
- /**/
114
- define ("S2MEMBER_PAYPAL_BUSINESS", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"]));
115
- define ("S2MEMBER_PAYPAL_ENDPOINT", ($c[] = ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com")));
116
- define ("S2MEMBER_PAYPAL_API_ENDPOINT", ($c[] = ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "api-3t.sandbox.paypal.com" : "api-3t.paypal.com")));
117
- define ("S2MEMBER_PAYPAL_API_USERNAME", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_username"]));
118
- define ("S2MEMBER_PAYPAL_API_PASSWORD", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_password"]));
119
- define ("S2MEMBER_PAYPAL_API_SIGNATURE", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_signature"]));
120
- /**/
121
- define ("S2MEMBER_PAYPAL_PDT_IDENTITY_TOKEN", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_identity_token"]));
122
- /**/
123
- define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0", ($c[] = ((S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID) ? "Updating Subscr. ID" : "")));
124
- define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0", ($c[] = ((S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID) ? S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID : "")));
125
- /**/
126
- $c = apply_filters ("ws_plugin__s2member_during_constants_c", $c, get_defined_vars ()); /* Allows other Constants to be calculated nicely. */
127
- /**/
128
- define ("WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5", md5 (serialize ($c) . c_ws_plugin__s2member_utilities::ver_checksum ())); /* Checksum. */
129
- /**/
130
- do_action ("ws_plugin__s2member_after_constants", get_defined_vars ()); /* Calls the after Hook. Do NOT set Constants here. */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  /**/
132
  return; /* Return for uniformity. */
133
  }
1
  <?php
2
+ /**
3
+ * s2Member's API Constants *( for site owners )*.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\API_Constants
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_constants"))
21
  {
22
+ /**
23
+ * s2Member's API Constants *( for site owners )*.
24
+ *
25
+ * @package s2Member\API_Constants
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_constants
29
  {
30
+ /**
31
+ * Defines several API Constants for s2Member.
32
+ *
33
+ * These are also duplicated into the JavaScript API for s2Member.
34
+ * Except for a few that would pose a security issue. Such as the PayPal® API Credentials;
35
+ * those are NOT included in the JavaScript API.
36
+ *
37
+ * @package s2Member\API_Constants
38
+ * @since 3.5
39
+ *
40
+ * @attaches-to ``add_action("init");``
41
+ *
42
+ * @return null
43
+ *
44
+ * @todo See if it's possible to further optimize this routine?
45
  */
46
  public static function constants ()
47
  {
58
  $custom = ($user) ? get_user_option ("s2member_custom", $user->ID) : "";
59
  $subscr_id = ($user) ? get_user_option ("s2member_subscr_id", $user->ID) : "";
60
  $subscr_gateway = ($user) ? get_user_option ("s2member_subscr_gateway", $user->ID) : "";
61
+ $registration_ip = ($user) ? get_user_option ("s2member_registration_ip", $user->ID) : "";
62
  $custom_fields = ($user) ? get_user_option ("s2member_custom_fields", $user->ID) : array ();
63
  $paid_registration_times = ($user) ? get_user_option ("s2member_paid_registration_times", $user->ID) : array ();
64
  /**/
65
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
66
  do_action ("ws_plugin__s2member_during_constants", get_defined_vars ());
67
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
68
+ /**
69
+ * Current version of s2Member.
70
+ *
71
+ * ———— Quick PHP Code Sample ————
72
+ * ```
73
+ * <!php echo S2MEMBER_VERSION; !>
74
+ * ```
75
+ * ———— Shortcode & JavaScript Equivalents ————
76
+ * ```
77
+ * [s2Get constant="S2MEMBER_VERSION" /]
78
+ *
79
+ * <script type="text/javascript">
80
+ * document.write(S2MEMBER_VERSION);
81
+ * </script>
82
+ * ```
83
+ *
84
+ * @package s2Member\API_Constants
85
+ * @since 3.5
86
+ *
87
+ * @var str
88
+ *
89
+ * @see s2Member\WS_PLUGIN__S2MEMBER_VERSION
90
+ */
91
+ if (!defined ("S2MEMBER_VERSION"))
92
+ define ("S2MEMBER_VERSION", ($c[] = (string)WS_PLUGIN__S2MEMBER_VERSION));
93
+ /**
94
+ * Is the current User logged-in at all.
95
+ *
96
+ * True if the current User IS logged-in, else false.
97
+ *
98
+ * ———— Quick PHP Code Sample ————
99
+ * ```
100
+ * <!php
101
+ * if(S2MEMBER_CURRENT_USER_IS_LOGGED_IN)
102
+ * echo 'You ARE logged in.';
103
+ * !>
104
+ * ```
105
+ * ———— Shortcode & JavaScript Equivalents ————
106
+ * ```
107
+ * [s2If constant(S2MEMBER_CURRENT_USER_IS_LOGGED_IN)]
108
+ * You ARE logged-in.
109
+ * [/s2If]
110
+ *
111
+ * <script type="text/javascript">
112
+ * if(S2MEMBER_CURRENT_USER_IS_LOGGED_IN)
113
+ * document.write('You ARE logged-in.');
114
+ * </script>
115
+ * ```
116
+ *
117
+ * @package s2Member\API_Constants
118
+ * @since 3.5
119
+ *
120
+ * @var bool
121
+ *
122
+ * @see s2Member\API_Functions\is_user_not_logged_in()
123
+ * @see http://codex.wordpress.org/Function_Reference/is_user_logged_in is_user_logged_in()
124
+ *
125
+ * @see http://codex.wordpress.org/Function_Reference/wp_get_current_user wp_get_current_user()
126
+ */
127
+ if (!defined ("S2MEMBER_CURRENT_USER_IS_LOGGED_IN"))
128
+ define ("S2MEMBER_CURRENT_USER_IS_LOGGED_IN", ($c[] = (($user) ? true : false)));
129
+ /**
130
+ * Is the current User logged-in as a Member.
131
+ *
132
+ * True if the current User IS logged-in with a Membership Level greater than `0`, else false.
133
+ *
134
+ * ———— Quick PHP Code Sample ————
135
+ * ```
136
+ * <!php
137
+ * if(S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER)
138
+ * echo 'You ARE logged in at Level #1 or higher.';
139
+ * !>
140
+ * ```
141
+ * ———— Shortcode & JavaScript Equivalents ————
142
+ * ```
143
+ * [s2If constant(S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER)]
144
+ * You ARE logged in at Level #1 or higher.
145
+ * [/s2If]
146
+ *
147
+ * <script type="text/javascript">
148
+ * if(S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER)
149
+ * document.write('You ARE logged in at Level #1 or higher.');
150
+ * </script>
151
+ * ```
152
+ *
153
+ * @package s2Member\API_Constants
154
+ * @since 3.5
155
+ *
156
+ * @var bool
157
+ *
158
+ * @see s2Member\API_Functions\is_user_not_logged_in()
159
+ * @see http://codex.wordpress.org/Function_Reference/is_user_logged_in is_user_logged_in()
160
+ *
161
+ * @see s2Member\API_Functions\user_is()
162
+ * @see s2Member\API_Functions\user_is_not()
163
+ *
164
+ * @see s2Member\API_Functions\current_user_is()
165
+ * @see s2Member\API_Functions\current_user_is_not()
166
+ * @see s2Member\API_Functions\current_user_is_for_blog()
167
+ * @see s2Member\API_Functions\current_user_is_not_for_blog()
168
+ *
169
+ * @see s2Member\API_Functions\current_user_cannot()
170
+ * @see s2Member\API_Functions\current_user_cannot_for_blog()
171
+ * @see http://codex.wordpress.org/Function_Reference/user_can user_can()
172
+ * @see http://codex.wordpress.org/Function_Reference/current_user_can current_user_can()
173
+ * @see http://codex.wordpress.org/Function_Reference/current_user_can_for_blog current_user_can_for_blog()
174
+ *
175
+ * @see s2Member\API_Functions\get_user_field()
176
+ * @see `get_user_field("s2member_access_role")`
177
+ * @see `get_user_field("s2member_access_level")`
178
+ * @see `get_user_field("s2member_access_label")`
179
+ *
180
+ * @see http://codex.wordpress.org/Function_Reference/wp_get_current_user wp_get_current_user()
181
+ */
182
+ if (!defined ("S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER"))
183
+ define ("S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER", ($c[] = (($user && $level >= 1) ? true : false)));
184
+ /**
185
+ * The current User's Membership Access Level.
186
+ *
187
+ * Negative `-1` through max Membership Level number.
188
+ * Negative `-1` indicates they are NOT logged-in.
189
+ *
190
+ * ———— Quick PHP Code Sample ————
191
+ * ```
192
+ * <!php echo S2MEMBER_CURRENT_USER_ACCESS_LEVEL; !>
193
+ * ```
194
+ * ———— Shortcode & JavaScript Equivalents ————
195
+ * ```
196
+ * [s2Get constant="S2MEMBER_CURRENT_USER_ACCESS_LEVEL" /]
197
+ *
198
+ * <script type="text/javascript">
199
+ * document.write(S2MEMBER_CURRENT_USER_ACCESS_LEVEL);
200
+ * </script>
201
+ * ```
202
+ *
203
+ * @package s2Member\API_Constants
204
+ * @since 3.5
205
+ *
206
+ * @var int
207
+ *
208
+ * @see s2Member\API_Functions\get_user_field()
209
+ * @see `get_user_field("s2member_access_role")`
210
+ * @see `get_user_field("s2member_access_level")`
211
+ * @see `get_user_field("s2member_access_label")`
212
+ *
213
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_ACCESS_LABEL
214
+ *
215
+ * @see http://codex.wordpress.org/Function_Reference/wp_get_current_user wp_get_current_user()
216
+ */
217
+ if (!defined ("S2MEMBER_CURRENT_USER_ACCESS_LEVEL"))
218
+ define ("S2MEMBER_CURRENT_USER_ACCESS_LEVEL", ($c[] = (int)$level));
219
+ /**
220
+ * The current User's Membership Access Label.
221
+ *
222
+ * As configured by the site owner. Each Membership Level is associated with a Membership Label
223
+ * *( i.e. Bronze, Silver, Gold, Platinum )*, or whatever the site owner has configured.
224
+ *
225
+ * An empty string if NOT logged-in.
226
+ *
227
+ * ———— Quick PHP Code Sample ————
228
+ * ```
229
+ * <!php echo S2MEMBER_CURRENT_USER_ACCESS_LABEL; !>
230
+ * ```
231
+ * ———— Shortcode & JavaScript Equivalents ————
232
+ * ```
233
+ * [s2Get constant="S2MEMBER_CURRENT_USER_ACCESS_LABEL" /]
234
+ *
235
+ * <script type="text/javascript">
236
+ * document.write(S2MEMBER_CURRENT_USER_ACCESS_LABEL);
237
+ * </script>
238
+ * ```
239
+ *
240
+ * @package s2Member\API_Constants
241
+ * @since 3.5
242
+ *
243
+ * @var str
244
+ *
245
+ * @see s2Member\API_Functions\get_user_field()
246
+ * @see `get_user_field("s2member_access_role")`
247
+ * @see `get_user_field("s2member_access_level")`
248
+ * @see `get_user_field("s2member_access_label")`
249
+ *
250
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_ACCESS_LEVEL
251
+ *
252
+ * @see http://codex.wordpress.org/Function_Reference/wp_get_current_user wp_get_current_user()
253
+ */
254
+ if (!defined ("S2MEMBER_CURRENT_USER_ACCESS_LABEL"))
255
+ define ("S2MEMBER_CURRENT_USER_ACCESS_LABEL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_label"]));
256
+ /**
257
+ * The current User's Paid Subscription ID ( when applicable ).
258
+ *
259
+ * An empty string if NOT logged-in.
260
+ *
261
+ * ———— Quick PHP Code Sample ————
262
+ * ```
263
+ * <!php echo S2MEMBER_CURRENT_USER_SUBSCR_ID; !>
264
+ * ```
265
+ * ———— Shortcode & JavaScript Equivalents ————
266
+ * ```
267
+ * [s2Get constant="S2MEMBER_CURRENT_USER_SUBSCR_ID" /]
268
+ *
269
+ * <script type="text/javascript">
270
+ * document.write(S2MEMBER_CURRENT_USER_SUBSCR_ID);
271
+ * </script>
272
+ * ```
273
+ *
274
+ * @package s2Member\API_Constants
275
+ * @since 3.5
276
+ *
277
+ * @var str
278
+ *
279
+ * @see s2Member\API_Functions\get_user_field()
280
+ * @see `get_user_field("s2member_subscr_id")`
281
+ *
282
+ * @see http://codex.wordpress.org/Function_Reference/get_user_option get_user_option()
283
+ * @see `get_user_option("s2member_subscr_id")`
284
+ *
285
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_CUSTOM
286
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID
287
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY
288
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_REGISTRATION_IP
289
+ *
290
+ * @see http://codex.wordpress.org/Function_Reference/wp_get_current_user wp_get_current_user()
291
+ */
292
+ if (!defined ("S2MEMBER_CURRENT_USER_SUBSCR_ID"))
293
+ define ("S2MEMBER_CURRENT_USER_SUBSCR_ID", ($c[] = (($user) ? (string)$subscr_id : "")));
294
+ /**
295
+ * The current User's Paid Subscription ID ( when applicable );
296
+ * otherwise, this will contain their WordPress® User ID.
297
+ *
298
+ * An empty string if NOT logged-in.
299
+ *
300
+ * ———— Quick PHP Code Sample ————
301
+ * ```
302
+ * <!php echo S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID; !>
303
+ * ```
304
+ * ———— Shortcode & JavaScript Equivalents ————
305
+ * ```
306
+ * [s2Get constant="S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID" /]
307
+ *
308
+ * <script type="text/javascript">
309
+ * document.write(S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID);
310
+ * </script>
311
+ * ```
312
+ *
313
+ * @package s2Member\API_Constants
314
+ * @since 3.5
315
+ *
316
+ * @var str
317
+ *
318
+ * @see s2Member\API_Functions\get_user_field()
319
+ * @see `get_user_field("s2member_subscr_or_wp_id")`
320
+ *
321
+ * @see http://codex.wordpress.org/Function_Reference/get_user_option get_user_option()
322
+ * @see `get_user_option("s2member_subscr_id")`
323
+ *
324
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_CUSTOM
325
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_SUBSCR_ID
326
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY
327
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_REGISTRATION_IP
328
+ *
329
+ * @see http://codex.wordpress.org/Function_Reference/wp_get_current_user wp_get_current_user()
330
+ */
331
+ if (!defined ("S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID"))
332
+ define ("S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID", ($c[] = (($user) ? (($subscr_id) ? (string)$subscr_id : (string)$user->ID) : "")));
333
+ /**
334
+ * The current User's Paid Subscription Gateway Code ( when applicable ).
335
+ *
336
+ * Usually one of these values: `paypal`, `authnet`, `clickbank`, `google`, `ccbill`, `alipay`.
337
+ *
338
+ * An empty string if NOT logged-in, or if NOT a paying Member.
339
+ *
340
+ * ———— Quick PHP Code Sample ————
341
+ * ```
342
+ * <!php echo S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY; !>
343
+ * ```
344
+ * ———— Shortcode & JavaScript Equivalents ————
345
+ * ```
346
+ * [s2Get constant="S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY" /]
347
+ *
348
+ * <script type="text/javascript">
349
+ * document.write(S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY);
350
+ * </script>
351
+ * ```
352
+ *
353
+ * @package s2Member\API_Constants
354
+ * @since 3.5
355
+ *
356
+ * @var str
357
+ *
358
+ * @see s2Member\API_Functions\get_user_field()
359
+ * @see `get_user_field("s2member_subscr_gateway")`
360
+ *
361
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_CUSTOM
362
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_SUBSCR_ID
363
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID
364
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_REGISTRATION_IP
365
+ *
366
+ * @see http://codex.wordpress.org/Function_Reference/get_user_option get_user_option()
367
+ * @see `get_user_option("s2member_subscr_gateway")`
368
+ */
369
+ if (!defined ("S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY"))
370
+ define ("S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY", ($c[] = (($user) ? (string)$subscr_gateway : "")));
371
+ /**
372
+ * The current User's Custom String, associated with their Profile.
373
+ *
374
+ * For paying Members, this should always start with the installation domain name.
375
+ * This is taken from the `custom=""` Attribute in your Button/Form Shortcode.
376
+ *
377
+ * Other pipe delimited values may follow the installation domain name, if configured by the site owner.
378
+ * For instance, this might be equal to something like: `www.example.com|cv1|cv2|cv3`.
379
+ *
380
+ * An empty string if NOT logged-in, or if NOT a paying Member.
381
+ *
382
+ * ———— Quick PHP Code Sample ————
383
+ * ```
384
+ * <!php echo S2MEMBER_CURRENT_USER_CUSTOM; !>
385
+ * ```
386
+ * ———— Shortcode & JavaScript Equivalents ————
387
+ * ```
388
+ * [s2Get constant="S2MEMBER_CURRENT_USER_CUSTOM" /]
389
+ *
390
+ * <script type="text/javascript">
391
+ * document.write(S2MEMBER_CURRENT_USER_CUSTOM);
392
+ * </script>
393
+ * ```
394
+ *
395
+ * @package s2Member\API_Constants
396
+ * @since 3.5
397
+ *
398
+ * @var str
399
+ *
400
+ * @see s2Member\API_Functions\get_user_field()
401
+ * @see `get_user_field("s2member_custom")`
402
+ *
403
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_SUBSCR_ID
404
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID
405
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY
406
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_REGISTRATION_IP
407
+ *
408
+ * @see http://codex.wordpress.org/Function_Reference/get_user_option get_user_option()
409
+ * @see `get_user_option("s2member_custom")`
410
+ */
411
+ if (!defined ("S2MEMBER_CURRENT_USER_CUSTOM"))
412
+ define ("S2MEMBER_CURRENT_USER_CUSTOM", ($c[] = (($user) ? (string)$custom : "")));
413
+ /**
414
+ * The current User's Registration Time.
415
+ *
416
+ * The Registration Time, is the time at which the Username was created for the account, that's it.
417
+ * There's nothing special about this. This simply returns a {@link http://en.wikipedia.org/wiki/Unix_time Unix Timestamp}.
418
+ *
419
+ * This will be equal to `0` if NOT logged-in.
420
+ *
421
+ * ———— Quick PHP Code Sample ————
422
+ * ```
423
+ * <!php echo S2MEMBER_CURRENT_USER_REGISTRATION_TIME; !>
424
+ * ```
425
+ * ———— Shortcode & JavaScript Equivalents ————
426
+ * ```
427
+ * [s2Get constant="S2MEMBER_CURRENT_USER_REGISTRATION_TIME" /]
428
+ *
429
+ * <script type="text/javascript">
430
+ * document.write(S2MEMBER_CURRENT_USER_REGISTRATION_TIME);
431
+ * </script>
432
+ * ```
433
+ *
434
+ * @package s2Member\API_Constants
435
+ * @since 3.5
436
+ *
437
+ * @var int
438
+ *
439
+ * @see s2Member\API_Functions\s2member_registration_time()
440
+ *
441
+ * @see s2Member\API_Functions\s2member_paid_registration_time()
442
+ * @see `s2member_paid_registration_time("level1")`
443
+ *
444
+ * @see s2Member\API_Functions\get_user_field()
445
+ *
446
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_REGISTRATION_DAYS
447
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME
448
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS
449
+ *
450
+ * @see http://codex.wordpress.org/Function_Reference/get_user_option get_user_option()
451
+ */
452
+ if (!defined ("S2MEMBER_CURRENT_USER_REGISTRATION_TIME"))
453
+ define ("S2MEMBER_CURRENT_USER_REGISTRATION_TIME", ($c[] = (($user && $user->user_registered) ? (int)strtotime ($user->user_registered) : 0)));
454
+ /**
455
+ * The current User's first Paid Registration Time; regardless of which paid Level they gained access to.
456
+ *
457
+ * **NOTE** A Paid Registration Time, is NOT necessarily related specifically to a Payment.
458
+ * s2Member records a Paid Registration Time, anytime a User acquires paid Membership Level Access.
459
+ *
460
+ * In other words, if you create a new User inside your Dashboard at a Membership Level greater than Level #0,
461
+ * s2Member will record a Paid Registration Time immediately, because Membership Levels > 0, are reserved for paying Members.
462
+ * s2Member monitors changes to all User accounts, and records the first Paid Registration Time for each Member, at each paid Membership Level.
463
+ * So, s2Member stores the first Time a Member reaches each Level of paid access; and s2Member does NOT care if they *actually* paid, or not.
464
+ *
465
+ * If the current User has never been at a paid Membership Level, this will be equal to `0`.
466
+ *
467
+ * This will be equal to `0` if NOT logged-in.
468
+ *
469
+ * ———— Quick PHP Code Sample ————
470
+ * ```
471
+ * <!php echo S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME; !>
472
+ * ```
473
+ * ———— Shortcode & JavaScript Equivalents ————
474
+ * ```
475
+ * [s2Get constant="S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME" /]
476
+ *
477
+ * <script type="text/javascript">
478
+ * document.write(S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME);
479
+ * </script>
480
+ * ```
481
+ *
482
+ * If you need to know the last time an actual payment was received, please use ``get_user_option ("s2member_last_payment_time")``.
483
+ *
484
+ * @package s2Member\API_Constants
485
+ * @since 3.5
486
+ *
487
+ * @var int
488
+ *
489
+ * @see s2Member\API_Functions\s2member_registration_time()
490
+ *
491
+ * @see s2Member\API_Functions\s2member_paid_registration_time()
492
+ * @see `s2member_paid_registration_time("level1")`
493
+ *
494
+ * @see s2Member\API_Functions\get_user_field()
495
+ *
496
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_REGISTRATION_TIME
497
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_REGISTRATION_DAYS
498
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS
499
+ *
500
+ * @see http://codex.wordpress.org/Function_Reference/get_user_option get_user_option()
501
+ */
502
+ if (!defined ("S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME"))
503
+ define ("S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME", ($c[] = (($user && (int)$paid_registration_times["level"]) ? (int)$paid_registration_times["level"] : 0)));
504
+ /**
505
+ * The number of days the current User has been a paid Member.
506
+ *
507
+ * **NOTE** This is calculated using the first Paid Registration Time.
508
+ * A Paid Registration Time, is NOT necessarily related specifically to a Payment.
509
+ * s2Member records a Paid Registration Time, anytime a User acquires paid Membership Level Access.
510
+ *
511
+ * In other words, if you create a new User inside your Dashboard at a Membership Level greater than Level #0,
512
+ * s2Member will record a Paid Registration Time immediately, because Membership Levels > 0, are reserved for paying Members.
513
+ * s2Member monitors changes to all User accounts, and records the first Paid Registration Time for each Member, at each paid Membership Level.
514
+ * So, s2Member stores the first Time a Member reaches each Level of paid access; and s2Member does NOT care if they *actually* paid, or not.
515
+ *
516
+ * If the current User has never been at a paid Membership Level, this will be equal to `0`.
517
+ *
518
+ * This will be equal to `0` if NOT logged-in.
519
+ *
520
+ * ———— Quick PHP Code Sample ————
521
+ * ```
522
+ * <!php echo S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS; !>
523
+ * ```
524
+ * ———— Shortcode & JavaScript Equivalents ————
525
+ * ```
526
+ * [s2Get constant="S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS" /]
527
+ *
528
+ * <script type="text/javascript">
529
+ * document.write(S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS);
530
+ * </script>
531
+ * ```
532
+ *
533
+ * If you need to know the last time an actual payment was received, please use ``get_user_option ("s2member_last_payment_time")``.
534
+ *
535
+ * @package s2Member\API_Constants
536
+ * @since 3.5
537
+ *
538
+ * @var int
539
+ *
540
+ * @see s2Member\API_Functions\s2member_registration_time()
541
+ *
542
+ * @see s2Member\API_Functions\s2member_paid_registration_time()
543
+ * @see `s2member_paid_registration_time("level1")`
544
+ *
545
+ * @see s2Member\API_Functions\get_user_field()
546
+ *
547
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_REGISTRATION_TIME
548
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_REGISTRATION_DAYS
549
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME
550
+ *
551
+ * @see http://codex.wordpress.org/Function_Reference/get_user_option get_user_option()
552
+ */
553
+ if (!defined ("S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS"))
554
+ define ("S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS", ($c[] = (($user && (int)$paid_registration_times["level"]) ? (int)floor ((strtotime ("now") - (int)$paid_registration_times["level"]) / 86400) : 0)));
555
+ /**
556
+ * The number of days the current User has had an account, period.
557
+ *
558
+ * **NOTE** This is calculated with Registration Time.
559
+ * The Registration Time, is the time at which the Username was created for the account, that's it.
560
+ *
561
+ * This will be equal to `0` if NOT logged-in.
562
+ *
563
+ * ———— Quick PHP Code Sample ————
564
+ * ```
565
+ * <!php echo S2MEMBER_CURRENT_USER_REGISTRATION_DAYS; !>
566
+ * ```
567
+ * ———— Shortcode & JavaScript Equivalents ————
568
+ * ```
569
+ * [s2Get constant="S2MEMBER_CURRENT_USER_REGISTRATION_DAYS" /]
570
+ *
571
+ * <script type="text/javascript">
572
+ * document.write(S2MEMBER_CURRENT_USER_REGISTRATION_DAYS);
573
+ * </script>
574
+ * ```
575
+ *
576
+ * @package s2Member\API_Constants
577
+ * @since 3.5
578
+ *
579
+ * @var int
580
+ *
581
+ * @see s2Member\API_Functions\s2member_registration_time()
582
+ *
583
+ * @see s2Member\API_Functions\s2member_paid_registration_time()
584
+ * @see `s2member_paid_registration_time("level1")`
585
+ *
586
+ * @see s2Member\API_Functions\get_user_field()
587
+ *
588
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_REGISTRATION_TIME
589
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME
590
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS
591
+ *
592
+ * @see http://codex.wordpress.org/Function_Reference/get_user_option get_user_option()
593
+ */
594
+ if (!defined ("S2MEMBER_CURRENT_USER_REGISTRATION_DAYS"))
595
+ define ("S2MEMBER_CURRENT_USER_REGISTRATION_DAYS", ($c[] = (($user && $user->user_registered) ? (int)floor ((strtotime ("now") - strtotime ($user->user_registered)) / 86400) : 0)));
596
+ /**
597
+ * The current User's Display Name.
598
+ *
599
+ * This is usually a name they prefer to be known by publicly.
600
+ * Some Users/Members prefer to use their First Name as the Display Name, and keep their Last Name private.
601
+ *
602
+ * An empty string if NOT logged-in.
603
+ *
604
+ * ———— Quick PHP Code Sample ————
605
+ * ```
606
+ * <!php echo S2MEMBER_CURRENT_USER_DISPLAY_NAME; !>
607
+ * ```
608
+ * ———— Shortcode & JavaScript Equivalents ————
609
+ * ```
610
+ * [s2Get constant="S2MEMBER_CURRENT_USER_DISPLAY_NAME" /]
611
+ *
612
+ * <script type="text/javascript">
613
+ * document.write(S2MEMBER_CURRENT_USER_DISPLAY_NAME);
614
+ * </script>
615
+ * ```
616
+ *
617
+ * @package s2Member\API_Constants
618
+ * @since 3.5
619
+ *
620
+ * @var str
621
+ *
622
+ * @see s2Member\API_Functions\get_user_field()
623
+ * @see `get_user_field("display_name")`
624
+ *
625
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_ID
626
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_IP
627
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_REGISTRATION_IP
628
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_LOGIN
629
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_EMAIL
630
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_FIRST_NAME
631
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_LAST_NAME
632
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_FIELDS
633
+ *
634
+ * @see http://codex.wordpress.org/Function_Reference/wp_get_current_user wp_get_current_user()
635
+ */
636
+ if (!defined ("S2MEMBER_CURRENT_USER_DISPLAY_NAME"))
637
+ define ("S2MEMBER_CURRENT_USER_DISPLAY_NAME", ($c[] = (($user) ? (string)$user->display_name : "")));
638
+ /**
639
+ * The current User's First Name.
640
+ *
641
+ * An empty string if NOT logged-in.
642
+ *
643
+ * ———— Quick PHP Code Sample ————
644
+ * ```
645
+ * <!php echo S2MEMBER_CURRENT_USER_FIRST_NAME; !>
646
+ * ```
647
+ * ———— Shortcode & JavaScript Equivalents ————
648
+ * ```
649
+ * [s2Get constant="S2MEMBER_CURRENT_USER_FIRST_NAME" /]
650
+ *
651
+ * <script type="text/javascript">
652
+ * document.write(S2MEMBER_CURRENT_USER_FIRST_NAME);
653
+ * </script>
654
+ * ```
655
+ *
656
+ * @package s2Member\API_Constants
657
+ * @since 3.5
658
+ *
659
+ * @var str
660
+ *
661
+ * @see s2Member\API_Functions\get_user_field()
662
+ * @see `get_user_field("first_name")`
663
+ *
664
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_ID
665
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_IP
666
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_REGISTRATION_IP
667
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_LOGIN
668
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_EMAIL
669
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_LAST_NAME
670
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DISPLAY_NAME
671
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_FIELDS
672
+ *
673
+ * @see http://codex.wordpress.org/Function_Reference/wp_get_current_user wp_get_current_user()
674
+ */
675
+ if (!defined ("S2MEMBER_CURRENT_USER_FIRST_NAME"))
676
+ define ("S2MEMBER_CURRENT_USER_FIRST_NAME", ($c[] = (($user) ? (string)$user->first_name : "")));
677
+ /**
678
+ * The current User's Last Name.
679
+ *
680
+ * An empty string if NOT logged-in.
681
+ *
682
+ * ———— Quick PHP Code Sample ————
683
+ * ```
684
+ * <!php echo S2MEMBER_CURRENT_USER_LAST_NAME; !>
685
+ * ```
686
+ * ———— Shortcode & JavaScript Equivalents ————
687
+ * ```
688
+ * [s2Get constant="S2MEMBER_CURRENT_USER_LAST_NAME" /]
689
+ *
690
+ * <script type="text/javascript">
691
+ * document.write(S2MEMBER_CURRENT_USER_LAST_NAME);
692
+ * </script>
693
+ * ```
694
+ *
695
+ * @package s2Member\API_Constants
696
+ * @since 3.5
697
+ *
698
+ * @var str
699
+ *
700
+ * @see s2Member\API_Functions\get_user_field()
701
+ * @see `get_user_field("last_name")`
702
+ *
703
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_ID
704
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_IP
705
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_REGISTRATION_IP
706
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_LOGIN
707
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_EMAIL
708
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_FIRST_NAME
709
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DISPLAY_NAME
710
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_FIELDS
711
+ *
712
+ * @see http://codex.wordpress.org/Function_Reference/wp_get_current_user wp_get_current_user()
713
+ */
714
+ if (!defined ("S2MEMBER_CURRENT_USER_LAST_NAME"))
715
+ define ("S2MEMBER_CURRENT_USER_LAST_NAME", ($c[] = (($user) ? (string)$user->last_name : "")));
716
+ /**
717
+ * The current User's Username.
718
+ *
719
+ * An empty string if NOT logged-in.
720
+ *
721
+ * ———— Quick PHP Code Sample ————
722
+ * ```
723
+ * <!php echo S2MEMBER_CURRENT_USER_LOGIN; !>
724
+ * ```
725
+ * ———— Shortcode & JavaScript Equivalents ————
726
+ * ```
727
+ * [s2Get constant="S2MEMBER_CURRENT_USER_LOGIN" /]
728
+ *
729
+ * <script type="text/javascript">
730
+ * document.write(S2MEMBER_CURRENT_USER_LOGIN);
731
+ * </script>
732
+ * ```
733
+ *
734
+ * @package s2Member\API_Constants
735
+ * @since 3.5
736
+ *
737
+ * @var str
738
+ *
739
+ * @see s2Member\API_Functions\get_user_field()
740
+ * @see `get_user_field("user_login")`
741
+ *
742
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_ID
743
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_IP
744
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_REGISTRATION_IP
745
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_EMAIL
746
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_FIRST_NAME
747
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_LAST_NAME
748
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DISPLAY_NAME
749
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_FIELDS
750
+ *
751
+ * @see http://codex.wordpress.org/Function_Reference/wp_get_current_user wp_get_current_user()
752
+ */
753
+ if (!defined ("S2MEMBER_CURRENT_USER_LOGIN"))
754
+ define ("S2MEMBER_CURRENT_USER_LOGIN", ($c[] = (($user) ? (string)$user->user_login : "")));
755
+ /**
756
+ * The current User's Email Address.
757
+ *
758
+ * An empty string if NOT logged-in.
759
+ *
760
+ * ———— Quick PHP Code Sample ————
761
+ * ```
762
+ * <!php echo S2MEMBER_CURRENT_USER_EMAIL; !>
763
+ * ```
764
+ * ———— Shortcode & JavaScript Equivalents ————
765
+ * ```
766
+ * [s2Get constant="S2MEMBER_CURRENT_USER_EMAIL" /]
767
+ *
768
+ * <script type="text/javascript">
769
+ * document.write(S2MEMBER_CURRENT_USER_EMAIL);
770
+ * </script>
771
+ * ```
772
+ *
773
+ * @package s2Member\API_Constants
774
+ * @since 3.5
775
+ *
776
+ * @var str
777
+ *
778
+ * @see s2Member\API_Functions\get_user_field()
779
+ * @see `get_user_field("user_email")`
780
+ *
781
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_ID
782
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_IP
783
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_REGISTRATION_IP
784
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_LOGIN
785
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_FIRST_NAME
786
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_LAST_NAME
787
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DISPLAY_NAME
788
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_FIELDS
789
+ *
790
+ * @see http://codex.wordpress.org/Function_Reference/wp_get_current_user wp_get_current_user()
791
+ */
792
+ if (!defined ("S2MEMBER_CURRENT_USER_EMAIL"))
793
+ define ("S2MEMBER_CURRENT_USER_EMAIL", ($c[] = (($user) ? (string)$user->user_email : "")));
794
+ /**
795
+ * The current User's IP Address ( even if/when NOT logged-in ).
796
+ *
797
+ * This is the current IP Address, taken from ``$_SERVER["REMOTE_ADDR"]``.
798
+ *
799
+ * ———— Quick PHP Code Sample ————
800
+ * ```
801
+ * <!php echo S2MEMBER_CURRENT_USER_IP; !>
802
+ * ```
803
+ * ———— Shortcode & JavaScript Equivalents ————
804
+ * ```
805
+ * [s2Get constant="S2MEMBER_CURRENT_USER_IP" /]
806
+ *
807
+ * <script type="text/javascript">
808
+ * document.write(S2MEMBER_CURRENT_USER_IP);
809
+ * </script>
810
+ * ```
811
+ *
812
+ * @package s2Member\API_Constants
813
+ * @since 3.5
814
+ *
815
+ * @var str
816
+ *
817
+ * @see s2Member\API_Functions\get_user_field()
818
+ * @see `get_user_field("s2member_registration_ip")`
819
+ * @see `get_user_field("ip")`
820
+ *
821
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_REGISTRATION_IP
822
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_ID
823
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_LOGIN
824
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_EMAIL
825
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_FIRST_NAME
826
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_LAST_NAME
827
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DISPLAY_NAME
828
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_FIELDS
829
+ *
830
+ * @see http://www.php.net/manual/en/reserved.variables.server.php Superglobal $_SERVER
831
+ * @see `$_SERVER["REMOTE_ADDR"]`
832
+ */
833
+ if (!defined ("S2MEMBER_CURRENT_USER_IP"))
834
+ define ("S2MEMBER_CURRENT_USER_IP", ($c[] = (string)$_SERVER["REMOTE_ADDR"]));
835
+ /**
836
+ * IP Address the current User had during registration.
837
+ *
838
+ * This is the IP Address the User had at the time they registered.
839
+ * It's useful when you need to know the original IP Address they used.
840
+ * For instance, this is needed by some affiliate tracking systems; such as iDevAffiliate.
841
+ *
842
+ * An empty string if NOT logged-in.
843
+ *
844
+ * ———— Quick PHP Code Sample ————
845
+ * ```
846
+ * <!php echo S2MEMBER_CURRENT_USER_REGISTRATION_IP; !>
847
+ * ```
848
+ * ———— Shortcode & JavaScript Equivalents ————
849
+ * ```
850
+ * [s2Get constant="S2MEMBER_CURRENT_USER_REGISTRATION_IP" /]
851
+ *
852
+ * <script type="text/javascript">
853
+ * document.write(S2MEMBER_CURRENT_USER_REGISTRATION_IP);
854
+ * </script>
855
+ * ```
856
+ *
857
+ * @package s2Member\API_Constants
858
+ * @since 3.5
859
+ *
860
+ * @var str
861
+ *
862
+ * @see s2Member\API_Functions\get_user_field()
863
+ * @see `get_user_field("s2member_registration_ip")`
864
+ * @see `get_user_field("ip")`
865
+ *
866
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_IP
867
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_ID
868
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_LOGIN
869
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_EMAIL
870
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_FIRST_NAME
871
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_LAST_NAME
872
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DISPLAY_NAME
873
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_FIELDS
874
+ *
875
+ * @see http://www.php.net/manual/en/reserved.variables.server.php Superglobal $_SERVER
876
+ * @see `$_SERVER["REMOTE_ADDR"]`
877
+ */
878
+ if (!defined ("S2MEMBER_CURRENT_USER_REGISTRATION_IP"))
879
+ define ("S2MEMBER_CURRENT_USER_REGISTRATION_IP", ($c[] = (($user) ? (string)$registration_ip : "")));
880
+ /**
881
+ * The current User's WordPress® User ID.
882
+ *
883
+ * This will be equal to `0` if NOT logged-in.
884
+ *
885
+ * ———— Quick PHP Code Sample ————
886
+ * ```
887
+ * <!php echo S2MEMBER_CURRENT_USER_ID; !>
888
+ * ```
889
+ * ———— Shortcode & JavaScript Equivalents ————
890
+ * ```
891
+ * [s2Get constant="S2MEMBER_CURRENT_USER_ID" /]
892
+ *
893
+ * <script type="text/javascript">
894
+ * document.write(S2MEMBER_CURRENT_USER_ID);
895
+ * </script>
896
+ * ```
897
+ *
898
+ * @package s2Member\API_Constants
899
+ * @since 3.5
900
+ *
901
+ * @var int
902
+ *
903
+ * @see s2Member\API_Functions\get_user_field()
904
+ * @see `get_user_field("id")`
905
+ *
906
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_IP
907
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_REGISTRATION_IP
908
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_LOGIN
909
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_EMAIL
910
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_FIRST_NAME
911
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_LAST_NAME
912
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DISPLAY_NAME
913
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_FIELDS
914
+ *
915
+ * @see http://codex.wordpress.org/Function_Reference/wp_get_current_user wp_get_current_user()
916
+ */
917
+ if (!defined ("S2MEMBER_CURRENT_USER_ID"))
918
+ define ("S2MEMBER_CURRENT_USER_ID", ($c[] = (($user) ? (int)$user->ID : 0)));
919
+ /**
920
+ * The current User's fields, provided by s2Member.
921
+ *
922
+ * This holds a JSON-encoded array, containing these array keys:
923
+ *
924
+ * o `id` = value of {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_ID}
925
+ * o `ip` = value of {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_IP}
926
+ * o `email` = value of {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_EMAIL}
927
+ * o `login` = value of {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_LOGIN}
928
+ * o `first_name` = value of {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_FIRST_NAME}
929
+ * o `last_name` = value of {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_LAST_NAME}
930
+ * o `display_name` = value of {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_DISPLAY_NAME}
931
+ * o `subscr_id` = value of {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_SUBSCR_ID}
932
+ * o `subscr_or_wp_id` = value of {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID}
933
+ * o `subscr_gateway` = value of {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY}
934
+ * o `custom` = value of {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_CUSTOM}
935
+ * o and any Custom Registration Fields configured by the site owner.
936
+ *
937
+ * This will be an empty JSON-encoded array if NOT logged-in.
938
+ *
939
+ * ———— Code Sample ( Using ``json_decode(JSON, true)`` ) ————
940
+ * ```
941
+ * <!php
942
+ * $fields = json_decode(S2MEMBER_CURRENT_USER_FIELDS, true);
943
+ * echo $fields["email"]; # The current User's Email Address.
944
+ * echo $fields["my_unique_field_id"]; # A Custom Registration Field configured by the site owner.
945
+ * !>
946
+ * ```
947
+ * ———— Shortcode & JavaScript Equivalents ————
948
+ * ```
949
+ * [s2Get user_field="id" /]
950
+ * [s2Get user_field="ip" /]
951
+ * [s2Get user_field="user_email" /]
952
+ * [s2Get user_field="user_login" /]
953
+ * [s2Get user_field="first_name" /]
954
+ * [s2Get user_field="last_name" /]
955
+ * [s2Get user_field="display_name" /]
956
+ * [s2Get user_field="s2member_subscr_id" /]
957
+ * [s2Get user_field="s2member_subscr_wp_id" /]
958
+ * [s2Get user_field="s2member_subscr_gateway" /]
959
+ * [s2Get user_field="s2member_custom" /]
960
+ * [s2Get user_field="my_field_id" /]
961
+ *
962
+ * <script type="text/javascript">
963
+ * var obj = jQuery.parseJSON(S2MEMBER_CURRENT_USER_FIELDS);
964
+ * document.write(obj.display_name);
965
+ * </script>
966
+ * ```
967
+ *
968
+ * @package s2Member\API_Constants
969
+ * @since 3.5
970
+ *
971
+ * @var str
972
+ *
973
+ * @see s2Member\API_Functions\get_user_field()
974
+ *
975
+ * @see http://codex.wordpress.org/Function_Reference/wp_get_current_user wp_get_current_user()
976
+ */
977
+ if (!defined ("S2MEMBER_CURRENT_USER_FIELDS"))
978
+ define ("S2MEMBER_CURRENT_USER_FIELDS", ($c[] = (($user) ? json_encode (array_merge (array ("id" => S2MEMBER_CURRENT_USER_ID, "ip" => S2MEMBER_CURRENT_USER_IP, "email" => S2MEMBER_CURRENT_USER_EMAIL, "login" => S2MEMBER_CURRENT_USER_LOGIN, "first_name" => S2MEMBER_CURRENT_USER_FIRST_NAME, "last_name" => S2MEMBER_CURRENT_USER_LAST_NAME, "display_name" => S2MEMBER_CURRENT_USER_DISPLAY_NAME, "subscr_id" => S2MEMBER_CURRENT_USER_SUBSCR_ID, "subscr_or_wp_id" => S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID, "subscr_gateway" => S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY, "custom" => S2MEMBER_CURRENT_USER_CUSTOM), (array)$custom_fields)) : json_encode (array ()))));
979
+ /**
980
+ * Indicates the number of unique Files the current User is allowed to download every X days.
981
+ *
982
+ * `0` means no access to File Downloads has been made available to the User.
983
+ *
984
+ * This will be equal to `0` if NOT logged-in.
985
+ *
986
+ * ———— Quick PHP Code Sample ————
987
+ * ```
988
+ * <!php echo S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED; !>
989
+ * ```
990
+ * ———— Shortcode & JavaScript Equivalents ————
991
+ * ```
992
+ * [s2Get constant="S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED" /]
993
+ *
994
+ * <script type="text/javascript">
995
+ * document.write(S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED);
996
+ * </script>
997
+ * ```
998
+ *
999
+ * @package s2Member\API_Constants
1000
+ * @since 3.5
1001
+ *
1002
+ * @var int
1003
+ *
1004
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED
1005
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS
1006
+ *
1007
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY
1008
+ *
1009
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
1010
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
1011
+ *
1012
+ * @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED
1013
+ * @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS
1014
+ *
1015
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
1016
+ *
1017
+ * @see `Dashboard -> s2Member -> Download Options`
1018
+ */
1019
+ if (!defined ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED"))
1020
+ define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED", ($c[] = (int)$file_downloads["allowed"]));
1021
+ /**
1022
+ * Does the current User have access to unlimited File Downloads.
1023
+ *
1024
+ * A value of true means the current User's allowed downloads are >= `999999999`, and false means it is not.
1025
+ * This is useful if you are allowing unlimited ( i.e. `999999999+` ) Downloads on some Membership Levels.
1026
+ * You can display `Unlimited` instead of a numerical value.
1027
+ *
1028
+ * This will be false if NOT logged-in.
1029
+ *
1030
+ * ———— Quick PHP Code Sample ————
1031
+ * ```
1032
+ * <!php
1033
+ * if(S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED)
1034
+ * echo 'You have access to unlimited downloads.';
1035
+ * !>
1036
+ * ```
1037
+ * ———— Shortcode & JavaScript Equivalents ————
1038
+ * ```
1039
+ * [s2If constant(S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED)]
1040
+ * You have access to unlimited downloads.
1041
+ * [/s2If]
1042
+ *
1043
+ * <script type="text/javascript">
1044
+ * if(S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED)
1045
+ * document.write('You have access to unlimited downloads.');
1046
+ * </script>
1047
+ * ```
1048
+ *
1049
+ * @package s2Member\API_Constants
1050
+ * @since 3.5
1051
+ *
1052
+ * @var bool
1053
+ *
1054
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED
1055
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS
1056
+ *
1057
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY
1058
+ *
1059
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
1060
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
1061
+ *
1062
+ * @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED
1063
+ * @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS
1064
+ *
1065
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
1066
+ *
1067
+ * @see `Dashboard -> s2Member -> Download Options`
1068
+ */
1069
+ if (!defined ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED"))
1070
+ define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED", ($c[] = (($file_downloads["allowed"] >= 999999999) ? true : false)));
1071
+ /**
1072
+ * Indicates the number of unique Files the current User has downloaded in the last X days.
1073
+ *
1074
+ * This will be equal to `0` if NOT logged-in.
1075
+ *
1076
+ * ———— Quick PHP Code Sample ————
1077
+ * ```
1078
+ * <!php echo S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY; !>
1079
+ * ```
1080
+ * ———— Shortcode & JavaScript Equivalents ————
1081
+ * ```
1082
+ * [s2Get constant="S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY" /]
1083
+ *
1084
+ * <script type="text/javascript">
1085
+ * document.write(S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY);
1086
+ * </script>
1087
+ * ```
1088
+ *
1089
+ * @package s2Member\API_Constants
1090
+ * @since 3.5
1091
+ *
1092
+ * @var int
1093
+ *
1094
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED
1095
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED
1096
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS
1097
+ *
1098
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
1099
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
1100
+ *
1101
+ * @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED
1102
+ * @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS
1103
+ *
1104
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
1105
+ *
1106
+ * @see `Dashboard -> s2Member -> Download Options`
1107
+ */
1108
+ if (!defined ("S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY"))
1109
+ define ("S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY", ($c[] = (int)$file_downloads["currently"]));
1110
+ /**
1111
+ * Indicates the X number of days, configured by the site owner; for the current User.
1112
+ *
1113
+ * This will be equal to `0` if NOT logged-in.
1114
+ *
1115
+ * ———— Quick PHP Code Sample ————
1116
+ * ```
1117
+ * You are allowed to download <!php echo S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED; !> files, every <!php echo S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS; !> days.
1118
+ * You've downloaded <!php echo S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY; !> files in the last <!php echo S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS; !> days.
1119
+ * ```
1120
+ * ———— Shortcode & JavaScript Equivalents ————
1121
+ * ```
1122
+ * You are allowed to download [s2Get constant="S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED" /] files, every [s2Get constant="S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS" /] days.
1123
+ * You've downloaded [s2Get constant="S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY" /] files in the last [s2Get constant="S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS" /] days.
1124
+ *
1125
+ * You are allowed to download <script type="text/javascript">document.write(S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED);</script> files, every <script type="text/javascript">document.write(S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS);</script> days.
1126
+ * You've downloaded <script type="text/javascript">document.write(S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY);</script> files in the last <script type="text/javascript">document.write(S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS);</script> days.
1127
+ * ```
1128
+ *
1129
+ * @package s2Member\API_Constants
1130
+ * @since 3.5
1131
+ *
1132
+ * @var int
1133
+ *
1134
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED
1135
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED
1136
+ *
1137
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY
1138
+ *
1139
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
1140
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
1141
+ *
1142
+ * @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED
1143
+ * @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS
1144
+ *
1145
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
1146
+ *
1147
+ * @see `Dashboard -> s2Member -> Download Options`
1148
+ */
1149
+ if (!defined ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS"))
1150
+ define ("S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS", ($c[] = (int)$file_downloads["allowed_days"]));
1151
+ /**
1152
+ * The configured Page ID, for the Download Limit Exceeded Page.
1153
+ *
1154
+ * This will be equal to `0` if NOT yet configured.
1155
+ *
1156
+ * ———— Quick PHP Code Sample ————
1157
+ * ```
1158
+ * <!php echo S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID; !>
1159
+ * ```
1160
+ * ———— Shortcode & JavaScript Equivalents ————
1161
+ * ```
1162
+ * [s2Get constant="S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID" /]
1163
+ *
1164
+ * <script type="text/javascript">
1165
+ * document.write(S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID);
1166
+ * </script>
1167
+ * ```
1168
+ *
1169
+ * @package s2Member\API_Constants
1170
+ * @since 3.5
1171
+ *
1172
+ * @var int
1173
+ *
1174
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED
1175
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED
1176
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS
1177
+ *
1178
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY
1179
+ *
1180
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_PAGE_URL
1181
+ * @see s2Member\API_Constants\S2MEMBER_LOGOUT_PAGE_URL
1182
+ *
1183
+ * @see s2Member\API_Constants\S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID
1184
+ * @see s2Member\API_Constants\S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL
1185
+ *
1186
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_WELCOME_PAGE_ID
1187
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_WELCOME_PAGE_URL
1188
+ *
1189
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
1190
+ *
1191
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL
1192
+ *
1193
+ * @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED
1194
+ * @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS
1195
+ *
1196
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
1197
+ *
1198
+ * @see `Dashboard -> s2Member -> Download Options`
1199
+ */
1200
+ if (!defined ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID"))
1201
+ define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]));
1202
+ /**
1203
+ * The configured Page ID, for the Membership Options Page.
1204
+ *
1205
+ * This will be equal to `0` if NOT yet configured.
1206
+ *
1207
+ * ———— Quick PHP Code Sample ————
1208
+ * ```
1209
+ * <!php echo S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID; !>
1210
+ * ```
1211
+ * ———— Shortcode & JavaScript Equivalents ————
1212
+ * ```
1213
+ * [s2Get constant="S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID" /]
1214
+ *
1215
+ * <script type="text/javascript">
1216
+ * document.write(S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID);
1217
+ * </script>
1218
+ * ```
1219
+ *
1220
+ * @package s2Member\API_Constants
1221
+ * @since 3.5
1222
+ *
1223
+ * @var int
1224
+ *
1225
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_PAGE_URL
1226
+ * @see s2Member\API_Constants\S2MEMBER_LOGOUT_PAGE_URL
1227
+ *
1228
+ * @see s2Member\API_Constants\S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL
1229
+ *
1230
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_WELCOME_PAGE_ID
1231
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_WELCOME_PAGE_URL
1232
+ *
1233
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
1234
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
1235
+ *
1236
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL
1237
+ *
1238
+ * @see `Dashboard -> s2Member -> General Options -> Membership Options Page`
1239
+ */
1240
+ if (!defined ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID"))
1241
+ define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]));
1242
+ /**
1243
+ * The configured Page ID, for the Login Welcome Page.
1244
+ *
1245
+ * This will be equal to `0` if NOT yet configured.
1246
+ *
1247
+ * ———— Quick PHP Code Sample ————
1248
+ * ```
1249
+ * <!php echo S2MEMBER_LOGIN_WELCOME_PAGE_ID; !>
1250
+ * ```
1251
+ * ———— Shortcode & JavaScript Equivalents ————
1252
+ * ```
1253
+ * [s2Get constant="S2MEMBER_LOGIN_WELCOME_PAGE_ID" /]
1254
+ *
1255
+ * <script type="text/javascript">
1256
+ * document.write(S2MEMBER_LOGIN_WELCOME_PAGE_ID);
1257
+ * </script>
1258
+ * ```
1259
+ *
1260
+ * @package s2Member\API_Constants
1261
+ * @since 3.5
1262
+ *
1263
+ * @var int
1264
+ *
1265
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_PAGE_URL
1266
+ * @see s2Member\API_Constants\S2MEMBER_LOGOUT_PAGE_URL
1267
+ *
1268
+ * @see s2Member\API_Constants\S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID
1269
+ * @see s2Member\API_Constants\S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL
1270
+ *
1271
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_WELCOME_PAGE_URL
1272
+ *
1273
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
1274
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
1275
+ *
1276
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL
1277
+ *
1278
+ * @see `Dashboard -> s2Member -> General Options -> Login Welcome Page`
1279
+ */
1280
+ if (!defined ("S2MEMBER_LOGIN_WELCOME_PAGE_ID"))
1281
+ define ("S2MEMBER_LOGIN_WELCOME_PAGE_ID", ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
1282
+ /**
1283
+ * A URL, which leads to the Stand-Alone Profile Modification Page.
1284
+ *
1285
+ * This is always a reference to `/?s2member_profile=1` *( i.e. the Stand-Alone version )*.
1286
+ *
1287
+ * ———— Quick PHP Code Sample ————
1288
+ * ```
1289
+ * <!php echo S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL; !>
1290
+ * ```
1291
+ * ———— Shortcode & JavaScript Equivalents ————
1292
+ * ```
1293
+ * [s2Get constant="S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL" /]
1294
+ *
1295
+ * <script type="text/javascript">
1296
+ * document.write(S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL);
1297
+ * </script>
1298
+ * ```
1299
+ *
1300
+ * @package s2Member\API_Constants
1301
+ * @since 3.5
1302
+ *
1303
+ * @var str
1304
+ *
1305
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_PAGE_URL
1306
+ * @see s2Member\API_Constants\S2MEMBER_LOGOUT_PAGE_URL
1307
+ *
1308
+ * @see s2Member\API_Constants\S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID
1309
+ * @see s2Member\API_Constants\S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL
1310
+ *
1311
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_WELCOME_PAGE_ID
1312
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_WELCOME_PAGE_URL
1313
+ *
1314
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
1315
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
1316
+ *
1317
+ * @see `Dashboard -> s2Member -> General Options -> Profile Modifications`
1318
+ */
1319
+ if (!defined ("S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL"))
1320
+ define ("S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL", ($c[] = (string)site_url ("/?s2member_profile=1")));
1321
+ /**
1322
+ * A URL, which leads to the Download Limit Exceeded Page; as configured by the site owner.
1323
+ *
1324
+ * If the site owner has not yet configured a Download Limit Exceeded Page, this defaults to the Home Page.
1325
+ *
1326
+ * ———— Quick PHP Code Sample ————
1327
+ * ```
1328
+ * <!php echo S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL; !>
1329
+ * ```
1330
+ * ———— Shortcode & JavaScript Equivalents ————
1331
+ * ```
1332
+ * [s2Get constant="S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL" /]
1333
+ *
1334
+ * <script type="text/javascript">
1335
+ * document.write(S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL);
1336
+ * </script>
1337
+ * ```
1338
+ *
1339
+ * @package s2Member\API_Constants
1340
+ * @since 3.5
1341
+ *
1342
+ * @var str
1343
+ *
1344
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED
1345
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED
1346
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS
1347
+ *
1348
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY
1349
+ *
1350
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_PAGE_URL
1351
+ * @see s2Member\API_Constants\S2MEMBER_LOGOUT_PAGE_URL
1352
+ *
1353
+ * @see s2Member\API_Constants\S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID
1354
+ * @see s2Member\API_Constants\S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL
1355
+ *
1356
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_WELCOME_PAGE_ID
1357
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_WELCOME_PAGE_URL
1358
+ *
1359
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
1360
+ *
1361
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL
1362
+ *
1363
+ * @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED
1364
+ * @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS
1365
+ *
1366
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
1367
+ *
1368
+ * @see `Dashboard -> s2Member -> Download Options`
1369
+ */
1370
+ if (!defined ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL"))
1371
+ define ("S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL", ($c[] = (string)$links["file_download_limit_exceeded_page"]));
1372
+ /**
1373
+ * A URL, which leads to the Membership Options Page; as configured by the site owner.
1374
+ *
1375
+ * If the site owner has not yet configured a Membership Options Page, this defaults to the Home Page.
1376
+ *
1377
+ * ———— Quick PHP Code Sample ————
1378
+ * ```
1379
+ * <!php echo S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL; !>
1380
+ * ```
1381
+ * ———— Shortcode & JavaScript Equivalents ————
1382
+ * ```
1383
+ * [s2Get constant="S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL" /]
1384
+ *
1385
+ * <script type="text/javascript">
1386
+ * document.write(S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
1387
+ * </script>
1388
+ * ```
1389
+ *
1390
+ * @package s2Member\API_Constants
1391
+ * @since 3.5
1392
+ *
1393
+ * @var str
1394
+ *
1395
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_PAGE_URL
1396
+ * @see s2Member\API_Constants\S2MEMBER_LOGOUT_PAGE_URL
1397
+ *
1398
+ * @see s2Member\API_Constants\S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID
1399
+ *
1400
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_WELCOME_PAGE_ID
1401
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_WELCOME_PAGE_URL
1402
+ *
1403
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
1404
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
1405
+ *
1406
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL
1407
+ *
1408
+ * @see `Dashboard -> s2Member -> General Options -> Membership Options Page`
1409
+ */
1410
+ if (!defined ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL"))
1411
+ define ("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL", ($c[] = (string)$links["membership_options_page"])); /* Signup page. */
1412
+ /**
1413
+ * The URL, which leads to the Login Welcome Page; as configured by the site owner.
1414
+ *
1415
+ * If the site owner has not yet configured a Login Welcome Page, this defaults to the Home Page.
1416
+ *
1417
+ * ———— Quick PHP Code Sample ————
1418
+ * ```
1419
+ * <!php echo S2MEMBER_LOGIN_WELCOME_PAGE_URL; !>
1420
+ * ```
1421
+ * ———— Shortcode & JavaScript Equivalents ————
1422
+ * ```
1423
+ * [s2Get constant="S2MEMBER_LOGIN_WELCOME_PAGE_URL" /]
1424
+ *
1425
+ * <script type="text/javascript">
1426
+ * document.write(S2MEMBER_LOGIN_WELCOME_PAGE_URL);
1427
+ * </script>
1428
+ * ```
1429
+ *
1430
+ * @package s2Member\API_Constants
1431
+ * @since 3.5
1432
+ *
1433
+ * @var str
1434
+ *
1435
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_PAGE_URL
1436
+ * @see s2Member\API_Constants\S2MEMBER_LOGOUT_PAGE_URL
1437
+ *
1438
+ * @see s2Member\API_Constants\S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID
1439
+ * @see s2Member\API_Constants\S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL
1440
+ *
1441
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_WELCOME_PAGE_ID
1442
+ *
1443
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
1444
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
1445
+ *
1446
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL
1447
+ *
1448
+ * @see `Dashboard -> s2Member -> General Options -> Login Welcome Page`
1449
+ */
1450
+ if (!defined ("S2MEMBER_LOGIN_WELCOME_PAGE_URL"))
1451
+ define ("S2MEMBER_LOGIN_WELCOME_PAGE_URL", ($c[] = (($login_redirection_url) ? (string)$login_redirection_url : (string)$links["login_welcome_page"])));
1452
+ /**
1453
+ * The URL, which logs the current User out of their account.
1454
+ *
1455
+ * This is the value provided by WordPress®. It's the same as using ``wp_logout_url()``.
1456
+ *
1457
+ * ———— Quick PHP Code Sample ————
1458
+ * ```
1459
+ * <!php echo S2MEMBER_LOGOUT_PAGE_URL; !>
1460
+ * ```
1461
+ * ———— Shortcode & JavaScript Equivalents ————
1462
+ * ```
1463
+ * [s2Get constant="S2MEMBER_LOGOUT_PAGE_URL" /]
1464
+ *
1465
+ * <script type="text/javascript">
1466
+ * document.write(S2MEMBER_LOGOUT_PAGE_URL);
1467
+ * </script>
1468
+ * ```
1469
+ *
1470
+ * @package s2Member\API_Constants
1471
+ * @since 3.5
1472
+ *
1473
+ * @var str
1474
+ *
1475
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_PAGE_URL
1476
+ *
1477
+ * @see s2Member\API_Constants\S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID
1478
+ * @see s2Member\API_Constants\S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL
1479
+ *
1480
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_WELCOME_PAGE_ID
1481
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_WELCOME_PAGE_URL
1482
+ *
1483
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
1484
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
1485
+ *
1486
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL
1487
+ *
1488
+ * @see http://codex.wordpress.org/Function_Reference/wp_logout_url wp_logout_url()
1489
+ */
1490
+ if (!defined ("S2MEMBER_LOGOUT_PAGE_URL"))
1491
+ define ("S2MEMBER_LOGOUT_PAGE_URL", ($c[] = (string)wp_logout_url ())); /* This triggers `wp_nonce_tick()`; watch out for dynamic changes. */
1492
+ /**
1493
+ * The URL, where a User can log into their account.
1494
+ *
1495
+ * This is the value provided by WordPress®. It's the same as using ``wp_login_url()``.
1496
+ *
1497
+ * ———— Quick PHP Code Sample ————
1498
+ * ```
1499
+ * <!php echo S2MEMBER_LOGIN_PAGE_URL; !>
1500
+ * ```
1501
+ * ———— Shortcode & JavaScript Equivalents ————
1502
+ * ```
1503
+ * [s2Get constant="S2MEMBER_LOGIN_PAGE_URL" /]
1504
+ *
1505
+ * <script type="text/javascript">
1506
+ * document.write(S2MEMBER_LOGIN_PAGE_URL);
1507
+ * </script>
1508
+ * ```
1509
+ *
1510
+ * @package s2Member\API_Constants
1511
+ * @since 3.5
1512
+ *
1513
+ * @var str
1514
+ *
1515
+ * @see s2Member\API_Constants\S2MEMBER_LOGOUT_PAGE_URL
1516
+ *
1517
+ * @see s2Member\API_Constants\S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID
1518
+ * @see s2Member\API_Constants\S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL
1519
+ *
1520
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_WELCOME_PAGE_ID
1521
+ * @see s2Member\API_Constants\S2MEMBER_LOGIN_WELCOME_PAGE_URL
1522
+ *
1523
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
1524
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
1525
+ *
1526
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL
1527
+ *
1528
+ * @see http://codex.wordpress.org/Function_Reference/wp_login_url wp_login_url()
1529
+ */
1530
+ if (!defined ("S2MEMBER_LOGIN_PAGE_URL"))
1531
+ define ("S2MEMBER_LOGIN_PAGE_URL", ($c[] = (string)wp_login_url ())); /* Will not trigger `wp_nonce_tick()`, no worries in this case. */
1532
+ /**
1533
+ * Each Membership Level ( Label ); as configured by the site owner.
1534
+ *
1535
+ * The defaults are as follows:
1536
+ * o Level #0 ``S2MEMBER_LEVEL0_LABEL`` = Free Subscriber
1537
+ * o Level #1 ``S2MEMBER_LEVEL1_LABEL`` = Bronze Member
1538
+ * o Level #2 ``S2MEMBER_LEVEL2_LABEL`` = Silver Member
1539
+ * o Level #3 ``S2MEMBER_LEVEL3_LABEL`` = Gold Member
1540
+ * o Level #4 ``S2MEMBER_LEVEL4_LABEL`` = Platinum Member
1541
+ *
1542
+ * ———— Quick PHP Code Sample ————
1543
+ * ```
1544
+ * <!php echo S2MEMBER_LEVEL0_LABEL; !>
1545
+ * ```
1546
+ * ———— Shortcode & JavaScript Equivalents ————
1547
+ * ```
1548
+ * [s2Get constant="S2MEMBER_LEVEL0_LABEL" /]
1549
+ *
1550
+ * <script type="text/javascript">
1551
+ * document.write(S2MEMBER_LEVEL0_LABEL);
1552
+ * </script>
1553
+ * ```
1554
+ *
1555
+ * @package s2Member\API_Constants
1556
+ * @since 3.5
1557
+ *
1558
+ * @var str
1559
+ *
1560
+ * @see s2Member\API_Functions\get_user_field()
1561
+ * @see `get_user_field("s2member_access_role")`
1562
+ * @see `get_user_field("s2member_access_level")`
1563
+ * @see `get_user_field("s2member_access_label")`
1564
+ *
1565
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_ACCESS_LEVEL
1566
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_ACCESS_LABEL
1567
+ *
1568
+ * @see http://codex.wordpress.org/Function_Reference/wp_get_current_user wp_get_current_user()
1569
+ *
1570
+ * @see `Dashboard -> s2Member -> General Options -> Membership Level ( Labels )`
1571
+ */
1572
+ for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
1573
+ {
1574
+ if (!defined (($S2MEMBER_LEVELn_LABEL = "S2MEMBER_LEVEL" . $n . "_LABEL")))
1575
+ define ($S2MEMBER_LEVELn_LABEL, ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_label"]));
1576
+ }
1577
+ /**
1578
+ * File Downloads allowed at each Membership Level; as configured by the site owner.
1579
+ *
1580
+ * The defaults are as follows:
1581
+ * o Level #0 ``S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED`` = `0`
1582
+ * o Level #1 ``S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED`` = `0`
1583
+ * o Level #2 ``S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED`` = `0`
1584
+ * o Level #3 ``S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED`` = `0`
1585
+ * o Level #4 ``S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED`` = `0`
1586
+ *
1587
+ * ———— Quick PHP Code Sample ————
1588
+ * ```
1589
+ * <!php echo S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED; !>
1590
+ * ```
1591
+ * ———— Shortcode & JavaScript Equivalents ————
1592
+ * ```
1593
+ * [s2Get constant="S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED" /]
1594
+ *
1595
+ * <script type="text/javascript">
1596
+ * document.write(S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED);
1597
+ * </script>
1598
+ * ```
1599
+ *
1600
+ * @package s2Member\API_Constants
1601
+ * @since 3.5
1602
+ *
1603
+ * @var int
1604
+ *
1605
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED
1606
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED
1607
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS
1608
+ *
1609
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY
1610
+ *
1611
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
1612
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
1613
+ *
1614
+ * @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS
1615
+ *
1616
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
1617
+ *
1618
+ * @see `Dashboard -> s2Member -> Download Options`
1619
+ */
1620
+ for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
1621
+ {
1622
+ if (!defined (($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED = "S2MEMBER_LEVEL" . $n . "_FILE_DOWNLOADS_ALLOWED")))
1623
+ define ($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED, ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_file_downloads_allowed"]));
1624
+ }
1625
+ /**
1626
+ * File Download days, at each Membership Level; as configured by the site owner.
1627
+ *
1628
+ * The defaults are as follows:
1629
+ * o Level #0 ``S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED_DAYS`` = `0`
1630
+ * o Level #1 ``S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED_DAYS`` = `0`
1631
+ * o Level #2 ``S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED_DAYS`` = `0`
1632
+ * o Level #3 ``S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED_DAYS`` = `0`
1633
+ * o Level #4 ``S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED_DAYS`` = `0`
1634
+ *
1635
+ * ———— Quick PHP Code Sample ————
1636
+ * ```
1637
+ * At Level #1, Members are allowed to download <!php echo S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED; !> files, every <!php echo S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED_DAYS; !> days.
1638
+ * You are currently at Membership Level #<!php echo S2MEMBER_CURRENT_USER_ACCESS_LEVEL; !>. You've downloaded <!php echo S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY; !> files in the last <!php echo S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS; !> days.
1639
+ * ```
1640
+ * ———— Shortcode & JavaScript Equivalents ————
1641
+ * ```
1642
+ * At Level #1, Members are allowed to download [s2Get constant="S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED" /] files, every [s2Get constant="S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED_DAYS" /] days.
1643
+ * You are currently at Membership Level #[s2Get constant="S2MEMBER_CURRENT_USER_ACCESS_LEVEL" /]. You've downloaded [s2Get constant="S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY" /] files in the last [s2Get constant="S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS" /] days.
1644
+ *
1645
+ * At Level #1, Members are allowed to download <script type="text/javascript">document.write(S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED);</script> files, every <script type="text/javascript">document.write(S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED_DAYS);</script> days.
1646
+ * You are currently at Membership Level #<script type="text/javascript">document.write(S2MEMBER_CURRENT_USER_ACCESS_LEVEL);</script>. You've downloaded <script type="text/javascript">document.write(S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY);</script> files in the last <script type="text/javascript">document.write(S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS);</script> days.
1647
+ * ```
1648
+ *
1649
+ * @package s2Member\API_Constants
1650
+ * @since 3.5
1651
+ *
1652
+ * @var int
1653
+ *
1654
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED
1655
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED
1656
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS
1657
+ *
1658
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY
1659
+ *
1660
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
1661
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
1662
+ *
1663
+ * @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED
1664
+ *
1665
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS
1666
+ *
1667
+ * @see `Dashboard -> s2Member -> Download Options`
1668
+ */
1669
+ for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
1670
+ {
1671
+ if (!defined (($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS = "S2MEMBER_LEVEL" . $n . "_FILE_DOWNLOADS_ALLOWED_DAYS")))
1672
+ define ($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS, ($c[] = (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_file_downloads_allowed_days"]));
1673
+ }
1674
+ /**
1675
+ * Inline File Download extensions; as configured by the site owner.
1676
+ *
1677
+ * ———— Quick PHP Code Sample ————
1678
+ * ```
1679
+ * <!php echo S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS; !>
1680
+ * ```
1681
+ * ———— Shortcode & JavaScript Equivalents ————
1682
+ * ```
1683
+ * [s2Get constant="S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS" /]
1684
+ *
1685
+ * <script type="text/javascript">
1686
+ * document.write(S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS);
1687
+ * </script>
1688
+ * ```
1689
+ *
1690
+ * @package s2Member\API_Constants
1691
+ * @since 3.5
1692
+ *
1693
+ * @var str
1694
+ *
1695
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED
1696
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED
1697
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS
1698
+ *
1699
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY
1700
+ *
1701
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID
1702
+ * @see s2Member\API_Constants\S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL
1703
+ *
1704
+ * @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED
1705
+ * @see s2Member\API_Constants\S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS
1706
+ *
1707
+ * @see `Dashboard -> s2Member -> Download Options`
1708
+ */
1709
+ if (!defined ("S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS"))
1710
+ define ("S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_inline_extensions"]));
1711
+ /**
1712
+ * From: Name, for s2Member-specific emails; as configured by the site owner.
1713
+ *
1714
+ * ———— Quick PHP Code Sample ————
1715
+ * ```
1716
+ * <!php echo S2MEMBER_REG_EMAIL_FROM_NAME; !>
1717
+ * ```
1718
+ * ———— Shortcode & JavaScript Equivalents ————
1719
+ * ```
1720
+ * [s2Get constant="S2MEMBER_REG_EMAIL_FROM_NAME" /]
1721
+ *
1722
+ * <script type="text/javascript">
1723
+ * document.write(S2MEMBER_REG_EMAIL_FROM_NAME);
1724
+ * </script>
1725
+ * ```
1726
+ *
1727
+ * @package s2Member\API_Constants
1728
+ * @since 3.5
1729
+ *
1730
+ * @var str
1731
+ *
1732
+ * @see s2Member\API_Constants\S2MEMBER_REG_EMAIL_FROM_EMAIL
1733
+ *
1734
+ * @see `Dashboard -> s2Member -> General Options`
1735
+ */
1736
+ if (!defined ("S2MEMBER_REG_EMAIL_FROM_NAME"))
1737
+ define ("S2MEMBER_REG_EMAIL_FROM_NAME", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]));
1738
+ /**
1739
+ * From: Email Address, for s2Member-specific emails; as configured by the site owner.
1740
+ *
1741
+ * ———— Quick PHP Code Sample ————
1742
+ * ```
1743
+ * <!php echo S2MEMBER_REG_EMAIL_FROM_EMAIL; !>
1744
+ * ```
1745
+ * ———— Shortcode & JavaScript Equivalents ————
1746
+ * ```
1747
+ * [s2Get constant="S2MEMBER_REG_EMAIL_FROM_EMAIL" /]
1748
+ *
1749
+ * <script type="text/javascript">
1750
+ * document.write(S2MEMBER_REG_EMAIL_FROM_EMAIL);
1751
+ * </script>
1752
+ * ```
1753
+ *
1754
+ * @package s2Member\API_Constants
1755
+ * @since 3.5
1756
+ *
1757
+ * @var str
1758
+ *
1759
+ * @see s2Member\API_Constants\S2MEMBER_REG_EMAIL_FROM_NAME
1760
+ *
1761
+ * @see `Dashboard -> s2Member -> General Options`
1762
+ */
1763
+ if (!defined ("S2MEMBER_REG_EMAIL_FROM_EMAIL"))
1764
+ define ("S2MEMBER_REG_EMAIL_FROM_EMAIL", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"]));
1765
+ /**
1766
+ * Full URL to PayPal® IPN handler, provided by s2Member.
1767
+ *
1768
+ * ———— Quick PHP Code Sample ————
1769
+ * ```
1770
+ * <!php echo S2MEMBER_PAYPAL_NOTIFY_URL; !>
1771
+ * ```
1772
+ * ———— Shortcode & JavaScript Equivalents ————
1773
+ * ```
1774
+ * [s2Get constant="S2MEMBER_PAYPAL_NOTIFY_URL" /]
1775
+ *
1776
+ * <script type="text/javascript">
1777
+ * document.write(S2MEMBER_PAYPAL_NOTIFY_URL);
1778
+ * </script>
1779
+ * ```
1780
+ *
1781
+ * @package s2Member\API_Constants
1782
+ * @since 3.5
1783
+ *
1784
+ * @var str
1785
+ *
1786
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_RETURN_URL
1787
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_PDT_IDENTITY_TOKEN
1788
+ *
1789
+ * @see `Dashboard -> s2Member -> PayPal® Options -> IPN Integration`
1790
+ */
1791
+ if (!defined ("S2MEMBER_PAYPAL_NOTIFY_URL"))
1792
+ define ("S2MEMBER_PAYPAL_NOTIFY_URL", ($c[] = (string)site_url ("/?s2member_paypal_notify=1")));
1793
+ /**
1794
+ * Full URL to PayPal® Auto-Return/PDT handler, provided by s2Member.
1795
+ *
1796
+ * ———— Quick PHP Code Sample ————
1797
+ * ```
1798
+ * <!php echo S2MEMBER_PAYPAL_RETURN_URL; !>
1799
+ * ```
1800
+ * ———— Shortcode & JavaScript Equivalents ————
1801
+ * ```
1802
+ * [s2Get constant="S2MEMBER_PAYPAL_RETURN_URL" /]
1803
+ *
1804
+ * <script type="text/javascript">
1805
+ * document.write(S2MEMBER_PAYPAL_RETURN_URL);
1806
+ * </script>
1807
+ * ```
1808
+ *
1809
+ * @package s2Member\API_Constants
1810
+ * @since 3.5
1811
+ *
1812
+ * @var str
1813
+ *
1814
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_NOTIFY_URL
1815
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_PDT_IDENTITY_TOKEN
1816
+ *
1817
+ * @see `Dashboard -> s2Member -> PayPal® Options -> Auto-Return/PDT Integration`
1818
+ */
1819
+ if (!defined ("S2MEMBER_PAYPAL_RETURN_URL"))
1820
+ define ("S2MEMBER_PAYPAL_RETURN_URL", ($c[] = (string)site_url ("/?s2member_paypal_return=1")));
1821
+ /**
1822
+ * PayPal® Business Email Address; as configured by the site owner.
1823
+ *
1824
+ * ———— Quick PHP Code Sample ————
1825
+ * ```
1826
+ * <!php echo S2MEMBER_PAYPAL_BUSINESS; !>
1827
+ * ```
1828
+ * ———— Shortcode & JavaScript Equivalents ————
1829
+ * ```
1830
+ * [s2Get constant="S2MEMBER_PAYPAL_BUSINESS" /]
1831
+ *
1832
+ * <script type="text/javascript">
1833
+ * document.write(S2MEMBER_PAYPAL_BUSINESS);
1834
+ * </script>
1835
+ * ```
1836
+ *
1837
+ * @package s2Member\API_Constants
1838
+ * @since 3.5
1839
+ *
1840
+ * @var str
1841
+ *
1842
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_USERNAME
1843
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_PASSWORD
1844
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_SIGNATURE
1845
+ *
1846
+ * @see `Dashboard -> s2Member -> PayPal® Options -> Account Details`
1847
+ */
1848
+ if (!defined ("S2MEMBER_PAYPAL_BUSINESS"))
1849
+ define ("S2MEMBER_PAYPAL_BUSINESS", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"]));
1850
+ /**
1851
+ * PayPal® endpoint domain ( changes when Sandbox Mode is enabled ).
1852
+ *
1853
+ * o In Sandbox Mode, this is: `www.sandbox.paypal.com`.
1854
+ * o In Production Mode, this is: `www.paypal.com`.
1855
+ *
1856
+ * ———— Quick PHP Code Sample ————
1857
+ * ```
1858
+ * <!php echo S2MEMBER_PAYPAL_ENDPOINT; !>
1859
+ * ```
1860
+ * ———— Shortcode & JavaScript Equivalents ————
1861
+ * ```
1862
+ * [s2Get constant="S2MEMBER_PAYPAL_ENDPOINT" /]
1863
+ *
1864
+ * <script type="text/javascript">
1865
+ * document.write(S2MEMBER_PAYPAL_ENDPOINT);
1866
+ * </script>
1867
+ * ```
1868
+ *
1869
+ * @package s2Member\API_Constants
1870
+ * @since 3.5
1871
+ *
1872
+ * @var str
1873
+ *
1874
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_ENDPOINT
1875
+ *
1876
+ * @see `Dashboard -> s2Member -> PayPal® Options -> Account Details`
1877
+ */
1878
+ if (!defined ("S2MEMBER_PAYPAL_ENDPOINT"))
1879
+ define ("S2MEMBER_PAYPAL_ENDPOINT", ($c[] = (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com")));
1880
+ /**
1881
+ * PayPal® API endpoint domain ( changes when Sandbox Mode is enabled ).
1882
+ *
1883
+ * o In Sandbox Mode, this is: `api-3t.sandbox.paypal.com`.
1884
+ * o In Production Mode, this is: `api-3t.paypal.com`.
1885
+ *
1886
+ * ———— Quick PHP Code Sample ————
1887
+ * ```
1888
+ * <!php echo S2MEMBER_PAYPAL_API_ENDPOINT; !>
1889
+ * ```
1890
+ * ———— Shortcode & JavaScript Equivalents ————
1891
+ * ```
1892
+ * [s2Get constant="S2MEMBER_PAYPAL_API_ENDPOINT" /]
1893
+ *
1894
+ * <script type="text/javascript">
1895
+ * document.write(S2MEMBER_PAYPAL_API_ENDPOINT);
1896
+ * </script>
1897
+ * ```
1898
+ *
1899
+ * @package s2Member\API_Constants
1900
+ * @since 3.5
1901
+ *
1902
+ * @var str
1903
+ *
1904
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_ENDPOINT
1905
+ *
1906
+ * @see `Dashboard -> s2Member -> PayPal® Options -> Account Details`
1907
+ */
1908
+ if (!defined ("S2MEMBER_PAYPAL_API_ENDPOINT"))
1909
+ define ("S2MEMBER_PAYPAL_API_ENDPOINT", ($c[] = (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "api-3t.sandbox.paypal.com" : "api-3t.paypal.com")));
1910
+ /**
1911
+ * PayPal® API Username; as configured by the site owner.
1912
+ *
1913
+ * ———— Quick PHP Code Sample ————
1914
+ * ```
1915
+ * <!php echo S2MEMBER_PAYPAL_API_USERNAME; !>
1916
+ * ```
1917
+ * ———— Shortcode & JavaScript Equivalents ————
1918
+ * ```
1919
+ * [s2Get constant="S2MEMBER_PAYPAL_API_USERNAME" /]
1920
+ *
1921
+ * NOTE: For security purposes,
1922
+ * this API Constant is NOT available as a JavaScript Global.
1923
+ * ```
1924
+ *
1925
+ * @package s2Member\API_Constants
1926
+ * @since 3.5
1927
+ *
1928
+ * @var str
1929
+ *
1930
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_BUSINESS
1931
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_PASSWORD
1932
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_SIGNATURE
1933
+ *
1934
+ * @see `Dashboard -> s2Member -> PayPal® Options -> Account Details`
1935
+ */
1936
+ if (!defined ("S2MEMBER_PAYPAL_API_USERNAME"))
1937
+ define ("S2MEMBER_PAYPAL_API_USERNAME", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_username"]));
1938
+ /**
1939
+ * PayPal® API Password; as configured by the site owner.
1940
+ *
1941
+ * ———— Quick PHP Code Sample ————
1942
+ * ```
1943
+ * <!php echo S2MEMBER_PAYPAL_API_PASSWORD; !>
1944
+ * ```
1945
+ * ———— Shortcode & JavaScript Equivalents ————
1946
+ * ```
1947
+ * [s2Get constant="S2MEMBER_PAYPAL_API_PASSWORD" /]
1948
+ *
1949
+ * NOTE: For security purposes,
1950
+ * this API Constant is NOT available as a JavaScript Global.
1951
+ * ```
1952
+ *
1953
+ * @package s2Member\API_Constants
1954
+ * @since 3.5
1955
+ *
1956
+ * @var str
1957
+ *
1958
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_BUSINESS
1959
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_USERNAME
1960
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_SIGNATURE
1961
+ *
1962
+ * @see `Dashboard -> s2Member -> PayPal® Options -> Account Details`
1963
+ */
1964
+ if (!defined ("S2MEMBER_PAYPAL_API_PASSWORD"))
1965
+ define ("S2MEMBER_PAYPAL_API_PASSWORD", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_password"]));
1966
+ /**
1967
+ * PayPal® API Signature; as configured by the site owner.
1968
+ *
1969
+ * ———— Quick PHP Code Sample ————
1970
+ * ```
1971
+ * <!php echo S2MEMBER_PAYPAL_API_SIGNATURE; !>
1972
+ * ```
1973
+ * ———— Shortcode & JavaScript Equivalents ————
1974
+ * ```
1975
+ * [s2Get constant="S2MEMBER_PAYPAL_API_SIGNATURE" /]
1976
+ *
1977
+ * NOTE: For security purposes,
1978
+ * this API Constant is NOT available as a JavaScript Global.
1979
+ * ```
1980
+ *
1981
+ * @package s2Member\API_Constants
1982
+ * @since 3.5
1983
+ *
1984
+ * @var str
1985
+ *
1986
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_BUSINESS
1987
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_USERNAME
1988
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_API_PASSWORD
1989
+ *
1990
+ * @see `Dashboard -> s2Member -> PayPal® Options -> Account Details`
1991
+ */
1992
+ if (!defined ("S2MEMBER_PAYPAL_API_SIGNATURE"))
1993
+ define ("S2MEMBER_PAYPAL_API_SIGNATURE", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_signature"]));
1994
+ /**
1995
+ * PayPal® PDT Identity Token; as configured by the site owner.
1996
+ *
1997
+ * ———— Quick PHP Code Sample ————
1998
+ * ```
1999
+ * <!php echo S2MEMBER_PAYPAL_PDT_IDENTITY_TOKEN; !>
2000
+ * ```
2001
+ * ———— Shortcode & JavaScript Equivalents ————
2002
+ * ```
2003
+ * [s2Get constant="S2MEMBER_PAYPAL_PDT_IDENTITY_TOKEN" /]
2004
+ *
2005
+ * NOTE: For security purposes,
2006
+ * this API Constant is NOT available as a JavaScript Global.
2007
+ * ```
2008
+ *
2009
+ * @package s2Member\API_Constants
2010
+ * @since 3.5
2011
+ *
2012
+ * @var str
2013
+ *
2014
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_RETURN_URL
2015
+ * @see s2Member\API_Constants\S2MEMBER_PAYPAL_NOTIFY_URL
2016
+ *
2017
+ * @see `Dashboard -> s2Member -> PayPal® Options -> Auto-Return/PDT Integration`
2018
+ */
2019
+ if (!defined ("S2MEMBER_PAYPAL_PDT_IDENTITY_TOKEN"))
2020
+ define ("S2MEMBER_PAYPAL_PDT_IDENTITY_TOKEN", ($c[] = (string)$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_identity_token"]));
2021
+ /**
2022
+ * PayPal® value for Payment Buttons with input name: `on0`.
2023
+ *
2024
+ * Used in PayPal® Modification Buttons *( i.e. upgrades/downgrades )*.
2025
+ *
2026
+ * This auto-fills the `on0` value in PayPal® Button Codes. If a Button Code is presented to a logged-in Member,
2027
+ * this will auto-fill the value for the `on0` input variable, with the string: "Referencing Customer ID".
2028
+ * Otherwise, it will be set to a default value of: "Originating Domain".
2029
+ *
2030
+ * These four API Constants are special.
2031
+ * o {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0}
2032
+ * o {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0}
2033
+ * o {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1}
2034
+ * o {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1}
2035
+ *
2036
+ * They are used by the PayPal® Button Generator for s2Member.
2037
+ *
2038
+ * The `ON0/OS0` values, are how s2Member identifies an existing Member *( and/or a Free Subscriber )*, who is already logged-in
2039
+ * when they click a PayPal® Modification Button that was generated for you by s2Member's Button Generator.
2040
+ *
2041
+ * Instead of forcing a Member *( and/or a Free Subscriber )* to re-register for a new account,
2042
+ * s2Member can identify their existing account, and update it; according to the modified terms in your Button Code.
2043
+ * These three Button Code parameters: `on0`, `os0`, `modify`, work together in harmony. If you're using the Shortcode Format for PayPal® Buttons,
2044
+ * you won't even see these, because they're added internally by the Shortcode processor.
2045
+ *
2046
+ * The `ON1/OS1` values, are used by s2Member to identify a Customer's IP Address through IPN communications with PayPal®.
2047
+ *
2048
+ * Anyway, these four API Constants are just documented here for clarity;
2049
+ * you probably won't use any of these directly; the Button Generator pops them in.
2050
+ *
2051
+ * ———— Quick PHP Code Sample ————
2052
+ * ```
2053
+ * <!php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0; !>
2054
+ * ```
2055
+ * ———— Shortcode & JavaScript Equivalents ————
2056
+ * ```
2057
+ * [s2Get constant="S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0" /]
2058
+ *
2059
+ * <script type="text/javascript">
2060
+ * document.write(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0);
2061
+ * </script>
2062
+ * ```
2063
+ *
2064
+ * @package s2Member\API_Constants
2065
+ * @since 3.5
2066
+ *
2067
+ * @var str
2068
+ *
2069
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0
2070
+ *
2071
+ * @see `Dashboard -> s2Member -> PayPal® Buttons`
2072
+ */
2073
+ if (!defined ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0"))
2074
+ define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0", ($c[] = ((S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID) ? "Referencing Customer ID" : "Originating Domain")));
2075
+ /**
2076
+ * PayPal® value for Payment Buttons with input name: `os0`.
2077
+ *
2078
+ * Used in PayPal® Modification Buttons *( i.e. upgrades/downgrades )*.
2079
+ *
2080
+ * This auto-fills the `os0` value in PayPal® Button Codes. If a Button Code is presented to a logged-in Member,
2081
+ * this will auto-fill the value for the `os0` input variable, with the value of {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID}.
2082
+ * Otherwise, it will be set to a default value of ``$_SERVER["HTTP_HOST"]`` *( the originating domain name )*.
2083
+ *
2084
+ * These four API Constants are special.
2085
+ * o {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0}
2086
+ * o {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0}
2087
+ * o {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1}
2088
+ * o {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1}
2089
+ *
2090
+ * They are used by the PayPal® Button Generator for s2Member.
2091
+ *
2092
+ * The `ON0/OS0` values, are how s2Member identifies an existing Member *( and/or a Free Subscriber )*, who is already logged-in
2093
+ * when they click a PayPal® Modification Button that was generated for you by s2Member's Button Generator.
2094
+ *
2095
+ * Instead of forcing a Member *( and/or a Free Subscriber )* to re-register for a new account,
2096
+ * s2Member can identify their existing account, and update it; according to the modified terms in your Button Code.
2097
+ * These three Button Code parameters: `on0`, `os0`, `modify`, work together in harmony. If you're using the Shortcode Format for PayPal® Buttons,
2098
+ * you won't even see these, because they're added internally by the Shortcode processor.
2099
+ *
2100
+ * The `ON1/OS1` values, are used by s2Member to identify a Customer's IP Address through IPN communications with PayPal®.
2101
+ *
2102
+ * Anyway, these four API Constants are just documented here for clarity;
2103
+ * you probably won't use any of these directly; the Button Generator pops them in.
2104
+ *
2105
+ * ———— Quick PHP Code Sample ————
2106
+ * ```
2107
+ * <!php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0; !>
2108
+ * ```
2109
+ * ———— Shortcode & JavaScript Equivalents ————
2110
+ * ```
2111
+ * [s2Get constant="S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0" /]
2112
+ *
2113
+ * <script type="text/javascript">
2114
+ * document.write(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0);
2115
+ * </script>
2116
+ * ```
2117
+ *
2118
+ * @package s2Member\API_Constants
2119
+ * @since 3.5
2120
+ *
2121
+ * @var str
2122
+ *
2123
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0
2124
+ *
2125
+ * @see `Dashboard -> s2Member -> PayPal® Buttons`
2126
+ */
2127
+ if (!defined ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0"))
2128
+ define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0", ($c[] = ((S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID) ? S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID : (string)$_SERVER["HTTP_HOST"])));
2129
+ /**
2130
+ * PayPal® value for Payment Buttons with input name: `on1`.
2131
+ *
2132
+ * This auto-fills the `on1` value in PayPal® Button Codes.
2133
+ * This always contains the string: "Customer IP Address".
2134
+ *
2135
+ * These four API Constants are special.
2136
+ * o {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0}
2137
+ * o {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0}
2138
+ * o {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1}
2139
+ * o {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1}
2140
+ *
2141
+ * They are used by the PayPal® Button Generator for s2Member.
2142
+ *
2143
+ * The `ON1/OS1` values, are used by s2Member to identify a Customer's IP Address through IPN communications with PayPal®.
2144
+ *
2145
+ * The `ON0/OS0` values, are how s2Member identifies an existing Member *( and/or a Free Subscriber )*, who is already logged-in
2146
+ * when they click a PayPal® Modification Button that was generated for you by s2Member's Button Generator.
2147
+ *
2148
+ * Instead of forcing a Member *( and/or a Free Subscriber )* to re-register for a new account,
2149
+ * s2Member can identify their existing account, and update it; according to the modified terms in your Button Code.
2150
+ * These three Button Code parameters: `on0`, `os0`, `modify`, work together in harmony. If you're using the Shortcode Format for PayPal® Buttons,
2151
+ * you won't even see these, because they're added internally by the Shortcode processor.
2152
+ *
2153
+ * Anyway, these four API Constants are just documented here for clarity;
2154
+ * you probably won't use any of these directly; the Button Generator pops them in.
2155
+ *
2156
+ * ———— Quick PHP Code Sample ————
2157
+ * ```
2158
+ * <!php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1; !>
2159
+ * ```
2160
+ * ———— Shortcode & JavaScript Equivalents ————
2161
+ * ```
2162
+ * [s2Get constant="S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1" /]
2163
+ *
2164
+ * <script type="text/javascript">
2165
+ * document.write(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1);
2166
+ * </script>
2167
+ * ```
2168
+ *
2169
+ * @package s2Member\API_Constants
2170
+ * @since 3.5
2171
+ *
2172
+ * @var str
2173
+ *
2174
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1
2175
+ *
2176
+ * @see `Dashboard -> s2Member -> PayPal® Buttons`
2177
+ */
2178
+ if (!defined ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1"))
2179
+ define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1", ($c[] = "Customer IP Address" /* Via $_SERVER["REMOTE_ADDR"] below. */));
2180
+ /**
2181
+ * PayPal® value for Payment Buttons with input name: `os1`.
2182
+ *
2183
+ * This auto-fills the `os1` value in PayPal® Button Codes,
2184
+ * with the Customer's IP Address, via ``$_SERVER["REMOTE_ADDR"]``.
2185
+ *
2186
+ * These four API Constants are special.
2187
+ * o {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0}
2188
+ * o {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0}
2189
+ * o {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1}
2190
+ * o {@link s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1}
2191
+ *
2192
+ * They are used by the PayPal® Button Generator for s2Member.
2193
+ *
2194
+ * The `ON1/OS1` values, are used by s2Member to identify a Customer's IP Address through IPN communications with PayPal®.
2195
+ *
2196
+ * The `ON0/OS0` values, are how s2Member identifies an existing Member *( and/or a Free Subscriber )*, who is already logged-in
2197
+ * when they click a PayPal® Modification Button that was generated for you by s2Member's Button Generator.
2198
+ *
2199
+ * Instead of forcing a Member *( and/or a Free Subscriber )* to re-register for a new account,
2200
+ * s2Member can identify their existing account, and update it; according to the modified terms in your Button Code.
2201
+ * These three Button Code parameters: `on0`, `os0`, `modify`, work together in harmony. If you're using the Shortcode Format for PayPal® Buttons,
2202
+ * you won't even see these, because they're added internally by the Shortcode processor.
2203
+ *
2204
+ * Anyway, these four API Constants are just documented here for clarity;
2205
+ * you probably won't use any of these directly; the Button Generator pops them in.
2206
+ *
2207
+ * ———— Quick PHP Code Sample ————
2208
+ * ```
2209
+ * <!php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1; !>
2210
+ * ```
2211
+ * ———— Shortcode & JavaScript Equivalents ————
2212
+ * ```
2213
+ * [s2Get constant="S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1" /]
2214
+ *
2215
+ * <script type="text/javascript">
2216
+ * document.write(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1);
2217
+ * </script>
2218
+ * ```
2219
+ *
2220
+ * @package s2Member\API_Constants
2221
+ * @since 3.5
2222
+ *
2223
+ * @var str
2224
+ *
2225
+ * @see s2Member\API_Constants\S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1
2226
+ *
2227
+ * @see `Dashboard -> s2Member -> PayPal® Buttons`
2228
+ */
2229
+ if (!defined ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1"))
2230
+ define ("S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1", ($c[] = (string)$_SERVER["REMOTE_ADDR"]));
2231
+ /*
2232
+ Allows other Constants to be calculated with their checksums included too.
2233
+ */
2234
+ $c = apply_filters ("ws_plugin__s2member_during_constants_c", $c, get_defined_vars ());
2235
+ /**
2236
+ * Used internally by s2Member to compare the value of all API Constants at once.
2237
+ *
2238
+ * @package s2Member\API_Constants
2239
+ * @since 3.5
2240
+ *
2241
+ * @var str
2242
+ */
2243
+ if (!defined ("WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5"))
2244
+ define ("WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5", md5 (serialize ($c) . c_ws_plugin__s2member_utilities::ver_checksum ()));
2245
+ /*
2246
+ Calls the after Hook. Do NOT set Constants here.
2247
+ */
2248
+ do_action ("ws_plugin__s2member_after_constants", get_defined_vars ());
2249
  /**/
2250
  return; /* Return for uniformity. */
2251
  }
includes/classes/cron-jobs-in.inc.php CHANGED
@@ -1,26 +1,42 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_cron_jobs_in"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_cron_jobs_in
20
  {
21
- /*
22
- Extends the WP-Cron schedules to support 10 minute intervals.
23
- Attach to: add_filter("cron_schedules");
 
 
 
 
 
 
 
24
  */
25
  public static function extend_cron_schedules ($schedules = array ())
26
  {
@@ -32,15 +48,21 @@ if (!class_exists ("c_ws_plugin__s2member_cron_jobs_in"))
32
  /**/
33
  return apply_filters ("ws_plugin__s2member_extend_cron_schedules", array_merge ($array, $schedules), get_defined_vars ());
34
  }
35
- /*
36
- This function allows the Auto-EOT Sytem to be processed through a server-side Cron Job.
37
- Attach to: add_action("init");
 
 
 
 
 
 
38
  */
39
  public static function auto_eot_system_via_cron ()
40
  {
41
  do_action ("ws_plugin__s2member_before_auto_eot_system_via_cron", get_defined_vars ());
42
  /**/
43
- if ($_GET["s2member_auto_eot_system_via_cron"]) /* Being called through HTTP? */
44
  {
45
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"])
46
  {
1
  <?php
2
+ /**
3
+ * Cron routines handled by s2Member ( inner processing routines ).
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Cron_Jobs
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_cron_jobs_in"))
21
  {
22
+ /**
23
+ * Cron routines handled by s2Member ( inner processing routines ).
24
+ *
25
+ * @package s2Member\Cron_Jobs
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_cron_jobs_in
29
  {
30
+ /**
31
+ * Extends WP-Cron schedules to support 10 minute intervals.
32
+ *
33
+ * @package s2Member\Cron_Jobs
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_filter("cron_schedules");``
37
+ *
38
+ * @param array $schedules Expects an array of WP_Cron schedules passed in by the Filter.
39
+ * @return array Array of WP_Cron schedules after having added a 10 minute cycle.
40
  */
41
  public static function extend_cron_schedules ($schedules = array ())
42
  {
48
  /**/
49
  return apply_filters ("ws_plugin__s2member_extend_cron_schedules", array_merge ($array, $schedules), get_defined_vars ());
50
  }
51
+ /**
52
+ * Allows the Auto-EOT Sytem to be processed through a server-side Cron Job.
53
+ *
54
+ * @package s2Member\Cron_Jobs
55
+ * @since 3.5
56
+ *
57
+ * @attaches-to: ``add_action("init");``
58
+ *
59
+ * @return null Or exits script execution after task completed.
60
  */
61
  public static function auto_eot_system_via_cron ()
62
  {
63
  do_action ("ws_plugin__s2member_before_auto_eot_system_via_cron", get_defined_vars ());
64
  /**/
65
+ if (!empty ($_GET["s2member_auto_eot_system_via_cron"])) /* Being called through HTTP? */
66
  {
67
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"])
68
  {
includes/classes/cron-jobs.inc.php CHANGED
@@ -1,38 +1,60 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_cron_jobs"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_cron_jobs
20
  {
21
- /*
22
- Extends the WP-Cron schedules to support 10 minute intervals.
23
- Attach to: add_filter("cron_schedules");
 
 
 
 
 
 
 
24
  */
25
  public static function extend_cron_schedules ($schedules = array ()) /* Call inner function? */
26
  {
27
  return c_ws_plugin__s2member_cron_jobs_in::extend_cron_schedules ($schedules);
28
  }
29
- /*
30
- This function allows the Auto-EOT Sytem to be processed through a server-side Cron Job.
31
- Attach to: add_action("init");
 
 
 
 
 
 
32
  */
33
  public static function auto_eot_system_via_cron ()
34
  {
35
- if ($_GET["s2member_auto_eot_system_via_cron"]) /* Call inner function? */
36
  {
37
  return c_ws_plugin__s2member_cron_jobs_in::auto_eot_system_via_cron ();
38
  }
1
  <?php
2
+ /**
3
+ * Cron routines handled by s2Member.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Cron_Jobs
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_cron_jobs"))
21
  {
22
+ /**
23
+ * Cron routines handled by s2Member.
24
+ *
25
+ * @package s2Member\Cron_Jobs
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_cron_jobs
29
  {
30
+ /**
31
+ * Extends WP-Cron schedules to support 10 minute intervals.
32
+ *
33
+ * @package s2Member\Cron_Jobs
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_filter("cron_schedules");``
37
+ *
38
+ * @param array $schedules Expects an array of WP_Cron schedules passed in by the Filter.
39
+ * @return inner Return-value of inner routine.
40
  */
41
  public static function extend_cron_schedules ($schedules = array ()) /* Call inner function? */
42
  {
43
  return c_ws_plugin__s2member_cron_jobs_in::extend_cron_schedules ($schedules);
44
  }
45
+ /**
46
+ * Allows the Auto-EOT Sytem to be processed through a server-side Cron Job.
47
+ *
48
+ * @package s2Member\Cron_Jobs
49
+ * @since 3.5
50
+ *
51
+ * @attaches-to: ``add_action("init");``
52
+ *
53
+ * @return null|inner Return-value of inner routine.
54
  */
55
  public static function auto_eot_system_via_cron ()
56
  {
57
+ if (!empty ($_GET["s2member_auto_eot_system_via_cron"])) /* Call inner routine? */
58
  {
59
  return c_ws_plugin__s2member_cron_jobs_in::auto_eot_system_via_cron ();
60
  }
includes/classes/css-js-in.inc.php CHANGED
@@ -1,32 +1,47 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_css_js_in"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_css_js_in
20
  {
21
- /*
22
- Builds CSS files.
23
- Attach to: add_action("init");
 
 
 
 
 
 
24
  */
25
  public static function css ()
26
  {
27
  do_action ("ws_plugin__s2member_before_css", get_defined_vars ());
28
  /**/
29
- if ($_GET["ws_plugin__s2member_css"])
30
  {
31
  header ("Content-Type: text/css; charset=utf-8");
32
  header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("+1 week")) . " GMT");
@@ -48,16 +63,23 @@ if (!class_exists ("c_ws_plugin__s2member_css_js_in"))
48
  /**/
49
  do_action ("ws_plugin__s2member_after_css", get_defined_vars ());
50
  }
51
- /*
52
- Builds JavaScript files.
53
- Attach to: add_action("init");
54
  * Be sure s2Member's API Constants are already defined before firing this.
 
 
 
 
 
 
 
55
  */
56
  public static function js_w_globals ()
57
  {
58
  do_action ("ws_plugin__s2member_before_js_w_globals", get_defined_vars ());
59
  /**/
60
- if ($_GET["ws_plugin__s2member_js_w_globals"])
61
  {
62
  header ("Content-Type: text/javascript; charset=utf-8");
63
  header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("+1 week")) . " GMT");
@@ -69,21 +91,30 @@ if (!class_exists ("c_ws_plugin__s2member_css_js_in"))
69
  /**/
70
  $g .= "S2MEMBER_CURRENT_USER_IS_LOGGED_IN = " . ((S2MEMBER_CURRENT_USER_IS_LOGGED_IN) ? "true" : "false") . ",";
71
  $g .= "S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER = " . ((S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER) ? "true" : "false") . ",";
 
72
  $g .= "S2MEMBER_CURRENT_USER_ACCESS_LEVEL = " . S2MEMBER_CURRENT_USER_ACCESS_LEVEL . ",";
73
  $g .= "S2MEMBER_CURRENT_USER_ACCESS_LABEL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_ACCESS_LABEL) . "',";
 
74
  $g .= "S2MEMBER_CURRENT_USER_SUBSCR_ID = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_SUBSCR_ID) . "',";
75
  $g .= "S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID) . "',";
 
76
  $g .= "S2MEMBER_CURRENT_USER_CUSTOM = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_CUSTOM) . "',";
 
77
  $g .= "S2MEMBER_CURRENT_USER_REGISTRATION_TIME = " . S2MEMBER_CURRENT_USER_REGISTRATION_TIME . ",";
78
  $g .= "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME = " . S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME . ",";
 
79
  $g .= "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS = " . S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS . ",";
80
  $g .= "S2MEMBER_CURRENT_USER_REGISTRATION_DAYS = " . S2MEMBER_CURRENT_USER_REGISTRATION_DAYS . ",";
 
81
  $g .= "S2MEMBER_CURRENT_USER_DISPLAY_NAME = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_DISPLAY_NAME) . "',";
82
  $g .= "S2MEMBER_CURRENT_USER_FIRST_NAME = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_FIRST_NAME) . "',";
83
  $g .= "S2MEMBER_CURRENT_USER_LAST_NAME = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_LAST_NAME) . "',";
 
84
  $g .= "S2MEMBER_CURRENT_USER_LOGIN = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_LOGIN) . "',";
85
  $g .= "S2MEMBER_CURRENT_USER_EMAIL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_EMAIL) . "',";
86
  $g .= "S2MEMBER_CURRENT_USER_IP = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_IP) . "',";
 
 
87
  $g .= "S2MEMBER_CURRENT_USER_ID = " . S2MEMBER_CURRENT_USER_ID . ",";
88
  $g .= "S2MEMBER_CURRENT_USER_FIELDS = " . S2MEMBER_CURRENT_USER_FIELDS . ",";
89
  /**/
@@ -103,23 +134,23 @@ if (!class_exists ("c_ws_plugin__s2member_css_js_in"))
103
  $g .= "S2MEMBER_LOGOUT_PAGE_URL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_LOGOUT_PAGE_URL) . "',";
104
  $g .= "S2MEMBER_LOGIN_PAGE_URL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_LOGIN_PAGE_URL) . "',";
105
  /**/
106
- $g .= "S2MEMBER_LEVEL0_LABEL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_LEVEL0_LABEL) . "',";
107
- $g .= "S2MEMBER_LEVEL1_LABEL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_LEVEL1_LABEL) . "',";
108
- $g .= "S2MEMBER_LEVEL2_LABEL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_LEVEL2_LABEL) . "',";
109
- $g .= "S2MEMBER_LEVEL3_LABEL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_LEVEL3_LABEL) . "',";
110
- $g .= "S2MEMBER_LEVEL4_LABEL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_LEVEL4_LABEL) . "',";
111
  /**/
112
- $g .= "S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED = " . S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED . ",";
113
- $g .= "S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED = " . S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED . ",";
114
- $g .= "S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED = " . S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED . ",";
115
- $g .= "S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED = " . S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED . ",";
116
- $g .= "S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED = " . S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED . ",";
117
  /**/
118
- $g .= "S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED_DAYS = " . S2MEMBER_LEVEL0_FILE_DOWNLOADS_ALLOWED_DAYS . ",";
119
- $g .= "S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED_DAYS = " . S2MEMBER_LEVEL1_FILE_DOWNLOADS_ALLOWED_DAYS . ",";
120
- $g .= "S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED_DAYS = " . S2MEMBER_LEVEL2_FILE_DOWNLOADS_ALLOWED_DAYS . ",";
121
- $g .= "S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED_DAYS = " . S2MEMBER_LEVEL3_FILE_DOWNLOADS_ALLOWED_DAYS . ",";
122
- $g .= "S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED_DAYS = " . S2MEMBER_LEVEL4_FILE_DOWNLOADS_ALLOWED_DAYS . ",";
123
  /**/
124
  $g .= "S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS) . "',";
125
  /**/
@@ -136,12 +167,16 @@ if (!class_exists ("c_ws_plugin__s2member_css_js_in"))
136
  $g .= "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0 = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0) . "',";
137
  $g .= "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0 = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0) . "',";
138
  /**/
 
 
 
139
  $g = trim ($g, " ,") . ";"; /* Trim & add semicolon. */
140
  /**/
141
  $u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
142
  $i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images";
143
  /**/
144
- echo $g . "\n"; /* Add a line break before inclusion. */
 
145
  /**/
146
  include_once dirname (dirname (__FILE__)) . "/s2member-min.js";
147
  /**/
1
  <?php
2
+ /**
3
+ * CSS/JS loading handlers for s2Member ( inner processing routines ).
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\CSS_JS
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_css_js_in"))
21
  {
22
+ /**
23
+ * CSS/JS loading handlers for s2Member ( inner processing routines ).
24
+ *
25
+ * @package s2Member\CSS_JS
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_css_js_in
29
  {
30
+ /**
31
+ * Outputs CSS for theme integration.
32
+ *
33
+ * @package s2Member\CSS_JS
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_action("init");``
37
+ *
38
+ * @return null Or exits script execution after loading CSS.
39
  */
40
  public static function css ()
41
  {
42
  do_action ("ws_plugin__s2member_before_css", get_defined_vars ());
43
  /**/
44
+ if (!empty ($_GET["ws_plugin__s2member_css"]))
45
  {
46
  header ("Content-Type: text/css; charset=utf-8");
47
  header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("+1 week")) . " GMT");
63
  /**/
64
  do_action ("ws_plugin__s2member_after_css", get_defined_vars ());
65
  }
66
+ /**
67
+ * Outputs JS for theme integration.
68
+ *
69
  * Be sure s2Member's API Constants are already defined before firing this.
70
+ *
71
+ * @package s2Member\CSS_JS
72
+ * @since 3.5
73
+ *
74
+ * @attaches-to: ``add_action("init");``
75
+ *
76
+ * @return null Or exits script execution after loading JS w/Globals.
77
  */
78
  public static function js_w_globals ()
79
  {
80
  do_action ("ws_plugin__s2member_before_js_w_globals", get_defined_vars ());
81
  /**/
82
+ if (!empty ($_GET["ws_plugin__s2member_js_w_globals"]))
83
  {
84
  header ("Content-Type: text/javascript; charset=utf-8");
85
  header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("+1 week")) . " GMT");
91
  /**/
92
  $g .= "S2MEMBER_CURRENT_USER_IS_LOGGED_IN = " . ((S2MEMBER_CURRENT_USER_IS_LOGGED_IN) ? "true" : "false") . ",";
93
  $g .= "S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER = " . ((S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER) ? "true" : "false") . ",";
94
+ /**/
95
  $g .= "S2MEMBER_CURRENT_USER_ACCESS_LEVEL = " . S2MEMBER_CURRENT_USER_ACCESS_LEVEL . ",";
96
  $g .= "S2MEMBER_CURRENT_USER_ACCESS_LABEL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_ACCESS_LABEL) . "',";
97
+ /**/
98
  $g .= "S2MEMBER_CURRENT_USER_SUBSCR_ID = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_SUBSCR_ID) . "',";
99
  $g .= "S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID) . "',";
100
+ $g .= "S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY) . "',";
101
  $g .= "S2MEMBER_CURRENT_USER_CUSTOM = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_CUSTOM) . "',";
102
+ /**/
103
  $g .= "S2MEMBER_CURRENT_USER_REGISTRATION_TIME = " . S2MEMBER_CURRENT_USER_REGISTRATION_TIME . ",";
104
  $g .= "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME = " . S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME . ",";
105
+ /**/
106
  $g .= "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS = " . S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS . ",";
107
  $g .= "S2MEMBER_CURRENT_USER_REGISTRATION_DAYS = " . S2MEMBER_CURRENT_USER_REGISTRATION_DAYS . ",";
108
+ /**/
109
  $g .= "S2MEMBER_CURRENT_USER_DISPLAY_NAME = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_DISPLAY_NAME) . "',";
110
  $g .= "S2MEMBER_CURRENT_USER_FIRST_NAME = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_FIRST_NAME) . "',";
111
  $g .= "S2MEMBER_CURRENT_USER_LAST_NAME = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_LAST_NAME) . "',";
112
+ /**/
113
  $g .= "S2MEMBER_CURRENT_USER_LOGIN = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_LOGIN) . "',";
114
  $g .= "S2MEMBER_CURRENT_USER_EMAIL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_EMAIL) . "',";
115
  $g .= "S2MEMBER_CURRENT_USER_IP = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_IP) . "',";
116
+ $g .= "S2MEMBER_CURRENT_USER_REGISTRATION_IP = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_REGISTRATION_IP) . "',";
117
+ /**/
118
  $g .= "S2MEMBER_CURRENT_USER_ID = " . S2MEMBER_CURRENT_USER_ID . ",";
119
  $g .= "S2MEMBER_CURRENT_USER_FIELDS = " . S2MEMBER_CURRENT_USER_FIELDS . ",";
120
  /**/
134
  $g .= "S2MEMBER_LOGOUT_PAGE_URL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_LOGOUT_PAGE_URL) . "',";
135
  $g .= "S2MEMBER_LOGIN_PAGE_URL = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_LOGIN_PAGE_URL) . "',";
136
  /**/
137
+ for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
138
+ {
139
+ if (defined (($S2MEMBER_LEVELn_LABEL = "S2MEMBER_LEVEL" . $n . "_LABEL")))
140
+ $g .= $S2MEMBER_LEVELn_LABEL . " = '" . c_ws_plugin__s2member_utils_strings::esc_sq (constant ($S2MEMBER_LEVELn_LABEL)) . "',";
141
+ }
142
  /**/
143
+ for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
144
+ {
145
+ if (defined (($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED = "S2MEMBER_LEVEL" . $n . "_FILE_DOWNLOADS_ALLOWED")))
146
+ $g .= $S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED . " = " . constant ($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED) . ",";
147
+ }
148
  /**/
149
+ for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
150
+ {
151
+ if (defined (($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS = "S2MEMBER_LEVEL" . $n . "_FILE_DOWNLOADS_ALLOWED_DAYS")))
152
+ $g .= $S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS . " = " . constant ($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS) . ",";
153
+ }
154
  /**/
155
  $g .= "S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS) . "',";
156
  /**/
167
  $g .= "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0 = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0) . "',";
168
  $g .= "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0 = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0) . "',";
169
  /**/
170
+ $g .= "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1 = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1) . "',";
171
+ $g .= "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1 = '" . c_ws_plugin__s2member_utils_strings::esc_sq (S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1) . "',";
172
+ /**/
173
  $g = trim ($g, " ,") . ";"; /* Trim & add semicolon. */
174
  /**/
175
  $u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"];
176
  $i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images";
177
  /**/
178
+ echo $g . "\n"; /* Add a line break. */
179
+ unset ($g); /* Now unset this variable. */
180
  /**/
181
  include_once dirname (dirname (__FILE__)) . "/s2member-min.js";
182
  /**/
includes/classes/css-js-themes.inc.php CHANGED
@@ -1,26 +1,41 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_css_js_themes"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_css_js_themes
20
  {
21
- /*
22
- Adds CSS files.
23
- Attach to: add_action("wp_print_styles");
 
 
 
 
 
 
24
  */
25
  public static function add_css ()
26
  {
@@ -37,9 +52,17 @@ if (!class_exists ("c_ws_plugin__s2member_css_js_themes"))
37
  /**/
38
  return; /* Return for uniformity. */
39
  }
40
- /*
41
- Adds JavaScript files.
42
- Attach to: add_action("wp_print_scripts");
 
 
 
 
 
 
 
 
43
  */
44
  public static function add_js_w_globals ()
45
  {
@@ -47,18 +70,18 @@ if (!class_exists ("c_ws_plugin__s2member_css_js_themes"))
47
  /**/
48
  do_action ("ws_plugin__s2member_before_add_js_w_globals", get_defined_vars ());
49
  /**/
50
- if (!is_admin () || (c_ws_plugin__s2member_utils_conds::is_user_admin () && $pagenow === "profile.php" && !current_user_can ("edit_users")))
51
  {
52
  if (is_user_logged_in ()) /* Separate version for logged-in Users/Members. */
53
  {
54
  $md5 = WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5; /* An MD5 hash based on global key => values. */
55
  /* The MD5 hash allows the script to be cached in the browser until the globals happen to change. */
56
  /* For instance, the global variables may change when a User who is logged-in changes their Profile. */
57
- wp_enqueue_script ("ws-plugin--s2member", site_url ("/?ws_plugin__s2member_js_w_globals=" . urlencode ($md5) . "&qcABC=1"), array ("jquery"), c_ws_plugin__s2member_utilities::ver_checksum ());
58
  }
59
  else /* Else if they are not logged in, we distinguish the JavaScript file by NOT including $md5. */
60
  { /* This essentially creates 2 versions of the script. One while logged in & another when not. */
61
- wp_enqueue_script ("ws-plugin--s2member", site_url ("/?ws_plugin__s2member_js_w_globals=1&qcABC=1"), array ("jquery"), c_ws_plugin__s2member_utilities::ver_checksum ());
62
  }
63
  /**/
64
  do_action ("ws_plugin__s2member_during_add_js_w_globals", get_defined_vars ());
1
  <?php
2
+ /**
3
+ * CSS/JS integrations with theme.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\CSS_JS
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_css_js_themes"))
21
  {
22
+ /**
23
+ * CSS/JS integrations with theme.
24
+ *
25
+ * @package s2Member\CSS_JS
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_css_js_themes
29
  {
30
+ /**
31
+ * Enqueues CSS file for theme integration.
32
+ *
33
+ * @package s2Member\CSS_JS
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_action("wp_print_styles");``
37
+ *
38
+ * @return null After enqueuing CSS for theme integration.
39
  */
40
  public static function add_css ()
41
  {
52
  /**/
53
  return; /* Return for uniformity. */
54
  }
55
+ /**
56
+ * Enqueues JS file for theme integration.
57
+ *
58
+ * Be sure s2Member's API Constants are already defined before firing this.
59
+ *
60
+ * @package s2Member\CSS_JS
61
+ * @since 3.5
62
+ *
63
+ * @attaches-to: ``add_action("wp_print_scripts");``
64
+ *
65
+ * @return null After enqueuing JS for theme integration.
66
  */
67
  public static function add_js_w_globals ()
68
  {
70
  /**/
71
  do_action ("ws_plugin__s2member_before_add_js_w_globals", get_defined_vars ());
72
  /**/
73
+ if (!is_admin () || (is_user_admin () && $pagenow === "profile.php" && !current_user_can ("edit_users")))
74
  {
75
  if (is_user_logged_in ()) /* Separate version for logged-in Users/Members. */
76
  {
77
  $md5 = WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5; /* An MD5 hash based on global key => values. */
78
  /* The MD5 hash allows the script to be cached in the browser until the globals happen to change. */
79
  /* For instance, the global variables may change when a User who is logged-in changes their Profile. */
80
+ wp_enqueue_script ("ws-plugin--s2member", site_url ("/?ws_plugin__s2member_js_w_globals=" . urlencode ($md5) . "&qcABC=1"), array ("jquery", "password-strength-meter"), c_ws_plugin__s2member_utilities::ver_checksum ());
81
  }
82
  else /* Else if they are not logged in, we distinguish the JavaScript file by NOT including $md5. */
83
  { /* This essentially creates 2 versions of the script. One while logged in & another when not. */
84
+ wp_enqueue_script ("ws-plugin--s2member", site_url ("/?ws_plugin__s2member_js_w_globals=1&qcABC=1"), array ("jquery", "password-strength-meter"), c_ws_plugin__s2member_utilities::ver_checksum ());
85
  }
86
  /**/
87
  do_action ("ws_plugin__s2member_during_add_js_w_globals", get_defined_vars ());
includes/classes/css-js.inc.php CHANGED
@@ -1,41 +1,62 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_css_js"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_css_js
20
  {
21
- /*
22
- Builds CSS files.
23
- Attach to: add_action("init");
 
 
 
 
 
 
24
  */
25
  public static function css ()
26
  {
27
- if ($_GET["ws_plugin__s2member_css"]) /* Call inner function? */
28
  {
29
  return c_ws_plugin__s2member_css_js_in::css ();
30
  }
31
  }
32
- /*
33
- Builds JavaScript files.
34
- Attach to: add_action("init");
 
 
 
 
 
 
35
  */
36
  public static function js_w_globals ()
37
  {
38
- if ($_GET["ws_plugin__s2member_js_w_globals"]) /* Call inner function? */
39
  {
40
  return c_ws_plugin__s2member_css_js_in::js_w_globals ();
41
  }
1
  <?php
2
+ /**
3
+ * CSS/JS loading handlers for s2Member.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\CSS_JS
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_css_js"))
21
  {
22
+ /**
23
+ * CSS/JS loading handlers for s2Member.
24
+ *
25
+ * @package s2Member\CSS_JS
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_css_js
29
  {
30
+ /**
31
+ * Outputs CSS for theme integration.
32
+ *
33
+ * @package s2Member\CSS_JS
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_action("init");``
37
+ *
38
+ * @return null|inner Return-value of inner routine.
39
  */
40
  public static function css ()
41
  {
42
+ if (!empty ($_GET["ws_plugin__s2member_css"])) /* Call inner routine? */
43
  {
44
  return c_ws_plugin__s2member_css_js_in::css ();
45
  }
46
  }
47
+ /**
48
+ * Outputs JS for theme integration.
49
+ *
50
+ * @package s2Member\CSS_JS
51
+ * @since 3.5
52
+ *
53
+ * @attaches-to: ``add_action("init");``
54
+ *
55
+ * @return null|inner Return-value of inner routine.
56
  */
57
  public static function js_w_globals ()
58
  {
59
+ if (!empty ($_GET["ws_plugin__s2member_js_w_globals"])) /* Call inner routine? */
60
  {
61
  return c_ws_plugin__s2member_css_js_in::js_w_globals ();
62
  }
includes/classes/custom-reg-fields-4bp.inc.php ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Custom Registration Fields for BuddyPress integration.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Custom_Reg_Fields
15
+ * @since 3.5
16
+ */
17
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
+ /**/
20
+ if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields_4bp"))
21
+ {
22
+ /**
23
+ * Custom Registration Fields for BuddyPress integration.
24
+ *
25
+ * @package s2Member\Custom_Reg_Fields
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_custom_reg_fields_4bp
29
+ {
30
+ /**
31
+ * Adds Custom Fields to BuddyPress Registration Form.
32
+ *
33
+ * @package s2Member\Custom_Reg_Fields
34
+ * @since 110524RC
35
+ *
36
+ * @attaches-to: ``add_action("bp_after_signup_profile_fields");``
37
+ *
38
+ * @return null
39
+ *
40
+ * @todo Optimize with ``empty()``.
41
+ */
42
+ public static function custom_registration_fields_4bp ()
43
+ {
44
+ static $processed = false; /* Process this routine only one time. */
45
+ /**/
46
+ do_action ("ws_plugin__s2member_before_custom_registration_fields_4bp", get_defined_vars ());
47
+ /**/
48
+ if (!$processed && in_array ("registration", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields_4bp"]))
49
+ if (apply_filters ("ws_plugin__s2member_custom_registration_fields_4bp_display", true, get_defined_vars ()))
50
+ if (bp_is_register_page () && ($processed = true))
51
+ {
52
+ $_p = (!empty ($_POST)) ? c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)) : array ();
53
+ /**/
54
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
55
+ if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "registration")/**/
56
+ || ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated ()))
57
+ if (($close_section_container = true))
58
+ {
59
+ echo '<div id="ws-plugin--s2member-custom-reg-fields-4bp-section" class="ws-plugin--s2member-custom-reg-fields-4bp-section register-section">' . "\n";
60
+ echo '<div id="ws-plugin--s2member-custom-reg-fields-4bp-container" class="ws-plugin--s2member-custom-reg-fields-4bp-container">' . "\n";
61
+ echo '<input type="hidden" name="ws_plugin__s2member_registration" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-registration")) . '" />' . "\n";
62
+ }
63
+ /**/
64
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
65
+ do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_before", get_defined_vars ());
66
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
67
+ /**/
68
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
69
+ if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "registration"))
70
+ {
71
+ foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
72
+ {
73
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
74
+ do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_before_custom_fields", get_defined_vars ());
75
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
76
+ /**/
77
+ if (in_array ($field["id"], $fields_applicable)) /* Field applicable? */
78
+ {
79
+ $field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
80
+ $field_id_class = preg_replace ("/_/", "-", $field_var);
81
+ /**/
82
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
83
+ if (apply_filters ("ws_plugin__s2member_during_custom_registration_fields_4bp_during_custom_fields_display", true, get_defined_vars ()))
84
+ {
85
+ if (!empty ($field["section"]) && $field["section"] === "yes") /* Starts a new section? */
86
+ echo '<div class="ws-plugin--s2member-custom-reg-field-4bp-divider-section' . ((!empty ($field["sectitle"])) ? '-title' : '') . '">' . ((!empty ($field["sectitle"])) ? $field["sectitle"] : '') . '</div>';
87
+ /**/
88
+ echo '<div class="ws-plugin--s2member-custom-reg-field-4bp ws-plugin--s2member-custom-reg-field-4bp-' . esc_attr ($field_id_class) . ' field_' . esc_attr ($field_var) . ' editfield">' . "\n";
89
+ echo '<label for="ws-plugin--s2member-custom-reg-field-4bp-' . esc_attr ($field_id_class) . '">' . "\n";
90
+ echo '<span' . ((preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . (($field["required"] === "yes") ? ' *' : '') . '</span></label>' . "\n";
91
+ echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-4bp-", "ws-plugin--s2member-custom-reg-field-4bp", "", "", "", $_p, $_p["ws_plugin__s2member_custom_reg_field_" . $field_var], "registration");
92
+ echo '</div>' . "\n";
93
+ }
94
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
95
+ }
96
+ /**/
97
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
98
+ do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_after_custom_fields", get_defined_vars ());
99
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
100
+ }
101
+ }
102
+ /**/
103
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated ())
104
+ {
105
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
106
+ do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_before_opt_in", get_defined_vars ());
107
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
108
+ /**/
109
+ echo '<div class="ws-plugin--s2member-custom-reg-field-4bp field_opt_in editfield">' . "\n";
110
+ echo '<label for="ws-plugin--s2member-custom-reg-field-4bp-opt-in">' . "\n";
111
+ echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-4bp-opt-in" class="ws-plugin--s2member-custom-reg-field-4bp" value="1"' . (((empty ($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '') . ' />' . "\n";
112
+ echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
113
+ echo '</label>' . "\n";
114
+ echo '</div>' . "\n";
115
+ /**/
116
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
117
+ do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_after_opt_in", get_defined_vars ());
118
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
119
+ }
120
+ /**/
121
+ if ($close_section_container)
122
+ echo '</div></div>' . "\n";
123
+ /**/
124
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
125
+ do_action ("ws_plugin__s2member_during_custom_registration_fields_4bp_after", get_defined_vars ());
126
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
127
+ }
128
+ /**/
129
+ do_action ("ws_plugin__s2member_after_custom_registration_fields_4bp", get_defined_vars ());
130
+ /**/
131
+ return; /* Return for uniformity. */
132
+ }
133
+ /**
134
+ * Adds Custom Fields to BuddyPress Profiles.
135
+ *
136
+ * @package s2Member\Custom_Reg_Fields
137
+ * @since 110524RC
138
+ *
139
+ * @attaches-to: ``add_action("bp_after_profile_field_content");``
140
+ *
141
+ * @return null
142
+ */
143
+ public static function custom_profile_fields_4bp ()
144
+ {
145
+ static $processed = false; /* Process this routine only one time. */
146
+ /**/
147
+ do_action ("ws_plugin__s2member_before_custom_profile_fields_4bp", get_defined_vars ());
148
+ /**/
149
+ if (!$processed && in_array ("profile", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields_4bp"]))
150
+ if (apply_filters ("ws_plugin__s2member_custom_profile_fields_4bp_display", true, get_defined_vars ()))
151
+ if (bp_is_user_profile () && bp_is_profile_edit () && (int)bp_get_the_profile_group_id () === 1 && ($processed = true))
152
+ {
153
+ echo '<input type="hidden" name="ws_plugin__s2member_profile_4bp_save" id="ws-plugin--s2member-profile-4bp-save" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-profile-4bp-save")) . '" />' . "\n";
154
+ /**/
155
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
156
+ do_action ("ws_plugin__s2member_during_custom_profile_fields_4bp_before", get_defined_vars ());
157
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
158
+ /**/
159
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
160
+ if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "profile"))
161
+ {
162
+ $fields = get_user_option ("s2member_custom_fields"); /* Existing Custom Fields. */
163
+ /**/
164
+ foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
165
+ {
166
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
167
+ do_action ("ws_plugin__s2member_during_custom_profile_fields_4bp_before_custom_fields", get_defined_vars ());
168
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
169
+ /**/
170
+ if (in_array ($field["id"], $fields_applicable)) /* Field applicable? */
171
+ {
172
+ $field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
173
+ $field_id_class = preg_replace ("/_/", "-", $field_var);
174
+ /**/
175
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
176
+ if (apply_filters ("ws_plugin__s2member_during_custom_profile_fields_4bp_during_custom_fields_display", true, get_defined_vars ()))
177
+ {
178
+ if (!empty ($field["section"]) && $field["section"] === "yes") /* Starts a new section? */
179
+ echo '<div class="ws-plugin--s2member-profile-field-4bp-divider-section' . ((!empty ($field["sectitle"])) ? '-title' : '') . '">' . ((!empty ($field["sectitle"])) ? $field["sectitle"] : '') . '</div>';
180
+ /**/
181
+ echo '<div class="ws-plugin--s2member-profile-field-4bp ws-plugin--s2member-profile-4bp-' . esc_attr ($field_id_class) . ' field_' . esc_attr ($field_var) . ' editfield">' . "\n";
182
+ echo '<label for="ws-plugin--s2member-profile-4bp-' . esc_attr ($field_id_class) . '">' . "\n";
183
+ echo '<span' . ((preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . (($field["required"] === "yes") ? ' *' : '') . '</span></label>' . "\n";
184
+ echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_profile_4bp_", "ws-plugin--s2member-profile-4bp-", "ws-plugin--s2member-profile-field-4bp", "", "", "", $fields, $fields[$field_var], "profile");
185
+ echo '</div>' . "\n";
186
+ }
187
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
188
+ }
189
+ /**/
190
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
191
+ do_action ("ws_plugin__s2member_during_custom_profile_fields_4bp_after_custom_fields", get_defined_vars ());
192
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
193
+ }
194
+ }
195
+ /**/
196
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
197
+ do_action ("ws_plugin__s2member_during_custom_profile_fields_4bp_after", get_defined_vars ());
198
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
199
+ }
200
+ /**/
201
+ do_action ("ws_plugin__s2member_after_custom_profile_fields_4bp", get_defined_vars ());
202
+ /**/
203
+ return; /* Return for uniformity. */
204
+ }
205
+ /**
206
+ * Adds Custom Fields to BuddyPress Profiles in public view.
207
+ *
208
+ * @package s2Member\Custom_Reg_Fields
209
+ * @since 110524RC
210
+ *
211
+ * @attaches-to: ``add_action("bp_profile_field_item");``
212
+ *
213
+ * @return null
214
+ */
215
+ public static function custom_profile_field_items_4bp ()
216
+ {
217
+ static $processed = false; /* Process this routine only one time. */
218
+ /**/
219
+ do_action ("ws_plugin__s2member_before_custom_profile_field_items_4bp", get_defined_vars ());
220
+ /**/
221
+ if (!$processed && in_array ("profile-view", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields_4bp"]))
222
+ if (apply_filters ("ws_plugin__s2member_custom_profile_field_items_4bp_display", true, get_defined_vars ()))
223
+ if (bp_is_user_profile () && !bp_is_profile_edit () && (int)bp_get_the_profile_group_id () === 1 && ($processed = true))
224
+ {
225
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
226
+ do_action ("ws_plugin__s2member_during_custom_profile_field_items_4bp_before", get_defined_vars ());
227
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
228
+ /**/
229
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
230
+ if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "profile-view"))
231
+ {
232
+ $fields = get_user_option ("s2member_custom_fields"); /* Existing Custom Fields. */
233
+ /**/
234
+ foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
235
+ {
236
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
237
+ do_action ("ws_plugin__s2member_during_custom_profile_field_items_4bp_before_custom_fields", get_defined_vars ());
238
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
239
+ /**/
240
+ if (in_array ($field["id"], $fields_applicable)) /* Field applicable? */
241
+ {
242
+ $field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
243
+ $field_id_class = preg_replace ("/_/", "-", $field_var);
244
+ /**/
245
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
246
+ if (apply_filters ("ws_plugin__s2member_during_custom_profile_field_items_4bp_during_custom_fields_display", true, get_defined_vars ()))
247
+ {
248
+ if (!empty ($field["section"]) && $field["section"] === "yes") /* New section? */
249
+ {
250
+ echo '<tr class="ws-plugin--s2member-profile-field-4bp-divider-section">' . "\n";
251
+ echo '<td colspan="2"><div class="ws-plugin--s2member-profile-field-4bp-divider-section' . ((!empty ($field["sectitle"])) ? '-title' : '') . '">' . ((!empty ($field["sectitle"])) ? $field["sectitle"] : '') . '</div></td>' . "\n";
252
+ echo '</tr>' . "\n";
253
+ }
254
+ /**/
255
+ echo '<tr class="ws-plugin--s2member-profile-field-4bp ws-plugin--s2member-profile-4bp-' . esc_attr ($field_id_class) . ' field_' . esc_attr ($field_var) . '">' . "\n";
256
+ echo '<td class="ws-plugin--s2member-profile-field-4bp ws-plugin--s2member-profile-4bp-' . esc_attr ($field_id_class) . ' field_' . esc_attr ($field_var) . ' label"><span>' . $field["label"] . '</span></td>' . "\n";
257
+ echo '<td class="ws-plugin--s2member-profile-field-4bp ws-plugin--s2member-profile-4bp-' . esc_attr ($field_id_class) . ' field_' . esc_attr ($field_var) . ' data">' . c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_profile_4bp_", "ws-plugin--s2member-profile-4bp-", "ws-plugin--s2member-profile-field-4bp", "", "", "", $fields, $fields[$field_var], "profile-view") . '</td>' . "\n";
258
+ echo '</tr>' . "\n";
259
+ }
260
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
261
+ }
262
+ /**/
263
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
264
+ do_action ("ws_plugin__s2member_during_custom_profile_field_items_4bp_after_custom_fields", get_defined_vars ());
265
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
266
+ }
267
+ }
268
+ /**/
269
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
270
+ do_action ("ws_plugin__s2member_during_custom_profile_field_items_4bp_after", get_defined_vars ());
271
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
272
+ }
273
+ /**/
274
+ do_action ("ws_plugin__s2member_after_custom_profile_field_items_4bp", get_defined_vars ());
275
+ /**/
276
+ return; /* Return for uniformity. */
277
+ }
278
+ }
279
+ }
280
+ ?>
includes/classes/custom-reg-fields.inc.php CHANGED
@@ -1,35 +1,60 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_custom_reg_fields
20
  {
21
- /*
22
- Handles the creation of Custom Fields.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  */
24
- public static function custom_field_gen ($_function = FALSE, $_field = FALSE, $_name_prefix = FALSE, $_id_prefix = FALSE, $_classes = FALSE, $_styles = FALSE, $_tabindex = FALSE, $_attrs = FALSE, $_submission = FALSE, $_value = FALSE, $_lock_uneditables = FALSE)
25
  {
26
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
27
  do_action ("ws_plugin__s2member_before_custom_field_gen", get_defined_vars ());
28
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
29
  /**/
30
- if ($_function && is_array ($field = $_field) && $field["type"] && $field["id"] && $_name_prefix && $_id_prefix)
31
  {
32
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
33
  do_action ("ws_plugin__s2member_during_custom_field_gen_before", get_defined_vars ());
34
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
35
  /**/
@@ -42,130 +67,218 @@ if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields"))
42
  $common = ''; /* Common attribute configuration. */
43
  $common .= ' name="' . esc_attr ($field_name) . '"';
44
  $common .= ' id="' . esc_attr ($_id_prefix . $field_id_class) . '"';
45
- $common .= ( ($field["required"] === "yes") ? ' aria-required="true"' : '');
46
- $common .= ( (strlen ($_tabindex)) ? ' tabindex="' . esc_attr ($_tabindex) . '"' : '');
47
- $common .= ( ($field["expected"]) ? ' data-expected="' . esc_attr ($field["expected"]) . '"' : '');
48
- $common .= ( (preg_match ("/^no/", $field["editable"]) && $_lock_uneditables) ? ' disabled="disabled"' : '');
49
- $common .= ( ($_classes || $field["classes"]) ? ' class="' . esc_attr (trim ($_classes . ( ($field["classes"]) ? ' ' . $field["classes"] : ''))) . '"' : '');
50
- $common .= ( ($_styles || $field["styles"]) ? ' style="' . esc_attr (trim ($_styles . ( ($field["styles"]) ? ' ' . $field["styles"] : ''))) . '"' : '');
51
- $common .= ( ($_attrs || $field["attrs"]) ? ' ' . trim ($_attrs . ( ($field["attrs"]) ? ' ' . $field["attrs"] : '')) : '');
52
  /**/
53
  if ($field["type"] === "text")
54
  {
55
- $gen = '<input type="text" maxlength="100"';
56
- $gen .= ' value="' . format_to_edit ((string)$_value) . '"';
57
- $gen .= $common . ' />';
 
 
 
 
 
 
58
  }
59
  /**/
60
  else if ($field["type"] === "textarea")
61
  {
62
- $gen = '<textarea rows="3"' . $common . '>';
63
- $gen .= format_to_edit ((string)$_value);
64
- $gen .= '</textarea>';
 
 
 
 
 
 
65
  }
66
  /**/
67
- else if ($field["type"] === "select" && $field["options"])
68
  {
69
- $gen = '<select' . $common . '>';
70
- foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $option_line)
71
  {
72
- list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
73
- $gen .= '<option value="' . esc_attr ($option_value) . '"' . ( ( ($option_default && !$_submission) || $option_value === (string)$_value) ? ' selected="selected"' : '') . '>' . $option_label . '</option>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
- $gen .= '</select>';
76
  }
77
  /**/
78
- else if ($field["type"] === "selects" && $field["options"])
79
  {
80
- $common = preg_replace ('/ name\="(.+?)"/', ' name="$1[]"', $common);
81
- $common = preg_replace ('/ style\="(.+?)"/', ' style="height:auto; $1"', $common);
82
- /**/
83
- $gen = '<select multiple="multiple" size="3"' . $common . '>';
84
- foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $option_line)
85
  {
86
- list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
87
- $gen .= '<option value="' . esc_attr ($option_value) . '"' . ( ( ($option_default && !$_submission) || in_array ($option_value, (array)$_value)) ? ' selected="selected"' : '') . '>' . $option_label . '</option>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  }
89
- $gen .= '</select>';
90
  }
91
  /**/
92
- else if ($field["type"] === "checkbox")
93
  {
94
- $gen = '<input type="checkbox" value="1"';
95
- $gen .= ( ((string)$_value) ? ' checked="checked"' : '');
96
- $gen .= $common . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class) . '" style="display:inline;">' . $field["label"] . '</label>';
 
 
 
 
 
 
97
  }
98
  /**/
99
- else if ($field["type"] === "pre_checkbox")
100
  {
101
- $gen = '<input type="checkbox" value="1"';
102
- $gen .= ( (!$_submission || (string)$_value) ? ' checked="checked"' : '');
103
- $gen .= $common . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class) . '" style="display:inline;">' . $field["label"] . '</label>';
 
 
 
 
 
 
104
  }
105
  /**/
106
- else if ($field["type"] === "checkboxes" && $field["options"])
107
  {
108
- $gen = ""; /* Initialize generated field. */
109
- /**/
110
- $common = preg_replace ('/ name\="(.+?)"/', ' name="$1[]"', $common);
111
- /**/
112
- $sep = apply_filters ("ws_plugin__s2member_custom_field_gen_" . $field["type"] . "_sep", "&nbsp;&nbsp;", get_defined_vars ());
113
- $opl = apply_filters ("ws_plugin__s2member_custom_field_gen_" . $field["type"] . "_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars ());
114
- /**/
115
- foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
116
  {
117
- $common_i = preg_replace ('/ id\="(.+?)"/', ' id="$1-' . ($i) . '"', $common);
 
 
 
 
 
 
 
 
 
 
118
  /**/
119
- list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
 
120
  /**/
121
- $gen .= ($i > 0) ? $sep : ''; /* Separators can be filtered above. */
122
- $gen .= '<input type="checkbox" value="' . esc_attr ($option_value) . '"';
123
- $gen .= ( ( ($option_default && !$_submission) || in_array ($option_value, (array)$_value)) ? ' checked="checked"' : '');
124
- $gen .= $common_i . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class . "-" . $i) . '" class="' . esc_attr ($opl) . '" style="display:inline;">' . $option_label . '</label>';
 
 
 
 
 
 
 
125
  }
126
  }
127
  /**/
128
- else if ($field["type"] === "radios" && $field["options"])
129
  {
130
- $gen = ""; /* Initialize generated field. */
131
- /**/
132
- $sep = apply_filters ("ws_plugin__s2member_custom_field_gen_" . $field["type"] . "_sep", "&nbsp;&nbsp;", get_defined_vars ());
133
- $opl = apply_filters ("ws_plugin__s2member_custom_field_gen_" . $field["type"] . "_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars ());
134
- /**/
135
- foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
136
  {
137
- $common_i = preg_replace ('/ id\="(.+?)"/', ' id="$1-' . ($i) . '"', $common);
138
- /**/
139
- list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
 
 
 
 
 
 
 
 
 
 
 
140
  /**/
141
- $gen .= ($i > 0) ? $sep : ''; /* Separators can be filtered above. */
142
- $gen .= '<input type="radio" value="' . esc_attr ($option_value) . '"';
143
- $gen .= ( ( ($option_default && !$_submission) || $option_value === (string)$_value) ? ' checked="checked"' : '');
144
- $gen .= $common_i . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class . "-" . $i) . '" class="' . esc_attr ($opl) . '" style="display:inline;">' . $option_label . '</label>';
 
 
 
 
 
 
 
145
  }
146
  }
147
- else /* Otherwise, we use a default text field. */
148
  {
149
- $gen = '<input type="text" maxlength="100"';
150
- $gen .= ' value="' . format_to_edit ((string)$_value) . '"';
151
- $gen .= $common . ' />';
 
 
 
 
 
 
152
  }
153
  /**/
154
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
155
  do_action ("ws_plugin__s2member_during_custom_field_gen_after", get_defined_vars ());
156
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
157
  }
158
  /**/
159
  return apply_filters ("ws_plugin__s2member_custom_field_gen", $gen, get_defined_vars ());
160
  }
161
- /*
162
- Determines whether or not Custom Fields apply to a specific Level.
163
- The $level parameter defaults to the current User's Access Level number.
164
- $level MUST be numeric >= 0.
 
 
 
 
 
 
165
  */
166
  public static function custom_fields_configured_at_level ($_level = "auto-detection", $_editable_context = FALSE)
167
  {
168
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
169
  do_action ("ws_plugin__s2member_before_custom_fields_configured_at_level", get_defined_vars ());
170
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
171
  /**/
@@ -173,22 +286,31 @@ if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields"))
173
  if ($_level === "auto-detection" && $level < 0 && preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", ($cookie = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_level"]))))
174
  list ($level) = preg_split ("/\:/", $cookie, 3);
175
  /**/
176
- $level = (!is_numeric ($level) || $level < 0) ? 0 : $level; /* Always default to Level #0. */
177
  /**/
178
- if (is_numeric ($level) && $level >= 0 && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
179
  {
180
  foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
181
- if ($field["levels"] === "all" || in_array ($level, preg_split ("/[;,]+/", preg_replace ("/[^0-9,]/", "", $field["levels"]))))
182
- if (!$_editable_context || ($_editable_context === "registration" && $field["editable"] !== "yes-invisible") || ($_editable_context === "profile" && $field["editable"] !== "no-invisible"))
183
  $configured[] = $field["id"]; /* Add this to the array. */
184
  }
185
  /**/
186
- return apply_filters ("ws_plugin__s2member_custom_fields_configured_at_level", $configured, get_defined_vars ());
187
  }
188
- /*
189
- This adds custom fields to `wp-signup.php`.
190
- Attach to: add_action("signup_extra_fields");
191
- ~ For Multisite Blog Farms.
 
 
 
 
 
 
 
 
 
192
  */
193
  public static function ms_custom_registration_fields ()
194
  {
@@ -196,43 +318,48 @@ if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields"))
196
  /**/
197
  if (is_multisite () && is_main_site ()) /* Must be Multisite / Main Site. */
198
  {
199
- $_p = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST));
200
  /**/
201
  echo '<input type="hidden" name="ws_plugin__s2member_registration" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-registration")) . '" />' . "\n";
202
  /**/
203
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
204
  do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before", get_defined_vars ());
205
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
206
  /**/
207
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
208
- do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_first_name", get_defined_vars ());
209
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
210
- /**/
211
- echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">First Name *</label>' . "\n";
212
- echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_custom_reg_field_first_name" id="ws-plugin--s2member-custom-reg-field-first-name" class="ws-plugin--s2member-custom-reg-field" value="' . format_to_edit ($_p["ws_plugin__s2member_custom_reg_field_first_name"]) . '" />' . "\n";
213
- echo '<br />' . "\n";
214
- /**/
215
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
216
- do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_first_name", get_defined_vars ());
217
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
218
- /**/
219
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
220
- do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_last_name", get_defined_vars ());
221
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
222
- /**/
223
- echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">Last Name *</label>' . "\n";
224
- echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_custom_reg_field_last_name" id="ws-plugin--s2member-custom-reg-field-last-name" class="ws-plugin--s2member-custom-reg-field" value="' . format_to_edit ($_p["ws_plugin__s2member_custom_reg_field_last_name"]) . '" />' . "\n";
225
- echo '<br />' . "\n";
226
- /**/
227
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
228
- do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_last_name", get_defined_vars ());
229
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
 
 
 
 
 
230
  /**/
231
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
232
  if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "registration"))
233
  foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
234
  {
235
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
236
  do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_custom_fields", get_defined_vars ());
237
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
238
  /**/
@@ -241,122 +368,144 @@ if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields"))
241
  $field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
242
  $field_id_class = preg_replace ("/_/", "-", $field_var);
243
  /**/
244
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
245
  if (apply_filters ("ws_plugin__s2member_during_ms_custom_registration_fields_during_custom_fields_display", true, get_defined_vars ()))
246
  {
247
- echo '<label for="ws-plugin--s2member-custom-reg-field-' . esc_attr ($field_id_class) . '"' . ( (preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . ( ($field["required"] === "yes") ? ' *' : '') . '</label>' . "\n";
248
- echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-", "ws-plugin--s2member-custom-reg-field", "", "", "", $_p, $_p["ws_plugin__s2member_custom_reg_field_" . $field_var]);
 
 
 
249
  echo '<br />' . "\n";
250
  }
251
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
252
  }
253
  /**/
254
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
255
  do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_custom_fields", get_defined_vars ());
256
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
257
  }
258
  /**/
259
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated ())
260
  {
261
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
262
  do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_opt_in", get_defined_vars ());
263
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
264
  /**/
265
  echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">' . "\n";
266
- echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" class="ws-plugin--s2member-custom-reg-field" value="1"' . ( ( (empty ($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '') . ' />' . "\n";
267
  echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
268
  echo '</label>' . "\n";
269
  echo '<br />' . "\n";
270
  /**/
271
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
272
  do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_opt_in", get_defined_vars ());
273
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
274
  }
275
  /**/
276
- echo '<br />' . "\n"; /* Toss in one extra line break ( extra margin ). */
277
- /**/
278
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
279
  do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after", get_defined_vars ());
280
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
281
  }
282
  /**/
283
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
284
  do_action ("ws_plugin__s2member_after_ms_custom_registration_fields", get_defined_vars ());
285
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
286
  /**/
287
  return; /* Return for uniformity. */
288
  }
289
- /*
290
- This adds custom fields to `wp-login.php?action=register`.
291
- Attach to: add_action("register_form");
 
 
 
 
 
 
 
 
292
  */
293
  public static function custom_registration_fields ()
294
  {
295
  do_action ("ws_plugin__s2member_before_custom_registration_fields", get_defined_vars ());
296
  /**/
297
- $_p = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST));
298
  /**/
299
  echo '<input type="hidden" name="ws_plugin__s2member_registration" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-registration")) . '" />' . "\n";
300
  /**/
301
  $tabindex = 20; /* Incremented tabindex starting with 20. */
302
  /**/
303
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
304
  do_action ("ws_plugin__s2member_during_custom_registration_fields_before", get_defined_vars ());
305
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
306
  /**/
307
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"]) /* Custom Passwords? */
308
  {
309
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
310
  do_action ("ws_plugin__s2member_during_custom_registration_fields_before_user_pass", get_defined_vars ());
311
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
312
  /**/
313
  echo '<p>' . "\n";
314
- echo '<label>' . "\n";
315
- echo '<span>Password *</span><br />' . "\n";
316
- echo '<input aria-required="true" type="password" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_user_pass" id="ws-plugin--s2member-custom-reg-field-user-pass" class="ws-plugin--s2member-custom-reg-field" value="' . format_to_edit ($_p["ws_plugin__s2member_custom_reg_field_user_pass"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
 
317
  echo '</label>' . "\n";
318
- echo '</p>';
319
  /**/
320
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
 
 
 
 
 
 
 
 
321
  do_action ("ws_plugin__s2member_during_custom_registration_fields_after_user_pass", get_defined_vars ());
322
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
323
  }
324
  /**/
325
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
326
- do_action ("ws_plugin__s2member_during_custom_registration_fields_before_first_name", get_defined_vars ());
327
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
328
- /**/
329
- echo '<p>' . "\n";
330
- echo '<label>' . "\n";
331
- echo '<span>First Name *</span><br />' . "\n";
332
- echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_custom_reg_field_first_name" id="ws-plugin--s2member-custom-reg-field-first-name" class="ws-plugin--s2member-custom-reg-field" value="' . format_to_edit ($_p["ws_plugin__s2member_custom_reg_field_first_name"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
333
- echo '</label>' . "\n";
334
- echo '</p>';
335
- /**/
336
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
337
- do_action ("ws_plugin__s2member_during_custom_registration_fields_after_first_name", get_defined_vars ());
338
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
339
- /**/
340
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
341
- do_action ("ws_plugin__s2member_during_custom_registration_fields_before_last_name", get_defined_vars ());
342
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
343
- /**/
344
- echo '<p>' . "\n";
345
- echo '<label>' . "\n";
346
- echo '<span>Last Name *</span><br />' . "\n";
347
- echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_custom_reg_field_last_name" id="ws-plugin--s2member-custom-reg-field-last-name" class="ws-plugin--s2member-custom-reg-field" value="' . format_to_edit ($_p["ws_plugin__s2member_custom_reg_field_last_name"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
348
- echo '</label>' . "\n";
349
- echo '</p>';
350
- /**/
351
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
352
- do_action ("ws_plugin__s2member_during_custom_registration_fields_after_last_name", get_defined_vars ());
353
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
 
 
 
 
 
354
  /**/
355
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
356
  if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "registration"))
357
  foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
358
  {
359
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
360
  do_action ("ws_plugin__s2member_during_custom_registration_fields_before_custom_fields", get_defined_vars ());
361
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
362
  /**/
@@ -365,84 +514,54 @@ if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields"))
365
  $field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
366
  $field_id_class = preg_replace ("/_/", "-", $field_var);
367
  /**/
368
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
369
  if (apply_filters ("ws_plugin__s2member_during_custom_registration_fields_during_custom_fields_display", true, get_defined_vars ()))
370
  {
 
 
 
371
  echo '<p>' . "\n";
372
- echo '<label>' . "\n";
373
- echo '<span' . ( (preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . ( ($field["required"] === "yes") ? ' *' : '') . '</span>' . ( (preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? '' : '<br />') . "\n";
374
- echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-", "ws-plugin--s2member-custom-reg-field", "", ($tabindex = $tabindex + 10), "", $_p, $_p["ws_plugin__s2member_custom_reg_field_" . $field_var]);
375
- echo '</label>' . "\n";
376
- echo '</p>';
377
  }
378
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
379
  }
380
  /**/
381
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
382
  do_action ("ws_plugin__s2member_during_custom_registration_fields_after_custom_fields", get_defined_vars ());
383
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
384
  }
385
  /**/
386
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated ())
387
  {
388
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
389
  do_action ("ws_plugin__s2member_during_custom_registration_fields_before_opt_in", get_defined_vars ());
390
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
391
  /**/
392
  echo '<p>' . "\n";
393
- echo '<label>' . "\n";
394
- echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" class="ws-plugin--s2member-custom-reg-field" value="1"' . ( ( (empty ($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '') . ' tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
395
  echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
396
  echo '</label>' . "\n";
397
- echo '</p>';
398
  /**/
399
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
400
  do_action ("ws_plugin__s2member_during_custom_registration_fields_after_opt_in", get_defined_vars ());
401
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
402
  }
403
  /**/
404
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
405
  do_action ("ws_plugin__s2member_during_custom_registration_fields_after", get_defined_vars ());
406
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
407
  /**/
408
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
409
  do_action ("ws_plugin__s2member_after_custom_registration_fields", get_defined_vars ());
410
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
411
  /**/
412
  return; /* Return for uniformity. */
413
  }
414
- /*
415
- This adds an opt-in checkbox to the BuddyPress signup form.
416
- Attach to: add_action("bp_before_registration_submit_buttons");
417
- */
418
- public static function opt_in_4bp ()
419
- {
420
- do_action ("ws_plugin__s2member_before_opt_in_4bp", get_defined_vars ());
421
- /**/
422
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated ())
423
- {
424
- do_action ("ws_plugin__s2member_during_opt_in_4bp_before", get_defined_vars ());
425
- /**/
426
- $_p = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST));
427
- /**/
428
- echo '<div class="s2member-opt-in-4bp" style="' . apply_filters ("ws_plugin__s2member_opt_in_4bp_styles", "clear:both; padding-top:10px; margin-left:-3px;", get_defined_vars ()) . '">' . "\n";
429
- /**/
430
- echo '<p>' . "\n";
431
- echo '<label>' . "\n";
432
- echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" class="ws-plugin--s2member-custom-reg-field" value="1"' . ( ( (empty ($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '') . ' />' . "\n";
433
- echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
434
- echo '</label>' . "\n";
435
- echo '</p>';
436
- /**/
437
- echo '</div>' . "\n";
438
- /**/
439
- do_action ("ws_plugin__s2member_during_opt_in_4bp_after", get_defined_vars ());
440
- }
441
- /**/
442
- do_action ("ws_plugin__s2member_after_opt_in_4bp", get_defined_vars ());
443
- /**/
444
- return; /* Return for uniformity. */
445
- }
446
  }
447
  }
448
  ?>
1
  <?php
2
+ /**
3
+ * Custom Registration Fields for s2Member.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Custom_Reg_Fields
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields"))
21
  {
22
+ /**
23
+ * Custom Registration Fields for s2Member.
24
+ *
25
+ * @package s2Member\Custom_Reg_Fields
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_custom_reg_fields
29
  {
30
+ /**
31
+ * Generates all Custom Fields.
32
+ *
33
+ * @package s2Member\Custom_Reg_Fields
34
+ * @since 3.5
35
+ *
36
+ * @param str $_function Function calling upon this routine.
37
+ * @param array $_field The Field array of configuration options.
38
+ * @param str $_name_prefix The `name=""` attribute prefix.
39
+ * @param str $_id_prefix The `id=""` attribute prefix.
40
+ * @param str $_classes Optional. String of space separated classes that will go inside the Field's `class=""` attribute.
41
+ * @param str $_styles Optional. String of CSS styles that will go inside the Field's `style=""` attribute.
42
+ * @param str|int $_tabindex. Optional numeric tabindex for the `tabindex=""` attribute.
43
+ * @param str $_attrs Optional. Some additional Field attributes and values.
44
+ * @param array $_submission Optional. But should be passed in with any submission data related to this Field. For instance, you might pass in ``$_POST``.
45
+ * @param str|array $_value Optional. The value of this Field, either by default, or from the ``$_submission`` array.
46
+ * @param str $_editable_context Optional. One of `profile|profile-view|registration`.
47
+ * @return str The resulting Custom Field, in HTML format.
48
  */
49
+ public static function custom_field_gen ($_function = FALSE, $_field = FALSE, $_name_prefix = FALSE, $_id_prefix = FALSE, $_classes = FALSE, $_styles = FALSE, $_tabindex = FALSE, $_attrs = FALSE, $_submission = FALSE, $_value = FALSE, $_editable_context = FALSE)
50
  {
51
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
52
  do_action ("ws_plugin__s2member_before_custom_field_gen", get_defined_vars ());
53
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
54
  /**/
55
+ if (!($gen = "") && $_function && is_array ($field = $_field) && !empty ($field["type"]) && !empty ($field["id"]) && $_name_prefix && $_id_prefix)
56
  {
57
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
58
  do_action ("ws_plugin__s2member_during_custom_field_gen_before", get_defined_vars ());
59
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
60
  /**/
67
  $common = ''; /* Common attribute configuration. */
68
  $common .= ' name="' . esc_attr ($field_name) . '"';
69
  $common .= ' id="' . esc_attr ($_id_prefix . $field_id_class) . '"';
70
+ $common .= ((!empty ($field["required"]) && $field["required"] === "yes") ? ' aria-required="true"' : '');
71
+ $common .= ((strlen ($_tabindex)) ? ' tabindex="' . esc_attr ($_tabindex) . '"' : ''); /* No tabindex if empty. */
72
+ $common .= ((!empty ($field["expected"])) ? ' data-expected="' . esc_attr ($field["expected"]) . '"' : ''); /* Certain data expected? */
73
+ $common .= (($_editable_context === "profile-view" || (!empty ($field["editable"]) && preg_match ("/^no/", $field["editable"]) && $_editable_context === "profile")) ? ' disabled="disabled"' : '');
74
+ $common .= (($_classes || !empty ($field["classes"])) ? ' class="' . esc_attr (trim ($_classes . ((!empty ($field["classes"])) ? ' ' . $field["classes"] : ''))) . '"' : '');
75
+ $common .= (($_styles || !empty ($field["styles"])) ? ' style="' . esc_attr (trim ($_styles . ((!empty ($field["styles"])) ? ' ' . $field["styles"] : ''))) . '"' : '');
76
+ $common .= (($_attrs || !empty ($field["attrs"])) ? ' ' . trim ($_attrs . ((!empty ($field["attrs"])) ? ' ' . $field["attrs"] : '')) : '');
77
  /**/
78
  if ($field["type"] === "text")
79
  {
80
+ if ($_editable_context === "profile-view")
81
+ $gen = esc_html ((string)$_value);
82
+ /**/
83
+ else /* Else handle this Field normally. */
84
+ {
85
+ $gen = '<input type="text" maxlength="100"';
86
+ $gen .= ' value="' . format_to_edit ((isset ($field["deflt"]) && strlen ($field["deflt"]) && !$_submission) ? (string)$field["deflt"] : (string)$_value) . '"';
87
+ $gen .= $common . ' />';
88
+ }
89
  }
90
  /**/
91
  else if ($field["type"] === "textarea")
92
  {
93
+ if ($_editable_context === "profile-view")
94
+ $gen = nl2br (esc_html ((string)$_value));
95
+ /**/
96
+ else /* Else handle this Field normally. */
97
+ {
98
+ $gen = '<textarea rows="3"' . $common . '>';
99
+ $gen .= format_to_edit ((isset ($field["deflt"]) && strlen ($field["deflt"]) && !$_submission) ? (string)$field["deflt"] : (string)$_value);
100
+ $gen .= '</textarea>';
101
+ }
102
  }
103
  /**/
104
+ else if ($field["type"] === "select" && !empty ($field["options"]))
105
  {
106
+ if ($_editable_context === "profile-view")
 
107
  {
108
+ foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $option_line)
109
+ {
110
+ list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
111
+ if ($option_value === (string)$_value)
112
+ {
113
+ $gen = $option_label;
114
+ break;
115
+ }
116
+ }
117
+ }
118
+ else /* Else handle this Field normally. */
119
+ {
120
+ $gen = '<select' . $common . '>';
121
+ foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $option_line)
122
+ {
123
+ list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
124
+ $gen .= '<option value="' . esc_attr ($option_value) . '"' . ((($option_default && !$_submission) || $option_value === (string)$_value) ? ' selected="selected"' : '') . '>' . $option_label . '</option>';
125
+ }
126
+ $gen .= '</select>';
127
  }
 
128
  }
129
  /**/
130
+ else if ($field["type"] === "selects" && !empty ($field["options"]))
131
  {
132
+ if ($_editable_context === "profile-view")
 
 
 
 
133
  {
134
+ foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $option_line)
135
+ {
136
+ list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
137
+ if (in_array ($option_value, (array)$_value))
138
+ $gen .= $option_label . ", ";
139
+ }
140
+ $gen = trim ($gen, ", \r\n\t\0\x0B");
141
+ }
142
+ else /* Else handle this Field normally. */
143
+ {
144
+ $common = preg_replace ('/ name\="(.+?)"/', ' name="$1[]"', $common);
145
+ $common = preg_replace ('/ style\="(.+?)"/', ' style="height:auto; $1"', $common);
146
+ /**/
147
+ $gen = '<select multiple="multiple" size="3"' . $common . '>';
148
+ foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $option_line)
149
+ {
150
+ list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
151
+ $gen .= '<option value="' . esc_attr ($option_value) . '"' . ((($option_default && !$_submission) || in_array ($option_value, (array)$_value)) ? ' selected="selected"' : '') . '>' . $option_label . '</option>';
152
+ }
153
+ $gen .= '</select>';
154
  }
 
155
  }
156
  /**/
157
+ else if ($field["type"] === "checkbox" && !empty ($field["label"]))
158
  {
159
+ if ($_editable_context === "profile-view")
160
+ $gen = ((string)$_value) ? "yes" : "no";
161
+ /**/
162
+ else /* Else handle this Field normally. */
163
+ {
164
+ $gen = '<input type="checkbox" value="1"';
165
+ $gen .= (((string)$_value) ? ' checked="checked"' : '');
166
+ $gen .= $common . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class) . '" style="display:inline !important; margin:0 !important;">' . $field["label"] . '</label>';
167
+ }
168
  }
169
  /**/
170
+ else if ($field["type"] === "pre_checkbox" && !empty ($field["label"]))
171
  {
172
+ if ($_editable_context === "profile-view")
173
+ $gen = ((string)$_value) ? "yes" : "no";
174
+ /**/
175
+ else /* Else handle this Field normally. */
176
+ {
177
+ $gen = '<input type="checkbox" value="1"';
178
+ $gen .= ((!$_submission || (string)$_value) ? ' checked="checked"' : '');
179
+ $gen .= $common . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class) . '" style="display:inline !important; margin:0 !important;">' . $field["label"] . '</label>';
180
+ }
181
  }
182
  /**/
183
+ else if ($field["type"] === "checkboxes" && !empty ($field["options"]))
184
  {
185
+ if ($_editable_context === "profile-view")
 
 
 
 
 
 
 
186
  {
187
+ foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
188
+ {
189
+ list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
190
+ if (in_array ($option_value, (array)$_value))
191
+ $gen .= $option_label . ", ";
192
+ }
193
+ $gen = trim ($gen, ", \r\n\t\0\x0B");
194
+ }
195
+ else /* Else handle this Field normally. */
196
+ {
197
+ $common = preg_replace ('/ name\="(.+?)"/', ' name="$1[]"', $common);
198
  /**/
199
+ $sep = apply_filters ("ws_plugin__s2member_custom_field_gen_checkboxes_sep", "&nbsp;&nbsp;", get_defined_vars ());
200
+ $opl = apply_filters ("ws_plugin__s2member_custom_field_gen_checkboxes_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars ());
201
  /**/
202
+ foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
203
+ {
204
+ $common_i = preg_replace ('/ id\="(.+?)"/', ' id="$1-' . ($i) . '"', $common);
205
+ /**/
206
+ list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
207
+ /**/
208
+ $gen .= ($i > 0) ? $sep : ''; /* Separators can be filtered above. */
209
+ $gen .= '<input type="checkbox" value="' . esc_attr ($option_value) . '"';
210
+ $gen .= ((($option_default && !$_submission) || in_array ($option_value, (array)$_value)) ? ' checked="checked"' : '');
211
+ $gen .= $common_i . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class . "-" . $i) . '" class="' . esc_attr ($opl) . '" style="display:inline !important; margin:0 !important;">' . $option_label . '</label>';
212
+ }
213
  }
214
  }
215
  /**/
216
+ else if ($field["type"] === "radios" && !empty ($field["options"]))
217
  {
218
+ if ($_editable_context === "profile-view")
 
 
 
 
 
219
  {
220
+ foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
221
+ {
222
+ list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
223
+ if ($option_value === (string)$_value)
224
+ {
225
+ $gen = $option_label;
226
+ break;
227
+ }
228
+ }
229
+ }
230
+ else /* Else handle this Field normally. */
231
+ {
232
+ $sep = apply_filters ("ws_plugin__s2member_custom_field_gen_radios_sep", "&nbsp;&nbsp;", get_defined_vars ());
233
+ $opl = apply_filters ("ws_plugin__s2member_custom_field_gen_radios_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars ());
234
  /**/
235
+ foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
236
+ {
237
+ $common_i = preg_replace ('/ id\="(.+?)"/', ' id="$1-' . ($i) . '"', $common);
238
+ /**/
239
+ list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line)));
240
+ /**/
241
+ $gen .= ($i > 0) ? $sep : ''; /* Separators can be filtered above. */
242
+ $gen .= '<input type="radio" value="' . esc_attr ($option_value) . '"';
243
+ $gen .= ((($option_default && !$_submission) || $option_value === (string)$_value) ? ' checked="checked"' : '');
244
+ $gen .= $common_i . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class . "-" . $i) . '" class="' . esc_attr ($opl) . '" style="display:inline !important; margin:0 !important;">' . $option_label . '</label>';
245
+ }
246
  }
247
  }
248
+ else /* Default to using a text field. */
249
  {
250
+ if ($_editable_context === "profile-view")
251
+ $gen = esc_html ((string)$_value);
252
+ /**/
253
+ else /* Else handle this Field normally. */
254
+ {
255
+ $gen = '<input type="text" maxlength="100"';
256
+ $gen .= ' value="' . format_to_edit ((isset ($field["deflt"]) && strlen ($field["deflt"]) && !$_submission) ? (string)$field["deflt"] : (string)$_value) . '"';
257
+ $gen .= $common . ' />';
258
+ }
259
  }
260
  /**/
261
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
262
  do_action ("ws_plugin__s2member_during_custom_field_gen_after", get_defined_vars ());
263
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
264
  }
265
  /**/
266
  return apply_filters ("ws_plugin__s2member_custom_field_gen", $gen, get_defined_vars ());
267
  }
268
+ /**
269
+ * Determines which Custom Fields apply to a specific Level.
270
+ *
271
+ * @package s2Member\Custom_Reg_Fields
272
+ * @since 3.5
273
+ *
274
+ * @param str|int $_level Optional. Defaults to the current User's Access Level number.
275
+ * You can either pass in a numeric Level number, or the string `auto-detection`.
276
+ * @param str $_editable_context Optional. One of `profile|profile-view|registration`.
277
+ * @return array Array of Custom Field IDs applicable.
278
  */
279
  public static function custom_fields_configured_at_level ($_level = "auto-detection", $_editable_context = FALSE)
280
  {
281
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
282
  do_action ("ws_plugin__s2member_before_custom_fields_configured_at_level", get_defined_vars ());
283
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
284
  /**/
286
  if ($_level === "auto-detection" && $level < 0 && preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", ($cookie = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_level"]))))
287
  list ($level) = preg_split ("/\:/", $cookie, 3);
288
  /**/
289
+ $level = ($level !== "any" && (!is_numeric ($level) || $level < 0)) ? 0 : $level; /* Default zero. */
290
  /**/
291
+ if (($level === "any" || (is_numeric ($level) && $level >= 0)) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
292
  {
293
  foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
294
+ if ($level === "any" || $field["levels"] === "all" || in_array ($level, preg_split ("/[;,]+/", preg_replace ("/[^0-9,]/", "", $field["levels"]))))
295
+ if (empty ($_editable_context) || $_editable_context === "administrative" || ($_editable_context === "registration" && $field["editable"] !== "yes-invisible") || (($_editable_context === "profile" || $_editable_context === "profile-view") && $field["editable"] !== "no-invisible"))
296
  $configured[] = $field["id"]; /* Add this to the array. */
297
  }
298
  /**/
299
+ return apply_filters ("ws_plugin__s2member_custom_fields_configured_at_level", ((!empty ($configured)) ? $configured : array ()), get_defined_vars ());
300
  }
301
+ /**
302
+ * Adds Custom Fields to: `/wp-signup.php`.
303
+ *
304
+ * For Multisite Blog Farms.
305
+ *
306
+ * @package s2Member\Custom_Reg_Fields
307
+ * @since 3.5
308
+ *
309
+ * @attaches-to: ``add_action("signup_extra_fields");``
310
+ *
311
+ * @return null
312
+ *
313
+ * @todo Optimize with ``empty()``.
314
  */
315
  public static function ms_custom_registration_fields ()
316
  {
318
  /**/
319
  if (is_multisite () && is_main_site ()) /* Must be Multisite / Main Site. */
320
  {
321
+ $_p = (!empty ($_POST)) ? c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)) : array ();
322
  /**/
323
  echo '<input type="hidden" name="ws_plugin__s2member_registration" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-registration")) . '" />' . "\n";
324
  /**/
325
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
326
  do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before", get_defined_vars ());
327
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
328
  /**/
329
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"])
330
+ {
331
+ echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section"></div>' . "\n";
332
+ /**/
333
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
334
+ do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_first_name", get_defined_vars ());
335
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
336
+ /**/
337
+ echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">First Name *</label>' . "\n";
338
+ echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_custom_reg_field_first_name" id="ws-plugin--s2member-custom-reg-field-first-name" class="ws-plugin--s2member-custom-reg-field" value="' . format_to_edit ($_p["ws_plugin__s2member_custom_reg_field_first_name"]) . '" />' . "\n";
339
+ echo '<br />' . "\n";
340
+ /**/
341
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
342
+ do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_first_name", get_defined_vars ());
343
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
344
+ /**/
345
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
346
+ do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_last_name", get_defined_vars ());
347
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
348
+ /**/
349
+ echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">Last Name *</label>' . "\n";
350
+ echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_custom_reg_field_last_name" id="ws-plugin--s2member-custom-reg-field-last-name" class="ws-plugin--s2member-custom-reg-field" value="' . format_to_edit ($_p["ws_plugin__s2member_custom_reg_field_last_name"]) . '" />' . "\n";
351
+ echo '<br />' . "\n";
352
+ /**/
353
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
354
+ do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_last_name", get_defined_vars ());
355
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
356
+ }
357
  /**/
358
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
359
  if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "registration"))
360
  foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
361
  {
362
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
363
  do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_custom_fields", get_defined_vars ());
364
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
365
  /**/
368
  $field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
369
  $field_id_class = preg_replace ("/_/", "-", $field_var);
370
  /**/
371
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
372
  if (apply_filters ("ws_plugin__s2member_during_ms_custom_registration_fields_during_custom_fields_display", true, get_defined_vars ()))
373
  {
374
+ if (!empty ($field["section"]) && $field["section"] === "yes") /* Starts a new section? */
375
+ echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section' . ((!empty ($field["sectitle"])) ? '-title' : '') . '">' . ((!empty ($field["sectitle"])) ? $field["sectitle"] : '') . '</div>';
376
+ /**/
377
+ echo '<label for="ws-plugin--s2member-custom-reg-field-' . esc_attr ($field_id_class) . '"' . ((preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . (($field["required"] === "yes") ? ' *' : '') . '</label>' . ((preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? '<br />' : '') . "\n";
378
+ echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-", "ws-plugin--s2member-custom-reg-field", "", "", "", $_p, $_p["ws_plugin__s2member_custom_reg_field_" . $field_var], "registration");
379
  echo '<br />' . "\n";
380
  }
381
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
382
  }
383
  /**/
384
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
385
  do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_custom_fields", get_defined_vars ());
386
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
387
  }
388
  /**/
389
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated ())
390
  {
391
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
392
  do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_opt_in", get_defined_vars ());
393
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
394
  /**/
395
  echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">' . "\n";
396
+ echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" class="ws-plugin--s2member-custom-reg-field" value="1"' . (((empty ($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '') . ' />' . "\n";
397
  echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
398
  echo '</label>' . "\n";
399
  echo '<br />' . "\n";
400
  /**/
401
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
402
  do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_opt_in", get_defined_vars ());
403
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
404
  }
405
  /**/
406
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
 
 
407
  do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after", get_defined_vars ());
408
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
409
  }
410
  /**/
411
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
412
  do_action ("ws_plugin__s2member_after_ms_custom_registration_fields", get_defined_vars ());
413
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
414
  /**/
415
  return; /* Return for uniformity. */
416
  }
417
+ /**
418
+ * Adds Custom Fields to: `/wp-login.php?action=register`.
419
+ *
420
+ * @package s2Member\Custom_Reg_Fields
421
+ * @since 3.5
422
+ *
423
+ * @attaches-to: ``add_action("register_form");``
424
+ *
425
+ * @return null
426
+ *
427
+ * @todo Optimize with ``empty()``.
428
  */
429
  public static function custom_registration_fields ()
430
  {
431
  do_action ("ws_plugin__s2member_before_custom_registration_fields", get_defined_vars ());
432
  /**/
433
+ $_p = (!empty ($_POST)) ? c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)) : array ();
434
  /**/
435
  echo '<input type="hidden" name="ws_plugin__s2member_registration" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-registration")) . '" />' . "\n";
436
  /**/
437
  $tabindex = 20; /* Incremented tabindex starting with 20. */
438
  /**/
439
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
440
  do_action ("ws_plugin__s2member_during_custom_registration_fields_before", get_defined_vars ());
441
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
442
  /**/
443
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
444
  {
445
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
446
  do_action ("ws_plugin__s2member_during_custom_registration_fields_before_user_pass", get_defined_vars ());
447
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
448
  /**/
449
  echo '<p>' . "\n";
450
+ /**/
451
+ echo '<label for="ws-plugin--s2member-custom-reg-field-user-pass1" title="Please type your Password twice to confirm.">' . "\n";
452
+ echo '<span>Password ( please type it twice ) *</span><br />' . "\n";
453
+ echo '<input aria-required="true" type="password" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_user_pass1" id="ws-plugin--s2member-custom-reg-field-user-pass1" class="ws-plugin--s2member-custom-reg-field" value="' . format_to_edit ($_p["ws_plugin__s2member_custom_reg_field_user_pass1"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
454
  echo '</label>' . "\n";
 
455
  /**/
456
+ echo '<label for="ws-plugin--s2member-custom-reg-field-user-pass2" title="Please type your Password twice to confirm.">' . "\n";
457
+ echo '<input type="password" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_user_pass2" id="ws-plugin--s2member-custom-reg-field-user-pass2" class="ws-plugin--s2member-custom-reg-field" value="' . format_to_edit ($_p["ws_plugin__s2member_custom_reg_field_user_pass2"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
458
+ echo '</label>' . "\n";
459
+ /**/
460
+ echo '<div id="ws-plugin--s2member-custom-reg-field-user-pass-strength" class="ws-plugin--s2member-password-strength"><em>password strength indicator</em></div>' . "\n";
461
+ /**/
462
+ echo '</p>' . "\n";
463
+ /**/
464
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
465
  do_action ("ws_plugin__s2member_during_custom_registration_fields_after_user_pass", get_defined_vars ());
466
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
467
  }
468
  /**/
469
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"])
470
+ {
471
+ echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section"></div>' . "\n";
472
+ /**/
473
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
474
+ do_action ("ws_plugin__s2member_during_custom_registration_fields_before_first_name", get_defined_vars ());
475
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
476
+ /**/
477
+ echo '<p>' . "\n";
478
+ echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">' . "\n";
479
+ echo '<span>First Name *</span><br />' . "\n";
480
+ echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_custom_reg_field_first_name" id="ws-plugin--s2member-custom-reg-field-first-name" class="ws-plugin--s2member-custom-reg-field" value="' . format_to_edit ($_p["ws_plugin__s2member_custom_reg_field_first_name"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
481
+ echo '</label>' . "\n";
482
+ echo '</p>' . "\n";
483
+ /**/
484
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
485
+ do_action ("ws_plugin__s2member_during_custom_registration_fields_after_first_name", get_defined_vars ());
486
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
487
+ /**/
488
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
489
+ do_action ("ws_plugin__s2member_during_custom_registration_fields_before_last_name", get_defined_vars ());
490
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
491
+ /**/
492
+ echo '<p>' . "\n";
493
+ echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">' . "\n";
494
+ echo '<span>Last Name *</span><br />' . "\n";
495
+ echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_custom_reg_field_last_name" id="ws-plugin--s2member-custom-reg-field-last-name" class="ws-plugin--s2member-custom-reg-field" value="' . format_to_edit ($_p["ws_plugin__s2member_custom_reg_field_last_name"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
496
+ echo '</label>' . "\n";
497
+ echo '</p>' . "\n";
498
+ /**/
499
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
500
+ do_action ("ws_plugin__s2member_during_custom_registration_fields_after_last_name", get_defined_vars ());
501
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
502
+ }
503
  /**/
504
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
505
  if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "registration"))
506
  foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
507
  {
508
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
509
  do_action ("ws_plugin__s2member_during_custom_registration_fields_before_custom_fields", get_defined_vars ());
510
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
511
  /**/
514
  $field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
515
  $field_id_class = preg_replace ("/_/", "-", $field_var);
516
  /**/
517
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
518
  if (apply_filters ("ws_plugin__s2member_during_custom_registration_fields_during_custom_fields_display", true, get_defined_vars ()))
519
  {
520
+ if (!empty ($field["section"]) && $field["section"] === "yes") /* Starts a new section? */
521
+ echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section' . ((!empty ($field["sectitle"])) ? '-title' : '') . '">' . ((!empty ($field["sectitle"])) ? $field["sectitle"] : '') . '</div>';
522
+ /**/
523
  echo '<p>' . "\n";
524
+ echo '<label for="ws-plugin--s2member-custom-reg-field-' . esc_attr ($field_id_class) . '">' . "\n";
525
+ echo '<span' . ((preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . (($field["required"] === "yes") ? ' *' : '') . '</span></label>' . ((preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? '' : '<br />') . "\n";
526
+ echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-", "ws-plugin--s2member-custom-reg-field", "", ($tabindex = $tabindex + 10), "", $_p, $_p["ws_plugin__s2member_custom_reg_field_" . $field_var], "registration");
527
+ echo '</p>' . "\n";
 
528
  }
529
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
530
  }
531
  /**/
532
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
533
  do_action ("ws_plugin__s2member_during_custom_registration_fields_after_custom_fields", get_defined_vars ());
534
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
535
  }
536
  /**/
537
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated ())
538
  {
539
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
540
  do_action ("ws_plugin__s2member_during_custom_registration_fields_before_opt_in", get_defined_vars ());
541
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
542
  /**/
543
  echo '<p>' . "\n";
544
+ echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">' . "\n";
545
+ echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" class="ws-plugin--s2member-custom-reg-field" value="1"' . (((empty ($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '') . ' tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
546
  echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
547
  echo '</label>' . "\n";
548
+ echo '</p>' . "\n";
549
  /**/
550
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
551
  do_action ("ws_plugin__s2member_during_custom_registration_fields_after_opt_in", get_defined_vars ());
552
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
553
  }
554
  /**/
555
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
556
  do_action ("ws_plugin__s2member_during_custom_registration_fields_after", get_defined_vars ());
557
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
558
  /**/
559
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
560
  do_action ("ws_plugin__s2member_after_custom_registration_fields", get_defined_vars ());
561
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
562
  /**/
563
  return; /* Return for uniformity. */
564
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
565
  }
566
  }
567
  ?>
includes/classes/email-configs.inc.php CHANGED
@@ -1,26 +1,41 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_email_configs"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_email_configs
20
  {
21
- /*
22
- Function that modifies the email From: "Name" <address>.
23
- ( these filters are only needed during registration )
 
 
 
 
 
 
24
  */
25
  public static function email_config ()
26
  {
@@ -35,8 +50,16 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
35
  /**/
36
  return; /* Return for uniformity. */
37
  }
38
- /*
39
- A sort of callback function that applies the email filter.
 
 
 
 
 
 
 
 
40
  */
41
  public static function _email_config_email ($email = FALSE)
42
  {
@@ -44,8 +67,16 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
44
  /**/
45
  return apply_filters ("_ws_plugin__s2member_email_config_email", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"], get_defined_vars ());
46
  }
47
- /*
48
- A sort of callback function that applies the name filter.
 
 
 
 
 
 
 
 
49
  */
50
  public static function _email_config_name ($name = FALSE)
51
  {
@@ -53,8 +84,14 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
53
  /**/
54
  return apply_filters ("_ws_plugin__s2member_email_config_name", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"], get_defined_vars ());
55
  }
56
- /*
57
- Checks the status of filters on the email From: "Name" <address>.
 
 
 
 
 
 
58
  */
59
  public static function email_config_status ($any = TRUE)
60
  {
@@ -68,8 +105,14 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
68
  /**/
69
  return apply_filters ("ws_plugin__s2member_email_config_status", false, get_defined_vars ());
70
  }
71
- /*
72
- Release functions that modify the email From: "Name" <address>.
 
 
 
 
 
 
73
  */
74
  public static function email_config_release ($all = TRUE)
75
  {
@@ -85,10 +128,18 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
85
  /**/
86
  return; /* Return for uniformity. */
87
  }
88
- /*
89
- Convert primitive Role names in emails sent by WordPress®.
90
- Attach to: add_filter("wpmu_signup_user_notification_email");
91
- ~ Only necessary with this particular email.
 
 
 
 
 
 
 
 
92
  */
93
  public static function ms_nice_email_roles ($message = FALSE)
94
  {
@@ -96,7 +147,7 @@ if (!class_exists ("c_ws_plugin__s2member_email_configs"))
96
  do_action ("ws_plugin__s2member_before_ms_nice_email_roles", get_defined_vars ());
97
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
98
  /**/
99
- $message = preg_replace ("/ as a (subscriber|s2member_level[1-4])/i", " as a Member", $message);
100
  /**/
101
  return apply_filters ("ws_plugin__s2member_ms_nice_email_roles", $message, get_defined_vars ());
102
  }
1
  <?php
2
+ /**
3
+ * Email configurations for s2Member.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Email_Configs
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_email_configs"))
21
  {
22
+ /**
23
+ * Email configurations for s2Member.
24
+ *
25
+ * @package s2Member\Email_Configs
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_email_configs
29
  {
30
+ /**
31
+ * Modifies email From: "Name" <address>.
32
+ *
33
+ * These Filters are only needed during registration.
34
+ *
35
+ * @package s2Member\Email_Configs
36
+ * @since 3.5
37
+ *
38
+ * @return null
39
  */
40
  public static function email_config ()
41
  {
50
  /**/
51
  return; /* Return for uniformity. */
52
  }
53
+ /**
54
+ * A sort of callback function that applies the email Filter.
55
+ *
56
+ * @package s2Member\Email_Configs
57
+ * @since 3.5
58
+ *
59
+ * @attaches-to ``add_filter("wp_mail_from");``
60
+ *
61
+ * @param str $email Expects the email address to be passed in by the Filter.
62
+ * @return str s2Member-configured email address.
63
  */
64
  public static function _email_config_email ($email = FALSE)
65
  {
67
  /**/
68
  return apply_filters ("_ws_plugin__s2member_email_config_email", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"], get_defined_vars ());
69
  }
70
+ /**
71
+ * A sort of callback function that applies the name Filter.
72
+ *
73
+ * @package s2Member\Email_Configs
74
+ * @since 3.5
75
+ *
76
+ * @attaches-to ``add_filter("wp_mail_from_name");``
77
+ *
78
+ * @param str $name Expects the name to be passed in by the Filter.
79
+ * @return str s2Member-configured name.
80
  */
81
  public static function _email_config_name ($name = FALSE)
82
  {
84
  /**/
85
  return apply_filters ("_ws_plugin__s2member_email_config_name", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"], get_defined_vars ());
86
  }
87
+ /**
88
+ * Checks the status of Filters being applied to the email From: "Name" <address>.
89
+ *
90
+ * @package s2Member\Email_Configs
91
+ * @since 3.5
92
+ *
93
+ * @param bool $any Optional. Defaults to true. If true, return true if ANY Filters are being applied, not just those applied by s2Member.
94
+ * @return bool True if Filters are being applied, else false.
95
  */
96
  public static function email_config_status ($any = TRUE)
97
  {
105
  /**/
106
  return apply_filters ("ws_plugin__s2member_email_config_status", false, get_defined_vars ());
107
  }
108
+ /**
109
+ * Releases Filters that modify the email From: "Name" <address>.
110
+ *
111
+ * @package s2Member\Email_Configs
112
+ * @since 3.5
113
+ *
114
+ * @param bool $all Optional. Defaults to true. If true, remove ALL Filters, not just those applied by s2Member.
115
+ * @return null
116
  */
117
  public static function email_config_release ($all = TRUE)
118
  {
128
  /**/
129
  return; /* Return for uniformity. */
130
  }
131
+ /**
132
+ * Converts primitive Role names in emails sent by WordPress®.
133
+ *
134
+ * Only necessary with this particular email: `wpmu_signup_user_notification_email`.
135
+ *
136
+ * @package s2Member\Email_Configs
137
+ * @since 3.5
138
+ *
139
+ * @attaches-to: ``add_filter("wpmu_signup_user_notification_email");``
140
+ *
141
+ * @param str $message Expects the message string to be passed in by the Filter.
142
+ * @return str Message after having been Filtered by s2Member.
143
  */
144
  public static function ms_nice_email_roles ($message = FALSE)
145
  {
147
  do_action ("ws_plugin__s2member_before_ms_nice_email_roles", get_defined_vars ());
148
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
149
  /**/
150
+ $message = preg_replace ("/ as a (subscriber|s2member_level[0-9]+)/i", " as a Member", $message);
151
  /**/
152
  return apply_filters ("ws_plugin__s2member_ms_nice_email_roles", $message, get_defined_vars ());
153
  }
includes/classes/files-checks.inc.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
13
- */
14
- if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
- /**/
17
- if (!class_exists ("c_ws_plugin__s2member_files_checks"))
18
- {
19
- class c_ws_plugin__s2member_files_checks
20
- {
21
- /*
22
- Function for handling download access permissions.
23
- Attach to: add_action("init");
24
- */
25
- public static function check_file_download_access ()
26
- {
27
- if ($_GET["s2member_file_download"]) /* Call inner function? */
28
- {
29
- return c_ws_plugin__s2member_files_in::check_file_download_access ();
30
- }
31
- }
32
- }
33
- }
34
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/classes/files-in.inc.php CHANGED
@@ -1,49 +1,69 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_files_in"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_files_in
20
  {
21
- /*
22
- Function for handling download access permissions.
23
- Attach to: add_action("init");
 
 
 
 
 
 
24
  */
25
  public static function check_file_download_access ()
26
  {
27
  do_action ("ws_plugin__s2member_before_file_download_access", get_defined_vars ());
28
  /**/
29
- if ($_GET["s2member_file_download"]) /* Filter $excluded to force free downloads. */
30
  {
31
  $excluded = apply_filters ("ws_plugin__s2member_check_file_download_access_excluded", false, get_defined_vars ());
32
  /**/
33
- if (!$excluded && (!$_GET["s2member_file_download_key"] || ($_GET["s2member_file_download_key"] && ! ($file_download_key_is_valid = ($_GET["s2member_file_download_key"] === c_ws_plugin__s2member_files::file_download_key ($_GET["s2member_file_download"]) || $_GET["s2member_file_download_key"] === c_ws_plugin__s2member_files::file_download_key ($_GET["s2member_file_download"], true))))))
 
 
 
34
  {
35
  $_GET["s2member_file_download"] = trim ($_GET["s2member_file_download"], "/"); /* Trim slashes after Key comparison. */
36
  /**/
37
- if (!file_exists ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]))
38
  {
39
  header ("HTTP/1.0 404 Not Found"); /* The file does NOT even exist. */
40
  exit ("404: Sorry, file not found. Please contact Support for assistance.");
41
  }
42
- else if ($_GET["s2member_file_download_key"] && !$file_download_key_is_valid) /* Was an invalid Key passed in? */
 
43
  {
44
  header ("HTTP/1.0 503 Service Temporarily Unavailable"); /* Invalid Download Keys are handled separately. */
45
  exit ("503 ( Invalid Key ): Sorry, your access to this file has expired. Please contact Support for assistance.");
46
  }
 
47
  else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Is a Membership Options Page configured? */
48
  /* This file will be processed WITHOUT a Download Key, using Membership Level Access ( w/ possible Custom Capabilities ). */
49
  {
@@ -53,12 +73,26 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
53
  if (($file_download_access_is_allowed = $min_level_4_downloads = c_ws_plugin__s2member_files::min_level_4_downloads ()) === false)
54
  {
55
  header ("HTTP/1.0 503 Service Temporarily Unavailable"); /* File downloads are NOT yet configured? */
56
- exit ("503: Sorry, file downloads are NOT enabled yet. Please contact Support for assistance. If you are the site owner, please configure `s2Member -> Download Options`.");
57
  }
58
  /**/
59
- else if ((!is_object ($user = apply_filters ("ws_plugin__s2member_check_file_download_access_user", ( (is_user_logged_in ()) ? wp_get_current_user () : false), get_defined_vars ())) || !$user->ID)/**/
60
- && wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "file-" . $_GET["s2member_file_download"], "s2member_level_req" => (string)$min_level_4_downloads)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ())) !== "nill")
61
- exit ();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  /**/
63
  else if ((!is_array ($file_downloads = c_ws_plugin__s2member_files::user_downloads ($user)) || !$file_downloads["allowed"] || !$file_downloads["allowed_days"])/**/
64
  && wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "file-" . $_GET["s2member_file_download"])), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ())) !== "nill")
@@ -80,10 +114,11 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
80
  exit ();
81
  }
82
  /**/
 
83
  $previous_file_downloads = 0; /* Here we're going to count how many downloads they've performed. */
84
- $max_days_logged = c_ws_plugin__s2member_files::max_download_period (); /* The longest period in days. */
85
- $file_download_access_log = (array)get_user_option ("s2member_file_download_access_log", $user->ID);
86
- $file_download_access_arc = (array)get_user_option ("s2member_file_download_access_arc", $user->ID);
87
  /**/
88
  foreach ($file_download_access_log as $file_download_access_log_entry_key => $file_download_access_log_entry)
89
  {
@@ -95,7 +130,6 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
95
  else if (strtotime ($file_download_access_log_entry["date"]) >= strtotime ("-" . $file_downloads["allowed_days"] . " days"))
96
  {
97
  $previous_file_downloads++;
98
- /* Here we check if this file has already been downloaded. */
99
  if ($file_download_access_log_entry["file"] === $_GET["s2member_file_download"])
100
  $already_downloaded = true;
101
  }
@@ -108,85 +142,126 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
108
  if (!$already_downloaded) /* Only add this file to the log if they have not already downloaded it. */
109
  $file_download_access_log[] = array ("date" => date ("Y-m-d"), "file" => $_GET["s2member_file_download"]);
110
  /**/
111
- update_user_option ($user->ID, "s2member_file_download_access_arc", c_ws_plugin__s2member_utils_arrays::array_unique ($file_download_access_arc));
112
- update_user_option ($user->ID, "s2member_file_download_access_log", c_ws_plugin__s2member_utils_arrays::array_unique ($file_download_access_log));
113
  }
114
  }
115
  else /* Otherwise... it's either $excluded; or permission was granted with a valid Download Key. */
116
  {
117
  $_GET["s2member_file_download"] = trim ($_GET["s2member_file_download"], "/");
118
  /**/
119
- if (!file_exists ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]))
120
  {
121
  header ("HTTP/1.0 404 Not Found"); /* The file does NOT even exist. */
122
  exit ("404: Sorry, file not found. Please contact Support for assistance.");
123
  }
124
  }
125
  /*
126
- Here we are going to put together all of the file download information.
127
  */
128
- $mimetypes = parse_ini_file (dirname (dirname (dirname (__FILE__))) . "/includes/mime-types.ini");
129
- $pathinfo = pathinfo ($file = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]);
130
- $extension = strtolower ($pathinfo["extension"]); /* Convert file extension to lowercase format for MIME type lookup. */
131
- $inline = ($_GET["s2member_file_inline"] || in_array ($extension, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_inline_extensions"]))) ? true : false;
132
- $mimetype = ($mimetypes[$extension]) ? $mimetypes[$extension] : "application/octet-stream"; /* Lookup MIME type. */
133
- $basename = $pathinfo["basename"]; /* The actual file name, including its extension. */
134
- $length = filesize ($file); /* The overall file size, in bytes. */
 
 
 
 
135
  /**/
136
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
137
  do_action ("ws_plugin__s2member_during_file_download_access", get_defined_vars ());
138
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
139
- /*
140
- Send the file to the browser in chunks ( in support of larger files ).
141
- Be sure to turn off output compression, as it DOES get in the way.
142
- */
143
- @set_time_limit (0); /* Unlimited. */
144
- @ini_set ("zlib.output_compression", 0);
145
- /**/
146
- header ("Accept-Ranges: none");
147
- header ("Content-Encoding: none");
148
- header ("Content-Type: " . $mimetype);
149
- header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
150
- header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
151
- header ("Cache-Control: no-cache, must-revalidate, max-age=0");
152
- header ("Cache-Control: post-check=0, pre-check=0", false);
153
- header ("Pragma: no-cache");
154
  /**/
155
- header ('Content-Disposition: ' . (($inline) ? "inline" : "attachment") . '; filename="' . $basename . '"');
156
- /**/
157
- if ($length && apply_filters ("ws_plugin__s2member_stream_file_downloads", true, get_defined_vars ()) && ($stream = fopen ($file, "rb")))
158
  {
159
- $_stream_w_content_length = (preg_match ("/^win/i", PHP_OS)) ? false : true; /* Windows® IIS does not jive here. */
160
- /* Windows® IIS doesn't seem to like it when both `Content-Length` and `Transfer-Encoding: chunked` are sent together. */
161
- if (apply_filters ("ws_plugin__s2member_stream_file_downloads_w_content_length", $_stream_w_content_length, get_defined_vars ()))
162
- header ("Content-Length: " . $length);
163
- /**/
164
- header ("Transfer-Encoding: chunked"); /* Uses `Transfer-Encoding: chunked` for simulated streaming. */
165
  /**/
166
- eval ('while (@ob_end_clean ());'); /* End/clean all output buffers that may or may not exist. */
 
 
167
  /**/
168
- while (!feof ($stream) && ($chunk_size = strlen ($data = fread ($stream, 2097152))))
169
- eval ('echo dechex ($chunk_size) . "\r\n". $data . "\r\n"; @flush ();');
170
  /**/
171
- fclose($stream);
172
  /**/
173
- exit ("0\r\n\r\n");
174
  }
175
- else if ($length) /* Else `file_get_contents()`. */
 
176
  {
177
- header ("Content-Length: " . $length);
 
 
 
 
 
 
 
 
 
 
 
 
178
  /**/
179
- exit (file_get_contents ($file));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  }
181
- else
182
- exit (); /* Empty file. */
183
  }
184
  /**/
185
  do_action ("ws_plugin__s2member_after_file_download_access", get_defined_vars ());
186
  }
187
- /*
188
- A sort of callback function that handles header authorization for File Downloads.
189
- Attach to: add_filter("ws_plugin__s2member_check_file_download_access_user");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  */
191
  public static function _file_remote_authorization ($user = FALSE)
192
  {
@@ -194,11 +269,11 @@ if (!class_exists ("c_ws_plugin__s2member_files_in"))
194
  do_action ("_ws_plugin__s2member_before_file_remote_authorization", get_defined_vars ());
195
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
196
  /**/
197
- if (!$user && $_GET["s2member_file_remote"]) /* Use remote header authorization? */
198
  {
199
  do_action ("_ws_plugin__s2member_during_file_remote_authorization_before", get_defined_vars ());
200
  /**/
201
- if (!$_SERVER["PHP_AUTH_USER"] || !$_SERVER["PHP_AUTH_PW"] || !user_pass_ok ($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"]))
202
  {
203
  header ('WWW-Authenticate: Basic realm="Members Only"');
204
  header ("HTTP/1.0 401 Unauthorized");
1
  <?php
2
+ /**
3
+ * File Download routines for s2Member ( inner processing routines ).
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Files
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_files_in"))
21
  {
22
+ /**
23
+ * File Download routines for s2Member ( inner processing routines ).
24
+ *
25
+ * @package s2Member\Files
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_files_in
29
  {
30
+ /**
31
+ * Handles Download Access permissions.
32
+ *
33
+ * @package s2Member\Files
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_action("init");``
37
+ *
38
+ * @return null Or exits script execution after serving a File Download.
39
  */
40
  public static function check_file_download_access ()
41
  {
42
  do_action ("ws_plugin__s2member_before_file_download_access", get_defined_vars ());
43
  /**/
44
+ if (!empty ($_GET["s2member_file_download"])) /* Is this a File Download request? */
45
  {
46
  $excluded = apply_filters ("ws_plugin__s2member_check_file_download_access_excluded", false, get_defined_vars ());
47
  /**/
48
+ if (!($using_amazon_s3_storage = 0) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"])
49
+ $using_amazon_s3_storage = true; /* Amazon® S3 storage has been configured! */
50
+ /**/
51
+ if (!$excluded && (empty ($_GET["s2member_file_download_key"]) || (!empty ($_GET["s2member_file_download_key"]) && !($file_download_key_is_valid = ($_GET["s2member_file_download_key"] === c_ws_plugin__s2member_files::file_download_key ($_GET["s2member_file_download"]) || $_GET["s2member_file_download_key"] === c_ws_plugin__s2member_files::file_download_key ($_GET["s2member_file_download"], "ip-forever") || $_GET["s2member_file_download_key"] === c_ws_plugin__s2member_files::file_download_key ($_GET["s2member_file_download"], "universal"))))))
52
  {
53
  $_GET["s2member_file_download"] = trim ($_GET["s2member_file_download"], "/"); /* Trim slashes after Key comparison. */
54
  /**/
55
+ if (!$using_amazon_s3_storage && !file_exists ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]))
56
  {
57
  header ("HTTP/1.0 404 Not Found"); /* The file does NOT even exist. */
58
  exit ("404: Sorry, file not found. Please contact Support for assistance.");
59
  }
60
+ /**/
61
+ else if (!empty ($_GET["s2member_file_download_key"]) && !$file_download_key_is_valid) /* Invalid Key? */
62
  {
63
  header ("HTTP/1.0 503 Service Temporarily Unavailable"); /* Invalid Download Keys are handled separately. */
64
  exit ("503 ( Invalid Key ): Sorry, your access to this file has expired. Please contact Support for assistance.");
65
  }
66
+ /**/
67
  else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Is a Membership Options Page configured? */
68
  /* This file will be processed WITHOUT a Download Key, using Membership Level Access ( w/ possible Custom Capabilities ). */
69
  {
73
  if (($file_download_access_is_allowed = $min_level_4_downloads = c_ws_plugin__s2member_files::min_level_4_downloads ()) === false)
74
  {
75
  header ("HTTP/1.0 503 Service Temporarily Unavailable"); /* File downloads are NOT yet configured? */
76
+ exit ("503: Sorry, File Downloads are NOT enabled yet. Please contact Support for assistance. If you are the site owner, please configure: `s2Member -> Download Options -> Basic Download Restrictions`.");
77
  }
78
  /**/
79
+ else if (!is_object ($user = apply_filters ("ws_plugin__s2member_check_file_download_access_user", ((is_user_logged_in ()) ? wp_get_current_user () : false), get_defined_vars ())) || !($user_id = $user->ID))
80
+ {
81
+ if (preg_match ("/^access[_\-]s2member[_\-]level([0-9]+)\//", $_GET["s2member_file_download"], $m))
82
+ {
83
+ $level_req = $m[1]; /* Which Level does this require? */
84
+ if (wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "file-" . $_GET["s2member_file_download"], "s2member_level_req" => $level_req)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ())) !== "nill")
85
+ exit ();
86
+ }
87
+ else if (preg_match ("/^access[_\-]s2member[_\-]ccap[_\-](.+?)\//", $_GET["s2member_file_download"], $m))
88
+ {
89
+ $ccap_req = preg_replace ("/-/", "_", $m[1]); /* Which Capability does this require? */
90
+ if (wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "file-" . $_GET["s2member_file_download"], "s2member_ccap_req" => $ccap_req)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ())) !== "nill")
91
+ exit ();
92
+ }
93
+ else if (wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "file-" . $_GET["s2member_file_download"], "s2member_level_req" => (string)$min_level_4_downloads)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ())) !== "nill")
94
+ exit ();
95
+ }
96
  /**/
97
  else if ((!is_array ($file_downloads = c_ws_plugin__s2member_files::user_downloads ($user)) || !$file_downloads["allowed"] || !$file_downloads["allowed_days"])/**/
98
  && wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "file-" . $_GET["s2member_file_download"])), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ())) !== "nill")
114
  exit ();
115
  }
116
  /**/
117
+ $already_downloaded = false; /* Initialize this to a false value. */
118
  $previous_file_downloads = 0; /* Here we're going to count how many downloads they've performed. */
119
+ $max_days_logged = c_ws_plugin__s2member_files::max_download_period (); /* Longest period/days. */
120
+ $file_download_access_log = (array)get_user_option ("s2member_file_download_access_log", $user_id);
121
+ $file_download_access_arc = (array)get_user_option ("s2member_file_download_access_arc", $user_id);
122
  /**/
123
  foreach ($file_download_access_log as $file_download_access_log_entry_key => $file_download_access_log_entry)
124
  {
130
  else if (strtotime ($file_download_access_log_entry["date"]) >= strtotime ("-" . $file_downloads["allowed_days"] . " days"))
131
  {
132
  $previous_file_downloads++;
 
133
  if ($file_download_access_log_entry["file"] === $_GET["s2member_file_download"])
134
  $already_downloaded = true;
135
  }
142
  if (!$already_downloaded) /* Only add this file to the log if they have not already downloaded it. */
143
  $file_download_access_log[] = array ("date" => date ("Y-m-d"), "file" => $_GET["s2member_file_download"]);
144
  /**/
145
+ update_user_option ($user_id, "s2member_file_download_access_arc", c_ws_plugin__s2member_utils_arrays::array_unique ($file_download_access_arc));
146
+ update_user_option ($user_id, "s2member_file_download_access_log", c_ws_plugin__s2member_utils_arrays::array_unique ($file_download_access_log));
147
  }
148
  }
149
  else /* Otherwise... it's either $excluded; or permission was granted with a valid Download Key. */
150
  {
151
  $_GET["s2member_file_download"] = trim ($_GET["s2member_file_download"], "/");
152
  /**/
153
+ if (!$using_amazon_s3_storage && !file_exists ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"]))
154
  {
155
  header ("HTTP/1.0 404 Not Found"); /* The file does NOT even exist. */
156
  exit ("404: Sorry, file not found. Please contact Support for assistance.");
157
  }
158
  }
159
  /*
160
+ Here we are going to put together all of the File Download information.
161
  */
162
+ $extension = strtolower (substr ($_GET["s2member_file_download"], strrpos ($_GET["s2member_file_download"], "."))); /* To lowercase. */
163
+ /**/
164
+ $mimetypes = parse_ini_file (dirname (dirname (dirname (__FILE__))) . "/includes/mime-types.ini"); /* Types provided by: `mime-types.ini`. */
165
+ $mimetype = ($mimetypes[$extension]) ? $mimetypes[$extension] : "application/octet-stream"; /* Lookup the MIME type for this file extension. */
166
+ /**/
167
+ $inline = (!empty ($_GET["s2member_file_inline"]) || in_array ($extension, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_inline_extensions"]))) ? true : false;
168
+ /**/
169
+ $basename = basename ($_GET["s2member_file_download"]); /* The actual name of this File Download ( i.e. the basename ); including its file extension too. */
170
+ /**/
171
+ $pathinfo = (!$using_amazon_s3_storage) ? pathinfo (($file = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"] . "/" . $_GET["s2member_file_download"])) : array ();
172
+ $length = (!$using_amazon_s3_storage && $file) ? filesize ($file) : -1; /* The overall file size, in bytes. */
173
  /**/
174
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
175
  do_action ("ws_plugin__s2member_during_file_download_access", get_defined_vars ());
176
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  /**/
178
+ if ($using_amazon_s3_storage) /* Using Amazon® S3 storage? In this case, we use an authenticated redirection to S3 storage. */
 
 
179
  {
180
+ $amazon_s3_file_expires = strtotime ("+" . apply_filters ("ws_plugin__s2member_amazon_s3_file_expires_time", "30 seconds", get_defined_vars ()));
 
 
 
 
 
181
  /**/
182
+ $amazon_s3_file = $amazon_s3_raw_file = "/" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"] . "/" . $_GET["s2member_file_download"];
183
+ $amazon_s3_file .= "?response-cache-control=" . urlencode (($amazon_s3_cache_control = "no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0")) . "&response-content-disposition=" . urlencode (($amazon_s3_content_disposition = (($inline) ? "inline" : "attachment") . '; filename="' . $basename . '"')) . "&response-content-type=" . urlencode (($amazon_s3_content_type = $mimetype)) . "&response-expires=" . urlencode (($amazon_s3_expires = gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT"));
184
+ $amazon_s3_raw_file .= "?response-cache-control=" . $amazon_s3_cache_control . "&response-content-disposition=" . $amazon_s3_content_disposition . "&response-content-type=" . $amazon_s3_content_type . "&response-expires=" . $amazon_s3_expires;
185
  /**/
186
+ $amazon_s3_url = "http://s3.amazonaws.com" . $amazon_s3_file . "&AWSAccessKeyId=" . urlencode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"]) . "&Expires=" . urlencode ($amazon_s3_file_expires) . "&Signature=" . urlencode (base64_encode (c_ws_plugin__s2member_files_in::amazon_s3_sign ("GET\n\n\n" . $amazon_s3_file_expires . "\n" . $amazon_s3_raw_file)));
 
187
  /**/
188
+ wp_redirect ($amazon_s3_url); /* 302 redirection, to Amazon® S3 storage location. */
189
  /**/
190
+ exit (); /* Clean exit. */
191
  }
192
+ /**/
193
+ else /* Else, using localized storage ( default ). */
194
  {
195
+ @set_time_limit (0); /* Unlimited. */
196
+ @ini_set ("zlib.output_compression", 0);
197
+ /**/
198
+ header ("Accept-Ranges: none");
199
+ header ("Content-Encoding: none");
200
+ header ("Content-Type: " . $mimetype);
201
+ header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT");
202
+ header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
203
+ header ("Cache-Control: no-cache, must-revalidate, max-age=0");
204
+ header ("Cache-Control: post-check=0, pre-check=0", false);
205
+ header ("Pragma: no-cache");
206
+ /**/
207
+ header ('Content-Disposition: ' . (($inline) ? "inline" : "attachment") . '; filename="' . $basename . '"');
208
  /**/
209
+ if ($length && apply_filters ("ws_plugin__s2member_stream_file_downloads", true, get_defined_vars ()) && ($stream = fopen ($file, "rb")))
210
+ {
211
+ $_stream_w_content_length = (preg_match ("/^win/i", PHP_OS)) ? false : true; /* Windows® IIS does not jive here. */
212
+ /* Windows® IIS doesn't seem to like it when both `Content-Length` and `Transfer-Encoding: chunked` are sent together. */
213
+ if (apply_filters ("ws_plugin__s2member_stream_file_downloads_w_content_length", $_stream_w_content_length, get_defined_vars ()))
214
+ header ("Content-Length: " . $length);
215
+ /**/
216
+ header ("Transfer-Encoding: chunked"); /* Uses `Transfer-Encoding: chunked` for simulated streaming. */
217
+ /**/
218
+ eval ('while (@ob_end_clean ());'); /* End/clean all output buffers that may or may not exist. */
219
+ /**/
220
+ while (!feof ($stream) && ($chunk_size = strlen ($data = fread ($stream, 2097152))))
221
+ eval ('echo dechex ($chunk_size) . "\r\n". $data . "\r\n"; @flush ();');
222
+ /**/
223
+ fclose ($stream);
224
+ /**/
225
+ exit ("0\r\n\r\n");
226
+ }
227
+ else if ($length) /* Else `file_get_contents()`. */
228
+ {
229
+ header ("Content-Length: " . $length);
230
+ /**/
231
+ exit (file_get_contents ($file));
232
+ }
233
+ else
234
+ exit (); /* Empty file. */
235
  }
 
 
236
  }
237
  /**/
238
  do_action ("ws_plugin__s2member_after_file_download_access", get_defined_vars ());
239
  }
240
+ /**
241
+ * Creates an Amazon® S3 HMAC-SHA1 signature.
242
+ *
243
+ * @package s2Member\Files
244
+ * @since 110524RC
245
+ *
246
+ * @param str $data Input data, to be signed by this routine.
247
+ * @return str An HMAC-SHA1 signature for Amazon® S3.
248
+ */
249
+ public static function amazon_s3_sign ($data = FALSE)
250
+ {
251
+ $key = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"];
252
+ $key = str_pad (((strlen ($key) > 64) ? pack ('H*', sha1 ($key)) : $key), 64, chr (0x00));
253
+ return pack ('H*', sha1 (($key ^ str_repeat (chr (0x5c), 64)) . pack ('H*', sha1 (($key ^ str_repeat (chr (0x36), 64)) . $data))));
254
+ }
255
+ /**
256
+ * A sort of callback function that handles Header Authorization for File Downloads.
257
+ *
258
+ * @package s2Member\Files
259
+ * @since 3.5
260
+ *
261
+ * @attaches-to: ``add_filter("ws_plugin__s2member_check_file_download_access_user");``
262
+ *
263
+ * @param obj $user Expects a WP_User object passed in by the Filter.
264
+ * @return obj A WP_User object, possibly obtained through Header Authorization.
265
  */
266
  public static function _file_remote_authorization ($user = FALSE)
267
  {
269
  do_action ("_ws_plugin__s2member_before_file_remote_authorization", get_defined_vars ());
270
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
271
  /**/
272
+ if (!is_object ($user) && !empty ($_GET["s2member_file_remote"])) /* Use Header Authorization? */
273
  {
274
  do_action ("_ws_plugin__s2member_during_file_remote_authorization_before", get_defined_vars ());
275
  /**/
276
+ if (empty ($_SERVER["PHP_AUTH_USER"]) || empty ($_SERVER["PHP_AUTH_PW"]) || !user_pass_ok ($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"]))
277
  {
278
  header ('WWW-Authenticate: Basic realm="Members Only"');
279
  header ("HTTP/1.0 401 Unauthorized");
includes/classes/files.inc.php CHANGED
@@ -1,150 +1,179 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_files"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_files
20
  {
21
- /*
22
- Function creates a special File Download Key.
23
- Uses: date("Y-m-d") . $_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"] . $file.
24
-
25
- The optional second argument can be passed in for compatiblity with Quick Cache / WP Super Cache.
26
- When $cache_compatible is passed in, the salt is reduced to only the $file value.
27
- - which is NOT as secure. So use that with caution.
 
 
28
  */
29
- public static function file_download_key ($file = FALSE, $universal = FALSE)
30
  {
31
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
32
- do_action ("ws_plugin__s2member_before_file_download_key", get_defined_vars ());
33
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
34
- /**/
35
- $salt = ($universal) ? $file /* ( cache compatible / universally available ) */
36
- : date ("Y-m-d") . $_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"] . $file;
37
- /**/
38
- $key = md5 (c_ws_plugin__s2member_utils_encryption::xencrypt ($salt));
39
- /**/
40
- if (!$universal) /* Disallow caching. */
41
- c_ws_plugin__s2member_nocache::nocache_constants (true);
42
- /**/
43
- return apply_filters ("ws_plugin__s2member_file_download_key", $key, get_defined_vars ());
44
  }
45
- /*
46
- Function determines the max period in days for download access.
47
- Returns number of days, where 0 means no access to files has been allowed.
 
 
 
 
 
 
 
48
  */
49
  public static function max_download_period ()
50
  {
51
  do_action ("ws_plugin__s2member_before_max_download_period", get_defined_vars ());
52
  /**/
53
- $max = 0; /* This initializes the default value for $max file download allowed days. */
54
- /**/
55
- if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"])
56
- $max = ($max < $days) ? $days : $max;
 
57
  /**/
58
- if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"])
59
- $max = ($max < $days) ? $days : $max;
60
- /**/
61
- if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"])
62
- $max = ($max < $days) ? $days : $max;
63
- /**/
64
- if ($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"])
65
- $max = ($max < $days) ? $days : $max;
66
- /**/
67
- return apply_filters ("ws_plugin__s2member_max_download_period", ( ($max > 365) ? 365 : (int)$max), get_defined_vars ());
68
  }
69
- /*
70
- Function determines the minimum level required for file download access.
71
- Test === false to see if no access is allowed.
72
- This returns false, or (int)[0-1].
 
 
 
73
  */
74
  public static function min_level_4_downloads ()
75
  {
76
  do_action ("ws_plugin__s2member_before_min_level_4_downloads", get_defined_vars ());
77
  /**/
78
- $file_download_access_is_allowed = $min_level_4_downloads = false; /* Test with === false, which means no access is allowed at all. */
79
- /**/
80
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed_days"])
81
- $file_download_access_is_allowed = $min_level_4_downloads = 0;
82
- /**/
83
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"])
84
- $file_download_access_is_allowed = $min_level_4_downloads = 1;
85
- /**/
86
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"])
87
- $file_download_access_is_allowed = $min_level_4_downloads = 2;
88
- /**/
89
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"])
90
- $file_download_access_is_allowed = $min_level_4_downloads = 3;
91
  /**/
92
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"])
93
- $file_download_access_is_allowed = $min_level_4_downloads = 4;
94
- /**/
95
- return apply_filters ("ws_plugin__s2member_min_level_4_downloads", ($file_download_access_is_allowed = $min_level_4_downloads), get_defined_vars ());
96
  }
97
- /*
98
- Function determines how many downloads allowed - etc, etc.
99
- Returns an array with 3 elements: allowed, allowed_days, currently.
100
- The 2nd parameter can be used to prevent another database connection.
 
 
 
 
 
 
101
  */
102
- public static function user_downloads ($current_user = FALSE, $not_counting_this_particular_file = FALSE, $log = NULL)
103
  {
104
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
105
  do_action ("ws_plugin__s2member_before_user_downloads", get_defined_vars ());
106
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
107
  /**/
108
- if ($current_user || ($current_user = (is_user_logged_in ()) ? wp_get_current_user () : false))
 
 
109
  {
110
- if ($current_user->has_cap ("access_s2member_level0") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed"])
111
- {
112
- $allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed"];
113
- $allowed_days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_file_downloads_allowed_days"];
114
- }
115
- /**/
116
- if ($current_user->has_cap ("access_s2member_level1") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed"])
117
- {
118
- $allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed"];
119
- $allowed_days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_file_downloads_allowed_days"];
120
- }
121
- /**/
122
- if ($current_user->has_cap ("access_s2member_level2") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed"])
123
  {
124
- $allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed"];
125
- $allowed_days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level2_file_downloads_allowed_days"];
 
 
 
 
 
 
 
 
126
  }
127
  /**/
128
- if ($current_user->has_cap ("access_s2member_level3") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed"])
129
- {
130
- $allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed"];
131
- $allowed_days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level3_file_downloads_allowed_days"];
132
- }
133
- /**/
134
- if ($current_user->has_cap ("access_s2member_level4") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed"])
135
- {
136
- $allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed"];
137
- $allowed_days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level4_file_downloads_allowed_days"];
138
- }
139
- /**/
140
- $file_download_access_log = (isset ($log)) ? (array)$log : (array)get_user_option ("s2member_file_download_access_log", $current_user->ID);
141
  foreach ($file_download_access_log as $file_download_access_log_entry_key => $file_download_access_log_entry)
142
- if (strtotime ($file_download_access_log_entry["date"]) >= strtotime ("-" . (int)$allowed_days . " days"))
143
  if ($file_download_access_log_entry["file"] !== $not_counting_this_particular_file)
144
- $currently = ($currently) ? $currently + 1 : 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  }
 
 
 
 
 
 
 
 
 
 
146
  /**/
147
- return apply_filters ("ws_plugin__s2member_user_downloads", array ("allowed" => (int)$allowed, "allowed_days" => (int)$allowed_days, "currently" => (int)$currently), get_defined_vars ());
148
  }
149
  }
150
  }
1
  <?php
2
+ /**
3
+ * File Download routines for s2Member.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Files
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_files"))
21
  {
22
+ /**
23
+ * File Download routines for s2Member.
24
+ *
25
+ * @package s2Member\Files
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_files
29
  {
30
+ /**
31
+ * Handles Download Access permissions.
32
+ *
33
+ * @package s2Member\Files
34
+ * @since 110524RC
35
+ *
36
+ * @attaches-to: ``add_action("init");``
37
+ *
38
+ * @return null|inner Return-value of inner routine.
39
  */
40
+ public static function check_file_download_access ()
41
  {
42
+ if (!empty ($_GET["s2member_file_download"])) /* Call inner routine? */
43
+ {
44
+ return c_ws_plugin__s2member_files_in::check_file_download_access ();
45
+ }
 
 
 
 
 
 
 
 
 
46
  }
47
+ /**
48
+ * Determines the max period ( in days ), for Download Access.
49
+ *
50
+ * @package s2Member\Files
51
+ * @since 3.5
52
+ *
53
+ * @return int Number of days, where 0 means no access to files is allowed.
54
+ * Will not return a value > `365`, because this routine also controls the age of download logs to archives.
55
+ *
56
+ * @todo Remove the limitation of `365` days somehow.
57
  */
58
  public static function max_download_period ()
59
  {
60
  do_action ("ws_plugin__s2member_before_max_download_period", get_defined_vars ());
61
  /**/
62
+ for ($n = 0, $max = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
63
+ if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_file_downloads_allowed"]))
64
+ if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_file_downloads_allowed_days"]))
65
+ if (($days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_file_downloads_allowed_days"]))
66
+ $max = ($max < $days) ? $days : $max;
67
  /**/
68
+ return apply_filters ("ws_plugin__s2member_max_download_period", (($max > 365) ? 365 : $max), get_defined_vars ());
 
 
 
 
 
 
 
 
 
69
  }
70
+ /**
71
+ * Determines the minimum Level required for File Download Access.
72
+ *
73
+ * @package s2Member\Files
74
+ * @since 3.5
75
+ *
76
+ * @return bool|int False if no access is allowed, else Level number (int) 0+.
77
  */
78
  public static function min_level_4_downloads ()
79
  {
80
  do_action ("ws_plugin__s2member_before_min_level_4_downloads", get_defined_vars ());
81
  /**/
82
+ for ($n = 0, $min = false; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
83
+ if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_file_downloads_allowed"]))
84
+ if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_file_downloads_allowed_days"]))
85
+ if (($min = $n) >= 0)
86
+ break;
 
 
 
 
 
 
 
 
87
  /**/
88
+ return apply_filters ("ws_plugin__s2member_min_level_4_downloads", ((is_int ($min)) ? $min : false), get_defined_vars ());
 
 
 
89
  }
90
+ /**
91
+ * Determines how many File Downloads are allowed, also provides some extended details.
92
+ *
93
+ * @package s2Member\Files
94
+ * @since 3.5
95
+ *
96
+ * @param obj $user Optional. Defaults to the current User's object.
97
+ * @param str $not_counting_this_particular_file Optional. If you want to exclude a particular file.
98
+ * @param array $log Optional. Prevents another database connection *( i.e. the log does not need to be pulled again )*.
99
+ * @return array An array with three elements: `allowed`, `allowed_days`, `currently`.
100
  */
101
+ public static function user_downloads ($user = FALSE, $not_counting_this_particular_file = FALSE, $log = NULL)
102
  {
103
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
104
  do_action ("ws_plugin__s2member_before_user_downloads", get_defined_vars ());
105
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
106
  /**/
107
+ $allowed = $allowed_days = $currently = 0; /* Initialize all of these to zero. */
108
+ /**/
109
+ if ((is_object ($user) || is_object ($user = (is_user_logged_in ()) ? wp_get_current_user () : false)) && ($user_id = $user->ID))
110
  {
111
+ for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++)
 
 
 
 
 
 
 
 
 
 
 
 
112
  {
113
+ if ($user->has_cap ("s2member_level" . $n)) /* In other words, is this their Role? */
114
+ {
115
+ if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_file_downloads_allowed"]))
116
+ if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_file_downloads_allowed_days"]))
117
+ {
118
+ $allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_file_downloads_allowed"];
119
+ $allowed_days = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_file_downloads_allowed_days"];
120
+ }
121
+ break; /* Break now, no need to continue searching. */
122
+ }
123
  }
124
  /**/
125
+ $file_download_access_log = (isset ($log)) ? (array)$log : (array)get_user_option ("s2member_file_download_access_log", $user_id);
 
 
 
 
 
 
 
 
 
 
 
 
126
  foreach ($file_download_access_log as $file_download_access_log_entry_key => $file_download_access_log_entry)
127
+ if (strtotime ($file_download_access_log_entry["date"]) >= strtotime ("-" . $allowed_days . " days"))
128
  if ($file_download_access_log_entry["file"] !== $not_counting_this_particular_file)
129
+ $currently = $currently + 1;
130
+ }
131
+ /**/
132
+ return apply_filters ("ws_plugin__s2member_user_downloads", array ("allowed" => $allowed, "allowed_days" => $allowed_days, "currently" => $currently), get_defined_vars ());
133
+ }
134
+ /**
135
+ * Creates a File Download Key.
136
+ *
137
+ * Builds a hash of: ``date("Y-m-d") . $_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"] . $file``.
138
+ *
139
+ * @package s2Member\Files
140
+ * @since 3.5
141
+ *
142
+ * @param str $file Location of your protected file, relative to the `/s2member-files/` directory.
143
+ * In other words, just the name of the file *(i.e. `file.zip` )*.
144
+ * @param str $directive Optional. One of `ip-forever|universal|cache-compatible`.
145
+ * `ip-forever` = a Download Key that never expires, tied only to a specific file and IP address.
146
+ * `universal` and/or `cache-compatible` = a Download Key which never expires, and is NOT tied to any specific User. Use at your own risk.
147
+ * @return str A Download Key. MD5 hash, 32 characters, URL-safe.
148
+ */
149
+ public static function file_download_key ($file = FALSE, $directive = FALSE)
150
+ {
151
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
152
+ do_action ("ws_plugin__s2member_before_file_download_key", get_defined_vars ());
153
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
154
+ /**/
155
+ if ($directive === "ip-forever")
156
+ {
157
+ $allow_caching = false;
158
+ $salt = $file . $_SERVER["REMOTE_ADDR"];
159
+ }
160
+ else if ($directive === "universal" || $directive === "cache-compatible" || !empty ($directive))
161
+ {
162
+ $allow_caching = true;
163
+ $salt = $file;
164
  }
165
+ else /* Otherwise, we use the default ``$salt``. */
166
+ {
167
+ $allow_caching = false;
168
+ $salt = date ("Y-m-d") . $_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"] . $file;
169
+ }
170
+ /**/
171
+ $key = md5 (c_ws_plugin__s2member_utils_encryption::xencrypt ($salt));
172
+ /**/
173
+ if ($allow_caching === false) /* Disallow caching? */
174
+ c_ws_plugin__s2member_no_cache::no_cache_constants (true);
175
  /**/
176
+ return apply_filters ("ws_plugin__s2member_file_download_key", $key, get_defined_vars ());
177
  }
178
  }
179
  }
includes/classes/installation.inc.php CHANGED
@@ -1,118 +1,48 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_installation"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_installation
20
  {
21
- /*
22
- Handles activation routines.
 
 
 
 
 
23
  */
24
  public static function activate ()
25
  {
26
- global $wpdb; /* To update points of origin on a Multisite Network. */
27
- global $current_site, $current_blog; /* For Multisite support. */
28
  /**/
29
  do_action ("ws_plugin__s2member_before_activation", get_defined_vars ());
30
  /**/
31
- add_role ("subscriber", "Subscriber");
32
- add_role ("s2member_level1", "s2Member Level 1");
33
- add_role ("s2member_level2", "s2Member Level 2");
34
- add_role ("s2member_level3", "s2Member Level 3");
35
- add_role ("s2member_level4", "s2Member Level 4");
36
- /**/
37
- if ($role = &get_role ("subscriber"))
38
- {
39
- $role->add_cap ("read");
40
- $role->add_cap ("access_s2member_level0");
41
- }
42
- /**/
43
- if ($role = &get_role ("s2member_level1"))
44
- {
45
- $role->add_cap ("read");
46
- $role->add_cap ("level_0");
47
- $role->add_cap ("access_s2member_level0");
48
- $role->add_cap ("access_s2member_level1");
49
- }
50
- /**/
51
- if ($role = &get_role ("s2member_level2"))
52
- {
53
- $role->add_cap ("read");
54
- $role->add_cap ("level_0");
55
- $role->add_cap ("access_s2member_level0");
56
- $role->add_cap ("access_s2member_level1");
57
- $role->add_cap ("access_s2member_level2");
58
- }
59
- /**/
60
- if ($role = &get_role ("s2member_level3"))
61
- {
62
- $role->add_cap ("read");
63
- $role->add_cap ("level_0");
64
- $role->add_cap ("access_s2member_level0");
65
- $role->add_cap ("access_s2member_level1");
66
- $role->add_cap ("access_s2member_level2");
67
- $role->add_cap ("access_s2member_level3");
68
- }
69
- /**/
70
- if ($role = &get_role ("s2member_level4"))
71
- {
72
- $role->add_cap ("read");
73
- $role->add_cap ("level_0");
74
- $role->add_cap ("access_s2member_level0");
75
- $role->add_cap ("access_s2member_level1");
76
- $role->add_cap ("access_s2member_level2");
77
- $role->add_cap ("access_s2member_level3");
78
- $role->add_cap ("access_s2member_level4");
79
- }
80
- /**/
81
- if ($role = &get_role ("administrator"))
82
- {
83
- $role->add_cap ("access_s2member_level0");
84
- $role->add_cap ("access_s2member_level1");
85
- $role->add_cap ("access_s2member_level2");
86
- $role->add_cap ("access_s2member_level3");
87
- $role->add_cap ("access_s2member_level4");
88
- }
89
- /**/
90
- if ($role = &get_role ("editor"))
91
- {
92
- $role->add_cap ("access_s2member_level0");
93
- $role->add_cap ("access_s2member_level1");
94
- $role->add_cap ("access_s2member_level2");
95
- $role->add_cap ("access_s2member_level3");
96
- $role->add_cap ("access_s2member_level4");
97
- }
98
- /**/
99
- if ($role = &get_role ("author"))
100
- {
101
- $role->add_cap ("access_s2member_level0");
102
- $role->add_cap ("access_s2member_level1");
103
- $role->add_cap ("access_s2member_level2");
104
- $role->add_cap ("access_s2member_level3");
105
- $role->add_cap ("access_s2member_level4");
106
- }
107
- /**/
108
- if ($role = &get_role ("contributor"))
109
- {
110
- $role->add_cap ("access_s2member_level0");
111
- $role->add_cap ("access_s2member_level1");
112
- $role->add_cap ("access_s2member_level2");
113
- $role->add_cap ("access_s2member_level3");
114
- $role->add_cap ("access_s2member_level4");
115
- }
116
  /**/
117
  if (!is_dir ($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]))
118
  if (is_writable (dirname (c_ws_plugin__s2member_utils_dirs::strip_dir_app_data ($files_dir))))
@@ -171,12 +101,12 @@ if (!class_exists ("c_ws_plugin__s2member_installation"))
171
  if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()) /* No Changelog on a Multisite Farm. */
172
  $notice .= '<br />Have fun, <a href="' . esc_attr (admin_url ("/admin.php?page=ws-plugin--s2member-info#rm-changelog")) . '">read the Changelog</a>, and make some money! :-)';
173
  /**/
174
- c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, array ("blog|network:plugins.php", "blog|network:ws-plugin--s2member-options"));
175
  /**/
176
  if (preg_match ("/^win/i", PHP_OS) && is_dir (c_ws_plugin__s2member_utils_dirs::strip_dir_app_data ($files_dir)) && count (scandir (c_ws_plugin__s2member_utils_dirs::strip_dir_app_data ($files_dir))) > 4)
177
  {
178
  $notice = '<strong>Windows® Server ( NOTICE ):</strong> Your protected files MUST be moved to the <code>/app_data</code> sub-directory. For further details, see: <code>s2Member -> Download Options -> Basic</code>.';
179
- c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, array ("blog|network:plugins.php", "blog|network:ws-plugin--s2member-options"), true);
180
  }
181
  }
182
  else /* Otherwise, (initial activation); we'll help the Site Owner out by giving them a link to the Quick Start Guide. */
@@ -188,18 +118,18 @@ if (!class_exists ("c_ws_plugin__s2member_installation"))
188
  $notice = '<strong>s2Member</strong> v' . esc_html (WS_PLUGIN__S2MEMBER_VERSION) . ' has been <strong>activated</strong>. Nice work!<br />';
189
  $notice .= 'Have fun, <a href="' . esc_attr (admin_url ("/admin.php?page=ws-plugin--s2member-start")) . '">read the Quick Start Guide</a>, and make some money! :-)';
190
  /**/
191
- c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, array ("blog|network:plugins.php", "blog|network:ws-plugin--s2member-options"));
192
  }
193
  /**/
194
  update_option ("ws_plugin__s2member_activated_version", WS_PLUGIN__S2MEMBER_VERSION); /* Mark version. */
195
  /**/
196
  if (is_multisite () && is_main_site ()) /* Network activation routines. A few quick adjustments. */
197
  {
198
- foreach ((array) ($users = $wpdb->get_results ("SELECT `ID` FROM `" . $wpdb->users . "`")) as $user)
199
  {
200
  /* Here we convert everyone already in the system; without a point of origin.
201
- This will set their point of origin to the Main Site ( Dashboard Blog ). */
202
- if (! ($originating_blog = get_user_meta ($user->ID, "s2member_originating_blog", true)))
203
  update_user_meta ($user->ID, "s2member_originating_blog", $current_site->blog_id);
204
  }
205
  /**/
@@ -208,7 +138,7 @@ if (!class_exists ("c_ws_plugin__s2member_installation"))
208
  $notice .= 'In the Dashboard for your Main Site, see:<br />';
209
  $notice .= '<code>s2Member -> Multisite ( Config )</code>.';
210
  /**/
211
- c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, array ("blog|network:plugins.php", "blog|network:ws-plugin--s2member-options"));
212
  /**/
213
  update_option ("ws_plugin__s2member_activated_mms_version", WS_PLUGIN__S2MEMBER_VERSION);
214
  }
@@ -217,63 +147,24 @@ if (!class_exists ("c_ws_plugin__s2member_installation"))
217
  /**/
218
  return; /* Return for uniformity. */
219
  }
220
- /*
221
- Handles de-activation / cleanup routines.
 
 
 
 
 
222
  */
223
  public static function deactivate ()
224
  {
225
- global $wpdb; /* May need this for database cleaning. */
226
- global $current_site, $current_blog; /* For Multisite support. */
227
  /**/
228
  do_action ("ws_plugin__s2member_before_deactivation", get_defined_vars ());
229
  /**/
230
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["run_deactivation_routines"])
231
  {
232
- remove_role ("s2member_level1");
233
- remove_role ("s2member_level2");
234
- remove_role ("s2member_level3");
235
- remove_role ("s2member_level4");
236
- /**/
237
- if ($role = &get_role ("subscriber"))
238
- {
239
- $role->remove_cap ("access_s2member_level0");
240
- }
241
- /**/
242
- if ($role = &get_role ("administrator"))
243
- {
244
- $role->remove_cap ("access_s2member_level0");
245
- $role->remove_cap ("access_s2member_level1");
246
- $role->remove_cap ("access_s2member_level2");
247
- $role->remove_cap ("access_s2member_level3");
248
- $role->remove_cap ("access_s2member_level4");
249
- }
250
- /**/
251
- if ($role = &get_role ("editor"))
252
- {
253
- $role->remove_cap ("access_s2member_level0");
254
- $role->remove_cap ("access_s2member_level1");
255
- $role->remove_cap ("access_s2member_level2");
256
- $role->remove_cap ("access_s2member_level3");
257
- $role->remove_cap ("access_s2member_level4");
258
- }
259
- /**/
260
- if ($role = &get_role ("author"))
261
- {
262
- $role->remove_cap ("access_s2member_level0");
263
- $role->remove_cap ("access_s2member_level1");
264
- $role->remove_cap ("access_s2member_level2");
265
- $role->remove_cap ("access_s2member_level3");
266
- $role->remove_cap ("access_s2member_level4");
267
- }
268
- /**/
269
- if ($role = &get_role ("contributor"))
270
- {
271
- $role->remove_cap ("access_s2member_level0");
272
- $role->remove_cap ("access_s2member_level1");
273
- $role->remove_cap ("access_s2member_level2");
274
- $role->remove_cap ("access_s2member_level3");
275
- $role->remove_cap ("access_s2member_level4");
276
- }
277
  /**/
278
  if (is_dir ($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]))
279
  {
@@ -294,12 +185,12 @@ if (!class_exists ("c_ws_plugin__s2member_installation"))
294
  @rmdir($logs_dir) . @rmdir (c_ws_plugin__s2member_utils_dirs::strip_dir_app_data ($logs_dir));
295
  }
296
  /**/
297
- delete_option ("ws_plugin__s2member_cache");
298
- delete_option ("ws_plugin__s2member_notices");
299
- delete_option ("ws_plugin__s2member_options");
300
- delete_option ("ws_plugin__s2member_configured");
301
- delete_option ("ws_plugin__s2member_activated_version");
302
- delete_option ("ws_plugin__s2member_activated_mms_version");
303
  /**/
304
  $wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '%" . esc_sql (like_escape ("s2member_")) . "%'");
305
  $wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '" . esc_sql (like_escape ("_transient_s2m_")) . "%'");
1
  <?php
2
+ /**
3
+ * Installation routines for s2Member.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Installation
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_installation"))
21
  {
22
+ /**
23
+ * Installation routines for s2Member.
24
+ *
25
+ * @package s2Member\Installation
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_installation
29
  {
30
+ /**
31
+ * Activation routines for s2Member.
32
+ *
33
+ * @package s2Member\Installation
34
+ * @since 3.5
35
+ *
36
+ * @return null
37
  */
38
  public static function activate ()
39
  {
40
+ global $wpdb; /* Global database object reference. */
41
+ global $current_site, $current_blog; /* Multisite. */
42
  /**/
43
  do_action ("ws_plugin__s2member_before_activation", get_defined_vars ());
44
  /**/
45
+ c_ws_plugin__s2member_roles_caps::config_roles (); /* Config Roles/Caps. */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  /**/
47
  if (!is_dir ($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]))
48
  if (is_writable (dirname (c_ws_plugin__s2member_utils_dirs::strip_dir_app_data ($files_dir))))
101
  if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()) /* No Changelog on a Multisite Farm. */
102
  $notice .= '<br />Have fun, <a href="' . esc_attr (admin_url ("/admin.php?page=ws-plugin--s2member-info#rm-changelog")) . '">read the Changelog</a>, and make some money! :-)';
103
  /**/
104
+ c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, array ("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
105
  /**/
106
  if (preg_match ("/^win/i", PHP_OS) && is_dir (c_ws_plugin__s2member_utils_dirs::strip_dir_app_data ($files_dir)) && count (scandir (c_ws_plugin__s2member_utils_dirs::strip_dir_app_data ($files_dir))) > 4)
107
  {
108
  $notice = '<strong>Windows® Server ( NOTICE ):</strong> Your protected files MUST be moved to the <code>/app_data</code> sub-directory. For further details, see: <code>s2Member -> Download Options -> Basic</code>.';
109
+ c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, array ("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"), true);
110
  }
111
  }
112
  else /* Otherwise, (initial activation); we'll help the Site Owner out by giving them a link to the Quick Start Guide. */
118
  $notice = '<strong>s2Member</strong> v' . esc_html (WS_PLUGIN__S2MEMBER_VERSION) . ' has been <strong>activated</strong>. Nice work!<br />';
119
  $notice .= 'Have fun, <a href="' . esc_attr (admin_url ("/admin.php?page=ws-plugin--s2member-start")) . '">read the Quick Start Guide</a>, and make some money! :-)';
120
  /**/
121
+ c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, array ("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
122
  }
123
  /**/
124
  update_option ("ws_plugin__s2member_activated_version", WS_PLUGIN__S2MEMBER_VERSION); /* Mark version. */
125
  /**/
126
  if (is_multisite () && is_main_site ()) /* Network activation routines. A few quick adjustments. */
127
  {
128
+ foreach ((array)($users = $wpdb->get_results ("SELECT `ID` FROM `" . $wpdb->users . "`")) as $user)
129
  {
130
  /* Here we convert everyone already in the system; without a point of origin.
131
+ This will set their point of origin to the Main Site. */
132
+ if (!($originating_blog = get_user_meta ($user->ID, "s2member_originating_blog", true)))
133
  update_user_meta ($user->ID, "s2member_originating_blog", $current_site->blog_id);
134
  }
135
  /**/
138
  $notice .= 'In the Dashboard for your Main Site, see:<br />';
139
  $notice .= '<code>s2Member -> Multisite ( Config )</code>.';
140
  /**/
141
+ c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, array ("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
142
  /**/
143
  update_option ("ws_plugin__s2member_activated_mms_version", WS_PLUGIN__S2MEMBER_VERSION);
144
  }
147
  /**/
148
  return; /* Return for uniformity. */
149
  }
150
+ /**
151
+ * Deactivation routines for s2Member.
152
+ *
153
+ * @package s2Member\Installation
154
+ * @since 3.5
155
+ *
156
+ * @return null
157
  */
158
  public static function deactivate ()
159
  {
160
+ global $wpdb; /* Global database object reference. */
161
+ global $current_site, $current_blog; /* Multisite. */
162
  /**/
163
  do_action ("ws_plugin__s2member_before_deactivation", get_defined_vars ());
164
  /**/
165
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["run_deactivation_routines"])
166
  {
167
+ c_ws_plugin__s2member_roles_caps::unlink_roles (); /* Unlink Roles/Caps. */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  /**/
169
  if (is_dir ($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"]))
170
  {
185
  @rmdir($logs_dir) . @rmdir (c_ws_plugin__s2member_utils_dirs::strip_dir_app_data ($logs_dir));
186
  }
187
  /**/
188
+ delete_option("ws_plugin__s2member_cache");
189
+ delete_option("ws_plugin__s2member_notices");
190
+ delete_option("ws_plugin__s2member_options");
191
+ delete_option("ws_plugin__s2member_configured");
192
+ delete_option("ws_plugin__s2member_activated_version");
193
+ delete_option("ws_plugin__s2member_activated_mms_version");
194
  /**/
195
  $wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '%" . esc_sql (like_escape ("s2member_")) . "%'");
196
  $wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '" . esc_sql (like_escape ("_transient_s2m_")) . "%'");
includes/classes/ip-restrictions.inc.php CHANGED
@@ -1,98 +1,120 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_ip_restrictions"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_ip_restrictions
20
  {
21
- /*
22
- Function for handling IP Restrictions.
23
- IP address details are stored in Transient fields.
 
 
 
 
 
 
 
 
24
  */
25
  public static function ip_restrictions_ok ($ip = FALSE, $restriction = FALSE)
26
  {
27
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
28
  do_action ("ws_plugin__s2member_before_ip_restrictions_ok", get_defined_vars ());
29
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
30
  /**/
31
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] && $restriction)
32
- {
33
- $prefix = "s2m_ipr_"; /* s2Member Transient prefix for all IP Restrictions. */
34
- $transient_entries = $prefix . md5 ("s2member_ip_restrictions_" . $restriction . "_entries");
35
- $transient_security_breach = $prefix . md5 ("s2member_ip_restrictions_" . $restriction . "_security_breach");
36
- /**/
37
- /* If you add Filters, use a string compatible with PHP's strtotime() function. */
38
- $conc_filter = "ws_plugin__s2member_ip_restrictions__concurrency_time_per_ip";
39
- $concurrency = apply_filters ($conc_filter, "30 days");
40
- /**/
41
- $entries = (is_array ($entries = get_transient ($transient_entries))) ? $entries : array ();
42
- /**/
43
- foreach ($entries as $_entry => $_time) /* Auto-expire entries. */
44
- if ($_time < strtotime ("-" . $concurrency))
45
- unset ($entries[$_entry]);
46
- /**/
47
- $ip = ($ip) ? $ip : "empty"; /* Allow empty IPs. */
48
- $entries[$ip] = strtotime ("now"); /* Log this entry. */
49
- set_transient ($transient_entries, $entries, 2 * (strtotime ("+" . $concurrency) - strtotime ("now")));
50
- /**/
51
- if (get_transient ($transient_security_breach)) /* Has this restriction already been breached? */
52
- {
53
- c_ws_plugin__s2member_nocache::nocache_constants (true) . wp_clear_auth_cookie ();
54
- /**/
55
- do_action ("ws_plugin__s2member_during_ip_restrictions_ok_no", get_defined_vars ());
56
- /**/
57
- header ("HTTP/1.0 503 Service Temporarily Unavailable"); /* Sends a status header. */
58
- /**/
59
- echo '<strong>503: Service Temporarily Unavailable</strong><br />' . "\n";
60
- echo 'Too many IP addresses accessing one secure area<em>!</em><br />' . "\n";
61
- echo 'Please contact Support if you require assistance.';
62
- /**/
63
- exit ();
64
- }
65
- else if (count ($entries) > $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"])
66
- {
67
- c_ws_plugin__s2member_nocache::nocache_constants (true) . wp_clear_auth_cookie ();
68
- /**/
69
- set_transient ($transient_security_breach, 1, /* Lock down. */
70
- $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"]);
71
- /**/
72
- do_action ("ws_plugin__s2member_during_ip_restrictions_ok_no", get_defined_vars ());
73
- /**/
74
- header ("HTTP/1.0 503 Service Temporarily Unavailable"); /* Sends a status header. */
75
- /**/
76
- echo '<strong>503: Service Temporarily Unavailable</strong><br />' . "\n";
77
- echo 'Too many IP addresses accessing one secure area<em>!</em><br />' . "\n";
78
- echo 'Please contact Support if you require assistance.';
79
- /**/
80
- exit ();
81
- }
82
- else /* OK, this looks legitimate. Apply Filters here and return true. */
83
- {
84
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
85
- do_action ("ws_plugin__s2member_during_ip_restrictions_ok_yes", get_defined_vars ());
86
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
87
- /**/
88
- return apply_filters ("ws_plugin__s2member_ip_restrictions_ok", true, get_defined_vars ());
89
- }
90
- }
91
  /**/
92
  return apply_filters ("ws_plugin__s2member_ip_restrictions_ok", true, get_defined_vars ());
93
  }
94
- /*
95
- This queries Transients for specific IP Restrictions that have resulted in a security breach.
 
 
 
 
 
 
96
  */
97
  public static function specific_ip_restriction_breached_security ($restriction = FALSE)
98
  {
@@ -100,11 +122,18 @@ if (!class_exists ("c_ws_plugin__s2member_ip_restrictions"))
100
  /**/
101
  $prefix = "s2m_ipr_"; /* s2Member Transient prefix for all IP Restrictions. */
102
  $transient_security_breach = $prefix . md5 ("s2member_ip_restrictions_" . $restriction . "_security_breach");
 
103
  /**/
104
- return apply_filters ("ws_plugin__s2member_before_specific_ip_restriction_breached_security", get_transient ($transient_security_breach), get_defined_vars ());
105
  }
106
- /*
107
- Function resets/deletes specific IP Restrictions.
 
 
 
 
 
 
108
  */
109
  public static function delete_reset_specific_ip_restrictions ($restriction = FALSE)
110
  {
@@ -123,24 +152,41 @@ if (!class_exists ("c_ws_plugin__s2member_ip_restrictions"))
123
  /**/
124
  return; /* Return for uniformity. */
125
  }
126
- /*
127
- Function resets/deletes specific IP Restrictions.
128
- Attach to: add_action("wp_ajax_ws_plugin__s2member_delete_reset_specific_ip_restrictions_via_ajax");
 
 
 
 
 
 
129
  */
130
  public static function delete_reset_specific_ip_restrictions_via_ajax ()
131
  {
132
  do_action ("ws_plugin__s2member_before_delete_reset_specific_ip_restrictions_via_ajax", get_defined_vars ());
133
  /**/
134
  if (current_user_can ("create_users")) /* Check priveledges as well. */
135
- if (($nonce = $_POST["ws_plugin__s2member_delete_reset_specific_ip_restrictions_via_ajax"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-delete-reset-specific-ip-restrictions-via-ajax"))
136
- if (($restriction = trim (stripslashes ($_POST["ws_plugin__s2member_delete_reset_specific_ip_restriction"])))) /* Do we have the restriction specification? */
137
- if (c_ws_plugin__s2member_ip_restrictions::delete_reset_specific_ip_restrictions ($restriction) !== "nill") /* Delete/reset IP Restrictions. */
138
- echo apply_filters ("ws_plugin__s2member_delete_reset_specific_ip_restrictions_via_ajax", 1, get_defined_vars ());
 
 
 
 
 
 
139
  /**/
140
  exit (); /* Clean exit. */
141
  }
142
- /*
143
- Function resets/deletes all IP Restrictions.
 
 
 
 
 
144
  */
145
  public static function delete_reset_all_ip_restrictions ()
146
  {
@@ -155,18 +201,28 @@ if (!class_exists ("c_ws_plugin__s2member_ip_restrictions"))
155
  /**/
156
  return; /* Return for uniformity. */
157
  }
158
- /*
159
- Function resets/deletes all IP Restrictions.
160
- Attach to: add_action("wp_ajax_ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax");
 
 
 
 
 
 
161
  */
162
  public static function delete_reset_all_ip_restrictions_via_ajax ()
163
  {
164
  do_action ("ws_plugin__s2member_before_delete_reset_all_ip_restrictions_via_ajax", get_defined_vars ());
165
  /**/
166
  if (current_user_can ("create_users")) /* Check priveledges as well. */
167
- if (($nonce = $_POST["ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-delete-reset-all-ip-restrictions-via-ajax"))
168
- if (c_ws_plugin__s2member_ip_restrictions::delete_reset_all_ip_restrictions () !== "nill") /* Delete/reset IP Restrictions. */
169
- echo apply_filters ("ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax", 1, get_defined_vars ());
 
 
 
 
170
  /**/
171
  exit (); /* Clean exit. */
172
  }
1
  <?php
2
+ /**
3
+ * IP Restrictions.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\IP_Restrictions
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_ip_restrictions"))
21
  {
22
+ /**
23
+ * IP Restrictions.
24
+ *
25
+ * @package s2Member\IP_Restrictions
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_ip_restrictions
29
  {
30
+ /**
31
+ * Handles IP Restrictions.
32
+ *
33
+ * IP address details are stored in Transient fields.
34
+ *
35
+ * @package s2Member\IP_Restrictions
36
+ * @since 3.5
37
+ *
38
+ * @param str $ip IP Address.
39
+ * @param str $restriction Unique IP Restriction name/identifier. Such as a Username, or a unique access code.
40
+ * @return bool True if IP Restrictions are OK, otherwise this function will exit script execution after issuing a warning.
41
  */
42
  public static function ip_restrictions_ok ($ip = FALSE, $restriction = FALSE)
43
  {
44
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
45
  do_action ("ws_plugin__s2member_before_ip_restrictions_ok", get_defined_vars ());
46
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
47
  /**/
48
+ if (!apply_filters ("ws_plugin__s2member_disable_all_ip_restrictions", false, get_defined_vars ()))
49
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] && $restriction)
50
+ {
51
+ $prefix = "s2m_ipr_"; /* s2Member Transient prefix for all IP Restrictions. */
52
+ $transient_entries = $prefix . md5 ("s2member_ip_restrictions_" . $restriction . "_entries");
53
+ $transient_security_breach = $prefix . md5 ("s2member_ip_restrictions_" . $restriction . "_security_breach");
54
+ /**/
55
+ /* If you add Filters, use a string compatible with PHP's strtotime() function. */
56
+ $concurrency = apply_filters ("ws_plugin__s2member_ip_restrictions__concurrency_time_per_ip", "30 days");
57
+ /**/
58
+ $entries = (is_array ($entries = get_transient ($transient_entries))) ? $entries : array ();
59
+ /**/
60
+ foreach ($entries as $_entry => $_time) /* Auto-expire entries. */
61
+ if ($_time < strtotime ("-" . $concurrency))
62
+ unset($entries[$_entry]);
63
+ /**/
64
+ $ip = ($ip) ? $ip : "empty"; /* Allow empty IPs. */
65
+ $entries[$ip] = strtotime ("now"); /* Log this entry. */
66
+ set_transient ($transient_entries, $entries, 2 * (strtotime ("+" . $concurrency) - strtotime ("now")));
67
+ /**/
68
+ if (get_transient ($transient_security_breach)) /* Has this restriction already been breached? */
69
+ {
70
+ c_ws_plugin__s2member_no_cache::no_cache_constants (true) . wp_clear_auth_cookie ();
71
+ /**/
72
+ do_action ("ws_plugin__s2member_during_ip_restrictions_ok_no", get_defined_vars ());
73
+ /**/
74
+ header("HTTP/1.0 503 Service Temporarily Unavailable"); /* Sends a status header. */
75
+ /**/
76
+ echo '<strong>503: Service Temporarily Unavailable</strong><br />' . "\n";
77
+ echo 'Too many IP addresses accessing one secure area<em>!</em><br />' . "\n";
78
+ echo 'Please contact Support if you require assistance.';
79
+ /**/
80
+ exit (); /* Clean exit. */
81
+ }
82
+ else if (count ($entries) > $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"])
83
+ {
84
+ c_ws_plugin__s2member_no_cache::no_cache_constants (true) . wp_clear_auth_cookie ();
85
+ /**/
86
+ set_transient ($transient_security_breach, 1, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction_time"]);
87
+ /**/
88
+ do_action ("ws_plugin__s2member_during_ip_restrictions_ok_no", get_defined_vars ());
89
+ /**/
90
+ header("HTTP/1.0 503 Service Temporarily Unavailable"); /* Sends a status header. */
91
+ /**/
92
+ echo '<strong>503: Service Temporarily Unavailable</strong><br />' . "\n";
93
+ echo 'Too many IP addresses accessing one secure area<em>!</em><br />' . "\n";
94
+ echo 'Please contact Support if you require assistance.';
95
+ /**/
96
+ exit (); /* Clean exit. */
97
+ }
98
+ else /* OK, this looks legitimate. Apply Filters here and return true. */
99
+ {
100
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
101
+ do_action ("ws_plugin__s2member_during_ip_restrictions_ok_yes", get_defined_vars ());
102
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
103
+ /**/
104
+ return apply_filters ("ws_plugin__s2member_ip_restrictions_ok", true, get_defined_vars ());
105
+ }
106
+ }
 
107
  /**/
108
  return apply_filters ("ws_plugin__s2member_ip_restrictions_ok", true, get_defined_vars ());
109
  }
110
+ /**
111
+ * Queries Transients for specific IP Restrictions associated with a security breach.
112
+ *
113
+ * @package s2Member\IP_Restrictions
114
+ * @since 3.5
115
+ *
116
+ * @param str $restriction Unique IP Restriction name/identifier. Such as a Username, or a unique access code.
117
+ * @return bool True if the specific IP Restriction is associated with a security breach, else false.
118
  */
119
  public static function specific_ip_restriction_breached_security ($restriction = FALSE)
120
  {
122
  /**/
123
  $prefix = "s2m_ipr_"; /* s2Member Transient prefix for all IP Restrictions. */
124
  $transient_security_breach = $prefix . md5 ("s2member_ip_restrictions_" . $restriction . "_security_breach");
125
+ $associated_with_security_breach = (get_transient ($transient_security_breach)) ? true : false;
126
  /**/
127
+ return apply_filters ("ws_plugin__s2member_before_specific_ip_restriction_breached_security", $associated_with_security_breach, get_defined_vars ());
128
  }
129
+ /**
130
+ * Resets/deletes specific IP Restrictions.
131
+ *
132
+ * @package s2Member\IP_Restrictions
133
+ * @since 3.5
134
+ *
135
+ * @param str $restriction Unique IP Restriction name/identifier. Such as a Username, or a unique access code.
136
+ * @return null
137
  */
138
  public static function delete_reset_specific_ip_restrictions ($restriction = FALSE)
139
  {
152
  /**/
153
  return; /* Return for uniformity. */
154
  }
155
+ /**
156
+ * Resets/deletes specific IP Restrictions via AJAX.
157
+ *
158
+ * @package s2Member\IP_Restrictions
159
+ * @since 3.5
160
+ *
161
+ * @attaches-to: ``add_action("wp_ajax_ws_plugin__s2member_delete_reset_specific_ip_restrictions_via_ajax");``
162
+ *
163
+ * @return null Exits script execution after returning data for AJAX caller.
164
  */
165
  public static function delete_reset_specific_ip_restrictions_via_ajax ()
166
  {
167
  do_action ("ws_plugin__s2member_before_delete_reset_specific_ip_restrictions_via_ajax", get_defined_vars ());
168
  /**/
169
  if (current_user_can ("create_users")) /* Check priveledges as well. */
170
+ /**/
171
+ if (!empty ($_POST["ws_plugin__s2member_delete_reset_specific_ip_restrictions_via_ajax"]))
172
+ if (($nonce = $_POST["ws_plugin__s2member_delete_reset_specific_ip_restrictions_via_ajax"]))
173
+ if (wp_verify_nonce ($nonce, "ws-plugin--s2member-delete-reset-specific-ip-restrictions-via-ajax"))
174
+ /**/
175
+ if (!empty ($_POST["ws_plugin__s2member_delete_reset_specific_ip_restriction"]))
176
+ if (($restriction = trim (stripslashes ($_POST["ws_plugin__s2member_delete_reset_specific_ip_restriction"]))))
177
+ /**/
178
+ if (c_ws_plugin__s2member_ip_restrictions::delete_reset_specific_ip_restrictions ($restriction) !== "nill")
179
+ echo apply_filters ("ws_plugin__s2member_delete_reset_specific_ip_restrictions_via_ajax", 1, get_defined_vars ());
180
  /**/
181
  exit (); /* Clean exit. */
182
  }
183
+ /**
184
+ * Resets/deletes all IP Restrictions.
185
+ *
186
+ * @package s2Member\IP_Restrictions
187
+ * @since 3.5
188
+ *
189
+ * @return null
190
  */
191
  public static function delete_reset_all_ip_restrictions ()
192
  {
201
  /**/
202
  return; /* Return for uniformity. */
203
  }
204
+ /**
205
+ * Resets/deletes all IP Restrictions via AJAX.
206
+ *
207
+ * @package s2Member\IP_Restrictions
208
+ * @since 3.5
209
+ *
210
+ * @attaches-to: ``add_action("wp_ajax_ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax");``
211
+ *
212
+ * @return null Exits script execution after returning data for AJAX caller.
213
  */
214
  public static function delete_reset_all_ip_restrictions_via_ajax ()
215
  {
216
  do_action ("ws_plugin__s2member_before_delete_reset_all_ip_restrictions_via_ajax", get_defined_vars ());
217
  /**/
218
  if (current_user_can ("create_users")) /* Check priveledges as well. */
219
+ /**/
220
+ if (!empty ($_POST["ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax"]))
221
+ if (($nonce = $_POST["ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax"]))
222
+ if (wp_verify_nonce ($nonce, "ws-plugin--s2member-delete-reset-all-ip-restrictions-via-ajax"))
223
+ /**/
224
+ if (c_ws_plugin__s2member_ip_restrictions::delete_reset_all_ip_restrictions () !== "nill")
225
+ echo apply_filters ("ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax", 1, get_defined_vars ());
226
  /**/
227
  exit (); /* Clean exit. */
228
  }
includes/classes/labels.inc.php CHANGED
@@ -1,26 +1,41 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_labels"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_labels
20
  {
21
- /*
22
- Function configures Label translations.
23
- Attach to: add_action("init");
 
 
 
 
 
 
24
  */
25
  public static function config_label_translations ()
26
  {
@@ -33,9 +48,18 @@ if (!class_exists ("c_ws_plugin__s2member_labels"))
33
  /**/
34
  return; /* Return for uniformity. */
35
  }
36
- /*
37
- A sort of callback function that deals with Label translations.
38
- Attach to: add_filter("gettext_with_context");
 
 
 
 
 
 
 
 
 
39
  */
40
  public static function _label_translations ($translation = FALSE, $text = FALSE, $context = FALSE)
41
  {
1
  <?php
2
+ /**
3
+ * Membership Level Labels.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Roles_Caps
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_labels"))
21
  {
22
+ /**
23
+ * Membership Level Labels.
24
+ *
25
+ * @package s2Member\Roles_Caps
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_labels
29
  {
30
+ /**
31
+ * Configures Label translations.
32
+ *
33
+ * @package s2Member\Roles_Caps
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_action("init");``
37
+ *
38
+ * @return null
39
  */
40
  public static function config_label_translations ()
41
  {
48
  /**/
49
  return; /* Return for uniformity. */
50
  }
51
+ /**
52
+ * A sort of callback function that deals with Label translations.
53
+ *
54
+ * @package s2Member\Roles_Caps
55
+ * @since 3.5
56
+ *
57
+ * @attaches-to: ``add_filter("gettext_with_context");``
58
+ *
59
+ * @param str $translation Expects a string; already translated.
60
+ * @param str $text The original text, passed in by the calling Filter.
61
+ * @param str $context Contextual specification for this translation.
62
+ * @return str The ``$translation``, after translations applied by this routine.
63
  */
64
  public static function _label_translations ($translation = FALSE, $text = FALSE, $context = FALSE)
65
  {
includes/classes/list-servers.inc.php CHANGED
@@ -1,73 +1,174 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_list_servers"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_list_servers
20
  {
21
- /*
22
- Determines whether or not any list servers have been integrated into the s2Member options.
 
 
 
 
 
23
  */
24
  public static function list_servers_integrated ()
25
  {
26
  do_action ("ws_plugin__s2member_before_list_servers_integrated", get_defined_vars ());
27
  /**/
28
- for ($i = 0; $i <= 4; $i++)
29
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_mailchimp_list_ids"] || $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_aweber_list_ids"])
30
  return apply_filters ("ws_plugin__s2member_list_servers_integrated", true, get_defined_vars ());
31
  /**/
32
  return apply_filters ("ws_plugin__s2member_list_servers_integrated", false, get_defined_vars ());
33
  }
34
- /*
35
- Processes List Server integrations for s2Member.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  */
37
- public static function process_list_servers ($role = FALSE, $level = FALSE, $login = FALSE, $pass = FALSE, $email = FALSE, $fname = FALSE, $lname = FALSE, $ip = FALSE, $opt_in = FALSE, $user_id = FALSE)
38
  {
39
  global $current_site, $current_blog; /* For Multisite support. */
40
  /**/
41
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
42
  do_action ("ws_plugin__s2member_before_process_list_servers", get_defined_vars ());
43
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
44
  /**/
45
- if ($role && strlen ($level) && $login && is_email ($email) && $opt_in && $user_id)
46
  {
47
- $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status (0);
48
- c_ws_plugin__s2member_email_configs::email_config_release (); /* Release. */
49
  /**/
50
- if (($mailchimp_api_key = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]))
51
- if (($mailchimp_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]))
52
- {
53
- if (!class_exists ("NC_MCAPI"))
54
- include_once dirname (dirname (__FILE__)) . "/mailchimp/nc-mcapi.inc.php";
55
- /**/
56
- $MCAPI = new NC_MCAPI ($mailchimp_api_key); /* MailChimp® API class. */
57
- /**/
58
- foreach (preg_split ("/[\r\n\t\s;,]+/", $mailchimp_list_ids) as $mailchimp_list_id)
59
- $MCAPI->listSubscribe ($mailchimp_list_id, $email, apply_filters ("ws_plugin__s2member_mailchimp_array", array ("FNAME" => $fname, "LNAME" => $lname, "OPTINIP" => $ip), get_defined_vars ()));
60
- }
61
  /**/
62
- if (($aweber_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]))
63
  {
64
- $aweber_pass_inclusion = /* Off by default ( this poses a security risk ) » */ (apply_filters ("ws_plugin__s2member_aweber_pass_inclusion", false, get_defined_vars ()) && $pass) ? "\nPass: " . $pass : false;
 
 
 
65
  /**/
66
- foreach (preg_split ("/[\r\n\t\s;,]+/", $aweber_list_ids) as $aweber_list_id)
67
- wp_mail ($aweber_list_id . "@aweber.com", apply_filters ("ws_plugin__s2member_aweber_sbj", "s2Member Subscription Request", get_defined_vars ()), apply_filters ("ws_plugin__s2member_aweber_msg", "s2Member Subscription Request\ns2Member w/ PayPal Email ID\nEMail Address: " . $email . "\nBuyer: " . $fname . " " . $lname . "\nFull Name: " . $fname . " " . $lname . "\nFirst Name: " . $fname . "\nLast Name: " . $lname . "\nIP Address: " . $ip . "\nUser ID: " . $user_id . "\nLogin: " . $login . $aweber_pass_inclusion . "\nRole: " . $role . "\nLevel: " . $level . "\n - end.", get_defined_vars ()), "From: \"" . preg_replace ("/\"/", "", $fname . " " . $lname) . "\" <" . $email . ">\r\nContent-Type: text/plain; charset=utf-8");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  }
69
  /**/
70
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  do_action ("ws_plugin__s2member_during_process_list_servers", get_defined_vars ());
72
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
73
  /**/
@@ -75,47 +176,109 @@ if (!class_exists ("c_ws_plugin__s2member_list_servers"))
75
  c_ws_plugin__s2member_email_configs::email_config ();
76
  }
77
  /**/
78
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
79
  do_action ("ws_plugin__s2member_after_process_list_servers", get_defined_vars ());
80
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
81
  /**/
82
- return; /* Return for uniformity. */
83
  }
84
- /*
85
- Processes list server removals for s2Member.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  */
87
  public static function process_list_server_removals ($role = FALSE, $level = FALSE, $login = FALSE, $pass = FALSE, $email = FALSE, $fname = FALSE, $lname = FALSE, $ip = FALSE, $opt_out = FALSE, $user_id = FALSE)
88
  {
89
  global $current_site, $current_blog; /* For Multisite support. */
90
  /**/
91
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
92
  do_action ("ws_plugin__s2member_before_process_list_server_removals", get_defined_vars ());
93
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
94
  /**/
95
- if ($role && strlen ($level) && $login && is_email ($email) && $opt_out && $user_id)
96
  {
97
- $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status (0);
98
- c_ws_plugin__s2member_email_configs::email_config_release (); /* Release Filters. */
99
  /**/
100
- if (($mailchimp_api_key = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]))
101
- if (($mailchimp_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]))
102
- {
103
- if (!class_exists ("NC_MCAPI"))
104
- include_once dirname (dirname (__FILE__)) . "/mailchimp/nc-mcapi.inc.php";
105
- /**/
106
- $MCAPI = new NC_MCAPI ($mailchimp_api_key); /* MailChimp® API class. */
107
- /**/
108
- foreach (preg_split ("/[\r\n\t\s;,]+/", $mailchimp_list_ids) as $mailchimp_list_id)
109
- $MCAPI->listUnsubscribe ($mailchimp_list_id, $email, apply_filters ("ws_plugin__s2member_mailchimp_removal_delete_member", false, get_defined_vars ()), apply_filters ("ws_plugin__s2member_mailchimp_removal_send_goodbye", false, get_defined_vars ()), apply_filters ("ws_plugin__s2member_mailchimp_removal_send_notify", false, get_defined_vars ()));
110
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  /**/
112
- if (($aweber_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]))
113
  {
114
- foreach (preg_split ("/[\r\n\t\s;,]+/", $aweber_list_ids) as $aweber_list_id)
115
- wp_mail ($aweber_list_id . "@aweber.com", apply_filters ("ws_plugin__s2member_aweber_removal_sbj", "REMOVE#" . $email . "#s2Member-" . ( (is_multisite () && !is_main_site ()) ? $current_blog->domain . $current_blog->path : $_SERVER["HTTP_HOST"]) . "#" . $aweber_list_id, get_defined_vars ()), "", "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
117
  /**/
118
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
119
  do_action ("ws_plugin__s2member_during_process_list_server_removals", get_defined_vars ());
120
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
121
  /**/
@@ -123,39 +286,61 @@ if (!class_exists ("c_ws_plugin__s2member_list_servers"))
123
  c_ws_plugin__s2member_email_configs::email_config ();
124
  }
125
  /**/
126
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
127
  do_action ("ws_plugin__s2member_after_process_list_server_removals", get_defined_vars ());
128
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
129
  /**/
130
- return; /* Return for uniformity. */
131
  }
132
- /*
133
- Listens to Collective EOT/MOD Events processed internally by s2Member.
134
- This is only applicable when ["custom_reg_auto_opt_outs"] contains related Event(s).
135
- Attach to: add_action("ws_plugin__s2member_during_collective_eots");
136
- Attach to: add_action("ws_plugin__s2member_during_collective_mods");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  */
138
- public static function auto_process_list_server_removals ($user_id = FALSE, $vars = FALSE, $event = FALSE, $_event_spec = FALSE, $_mod_new_level = FALSE)
139
  {
140
  global $current_site, $current_blog; /* For Multisite support. */
141
  static $auto_processed = array (); /* Only process ONE time for each User ID. */
142
  /**/
143
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
144
  do_action ("ws_plugin__s2member_before_auto_process_list_server_removals", get_defined_vars ());
145
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
146
  /**/
147
- if ($user_id && !in_array ($user_id, $auto_processed) && (c_ws_plugin__s2member_utils_arrays::in_regex_array ($event, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_outs"]) || c_ws_plugin__s2member_utils_arrays::in_regex_array ($_event_spec, $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_outs"])) && c_ws_plugin__s2member_list_servers::list_servers_integrated () && is_object ($user = new WP_User ($user_id)) && $user->ID)
 
 
148
  {
149
- if (($_event_spec !== "modification" || ($_event_spec === "modification" && strlen ($_mod_new_level) && (int)$_mod_new_level !== c_ws_plugin__s2member_user_access::user_access_level ($user))) && ($auto_processed[$user_id] = true))
 
 
 
150
  {
151
- c_ws_plugin__s2member_list_servers::process_list_server_removals (c_ws_plugin__s2member_user_access::user_access_role ($user), c_ws_plugin__s2member_user_access::user_access_level ($user), $user->user_login, false, $user->user_email, $user->first_name, $user->last_name, false, true, $user_id);
152
- /**/
153
- if ($_event_spec === "modification" && strlen ($_mod_new_level) && apply_filters ("ws_plugin__s2member_auto_process_new_list_servers", true, get_defined_vars ())) /* Subscribe to new List(s)? */
154
- c_ws_plugin__s2member_list_servers::process_list_servers ("s2member_level" . $_mod_new_level, $_mod_new_level, $user->user_login, false, $user->user_email, $user->first_name, $user->last_name, false, true, $user_id);
155
  }
156
  }
157
  /**/
158
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
159
  do_action ("ws_plugin__s2member_after_auto_process_list_server_removals", get_defined_vars ());
160
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
161
  /**/
1
  <?php
2
+ /**
3
+ * List Server integrations.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\List_Servers
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_list_servers"))
21
  {
22
+ /**
23
+ * List Server integrations.
24
+ *
25
+ * @package s2Member\List_Servers
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_list_servers
29
  {
30
+ /**
31
+ * Determines whether or not any List Servers have been integrated.
32
+ *
33
+ * @package s2Member\List_Servers
34
+ * @since 3.5
35
+ *
36
+ * @return bool True if List Servers have been integrated, else false.
37
  */
38
  public static function list_servers_integrated ()
39
  {
40
  do_action ("ws_plugin__s2member_before_list_servers_integrated", get_defined_vars ());
41
  /**/
42
+ for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++) /* Go through each Level; looking for a configured list. */
43
+ if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_mailchimp_list_ids"]) || !empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_aweber_list_ids"]))
44
  return apply_filters ("ws_plugin__s2member_list_servers_integrated", true, get_defined_vars ());
45
  /**/
46
  return apply_filters ("ws_plugin__s2member_list_servers_integrated", false, get_defined_vars ());
47
  }
48
+ /**
49
+ * Processes List Server integrations for s2Member.
50
+ *
51
+ * @package s2Member\List_Servers
52
+ * @since 3.5
53
+ *
54
+ * @param str $role A WordPress Role ID/Name, such as `subscriber`, or `s2member_level1`.
55
+ * @param int|str $level A numeric s2Member Access Level number.
56
+ * @param str $login Username for the User.
57
+ * @param str $pass Plain Text Password for the User.
58
+ * @param str $email Email Address for the User.
59
+ * @param str $fname First Name for the User.
60
+ * @param str $lname Last Name for the User.
61
+ * @param str $ip IP Address for the User.
62
+ * @param bool $opt_in Defaults to false; must be set to true. Indicates the User IS opting in.
63
+ * @param bool $double_opt_in Defaults to true. If false, no email confirmation is required. Use at your own risk.
64
+ * @param int|str $user_id A WordPress User ID, numeric string or integer.
65
+ * @return bool True if at least one List Server is processed successfully, else false.
66
+ *
67
+ * @todo Integrate {@link https://labs.aweber.com/docs/php-library-walkthrough AWeber's API}.
68
+ * @todo Add a separate option for mail debugging; or consolidate?
69
+ * @todo Integrate AWeber® API ( much like the MailChimp® API ).
70
  */
71
+ public static function process_list_servers ($role = FALSE, $level = FALSE, $login = FALSE, $pass = FALSE, $email = FALSE, $fname = FALSE, $lname = FALSE, $ip = FALSE, $opt_in = FALSE, $double_opt_in = TRUE, $user_id = FALSE)
72
  {
73
  global $current_site, $current_blog; /* For Multisite support. */
74
  /**/
75
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
76
  do_action ("ws_plugin__s2member_before_process_list_servers", get_defined_vars ());
77
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
78
  /**/
79
+ if (($args = func_get_args ()) && $role && strlen ($level) && $login && is_email ($email) && $opt_in && $user_id && is_object ($user = new WP_User ($user_id)) && ($user_id = $user->ID))
80
  {
81
+ $ccaps = implode (",", c_ws_plugin__s2member_user_access::user_access_ccaps ($user)); /* Get Custom Capabilities ( comma-delimited ). */
 
82
  /**/
83
+ $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status (false); /* s2Member Filters enabled? */
84
+ c_ws_plugin__s2member_email_configs::email_config_release (true); /* Release all mail Filters before we begin this routine. */
 
 
 
 
 
 
 
 
 
85
  /**/
86
+ if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]) && !empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]))
87
  {
88
+ if (!class_exists ("NC_MCAPI")) /* Include the MailChimp® API Class here. */
89
+ include_once dirname (dirname (__FILE__)) . "/_xtnls/mailchimp/nc-mcapi.inc.php"; /* MailChimp® API ( no-conflict version ). */
90
+ /**/
91
+ $mcapi = new NC_MCAPI ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]); /* MailChimp® API ( no-conflict ). */
92
  /**/
93
+ foreach (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]) as $mailchimp_list)
94
+ {
95
+ $mailchimp = array ("function" => __FUNCTION__, "func_get_args" => $args, "api_method" => "listSubscribe");
96
+ /**/
97
+ if (($mailchimp["list"] = trim ($mailchimp_list))) /* Trim this up. NO trailing white space. */
98
+ {
99
+ if (strpos ($mailchimp["list"], "::") !== false) /* Also contains Interest Groups? */
100
+ {
101
+ list ($mailchimp["list_id"], $mailchimp["interest_groups_title"], $mailchimp["interest_groups"]) = preg_split ("/\:\:/", $mailchimp["list"], 3);
102
+ /**/
103
+ if (($mailchimp["interest_groups_title"] = trim ($mailchimp["interest_groups_title"]))) /* This is a title configured by the list master. */
104
+ if (($mailchimp["interest_groups"] = (trim ($mailchimp["interest_groups"])) ? preg_split ("/\|/", trim ($mailchimp["interest_groups"])) : false))
105
+ $mailchimp["interest_groups"] = array ("GROUPINGS" => array (array ("name" => $mailchimp["interest_groups_title"], "groups" => implode (",", $mailchimp["interest_groups"]))));
106
+ /**/
107
+ if (empty ($mailchimp["list_id"])) /* Need to double-check this. If empty, skip over this entry. */
108
+ continue; /* Continue to next List, if there is one. */
109
+ }
110
+ else /* Else, it's just a List ID. */
111
+ $mailchimp["list_id"] = $mailchimp["list"];
112
+ /**/
113
+ $mailchimp["merge_array"] = array ("MERGE1" => $fname, "MERGE2" => $lname, "OPTIN_IP" => $ip, "OPTIN_TIME" => date ("Y-m-d H:i:s"));
114
+ $mailchimp["merge_array"] = ($mailchimp["interest_groups"]) ? array_merge ($mailchimp["merge_array"], $mailchimp["interest_groups"]) : $mailchimp["merge_array"];
115
+ $mailchimp["merge_array"] = apply_filters ( /* Deprecated. */"ws_plugin__s2member_mailchimp_array", $mailchimp["merge_array"], get_defined_vars ());
116
+ /* Filter: `ws_plugin__s2member_mailchimp_array` deprecated in v110523. Please use Filter: `ws_plugin__s2member_mailchimp_merge_array`. */
117
+ /**/
118
+ if ($mailchimp["api_response"] = $mcapi->{$mailchimp["api_method"]}($mailchimp["list_id"], $email, /* See: `http://apidocs.mailchimp.com/` for full details. */
119
+ ($mailchimp["api_merge_array"] = apply_filters ("ws_plugin__s2member_mailchimp_merge_array", $mailchimp["merge_array"], get_defined_vars ())), /* Configured merge array above. */
120
+ ($mailchimp["api_email_type"] = apply_filters ("ws_plugin__s2member_mailchimp_email_type", "html", get_defined_vars ())), /* Type of email to receive ( i.e. html,text,mobile ).*/
121
+ ($mailchimp["api_double_optin"] = apply_filters ("ws_plugin__s2member_mailchimp_double_optin", $double_opt_in, get_defined_vars ())), /* Abuse of this may cause account suspension. */
122
+ ($mailchimp["api_update_existing"] = apply_filters ("ws_plugin__s2member_mailchimp_update_existing", false, get_defined_vars ())), /* Existing subscribers should be updated with this? */
123
+ ($mailchimp["api_replace_interests"] = apply_filters ("ws_plugin__s2member_mailchimp_replace_interests", true, get_defined_vars ())), /* Replace interest groups? ( only if provided ) */
124
+ ($mailchimp["api_send_welcome"] = apply_filters ("ws_plugin__s2member_mailchimp_send_welcome", false, get_defined_vars ())))) /* See documentation. This is a weird option. */
125
+ $mailchimp["api_success"] = $success = true; /* Flag indicating that we DO have a successful processing of a new List; affects the function's overall return value. */
126
+ $mailchimp["api_properties"] = $mcapi; /* Include API instance too; as it contains some additional information after each method is processed ( need this in the logs ). */
127
+ /**/
128
+ $logv = c_ws_plugin__s2member_utilities::ver_details ();
129
+ $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
130
+ $log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
131
+ $log2 = (is_multisite () && !is_main_site ()) ? "mailchimp-api-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "mailchimp-api.log";
132
+ /**/
133
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
134
+ if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
135
+ if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
136
+ file_put_contents ($logs_dir . "/" . $log2, $logv . "\n" . $log4 . "\n" . var_export ($mailchimp, true) . "\n\n", FILE_APPEND);
137
+ }
138
+ }
139
  }
140
  /**/
141
+ if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]))
142
+ {
143
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]) as $aweber_list)
144
+ {
145
+ $aweber = array ("function" => __FUNCTION__, "func_get_args" => $args, "wp_mail_method" => "listSubscribe");
146
+ /**/
147
+ if (($aweber["list_id"] = trim ($aweber_list))) /* Trim this up. NO trailing white space. */
148
+ {
149
+ $aweber["bcc"] = apply_filters ("ws_plugin__s2member_aweber_bcc", false, get_defined_vars ());
150
+ $aweber["pass_inclusion"] = (apply_filters ("ws_plugin__s2member_aweber_pass_inclusion", false, get_defined_vars ()) && $pass) ? "\nPass: " . $pass : false;
151
+ /**/
152
+ if ($aweber["wp_mail_response"] = wp_mail ($aweber["list_id"] . "@aweber.com", /* AWeber® List ID converts to email address @aweber.com. */
153
+ ($aweber["wp_mail_sbj"] = apply_filters ("ws_plugin__s2member_aweber_sbj", "s2Member Subscription Request", get_defined_vars ())), /* These Filters make it possible to customize these emails. */
154
+ ($aweber["wp_mail_msg"] = apply_filters ("ws_plugin__s2member_aweber_msg", "s2Member Subscription Request\ns2Member w/ PayPal Email ID\nAd Tracking: s2Member-" . ((is_multisite () && !is_main_site ()) ? $current_blog->domain . $current_blog->path : $_SERVER["HTTP_HOST"]) . "\nEMail Address: " . $email . "\nBuyer: " . $fname . " " . $lname . "\nFull Name: " . $fname . " " . $lname . "\nFirst Name: " . $fname . "\nLast Name: " . $lname . "\nIP Address: " . $ip . "\nUser ID: " . $user_id . "\nLogin: " . $login . $aweber["pass_inclusion"] . "\nRole: " . $role . "\nLevel: " . $level . "\nCCaps: " . $ccaps . "\n - end.", get_defined_vars ())),/**/
155
+ ($aweber["wp_mail_headers"] = "From: \"" . preg_replace ("/\"/", "", $fname . " " . $lname) . "\" <" . $email . ">" . (($aweber["bcc"]) ? "\r\nBcc: " . $aweber["bcc"] : "") . "\r\nContent-Type: text/plain; charset=utf-8")))
156
+ $aweber["wp_mail_success"] = $success = true; /* Flag indicating that we DO have a successful processing of a new List; affects the function's overall return value. */
157
+ /**/
158
+ $logv = c_ws_plugin__s2member_utilities::ver_details ();
159
+ $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
160
+ $log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
161
+ $log2 = (is_multisite () && !is_main_site ()) ? "aweber-api-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "aweber-api.log";
162
+ /**/
163
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
164
+ if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
165
+ if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
166
+ file_put_contents ($logs_dir . "/" . $log2, $logv . "\n" . $log4 . "\n" . var_export ($aweber, true) . "\n\n", FILE_APPEND);
167
+ }
168
+ }
169
+ }
170
+ /**/
171
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
172
  do_action ("ws_plugin__s2member_during_process_list_servers", get_defined_vars ());
173
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
174
  /**/
176
  c_ws_plugin__s2member_email_configs::email_config ();
177
  }
178
  /**/
179
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
180
  do_action ("ws_plugin__s2member_after_process_list_servers", get_defined_vars ());
181
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
182
  /**/
183
+ return apply_filters ("ws_plugin__s2member_process_list_servers", (isset ($success) && $success), get_defined_vars ());
184
  }
185
+ /**
186
+ * Processes List Server removals for s2Member.
187
+ *
188
+ * @package s2Member\List_Servers
189
+ * @since 3.5
190
+ *
191
+ * @param str $role A WordPress Role ID/Name, such as `subscriber`, or `s2member_level1`.
192
+ * @param int|str $level A numeric s2Member Access Level number.
193
+ * @param str $login Username for the User.
194
+ * @param str $pass Plain Text Password for the User.
195
+ * @param str $email Email address for the User.
196
+ * @param str $fname First Name for the User.
197
+ * @param str $lname Last Name for the User.
198
+ * @param str $ip IP Address for the User.
199
+ * @param bool $opt_out Defaults to false; must be set to true. Indicates the User IS opting out.
200
+ * @param int|str $user_id A WordPress User ID, numeric string or integer.
201
+ * @return bool True if at least one List Server is processed successfully, else false.
202
+ *
203
+ * @todo Integrate {@link https://labs.aweber.com/docs/php-library-walkthrough AWeber's API}.
204
+ * @todo Add a separate option for mail debugging; or consolidate?
205
+ * @todo Integrate AWeber® API ( much like the MailChimp® API ).
206
  */
207
  public static function process_list_server_removals ($role = FALSE, $level = FALSE, $login = FALSE, $pass = FALSE, $email = FALSE, $fname = FALSE, $lname = FALSE, $ip = FALSE, $opt_out = FALSE, $user_id = FALSE)
208
  {
209
  global $current_site, $current_blog; /* For Multisite support. */
210
  /**/
211
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
212
  do_action ("ws_plugin__s2member_before_process_list_server_removals", get_defined_vars ());
213
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
214
  /**/
215
+ if (($args = func_get_args ()) && $role && strlen ($level) && $login && is_email ($email) && $opt_out && $user_id && is_object ($user = new WP_User ($user_id)) && ($user_id = $user->ID))
216
  {
217
+ $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status (false); /* s2Member Filters enabled? */
218
+ c_ws_plugin__s2member_email_configs::email_config_release (true); /* Release all mail Filters before we begin this routine. */
219
  /**/
220
+ if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]) && !empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]))
221
+ {
222
+ if (!class_exists ("NC_MCAPI")) /* Include the MailChimp® API Class here. */
223
+ include_once dirname (dirname (__FILE__)) . "/_xtnls/mailchimp/nc-mcapi.inc.php"; /* MailChimp® API ( no-conflict version ). */
224
+ /**/
225
+ $mcapi = new NC_MCAPI ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]); /* MailChimp® API ( no-conflict ). */
226
+ /**/
227
+ foreach (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]) as $mailchimp_list)
228
+ {
229
+ $mailchimp = array ("function" => __FUNCTION__, "func_get_args" => $args, "api_removal_method" => "listUnsubscribe");
230
+ /**/
231
+ if (($mailchimp["list_id"] = trim (preg_replace ("/\:\:.*$/", "", $mailchimp_list)))) /* Trim & strip groups. */
232
+ {
233
+ if ($mailchimp["api_removal_response"] = $mcapi->{$mailchimp["api_removal_method"]}($mailchimp["list_id"], $email, /* See: `http://apidocs.mailchimp.com/` for full details. */
234
+ ($mailchimp["api_removal_delete_member"] = apply_filters ("ws_plugin__s2member_mailchimp_removal_delete_member", false, get_defined_vars ())), /* Completely delete? */
235
+ ($mailchimp["api_removal_send_goodbye"] = apply_filters ("ws_plugin__s2member_mailchimp_removal_send_goodbye", false, get_defined_vars ())), /* Send goodbye letter? */
236
+ ($mailchimp["api_removal_send_notify"] = apply_filters ("ws_plugin__s2member_mailchimp_removal_send_notify", false, get_defined_vars ())))) /* Send notification? */
237
+ $mailchimp["api_removal_success"] = $removal_success = true; /* Flag indicating that we DO have a successful removal; affects the function's overall return value. */
238
+ $mailchimp["api_removal_properties"] = $mcapi; /* Include API instance too; as it contains some additional information after each method is processed ( need this in the logs ). */
239
+ /**/
240
+ $logv = c_ws_plugin__s2member_utilities::ver_details ();
241
+ $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
242
+ $log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
243
+ $log2 = (is_multisite () && !is_main_site ()) ? "mailchimp-api-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "mailchimp-api.log";
244
+ /**/
245
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
246
+ if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
247
+ if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
248
+ file_put_contents ($logs_dir . "/" . $log2, $logv . "\n" . $log4 . "\n" . var_export ($mailchimp, true) . "\n\n", FILE_APPEND);
249
+ }
250
+ }
251
+ }
252
  /**/
253
+ if (!empty ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]))
254
  {
255
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]) as $aweber_list)
256
+ {
257
+ $aweber = array ("function" => __FUNCTION__, "func_get_args" => $args, "wp_mail_removal_method" => "listUnsubscribe");
258
+ /**/
259
+ if (($aweber["list_id"] = trim ($aweber_list))) /* Trim this up. NO trailing white space. */
260
+ {
261
+ $aweber["removal_bcc"] = apply_filters ("ws_plugin__s2member_aweber_removal_bcc", false, get_defined_vars ());
262
+ /**/
263
+ if ($aweber["wp_mail_removal_response"] = wp_mail ($aweber["list_id"] . "@aweber.com", /* AWeber® List ID converts to email address @aweber.com. */
264
+ ($aweber["wp_mail_removal_sbj"] = apply_filters ("ws_plugin__s2member_aweber_removal_sbj", "REMOVE#" . $email . "#s2Member#" . $aweber["list_id"], get_defined_vars ())), /* Bug fix. AWeber® does not like dots ( possibly other chars ) in the Ad Tracking field. Now using just: `s2Member`. */
265
+ ($aweber["wp_mail_removal_msg"] = "REMOVE"), ($aweber["wp_mail_removal_headers"] = "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">" . (($aweber["removal_bcc"]) ? "\r\nBcc: " . $aweber["removal_bcc"] : "") . "\r\nContent-Type: text/plain; charset=utf-8")))
266
+ $aweber["wp_mail_removal_success"] = $removal_success = true; /* Flag indicating that we DO have a successful removal; affects the function's overall return value. */
267
+ /**/
268
+ $logv = c_ws_plugin__s2member_utilities::ver_details ();
269
+ $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
270
+ $log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
271
+ $log2 = (is_multisite () && !is_main_site ()) ? "aweber-api-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "aweber-api.log";
272
+ /**/
273
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
274
+ if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
275
+ if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
276
+ file_put_contents ($logs_dir . "/" . $log2, $logv . "\n" . $log4 . "\n" . var_export ($aweber, true) . "\n\n", FILE_APPEND);
277
+ }
278
+ }
279
  }
280
  /**/
281
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
282
  do_action ("ws_plugin__s2member_during_process_list_server_removals", get_defined_vars ());
283
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
284
  /**/
286
  c_ws_plugin__s2member_email_configs::email_config ();
287
  }
288
  /**/
289
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
290
  do_action ("ws_plugin__s2member_after_process_list_server_removals", get_defined_vars ());
291
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
292
  /**/
293
+ return apply_filters ("ws_plugin__s2member_process_list_server_removals", (isset ($removal_success) && $removal_success), get_defined_vars ());
294
  }
295
+ /**
296
+ * Listens to Collective EOT/MOD Events processed internally by s2Member.
297
+ *
298
+ * This is only applicable when ``["custom_reg_auto_opt_outs"]`` contains related Event(s).
299
+ *
300
+ * @package s2Member\List_Servers
301
+ * @since 3.5
302
+ *
303
+ * @attaches-to: ``add_action("ws_plugin__s2member_during_collective_mods");``
304
+ * @attaches-to: ``add_action("ws_plugin__s2member_during_collective_eots");``
305
+ *
306
+ * @param int|str $user_id A WordPress® User ID, numeric string or integer.
307
+ * @param array $vars An array of defined variables from the calling Action Hook.
308
+ * @param str $event A specific event that triggered this call from the Action Hook.
309
+ * @param str $event_spec A specific event specification *( a broader classification )*.
310
+ * @param str $mod_new_role If it's a modification, the new Role they are being modified to.
311
+ * @param str $mod_old_role If it's a modification, the old Role they had previously.
312
+ * @param obj $user Optional. A WP_User object that can reduce database queries for this routine.
313
+ * @return null
314
+ *
315
+ * @todo Make it possible to transition Users, even if they were not currently on a list?
316
+ * One suggestion was to send a double-opt-in email in that case; or to provide an option for this?
317
+ * @todo Tighten up the call to ``c_ws_plugin__s2member_utils_strings::wrap_deep()`` by using `^$`?
318
  */
319
+ public static function auto_process_list_server_removals ($user_id = FALSE, $vars = FALSE, $event = FALSE, $event_spec = FALSE, $mod_new_role = FALSE, $mod_old_role = FALSE, $user = FALSE)
320
  {
321
  global $current_site, $current_blog; /* For Multisite support. */
322
  static $auto_processed = array (); /* Only process ONE time for each User ID. */
323
  /**/
324
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
325
  do_action ("ws_plugin__s2member_before_auto_process_list_server_removals", get_defined_vars ());
326
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
327
  /**/
328
+ $custom_reg_auto_op_outs = c_ws_plugin__s2member_utils_strings::wrap_deep ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_outs"], "/", "/i");
329
+ /**/
330
+ if ($user_id && !in_array ($user_id, $auto_processed) && (c_ws_plugin__s2member_utils_arrays::in_regex_array ($event, $custom_reg_auto_op_outs) || c_ws_plugin__s2member_utils_arrays::in_regex_array ($event_spec, $custom_reg_auto_op_outs)) && c_ws_plugin__s2member_list_servers::list_servers_integrated () && (is_object ($user) || is_object ($user = new WP_User ($user_id))) && ($user_id = $user->ID))
331
  {
332
+ $role = ($event_spec === "modification" && $mod_new_role && $mod_old_role) ? $mod_old_role : c_ws_plugin__s2member_user_access::user_access_role ($user);
333
+ $level = ($event_spec === "modification" && $mod_new_role && $mod_old_role) ? c_ws_plugin__s2member_user_access::user_access_role_to_level ($mod_old_role) : c_ws_plugin__s2member_user_access::user_access_level ($user);
334
+ /**/
335
+ if (($event_spec !== "modification" || ($event_spec === "modification" && $mod_new_role && $mod_new_role !== $role && strtotime ($user->user_registered) < strtotime ("-10 seconds") && ($event !== "user-role-change" || ($event === "user-role-change" && !empty ($_POST["ws_plugin__s2member_custom_reg_auto_opt_out_transitions"]))))) && ($auto_processed[$user_id] = true))
336
  {
337
+ $removal_success = c_ws_plugin__s2member_list_servers::process_list_server_removals ($role, $level, $user->user_login, false, $user->user_email, $user->first_name, $user->last_name, false, true, $user_id);
338
+ if ( /* Only if removed successfully. */$removal_success && $event_spec === "modification" && $mod_new_role && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_out_transitions"]) /* Transition? */
339
+ c_ws_plugin__s2member_list_servers::process_list_servers ($mod_new_role, ($mod_new_level = c_ws_plugin__s2member_user_access::user_access_role_to_level ($mod_new_role)), $user->user_login, false, $user->user_email, $user->first_name, $user->last_name, false, true, false, $user_id);
 
340
  }
341
  }
342
  /**/
343
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
344
  do_action ("ws_plugin__s2member_after_auto_process_list_server_removals", get_defined_vars ());
345
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
346
  /**/
includes/classes/login-customizations.inc.php CHANGED
@@ -1,26 +1,42 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_login_customizations"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_login_customizations
20
  {
21
- /*
22
- Filters the Login/Registration Logo Url.
23
- Attach to: add_filter("login_headerurl");
 
 
 
 
 
 
 
24
  */
25
  public static function login_header_url ($url = FALSE)
26
  {
@@ -30,9 +46,16 @@ if (!class_exists ("c_ws_plugin__s2member_login_customizations"))
30
  /**/
31
  return apply_filters ("ws_plugin__s2member_login_header_url", $url, get_defined_vars ());
32
  }
33
- /*
34
- Filters the Login/Registration Logo Title.
35
- Attach to: add_filter("login_headertitle");
 
 
 
 
 
 
 
36
  */
37
  public static function login_header_title ($title = FALSE)
38
  {
@@ -42,79 +65,95 @@ if (!class_exists ("c_ws_plugin__s2member_login_customizations"))
42
  /**/
43
  return apply_filters ("ws_plugin__s2member_login_header_title", $title, get_defined_vars ());
44
  }
45
- /*
46
- Creates styles for the Login/Registration panel.
47
- Attach to: add_action("login_head");
 
 
 
 
 
 
48
  */
49
  public static function login_header_styles ()
50
  {
51
- $s = ""; /* Initialize here to give Hooks a chance. */
 
52
  /**/
53
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
54
  do_action ("ws_plugin__s2member_before_login_header_styles", get_defined_vars ());
55
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
56
  /**/
57
- /* The !important declarations can be disabled here if you need to apply other hard-coded styles. */
58
- $important = $i = apply_filters ("ws_plugin__s2member_login_header_styles_important", " !important", get_defined_vars ());
 
 
 
 
 
 
59
  /**/
60
- if (!version_compare (get_bloginfo ("version"), "3.1-RC", ">=")) /* No longer required with WordPress® 3.1+. */
61
- {
62
- $s .= "\n" . '<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>' . "\n";
63
- $s .= '<script type="text/javascript" src="' . esc_attr (site_url ("/?ws_plugin__s2member_js_w_globals=1&amp;no-cache=" . urlencode (md5 (mt_rand ())))) . '"></script>' . "\n";
64
- }
65
  /**/
66
- $s .= "\n" . '<style type="text/css">' . "\n";
67
  /**/
68
- $s .= 'html, body { border: 0' . $i . '; background: none' . $i . '; }' . "\n"; /* Clear existing. */
69
- $s .= 'html { background-color: #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_color"] . $i . '; }' . "\n";
70
- $s .= 'html { background-image: url(' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image"] . ')' . $i . '; }' . "\n";
71
- $s .= 'html { background-repeat: ' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image_repeat"] . $i . '; }' . "\n";
72
  /**/
73
- $s .= 'body, body * { font-size: ' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_size"] . $i . '; }' . "\n";
74
- $s .= 'body, body * { font-family: ' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_family"] . $i . '; }' . "\n";
75
  /**/
76
- $s .= 'p#backtoblog a, p#backtoblog a:hover, p#backtoblog a:active, p#backtoblog a:focus { color: #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_color"] . $i . '; text-shadow: 1px 1px 3px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_shadow_color"] . $i . '; top: 15px' . $i . '; left: 15px' . $i . '; padding: 10px' . $i . '; border:1px solid #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . $i . '; background-color: #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_color"] . $i . '; -moz-border-radius:3px' . $i . '; -webkit-border-radius:3px' . $i . '; border-radius:3px' . $i . '; }' . "\n";
77
  /**/
78
- $s .= 'div#login { width: ' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_src_width"] . 'px' . $i . '; }' . "\n";
79
- $s .= 'div#login h1 a { background: url(' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_src"] . ') no-repeat top center' . $i . '; }' . "\n";
80
- $s .= 'div#login h1 a { display: block' . $i . '; width: 100%' . $i . '; height: ' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_src_height"] . 'px' . $i . '; }' . "\n";
 
 
 
81
  /**/
82
- $s .= 'div#login form { -moz-box-shadow: 1px 1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . ', -1px -1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . $i . '; -webkit-box-shadow: 1px 1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . ', -1px -1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . $i . '; box-shadow: 1px 1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . ', -1px -1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . $i . '; }' . "\n";
 
83
  /**/
84
- $s .= 'div#login p#nav, div#login p#nav a, div#login p#nav a:hover, div#login p#nav a:active, div#login p#nav a:focus { color: #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_color"] . $i . '; text-shadow: 1px 1px 3px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_shadow_color"] . $i . '; }' . "\n";
 
 
 
 
85
  /**/
86
- $s .= 'div#login form p { margin: 2px 0 16px 0' . $i . '; }' . "\n"; /* Handle margins. */
87
- $s .= 'div#login form input[type="text"].input, div#login form input[type="password"].input, div#login form input[type="text"].ws-plugin--s2member-custom-reg-field, div#login form input[type="password"].ws-plugin--s2member-custom-reg-field, div#login form textarea.ws-plugin--s2member-custom-reg-field, div#login form select.ws-plugin--s2member-custom-reg-field { font-weight:normal' . $i . '; color:#333333' . $i . '; background:none repeat scroll 0 0 #FBFBFB' . $i . '; border:1px solid #E5E5E5' . $i . '; font-size:' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_field_size"] . $i . '; margin: 0 2% 0 0' . $i . '; padding:3px' . $i . '; width:98%' . $i . '; }' . "\n";
88
- $s .= 'div#login form input[type="checkbox"].ws-plugin--s2member-custom-reg-field, div#login form input[type="radio"].ws-plugin--s2member-custom-reg-field { vertical-align:middle' . $i . '; }' . "\n";
89
- $s .= 'div#login form select.ws-plugin--s2member-custom-reg-field > option { font-size:' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_field_size"] . $i . '; }' . "\n";
90
- $s .= 'div#login form label.ws-plugin--s2member-custom-reg-field-op-l { vertical-align:middle' . $i . '; font-size:90%' . $i . '; }' . "\n";
91
- $s .= 'div#login form select.ws-plugin--s2member-custom-reg-field { width:100%' . $i . '; }' . "\n";
92
  /**/
93
- $s .= 'div#login form p.submit { margin-bottom: 0' . $i . '; }' . "\n";
94
- $s .= 'div#login form input[type="submit"], div#login form input[type="submit"]:hover, div#login form input[type="submit"]:active, div#login form input[type="submit"]:focus { color: #666666' . $i . '; text-shadow: 2px 2px 5px #EEEEEE' . $i . '; border: 1px solid #999999' . $i . '; background: #FBFBFB' . $i . '; padding: 5px' . $i . '; -moz-border-radius: 3px' . $i . '; -webkit-border-radius: 3px' . $i . '; border-radius: 3px' . $i . '; }' . "\n";
95
- $s .= 'div#login form input[type="submit"]:hover, div#login form input[type="submit"]:active, div#login form input[type="submit"]:focus { color: #000000' . $i . '; text-shadow: 2px 2px 5px #CCCCCC' . $i . '; border-color: #000000' . $i . '; }' . "\n";
96
- $s .= 'div#login form#lostpasswordform { padding-bottom: 16px' . $i . '; } div#login form#lostpasswordform p.submit { float: none' . $i . '; } div#login form#lostpasswordform input[type="submit"] { width: 100%' . $i . '; }' . "\n";
97
- $s .= 'div#login form#registerform { padding-bottom: 16px' . $i . '; } div#login form#registerform p.submit { float: none' . $i . '; margin-top: -10px' . $i . '; } div#login form#registerform input[type="submit"] { width: 100%' . $i . '; }' . "\n";
98
  /**/
99
- $s .= 'div#login form#registerform p#reg_passmail { font-style: italic' . $i . '; }' . "\n";
100
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
101
- $s .= 'p#reg_passmail { display: none' . $i . '; }' . "\n";
102
  /**/
103
- $s .= '</style>' . "\n\n";
 
104
  /**/
105
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
106
  do_action ("ws_plugin__s2member_during_login_header_styles", get_defined_vars ());
107
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
108
  /**/
 
 
 
109
  echo apply_filters ("ws_plugin__s2member_login_header_styles", $s, get_defined_vars ());
110
  /**/
111
  do_action ("ws_plugin__s2member_after_login_header_styles", get_defined_vars ());
112
  /**/
113
  return; /* Return for uniformity. */
114
  }
115
- /*
116
- Function displays Login Footer Design.
117
- Attach to: add_action("login_footer");
 
 
 
 
 
 
118
  */
119
  public static function login_footer_design ()
120
  {
1
  <?php
2
+ /**
3
+ * Login customizations.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Login_Customizations
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_login_customizations"))
21
  {
22
+ /**
23
+ * Login customizations.
24
+ *
25
+ * @package s2Member\Login_Customizations
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_login_customizations
29
  {
30
+ /**
31
+ * Filters the login/registration logo URL.
32
+ *
33
+ * @package s2Member\Login_Customizations
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_filter("login_headerurl");``
37
+ *
38
+ * @param str $url Expects a login header URL passed in by the Filter.
39
+ * @return str A URL based on s2Member's UI configuration.
40
  */
41
  public static function login_header_url ($url = FALSE)
42
  {
46
  /**/
47
  return apply_filters ("ws_plugin__s2member_login_header_url", $url, get_defined_vars ());
48
  }
49
+ /**
50
+ * Filters the login/registration logo title.
51
+ *
52
+ * @package s2Member\Login_Customizations
53
+ * @since 3.5
54
+ *
55
+ * @attaches-to: ``add_filter("login_headertitle");``
56
+ *
57
+ * @param str $title Expects a title passed in by the Filter.
58
+ * @return str A title based on s2Member's UI configuration.
59
  */
60
  public static function login_header_title ($title = FALSE)
61
  {
65
  /**/
66
  return apply_filters ("ws_plugin__s2member_login_header_title", $title, get_defined_vars ());
67
  }
68
+ /**
69
+ * Styles login/registration *( i.e. `/wp-login.php` )*.
70
+ *
71
+ * @package s2Member\Login_Customizations
72
+ * @since 3.5
73
+ *
74
+ * @attaches-to: ``add_action("login_head");``
75
+ *
76
+ * @return void
77
  */
78
  public static function login_header_styles ()
79
  {
80
+ $s = ""; /* Initialize styles string here to give Hooks a chance. */
81
+ $a = array (); /* Initialize here to give Filters a chance. */
82
  /**/
83
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
84
  do_action ("ws_plugin__s2member_before_login_header_styles", get_defined_vars ());
85
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
86
  /**/
87
+ $a[] = '<style type="text/css">'; /* Open style tag, then give Filters a chance below. */
88
+ $i = apply_filters ("ws_plugin__s2member_login_header_styles_important", " !important", get_defined_vars ());
89
+ $a = apply_filters ("ws_plugin__s2member_login_header_styles_array_after_open", $a, get_defined_vars ());
90
+ /**/
91
+ $a[] = 'html, body { border:0' . $i . '; background:none' . $i . '; }'; /* Clear existing. */
92
+ $a[] = 'html { background-color:#' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_color"] . $i . '; }';
93
+ $a[] = 'html { background-image:url(' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image"] . ')' . $i . '; }';
94
+ $a[] = 'html { background-repeat:' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_image_repeat"] . $i . '; }';
95
  /**/
96
+ $a[] = 'body, body * { font-size:' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_size"] . $i . '; }';
97
+ $a[] = 'body, body * { font-family:' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_family"] . $i . '; }';
 
 
 
98
  /**/
99
+ $a[] = 'p#backtoblog a, p#backtoblog a:hover, p#backtoblog a:active, p#backtoblog a:focus { color:#' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_color"] . $i . '; text-shadow:1px 1px 3px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_shadow_color"] . $i . '; top:15px' . $i . '; left:15px' . $i . '; padding:10px' . $i . '; border:1px solid #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . $i . '; background-color:#' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_color"] . $i . '; -moz-border-radius:3px' . $i . '; -webkit-border-radius:3px' . $i . '; border-radius:3px' . $i . '; }';
100
  /**/
101
+ $a[] = 'div#login { width:' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_src_width"] . 'px' . $i . '; }';
102
+ $a[] = 'div#login h1 a { background:url(' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_src"] . ') no-repeat top center' . $i . '; }';
103
+ $a[] = 'div#login h1 a { display:block' . $i . '; width:100%' . $i . '; height:' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_logo_src_height"] . 'px' . $i . '; }';
 
104
  /**/
105
+ $a[] = 'div#login form { -moz-box-shadow:1px 1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . ', -1px -1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . $i . '; -webkit-box-shadow:1px 1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . ', -1px -1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . $i . '; box-shadow:1px 1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . ', -1px -1px 5px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_box_shadow_color"] . $i . '; }';
 
106
  /**/
107
+ $a[] = 'div#login p#nav, div#login p#nav a, div#login p#nav a:hover, div#login p#nav a:active, div#login p#nav a:focus { color:#' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_color"] . $i . '; text-shadow:1px 1px 3px #' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_background_text_shadow_color"] . $i . '; }';
108
  /**/
109
+ $a[] = 'div#login form p { margin:2px 0 16px 0' . $i . '; }'; /* Handles paragraph margins inside the form. */
110
+ $a[] = 'div#login form input[type="text"], div#login form input[type="password"], div#login form textarea, div#login form select { font-weight:normal' . $i . '; color:#333333' . $i . '; background:none repeat scroll 0 0 #FBFBFB' . $i . '; border:1px solid #E5E5E5' . $i . '; font-size:' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_field_size"] . $i . '; margin:0' . $i . '; padding:3px' . $i . '; -moz-border-radius:3px' . $i . '; -webkit-border-radius:3px' . $i . '; border-radius:3px' . $i . '; width:100%' . $i . '; width:98%' . $i . ' !ie<8; margin-right:2%' . $i . ' !ie<8; box-sizing:border-box' . $i . '; -ms-box-sizing:border-box' . $i . '; -moz-box-sizing:border-box' . $i . '; -webkit-box-sizing:border-box' . $i . '; }';
111
+ $a[] = 'div#login form select { width:99.5%' . $i . ' !ie<8; } div#login form select > option { font-size:' . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_reg_font_field_size"] . $i . '; }';
112
+ $a[] = 'div#login form label { cursor:pointer' . $i . '; } div#login form label.ws-plugin--s2member-custom-reg-field-op-l { opacity:0.7' . $i . '; font-size:90%' . $i . '; vertical-align:middle' . $i . '; }';
113
+ $a[] = 'div#login form input[type="checkbox"], div#login form input[type="radio"] { margin:0 3px 0 0' . $i . '; vertical-align:middle' . $i . '; }';
114
+ $a[] = 'div#login form input#ws-plugin--s2member-custom-reg-field-user-pass2[type="password"] { margin-top:5px' . $i . '; }';
115
  /**/
116
+ $a[] = 'div#login form div.ws-plugin--s2member-custom-reg-field-divider-section { margin:2px 0 16px 0' . $i . '; border:0' . $i . '; height:1px' . $i . '; line-height:1px' . $i . '; background:#CCCCCC' . $i . '; }';
117
+ $a[] = 'div#login form div.ws-plugin--s2member-custom-reg-field-divider-section-title { margin:2px 0 16px 0' . $i . '; border:0 solid #CCCCCC' . $i . '; border-width:0 0 1px 0' . $i . '; padding:0 0 10px 0' . $i . '; font-size:110%' . $i . '; }';
118
  /**/
119
+ $a[] = 'div#login form p.submit { margin-bottom:0' . $i . '; }';
120
+ $a[] = 'div#login form input[type="submit"], div#login form input[type="submit"]:hover, div#login form input[type="submit"]:active, div#login form input[type="submit"]:focus { color:#666666' . $i . '; text-shadow:2px 2px 5px #EEEEEE' . $i . '; border:1px solid #999999' . $i . '; background:#FBFBFB' . $i . '; padding:5px' . $i . '; -moz-border-radius:3px' . $i . '; -webkit-border-radius:3px' . $i . '; border-radius:3px' . $i . '; }';
121
+ $a[] = 'div#login form input[type="submit"]:hover, div#login form input[type="submit"]:active, div#login form input[type="submit"]:focus { color:#000000' . $i . '; text-shadow:2px 2px 5px #CCCCCC' . $i . '; border-color:#000000' . $i . '; }';
122
+ $a[] = 'div#login form#registerform { padding-bottom:16px' . $i . '; } div#login form#registerform p.submit { float:none' . $i . '; margin-top:-10px' . $i . '; } div#login form#registerform input[type="submit"] { width:100%' . $i . '; }';
123
+ $a[] = 'div#login form#lostpasswordform { padding-bottom:16px' . $i . '; } div#login form#lostpasswordform p.submit { float:none' . $i . '; } div#login form#lostpasswordform input[type="submit"] { width:100%' . $i . '; }';
124
  /**/
125
+ $a[] = 'div.ws-plugin--s2member-password-strength { margin-top:3px' . $i . '; font-color:#000000' . $i . '; background-color:#EEEEEE' . $i . '; padding:3px' . $i . '; -moz-border-radius:3px' . $i . '; -webkit-border-radius:3px' . $i . '; border-radius:3px' . $i . '; } div.ws-plugin--s2member-password-strength-short { background-color:#FFA0A0' . $i . '; } div.ws-plugin--s2member-password-strength-bad { background-color:#FFB78C' . $i . '; } div.ws-plugin--s2member-password-strength-good { background-color:#FFEC8B' . $i . '; } div.ws-plugin--s2member-password-strength-strong { background-color:#C3FF88' . $i . '; } div.ws-plugin--s2member-password-strength-mismatch { background-color:#D6C1AB' . $i . '; }';
 
 
 
 
 
126
  /**/
127
+ $a[] = 'div#login form#registerform p#reg_passmail { font-style:italic' . $i . '; }';
 
 
 
 
128
  /**/
 
129
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
130
+ $a[] = 'p#reg_passmail { display:none' . $i . '; }';
131
  /**/
132
+ $a = apply_filters ("ws_plugin__s2member_login_header_styles_array_before_close", $a, get_defined_vars ());
133
+ $a[] = '</style>'; /* Now close style tag. There are other Filters below. */
134
  /**/
135
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
136
  do_action ("ws_plugin__s2member_during_login_header_styles", get_defined_vars ());
137
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
138
  /**/
139
+ $a = apply_filters ("ws_plugin__s2member_login_header_styles_array", $a, get_defined_vars ());
140
+ $s .= "\n" . implode ("\n", $a) . "\n\n"; /* Now put all array elements together. */
141
+ /**/
142
  echo apply_filters ("ws_plugin__s2member_login_header_styles", $s, get_defined_vars ());
143
  /**/
144
  do_action ("ws_plugin__s2member_after_login_header_styles", get_defined_vars ());
145
  /**/
146
  return; /* Return for uniformity. */
147
  }
148
+ /**
149
+ * Displays login footer design.
150
+ *
151
+ * @package s2Member\Login_Customizations
152
+ * @since 3.5
153
+ *
154
+ * @attaches-to: ``add_action("login_footer");``
155
+ *
156
+ * @return void
157
  */
158
  public static function login_footer_design ()
159
  {
includes/classes/login-redirects-r.inc.php CHANGED
@@ -1,35 +1,52 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_login_redirects_r"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_login_redirects_r
20
  {
21
- /*
22
- Removes login_redirect Filters to prevent conflicts with s2Member.
23
- Attach to: add_action("init");
 
 
 
 
 
 
24
  */
25
  public static function remove_login_redirect_filters () /* For compatibility. */
26
  {
27
  do_action ("ws_plugin__s2member_before_remove_login_redirect_filters", get_defined_vars ());
28
  /**/
29
  if (!apply_filters ("ws_plugin__s2member_allow_other_login_redirect_filters", false, get_defined_vars ()))
30
- remove_all_filters ("login_redirect"); /* Removes ALL `login_redirect` Filters. */
31
  /**/
32
  do_action ("ws_plugin__s2member_after_remove_login_redirect_filters", get_defined_vars ());
 
 
33
  }
34
  }
35
  }
1
  <?php
2
+ /**
3
+ * Login redirect removals.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Login_Redirects
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_login_redirects_r"))
21
  {
22
+ /**
23
+ * Login redirect removals.
24
+ *
25
+ * @package s2Member\Login_Redirects
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_login_redirects_r
29
  {
30
+ /**
31
+ * Removes ``login_redirect`` Filters to prevent conflicts with s2Member.
32
+ *
33
+ * @attaches-to: ``add_action("init");``
34
+ *
35
+ * @package s2Member\Login_Redirects
36
+ * @since 3.5
37
+ *
38
+ * @return null
39
  */
40
  public static function remove_login_redirect_filters () /* For compatibility. */
41
  {
42
  do_action ("ws_plugin__s2member_before_remove_login_redirect_filters", get_defined_vars ());
43
  /**/
44
  if (!apply_filters ("ws_plugin__s2member_allow_other_login_redirect_filters", false, get_defined_vars ()))
45
+ remove_all_filters("login_redirect"); /* Removes all `login_redirect` Filters. */
46
  /**/
47
  do_action ("ws_plugin__s2member_after_remove_login_redirect_filters", get_defined_vars ());
48
+ /**/
49
+ return; /* Return for uniformity. */
50
  }
51
  }
52
  }
includes/classes/login-redirects.inc.php CHANGED
@@ -1,114 +1,163 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_login_redirects"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_login_redirects
20
  {
21
- /*
22
- Handles login redirections.
23
- Attach to: add_action("wp_login");
 
 
 
 
 
 
 
24
  */
25
  public static function login_redirect ($username = FALSE)
26
  {
27
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
28
  do_action ("ws_plugin__s2member_before_login_redirect", get_defined_vars ());
29
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
30
  /**/
31
- $username = (!$username && is_object ($user = wp_get_current_user ())) ? $user->user_login : $username;
32
  /**/
33
- if ($username && (is_object ($user) || is_object ($user = new WP_User ($username))) && ($user_id = $user->ID) && (!$user->has_cap ("edit_posts") || apply_filters ("ws_plugin__s2member_login_redirect", false, get_defined_vars ())))
34
  {
35
- if ($user->has_cap ("edit_posts") || strtolower ($username) === "demo" || c_ws_plugin__s2member_ip_restrictions::ip_restrictions_ok ($_SERVER["REMOTE_ADDR"], strtolower ($username)))
 
 
 
 
 
 
 
 
 
 
 
36
  {
37
- if (!$_REQUEST["redirect_to"] || $_REQUEST["redirect_to"] === "wp-admin/" || $_REQUEST["redirect_to"] === admin_url ()) /* ?redirect_to=[value]. */
 
 
38
  {
39
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"]) /* Using custom Passwords? */
40
- {
41
- delete_user_setting ("default_password_nag"); /* `setcookie()` */
42
- update_user_option ($user_id, "default_password_nag", false, true);
43
- }
44
- /**/
45
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
46
  do_action ("ws_plugin__s2member_during_login_redirect", get_defined_vars ());
47
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
48
  /**/
49
- if ($special_redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ($user))
50
- wp_redirect($special_redirection_url); /* Special Redirection. */
 
 
 
51
  /**/
52
  else /* Else we use the Login Welcome Page configured for s2Member. */
53
- wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
54
  /**/
55
  exit (); /* Clean exit. */
56
  }
57
  }
58
  }
59
  /**/
60
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
61
  do_action ("ws_plugin__s2member_after_login_redirect", get_defined_vars ());
62
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
63
  /**/
64
  return; /* Return for uniformity. */
65
  }
66
- /*
67
- This function formulates a possible ( Special ) Login Redirection URL.
 
 
 
 
 
 
 
68
  */
69
- public static function login_redirection_url ($user = FALSE)
70
  {
71
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
72
  do_action ("ws_plugin__s2member_before_login_redirection_url", get_defined_vars ());
73
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
74
  /**/
75
- $url = c_ws_plugin__s2member_login_redirects::fill_login_redirect_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"], $user);
 
76
  /**/
77
  return apply_filters ("ws_plugin__s2member_login_redirection_url", $url, get_defined_vars ());
78
  }
79
- /*
80
- Parses the URI out of a possible ( Special ) Login Redirection URL.
 
 
 
 
 
 
 
81
  */
82
- public static function login_redirection_uri ($user = FALSE)
83
  {
84
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
85
  do_action ("ws_plugin__s2member_before_login_redirection_uri", get_defined_vars ());
86
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
87
  /**/
88
- if (! ($uri = false) && $url = c_ws_plugin__s2member_login_redirects::login_redirection_url ($user))
89
- {
90
- $path = parse_url ($url, PHP_URL_PATH);
91
- $query = parse_url ($url, PHP_URL_QUERY);
92
- $uri = ($query) ? $path . "?" . $query : $path;
93
- }
94
  /**/
95
- return apply_filters ("ws_plugin__s2member_login_redirection_uri", $uri, get_defined_vars ());
96
  }
97
- /*
98
- Fills Replacement Code variables in Special Redirection URLs.
 
 
 
 
 
 
 
 
99
  */
100
- public static function fill_login_redirect_rc_vars ($url = FALSE, $user = FALSE)
101
  {
102
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
103
  do_action ("ws_plugin__s2member_before_fill_login_redirect_rc_vars", get_defined_vars ());
104
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
105
  /**/
106
- $user = (is_object ($user) && $user->ID) ? $user : wp_get_current_user ();
107
- $user_login = (is_object ($user) && $user->ID) ? strtolower ($user->user_login) : "";
108
- $user_id = (is_object ($user) && $user->ID) ? (string)$user->ID : "";
 
 
 
 
109
  $user_level = (string)c_ws_plugin__s2member_user_access::user_access_level ($user);
110
  $user_role = (string)c_ws_plugin__s2member_user_access::user_access_role ($user);
111
- $user_ccaps = implode ("-", c_ws_plugin__s2member_user_access::user_access_ccaps ($user));
112
  /**/
113
  $url = preg_replace ("/%%current_user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_login), $url);
114
  $url = preg_replace ("/%%current_user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $url);
@@ -116,6 +165,12 @@ if (!class_exists ("c_ws_plugin__s2member_login_redirects"))
116
  $url = preg_replace ("/%%current_user_role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_role), $url);
117
  $url = preg_replace ("/%%current_user_ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_ccaps), $url);
118
  /**/
 
 
 
 
 
 
119
  return apply_filters ("ws_plugin__s2member_fill_login_redirect_rc_vars", $url, get_defined_vars ());
120
  }
121
  }
1
  <?php
2
+ /**
3
+ * Login redirections.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Login_Redirects
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_login_redirects"))
21
  {
22
+ /**
23
+ * Login redirections.
24
+ *
25
+ * @package s2Member\Login_Redirects
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_login_redirects
29
  {
30
+ /**
31
+ * Handles login redirections.
32
+ *
33
+ * @package s2Member\Login_Redirects
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_action("wp_login");``
37
+ *
38
+ * @param str $username Expects Username to be passed in by the Action Hook.
39
+ * @return null Or exits script execution after a redirection takes place.
40
  */
41
  public static function login_redirect ($username = FALSE)
42
  {
43
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
44
  do_action ("ws_plugin__s2member_before_login_redirect", get_defined_vars ());
45
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
46
  /**/
47
+ $username = (!$username && is_object ($user = wp_get_current_user ())) ? strtolower ($user->user_login) : strtolower ($username);
48
  /**/
49
+ if ($username && (is_object ($user) || is_object ($user = new WP_User ($username))) && ($user_id = $user->ID))
50
  {
51
+ if (!get_user_option ("s2member_registration_ip", $user_id)) /* Have we got this yet? */
52
+ update_user_option ($user_id, "s2member_registration_ip", $_SERVER["REMOTE_ADDR"]);
53
+ /**/
54
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"]) /* Nag em? */
55
+ delete_user_setting("default_password_nag") . update_user_option ($user_id, "default_password_nag", false, true);
56
+ /**/
57
+ $disable_login_ip_restrictions = apply_filters ("ws_plugin__s2member_disable_login_ip_restrictions", false, get_defined_vars ());
58
+ /**/
59
+ if (($ok = true) && !is_super_admin ($user_id) && $username !== "demo" && !$disable_login_ip_restrictions)
60
+ $ok = c_ws_plugin__s2member_ip_restrictions::ip_restrictions_ok ($_SERVER["REMOTE_ADDR"], $username);
61
+ /**/
62
+ if (($redirect = apply_filters ("ws_plugin__s2member_login_redirect", (($user->has_cap ("edit_posts")) ? false : true), get_defined_vars ())))
63
  {
64
+ $obey_redirect_to = apply_filters ("ws_plugin__s2member_obey_login_redirect_to", /* By default, we obey this. */ true, get_defined_vars ());
65
+ /**/
66
+ if (!$obey_redirect_to || empty ($_REQUEST["redirect_to"]) || $_REQUEST["redirect_to"] === "wp-admin/" || $_REQUEST["redirect_to"] === admin_url ())
67
  {
68
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
 
 
 
 
 
 
69
  do_action ("ws_plugin__s2member_during_login_redirect", get_defined_vars ());
70
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
71
  /**/
72
+ if ($redirect && is_string ($redirect)) /* Is this a string? */
73
+ wp_redirect($redirect); /* Dynamic URL introduced by a Filter. */
74
+ /**/
75
+ else if ($special_redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ($user))
76
+ wp_redirect($special_redirection_url); /* Special Redirection URL configured with s2Member. */
77
  /**/
78
  else /* Else we use the Login Welcome Page configured for s2Member. */
79
+ wp_redirect(get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
80
  /**/
81
  exit (); /* Clean exit. */
82
  }
83
  }
84
  }
85
  /**/
86
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
87
  do_action ("ws_plugin__s2member_after_login_redirect", get_defined_vars ());
88
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
89
  /**/
90
  return; /* Return for uniformity. */
91
  }
92
+ /**
93
+ * Parses a Special Login Redirection URL.
94
+ *
95
+ * @package s2Member\Login_Redirects
96
+ * @since 3.5
97
+ *
98
+ * @param obj $user Optional. A WP_User object. Defaults to the current User, if logged-in.
99
+ * @param bool $root_returns_false Defaults to false. True if the function should return false when a URL is reduced to the site root.
100
+ * @return str|bool A Special Login Redirection URL with Replacement Codes having been parsed, or false if ``$root_returns_false = true`` and the URL is the site root.
101
  */
102
+ public static function login_redirection_url ($user = FALSE, $root_returns_false = FALSE)
103
  {
104
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
105
  do_action ("ws_plugin__s2member_before_login_redirection_url", get_defined_vars ());
106
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
107
  /**/
108
+ $url = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"];
109
+ $url = c_ws_plugin__s2member_login_redirects::fill_login_redirect_rc_vars ($url, $user, $root_returns_false);
110
  /**/
111
  return apply_filters ("ws_plugin__s2member_login_redirection_url", $url, get_defined_vars ());
112
  }
113
+ /**
114
+ * Parses a Special Login Redirection URI.
115
+ *
116
+ * @package s2Member\Login_Redirects
117
+ * @since 3.5
118
+ *
119
+ * @param obj $user Optional. A WP_User object. Defaults to the current User, if logged-in.
120
+ * @param bool $root_returns_false Defaults to false. True if the function should return false when a URI is reduced to the site root.
121
+ * @return str|bool A Special Login Redirection URI with Replacement Codes having been parsed, or false if ``$root_returns_false = true`` and the URI is the site root.
122
  */
123
+ public static function login_redirection_uri ($user = FALSE, $root_returns_false = FALSE)
124
  {
125
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
126
  do_action ("ws_plugin__s2member_before_login_redirection_uri", get_defined_vars ());
127
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
128
  /**/
129
+ if (($url = c_ws_plugin__s2member_login_redirects::login_redirection_url ($user, $root_returns_false)))
130
+ $uri = c_ws_plugin__s2member_utils_urls::parse_uri ($url);
 
 
 
 
131
  /**/
132
+ return apply_filters ("ws_plugin__s2member_login_redirection_uri", ((!empty ($uri)) ? $uri : false), get_defined_vars ());
133
  }
134
+ /**
135
+ * Fills Replacement Codes in Special Redirection URLs.
136
+ *
137
+ * @package s2Member\Login_Redirects
138
+ * @since 3.5
139
+ *
140
+ * @param str $url A URL with possible Replacement Codes in it.
141
+ * @param obj $user Optional. A WP_User object. Defaults to the current User, if logged-in.
142
+ * @param bool $root_returns_false Defaults to false. True if the function should return false when a URL is reduced to the site root.
143
+ * @return str|bool A Special Login Redirection URL with Replacement Codes having been parsed, or false if ``$root_returns_false = true`` and the URL is the site root.
144
  */
145
+ public static function fill_login_redirect_rc_vars ($url = FALSE, $user = FALSE, $root_returns_false = FALSE)
146
  {
147
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
148
  do_action ("ws_plugin__s2member_before_fill_login_redirect_rc_vars", get_defined_vars ());
149
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
150
  /**/
151
+ $orig_url = $url; /* Record the original URL that was passed in. */
152
+ /**/
153
+ $user = ((is_object ($user) || is_object ($user = (is_user_logged_in ()) ? wp_get_current_user () : false)) && !empty ($user->ID)) ? $user : false;
154
+ /**/
155
+ $user_login = ($user) ? (string)strtolower ($user->user_login) : "";
156
+ $user_id = ($user) ? (string)$user->ID : "";
157
+ /**/
158
  $user_level = (string)c_ws_plugin__s2member_user_access::user_access_level ($user);
159
  $user_role = (string)c_ws_plugin__s2member_user_access::user_access_role ($user);
160
+ $user_ccaps = (string)implode ("-", c_ws_plugin__s2member_user_access::user_access_ccaps ($user));
161
  /**/
162
  $url = preg_replace ("/%%current_user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_login), $url);
163
  $url = preg_replace ("/%%current_user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $url);
165
  $url = preg_replace ("/%%current_user_role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_role), $url);
166
  $url = preg_replace ("/%%current_user_ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_ccaps), $url);
167
  /**/
168
+ if ( /* Only if s2Member's fault » */$url !== $orig_url && (!($parse = @parse_url ($url)) || strpos ($parse["path"], "//") !== false))
169
+ $url = site_url ("/"); /* Defaults to home page. We don't return invalid URLs produced by empty Replacement Codes ( i.e. // ). */
170
+ /**/
171
+ if ($root_returns_false /* Used by s2Member's security gate. */ && c_ws_plugin__s2member_utils_conds::is_site_root ($url))
172
+ $url = false; /* In case we need to return false on root URLs ( i.e. don't protect the Home Page inadvertently ). */
173
+ /**/
174
  return apply_filters ("ws_plugin__s2member_fill_login_redirect_rc_vars", $url, get_defined_vars ());
175
  }
176
  }
includes/classes/menu-pages-rs.inc.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Right-side for Menu Pages.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Menu_Pages
15
+ * @since 110531
16
+ */
17
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
+ /**/
20
+ if (!class_exists ("c_ws_plugin__s2member_menu_pages_rs"))
21
+ {
22
+ /**
23
+ * Right-side for Menu Pages.
24
+ *
25
+ * @package s2Member\Menu_Pages
26
+ * @since 110531
27
+ */
28
+ class c_ws_plugin__s2member_menu_pages_rs
29
+ {
30
+ /**
31
+ * Right-side for Menu Pages.
32
+ *
33
+ * @package s2Member\Menu_Pages
34
+ * @since 110531
35
+ *
36
+ * @return null
37
+ */
38
+ public static function display ()
39
+ {
40
+ do_action ("ws_plugin__s2member_during_menu_pages_before_right_sections", get_defined_vars ());
41
+ /**/
42
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["mlist"])
43
+ {
44
+ echo '<div class="ws-menu-page-mlist">' . "\n";
45
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/ws-mlist.inc.php";
46
+ echo '</div>' . "\n";
47
+ }
48
+ /**/
49
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["upsell-pro"])
50
+ {
51
+ echo '<div class="ws-menu-page-others">' . "\n";
52
+ echo '<a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Pro Module / Prices")) . '" target="_blank"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-upsell-pro.png" alt="." /></a>' . "\n";
53
+ echo '</div>' . "\n";
54
+ }
55
+ /**/
56
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["installation"])
57
+ {
58
+ echo '<div class="ws-menu-page-installation">' . "\n";
59
+ echo '<a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Professional Installation URI")) . '" target="_blank"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-installation.png" alt="." /></a>' . "\n";
60
+ echo '</div>' . "\n";
61
+ }
62
+ /**/
63
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["tools"])
64
+ {
65
+ echo '<div class="ws-menu-page-tools">' . "\n";
66
+ echo '<img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-tools.png" alt="." />' . "\n";
67
+ echo '</div>' . "\n";
68
+ }
69
+ /**/
70
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["videos"])
71
+ {
72
+ echo '<div class="ws-menu-page-videos">' . "\n";
73
+ echo '<a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Video Tutorials")) . '" target="_blank"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-videos.png" alt="." /></a>' . "\n";
74
+ echo '</div>' . "\n";
75
+ }
76
+ /**/
77
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["support"])
78
+ {
79
+ echo '<div class="ws-menu-page-support">' . "\n";
80
+ echo '<a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Forum URI")) . '" target="_blank"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-support.png" alt="." /></a>' . "\n";
81
+ echo '</div>' . "\n";
82
+ }
83
+ /**/
84
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"]["donations"])
85
+ {
86
+ echo '<div class="ws-menu-page-donations">' . "\n";
87
+ echo '<a href="' . esc_attr (c_ws_plugin__s2member_readmes::parse_readme_value ("Donate link")) . '" target="_blank"><img src="' . esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/brand-donations.png" alt="." /></a>' . "\n";
88
+ echo '</div>' . "\n";
89
+ }
90
+ /**/
91
+ do_action ("ws_plugin__s2member_during_menu_pages_after_right_sections", get_defined_vars ());
92
+ /**/
93
+ return; /* Return for uniformity. */
94
+ }
95
+ }
96
+ }
97
+ ?>
includes/classes/menu-pages.inc.php CHANGED
@@ -1,36 +1,56 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_menu_pages
20
  {
21
- /*
22
- Saves all options from any page.
23
- Options can also be passed in directly.
24
- Can also be self-verified.
 
 
 
 
 
 
 
 
 
 
 
25
  */
26
  public static function update_all_options ($new_options = FALSE, $verified = FALSE, $update_other = TRUE, $display_notices = TRUE, $enqueue_notices = FALSE, $request_refresh = FALSE)
27
  {
28
  do_action ("ws_plugin__s2member_before_update_all_options", get_defined_vars ()); /* If you use this Hook, be sure to use `wp_verify_nonce()`. */
29
  /**/
30
- if ($verified || ( ($nonce = $_POST["ws_plugin__s2member_options_save"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-options-save")))
31
  {
32
  $options = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]; /* Here we get all of the existing options. */
33
- $new_options = (is_array ($new_options)) ? $new_options : (array)$_POST; /* Force array. */
34
  $new_options = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($new_options));
35
  /**/
36
  foreach ((array)$new_options as $key => $value) /* Looking for relevant keys. */
@@ -48,7 +68,7 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
48
  $options[$key] = $value; /* Overriding a possible existing option. */
49
  }
50
  /**/
51
- $options["options_version"] = (string) ($options["options_version"] + 0.001);
52
  $options = ws_plugin__s2member_configure_options_and_their_defaults ($options);
53
  /**/
54
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
@@ -63,7 +83,7 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
63
  if (($display_notices === true || in_array ("success", (array)$display_notices)) && ($notice = '<strong>Options saved.' . (($request_refresh) ? ' Please <a href="' . esc_attr ($_SERVER["REQUEST_URI"]) . '">refresh</a>.' : '') . '</strong>'))
64
  ($enqueue_notices === true || in_array ("success", (array)$enqueue_notices)) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "*:*") : c_ws_plugin__s2member_admin_notices::display_admin_notice ($notice);
65
  /**/
66
- if ($_GET["page"] !== "ws-plugin--s2member-mms-options") /* Do NOT display page-conflict-warnings on the Main Multisite Configuration panel. */
67
  {
68
  if (!$options["membership_options_page"] && ($display_notices === true || in_array ("page-conflict-warnings", (array)$display_notices)) && ($notice = '<strong>NOTE:</strong> s2Member security restrictions will NOT be enforced until you\'ve configured a Membership Options Page. See: <code>s2Member -> General Options -> Membership Options Page</code>.'))
69
  ($enqueue_notices === true || in_array ("page-conflict-warnings", (array)$enqueue_notices)) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "*:*", true) : c_ws_plugin__s2member_admin_notices::display_admin_notice ($notice, true);
@@ -92,11 +112,17 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
92
  /**/
93
  do_action ("ws_plugin__s2member_after_update_all_options", get_defined_vars ());
94
  /**/
95
- return $updated_all_options; /* Return status update. */
96
  }
97
- /*
98
- Adds the options menus & sub-menus.
99
- Attach to: add_action("admin_menu");
 
 
 
 
 
 
100
  */
101
  public static function add_admin_options ()
102
  {
@@ -107,30 +133,42 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
107
  if (apply_filters ("ws_plugin__s2member_during_add_admin_options_create_menu_items", true, get_defined_vars ()))
108
  {
109
  if ((is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ()) || apply_filters ("ws_plugin__s2member_during_add_admin_options_clear_right_side", false, get_defined_vars ()))
110
- foreach ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"] as &$right_side)
111
- $right_side = false; /* Clear right side. */
112
  /**/
113
- if (is_multisite () && is_main_site ()) /* Re-organize menu whenever Multisite Networking is enabled; and we're on the Main Site. */
114
- {
115
- $menu = "ws-plugin--s2member-mms-options"; /* Used below for nesting additional sub-menu pages. */
116
- /**/
117
- add_menu_page ("s2Member Options", "s2Member", "create_users", $menu, "c_ws_plugin__s2member_menu_pages::mms_options_page", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images/brand-favicon.png");
118
- /**/
119
- add_submenu_page ($menu, "s2Member Multisite ( Configuration )", "Multisite (Config)", "create_users", "ws-plugin--s2member-mms-options", "c_ws_plugin__s2member_menu_pages::mms_options_page");
120
- add_submenu_page ($menu, "s2Member General Options", "General Options", "create_users", "ws-plugin--s2member-options", "c_ws_plugin__s2member_menu_pages::options_page");
121
- }
122
- else /* Otherwise, we use the standard menu configuration here. The parent menu is the General Options for s2Member in this case. */
123
- {
124
- $menu = "ws-plugin--s2member-options"; /* Used below for nesting additional sub-menu pages. */
125
- /**/
126
- add_menu_page ("s2Member Options", "s2Member", "create_users", $menu, "c_ws_plugin__s2member_menu_pages::options_page", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images/brand-favicon.png");
127
- /**/
128
- add_submenu_page ($menu, "s2Member General Options", "General Options", "create_users", "ws-plugin--s2member-options", "c_ws_plugin__s2member_menu_pages::options_page");
129
- (!is_multisite ()) ? add_submenu_page ($menu, "s2Member Multisite ( NOT enabled )", "Multisite Config", "create_users", "ws-plugin--s2member-mms-options", "c_ws_plugin__s2member_menu_pages::mms_options_page") : null;
130
- }
 
 
 
 
 
 
 
131
  /**/
132
  if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_new_user_page", true, get_defined_vars ())) /* Shortcut. */
133
- add_submenu_page ($menu, "s2Member / Add A Member", "Add A Member", "create_users", "user-new.php"); /* Shortcut to user-new.php. */
 
 
 
 
 
 
134
  /**/
135
  if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_paypal_ops_page", true, get_defined_vars ()))
136
  add_submenu_page ($menu, "s2Member PayPal Options", "PayPal® Options", "create_users", "ws-plugin--s2member-paypal-ops", "c_ws_plugin__s2member_menu_pages::paypal_ops_page");
@@ -138,8 +176,8 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
138
  if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_paypal_buttons_page", true, get_defined_vars ()))
139
  add_submenu_page ($menu, "s2Member PayPal® Buttons", "PayPal® Buttons", "create_users", "ws-plugin--s2member-paypal-buttons", "c_ws_plugin__s2member_menu_pages::paypal_buttons_page");
140
  /**/
141
- if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_down_ops_page", (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()), get_defined_vars ()))
142
- add_submenu_page ($menu, "s2Member File Download Options", "Download Options", "create_users", "ws-plugin--s2member-down-ops", "c_ws_plugin__s2member_menu_pages::down_ops_page");
143
  /**/
144
  if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_trk_ops_page", true, get_defined_vars ()))
145
  add_submenu_page ($menu, "s2Member API / Tracking", "API / Tracking", "create_users", "ws-plugin--s2member-trk-ops", "c_ws_plugin__s2member_menu_pages::trk_ops_page");
@@ -153,23 +191,34 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
153
  if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_scripting_page", true, get_defined_vars ()))
154
  add_submenu_page ($menu, "s2Member API / Scripting", "API / Scripting", "create_users", "ws-plugin--s2member-scripting", "c_ws_plugin__s2member_menu_pages::scripting_page");
155
  /**/
156
- if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_bridges_page", (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()), get_defined_vars ()))
157
- add_submenu_page ($menu, "s2Member Bridge Integrations", "API / Bridges", "create_users", "ws-plugin--s2member-bridges", "c_ws_plugin__s2member_menu_pages::bridges_page");
 
 
 
 
 
 
158
  /**/
159
  if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_info_page", (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()), get_defined_vars ()))
160
  add_submenu_page ($menu, "s2Member Information", "s2Member Info", "create_users", "ws-plugin--s2member-info", "c_ws_plugin__s2member_menu_pages::info_page");
161
  /**/
162
- if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_start_page", true, get_defined_vars ()))
163
- add_submenu_page ($menu, "s2Member Quick-Start Guide", "Quick-Start Guide", "create_users", "ws-plugin--s2member-start", "c_ws_plugin__s2member_menu_pages::start_page");
164
  }
165
  /**/
166
  do_action ("ws_plugin__s2member_after_add_admin_options", get_defined_vars ());
167
  /**/
168
  return; /* Return for uniformity. */
169
  }
170
- /*
171
- Adds the options menus & sub-menus.
172
- Attach to: add_action("network_admin_menu");
 
 
 
 
 
 
173
  */
174
  public static function add_network_admin_options ()
175
  {
@@ -177,27 +226,38 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
177
  /**/
178
  if (apply_filters ("ws_plugin__s2member_during_add_network_admin_options_create_menu_items", true, get_defined_vars ()))
179
  {
180
- if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ())
181
  $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"] = array (); /* Clear right side. */
182
  /**/
183
- $menu = "ws-plugin--s2member-mms-options"; /* Used below for nesting additional sub-menu pages. */
184
  /**/
185
- add_menu_page ("s2Member Options", "s2Member", "create_users", $menu, "c_ws_plugin__s2member_menu_pages::mms_options_page", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images/brand-favicon.png");
186
  /**/
187
- add_submenu_page ($menu, "s2Member Multisite ( Configuration )", "Multisite (Config)", "create_users", "ws-plugin--s2member-mms-options", "c_ws_plugin__s2member_menu_pages::mms_options_page");
188
  /**/
189
  if (apply_filters ("ws_plugin__s2member_during_add_network_admin_options_add_info_page", (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()), get_defined_vars ()))
190
  add_submenu_page ($menu, "s2Member Information", "s2Member Info", "create_users", "ws-plugin--s2member-info", "c_ws_plugin__s2member_menu_pages::info_page");
 
 
191
  }
192
  /**/
193
  do_action ("ws_plugin__s2member_after_add_network_admin_options", get_defined_vars ());
194
  /**/
195
  return; /* Return for uniformity. */
196
  }
197
- /*
198
- A sort of callback function to add the settings link.
 
 
 
 
 
 
 
 
 
199
  */
200
- public static function _add_settings_link ($links = array (), $file = "")
201
  {
202
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
203
  do_action ("_ws_plugin__s2member_before_add_settings_link", get_defined_vars ());
@@ -205,7 +265,7 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
205
  /**/
206
  if (preg_match ("/" . preg_quote ($file, "/") . "$/", $GLOBALS["WS_PLUGIN__"]["s2member"]["l"]) && is_array ($links))
207
  {
208
- $settings = '<a href="' . esc_attr (admin_url ("/admin.php?page=ws-plugin--s2member-options")) . '">Settings</a>';
209
  array_unshift ($links, apply_filters ("ws_plugin__s2member_add_settings_link", $settings, get_defined_vars ()));
210
  /**/
211
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
@@ -215,15 +275,21 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
215
  /**/
216
  return apply_filters ("_ws_plugin__s2member_add_settings_link", $links, get_defined_vars ());
217
  }
218
- /*
219
- Add scripts to admin panels.
220
- Attach to: add_action("admin_print_scripts");
 
 
 
 
 
 
221
  */
222
  public static function add_admin_scripts ()
223
  {
224
  do_action ("ws_plugin__s2member_before_add_admin_scripts", get_defined_vars ());
225
  /**/
226
- if ($_GET["page"] && preg_match ("/ws-plugin--s2member-/", $_GET["page"]))
227
  {
228
  wp_enqueue_script ("jquery");
229
  wp_enqueue_script ("thickbox");
@@ -231,7 +297,7 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
231
  wp_enqueue_script ("jquery-ui-core");
232
  wp_enqueue_script ("jquery-json-ps", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/includes/menu-pages/jquery-json-ps-min.js", array ("jquery"), c_ws_plugin__s2member_utilities::ver_checksum ());
233
  wp_enqueue_script ("jquery-ui-effects", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/includes/menu-pages/jquery-ui-effects.js", array ("jquery", "jquery-ui-core"), c_ws_plugin__s2member_utilities::ver_checksum ());
234
- wp_enqueue_script ("ws-plugin--s2member-menu-pages", site_url ("/?ws_plugin__s2member_menu_pages_js=" . urlencode (mt_rand ())), array ("jquery", "thickbox", "media-upload", "jquery-json-ps", "jquery-ui-core", "jquery-ui-effects"), c_ws_plugin__s2member_utilities::ver_checksum ());
235
  /**/
236
  do_action ("ws_plugin__s2member_during_add_admin_scripts", get_defined_vars ());
237
  }
@@ -240,15 +306,21 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
240
  /**/
241
  return; /* Return for uniformity. */
242
  }
243
- /*
244
- Add styles to admin panels.
245
- Attach to: add_action("admin_print_styles");
 
 
 
 
 
 
246
  */
247
  public static function add_admin_styles ()
248
  {
249
  do_action ("ws_plugin__s2member_before_add_admin_styles", get_defined_vars ());
250
  /**/
251
- if ($_GET["page"] && preg_match ("/ws-plugin--s2member-/", $_GET["page"]))
252
  {
253
  wp_enqueue_style ("thickbox");
254
  wp_enqueue_style ("ws-plugin--s2member-menu-pages", site_url ("/?ws_plugin__s2member_menu_pages_css=" . urlencode (mt_rand ())), array ("thickbox"), c_ws_plugin__s2member_utilities::ver_checksum (), "all");
@@ -260,48 +332,95 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
260
  /**/
261
  return; /* Return for uniformity. */
262
  }
263
- /*
264
- Builds and handles the Main Multisite Options page.
 
 
 
 
 
265
  */
266
- public static function mms_options_page ()
267
  {
268
- global $current_site, $current_blog; /* Multisite Networking. */
269
  /**/
270
- do_action ("ws_plugin__s2member_before_mms_options_page", get_defined_vars ());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  /**/
272
  if (c_ws_plugin__s2member_menu_pages::update_all_options ())
273
  c_ws_plugin__s2member_mms_patches::mms_patches (true);
274
  /**/
275
- include_once dirname (dirname (__FILE__)) . "/menu-pages/mms-options.inc.php";
276
  /**/
277
- do_action ("ws_plugin__s2member_after_mms_options_page", get_defined_vars ());
278
  /**/
279
  return; /* Return for uniformity. */
280
  }
281
- /*
282
- Builds and handles the General Options page.
 
 
 
 
 
283
  */
284
- public static function options_page ()
285
  {
286
- global $current_site, $current_blog; /* Multisite Networking. */
 
 
287
  /**/
288
- do_action ("ws_plugin__s2member_before_options_page", get_defined_vars ());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
  /**/
290
  c_ws_plugin__s2member_menu_pages::update_all_options ();
291
  /**/
292
- include_once dirname (dirname (__FILE__)) . "/menu-pages/options.inc.php";
293
  /**/
294
- do_action ("ws_plugin__s2member_after_options_page", get_defined_vars ());
295
  /**/
296
  return; /* Return for uniformity. */
297
  }
298
- /*
299
- Builds and handles the Paypal Options page.
 
 
 
 
 
300
  */
301
  public static function paypal_ops_page ()
302
  {
303
- global $current_site, $current_blog; /* Multisite Networking. */
304
- /**/
305
  do_action ("ws_plugin__s2member_before_paypal_ops_page", get_defined_vars ());
306
  /**/
307
  c_ws_plugin__s2member_menu_pages::update_all_options ();
@@ -337,17 +456,23 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
337
  /**/
338
  return; /* Return for uniformity. */
339
  }
340
- /*
341
- Builds and handles the Download Options page.
 
 
 
 
 
342
  */
343
  public static function down_ops_page ()
344
  {
345
- global $current_site, $current_blog; /* Multisite Networking. */
346
- /**/
347
  do_action ("ws_plugin__s2member_before_down_ops_page", get_defined_vars ());
348
  /**/
349
  c_ws_plugin__s2member_menu_pages::update_all_options ();
350
  /**/
 
 
 
351
  $files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"];
352
  /**/
353
  if (!is_dir ($files_dir) && is_writable (dirname (c_ws_plugin__s2member_utils_dirs::strip_dir_app_data ($files_dir))))
@@ -358,13 +483,13 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
358
  if (is_dir ($files_dir) && is_writable ($files_dir) && !file_exists ($htaccess))
359
  file_put_contents ($htaccess, "deny from all") . clearstatcache ();
360
  /**/
361
- if (!is_dir ($files_dir)) /* If the security-enabled files directory does not exist yet. */
362
  c_ws_plugin__s2member_admin_notices::display_admin_notice ("The security-enabled files directory ( <code>" . esc_html (preg_replace ("/^" . preg_quote ($_SERVER["DOCUMENT_ROOT"], "/") . "/", "", $files_dir)) . "</code> ) does not exist. Please create this directory manually.", true);
363
  /**/
364
- if (!file_exists ($htaccess)) /* If the .htaccess file has not been created yet. */
365
  c_ws_plugin__s2member_admin_notices::display_admin_notice ("The .htaccess protection file ( <code>" . esc_html (preg_replace ("/^" . preg_quote ($_SERVER["DOCUMENT_ROOT"], "/") . "/", "", $htaccess)) . "</code> ) does not exist. Please create this file manually. Inside your .htaccess file, add this one line: <code>deny from all</code>.", true);
366
  /**/
367
- else if (!preg_match ("/deny from all/i", file_get_contents ($htaccess))) /* Else if the .htaccess file does not offer the required protection. */
368
  c_ws_plugin__s2member_admin_notices::display_admin_notice ("Unprotected. The .htaccess protection file ( <code>" . esc_html (preg_replace ("/^" . preg_quote ($_SERVER["DOCUMENT_ROOT"], "/") . "/", "", $htaccess)) . "</code> ) does not contain <code>deny from all</code>. Inside your .htaccess file, add this one line: <code>deny from all</code>.", true);
369
  /**/
370
  include_once dirname (dirname (__FILE__)) . "/menu-pages/down-ops.inc.php";
@@ -373,13 +498,16 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
373
  /**/
374
  return; /* Return for uniformity. */
375
  }
376
- /*
377
- Builds and handles the API Tracking options page.
 
 
 
 
 
378
  */
379
  public static function trk_ops_page ()
380
  {
381
- global $current_site, $current_blog; /* Multisite Networking. */
382
- /**/
383
  do_action ("ws_plugin__s2member_before_trk_ops_page", get_defined_vars ());
384
  /**/
385
  c_ws_plugin__s2member_menu_pages::update_all_options ();
@@ -390,13 +518,16 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
390
  /**/
391
  return; /* Return for uniformity. */
392
  }
393
- /*
394
- Builds and handles the API List Server options page.
 
 
 
 
 
395
  */
396
  public static function els_ops_page ()
397
  {
398
- global $current_site, $current_blog; /* Multisite Networking. */
399
- /**/
400
  do_action ("ws_plugin__s2member_before_els_ops_page", get_defined_vars ());
401
  /**/
402
  c_ws_plugin__s2member_menu_pages::update_all_options ();
@@ -407,13 +538,16 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
407
  /**/
408
  return; /* Return for uniformity. */
409
  }
410
- /*
411
- Builds and handles the API Notifications page.
 
 
 
 
 
412
  */
413
  public static function api_ops_page ()
414
  {
415
- global $current_site, $current_blog; /* Multisite Networking. */
416
- /**/
417
  do_action ("ws_plugin__s2member_before_api_ops_page", get_defined_vars ());
418
  /**/
419
  c_ws_plugin__s2member_menu_pages::update_all_options ();
@@ -424,13 +558,16 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
424
  /**/
425
  return; /* Return for uniformity. */
426
  }
427
- /*
428
- Builds and handles the PayPal Button Generator page.
 
 
 
 
 
429
  */
430
  public static function paypal_buttons_page ()
431
  {
432
- global $current_site, $current_blog; /* Multisite Networking. */
433
- /**/
434
  do_action ("ws_plugin__s2member_before_paypal_buttons_page", get_defined_vars ());
435
  /**/
436
  if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_username"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_password"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_signature"])
@@ -442,13 +579,16 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
442
  /**/
443
  return; /* Return for uniformity. */
444
  }
445
- /*
446
- Builds and handles the API Scripting page.
 
 
 
 
 
447
  */
448
  public static function scripting_page ()
449
  {
450
- global $current_site, $current_blog; /* Multisite Networking. */
451
- /**/
452
  do_action ("ws_plugin__s2member_before_scripting_page", get_defined_vars ());
453
  /**/
454
  include_once dirname (dirname (__FILE__)) . "/menu-pages/scripting.inc.php";
@@ -457,22 +597,23 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
457
  /**/
458
  return; /* Return for uniformity. */
459
  }
460
- /*
461
- Builds and handles the Bridge Integrations page.
 
 
 
 
 
462
  */
463
- public static function bridges_page ()
464
  {
465
- global $current_site, $current_blog; /* Multisite Networking. */
466
- /**/
467
- do_action ("ws_plugin__s2member_before_bridges_page", get_defined_vars ());
468
  /**/
469
- if (($nonce = $_POST["ws_plugin__s2member_bridge_bbpress"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-bridge-bbpress"))
470
  {
471
- $_p = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)); /* Trim/strip all _POST vars. */
472
- /**/
473
- if (($plugins_dir = untrailingslashit ($_p["ws_plugin__s2member_bridge_bbpress_plugins_dir"])) && is_dir ($plugins_dir))
474
  {
475
- if (is_writable ($plugins_dir)) /* This directory MUST be writable. Otherwise, we cannot continue. */
476
  {
477
  if (preg_match ("/^Install/i", $_p["ws_plugin__s2member_bridge_bbpress_action"]))
478
  {
@@ -507,27 +648,22 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
507
  c_ws_plugin__s2member_admin_notices::display_admin_notice ("The directory you specified does NOT exist. Please try again, or install manually.", true);
508
  }
509
  /**/
510
- if (!is_dir ($plugins_dir_guess = untrailingslashit ($_SERVER["DOCUMENT_ROOT"]) . "/bbpress/my-plugins"))
511
- if (!is_dir ($plugins_dir_guess = untrailingslashit ($_SERVER["DOCUMENT_ROOT"]) . "/forums/my-plugins"))
512
- if (!is_dir ($plugins_dir_guess = untrailingslashit ($_SERVER["DOCUMENT_ROOT"]) . "/bbpress/bb-plugins"))
513
- if (!is_dir ($plugins_dir_guess = untrailingslashit ($_SERVER["DOCUMENT_ROOT"]) . "/forums/bb-plugins"))
514
- $plugins_dir_guess = ($plugins_dir) ? $plugins_dir : $plugins_dir_guess;
515
- /**/
516
- $_bridge_bbpress_plugins_dir_guess = ($plugins_dir) ? $plugins_dir : $plugins_dir_guess;
517
- /**/
518
- include_once dirname (dirname (__FILE__)) . "/menu-pages/bridges.inc.php";
519
  /**/
520
- do_action ("ws_plugin__s2member_after_bridges_page", get_defined_vars ());
521
  /**/
522
  return; /* Return for uniformity. */
523
  }
524
- /*
525
- Builds and handles the s2Member Info page.
 
 
 
 
 
526
  */
527
  public static function info_page ()
528
  {
529
- global $current_site, $current_blog; /* Multisite Networking. */
530
- /**/
531
  do_action ("ws_plugin__s2member_before_info_page", get_defined_vars ());
532
  /**/
533
  include_once dirname (dirname (__FILE__)) . "/menu-pages/info.inc.php";
@@ -536,21 +672,6 @@ if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
536
  /**/
537
  return; /* Return for uniformity. */
538
  }
539
- /*
540
- Builds and handles the Quick Start page.
541
- */
542
- public static function start_page ()
543
- {
544
- global $current_site, $current_blog; /* Multisite Networking. */
545
- /**/
546
- do_action ("ws_plugin__s2member_before_start_page", get_defined_vars ());
547
- /**/
548
- include_once dirname (dirname (__FILE__)) . "/menu-pages/start.inc.php";
549
- /**/
550
- do_action ("ws_plugin__s2member_after_start_page", get_defined_vars ());
551
- /**/
552
- return; /* Return for uniformity. */
553
- }
554
  }
555
  }
556
  ?>
1
  <?php
2
+ /**
3
+ * Administrative menu pages.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Menu_Pages
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_menu_pages"))
21
  {
22
+ /**
23
+ * Administrative menu pages.
24
+ *
25
+ * @package s2Member\Menu_Pages
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_menu_pages
29
  {
30
+ /**
31
+ * Saves all options from any menu page.
32
+ *
33
+ * Can also be self-verified; and configured extensively with function parameters.
34
+ *
35
+ * @package s2Member\Menu_Pages
36
+ * @since 3.5
37
+ *
38
+ * @param array $new_options Optional. Force feed an array of new options. Defaults to ``$_POST`` vars.
39
+ * @param bool $verified Optional. Defaults to false. If true, ``wp_verify_nonce()`` is skipped in this routine.
40
+ * @param bool $update_other Optional. Defaults to true. If false, other option-dependent routines will not be processed.
41
+ * @param bool|array $display_notices Optional. Defaults to true. Can be false, or an array of certain notices that can be displayed.
42
+ * @param bool|array $enqueue_notices Optional. Defaults to false. Can be true, or an array of certain notices that should be enqueued.
43
+ * @param bool $request_refresh Optional. Defaults to false. If true, resulting `success` notice will include a link to refresh the menu page.
44
+ * @return bool True if options were updated successfully.
45
  */
46
  public static function update_all_options ($new_options = FALSE, $verified = FALSE, $update_other = TRUE, $display_notices = TRUE, $enqueue_notices = FALSE, $request_refresh = FALSE)
47
  {
48
  do_action ("ws_plugin__s2member_before_update_all_options", get_defined_vars ()); /* If you use this Hook, be sure to use `wp_verify_nonce()`. */
49
  /**/
50
+ if ($verified || (!empty ($_POST["ws_plugin__s2member_options_save"]) && ($nonce = $_POST["ws_plugin__s2member_options_save"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-options-save")))
51
  {
52
  $options = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]; /* Here we get all of the existing options. */
53
+ $new_options = (is_array ($new_options)) ? $new_options : ((!empty ($_POST)) ? $_POST : array ());
54
  $new_options = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($new_options));
55
  /**/
56
  foreach ((array)$new_options as $key => $value) /* Looking for relevant keys. */
68
  $options[$key] = $value; /* Overriding a possible existing option. */
69
  }
70
  /**/
71
+ $options["options_version"] = (string)($options["options_version"] + 0.001);
72
  $options = ws_plugin__s2member_configure_options_and_their_defaults ($options);
73
  /**/
74
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
83
  if (($display_notices === true || in_array ("success", (array)$display_notices)) && ($notice = '<strong>Options saved.' . (($request_refresh) ? ' Please <a href="' . esc_attr ($_SERVER["REQUEST_URI"]) . '">refresh</a>.' : '') . '</strong>'))
84
  ($enqueue_notices === true || in_array ("success", (array)$enqueue_notices)) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "*:*") : c_ws_plugin__s2member_admin_notices::display_admin_notice ($notice);
85
  /**/
86
+ if ($_GET["page"] !== "ws-plugin--s2member-mms-ops") /* Do NOT display page-conflict-warnings on the Main Multisite Configuration panel. */
87
  {
88
  if (!$options["membership_options_page"] && ($display_notices === true || in_array ("page-conflict-warnings", (array)$display_notices)) && ($notice = '<strong>NOTE:</strong> s2Member security restrictions will NOT be enforced until you\'ve configured a Membership Options Page. See: <code>s2Member -> General Options -> Membership Options Page</code>.'))
89
  ($enqueue_notices === true || in_array ("page-conflict-warnings", (array)$enqueue_notices)) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice ($notice, "*:*", true) : c_ws_plugin__s2member_admin_notices::display_admin_notice ($notice, true);
112
  /**/
113
  do_action ("ws_plugin__s2member_after_update_all_options", get_defined_vars ());
114
  /**/
115
+ return isset ($updated_all_options) ? $updated_all_options : false;
116
  }
117
+ /**
118
+ * Adds option menus / sub-menus.
119
+ *
120
+ * @package s2Member\Menu_Pages
121
+ * @since 3.5
122
+ *
123
+ * @attaches-to: ``add_action("admin_menu");``
124
+ *
125
+ * @return null
126
  */
127
  public static function add_admin_options ()
128
  {
133
  if (apply_filters ("ws_plugin__s2member_during_add_admin_options_create_menu_items", true, get_defined_vars ()))
134
  {
135
  if ((is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ()) || apply_filters ("ws_plugin__s2member_during_add_admin_options_clear_right_side", false, get_defined_vars ()))
136
+ $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"] = array (); /* Clear right side. */
 
137
  /**/
138
+ $menu = apply_filters ("ws_plugin__s2member_during_add_admin_options_menu_slug", "ws-plugin--s2member-start", get_defined_vars ());
139
+ /**/
140
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_menu_page", true, get_defined_vars ()))
141
+ add_menu_page ("s2Member®", "s2Member®", "create_users", $menu, "c_ws_plugin__s2member_menu_pages::start_page", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images/brand-favicon.png");
142
+ /**/
143
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_start_page", true, get_defined_vars ()))
144
+ add_submenu_page ($menu, "s2Member Quick-Start Guide", "Quick-Start Guide", "create_users", "ws-plugin--s2member-start", "c_ws_plugin__s2member_menu_pages::start_page");
145
+ /**/
146
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_divider_1", true, get_defined_vars ())) /* Divider. */
147
+ add_submenu_page ($menu, "-", '<div style="margin:1px 0 1px -5px; height:1px; line-height:1px; background:#CCCCCC;"></div>', "create_users", "#");
148
+ /**/
149
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_mms_ops_page", (!is_multisite () || is_main_site ()), get_defined_vars ()))
150
+ add_submenu_page ($menu, "s2Member Multisite Configuration", "Multisite (Config)", "create_users", "ws-plugin--s2member-mms-ops", "c_ws_plugin__s2member_menu_pages::mms_ops_page");
151
+ /**/
152
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_gen_ops_page", true, get_defined_vars ()))
153
+ add_submenu_page ($menu, "s2Member General Options", "General Options", "create_users", "ws-plugin--s2member-gen-ops", "c_ws_plugin__s2member_menu_pages::gen_ops_page");
154
+ /**/
155
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_res_ops_page", true, get_defined_vars ()))
156
+ add_submenu_page ($menu, "s2Member Restriction Options", "Restriction Options", "create_users", "ws-plugin--s2member-res-ops", "c_ws_plugin__s2member_menu_pages::res_ops_page");
157
+ /**/
158
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_down_ops_page", (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()), get_defined_vars ()))
159
+ add_submenu_page ($menu, "s2Member Download Options", "Download Options", "create_users", "ws-plugin--s2member-down-ops", "c_ws_plugin__s2member_menu_pages::down_ops_page");
160
+ /**/
161
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_divider_2", true, get_defined_vars ())) /* Divider. */
162
+ add_submenu_page ($menu, "-", '<div style="margin:1px 0 1px -5px; height:1px; line-height:1px; background:#CCCCCC;"></div>', "create_users", "#");
163
  /**/
164
  if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_new_user_page", true, get_defined_vars ())) /* Shortcut. */
165
+ add_submenu_page ($menu, "s2Member / Add A Member", "Add A Member", "create_users", "user-new.php");
166
+ /**/
167
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_browse_users_page", true, get_defined_vars ())) /* Shortcut. */
168
+ add_submenu_page ($menu, "s2Member / Browse Members", "Browse Members", "create_users", "users.php");
169
+ /**/
170
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_divider_3", true, get_defined_vars ())) /* Divider. */
171
+ add_submenu_page ($menu, "-", '<div style="margin:1px 0 1px -5px; height:1px; line-height:1px; background:#CCCCCC;"></div>', "create_users", "#");
172
  /**/
173
  if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_paypal_ops_page", true, get_defined_vars ()))
174
  add_submenu_page ($menu, "s2Member PayPal Options", "PayPal® Options", "create_users", "ws-plugin--s2member-paypal-ops", "c_ws_plugin__s2member_menu_pages::paypal_ops_page");
176
  if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_paypal_buttons_page", true, get_defined_vars ()))
177
  add_submenu_page ($menu, "s2Member PayPal® Buttons", "PayPal® Buttons", "create_users", "ws-plugin--s2member-paypal-buttons", "c_ws_plugin__s2member_menu_pages::paypal_buttons_page");
178
  /**/
179
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_divider_4", true, get_defined_vars ())) /* Divider. */
180
+ add_submenu_page ($menu, "-", '<div style="margin:1px 0 1px -5px; height:1px; line-height:1px; background:#CCCCCC;"></div>', "create_users", "#");
181
  /**/
182
  if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_trk_ops_page", true, get_defined_vars ()))
183
  add_submenu_page ($menu, "s2Member API / Tracking", "API / Tracking", "create_users", "ws-plugin--s2member-trk-ops", "c_ws_plugin__s2member_menu_pages::trk_ops_page");
191
  if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_scripting_page", true, get_defined_vars ()))
192
  add_submenu_page ($menu, "s2Member API / Scripting", "API / Scripting", "create_users", "ws-plugin--s2member-scripting", "c_ws_plugin__s2member_menu_pages::scripting_page");
193
  /**/
194
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_divider_5", true, get_defined_vars ())) /* Divider. */
195
+ add_submenu_page ($menu, "-", '<div style="margin:1px 0 1px -5px; height:1px; line-height:1px; background:#CCCCCC;"></div>', "create_users", "#");
196
+ /**/
197
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_integrations_page", (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()), get_defined_vars ()))
198
+ add_submenu_page ($menu, "s2Member / Other Integrations", "Other Integrations", "create_users", "ws-plugin--s2member-integrations", "c_ws_plugin__s2member_menu_pages::integrations_page");
199
+ /**/
200
+ if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_divider_6", true, get_defined_vars ())) /* Divider. */
201
+ add_submenu_page ($menu, "-", '<div style="margin:1px 0 1px -5px; height:1px; line-height:1px; background:#CCCCCC;"></div>', "create_users", "#");
202
  /**/
203
  if (apply_filters ("ws_plugin__s2member_during_add_admin_options_add_info_page", (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()), get_defined_vars ()))
204
  add_submenu_page ($menu, "s2Member Information", "s2Member Info", "create_users", "ws-plugin--s2member-info", "c_ws_plugin__s2member_menu_pages::info_page");
205
  /**/
206
+ do_action ("ws_plugin__s2member_during_add_admin_options_additional_pages", get_defined_vars ());
 
207
  }
208
  /**/
209
  do_action ("ws_plugin__s2member_after_add_admin_options", get_defined_vars ());
210
  /**/
211
  return; /* Return for uniformity. */
212
  }
213
+ /**
214
+ * Adds network option menus / sub-menus.
215
+ *
216
+ * @package s2Member\Menu_Pages
217
+ * @since 3.5
218
+ *
219
+ * @attaches-to: ``add_action("network_admin_menu");``
220
+ *
221
+ * @return null
222
  */
223
  public static function add_network_admin_options ()
224
  {
226
  /**/
227
  if (apply_filters ("ws_plugin__s2member_during_add_network_admin_options_create_menu_items", true, get_defined_vars ()))
228
  {
229
+ if ((is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ()) || apply_filters ("ws_plugin__s2member_during_add_network_admin_options_clear_right_side", false, get_defined_vars ()))
230
  $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["menu_pages"] = array (); /* Clear right side. */
231
  /**/
232
+ $menu = "ws-plugin--s2member-mms-ops"; /* Used below for nesting additional sub-menu pages. */
233
  /**/
234
+ add_menu_page ("s2Member®", "s2Member®", "create_users", $menu, "c_ws_plugin__s2member_menu_pages::mms_ops_page", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images/brand-favicon.png");
235
  /**/
236
+ add_submenu_page ($menu, "s2Member Multisite ( Configuration )", "Multisite (Config)", "create_users", "ws-plugin--s2member-mms-ops", "c_ws_plugin__s2member_menu_pages::mms_ops_page");
237
  /**/
238
  if (apply_filters ("ws_plugin__s2member_during_add_network_admin_options_add_info_page", (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ()), get_defined_vars ()))
239
  add_submenu_page ($menu, "s2Member Information", "s2Member Info", "create_users", "ws-plugin--s2member-info", "c_ws_plugin__s2member_menu_pages::info_page");
240
+ /**/
241
+ do_action ("ws_plugin__s2member_during_add_network_admin_options_additional_pages", get_defined_vars ());
242
  }
243
  /**/
244
  do_action ("ws_plugin__s2member_after_add_network_admin_options", get_defined_vars ());
245
  /**/
246
  return; /* Return for uniformity. */
247
  }
248
+ /**
249
+ * A sort of callback function to add the settings link.
250
+ *
251
+ * @package s2Member\Menu_Pages
252
+ * @since 3.5
253
+ *
254
+ * @attaches-to: ``add_filter("plugin_action_links");``
255
+ *
256
+ * @param array $links Expects an existing array of links, passed in by the Filter.
257
+ * @param str $file Expects path to a plugin file. We need to test against this for s2Member.
258
+ * @return array An array of links, Filtered by this routine.
259
  */
260
+ public static function _add_settings_link ($links = FALSE, $file = FALSE)
261
  {
262
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
263
  do_action ("_ws_plugin__s2member_before_add_settings_link", get_defined_vars ());
265
  /**/
266
  if (preg_match ("/" . preg_quote ($file, "/") . "$/", $GLOBALS["WS_PLUGIN__"]["s2member"]["l"]) && is_array ($links))
267
  {
268
+ $settings = '<a href="' . esc_attr (admin_url ("/admin.php?page=ws-plugin--s2member-gen-ops")) . '">Settings</a>';
269
  array_unshift ($links, apply_filters ("ws_plugin__s2member_add_settings_link", $settings, get_defined_vars ()));
270
  /**/
271
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
275
  /**/
276
  return apply_filters ("_ws_plugin__s2member_add_settings_link", $links, get_defined_vars ());
277
  }
278
+ /**
279
+ * Enqueue scripts for administrative menu pages.
280
+ *
281
+ * @package s2Member\Menu_Pages
282
+ * @since 3.5
283
+ *
284
+ * @attaches-to: ``add_action("admin_print_scripts");``
285
+ *
286
+ * @return null
287
  */
288
  public static function add_admin_scripts ()
289
  {
290
  do_action ("ws_plugin__s2member_before_add_admin_scripts", get_defined_vars ());
291
  /**/
292
+ if (!empty ($_GET["page"]) && preg_match ("/ws-plugin--s2member-/", $_GET["page"]))
293
  {
294
  wp_enqueue_script ("jquery");
295
  wp_enqueue_script ("thickbox");
297
  wp_enqueue_script ("jquery-ui-core");
298
  wp_enqueue_script ("jquery-json-ps", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/includes/menu-pages/jquery-json-ps-min.js", array ("jquery"), c_ws_plugin__s2member_utilities::ver_checksum ());
299
  wp_enqueue_script ("jquery-ui-effects", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/includes/menu-pages/jquery-ui-effects.js", array ("jquery", "jquery-ui-core"), c_ws_plugin__s2member_utilities::ver_checksum ());
300
+ wp_enqueue_script ("ws-plugin--s2member-menu-pages", site_url ("/?ws_plugin__s2member_menu_pages_js=" . urlencode (mt_rand ())), array ("jquery", "thickbox", "media-upload", "jquery-json-ps", "jquery-ui-core", "jquery-ui-effects", "password-strength-meter"), c_ws_plugin__s2member_utilities::ver_checksum ());
301
  /**/
302
  do_action ("ws_plugin__s2member_during_add_admin_scripts", get_defined_vars ());
303
  }
306
  /**/
307
  return; /* Return for uniformity. */
308
  }
309
+ /**
310
+ * Enqueue styles for administrative menu pages.
311
+ *
312
+ * @package s2Member\Menu_Pages
313
+ * @since 3.5
314
+ *
315
+ * @attaches-to: ``add_action("admin_print_styles");``
316
+ *
317
+ * @return null
318
  */
319
  public static function add_admin_styles ()
320
  {
321
  do_action ("ws_plugin__s2member_before_add_admin_styles", get_defined_vars ());
322
  /**/
323
+ if (!empty ($_GET["page"]) && preg_match ("/ws-plugin--s2member-/", $_GET["page"]))
324
  {
325
  wp_enqueue_style ("thickbox");
326
  wp_enqueue_style ("ws-plugin--s2member-menu-pages", site_url ("/?ws_plugin__s2member_menu_pages_css=" . urlencode (mt_rand ())), array ("thickbox"), c_ws_plugin__s2member_utilities::ver_checksum (), "all");
332
  /**/
333
  return; /* Return for uniformity. */
334
  }
335
+ /**
336
+ * Builds and handles the Quick Start page.
337
+ *
338
+ * @package s2Member\Menu_Pages
339
+ * @since 3.5
340
+ *
341
+ * @return null
342
  */
343
+ public static function start_page ()
344
  {
345
+ do_action ("ws_plugin__s2member_before_start_page", get_defined_vars ());
346
  /**/
347
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/start.inc.php";
348
+ /**/
349
+ do_action ("ws_plugin__s2member_after_start_page", get_defined_vars ());
350
+ /**/
351
+ return; /* Return for uniformity. */
352
+ }
353
+ /**
354
+ * Builds and handles the Main Multisite Options page.
355
+ *
356
+ * @package s2Member\Menu_Pages
357
+ * @since 3.5
358
+ *
359
+ * @return null
360
+ */
361
+ public static function mms_ops_page ()
362
+ {
363
+ do_action ("ws_plugin__s2member_before_mms_ops_page", get_defined_vars ());
364
  /**/
365
  if (c_ws_plugin__s2member_menu_pages::update_all_options ())
366
  c_ws_plugin__s2member_mms_patches::mms_patches (true);
367
  /**/
368
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/mms-ops.inc.php";
369
  /**/
370
+ do_action ("ws_plugin__s2member_after_mms_ops_page", get_defined_vars ());
371
  /**/
372
  return; /* Return for uniformity. */
373
  }
374
+ /**
375
+ * Builds and handles the General Options page.
376
+ *
377
+ * @package s2Member\Menu_Pages
378
+ * @since 3.5
379
+ *
380
+ * @return null
381
  */
382
+ public static function gen_ops_page ()
383
  {
384
+ do_action ("ws_plugin__s2member_before_gen_ops_page", get_defined_vars ());
385
+ /**/
386
+ c_ws_plugin__s2member_menu_pages::update_all_options ();
387
  /**/
388
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/gen-ops.inc.php";
389
+ /**/
390
+ do_action ("ws_plugin__s2member_after_gen_ops_page", get_defined_vars ());
391
+ /**/
392
+ return; /* Return for uniformity. */
393
+ }
394
+ /**
395
+ * Builds and handles the Restriction Options page.
396
+ *
397
+ * @package s2Member\Menu_Pages
398
+ * @since 3.5
399
+ *
400
+ * @return null
401
+ */
402
+ public static function res_ops_page ()
403
+ {
404
+ do_action ("ws_plugin__s2member_before_res_ops_page", get_defined_vars ());
405
  /**/
406
  c_ws_plugin__s2member_menu_pages::update_all_options ();
407
  /**/
408
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/res-ops.inc.php";
409
  /**/
410
+ do_action ("ws_plugin__s2member_after_res_ops_page", get_defined_vars ());
411
  /**/
412
  return; /* Return for uniformity. */
413
  }
414
+ /**
415
+ * Builds and handles the Paypal Options page.
416
+ *
417
+ * @package s2Member\Menu_Pages
418
+ * @since 3.5
419
+ *
420
+ * @return null
421
  */
422
  public static function paypal_ops_page ()
423
  {
 
 
424
  do_action ("ws_plugin__s2member_before_paypal_ops_page", get_defined_vars ());
425
  /**/
426
  c_ws_plugin__s2member_menu_pages::update_all_options ();
456
  /**/
457
  return; /* Return for uniformity. */
458
  }
459
+ /**
460
+ * Builds and handles the Download Options page.
461
+ *
462
+ * @package s2Member\Menu_Pages
463
+ * @since 3.5
464
+ *
465
+ * @return null
466
  */
467
  public static function down_ops_page ()
468
  {
 
 
469
  do_action ("ws_plugin__s2member_before_down_ops_page", get_defined_vars ());
470
  /**/
471
  c_ws_plugin__s2member_menu_pages::update_all_options ();
472
  /**/
473
+ if (!($using_amazon_s3_storage = 0) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_bucket"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_access_key"] && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["amazon_s3_files_secret_key"])
474
+ $using_amazon_s3_storage = true; /* Amazon® S3 storage has been configured! */
475
+ /**/
476
  $files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"];
477
  /**/
478
  if (!is_dir ($files_dir) && is_writable (dirname (c_ws_plugin__s2member_utils_dirs::strip_dir_app_data ($files_dir))))
483
  if (is_dir ($files_dir) && is_writable ($files_dir) && !file_exists ($htaccess))
484
  file_put_contents ($htaccess, "deny from all") . clearstatcache ();
485
  /**/
486
+ if (!$using_amazon_s3_storage && !is_dir ($files_dir)) /* If the security-enabled files directory does not exist yet. */
487
  c_ws_plugin__s2member_admin_notices::display_admin_notice ("The security-enabled files directory ( <code>" . esc_html (preg_replace ("/^" . preg_quote ($_SERVER["DOCUMENT_ROOT"], "/") . "/", "", $files_dir)) . "</code> ) does not exist. Please create this directory manually.", true);
488
  /**/
489
+ if (!$using_amazon_s3_storage && !file_exists ($htaccess)) /* If the .htaccess file has not been created yet. */
490
  c_ws_plugin__s2member_admin_notices::display_admin_notice ("The .htaccess protection file ( <code>" . esc_html (preg_replace ("/^" . preg_quote ($_SERVER["DOCUMENT_ROOT"], "/") . "/", "", $htaccess)) . "</code> ) does not exist. Please create this file manually. Inside your .htaccess file, add this one line: <code>deny from all</code>.", true);
491
  /**/
492
+ else if (!$using_amazon_s3_storage && !preg_match ("/deny from all/i", file_get_contents ($htaccess))) /* Else if the .htaccess file does not offer the required protection. */
493
  c_ws_plugin__s2member_admin_notices::display_admin_notice ("Unprotected. The .htaccess protection file ( <code>" . esc_html (preg_replace ("/^" . preg_quote ($_SERVER["DOCUMENT_ROOT"], "/") . "/", "", $htaccess)) . "</code> ) does not contain <code>deny from all</code>. Inside your .htaccess file, add this one line: <code>deny from all</code>.", true);
494
  /**/
495
  include_once dirname (dirname (__FILE__)) . "/menu-pages/down-ops.inc.php";
498
  /**/
499
  return; /* Return for uniformity. */
500
  }
501
+ /**
502
+ * Builds and handles the API Tracking options page.
503
+ *
504
+ * @package s2Member\Menu_Pages
505
+ * @since 3.5
506
+ *
507
+ * @return null
508
  */
509
  public static function trk_ops_page ()
510
  {
 
 
511
  do_action ("ws_plugin__s2member_before_trk_ops_page", get_defined_vars ());
512
  /**/
513
  c_ws_plugin__s2member_menu_pages::update_all_options ();
518
  /**/
519
  return; /* Return for uniformity. */
520
  }
521
+ /**
522
+ * Builds and handles the API List Server options page.
523
+ *
524
+ * @package s2Member\Menu_Pages
525
+ * @since 3.5
526
+ *
527
+ * @return null
528
  */
529
  public static function els_ops_page ()
530
  {
 
 
531
  do_action ("ws_plugin__s2member_before_els_ops_page", get_defined_vars ());
532
  /**/
533
  c_ws_plugin__s2member_menu_pages::update_all_options ();
538
  /**/
539
  return; /* Return for uniformity. */
540
  }
541
+ /**
542
+ * Builds and handles the API Notifications page.
543
+ *
544
+ * @package s2Member\Menu_Pages
545
+ * @since 3.5
546
+ *
547
+ * @return null
548
  */
549
  public static function api_ops_page ()
550
  {
 
 
551
  do_action ("ws_plugin__s2member_before_api_ops_page", get_defined_vars ());
552
  /**/
553
  c_ws_plugin__s2member_menu_pages::update_all_options ();
558
  /**/
559
  return; /* Return for uniformity. */
560
  }
561
+ /**
562
+ * Builds and handles the PayPal Button Generator page.
563
+ *
564
+ * @package s2Member\Menu_Pages
565
+ * @since 3.5
566
+ *
567
+ * @return null
568
  */
569
  public static function paypal_buttons_page ()
570
  {
 
 
571
  do_action ("ws_plugin__s2member_before_paypal_buttons_page", get_defined_vars ());
572
  /**/
573
  if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_username"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_password"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_signature"])
579
  /**/
580
  return; /* Return for uniformity. */
581
  }
582
+ /**
583
+ * Builds and handles the API Scripting page.
584
+ *
585
+ * @package s2Member\Menu_Pages
586
+ * @since 3.5
587
+ *
588
+ * @return null
589
  */
590
  public static function scripting_page ()
591
  {
 
 
592
  do_action ("ws_plugin__s2member_before_scripting_page", get_defined_vars ());
593
  /**/
594
  include_once dirname (dirname (__FILE__)) . "/menu-pages/scripting.inc.php";
597
  /**/
598
  return; /* Return for uniformity. */
599
  }
600
+ /**
601
+ * Builds and handles the Integrations page.
602
+ *
603
+ * @package s2Member\Menu_Pages
604
+ * @since 3.5
605
+ *
606
+ * @return null
607
  */
608
+ public static function integrations_page ()
609
  {
610
+ do_action ("ws_plugin__s2member_before_integrations_page", get_defined_vars ());
 
 
611
  /**/
612
+ if (!empty ($_POST["ws_plugin__s2member_bridge_bbpress"]) && ($nonce = $_POST["ws_plugin__s2member_bridge_bbpress"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-bridge-bbpress") && ($_p = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST))))
613
  {
614
+ if (!empty ($_p["ws_plugin__s2member_bridge_bbpress_plugins_dir"]) && is_dir ($plugins_dir = untrailingslashit ($_p["ws_plugin__s2member_bridge_bbpress_plugins_dir"])))
 
 
615
  {
616
+ if (is_writable ($plugins_dir)) /* This directory MUST be writable. */
617
  {
618
  if (preg_match ("/^Install/i", $_p["ws_plugin__s2member_bridge_bbpress_action"]))
619
  {
648
  c_ws_plugin__s2member_admin_notices::display_admin_notice ("The directory you specified does NOT exist. Please try again, or install manually.", true);
649
  }
650
  /**/
651
+ include_once dirname (dirname (__FILE__)) . "/menu-pages/integrations.inc.php";
 
 
 
 
 
 
 
 
652
  /**/
653
+ do_action ("ws_plugin__s2member_after_integrations_page", get_defined_vars ());
654
  /**/
655
  return; /* Return for uniformity. */
656
  }
657
+ /**
658
+ * Builds and handles the s2Member Info page.
659
+ *
660
+ * @package s2Member\Menu_Pages
661
+ * @since 3.5
662
+ *
663
+ * @return null
664
  */
665
  public static function info_page ()
666
  {
 
 
667
  do_action ("ws_plugin__s2member_before_info_page", get_defined_vars ());
668
  /**/
669
  include_once dirname (dirname (__FILE__)) . "/menu-pages/info.inc.php";
672
  /**/
673
  return; /* Return for uniformity. */
674
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
675
  }
676
  }
677
  ?>
includes/classes/meta-box-saves.inc.php CHANGED
@@ -1,27 +1,42 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_meta_box_saves"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_meta_box_saves
20
  {
21
- /*
22
- Function save data entered into meta boxes,
23
- on Post/Page editing stations.
24
- Attach to: add_action("save_post");
 
 
 
 
 
 
25
  */
26
  public static function save_meta_boxes ($post_id = FALSE)
27
  {
@@ -29,8 +44,8 @@ if (!class_exists ("c_ws_plugin__s2member_meta_box_saves"))
29
  do_action ("ws_plugin__s2member_before_save_meta_boxes", get_defined_vars ());
30
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
31
  /**/
32
- if ($post_id && ($nonce = $_POST["ws_plugin__s2member_security_meta_box_save"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-security-meta-box-save"))
33
- if ($post_id == $_POST["ws_plugin__s2member_security_meta_box_save_id"]) /* Do NOT process historical revisions. */
34
  /* We do NOT process historical revisions here; because it causes confusion in the General Options panel for s2Member. */
35
  {
36
  $_p = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)); /* Clean and create a local copy. */
1
  <?php
2
+ /**
3
+ * Meta box saves.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Meta_Boxes
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_meta_box_saves"))
21
  {
22
+ /**
23
+ * Meta box saves.
24
+ *
25
+ * @package s2Member\Meta_Boxes
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_meta_box_saves
29
  {
30
+ /**
31
+ * Saves data entered into meta boxes on Post/Page editing stations.
32
+ *
33
+ * @package s2Member\Meta_Boxes
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_action("save_post");``
37
+ *
38
+ * @param int|str $post_id Numeric Post/Page ID.
39
+ * @return null
40
  */
41
  public static function save_meta_boxes ($post_id = FALSE)
42
  {
44
  do_action ("ws_plugin__s2member_before_save_meta_boxes", get_defined_vars ());
45
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
46
  /**/
47
+ if ($post_id && !empty ($_POST["ws_plugin__s2member_security_meta_box_save"]) && ($nonce = $_POST["ws_plugin__s2member_security_meta_box_save"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-security-meta-box-save"))
48
+ if (!empty ($_POST["ws_plugin__s2member_security_meta_box_save_id"]) && $post_id == $_POST["ws_plugin__s2member_security_meta_box_save_id"] && !empty ($_POST["post_type"]))
49
  /* We do NOT process historical revisions here; because it causes confusion in the General Options panel for s2Member. */
50
  {
51
  $_p = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)); /* Clean and create a local copy. */
includes/classes/meta-box-security.inc.php CHANGED
@@ -1,33 +1,48 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_meta_box_security"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_meta_box_security
20
  {
21
- /*
22
- Function adds meta boxes to Post/Page editing stations.
 
 
 
 
 
 
23
  */
24
  public static function security_meta_box ($post = FALSE)
25
  {
26
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
27
  do_action ("ws_plugin__s2member_before_security_meta_box", get_defined_vars ());
28
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
29
  /**/
30
- if (is_object ($post) && ($post_id = $post->ID) && ( ($post->post_type === "page" && current_user_can ("edit_page", $post_id)) || current_user_can ("edit_post", $post_id)))
31
  {
32
  if ($post->post_type === "page" && ($page_id = $post_id)) /* OK. So we're dealing with a Page classification. */
33
  {
@@ -46,11 +61,11 @@ if (!class_exists ("c_ws_plugin__s2member_meta_box_security"))
46
  echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-level">Add Level Restriction?</label>' . "\n";
47
  echo '<select name="ws_plugin__s2member_security_meta_box_level" id="ws-plugin--s2member-security-meta-box-level" style="width:99%;">' . "\n";
48
  echo '<option value=""></option>' . "\n"; /* By default, we allow public access to any Post/Page. */
49
- echo ($pages["0"] !== array ("all")) ? '<option value="0"' . ( (in_array ($page_id, $pages["0"])) ? ' selected="selected"' : '') . '>Require Level# 0 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #0 ( already protects "all" Pages )</option>';
50
- echo ($pages["1"] !== array ("all")) ? '<option value="1"' . ( (in_array ($page_id, $pages["1"])) ? ' selected="selected"' : '') . '>Require Level# 1 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #1 ( already protects "all" Pages )</option>';
51
- echo ($pages["2"] !== array ("all")) ? '<option value="2"' . ( (in_array ($page_id, $pages["2"])) ? ' selected="selected"' : '') . '>Require Level# 2 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #2 ( already protects "all" Pages )</option>';
52
- echo ($pages["3"] !== array ("all")) ? '<option value="3"' . ( (in_array ($page_id, $pages["3"])) ? ' selected="selected"' : '') . '>Require Level# 3 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #3 ( already protects "all" Pages )</option>';
53
- echo ($pages["4"] !== array ("all")) ? '<option value="4"' . ( (in_array ($page_id, $pages["4"])) ? ' selected="selected"' : '') . '>Require Level# 4 ( highest level )</option>' . "\n" : '<option value="" disabled="disabled">Level #4 ( already protects "all" Pages )</option>';
54
  echo '</select><br /><small>* see: <code>General Options -> Page Level Access</code></small>' . "\n";
55
  /**/
56
  if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ())
@@ -86,11 +101,11 @@ if (!class_exists ("c_ws_plugin__s2member_meta_box_security"))
86
  echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-level">Add Level Restriction?</label>' . "\n";
87
  echo '<select name="ws_plugin__s2member_security_meta_box_level" id="ws-plugin--s2member-security-meta-box-level" style="width:99%;">' . "\n";
88
  echo '<option value=""></option>' . "\n"; /* By default, we allow public access to any Post/Page. */
89
- echo ($posts["0"] !== array ("all")) ? '<option value="0"' . ( (in_array ($post_id, $posts["0"])) ? ' selected="selected"' : '') . '>Require Level# 0 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #0 ( already protects "all" Posts )</option>';
90
- echo ($posts["1"] !== array ("all")) ? '<option value="1"' . ( (in_array ($post_id, $posts["1"])) ? ' selected="selected"' : '') . '>Require Level# 1 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #1 ( already protects "all" Posts )</option>';
91
- echo ($posts["2"] !== array ("all")) ? '<option value="2"' . ( (in_array ($post_id, $posts["2"])) ? ' selected="selected"' : '') . '>Require Level# 2 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #2 ( already protects "all" Posts )</option>';
92
- echo ($posts["3"] !== array ("all")) ? '<option value="3"' . ( (in_array ($post_id, $posts["3"])) ? ' selected="selected"' : '') . '>Require Level# 3 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #3 ( already protects "all" Posts )</option>';
93
- echo ($posts["4"] !== array ("all")) ? '<option value="4"' . ( (in_array ($post_id, $posts["4"])) ? ' selected="selected"' : '') . '>Require Level# 4 ( highest level )</option>' . "\n" : '<option value="" disabled="disabled">Level #4 ( already protects "all" Posts )</option>';
94
  echo '</select><br /><small>* see: <code>General Options -> Post Level Access</code></small>' . "\n";
95
  /**/
96
  if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ())
1
  <?php
2
+ /**
3
+ * Security meta box.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Meta_Boxes
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_meta_box_security"))
21
  {
22
+ /**
23
+ * Security meta box.
24
+ *
25
+ * @package s2Member\Meta_Boxes
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_meta_box_security
29
  {
30
+ /**
31
+ * Adds security meta box to Post/Page editing stations.
32
+ *
33
+ * @package s2Member\Meta_Boxes
34
+ * @since 3.5
35
+ *
36
+ * @param obj $post Post/Page object.
37
+ * @return null
38
  */
39
  public static function security_meta_box ($post = FALSE)
40
  {
41
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
42
  do_action ("ws_plugin__s2member_before_security_meta_box", get_defined_vars ());
43
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
44
  /**/
45
+ if (is_object ($post) && ($post_id = $post->ID) && (($post->post_type === "page" && current_user_can ("edit_page", $post_id)) || current_user_can ("edit_post", $post_id)))
46
  {
47
  if ($post->post_type === "page" && ($page_id = $post_id)) /* OK. So we're dealing with a Page classification. */
48
  {
61
  echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-level">Add Level Restriction?</label>' . "\n";
62
  echo '<select name="ws_plugin__s2member_security_meta_box_level" id="ws-plugin--s2member-security-meta-box-level" style="width:99%;">' . "\n";
63
  echo '<option value=""></option>' . "\n"; /* By default, we allow public access to any Post/Page. */
64
+ echo ($pages["0"] !== array ("all")) ? '<option value="0"' . ((in_array ($page_id, $pages["0"])) ? ' selected="selected"' : '') . '>Require Level# 0 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #0 ( already protects "all" Pages )</option>';
65
+ echo ($pages["1"] !== array ("all")) ? '<option value="1"' . ((in_array ($page_id, $pages["1"])) ? ' selected="selected"' : '') . '>Require Level# 1 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #1 ( already protects "all" Pages )</option>';
66
+ echo ($pages["2"] !== array ("all")) ? '<option value="2"' . ((in_array ($page_id, $pages["2"])) ? ' selected="selected"' : '') . '>Require Level# 2 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #2 ( already protects "all" Pages )</option>';
67
+ echo ($pages["3"] !== array ("all")) ? '<option value="3"' . ((in_array ($page_id, $pages["3"])) ? ' selected="selected"' : '') . '>Require Level# 3 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #3 ( already protects "all" Pages )</option>';
68
+ echo ($pages["4"] !== array ("all")) ? '<option value="4"' . ((in_array ($page_id, $pages["4"])) ? ' selected="selected"' : '') . '>Require Level# 4 ( highest level )</option>' . "\n" : '<option value="" disabled="disabled">Level #4 ( already protects "all" Pages )</option>';
69
  echo '</select><br /><small>* see: <code>General Options -> Page Level Access</code></small>' . "\n";
70
  /**/
71
  if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ())
101
  echo '<label class="screen-reader-text" for="ws-plugin--s2member-security-meta-box-level">Add Level Restriction?</label>' . "\n";
102
  echo '<select name="ws_plugin__s2member_security_meta_box_level" id="ws-plugin--s2member-security-meta-box-level" style="width:99%;">' . "\n";
103
  echo '<option value=""></option>' . "\n"; /* By default, we allow public access to any Post/Page. */
104
+ echo ($posts["0"] !== array ("all")) ? '<option value="0"' . ((in_array ($post_id, $posts["0"])) ? ' selected="selected"' : '') . '>Require Level# 0 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #0 ( already protects "all" Posts )</option>';
105
+ echo ($posts["1"] !== array ("all")) ? '<option value="1"' . ((in_array ($post_id, $posts["1"])) ? ' selected="selected"' : '') . '>Require Level# 1 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #1 ( already protects "all" Posts )</option>';
106
+ echo ($posts["2"] !== array ("all")) ? '<option value="2"' . ((in_array ($post_id, $posts["2"])) ? ' selected="selected"' : '') . '>Require Level# 2 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #2 ( already protects "all" Posts )</option>';
107
+ echo ($posts["3"] !== array ("all")) ? '<option value="3"' . ((in_array ($post_id, $posts["3"])) ? ' selected="selected"' : '') . '>Require Level# 3 ( or higher )</option>' . "\n" : '<option value="" disabled="disabled">Level #3 ( already protects "all" Posts )</option>';
108
+ echo ($posts["4"] !== array ("all")) ? '<option value="4"' . ((in_array ($post_id, $posts["4"])) ? ' selected="selected"' : '') . '>Require Level# 4 ( highest level )</option>' . "\n" : '<option value="" disabled="disabled">Level #4 ( already protects "all" Posts )</option>';
109
  echo '</select><br /><small>* see: <code>General Options -> Post Level Access</code></small>' . "\n";
110
  /**/
111
  if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site ())
includes/classes/meta-boxes.inc.php CHANGED
@@ -1,35 +1,55 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_meta_boxes"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_meta_boxes
20
  {
21
- /*
22
- Function adds meta boxes to Post/Page editing stations.
23
- * Note: WordPress® also calls this Hook with $type set to: `link` and `comment` Possibly others.
24
- Thus, the need for: `in_array ($type, array_keys (get_post_types ()))`.
25
- Attach to: add_action("add_meta_boxes");
 
 
 
 
 
 
 
 
26
  */
27
  public static function add_meta_boxes ($type = FALSE)
28
  {
29
  do_action ("ws_plugin__s2member_before_add_meta_boxes", get_defined_vars ());
30
  /**/
31
- if (in_array ($type, array_keys (get_post_types ())) && !in_array ($type, array ("link", "comment", "revision", "attachment", "nav_menu_item")))
32
- add_meta_box ("ws-plugin--s2member-security", "s2Member", "c_ws_plugin__s2member_meta_box_security::security_meta_box", $type, "side", "high");
 
 
 
33
  /**/
34
  do_action ("ws_plugin__s2member_after_add_meta_boxes", get_defined_vars ());
35
  /**/
1
  <?php
2
+ /**
3
+ * Administrative Meta Boxes.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Meta_Boxes
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_meta_boxes"))
21
  {
22
+ /**
23
+ * Administrative Meta Boxes.
24
+ *
25
+ * @package s2Member\Meta_Boxes
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_meta_boxes
29
  {
30
+ /**
31
+ * Adds meta boxes to Post/Page editing stations.
32
+ *
33
+ * Note: WordPress® also calls this Hook with ``$type`` set to: `link` and `comment`. Possibly others.
34
+ * Thus, the need for: ``in_array ($type, array_keys (get_post_types ()))``.
35
+ *
36
+ * @package s2Member\Meta_Boxes
37
+ * @since 3.5
38
+ *
39
+ * @attaches-to: ``add_action("add_meta_boxes");``
40
+ *
41
+ * @param str $type String indicating type of Post, or another classification *( i.e. `nav_menu_item` )*.
42
+ * @return null
43
  */
44
  public static function add_meta_boxes ($type = FALSE)
45
  {
46
  do_action ("ws_plugin__s2member_before_add_meta_boxes", get_defined_vars ());
47
  /**/
48
+ $excluded_types = array ("link", "comment", "revision", "attachment", "nav_menu_item");
49
+ $excluded_types = apply_filters ("ws_plugin__s2member_add_meta_boxes_excluded_types", $excluded_types, get_defined_vars ());
50
+ /**/
51
+ if (in_array ($type, array_keys (get_post_types ())) && !in_array ($type, $excluded_types))
52
+ add_meta_box ("ws-plugin--s2member-security", "s2Member®", "c_ws_plugin__s2member_meta_box_security::security_meta_box", $type, "side", "high");
53
  /**/
54
  do_action ("ws_plugin__s2member_after_add_meta_boxes", get_defined_vars ());
55
  /**/
includes/classes/mms-patches.inc.php CHANGED
@@ -1,47 +1,69 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_mms_patches"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_mms_patches
20
  {
21
- /*
22
- Function synchronizes Multisite patches with WordPress® core upgrades.
23
- Attach to: add_filter("update_feedback");
 
 
 
 
 
 
 
24
  */
25
  public static function sync_mms_patches ($message = FALSE)
26
  {
27
  global $pagenow; /* Need access to this global var. */
28
  /**/
29
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
30
  do_action ("ws_plugin__s2member_before_sync_mms_patches", get_defined_vars ());
31
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
32
  /**/
33
- if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_network_admin () && $pagenow === "update-core.php")
34
  if ($message === "Upgrading database&#8230;" && c_ws_plugin__s2member_mms_patches::mms_patches ())
35
  apply_filters ("update_feedback", "s2 Multisite patches applied&#8230;");
36
  /**/
37
  return apply_filters ("ws_plugin__s2member_sync_mms_patches", $message, get_defined_vars ());
38
  }
39
- /*
40
- Function handles patches on a Multisite Network installation.
 
 
 
 
 
 
41
  */
42
  public static function mms_patches ($display_notices = FALSE)
43
  {
44
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
45
  do_action ("ws_plugin__s2member_before_mms_patches", get_defined_vars ());
46
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
47
  /**/
@@ -56,7 +78,7 @@ if (!class_exists ("c_ws_plugin__s2member_mms_patches"))
56
  /**/
57
  if (file_exists ($wp_login_file) && ($wp_login = file_get_contents ($wp_login_file)) && is_writable ($wp_login_file))
58
  {
59
- if (( ($wp_login_written = file_put_contents ($wp_login_file, preg_replace ($wp_login_section, $wp_login_replace, $wp_login, 1, $wp_login_patched))) && $wp_login_patched) || ($wp_login_patched_already = $wp_login_patched = strpos ($wp_login, $wp_login_replace)))
60
  ($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-login.php</code> file ' . (($wp_login_patched_already) ? 'is patched' : 'has been patched successfully') . '.') : null;
61
  else if (!$wp_login_written) /* Otherwise, we need to report that /wp-login.php could NOT be updated. Possibly a permissions error. */
62
  ($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-login.php</code> file could NOT be patched. Patch NOT written.', true) : null;
@@ -72,7 +94,7 @@ if (!class_exists ("c_ws_plugin__s2member_mms_patches"))
72
  /**/
73
  if (file_exists ($load_file) && ($load = file_get_contents ($load_file)) && is_writable ($load_file))
74
  {
75
- if (( ($load_written = file_put_contents ($load_file, preg_replace ($load_section, $load_replace, $load, 1, $load_patched))) && $load_patched) || ($load_patched_already = $load_patched = strpos ($load, $load_replace)))
76
  ($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/load.php</code> file ' . (($load_patched_already) ? 'is patched' : 'has been patched successfully') . '.') : null;
77
  else if (!$load_written) /* Otherwise, we need to report that /wp-includes/load.php could NOT be updated. Possibly a permissions error. */
78
  ($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/load.php</code> file could NOT be patched. Patch NOT written.', true) : null;
@@ -88,7 +110,7 @@ if (!class_exists ("c_ws_plugin__s2member_mms_patches"))
88
  /**/
89
  if (file_exists ($user_new_file) && ($user_new = file_get_contents ($user_new_file)) && is_writable ($user_new_file))
90
  {
91
- if (( ($user_new_written = file_put_contents ($user_new_file, preg_replace ($user_new_section, $user_new_replace, $user_new, 1, $user_new_patched))) && $user_new_patched) || ($user_new_patched_already = $user_new_patched = strpos ($user_new, $user_new_replace)))
92
  ($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-admin/user-new.php</code> file ' . (($user_new_patched_already) ? 'is patched' : 'has been patched successfully') . '.') : null;
93
  else if (!$user_new_written) /* Otherwise, we need to report that /wp-admin/user-new.php could NOT be updated. Possibly a permissions error. */
94
  ($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-admin/user-new.php</code> file could NOT be patched. Patch NOT written.', true) : null;
@@ -104,7 +126,7 @@ if (!class_exists ("c_ws_plugin__s2member_mms_patches"))
104
  /**/
105
  if (file_exists ($ms_functions_file) && ($ms_functions = file_get_contents ($ms_functions_file)) && is_writable ($ms_functions_file))
106
  {
107
- if (( ($ms_functions_written = file_put_contents ($ms_functions_file, preg_replace ($ms_functions_section, $ms_functions_replace, $ms_functions, 1, $ms_functions_patched))) && $ms_functions_patched) || ($ms_functions_patched_already = $ms_functions_patched = strpos ($ms_functions, $ms_functions_replace)))
108
  ($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/ms-functions.php</code> file ' . (($ms_functions_patched_already) ? 'is patched' : 'has been patched successfully') . '.') : null;
109
  else if (!$ms_functions_written) /* Otherwise, we need to report that /wp-includes/ms-functions.php could NOT be updated. Possibly a permissions error. */
110
  ($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/ms-functions.php</code> file could NOT be patched. Patch NOT written.', true) : null;
@@ -121,7 +143,7 @@ if (!class_exists ("c_ws_plugin__s2member_mms_patches"))
121
  /**/
122
  do_action ("ws_plugin__s2member_after_mms_patches", get_defined_vars ());
123
  /**/
124
- return$ran_mms_patches; /* Return status update. */
125
  }
126
  }
127
  }
1
  <?php
2
+ /**
3
+ * Main Multisite patches.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Main_Multisite_Patches
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_mms_patches"))
21
  {
22
+ /**
23
+ * Main Multisite patches.
24
+ *
25
+ * @package s2Member\Main_Multisite_Patches
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_mms_patches
29
  {
30
+ /**
31
+ * Synchronizes Multisite patches with WordPress® core upgrades.
32
+ *
33
+ * @package s2Member\Main_Multisite_Patches
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_filter("update_feedback");``
37
+ *
38
+ * @param str $message Expects message string passed through by the Filter.
39
+ * @return str Message after having been Filtered by this routine.
40
  */
41
  public static function sync_mms_patches ($message = FALSE)
42
  {
43
  global $pagenow; /* Need access to this global var. */
44
  /**/
45
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
46
  do_action ("ws_plugin__s2member_before_sync_mms_patches", get_defined_vars ());
47
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
48
  /**/
49
+ if (is_multisite () && is_network_admin () && $pagenow === "update-core.php")
50
  if ($message === "Upgrading database&#8230;" && c_ws_plugin__s2member_mms_patches::mms_patches ())
51
  apply_filters ("update_feedback", "s2 Multisite patches applied&#8230;");
52
  /**/
53
  return apply_filters ("ws_plugin__s2member_sync_mms_patches", $message, get_defined_vars ());
54
  }
55
+ /**
56
+ * Handles patches on a Multisite Network installation.
57
+ *
58
+ * @package s2Member\Main_Multisite_Patches
59
+ * @since 3.5
60
+ *
61
+ * @param bool $display_notices Defaults to false. If true, notices are displayed.
62
+ * @return bool True if Multisite patches were processed, else false.
63
  */
64
  public static function mms_patches ($display_notices = FALSE)
65
  {
66
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
67
  do_action ("ws_plugin__s2member_before_mms_patches", get_defined_vars ());
68
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
69
  /**/
78
  /**/
79
  if (file_exists ($wp_login_file) && ($wp_login = file_get_contents ($wp_login_file)) && is_writable ($wp_login_file))
80
  {
81
+ if ((($wp_login_written = file_put_contents ($wp_login_file, preg_replace ($wp_login_section, $wp_login_replace, $wp_login, 1, $wp_login_patched))) && $wp_login_patched) || ($wp_login_patched_already = $wp_login_patched = strpos ($wp_login, $wp_login_replace)))
82
  ($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-login.php</code> file ' . (($wp_login_patched_already) ? 'is patched' : 'has been patched successfully') . '.') : null;
83
  else if (!$wp_login_written) /* Otherwise, we need to report that /wp-login.php could NOT be updated. Possibly a permissions error. */
84
  ($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-login.php</code> file could NOT be patched. Patch NOT written.', true) : null;
94
  /**/
95
  if (file_exists ($load_file) && ($load = file_get_contents ($load_file)) && is_writable ($load_file))
96
  {
97
+ if ((($load_written = file_put_contents ($load_file, preg_replace ($load_section, $load_replace, $load, 1, $load_patched))) && $load_patched) || ($load_patched_already = $load_patched = strpos ($load, $load_replace)))
98
  ($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/load.php</code> file ' . (($load_patched_already) ? 'is patched' : 'has been patched successfully') . '.') : null;
99
  else if (!$load_written) /* Otherwise, we need to report that /wp-includes/load.php could NOT be updated. Possibly a permissions error. */
100
  ($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/load.php</code> file could NOT be patched. Patch NOT written.', true) : null;
110
  /**/
111
  if (file_exists ($user_new_file) && ($user_new = file_get_contents ($user_new_file)) && is_writable ($user_new_file))
112
  {
113
+ if ((($user_new_written = file_put_contents ($user_new_file, preg_replace ($user_new_section, $user_new_replace, $user_new, 1, $user_new_patched))) && $user_new_patched) || ($user_new_patched_already = $user_new_patched = strpos ($user_new, $user_new_replace)))
114
  ($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-admin/user-new.php</code> file ' . (($user_new_patched_already) ? 'is patched' : 'has been patched successfully') . '.') : null;
115
  else if (!$user_new_written) /* Otherwise, we need to report that /wp-admin/user-new.php could NOT be updated. Possibly a permissions error. */
116
  ($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-admin/user-new.php</code> file could NOT be patched. Patch NOT written.', true) : null;
126
  /**/
127
  if (file_exists ($ms_functions_file) && ($ms_functions = file_get_contents ($ms_functions_file)) && is_writable ($ms_functions_file))
128
  {
129
+ if ((($ms_functions_written = file_put_contents ($ms_functions_file, preg_replace ($ms_functions_section, $ms_functions_replace, $ms_functions, 1, $ms_functions_patched))) && $ms_functions_patched) || ($ms_functions_patched_already = $ms_functions_patched = strpos ($ms_functions, $ms_functions_replace)))
130
  ($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/ms-functions.php</code> file ' . (($ms_functions_patched_already) ? 'is patched' : 'has been patched successfully') . '.') : null;
131
  else if (!$ms_functions_written) /* Otherwise, we need to report that /wp-includes/ms-functions.php could NOT be updated. Possibly a permissions error. */
132
  ($display_notices) ? c_ws_plugin__s2member_admin_notices::display_admin_notice ('Your <code>/wp-includes/ms-functions.php</code> file could NOT be patched. Patch NOT written.', true) : null;
143
  /**/
144
  do_action ("ws_plugin__s2member_after_mms_patches", get_defined_vars ());
145
  /**/
146
+ return !empty ($ran_mms_patches) ? $ran_mms_patches : false;
147
  }
148
  }
149
  }
includes/classes/mo-page-in.inc.php CHANGED
@@ -1,37 +1,50 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_mo_page_in"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_mo_page_in
20
  {
21
- /*
22
- This forces a redirection to the Membership Options Page for s2Member.
23
- This can be used by 3rd party applications that are not aware of which Page is currently set as the Membership Options Page.
24
-
25
- This is used by s2Member's bbPress Bridge integration.
26
-
27
- Attach to: add_action("init");
28
- Example usage: http://example.com/?s2member_membership_options_page=1
 
 
 
 
29
  */
30
- public static function membership_options_page () /* Force a redirection. */
31
  {
32
  do_action ("ws_plugin__s2member_before_membership_options_page", get_defined_vars ());
33
  /**/
34
- if ($_GET["s2member_membership_options_page"]) /* An incoming request? */
35
  {
36
  $query_args = array (); /* Initialize array. */
37
  foreach ($_GET as $var => $val) /* Include any s2member_ vars. */
1
  <?php
2
+ /**
3
+ * Membership Options Page ( inner processing routines ).
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Membership_Options_Page
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_mo_page_in"))
21
  {
22
+ /**
23
+ * Membership Options Page ( inner processing routines ).
24
+ *
25
+ * @package s2Member\Membership_Options_Page
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_mo_page_in
29
  {
30
+ /**
31
+ * Forces a redirection to the Membership Options Page for s2Member.
32
+ *
33
+ * This can be used by 3rd party apps that are not aware of which Page is currently set as the Membership Options Page.
34
+ * Example usage: `http://example.com/?s2member_membership_options_page=1`
35
+ *
36
+ * @package s2Member\Membership_Options_Page
37
+ * @since 3.5
38
+ *
39
+ * @attaches-to: ``add_action("init");``
40
+ *
41
+ * @return null Or exits script execution after redirection.
42
  */
43
+ public static function membership_options_page ()
44
  {
45
  do_action ("ws_plugin__s2member_before_membership_options_page", get_defined_vars ());
46
  /**/
47
+ if (!empty ($_GET["s2member_membership_options_page"])) /* An incoming request? */
48
  {
49
  $query_args = array (); /* Initialize array. */
50
  foreach ($_GET as $var => $val) /* Include any s2member_ vars. */
includes/classes/mo-page.inc.php CHANGED
@@ -1,35 +1,48 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_mo_page"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_mo_page
20
  {
21
- /*
22
- This forces a redirection to the Membership Options Page for s2Member.
23
- This can be used by 3rd party applications that are not aware of which Page is currently set as the Membership Options Page.
24
-
25
- This is used by s2Member's bbPress Bridge integration.
26
-
27
- Attach to: add_action("init");
28
- Example usage: http://example.com/?s2member_membership_options_page=1
 
 
 
 
29
  */
30
- public static function membership_options_page () /* Force a redirection. */
31
  {
32
- if ($_GET["s2member_membership_options_page"]) /* Call inner function? */
33
  {
34
  return c_ws_plugin__s2member_mo_page_in::membership_options_page ();
35
  }
1
  <?php
2
+ /**
3
+ * Membership Options Page.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Membership_Options_Page
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_mo_page"))
21
  {
22
+ /**
23
+ * Membership Options Page.
24
+ *
25
+ * @package s2Member\Membership_Options_Page
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_mo_page
29
  {
30
+ /**
31
+ * Forces a redirection to the Membership Options Page for s2Member.
32
+ *
33
+ * This can be used by 3rd party apps that are not aware of which Page is currently set as the Membership Options Page.
34
+ * Example usage: `http://example.com/?s2member_membership_options_page=1`
35
+ *
36
+ * @package s2Member\Membership_Options_Page
37
+ * @since 3.5
38
+ *
39
+ * @attaches-to: ``add_action("init");``
40
+ *
41
+ * @return null|inner Return-value of inner routine.
42
  */
43
+ public static function membership_options_page ()
44
  {
45
+ if (!empty ($_GET["s2member_membership_options_page"])) /* Call inner routine? */
46
  {
47
  return c_ws_plugin__s2member_mo_page_in::membership_options_page ();
48
  }
includes/classes/no-cache.inc.php ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * No-cache routines.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\No_Cache
15
+ * @since 3.5
16
+ */
17
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
+ /**/
20
+ if (!class_exists ("c_ws_plugin__s2member_no_cache"))
21
+ {
22
+ /**
23
+ * No-cache routines.
24
+ *
25
+ * @package s2Member\No_Cache
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_no_cache
29
+ {
30
+ /**
31
+ * Handles no-cache headers and compatible constants for s2Member.
32
+ *
33
+ * This is compatible with Quick Cache and also with WP Super Cache.
34
+ *
35
+ * @package s2Member\No_Cache
36
+ * @since 3.5
37
+ *
38
+ * @attaches-to: ``add_action("init");``
39
+ *
40
+ * @return null
41
+ */
42
+ public static function no_cache ()
43
+ {
44
+ do_action ("ws_plugin__s2member_before_no_cache", get_defined_vars ());
45
+ /**/
46
+ c_ws_plugin__s2member_no_cache::no_cache_constants (); /* This first. */
47
+ c_ws_plugin__s2member_no_cache::no_cache_headers (); /* Now run headers. */
48
+ /**/
49
+ do_action ("ws_plugin__s2member_after_no_cache", get_defined_vars ());
50
+ /**/
51
+ return; /* Return for uniformity. */
52
+ }
53
+ /**
54
+ * Defines compatible cache constants for s2Member.
55
+ *
56
+ * This is compatible with Quick Cache and also with WP Super Cache.
57
+ * Quick Cache uses: ``QUICK_CACHE_ALLOWED``, and Super Cache uses: ``DONOTCACHEPAGE``.
58
+ * Actually, Quick Cache is compatible with either of these defined constants.
59
+ *
60
+ * Always disallow caching for logged in users and GET requests with `/?s2member` systematic use.
61
+ * For clarity on the systematic use with s2member in the request, see: `/classes/systematics.inc.php`.
62
+ * Also disallow caching if the ``$no_cache`` param is passed in as true by other routines.
63
+ * BUT, always obey the `qcAC` param that specifically allows caching.
64
+ *
65
+ * This function is also called upon by other routines that protect members-only content areas.
66
+ * Members-only content areas should never be cached. In other words, there are some important supplemental
67
+ * routines that occur outside the scope of this single function. This function is called upon by those other
68
+ * targeted routines, to handle the cache constants when they are required.
69
+ *
70
+ * @package s2Member\No_Cache
71
+ * @since 3.5
72
+ *
73
+ * @param bool $no_cache Optional. Defaults to false. If true, force no-cache headers if at all possible.
74
+ * @return null
75
+ *
76
+ * @see s2Member\URIs\c_ws_plugin__s2member_ruris::check_ruri_level_access()
77
+ * @see s2Member\Categories\c_ws_plugin__s2member_catgs::check_catg_level_access()
78
+ * @see s2Member\Tags\c_ws_plugin__s2member_ptags::check_ptag_level_access()
79
+ * @see s2Member\Posts\c_ws_plugin__s2member_posts::check_post_level_access()
80
+ * @see s2Member\Pages\c_ws_plugin__s2member_pages::check_page_level_access()
81
+ * @see s2Member\IP_Restrictions\c_ws_plugin__s2member_ip_restrictions::ip_restrictions_ok()
82
+ * @see s2Member\Files\c_ws_plugin__s2member_files::file_download_key()
83
+ * @see Button/Form/Shortcode Generators.
84
+ */
85
+ public static function no_cache_constants ($no_cache = FALSE)
86
+ {
87
+ static $once; /* We only need to set these Constants once. */
88
+ /**/
89
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
90
+ do_action ("ws_plugin__s2member_before_no_cache_constants", get_defined_vars ());
91
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
92
+ /**/
93
+ if (!$once && empty ($_GET["qcAC"]) && ($no_cache || is_user_logged_in () || (!empty ($_SERVER["QUERY_STRING"]) && strpos ($_SERVER["QUERY_STRING"], "s2member") === 0 && c_ws_plugin__s2member_utils_conds::is_site_root ($_SERVER["REQUEST_URI"]))))
94
+ {
95
+ /**
96
+ * No-cache Constant for Quick Cache.
97
+ *
98
+ * @package s2Member\No_Cache
99
+ * @since 3.5
100
+ *
101
+ * @var bool
102
+ */
103
+ if (!defined ("QUICK_CACHE_ALLOWED"))
104
+ define ("QUICK_CACHE_ALLOWED", false);
105
+ /**
106
+ * No-cache for other cache plugins.
107
+ *
108
+ * @package s2Member\No_Cache
109
+ * @since 3.5
110
+ *
111
+ * @var bool
112
+ */
113
+ if (!defined ("DONOTCACHEPAGE"))
114
+ define ("DONOTCACHEPAGE", true);
115
+ /**/
116
+ $GLOBALS["ws_plugin__s2member_no_cache_headers_selective"] = true;
117
+ /**/
118
+ $once = true; /* Only need to set these Constants one time. */
119
+ /**/
120
+ do_action ("ws_plugin__s2member_during_no_cache_constants", get_defined_vars ());
121
+ }
122
+ /**/
123
+ do_action ("ws_plugin__s2member_after_no_cache_constants", get_defined_vars ());
124
+ /**/
125
+ return; /* Return for uniformity. */
126
+ }
127
+ /**
128
+ * Sends Cache-Control ( no-cache ) headers.
129
+ *
130
+ * This uses the ``nocache_headers()`` function provided by WordPress®.
131
+ * This is compatible with the Quick Cache parameter `?qcABC=1` as well.
132
+ * Always obey the `qcABC` param that specifically allows browser caching.
133
+ *
134
+ * @package s2Member\No_Cache
135
+ * @since 3.5
136
+ *
137
+ * @return null
138
+ */
139
+ public static function no_cache_headers ()
140
+ {
141
+ static $once; /* We only need to set these headers one time. */
142
+ /**/
143
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
144
+ do_action ("ws_plugin__s2member_before_no_cache_headers", get_defined_vars ());
145
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
146
+ /**/
147
+ $using_selective_behavior = apply_filters ("ws_plugin__s2member_no_cache_headers_selective", false, get_defined_vars ());
148
+ $selective = @$GLOBALS["ws_plugin__s2member_no_cache_headers_selective"]; /* Selective ( i.e. required ) ? */
149
+ /**/
150
+ if (!$once && empty ($_GET["qcABC"]) && (!$using_selective_behavior || $selective) && !apply_filters ("ws_plugin__s2member_disable_no_cache_headers", false, get_defined_vars ()))
151
+ {
152
+ if (is_array ($headers = headers_list ()))
153
+ foreach ($headers as $header) /* Already? */
154
+ if (stripos ($header, "no-cache") !== false)
155
+ $no_cache_already_sent = true;
156
+ /**/
157
+ if (!$no_cache_already_sent)
158
+ nocache_headers ();
159
+ /**/
160
+ $once = true; /* Only need to set these headers once. */
161
+ /**/
162
+ do_action ("ws_plugin__s2member_during_no_cache_headers", get_defined_vars ());
163
+ }
164
+ /**/
165
+ do_action ("ws_plugin__s2member_after_no_cache_headers", get_defined_vars ());
166
+ /**/
167
+ return; /* Return for uniformity. */
168
+ }
169
+ }
170
+ }
171
+ ?>
includes/classes/nocache.inc.php DELETED
@@ -1,124 +0,0 @@
1
- <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
13
- */
14
- if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
- /**/
17
- if (!class_exists ("c_ws_plugin__s2member_nocache"))
18
- {
19
- class c_ws_plugin__s2member_nocache
20
- {
21
- /*
22
- Handles no-cache headers and compatible constants for s2Member.
23
- This is compatible with Quick Cache and also with WP Super Cache.
24
- Attach to: add_action("init");
25
- */
26
- public static function nocache ()
27
- {
28
- do_action ("ws_plugin__s2member_before_nocache", get_defined_vars ());
29
- /**/
30
- c_ws_plugin__s2member_nocache::nocache_constants (); /* This first. */
31
- c_ws_plugin__s2member_nocache::nocache_headers (); /* Now run headers. */
32
- /**/
33
- do_action ("ws_plugin__s2member_after_nocache", get_defined_vars ());
34
- /**/
35
- return; /* Return for uniformity. */
36
- }
37
- /*
38
- Define compatible nocache constants for s2Member.
39
- This is compatible with Quick Cache and also with WP Super Cache.
40
- Quick Cache uses: QUICK_CACHE_ALLOWED, and Super Cache uses: DONOTCACHEPAGE.
41
- Actually, Quick Cache is compatible with either of these defined constants.
42
-
43
- Always disallow caching for logged in users and GET requests with /?s2member systematic use.
44
- For clarity on the systematic use with s2member in the request, see: /classes/systematics.inc.php.
45
- - Also disallow caching if the $nocache param is passed in as true by other routines.
46
- * BUT, always obey the qcAC param that specifically allows caching.
47
-
48
- This function is also called upon by other routines that protect members-only content areas.
49
- Members-only content areas should never be cached. In other words, there are some important supplemental
50
- routines that occur outside the scope of this single function. This function is called upon by those other
51
- targeted routines, to handle the nocache constants when they are required.
52
-
53
- These additional supplemental routines, include:
54
- - c_ws_plugin__s2member_ruris::check_ruri_level_access()
55
- - c_ws_plugin__s2member_catgs::check_catg_level_access()
56
- - c_ws_plugin__s2member_ptags::check_ptag_level_access()
57
- - c_ws_plugin__s2member_posts::check_post_level_access()
58
- - c_ws_plugin__s2member_pages::check_page_level_access()
59
- - c_ws_plugin__s2member_ip_restrictions::ip_restrictions_ok()
60
- - c_ws_plugin__s2member_files::file_download_key()
61
- - Button/Form/Shortcode Generators also call this.
62
- */
63
- public static function nocache_constants ($nocache = FALSE)
64
- {
65
- static $once; /* We only need to set these Constants once. */
66
- /**/
67
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
68
- do_action ("ws_plugin__s2member_before_nocache_constants", get_defined_vars ());
69
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
70
- /**/
71
- if (!$once && !$_GET["qcAC"] && ($nocache || is_user_logged_in () || (preg_match ("/^s2member/", $_SERVER["QUERY_STRING"]) && (parse_url ($_SERVER["REQUEST_URI"], PHP_URL_PATH) === "/" || parse_url (rtrim ($_SERVER["REQUEST_URI"], "/"), PHP_URL_PATH) === parse_url (rtrim (site_url (), "/"), PHP_URL_PATH)))))
72
- {
73
- define ("QUICK_CACHE_ALLOWED", false) . define ("DONOTCACHEPAGE", true);
74
- /**/
75
- $GLOBALS["ws_plugin__s2member_nocache_headers_selective"] = true;
76
- /**/
77
- $once = true; /* Only need to set these Constants one time. */
78
- /**/
79
- do_action ("ws_plugin__s2member_during_nocache_constants", get_defined_vars ());
80
- }
81
- /**/
82
- do_action ("ws_plugin__s2member_after_nocache_constants", get_defined_vars ());
83
- /**/
84
- return; /* Return for uniformity. */
85
- }
86
- /*
87
- Sends Cache-Control ( no-cache ) headers.
88
- This uses the nocache_headers() function provided by WordPress®.
89
- This is compatible with the Quick Cache parameter ?qcABC=1 as well.
90
- * Always obey the qcABC param that specifically allows browser caching.
91
- */
92
- public static function nocache_headers () /* Cache-Control header. */
93
- {
94
- static $once; /* We only need to set these headers one time. */
95
- /**/
96
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
97
- do_action ("ws_plugin__s2member_before_nocache_headers", get_defined_vars ());
98
- unset ($__refs, $__v); /* Unset defined __refs, __v. */
99
- /**/
100
- $using_selective_behavior = apply_filters ("ws_plugin__s2member_nocache_headers_selective", false, get_defined_vars ());
101
- $selective = $GLOBALS["ws_plugin__s2member_nocache_headers_selective"]; /* Selective ( i.e. required ) ? */
102
- /**/
103
- if (!$once && !$_GET["qcABC"] && (!$using_selective_behavior || $selective) && !apply_filters ("ws_plugin__s2member_disable_nocache_headers", false, get_defined_vars ()))
104
- {
105
- if (is_array ($headers = headers_list ()))
106
- foreach ($headers as $header) /* Already? */
107
- if (stripos ($header, "no-cache") !== false)
108
- $no_cache_already_sent = true;
109
- /**/
110
- if (!$no_cache_already_sent)
111
- nocache_headers ();
112
- /**/
113
- $once = true; /* Only need to set these headers once. */
114
- /**/
115
- do_action ("ws_plugin__s2member_during_nocache_headers", get_defined_vars ());
116
- }
117
- /**/
118
- do_action ("ws_plugin__s2member_after_nocache_headers", get_defined_vars ());
119
- /**/
120
- return; /* Return for uniformity. */
121
- }
122
- }
123
- }
124
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/classes/op-notices.inc.php CHANGED
@@ -1,26 +1,41 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_op_notices"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_op_notices
20
  {
21
- /*
22
- Function that describes the General Option overrides for clarity.
23
- Attach to: add_action("load-options-general.php");
 
 
 
 
 
 
24
  */
25
  public static function general_ops_notice ()
26
  {
@@ -28,7 +43,7 @@ if (!class_exists ("c_ws_plugin__s2member_op_notices"))
28
  /**/
29
  do_action ("ws_plugin__s2member_before_general_ops_notice", get_defined_vars ());
30
  /**/
31
- if (c_ws_plugin__s2member_utils_conds::is_blog_admin () && $pagenow === "options-general.php" && !isset ($_GET["page"]) && !is_multisite ()) /* Multisite does NOT provide these options. */
32
  {
33
  $notice = "<em>* Note: The s2Member plugin has control over two options on this page.<br /><code>Allow Open Registration = " . esc_html (get_option ("users_can_register")) . "</code>, and <code>Default Role = " . esc_html (get_option ("default_role")) . "</code>.<br />For further details, see: <code>s2Member -> General Options -> Open Registration</code>.";
34
  /**/
@@ -45,10 +60,15 @@ if (!class_exists ("c_ws_plugin__s2member_op_notices"))
45
  /**/
46
  return; /* Return for uniformity. */
47
  }
48
- /*
49
- Function that describes the Multisite Option overrides for clarity.
50
- Attach to: add_action("load-ms-options.php");
51
- Attach to: add_action("load-settings.php");
 
 
 
 
 
52
  */
53
  public static function multisite_ops_notice ()
54
  {
@@ -56,24 +76,13 @@ if (!class_exists ("c_ws_plugin__s2member_op_notices"))
56
  /**/
57
  do_action ("ws_plugin__s2member_before_multisite_ops_notice", get_defined_vars ());
58
  /**/
59
- if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_network_admin () && in_array ($pagenow, array ("settings.php", "ms-options.php")) && !isset ($_GET["page"]))
60
  {
61
- if (version_compare (get_bloginfo ("version"), "3.1-RC", ">="))
62
- {
63
- $notice = "<em>* Note: The s2Member plugin has control over two options on this page.<br /><code>Allow Open Registration = " . esc_html (get_site_option ("registration")) . "</code> and <code>Add New Users = " . esc_html (get_site_option ("add_new_users")) . "</code>.<br />Please check: <code>s2Member -> Multisite ( Config )</code>.";
64
- /**/
65
- $js = '<script type="text/javascript">';
66
- $js .= "jQuery('input[name=registration], input#add_new_users').attr('disabled', 'disabled');";
67
- $js .= '</script>';
68
- }
69
- else /* Else we use the old WordPress® v3.0.x method of disabling these important options on the `ms-options.php` page. */
70
- {
71
- $notice = "<em>* Note: The s2Member plugin has control over four options on this page.<br /><code>Dashboard Blog = " . esc_html (get_site_option ("dashboard_blog")) . " / Main Site</code>, <code>Default Role = " . esc_html (get_site_option ("default_user_role")) . "</code>, <code>Allow Open Registration = " . esc_html (get_site_option ("registration")) . "</code>, and <code>Add New Users = " . esc_html (get_site_option ("add_new_users")) . "</code>.<br />In your Dashboard ( on the Main Site ), see: <code>s2Member -> Multisite ( Config )</code>.";
72
- /**/
73
- $js = '<script type="text/javascript">';
74
- $js .= "jQuery('input#dashboard_blog, select#default_user_role, input[name=registration], input#add_new_users').attr('disabled', 'disabled');";
75
- $js .= '</script>';
76
- }
77
  /**/
78
  do_action ("ws_plugin__s2member_during_multisite_ops_notice", get_defined_vars ());
79
  /**/
@@ -84,9 +93,15 @@ if (!class_exists ("c_ws_plugin__s2member_op_notices"))
84
  /**/
85
  return; /* Return for uniformity. */
86
  }
87
- /*
88
- Function that deals with Reading Option conflicts.
89
- Attach to: add_action("load-options-reading.php");
 
 
 
 
 
 
90
  */
91
  public static function reading_ops_notice ()
92
  {
@@ -94,7 +109,7 @@ if (!class_exists ("c_ws_plugin__s2member_op_notices"))
94
  /**/
95
  do_action ("ws_plugin__s2member_before_reading_ops_notice", get_defined_vars ());
96
  /**/
97
- if (c_ws_plugin__s2member_utils_conds::is_blog_admin () && $pagenow === "options-reading.php" && !isset ($_GET["page"]))
98
  {
99
  do_action ("ws_plugin__s2member_during_reading_ops_notice", get_defined_vars ()); /* Now check for conflicts. */
100
  /**/
1
  <?php
2
+ /**
3
+ * Option panel notices.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Option_Notices
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_op_notices"))
21
  {
22
+ /**
23
+ * Option panel notices.
24
+ *
25
+ * @package s2Member\Option_Notices
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_op_notices
29
  {
30
+ /**
31
+ * Describes the General Option overrides for clarity.
32
+ *
33
+ * @package s2Member\Option_Notices
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_action("load-options-general.php");``
37
+ *
38
+ * @return null
39
  */
40
  public static function general_ops_notice ()
41
  {
43
  /**/
44
  do_action ("ws_plugin__s2member_before_general_ops_notice", get_defined_vars ());
45
  /**/
46
+ if (is_blog_admin () && $pagenow === "options-general.php" && !isset ($_GET["page"]) && !is_multisite ()) /* Multisite does NOT provide these options. */
47
  {
48
  $notice = "<em>* Note: The s2Member plugin has control over two options on this page.<br /><code>Allow Open Registration = " . esc_html (get_option ("users_can_register")) . "</code>, and <code>Default Role = " . esc_html (get_option ("default_role")) . "</code>.<br />For further details, see: <code>s2Member -> General Options -> Open Registration</code>.";
49
  /**/
60
  /**/
61
  return; /* Return for uniformity. */
62
  }
63
+ /**
64
+ * Describes the Multisite Option overrides for clarity.
65
+ *
66
+ * @package s2Member\Option_Notices
67
+ * @since 3.5
68
+ *
69
+ * @attaches-to: ``add_action("load-settings.php");``
70
+ *
71
+ * @return null
72
  */
73
  public static function multisite_ops_notice ()
74
  {
76
  /**/
77
  do_action ("ws_plugin__s2member_before_multisite_ops_notice", get_defined_vars ());
78
  /**/
79
+ if (is_multisite () && is_network_admin () && in_array ($pagenow, array ("settings.php")) && !isset ($_GET["page"]))
80
  {
81
+ $notice = "<em>* Note: The s2Member plugin has control over two options on this page.<br /><code>Allow Open Registration = " . esc_html (get_site_option ("registration")) . "</code> and <code>Add New Users = " . esc_html (get_site_option ("add_new_users")) . "</code>.<br />Please check: <code>s2Member -> Multisite ( Config )</code>.";
82
+ /**/
83
+ $js = '<script type="text/javascript">';
84
+ $js .= "jQuery('input[name=registration], input#add_new_users').attr('disabled', 'disabled');";
85
+ $js .= '</script>';
 
 
 
 
 
 
 
 
 
 
 
86
  /**/
87
  do_action ("ws_plugin__s2member_during_multisite_ops_notice", get_defined_vars ());
88
  /**/
93
  /**/
94
  return; /* Return for uniformity. */
95
  }
96
+ /**
97
+ * Deals with Reading Option conflicts.
98
+ *
99
+ * @package s2Member\Option_Notices
100
+ * @since 3.5
101
+ *
102
+ * @attaches-to: ``add_action("load-options-reading.php");``
103
+ *
104
+ * @return null
105
  */
106
  public static function reading_ops_notice ()
107
  {
109
  /**/
110
  do_action ("ws_plugin__s2member_before_reading_ops_notice", get_defined_vars ());
111
  /**/
112
+ if (is_blog_admin () && $pagenow === "options-reading.php" && !isset ($_GET["page"]))
113
  {
114
  do_action ("ws_plugin__s2member_during_reading_ops_notice", get_defined_vars ()); /* Now check for conflicts. */
115
  /**/
includes/classes/option-forces.inc.php CHANGED
@@ -1,26 +1,42 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_option_forces"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_option_forces
20
  {
21
- /*
22
- Forces a default Role for new registrations, NOT tied to an incoming payment.
23
- Attach to: add_filter("pre_option_default_role");
 
 
 
 
 
 
 
24
  */
25
  public static function force_default_role ($default_role = FALSE)
26
  {
@@ -28,9 +44,16 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
28
  /**/
29
  return apply_filters ("ws_plugin__s2member_force_default_role", ($default_role = "subscriber"), get_defined_vars ());
30
  }
31
- /*
32
- Forces a default Role for new Multisite registrations ( on the Main Site ) NOT tied to an incoming payment.
33
- Attach to: add_filter("pre_site_option_default_user_role");
 
 
 
 
 
 
 
34
  */
35
  public static function force_mms_default_role ($default_role = FALSE)
36
  {
@@ -38,9 +61,16 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
38
  /**/
39
  return apply_filters ("ws_plugin__s2member_force_mms_default_role", ($default_role = "subscriber"), get_defined_vars ());
40
  }
41
- /*
42
- Forces a specific Role to demote to; whenever a Member is demoted in one way or another.
43
- Use by PayPal® IPN routines, and also by the Auto-EOT system.
 
 
 
 
 
 
 
44
  */
45
  public static function force_demotion_role ($demotion_role = FALSE)
46
  {
@@ -48,9 +78,16 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
48
  /**/
49
  return apply_filters ("ws_plugin__s2member_force_demotion_role", ($demotion_role = "subscriber"), get_defined_vars ());
50
  }
51
- /*
52
- Allows new Users to be created on a Multisite Network.
53
- Attach to: add_filter("pre_site_option_add_new_users");
 
 
 
 
 
 
 
54
  */
55
  public static function mms_allow_new_users ($allow = FALSE)
56
  {
@@ -58,9 +95,16 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
58
  /**/
59
  return apply_filters ("ws_plugin__s2member_mms_allow_new_users", ($allow = "1"), get_defined_vars ());
60
  }
61
- /*
62
- Forces a Multisite Dashboard Blog to be the Main Site.
63
- Attach to: add_filter("pre_site_option_dashboard_blog");
 
 
 
 
 
 
 
64
  */
65
  public static function mms_dashboard_blog ($dashboard_blog = FALSE)
66
  {
@@ -68,14 +112,20 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
68
  /**/
69
  do_action ("ws_plugin__s2member_before_mms_dashboard_blog", get_defined_vars ());
70
  /**/
71
- $main_site = ( (is_multisite ()) ? $current_site->blog_id : "1"); /* Forces the Main Site. */
72
  /**/
73
  return apply_filters ("ws_plugin__s2member_mms_dashboard_blog", ($dashboard_blog = $main_site), get_defined_vars ());
74
  }
75
- /*
76
- Function for allowing access to the Registration Form.
77
- This function has been further optimized to reduce DB queries.
78
- Attach to: add_filter("pre_option_users_can_register");
 
 
 
 
 
 
79
  */
80
  public static function check_register_access ($users_can_register = FALSE)
81
  {
@@ -93,7 +143,7 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
93
  else if (!is_admin () && !$users_can_register) /* Do NOT run these security checks on option pages; it's confusing to a site owner. */
94
  if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || !is_main_site () || is_super_admin () || current_user_can ("create_users"))
95
  {
96
- if ((is_multisite () && is_super_admin ()) || current_user_can ("create_users") || ( ($subscr_gateway = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_subscr_gateway"])) && ($subscr_id = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_subscr_id"])) && preg_match ("/^" . preg_quote (preg_replace ("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", ($custom = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_custom"]))) && preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", ($level = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_level"]))) && ! ($exists = $wpdb->get_var ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($subscr_id) . "' LIMIT 1"))))
97
  {
98
  return apply_filters ("ws_plugin__s2member_check_register_access", ($users_can_register = "1"), get_defined_vars ());
99
  }
@@ -101,10 +151,16 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
101
  /**/
102
  return apply_filters ("ws_plugin__s2member_check_register_access", $users_can_register, get_defined_vars ());
103
  }
104
- /*
105
- Function for allowing access to the main Multisite Registration Form.
106
- This function has been further optimized to reduce DB queries.
107
- Attach to: add_filter("pre_site_option_registration");
 
 
 
 
 
 
108
  */
109
  public static function check_mms_register_access ($users_can_register = FALSE)
110
  {
@@ -118,14 +174,14 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
118
  $by_default = $users_can_register = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_grants"];
119
  /**/
120
  if (defined ("BP_VERSION") && is_multisite () && /* BP Multisite / but NOT offering Blogs? */ !c_ws_plugin__s2member_utils_conds::is_multisite_farm ())
121
- return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = ( (c_ws_plugin__s2member_option_forces::check_register_access ()) ? "user" : "none")), get_defined_vars ());
122
  /**/
123
  else if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || !is_main_site ()) /* Blog Farm? */
124
  return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "none"), get_defined_vars ());
125
  /**/
126
  else if (!is_admin () && $users_can_register !== "all") /* Do NOT run these checks on option pages; it's confusing to a site owner. */
127
  {
128
- if (is_super_admin () || current_user_can ("create_users") || ( ($subscr_gateway = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_subscr_gateway"])) && ($subscr_id = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_subscr_id"])) && preg_match ("/^" . preg_quote (preg_replace ("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", ($custom = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_custom"]))) && preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", ($level = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_level"]))) && ! ($exists = $wpdb->get_var ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($subscr_id) . "' LIMIT 1"))))
129
  {
130
  if (is_super_admin () || current_user_can ("create_users")) /* Either a Super Administrator, or an Administrator that can create. */
131
  {
@@ -148,8 +204,9 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
148
  /* --------------------> $users_can_register !== "all", so exclude Level #0. */
149
  else if (is_user_logged_in () && current_user_can ("access_s2member_level1") && is_object ($user = wp_get_current_user ()) && $user->ID)
150
  {
151
- $blogs_allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_blogs_level" . c_ws_plugin__s2member_user_access::user_access_level ()];
152
  $user_blogs = (is_array ($blogs = get_blogs_of_user ($user->ID))) ? count ($blogs) - 1 : 0;
 
153
  $user_blogs = ($user_blogs >= 0) ? $user_blogs : 0; /* NOT less than zero. */
154
  $blogs_allowed = ($blogs_allowed >= 0) ? $blogs_allowed : 0;
155
  /**/
@@ -166,6 +223,7 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
166
  {
167
  $blogs_allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_blogs_level" . c_ws_plugin__s2member_user_access::user_access_level ()];
168
  $user_blogs = (is_array ($blogs = get_blogs_of_user ($user->ID))) ? count ($blogs) - 1 : 0;
 
169
  $user_blogs = ($user_blogs >= 0) ? $user_blogs : 0; /* NOT less than zero. */
170
  $blogs_allowed = ($blogs_allowed >= 0) ? $blogs_allowed : 0;
171
  /**/
@@ -178,12 +236,18 @@ if (!class_exists ("c_ws_plugin__s2member_option_forces"))
178
  /**/
179
  return apply_filters ("ws_plugin__s2member_check_mms_register_access", $users_can_register, get_defined_vars ());
180
  }
181
- /*
182
- This handles register access in BuddyPress - for Multisite compatibility.
183
- Attach to: add_filter("bp_core_get_site_options");
184
-
185
- BuddyPress bypasses the default Filter ( `pre_site_option_registration` )
186
- and instead, it uses: bp_core_get_site_options()
 
 
 
 
 
 
187
  */
188
  public static function check_bp_mms_register_access ($site_options = FALSE)
189
  {
1
  <?php
2
+ /**
3
+ * Forces WordPress® options.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Option_Forces
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_option_forces"))
21
  {
22
+ /**
23
+ * Forces WordPress® options.
24
+ *
25
+ * @package s2Member\Option_Forces
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_option_forces
29
  {
30
+ /**
31
+ * Forces a default Role for new registrations, NOT tied to an incoming payment.
32
+ *
33
+ * @package s2Member\Option_Forces
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_filter("pre_option_default_role");``
37
+ *
38
+ * @param str $default_role Expects a default Role to be passed by the Filter.
39
+ * @return str Default Role, as configured by s2Member.
40
  */
41
  public static function force_default_role ($default_role = FALSE)
42
  {
44
  /**/
45
  return apply_filters ("ws_plugin__s2member_force_default_role", ($default_role = "subscriber"), get_defined_vars ());
46
  }
47
+ /**
48
+ * Forces a default Role for new Multisite registrations ( on the Main Site ) NOT tied to an incoming payment.
49
+ *
50
+ * @package s2Member\Option_Forces
51
+ * @since 3.5
52
+ *
53
+ * @attaches-to: ``add_filter("pre_site_option_default_user_role");``
54
+ *
55
+ * @param str $default_role Expects a default Role to be passed by the Filter.
56
+ * @return str Default Role, as configured by s2Member.
57
  */
58
  public static function force_mms_default_role ($default_role = FALSE)
59
  {
61
  /**/
62
  return apply_filters ("ws_plugin__s2member_force_mms_default_role", ($default_role = "subscriber"), get_defined_vars ());
63
  }
64
+ /**
65
+ * Forces a specific Role to demote to, whenever a Member is demoted in one way or another.
66
+ *
67
+ * Use by the PayPal® IPN routines, and also by the Auto-EOT system.
68
+ *
69
+ * @package s2Member\Option_Forces
70
+ * @since 3.5
71
+ *
72
+ * @param str $demotion_role Expects a demotion Role to be passed by the caller.
73
+ * @return str Demotion Role, as configured by s2Member.
74
  */
75
  public static function force_demotion_role ($demotion_role = FALSE)
76
  {
78
  /**/
79
  return apply_filters ("ws_plugin__s2member_force_demotion_role", ($demotion_role = "subscriber"), get_defined_vars ());
80
  }
81
+ /**
82
+ * Allows new Users to be created on a Multisite Network.
83
+ *
84
+ * @package s2Member\Option_Forces
85
+ * @since 3.5
86
+ *
87
+ * @attaches-to: ``add_filter("pre_site_option_add_new_users");``
88
+ *
89
+ * @param int|str $allow Numeric string (`1`) or (`0`), expected by the Filter.
90
+ * @return str Numeric (`1`) or (`0`) indicating true or false. Forces to (`1`) true.
91
  */
92
  public static function mms_allow_new_users ($allow = FALSE)
93
  {
95
  /**/
96
  return apply_filters ("ws_plugin__s2member_mms_allow_new_users", ($allow = "1"), get_defined_vars ());
97
  }
98
+ /**
99
+ * Forces a Multisite Dashboard Blog to be the Main Site.
100
+ *
101
+ * @package s2Member\Option_Forces
102
+ * @since 3.5
103
+ *
104
+ * @attaches-to: ``add_filter("pre_site_option_dashboard_blog");``
105
+ *
106
+ * @param int|str $dashboard_blog Numeric Dashboard Blog ID passed through by the Filter.
107
+ * @return int|str Numeric Dashboard Blog ID, as configured by s2Member. Forces to the Main Site.
108
  */
109
  public static function mms_dashboard_blog ($dashboard_blog = FALSE)
110
  {
112
  /**/
113
  do_action ("ws_plugin__s2member_before_mms_dashboard_blog", get_defined_vars ());
114
  /**/
115
+ $main_site = ((is_multisite ()) ? $current_site->blog_id : "1"); /* Forces the Main Site. */
116
  /**/
117
  return apply_filters ("ws_plugin__s2member_mms_dashboard_blog", ($dashboard_blog = $main_site), get_defined_vars ());
118
  }
119
+ /**
120
+ * Allows access to the Registration Form.
121
+ *
122
+ * @package s2Member\Option_Forces
123
+ * @since 3.5
124
+ *
125
+ * @attaches-to: ``add_filter("pre_option_users_can_register");``
126
+ *
127
+ * @param int|str $users_can_register Numeric (`1`) or (`0`), indicating true or false; passed through by the Filter.
128
+ * @return str Numeric value of (`1`) or (`0`), indicating true or false; depending on several factors.
129
  */
130
  public static function check_register_access ($users_can_register = FALSE)
131
  {
143
  else if (!is_admin () && !$users_can_register) /* Do NOT run these security checks on option pages; it's confusing to a site owner. */
144
  if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || !is_main_site () || is_super_admin () || current_user_can ("create_users"))
145
  {
146
+ if ((is_multisite () && is_super_admin ()) || current_user_can ("create_users") || (($subscr_gateway = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_subscr_gateway"])) && ($subscr_id = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_subscr_id"])) && preg_match ("/^" . preg_quote (preg_replace ("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", ($custom = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_custom"]))) && preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", ($level = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_level"]))) && !($exists = $wpdb->get_var ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($subscr_id) . "' LIMIT 1"))))
147
  {
148
  return apply_filters ("ws_plugin__s2member_check_register_access", ($users_can_register = "1"), get_defined_vars ());
149
  }
151
  /**/
152
  return apply_filters ("ws_plugin__s2member_check_register_access", $users_can_register, get_defined_vars ());
153
  }
154
+ /**
155
+ * Allows access to the main Multisite Registration Form.
156
+ *
157
+ * @package s2Member\Option_Forces
158
+ * @since 3.5
159
+ *
160
+ * @attaches-to: ``add_filter("pre_site_option_registration");``
161
+ *
162
+ * @param str $users_can_register Expects *( `none`, `all`, or `user` )*, passed through by the Filter.
163
+ * @return str One of `none|all|user`; depending on several factors.
164
  */
165
  public static function check_mms_register_access ($users_can_register = FALSE)
166
  {
174
  $by_default = $users_can_register = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_grants"];
175
  /**/
176
  if (defined ("BP_VERSION") && is_multisite () && /* BP Multisite / but NOT offering Blogs? */ !c_ws_plugin__s2member_utils_conds::is_multisite_farm ())
177
+ return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = ((c_ws_plugin__s2member_option_forces::check_register_access ()) ? "user" : "none")), get_defined_vars ());
178
  /**/
179
  else if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || !is_main_site ()) /* Blog Farm? */
180
  return apply_filters ("ws_plugin__s2member_check_mms_register_access", ($users_can_register = "none"), get_defined_vars ());
181
  /**/
182
  else if (!is_admin () && $users_can_register !== "all") /* Do NOT run these checks on option pages; it's confusing to a site owner. */
183
  {
184
+ if (is_super_admin () || current_user_can ("create_users") || (($subscr_gateway = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_subscr_gateway"])) && ($subscr_id = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_subscr_id"])) && preg_match ("/^" . preg_quote (preg_replace ("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", ($custom = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_custom"]))) && preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", ($level = c_ws_plugin__s2member_utils_encryption::decrypt ($_COOKIE["s2member_level"]))) && !($exists = $wpdb->get_var ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($subscr_id) . "' LIMIT 1"))))
185
  {
186
  if (is_super_admin () || current_user_can ("create_users")) /* Either a Super Administrator, or an Administrator that can create. */
187
  {
204
  /* --------------------> $users_can_register !== "all", so exclude Level #0. */
205
  else if (is_user_logged_in () && current_user_can ("access_s2member_level1") && is_object ($user = wp_get_current_user ()) && $user->ID)
206
  {
207
+ $blogs_allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_blogs_level" . c_ws_plugin__s2member_user_access::user_access_level ($user)];
208
  $user_blogs = (is_array ($blogs = get_blogs_of_user ($user->ID))) ? count ($blogs) - 1 : 0;
209
+ /**/
210
  $user_blogs = ($user_blogs >= 0) ? $user_blogs : 0; /* NOT less than zero. */
211
  $blogs_allowed = ($blogs_allowed >= 0) ? $blogs_allowed : 0;
212
  /**/
223
  {
224
  $blogs_allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_blogs_level" . c_ws_plugin__s2member_user_access::user_access_level ()];
225
  $user_blogs = (is_array ($blogs = get_blogs_of_user ($user->ID))) ? count ($blogs) - 1 : 0;
226
+ /**/
227
  $user_blogs = ($user_blogs >= 0) ? $user_blogs : 0; /* NOT less than zero. */
228
  $blogs_allowed = ($blogs_allowed >= 0) ? $blogs_allowed : 0;
229
  /**/
236
  /**/
237
  return apply_filters ("ws_plugin__s2member_check_mms_register_access", $users_can_register, get_defined_vars ());
238
  }
239
+ /**
240
+ * Register access in BuddyPress, for Multisite compatibility.
241
+ *
242
+ * BuddyPress bypasses the default Filter `pre_site_option_registration`, and instead uses: ``bp_core_get_site_options()``.
243
+ *
244
+ * @package s2Member\Option_Forces
245
+ * @since 3.5
246
+ *
247
+ * @attaches-to: ``add_filter("bp_core_get_site_options");``
248
+ *
249
+ * @param array $site_options Expects array of BuddyPress site options.
250
+ * @return array Site options array, after having been Filtered by this routine.
251
  */
252
  public static function check_bp_mms_register_access ($site_options = FALSE)
253
  {
includes/classes/pages-sp.inc.php CHANGED
@@ -1,37 +1,41 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_pages_sp"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_pages_sp
20
  {
21
- /*
22
- Checks Page Level Access permissions - for a specific Page.
23
-
24
- Don't call this function directly, use one of these API functions:
25
-
26
- Is it protected by s2Member at all?
27
- - is_page_protected_by_s2member($page_id);
28
- - is_protected_by_s2member($page_id, "page");
29
-
30
- Is the current User permitted/authorized?
31
- - is_page_permitted_by_s2member($page_id);
32
- - is_permitted_by_s2member($page_id, "page");
33
-
34
- See: `/s2member/includes/functions/api-functions.inc.php`.
35
  */
36
  public static function check_specific_page_level_access ($page_id = FALSE, $check_user = TRUE)
37
  {
@@ -41,56 +45,53 @@ if (!class_exists ("c_ws_plugin__s2member_pages_sp"))
41
  /**/
42
  if (!$excluded && $page_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Check? */
43
  {
44
- $page_link = get_page_link ($page_id); /* Determine link to this Page. */
45
- $page_path = parse_url ($page_link, PHP_URL_PATH); /* Parse req path. */
46
- $page_query = parse_url ($page_link, PHP_URL_QUERY); /* Parse query. */
47
- $page_uri = ($page_query) ? $page_path . "?" . $page_query : $page_path;
48
  /**/
49
- $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
50
  /**/
51
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && (!$check_user || !$current_user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
52
  return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
53
  /**/
54
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $page_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
55
  return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
56
  /**/
57
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && (!$check_user || !$current_user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
58
  return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
59
  /**/
60
- else if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page ($page_id, $page_uri)) /* However, there are 3 exceptions above ^. */
61
  {
62
- for ($i = 0; $i <= 4; $i++) /* Page Level restrictions. Go through each Membership Level. */
63
  {
64
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"] === "all" && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
65
- return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
66
  /**/
67
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"])) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
68
- return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
69
  }
70
  /**/
71
  if (has_tag ("", $page_id)) /* Here we take a look to see if this Page has any Tags. If so, we need to run the full set of routines against Tags also. */
72
  {
73
- for ($i = 0; $i <= 4; $i++) /* Tag Level restrictions ( possibly through Page Tagger ). Go through each Membership Level. */
74
  {
75
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] === "all" && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
76
- return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
77
  /**/
78
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"]), $page_id) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
79
- return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
80
  }
81
  }
82
  /**/
83
- for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
84
  {
85
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
86
- foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
87
- if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $page_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
88
- return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
89
  }
90
  /**/
91
  if (is_array ($ccaps_req = get_post_meta ($page_id, "s2member_ccaps_req", true)) && !empty ($ccaps_req))
92
- foreach ($ccaps_req as $ccap) /* The $current_user MUST satisfy ALL Custom Capabilities. Serialized array. */
93
- if (strlen ($ccap) && (!$check_user || !$current_user || !$current_user->has_cap ("access_s2member_ccap_" . $ccap)))
94
  return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_ccap_req" => $ccap), get_defined_vars ());
95
  /**/
96
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && (!$check_user || !c_ws_plugin__s2member_sp_access::sp_access ($page_id, "read-only")))
1
  <?php
2
+ /**
3
+ * s2Member's Page protection routines *( for specific Pages )*.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Pages
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_pages_sp"))
21
  {
22
+ /**
23
+ * s2Member's Page protection routines *( for specific Pages )*.
24
+ *
25
+ * @package s2Member\Pages
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_pages_sp
29
  {
30
+ /**
31
+ * Handles Page Level Access *( for specific Pages )*.
32
+ *
33
+ * @package s2Member\Pages
34
+ * @since 3.5
35
+ *
36
+ * @param int|str $page_id Numeric Page ID.
37
+ * @param bool $check_user Test permissions against the current User? Defaults to true.
38
+ * @return null|array Non-empty array ( with details ) if access is denied, else null if access is allowed.
 
 
 
 
 
39
  */
40
  public static function check_specific_page_level_access ($page_id = FALSE, $check_user = TRUE)
41
  {
45
  /**/
46
  if (!$excluded && $page_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Check? */
47
  {
48
+ $page_uri = c_ws_plugin__s2member_utils_urls::parse_uri (get_page_link ($page_id));
 
 
 
49
  /**/
50
+ $user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
51
  /**/
52
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && (!$check_user || !$user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
53
  return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
54
  /**/
55
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $page_uri) && (!$check_user || !$user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
56
  return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
57
  /**/
58
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && (!$check_user || !$user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
59
  return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
60
  /**/
61
+ else if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page ($page_id, $page_uri)) /* However, there are 3 exceptions ^. */
62
  {
63
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* Page Level restrictions. Go through each Level. */
64
  {
65
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] === "all" && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
66
+ return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
67
  /**/
68
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"])) && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
69
+ return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
70
  }
71
  /**/
72
  if (has_tag ("", $page_id)) /* Here we take a look to see if this Page has any Tags. If so, we need to run the full set of routines against Tags also. */
73
  {
74
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* Tag Level restrictions ( possibly through Page Tagger ). Go through each Level. */
75
  {
76
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] === "all" && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
77
+ return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
78
  /**/
79
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"]), $page_id) && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
80
+ return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
81
  }
82
  }
83
  /**/
84
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* URIs. Go through each Level. */
85
  {
86
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"])
87
+ foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str)
88
+ if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $page_uri) && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
89
+ return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
90
  }
91
  /**/
92
  if (is_array ($ccaps_req = get_post_meta ($page_id, "s2member_ccaps_req", true)) && !empty ($ccaps_req))
93
+ foreach ($ccaps_req as $ccap) /* The $user MUST satisfy ALL Custom Capabilities. Serialized array. */
94
+ if (strlen ($ccap) && (!$check_user || !$user || !$user->has_cap ("access_s2member_ccap_" . $ccap)))
95
  return apply_filters ("ws_plugin__s2member_check_specific_page_level_access", array ("s2member_ccap_req" => $ccap), get_defined_vars ());
96
  /**/
97
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && (!$check_user || !c_ws_plugin__s2member_sp_access::sp_access ($page_id, "read-only")))
includes/classes/pages.inc.php CHANGED
@@ -1,37 +1,39 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_pages"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_pages
20
  {
21
- /*
22
- Handles Page Level Access permissions.
23
-
24
- Don't call this function directly, use one of these API functions:
25
-
26
- Is it protected by s2Member at all?
27
- - is_page_protected_by_s2member($page_id);
28
- - is_protected_by_s2member($page_id, "page");
29
-
30
- Is the current User permitted/authorized?
31
- - is_page_permitted_by_s2member($page_id);
32
- - is_permitted_by_s2member($page_id, "page");
33
-
34
- See: `/s2member/includes/functions/api-functions.inc.php`.
35
  */
36
  public static function check_page_level_access ()
37
  {
@@ -43,78 +45,78 @@ if (!class_exists ("c_ws_plugin__s2member_pages"))
43
  /**/
44
  if (!$excluded && is_page () && is_object ($post) && ($page_id = $post->ID) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
45
  {
46
- $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
47
  /**/
48
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
49
  {
50
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_level_req" => "0")), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
51
  exit ();
52
  }
53
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
54
  {
55
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_level_req" => "0")), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
56
  exit ();
57
  }
58
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
59
  {
60
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_level_req" => "0")), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
61
  exit ();
62
  }
63
- else if (!c_ws_plugin__s2member_systematics::is_systematic_use_page ()) /* Never restrict Systematic Use Pages. However, there are 3 exceptions above ^. */
64
  {
65
- for ($i = 0; $i <= 4; $i++) /* Page Level restrictions. Go through each Membership Level. */
66
  {
67
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"] === "all" && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
68
  {
69
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
70
  exit ();
71
  }
72
  /**/
73
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_pages"])) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
74
  {
75
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
76
  exit ();
77
  }
78
  }
79
  /**/
80
  if (has_tag ()) /* Here we take a look to see if this Page has any Tags. If so, we need to run the full set of routines against Tags also. */
81
  {
82
- for ($i = 0; $i <= 4; $i++) /* Tag Level restrictions ( possibly through Page Tagger ). Go through each Membership Level. */
83
  {
84
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] === "all" && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
85
  {
86
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
87
  exit ();
88
  }
89
  /**/
90
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"])) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
91
  {
92
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
93
  exit ();
94
  }
95
  }
96
  }
97
  /**/
98
- for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
99
  {
100
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
101
- foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
102
- if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
103
  {
104
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
105
  exit ();
106
  }
107
  }
108
  /**/
109
- if (is_array ($ccaps_req = get_post_meta ($page_id, "s2member_ccaps_req", true)) && !empty ($ccaps_req) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill")
110
- foreach ($ccaps_req as $ccap) /* The $current_user MUST satisfy ALL Custom Capability requirements. Stored as a serialized array. */
111
- if (strlen ($ccap) && (!$current_user || !$current_user->has_cap ("access_s2member_ccap_" . $ccap)))
112
  {
113
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_ccap_req" => $ccap)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
114
  exit ();
115
  }
116
  /**/
117
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && !c_ws_plugin__s2member_sp_access::sp_access ($page_id))
118
  {
119
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_sp_req" => $page_id)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
120
  exit ();
1
  <?php
2
+ /**
3
+ * s2Member's Page protection routines *( for current Page )*.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Pages
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_pages"))
21
  {
22
+ /**
23
+ * s2Member's Page protection routines *( for current Page )*.
24
+ *
25
+ * @package s2Member\Pages
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_pages
29
  {
30
+ /**
31
+ * Handles Page Level Access permissions *( for current Page )*.
32
+ *
33
+ * @package s2Member\Pages
34
+ * @since 3.5
35
+ *
36
+ * @return null Or exits script execution after redirection.
 
 
 
 
 
 
 
37
  */
38
  public static function check_page_level_access ()
39
  {
45
  /**/
46
  if (!$excluded && is_page () && is_object ($post) && ($page_id = $post->ID) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
47
  {
48
+ $user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
49
  /**/
50
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
51
  {
52
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_level_req" => "0")), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
53
  exit ();
54
  }
55
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
56
  {
57
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_level_req" => "0")), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
58
  exit ();
59
  }
60
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && $page_id == $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level0")) && $page_id != $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
61
  {
62
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_level_req" => "0")), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
63
  exit ();
64
  }
65
+ else if (!c_ws_plugin__s2member_systematics::is_systematic_use_page ()) /* Never restrict Systematics. However, there are 3 exceptions ^. */
66
  {
67
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* Page Level restrictions. Go through each Level. */
68
  {
69
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
70
  {
71
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_level_req" => $n)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
72
  exit ();
73
  }
74
  /**/
75
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"])) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
76
  {
77
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_level_req" => $n)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
78
  exit ();
79
  }
80
  }
81
  /**/
82
  if (has_tag ()) /* Here we take a look to see if this Page has any Tags. If so, we need to run the full set of routines against Tags also. */
83
  {
84
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* Tag Level restrictions ( possibly through Page Tagger ). Go through each Level. */
85
  {
86
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
87
  {
88
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_level_req" => $n)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
89
  exit ();
90
  }
91
  /**/
92
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"])) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
93
  {
94
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_level_req" => $n)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
95
  exit ();
96
  }
97
  }
98
  }
99
  /**/
100
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* URIs. Go through each Level. */
101
  {
102
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"])
103
+ foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str)
104
+ if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
105
  {
106
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_level_req" => $n)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
107
  exit ();
108
  }
109
  }
110
  /**/
111
+ if (is_array ($ccaps_req = get_post_meta ($page_id, "s2member_ccaps_req", true)) && !empty ($ccaps_req) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill")
112
+ foreach ($ccaps_req as $ccap) /* The $user MUST satisfy ALL Custom Capability requirements. Stored as a serialized array. */
113
+ if (strlen ($ccap) && (!$user || !$user->has_cap ("access_s2member_ccap_" . $ccap)))
114
  {
115
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_ccap_req" => $ccap)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
116
  exit ();
117
  }
118
  /**/
119
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array ($page_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && !c_ws_plugin__s2member_sp_access::sp_access ($page_id))
120
  {
121
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "page-" . $page_id, "s2member_sp_req" => $page_id)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
122
  exit ();
includes/classes/paypal-notify-in.inc.php CHANGED
@@ -1,36 +1,54 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_paypal_notify_in
20
  {
21
- /*
22
- Handles PayPal® IPN URL processing.
23
- These same routines also handle s2Member Pro/PayPal® Pro operations;
24
- giving you the ability ( as needed ) to Hook into these routines using
25
- WordPress® Hooks/Filters; as seen in the source code below.
26
-
27
- Please do NOT modify the source code directly.
28
- Instead, use WordPress® Hooks/Filters.
29
-
30
- For example, if you'd like to add your own custom conditionals, use:
31
- add_filter ("ws_plugin__s2member_during_paypal_notify_conditionals", "your_function");
32
-
33
- Attach to: add_action("init");
 
 
 
 
 
 
 
 
 
34
  */
35
  public static function paypal_notify ()
36
  {
@@ -38,9 +56,9 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
38
  /**/
39
  do_action ("ws_plugin__s2member_before_paypal_notify", get_defined_vars ());
40
  /**/
41
- if ($_GET["s2member_paypal_notify"] && ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] || $_GET["s2member_paypal_proxy"]))
42
  {
43
- @ignore_user_abort(true); /* Important. Continue processing even if/when the connection is broken by the sending party. */
44
  /**/
45
  include_once ABSPATH . "wp-admin/includes/admin.php"; /* Get administrative functions. Needed for `wp_delete_user()`. */
46
  /**/
@@ -49,7 +67,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
49
  if (is_array ($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_postvars ()) && ($_paypal = $paypal))
50
  {
51
  $paypal["s2member_log"][] = "IPN received on: " . date ("D M j, Y g:i:s a T");
52
- $paypal["s2member_log"][] = "s2Member POST vars verified " . ( ($paypal["proxy_verified"]) ? "with a Proxy Key" : "through a POST back to PayPal®.");
53
  /**/
54
  $payment_status_issues = "/^(failed|denied|expired|refunded|partially_refunded|reversed|reversal|canceled_reversal|voided)$/i";
55
  /**/
@@ -77,8 +95,8 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
77
  be necessary in a future release of s2Member. For now, it's just a fill-in.
78
  These Hooks/Filters will remain, so you can use them now; if you need to.
79
  */
80
- if (/**/(preg_match ("/^virtual_terminal$/i",$paypal["txn_type"]))/**/
81
- && (!preg_match ($payment_status_issues,$paypal["payment_status"]))/**/
82
  && ($paypal["txn_id"])/**/)
83
  {
84
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
@@ -105,8 +123,8 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
105
  be necessary in a future release of s2Member. For now, it's just a fill-in.
106
  These Hooks/Filters will remain, so you can use them now; if you need to.
107
  */
108
- else if (/**/(preg_match ("/^express_checkout$/i",$paypal["txn_type"]))/**/
109
- && (!preg_match ($payment_status_issues,$paypal["payment_status"]))/**/
110
  && ($paypal["txn_id"])/**/)
111
  {
112
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
@@ -134,8 +152,8 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
134
  be necessary in a future release of s2Member. For now, it's just a fill-in.
135
  These Hooks/Filters will remain, so you can use them now; if you need to.
136
  */
137
- else if (/**/(preg_match ("/^cart$/i",$paypal["txn_type"]))/**/
138
- && (!preg_match ($payment_status_issues,$paypal["payment_status"]))/**/
139
  && ($paypal["txn_id"])/**/)
140
  {
141
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
@@ -163,8 +181,8 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
163
  be necessary in a future release of s2Member. For now, it's just a fill-in.
164
  These Hooks/Filters will remain, so you can use them now; if you need to.
165
  */
166
- else if (/**/(preg_match ("/^send_money$/i",$paypal["txn_type"]))/**/
167
- && (!preg_match ($payment_status_issues,$paypal["payment_status"]))/**/
168
  && ($paypal["txn_id"])/**/)
169
  {
170
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
@@ -188,9 +206,9 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
188
  /*
189
  Specific Post/Page Access ~ Sales.
190
  */
191
- else if (/**/(preg_match ("/^web_accept$/i",$paypal["txn_type"]))/**/
192
- && (preg_match ("/^sp\:[0-9,]+\:[0-9]+$/",$paypal["item_number"]))/**/
193
- && (!preg_match ($payment_status_issues,$paypal["payment_status"]))/**/
194
  && ($paypal["payer_email"] && $paypal["txn_id"])/**/)
195
  {
196
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
@@ -201,17 +219,31 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
201
  /**/
202
  list (, $paypal["sp_ids"], $paypal["hours"]) = preg_split ("/\:/", $paypal["item_number"], 3);
203
  /**/
 
 
 
204
  if (($sp_access_url = c_ws_plugin__s2member_sp_access::sp_access_link_gen ($paypal["sp_ids"], $paypal["hours"])) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
205
  {
206
  $processing = $during = true; /* Yes, we ARE processing this. */
207
  /**/
208
- $sbj = preg_replace ("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][ ( ($_GET["s2member_paypal_proxy"] && preg_match ("/pro-emails/",$_GET["s2member_paypal_proxy_use"])) ? "pro_" : "") . "sp_email_subject"]);
 
 
 
 
 
 
 
 
 
 
 
209
  $sbj = preg_replace ("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours"))), $sbj);
210
  /**/
211
- $msg = preg_replace ("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][ ( ($_GET["s2member_paypal_proxy"] && preg_match ("/pro-emails/",$_GET["s2member_paypal_proxy_use"])) ? "pro_" : "") . "sp_email_message"]);
212
  $msg = preg_replace ("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours"))), $msg);
213
  /**/
214
- $rec = preg_replace ("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][ ( ($_GET["s2member_paypal_proxy"] && preg_match ("/pro-emails/",$_GET["s2member_paypal_proxy_use"])) ? "pro_" : "") . "sp_email_recipients"]);
215
  $rec = preg_replace ("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours"))), $rec);
216
  /**/
217
  if (($rec = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $rec)) && ($rec = preg_replace ("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["txn_id"]), $rec)))
@@ -220,28 +252,31 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
220
  if (($rec = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq (c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"])), $rec)) && ($rec = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq (c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"])), $rec)))
221
  if (($rec = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq (c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $rec))) /* **NOTE** c_ws_plugin__s2member_utils_strings::esc_dq() is applied here. ( ex. "N\"ame" <email> ). */
222
  if (($rec = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $rec)))
223
- /**/
224
- if (($sbj = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)) && ($sbj = preg_replace ("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["txn_id"]), $sbj)))
225
- if (($sbj = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["mc_gross"]), $sbj))) /* Full amount of the payment, before fee is subtracted. */
226
- if (($sbj = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_number"]), $sbj)) && ($sbj = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_name"]), $sbj)))
227
- if (($sbj = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $sbj)) && ($sbj = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $sbj)))
228
- if (($sbj = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)))
229
- if (($sbj = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $sbj)))
230
- /**/
231
- if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["txn_id"]), $msg)))
232
- if (($msg = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["mc_gross"]), $msg))) /* Full amount of the payment, before fee is subtracted. */
233
- if (($msg = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_name"]), $msg)))
234
- if (($msg = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $msg)))
235
- if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
236
- if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
237
- /**/
238
- if (($recipients = preg_split ("/;+/", preg_replace ("/%%(.+?)%%/i", "", $rec))) && ($sbj = trim (preg_replace ("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
239
- {
240
- foreach (c_ws_plugin__s2member_utils_strings::trim_deep ($recipients) as $recipient) /* Go through the full list of recipients. */
241
- ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_sp_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_sp_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
242
- /**/
243
- $paypal["s2member_log"][] = "Specific Post/Page Confirmation Email sent to: " . implode ("; ", $recipients) . ".";
244
- }
 
 
 
245
  /**/
246
  if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_urls"])
247
  {
@@ -254,9 +289,10 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
254
  if (($url = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["last_name"])), $url)))
255
  if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
256
  if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
257
- /**/
258
- if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
259
- c_ws_plugin__s2member_utils_urls::remote ($url);
 
260
  /**/
261
  $paypal["s2member_log"][] = "Specific Post/Page ~ Sale Notification URLs have been processed.";
262
  }
@@ -276,6 +312,8 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
276
  $msg .= "last_name: %%last_name%%\n";
277
  $msg .= "full_name: %%full_name%%\n";
278
  $msg .= "payer_email: %%payer_email%%\n";
 
 
279
  $msg .= "cv0: %%cv0%%\n";
280
  $msg .= "cv1: %%cv1%%\n";
281
  $msg .= "cv2: %%cv2%%\n";
@@ -294,10 +332,11 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
294
  if (($msg = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $msg)))
295
  if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
296
  if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
297
- /**/
298
- if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
299
- foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_recipients"])) as $recipient)
300
- ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_sp_sale_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_sp_sale_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
 
301
  /**/
302
  $paypal["s2member_log"][] = "Specific Post/Page ~ Sale Notification Emails have been processed.";
303
  }
@@ -311,10 +350,11 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
311
  if (($url = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["last_name"])), $url)))
312
  if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
313
  if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
314
- /**/
315
- if (($url = trim ($url))) /* Preserve Remaining replacements. */
316
- /* Because the parent routine may perform replacements too. */
317
- $paypal["s2member_paypal_proxy_return_url"] = $url;
 
318
  /**/
319
  $paypal["s2member_log"][] = "Specific Post/Page Return, a Proxy Return URL is ready.";
320
  }
@@ -326,12 +366,13 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
326
  if (($code = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $code)) && ($code = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $code)))
327
  if (($code = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
328
  if (($code = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $code)))
329
- /**/
330
- if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code)))) /* This gets stored into a Transient Queue. */
331
- {
332
- $paypal["s2member_log"][] = "Storing Specific Post/Page Tracking Codes into a Transient Queue. These will be processed on-site.";
333
- set_transient ("s2m_" . md5 ("s2member_transient_sp_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
334
- }
 
335
  }
336
  /**/
337
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
@@ -350,10 +391,10 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
350
  Possibly containing advanced update vars
351
  ( option_name1, option_selection1 ); which allow account modifications.
352
  */
353
- else if (/**/(preg_match ("/^(web_accept|subscr_signup)$/i",$paypal["txn_type"]))/**/
354
- && (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/",$paypal["item_number"]))/**/
355
  && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["txn_id"]))/**/
356
- && (!preg_match ($payment_status_issues,$paypal["payment_status"]))/**/
357
  && ($paypal["payer_email"])/**/)
358
  {
359
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
@@ -364,7 +405,10 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
364
  /**/
365
  list ($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split ("/\:/", $paypal["item_number"], 3);
366
  /**/
367
- $paypal["period1"] = (preg_match ("/^[1-9]/",$paypal["period1"])) ? $paypal["period1"] : "0 D"; /* Defaults to "0 D" ( zero days ). */
 
 
 
368
  $paypal["mc_amount1"] = (strlen ($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0) ? $paypal["mc_amount1"] : "0.00"; /* "0.00". */
369
  /**/
370
  if (preg_match ("/^web_accept$/i", $paypal["txn_type"])) /* Conversions for Lifetime & Fixed-Term sales. */
@@ -383,9 +427,9 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
383
  /*
384
  New Subscription with advanced update vars ( option_name1, option_selection1 )? These variables are used in Subscr. Modifications.
385
  */
386
- if (preg_match ("/(updat|upgrad)/i",$paypal["option_name1"]) && $paypal["option_selection1"]) /* This is an advanced way to handle Subscription update modifications. */
387
- /* 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
388
- modify=1|2 parameter to be used in those scenarios, because technically there is nothing to update. The only thing that actually needs to be updated is the account. */
389
  {
390
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
391
  do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_signup_w_update_vars", get_defined_vars ());
@@ -402,10 +446,12 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
402
  /**/
403
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
404
  do_action ("ws_plugin__s2member_during_paypal_notify_during_before_subscr_signup_w_update_vars", get_defined_vars ());
405
- do_action ("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars (), "ipn-upgrade-downgrade", "modification", $paypal["level"]);
406
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
407
  /**/
408
- $fields = get_user_option ("s2member_custom_fields", $user_id);
 
 
409
  /**/
410
  if (is_multisite () && !is_user_member_of_blog ($user_id))
411
  {
@@ -431,13 +477,20 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
431
  update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
432
  update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
433
  /**/
 
 
 
434
  update_user_option ($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
435
  /**/
436
  delete_user_option ($user_id, "s2member_file_download_access_arc");
437
  delete_user_option ($user_id, "s2member_file_download_access_log");
438
  /**/
439
  if (preg_match ("/^web_accept$/i", $paypal["txn_type"]) && $paypal["eotper"])
440
- update_user_option ($user_id, "s2member_auto_eot_time", c_ws_plugin__s2member_utils_time::auto_eot_time ("", "", "", $paypal["eotper"]));
 
 
 
 
441
  else /* Otherwise, we need to clear the Auto-EOT Time. */
442
  delete_user_option ($user_id, "s2member_auto_eot_time");
443
  /**/
@@ -454,6 +507,106 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
454
  /**/
455
  $paypal["s2member_log"][] = "Modification Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.";
456
  /**/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
457
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
458
  do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_signup_w_update_vars", get_defined_vars ());
459
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
@@ -483,47 +636,50 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
483
  {
484
  $processing = $during = true; /* Yes, we ARE processing this. */
485
  /**/
486
- $sbj = preg_replace ("/%%registration_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][ ( ($_GET["s2member_paypal_proxy"] && preg_match ("/pro-emails/",$_GET["s2member_paypal_proxy_use"])) ? "pro_" : "") . "signup_email_subject"]);
487
- $msg = preg_replace ("/%%registration_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][ ( ($_GET["s2member_paypal_proxy"] && preg_match ("/pro-emails/",$_GET["s2member_paypal_proxy_use"])) ? "pro_" : "") . "signup_email_message"]);
488
- $rec = preg_replace ("/%%registration_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][ ( ($_GET["s2member_paypal_proxy"] && preg_match ("/pro-emails/",$_GET["s2member_paypal_proxy_use"])) ? "pro_" : "") . "signup_email_recipients"]);
489
  /**/
490
  if (($rec = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $rec)) && ($rec = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["subscr_id"]), $rec)))
491
  if (($rec = preg_replace ("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial"]), $rec)) && ($rec = preg_replace ("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular"]), $rec)))
492
  if (($rec = preg_replace ("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial_term"]), $rec)) && ($rec = preg_replace ("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular_term"]), $rec)))
493
  if (($rec = preg_replace ("/%%initial_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::period_term ($paypal["initial_term"])), $rec)) && ($rec = preg_replace ("/%%regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::period_term ($paypal["regular_term"], $paypal["recurring"])), $rec)))
494
- if (($rec = preg_replace ("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["recurring"]), $rec)) && ($rec = preg_replace ("/%%recurring\/regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (( ($paypal["recurring"]) ? $paypal["recurring"] . " / " . c_ws_plugin__s2member_utils_time::period_term ($paypal["regular_term"], true) : "0 / non-recurring")), $rec)))
495
  if (($rec = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_number"]), $rec)) && ($rec = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_name"]), $rec)))
496
  if (($rec = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq (c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"])), $rec)) && ($rec = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq (c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"])), $rec)))
497
  if (($rec = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq (c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $rec))) /* **NOTE** c_ws_plugin__s2member_utils_strings::esc_dq() is applied here. ( ex. "N\"ame" <email> ). */
498
  if (($rec = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $rec)))
499
- /**/
500
- if (($sbj = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)) && ($sbj = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["subscr_id"]), $sbj)))
501
- if (($sbj = preg_replace ("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial"]), $sbj)) && ($sbj = preg_replace ("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular"]), $sbj)))
502
- if (($sbj = preg_replace ("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial_term"]), $sbj)) && ($sbj = preg_replace ("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular_term"]), $sbj)))
503
- if (($sbj = preg_replace ("/%%initial_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::period_term ($paypal["initial_term"])), $sbj)) && ($sbj = preg_replace ("/%%regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::period_term ($paypal["regular_term"], $paypal["recurring"])), $sbj)))
504
- if (($sbj = preg_replace ("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["recurring"]), $sbj)) && ($sbj = preg_replace ("/%%recurring\/regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (( ($paypal["recurring"]) ? $paypal["recurring"] . " / " . c_ws_plugin__s2member_utils_time::period_term ($paypal["regular_term"], true) : "0 / non-recurring")), $sbj)))
505
- if (($sbj = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_number"]), $sbj)) && ($sbj = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_name"]), $sbj)))
506
- if (($sbj = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $sbj)) && ($sbj = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $sbj)))
507
- if (($sbj = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)))
508
- if (($sbj = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $sbj)))
509
- /**/
510
- if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["subscr_id"]), $msg)))
511
- if (($msg = preg_replace ("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial"]), $msg)) && ($msg = preg_replace ("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular"]), $msg)))
512
- if (($msg = preg_replace ("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial_term"]), $msg)) && ($msg = preg_replace ("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular_term"]), $msg)))
513
- if (($msg = preg_replace ("/%%initial_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::period_term ($paypal["initial_term"])), $msg)) && ($msg = preg_replace ("/%%regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::period_term ($paypal["regular_term"], $paypal["recurring"])), $msg)))
514
- if (($msg = preg_replace ("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["recurring"]), $msg)) && ($msg = preg_replace ("/%%recurring\/regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (( ($paypal["recurring"]) ? $paypal["recurring"] . " / " . c_ws_plugin__s2member_utils_time::period_term ($paypal["regular_term"], true) : "0 / non-recurring")), $msg)))
515
- if (($msg = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_name"]), $msg)))
516
- if (($msg = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $msg)))
517
- if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
518
- if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
519
- /**/
520
- if (($recipients = preg_split ("/;+/", preg_replace ("/%%(.+?)%%/i", "", $rec))) && ($sbj = trim (preg_replace ("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
521
- {
522
- foreach (c_ws_plugin__s2member_utils_strings::trim_deep ($recipients) as $recipient) /* Go through the full list of recipients. */
523
- ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_signup_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_signup_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
524
- /**/
525
- $paypal["s2member_log"][] = "Signup Confirmation Email sent to: " . implode ("; ", $recipients) . ".";
526
- }
 
 
 
527
  /**/
528
  if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
529
  {
@@ -536,9 +692,10 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
536
  if (($url = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["last_name"])), $url)))
537
  if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
538
  if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
539
- /**/
540
- if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
541
- c_ws_plugin__s2member_utils_urls::remote ($url);
 
542
  /**/
543
  $paypal["s2member_log"][] = "Signup Notification URLs have been processed.";
544
  }
@@ -560,6 +717,8 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
560
  $msg .= "last_name: %%last_name%%\n";
561
  $msg .= "full_name: %%full_name%%\n";
562
  $msg .= "payer_email: %%payer_email%%\n";
 
 
563
  $msg .= "cv0: %%cv0%%\n";
564
  $msg .= "cv1: %%cv1%%\n";
565
  $msg .= "cv2: %%cv2%%\n";
@@ -578,10 +737,11 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
578
  if (($msg = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $msg)))
579
  if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
580
  if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
581
- /**/
582
- if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
583
- foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_recipients"])) as $recipient)
584
- ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_signup_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_signup_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
 
585
  /**/
586
  $paypal["s2member_log"][] = "Signup Notification Emails have been processed.";
587
  }
@@ -595,12 +755,13 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
595
  if (($code = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $code)) && ($code = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $code)))
596
  if (($code = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
597
  if (($code = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $code)))
598
- /**/
599
- if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code)))) /* This gets stored into a Transient Queue. */
600
- {
601
- $paypal["s2member_log"][] = "Storing Signup Tracking Codes into a Transient Queue. These will be processed on-site.";
602
- set_transient ("s2m_" . md5 ("s2member_transient_signup_tracking_codes_" . $paypal["subscr_id"]), $code, 43200);
603
- }
 
604
  }
605
  /**/
606
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
@@ -617,9 +778,10 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
617
  /**/
618
  if ($processing && $_GET["s2member_paypal_proxy"] && ($url = $_GET["s2member_paypal_proxy_return_url"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"]))) /* A Proxy is requesting a Return URL? */
619
  {
620
- if (($user_id && is_object ($user) && $user->ID) || ( ($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["subscr_id"],$paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID))
621
  {
622
- $fields = get_user_option ("s2member_custom_fields", $user_id); /* These will be needed below. */
 
623
  /**/
624
  if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["subscr_id"])), $url)))
625
  if (($url = preg_replace ("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["initial"])), $url)) && ($url = preg_replace ("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["regular"])), $url)) && ($url = preg_replace ("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["recurring"])), $url)))
@@ -634,17 +796,18 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
634
  if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
635
  if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
636
  if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
637
- if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
638
- {
639
- if (is_array ($fields) && !empty ($fields))
640
- foreach ($fields as $var => $val) /* Custom Registration Fields. */
641
- if (! ($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
642
- break;
643
- /**/
644
- if (($url = trim ($url))) /* Preserve remaining replacements. */
645
- /* Because the parent routine may perform replacements too. */
646
- $paypal["s2member_paypal_proxy_return_url"] = $url;
647
- }
 
648
  }
649
  }
650
  /**/
@@ -652,19 +815,23 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
652
  }
653
  /**/
654
  if ($processing /* Process a payment now? Special cases for web_accept and/or Proxy requests with `subscr-signup-as-subscr-payment`. */
655
- && (preg_match ("/^web_accept$/i", $paypal["txn_type"]) || ($_GET["s2member_paypal_proxy"] && preg_match ("/subscr-signup-as-subscr-payment/",$_GET["s2member_paypal_proxy_use"]) && $paypal["txn_id"] && $paypal["mc_gross"] > 0))/**/
656
- && ( ($user_id && is_object ($user) && $user->ID) || ( ($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["subscr_id"],$paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)))
657
  {
658
- $paypal["s2member_log"][] = "User exists. Handling `payment` for Subscription via (" . ( (preg_match ("/^web_accept$/i", $paypal["txn_type"])) ? "web_accept" : "subscr-signup-as-subscr-payment") . ").";
659
  /**/
660
  $pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
661
  $pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"]; /* Preserves existing. */
662
  $pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
663
  update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
664
  /**/
665
- update_user_option ($user_id, "s2member_last_payment_time", time ()); /* Also update the last payment time. */
 
 
 
666
  /**/
667
  $fields = get_user_option ("s2member_custom_fields", $user_id); /* These will be needed in the routines below. */
 
668
  /**/
669
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
670
  {
@@ -681,16 +848,17 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
681
  if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
682
  if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
683
  if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
684
- if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
685
- {
686
- if (is_array ($fields) && !empty ($fields))
687
- foreach ($fields as $var => $val) /* Custom Registration Fields. */
688
- if (! ($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
689
- break;
690
- /**/
691
- if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
692
- c_ws_plugin__s2member_utils_urls::remote ($url);
693
- }
 
694
  }
695
  /**/
696
  $paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
@@ -716,6 +884,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
716
  $msg .= "user_full_name: %%user_full_name%%\n";
717
  $msg .= "user_email: %%user_email%%\n";
718
  $msg .= "user_login: %%user_login%%\n";
 
719
  $msg .= "user_id: %%user_id%%\n";
720
  /**/
721
  if (is_array ($fields) && !empty ($fields))
@@ -744,31 +913,32 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
744
  if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
745
  if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
746
  if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
747
- if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
748
- {
749
- if (is_array ($fields) && !empty ($fields))
750
- foreach ($fields as $var => $val) /* Custom Registration Fields. */
751
- if (! ($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
752
- break;
753
- /**/
754
- if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
755
- foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"])) as $recipient)
756
- ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_payment_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_payment_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
757
- }
 
758
  }
759
  /**/
760
  $paypal["s2member_log"][] = "Payment Notification Emails have been processed.";
761
  }
762
  }
763
  else if ($processing /* Process a payment now? Special cases for web_accept and/or Proxy requests with `subscr-signup-as-subscr-payment`. */
764
- && (preg_match ("/^web_accept$/i", $paypal["txn_type"]) || ($_GET["s2member_paypal_proxy"] && preg_match ("/subscr-signup-as-subscr-payment/",$_GET["s2member_paypal_proxy_use"]) && $paypal["txn_id"] && $paypal["mc_gross"] > 0)))
765
  {
766
- $paypal["s2member_log"][] = "Storing `payment` for Subscription via (" . ( (preg_match ("/^web_accept$/i", $paypal["txn_type"])) ? "web_accept" : "subscr-signup-as-subscr-payment") . ").";
767
  /**/
768
  $ipn = array ("txn_type" => "subscr_payment"); /* Create a simulated IPN response for txn_type=subscr_payment. */
769
  /**/
770
  foreach ($paypal as $var => $val)
771
- if (in_array ($var, array ("subscr_gateway", "subscr_id", "txn_id", "custom", "mc_gross", "mc_currency", "tax", "payer_email", "first_name", "last_name", "item_name", "item_number")))
772
  $ipn[$var] = $val;
773
  /**/
774
  $paypal["s2member_log"][] = "Creating an IPN response for `subscr_payment`. This will go into a Transient Queue; and be processed during registration.";
@@ -777,7 +947,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
777
  }
778
  /**/
779
  if ($processing /* Store signup vars now? If the User already exists in the database, we can go ahead and store these right now. */
780
- && ( ($user_id && is_object ($user) && $user->ID) || ( ($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["subscr_id"],$paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)))
781
  {
782
  $paypal["s2member_log"][] = "Storing IPN signup vars now. These are associated with a User's account record; for future reference.";
783
  /**/
@@ -800,7 +970,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
800
  be necessary in a future release of s2Member. For now, it's just a fill-in.
801
  These Hooks/Filters will remain, so you can use them now; if you need to.
802
  */
803
- else if (/**/(preg_match ("/^recurring_payment_profile_created$/i",$paypal["txn_type"]))/**/
804
  && ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal)))/**/
805
  && (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])) /* This must match a Subscription. */
806
  && ($paypal["subscr_id"] || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)))/**/
@@ -829,8 +999,8 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
829
  /*
830
  Subscription modifications.
831
  */
832
- else if (/**/(preg_match ("/^subscr_modify$/i",$paypal["txn_type"]))/**/
833
- && (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/",$paypal["item_number"]))/**/
834
  && ($paypal["subscr_id"] && $paypal["payer_email"])/**/)
835
  {
836
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
@@ -841,7 +1011,10 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
841
  /**/
842
  list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
843
  /**/
844
- $paypal["period1"] = (preg_match ("/^[1-9]/",$paypal["period1"])) ? $paypal["period1"] : "0 D"; /* Defaults to "0 D" ( zero days ). */
 
 
 
845
  $paypal["mc_amount1"] = (strlen ($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0) ? $paypal["mc_amount1"] : "0.00"; /* "0.00". */
846
  /**/
847
  $paypal["initial_term"] = (preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : "0 D"; /* Defaults to "0 D" ( zero days ). */
@@ -860,10 +1033,12 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
860
  /**/
861
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
862
  do_action ("ws_plugin__s2member_during_paypal_notify_during_before_subscr_modify", get_defined_vars ());
863
- do_action ("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars (), "ipn-upgrade-downgrade", "modification", $paypal["level"]);
864
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
865
  /**/
866
- $fields = get_user_option ("s2member_custom_fields", $user_id);
 
 
867
  /**/
868
  if (is_multisite () && !is_user_member_of_blog ($user_id))
869
  {
@@ -889,6 +1064,9 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
889
  update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
890
  update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
891
  /**/
 
 
 
892
  update_user_option ($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
893
  /**/
894
  delete_user_option ($user_id, "s2member_file_download_access_arc");
@@ -909,6 +1087,106 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
909
  /**/
910
  $paypal["s2member_log"][] = "Modification Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.";
911
  /**/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
912
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
913
  do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_modify", get_defined_vars ());
914
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
@@ -927,11 +1205,11 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
927
  Subscription payment notifications.
928
  We need these to update: `s2member_last_payment_time`.
929
  */
930
- else if (/**/(preg_match ("/^(subscr_payment|recurring_payment)$/i",$paypal["txn_type"]))/**/
931
  && ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal)))/**/
932
  && (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])) /* This must match a Subscription. */
933
  && ($paypal["subscr_id"] || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)))/**/
934
- && (!preg_match ($payment_status_issues,$paypal["payment_status"])) /* Status OK? This goes thru a list of known status issues. */
935
  && ($paypal["item_name"] || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal)))/**/
936
  && ($paypal["payer_email"] || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with ($paypal["subscr_id"])))/**/
937
  && ($paypal["txn_id"] && $paypal["mc_gross"])/**/)
@@ -940,14 +1218,17 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
940
  do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_payment", get_defined_vars ());
941
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
942
  /**/
943
- $paypal["s2member_log"][] = "s2Member txn_type identified as subscr_payment|recurring_payment.";
944
- $paypal["s2member_log"][] = "Sleeping for 2 seconds. Waiting for a possible subscr_signup|subscr_modify|recurring_payment_profile_created.";
945
- sleep (2); /* Sleep here for a moment. PayPal® sometimes sends a subscr_payment before the subscr_signup, subscr_modify.
946
- It is NOT a big deal if they do. However, s2Member goes to sleep here, just to help keep the log files in a logical order. */
947
- $paypal["s2member_log"][] = "Awake. It's " . date ("D M j, Y g:i:s a T") . ". s2Member txn_type identified as subscr_payment|recurring_payment.";
948
  /**/
949
  list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
950
  /**/
 
 
 
951
  if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["subscr_id"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
952
  {
953
  $processing = $during = true; /* Yes, we ARE processing this. */
@@ -957,11 +1238,16 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
957
  $pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
958
  update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
959
  /**/
 
 
 
960
  update_user_option ($user_id, "s2member_last_payment_time", time ()); /* Also update last payment time. */
961
  /**/
962
  $paypal["s2member_log"][] = "Updated Payment Times for this Member."; /* Flag this action in the log. */
963
  /**/
964
  $fields = get_user_option ("s2member_custom_fields", $user_id); /* These will be needed in the routines below. */
 
 
965
  /**/
966
  if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
967
  {
@@ -978,16 +1264,17 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
978
  if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
979
  if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
980
  if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
981
- if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
982
- {
983
- if (is_array ($fields) && !empty ($fields))
984
- foreach ($fields as $var => $val) /* Custom Registration Fields. */
985
- if (! ($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
986
- break;
987
- /**/
988
- if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
989
- c_ws_plugin__s2member_utils_urls::remote ($url);
990
- }
 
991
  }
992
  /**/
993
  $paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
@@ -1013,6 +1300,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1013
  $msg .= "user_full_name: %%user_full_name%%\n";
1014
  $msg .= "user_email: %%user_email%%\n";
1015
  $msg .= "user_login: %%user_login%%\n";
 
1016
  $msg .= "user_id: %%user_id%%\n";
1017
  /**/
1018
  if (is_array ($fields) && !empty ($fields))
@@ -1041,17 +1329,18 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1041
  if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
1042
  if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
1043
  if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
1044
- if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
1045
- {
1046
- if (is_array ($fields) && !empty ($fields))
1047
- foreach ($fields as $var => $val) /* Custom Registration Fields. */
1048
- if (! ($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
1049
- break;
1050
- /**/
1051
- if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
1052
- foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"])) as $recipient)
1053
- ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_payment_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_payment_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
1054
- }
 
1055
  }
1056
  /**/
1057
  $paypal["s2member_log"][] = "Payment Notification Emails have been processed.";
@@ -1068,10 +1357,10 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1068
  $ipn = array ("txn_type" => "subscr_payment"); /* Create a simulated IPN response for txn_type=subscr_payment. */
1069
  /**/
1070
  foreach ($paypal as $var => $val)
1071
- if (in_array ($var, array ("subscr_gateway", "subscr_id", "txn_id", "custom", "mc_gross", "mc_currency", "tax", "payer_email", "first_name", "last_name", "item_name", "item_number")))
1072
  $ipn[$var] = $val;
1073
  /**/
1074
- $paypal["s2member_log"][] = "Re-generating. This IPN will go into a Transient Queue; and re-processed during registration.";
1075
  /**/
1076
  set_transient ("s2m_" . md5 ("s2member_transient_ipn_subscr_payment_" . $paypal["subscr_id"]), $ipn, 43200);
1077
  }
@@ -1086,7 +1375,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1086
  be necessary in a future release of s2Member. For now, it's just a fill-in.
1087
  These Hooks/Filters will remain, so you can use them now; if you need to.
1088
  */
1089
- else if (/**/(preg_match ("/^(subscr_failed|recurring_payment_failed|recurring_payment_skipped)$/i",$paypal["txn_type"]))/**/
1090
  && ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal)))/**/
1091
  && (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])) /* Must match a Subscription. */
1092
  && ($paypal["subscr_id"] || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)))/**/
@@ -1119,8 +1408,8 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1119
  This works in conjunction with `s2member_last_payment_time`, and the s2Member Auto-EOT System.
1120
  For further details, see: https://www.x.com/thread/41155?start=15&tstart=0
1121
  */
1122
- else if (/**/(preg_match ("/^(subscr_cancel|recurring_payment_profile_cancel)$/i",$paypal["txn_type"]))/**/
1123
- && ! (preg_match ("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]) && preg_match ("/^failed$/i",$paypal["initial_payment_status"]))
1124
  /* ^^ Bypass this case ( for now ) "recurring_payment_profile_cancel" with an initial failed payment warrants an EOT instead of a cancellation. */
1125
  && ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) /* item_number? */
1126
  && (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])) /* This item_number must validate as Membership Access. */
@@ -1138,11 +1427,16 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1138
  /**/
1139
  list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
1140
  /**/
 
 
 
1141
  if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["subscr_id"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
1142
  {
1143
  if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
1144
  {
1145
- $fields = get_user_option ("s2member_custom_fields", $user_id);
 
 
1146
  /**/
1147
  if (!get_user_option ("s2member_auto_eot_time", $user_id)) /* Respect existing. */
1148
  {
@@ -1171,16 +1465,17 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1171
  if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
1172
  if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
1173
  if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
1174
- if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
1175
- {
1176
- if (is_array ($fields) && !empty ($fields))
1177
- foreach ($fields as $var => $val) /* Custom Registration Fields. */
1178
- if (! ($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
1179
- break;
1180
- /**/
1181
- if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
1182
- c_ws_plugin__s2member_utils_urls::remote ($url);
1183
- }
 
1184
  /**/
1185
  $paypal["s2member_log"][] = "Cancellation Notification URLs have been processed.";
1186
  }
@@ -1198,6 +1493,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1198
  $msg .= "user_full_name: %%user_full_name%%\n";
1199
  $msg .= "user_email: %%user_email%%\n";
1200
  $msg .= "user_login: %%user_login%%\n";
 
1201
  $msg .= "user_id: %%user_id%%\n";
1202
  /**/
1203
  if (is_array ($fields) && !empty ($fields))
@@ -1221,17 +1517,18 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1221
  if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
1222
  if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
1223
  if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
1224
- if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
1225
- {
1226
- if (is_array ($fields) && !empty ($fields))
1227
- foreach ($fields as $var => $val) /* Custom Registration Fields. */
1228
- if (! ($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
1229
- break;
1230
- /**/
1231
- if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
1232
- foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_recipients"])) as $recipient)
1233
- ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_cancellation_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_cancellation_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
1234
- }
 
1235
  /**/
1236
  $paypal["s2member_log"][] = "Cancellation Notification Emails have been processed.";
1237
  }
@@ -1262,13 +1559,13 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1262
  ~ NOTE: Partial Refunds ( i.e. payment_status=partially_refunded or txn_type=adjustment ) are NOT processed by this routine.
1263
  ( This is the intended behavior. A Partial Refund does NOT clearly indicate that s2Member should do anything at all. )
1264
  HOWEVER. PayPal® does NOT always send payment_status=partially_refunded. This is well documented on their site, but in
1265
- practice it never seems to happen. It's best to check the negative mc_gross amount instead.
1266
  */
1267
  else if (/**/( /* Partial Refunds ( i.e. payment_status=partially_refunded or txn_type=adjustment ) are NOT processed by this routine. */
1268
- (preg_match ("/^(subscr_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment)$/i",$paypal["txn_type"]) && ($recurring = 1))/**/
1269
- || (preg_match ("/^recurring_payment_profile_cancel$/i",$paypal["txn_type"]) && preg_match ("/^failed$/i",$paypal["initial_payment_status"]) && ($recurring = 1))/**/
1270
- || (preg_match ("/^new_case$/i",$paypal["txn_type"]) && preg_match ("/^chargeback$/i",$paypal["case_type"])) /* ONLY for future compatibility. This does NOT work yet. */
1271
- || (preg_match ("/^(refunded|reversed|reversal)$/i",$paypal["payment_status"])) /* The "txn_type" is irrelevant in all of these cases: refunded|reversed|reversal. */)/**/
1272
  && ($paypal["period1"] || ($paypal["period1"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1 ($paypal)) || !$recurring || ($paypal["period1"] = "0 D"))/**/
1273
  && ($paypal["period3"] || ($paypal["period3"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3 ($paypal)) || !$recurring) /* Was it even recurring? */
1274
  && ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) /* Do we have a valid item_number? */
@@ -1282,20 +1579,30 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1282
  do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_eot", get_defined_vars ());
1283
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
1284
  /**/
1285
- $is_refund = (preg_match ("/^refunded$/i",$paypal["payment_status"]) && $paypal["parent_txn_id"]);
1286
- $is_reversal = (preg_match ("/^(reversed|reversal)$/i",$paypal["payment_status"]) && $paypal["parent_txn_id"]);
1287
- $is_reversal = (!$is_reversal) ? (preg_match ("/^new_case$/i",$paypal["txn_type"]) && preg_match ("/^chargeback$/i",$paypal["case_type"])) : $is_reversal;
1288
- $is_refund_or_reversal = ($is_refund || $is_reversal); /* If either of the previous tests above evaluated to true; it's obviously a Refund or Reversal. */
1289
- $is_delayed_eot = (preg_match ("/^(subscr_eot|recurring_payment_expired)$/i",$paypal["txn_type"]) && preg_match ("/^I-/i", $paypal["subscr_id"]));
1290
  /**/
1291
  if ($is_refund_or_reversal)
1292
- $paypal["s2member_log"][] = "s2Member txn_type identified as [empty or irrelevant] w/ payment_status (refunded|reversed|reversal) - or - new_case w/ case_type (chargeback).";
1293
  else
1294
- $paypal["s2member_log"][] = "s2Member txn_type identified as (subscr_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment) - or - recurring_payment_profile_cancel w/ initial_payment_status (failed).";
 
 
 
 
 
 
 
 
1295
  /**/
1296
  if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["subscr_id"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
1297
  {
1298
  $fields = get_user_option ("s2member_custom_fields", $user_id); /* These will be needed below. */
 
 
1299
  /**/
1300
  if ( /* Here we take action, BUT based on Auto EOT Behavior options; as configured by the Site Owner. */
1301
  (!$is_refund_or_reversal && !$is_delayed_eot && !get_user_option ("s2member_auto_eot_time", $user_id))/**/
@@ -1311,17 +1618,18 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1311
  {
1312
  $processing = $during = true; /* Yes, we ARE processing this. */
1313
  /**/
1314
- $eot_del_type = ($is_refund_or_reversal) ? "ipn-refund-reversal-demotion" : "ipn-cancellation-expiration-demotion";
1315
- $eot_del_type_spec = ($is_refund_or_reversal) ? "refund-reversal" : "cancellation-expiration";
 
 
 
1316
  /**/
1317
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1318
  do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_before_demote", get_defined_vars ());
1319
- do_action ("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars (), $eot_del_type, $eot_del_type_spec);
 
1320
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
1321
  /**/
1322
- $demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role ("subscriber");
1323
- $existing_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
1324
- /**/
1325
  if ($existing_role !== $demotion_role) /* Only if NOT the existing Role. */
1326
  $user->set_role ($demotion_role); /* Give User the demotion Role. */
1327
  /**/
@@ -1339,6 +1647,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1339
  delete_user_option ($user_id, "s2member_paid_registration_times");
1340
  /**/
1341
  delete_user_option ($user_id, "s2member_last_status_scan");
 
1342
  delete_user_option ($user_id, "s2member_last_payment_time");
1343
  delete_user_option ($user_id, "s2member_auto_eot_time");
1344
  /**/
@@ -1358,16 +1667,17 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1358
  if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
1359
  if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
1360
  if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
1361
- if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
1362
- {
1363
- if (is_array ($fields) && !empty ($fields))
1364
- foreach ($fields as $var => $val) /* Custom Registration Fields. */
1365
- if (! ($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
1366
- break;
1367
- /**/
1368
- if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
1369
- c_ws_plugin__s2member_utils_urls::remote ($url);
1370
- }
 
1371
  /**/
1372
  $paypal["s2member_log"][] = "EOT/Deletion Notification URLs have been processed.";
1373
  }
@@ -1384,6 +1694,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1384
  $msg .= "user_full_name: %%user_full_name%%\n";
1385
  $msg .= "user_email: %%user_email%%\n";
1386
  $msg .= "user_login: %%user_login%%\n";
 
1387
  $msg .= "user_id: %%user_id%%\n";
1388
  /**/
1389
  if (is_array ($fields) && !empty ($fields))
@@ -1406,17 +1717,18 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1406
  if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
1407
  if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
1408
  if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
1409
- if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
1410
- {
1411
- if (is_array ($fields) && !empty ($fields))
1412
- foreach ($fields as $var => $val) /* Custom Registration Fields. */
1413
- if (! ($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
1414
- break;
1415
- /**/
1416
- if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
1417
- foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"])) as $recipient)
1418
- ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_eot_del_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_eot_del_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
1419
- }
 
1420
  /**/
1421
  $paypal["s2member_log"][] = "EOT/Deletion Notification Emails have been processed.";
1422
  }
@@ -1430,17 +1742,14 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1430
  {
1431
  $processing = $during = true; /* Yes, we ARE processing this. */
1432
  /**/
1433
- $eot_del_type = ($is_refund_or_reversal) ? "ipn-refund-reversal-deletion" : "ipn-cancellation-expiration-deletion";
1434
- $eot_del_type_spec = ($is_refund_or_reversal) ? "refund-reversal" : "cancellation-expiration";
1435
  /**/
1436
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1437
  do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_before_delete", get_defined_vars ());
1438
- do_action ("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars (), $eot_del_type, $eot_del_type_spec);
1439
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
1440
  /**/
1441
- $GLOBALS["ws_plugin__s2member_eot_del_type"] = $eot_del_type;
1442
- $GLOBALS["ws_plugin__s2member_eot_del_type_spec"] = $eot_del_type_spec;
1443
- /**/
1444
  if (is_multisite ()) /* Multisite does NOT actually delete; ONLY removes. */
1445
  {
1446
  remove_user_from_blog ($user_id, $current_blog->blog_id);
@@ -1450,9 +1759,9 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1450
  /**/
1451
  else /* Otherwise, we can actually delete them. */
1452
  /* This will automatically trigger `eot_del_notification_urls` as well. */
1453
- wp_delete_user($user_id); /* `c_ws_plugin__s2member_user_deletions::handle_user_deletions()` */
1454
  /**/
1455
- $paypal["s2member_log"][] = "This Member's account has been " . ( (is_multisite ()) ? "removed" : "deleted") . ".";
1456
  /**/
1457
  $paypal["s2member_log"][] = "EOT/Deletion Notification URLs have been processed.";
1458
  /**/
@@ -1514,6 +1823,21 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1514
  else if ($is_refund)
1515
  $paypal["s2member_log"][] = "Skipping (demote|delete) Member. Your configuration dictates that s2Member should NOT take any immediate action on an EOT associated with a Refund. An s2Member API Notification will still be processed however.";
1516
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1517
  else
1518
  $paypal["s2member_log"][] = "Unable to (demote|delete) Member. Could not get the existing User ID from the DB. It's possible that it was ALREADY processed through another IPN, removed manually by a Site Administrator, or by s2Member's Auto-EOT Sys.";
1519
  /*
@@ -1524,6 +1848,10 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1524
  */
1525
  if ($is_refund_or_reversal) /* Here we access this variable that was previously assigned as a quick method of Refund/Reversal detection. */
1526
  {
 
 
 
 
1527
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
1528
  {
1529
  foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"]) as $url)
@@ -1534,16 +1862,17 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1534
  if (($url = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["last_name"])), $url)))
1535
  if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
1536
  if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
1537
- if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
1538
- {
1539
- if (is_array ($fields) && !empty ($fields))
1540
- foreach ($fields as $var => $val) /* Custom Registration Fields. */
1541
- if (! ($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
1542
- break;
1543
- /**/
1544
- if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
1545
- c_ws_plugin__s2member_utils_urls::remote ($url);
1546
- }
 
1547
  /**/
1548
  $paypal["s2member_log"][] = "Refund/Reversal Notification URLs have been processed.";
1549
  }
@@ -1563,6 +1892,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1563
  $msg .= "last_name: %%last_name%%\n";
1564
  $msg .= "full_name: %%full_name%%\n";
1565
  $msg .= "payer_email: %%payer_email%%\n";
 
1566
  $msg .= "user_id: %%user_id%%\n";
1567
  /**/
1568
  if (is_array ($fields) && !empty ($fields))
@@ -1586,17 +1916,18 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1586
  if (($msg = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $msg)))
1587
  if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
1588
  if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
1589
- if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
1590
- {
1591
- if (is_array ($fields) && !empty ($fields))
1592
- foreach ($fields as $var => $val) /* Custom Registration Fields. */
1593
- if (! ($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
1594
- break;
1595
- /**/
1596
- if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
1597
- foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_recipients"])) as $recipient)
1598
- ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_ref_rev_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_ref_rev_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
1599
- }
 
1600
  /**/
1601
  $paypal["s2member_log"][] = "Refund/Reversal Notification Emails have been processed.";
1602
  }
@@ -1621,15 +1952,15 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1621
  ~ NOTE: Partial Refunds ( i.e. payment_status=partially_refunded ) is NOT processed by this routine, or any other s2Member routine.
1622
  ( This is the intended behavior. A Partial Refund does NOT clearly indicate that s2Member should do anything at all. )
1623
  HOWEVER. PayPal® does NOT always send payment_status=partially_refunded. This is well documented on their site, but in
1624
- practice it never seems to happen. It's best to check the negative mc_gross amount instead.
1625
  */
1626
- else if (/**/(/**/ (preg_match ("/^new_case$/i",$paypal["txn_type"]) && preg_match ("/^chargeback$/i",$paypal["case_type"])) /* Future compatibility. */
1627
- || (preg_match ("/^(refunded|reversed|reversal)$/i",$paypal["payment_status"])) /* The "txn_type" is irrelevant in all of these special cases. */)/**/
1628
- && ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) /* Required. */
1629
- && (preg_match ("/^sp\:[0-9,]+\:[0-9]+$/", $paypal["item_number"])) /* Only for "Specific Post/Page Access" here. NOT for Membership. */
1630
- && ($paypal["item_name"] || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal))) /* ? */
1631
- && ($paypal["payer_email"] || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with ($paypal["subscr_id"])))/**/
1632
- && ($paypal["parent_txn_id"])/**/)
1633
  {
1634
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1635
  do_action ("ws_plugin__s2member_during_paypal_notify_before_sp_refund_reversal", get_defined_vars ());
@@ -1637,6 +1968,9 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1637
  /**/
1638
  $paypal["s2member_log"][] = "s2Member txn_type identified as [empty or irrelevant] w/ payment_status (refunded|reversed|reversal) - or - new_case w/ case_type (chargeback).";
1639
  /**/
 
 
 
1640
  $processing = $during = true; /* Yes, we ARE processing this. */
1641
  /*
1642
  Refunds and chargeback reversals. This is excluded from the processing check.
@@ -1654,9 +1988,10 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1654
  if (($url = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["last_name"])), $url)))
1655
  if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
1656
  if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
1657
- /**/
1658
- if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
1659
- c_ws_plugin__s2member_utils_urls::remote ($url);
 
1660
  /**/
1661
  $paypal["s2member_log"][] = "Specific Post/Page ~ Refund/Reversal Notification URLs have been processed.";
1662
  }
@@ -1675,6 +2010,8 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1675
  $msg .= "last_name: %%last_name%%\n";
1676
  $msg .= "full_name: %%full_name%%\n";
1677
  $msg .= "payer_email: %%payer_email%%\n";
 
 
1678
  $msg .= "cv0: %%cv0%%\n";
1679
  $msg .= "cv1: %%cv1%%\n";
1680
  $msg .= "cv2: %%cv2%%\n";
@@ -1692,10 +2029,11 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1692
  if (($msg = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $msg)))
1693
  if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
1694
  if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
1695
- /**/
1696
- if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
1697
- foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_recipients"])) as $recipient)
1698
- ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_sp_ref_rev_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_sp_ref_rev_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
 
1699
  /**/
1700
  $paypal["s2member_log"][] = "Specific Post/Page ~ Refund/Reversal Notification Emails have been processed.";
1701
  }
@@ -1717,7 +2055,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1717
  /*
1718
  Else, check on cancelled recurring profiles.
1719
  */
1720
- else if (preg_match ("/^recurring_payment_profile_cancel$/i",$paypal["txn_type"]))
1721
  {
1722
  $paypal["s2member_log"][] = "Transaction type ( recurring_payment_profile_cancel ), but there is no match to an existing account; so verification of _SERVER[HTTP_HOST] was not possible.";
1723
  $paypal["s2member_log"][] = "It's likely this account was just upgraded/downgraded by s2Member Pro; so the Subscr. ID has probably been updated on-site; nothing to worry about here.";
@@ -1725,7 +2063,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1725
  /*
1726
  Else, check on other ^recurring_ transaction types.
1727
  */
1728
- else if (preg_match ("/^recurring_/i",$paypal["txn_type"])) /* Otherwise, is this a ^recurring_ txn_type? */
1729
  $paypal["s2member_log"][] = "Transaction type ( ^recurring_? ), but there is no match to an existing account; so verification of _SERVER[HTTP_HOST] was not possible.";
1730
  /**/
1731
  else /* Else, use the default _SERVER[HTTP_HOST] error. */
@@ -1758,14 +2096,15 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
1758
  If debugging/logging is enabled; we need to append $paypal to the log file.
1759
  Logging now supports Multisite Networking as well.
1760
  */
 
1761
  $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
1762
  $log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
1763
- $log2 = (is_multisite () && !is_main_site ()) ? "paypal-ipn-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-",$_log4), "-") . ".log" : "paypal-ipn.log";
1764
  /**/
1765
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
1766
  if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
1767
  if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
1768
- file_put_contents ($logs_dir . "/" . $log2, $log4 . "\n" . var_export ($paypal, true) . "\n\n", FILE_APPEND);
1769
  /**/
1770
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1771
  do_action ("ws_plugin__s2member_during_paypal_notify", get_defined_vars ());
1
  <?php
2
+ /**
3
+ * s2Member's PayPal® IPN handler ( inner processing routines ).
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\PayPal
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_paypal_notify_in"))
21
  {
22
+ /**
23
+ * s2Member's PayPal® IPN handler ( inner processing routines ).
24
+ *
25
+ * @package s2Member\PayPal
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_paypal_notify_in
29
  {
30
+ /**
31
+ * Handles PayPal® IPN processing.
32
+ *
33
+ * These same routines also handle s2Member Pro/PayPal® Pro operations;
34
+ * giving you the ability *( as needed )* to Hook into these routines using
35
+ * WordPress® Hooks/Filters; as seen in the source code below.
36
+ *
37
+ * Please do NOT modify the source code directly.
38
+ * Instead, use WordPress® Hooks/Filters.
39
+ *
40
+ * For example, if you'd like to add your own custom conditionals, use:
41
+ * ``add_filter ("ws_plugin__s2member_during_paypal_notify_conditionals", "your_function");``
42
+ *
43
+ * @package s2Member\PayPal
44
+ * @since 3.5
45
+ *
46
+ * @attaches-to: ``add_action("init");``
47
+ *
48
+ * @return null Or exits script execution after handling IPN procesing.
49
+ *
50
+ * @todo Break this HUGE routine apart into logical class methods.
51
+ * @todo Optimize with ``empty()`` and ``isset()``.
52
  */
53
  public static function paypal_notify ()
54
  {
56
  /**/
57
  do_action ("ws_plugin__s2member_before_paypal_notify", get_defined_vars ());
58
  /**/
59
+ if (!empty ($_GET["s2member_paypal_notify"]) && ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] || $_GET["s2member_paypal_proxy"]))
60
  {
61
+ @ignore_user_abort (true); /* Important. Continue processing even if/when the connection is broken by the sending party. */
62
  /**/
63
  include_once ABSPATH . "wp-admin/includes/admin.php"; /* Get administrative functions. Needed for `wp_delete_user()`. */
64
  /**/
67
  if (is_array ($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_postvars ()) && ($_paypal = $paypal))
68
  {
69
  $paypal["s2member_log"][] = "IPN received on: " . date ("D M j, Y g:i:s a T");
70
+ $paypal["s2member_log"][] = "s2Member POST vars verified " . (($paypal["proxy_verified"]) ? "with a Proxy Key" : "through a POST back to PayPal®.");
71
  /**/
72
  $payment_status_issues = "/^(failed|denied|expired|refunded|partially_refunded|reversed|reversal|canceled_reversal|voided)$/i";
73
  /**/
95
  be necessary in a future release of s2Member. For now, it's just a fill-in.
96
  These Hooks/Filters will remain, so you can use them now; if you need to.
97
  */
98
+ if (/**/(preg_match ("/^virtual_terminal$/i", $paypal["txn_type"]))/**/
99
+ && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
100
  && ($paypal["txn_id"])/**/)
101
  {
102
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
123
  be necessary in a future release of s2Member. For now, it's just a fill-in.
124
  These Hooks/Filters will remain, so you can use them now; if you need to.
125
  */
126
+ else if (/**/(preg_match ("/^express_checkout$/i", $paypal["txn_type"]))/**/
127
+ && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
128
  && ($paypal["txn_id"])/**/)
129
  {
130
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
152
  be necessary in a future release of s2Member. For now, it's just a fill-in.
153
  These Hooks/Filters will remain, so you can use them now; if you need to.
154
  */
155
+ else if (/**/(preg_match ("/^cart$/i", $paypal["txn_type"]))/**/
156
+ && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
157
  && ($paypal["txn_id"])/**/)
158
  {
159
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
181
  be necessary in a future release of s2Member. For now, it's just a fill-in.
182
  These Hooks/Filters will remain, so you can use them now; if you need to.
183
  */
184
+ else if (/**/(preg_match ("/^send_money$/i", $paypal["txn_type"]))/**/
185
+ && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
186
  && ($paypal["txn_id"])/**/)
187
  {
188
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
206
  /*
207
  Specific Post/Page Access ~ Sales.
208
  */
209
+ else if (/**/(preg_match ("/^web_accept$/i", $paypal["txn_type"]))/**/
210
+ && (preg_match ("/^sp\:[0-9,]+\:[0-9]+$/", $paypal["item_number"]))/**/
211
+ && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
212
  && ($paypal["payer_email"] && $paypal["txn_id"])/**/)
213
  {
214
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
219
  /**/
220
  list (, $paypal["sp_ids"], $paypal["hours"]) = preg_split ("/\:/", $paypal["item_number"], 3);
221
  /**/
222
+ $paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
223
+ $paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[0-9]+~[0-9\.]+$/", $paypal["invoice"])) ? preg_replace ("/^[0-9]+~/", "", $paypal["invoice"]) : $paypal["ip"];
224
+ /**/
225
  if (($sp_access_url = c_ws_plugin__s2member_sp_access::sp_access_link_gen ($paypal["sp_ids"], $paypal["hours"])) && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
226
  {
227
  $processing = $during = true; /* Yes, we ARE processing this. */
228
  /**/
229
+ if (preg_match ("/(referenc|associat)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) /* Associating this purchase with a Member? */
230
+ if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["option_selection1"], $paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
231
+ {
232
+ $sp_references = (array)get_user_option ("s2member_sp_references", $user_id);
233
+ $_sp_reference = array ("time" => time (), "ids" => $paypal["sp_ids"], "hours" => $paypal["hours"], "url" => $sp_access_url);
234
+ $sp_references = c_ws_plugin__s2member_utils_arrays::array_unique (array_merge ($sp_references, $_sp_reference));
235
+ update_user_option ($user_id, "s2member_sp_references", $sp_references);
236
+ /**/
237
+ $paypal["s2member_log"][] = "Specific Post/Page ~ Sale associated with User ID: " . $user_id . ".";
238
+ }
239
+ /**/
240
+ $sbj = preg_replace ("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_GET["s2member_paypal_proxy"] && preg_match ("/pro-emails/", $_GET["s2member_paypal_proxy_use"])) ? "pro_" : "") . "sp_email_subject"]);
241
  $sbj = preg_replace ("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours"))), $sbj);
242
  /**/
243
+ $msg = preg_replace ("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_GET["s2member_paypal_proxy"] && preg_match ("/pro-emails/", $_GET["s2member_paypal_proxy_use"])) ? "pro_" : "") . "sp_email_message"]);
244
  $msg = preg_replace ("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours"))), $msg);
245
  /**/
246
+ $rec = preg_replace ("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_GET["s2member_paypal_proxy"] && preg_match ("/pro-emails/", $_GET["s2member_paypal_proxy_use"])) ? "pro_" : "") . "sp_email_recipients"]);
247
  $rec = preg_replace ("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::approx_time_difference (time (), strtotime ("+" . $paypal["hours"] . " hours"))), $rec);
248
  /**/
249
  if (($rec = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $rec)) && ($rec = preg_replace ("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["txn_id"]), $rec)))
252
  if (($rec = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq (c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"])), $rec)) && ($rec = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq (c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"])), $rec)))
253
  if (($rec = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq (c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $rec))) /* **NOTE** c_ws_plugin__s2member_utils_strings::esc_dq() is applied here. ( ex. "N\"ame" <email> ). */
254
  if (($rec = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $rec)))
255
+ if (($rec = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $rec)))
256
+ /**/
257
+ if (($sbj = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)) && ($sbj = preg_replace ("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["txn_id"]), $sbj)))
258
+ if (($sbj = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["mc_gross"]), $sbj))) /* Full amount of the payment, before fee is subtracted. */
259
+ if (($sbj = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_number"]), $sbj)) && ($sbj = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_name"]), $sbj)))
260
+ if (($sbj = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $sbj)) && ($sbj = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $sbj)))
261
+ if (($sbj = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)))
262
+ if (($sbj = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $sbj)))
263
+ if (($sbj = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $sbj)))
264
+ /**/
265
+ if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["txn_id"]), $msg)))
266
+ if (($msg = preg_replace ("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["mc_gross"]), $msg))) /* Full amount of the payment, before fee is subtracted. */
267
+ if (($msg = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_name"]), $msg)))
268
+ if (($msg = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $msg)))
269
+ if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
270
+ if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
271
+ if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $msg)))
272
+ /**/
273
+ if (($recipients = preg_split ("/;+/", preg_replace ("/%%(.+?)%%/i", "", $rec))) && ($sbj = trim (preg_replace ("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
274
+ {
275
+ foreach (c_ws_plugin__s2member_utils_strings::trim_deep ($recipients) as $recipient) /* Go through the full list of recipients. */
276
+ ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_sp_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_sp_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
277
+ /**/
278
+ $paypal["s2member_log"][] = "Specific Post/Page Confirmation Email sent to: " . implode ("; ", $recipients) . ".";
279
+ }
280
  /**/
281
  if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_urls"])
282
  {
289
  if (($url = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["last_name"])), $url)))
290
  if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
291
  if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
292
+ if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["ip"])), $url)))
293
+ /**/
294
+ if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
295
+ c_ws_plugin__s2member_utils_urls::remote ($url);
296
  /**/
297
  $paypal["s2member_log"][] = "Specific Post/Page ~ Sale Notification URLs have been processed.";
298
  }
312
  $msg .= "last_name: %%last_name%%\n";
313
  $msg .= "full_name: %%full_name%%\n";
314
  $msg .= "payer_email: %%payer_email%%\n";
315
+ $msg .= "user_ip: %%user_ip%%\n";
316
+ /**/
317
  $msg .= "cv0: %%cv0%%\n";
318
  $msg .= "cv1: %%cv1%%\n";
319
  $msg .= "cv2: %%cv2%%\n";
332
  if (($msg = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $msg)))
333
  if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
334
  if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
335
+ if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $msg)))
336
+ /**/
337
+ if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
338
+ foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_recipients"])) as $recipient)
339
+ ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_sp_sale_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_sp_sale_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
340
  /**/
341
  $paypal["s2member_log"][] = "Specific Post/Page ~ Sale Notification Emails have been processed.";
342
  }
350
  if (($url = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["last_name"])), $url)))
351
  if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
352
  if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
353
+ if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["ip"])), $url)))
354
+ /**/
355
+ if (($url = trim ($url))) /* Preserve Remaining replacements. */
356
+ /* Because the parent routine may perform replacements too. */
357
+ $paypal["s2member_paypal_proxy_return_url"] = $url;
358
  /**/
359
  $paypal["s2member_log"][] = "Specific Post/Page Return, a Proxy Return URL is ready.";
360
  }
366
  if (($code = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $code)) && ($code = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $code)))
367
  if (($code = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
368
  if (($code = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $code)))
369
+ if (($code = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $code)))
370
+ /**/
371
+ if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code)))) /* This gets stored into a Transient Queue. */
372
+ {
373
+ $paypal["s2member_log"][] = "Storing Specific Post/Page Tracking Codes into a Transient Queue. These will be processed on-site.";
374
+ set_transient ("s2m_" . md5 ("s2member_transient_sp_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
375
+ }
376
  }
377
  /**/
378
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
391
  Possibly containing advanced update vars
392
  ( option_name1, option_selection1 ); which allow account modifications.
393
  */
394
+ else if (/**/(preg_match ("/^(web_accept|subscr_signup)$/i", $paypal["txn_type"]))/**/
395
+ && (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"]))/**/
396
  && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["txn_id"]))/**/
397
+ && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
398
  && ($paypal["payer_email"])/**/)
399
  {
400
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
405
  /**/
406
  list ($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split ("/\:/", $paypal["item_number"], 3);
407
  /**/
408
+ $paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
409
+ $paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[0-9]+~[0-9\.]+$/", $paypal["invoice"])) ? preg_replace ("/^[0-9]+~/", "", $paypal["invoice"]) : $paypal["ip"];
410
+ /**/
411
+ $paypal["period1"] = (preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : "0 D"; /* Defaults to "0 D" ( zero days ). */
412
  $paypal["mc_amount1"] = (strlen ($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0) ? $paypal["mc_amount1"] : "0.00"; /* "0.00". */
413
  /**/
414
  if (preg_match ("/^web_accept$/i", $paypal["txn_type"])) /* Conversions for Lifetime & Fixed-Term sales. */
427
  /*
428
  New Subscription with advanced update vars ( option_name1, option_selection1 )? These variables are used in Subscr. Modifications.
429
  */
430
+ if (preg_match ("/(referenc|associat|updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) /* Advanced way to handle Subscription mods. */
431
+ /* 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.
432
+ PayPal® will not allow the `modify=1|2` parameter to be used in those scenarios, because technically there is no billing to update; only the account. */
433
  {
434
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
435
  do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_signup_w_update_vars", get_defined_vars ());
446
  /**/
447
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
448
  do_action ("ws_plugin__s2member_during_paypal_notify_during_before_subscr_signup_w_update_vars", get_defined_vars ());
449
+ do_action ("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars (), "ipn-upgrade-downgrade", "modification", "s2member_level" . $paypal["level"]);
450
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
451
  /**/
452
+ $fields = get_user_option ("s2member_custom_fields", $user_id); /* These will be needed in the routines below. */
453
+ $user_reg_ip = get_user_option ("s2member_registration_ip", $user_id); /* Original IP during Registration. */
454
+ $user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"]; /* Now merge conditionally. */
455
  /**/
456
  if (is_multisite () && !is_user_member_of_blog ($user_id))
457
  {
477
  update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
478
  update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
479
  /**/
480
+ if (!get_user_option ("s2member_registration_ip", $user_id))
481
+ update_user_option ($user_id, "s2member_registration_ip", $paypal["ip"]);
482
+ /**/
483
  update_user_option ($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
484
  /**/
485
  delete_user_option ($user_id, "s2member_file_download_access_arc");
486
  delete_user_option ($user_id, "s2member_file_download_access_log");
487
  /**/
488
  if (preg_match ("/^web_accept$/i", $paypal["txn_type"]) && $paypal["eotper"])
489
+ {
490
+ update_user_option ($user_id, "s2member_auto_eot_time", /* Set exclusively by the IPN handler; to avoid duplicate extensions. */
491
+ ($eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time ("", "", "", $paypal["eotper"], "", get_user_option ("s2member_auto_eot_time", $user_id))));
492
+ $paypal["s2member_log"][] = "Automatic EOT ( End Of Term ) Time set to: " . date ("D M j, Y g:i:s a T", $eot_time) . ".";
493
+ }
494
  else /* Otherwise, we need to clear the Auto-EOT Time. */
495
  delete_user_option ($user_id, "s2member_auto_eot_time");
496
  /**/
507
  /**/
508
  $paypal["s2member_log"][] = "Modification Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.";
509
  /**/
510
+ if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
511
+ {
512
+ foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_urls"]) as $url)
513
+ /**/
514
+ if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["subscr_id"])), $url)))
515
+ if (($url = preg_replace ("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["initial"])), $url)) && ($url = preg_replace ("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["regular"])), $url)) && ($url = preg_replace ("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["recurring"])), $url)))
516
+ if (($url = preg_replace ("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["initial_term"])), $url)) && ($url = preg_replace ("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["regular_term"])), $url)))
517
+ if (($url = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["item_name"])), $url)))
518
+ if (($url = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["last_name"])), $url)))
519
+ if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
520
+ if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
521
+ /**/
522
+ if (($url = preg_replace ("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->first_name)), $url)) && ($url = preg_replace ("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->last_name)), $url)))
523
+ if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
524
+ if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
525
+ if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
526
+ if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_reg_ip)), $url)))
527
+ if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
528
+ {
529
+ if (is_array ($fields) && !empty ($fields))
530
+ foreach ($fields as $var => $val) /* Custom Registration Fields. */
531
+ if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
532
+ break;
533
+ /**/
534
+ if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
535
+ c_ws_plugin__s2member_utils_urls::remote ($url);
536
+ }
537
+ /**/
538
+ $paypal["s2member_log"][] = "Modification Notification URLs have been processed.";
539
+ }
540
+ /**/
541
+ if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
542
+ {
543
+ $msg = $sbj = "( s2Member / API Notification Email ) - Modification";
544
+ $msg .= "\n\n"; /* Spacing in the message body. */
545
+ /**/
546
+ $msg .= "subscr_id: %%subscr_id%%\n";
547
+ $msg .= "initial: %%initial%%\n";
548
+ $msg .= "regular: %%regular%%\n";
549
+ $msg .= "recurring: %%recurring%%\n";
550
+ $msg .= "initial_term: %%initial_term%%\n";
551
+ $msg .= "regular_term: %%regular_term%%\n";
552
+ $msg .= "item_number: %%item_number%%\n";
553
+ $msg .= "item_name: %%item_name%%\n";
554
+ $msg .= "first_name: %%first_name%%\n";
555
+ $msg .= "last_name: %%last_name%%\n";
556
+ $msg .= "full_name: %%full_name%%\n";
557
+ $msg .= "payer_email: %%payer_email%%\n";
558
+ /**/
559
+ $msg .= "user_first_name: %%user_first_name%%\n";
560
+ $msg .= "user_last_name: %%user_last_name%%\n";
561
+ $msg .= "user_full_name: %%user_full_name%%\n";
562
+ $msg .= "user_email: %%user_email%%\n";
563
+ $msg .= "user_login: %%user_login%%\n";
564
+ $msg .= "user_ip: %%user_ip%%\n";
565
+ $msg .= "user_id: %%user_id%%\n";
566
+ /**/
567
+ if (is_array ($fields) && !empty ($fields))
568
+ foreach ($fields as $var => $val)
569
+ $msg .= $var . ": %%" . $var . "%%\n";
570
+ /**/
571
+ $msg .= "cv0: %%cv0%%\n";
572
+ $msg .= "cv1: %%cv1%%\n";
573
+ $msg .= "cv2: %%cv2%%\n";
574
+ $msg .= "cv3: %%cv3%%\n";
575
+ $msg .= "cv4: %%cv4%%\n";
576
+ $msg .= "cv5: %%cv5%%\n";
577
+ $msg .= "cv6: %%cv6%%\n";
578
+ $msg .= "cv7: %%cv7%%\n";
579
+ $msg .= "cv8: %%cv8%%\n";
580
+ $msg .= "cv9: %%cv9%%";
581
+ /**/
582
+ if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["subscr_id"]), $msg)))
583
+ if (($msg = preg_replace ("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial"]), $msg)) && ($msg = preg_replace ("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular"]), $msg)) && ($msg = preg_replace ("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["recurring"]), $msg)))
584
+ if (($msg = preg_replace ("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial_term"]), $msg)) && ($msg = preg_replace ("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular_term"]), $msg)))
585
+ if (($msg = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_name"]), $msg)))
586
+ if (($msg = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $msg)))
587
+ if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
588
+ if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
589
+ /**/
590
+ if (($msg = preg_replace ("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->first_name), $msg)) && ($msg = preg_replace ("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->last_name), $msg)))
591
+ if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
592
+ if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
593
+ if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
594
+ if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_reg_ip), $msg)))
595
+ if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
596
+ {
597
+ if (is_array ($fields) && !empty ($fields))
598
+ foreach ($fields as $var => $val) /* Custom Registration Fields. */
599
+ if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
600
+ break;
601
+ /**/
602
+ if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
603
+ foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_recipients"])) as $recipient)
604
+ ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_modification_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_modification_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
605
+ }
606
+ /**/
607
+ $paypal["s2member_log"][] = "Modification Notification Emails have been processed.";
608
+ }
609
+ /**/
610
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
611
  do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_signup_w_update_vars", get_defined_vars ());
612
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
636
  {
637
  $processing = $during = true; /* Yes, we ARE processing this. */
638
  /**/
639
+ $sbj = preg_replace ("/%%registration_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_GET["s2member_paypal_proxy"] && preg_match ("/pro-emails/", $_GET["s2member_paypal_proxy_use"])) ? "pro_" : "") . "signup_email_subject"]);
640
+ $msg = preg_replace ("/%%registration_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_GET["s2member_paypal_proxy"] && preg_match ("/pro-emails/", $_GET["s2member_paypal_proxy_use"])) ? "pro_" : "") . "signup_email_message"]);
641
+ $rec = preg_replace ("/%%registration_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($registration_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][(($_GET["s2member_paypal_proxy"] && preg_match ("/pro-emails/", $_GET["s2member_paypal_proxy_use"])) ? "pro_" : "") . "signup_email_recipients"]);
642
  /**/
643
  if (($rec = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $rec)) && ($rec = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["subscr_id"]), $rec)))
644
  if (($rec = preg_replace ("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial"]), $rec)) && ($rec = preg_replace ("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular"]), $rec)))
645
  if (($rec = preg_replace ("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial_term"]), $rec)) && ($rec = preg_replace ("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular_term"]), $rec)))
646
  if (($rec = preg_replace ("/%%initial_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::period_term ($paypal["initial_term"])), $rec)) && ($rec = preg_replace ("/%%regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::period_term ($paypal["regular_term"], $paypal["recurring"])), $rec)))
647
+ if (($rec = preg_replace ("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["recurring"]), $rec)) && ($rec = preg_replace ("/%%recurring\/regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ((($paypal["recurring"]) ? $paypal["recurring"] . " / " . c_ws_plugin__s2member_utils_time::period_term ($paypal["regular_term"], true) : "0 / non-recurring")), $rec)))
648
  if (($rec = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_number"]), $rec)) && ($rec = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_name"]), $rec)))
649
  if (($rec = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq (c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"])), $rec)) && ($rec = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq (c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"])), $rec)))
650
  if (($rec = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq (c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $rec))) /* **NOTE** c_ws_plugin__s2member_utils_strings::esc_dq() is applied here. ( ex. "N\"ame" <email> ). */
651
  if (($rec = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $rec)))
652
+ if (($rec = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $rec)))
653
+ /**/
654
+ if (($sbj = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)) && ($sbj = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["subscr_id"]), $sbj)))
655
+ if (($sbj = preg_replace ("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial"]), $sbj)) && ($sbj = preg_replace ("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular"]), $sbj)))
656
+ if (($sbj = preg_replace ("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial_term"]), $sbj)) && ($sbj = preg_replace ("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular_term"]), $sbj)))
657
+ if (($sbj = preg_replace ("/%%initial_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::period_term ($paypal["initial_term"])), $sbj)) && ($sbj = preg_replace ("/%%regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::period_term ($paypal["regular_term"], $paypal["recurring"])), $sbj)))
658
+ if (($sbj = preg_replace ("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["recurring"]), $sbj)) && ($sbj = preg_replace ("/%%recurring\/regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ((($paypal["recurring"]) ? $paypal["recurring"] . " / " . c_ws_plugin__s2member_utils_time::period_term ($paypal["regular_term"], true) : "0 / non-recurring")), $sbj)))
659
+ if (($sbj = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_number"]), $sbj)) && ($sbj = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_name"]), $sbj)))
660
+ if (($sbj = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $sbj)) && ($sbj = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $sbj)))
661
+ if (($sbj = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)))
662
+ if (($sbj = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $sbj)))
663
+ if (($sbj = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $sbj)))
664
+ /**/
665
+ if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["subscr_id"]), $msg)))
666
+ if (($msg = preg_replace ("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial"]), $msg)) && ($msg = preg_replace ("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular"]), $msg)))
667
+ if (($msg = preg_replace ("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial_term"]), $msg)) && ($msg = preg_replace ("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular_term"]), $msg)))
668
+ if (($msg = preg_replace ("/%%initial_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::period_term ($paypal["initial_term"])), $msg)) && ($msg = preg_replace ("/%%regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (c_ws_plugin__s2member_utils_time::period_term ($paypal["regular_term"], $paypal["recurring"])), $msg)))
669
+ if (($msg = preg_replace ("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["recurring"]), $msg)) && ($msg = preg_replace ("/%%recurring\/regular_cycle%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ((($paypal["recurring"]) ? $paypal["recurring"] . " / " . c_ws_plugin__s2member_utils_time::period_term ($paypal["regular_term"], true) : "0 / non-recurring")), $msg)))
670
+ if (($msg = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_name"]), $msg)))
671
+ if (($msg = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $msg)))
672
+ if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
673
+ if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
674
+ if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $msg)))
675
+ /**/
676
+ if (($recipients = preg_split ("/;+/", preg_replace ("/%%(.+?)%%/i", "", $rec))) && ($sbj = trim (preg_replace ("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
677
+ {
678
+ foreach (c_ws_plugin__s2member_utils_strings::trim_deep ($recipients) as $recipient) /* Go through the full list of recipients. */
679
+ ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_signup_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_signup_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
680
+ /**/
681
+ $paypal["s2member_log"][] = "Signup Confirmation Email sent to: " . implode ("; ", $recipients) . ".";
682
+ }
683
  /**/
684
  if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
685
  {
692
  if (($url = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["last_name"])), $url)))
693
  if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
694
  if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
695
+ if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["ip"])), $url)))
696
+ /**/
697
+ if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
698
+ c_ws_plugin__s2member_utils_urls::remote ($url);
699
  /**/
700
  $paypal["s2member_log"][] = "Signup Notification URLs have been processed.";
701
  }
717
  $msg .= "last_name: %%last_name%%\n";
718
  $msg .= "full_name: %%full_name%%\n";
719
  $msg .= "payer_email: %%payer_email%%\n";
720
+ $msg .= "user_ip: %%user_ip%%\n";
721
+ /**/
722
  $msg .= "cv0: %%cv0%%\n";
723
  $msg .= "cv1: %%cv1%%\n";
724
  $msg .= "cv2: %%cv2%%\n";
737
  if (($msg = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $msg)))
738
  if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
739
  if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
740
+ if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $msg)))
741
+ /**/
742
+ if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
743
+ foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["signup_notification_recipients"])) as $recipient)
744
+ ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_signup_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_signup_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
745
  /**/
746
  $paypal["s2member_log"][] = "Signup Notification Emails have been processed.";
747
  }
755
  if (($code = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $code)) && ($code = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $code)))
756
  if (($code = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
757
  if (($code = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $code)))
758
+ if (($code = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $code)))
759
+ /**/
760
+ if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code)))) /* This gets stored into a Transient Queue. */
761
+ {
762
+ $paypal["s2member_log"][] = "Storing Signup Tracking Codes into a Transient Queue. These will be processed on-site.";
763
+ set_transient ("s2m_" . md5 ("s2member_transient_signup_tracking_codes_" . $paypal["subscr_id"]), $code, 43200);
764
+ }
765
  }
766
  /**/
767
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
778
  /**/
779
  if ($processing && $_GET["s2member_paypal_proxy"] && ($url = $_GET["s2member_paypal_proxy_return_url"]) && is_array ($cv = preg_split ("/\|/", $paypal["custom"]))) /* A Proxy is requesting a Return URL? */
780
  {
781
+ if (($user_id && is_object ($user) && $user->ID) || (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["subscr_id"], $paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID))
782
  {
783
+ $fields = get_user_option ("s2member_custom_fields", $user_id); /* These will be needed in the routines below. */
784
+ $user_reg_ip = get_user_option ("s2member_registration_ip", $user_id); /* Original IP during Registration. */
785
  /**/
786
  if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["subscr_id"])), $url)))
787
  if (($url = preg_replace ("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["initial"])), $url)) && ($url = preg_replace ("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["regular"])), $url)) && ($url = preg_replace ("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["recurring"])), $url)))
796
  if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
797
  if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
798
  if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
799
+ if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_reg_ip)), $url)))
800
+ if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
801
+ {
802
+ if (is_array ($fields) && !empty ($fields))
803
+ foreach ($fields as $var => $val) /* Custom Registration Fields. */
804
+ if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
805
+ break;
806
+ /**/
807
+ if (($url = trim ($url))) /* Preserve remaining replacements. */
808
+ /* Because the parent routine may perform replacements too. */
809
+ $paypal["s2member_paypal_proxy_return_url"] = $url;
810
+ }
811
  }
812
  }
813
  /**/
815
  }
816
  /**/
817
  if ($processing /* Process a payment now? Special cases for web_accept and/or Proxy requests with `subscr-signup-as-subscr-payment`. */
818
+ && (preg_match ("/^web_accept$/i", $paypal["txn_type"]) || ($_GET["s2member_paypal_proxy"] && preg_match ("/subscr-signup-as-subscr-payment/", $_GET["s2member_paypal_proxy_use"]) && $paypal["txn_id"] && $paypal["mc_gross"] > 0))/**/
819
+ && (($user_id && is_object ($user) && $user->ID) || (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["subscr_id"], $paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)))
820
  {
821
+ $paypal["s2member_log"][] = "User exists. Handling `payment` for Subscription via (" . ((preg_match ("/^web_accept$/i", $paypal["txn_type"])) ? "web_accept" : "subscr-signup-as-subscr-payment") . ").";
822
  /**/
823
  $pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
824
  $pr_times["level"] = (!$pr_times["level"]) ? time () : $pr_times["level"]; /* Preserves existing. */
825
  $pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
826
  update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
827
  /**/
828
+ if (!get_user_option ("s2member_first_payment_txn_id", $user_id)) /* 1st payment? */
829
+ update_user_option ($user_id, "s2member_first_payment_txn_id", $paypal["txn_id"]);
830
+ /**/
831
+ update_user_option ($user_id, "s2member_last_payment_time", time ()); /* Update the last payment time. */
832
  /**/
833
  $fields = get_user_option ("s2member_custom_fields", $user_id); /* These will be needed in the routines below. */
834
+ $user_reg_ip = get_user_option ("s2member_registration_ip", $user_id); /* Original IP during Registration. */
835
  /**/
836
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
837
  {
848
  if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
849
  if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
850
  if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
851
+ if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_reg_ip)), $url)))
852
+ if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
853
+ {
854
+ if (is_array ($fields) && !empty ($fields))
855
+ foreach ($fields as $var => $val) /* Custom Registration Fields. */
856
+ if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
857
+ break;
858
+ /**/
859
+ if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
860
+ c_ws_plugin__s2member_utils_urls::remote ($url);
861
+ }
862
  }
863
  /**/
864
  $paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
884
  $msg .= "user_full_name: %%user_full_name%%\n";
885
  $msg .= "user_email: %%user_email%%\n";
886
  $msg .= "user_login: %%user_login%%\n";
887
+ $msg .= "user_ip: %%user_ip%%\n";
888
  $msg .= "user_id: %%user_id%%\n";
889
  /**/
890
  if (is_array ($fields) && !empty ($fields))
913
  if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
914
  if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
915
  if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
916
+ if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_reg_ip), $msg)))
917
+ if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
918
+ {
919
+ if (is_array ($fields) && !empty ($fields))
920
+ foreach ($fields as $var => $val) /* Custom Registration Fields. */
921
+ if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
922
+ break;
923
+ /**/
924
+ if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
925
+ foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"])) as $recipient)
926
+ ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_payment_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_payment_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
927
+ }
928
  }
929
  /**/
930
  $paypal["s2member_log"][] = "Payment Notification Emails have been processed.";
931
  }
932
  }
933
  else if ($processing /* Process a payment now? Special cases for web_accept and/or Proxy requests with `subscr-signup-as-subscr-payment`. */
934
+ && (preg_match ("/^web_accept$/i", $paypal["txn_type"]) || ($_GET["s2member_paypal_proxy"] && preg_match ("/subscr-signup-as-subscr-payment/", $_GET["s2member_paypal_proxy_use"]) && $paypal["txn_id"] && $paypal["mc_gross"] > 0)))
935
  {
936
+ $paypal["s2member_log"][] = "Storing `payment` for Subscription via (" . ((preg_match ("/^web_accept$/i", $paypal["txn_type"])) ? "web_accept" : "subscr-signup-as-subscr-payment") . ").";
937
  /**/
938
  $ipn = array ("txn_type" => "subscr_payment"); /* Create a simulated IPN response for txn_type=subscr_payment. */
939
  /**/
940
  foreach ($paypal as $var => $val)
941
+ if (in_array ($var, array ("subscr_gateway", "subscr_id", "txn_id", "custom", "invoice", "mc_gross", "mc_currency", "tax", "payer_email", "first_name", "last_name", "item_name", "item_number", "option_name1", "option_selection1", "option_name2", "option_selection2")))
942
  $ipn[$var] = $val;
943
  /**/
944
  $paypal["s2member_log"][] = "Creating an IPN response for `subscr_payment`. This will go into a Transient Queue; and be processed during registration.";
947
  }
948
  /**/
949
  if ($processing /* Store signup vars now? If the User already exists in the database, we can go ahead and store these right now. */
950
+ && (($user_id && is_object ($user) && $user->ID) || (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["subscr_id"], $paypal["option_selection1"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)))
951
  {
952
  $paypal["s2member_log"][] = "Storing IPN signup vars now. These are associated with a User's account record; for future reference.";
953
  /**/
970
  be necessary in a future release of s2Member. For now, it's just a fill-in.
971
  These Hooks/Filters will remain, so you can use them now; if you need to.
972
  */
973
+ else if (/**/(preg_match ("/^recurring_payment_profile_created$/i", $paypal["txn_type"]))/**/
974
  && ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal)))/**/
975
  && (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])) /* This must match a Subscription. */
976
  && ($paypal["subscr_id"] || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)))/**/
999
  /*
1000
  Subscription modifications.
1001
  */
1002
+ else if (/**/(preg_match ("/^subscr_modify$/i", $paypal["txn_type"]))/**/
1003
+ && (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"]))/**/
1004
  && ($paypal["subscr_id"] && $paypal["payer_email"])/**/)
1005
  {
1006
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1011
  /**/
1012
  list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
1013
  /**/
1014
+ $paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
1015
+ $paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[0-9]+~[0-9\.]+$/", $paypal["invoice"])) ? preg_replace ("/^[0-9]+~/", "", $paypal["invoice"]) : $paypal["ip"];
1016
+ /**/
1017
+ $paypal["period1"] = (preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : "0 D"; /* Defaults to "0 D" ( zero days ). */
1018
  $paypal["mc_amount1"] = (strlen ($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0) ? $paypal["mc_amount1"] : "0.00"; /* "0.00". */
1019
  /**/
1020
  $paypal["initial_term"] = (preg_match ("/^[1-9]/", $paypal["period1"])) ? $paypal["period1"] : "0 D"; /* Defaults to "0 D" ( zero days ). */
1033
  /**/
1034
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1035
  do_action ("ws_plugin__s2member_during_paypal_notify_during_before_subscr_modify", get_defined_vars ());
1036
+ do_action ("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars (), "ipn-upgrade-downgrade", "modification", "s2member_level" . $paypal["level"]);
1037
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
1038
  /**/
1039
+ $fields = get_user_option ("s2member_custom_fields", $user_id); /* These will be needed in the routines below. */
1040
+ $user_reg_ip = get_user_option ("s2member_registration_ip", $user_id); /* Original IP during Registration. */
1041
+ $user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"]; /* Now merge conditionally. */
1042
  /**/
1043
  if (is_multisite () && !is_user_member_of_blog ($user_id))
1044
  {
1064
  update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
1065
  update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
1066
  /**/
1067
+ if (!get_user_option ("s2member_registration_ip", $user_id))
1068
+ update_user_option ($user_id, "s2member_registration_ip", $paypal["ip"]);
1069
+ /**/
1070
  update_user_option ($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
1071
  /**/
1072
  delete_user_option ($user_id, "s2member_file_download_access_arc");
1087
  /**/
1088
  $paypal["s2member_log"][] = "Modification Confirmation Email sent to Customer, with a URL that provides them with a way to log back in.";
1089
  /**/
1090
+ if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
1091
+ {
1092
+ foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_urls"]) as $url)
1093
+ /**/
1094
+ if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["subscr_id"])), $url)))
1095
+ if (($url = preg_replace ("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["initial"])), $url)) && ($url = preg_replace ("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["regular"])), $url)) && ($url = preg_replace ("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["recurring"])), $url)))
1096
+ if (($url = preg_replace ("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["initial_term"])), $url)) && ($url = preg_replace ("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["regular_term"])), $url)))
1097
+ if (($url = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["item_number"])), $url)) && ($url = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["item_name"])), $url)))
1098
+ if (($url = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["last_name"])), $url)))
1099
+ if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
1100
+ if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
1101
+ /**/
1102
+ if (($url = preg_replace ("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->first_name)), $url)) && ($url = preg_replace ("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->last_name)), $url)))
1103
+ if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
1104
+ if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
1105
+ if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
1106
+ if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_reg_ip)), $url)))
1107
+ if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
1108
+ {
1109
+ if (is_array ($fields) && !empty ($fields))
1110
+ foreach ($fields as $var => $val) /* Custom Registration Fields. */
1111
+ if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
1112
+ break;
1113
+ /**/
1114
+ if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
1115
+ c_ws_plugin__s2member_utils_urls::remote ($url);
1116
+ }
1117
+ /**/
1118
+ $paypal["s2member_log"][] = "Modification Notification URLs have been processed.";
1119
+ }
1120
+ /**/
1121
+ if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_recipients"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
1122
+ {
1123
+ $msg = $sbj = "( s2Member / API Notification Email ) - Modification";
1124
+ $msg .= "\n\n"; /* Spacing in the message body. */
1125
+ /**/
1126
+ $msg .= "subscr_id: %%subscr_id%%\n";
1127
+ $msg .= "initial: %%initial%%\n";
1128
+ $msg .= "regular: %%regular%%\n";
1129
+ $msg .= "recurring: %%recurring%%\n";
1130
+ $msg .= "initial_term: %%initial_term%%\n";
1131
+ $msg .= "regular_term: %%regular_term%%\n";
1132
+ $msg .= "item_number: %%item_number%%\n";
1133
+ $msg .= "item_name: %%item_name%%\n";
1134
+ $msg .= "first_name: %%first_name%%\n";
1135
+ $msg .= "last_name: %%last_name%%\n";
1136
+ $msg .= "full_name: %%full_name%%\n";
1137
+ $msg .= "payer_email: %%payer_email%%\n";
1138
+ /**/
1139
+ $msg .= "user_first_name: %%user_first_name%%\n";
1140
+ $msg .= "user_last_name: %%user_last_name%%\n";
1141
+ $msg .= "user_full_name: %%user_full_name%%\n";
1142
+ $msg .= "user_email: %%user_email%%\n";
1143
+ $msg .= "user_login: %%user_login%%\n";
1144
+ $msg .= "user_ip: %%user_ip%%\n";
1145
+ $msg .= "user_id: %%user_id%%\n";
1146
+ /**/
1147
+ if (is_array ($fields) && !empty ($fields))
1148
+ foreach ($fields as $var => $val)
1149
+ $msg .= $var . ": %%" . $var . "%%\n";
1150
+ /**/
1151
+ $msg .= "cv0: %%cv0%%\n";
1152
+ $msg .= "cv1: %%cv1%%\n";
1153
+ $msg .= "cv2: %%cv2%%\n";
1154
+ $msg .= "cv3: %%cv3%%\n";
1155
+ $msg .= "cv4: %%cv4%%\n";
1156
+ $msg .= "cv5: %%cv5%%\n";
1157
+ $msg .= "cv6: %%cv6%%\n";
1158
+ $msg .= "cv7: %%cv7%%\n";
1159
+ $msg .= "cv8: %%cv8%%\n";
1160
+ $msg .= "cv9: %%cv9%%";
1161
+ /**/
1162
+ if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace ("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["subscr_id"]), $msg)))
1163
+ if (($msg = preg_replace ("/%%initial%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial"]), $msg)) && ($msg = preg_replace ("/%%regular%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular"]), $msg)) && ($msg = preg_replace ("/%%recurring%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["recurring"]), $msg)))
1164
+ if (($msg = preg_replace ("/%%initial_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["initial_term"]), $msg)) && ($msg = preg_replace ("/%%regular_term%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["regular_term"]), $msg)))
1165
+ if (($msg = preg_replace ("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_number"]), $msg)) && ($msg = preg_replace ("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["item_name"]), $msg)))
1166
+ if (($msg = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $msg)))
1167
+ if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
1168
+ if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
1169
+ /**/
1170
+ if (($msg = preg_replace ("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->first_name), $msg)) && ($msg = preg_replace ("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->last_name), $msg)))
1171
+ if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
1172
+ if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
1173
+ if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
1174
+ if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_reg_ip), $msg)))
1175
+ if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
1176
+ {
1177
+ if (is_array ($fields) && !empty ($fields))
1178
+ foreach ($fields as $var => $val) /* Custom Registration Fields. */
1179
+ if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
1180
+ break;
1181
+ /**/
1182
+ if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
1183
+ foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["modification_notification_recipients"])) as $recipient)
1184
+ ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_modification_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_modification_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
1185
+ }
1186
+ /**/
1187
+ $paypal["s2member_log"][] = "Modification Notification Emails have been processed.";
1188
+ }
1189
+ /**/
1190
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1191
  do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_modify", get_defined_vars ());
1192
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
1205
  Subscription payment notifications.
1206
  We need these to update: `s2member_last_payment_time`.
1207
  */
1208
+ else if (/**/(preg_match ("/^(subscr_payment|recurring_payment)$/i", $paypal["txn_type"]))/**/
1209
  && ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal)))/**/
1210
  && (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])) /* This must match a Subscription. */
1211
  && ($paypal["subscr_id"] || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)))/**/
1212
+ && (!preg_match ($payment_status_issues, $paypal["payment_status"])) /* Status OK? This goes thru a list of known status issues. */
1213
  && ($paypal["item_name"] || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal)))/**/
1214
  && ($paypal["payer_email"] || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with ($paypal["subscr_id"])))/**/
1215
  && ($paypal["txn_id"] && $paypal["mc_gross"])/**/)
1218
  do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_payment", get_defined_vars ());
1219
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
1220
  /**/
1221
+ $paypal["s2member_log"][] = "s2Member txn_type identified as " . ($identified_as = "subscr_payment|recurring_payment") . ".";
1222
+ $paypal["s2member_log"][] = "Sleeping for 5 seconds. Waiting for a possible subscr_signup|subscr_modify|recurring_payment_profile_created.";
1223
+ sleep (5); /* Sleep here for a moment. PayPal® sometimes sends a subscr_payment before the subscr_signup, subscr_modify. */
1224
+ /* It is NOT a big deal if they do. However, s2Member goes to sleep here, just to help keep the log files in a logical order. */
1225
+ $paypal["s2member_log"][] = "Awake. It's " . date ("D M j, Y g:i:s a T") . ". s2Member txn_type identified as " . $identified_as . ".";
1226
  /**/
1227
  list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
1228
  /**/
1229
+ $paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
1230
+ $paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[0-9]+~[0-9\.]+$/", $paypal["invoice"])) ? preg_replace ("/^[0-9]+~/", "", $paypal["invoice"]) : $paypal["ip"];
1231
+ /**/
1232
  if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["subscr_id"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
1233
  {
1234
  $processing = $during = true; /* Yes, we ARE processing this. */
1238
  $pr_times["level" . $paypal["level"]] = (!$pr_times["level" . $paypal["level"]]) ? time () : $pr_times["level" . $paypal["level"]];
1239
  update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
1240
  /**/
1241
+ if (!get_user_option ("s2member_first_payment_txn_id", $user_id)) /* 1st payment? */
1242
+ update_user_option ($user_id, "s2member_first_payment_txn_id", $paypal["txn_id"]);
1243
+ /**/
1244
  update_user_option ($user_id, "s2member_last_payment_time", time ()); /* Also update last payment time. */
1245
  /**/
1246
  $paypal["s2member_log"][] = "Updated Payment Times for this Member."; /* Flag this action in the log. */
1247
  /**/
1248
  $fields = get_user_option ("s2member_custom_fields", $user_id); /* These will be needed in the routines below. */
1249
+ $user_reg_ip = get_user_option ("s2member_registration_ip", $user_id); /* Original IP during Registration. */
1250
+ $user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"]; /* Now merge conditionally. */
1251
  /**/
1252
  if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
1253
  {
1264
  if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
1265
  if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
1266
  if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
1267
+ if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_reg_ip)), $url)))
1268
+ if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
1269
+ {
1270
+ if (is_array ($fields) && !empty ($fields))
1271
+ foreach ($fields as $var => $val) /* Custom Registration Fields. */
1272
+ if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
1273
+ break;
1274
+ /**/
1275
+ if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
1276
+ c_ws_plugin__s2member_utils_urls::remote ($url);
1277
+ }
1278
  }
1279
  /**/
1280
  $paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
1300
  $msg .= "user_full_name: %%user_full_name%%\n";
1301
  $msg .= "user_email: %%user_email%%\n";
1302
  $msg .= "user_login: %%user_login%%\n";
1303
+ $msg .= "user_ip: %%user_ip%%\n";
1304
  $msg .= "user_id: %%user_id%%\n";
1305
  /**/
1306
  if (is_array ($fields) && !empty ($fields))
1329
  if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
1330
  if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
1331
  if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
1332
+ if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_reg_ip), $msg)))
1333
+ if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
1334
+ {
1335
+ if (is_array ($fields) && !empty ($fields))
1336
+ foreach ($fields as $var => $val) /* Custom Registration Fields. */
1337
+ if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
1338
+ break;
1339
+ /**/
1340
+ if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
1341
+ foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"])) as $recipient)
1342
+ ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_payment_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_payment_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
1343
+ }
1344
  }
1345
  /**/
1346
  $paypal["s2member_log"][] = "Payment Notification Emails have been processed.";
1357
  $ipn = array ("txn_type" => "subscr_payment"); /* Create a simulated IPN response for txn_type=subscr_payment. */
1358
  /**/
1359
  foreach ($paypal as $var => $val)
1360
+ if (in_array ($var, array ("subscr_gateway", "subscr_id", "txn_id", "custom", "invoice", "mc_gross", "mc_currency", "tax", "payer_email", "first_name", "last_name", "item_name", "item_number", "option_name1", "option_selection1", "option_name2", "option_selection2")))
1361
  $ipn[$var] = $val;
1362
  /**/
1363
+ $paypal["s2member_log"][] = "Re-generating. This IPN will go into a Transient Queue; and be re-processed during registration.";
1364
  /**/
1365
  set_transient ("s2m_" . md5 ("s2member_transient_ipn_subscr_payment_" . $paypal["subscr_id"]), $ipn, 43200);
1366
  }
1375
  be necessary in a future release of s2Member. For now, it's just a fill-in.
1376
  These Hooks/Filters will remain, so you can use them now; if you need to.
1377
  */
1378
+ else if (/**/(preg_match ("/^(subscr_failed|recurring_payment_failed|recurring_payment_skipped)$/i", $paypal["txn_type"]))/**/
1379
  && ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal)))/**/
1380
  && (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])) /* Must match a Subscription. */
1381
  && ($paypal["subscr_id"] || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id ($paypal)))/**/
1408
  This works in conjunction with `s2member_last_payment_time`, and the s2Member Auto-EOT System.
1409
  For further details, see: https://www.x.com/thread/41155?start=15&tstart=0
1410
  */
1411
+ else if (/**/(preg_match ("/^(subscr_cancel|recurring_payment_profile_cancel)$/i", $paypal["txn_type"]))/**/
1412
+ && !(preg_match ("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]) && preg_match ("/^failed$/i", $paypal["initial_payment_status"]))
1413
  /* ^^ Bypass this case ( for now ) "recurring_payment_profile_cancel" with an initial failed payment warrants an EOT instead of a cancellation. */
1414
  && ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) /* item_number? */
1415
  && (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"])) /* This item_number must validate as Membership Access. */
1427
  /**/
1428
  list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
1429
  /**/
1430
+ $paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
1431
+ $paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[0-9]+~[0-9\.]+$/", $paypal["invoice"])) ? preg_replace ("/^[0-9]+~/", "", $paypal["invoice"]) : $paypal["ip"];
1432
+ /**/
1433
  if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["subscr_id"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
1434
  {
1435
  if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
1436
  {
1437
+ $fields = get_user_option ("s2member_custom_fields", $user_id); /* These will be needed in the routines below. */
1438
+ $user_reg_ip = get_user_option ("s2member_registration_ip", $user_id); /* Original IP during Registration. */
1439
+ $user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"]; /* Now merge conditionally. */
1440
  /**/
1441
  if (!get_user_option ("s2member_auto_eot_time", $user_id)) /* Respect existing. */
1442
  {
1465
  if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
1466
  if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
1467
  if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
1468
+ if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_reg_ip)), $url)))
1469
+ if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
1470
+ {
1471
+ if (is_array ($fields) && !empty ($fields))
1472
+ foreach ($fields as $var => $val) /* Custom Registration Fields. */
1473
+ if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
1474
+ break;
1475
+ /**/
1476
+ if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
1477
+ c_ws_plugin__s2member_utils_urls::remote ($url);
1478
+ }
1479
  /**/
1480
  $paypal["s2member_log"][] = "Cancellation Notification URLs have been processed.";
1481
  }
1493
  $msg .= "user_full_name: %%user_full_name%%\n";
1494
  $msg .= "user_email: %%user_email%%\n";
1495
  $msg .= "user_login: %%user_login%%\n";
1496
+ $msg .= "user_ip: %%user_ip%%\n";
1497
  $msg .= "user_id: %%user_id%%\n";
1498
  /**/
1499
  if (is_array ($fields) && !empty ($fields))
1517
  if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
1518
  if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
1519
  if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
1520
+ if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_reg_ip), $msg)))
1521
+ if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
1522
+ {
1523
+ if (is_array ($fields) && !empty ($fields))
1524
+ foreach ($fields as $var => $val) /* Custom Registration Fields. */
1525
+ if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
1526
+ break;
1527
+ /**/
1528
+ if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
1529
+ foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_recipients"])) as $recipient)
1530
+ ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_cancellation_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_cancellation_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
1531
+ }
1532
  /**/
1533
  $paypal["s2member_log"][] = "Cancellation Notification Emails have been processed.";
1534
  }
1559
  ~ NOTE: Partial Refunds ( i.e. payment_status=partially_refunded or txn_type=adjustment ) are NOT processed by this routine.
1560
  ( This is the intended behavior. A Partial Refund does NOT clearly indicate that s2Member should do anything at all. )
1561
  HOWEVER. PayPal® does NOT always send payment_status=partially_refunded. This is well documented on their site, but in
1562
+ practice, it never seems to happen. It's best to check the negative mc_gross amount instead.
1563
  */
1564
  else if (/**/( /* Partial Refunds ( i.e. payment_status=partially_refunded or txn_type=adjustment ) are NOT processed by this routine. */
1565
+ (preg_match ("/^(subscr_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment)$/i", $paypal["txn_type"]) && ($recurring = 1))/**/
1566
+ || (preg_match ("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]) && preg_match ("/^failed$/i", $paypal["initial_payment_status"]) && ($recurring = 1))/**/
1567
+ || (preg_match ("/^new_case$/i", $paypal["txn_type"]) && preg_match ("/^chargeback$/i", $paypal["case_type"])) /* ONLY for future compatibility. This does NOT work yet. */
1568
+ || (preg_match ("/^(refunded|reversed|reversal)$/i", $paypal["payment_status"])) /* The "txn_type" is irrelevant in all of these cases: refunded|reversed|reversal. */)/**/
1569
  && ($paypal["period1"] || ($paypal["period1"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1 ($paypal)) || !$recurring || ($paypal["period1"] = "0 D"))/**/
1570
  && ($paypal["period3"] || ($paypal["period3"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3 ($paypal)) || !$recurring) /* Was it even recurring? */
1571
  && ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) /* Do we have a valid item_number? */
1579
  do_action ("ws_plugin__s2member_during_paypal_notify_before_subscr_eot", get_defined_vars ());
1580
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
1581
  /**/
1582
+ $is_refund = (preg_match ("/^refunded$/i", $paypal["payment_status"]) && $paypal["parent_txn_id"]);
1583
+ $is_reversal = (preg_match ("/^(reversed|reversal)$/i", $paypal["payment_status"]) && $paypal["parent_txn_id"]);
1584
+ $is_reversal = (!$is_reversal) ? (preg_match ("/^new_case$/i", $paypal["txn_type"]) && preg_match ("/^chargeback$/i", $paypal["case_type"])) : $is_reversal;
1585
+ $is_refund_or_reversal = ($is_refund || $is_reversal); /* If either of the previous tests above evaluated to true; then it's obviously a Refund and/or a Reversal. */
1586
+ $is_delayed_eot = (!$is_refund_or_reversal && preg_match ("/^(subscr_eot|recurring_payment_expired)$/i", $paypal["txn_type"]) && preg_match ("/^I-/i", $paypal["subscr_id"]));
1587
  /**/
1588
  if ($is_refund_or_reversal)
1589
+ $paypal["s2member_log"][] = "s2Member txn_type identified as " . ($identified_as = "[empty or irrelevant] w/ payment_status (refunded|reversed|reversal) - or - new_case w/ case_type (chargeback)") . ".";
1590
  else
1591
+ $paypal["s2member_log"][] = "s2Member txn_type identified as " . ($identified_as = "(subscr_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment) - or - recurring_payment_profile_cancel w/ initial_payment_status (failed)") . ".";
1592
+ /**/
1593
+ $paypal["s2member_log"][] = "Sleeping for 5 seconds. Waiting for a possible subscr_signup|subscr_modify|recurring_payment_profile_created.";
1594
+ sleep (5); /* Sleep here for a moment. PayPal® sometimes sends a subscr_eot before the subscr_signup, subscr_modify. */
1595
+ /* It is NOT a big deal if they do. However, s2Member goes to sleep here, just to help keep the log files in a logical order. */
1596
+ $paypal["s2member_log"][] = "Awake. It's " . date ("D M j, Y g:i:s a T") . ". s2Member txn_type identified as " . $identified_as . ".";
1597
+ /**/
1598
+ $paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
1599
+ $paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[0-9]+~[0-9\.]+$/", $paypal["invoice"])) ? preg_replace ("/^[0-9]+~/", "", $paypal["invoice"]) : $paypal["ip"];
1600
  /**/
1601
  if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["subscr_id"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
1602
  {
1603
  $fields = get_user_option ("s2member_custom_fields", $user_id); /* These will be needed below. */
1604
+ $user_reg_ip = get_user_option ("s2member_registration_ip", $user_id); /* Needed below. */
1605
+ $user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"];
1606
  /**/
1607
  if ( /* Here we take action, BUT based on Auto EOT Behavior options; as configured by the Site Owner. */
1608
  (!$is_refund_or_reversal && !$is_delayed_eot && !get_user_option ("s2member_auto_eot_time", $user_id))/**/
1618
  {
1619
  $processing = $during = true; /* Yes, we ARE processing this. */
1620
  /**/
1621
+ $eot_del_type = ($is_refund_or_reversal) ? /* Set EOT/Del type. */
1622
+ "ipn-refund-reversal-demotion" : "ipn-cancellation-expiration-demotion";
1623
+ /**/
1624
+ $demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role ("subscriber");
1625
+ $existing_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
1626
  /**/
1627
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1628
  do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_before_demote", get_defined_vars ());
1629
+ do_action ("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars (), $eot_del_type, "modification", $demotion_role);
1630
+ do_action ("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars (), $eot_del_type, "modification");
1631
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
1632
  /**/
 
 
 
1633
  if ($existing_role !== $demotion_role) /* Only if NOT the existing Role. */
1634
  $user->set_role ($demotion_role); /* Give User the demotion Role. */
1635
  /**/
1647
  delete_user_option ($user_id, "s2member_paid_registration_times");
1648
  /**/
1649
  delete_user_option ($user_id, "s2member_last_status_scan");
1650
+ delete_user_option ($user_id, "s2member_first_payment_txn_id");
1651
  delete_user_option ($user_id, "s2member_last_payment_time");
1652
  delete_user_option ($user_id, "s2member_auto_eot_time");
1653
  /**/
1667
  if (($url = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
1668
  if (($url = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_email)), $url)))
1669
  if (($url = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user->user_login)), $url)))
1670
+ if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_reg_ip)), $url)))
1671
+ if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
1672
+ {
1673
+ if (is_array ($fields) && !empty ($fields))
1674
+ foreach ($fields as $var => $val) /* Custom Registration Fields. */
1675
+ if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
1676
+ break;
1677
+ /**/
1678
+ if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
1679
+ c_ws_plugin__s2member_utils_urls::remote ($url);
1680
+ }
1681
  /**/
1682
  $paypal["s2member_log"][] = "EOT/Deletion Notification URLs have been processed.";
1683
  }
1694
  $msg .= "user_full_name: %%user_full_name%%\n";
1695
  $msg .= "user_email: %%user_email%%\n";
1696
  $msg .= "user_login: %%user_login%%\n";
1697
+ $msg .= "user_ip: %%user_ip%%\n";
1698
  $msg .= "user_id: %%user_id%%\n";
1699
  /**/
1700
  if (is_array ($fields) && !empty ($fields))
1717
  if (($msg = preg_replace ("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($user->first_name . " " . $user->last_name)), $msg)))
1718
  if (($msg = preg_replace ("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_email), $msg)))
1719
  if (($msg = preg_replace ("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user->user_login), $msg)))
1720
+ if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_reg_ip), $msg)))
1721
+ if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
1722
+ {
1723
+ if (is_array ($fields) && !empty ($fields))
1724
+ foreach ($fields as $var => $val) /* Custom Registration Fields. */
1725
+ if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
1726
+ break;
1727
+ /**/
1728
+ if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
1729
+ foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_recipients"])) as $recipient)
1730
+ ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_eot_del_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_eot_del_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
1731
+ }
1732
  /**/
1733
  $paypal["s2member_log"][] = "EOT/Deletion Notification Emails have been processed.";
1734
  }
1742
  {
1743
  $processing = $during = true; /* Yes, we ARE processing this. */
1744
  /**/
1745
+ $eot_del_type = $GLOBALS["ws_plugin__s2member_eot_del_type"] = /* Configure EOT/Del type. */
1746
+ ($is_refund_or_reversal) ? "ipn-refund-reversal-deletion" : "ipn-cancellation-expiration-deletion";
1747
  /**/
1748
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1749
  do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_before_delete", get_defined_vars ());
1750
+ do_action ("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars (), $eot_del_type, "removal-deletion");
1751
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
1752
  /**/
 
 
 
1753
  if (is_multisite ()) /* Multisite does NOT actually delete; ONLY removes. */
1754
  {
1755
  remove_user_from_blog ($user_id, $current_blog->blog_id);
1759
  /**/
1760
  else /* Otherwise, we can actually delete them. */
1761
  /* This will automatically trigger `eot_del_notification_urls` as well. */
1762
+ wp_delete_user ($user_id); /* `c_ws_plugin__s2member_user_deletions::handle_user_deletions()` */
1763
  /**/
1764
+ $paypal["s2member_log"][] = "This Member's account has been " . ((is_multisite ()) ? "removed" : "deleted") . ".";
1765
  /**/
1766
  $paypal["s2member_log"][] = "EOT/Deletion Notification URLs have been processed.";
1767
  /**/
1823
  else if ($is_refund)
1824
  $paypal["s2member_log"][] = "Skipping (demote|delete) Member. Your configuration dictates that s2Member should NOT take any immediate action on an EOT associated with a Refund. An s2Member API Notification will still be processed however.";
1825
  }
1826
+ else if ($is_delayed_eot) /* Otherwise, we need to re-generate/store this IPN into a Transient Queue. Then re-process it on registration. */
1827
+ {
1828
+ $paypal["s2member_log"][] = "Skipping this IPN response, for now. The Subscr. ID is not associated with a registered Member.";
1829
+ /**/
1830
+ $ipn = array ("txn_type" => "subscr_eot"); /* Create a simulated IPN response for txn_type=subscr_eot. */
1831
+ /**/
1832
+ foreach ($paypal as $var => $val)
1833
+ if (in_array ($var, array ("subscr_gateway", "subscr_id", "custom", "invoice", "payer_email", "first_name", "last_name", "item_name", "item_number", "period1", "period3", "option_name1", "option_selection1", "option_name2", "option_selection2")))
1834
+ $ipn[$var] = $val;
1835
+ /**/
1836
+ $paypal["s2member_log"][] = "Re-generating. This IPN will go into a Transient Queue; and be re-processed during registration.";
1837
+ /**/
1838
+ set_transient ("s2m_" . md5 ("s2member_transient_ipn_subscr_eot_" . $paypal["subscr_id"]), $ipn, 43200);
1839
+ }
1840
+ /**/
1841
  else
1842
  $paypal["s2member_log"][] = "Unable to (demote|delete) Member. Could not get the existing User ID from the DB. It's possible that it was ALREADY processed through another IPN, removed manually by a Site Administrator, or by s2Member's Auto-EOT Sys.";
1843
  /*
1848
  */
1849
  if ($is_refund_or_reversal) /* Here we access this variable that was previously assigned as a quick method of Refund/Reversal detection. */
1850
  {
1851
+ $fields = ($user_id) ? get_user_option ("s2member_custom_fields", $user_id) : array (); /* These will be needed below. */
1852
+ $user_reg_ip = ($user_id) ? get_user_option ("s2member_registration_ip", $user_id) : ""; /* Needed below. */
1853
+ $user_reg_ip = $paypal["ip"] = ($user_reg_ip) ? $user_reg_ip : $paypal["ip"]; /* Now merge conditionally. */
1854
+ /**/
1855
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"] && is_array ($cv = preg_split ("/\|/", $paypal["custom"])))
1856
  {
1857
  foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_urls"]) as $url)
1862
  if (($url = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["last_name"])), $url)))
1863
  if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
1864
  if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
1865
+ if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_reg_ip)), $url)))
1866
+ if (($url = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($user_id)), $url)))
1867
+ {
1868
+ if (is_array ($fields) && !empty ($fields))
1869
+ foreach ($fields as $var => $val) /* Custom Registration Fields. */
1870
+ if (!($url = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (maybe_serialize ($val))), $url)))
1871
+ break;
1872
+ /**/
1873
+ if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
1874
+ c_ws_plugin__s2member_utils_urls::remote ($url);
1875
+ }
1876
  /**/
1877
  $paypal["s2member_log"][] = "Refund/Reversal Notification URLs have been processed.";
1878
  }
1892
  $msg .= "last_name: %%last_name%%\n";
1893
  $msg .= "full_name: %%full_name%%\n";
1894
  $msg .= "payer_email: %%payer_email%%\n";
1895
+ $msg .= "user_ip: %%user_ip%%\n";
1896
  $msg .= "user_id: %%user_id%%\n";
1897
  /**/
1898
  if (is_array ($fields) && !empty ($fields))
1916
  if (($msg = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $msg)))
1917
  if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
1918
  if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
1919
+ if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_reg_ip), $msg)))
1920
+ if (($msg = preg_replace ("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($user_id), $msg)))
1921
+ {
1922
+ if (is_array ($fields) && !empty ($fields))
1923
+ foreach ($fields as $var => $val) /* Custom Registration Fields. */
1924
+ if (!($msg = preg_replace ("/%%" . preg_quote ($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (maybe_serialize ($val)), $msg)))
1925
+ break;
1926
+ /**/
1927
+ if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
1928
+ foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["ref_rev_notification_recipients"])) as $recipient)
1929
+ ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_ref_rev_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_ref_rev_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
1930
+ }
1931
  /**/
1932
  $paypal["s2member_log"][] = "Refund/Reversal Notification Emails have been processed.";
1933
  }
1952
  ~ NOTE: Partial Refunds ( i.e. payment_status=partially_refunded ) is NOT processed by this routine, or any other s2Member routine.
1953
  ( This is the intended behavior. A Partial Refund does NOT clearly indicate that s2Member should do anything at all. )
1954
  HOWEVER. PayPal® does NOT always send payment_status=partially_refunded. This is well documented on their site, but in
1955
+ practice, it never seems to happen. It's best to check the negative mc_gross amount instead.
1956
  */
1957
+ else if (/**/(/**/(preg_match ("/^new_case$/i", $paypal["txn_type"]) && preg_match ("/^chargeback$/i", $paypal["case_type"])) /* Future compatibility. */
1958
+ || (preg_match ("/^(refunded|reversed|reversal)$/i", $paypal["payment_status"])) /* The "txn_type" is irrelevant in all of these special cases. */)/**/
1959
+ && ($paypal["item_number"] || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number ($paypal))) /* Item number required. */
1960
+ && (preg_match ("/^sp\:[0-9,]+\:[0-9]+$/", $paypal["item_number"])) /* Only for "Specific Post/Page Access" here. NOT for Membership ( i.e. sp:IDs:expiration hours ). */
1961
+ && ($paypal["item_name"] || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name ($paypal)) || ($paypal["item_name"] = $_SERVER["HTTP_HOST"]))/**/
1962
+ /* The item_name can default to HTTP_HOST because we've seen payment_status=reversed come through WITHOUT a product_name or item_name given. */
1963
+ && ($paypal["payer_email"]) && ($paypal["parent_txn_id"])/**/)
1964
  {
1965
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
1966
  do_action ("ws_plugin__s2member_during_paypal_notify_before_sp_refund_reversal", get_defined_vars ());
1968
  /**/
1969
  $paypal["s2member_log"][] = "s2Member txn_type identified as [empty or irrelevant] w/ payment_status (refunded|reversed|reversal) - or - new_case w/ case_type (chargeback).";
1970
  /**/
1971
+ $paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
1972
+ $paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[0-9]+~[0-9\.]+$/", $paypal["invoice"])) ? preg_replace ("/^[0-9]+~/", "", $paypal["invoice"]) : $paypal["ip"];
1973
+ /**/
1974
  $processing = $during = true; /* Yes, we ARE processing this. */
1975
  /*
1976
  Refunds and chargeback reversals. This is excluded from the processing check.
1988
  if (($url = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["first_name"])), $url)) && ($url = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["last_name"])), $url)))
1989
  if (($url = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode (trim ($paypal["first_name"] . " " . $paypal["last_name"]))), $url)))
1990
  if (($url = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["payer_email"])), $url)))
1991
+ if (($url = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (urlencode ($paypal["ip"])), $url)))
1992
+ /**/
1993
+ if (($url = trim (preg_replace ("/%%(.+?)%%/i", "", $url))))
1994
+ c_ws_plugin__s2member_utils_urls::remote ($url);
1995
  /**/
1996
  $paypal["s2member_log"][] = "Specific Post/Page ~ Refund/Reversal Notification URLs have been processed.";
1997
  }
2010
  $msg .= "last_name: %%last_name%%\n";
2011
  $msg .= "full_name: %%full_name%%\n";
2012
  $msg .= "payer_email: %%payer_email%%\n";
2013
+ $msg .= "user_ip: %%user_ip%%\n";
2014
+ /**/
2015
  $msg .= "cv0: %%cv0%%\n";
2016
  $msg .= "cv1: %%cv1%%\n";
2017
  $msg .= "cv2: %%cv2%%\n";
2029
  if (($msg = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $msg)) && ($msg = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $msg)))
2030
  if (($msg = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $msg)))
2031
  if (($msg = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $msg)))
2032
+ if (($msg = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $msg)))
2033
+ /**/
2034
+ if (($msg = trim (preg_replace ("/%%(.+?)%%/i", "", $msg))))
2035
+ foreach (c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_recipients"])) as $recipient)
2036
+ ($recipient) ? wp_mail ($recipient, apply_filters ("ws_plugin__s2member_sp_ref_rev_notification_email_sbj", $sbj, get_defined_vars ()), apply_filters ("ws_plugin__s2member_sp_ref_rev_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
2037
  /**/
2038
  $paypal["s2member_log"][] = "Specific Post/Page ~ Refund/Reversal Notification Emails have been processed.";
2039
  }
2055
  /*
2056
  Else, check on cancelled recurring profiles.
2057
  */
2058
+ else if (preg_match ("/^recurring_payment_profile_cancel$/i", $paypal["txn_type"]))
2059
  {
2060
  $paypal["s2member_log"][] = "Transaction type ( recurring_payment_profile_cancel ), but there is no match to an existing account; so verification of _SERVER[HTTP_HOST] was not possible.";
2061
  $paypal["s2member_log"][] = "It's likely this account was just upgraded/downgraded by s2Member Pro; so the Subscr. ID has probably been updated on-site; nothing to worry about here.";
2063
  /*
2064
  Else, check on other ^recurring_ transaction types.
2065
  */
2066
+ else if (preg_match ("/^recurring_/i", $paypal["txn_type"])) /* Otherwise, is this a ^recurring_ txn_type? */
2067
  $paypal["s2member_log"][] = "Transaction type ( ^recurring_? ), but there is no match to an existing account; so verification of _SERVER[HTTP_HOST] was not possible.";
2068
  /**/
2069
  else /* Else, use the default _SERVER[HTTP_HOST] error. */
2096
  If debugging/logging is enabled; we need to append $paypal to the log file.
2097
  Logging now supports Multisite Networking as well.
2098
  */
2099
+ $logv = c_ws_plugin__s2member_utilities::ver_details ();
2100
  $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
2101
  $log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
2102
+ $log2 = (is_multisite () && !is_main_site ()) ? "paypal-ipn-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-ipn.log";
2103
  /**/
2104
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
2105
  if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
2106
  if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
2107
+ file_put_contents ($logs_dir . "/" . $log2, $logv . "\n" . $log4 . "\n" . var_export ($paypal, true) . "\n\n", FILE_APPEND);
2108
  /**/
2109
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
2110
  do_action ("ws_plugin__s2member_during_paypal_notify", get_defined_vars ());
includes/classes/paypal-notify.inc.php CHANGED
@@ -1,40 +1,45 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_paypal_notify"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_paypal_notify
20
  {
21
- /*
22
- Handles PayPal® IPN URL processing.
23
- These same routines also handle s2Member Pro/PayPal® Pro operations;
24
- giving you the ability ( as needed ) to Hook into these routines using
25
- WordPress® Hooks/Filters; as seen in the source code below.
26
-
27
- Please do NOT modify the source code directly.
28
- Instead, use WordPress® Hooks/Filters.
29
-
30
- For example, if you'd like to add your own custom conditionals, use:
31
- add_filter ("ws_plugin__s2member_during_paypal_notify_conditionals", "your_function");
32
-
33
- Attach to: add_action("init");
34
  */
35
  public static function paypal_notify ()
36
  {
37
- if ($_GET["s2member_paypal_notify"]) /* Call inner function? */
38
  {
39
  return c_ws_plugin__s2member_paypal_notify_in::paypal_notify ();
40
  }
1
  <?php
2
+ /**
3
+ * s2Member's PayPal® IPN handler.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\PayPal
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_paypal_notify"))
21
  {
22
+ /**
23
+ * s2Member's PayPal® IPN handler.
24
+ *
25
+ * @package s2Member\PayPal
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_paypal_notify
29
  {
30
+ /**
31
+ * Handles PayPal® IPN processing.
32
+ *
33
+ * @package s2Member\PayPal
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_action("init");``
37
+ *
38
+ * @return null|inner Return-value of inner routine.
 
 
 
 
39
  */
40
  public static function paypal_notify ()
41
  {
42
+ if (!empty ($_GET["s2member_paypal_notify"])) /* Call inner routine? */
43
  {
44
  return c_ws_plugin__s2member_paypal_notify_in::paypal_notify ();
45
  }
includes/classes/paypal-return-in.inc.php CHANGED
@@ -1,26 +1,44 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_paypal_return_in
20
  {
21
- /*
22
- Handles PayPal® Return URLs.
23
- Attach to: add_action("init");
 
 
 
 
 
 
 
 
 
24
  */
25
  public static function paypal_return ()
26
  {
@@ -28,12 +46,12 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
28
  /**/
29
  do_action ("ws_plugin__s2member_before_paypal_return", get_defined_vars ());
30
  /**/
31
- if ($_GET["s2member_paypal_return"] && ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] || $_GET["s2member_paypal_proxy"]))
32
  {
33
  if (is_array ($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_postvars ()) && ($_paypal = $paypal))
34
  {
35
  $paypal["s2member_log"][] = "Return-Data received on: " . date ("D M j, Y g:i:s a T");
36
- $paypal["s2member_log"][] = "s2Member POST vars verified " . ( ($paypal["proxy_verified"]) ? "with a Proxy Key" : "through a POST back to PayPal®.");
37
  /**/
38
  $paypal["subscr_gateway"] = ($_GET["s2member_paypal_proxy"]) ? $_GET["s2member_paypal_proxy"] : "paypal";
39
  /**/
@@ -48,7 +66,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
48
  /*
49
  Custom conditionals can be applied by Filters.
50
  */
51
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
52
  if (!apply_filters ("ws_plugin__s2member_during_paypal_return_conditionals", false, get_defined_vars ()))
53
  {
54
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
@@ -60,7 +78,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
60
  && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
61
  && ($paypal["txn_id"])/**/)
62
  {
63
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
64
  do_action ("ws_plugin__s2member_during_paypal_return_before_sp_access", get_defined_vars ());
65
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
66
  /**/
@@ -68,6 +86,10 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
68
  /**/
69
  list (, $paypal["sp_ids"], $paypal["hours"]) = preg_split ("/\:/", $paypal["item_number"], 3);
70
  /**/
 
 
 
 
71
  if (($sp_access_url = c_ws_plugin__s2member_sp_access::sp_access_link_gen ($paypal["sp_ids"], $paypal["hours"], false)))
72
  {
73
  $processing = $during = true; /* Yes, we ARE processing this. */
@@ -83,21 +105,22 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
83
  if (($code = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $code)) && ($code = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $code)))
84
  if (($code = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
85
  if (($code = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $code)))
86
- /**/
87
- if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code)))) /* This gets stored into a Transient Queue. */
88
- {
89
- $paypal["s2member_log"][] = "Storing Specific Post/Page Tracking Codes into a Transient Queue. These will be processed on-site.";
90
- set_transient ("s2m_" . md5 ("s2member_transient_sp_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
91
- }
 
92
  }
93
  /**/
94
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
95
  do_action ("ws_plugin__s2member_during_paypal_return_during_sp_access", get_defined_vars ());
96
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
97
  /**/
98
  $paypal["s2member_log"][] = "Redirecting Customer to the Specific Post/Page.";
99
  /**/
100
- wp_redirect ($sp_access_url); /* Redirect Customer to the Specific Post/Page. */
101
  }
102
  else /* Otherwise, the ID must have been invalid. Or the Post/Page was deleted. */
103
  {
@@ -111,7 +134,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
111
  echo '</script>' . "\n";
112
  }
113
  /**/
114
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
115
  do_action ("ws_plugin__s2member_during_paypal_return_after_sp_access", get_defined_vars ());
116
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
117
  }
@@ -128,21 +151,25 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
128
  && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["txn_id"]))/**/
129
  && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/)
130
  {
131
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
132
  do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_signup", get_defined_vars ());
133
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
134
  /**/
135
  $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup|subscr_payment).";
136
  /**/
137
  list ($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split ("/\:/", $paypal["item_number"], 3);
 
 
 
 
138
  /*
139
  New Subscription with advanced update vars ( option_name1, option_selection1 ).
140
  */
141
- if (preg_match ("/(updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) /* Advanced Subscription update modifications. */
142
- /* 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
143
- modify=2 parameter to be used in those scenarios, because technically there is nothing to update. The only thing to be updated is the account. */
144
  {
145
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
146
  do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_signup_w_update_vars", get_defined_vars ());
147
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
148
  /**/
@@ -157,7 +184,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
157
  /**/
158
  if (is_multisite () && !is_user_member_of_blog ($user_id))
159
  {
160
- add_existing_user_to_blog (array ("user_id" => $user_id, "role" => "s2member_level" . $paypal["level"]));
161
  $user = new WP_User ($user_id);
162
  }
163
  /**/
@@ -179,11 +206,19 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
179
  update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
180
  update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
181
  /**/
 
 
 
182
  delete_user_option ($user_id, "s2member_file_download_access_arc");
183
  delete_user_option ($user_id, "s2member_file_download_access_log");
184
  /**/
185
  if (preg_match ("/^web_accept$/i", $paypal["txn_type"]) && $paypal["eotper"])
186
- update_user_option ($user_id, "s2member_auto_eot_time", c_ws_plugin__s2member_utils_time::auto_eot_time ("", "", "", $paypal["eotper"]));
 
 
 
 
 
187
  else /* Otherwise, we need to clear the Auto-EOT Time. */
188
  delete_user_option ($user_id, "s2member_auto_eot_time");
189
  /**/
@@ -196,7 +231,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
196
  /**/
197
  $paypal["s2member_log"][] = "s2Member Level/Capabilities updated w/ advanced update routines.";
198
  /**/
199
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
200
  do_action ("ws_plugin__s2member_during_paypal_return_during_subscr_signup_w_update_vars", get_defined_vars ());
201
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
202
  /**/
@@ -243,7 +278,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
243
  echo '</script>' . "\n";
244
  }
245
  /**/
246
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
247
  do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_signup_w_update_vars", get_defined_vars ());
248
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
249
  }
@@ -252,7 +287,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
252
  */
253
  else /* Else this is a normal Subscription signup, we are not updating an existing Subscription. */
254
  {
255
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
256
  do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_signup_wo_update_vars", get_defined_vars ());
257
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
258
  /**/
@@ -267,7 +302,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
267
  /**/
268
  $paypal["s2member_log"][] = "Registration Cookies set on (web_accept|subscr_signup|subscr_payment) w/o update vars.";
269
  /**/
270
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
271
  do_action ("ws_plugin__s2member_during_paypal_return_during_subscr_signup_wo_update_vars", get_defined_vars ());
272
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
273
  /**/
@@ -314,12 +349,12 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
314
  }
315
  }
316
  /**/
317
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
318
  do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_signup_wo_update_vars", get_defined_vars ());
319
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
320
  }
321
  /**/
322
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
323
  do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_signup", get_defined_vars ());
324
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
325
  }
@@ -330,7 +365,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
330
  && (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"]))/**/
331
  && ($paypal["subscr_id"])/**/)
332
  {
333
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
334
  do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_modify", get_defined_vars ());
335
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
336
  /**/
@@ -338,6 +373,10 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
338
  /**/
339
  list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
340
  /**/
 
 
 
 
341
  if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["subscr_id"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
342
  {
343
  if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
@@ -346,8 +385,8 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
346
  /**/
347
  if (is_multisite () && !is_user_member_of_blog ($user_id))
348
  {
349
- add_existing_user_to_blog (array ("user_id" => $user_id, "role" => "s2member_level" . $paypal["level"]));
350
- $user = new WP_User ($user_id);
351
  }
352
  /**/
353
  $current_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
@@ -368,6 +407,9 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
368
  update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
369
  update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
370
  /**/
 
 
 
371
  delete_user_option ($user_id, "s2member_file_download_access_arc");
372
  delete_user_option ($user_id, "s2member_file_download_access_log");
373
  /**/
@@ -382,7 +424,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
382
  /**/
383
  $paypal["s2member_log"][] = "s2Member Level/Capabilities updated on Subscription modification.";
384
  /**/
385
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
386
  do_action ("ws_plugin__s2member_during_paypal_return_during_subscr_modify", get_defined_vars ());
387
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
388
  /**/
@@ -429,7 +471,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
429
  echo '</script>' . "\n";
430
  }
431
  /**/
432
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
433
  do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_modify", get_defined_vars ());
434
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
435
  }
@@ -440,7 +482,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
440
  $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
441
  /**/
442
  echo '<script type="text/javascript">' . "\n";
443
- echo "alert('ERROR: Unexpected txn_type/status. Please contact Support for assistance.\\n\\nThe PayPal® txn_type/status did not match a required action.');" . "\n";
444
  echo "window.location = '" . esc_js (wp_login_url ()) . "';";
445
  echo '</script>' . "\n";
446
  }
@@ -462,13 +504,13 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
462
  }
463
  else /* In this case ... a Proxy has explicitly requested ty-email processing. */
464
  {
465
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
466
  do_action ("ws_plugin__s2member_during_paypal_return_before_explicit_ty_email", get_defined_vars ());
467
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
468
  /**/
469
  $paypal["s2member_log"][] = "Customer must wait for Email Confirmation ( proxy_use: ty-email ).";
470
  /**/
471
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
472
  do_action ("ws_plugin__s2member_during_paypal_return_during_explicit_ty_email", get_defined_vars ());
473
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
474
  /**/
@@ -480,20 +522,20 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
480
  echo "window.location = '" . esc_js (home_url ("/")) . "';";
481
  echo '</script>' . "\n";
482
  /**/
483
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
484
  do_action ("ws_plugin__s2member_during_paypal_return_after_explicit_ty_email", get_defined_vars ());
485
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
486
  }
487
  }
488
  else if (!isset ($_GET["tx"])) /* No Return-Data from PayPal® at all? */
489
  {
490
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
491
  do_action ("ws_plugin__s2member_during_paypal_return_before_no_return_data", get_defined_vars ());
492
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
493
  /**/
494
  $paypal["s2member_log"][] = "No Return-Data from PayPal®. Customer must wait for Email Confirmation.";
495
  /**/
496
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
497
  do_action ("ws_plugin__s2member_during_paypal_return_during_no_return_data", get_defined_vars ());
498
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
499
  /**/
@@ -505,7 +547,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
505
  echo "window.location = '" . esc_js (home_url ("/")) . "';";
506
  echo '</script>' . "\n";
507
  /**/
508
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
509
  do_action ("ws_plugin__s2member_during_paypal_return_after_no_return_data", get_defined_vars ());
510
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
511
  }
@@ -542,6 +584,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
542
  If debugging/logging is enabled; we need to append $paypal to the log file.
543
  Logging now supports Multisite Networking as well.
544
  */
 
545
  $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
546
  $log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
547
  $log2 = (is_multisite () && !is_main_site ()) ? "paypal-rtn-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-rtn.log";
@@ -549,16 +592,16 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
549
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
550
  if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
551
  if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
552
- file_put_contents ($logs_dir . "/" . $log2, $log4 . "\n" . var_export ($paypal, true) . "\n\n", FILE_APPEND);
553
  /**/
554
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
555
  do_action ("ws_plugin__s2member_during_paypal_return", get_defined_vars ());
556
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
557
  /**/
558
- exit ();
559
  }
560
  /**/
561
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
562
  do_action ("ws_plugin__s2member_after_paypal_return", get_defined_vars ());
563
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
564
  }
1
  <?php
2
+ /**
3
+ * s2Member's PayPal® Auto-Return/PDT handler ( inner processing routines ).
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\PayPal
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_paypal_return_in"))
21
  {
22
+ /**
23
+ * s2Member's PayPal® Auto-Return/PDT handler ( inner processing routines ).
24
+ *
25
+ * @package s2Member\PayPal
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_paypal_return_in
29
  {
30
+ /**
31
+ * Handles PayPal® Return URLs.
32
+ *
33
+ * @package s2Member\PayPal
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_action("init");``
37
+ *
38
+ * @return null Or exits script execution after redirection.
39
+ *
40
+ * @todo Break this routine apart into logical class methods.
41
+ * @todo Optimize with ``empty()`` and ``isset()``.
42
  */
43
  public static function paypal_return ()
44
  {
46
  /**/
47
  do_action ("ws_plugin__s2member_before_paypal_return", get_defined_vars ());
48
  /**/
49
+ if (!empty ($_GET["s2member_paypal_return"]) && ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] || $_GET["s2member_paypal_proxy"]))
50
  {
51
  if (is_array ($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_postvars ()) && ($_paypal = $paypal))
52
  {
53
  $paypal["s2member_log"][] = "Return-Data received on: " . date ("D M j, Y g:i:s a T");
54
+ $paypal["s2member_log"][] = "s2Member POST vars verified " . (($paypal["proxy_verified"]) ? "with a Proxy Key" : "through a POST back to PayPal®.");
55
  /**/
56
  $paypal["subscr_gateway"] = ($_GET["s2member_paypal_proxy"]) ? $_GET["s2member_paypal_proxy"] : "paypal";
57
  /**/
66
  /*
67
  Custom conditionals can be applied by Filters.
68
  */
69
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
70
  if (!apply_filters ("ws_plugin__s2member_during_paypal_return_conditionals", false, get_defined_vars ()))
71
  {
72
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
78
  && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/
79
  && ($paypal["txn_id"])/**/)
80
  {
81
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
82
  do_action ("ws_plugin__s2member_during_paypal_return_before_sp_access", get_defined_vars ());
83
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
84
  /**/
86
  /**/
87
  list (, $paypal["sp_ids"], $paypal["hours"]) = preg_split ("/\:/", $paypal["item_number"], 3);
88
  /**/
89
+ $paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
90
+ $paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[0-9]+~[0-9\.]+$/", $paypal["invoice"])) ? preg_replace ("/^[0-9]+~/", "", $paypal["invoice"]) : $paypal["ip"];
91
+ $paypal["ip"] = (!$paypal["ip"] && $_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : $paypal["ip"];
92
+ /**/
93
  if (($sp_access_url = c_ws_plugin__s2member_sp_access::sp_access_link_gen ($paypal["sp_ids"], $paypal["hours"], false)))
94
  {
95
  $processing = $during = true; /* Yes, we ARE processing this. */
105
  if (($code = preg_replace ("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["first_name"]), $code)) && ($code = preg_replace ("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["last_name"]), $code)))
106
  if (($code = preg_replace ("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds (trim ($paypal["first_name"] . " " . $paypal["last_name"])), $code)))
107
  if (($code = preg_replace ("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["payer_email"]), $code)))
108
+ if (($code = preg_replace ("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($paypal["ip"]), $code)))
109
+ /**/
110
+ if (($code = trim (preg_replace ("/%%(.+?)%%/i", "", $code)))) /* This gets stored into a Transient Queue. */
111
+ {
112
+ $paypal["s2member_log"][] = "Storing Specific Post/Page Tracking Codes into a Transient Queue. These will be processed on-site.";
113
+ set_transient ("s2m_" . md5 ("s2member_transient_sp_tracking_codes_" . $paypal["txn_id"]), $code, 43200);
114
+ }
115
  }
116
  /**/
117
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
118
  do_action ("ws_plugin__s2member_during_paypal_return_during_sp_access", get_defined_vars ());
119
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
120
  /**/
121
  $paypal["s2member_log"][] = "Redirecting Customer to the Specific Post/Page.";
122
  /**/
123
+ wp_redirect($sp_access_url); /* Redirect Customer to the Specific Post/Page. */
124
  }
125
  else /* Otherwise, the ID must have been invalid. Or the Post/Page was deleted. */
126
  {
134
  echo '</script>' . "\n";
135
  }
136
  /**/
137
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
138
  do_action ("ws_plugin__s2member_during_paypal_return_after_sp_access", get_defined_vars ());
139
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
140
  }
151
  && ($paypal["subscr_id"] || ($paypal["subscr_id"] = $paypal["txn_id"]))/**/
152
  && (!preg_match ($payment_status_issues, $paypal["payment_status"]))/**/)
153
  {
154
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
155
  do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_signup", get_defined_vars ());
156
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
157
  /**/
158
  $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup|subscr_payment).";
159
  /**/
160
  list ($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split ("/\:/", $paypal["item_number"], 3);
161
+ /**/
162
+ $paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
163
+ $paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[0-9]+~[0-9\.]+$/", $paypal["invoice"])) ? preg_replace ("/^[0-9]+~/", "", $paypal["invoice"]) : $paypal["ip"];
164
+ $paypal["ip"] = (!$paypal["ip"] && $_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : $paypal["ip"];
165
  /*
166
  New Subscription with advanced update vars ( option_name1, option_selection1 ).
167
  */
168
+ if (preg_match ("/(referenc|associat|updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) /* Advanced Subscription update modifications. */
169
+ /* 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.
170
+ PayPal® will not allow the `modify=1|2` parameter to be used in those scenarios, because technically there is no billing to update; only the account. */
171
  {
172
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
173
  do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_signup_w_update_vars", get_defined_vars ());
174
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
175
  /**/
184
  /**/
185
  if (is_multisite () && !is_user_member_of_blog ($user_id))
186
  {
187
+ add_existing_user_to_blog(array ("user_id" => $user_id, "role" => "s2member_level" . $paypal["level"]));
188
  $user = new WP_User ($user_id);
189
  }
190
  /**/
206
  update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
207
  update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
208
  /**/
209
+ if (!get_user_option ("s2member_registration_ip", $user_id))
210
+ update_user_option ($user_id, "s2member_registration_ip", $paypal["ip"]);
211
+ /**/
212
  delete_user_option ($user_id, "s2member_file_download_access_arc");
213
  delete_user_option ($user_id, "s2member_file_download_access_log");
214
  /**/
215
  if (preg_match ("/^web_accept$/i", $paypal["txn_type"]) && $paypal["eotper"])
216
+ {
217
+ /* Don't update this in the return routine. Leave this for the IPN routine. */
218
+ /* EOT Times might be extended, and we don't want the IPN routine to extend an already-extended EOT Time. */
219
+ $eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time ("", "", "", $paypal["eotper"], "", get_user_option ("s2member_auto_eot_time", $user_id));
220
+ $paypal["s2member_log"][] = "Automatic EOT ( End Of Term ) Time will be set to: " . date ("D M j, Y g:i:s a T", $eot_time) . ".";
221
+ }
222
  else /* Otherwise, we need to clear the Auto-EOT Time. */
223
  delete_user_option ($user_id, "s2member_auto_eot_time");
224
  /**/
231
  /**/
232
  $paypal["s2member_log"][] = "s2Member Level/Capabilities updated w/ advanced update routines.";
233
  /**/
234
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
235
  do_action ("ws_plugin__s2member_during_paypal_return_during_subscr_signup_w_update_vars", get_defined_vars ());
236
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
237
  /**/
278
  echo '</script>' . "\n";
279
  }
280
  /**/
281
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
282
  do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_signup_w_update_vars", get_defined_vars ());
283
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
284
  }
287
  */
288
  else /* Else this is a normal Subscription signup, we are not updating an existing Subscription. */
289
  {
290
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
291
  do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_signup_wo_update_vars", get_defined_vars ());
292
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
293
  /**/
302
  /**/
303
  $paypal["s2member_log"][] = "Registration Cookies set on (web_accept|subscr_signup|subscr_payment) w/o update vars.";
304
  /**/
305
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
306
  do_action ("ws_plugin__s2member_during_paypal_return_during_subscr_signup_wo_update_vars", get_defined_vars ());
307
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
308
  /**/
349
  }
350
  }
351
  /**/
352
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
353
  do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_signup_wo_update_vars", get_defined_vars ());
354
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
355
  }
356
  /**/
357
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
358
  do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_signup", get_defined_vars ());
359
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
360
  }
365
  && (preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $paypal["item_number"]))/**/
366
  && ($paypal["subscr_id"])/**/)
367
  {
368
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
369
  do_action ("ws_plugin__s2member_during_paypal_return_before_subscr_modify", get_defined_vars ());
370
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
371
  /**/
373
  /**/
374
  list ($paypal["level"], $paypal["ccaps"]) = preg_split ("/\:/", $paypal["item_number"], 2);
375
  /**/
376
+ $paypal["ip"] = (preg_match ("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"]) ? $paypal["option_selection2"] : "";
377
+ $paypal["ip"] = (!$paypal["ip"] && preg_match ("/^[0-9]+~[0-9\.]+$/", $paypal["invoice"])) ? preg_replace ("/^[0-9]+~/", "", $paypal["invoice"]) : $paypal["ip"];
378
+ $paypal["ip"] = (!$paypal["ip"] && $_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : $paypal["ip"];
379
+ /**/
380
  if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with ($paypal["subscr_id"])) && is_object ($user = new WP_User ($user_id)) && $user->ID)
381
  {
382
  if (!$user->has_cap ("administrator")) /* Do NOT process this routine on Administrators. */
385
  /**/
386
  if (is_multisite () && !is_user_member_of_blog ($user_id))
387
  {
388
+ add_existing_user_to_blog(array ("user_id" => $user_id, "role" => "s2member_level" . $paypal["level"]));
389
+ $user = new WP_User ($user_id); /* Now update the $user object we're using. */
390
  }
391
  /**/
392
  $current_role = c_ws_plugin__s2member_user_access::user_access_role ($user);
407
  update_user_option ($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
408
  update_user_option ($user_id, "s2member_custom", $paypal["custom"]);
409
  /**/
410
+ if (!get_user_option ("s2member_registration_ip", $user_id))
411
+ update_user_option ($user_id, "s2member_registration_ip", $paypal["ip"]);
412
+ /**/
413
  delete_user_option ($user_id, "s2member_file_download_access_arc");
414
  delete_user_option ($user_id, "s2member_file_download_access_log");
415
  /**/
424
  /**/
425
  $paypal["s2member_log"][] = "s2Member Level/Capabilities updated on Subscription modification.";
426
  /**/
427
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
428
  do_action ("ws_plugin__s2member_during_paypal_return_during_subscr_modify", get_defined_vars ());
429
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
430
  /**/
471
  echo '</script>' . "\n";
472
  }
473
  /**/
474
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
475
  do_action ("ws_plugin__s2member_during_paypal_return_after_subscr_modify", get_defined_vars ());
476
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
477
  }
482
  $paypal["s2member_log"][] = "Redirecting Customer to the Login Page, due to an error that occurred.";
483
  /**/
484
  echo '<script type="text/javascript">' . "\n";
485
+ echo "alert('ERROR: Unexpected txn_type/status. Please contact Support for assistance.\\n\\nThe PayPal® txn_type/status did not meet requirements.');" . "\n";
486
  echo "window.location = '" . esc_js (wp_login_url ()) . "';";
487
  echo '</script>' . "\n";
488
  }
504
  }
505
  else /* In this case ... a Proxy has explicitly requested ty-email processing. */
506
  {
507
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
508
  do_action ("ws_plugin__s2member_during_paypal_return_before_explicit_ty_email", get_defined_vars ());
509
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
510
  /**/
511
  $paypal["s2member_log"][] = "Customer must wait for Email Confirmation ( proxy_use: ty-email ).";
512
  /**/
513
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
514
  do_action ("ws_plugin__s2member_during_paypal_return_during_explicit_ty_email", get_defined_vars ());
515
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
516
  /**/
522
  echo "window.location = '" . esc_js (home_url ("/")) . "';";
523
  echo '</script>' . "\n";
524
  /**/
525
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
526
  do_action ("ws_plugin__s2member_during_paypal_return_after_explicit_ty_email", get_defined_vars ());
527
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
528
  }
529
  }
530
  else if (!isset ($_GET["tx"])) /* No Return-Data from PayPal® at all? */
531
  {
532
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
533
  do_action ("ws_plugin__s2member_during_paypal_return_before_no_return_data", get_defined_vars ());
534
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
535
  /**/
536
  $paypal["s2member_log"][] = "No Return-Data from PayPal®. Customer must wait for Email Confirmation.";
537
  /**/
538
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
539
  do_action ("ws_plugin__s2member_during_paypal_return_during_no_return_data", get_defined_vars ());
540
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
541
  /**/
547
  echo "window.location = '" . esc_js (home_url ("/")) . "';";
548
  echo '</script>' . "\n";
549
  /**/
550
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
551
  do_action ("ws_plugin__s2member_during_paypal_return_after_no_return_data", get_defined_vars ());
552
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
553
  }
584
  If debugging/logging is enabled; we need to append $paypal to the log file.
585
  Logging now supports Multisite Networking as well.
586
  */
587
+ $logv = c_ws_plugin__s2member_utilities::ver_details ();
588
  $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
589
  $log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
590
  $log2 = (is_multisite () && !is_main_site ()) ? "paypal-rtn-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-rtn.log";
592
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
593
  if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
594
  if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
595
+ file_put_contents ($logs_dir . "/" . $log2, $logv . "\n" . $log4 . "\n" . var_export ($paypal, true) . "\n\n", FILE_APPEND);
596
  /**/
597
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
598
  do_action ("ws_plugin__s2member_during_paypal_return", get_defined_vars ());
599
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
600
  /**/
601
+ exit (); /* Clean exit. */
602
  }
603
  /**/
604
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
605
  do_action ("ws_plugin__s2member_after_paypal_return", get_defined_vars ());
606
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
607
  }
includes/classes/paypal-return.inc.php CHANGED
@@ -1,30 +1,45 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_paypal_return"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_paypal_return
20
  {
21
- /*
22
- Handles PayPal® Return URLs.
23
- Attach to: add_action("init");
 
 
 
 
 
 
24
  */
25
  public static function paypal_return ()
26
  {
27
- if ($_GET["s2member_paypal_return"]) /* Call inner function? */
28
  {
29
  return c_ws_plugin__s2member_paypal_return_in::paypal_return ();
30
  }
1
  <?php
2
+ /**
3
+ * s2Member's PayPal® Auto-Return/PDT handler.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\PayPal
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_paypal_return"))
21
  {
22
+ /**
23
+ * s2Member's PayPal® Auto-Return/PDT handler.
24
+ *
25
+ * @package s2Member\PayPal
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_paypal_return
29
  {
30
+ /**
31
+ * Handles PayPal® Return URLs.
32
+ *
33
+ * @package s2Member\PayPal
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_action("init");``
37
+ *
38
+ * @return null|inner Return-value of inner routine.
39
  */
40
  public static function paypal_return ()
41
  {
42
+ if (!empty ($_GET["s2member_paypal_return"])) /* Call inner routine? */
43
  {
44
  return c_ws_plugin__s2member_paypal_return_in::paypal_return ();
45
  }
includes/classes/paypal-utilities.inc.php CHANGED
@@ -1,25 +1,39 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_paypal_utilities
20
  {
21
- /*
22
- Get POST vars from PayPal®, verify and return array.
 
 
 
 
 
23
  */
24
  public static function paypal_postvars ()
25
  {
@@ -30,11 +44,11 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
30
  Custom conditionals can be applied by filters.
31
  */
32
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
33
- if (! ($postvars = apply_filters ("ws_plugin__s2member_during_paypal_postvars_conditionals", array (), get_defined_vars ())))
34
  {
35
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
36
  /**/
37
- if ($_GET["tx"] && !$_GET["s2member_paypal_proxy"]) /* Auto-Return w/PDT. */
38
  {
39
  $postback["tx"] = $_GET["tx"];
40
  $postback["cmd"] = "_notify-synch";
@@ -56,7 +70,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
56
  else /* Nope. */
57
  return false;
58
  }
59
- else if (is_array ($postvars = stripslashes_deep ($_REQUEST)))
60
  {
61
  foreach ($postvars as $key => $value)
62
  if (preg_match ("/^s2member_/", $key))
@@ -69,10 +83,10 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
69
  /**/
70
  $endpoint = ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com";
71
  /**/
72
- if ($_GET["s2member_paypal_proxy"] && $_GET["s2member_paypal_proxy_verification"] === c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen ())
73
  return apply_filters ("ws_plugin__s2member_paypal_postvars", array_merge ($postvars, array ("proxy_verified" => $_GET["s2member_paypal_proxy"])), get_defined_vars ());
74
  /**/
75
- else if (strtolower (trim (c_ws_plugin__s2member_utils_urls::remote ("https://" . $endpoint . "/cgi-bin/webscr", $postback, array ("timeout" => 20)))) === "verified")
76
  return apply_filters ("ws_plugin__s2member_paypal_postvars", $postvars, get_defined_vars ());
77
  /**/
78
  else /* Nope. */
@@ -88,8 +102,13 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
88
  return apply_filters ("ws_plugin__s2member_paypal_postvars", $postvars, get_defined_vars ());
89
  }
90
  }
91
- /*
92
- Function generated a PayPal® Proxy Key, for simulated IPN responses.
 
 
 
 
 
93
  */
94
  public static function paypal_proxy_key_gen () /* Generate Key. */
95
  {
@@ -99,16 +118,24 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
99
  do_action ("ws_plugin__s2member_before_paypal_proxy_key_gen", get_defined_vars ());
100
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
101
  /**/
102
- if (!is_multisite () || is_main_site ())
103
- $key = md5 (c_ws_plugin__s2member_utils_encryption::xencrypt (preg_replace ("/\:[0-9]+$/", "", $_SERVER["HTTP_HOST"])));
104
- /**/
105
- else if (is_multisite ())
106
  $key = md5 (c_ws_plugin__s2member_utils_encryption::xencrypt ($current_blog->domain . $current_blog->path));
107
  /**/
 
 
 
108
  return apply_filters ("ws_plugin__s2member_paypal_proxy_key_gen", $key, get_defined_vars ());
109
  }
110
- /*
111
- Function that calls upon the PayPal® API, and returns the response.
 
 
 
 
 
 
 
 
112
  */
113
  public static function paypal_api_response ($post_vars = FALSE)
114
  {
@@ -118,11 +145,12 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
118
  do_action ("ws_plugin__s2member_before_paypal_api_response", get_defined_vars ());
119
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
120
  /**/
121
- $url = "https://" . ( ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "api-3t.sandbox.paypal.com" : "api-3t.paypal.com") . "/nvp";
122
  /**/
 
123
  $post_vars = (is_array ($post_vars)) ? $post_vars : array (); /* Must be an array. */
124
  /**/
125
- $post_vars["VERSION"] = "63.0"; /* Configure the PayPal® API version. */
126
  $post_vars["USER"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_username"];
127
  $post_vars["PWD"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_password"];
128
  $post_vars["SIGNATURE"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_signature"];
@@ -148,26 +176,33 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
148
  If debugging is enabled; we need to maintain a comprehensive log file.
149
  Logging now supports Multisite Networking as well.
150
  */
 
151
  $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
152
  $log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
153
  $log2 = (is_multisite () && !is_main_site ()) ? "paypal-api-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-api.log";
154
  /**/
155
- if (strlen ($post_vars["ACCT"]) > 4) /* Only log last 4 digits for security. */
156
- $post_vars["ACCT"] = str_repeat ("*", strlen ($post_vars["ACCT"]) - 4)/**/
157
- . substr ($post_vars["ACCT"], -4); /* Then display last 4 digits. */
158
  /**/
159
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
160
  if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
161
  if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
162
  if (($log = "-------- Input vars: ( " . $input_time . " ) --------\n" . var_export ($post_vars, true) . "\n"))
163
  if (($log .= "-------- Output string/vars: ( " . $output_time . " ) --------\n" . $nvp . "\n" . var_export ($response, true)))
164
- file_put_contents ($logs_dir . "/" . $log2, $log4 . "\n" . $log . "\n\n", FILE_APPEND);
165
  /**/
166
  return apply_filters ("ws_plugin__s2member_paypal_api_response", c_ws_plugin__s2member_paypal_utilities::_paypal_api_response_filters ($response), get_defined_vars ());
167
  }
168
- /*
169
- A sort of callback function that Filters PayPal® responses.
170
- Provides alternative explanations in some cases that require special attention.
 
 
 
 
 
 
 
171
  */
172
  public static function _paypal_api_response_filters ($response = FALSE)
173
  {
@@ -175,7 +210,7 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
175
  do_action ("_ws_plugin__s2member_before_paypal_api_response_filters", get_defined_vars ());
176
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
177
  /**/
178
- if ($response["__error"]) /* Only if there was a problem. */
179
  {
180
  if ($response["L_ERRORCODE0"] == 10422)
181
  $response["__error"] = "Error# " . $response["L_ERRORCODE0"] . ". Transaction declined. Please use an alternate funding source.";
@@ -187,10 +222,16 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
187
  $response["__error"] = "Error# " . $response["L_ERRORCODE0"] . ". Transaction declined. Please use an alternate funding source.";
188
  }
189
  /**/
190
- return $response; /* Filters already applied with: ws_plugin__s2member_paypal_api_response. */
191
  }
192
- /*
193
- Function converts a term [DWMY] into PayPal® Pro format.
 
 
 
 
 
 
194
  */
195
  public static function paypal_pro_term ($term = FALSE)
196
  {
@@ -200,12 +241,18 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
200
  /**/
201
  $paypal_pro_terms = array ("D" => "Day", "W" => "Week", "M" => "Month", "Y" => "Year");
202
  /**/
203
- $pro_term = $paypal_pro_terms[strtoupper ($term)];
204
  /**/
205
  return apply_filters ("ws_plugin__s2member_paypal_pro_term", $pro_term, get_defined_vars ());
206
  }
207
- /*
208
- Function converts a term [Day,Week,Month,Year] into PayPal® Standard format.
 
 
 
 
 
 
209
  */
210
  public static function paypal_std_term ($term = FALSE)
211
  {
@@ -215,12 +262,18 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
215
  /**/
216
  $paypal_std_terms = array ("DAY" => "D", "WEEK" => "W", "MONTH" => "M", "YEAR" => "Y");
217
  /**/
218
- $std_term = $paypal_std_terms[strtoupper ($term)];
219
  /**/
220
  return apply_filters ("ws_plugin__s2member_paypal_std_term", $std_term, get_defined_vars ());
221
  }
222
- /*
223
- Parse/validate item_name from either an array with recurring_payment_id, or use an existing string.
 
 
 
 
 
 
224
  */
225
  public static function paypal_pro_subscr_id ($array_or_string = FALSE)
226
  {
@@ -228,18 +281,26 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
228
  do_action ("ws_plugin__s2member_before_paypal_pro_subscr_id", get_defined_vars ());
229
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
230
  /**/
231
- if (is_array ($array = $array_or_string) && $array["recurring_payment_id"])
232
- $subscr_id = $array["recurring_payment_id"];
 
 
 
233
  /**/
234
- else if (is_string ($string = $array_or_string) && $string)
235
- $subscr_id = $string;
236
  /**/
237
- return apply_filters ("ws_plugin__s2member_paypal_pro_subscr_id",$subscr_id, get_defined_vars ());
238
  }
239
- /*
240
- Parse/validate item_number from either an array with:
241
- item_number1|PROFILEREFERENCE|rp_invoice_id, or parse/validate an existing string
242
- to make sure it is a valid "level:ccaps:eotper" combination.
 
 
 
 
 
243
  */
244
  public static function paypal_pro_item_number ($array_or_string = FALSE)
245
  {
@@ -247,25 +308,34 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
247
  do_action ("ws_plugin__s2member_before_paypal_pro_item_number", get_defined_vars ());
248
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
249
  /**/
250
- if (is_array ($array = $array_or_string) && $array["item_number1"])
251
- $_item_number = $array["item_number1"];
252
  /**/
253
- else if (is_array ($array = $array_or_string) && ($array["PROFILEREFERENCE"] || $array["rp_invoice_id"]))
254
- list ($_reference, $_domain, $_item_number) = preg_split ("/~/", ( ($array["PROFILEREFERENCE"]) ? $array["PROFILEREFERENCE"] : $array["rp_invoice_id"]), 3);
255
  /**/
256
- else if (is_string ($string = $array_or_string) && $string)
257
- $_item_number = $string;
258
  /**/
259
- if ($_item_number && preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $_item_number))
 
 
 
260
  $item_number = $_item_number;
261
  /**/
262
- else if ($_item_number && preg_match ("/^sp\:[0-9,]+\:[0-9]+$/", $_item_number))
263
  $item_number = $_item_number;
264
  /**/
265
- return apply_filters ("ws_plugin__s2member_paypal_pro_item_number",$item_number, get_defined_vars ());
266
  }
267
- /*
268
- Parse/validate item_name from either an array with: item_name1|product_name, or use an existing string.
 
 
 
 
 
 
269
  */
270
  public static function paypal_pro_item_name ($array_or_string = FALSE)
271
  {
@@ -273,24 +343,32 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
273
  do_action ("ws_plugin__s2member_before_paypal_pro_item_name", get_defined_vars ());
274
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
275
  /**/
276
- if (is_array ($array = $array_or_string) && $array["item_name1"])
277
- $item_name = $array["item_name1"];
 
 
 
278
  /**/
279
- else if (is_array ($array = $array_or_string) && $array["product_name"])
280
- $item_name = $array["product_name"];
281
  /**/
282
- else if (is_string ($string = $array_or_string))
283
- $item_name = $string;
284
  /**/
285
- return apply_filters ("ws_plugin__s2member_paypal_pro_item_name",$item_name, get_defined_vars ());
286
  }
287
- /*
288
- Parse/validate period1 from either a return array coming from the
289
- Pro API with PROFILEREFERENCE|rp_invoice_id, or parse/validate an existing string
290
- to make sure it is a valid "period term" combination.
291
-
292
- Note: This will also convert "1 Day", into "1 D".
293
- Note: This will also convert "1 SemiMonth", into "2 W".
 
 
 
 
 
294
  */
295
  public static function paypal_pro_period1 ($array_or_string = FALSE)
296
  {
@@ -298,18 +376,20 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
298
  do_action ("ws_plugin__s2member_before_paypal_pro_period1", get_defined_vars ());
299
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
300
  /**/
301
- if (is_array ($array = $array_or_string) && ($array["PROFILEREFERENCE"] || $array["rp_invoice_id"]))
302
  {
303
- list ($_reference, $_domain, $_item_number) = preg_split ("/~/", ( ($array["PROFILEREFERENCE"]) ? $array["PROFILEREFERENCE"] : $array["rp_invoice_id"]), 3);
304
- list ($_start_time, $_period1, $_period3) = preg_split ("/\:/", $_reference, 3);
305
  }
 
 
306
  /**/
307
- else if (is_string ($string = $array_or_string) && $string)
308
- $_period1 = $string; /* In string form? */
309
  /**/
310
- if ($_period1) /* Were we able to get a period1 string? */
311
  {
312
- list ($num, $span) = preg_split ("/ /", $_period1, 2);
313
  /**/
314
  if (strtoupper ($span) === "SEMIMONTH")
315
  if (is_numeric ($num) && $num >= 1)
@@ -328,14 +408,19 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
328
  else /* Default. */
329
  return apply_filters ("ws_plugin__s2member_paypal_pro_period1", "0 D", get_defined_vars ());
330
  }
331
- /*
332
- Parse/validate period3 from either a return array coming from the
333
- Pro API with PROFILEREFERENCE|rp_invoice_id, or parse/validate an existing string
334
- to make sure it is a valid "period term" combination.
335
-
336
- Note: This will also convert "1 Day", into "1 D".
337
- Note: This will also convert "1 SemiMonth", into "2 W".
338
- Note: The Regular Period can never be less than 1 day ( 1 D ).
 
 
 
 
 
339
  */
340
  public static function paypal_pro_period3 ($array_or_string = FALSE)
341
  {
@@ -343,18 +428,20 @@ if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
343
  do_action ("ws_plugin__s2member_before_paypal_pro_period3", get_defined_vars ());
344
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
345
  /**/
346
- if (is_array ($array = $array_or_string) && ($array["PROFILEREFERENCE"] || $array["rp_invoice_id"]))
347
  {
348
- list ($_reference, $_domain, $_item_number) = preg_split ("/~/", ( ($array["PROFILEREFERENCE"]) ? $array["PROFILEREFERENCE"] : $array["rp_invoice_id"]), 3);
349
- list ($_start_time, $_period1, $_period3) = preg_split ("/\:/", $_reference, 3);
350
  }
 
 
351
  /**/
352
- else if (is_string ($string = $array_or_string) && $string)
353
- $_period3 = $string; /* In string form? */
354
  /**/
355
- if ($_period3) /* Were we able to get a period3 string? */
356
  {
357
- list ($num, $span) = preg_split ("/ /", $_period3, 2);
358
  /**/
359
  if (strtoupper ($span) === "SEMIMONTH")
360
  if (is_numeric ($num) && $num >= 1)
1
  <?php
2
+ /**
3
+ * PayPal® utilities.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\PayPal
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_paypal_utilities"))
21
  {
22
+ /**
23
+ * PayPal® utilities.
24
+ *
25
+ * @package s2Member\PayPal
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_paypal_utilities
29
  {
30
+ /**
31
+ * Get ``$_POST`` or ``$_REQUEST`` vars from PayPal®.
32
+ *
33
+ * @package s2Member\PayPal
34
+ * @since 3.5
35
+ *
36
+ * @return array|bool An array of verified ``$_POST`` or ``$_REQUEST`` variables, else false.
37
  */
38
  public static function paypal_postvars ()
39
  {
44
  Custom conditionals can be applied by filters.
45
  */
46
  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
47
+ if (!($postvars = apply_filters ("ws_plugin__s2member_during_paypal_postvars_conditionals", array (), get_defined_vars ())))
48
  {
49
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
50
  /**/
51
+ if (!empty ($_GET["tx"]) && empty ($_GET["s2member_paypal_proxy"]))
52
  {
53
  $postback["tx"] = $_GET["tx"];
54
  $postback["cmd"] = "_notify-synch";
70
  else /* Nope. */
71
  return false;
72
  }
73
+ else if (!empty ($_REQUEST) && is_array ($postvars = stripslashes_deep ($_REQUEST)))
74
  {
75
  foreach ($postvars as $key => $value)
76
  if (preg_match ("/^s2member_/", $key))
83
  /**/
84
  $endpoint = ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "www.sandbox.paypal.com" : "www.paypal.com";
85
  /**/
86
+ if (!empty ($_GET["s2member_paypal_proxy"]) && !empty ($_GET["s2member_paypal_proxy_verification"]) && $_GET["s2member_paypal_proxy_verification"] === c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen ())
87
  return apply_filters ("ws_plugin__s2member_paypal_postvars", array_merge ($postvars, array ("proxy_verified" => $_GET["s2member_paypal_proxy"])), get_defined_vars ());
88
  /**/
89
+ else if (trim (strtolower (c_ws_plugin__s2member_utils_urls::remote ("https://" . $endpoint . "/cgi-bin/webscr", $postback, array ("timeout" => 20)))) === "verified")
90
  return apply_filters ("ws_plugin__s2member_paypal_postvars", $postvars, get_defined_vars ());
91
  /**/
92
  else /* Nope. */
102
  return apply_filters ("ws_plugin__s2member_paypal_postvars", $postvars, get_defined_vars ());
103
  }
104
  }
105
+ /**
106
+ * Generates a PayPal® Proxy Key, for simulated IPN responses.
107
+ *
108
+ * @package s2Member\PayPal
109
+ * @since 3.5
110
+ *
111
+ * @return str A Proxy Key. It's an MD5 Hash, 32 chars, URL-safe.
112
  */
113
  public static function paypal_proxy_key_gen () /* Generate Key. */
114
  {
118
  do_action ("ws_plugin__s2member_before_paypal_proxy_key_gen", get_defined_vars ());
119
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
120
  /**/
121
+ if (is_multisite () && !is_main_site ())
 
 
 
122
  $key = md5 (c_ws_plugin__s2member_utils_encryption::xencrypt ($current_blog->domain . $current_blog->path));
123
  /**/
124
+ else /* Else it's a standard Proxy Key; not on a Multisite Network, or not on the Main Site anyway. */
125
+ $key = md5 (c_ws_plugin__s2member_utils_encryption::xencrypt (preg_replace ("/\:[0-9]+$/", "", $_SERVER["HTTP_HOST"])));
126
+ /**/
127
  return apply_filters ("ws_plugin__s2member_paypal_proxy_key_gen", $key, get_defined_vars ());
128
  }
129
+ /**
130
+ * Calls upon the PayPal® API, and returns the response.
131
+ *
132
+ * @package s2Member\PayPal
133
+ * @since 3.5
134
+ *
135
+ * @param array $post_vars An array of variables to send through the PayPal® API call.
136
+ * @return array An array of variables returned by the PayPal® API.
137
+ *
138
+ * @todo Optimize this routine with ``empty()`` and ``isset()``.
139
  */
140
  public static function paypal_api_response ($post_vars = FALSE)
141
  {
145
  do_action ("ws_plugin__s2member_before_paypal_api_response", get_defined_vars ());
146
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
147
  /**/
148
+ $url = "https://" . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"]) ? "api-3t.sandbox.paypal.com" : "api-3t.paypal.com") . "/nvp";
149
  /**/
150
+ $post_vars = apply_filters ("ws_plugin__s2member_paypal_api_post_vars", $post_vars, get_defined_vars ());
151
  $post_vars = (is_array ($post_vars)) ? $post_vars : array (); /* Must be an array. */
152
  /**/
153
+ $post_vars["VERSION"] = "71.0"; /* Configure the PayPal® API version. */
154
  $post_vars["USER"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_username"];
155
  $post_vars["PWD"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_password"];
156
  $post_vars["SIGNATURE"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_signature"];
176
  If debugging is enabled; we need to maintain a comprehensive log file.
177
  Logging now supports Multisite Networking as well.
178
  */
179
+ $logv = c_ws_plugin__s2member_utilities::ver_details ();
180
  $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
181
  $log4 = (is_multisite () && !is_main_site ()) ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
182
  $log2 = (is_multisite () && !is_main_site ()) ? "paypal-api-4-" . trim (preg_replace ("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-api.log";
183
  /**/
184
+ if (isset ($post_vars["ACCT"]) && strlen ($post_vars["ACCT"]) > 4)
185
+ $post_vars["ACCT"] = str_repeat ("*", strlen ($post_vars["ACCT"]) - 4) . substr ($post_vars["ACCT"], -4);
 
186
  /**/
187
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"])
188
  if (is_dir ($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"]))
189
  if (is_writable ($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files ())
190
  if (($log = "-------- Input vars: ( " . $input_time . " ) --------\n" . var_export ($post_vars, true) . "\n"))
191
  if (($log .= "-------- Output string/vars: ( " . $output_time . " ) --------\n" . $nvp . "\n" . var_export ($response, true)))
192
+ file_put_contents ($logs_dir . "/" . $log2, $logv . "\n" . $log4 . "\n" . $log . "\n\n", FILE_APPEND);
193
  /**/
194
  return apply_filters ("ws_plugin__s2member_paypal_api_response", c_ws_plugin__s2member_paypal_utilities::_paypal_api_response_filters ($response), get_defined_vars ());
195
  }
196
+ /**
197
+ * A sort of callback function that Filters PayPal® responses.
198
+ *
199
+ * Provides alternative explanations in some cases that require special attention.
200
+ *
201
+ * @package s2Member\PayPal
202
+ * @since 3.5
203
+ *
204
+ * @param array $response Expects an array of response variables returned by the PayPal® API.
205
+ * @return array An array of variables returned by the PayPal® API, after ``$response["__error"]`` is Filtered.
206
  */
207
  public static function _paypal_api_response_filters ($response = FALSE)
208
  {
210
  do_action ("_ws_plugin__s2member_before_paypal_api_response_filters", get_defined_vars ());
211
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
212
  /**/
213
+ if (!empty ($response["__error"]) && !empty ($response["L_ERRORCODE0"]))
214
  {
215
  if ($response["L_ERRORCODE0"] == 10422)
216
  $response["__error"] = "Error# " . $response["L_ERRORCODE0"] . ". Transaction declined. Please use an alternate funding source.";
222
  $response["__error"] = "Error# " . $response["L_ERRORCODE0"] . ". Transaction declined. Please use an alternate funding source.";
223
  }
224
  /**/
225
+ return $response; /* Filters already applied with: ``ws_plugin__s2member_paypal_api_response``. */
226
  }
227
+ /**
228
+ * Converts a term `D|W|M|Y` into PayPal® Pro format.
229
+ *
230
+ * @package s2Member\PayPal
231
+ * @since 3.5
232
+ *
233
+ * @param str $term Expects one of `D|W|M|Y`.
234
+ * @return bool|str A full singular description of the term *( i.e. `Day|Week|Month|Year` )*, else false.
235
  */
236
  public static function paypal_pro_term ($term = FALSE)
237
  {
241
  /**/
242
  $paypal_pro_terms = array ("D" => "Day", "W" => "Week", "M" => "Month", "Y" => "Year");
243
  /**/
244
+ $pro_term = (!empty ($paypal_pro_terms[strtoupper ($term)])) ? $paypal_pro_terms[strtoupper ($term)] : false;
245
  /**/
246
  return apply_filters ("ws_plugin__s2member_paypal_pro_term", $pro_term, get_defined_vars ());
247
  }
248
+ /**
249
+ * Converts a term `Day|Week|Month|Year` into PayPal® Standard format.
250
+ *
251
+ * @package s2Member\PayPal
252
+ * @since 3.5
253
+ *
254
+ * @param str $term Expects one of `Day|Week|Month|Year`.
255
+ * @return bool|str A term code *( i.e. `D|W|M|Y` )*, else false.
256
  */
257
  public static function paypal_std_term ($term = FALSE)
258
  {
262
  /**/
263
  $paypal_std_terms = array ("DAY" => "D", "WEEK" => "W", "MONTH" => "M", "YEAR" => "Y");
264
  /**/
265
+ $std_term = (!empty ($paypal_std_terms[strtoupper ($term)])) ? $paypal_std_terms[strtoupper ($term)] : false;
266
  /**/
267
  return apply_filters ("ws_plugin__s2member_paypal_std_term", $std_term, get_defined_vars ());
268
  }
269
+ /**
270
+ * Get `subscr_id` from either an array with `recurring_payment_id|subscr_id`, or use an existing string.
271
+ *
272
+ * @package s2Member\PayPal
273
+ * @since 3.5
274
+ *
275
+ * @param str|array $array_or_string Either an array of PayPal® post vars, or a string.
276
+ * @return str|bool A `subscr_id` string if non-empty, else false.
277
  */
278
  public static function paypal_pro_subscr_id ($array_or_string = FALSE)
279
  {
281
  do_action ("ws_plugin__s2member_before_paypal_pro_subscr_id", get_defined_vars ());
282
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
283
  /**/
284
+ if (is_array ($array = $array_or_string) && !empty ($array["recurring_payment_id"]))
285
+ $subscr_id = trim ($array["recurring_payment_id"]);
286
+ /**/
287
+ else if (is_array ($array = $array_or_string) && !empty ($array["subscr_id"]))
288
+ $subscr_id = trim ($array["subscr_id"]);
289
  /**/
290
+ else if (is_string ($string = $array_or_string) && !empty ($string))
291
+ $subscr_id = trim ($string);
292
  /**/
293
+ return apply_filters ("ws_plugin__s2member_paypal_pro_subscr_id", ((!empty ($subscr_id)) ? $subscr_id : false), get_defined_vars ());
294
  }
295
+ /**
296
+ * Get `item_number` from either an array with `PROFILEREFERENCE|rp_invoice_id|item_number1|item_number`, or use an existing string.
297
+ *
298
+ * @package s2Member\PayPal
299
+ * @since 3.5
300
+ *
301
+ * @param str|array $array_or_string Either an array of PayPal® post vars, or a string.
302
+ * If it's a string, we make sure it is a valid `level:ccaps:eotper` or `sp:ids:expiration` combination.
303
+ * @return str|bool An `item_number` string if non-empty, else false.
304
  */
305
  public static function paypal_pro_item_number ($array_or_string = FALSE)
306
  {
308
  do_action ("ws_plugin__s2member_before_paypal_pro_item_number", get_defined_vars ());
309
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
310
  /**/
311
+ if (is_array ($array = $array_or_string) && (!empty ($array["PROFILEREFERENCE"]) || !empty ($array["rp_invoice_id"])))
312
+ list ($_reference, $_domain, $_item_number) = array_map ("trim", preg_split ("/~/", ((!empty ($array["PROFILEREFERENCE"])) ? $array["PROFILEREFERENCE"] : $array["rp_invoice_id"]), 3));
313
  /**/
314
+ else if (is_array ($array = $array_or_string) && !empty ($array["item_number1"]))
315
+ $_item_number = trim ($array["item_number1"]);
316
  /**/
317
+ else if (is_array ($array = $array_or_string) && !empty ($array["item_number"]))
318
+ $_item_number = trim ($array["item_number"]);
319
  /**/
320
+ else if (is_string ($string = $array_or_string) && !empty ($string))
321
+ $_item_number = trim ($string);
322
+ /**/
323
+ if (!empty ($_item_number) && preg_match ("/^[1-4](\:|$)([\+a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", $_item_number))
324
  $item_number = $_item_number;
325
  /**/
326
+ else if (!empty ($_item_number) && preg_match ("/^sp\:[0-9,]+\:[0-9]+$/", $_item_number))
327
  $item_number = $_item_number;
328
  /**/
329
+ return apply_filters ("ws_plugin__s2member_paypal_pro_item_number", ((!empty ($item_number)) ? $item_number : false), get_defined_vars ());
330
  }
331
+ /**
332
+ * Get `item_name` from either an array with `product_name|item_name1|item_name`, or use an existing string.
333
+ *
334
+ * @package s2Member\PayPal
335
+ * @since 3.5
336
+ *
337
+ * @param str|array $array_or_string Either an array of PayPal® post vars, or a string.
338
+ * @return str|bool An `item_name` string if non-empty, else false.
339
  */
340
  public static function paypal_pro_item_name ($array_or_string = FALSE)
341
  {
343
  do_action ("ws_plugin__s2member_before_paypal_pro_item_name", get_defined_vars ());
344
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
345
  /**/
346
+ if (is_array ($array = $array_or_string) && !empty ($array["product_name"]))
347
+ $item_name = trim ($array["product_name"]);
348
+ /**/
349
+ else if (is_array ($array = $array_or_string) && !empty ($array["item_name1"]))
350
+ $item_name = trim ($array["item_name1"]);
351
  /**/
352
+ else if (is_array ($array = $array_or_string) && !empty ($array["item_name"]))
353
+ $item_name = trim ($array["item_name"]);
354
  /**/
355
+ else if (is_string ($string = $array_or_string) && !empty ($string))
356
+ $item_name = trim ($string);
357
  /**/
358
+ return apply_filters ("ws_plugin__s2member_paypal_pro_item_name", ((!empty ($item_name)) ? $item_name : false), get_defined_vars ());
359
  }
360
+ /**
361
+ * Get `period1` from either an array with `PROFILEREFERENCE|rp_invoice_id|period1`, or use an existing string.
362
+ *
363
+ * This will also convert `1 Day`, into `1 D`, and so on.
364
+ * This will also convert `1 SemiMonth`, into `2 W`, and so on.
365
+ *
366
+ * @package s2Member\PayPal
367
+ * @since 3.5
368
+ *
369
+ * @param str|array $array_or_string Either an array of PayPal® post vars, or a string.
370
+ * If it's a string, we make sure it is a valid `period term` combination.
371
+ * @return str A `period1` string if possible, or defaults to `0 D`.
372
  */
373
  public static function paypal_pro_period1 ($array_or_string = FALSE)
374
  {
376
  do_action ("ws_plugin__s2member_before_paypal_pro_period1", get_defined_vars ());
377
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
378
  /**/
379
+ if (is_array ($array = $array_or_string) && (!empty ($array["PROFILEREFERENCE"]) || !empty ($array["rp_invoice_id"])))
380
  {
381
+ list ($_reference, $_domain, $_item_number) = array_map ("trim", preg_split ("/~/", ((!empty ($array["PROFILEREFERENCE"])) ? $array["PROFILEREFERENCE"] : $array["rp_invoice_id"]), 3));
382
+ list ($_start_time, $_period1, $_period3) = array_map ("trim", preg_split ("/\:/", $_reference, 3));
383
  }
384
+ else if (is_array ($array = $array_or_string) && !empty ($array["period1"]))
385
+ $_period1 = trim ($array["period1"]);
386
  /**/
387
+ else if (is_string ($string = $array_or_string) && !empty ($string))
388
+ $_period1 = trim ($string);
389
  /**/
390
+ if (!empty ($_period1)) /* Were we able to get a `period1` string? */
391
  {
392
+ list ($num, $span) = array_map ("trim", preg_split ("/ /", $_period1, 2));
393
  /**/
394
  if (strtoupper ($span) === "SEMIMONTH")
395
  if (is_numeric ($num) && $num >= 1)
408
  else /* Default. */
409
  return apply_filters ("ws_plugin__s2member_paypal_pro_period1", "0 D", get_defined_vars ());
410
  }
411
+ /**
412
+ * Get `period3` from either an array with `PROFILEREFERENCE|rp_invoice_id|period3`, or use an existing string.
413
+ *
414
+ * This will also convert `1 Day`, into `1 D`, and so on.
415
+ * This will also convert `1 SemiMonth`, into `2 W`, and so on.
416
+ * The Regular Period can never be less than 1 day ( `1 D` ).
417
+ *
418
+ * @package s2Member\PayPal
419
+ * @since 3.5
420
+ *
421
+ * @param str|array $array_or_string Either an array of PayPal® post vars, or a string.
422
+ * If it's a string, we make sure it is a valid `period term` combination.
423
+ * @return str A `period3` string if possible, or defaults to `1 D`.
424
  */
425
  public static function paypal_pro_period3 ($array_or_string = FALSE)
426
  {
428
  do_action ("ws_plugin__s2member_before_paypal_pro_period3", get_defined_vars ());
429
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
430
  /**/
431
+ if (is_array ($array = $array_or_string) && (!empty ($array["PROFILEREFERENCE"]) || !empty ($array["rp_invoice_id"])))
432
  {
433
+ list ($_reference, $_domain, $_item_number) = array_map ("trim", preg_split ("/~/", ((!empty ($array["PROFILEREFERENCE"])) ? $array["PROFILEREFERENCE"] : $array["rp_invoice_id"]), 3));
434
+ list ($_start_time, $_period1, $_period3) = array_map ("trim", preg_split ("/\:/", $_reference, 3));
435
  }
436
+ else if (is_array ($array = $array_or_string) && !empty ($array["period3"]))
437
+ $_period3 = trim ($array["period3"]);
438
  /**/
439
+ else if (is_string ($string = $array_or_string) && !empty ($string))
440
+ $_period3 = trim ($string);
441
  /**/
442
+ if (!empty ($_period3)) /* Were we able to get a `period3` string? */
443
  {
444
+ list ($num, $span) = array_map ("trim", preg_split ("/ /", $_period3, 2));
445
  /**/
446
  if (strtoupper ($span) === "SEMIMONTH")
447
  if (is_numeric ($num) && $num >= 1)
includes/classes/posts-sp.inc.php CHANGED
@@ -1,37 +1,41 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_posts_sp"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_posts_sp
20
  {
21
- /*
22
- Checks Post Level Access restrictions - for a specific Post.
23
-
24
- Don't call this function directly, use one of these API functions:
25
-
26
- Is it protected by s2Member at all?
27
- - is_post_protected_by_s2member($post_id);
28
- - is_protected_by_s2member($post_id, "post");
29
-
30
- Is the current User permitted/authorized?
31
- - is_post_permitted_by_s2member($post_id);
32
- - is_permitted_by_s2member($post_id, "post");
33
-
34
- See: `/s2member/includes/functions/api-functions.inc.php`.
35
  */
36
  public static function check_specific_post_level_access ($post_id = FALSE, $check_user = TRUE)
37
  {
@@ -41,59 +45,56 @@ if (!class_exists ("c_ws_plugin__s2member_posts_sp"))
41
  /**/
42
  if (!$excluded && $post_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Check? */
43
  {
44
- $post_link = get_permalink ($post_id); /* Determine link to this Post. */
45
- $post_path = parse_url ($post_link, PHP_URL_PATH); /* Parse req path. */
46
- $post_query = parse_url ($post_link, PHP_URL_QUERY); /* Parse query. */
47
- $post_uri = ($post_query) ? $post_path . "?" . $post_query : $post_path;
48
  /**/
49
- $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
50
  /**/
51
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $post_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level0")))
52
  return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
53
  /**/
54
- else if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page (null, $post_uri)) /* Never restrict Systematic Use Pages. However, there is 1 exception above ^. */
55
  {
56
- for ($i = 0; $i <= 4; $i++) /* Post Level restrictions ( including Custom Post Types ). Go through each Membership Level. */
57
  {
58
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"] === "all" && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
59
- return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
60
  /**/
61
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"] && in_array ($post_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"])) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
62
- return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
63
  }
64
  /**/
65
- for ($i = 0; $i <= 4; $i++) /* Category Level Access against this Post. Go through each Membership Level. */
66
  {
67
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] === "all" && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
68
- return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
69
  /**/
70
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] && (in_category (($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"])), $post_id) || c_ws_plugin__s2member_utils_conds::in_descendant_category ($catgs, $post_id)) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
71
- return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
72
  }
73
  /**/
74
  if (has_tag ("", $post_id)) /* Here we take a look to see if this Post has any Tags. If so, we need to run the full set of routines against Tags also. */
75
  {
76
- for ($i = 0; $i <= 4; $i++) /* Tag Level restrictions now. Go through each Membership Level. */
77
  {
78
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] === "all" && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
79
- return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
80
  /**/
81
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"]), $post_id) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
82
- return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
83
  }
84
  }
85
  /**/
86
- for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
87
  {
88
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
89
- foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
90
- if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $post_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
91
- return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
92
  }
93
  /**/
94
  if (is_array ($ccaps_req = get_post_meta ($post_id, "s2member_ccaps_req", true)) && !empty ($ccaps_req))
95
- foreach ($ccaps_req as $ccap) /* The $current_user MUST satisfy ALL Custom Capabilities. Serialized array. */
96
- if (strlen ($ccap) && (!$check_user || !$current_user || !$current_user->has_cap ("access_s2member_ccap_" . $ccap)))
97
  return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_ccap_req" => $ccap), get_defined_vars ());
98
  /**/
99
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array ($post_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && (!$check_user || !c_ws_plugin__s2member_sp_access::sp_access ($post_id, "read-only")))
1
  <?php
2
+ /**
3
+ * s2Member's Post protection routines *( for specific Posts )*.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Posts
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_posts_sp"))
21
  {
22
+ /**
23
+ * s2Member's Post protection routines *( for specific Posts )*.
24
+ *
25
+ * @package s2Member\Posts
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_posts_sp
29
  {
30
+ /**
31
+ * Handles Post Level Access *( for specific Posts )*.
32
+ *
33
+ * @package s2Member\Posts
34
+ * @since 3.5
35
+ *
36
+ * @param int|str $post_id Numeric Post ID.
37
+ * @param bool $check_user Test permissions against the current User? Defaults to true.
38
+ * @return null|array Non-empty array ( with details ) if access is denied, else null if access is allowed.
 
 
 
 
 
39
  */
40
  public static function check_specific_post_level_access ($post_id = FALSE, $check_user = TRUE)
41
  {
45
  /**/
46
  if (!$excluded && $post_id && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) /* Check? */
47
  {
48
+ $post_uri = c_ws_plugin__s2member_utils_urls::parse_uri (get_permalink ($post_id));
 
 
 
49
  /**/
50
+ $user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
51
  /**/
52
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $post_uri) && (!$check_user || !$user || !current_user_can ("access_s2member_level0")))
53
  return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
54
  /**/
55
+ else if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page (null, $post_uri)) /* Never restrict Systematics. However, there is 1 exception ^. */
56
  {
57
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* Post Level restrictions ( including Custom Post Types ). Go through each Level. */
58
  {
59
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"] === "all" && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
60
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
61
  /**/
62
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"] && in_array ($post_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"])) && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
63
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
64
  }
65
  /**/
66
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* Category Level Access against this Post. Go through each Level. */
67
  {
68
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] === "all" && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
69
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
70
  /**/
71
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] && (in_category (($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"])), $post_id) || c_ws_plugin__s2member_utils_conds::in_descendant_category ($catgs, $post_id)) && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
72
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
73
  }
74
  /**/
75
  if (has_tag ("", $post_id)) /* Here we take a look to see if this Post has any Tags. If so, we need to run the full set of routines against Tags also. */
76
  {
77
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* Tag Level restrictions now. Go through each Level. */
78
  {
79
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] === "all" && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
80
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
81
  /**/
82
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"]), $post_id) && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
83
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
84
  }
85
  }
86
  /**/
87
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* URIs. Go through each Level. */
88
  {
89
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"])
90
+ foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str)
91
+ if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $post_uri) && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
92
+ return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
93
  }
94
  /**/
95
  if (is_array ($ccaps_req = get_post_meta ($post_id, "s2member_ccaps_req", true)) && !empty ($ccaps_req))
96
+ foreach ($ccaps_req as $ccap) /* The $user MUST satisfy ALL Custom Capabilities. Serialized array. */
97
+ if (strlen ($ccap) && (!$check_user || !$user || !$user->has_cap ("access_s2member_ccap_" . $ccap)))
98
  return apply_filters ("ws_plugin__s2member_check_specific_post_level_access", array ("s2member_ccap_req" => $ccap), get_defined_vars ());
99
  /**/
100
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array ($post_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && (!$check_user || !c_ws_plugin__s2member_sp_access::sp_access ($post_id, "read-only")))
includes/classes/posts.inc.php CHANGED
@@ -1,37 +1,39 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_posts"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_posts
20
  {
21
- /*
22
- Handles Post Level Access restrictions.
23
-
24
- Don't call this function directly, use one of these API functions:
25
-
26
- Is it protected by s2Member at all?
27
- - is_post_protected_by_s2member($post_id);
28
- - is_protected_by_s2member($post_id, "post");
29
-
30
- Is the current User permitted/authorized?
31
- - is_post_permitted_by_s2member($post_id);
32
- - is_permitted_by_s2member($post_id, "post");
33
-
34
- See: `/s2member/includes/functions/api-functions.inc.php`.
35
  */
36
  public static function check_post_level_access ()
37
  {
@@ -43,83 +45,83 @@ if (!class_exists ("c_ws_plugin__s2member_posts"))
43
  /**/
44
  if (!$excluded && is_single () && is_object ($post) && ($post_id = $post->ID) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
45
  {
46
- $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
47
  /**/
48
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")))
49
  {
50
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_level_req" => "0")), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
51
  exit ();
52
  }
53
- else if (!c_ws_plugin__s2member_systematics::is_systematic_use_page ()) /* Do NOT protect Systematics. However, there is 1 exception above ^. */
54
  {
55
- for ($i = 0; $i <= 4; $i++) /* Post Level restrictions ( including Custom Post Types ). Go through each Membership Level. */
56
  {
57
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"] === "all" && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
58
  {
59
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
60
  exit ();
61
  }
62
  /**/
63
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"] && in_array ($post_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_posts"])) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
64
  {
65
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
66
  exit ();
67
  }
68
  }
69
  /**/
70
- for ($i = 0; $i <= 4; $i++) /* Category Level restrictions. Go through each Membership Level. */
71
  {
72
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] === "all" && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
73
  {
74
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
75
  exit ();
76
  }
77
  /**/
78
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"] && (in_category (($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_catgs"])), $post_id) || c_ws_plugin__s2member_utils_conds::in_descendant_category ($catgs, $post_id)) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
79
  {
80
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
81
  exit ();
82
  }
83
  }
84
  /**/
85
  if (has_tag ()) /* Here we take a look to see if this Post has any Tags. If so, we need to run the full set of routines against Tags also. */
86
  {
87
- for ($i = 0; $i <= 4; $i++) /* Tag Level restrictions. Go through each Membership Level. */
88
  {
89
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] === "all" && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
90
  {
91
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
92
  exit ();
93
  }
94
  /**/
95
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"])) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
96
  {
97
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
98
  exit ();
99
  }
100
  }
101
  }
102
  /**/
103
- for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
104
  {
105
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
106
- foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
107
- if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
108
  {
109
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
110
  exit ();
111
  }
112
  }
113
  /**/
114
- if (is_array ($ccaps_req = get_post_meta ($post_id, "s2member_ccaps_req", true)) && !empty ($ccaps_req) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill")
115
- foreach ($ccaps_req as $ccap) /* The $current_user MUST satisfy ALL Custom Capability requirements. Stored as a serialized array. */
116
- if (strlen ($ccap) && (!$current_user || !$current_user->has_cap ("access_s2member_ccap_" . $ccap)))
117
  {
118
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_ccap_req" => $ccap)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
119
  exit ();
120
  }
121
  /**/
122
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array ($post_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && !c_ws_plugin__s2member_sp_access::sp_access ($post_id))
123
  {
124
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_sp_req" => $post_id)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
125
  exit ();
1
  <?php
2
+ /**
3
+ * s2Member's Post protection routines *( for current Post )*.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Posts
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_posts"))
21
  {
22
+ /**
23
+ * s2Member's Post protection routines *( for current Post )*.
24
+ *
25
+ * @package s2Member\Posts
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_posts
29
  {
30
+ /**
31
+ * Handles Post Level Access permissions *( for current Post )*.
32
+ *
33
+ * @package s2Member\Posts
34
+ * @since 3.5
35
+ *
36
+ * @return null Or exits script execution after redirection.
 
 
 
 
 
 
 
37
  */
38
  public static function check_post_level_access ()
39
  {
45
  /**/
46
  if (!$excluded && is_single () && is_object ($post) && ($post_id = $post->ID) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
47
  {
48
+ $user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
49
  /**/
50
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level0")))
51
  {
52
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_level_req" => "0")), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
53
  exit ();
54
  }
55
+ else if (!c_ws_plugin__s2member_systematics::is_systematic_use_page ()) /* Do NOT protect Systematics. However, there is 1 exception ^. */
56
  {
57
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* Post Level restrictions ( including Custom Post Types ). Go through each Level. */
58
  {
59
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
60
  {
61
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_level_req" => $n)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
62
  exit ();
63
  }
64
  /**/
65
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"] && in_array ($post_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"])) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
66
  {
67
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_level_req" => $n)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
68
  exit ();
69
  }
70
  }
71
  /**/
72
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* Category Level restrictions. Go through each Level. */
73
  {
74
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
75
  {
76
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_level_req" => $n)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
77
  exit ();
78
  }
79
  /**/
80
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] && (in_category (($catgs = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"])), $post_id) || c_ws_plugin__s2member_utils_conds::in_descendant_category ($catgs, $post_id)) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
81
  {
82
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_level_req" => $n)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
83
  exit ();
84
  }
85
  }
86
  /**/
87
  if (has_tag ()) /* Here we take a look to see if this Post has any Tags. If so, we need to run the full set of routines against Tags also. */
88
  {
89
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* Tag Level restrictions. Go through each Level. */
90
  {
91
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
92
  {
93
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_level_req" => $n)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
94
  exit ();
95
  }
96
  /**/
97
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] && has_tag (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"])) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
98
  {
99
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_level_req" => $n)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
100
  exit ();
101
  }
102
  }
103
  }
104
  /**/
105
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* URIs. Go through each Level. */
106
  {
107
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"])
108
+ foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str)
109
+ if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
110
  {
111
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_level_req" => $n)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
112
  exit ();
113
  }
114
  }
115
  /**/
116
+ if (is_array ($ccaps_req = get_post_meta ($post_id, "s2member_ccaps_req", true)) && !empty ($ccaps_req) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill")
117
+ foreach ($ccaps_req as $ccap) /* The $user MUST satisfy ALL Custom Capability requirements. Stored as a serialized array. */
118
+ if (strlen ($ccap) && (!$user || !$user->has_cap ("access_s2member_ccap_" . $ccap)))
119
  {
120
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_ccap_req" => $ccap)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
121
  exit ();
122
  }
123
  /**/
124
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array ($post_id, preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && !c_ws_plugin__s2member_sp_access::sp_access ($post_id))
125
  {
126
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "post-" . $post_id, "s2member_sp_req" => $post_id)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
127
  exit ();
includes/classes/profile-in.inc.php CHANGED
@@ -1,35 +1,294 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_profile_in"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_profile_in
20
  {
21
- /*
22
- Function that displays a Profile Modification Form.
23
- Attach to: add_action("init");
 
 
 
 
 
 
24
  */
25
  public static function profile ()
26
  {
27
  do_action ("ws_plugin__s2member_before_profile", get_defined_vars ());
28
  /**/
29
- if ($_GET["s2member_profile"] && is_user_logged_in ()) /* Logged in? */
30
  {
31
- include_once dirname (dirname (__FILE__)) . "/profile.inc.php";
32
- /* Additional Hooks/Filters inside profile.inc.php. */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  exit (); /* Clean exit. */
34
  }
35
  /**/
1
  <?php
2
+ /**
3
+ * s2Member Stand-Alone Profile page ( inner processing routines ).
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Profiles
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_profile_in"))
21
  {
22
+ /**
23
+ * s2Member Stand-Alone Profile page ( inner processing routines ).
24
+ *
25
+ * @package s2Member\Profiles
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_profile_in
29
  {
30
+ /**
31
+ * Displays a Stand-Alone Profile Modification Form.
32
+ *
33
+ * @package s2Member\Profiles
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_action("init");``
37
+ *
38
+ * @return null Or exits script execution after display.
39
  */
40
  public static function profile ()
41
  {
42
  do_action ("ws_plugin__s2member_before_profile", get_defined_vars ());
43
  /**/
44
+ if (!empty ($_GET["s2member_profile"])) /* Requesting Profile? */
45
  {
46
+ c_ws_plugin__s2member_no_cache::no_cache_constants (true);
47
+ /**/
48
+ $tabindex = apply_filters ("ws_plugin__s2member_sc_profile_tabindex", 0, get_defined_vars ());
49
+ /**/
50
+ if (($user = (is_user_logged_in ()) ? wp_get_current_user () : false) && ($user_id = $user->ID))
51
+ {
52
+ echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
53
+ /**/
54
+ echo '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n";
55
+ echo '<head>' . "\n";
56
+ /**/
57
+ echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\n";
58
+ /**/
59
+ echo '<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>' . "\n";
60
+ echo '<script type="text/javascript" src="' . esc_attr (site_url ("/?ws_plugin__s2member_js_w_globals=" . urlencode (WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5) . "&amp;qcABC=1&amp;ver=" . urlencode (c_ws_plugin__s2member_utilities::ver_checksum ()))) . '"></script>' . "\n";
61
+ echo '<link href="' . esc_attr (site_url ("/?ws_plugin__s2member_css=1&amp;qcABC=1&amp;ver=" . urlencode (c_ws_plugin__s2member_utilities::ver_checksum ()))) . '" type="text/css" rel="stylesheet" media="all" />' . "\n";
62
+ /**/
63
+ echo '<title>My Profile</title>' . "\n";
64
+ /**/
65
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
66
+ do_action ("ws_plugin__s2member_during_profile_head", get_defined_vars ());
67
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
68
+ /**/
69
+ echo '</head>' . "\n";
70
+ /**/
71
+ echo '<body style="' . esc_attr (apply_filters ("ws_plugin__s2member_profile_body_styles", "background:#FFFFFF; color:#333333; font-family:'Verdana', sans-serif; font-size:13px;", get_defined_vars ())) . '">' . "\n";
72
+ /**/
73
+ echo '<form method="post" name="ws_plugin__s2member_profile" id="ws-plugin--s2member-profile" action="' . esc_attr (site_url ("/")) . '">' . "\n";
74
+ /**/
75
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
76
+ do_action ("ws_plugin__s2member_during_profile_before_table", get_defined_vars ());
77
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
78
+ /**/
79
+ echo '<table cellpadding="0" cellspacing="0">' . "\n";
80
+ echo '<tbody>' . "\n";
81
+ /**/
82
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
83
+ do_action ("ws_plugin__s2member_during_profile_before_fields", get_defined_vars ());
84
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
85
+ /**/
86
+ if (apply_filters ("ws_plugin__s2member_during_profile_during_fields_display_username", true, get_defined_vars ()))
87
+ {
88
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
89
+ do_action ("ws_plugin__s2member_during_profile_during_fields_before_username", get_defined_vars ());
90
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
91
+ /**/
92
+ echo '<tr>' . "\n";
93
+ echo '<td>' . "\n";
94
+ echo '<label for="ws-plugin--s2member-profile-login">' . "\n";
95
+ echo '<strong>Username *</strong> <small>( cannot be changed )</small><br />' . "\n";
96
+ echo '<input aria-required="true" type="text" maxlength="60" name="ws_plugin__s2member_profile_login" id="ws-plugin--s2member-profile-login" class="ws-plugin--s2member-profile-field" value="' . format_to_edit ($user->user_login) . '" disabled="disabled" />' . "\n";
97
+ echo '</label>' . "\n";
98
+ echo '</td>' . "\n";
99
+ echo '</tr>' . "\n";
100
+ /**/
101
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
102
+ do_action ("ws_plugin__s2member_during_profile_during_fields_after_username", get_defined_vars ());
103
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
104
+ }
105
+ /**/
106
+ if (apply_filters ("ws_plugin__s2member_during_profile_during_fields_display_email", true, get_defined_vars ()))
107
+ {
108
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
109
+ do_action ("ws_plugin__s2member_during_profile_during_fields_before_email", get_defined_vars ());
110
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
111
+ /**/
112
+ echo '<tr>' . "\n";
113
+ echo '<td>' . "\n";
114
+ echo '<label for="ws-plugin--s2member-profile-email">' . "\n";
115
+ echo '<strong>Email Address *</strong><br />' . "\n";
116
+ echo '<input aria-required="true" data-expected="email" type="text" maxlength="100" name="ws_plugin__s2member_profile_email" id="ws-plugin--s2member-profile-email" class="ws-plugin--s2member-profile-field" value="' . format_to_edit ($user->user_email) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
117
+ echo '</label>' . "\n";
118
+ echo '</td>' . "\n";
119
+ echo '</tr>' . "\n";
120
+ /**/
121
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
122
+ do_action ("ws_plugin__s2member_during_profile_during_fields_after_email", get_defined_vars ());
123
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
124
+ }
125
+ /**/
126
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"])
127
+ {
128
+ if (apply_filters ("ws_plugin__s2member_during_profile_during_fields_display_first_name", true, get_defined_vars ()))
129
+ {
130
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
131
+ do_action ("ws_plugin__s2member_during_profile_during_fields_before_first_name", get_defined_vars ());
132
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
133
+ /**/
134
+ echo '<tr>' . "\n";
135
+ echo '<td>' . "\n";
136
+ echo '<label for="ws-plugin--s2member-profile-first-name">' . "\n";
137
+ echo '<strong>First Name *</strong><br />' . "\n";
138
+ echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_profile_first_name" id="ws-plugin--s2member-profile-first-name" class="ws-plugin--s2member-profile-field" value="' . format_to_edit ($user->first_name) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
139
+ echo '</label>' . "\n";
140
+ echo '</td>' . "\n";
141
+ echo '</tr>' . "\n";
142
+ /**/
143
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
144
+ do_action ("ws_plugin__s2member_during_profile_during_fields_after_first_name", get_defined_vars ());
145
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
146
+ }
147
+ /**/
148
+ if (apply_filters ("ws_plugin__s2member_during_profile_during_fields_display_last_name", true, get_defined_vars ()))
149
+ {
150
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
151
+ do_action ("ws_plugin__s2member_during_profile_during_fields_before_last_name", get_defined_vars ());
152
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
153
+ /**/
154
+ echo '<tr>' . "\n";
155
+ echo '<td>' . "\n";
156
+ echo '<label for="ws-plugin--s2member-profile-last-name">' . "\n";
157
+ echo '<strong>Last Name *</strong><br />' . "\n";
158
+ echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_profile_last_name" id="ws-plugin--s2member-profile-last-name" class="ws-plugin--s2member-profile-field" value="' . format_to_edit ($user->last_name) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
159
+ echo '</label>' . "\n";
160
+ echo '</td>' . "\n";
161
+ echo '</tr>' . "\n";
162
+ /**/
163
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
164
+ do_action ("ws_plugin__s2member_during_profile_during_fields_after_last_name", get_defined_vars ());
165
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
166
+ }
167
+ /**/
168
+ if (apply_filters ("ws_plugin__s2member_during_profile_during_fields_display_display_name", true, get_defined_vars ()))
169
+ {
170
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
171
+ do_action ("ws_plugin__s2member_during_profile_during_fields_before_display_name", get_defined_vars ());
172
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
173
+ /**/
174
+ echo '<tr>' . "\n";
175
+ echo '<td>' . "\n";
176
+ echo '<label for="ws-plugin--s2member-profile-display-name">' . "\n";
177
+ echo '<strong>Display Name *</strong><br />' . "\n";
178
+ echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_profile_display_name" id="ws-plugin--s2member-profile-display-name" class="ws-plugin--s2member-profile-field" value="' . format_to_edit ($user->display_name) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
179
+ echo '</label>' . "\n";
180
+ echo '</td>' . "\n";
181
+ echo '</tr>' . "\n";
182
+ /**/
183
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
184
+ do_action ("ws_plugin__s2member_during_profile_during_fields_after_display_name", get_defined_vars ());
185
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
186
+ }
187
+ }
188
+ /**/
189
+ if (apply_filters ("ws_plugin__s2member_during_profile_during_fields_display_custom_fields", true, get_defined_vars ()))
190
+ {
191
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) /* Now, do we have Custom Fields? */
192
+ if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "profile"))
193
+ {
194
+ $fields = get_user_option ("s2member_custom_fields", $user_id);
195
+ /**/
196
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
197
+ do_action ("ws_plugin__s2member_during_profile_during_fields_before_custom_fields", get_defined_vars ());
198
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
199
+ /**/
200
+ foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
201
+ {
202
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
203
+ do_action ("ws_plugin__s2member_during_profile_during_fields_during_custom_fields_before", get_defined_vars ());
204
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
205
+ /**/
206
+ if (in_array ($field["id"], $fields_applicable)) /* Field applicable? */
207
+ {
208
+ $field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
209
+ $field_id_class = preg_replace ("/_/", "-", $field_var);
210
+ /**/
211
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
212
+ if (apply_filters ("ws_plugin__s2member_during_profile_during_fields_during_custom_fields_display", true, get_defined_vars ()))
213
+ {
214
+ if (!empty ($field["section"]) && $field["section"] === "yes") /* Starts a new section? */
215
+ echo '<tr><td><div class="ws-plugin--s2member-profile-field-divider-section' . ((!empty ($field["sectitle"])) ? '-title' : '') . '">' . ((!empty ($field["sectitle"])) ? $field["sectitle"] : '') . '</div></td></tr>';
216
+ /**/
217
+ echo '<tr>' . "\n";
218
+ echo '<td>' . "\n";
219
+ echo '<label for="ws-plugin--s2member-profile-' . esc_attr ($field_id_class) . '">' . "\n";
220
+ echo '<strong' . ((preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . (($field["required"] === "yes") ? ' *' : '') . '</strong></label>' . ((preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? '' : '<br />') . "\n";
221
+ echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_profile_", "ws-plugin--s2member-profile-", "ws-plugin--s2member-profile-field", "", ($tabindex = $tabindex + 10), "", $fields, $fields[$field_var], "profile");
222
+ echo '</td>' . "\n";
223
+ echo '</tr>' . "\n";
224
+ }
225
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
226
+ }
227
+ /**/
228
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
229
+ do_action ("ws_plugin__s2member_during_profile_during_fields_during_custom_fields_after", get_defined_vars ());
230
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
231
+ }
232
+ /**/
233
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
234
+ do_action ("ws_plugin__s2member_during_profile_during_fields_after_custom_fields", get_defined_vars ());
235
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
236
+ }
237
+ }
238
+ /**/
239
+ if (apply_filters ("ws_plugin__s2member_during_profile_during_fields_display_password", true, get_defined_vars ()))
240
+ {
241
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
242
+ do_action ("ws_plugin__s2member_during_profile_during_fields_before_password", get_defined_vars ());
243
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
244
+ /**/
245
+ echo '<tr>' . "\n";
246
+ echo '<td>' . "\n";
247
+ /**/
248
+ echo '<label for="ws-plugin--s2member-profile-password1" title="Please type your Password twice to confirm.">' . "\n";
249
+ echo '<strong>New Password?</strong> <em>( please type it twice )</em><br />' . "\n";
250
+ echo '<em>Only if changing password, otherwise leave blank.</em><br />' . "\n";
251
+ echo '<input type="password" maxlength="100" autocomplete="off" name="ws_plugin__s2member_profile_password1" id="ws-plugin--s2member-profile-password1" class="ws-plugin--s2member-profile-field" value="" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '"' . (($user->user_login === "demo") ? ' disabled="disabled"' : '') . ' />' . "\n";
252
+ echo '</label>' . "\n";
253
+ /**/
254
+ echo '<label for="ws-plugin--s2member-profile-password2" title="Please type your Password twice to confirm.">' . "\n";
255
+ echo '<input type="password" maxlength="100" autocomplete="off" name="ws_plugin__s2member_profile_password2" id="ws-plugin--s2member-profile-password2" class="ws-plugin--s2member-profile-field" value="" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '"' . (($user->user_login === "demo") ? ' disabled="disabled"' : '') . ' />' . "\n";
256
+ echo '</label>' . "\n";
257
+ /**/
258
+ echo '<div id="ws-plugin--s2member-profile-password-strength" class="ws-plugin--s2member-password-strength"><em>password strength indicator</em></div>' . "\n";
259
+ /**/
260
+ echo '</td>' . "\n";
261
+ echo '</tr>' . "\n";
262
+ /**/
263
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
264
+ do_action ("ws_plugin__s2member_during_profile_during_fields_after_password", get_defined_vars ());
265
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
266
+ }
267
+ /**/
268
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
269
+ do_action ("ws_plugin__s2member_during_profile_after_fields", get_defined_vars ());
270
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
271
+ /**/
272
+ echo '<tr>' . "\n";
273
+ echo '<td>' . "\n";
274
+ echo '<input type="hidden" name="ws_plugin__s2member_profile_save" id="ws-plugin--s2member-profile-save" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-profile-save")) . '" />' . "\n";
275
+ echo '<input id="ws-plugin--s2member-profile-submit" type="submit" value="Save All Changes" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
276
+ echo '</td>' . "\n";
277
+ echo '</tr>' . "\n";
278
+ /**/
279
+ echo '</tbody>' . "\n";
280
+ echo '</table>' . "\n";
281
+ /**/
282
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
283
+ do_action ("ws_plugin__s2member_during_profile_after_table", get_defined_vars ());
284
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
285
+ /**/
286
+ echo '</form>' . "\n";
287
+ /**/
288
+ echo '</body>' . "\n";
289
+ echo '</html>';
290
+ }
291
+ /**/
292
  exit (); /* Clean exit. */
293
  }
294
  /**/
includes/classes/profile-mods-4bp-in.inc.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Profile modifications for BuddyPress ( inner processing routines ).
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Profiles
15
+ * @since 3.5
16
+ */
17
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit ("Do not access this file directly.");
19
+ /**/
20
+ if (!class_exists ("c_ws_plugin__s2member_profile_mods_4bp_in"))
21
+ {
22
+ /**
23
+ * Profile modifications for BuddyPress ( inner processing routines ).
24
+ *
25
+ * @package s2Member\Profiles
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_profile_mods_4bp_in
29
+ {
30
+ /**
31
+ * Handles Profile modifications for Custom Fields *( created with s2Member )*; integrated with BuddyPress.
32
+ *
33
+ * @package s2Member\Profiles
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_action("init");``
37
+ *
38
+ * @return null After re-configuring the ``$current_user`` object.
39
+ */
40
+ public static function handle_profile_modifications_4bp ()
41
+ {
42
+ global $current_user; /* We'll need to update this global object. */
43
+ /**/
44
+ $user = &$current_user; /* Shorter reference to the $current_user object. */
45
+ /**/
46
+ do_action ("ws_plugin__s2member_before_handle_profile_modifications_4bp", get_defined_vars ());
47
+ /**/
48
+ if (!empty ($_POST["ws_plugin__s2member_profile_4bp_save"]) && is_user_logged_in () && is_object ($user) && ($user_id = $user->ID))
49
+ {
50
+ if (($nonce = $_POST["ws_plugin__s2member_profile_4bp_save"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-profile-4bp-save"))
51
+ {
52
+ $GLOBALS["ws_plugin__s2member_profile_4bp_saved"] = true; /* Global flag as having been saved/updated successfully. */
53
+ /**/
54
+ $_p = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)); /* Clean POST vars. */
55
+ /**/
56
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
57
+ if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "profile"))
58
+ {
59
+ $_existing_fields = get_user_option ("s2member_custom_fields", $user_id);
60
+ /**/
61
+ foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
62
+ {
63
+ $field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
64
+ $field_id_class = preg_replace ("/_/", "-", $field_var);
65
+ /**/
66
+ if (!in_array ($field["id"], $fields_applicable) || preg_match ("/^no/", $field["editable"]))
67
+ {
68
+ if (isset ($_existing_fields[$field_var]) && ((is_array ($_existing_fields[$field_var]) && !empty ($_existing_fields[$field_var])) || strlen ($_existing_fields[$field_var])))
69
+ $fields[$field_var] = $_existing_fields[$field_var];
70
+ else /* Else unset. */
71
+ unset ($fields[$field_var]);
72
+ }
73
+ else if ($field["required"] === "yes" && (!isset ($_p["ws_plugin__s2member_profile_4bp_" . $field_var]) || (is_array ($_p["ws_plugin__s2member_profile_4bp_" . $field_var]) && empty ($_p["ws_plugin__s2member_profile_4bp_" . $field_var])) || !strlen ($_p["ws_plugin__s2member_profile_4bp_" . $field_var])))
74
+ {
75
+ if (isset ($_existing_fields[$field_var]) && ((is_array ($_existing_fields[$field_var]) && !empty ($_existing_fields[$field_var])) || strlen ($_existing_fields[$field_var])))
76
+ $fields[$field_var] = $_existing_fields[$field_var];
77
+ else /* Else unset. */
78
+ unset ($fields[$field_var]);
79
+ }
80
+ else if (isset ($_p["ws_plugin__s2member_profile_4bp_" . $field_var]))
81
+ {
82
+ if ((is_array ($_p["ws_plugin__s2member_profile_4bp_" . $field_var]) && !empty ($_p["ws_plugin__s2member_profile_4bp_" . $field_var])) || strlen ($_p["ws_plugin__s2member_profile_4bp_" . $field_var]))
83
+ $fields[$field_var] = $_p["ws_plugin__s2member_profile_4bp_" . $field_var];
84
+ else /* Else unset. */
85
+ unset ($fields[$field_var]);
86
+ }
87
+ else /* Else ``unset()``. */
88
+ unset ($fields[$field_var]);
89
+ }
90
+ /**/
91
+ if (!empty ($fields))
92
+ update_user_option ($user_id, "s2member_custom_fields", $fields);
93
+ else /* Else delete their Custom Fields? */
94
+ delete_user_option ($user_id, "s2member_custom_fields");
95
+ }
96
+ /**/
97
+ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
98
+ do_action ("ws_plugin__s2member_during_handle_profile_modifications_4bp", get_defined_vars ());
99
+ unset ($__refs, $__v); /* Unset defined __refs, __v. */
100
+ /**/
101
+ $user = new WP_User ($user_id); /* Update the WP_User object for the current User/Member. */
102
+ (function_exists ("setup_userdata")) ? setup_userdata () : null; /* Update global vars. */
103
+ }
104
+ }
105
+ /**/
106
+ do_action ("ws_plugin__s2member_after_handle_profile_modifications_4bp", get_defined_vars ());
107
+ /**/
108
+ return; /* Return for uniformity. */
109
+ }
110
+ }
111
+ }
112
+ ?>
includes/classes/profile-mods-4bp.inc.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Profile modifications for BuddyPress.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Profiles
15
+ * @since 3.5
16
+ */
17
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
+ /**/
20
+ if (!class_exists ("c_ws_plugin__s2member_profile_mods_4bp"))
21
+ {
22
+ /**
23
+ * Profile modifications for BuddyPress.
24
+ *
25
+ * @package s2Member\Profiles
26
+ * @since 3.5
27
+ */
28
+ class c_ws_plugin__s2member_profile_mods_4bp
29
+ {
30
+ /**
31
+ * Handles Profile modifications for Custom Fields *( created with s2Member )*; integrated with BuddyPress.
32
+ *
33
+ * @package s2Member\Profiles
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_action("init");``
37
+ *
38
+ * @return null|inner Return-value of inner routine.
39
+ */
40
+ public static function handle_profile_modifications_4bp ()
41
+ {
42
+ if (!empty ($_POST["ws_plugin__s2member_profile_4bp_save"])) /* Call inner routine? */
43
+ {
44
+ return c_ws_plugin__s2member_profile_mods_4bp_in::handle_profile_modifications_4bp ();
45
+ }
46
+ }
47
+ }
48
+ }
49
+ ?>
includes/classes/profile-mods-in.inc.php CHANGED
@@ -1,63 +1,80 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_profile_mods_in"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_profile_mods_in
20
  {
21
- /*
22
- Function handles Profile Modifications.
23
- Attach to: add_action("init");
 
 
 
 
 
 
 
24
  */
25
  public static function handle_profile_modifications ()
26
  {
27
  global $current_user; /* We'll need to update this global object. */
28
  /**/
 
 
29
  do_action ("ws_plugin__s2member_before_handle_profile_modifications", get_defined_vars ());
30
  /**/
31
- if ($_POST["ws_plugin__s2member_profile_save"] && is_user_logged_in () && is_object ($current_user) && ($user_id = $current_user->ID))
32
  {
33
  if (($nonce = $_POST["ws_plugin__s2member_profile_save"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-profile-save"))
34
  {
35
  $GLOBALS["ws_plugin__s2member_profile_saved"] = true; /* Global flag as having been saved/updated successfully. */
36
  /**/
37
- $_p = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)); /* Clean POST vars. */
38
- /**/
39
- $userdata["ID"] = $user_id = $current_user->ID; /* Needed for database update. */
40
  /**/
41
- include_once ABSPATH . WPINC . "/registration.php";
42
  /**/
43
- if (is_email ($_p["ws_plugin__s2member_profile_email"]))
44
- if (!email_exists ($_p["ws_plugin__s2member_profile_email"]))
45
- $userdata["user_email"] = $_p["ws_plugin__s2member_profile_email"];
 
46
  /**/
47
- if ($_p["ws_plugin__s2member_profile_password"])
48
- if ($current_user->user_login !== "demo") /* No pass change on demo. */
49
- $userdata["user_pass"] = $_p["ws_plugin__s2member_profile_password"];
50
  /**/
51
- if ($_p["ws_plugin__s2member_profile_first_name"])
52
  $userdata["first_name"] = $_p["ws_plugin__s2member_profile_first_name"];
53
  /**/
54
- if ($_p["ws_plugin__s2member_profile_display_name"])
55
  $userdata["display_name"] = $_p["ws_plugin__s2member_profile_display_name"];
56
  /**/
57
- if ($_p["ws_plugin__s2member_profile_last_name"])
58
  $userdata["last_name"] = $_p["ws_plugin__s2member_profile_last_name"];
59
  /**/
60
- wp_update_user ($userdata); /* OK. Now send this array for an update. */
61
  /**/
62
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
63
  if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "profile"))
@@ -70,31 +87,49 @@ if (!class_exists ("c_ws_plugin__s2member_profile_mods_in"))
70
  $field_id_class = preg_replace ("/_/", "-", $field_var);
71
  /**/
72
  if (!in_array ($field["id"], $fields_applicable) || preg_match ("/^no/", $field["editable"]))
73
- $fields[$field_var] = $_existing_fields[$field_var];
74
- /**/
75
- else if ($field["required"] === "yes" && empty ($_p["ws_plugin__s2member_profile_" . $field_var]) && $_p["ws_plugin__s2member_profile_" . $field_var] !== "0")
76
- $fields[$field_var] = $_existing_fields[$field_var];
77
- /**/
78
- else /* Otherwise, we can use the newly updated value. */
79
- $fields[$field_var] = $_p["ws_plugin__s2member_profile_" . $field_var];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
81
  /**/
82
- update_user_option ($user_id, "s2member_custom_fields", $fields);
 
 
 
83
  }
84
  /**/
85
- eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
86
  do_action ("ws_plugin__s2member_during_handle_profile_modifications", get_defined_vars ());
87
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
88
  /**/
89
- $current_user = new WP_User ($user_id); /* Update the WP_User object for current User/Member. */
90
  (function_exists ("setup_userdata")) ? setup_userdata () : null; /* Update global vars. */
91
  /**/
92
- if (!$_p["ws_plugin__s2member_sc_profile_save"]) /* But NOT with Shortcode Profiles. */
93
  {
94
  echo '<script type="text/javascript">' . "\n";
95
- echo "if(window.parent && window.parent != window) { try{ window.parent.Shadowbox.close(); } catch(e){} try{ window.parent.tb_remove(); } catch(e){} window.parent.alert('Profile updated successfully!'); window.parent.location = '" . esc_js (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])) . "'; }";
96
- echo "else if(window.opener) { window.close(); window.opener.alert('Profile updated successfully!'); window.opener.location = '" . esc_js (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])) . "'; }";
97
- echo "else { alert('Profile updated successfully!'); window.location = '" . esc_js (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])) . "'; }";
98
  echo '</script>' . "\n";
99
  /**/
100
  exit (); /* Clean exit. */
1
  <?php
2
+ /**
3
+ * s2Member Profile modifications ( inner processing routines ).
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Profiles
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_profile_mods_in"))
21
  {
22
+ /**
23
+ * s2Member Profile modifications ( inner processing routines ).
24
+ *
25
+ * @package s2Member\Profiles
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_profile_mods_in
29
  {
30
+ /**
31
+ * Handles Profile modifications.
32
+ *
33
+ * @package s2Member\Profiles
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_action("init");``
37
+ *
38
+ * @return null After re-configuring the ``$current_user`` object.
39
+ * May also exit script execution when handling the Stand-Alone Profile Modification Form.
40
  */
41
  public static function handle_profile_modifications ()
42
  {
43
  global $current_user; /* We'll need to update this global object. */
44
  /**/
45
+ $user = &$current_user; /* Shorter reference to the $current_user object. */
46
+ /**/
47
  do_action ("ws_plugin__s2member_before_handle_profile_modifications", get_defined_vars ());
48
  /**/
49
+ if (!empty ($_POST["ws_plugin__s2member_profile_save"]) && is_user_logged_in () && is_object ($user) && ($user_id = $user->ID))
50
  {
51
  if (($nonce = $_POST["ws_plugin__s2member_profile_save"]) && wp_verify_nonce ($nonce, "ws-plugin--s2member-profile-save"))
52
  {
53
  $GLOBALS["ws_plugin__s2member_profile_saved"] = true; /* Global flag as having been saved/updated successfully. */
54
  /**/
55
+ $_p = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST));
 
 
56
  /**/
57
+ $userdata["ID"] = $user_id; /* Needed for database update. */
58
  /**/
59
+ if (!empty ($_p["ws_plugin__s2member_profile_email"]))
60
+ if (is_email ($_p["ws_plugin__s2member_profile_email"]))
61
+ if (!email_exists ($_p["ws_plugin__s2member_profile_email"]))
62
+ $userdata["user_email"] = $_p["ws_plugin__s2member_profile_email"];
63
  /**/
64
+ if (!empty ($_p["ws_plugin__s2member_profile_password1"]))
65
+ if ($user->user_login !== "demo") /* No pass change on demo! */
66
+ $userdata["user_pass"] = $_p["ws_plugin__s2member_profile_password1"];
67
  /**/
68
+ if (!empty ($_p["ws_plugin__s2member_profile_first_name"]))
69
  $userdata["first_name"] = $_p["ws_plugin__s2member_profile_first_name"];
70
  /**/
71
+ if (!empty ($_p["ws_plugin__s2member_profile_display_name"]))
72
  $userdata["display_name"] = $_p["ws_plugin__s2member_profile_display_name"];
73
  /**/
74
+ if (!empty ($_p["ws_plugin__s2member_profile_last_name"]))
75
  $userdata["last_name"] = $_p["ws_plugin__s2member_profile_last_name"];
76
  /**/
77
+ wp_update_user($userdata); /* OK. Now send this array for an update. */
78
  /**/
79
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
80
  if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "profile"))
87
  $field_id_class = preg_replace ("/_/", "-", $field_var);
88
  /**/
89
  if (!in_array ($field["id"], $fields_applicable) || preg_match ("/^no/", $field["editable"]))
90
+ {
91
+ if (isset ($_existing_fields[$field_var]) && ((is_array ($_existing_fields[$field_var]) && !empty ($_existing_fields[$field_var])) || strlen ($_existing_fields[$field_var])))
92
+ $fields[$field_var] = $_existing_fields[$field_var];
93
+ else /* Else unset. */
94
+ unset($fields[$field_var]);
95
+ }
96
+ else if ($field["required"] === "yes" && (!isset ($_p["ws_plugin__s2member_profile_" . $field_var]) || (is_array ($_p["ws_plugin__s2member_profile_" . $field_var]) && empty ($_p["ws_plugin__s2member_profile_" . $field_var])) || !strlen ($_p["ws_plugin__s2member_profile_" . $field_var])))
97
+ {
98
+ if (isset ($_existing_fields[$field_var]) && ((is_array ($_existing_fields[$field_var]) && !empty ($_existing_fields[$field_var])) || strlen ($_existing_fields[$field_var])))
99
+ $fields[$field_var] = $_existing_fields[$field_var];
100
+ else /* Else unset. */
101
+ unset($fields[$field_var]);
102
+ }
103
+ else if (isset ($_p["ws_plugin__s2member_profile_" . $field_var]))
104
+ {
105
+ if ((is_array ($_p["ws_plugin__s2member_profile_" . $field_var]) && !empty ($_p["ws_plugin__s2member_profile_" . $field_var])) || strlen ($_p["ws_plugin__s2member_profile_" . $field_var]))
106
+ $fields[$field_var] = $_p["ws_plugin__s2member_profile_" . $field_var];
107
+ else /* Else unset. */
108
+ unset($fields[$field_var]);
109
+ }
110
+ else /* Else ``unset()``. */
111
+ unset($fields[$field_var]);
112
  }
113
  /**/
114
+ if (!empty ($fields))
115
+ update_user_option ($user_id, "s2member_custom_fields", $fields);
116
+ else /* Else delete their Custom Fields? */
117
+ delete_user_option ($user_id, "s2member_custom_fields");
118
  }
119
  /**/
120
+ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
121
  do_action ("ws_plugin__s2member_during_handle_profile_modifications", get_defined_vars ());
122
  unset ($__refs, $__v); /* Unset defined __refs, __v. */
123
  /**/
124
+ $user = new WP_User ($user_id); /* Update the WP_User object for the current User/Member. */
125
  (function_exists ("setup_userdata")) ? setup_userdata () : null; /* Update global vars. */
126
  /**/
127
+ if (empty ($_p["ws_plugin__s2member_sc_profile_save"]))
128
  {
129
  echo '<script type="text/javascript">' . "\n";
130
+ echo "if(window.parent && window.parent != window) { window.parent.alert('Profile updated successfully.'); window.parent.location = '" . esc_js (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])) . "'; }";
131
+ echo "else if(window.opener) { window.alert('Profile updated successfully.'); window.opener.location = '" . esc_js (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])) . "'; window.close(); }";
132
+ echo "else { alert('Profile updated successfully.'); window.location = '" . esc_js (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])) . "'; }";
133
  echo '</script>' . "\n";
134
  /**/
135
  exit (); /* Clean exit. */
includes/classes/profile-mods.inc.php CHANGED
@@ -1,30 +1,45 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_profile_mods"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_profile_mods
20
  {
21
- /*
22
- Function handles Profile Modifications.
23
- Attach to: add_action("init");
 
 
 
 
 
 
24
  */
25
  public static function handle_profile_modifications ()
26
  {
27
- if ($_POST["ws_plugin__s2member_profile_save"]) /* Call inner function? */
28
  {
29
  return c_ws_plugin__s2member_profile_mods_in::handle_profile_modifications ();
30
  }
1
  <?php
2
+ /**
3
+ * s2Member Profile modifications.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Profiles
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_profile_mods"))
21
  {
22
+ /**
23
+ * s2Member Profile modifications.
24
+ *
25
+ * @package s2Member\Profiles
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_profile_mods
29
  {
30
+ /**
31
+ * Handles Profile modifications.
32
+ *
33
+ * @package s2Member\Profiles
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_action("init");``
37
+ *
38
+ * @return null|inner Return-value of inner routine.
39
  */
40
  public static function handle_profile_modifications ()
41
  {
42
+ if (!empty ($_POST["ws_plugin__s2member_profile_save"])) /* Call inner routine? */
43
  {
44
  return c_ws_plugin__s2member_profile_mods_in::handle_profile_modifications ();
45
  }
includes/classes/profile.inc.php CHANGED
@@ -1,30 +1,45 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_profile"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_profile
20
  {
21
- /*
22
- Function that displays a Profile Modification Form.
23
- Attach to: add_action("init");
 
 
 
 
 
 
24
  */
25
  public static function profile ()
26
  {
27
- if ($_GET["s2member_profile"]) /* Call inner function? */
28
  {
29
  return c_ws_plugin__s2member_profile_in::profile ();
30
  }
1
  <?php
2
+ /**
3
+ * s2Member Stand-Alone Profile page.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Profiles
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_profile"))
21
  {
22
+ /**
23
+ * s2Member Stand-Alone Profile page.
24
+ *
25
+ * @package s2Member\Profiles
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_profile
29
  {
30
+ /**
31
+ * Displays a Stand-Alone Profile Modification Form.
32
+ *
33
+ * @package s2Member\Profiles
34
+ * @since 3.5
35
+ *
36
+ * @attaches-to: ``add_action("init");``
37
+ *
38
+ * @return null|inner Return-value of inner routine.
39
  */
40
  public static function profile ()
41
  {
42
+ if (!empty ($_GET["s2member_profile"])) /* Call inner routine? */
43
  {
44
  return c_ws_plugin__s2member_profile_in::profile ();
45
  }
includes/classes/ptags-sp.inc.php CHANGED
@@ -1,60 +1,64 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
  exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_ptags_sp"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_ptags_sp
20
  {
21
- /*
22
- Checks Tag Level Access permissions - for a specific Tag.
23
-
24
- Don't call this function directly, use one of these API functions:
25
-
26
- Is it protected by s2Member at all?
27
- - is_tag_protected_by_s2member($tag_id [ or slug, or tag name ]);
28
- - is_protected_by_s2member($tag_id [ or slug, or tag name ], "tag");
29
-
30
- Is the current User permitted/authorized?
31
- - is_tag_permitted_by_s2member($tag_id [ or slug, or tag name ]);
32
- - is_permitted_by_s2member($tag_id [ or slug, or tag name ], "tag");
33
-
34
- See: `/s2member/includes/functions/api-functions.inc.php`.
35
  */
36
- public static function check_specific_ptag_level_access ($__tag = FALSE, $check_user = TRUE)
37
  {
38
  do_action ("ws_plugin__s2member_before_check_specific_ptag_level_access", get_defined_vars ());
39
  /**/
40
- if ($__tag && is_numeric ($__tag) && is_object ($term = get_term_by ("id", $__tag, "post_tag")))
41
  {
42
- $tag_id = $__tag; /* We need the $tag_id, $tag_slug, and also the $tag_name. */
43
  $tag_slug = $term->slug; /* Tag slug. */
44
  $tag_name = $term->name; /* Tag name. */
45
  }
46
- else if ($__tag && is_string ($__tag)) /* A string? Either a Tag name or a slug. */
47
  {
48
  /* Here, we give "name" priority, because it's likely to be a Tag name. */
49
- if (is_object ($term = get_term_by ("name", $__tag, "post_tag")))
50
  {
51
- $tag_name = $__tag; /* A name was passed in. */
52
  $tag_id = $term->term_id; /* Tag ID. */
53
  $tag_slug = $term->slug; /* Tag slug. */
54
  }
55
- else if (is_object ($term = get_term_by ("slug", $__tag, "post_tag")))
56
  {
57
- $tag_slug = $__tag; /* A slug was passed in. */
58
  $tag_id = $term->term_id; /* Tag ID. */
59
  $tag_name = $term->name; /* Tag name. */
60
  }
@@ -62,35 +66,32 @@ if (!class_exists ("c_ws_plugin__s2member_ptags_sp"))
62
  /**/
63
  $excluded = apply_filters ("ws_plugin__s2member_check_specific_ptag_level_access_excluded", false, get_defined_vars ());
64
  /**/
65
- if (!$excluded && $tag_id && $tag_slug && $tag_name && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
66
  {
67
- $tag_link = get_tag_link ($tag_id); /* Determine link to this Tag. */
68
- $tag_path = parse_url ($tag_link, PHP_URL_PATH); /* Parse req path. */
69
- $tag_query = parse_url ($tag_link, PHP_URL_QUERY); /* Parse query. */
70
- $tag_uri = ($tag_query) ? $tag_path . "?" . $tag_query : $tag_path;
71
  /**/
72
- $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
73
  /**/
74
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $tag_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level0")))
75
  return apply_filters ("ws_plugin__s2member_check_specific_ptag_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
76
  /**/
77
- else if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page (null, $tag_uri)) /* Never restrict Systematic Use Pages. However, there is 1 exception above ^. */
78
  {
79
- for ($i = 0; $i <= 4; $i++) /* Tag Level restrictions. Go through each Membership Level. This is pretty simple. We're just checking Tags. */
80
  {
81
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] === "all" && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
82
- return apply_filters ("ws_plugin__s2member_check_specific_ptag_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
83
  /**/
84
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] && (in_array ($tag_name, ($tags = preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"]))) || in_array ($tag_slug, $tags)) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
85
- return apply_filters ("ws_plugin__s2member_check_specific_ptag_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
86
  }
87
  /**/
88
- for ($i = 0; $i <= 4; $i++) /* URIs. Go through each Membership Level. */
89
  {
90
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"])
91
- foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ruris"], $current_user)) as $str)
92
- if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $tag_uri) && (!$check_user || !$current_user || !current_user_can ("access_s2member_level" . $i)))
93
- return apply_filters ("ws_plugin__s2member_check_specific_ptag_level_access", array ("s2member_level_req" => $i), get_defined_vars ());
94
  }
95
  }
96
  /**/
1
  <?php
2
+ /**
3
+ * s2Member's Tag protection routines *( for specific Tags )*.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Tags
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
  exit ("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_ptags_sp"))
21
  {
22
+ /**
23
+ * s2Member's Tag protection routines *( for specific Tags )*.
24
+ *
25
+ * @package s2Member\Tags
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_ptags_sp
29
  {
30
+ /**
31
+ * Handles Tag Level Access *( for specific Tags )*.
32
+ *
33
+ * @package s2Member\Tags
34
+ * @since 3.5
35
+ *
36
+ * @param int|str $_tag Numeric Tag ID, Tag Slug, or Tag Name.
37
+ * @param bool $check_user Test permissions against the current User? Defaults to true.
38
+ * @return null|array Non-empty array ( with details ) if access is denied, else null if access is allowed.
 
 
 
 
 
39
  */
40
+ public static function check_specific_ptag_level_access ($_tag = FALSE, $check_user = TRUE)
41
  {
42
  do_action ("ws_plugin__s2member_before_check_specific_ptag_level_access", get_defined_vars ());
43
  /**/
44
+ if ($_tag && is_numeric ($_tag) && is_object ($term = get_term_by ("id", $_tag, "post_tag")))
45
  {
46
+ $tag_id = $_tag; /* We need the $tag_id, $tag_slug, and also the $tag_name. */
47
  $tag_slug = $term->slug; /* Tag slug. */
48
  $tag_name = $term->name; /* Tag name. */
49
  }
50
+ else if ($_tag && is_string ($_tag)) /* A string? Either a Tag name or a slug. */
51
  {
52
  /* Here, we give "name" priority, because it's likely to be a Tag name. */
53
+ if (is_object ($term = get_term_by ("name", $_tag, "post_tag")))
54
  {
55
+ $tag_name = $_tag; /* A name was passed in. */
56
  $tag_id = $term->term_id; /* Tag ID. */
57
  $tag_slug = $term->slug; /* Tag slug. */
58
  }
59
+ else if (is_object ($term = get_term_by ("slug", $_tag, "post_tag")))
60
  {
61
+ $tag_slug = $_tag; /* A slug was passed in. */
62
  $tag_id = $term->term_id; /* Tag ID. */
63
  $tag_name = $term->name; /* Tag name. */
64
  }
66
  /**/
67
  $excluded = apply_filters ("ws_plugin__s2member_check_specific_ptag_level_access_excluded", false, get_defined_vars ());
68
  /**/
69
+ if (!$excluded && !empty ($tag_id) && !empty ($tag_slug) && !empty ($tag_name) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
70
  {
71
+ $tag_uri = c_ws_plugin__s2member_utils_urls::parse_uri (get_tag_link ($tag_id));
 
 
 
72
  /**/
73
+ $user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
74
  /**/
75
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $tag_uri) && (!$check_user || !$user || !current_user_can ("access_s2member_level0")))
76
  return apply_filters ("ws_plugin__s2member_check_specific_ptag_level_access", array ("s2member_level_req" => 0), get_defined_vars ());
77
  /**/
78
+ else if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page (null, $tag_uri)) /* Never restrict Systematics. However, there is 1 exception ^. */
79
  {
80
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* Tag Level restrictions. Go through each Level. */
81
  {
82
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] === "all" && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
83
+ return apply_filters ("ws_plugin__s2member_check_specific_ptag_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
84
  /**/
85
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] && (in_array ($tag_name, ($tags = preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"]))) || in_array ($tag_slug, $tags)) && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
86
+ return apply_filters ("ws_plugin__s2member_check_specific_ptag_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
87
  }
88
  /**/
89
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* URIs. Go through each Level. */
90
  {
91
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"])
92
+ foreach (preg_split ("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str)
93
+ if ($str && preg_match ("/" . preg_quote ($str, "/") . "/", $tag_uri) && (!$check_user || !$user || !current_user_can ("access_s2member_level" . $n)))
94
+ return apply_filters ("ws_plugin__s2member_check_specific_ptag_level_access", array ("s2member_level_req" => $n), get_defined_vars ());
95
  }
96
  }
97
  /**/
includes/classes/ptags.inc.php CHANGED
@@ -1,37 +1,39 @@
1
  <?php
2
- /*
3
- Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
- <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
-
6
- Released under the terms of the GNU General Public License.
7
- You should have received a copy of the GNU General Public License,
8
- along with this software. In the main directory, see: /licensing/
9
- If not, see: <http://www.gnu.org/licenses/>.
10
- */
11
- /*
12
- Direct access denial.
 
 
 
13
  */
14
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
- exit ("Do not access this file directly.");
16
  /**/
17
  if (!class_exists ("c_ws_plugin__s2member_ptags"))
18
  {
 
 
 
 
 
 
19
  class c_ws_plugin__s2member_ptags
20
  {
21
- /*
22
- Handles Tag Level Access permissions.
23
-
24
- Don't call this function directly, use one of these API functions:
25
-
26
- Is it protected by s2Member at all?
27
- - is_tag_protected_by_s2member($tag_id [ or slug, or tag name ]);
28
- - is_protected_by_s2member($tag_id [ or slug, or tag name ], "tag");
29
-
30
- Is the current User permitted/authorized?
31
- - is_tag_permitted_by_s2member($tag_id [ or slug, or tag name ]);
32
- - is_permitted_by_s2member($tag_id [ or slug, or tag name ], "tag");
33
-
34
- See: `/s2member/includes/functions/api-functions.inc.php`.
35
  */
36
  public static function check_ptag_level_access ()
37
  {
@@ -43,37 +45,37 @@ if (!class_exists ("c_ws_plugin__s2member_ptags"))
43
  /**/
44
  if (!$excluded && is_tag () && is_object ($tag = $wp_query->get_queried_object ()) && ($tag_id = $tag->term_id) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
45
  {
46
- $current_user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
47
  /**/
48
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($current_user)) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level0")))
49
  {
50
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "ptag-" . $tag_id, "s2member_level_req" => "0")), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
51
  exit ();
52
  }
53
  else if (!c_ws_plugin__s2member_systematics::is_systematic_use_page ()) /* Do NOT protect Systematics. However, there is 1 exception above ^. */
54
  {
55
- for ($i = 0; $i <= 4; $i++) /* Tag Level restrictions. Go through each Membership Level. This is pretty simple. We're just checking Tags. */
56
  {
57
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] === "all" && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
58
  {
59
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "ptag-" . $tag_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
60
  exit ();
61
  }
62
  /**/
63
- else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"] && (is_tag ($tags = preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_ptags"])) || in_array ($tag_id, $tags)) && c_ws_plugin__s2member_nocache::nocache_constants (true) !== "nill" && (!$current_user || !current_user_can ("access_s2member_level" . $i)))
64
  {
65
- wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "ptag-" . $tag_id, "s2member_level_req" => $i)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
1
  <?php
2
+ /**
3
+ * s2Member's Tag protection routines *( for current page )*.
4
+ *
5
+ * Copyright: © 2009-2011
6
+ * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
7
+ * ( coded in the USA )
8
+ *
9
+ * Released under the terms of the GNU General Public License.
10
+ * You should have received a copy of the GNU General Public License,
11
+ * along with this software. In the main directory, see: /licensing/
12
+ * If not, see: {@link http://www.gnu.org/licenses/}.
13
+ *
14
+ * @package s2Member\Tags
15
+ * @since 3.5
16
  */
17
  if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
18
+ exit("Do not access this file directly.");
19
  /**/
20
  if (!class_exists ("c_ws_plugin__s2member_ptags"))
21
  {
22
+ /**
23
+ * s2Member's Tag protection routines *( for current page )*.
24
+ *
25
+ * @package s2Member\Tags
26
+ * @since 3.5
27
+ */
28
  class c_ws_plugin__s2member_ptags
29
  {
30
+ /**
31
+ * Handles Tag Level Access permissions *( for current page )*.
32
+ *
33
+ * @package s2Member\Tags
34
+ * @since 3.5
35
+ *
36
+ * @return null Or exits script execution after redirection.
 
 
 
 
 
 
 
37
  */
38
  public static function check_ptag_level_access ()
39
  {
45
  /**/
46
  if (!$excluded && is_tag () && is_object ($tag = $wp_query->get_queried_object ()) && ($tag_id = $tag->term_id) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])
47
  {
48
+ $user = (is_user_logged_in ()) ? wp_get_current_user () : false; /* Get the current User's object. */
49
  /**/
50
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri ($user, "root-returns-false")) && preg_match ("/^" . preg_quote ($login_redirection_uri, "/") . "$/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level0")))
51
  {
52
  wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "ptag-" . $tag_id, "s2member_level_req" => "0")), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
53
  exit ();
54
  }
55
  else if (!c_ws_plugin__s2member_systematics::is_systematic_use_page ()) /* Do NOT protect Systematics. However, there is 1 exception above ^. */
56
  {
57
+ for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) /* Tag Level restrictions. Go through each Level. */
58
  {
59
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
60
  {
61
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "ptag-" . $tag_id, "s2member_level_req" => $n)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()));
62
  exit ();
63
  }
64
  /**/
65
+ else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] && (is_tag ($tags = preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"])) || in_array ($tag_id, $tags)) && c_ws_plugin__s2member_no_cache::no_cache_constants (true) !== "nill" && (!$user || !current_user_can ("access_s2member_level" . $n)))
66
  {
67
+ wp_redirect (add_query_arg (urlencode_deep (array ("s2member_seeking" => "ptag-" . $tag_id, "s2member_level_req" => $n